Revision: 462 http://cishell.svn.sourceforge.net/cishell/?rev=462&view=rev Author: mwlinnem Date: 2007-08-06 13:13:50 -0700 (Mon, 06 Aug 2007) Log Message: ----------- Prettied up TestFileKeeper and fixed a type causing .net test files not to be loaded. Modified Paths: -------------- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/TestFileKeeper.java Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/TestFileKeeper.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/TestFileKeeper.java 2007-08-06 20:13:00 UTC (rev 461) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/TestFileKeeper.java 2007-08-06 20:13:50 UTC (rev 462) @@ -15,53 +15,74 @@ public class TestFileKeeper { + //TODO: How should we expose this to the user? public static final String DEFAULT_ROOT_DIR = "workspace/org.cishell." + "testing.convertertester.core.new/src/org/cishell/testing/" + "convertertester/core/test_files/"; public static final String CONF_FILE_NAME = "filetypes.conf"; - - public static final Pattern LINE_FORMAT = - Pattern.compile("^file:[^=]*?=[^=]*$"); - - private Map formatToDir = new HashMap(); + + public static final Pattern LINE_FORMAT = Pattern + .compile("^file:[^=]*?=[^=]*$"); + + private Map formatToTestFileNames = new HashMap(); + private LogService log; - + public TestFileKeeper(String rootDir, LogService log) { this.log = log; - + loadTestFileNames(rootDir); + } + + public void loadTestFileNames(String rootDir) { String line; BufferedReader reader = null; + try { - String filePath = System.getProperty("user.home") + "/" + - rootDir + CONF_FILE_NAME; + //open config file that maps formats to test file directories + + String filePath = System.getProperty("user.home") + "/" + rootDir + + CONF_FILE_NAME; reader = new BufferedReader(new FileReader(filePath)); + + //map formats to test files found in specified directories + + //for each file format... while ((line = reader.readLine()) != null) { - Matcher matcher = LINE_FORMAT.matcher(line); + if (matcher.matches()) { + + //get the file format and directory name from config file. + String[] splitLine = line.split("="); - + String fileFormat = splitLine[0]; - String dir = splitLine[1]; + String dir = splitLine[1]; + + String testFileDirPath = System.getProperty("user.home") + + "/" + rootDir + dir; + + //use directory name to get names of test files inside it. + String[] testFileNames = + getVisibleFileNames(testFileDirPath); - String testFilePath = System.getProperty("user.home") + - "/" + rootDir + dir; + //associate the file format with the names of test files. + this.formatToTestFileNames.put(fileFormat, testFileNames); - formatToDir.put(fileFormat, testFilePath); } else { - this.log.log(LogService.LOG_ERROR, "the line '" + line + - "' is not formatted correctly"); + this.log.log(LogService.LOG_ERROR, "the line '" + line + + "' is not formatted correctly"); } } } catch (IOException e) { - this.log.log(LogService.LOG_ERROR, "Incorrect directory for " + - "test file specified", e); + this.log.log(LogService.LOG_ERROR, "Incorrect directory for " + + "test file specified", e); e.printStackTrace(); } finally { - if (reader != null) { + if (reader != null) { try { - reader.close(); + reader.close(); } catch (IOException e) { this.log.log(LogService.LOG_ERROR, "Cannot close reader.", e); @@ -69,29 +90,37 @@ } } } - - //TODO: maybe make it cache the files instead of getting them every time? + public String[] getTestFilePaths(String format) { - List results = new ArrayList(); - - String testFileDirPath = (String) this.formatToDir.get(format); - if (testFileDirPath == null) { - this.log.log(LogService.LOG_ERROR, "Could not load directory " + - "for files of format " + format); + String[] testFileNames = (String[]) this.formatToTestFileNames + .get(format); + if (testFileNames == null) { + this.log.log(LogService.LOG_ERROR, "Could not load directory " + + "for files of format " + format); return new String[0]; } - File testFileDir = new File(testFileDirPath); - File[] dirContents = testFileDir.listFiles(); + return testFileNames; + } + + private String[] getVisibleFileNames(String dirName) { + List results = new ArrayList(); + + File dir = new File(dirName); + + File[] dirContents = dir.listFiles(); for (int ii = 0; ii < dirContents.length; ii++) { - if (! dirContents[ii].isHidden()) { + + if (!dirContents[ii].isHidden()) { try { - String fullTestFilePath = dirContents[ii].getCanonicalPath(); - results.add(fullTestFilePath); + String testFilePath = dirContents[ii] + .getCanonicalPath(); + results.add(testFilePath); } catch (IOException e) { - this.log.log(LogService.LOG_ERROR, "Could not open " + - "file " + dirContents[ii], e); + this.log.log(LogService.LOG_ERROR, + "Could not open " + "file " + + dirContents[ii], e); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
Revision: 476 http://cishell.svn.sourceforge.net/cishell/?rev=476&view=rev Author: huangb Date: 2007-08-16 13:14:27 -0700 (Thu, 16 Aug 2007) Log Message: ----------- This is a quick fix. The previous implementation tries to find test_files directory under default Eclipse workspace directory. We change it to point to converter_test_files subfolder under nwb installation directory. Modified Paths: -------------- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/TestFileKeeper.java Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/TestFileKeeper.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/TestFileKeeper.java 2007-08-16 20:09:25 UTC (rev 475) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/TestFileKeeper.java 2007-08-16 20:14:27 UTC (rev 476) @@ -19,10 +19,25 @@ static { String fs = File.separator; - DEFAULT_ROOT_DIR = "workspace" + fs + "org.cishell." +//Replaced by Bonnie +/* DEFAULT_ROOT_DIR = "My Documents"+fs+"workspace" + fs + "org.cishell." + "testing.convertertester.core.new" + fs + "src" + fs + "org" + fs + "cishell" + fs + "testing" + fs + "convertertester" + fs + "core" + fs + "test_files" + fs; +*/ + File currentDir = null; + currentDir = new File(System.getProperty("user.dir") + File.separator + "converter_test_files"); + + if (currentDir.exists()) { + DEFAULT_ROOT_DIR = currentDir.getPath()+fs; + } + else{ + System.err.println(">>>Error, didn't find test_files directory."); + DEFAULT_ROOT_DIR = null; + } + + + } public static final String DEFAULT_ROOT_DIR; @@ -51,9 +66,11 @@ try { //open config file that maps formats to test file directories - - String filePath = System.getProperty("user.home") + File.separator + rootDir - + CONF_FILE_NAME; + +// Replaced by Bonnie +// String filePath = System.getProperty("user.home") + File.separator + rootDir +// + CONF_FILE_NAME; + String filePath = rootDir + CONF_FILE_NAME; reader = new BufferedReader(new FileReader(filePath)); //map formats to test files found in specified directories @@ -71,9 +88,12 @@ String fileFormat = splitLine[0]; String dir = splitLine[1]; - String testFileDirPath = System.getProperty("user.home") - + "/" + rootDir + dir; - +// Replaced by Bonnie +// String testFileDirPath = System.getProperty("user.home") +// + "/" + rootDir + dir; + + String testFileDirPath =rootDir + dir; + //use directory name to get names of test files inside it. String[] testFileNames = getVisibleFileNames(testFileDirPath); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
Revision: 477 http://cishell.svn.sourceforge.net/cishell/?rev=477&view=rev Author: huangb Date: 2007-08-16 13:36:06 -0700 (Thu, 16 Aug 2007) Log Message: ----------- try to make the change work on linux Modified Paths: -------------- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/TestFileKeeper.java Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/TestFileKeeper.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/TestFileKeeper.java 2007-08-16 20:14:27 UTC (rev 476) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/TestFileKeeper.java 2007-08-16 20:36:06 UTC (rev 477) @@ -26,17 +26,21 @@ "convertertester" + fs + "core" + fs + "test_files" + fs; */ File currentDir = null; - currentDir = new File(System.getProperty("user.dir") + File.separator + "converter_test_files"); + currentDir = new File(System.getProperty("user.dir") + fs + "converter_test_files"); - if (currentDir.exists()) { - DEFAULT_ROOT_DIR = currentDir.getPath()+fs; - } - else{ - System.err.println(">>>Error, didn't find test_files directory."); - DEFAULT_ROOT_DIR = null; - } - - + if (!currentDir.exists()) { + currentDir = new File(System.getProperty("user.home") + fs + "anything"); + } else { + currentDir = new File(System.getProperty("user.dir") + fs + "converter_test_files" + File.separator + "anything"); + } + + if (currentDir.exists()) { + DEFAULT_ROOT_DIR = currentDir.getPath()+fs; + } + else{ + System.err.println(">>>Error, didn't find test_files directory."); + DEFAULT_ROOT_DIR = null; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
Revision: 479 http://cishell.svn.sourceforge.net/cishell/?rev=479&view=rev Author: mwlinnem Date: 2007-08-16 15:10:02 -0700 (Thu, 16 Aug 2007) Log Message: ----------- Test files are now expected to be in nwb/converter_test_files/. Solves problem of the file path previously being platform-dependent. Modified Paths: -------------- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/TestFileKeeper.java Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/TestFileKeeper.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/TestFileKeeper.java 2007-08-16 21:06:26 UTC (rev 478) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/TestFileKeeper.java 2007-08-16 22:10:02 UTC (rev 479) @@ -25,23 +25,9 @@ "org" + fs + "cishell" + fs + "testing" + fs + "convertertester" + fs + "core" + fs + "test_files" + fs; */ - File currentDir = null; - currentDir = new File(System.getProperty("user.dir") + fs + "converter_test_files"); - - if (!currentDir.exists()) { - currentDir = new File(System.getProperty("user.home") + fs + "anything"); - } else { - currentDir = new File(System.getProperty("user.dir") + fs + "converter_test_files" + File.separator + "anything"); - } - - if (currentDir.exists()) { - DEFAULT_ROOT_DIR = currentDir.getPath()+fs; - } - else{ - System.err.println(">>>Error, didn't find test_files directory."); - DEFAULT_ROOT_DIR = null; - } + System.out.println("osgi.install.area:"+System.getProperty("osgi.install.area")); + DEFAULT_ROOT_DIR = System.getProperty("osgi.install.area").replace("file:","") + fs + "converter_test_files" + fs; } public static final String DEFAULT_ROOT_DIR; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
Revision: 481 http://cishell.svn.sourceforge.net/cishell/?rev=481&view=rev Author: mwlinnem Date: 2007-08-16 15:20:00 -0700 (Thu, 16 Aug 2007) Log Message: ----------- Removed extraneous file separator. Modified Paths: -------------- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/TestFileKeeper.java Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/TestFileKeeper.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/TestFileKeeper.java 2007-08-16 22:13:37 UTC (rev 480) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/TestFileKeeper.java 2007-08-16 22:20:00 UTC (rev 481) @@ -18,16 +18,9 @@ //TODO: How should we expose this to the user? static { String fs = File.separator; - -//Replaced by Bonnie -/* DEFAULT_ROOT_DIR = "My Documents"+fs+"workspace" + fs + "org.cishell." - + "testing.convertertester.core.new" + fs + "src" + fs + - "org" + fs + "cishell" + fs + "testing" + fs + - "convertertester" + fs + "core" + fs + "test_files" + fs; -*/ - System.out.println("osgi.install.area:"+System.getProperty("osgi.install.area")); - - DEFAULT_ROOT_DIR = System.getProperty("osgi.install.area").replace("file:","") + fs + "converter_test_files" + fs; + DEFAULT_ROOT_DIR = + System.getProperty("osgi.install.area"). + replace("file:","") + "converter_test_files" + fs; } public static final String DEFAULT_ROOT_DIR; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
Revision: 519 http://cishell.svn.sourceforge.net/cishell/?rev=519&view=rev Author: mwlinnem Date: 2007-09-12 11:16:29 -0700 (Wed, 12 Sep 2007) Log Message: ----------- No longer attempts to use directories as test files. Modified Paths: -------------- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/TestFileKeeper.java Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/TestFileKeeper.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/TestFileKeeper.java 2007-09-12 18:01:51 UTC (rev 518) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/TestFileKeeper.java 2007-09-12 18:16:29 UTC (rev 519) @@ -127,7 +127,7 @@ File[] dirContents = dir.listFiles(); for (int ii = 0; ii < dirContents.length; ii++) { File fileInDir = dirContents[ii]; - if (! fileInDir.isHidden()) { + if (! fileInDir.isHidden() && !fileInDir.isDirectory()) { try { String testFilePath = fileInDir .getCanonicalPath(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |