Package com.example.customerservice

Examples of com.example.customerservice.CustomerService


public class CustomerServiceServer {

    protected CustomerServiceServer() throws Exception {
        System.out.println("Starting Server");
        CustomerService implementor = new CustomerServiceImpl();
        EndpointImpl ep = (EndpointImpl)Endpoint.publish("http://localhost:9090/CustomerServicePort",
                                                         implementor);

        // Adding logging for incoming and outgoing messages
        ep.getServer().getEndpoint().getInInterceptors().add(new LoggingInInterceptor());
View Full Code Here


    }
   
    public static void main(String args[]) throws NoSuchCustomerException {
        // Create the service client with its default wsdlurl
        CustomerServiceService customerServiceService = new CustomerServiceService();
        CustomerService customerService = customerServiceService.getCustomerServicePort();
       
        // Initialize the test class and call the tests
        CustomerServiceTester client = new CustomerServiceTester();
        client.setCustomerService(customerService);
        client.testCustomerService();
View Full Code Here

    private void run() {
        JaxWsProxyFactoryBean factoryBean = new JaxWsProxyFactoryBean();
        factoryBean.setAddress(address);
        factoryBean.setServiceClass(CustomerService.class);
        CustomerService customerService = factoryBean.create(CustomerService.class);

        // Anonymous should not be able to read customers
        try {
            List<Customer> customersByName = customerService.getCustomersByName("Fred");
            customersByName.get(0);
            Assert.fail("Anonymous should not be allowed to read customers");
        } catch (Exception e) {
            logger.info("Anonymous request was correctly denied. " + getMessage(e));
        }

        // Alex should not be able to read customers
        CredentialsInjector.inject(customerService, "alex", "alexspassword");
        try {
            customerService.getCustomersByName("Test");
            Assert.fail("Alex should not be allowed to read customers");
        } catch (Exception e) {
            logger.info("Alex's request was correctly denied. " + getMessage(e));
        }

        // Bob should be able to read customers but not to update
        CredentialsInjector.inject(customerService, "bob", "bobspassword");
        try {
            List<Customer> customersByName = customerService.getCustomersByName("Fred");
            Customer customer = customersByName.get(0);
            logger.info("Bob was able to load the customer " + customer.getName());
        } catch (Exception e) {
            Assert.fail("Bob should be allowed to read customers");
        }
        CredentialsInjector.inject(customerService, "bob", "bobspassword");
        try {
            Customer customer = new Customer();
            customer.setName("Fred");
            customerService.updateCustomer(customer);
            Assert.fail("Bob should not be allowed to update a customer");
        } catch (Exception e) {
            logger.info("Bob's request was correctly denied. " + getMessage(e));
        }

        // Jim should be able to read and update customers
        CredentialsInjector.inject(customerService, "jim", "jimspassword");
        try {
            List<Customer> customersByName = customerService.getCustomersByName("Fred");
            Customer customer = customersByName.get(0);
            logger.info("Jim was able to load the customer " + customer.getName());
        } catch (Exception e) {
            Assert.fail("Jim should be allowed to read customers");
        }
        CredentialsInjector.inject(customerService, "jim", "jimspassword");
        try {
            Customer customer = new Customer();
            customer.setName("Fred");
            customerService.updateCustomer(customer);
            logger.info("Jim was able to update the customer");
        } catch (Exception e) {
            Assert.fail("Jim should be allowed to update a customer");
        }
        logger.info("All request were processed as expected");
View Full Code Here

        } else {
            // Create the service client with its default wsdlurl
            customerServiceService = new CustomerServiceService();
        }

        CustomerService customerService = customerServiceService.getCustomerServicePort();
       
        // Initialize the test class and call the tests
        CustomerServiceTester client = new CustomerServiceTester();
        client.setCustomerService(customerService);
        client.testCustomerService();
View Full Code Here

public class CustomerServiceServer {

    protected CustomerServiceServer() throws Exception {
        System.out.println("Starting Server");
        CustomerService implementor = new CustomerServiceImpl();
        EndpointImpl ep = (EndpointImpl)Endpoint.publish("http://localhost:9090/CustomerServicePort",
                                                         implementor);

        // Adding logging for incoming and outgoing messages
        ep.getServer().getEndpoint().getInInterceptors().add(new LoggingInInterceptor());
View Full Code Here

        } else {
            // Create the service client with its default wsdlurl
            customerServiceService = new CustomerServiceService();
        }

        CustomerService customerService = customerServiceService.getCustomerServicePort();
       
        // Initialize the test class and call the tests
        CustomerServiceTester client = new CustomerServiceTester();
        client.setCustomerService(customerService);
        client.testCustomerService();
View Full Code Here

TOP

Related Classes of com.example.customerservice.CustomerService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.