-
-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#6802 - added TemplateFeatureInfoSerializerTest, fixed output of the …
…same GML ID for different features
- Loading branch information
Showing
4 changed files
with
250 additions
and
4 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
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
59 changes: 59 additions & 0 deletions
59
.../src/test/java/org/deegree/featureinfo/serializing/TemplateFeatureInfoSerializerTest.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,59 @@ | ||
package org.deegree.featureinfo.serializing; | ||
|
||
import org.deegree.feature.FeatureCollection; | ||
import org.deegree.featureinfo.FeatureInfoContext; | ||
import org.deegree.featureinfo.FeatureInfoParams; | ||
import org.deegree.gml.GMLInputFactory; | ||
import org.deegree.gml.GMLStreamReader; | ||
import org.deegree.gml.GMLVersion; | ||
import org.junit.Test; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
import java.io.IOException; | ||
import java.io.OutputStream; | ||
import java.net.URL; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import static org.hamcrest.CoreMatchers.endsWith; | ||
import static org.hamcrest.CoreMatchers.startsWith; | ||
import static org.junit.Assert.assertThat; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
/** | ||
* @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz </a> | ||
*/ | ||
public class TemplateFeatureInfoSerializerTest { | ||
|
||
@Test | ||
public void testSerialize_DefautHtmlGfi_ShouldReturnHtml() | ||
throws Exception { | ||
ByteArrayOutputStream bos = new ByteArrayOutputStream(); | ||
TemplateFeatureInfoSerializer serializer = new TemplateFeatureInfoSerializer(); | ||
FeatureInfoParams params = createParams(); | ||
FeatureInfoContext context = mockContext( bos ); | ||
serializer.serialize( params, context ); | ||
|
||
String html = bos.toString().trim(); | ||
assertThat( html, startsWith( "<html>" ) ); | ||
assertThat( html, endsWith( "</html>" ) ); | ||
} | ||
|
||
private FeatureInfoParams createParams() | ||
throws Exception { | ||
URL resource = TemplateFeatureInfoSerializer.class.getResource( "featurecollection.gml" ); | ||
GMLStreamReader gmlStreamReader = GMLInputFactory.createGMLStreamReader( GMLVersion.GML_32, | ||
resource ); | ||
Map<String, String> nsBindings = new HashMap<>(); | ||
FeatureCollection col = gmlStreamReader.readFeatureCollection(); | ||
return new FeatureInfoParams( nsBindings, col, "text/html", true, null, null, null ); | ||
} | ||
|
||
private FeatureInfoContext mockContext( OutputStream os ) | ||
throws IOException { | ||
FeatureInfoContext mock = mock( FeatureInfoContext.class ); | ||
when( mock.getOutputStream() ).thenReturn( os ); | ||
return mock; | ||
} | ||
} |
178 changes: 178 additions & 0 deletions
178
...-featureinfo/src/test/resources/org/deegree/featureinfo/serializing/featurecollection.gml
Large diffs are not rendered by default.
Oops, something went wrong.