-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GEOS-8181] KML reflector attempts to query all records in table
- Loading branch information
Showing
2 changed files
with
71 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/kml/src/test/java/org/geoserver/kml/sequence/FeatureSequenceFactoryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* (c) 2017 Open Source Geospatial Foundation - all rights reserved | ||
* This code is licensed under the GPL 2.0 license, available at the root | ||
* application directory. | ||
*/ | ||
package org.geoserver.kml.sequence; | ||
|
||
import static org.easymock.EasyMock.*; | ||
import static org.junit.Assert.*; | ||
|
||
import org.geoserver.kml.KmlEncodingContext; | ||
import org.geoserver.wms.WMSMapContent; | ||
import org.geotools.data.simple.SimpleFeatureCollection; | ||
import org.geotools.feature.DefaultFeatureCollection; | ||
import org.geotools.map.FeatureLayer; | ||
import org.geotools.styling.Style; | ||
import org.geotools.styling.StyleBuilder; | ||
import org.junit.Test; | ||
|
||
import de.micromata.opengis.kml.v_2_2_0.Feature; | ||
import junit.framework.AssertionFailedError; | ||
|
||
public class FeatureSequenceFactoryTest { | ||
|
||
@Test | ||
public void testNoScanOnEmptyStyle() { | ||
// a style with scale dependency | ||
StyleBuilder sb = new StyleBuilder(); | ||
Style style = sb.createStyle(sb.createPolygonSymbolizer()); | ||
style.featureTypeStyles().get(0).rules().get(0).setMaxScaleDenominator(1000); | ||
|
||
// the layer | ||
final DefaultFeatureCollection fc = new DefaultFeatureCollection(); | ||
FeatureLayer layer = new FeatureLayer(fc, style); | ||
|
||
// a max context with a scale outside the rule range | ||
WMSMapContent mc = createNiceMock(WMSMapContent.class); | ||
expect(mc.getScaleDenominator()).andReturn(2000d).anyTimes(); | ||
replay(mc); | ||
|
||
// and the context wiring everything toghether | ||
KmlEncodingContext context = createNiceMock(KmlEncodingContext.class); | ||
expect(context.openIterator(anyObject(SimpleFeatureCollection.class))) | ||
.andThrow(new AssertionFailedError("Should not have called openIterator")).anyTimes(); | ||
expect(context.getCurrentFeatureCollection()).andReturn(fc).anyTimes(); | ||
expect(context.getMapContent()).andReturn(mc).anyTimes(); | ||
replay(context); | ||
|
||
// check no features have been read | ||
FeatureSequenceFactory sf = new FeatureSequenceFactory(context, layer); | ||
Sequence<Feature> sequence = sf.newSequence(); | ||
assertNull(sequence.next()); | ||
} | ||
} |