LinkedDataFragments / Server.Java

A Triple Pattern Fragments server for Java
MIT License
27 stars 20 forks source link

Context Path issue when running application in a servlet container #52

Open larsgsvensson opened 5 years ago

larsgsvensson commented 5 years ago

When running the application i a servlet container (e. g. Tomcat) the dataset URLs were not properly built since the algorithm did not cater for the servlet path. In order to write the test cases, I also had to move the tests into the same packages as the classes they test so that they can access protected methods and inner classes

mielvds commented 4 years ago

Hi, would like to merge this, but it seems to have errors:

shouldIncludeContextPathInBaseUrl(org.linkeddatafragments.fragments.FragmentRequestParserBaseTest)  Time elapsed: 0.036 sec  <<< ERROR!
org.mockito.exceptions.base.MockitoException: 
Mockito cannot mock this class: interface javax.servlet.ServletContext.

Mockito can only mock non-private & non-final classes.
If you're not sure why you're getting this error, please report to the mailing list.

Java               : 1.8
JVM vendor name    : Oracle Corporation
JVM vendor version : 25.5-b02
JVM name           : Java HotSpot(TM) 64-Bit Server VM
JVM version        : 1.8.0_05-b13
JVM info           : mixed mode
OS name            : Mac OS X
OS version         : 10.13.6

Underlying exception : java.lang.IllegalArgumentException: object is not an instance of declaring class
    at org.linkeddatafragments.fragments.FragmentRequestParserBaseTest.shouldIncludeContextPathInBaseUrl(FragmentRequestParserBaseTest.java:19)
    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 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.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    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:483)
    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)
awoods commented 4 years ago

The non-functional reformatting in this pull-request makes the review very challenging. Would it be possible to resubmit, only including the functional updates?