From: <ni...@us...> - 2006-09-12 19:23:36
|
Revision: 5509 http://svn.sourceforge.net/jmol/?rev=5509&view=rev Author: nicove Date: 2006-09-12 12:23:27 -0700 (Tue, 12 Sep 2006) Log Message: ----------- Logger Modified Paths: -------------- branches/v10_9/Jmol/test/org/jmol/adapter/smarter/TestSmarterJmolAdapter.java branches/v10_9/Jmol/test/org/jmol/util/JUnitLogger.java Modified: branches/v10_9/Jmol/test/org/jmol/adapter/smarter/TestSmarterJmolAdapter.java =================================================================== --- branches/v10_9/Jmol/test/org/jmol/adapter/smarter/TestSmarterJmolAdapter.java 2006-09-12 16:52:09 UTC (rev 5508) +++ branches/v10_9/Jmol/test/org/jmol/adapter/smarter/TestSmarterJmolAdapter.java 2006-09-12 19:23:27 UTC (rev 5509) @@ -286,12 +286,14 @@ private String checkOpenFile(String directory, String filename) { // Open file + JUnitLogger.setInformation(null); Object result = null; try { JUnitLogger.activateLogger(); SmarterJmolAdapter adapter = new SmarterJmolAdapter(null); adapter.logger = new TestLogger(adapter); File file = new File(new File("../Jmol-datafiles", directory), filename); + JUnitLogger.setInformation(file.getPath()); InputStream iStream = new FileInputStream(file); BufferedInputStream biStream = new BufferedInputStream(iStream); BufferedReader bReader = new BufferedReader(new InputStreamReader(biStream)); @@ -320,13 +322,14 @@ */ private String checkOpenFileGzip(String directory, String filename) { - // Open file + // Open file + JUnitLogger.setInformation(null); Object result = null; try { - JUnitLogger.activateLogger(); SmarterJmolAdapter adapter = new SmarterJmolAdapter(null); adapter.logger = new TestLogger(adapter); File file = new File(new File("../Jmol-datafiles", directory), filename); + JUnitLogger.setInformation(file.getPath()); InputStream iStream = new FileInputStream(file); BufferedInputStream biStream = new BufferedInputStream(iStream); BufferedReader bReader = new BufferedReader(new InputStreamReader(new GZIPInputStream(biStream))); @@ -349,6 +352,15 @@ return null; } + /* (non-Javadoc) + * @see junit.framework.TestCase#setUp() + */ + protected void setUp() throws Exception { + super.setUp(); + JUnitLogger.activateLogger(); + JUnitLogger.setInformation(null); + } + /** * Logger class to remove readers log from JUnit output */ Modified: branches/v10_9/Jmol/test/org/jmol/util/JUnitLogger.java =================================================================== --- branches/v10_9/Jmol/test/org/jmol/util/JUnitLogger.java 2006-09-12 16:52:09 UTC (rev 5508) +++ branches/v10_9/Jmol/test/org/jmol/util/JUnitLogger.java 2006-09-12 19:23:27 UTC (rev 5509) @@ -37,7 +37,18 @@ Logger.setLogger(new JUnitLogger()); } + private static String information = null; + /** + * Add information to log in case of an error. + * + * @param txt Information to log. + */ + public static void setInformation(String txt) { + information = txt; + } + + /** * Private constructor, use activateLogger() instead. */ private JUnitLogger() { @@ -53,6 +64,7 @@ private void logError(String txt, Throwable e) { System.err.println( "Error: " + + ((information != null) ? ("[" + information + "] ") : "") + ((txt != null) ? (txt + " - ") : "") + ((e != null) ? e.getClass().getName() : "") + ((e != null) && (e.getMessage() != null) ? (" - " + e.getMessage()) : "")); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |