Jaxws endpoint

Run
How to run the sample
The source code for this sample can be found in the javaee7-samples GitHub repository. The first thing we need to do is to get the source by downloading the repository and then go into the samples folder:
git clone git://github.com/javaee-samples/javaee7-samples.git
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

  • Specifications in use:
    • jaxws

    EBookStoreTest

    Missing a description for the story. Add some javadoc to the TestClass. Show me how!

    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");
    }
    Missing a description for the test scenario. Add some javadoc to the @Test method. Show me how!
    @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);
    }
    Missing a description for the test scenario. Add some javadoc to the @Test method. Show me how!
    @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());
    }
    Missing a description for the test scenario. Add some javadoc to the @Test method. Show me how!
    @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));
    }
    Missing a description for the test scenario. Add some javadoc to the @Test method. Show me how!
    @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());
    }

    Share the Knowledge

    Find this sample useful? Share on

    There's a lot more about JavaEE to cover. If you're ready to learn more, check out the other available samples.

    Help Improve

    Find a bug in the sample? Something missing? You can fix it by editing the source, making the correction and sending a pull request. Or report the problem to the issue tracker

    Recent Changelog

    • Dec 01, 2014: Added tests for jndi-context project by Roberto Cortez
    • Nov 02, 2014: Issue #253 - fix to make jaxws-endpoint compile against jdk 8 by Nico Schlebusch
    • Feb 10, 2014: Removed unnecessary files in jax-ws projects by Fermin Gallego
    • Feb 06, 2014: Jax-ws endpoint example by Fermin Gallego
    How to help improve this sample
    The source code for this sample can be found in the javaee7-samples GitHub repository. The first thing you need to do is to get the source by downloading the repository and then go into the samples folder:
    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!