svn - r33532 - in trunk/modules/library/render/src: main/java/org/geotools/map test/java/org/geotools test/java/org/geotools/map

1 message Options
Embed this post
Permalink
svn_geotools

svn - r33532 - in trunk/modules/library/render/src: main/java/org/geotools/map test/java/org/geotools test/java/org/geotools/map

Reply Threaded More More options
Print post
Permalink
Author: aaime
Date: 2009-07-09 03:02:51 -0400 (Thu, 09 Jul 2009)
New Revision: 33532

Added:
   trunk/modules/library/render/src/test/java/org/geotools/map/
   trunk/modules/library/render/src/test/java/org/geotools/map/DefaultMapContextTest.java
Modified:
   trunk/modules/library/render/src/main/java/org/geotools/map/DefaultMapContext.java
Log:
GEOT-2600 NullPointerException if MapLayer.getBounds returns null

Modified: trunk/modules/library/render/src/main/java/org/geotools/map/DefaultMapContext.java
===================================================================
--- trunk/modules/library/render/src/main/java/org/geotools/map/DefaultMapContext.java 2009-07-09 02:02:39 UTC (rev 33531)
+++ trunk/modules/library/render/src/main/java/org/geotools/map/DefaultMapContext.java 2009-07-09 07:02:51 UTC (rev 33532)
@@ -588,12 +588,11 @@
  env = new ReferencedEnvelope(fs.getBounds(), sourceCrs);*/
 
  env = layer.getBounds();
- sourceCrs = env.getCoordinateReferenceSystem();
  if (env == null) {
  continue;
  } else {
  try {
-
+ sourceCrs = env.getCoordinateReferenceSystem();
  if ((sourceCrs != null)
  && !CRS.equalsIgnoreMetadata(sourceCrs, crs)) {
  env = env.transform(crs, true);

Added: trunk/modules/library/render/src/test/java/org/geotools/map/DefaultMapContextTest.java
===================================================================
--- trunk/modules/library/render/src/test/java/org/geotools/map/DefaultMapContextTest.java                        (rev 0)
+++ trunk/modules/library/render/src/test/java/org/geotools/map/DefaultMapContextTest.java 2009-07-09 07:02:51 UTC (rev 33532)
@@ -0,0 +1,33 @@
+package org.geotools.map;
+
+
+import static org.easymock.EasyMock.*;
+
+import java.io.IOException;
+
+import org.geotools.referencing.crs.DefaultGeographicCRS;
+import org.junit.Test;
+
+public class DefaultMapContextTest {
+
+ MapLayer mapLayerBoundsNull = createNiceMock(MapLayer.class);
+
+ /**
+ * if a {@link MapLayer#getBounds()} returns null a NullPointerException will be thrown
+ */
+ @Test
+ public void testNPELayerBounds() {
+ expect(mapLayerBoundsNull.getBounds()).andReturn(null);
+
+ replay(mapLayerBoundsNull);
+
+ DefaultMapContext mapContext = new DefaultMapContext(DefaultGeographicCRS.WGS84);
+ try {
+ mapContext.addLayer(mapLayerBoundsNull);
+ // throws a NullPointerException
+ mapContext.getLayerBounds();
+ } catch (IOException e) {
+ // don't care about is right here
+ }
+ }
+}


------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
GeoTools-commits mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-commits