Skip to content

Commit

Permalink
#6802 - added TemplateFeatureInfoSerializerTest, fixed output of the …
Browse files Browse the repository at this point in the history
…same GML ID for different features
  • Loading branch information
lgoltz committed Feb 1, 2021
1 parent 8117e02 commit 99cc3f4
Show file tree
Hide file tree
Showing 4 changed files with 250 additions and 4 deletions.
10 changes: 10 additions & 0 deletions deegree-core/deegree-core-featureinfo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.10.19</version>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,18 @@ if(! this.<?name>_switchfunction){
th(row, "Field").style.cssText = headerStyle
th(row, "Value").style.cssText = headerStyle
for(var i in <?name>){
row = tr(table)
td(row, 'GML ID').style.cssText = headerStyle
td(row, '<?gmlid>').style.cssText = headerStyle
<?name>[i](table)
}
}

<?name> = []
}

<?name>[<?name>.length] = function (table) {
var odd = true
var row
row = tr(table)
td(row, 'GML ID').style.cssText = headerStyle
td(row, '<?gmlid>').style.cssText = headerStyle
<?property *:properties>
}

Expand Down
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;
}
}

Large diffs are not rendered by default.

0 comments on commit 99cc3f4

Please sign in to comment.