Package org.apache.cxf.greeter_control

Examples of org.apache.cxf.greeter_control.Greeter


                   launchServer(Server11.class, true));
    }
   
    @Test
    public void testFaultMessage() throws Exception {
        Greeter greeter = getGreeter();
        try {
            greeter.sayHi();
            fail("Should throw Exception!");
        } catch (SOAPFaultException ex) {
            assertEquals("sayHiFault Caused by: Get a wrong name <sayHi>", ex.getMessage());
            StackTraceElement[] elements = ex.getCause().getStackTrace();
            assertEquals("org.apache.cxf.systest.soapfault.details.GreeterImpl11",
                         elements[0].getClassName());
        }
       
        // testing Fault(new NullPointerException())
        try {
            greeter.greetMe("Anya");
            fail("Should throw Exception!");
        } catch (SOAPFaultException ex) {
            assertEquals(NullPointerException.class.getName(), ex.getMessage());
        }

        // testing Fault(new IllegalArgumentException("Get a wrong name for greetMe"))
        try {
            greeter.greetMe("Banya");
            fail("Should throw Exception!");
        } catch (SOAPFaultException ex) {
            assertEquals("Get a wrong name for greetMe", ex.getMessage());
        }

        // testing Fault("unexpected null", LOG, new NullPointerException())       
        try {
            greeter.greetMe("Canya");
            fail("Should throw Exception!");
        } catch (SOAPFaultException ex) {
            assertEquals("unexpected null", ex.getMessage());
        }

        // testing Fault("greetMeFault", LOG, new IllegalArgumentException("Get a wrong name greetMe"))
        try {
            greeter.greetMe("Danya");
            fail("Should throw Exception!");
        } catch (SOAPFaultException ex) {
            assertEquals("greetMeFault Caused by: Get a wrong name greetMe", ex.getMessage());
        }

        // testing Fault("invalid", LOG)       
        try {
            greeter.greetMe("Eanna");
            fail("Should throw Exception!");
        } catch (SOAPFaultException ex) {
            assertEquals("invalid", ex.getMessage());
        }
    }
View Full Code Here


    }
   
   
    @Test
    public void testNewLineInExceptionMessage() throws Exception {
        Greeter greeter = getGreeter();
       
        try {
            greeter.greetMe("newline");
            fail("Should throw Exception!");
        } catch (SOAPFaultException ex) {
            assertEquals("greetMeFault Caused by: Get a wrong name <greetMe>", ex.getMessage());
            StackTraceElement[] elements = ex.getCause().getStackTrace();
            assertEquals("org.apache.cxf.systest.soapfault.details.GreeterImpl11",
View Full Code Here

    }


    @Test
    public void testPingMeFault() throws Exception {
        Greeter greeter = getGreeter();
        try {
            greeter.pingMe();
            fail("Should throw Exception!");
        } catch (PingMeFault ex) {
            FaultDetail detail = ex.getFaultInfo();
            assertEquals((short)2, detail.getMajor());
            assertEquals((short)1, detail.getMinor());
View Full Code Here

   
    private Greeter getGreeter() throws NumberFormatException, MalformedURLException {
        GreeterService service = new GreeterService();
        assertNotNull(service);
        Greeter greeter = service.getGreeterPort();
        updateAddressPort(greeter, PORT);
        return greeter;
    }
View Full Code Here

        GreeterService service = new GreeterService();
        assertNotNull(service);

        try {
            Greeter greeter = service.getGreeterPort();
            ((BindingProvider)greeter).getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY,
                                                                   true);
            String greeting = greeter.greetMe("Bonjour");
           
            assertNotNull("no response received from service", greeting);
            assertEquals("Hello Bonjour", greeting);
           
            greeting = greeter.greetMe("Hello");
            assertNotNull("no response received from service", greeting);
            assertEquals("Hello Bonjour", greeting);
           
           
            greeting = greeter.greetMe("NiHao");
            assertNotNull("no response received from service", greeting);
            assertEquals("Hello Hello", greeting);

        } catch (UndeclaredThrowableException ex) {
            throw (Exception)ex.getCause();
View Full Code Here

        GreeterService service = new GreeterService();
        assertNotNull(service);

        try {
            Greeter greeter = service.getGreeterPort();

            String greeting = greeter.greetMe("Bonjour");
           
            assertNotNull("no response received from service", greeting);
            assertEquals("Hello Bonjour", greeting);
           
            greeting = greeter.greetMe("Hello");
            assertNotNull("no response received from service", greeting);
            assertEquals("Hello Hello", greeting);
           
           
            greeting = greeter.greetMe("NiHao");
            assertNotNull("no response received from service", greeting);
            assertEquals("Hello NiHao", greeting);

        } catch (UndeclaredThrowableException ex) {
            throw (Exception)ex.getCause();
View Full Code Here

        LoggingOutInterceptor out = new LoggingOutInterceptor();
        bus.getOutInterceptors().add(out);
        bus.getOutFaultInterceptors().add(out);
       
        GreeterService gs = new GreeterService();
        final Greeter greeter = gs.getGreeterPort();
        updateAddressPort(greeter, PORT);
        ((BindingProvider)greeter).getRequestContext().put("schema-validation-enabled",
                                                           shouldValidate());
        LOG.fine("Created greeter client.");
      
        ConnectionHelper.setKeepAliveConnection(greeter, true);

        class TwowayThread extends Thread {

            String response;
           
            @Override
            public void run() {
                response = greeter.greetMe("twoway");
            }
  
        }
       
        TwowayThread t = new TwowayThread();   
        t.start();
       
        // allow for partial response to twoway request to arrive
       
        long wait = 3000;
        while (wait > 0) {
            long start = System.currentTimeMillis();
            try {
                Thread.sleep(wait);
            } catch (InterruptedException ex) {
                // ignore
            }
            wait -= System.currentTimeMillis() - start;
        }

        greeter.greetMeOneWay("oneway");
       
        t.join();
        assertEquals("Unexpected response to twoway request", "oneway", t.response);
       
    }
View Full Code Here

        LoggingOutInterceptor out = new LoggingOutInterceptor();
        bus.getOutInterceptors().add(out);
        bus.getOutFaultInterceptors().add(out);
       
        BasicGreeterService gs = new BasicGreeterService();
        final Greeter greeter = gs.getGreeterPort();
        updateAddressPort(greeter, PORT);
        LOG.fine("Created greeter client.");    
        ConnectionHelper.setKeepAliveConnection(greeter, true);

        // oneway

        greeter.greetMeOneWay("CXF");

        // two-way

        assertEquals("CXF", greeter.greetMe("cxf"));
    
        // exception

        try {
            greeter.pingMe();
        } catch (PingMeFault ex) {
            fail("First invocation should have succeeded.");
        }
      
        try {
            greeter.pingMe();
            fail("Expected PingMeFault not thrown.");
        } catch (PingMeFault ex) {
            assertEquals(2, ex.getFaultInfo().getMajor());
            assertEquals(1, ex.getFaultInfo().getMinor());
        }
View Full Code Here

        bus = bf.createBus("org/apache/cxf/systest/ws/policy/addr-inline-policy-old.xml");
       
        BusFactory.setDefaultBus(bus);
       
        BasicGreeterService gs = new BasicGreeterService();
        final Greeter greeter = gs.getGreeterPort();
        updateAddressPort(greeter, PORT);
        LOG.fine("Created greeter client.");

        ConnectionHelper.setKeepAliveConnection(greeter, true);

        testInterceptors(bus);
       
        // oneway
       
        greeter.greetMeOneWay("CXF");

        // two-way

        assertEquals("CXF", greeter.greetMe("cxf"));
    
        // exception

        try {
            greeter.pingMe();
        } catch (PingMeFault ex) {
            fail("First invocation should have succeeded.");
        }
      
        try {
            greeter.pingMe();
            fail("Expected PingMeFault not thrown.");
        } catch (PingMeFault ex) {
            assertEquals(2, ex.getFaultInfo().getMajor());
            assertEquals(1, ex.getFaultInfo().getMinor());
        }
View Full Code Here

        bus.getOutInterceptors().add(outRecorder);
        InMessageRecorder inRecorder = new InMessageRecorder();
        bus.getInInterceptors().add(inRecorder);
       
        ReliableGreeterService gs = new ReliableGreeterService();
        final Greeter greeter = gs.getGreeterPort();
        updateAddressPort(greeter, PORT);
        LOG.fine("Created greeter client.");

        ConnectionHelper.setKeepAliveConnection(greeter, true);

        // oneway

        greeter.greetMeOneWay("CXF");

        // two-way

        assertEquals("CXF", greeter.greetMe("cxf"));
    
        // exception

        try {
            greeter.pingMe();
        } catch (PingMeFault ex) {
            fail("First invocation should have succeeded.");
        }
      
        try {
            greeter.pingMe();
            fail("Expected PingMeFault not thrown.");
        } catch (PingMeFault ex) {
            assertEquals(2, ex.getFaultInfo().getMajor());
            assertEquals(1, ex.getFaultInfo().getMinor());
        }
View Full Code Here

TOP

Related Classes of org.apache.cxf.greeter_control.Greeter

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.