@Deployment(testable = false)
public static WebArchive createDeployment() {
return ShrinkWrap.create(WebArchive.class).
addPackage("org.javaee7.jaxws.endpoint");
}
cd javaee7-samples/jaxws/jaxws-endpoint/Now we are ready to start testing. You can run all the tests in this sample by executing:
mvn test
Or you can run individual tests by executing one of the following:mvn test -Dtest=EBookStoreTest
Arquillian specific method for creating a file which can be deployed while executing the test.
@Deployment(testable = false)
public static WebArchive createDeployment() {
return ShrinkWrap.create(WebArchive.class).
addPackage("org.javaee7.jaxws.endpoint");
}
@Test
public void test1WelcomeMessage() throws MalformedURLException {
EBookStore eBookStore = eBookStoreService.getPort(EBookStore.class);
String response=eBookStore.welcomeMessage("Johnson");
assertEquals("Welcome to EBookStore WebService, Mr/Mrs Johnson", response);
}
@Test
public void test2SaveAndTakeBook() throws MalformedURLException {
EBookStore eBookStore = eBookStoreService.getPort(EBookStore.class);
EBook eBook=new EBook();
eBook.setTitle("The Lord of the Rings");
eBook.setNumPages(1178);
eBook.setPrice(21.8);
eBookStore.saveBook(eBook);
eBook=new EBook();
eBook.setTitle("Oliver Twist");
eBook.setNumPages(268);
eBook.setPrice(7.45);
eBookStore.saveBook(eBook);
EBook response=eBookStore.takeBook("Oliver Twist");
assertEquals(eBook.getNumPages(),response.getNumPages());
}
@Test
public void test3FindEbooks(){
EBookStore eBookStore = eBookStoreService.getPort(EBookStore.class);
List<String> titleList=eBookStore.findEBooks("Rings");
assertNotNull(titleList);
assertEquals(1, titleList.size());
assertEquals("The Lord of the Rings",titleList.get(0));
}
@Test
public void test4AddAppendix(){
EBookStore eBookStore = eBookStoreService.getPort(EBookStore.class);
EBook eBook=eBookStore.takeBook("Oliver Twist");
assertEquals(268,eBook.getNumPages());
EBook eBookResponse=eBookStore.addAppendix(eBook, 5);
assertEquals(268,eBook.getNumPages());
assertEquals(273,eBookResponse.getNumPages());
}
There's a lot more about JavaEE to cover. If you're ready to learn more, check out the other available samples.
git clone git://github.com/javaee-samples/javaee7-samples.git
cd javaee7-samples/jaxws/jaxws-endpoint/
Do the changes as you see fit and send a pull request!
Good Luck!