Arquillian Testing Guide by Arquillian Testing Guide 2013

Arquillian Testing Guide by Arquillian Testing Guide 2013

Author:Arquillian Testing Guide 2013
Language: eng
Format: epub
Publisher: Packt Publishing


This simply forces JAX-RS activation within your application. It needs to be included in the deployment archive. Then, we'll update our deployment to include the following class:

@Deployment public static WebArchive createTestArchive() { return ShrinkWrap.create(WebArchive.class,"test.war") .addClasses(GreeterService.class,JaxRsActivator.class,GreeterResource.class) .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); }

Finally, we'll create our test case that reads the resource:

@Test @RunAsClient public void testResourceInjection(@ArquillianResource URL baseUrl) throws Exception { URL url = new URL(baseUrl,"/test/resources/greeter/Dave"); InputStream is = url.openStream(); BufferedReader br = new BufferedReader(new InputStreamReader(is)); String result = br.readLine(); String expected = "Hello, Dave!"; assertEquals(expected, result); }



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.