Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-activate the remote WMS integration tests #1446

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the base64 encoded output to STDOUT was intentional, because by default the LOG is very strongly suppressed on the CI/CD system.
Had you checked whether the results still appear in the CI/CD log after the change in case of an image error ?

Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ private static void toTempfile( RenderedImage expected, RenderedImage actual, St
Files.write( tempDir.resolve( name + "_actual.png" ), toBytes( actual, "png" ) );
Files.write( tempDir.resolve( name + "_expected.png" ), toBytes( expected, "png" ) );

System.out.println( "Result returned for " + name + " (base64 -di encoded.dat > failed-test.zip)" );
System.out.println( toBase64Zip( toBytes( actual, "png" ), name + ".png" ) );
LOG.debug( "Result returned for " + name + " (base64 -di encoded.dat > failed-test.zip)" );
LOG.debug( toBase64Zip( toBytes( actual, "png" ), name + ".png" ) );
} catch ( Throwable t ) {
}
}
Expand All @@ -178,7 +178,7 @@ public static boolean isImageSimilar( RenderedImage expected, RenderedImage actu

String pasteBin = IntegrationTestUtils.toPasteBin( toBytes( actual, "png" ) );
if ( pasteBin != null ) {
System.out.println( "Actual returned image for " + name + " available at " + pasteBin );
LOG.info( "Actual returned image for " + name + " available at " + pasteBin );
}
toTempfile( expected, actual, name );

Expand Down
8 changes: 8 additions & 0 deletions deegree-tests/deegree-wms-remoteows-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.xmlunit</groupId>
<artifactId>xmlunit-core</artifactId>
</dependency>
<dependency>
<groupId>org.xmlunit</groupId>
<artifactId>xmlunit-matchers</artifactId>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
//$HeadURL$
/*----------------------------------------------------------------------------
This file is part of deegree, http://deegree.org/
Copyright (C) 2001-2010 by:
- Department of Geography, University of Bonn -
and
- lat/lon GmbH -

This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free
Software Foundation; either version 2.1 of the License, or (at your option)
any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

Contact information:

lat/lon GmbH
Aennchenstr. 19, 53177 Bonn
Germany
http://lat-lon.de/

Department of Geography, University of Bonn
Prof. Dr. Klaus Greve
Postfach 1147, 53001 Bonn
Germany
http://www.geographie.uni-bonn.de/deegree/

Occam Labs UG (haftungsbeschränkt)
Godesberger Allee 139, 53175 Bonn
Germany
http://www.occamlabs.de/

e-mail: [email protected]
----------------------------------------------------------------------------*/

package org.deegree.services.wms;

import org.apache.commons.io.IOUtils;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import org.slf4j.Logger;
import org.xmlunit.matchers.CompareMatcher;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import static org.deegree.commons.utils.net.HttpUtils.UTF8STRING;
import static org.deegree.commons.utils.net.HttpUtils.retrieve;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.slf4j.LoggerFactory.getLogger;

/**
* <code>RemoteWMSIntegrationTest</code>
*
* @author <a href="mailto:[email protected]">Andreas Schmitz</a>
* @author last edited by: $Author: mschneider $
* @version $Revision: 31882 $, $Date: 2011-09-15 02:05:04 +0200 (Thu, 15 Sep 2011) $
*/

@Ignore
@RunWith(Parameterized.class)
public class RemoteWMSGfiIntegrationTest {

private static final Logger LOG = getLogger( RemoteWMSGfiIntegrationTest.class );

private final String resourceName;

private final String request;

private final String expected;

public RemoteWMSGfiIntegrationTest( String resourceName )
throws IOException {
this.resourceName = resourceName;
this.request = IOUtils.toString(
RemoteWMSGfiIntegrationTest.class.getResourceAsStream(
"/requests/" + resourceName + ".kvp" ) );
this.expected = IOUtils.toString(
RemoteWMSGfiIntegrationTest.class.getResourceAsStream(
"/requests/" + resourceName + ".xml" ) );
}

@Parameters(name = "{index}: {0}")
public static Collection<Object[]> getParameters() {
List<Object[]> requests = new ArrayList<>();
requests.add( new Object[] { "featureinfofromdeegree" } );
return requests;
}

@Test
public void testGfiResponse()
throws
Exception {
String request = createRequest();
LOG.info( "Requesting {}", request );
String actual = retrieve( UTF8STRING, request );

assertThat( "GFI Response for " + resourceName + " does not match expected response", actual,
CompareMatcher.isSimilarTo( expected ).ignoreWhitespace() );
}

private String createRequest() {
StringBuffer sb = new StringBuffer();
sb.append( "http://localhost:" );
sb.append( "8090" );
sb.append( "/" );
sb.append( System.getProperty( "deegree-wms-remoteows-webapp", "deegree-wms-remoteows-tests" ) );
sb.append( "/services/wms" );
if ( !request.startsWith( "?" ) )
sb.append( "?" );
sb.append( request );
return sb.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ Occam Labs UG (haftungsbeschränkt)
package org.deegree.services.wms;

import org.apache.commons.io.IOUtils;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
Expand All @@ -51,9 +50,8 @@ Occam Labs UG (haftungsbeschränkt)

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.awt.image.RenderedImage;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
Expand All @@ -73,34 +71,44 @@ Occam Labs UG (haftungsbeschränkt)
*/

@RunWith(Parameterized.class)
@Ignore
public class RemoteWMSIntegrationTest {

private static final Logger LOG = getLogger( RemoteWMSIntegrationTest.class );

private static int numFailed = 0;
private enum IMAGE_RESPONSE_SUFFIXES {
FIRST( "" ), SECOND( "2" ), THIRD( "3" ), FOURTH( "4" );

private String suffix;

IMAGE_RESPONSE_SUFFIXES( String suffix ) {
this.suffix = suffix;
}
}

private final String resourceName;

private final String request;

private final BufferedImage expected;
private final List<String> expectedResourcePath = new ArrayList<>();

public RemoteWMSIntegrationTest( String resourceName )
throws IOException {
this.resourceName = resourceName;
this.request = IOUtils.toString(
RemoteWMSIntegrationTest.class.getResourceAsStream(
"/requests/" + resourceName + ".kvp" ) );
this.expected = ImageIO.read(
RemoteWMSIntegrationTest.class.getResourceAsStream(
"/requests/" + resourceName + ".response" ) );
for ( IMAGE_RESPONSE_SUFFIXES suffix : IMAGE_RESPONSE_SUFFIXES.values() ) {
String resourcePath = "/requests/" + resourceName + suffix.suffix + ".png";
URL resource = RemoteWMSIntegrationTest.class.getResource(
resourcePath );
if ( resource != null )
this.expectedResourcePath.add( resourcePath );
}
}

@Parameters(name = "{index}: {0}")
public static Collection<Object[]> getParameters() {
List<Object[]> requests = new ArrayList<>();
requests.add( new Object[] { "featureinfofromdeegree" } );
requests.add( new Object[] { "multiple" } );
requests.add( new Object[] { "optionsmultiple" } );
requests.add( new Object[] { "optionssingle" } );
Expand All @@ -114,14 +122,29 @@ public static Collection<Object[]> getParameters() {

@Test
public void testSimilarity()
throws
Exception {
throws
Exception {
String request = createRequest();
LOG.info( "Requesting {}", request );
BufferedImage actual = retrieve( IMAGE, request );

assertTrue( "Image for " + resourceName + "are not similar enough",
isImageSimilar( expected, actual, 0.01, getClass().getName() + resourceName ) );
assertTrue( "Image for " + resourceName + " are not similar enough",
isAtLeastOneImageCandidateSimilar( actual ) );
}

private boolean isAtLeastOneImageCandidateSimilar( BufferedImage actual )
throws Exception {
for ( String expectedCandidate : expectedResourcePath ) {
BufferedImage expected = ImageIO.read( RemoteWMSIntegrationTest.class.getResourceAsStream(
expectedCandidate ) );
boolean imageSimilar = isImageSimilar( expected, actual, 0.01,
getClass().getName() + "_" + expectedCandidate );
if ( imageSimilar ) {
LOG.info( "Found expected image {}", expectedCandidate );
return true;
}
}
return false;
}

private String createRequest() {
Expand All @@ -136,13 +159,4 @@ private String createRequest() {
sb.append( request );
return sb.toString();
}

private byte[] parseAsBytes( RenderedImage actual )
throws IOException {
ByteArrayOutputStream bosActual = new ByteArrayOutputStream();
ImageIO.write( actual, "png", bosActual );
bosActual.flush();
bosActual.close();
return bosActual.toByteArray();
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
?REQUEST=GetMap&SERVICE=WMS&VERSION=1.1.1&WIDTH=1193&HEIGHT=857&LAYERS=timeout&TRANSPARENT=TRUE&FORMAT=image%2Fpng&BBOX=389861.0150035092,4426483.167746064,531448.4199583281,4528193.482956693&SRS=EPSG:26912&STYLES=
?REQUEST=GetMap&SERVICE=WMS&VERSION=1.1.1&WIDTH=1193&HEIGHT=857&LAYERS=timeout&TRANSPARENT=TRUE&FORMAT=image%2Fpng&BBOX=389861.0150035092,4426483.167746064,531448.4199583281,4528193.482956693&SRS=EPSG:26912&STYLES=&EXCEPTIONS=application/vnd.ogc.se_inimage
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.