< prev index next >

src/com/sun/javatest/WorkDirectory.java

Print this page
rev 145 : 7902237: Fixing raw use of parameterized class
Reviewed-by: jjg


 347     public String getLogFileName() {
 348         return logFileName;
 349     }
 350 
 351     private static boolean mkdirs(File dir, ArrayList<File> undoList) {
 352         File parent = dir.getParentFile();
 353         if (parent != null && !parent.exists()) {
 354             if (!mkdirs(parent, undoList))
 355                 return false;
 356         }
 357 
 358         if (dir.mkdir()) {
 359             //System.err.println("WD.mkdir " + dir);
 360             undoList.add(dir);
 361             return true;
 362         }
 363 
 364         return false;
 365     }
 366 
 367     private static void undo(ArrayList undoList) {
 368         for (int i = undoList.size() - 1; i >= 0; i--) {
 369             File f = (File) (undoList.get(i));
 370             delete(f);
 371         }
 372     }
 373 
 374     private static void delete(File f) {
 375         //System.err.println("WD.delete " + f);
 376         if (f.isDirectory()) {
 377             File[] ff = f.listFiles();
 378             for (int i = 0; i < ff.length; i++) {
 379                 if (ff[i].isDirectory() || ff[i].isFile())
 380                     delete(ff[i]);
 381             }
 382         }
 383         f.delete();
 384     }
 385 
 386         public static void changeTemplate(File dir, File newTemplate) {
 387             File templateData = new File(dir, JTDATA + File.separator + "template.data");
 388             if (templateData.exists()) {
 389                 Properties p = new Properties();


 428 
 429         File jtData = new File(canonDir, JTDATA);
 430         if (!jtData.exists()) {
 431             throw new NotWorkDirectoryFault(i18n, "wd.notWorkDir", canonDir);
 432         }
 433 
 434         File templateData = new File(canonDir, JTDATA + File.separator + "template.data");
 435         if (templateData.exists()) {
 436             Properties p = new Properties();
 437             try (FileInputStream fis = new FileInputStream(templateData.getAbsolutePath())) {
 438                 p.load(fis);
 439             } catch (IOException e) {
 440                 e.printStackTrace();
 441             }
 442 
 443             String templateFile = p.getProperty("file");
 444             if (!new File(templateFile).exists()) {
 445 
 446                 try {
 447                     // try to calculate relocation
 448                     String oldWDpath = loadWdInfo(jtData).getProperty(PREV_WD_PATH);
 449                     String[] begins = getDiffInPaths(dir.getPath(), oldWDpath);
 450                     if (begins != null) {
 451                         if (templateFile.startsWith(begins[1])) {
 452                             String candidat = begins[0] + templateFile.substring(begins[1].length());
 453                             if (!new File(candidat).exists()) {
 454                                 throw new TemplateMissingFault(i18n, "wd.templateMissing", canonDir, templateFile);
 455                             } else {
 456                                 // update WD info
 457                                 p.setProperty("file", candidat);
 458                                 FileOutputStream out = null;
 459                                 try {
 460                                     out = new FileOutputStream(templateData);
 461                                 } catch (FileNotFoundException e) {
 462                                     // should log the error
 463                                     // e.printStackTrace()
 464                                     return;
 465                                 }
 466 
 467                                 try {
 468                                     p.save(out, "template information file - do not modify");


 534      *         work directory
 535      */
 536     public static WorkDirectory open(File dir)
 537     throws FileNotFoundException,
 538             BadDirectoryFault,
 539             NotWorkDirectoryFault,
 540             MismatchFault,
 541             TestSuiteFault,
 542             InitializationFault,
 543             TemplateMissingFault {
 544 
 545          validateWD(dir);
 546 
 547      File canonDir = canonicalize(dir);
 548         File jtData = new File(canonDir, JTDATA);
 549 
 550         WorkDirectory wd;
 551 
 552         synchronized (dirMap) {
 553             // sync-ed to make dirMap data consistent
 554             WeakReference ref = (WeakReference)(dirMap.get(canonDir));
 555             wd = (ref == null ? null : (WorkDirectory) (ref.get()));
 556 
 557             if (wd != null)
 558                 return wd;
 559 
 560             Properties tsInfo;
 561             TestSuite ts;
 562 
 563             try {
 564                 tsInfo = loadTestSuiteInfo(jtData);
 565                 String root = tsInfo.getProperty(TESTSUITE_ROOT);
 566                 if (root == null)
 567                     throw new BadDirectoryFault(i18n, "wd.noTestSuiteRoot", canonDir);
 568 
 569                 File tsr = new File(root);
 570                 if (!tsr.exists())
 571                     throw new TestSuiteFault(i18n, "wd.cantFindTestSuite", canonDir, tsr.getPath());
 572 
 573                 ts = TestSuite.open(tsr);
 574 
 575                 String wdID = (tsInfo == null ? null : (String) (tsInfo.get(TESTSUITE_ID)));
 576                 String tsID = ts.getID();
 577                 if (!(wdID == null ? "" : wdID).equals(tsID == null ? "" : tsID))
 578                     throw new MismatchFault(i18n, "wd.mismatchID", canonDir);
 579 
 580             }   // try
 581             catch (FileNotFoundException e) {
 582                 throw new BadDirectoryFault(i18n, "wd.noTestSuiteFile", canonDir);
 583             } catch (IOException e) {
 584                 throw new BadDirectoryFault(i18n, "wd.badTestSuiteFile", canonDir, e);
 585             } catch (TestSuite.Fault e) {
 586                 throw new TestSuiteFault(i18n, "wd.cantOpenTestSuite", canonDir, e.toString());
 587             }   // catch
 588 
 589             wd = new WorkDirectory(canonDir, ts, tsInfo);
 590 
 591             // dirMap.put(canonDir, new WeakReference(wd));
 592         }   // sync block
 593 
 594         return wd;
 595     }


 616      *          match the ID recorded in the work directory.
 617      * @throws WorkDirectory.InitializationFault if there are unrecoverable
 618      *         problems encountered while reading the data present in the
 619      *         work directory
 620      */
 621     public static WorkDirectory open(File dir, TestSuite testSuite)
 622     throws FileNotFoundException,
 623             BadDirectoryFault,
 624             NotWorkDirectoryFault,
 625             MismatchFault,
 626             InitializationFault,
 627             TemplateMissingFault {
 628 
 629          validateWD(dir);
 630 
 631         File canonDir = canonicalize(dir);
 632         File jtData = new File(canonDir, JTDATA);
 633 
 634         WorkDirectory wd = null;
 635         synchronized (dirMap) {
 636             WeakReference ref = (WeakReference)(dirMap.get(canonDir));
 637             if (ref != null)
 638                 wd = (WorkDirectory)(ref.get());
 639 
 640             if (wd == null) {
 641                 Properties tsInfo;
 642                 try {
 643                     tsInfo = loadTestSuiteInfo(jtData);
 644                 } catch (IOException e) {
 645                     tsInfo = null;
 646                 }
 647 
 648                 String wdID = (tsInfo == null ? null : (String) (tsInfo.get(TESTSUITE_ID)));
 649                 String tsID = testSuite.getID();
 650                 if (!(wdID == null ? "" : wdID).equals(tsID == null ? "" : tsID))
 651                     throw new MismatchFault(i18n, "wd.mismatchID", canonDir);
 652 
 653                 // no existing instance, create one
 654                 try {
 655                     wd = new WorkDirectory(canonDir, testSuite, tsInfo);
 656                     wd.saveTestSuiteInfo();
 657                     //dirMap.put(canonDir, new WeakReference(wd));
 658                 } catch (IOException e) {
 659                     throw new BadDirectoryFault(i18n, "wd.cantWriteTestSuiteInfo", canonDir, e);
 660                 }
 661             }   // if
 662         }   // sync
 663 
 664         return wd;
 665     }
 666 
 667     /**
 668      * Create a WorkDirectory object for a given directory and testsuite.
 669      * The directory is assumed to be valid (exists(), isDirectory(), canRead() etc)
 670      */
 671     private WorkDirectory(File root, TestSuite testSuite, Map tsInfo) {
 672         if (root == null || testSuite == null)
 673             throw new NullPointerException();
 674         this.root = root;
 675         this.testSuite = testSuite;
 676         jtData = new File(root, JTDATA);
 677 
 678         if (jtData != null) {
 679             File loggerFile = getSystemFile(LoggerFactory.LOGFILE_NAME + "." + LoggerFactory.LOGFILE_EXTENSION);
 680             logFileName = loggerFile.getAbsolutePath();
 681             testSuite.setLogFilePath(this);
 682             try {
 683                 loggerFile.createNewFile();
 684             } catch (IOException ioe) {
 685                 testSuite.getNotificationLog(this).throwing("WorkDirectory", "WorkDirectory(File,TestSuite,Map)", ioe);
 686             }
 687 
 688         }
 689 
 690         // should consider saving parameter interview here;
 691         // -- possibly conditionally (don't need to write it in case of normal open)
 692 
 693         if (tsInfo != null) {
 694             String testC = (String) (tsInfo.get(TESTSUITE_TESTCOUNT));
 695             int tc;
 696             if (testC == null)
 697                 tc = -1;
 698             else {
 699                 try {
 700                     tc = Integer.parseInt(testC);
 701                 } catch (NumberFormatException e) {
 702                     tc = -1;
 703                 }
 704             }
 705             testCount = tc;
 706         } else
 707             testCount = testSuite.getEstimatedTestCount();
 708 
 709         testSuiteID = testSuite.getID();
 710         if (testSuiteID == null)
 711             testSuiteID = "";
 712 
 713         doWDinfo(jtData, testSuite);
 714 
 715     }
 716 
 717 
 718     private void doWDinfo(File jtData, TestSuite testSuite) {
 719         try {
 720             oldWDpath = loadWdInfo(jtData).getProperty(PREV_WD_PATH);
 721         } catch (IOException ex) {
 722             oldWDpath = null;
 723         }
 724         try {
 725             Properties p = new Properties();
 726             p.put(PREV_WD_PATH, root.getPath());
 727             saveInfo(p, WD_INFO, "WD information");
 728         } catch (IOException ex) {
 729             testSuite.getNotificationLog(this).throwing("WorkDirectory", "doWDinfo(File jtData, TestSuite testSuite)", ex);
 730         }
 731     }
 732 
 733     public String getPrevWDPath() {
 734         return oldWDpath;
 735     }
 736 
 737     /**
 738      * Get the root directory for this work directory.
 739      * @return the root directory for this work directory
 740      */


1167             String p; // root-relative path for f
1168             if (pathFromRoot.length() == 0)
1169                 p = f.getName();
1170             else
1171                 p = pathFromRoot + "/" + f.getName();
1172 
1173             if (f.isFile()) {
1174                 result &= f.delete();
1175                 if (f.getName().endsWith(TestResult.EXTN))
1176                     testResultTable.resetTest(p);
1177             } else if (!p.equals(JTDATA)) {
1178                 // directory, make sure not to delete jtData
1179                 result &= recursivePurge(f, p);
1180                 result &= f.delete();
1181             }
1182         }
1183 
1184         return result;
1185     }
1186 
1187     private static Properties loadTestSuiteInfo(File jtData) throws FileNotFoundException, IOException {
1188         return loadInfo(jtData, TESTSUITE);
1189     }
1190 
1191     private static Properties loadWdInfo(File jtData) throws FileNotFoundException, IOException {
1192         return loadInfo(jtData, WD_INFO);
1193     }
1194 
1195     private static Properties loadInfo(File jtData, String name) throws FileNotFoundException, IOException {
1196         File f = new File(jtData, name);
1197         InputStream in = new BufferedInputStream(new FileInputStream(f));
1198         Properties p = new Properties();
1199         p.load(in);
1200         in.close();
1201         return p;
1202     }
1203 
1204 
1205     private synchronized void saveTestSuiteInfo() throws IOException {
1206         Properties p = new Properties();
1207         p.put(TESTSUITE_ROOT, testSuite.getPath());
1208         String name = testSuite.getName();
1209         if (name != null)
1210             p.put(TESTSUITE_NAME, name);
1211 
1212         if (testCount > 0)
1213             p.put(TESTSUITE_TESTCOUNT, Integer.toString(testCount));
1214 
1215         if (testSuiteID != null && testSuiteID.length() > 0)
1216             p.put(TESTSUITE_ID, testSuiteID);
1217 
1218         saveInfo(p, TESTSUITE, "JT Harness Work Directory: Test Suite Info");
1219     }
1220 
1221 


1237     }
1238 
1239     private static File canonicalize(File dir) throws BadDirectoryFault {
1240         try {
1241             return dir.getCanonicalFile();
1242         } catch (IOException e) {
1243             throw new BadDirectoryFault(i18n, "wd.cantCanonicalize", dir, e);
1244         }
1245     }
1246 
1247     private File root;
1248     private TestSuite testSuite;
1249     private String testSuiteID;
1250     private String oldWDpath;
1251     private int testCount = -1;
1252     private TestResultTable testResultTable;
1253     private Map<String, Map<String,String>> annotationMap;
1254     private File jtData;
1255     private String logFileName;
1256     private LogFile logFile;
1257     private static HashMap dirMap = new HashMap(2);     // must be manually synchronized
1258     public static final String JTDATA = "jtData";
1259     private static final String TESTSUITE = "testsuite";
1260     private static final String WD_INFO = "wdinfo";
1261     private static final String PREV_WD_PATH = "prev.wd.path";
1262     private static final String TESTSUITE_ID = "id";
1263     private static final String TESTSUITE_NAME = "name";
1264     private static final String TESTSUITE_ROOT = "root";
1265     private static final String TESTSUITE_TESTCOUNT = "testCount";
1266 
1267     private static I18NResourceBundle i18n = I18NResourceBundle.getBundleForClass(WorkDirectory.class);
1268 
1269     private static final String TEST_ANNOTATION_FILE = "test_annotations.dat";
1270 }


 347     public String getLogFileName() {
 348         return logFileName;
 349     }
 350 
 351     private static boolean mkdirs(File dir, ArrayList<File> undoList) {
 352         File parent = dir.getParentFile();
 353         if (parent != null && !parent.exists()) {
 354             if (!mkdirs(parent, undoList))
 355                 return false;
 356         }
 357 
 358         if (dir.mkdir()) {
 359             //System.err.println("WD.mkdir " + dir);
 360             undoList.add(dir);
 361             return true;
 362         }
 363 
 364         return false;
 365     }
 366 
 367     private static void undo(ArrayList<File> undoList) {
 368         for (int i = undoList.size() - 1; i >= 0; i--) {
 369             File f = undoList.get(i);
 370             delete(f);
 371         }
 372     }
 373 
 374     private static void delete(File f) {
 375         //System.err.println("WD.delete " + f);
 376         if (f.isDirectory()) {
 377             File[] ff = f.listFiles();
 378             for (int i = 0; i < ff.length; i++) {
 379                 if (ff[i].isDirectory() || ff[i].isFile())
 380                     delete(ff[i]);
 381             }
 382         }
 383         f.delete();
 384     }
 385 
 386         public static void changeTemplate(File dir, File newTemplate) {
 387             File templateData = new File(dir, JTDATA + File.separator + "template.data");
 388             if (templateData.exists()) {
 389                 Properties p = new Properties();


 428 
 429         File jtData = new File(canonDir, JTDATA);
 430         if (!jtData.exists()) {
 431             throw new NotWorkDirectoryFault(i18n, "wd.notWorkDir", canonDir);
 432         }
 433 
 434         File templateData = new File(canonDir, JTDATA + File.separator + "template.data");
 435         if (templateData.exists()) {
 436             Properties p = new Properties();
 437             try (FileInputStream fis = new FileInputStream(templateData.getAbsolutePath())) {
 438                 p.load(fis);
 439             } catch (IOException e) {
 440                 e.printStackTrace();
 441             }
 442 
 443             String templateFile = p.getProperty("file");
 444             if (!new File(templateFile).exists()) {
 445 
 446                 try {
 447                     // try to calculate relocation
 448                     String oldWDpath = loadWdInfo(jtData).get(PREV_WD_PATH);
 449                     String[] begins = getDiffInPaths(dir.getPath(), oldWDpath);
 450                     if (begins != null) {
 451                         if (templateFile.startsWith(begins[1])) {
 452                             String candidat = begins[0] + templateFile.substring(begins[1].length());
 453                             if (!new File(candidat).exists()) {
 454                                 throw new TemplateMissingFault(i18n, "wd.templateMissing", canonDir, templateFile);
 455                             } else {
 456                                 // update WD info
 457                                 p.setProperty("file", candidat);
 458                                 FileOutputStream out = null;
 459                                 try {
 460                                     out = new FileOutputStream(templateData);
 461                                 } catch (FileNotFoundException e) {
 462                                     // should log the error
 463                                     // e.printStackTrace()
 464                                     return;
 465                                 }
 466 
 467                                 try {
 468                                     p.save(out, "template information file - do not modify");


 534      *         work directory
 535      */
 536     public static WorkDirectory open(File dir)
 537     throws FileNotFoundException,
 538             BadDirectoryFault,
 539             NotWorkDirectoryFault,
 540             MismatchFault,
 541             TestSuiteFault,
 542             InitializationFault,
 543             TemplateMissingFault {
 544 
 545          validateWD(dir);
 546 
 547      File canonDir = canonicalize(dir);
 548         File jtData = new File(canonDir, JTDATA);
 549 
 550         WorkDirectory wd;
 551 
 552         synchronized (dirMap) {
 553             // sync-ed to make dirMap data consistent
 554             WeakReference<WorkDirectory> ref = dirMap.get(canonDir);
 555             wd = (ref == null ? null : ref.get());
 556 
 557             if (wd != null)
 558                 return wd;
 559 
 560             Map<String, String> tsInfo;
 561             TestSuite ts;
 562 
 563             try {
 564                 tsInfo = loadTestSuiteInfo(jtData);
 565                 String root = tsInfo.get(TESTSUITE_ROOT);
 566                 if (root == null)
 567                     throw new BadDirectoryFault(i18n, "wd.noTestSuiteRoot", canonDir);
 568 
 569                 File tsr = new File(root);
 570                 if (!tsr.exists())
 571                     throw new TestSuiteFault(i18n, "wd.cantFindTestSuite", canonDir, tsr.getPath());
 572 
 573                 ts = TestSuite.open(tsr);
 574 
 575                 String wdID = (tsInfo == null ? null : tsInfo.get(TESTSUITE_ID));
 576                 String tsID = ts.getID();
 577                 if (!(wdID == null ? "" : wdID).equals(tsID == null ? "" : tsID))
 578                     throw new MismatchFault(i18n, "wd.mismatchID", canonDir);
 579 
 580             }   // try
 581             catch (FileNotFoundException e) {
 582                 throw new BadDirectoryFault(i18n, "wd.noTestSuiteFile", canonDir);
 583             } catch (IOException e) {
 584                 throw new BadDirectoryFault(i18n, "wd.badTestSuiteFile", canonDir, e);
 585             } catch (TestSuite.Fault e) {
 586                 throw new TestSuiteFault(i18n, "wd.cantOpenTestSuite", canonDir, e.toString());
 587             }   // catch
 588 
 589             wd = new WorkDirectory(canonDir, ts, tsInfo);
 590 
 591             // dirMap.put(canonDir, new WeakReference(wd));
 592         }   // sync block
 593 
 594         return wd;
 595     }


 616      *          match the ID recorded in the work directory.
 617      * @throws WorkDirectory.InitializationFault if there are unrecoverable
 618      *         problems encountered while reading the data present in the
 619      *         work directory
 620      */
 621     public static WorkDirectory open(File dir, TestSuite testSuite)
 622     throws FileNotFoundException,
 623             BadDirectoryFault,
 624             NotWorkDirectoryFault,
 625             MismatchFault,
 626             InitializationFault,
 627             TemplateMissingFault {
 628 
 629          validateWD(dir);
 630 
 631         File canonDir = canonicalize(dir);
 632         File jtData = new File(canonDir, JTDATA);
 633 
 634         WorkDirectory wd = null;
 635         synchronized (dirMap) {
 636             WeakReference<WorkDirectory> ref = dirMap.get(canonDir);
 637             if (ref != null)
 638                 wd = ref.get();
 639 
 640             if (wd == null) {
 641                 Map<String, String> tsInfo;
 642                 try {
 643                     tsInfo = loadTestSuiteInfo(jtData);
 644                 } catch (IOException e) {
 645                     tsInfo = null;
 646                 }
 647 
 648                 String wdID = (tsInfo == null ? null : tsInfo.get(TESTSUITE_ID));
 649                 String tsID = testSuite.getID();
 650                 if (!(wdID == null ? "" : wdID).equals(tsID == null ? "" : tsID))
 651                     throw new MismatchFault(i18n, "wd.mismatchID", canonDir);
 652 
 653                 // no existing instance, create one
 654                 try {
 655                     wd = new WorkDirectory(canonDir, testSuite, tsInfo);
 656                     wd.saveTestSuiteInfo();
 657                     //dirMap.put(canonDir, new WeakReference(wd));
 658                 } catch (IOException e) {
 659                     throw new BadDirectoryFault(i18n, "wd.cantWriteTestSuiteInfo", canonDir, e);
 660                 }
 661             }   // if
 662         }   // sync
 663 
 664         return wd;
 665     }
 666 
 667     /**
 668      * Create a WorkDirectory object for a given directory and testsuite.
 669      * The directory is assumed to be valid (exists(), isDirectory(), canRead() etc)
 670      */
 671     private WorkDirectory(File root, TestSuite testSuite, Map<String, String> tsInfo) {
 672         if (root == null || testSuite == null)
 673             throw new NullPointerException();
 674         this.root = root;
 675         this.testSuite = testSuite;
 676         jtData = new File(root, JTDATA);
 677 
 678         if (jtData != null) {
 679             File loggerFile = getSystemFile(LoggerFactory.LOGFILE_NAME + "." + LoggerFactory.LOGFILE_EXTENSION);
 680             logFileName = loggerFile.getAbsolutePath();
 681             testSuite.setLogFilePath(this);
 682             try {
 683                 loggerFile.createNewFile();
 684             } catch (IOException ioe) {
 685                 testSuite.getNotificationLog(this).throwing("WorkDirectory", "WorkDirectory(File,TestSuite,Map)", ioe);
 686             }
 687 
 688         }
 689 
 690         // should consider saving parameter interview here;
 691         // -- possibly conditionally (don't need to write it in case of normal open)
 692 
 693         if (tsInfo != null) {
 694             String testC = (tsInfo.get(TESTSUITE_TESTCOUNT));
 695             int tc;
 696             if (testC == null)
 697                 tc = -1;
 698             else {
 699                 try {
 700                     tc = Integer.parseInt(testC);
 701                 } catch (NumberFormatException e) {
 702                     tc = -1;
 703                 }
 704             }
 705             testCount = tc;
 706         } else
 707             testCount = testSuite.getEstimatedTestCount();
 708 
 709         testSuiteID = testSuite.getID();
 710         if (testSuiteID == null)
 711             testSuiteID = "";
 712 
 713         doWDinfo(jtData, testSuite);
 714 
 715     }
 716 
 717 
 718     private void doWDinfo(File jtData, TestSuite testSuite) {
 719         try {
 720             oldWDpath = loadWdInfo(jtData).get(PREV_WD_PATH);
 721         } catch (IOException ex) {
 722             oldWDpath = null;
 723         }
 724         try {
 725             Properties p = new Properties();
 726             p.put(PREV_WD_PATH, root.getPath());
 727             saveInfo(p, WD_INFO, "WD information");
 728         } catch (IOException ex) {
 729             testSuite.getNotificationLog(this).throwing("WorkDirectory", "doWDinfo(File jtData, TestSuite testSuite)", ex);
 730         }
 731     }
 732 
 733     public String getPrevWDPath() {
 734         return oldWDpath;
 735     }
 736 
 737     /**
 738      * Get the root directory for this work directory.
 739      * @return the root directory for this work directory
 740      */


1167             String p; // root-relative path for f
1168             if (pathFromRoot.length() == 0)
1169                 p = f.getName();
1170             else
1171                 p = pathFromRoot + "/" + f.getName();
1172 
1173             if (f.isFile()) {
1174                 result &= f.delete();
1175                 if (f.getName().endsWith(TestResult.EXTN))
1176                     testResultTable.resetTest(p);
1177             } else if (!p.equals(JTDATA)) {
1178                 // directory, make sure not to delete jtData
1179                 result &= recursivePurge(f, p);
1180                 result &= f.delete();
1181             }
1182         }
1183 
1184         return result;
1185     }
1186 
1187     private static Map<String, String> loadTestSuiteInfo(File jtData) throws FileNotFoundException, IOException {
1188         return loadInfo(jtData, TESTSUITE);
1189     }
1190 
1191     private static Map<String, String> loadWdInfo(File jtData) throws FileNotFoundException, IOException {
1192         return loadInfo(jtData, WD_INFO);
1193     }
1194 
1195     private static Map<String, String> loadInfo(File jtData, String name) throws FileNotFoundException, IOException {
1196         try (InputStream in = new BufferedInputStream(new FileInputStream(new File(jtData, name)))) {
1197             return com.sun.javatest.util.Properties.load(in);
1198         }



1199     }
1200 
1201 
1202     private synchronized void saveTestSuiteInfo() throws IOException {
1203         Properties p = new Properties();
1204         p.put(TESTSUITE_ROOT, testSuite.getPath());
1205         String name = testSuite.getName();
1206         if (name != null)
1207             p.put(TESTSUITE_NAME, name);
1208 
1209         if (testCount > 0)
1210             p.put(TESTSUITE_TESTCOUNT, Integer.toString(testCount));
1211 
1212         if (testSuiteID != null && testSuiteID.length() > 0)
1213             p.put(TESTSUITE_ID, testSuiteID);
1214 
1215         saveInfo(p, TESTSUITE, "JT Harness Work Directory: Test Suite Info");
1216     }
1217 
1218 


1234     }
1235 
1236     private static File canonicalize(File dir) throws BadDirectoryFault {
1237         try {
1238             return dir.getCanonicalFile();
1239         } catch (IOException e) {
1240             throw new BadDirectoryFault(i18n, "wd.cantCanonicalize", dir, e);
1241         }
1242     }
1243 
1244     private File root;
1245     private TestSuite testSuite;
1246     private String testSuiteID;
1247     private String oldWDpath;
1248     private int testCount = -1;
1249     private TestResultTable testResultTable;
1250     private Map<String, Map<String,String>> annotationMap;
1251     private File jtData;
1252     private String logFileName;
1253     private LogFile logFile;
1254     private static HashMap<File, WeakReference<WorkDirectory>> dirMap = new HashMap<>(2);     // must be manually synchronized
1255     public static final String JTDATA = "jtData";
1256     private static final String TESTSUITE = "testsuite";
1257     private static final String WD_INFO = "wdinfo";
1258     private static final String PREV_WD_PATH = "prev.wd.path";
1259     private static final String TESTSUITE_ID = "id";
1260     private static final String TESTSUITE_NAME = "name";
1261     private static final String TESTSUITE_ROOT = "root";
1262     private static final String TESTSUITE_TESTCOUNT = "testCount";
1263 
1264     private static I18NResourceBundle i18n = I18NResourceBundle.getBundleForClass(WorkDirectory.class);
1265 
1266     private static final String TEST_ANNOTATION_FILE = "test_annotations.dat";
1267 }
< prev index next >