Uploaded image for project: 'GeoServer'
  1. GEOS-8789

FileWrapperResourceTheoryTest fails if java.io.tmpdir is relative

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Medium
    • Resolution: Fixed
    • Affects Version/s: 2.12.3, 2.13.1, 2.14-RC
    • Fix Version/s: 2.12.5, 2.13.2, 2.14-RC
    • Component/s: Global
    • Labels:
      None
    • Environment:

      Linux

      Description

      FileWrapperResourceTheoryTest fails if java.io.tmpdir is a relative path because the temporary directory root then also lacks a leading slash on Linux and the logic is incorrect, leading to a bad resource path.

      Here are the failures seen without the patch, with -Djava.io.tmpdir=target. Notice the duplicated paths:

      Running org.geoserver.platform.resource.FileWrapperResourceTheoryTest
      Tests run: 33, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.074 sec <<< FAILURE!
      theoryAddingFileToDirectoryAddsResource(org.geoserver.platform.resource.FileWrapperResourceTheoryTest)  Time elapsed: 3 sec  <<< ERROR!
      org.junit.experimental.theories.internal.ParameterizedAssertionError: theoryAddingFileToDirectoryAddsResource(testPaths[2])
      	at org.junit.experimental.theories.Theories$TheoryAnchor.reportParameterizedError(Theories.java:192)
      	at org.junit.experimental.theories.Theories$TheoryAnchor$1$1.evaluate(Theories.java:146)
      	at org.junit.experimental.theories.Theories$TheoryAnchor.runWithCompleteAssignment(Theories.java:127)
      	at org.junit.experimental.theories.Theories$TheoryAnchor.runWithAssignment(Theories.java:111)
      	at org.junit.experimental.theories.Theories$TheoryAnchor.runWithIncompleteAssignment(Theories.java:120)
      	at org.junit.experimental.theories.Theories$TheoryAnchor.runWithAssignment(Theories.java:109)
      	at org.junit.experimental.theories.Theories$TheoryAnchor.evaluate(Theories.java:96)
      	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
      	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
      	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
      	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
      	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
      	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
      	at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
      	at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
      	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
      	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
      	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:498)
      	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:115)
      	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
      Caused by: java.lang.AssertionError: 
      Expected: is resource that is defined
           but: was <ResourceAdaptor(/home/ben/geoserver/src with spaces/geoserver/src/platform/target/junit5736649089550125717/home/ben/geoserver/src with spaces/geoserver/src/platform/target/junit5736649089550125717/DirC/newFileCreatedDirectly)>
      	at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
      	at org.junit.Assert.assertThat(Assert.java:865)
      	at org.junit.Assert.assertThat(Assert.java:832)
      	at org.geoserver.platform.resource.ResourceTheoryTest.theoryAddingFileToDirectoryAddsResource(ResourceTheoryTest.java:420)
      	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:498)
      	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
      	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
      	at org.junit.experimental.theories.Theories$TheoryAnchor$2.evaluate(Theories.java:175)
      	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
      	at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:48)
      	at org.junit.rules.ExpectedException$ExpectedExceptionStatement.evaluate(ExpectedException.java:168)
      	at org.junit.rules.RunRules.evaluate(RunRules.java:20)
      	at org.junit.experimental.theories.Theories$TheoryAnchor$1$1.evaluate(Theories.java:141)
      	... 26 more
      
      Running org.geoserver.platform.resource.PathsTest
      Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec
      Running org.geoserver.platform.resource.ResourcesTest
      Tests run: 34, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.065 sec <<< FAILURE!
      theoryAddingFileToDirectoryAddsResource(org.geoserver.platform.resource.ResourcesTest)  Time elapsed: 2 sec  <<< ERROR!
      org.junit.experimental.theories.internal.ParameterizedAssertionError: theoryAddingFileToDirectoryAddsResource(testPaths[2])
      	at org.junit.experimental.theories.Theories$TheoryAnchor.reportParameterizedError(Theories.java:192)
      	at org.junit.experimental.theories.Theories$TheoryAnchor$1$1.evaluate(Theories.java:146)
      	at org.junit.experimental.theories.Theories$TheoryAnchor.runWithCompleteAssignment(Theories.java:127)
      	at org.junit.experimental.theories.Theories$TheoryAnchor.runWithAssignment(Theories.java:111)
      	at org.junit.experimental.theories.Theories$TheoryAnchor.runWithIncompleteAssignment(Theories.java:120)
      	at org.junit.experimental.theories.Theories$TheoryAnchor.runWithAssignment(Theories.java:109)
      	at org.junit.experimental.theories.Theories$TheoryAnchor.evaluate(Theories.java:96)
      	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
      	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
      	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
      	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
      	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
      	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
      	at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
      	at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
      	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
      	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
      	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:498)
      	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:115)
      	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
      Caused by: java.lang.AssertionError: 
      Expected: is resource that is defined
           but: was <ResourceAdaptor(/home/ben/geoserver/src with spaces/geoserver/src/platform/target/junit3049597659115012310/home/ben/geoserver/src with spaces/geoserver/src/platform/target/junit3049597659115012310/DirC/newFileCreatedDirectly)>
      	at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
      	at org.junit.Assert.assertThat(Assert.java:865)
      	at org.junit.Assert.assertThat(Assert.java:832)
      	at org.geoserver.platform.resource.ResourceTheoryTest.theoryAddingFileToDirectoryAddsResource(ResourceTheoryTest.java:420)
      	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:498)
      	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
      	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
      	at org.junit.experimental.theories.Theories$TheoryAnchor$2.evaluate(Theories.java:175)
      	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
      	at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:48)
      	at org.junit.rules.ExpectedException$ExpectedExceptionStatement.evaluate(ExpectedException.java:168)
      	at org.junit.rules.RunRules.evaluate(RunRules.java:20)
      	at org.junit.experimental.theories.Theories$TheoryAnchor$1$1.evaluate(Theories.java:141)
      	... 26 more
      

        Attachments

          Issue links

            Activity

              People

              • Assignee:
                bencaradocdavies Ben Caradoc-Davies
                Reporter:
                bencaradocdavies Ben Caradoc-Davies
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: