WPS icon indicating copy to clipboard operation
WPS copied to clipboard

Unit tests should not rely on online resources

Open nuest opened this issue 9 years ago • 2 comments

Some unit tests do not work without an internet connection. Imho these tests should be integration tests. Afaics this is related to parsers and encoders that use schemas from geoprocessing.demo.52north.org

For example, running GML3BasicGeneratorTest offline results in the following stacktrace:

Aug 18, 2014 3:04:55 PM org.geotools.xml.SchemaLocator locateSchema
WARNUNG: Error occured getting schema
java.net.UnknownHostException: geoprocessing.demo.52north.org
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:589)
    at java.net.Socket.connect(Socket.java:538)
    at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:432)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:527)
    at sun.net.www.http.HttpClient.<init>(HttpClient.java:211)
    at sun.net.www.http.HttpClient.New(HttpClient.java:308)
    at sun.net.www.http.HttpClient.New(HttpClient.java:326)
    at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1167)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1103)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:997)
    at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:931)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1511)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1439)
    at org.eclipse.emf.ecore.resource.impl.URIHandlerImpl.createInputStream(URIHandlerImpl.java:178)
    at org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl.createInputStream(ExtensibleURIConverterImpl.java:301)
    at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1254)
    at org.geotools.xml.Schemas.parse(Schemas.java:313)
    at org.geotools.xml.Schemas.parse(Schemas.java:285)
    at org.geotools.xml.Schemas.parse(Schemas.java:247)
    at org.geotools.xml.XSD.buildSchema(XSD.java:281)
    at org.geotools.xml.XSD.getSchema(XSD.java:232)
    at org.geotools.xml.SchemaLocator.locateSchema(SchemaLocator.java:96)
    at org.geotools.xml.impl.ParserHandler.startElement(ParserHandler.java:357)
    at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
    at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
    at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
    at org.geotools.xml.Parser.parse(Parser.java:239)
    at org.geotools.xml.Parser.parse(Parser.java:167)
    at org.n52.wps.io.datahandler.parser.GML3BasicParser.parseFeatureCollection(GML3BasicParser.java:209)
    at org.n52.wps.io.datahandler.parser.GML3BasicParser.parseFeatureCollection(GML3BasicParser.java:187)
    at org.n52.wps.io.datahandler.parser.GML3BasicParser.parseXML(GML3BasicParser.java:135)
    at org.n52.wps.io.datahandler.parser.GML3BasicParser.parse(GML3BasicParser.java:120)
    at org.n52.wps.io.test.datahandler.generator.GML3BasicGeneratorTest.testParser(GML3BasicGeneratorTest.java:92)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at junit.framework.TestCase.runTest(TestCase.java:176)
    at junit.framework.TestCase.runBare(TestCase.java:141)
    at junit.framework.TestResult$1.protect(TestResult.java:122)
    at junit.framework.TestResult.runProtected(TestResult.java:142)
    at junit.framework.TestResult.run(TestResult.java:125)
    at junit.framework.TestCase.run(TestCase.java:129)
    at junit.framework.TestSuite.runTest(TestSuite.java:255)
    at junit.framework.TestSuite.run(TestSuite.java:250)
    at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:84)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

Aug 18, 2014 3:04:55 PM org.geotools.xml.impl.ParserHandler startElement
WARNUNG: Error parsing: http://geoprocessing.demo.52north.org:8080/geoserver/wfs?service=WFS&version=1.1.0&request=DescribeFeatureType&typeName=sf%3Arestricted
[main] ERROR org.n52.wps.io.datahandler.parser.GML3BasicParser - Exception while handling parsed GML.
org.xml.sax.SAXException: Error parsing: http://geoprocessing.demo.52north.org:8080/geoserver/wfs?service=WFS&version=1.1.0&request=DescribeFeatureType&typeName=sf%3Arestricted
    at org.geotools.xml.impl.ParserHandler.startElement(ParserHandler.java:387)
    at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
    at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
    at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
    at org.geotools.xml.Parser.parse(Parser.java:239)
    at org.geotools.xml.Parser.parse(Parser.java:167)
    at org.n52.wps.io.datahandler.parser.GML3BasicParser.parseFeatureCollection(GML3BasicParser.java:209)
    at org.n52.wps.io.datahandler.parser.GML3BasicParser.parseFeatureCollection(GML3BasicParser.java:187)
    at org.n52.wps.io.datahandler.parser.GML3BasicParser.parseXML(GML3BasicParser.java:135)
    at org.n52.wps.io.datahandler.parser.GML3BasicParser.parse(GML3BasicParser.java:120)
    at org.n52.wps.io.test.datahandler.generator.GML3BasicGeneratorTest.testParser(GML3BasicGeneratorTest.java:92)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at junit.framework.TestCase.runTest(TestCase.java:176)
    at junit.framework.TestCase.runBare(TestCase.java:141)
    at junit.framework.TestResult$1.protect(TestResult.java:122)
    at junit.framework.TestResult.runProtected(TestResult.java:142)
    at junit.framework.TestResult.run(TestResult.java:125)
    at junit.framework.TestCase.run(TestCase.java:129)
    at junit.framework.TestSuite.runTest(TestSuite.java:255)
    at junit.framework.TestSuite.run(TestSuite.java:250)
    at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:84)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

And even for integration tests, we could probably mock these server resources.

nuest avatar Aug 18 '14 13:08 nuest

@ridoo Is this still the case with the latest WPS?

nuest avatar Nov 10 '15 15:11 nuest

never run into such exception but did not check that module yet to tell if the problem does not exist anymore, though

ridoo avatar Nov 10 '15 17:11 ridoo