< prev index next >

src/com/sun/javatest/WorkDirectory.java

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

*** 362,374 **** } return false; } ! private static void undo(ArrayList undoList) { for (int i = undoList.size() - 1; i >= 0; i--) { ! File f = (File) (undoList.get(i)); delete(f); } } private static void delete(File f) { --- 362,374 ---- } return false; } ! private static void undo(ArrayList<File> undoList) { for (int i = undoList.size() - 1; i >= 0; i--) { ! File f = undoList.get(i); delete(f); } } private static void delete(File f) {
*** 443,453 **** String templateFile = p.getProperty("file"); if (!new File(templateFile).exists()) { try { // try to calculate relocation ! String oldWDpath = loadWdInfo(jtData).getProperty(PREV_WD_PATH); String[] begins = getDiffInPaths(dir.getPath(), oldWDpath); if (begins != null) { if (templateFile.startsWith(begins[1])) { String candidat = begins[0] + templateFile.substring(begins[1].length()); if (!new File(candidat).exists()) { --- 443,453 ---- String templateFile = p.getProperty("file"); if (!new File(templateFile).exists()) { try { // try to calculate relocation ! String oldWDpath = loadWdInfo(jtData).get(PREV_WD_PATH); String[] begins = getDiffInPaths(dir.getPath(), oldWDpath); if (begins != null) { if (templateFile.startsWith(begins[1])) { String candidat = begins[0] + templateFile.substring(begins[1].length()); if (!new File(candidat).exists()) {
*** 549,580 **** WorkDirectory wd; synchronized (dirMap) { // sync-ed to make dirMap data consistent ! WeakReference ref = (WeakReference)(dirMap.get(canonDir)); ! wd = (ref == null ? null : (WorkDirectory) (ref.get())); if (wd != null) return wd; ! Properties tsInfo; TestSuite ts; try { tsInfo = loadTestSuiteInfo(jtData); ! String root = tsInfo.getProperty(TESTSUITE_ROOT); if (root == null) throw new BadDirectoryFault(i18n, "wd.noTestSuiteRoot", canonDir); File tsr = new File(root); if (!tsr.exists()) throw new TestSuiteFault(i18n, "wd.cantFindTestSuite", canonDir, tsr.getPath()); ts = TestSuite.open(tsr); ! String wdID = (tsInfo == null ? null : (String) (tsInfo.get(TESTSUITE_ID))); String tsID = ts.getID(); if (!(wdID == null ? "" : wdID).equals(tsID == null ? "" : tsID)) throw new MismatchFault(i18n, "wd.mismatchID", canonDir); } // try --- 549,580 ---- WorkDirectory wd; synchronized (dirMap) { // sync-ed to make dirMap data consistent ! WeakReference<WorkDirectory> ref = dirMap.get(canonDir); ! wd = (ref == null ? null : ref.get()); if (wd != null) return wd; ! Map<String, String> tsInfo; TestSuite ts; try { tsInfo = loadTestSuiteInfo(jtData); ! String root = tsInfo.get(TESTSUITE_ROOT); if (root == null) throw new BadDirectoryFault(i18n, "wd.noTestSuiteRoot", canonDir); File tsr = new File(root); if (!tsr.exists()) throw new TestSuiteFault(i18n, "wd.cantFindTestSuite", canonDir, tsr.getPath()); ts = TestSuite.open(tsr); ! String wdID = (tsInfo == null ? null : tsInfo.get(TESTSUITE_ID)); String tsID = ts.getID(); if (!(wdID == null ? "" : wdID).equals(tsID == null ? "" : tsID)) throw new MismatchFault(i18n, "wd.mismatchID", canonDir); } // try
*** 631,653 **** File canonDir = canonicalize(dir); File jtData = new File(canonDir, JTDATA); WorkDirectory wd = null; synchronized (dirMap) { ! WeakReference ref = (WeakReference)(dirMap.get(canonDir)); if (ref != null) ! wd = (WorkDirectory)(ref.get()); if (wd == null) { ! Properties tsInfo; try { tsInfo = loadTestSuiteInfo(jtData); } catch (IOException e) { tsInfo = null; } ! String wdID = (tsInfo == null ? null : (String) (tsInfo.get(TESTSUITE_ID))); String tsID = testSuite.getID(); if (!(wdID == null ? "" : wdID).equals(tsID == null ? "" : tsID)) throw new MismatchFault(i18n, "wd.mismatchID", canonDir); // no existing instance, create one --- 631,653 ---- File canonDir = canonicalize(dir); File jtData = new File(canonDir, JTDATA); WorkDirectory wd = null; synchronized (dirMap) { ! WeakReference<WorkDirectory> ref = dirMap.get(canonDir); if (ref != null) ! wd = ref.get(); if (wd == null) { ! Map<String, String> tsInfo; try { tsInfo = loadTestSuiteInfo(jtData); } catch (IOException e) { tsInfo = null; } ! String wdID = (tsInfo == null ? null : tsInfo.get(TESTSUITE_ID)); String tsID = testSuite.getID(); if (!(wdID == null ? "" : wdID).equals(tsID == null ? "" : tsID)) throw new MismatchFault(i18n, "wd.mismatchID", canonDir); // no existing instance, create one
*** 666,676 **** /** * Create a WorkDirectory object for a given directory and testsuite. * The directory is assumed to be valid (exists(), isDirectory(), canRead() etc) */ ! private WorkDirectory(File root, TestSuite testSuite, Map tsInfo) { if (root == null || testSuite == null) throw new NullPointerException(); this.root = root; this.testSuite = testSuite; jtData = new File(root, JTDATA); --- 666,676 ---- /** * Create a WorkDirectory object for a given directory and testsuite. * The directory is assumed to be valid (exists(), isDirectory(), canRead() etc) */ ! private WorkDirectory(File root, TestSuite testSuite, Map<String, String> tsInfo) { if (root == null || testSuite == null) throw new NullPointerException(); this.root = root; this.testSuite = testSuite; jtData = new File(root, JTDATA);
*** 689,699 **** // should consider saving parameter interview here; // -- possibly conditionally (don't need to write it in case of normal open) if (tsInfo != null) { ! String testC = (String) (tsInfo.get(TESTSUITE_TESTCOUNT)); int tc; if (testC == null) tc = -1; else { try { --- 689,699 ---- // should consider saving parameter interview here; // -- possibly conditionally (don't need to write it in case of normal open) if (tsInfo != null) { ! String testC = (tsInfo.get(TESTSUITE_TESTCOUNT)); int tc; if (testC == null) tc = -1; else { try {
*** 715,725 **** } private void doWDinfo(File jtData, TestSuite testSuite) { try { ! oldWDpath = loadWdInfo(jtData).getProperty(PREV_WD_PATH); } catch (IOException ex) { oldWDpath = null; } try { Properties p = new Properties(); --- 715,725 ---- } private void doWDinfo(File jtData, TestSuite testSuite) { try { ! oldWDpath = loadWdInfo(jtData).get(PREV_WD_PATH); } catch (IOException ex) { oldWDpath = null; } try { Properties p = new Properties();
*** 1182,1206 **** } return result; } ! private static Properties loadTestSuiteInfo(File jtData) throws FileNotFoundException, IOException { return loadInfo(jtData, TESTSUITE); } ! private static Properties loadWdInfo(File jtData) throws FileNotFoundException, IOException { return loadInfo(jtData, WD_INFO); } ! private static Properties loadInfo(File jtData, String name) throws FileNotFoundException, IOException { ! File f = new File(jtData, name); ! InputStream in = new BufferedInputStream(new FileInputStream(f)); ! Properties p = new Properties(); ! p.load(in); ! in.close(); ! return p; } private synchronized void saveTestSuiteInfo() throws IOException { Properties p = new Properties(); --- 1182,1203 ---- } return result; } ! private static Map<String, String> loadTestSuiteInfo(File jtData) throws FileNotFoundException, IOException { return loadInfo(jtData, TESTSUITE); } ! private static Map<String, String> loadWdInfo(File jtData) throws FileNotFoundException, IOException { return loadInfo(jtData, WD_INFO); } ! private static Map<String, String> loadInfo(File jtData, String name) throws FileNotFoundException, IOException { ! try (InputStream in = new BufferedInputStream(new FileInputStream(new File(jtData, name)))) { ! return com.sun.javatest.util.Properties.load(in); ! } } private synchronized void saveTestSuiteInfo() throws IOException { Properties p = new Properties();
*** 1252,1262 **** private TestResultTable testResultTable; private Map<String, Map<String,String>> annotationMap; private File jtData; private String logFileName; private LogFile logFile; ! private static HashMap dirMap = new HashMap(2); // must be manually synchronized public static final String JTDATA = "jtData"; private static final String TESTSUITE = "testsuite"; private static final String WD_INFO = "wdinfo"; private static final String PREV_WD_PATH = "prev.wd.path"; private static final String TESTSUITE_ID = "id"; --- 1249,1259 ---- private TestResultTable testResultTable; private Map<String, Map<String,String>> annotationMap; private File jtData; private String logFileName; private LogFile logFile; ! private static HashMap<File, WeakReference<WorkDirectory>> dirMap = new HashMap<>(2); // must be manually synchronized public static final String JTDATA = "jtData"; private static final String TESTSUITE = "testsuite"; private static final String WD_INFO = "wdinfo"; private static final String PREV_WD_PATH = "prev.wd.path"; private static final String TESTSUITE_ID = "id";
< prev index next >