[Schmitzm-commits] r1257 - in trunk: . src/schmitzm/lang src_junit/schmitzm/jfree/feature/style src_junit/schmitzm/swing

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Nov 10 13:07:48 CET 2010


Author: mojays
Date: 2010-11-10 13:07:48 +0100 (Wed, 10 Nov 2010)
New Revision: 1257

Modified:
   trunk/pom.xml
   trunk/src/schmitzm/lang/LangUtil.java
   trunk/src/schmitzm/lang/ResourceProvider.java
   trunk/src_junit/schmitzm/jfree/feature/style/FeatureChartStyleTest.java
   trunk/src_junit/schmitzm/swing/TestingUtil.java
Log:
LangUtil/TestingUtil: new method to initialize a default console logger
ResourceProvider: bug fix so that getPropertyFile(.) can called for NULL locale


Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml	2010-11-10 10:54:06 UTC (rev 1256)
+++ trunk/pom.xml	2010-11-10 12:07:48 UTC (rev 1257)
@@ -282,6 +282,13 @@
 			<scope>compile</scope>
 		</dependency>
 
+		<dependency>
+			<groupId>commons-cli</groupId>
+			<artifactId>commons-cli</artifactId>
+			<version>1.2</version>
+			<type>jar</type>
+			<scope>compile</scope>
+		</dependency>
 	</dependencies>
 
 

Modified: trunk/src/schmitzm/lang/LangUtil.java
===================================================================
--- trunk/src/schmitzm/lang/LangUtil.java	2010-11-10 10:54:06 UTC (rev 1256)
+++ trunk/src/schmitzm/lang/LangUtil.java	2010-11-10 12:07:48 UTC (rev 1257)
@@ -50,8 +50,13 @@
 
 import net.jini.loader.pref.PreferredClassLoader;
 
+import org.apache.log4j.Appender;
 import org.apache.log4j.Category;
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.Layout;
+import org.apache.log4j.Level;
 import org.apache.log4j.Logger;
+import org.apache.log4j.PatternLayout;
 
 import schmitzm.io.IOUtil;
 
@@ -1399,6 +1404,31 @@
 			StackTraceElement[] stackTrace, int depth) {
 		printLastStackTraceClasses(stackTrace, depth, System.out);
 	}
+	
+	
+	/**
+	 * Initializes the {@link Logger} (root logger) with a default {@link ConsoleAppender}.
+	 * This method does nothing when the root logger already contains
+	 * an appender, so it does not matter when this method is called twice or
+	 * more.
+	 * @param logLevel log level (if {@code null} the level {@link Level#DEBUG}
+	 *                        is used)
+	 * @param logPattern pattern for the console output (if {@code null} a default pattern
+	 *                   "%r\t%p\t%c\t%m%n" is used)
+	 */
+	public static void initializeDefaultLogger(Level logLevel, String logPattern) {
+	  if ( Logger.getRootLogger().getAllAppenders().hasMoreElements() )
+	    return;
+	  
+	  if ( logPattern == null )
+	    logPattern = "%r\t%p\t%c\t%m%n";
+	  if ( logLevel == null )
+	    logLevel = Level.DEBUG;
+	  Layout   appenderLayout  = new PatternLayout(logPattern);
+	  Appender appender = new ConsoleAppender(appenderLayout, "System.out"); 
+      Logger.getRootLogger().addAppender(appender);
+      Logger.getRootLogger().setLevel(logLevel);
+	}
 
 	/**
 	 * Erzeugt einen Log4j-Logger fuer ein Objekt. Als Identifier fuer den

Modified: trunk/src/schmitzm/lang/ResourceProvider.java
===================================================================
--- trunk/src/schmitzm/lang/ResourceProvider.java	2010-11-10 10:54:06 UTC (rev 1256)
+++ trunk/src/schmitzm/lang/ResourceProvider.java	2010-11-10 12:07:48 UTC (rev 1257)
@@ -773,7 +773,11 @@
 		String bundleName = provider.getBundleSimpleName();
 		
 		// determine the exact package URL on the file system
-        String newBundleName = bundleName + "_" + l.toString() + ".properties";
+        String newBundleName = bundleName;
+        if ( l != null) 
+          newBundleName += "_" + l.toString();
+        newBundleName += ".properties";
+        
         File   newBundleFile = null;
 		if ( rootPath != null ) {
 		  // use the given root path

Modified: trunk/src_junit/schmitzm/jfree/feature/style/FeatureChartStyleTest.java
===================================================================
--- trunk/src_junit/schmitzm/jfree/feature/style/FeatureChartStyleTest.java	2010-11-10 10:54:06 UTC (rev 1256)
+++ trunk/src_junit/schmitzm/jfree/feature/style/FeatureChartStyleTest.java	2010-11-10 12:07:48 UTC (rev 1257)
@@ -145,7 +145,7 @@
 
 		assertNotNull("applyToDataset lieferte null!", barChart);
 
-		TestingUtil.testGui(barChart, "bar chart", -1);
+		TestingUtil.testGui(barChart, "bar chart");
 	}
 
 	@Ignore
@@ -506,7 +506,7 @@
 	  if  ( TestingUtil.INTERACTIVE ) {
 	    SelectableChartPanel panel = new SelectableChartPanel(chart);
 	    panel.setWindowSelectionMode( WindowSelectionMode.SELECT_SET );
-	    TestingUtil.testGui(panel, "scatter chart",-1);
+	    TestingUtil.testGui(panel, "scatter chart");
 	  }
 	  
 

Modified: trunk/src_junit/schmitzm/swing/TestingUtil.java
===================================================================
--- trunk/src_junit/schmitzm/swing/TestingUtil.java	2010-11-10 10:54:06 UTC (rev 1256)
+++ trunk/src_junit/schmitzm/swing/TestingUtil.java	2010-11-10 12:07:48 UTC (rev 1257)
@@ -68,11 +68,12 @@
 public class TestingUtil {
 
 	static {
-		// Adds a Console Logger so that logger output during tests is not lost
-		Logger.getRootLogger().addAppender(
-				new ConsoleAppender(new PatternLayout("%r\t%p\t%c\t%m%n"),
-						"System.out"));
-		Logger.getRootLogger().setLevel(Level.DEBUG);
+	  LangUtil.initializeDefaultLogger(Level.DEBUG, null);
+//		// Adds a Console Logger so that logger output during tests is not lost
+//		Logger.getRootLogger().addAppender(
+//				new ConsoleAppender(new PatternLayout("%r\t%p\t%c\t%m%n"),
+//						"System.out"));
+//		Logger.getRootLogger().setLevel(Level.DEBUG);
 	}
 
 	/**



More information about the Schmitzm-commits mailing list