[Schmitzm-commits] r970 - in branches/2.2.x: src/schmitzm/geotools/feature src_junit/schmitzm/geotools src_junit/schmitzm/geotools/styling

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Aug 12 13:02:56 CEST 2010


Author: alfonx
Date: 2010-08-12 13:02:55 +0200 (Thu, 12 Aug 2010)
New Revision: 970

Added:
   branches/2.2.x/src_junit/schmitzm/geotools/styling/
   branches/2.2.x/src_junit/schmitzm/geotools/styling/StylingUtilTest.java
Modified:
   branches/2.2.x/src/schmitzm/geotools/feature/FeatureUtil.java
Log:
NPE Bugfix for RasterSymbolizer in StylingUtil.correctAttributeNames

Modified: branches/2.2.x/src/schmitzm/geotools/feature/FeatureUtil.java
===================================================================
--- branches/2.2.x/src/schmitzm/geotools/feature/FeatureUtil.java	2010-08-12 11:02:45 UTC (rev 969)
+++ branches/2.2.x/src/schmitzm/geotools/feature/FeatureUtil.java	2010-08-12 11:02:55 UTC (rev 970)
@@ -2232,8 +2232,9 @@
 	 * has no attributes, an exception is thrown.
 	 * 
 	 * @param schema
-	 *            SimpleFeatureType to check against
-	 * @param name
+	 *            SimpleFeatureType to check against. if <code>null</code>, a
+	 *            new NameImpl is returned with empty namespace.
+	 * @param localName
 	 *            localname of an attribte to look for
 	 * 
 	 * @return If no match is found, the first attribute is returned.
@@ -2241,6 +2242,9 @@
 	public static Name findBestMatchingAttributeFallBackFirst(
 			SimpleFeatureType schema, String localName) {
 
+		if (schema == null)
+			return new NameImpl(localName);
+
 		Name bestmatch = findBestMatchingAttribute(schema, localName);
 
 		if (bestmatch == null)

Added: branches/2.2.x/src_junit/schmitzm/geotools/styling/StylingUtilTest.java
===================================================================
--- branches/2.2.x/src_junit/schmitzm/geotools/styling/StylingUtilTest.java	2010-08-12 11:02:45 UTC (rev 969)
+++ branches/2.2.x/src_junit/schmitzm/geotools/styling/StylingUtilTest.java	2010-08-12 11:02:55 UTC (rev 970)
@@ -0,0 +1,33 @@
+package schmitzm.geotools.styling;
+
+import java.awt.GraphicsEnvironment;
+
+import junit.framework.TestCase;
+
+import org.geotools.styling.RasterSymbolizer;
+import org.geotools.styling.Style;
+import org.geotools.styling.StyleBuilder;
+import org.junit.Test;
+
+public class StylingUtilTest extends TestCase {
+
+	boolean INTERACTIVE = !GraphicsEnvironment.isHeadless();
+	
+
+	@Test
+	public void testCorrectPropertyNamesWithRasterSymbolizer() {
+		
+		StyleBuilder sb = StylingUtil.STYLE_BUILDER;
+		RasterSymbolizer rs = sb.createRasterSymbolizer();
+		Style style = sb.createStyle(rs);
+		
+		assertNotNull(style);
+		
+		// Once we NPEs here.
+		StylingUtil.correctPropertyNames(style, null);
+		
+		assertNotNull(style);
+	}
+
+
+}


Property changes on: branches/2.2.x/src_junit/schmitzm/geotools/styling/StylingUtilTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Id URL
Name: svn:eol-style
   + native



More information about the Schmitzm-commits mailing list