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

Test failure when getting files from resources #2339

Closed
marcusyoung opened this issue Sep 9, 2016 · 9 comments · Fixed by #3703
Closed

Test failure when getting files from resources #2339

marcusyoung opened this issue Sep 9, 2016 · 9 comments · Fixed by #3703
Labels
Milestone

Comments

@marcusyoung
Copy link
Contributor

I get the following test error so am unable to build version 1.0:


Test set: org.opentripplanner.updater.bike_rental.TestShareBikeRentalStationSource

Tests run: 2, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.072 sec <<< FAILURE!
testShareBike(org.opentripplanner.updater.bike_rental.TestShareBikeRentalStationSource) Time elapsed: 0.035 sec <<< FAILURE!
junit.framework.AssertionFailedError: null
at junit.framework.Assert.fail(Assert.java:47)
at junit.framework.Assert.assertTrue(Assert.java:20)
at junit.framework.Assert.assertTrue(Assert.java:27)
at org.opentripplanner.updater.bike_rental.TestShareBikeRentalStationSource.testShareBike(TestShareBikeRentalStationSource.java:16)
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:497)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:236)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:134)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:113)
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:497)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:103)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:74)

@barbeau
Copy link
Contributor

barbeau commented Sep 9, 2016

@marcusyoung Note that you can still build the project and skip the tests with mvn install -DskipTests.

@abyrd
Copy link
Member

abyrd commented Sep 12, 2016

I'm still unable to reproduce this, but leaving the ticket open until we try the build on more platforms.

@barbeau
Copy link
Contributor

barbeau commented Sep 12, 2016

I'm able to reproduce this with a clean clone and mvn install on the master branch, on Windows 10 Pro and Java 1.8.0_91 64-bit.

Looks like the test failure boils down to not finding the share-bike.json file:

Bike rental station TNB at 48.107697, -1.673695
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.064 sec
Running org.opentripplanner.updater.bike_rental.TestShareBikeRentalStationSource
09:32:47.616 WARN (ShareBikeRentalDataSource.java:77) Unable to extract url parameter 'SystemID' query parameter from sharebike url, using random value 4fab207a-30d4-4f15-acc2-f510cbec9fed
09:32:47.631 WARN (GenericJsonBikeRentalDataSource.java:99) Error reading bike rental feed from file:src/test/resources/bike/share-bike.json?SystemID=dummyid
java.io.FileNotFoundException: src\test\resources\bike\share-bike.json?SystemID=dummyid (The filename, directory name, or volume label syntax is incorrect)
        at java.io.FileInputStream.open0(Native Method) ~[na:1.8.0_60]
        at java.io.FileInputStream.open(FileInputStream.java:195) ~[na:1.8.0_60]
        at java.io.FileInputStream.<init>(FileInputStream.java:138) ~[na:1.8.0_60]
        at java.io.FileInputStream.<init>(FileInputStream.java:93) ~[na:1.8.0_60]
        at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:90) ~[na:1.8.0_60]
        at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:188) ~[na:1.8.0_60]
        at java.net.URL.openStream(URL.java:1038) ~[na:1.8.0_60]
        at org.opentripplanner.updater.bike_rental.GenericJsonBikeRentalDataSource.update(GenericJsonBikeRentalDataSource.java:83) ~[classes/:na]
        at org.opentripplanner.updater.bike_rental.TestShareBikeRentalStationSource.testShareBike(TestShareBikeRentalStationSource.java:16) [test-classes/:na]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_60]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_60]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_60]
        at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_60]
        at junit.framework.TestCase.runTest(TestCase.java:168) [junit-4.8.1.jar:na]
        at junit.framework.TestCase.runBare(TestCase.java:134) [junit-4.8.1.jar:na]
        at junit.framework.TestResult$1.protect(TestResult.java:110) [junit-4.8.1.jar:na]
        at junit.framework.TestResult.runProtected(TestResult.java:128) [junit-4.8.1.jar:na]
        at junit.framework.TestResult.run(TestResult.java:113) [junit-4.8.1.jar:na]
        at junit.framework.TestCase.run(TestCase.java:124) [junit-4.8.1.jar:na]
        at junit.framework.TestSuite.runTest(TestSuite.java:232) [junit-4.8.1.jar:na]
        at junit.framework.TestSuite.run(TestSuite.java:227) [junit-4.8.1.jar:na]
        at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83) [junit-4.8.1.jar:na]
        at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:236) [surefire-junit4-2.12.jar:2.12]
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:134) [surefire-junit4-2.12.jar:2.12]
        at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:113) [surefire-junit4-2.12.jar:2.12]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_60]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_60]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_60]
        at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_60]
        at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189) [surefire-api-2.12.jar:2.12]
        at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165) [surefire-booter-2.12.jar:2.12]
        at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85) [surefire-booter-2.12.jar:2.12]
        at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:103) [surefire-booter-2.12.jar:2.12]
        at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:74) [surefire-booter-2.12.jar:2.12]
Tests run: 2, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.087 sec <<< FAILURE!
...
Results :

Failed tests:   testShareBike(org.opentripplanner.updater.bike_rental.TestShareBikeRentalStationSource)

Tests in error:
  testRoadPassingOverDuplicatedNode(org.opentripplanner.graph_builder.module.osm.TestUnconnectedAreas): error loading OSM from path c:\Git%20Projects\opentripplanner\target\test-classes\org\opentripplanner\graph_builder\module\osm\coincident_pr.osm
  testCoincidentNodeUnconnectedParkAndRide(org.opentripplanner.graph_builder.module.osm.TestUnconnectedAreas): error loading OSM from path c:\Git%20Projects\opentripplanner\target\test-classes\org\opentripplanner\graph_builder\module\osm\hackett_pr.osm.gz
  testAreaPassingOverNode(org.opentripplanner.graph_builder.module.osm.TestUnconnectedAreas): error loading OSM from path c:\Git%20Projects\opentripplanner\target\test-classes\org\opentripplanner\graph_builder\module\osm\coincident_pr.osm
  testUnconnectedParkAndRide(org.opentripplanner.graph_builder.module.osm.TestUnconnectedAreas): error loading OSM from path c:\Git%20Projects\opentripplanner\target\test-classes\org\opentripplanner\graph_builder\module\osm\P+R.osm.gz
  testRoadPassingOverNode(org.opentripplanner.graph_builder.module.osm.TestUnconnectedAreas): error loading OSM from path c:\Git%20Projects\opentripplanner\target\test-classes\org\opentripplanner\graph_builder\module\osm\coincident_pr.osm

Tests run: 387, Failures: 1, Errors: 5, Skipped: 2

As you can see above there are also a few errors.

@abyrd
Copy link
Member

abyrd commented Sep 13, 2016

The file src\test\resources\bike\share-bike.json is in the repo, but it looks like the file: URL has a query parameter on the end.

@seime
Copy link
Contributor

seime commented Sep 13, 2016

I will make a PR for this very soon.

making data fly.

Arne Seime | Senior consultant & developer
greenbird Integration Technology AS
+47 99574896 | arne.seime@greenbird.com | www.greenbird.com

From: Andrew Byrd notifications@github.com
Reply-To: opentripplanner/OpenTripPlanner reply@reply.github.com
Date: Tuesday 13 September 2016 at 09:01
To: opentripplanner/OpenTripPlanner OpenTripPlanner@noreply.github.com
Subject: Re: [opentripplanner/OpenTripPlanner] Test failure when trying to build v1.0 (#2339)

The file src\test\resources\bike\share-bike.json is in the repo, but it looks like the file: URL has a query parameter on the end.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHubhttps://github.com//issues/2339#issuecomment-246592987, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ABfh5ICc-mTUye7Ng9KfUKYMU_2iwLZiks5qpkozgaJpZM4J5O83.

@abyrd
Copy link
Member

abyrd commented Sep 13, 2016

It looks like the real problem is that relative file URLs are not a good idea in Java, and can run into authorization problems. We should probably be using getClass().getResource("X");.

seime pushed a commit to entur/OpenTripPlanner that referenced this issue Sep 13, 2016
csolem added a commit to entur/OpenTripPlanner that referenced this issue Sep 26, 2016
csolem added a commit to entur/OpenTripPlanner that referenced this issue Sep 26, 2016
barslett pushed a commit to barslett/OpenTripPlanner that referenced this issue Oct 21, 2016
@abyrd abyrd closed this as completed Oct 13, 2020
@barbeau
Copy link
Contributor

barbeau commented Oct 28, 2021

I'm re-opening this, as I'm still able to reproduce as of the latest dev-v2.x branch at 2cb7cdb.

This is on a Windows 7 Enterprise machine with Java version "11.0.12" 2021-07-20 LTS.

I used the same exact Maven command as CI:

mvn --batch-mode --update-snapshots verify

And I get:

[INFO] Results:
[INFO]
[ERROR] Errors:
[ERROR]   LinkingTest.testStopsLinkedIdentically:82 » IllegalState error loading OSM fro...
[ERROR]   TestUnconnectedAreas.testAreaPassingOverNode:145->testGeometricGraphWithClasspathFile:175 » IllegalState
[ERROR]   TestUnconnectedAreas.testCoincidentNodeUnconnectedParkAndRide:76 » IllegalState
[ERROR]   TestUnconnectedAreas.testRoadPassingOverDuplicatedNode:155->testGeometricGraphWithClasspathFile:175 » IllegalState
[ERROR]   TestUnconnectedAreas.testRoadPassingOverNode:135->testGeometricGraphWithClasspathFile:175 » IllegalState
[ERROR]   TestUnconnectedAreas.testUnconnectedParkAndRide:41 » IllegalState error loadin...
[INFO]
[ERROR] Tests run: 1264, Failures: 0, Errors: 6, Skipped: 40
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  02:02 min
[INFO] Finished at: 2021-10-28T17:30:38-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M5:test (default-test) on project otp: There are test failures.
[ERROR]

It looks like it's a path encoding issue on Windows specifically - when I run the test from within IntelliJ they also fail. Here's an example stack trace:

17:26:27.257 INFO (OpenStreetMapModule.java:200) Gathering OSM from provider: BinaryFileBasedOpenStreetMapProviderImpl(E:\Git%20Projects\OpenTripPlanner\target\test-classes\org\opentripplanner\graph_builder\module\columbus.osm.pbf)

java.lang.IllegalStateException: error loading OSM from path E:\Git%20Projects\OpenTripPlanner\target\test-classes\org\opentripplanner\graph_builder\module\columbus.osm.pbf

	at org.opentripplanner.openstreetmap.BinaryOpenStreetMapProvider.readOSM(BinaryOpenStreetMapProvider.java:53)
	at org.opentripplanner.graph_builder.module.osm.OpenStreetMapModule.buildGraph(OpenStreetMapModule.java:201)
	at org.opentripplanner.graph_builder.services.GraphBuilderModule.buildGraph(GraphBuilderModule.java:22)
	at org.opentripplanner.graph_builder.module.FakeGraph.buildGraphNoTransit(FakeGraph.java:39)
	at org.opentripplanner.graph_builder.module.linking.LinkingTest.testStopsLinkedIdentically(LinkingTest.java:82)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
	at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
	at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
	at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
	at org.junit.vintage.engine.execution.RunnerExecutor.execute(RunnerExecutor.java:43)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
	at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
	at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
	at org.junit.vintage.engine.VintageTestEngine.executeAllChildren(VintageTestEngine.java:82)
	at org.junit.vintage.engine.VintageTestEngine.execute(VintageTestEngine.java:73)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:108)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:96)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:75)
	at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:71)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
Caused by: java.lang.RuntimeException: Failed to load E:\Git%20Projects\OpenTripPlanner\target\test-classes\org\opentripplanner\graph_builder\module\columbus.osm.pbf: E:\Git%20Projects\OpenTripPlanner\target\test-classes\org\opentripplanner\graph_builder\module\columbus.osm.pbf (The system cannot find the path specified)

@barbeau barbeau reopened this Oct 28, 2021
@barbeau barbeau added the bug label Oct 28, 2021
@barbeau
Copy link
Contributor

barbeau commented Oct 28, 2021

I'm guessing it's due to the space in the directory name - E:\Git%20Projects

@barbeau
Copy link
Contributor

barbeau commented Oct 28, 2021

I believe I have a fix for this - I'll test more and then open a PR.

@barbeau barbeau changed the title Test failure when trying to build v1.0 Test failure when getting files from resources Oct 28, 2021
barbeau added a commit to CUTR-at-USF/OpenTripPlanner that referenced this issue Oct 29, 2021
@t2gran t2gran added this to the 2.1 milestone Oct 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants