I am trying to set up a simple Arquillian test for REST service written with Spring. Here is my SpringBoot application:
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
and controller:
@RestController
public class TestController {
@RequestMapping(value = "/test", method = RequestMethod.GET)
public ResponseEntity test() {
return ResponseEntity.status(HttpStatus.OK).body("Hello world");
}
}
then I want to test it running Arquillian test:
@RunWith(Arquillian.class)
public class TestControllerTest {
@Deployment(testable = false)
public static WebArchive createDeployment() {
File[] files = Maven.resolver()
.loadPomFromFile("pom.xml")
.importRuntimeDependencies()
.resolve().withTransitivity()
.asFile();
return ShrinkWrap.create(WebArchive.class)
.addPackage(pl.fuv.Application.class.getPackage())
.addPackage(TestController.class.getPackage())
.addAsLibraries(files);
}
@Test
@RunAsClient
public void callRest(@ArquillianResteasyResource final WebTarget webTarget) {
Response response = webTarget.path("/test").request().get();
String result = response.readEntity(String.class);
assertEquals("Hello world", result);
}
}
During deployment I get runtime exception:
SEVERE: Servlet [jsp] in web application [/0a1cee74-c798-46af-9402-474168676ae6] threw load() exception java.lang.ClassNotFoundException: org.apache.jasper.servlet.JspServlet at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1291) at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1119) at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:544) at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:525) at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:150) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1050) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:989) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4931) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5241) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734) at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:986) at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1857) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)
and Arquillian gets 404 HTTP response calling the service:
org.junit.ComparisonFailure: Expected :Hello world Actual
:HTTP Status 404 – Not Found (...)
My guess is that I build deployment artifact in a wrong way, that is missing something, but I could not find any info what might be wrong.