Search in sources :

Example 1 with NoSuchCodeLitFault

use of org.apache.cxf.hello_world_jms.NoSuchCodeLitFault in project cxf by apache.

the class JMSClientServerTest method testBasicConnection.

@Test
public void testBasicConnection() throws Exception {
    QName serviceName = new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldService");
    QName portName = new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldPort");
    URL wsdl = getWSDLURL("/wsdl/jms_test.wsdl");
    HelloWorldService service = new HelloWorldService(wsdl, serviceName);
    String response1 = new String("Hello Milestone-");
    String response2 = new String("Bonjour");
    HelloWorldPortType greeter = service.getPort(portName, HelloWorldPortType.class);
    for (int idx = 0; idx < 5; idx++) {
        String greeting = greeter.greetMe("Milestone-" + idx);
        assertNotNull("no response received from service", greeting);
        String exResponse = response1 + idx;
        assertEquals(exResponse, greeting);
        String reply = greeter.sayHi();
        assertNotNull("no response received from service", reply);
        assertEquals(response2, reply);
        try {
            greeter.testRpcLitFault("BadRecordLitFault");
            fail("Should have thrown BadRecoedLitFault");
        } catch (BadRecordLitFault ex) {
            assertNotNull(ex.getFaultInfo());
        }
        try {
            greeter.testRpcLitFault("NoSuchCodeLitFault");
            fail("Should have thrown NoSuchCodeLitFault exception");
        } catch (NoSuchCodeLitFault nslf) {
            assertNotNull(nslf.getFaultInfo());
            assertNotNull(nslf.getFaultInfo().getCode());
        }
    }
    ((java.io.Closeable) greeter).close();
}
Also used : BadRecordLitFault(org.apache.cxf.hello_world_jms.BadRecordLitFault) QName(javax.xml.namespace.QName) NoSuchCodeLitFault(org.apache.cxf.hello_world_jms.NoSuchCodeLitFault) HelloWorldService(org.apache.cxf.hello_world_jms.HelloWorldService) Closeable(java.io.Closeable) HelloWorldPortType(org.apache.cxf.hello_world_jms.HelloWorldPortType) URL(java.net.URL) Endpoint(javax.xml.ws.Endpoint) Test(org.junit.Test)

Example 2 with NoSuchCodeLitFault

use of org.apache.cxf.hello_world_jms.NoSuchCodeLitFault in project cxf by apache.

the class JMSClientServerTest method testConnectionsWithinSpring.

@Test
public void testConnectionsWithinSpring() throws Exception {
    BusFactory.setDefaultBus(null);
    BusFactory.setThreadDefaultBus(null);
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(new String[] { "/org/apache/cxf/systest/jms/JMSClients.xml" });
    try {
        String wsdlString2 = "classpath:wsdl/jms_test.wsdl";
        wsdlStrings.add(wsdlString2);
        broker.updateWsdl((Bus) ctx.getBean("cxf"), wsdlString2);
        HelloWorldPortType greeter = (HelloWorldPortType) ctx.getBean("jmsRPCClient");
        try {
            for (int idx = 0; idx < 5; idx++) {
                String greeting = greeter.greetMe("Milestone-" + idx);
                assertNotNull("no response received from service", greeting);
                String exResponse = "Hello Milestone-" + idx;
                assertEquals(exResponse, greeting);
                String reply = greeter.sayHi();
                assertEquals("Bonjour", reply);
                try {
                    greeter.testRpcLitFault("BadRecordLitFault");
                    fail("Should have thrown BadRecoedLitFault");
                } catch (BadRecordLitFault ex) {
                    assertNotNull(ex.getFaultInfo());
                }
                try {
                    greeter.testRpcLitFault("NoSuchCodeLitFault");
                    fail("Should have thrown NoSuchCodeLitFault exception");
                } catch (NoSuchCodeLitFault nslf) {
                    assertNotNull(nslf.getFaultInfo());
                    assertNotNull(nslf.getFaultInfo().getCode());
                }
            }
        } catch (UndeclaredThrowableException ex) {
            ctx.close();
            throw (Exception) ex.getCause();
        }
        HelloWorldOneWayPort greeter1 = (HelloWorldOneWayPort) ctx.getBean("jmsQueueOneWayServiceClient");
        assertNotNull(greeter1);
        try {
            greeter1.greetMeOneWay("hello");
        } catch (Exception ex) {
            fail("There should not throw the exception" + ex);
        }
    } finally {
        ctx.close();
        BusFactory.setDefaultBus(getBus());
        BusFactory.setThreadDefaultBus(getBus());
    }
}
Also used : BadRecordLitFault(org.apache.cxf.hello_world_jms.BadRecordLitFault) HelloWorldOneWayPort(org.apache.cxf.hello_world_jms.HelloWorldOneWayPort) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) NoSuchCodeLitFault(org.apache.cxf.hello_world_jms.NoSuchCodeLitFault) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) HelloWorldPortType(org.apache.cxf.hello_world_jms.HelloWorldPortType) Endpoint(javax.xml.ws.Endpoint) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) ExecutionException(java.util.concurrent.ExecutionException) Test(org.junit.Test)

Example 3 with NoSuchCodeLitFault

use of org.apache.cxf.hello_world_jms.NoSuchCodeLitFault in project cxf by apache.

the class TwoWayJMSImplBase method testRpcLitFault.

public TestRpcLitFaultResponse testRpcLitFault(String faultType) throws BadRecordLitFault, NoSuchCodeLitFault {
    BadRecordLit badRecord = new BadRecordLit();
    badRecord.setReason("BadRecordLitFault");
    if (faultType.equals(BadRecordLitFault.class.getSimpleName())) {
        throw new BadRecordLitFault("TestBadRecordLit", badRecord);
    }
    if (faultType.equals(NoSuchCodeLitFault.class.getSimpleName())) {
        ErrorCode ec = new ErrorCode();
        ec.setMajor((short) 1);
        ec.setMinor((short) 1);
        NoSuchCodeLit nscl = new NoSuchCodeLit();
        nscl.setCode(ec);
        throw new NoSuchCodeLitFault("TestNoSuchCodeLit", nscl);
    }
    return new TestRpcLitFaultResponse();
}
Also used : TestRpcLitFaultResponse(org.apache.cxf.hello_world_jms.types.TestRpcLitFaultResponse) BadRecordLitFault(org.apache.cxf.hello_world_jms.BadRecordLitFault) NoSuchCodeLit(org.apache.cxf.hello_world_jms.types.NoSuchCodeLit) NoSuchCodeLitFault(org.apache.cxf.hello_world_jms.NoSuchCodeLitFault) ErrorCode(org.apache.cxf.hello_world_jms.types.ErrorCode) BadRecordLit(org.apache.cxf.hello_world_jms.types.BadRecordLit)

Example 4 with NoSuchCodeLitFault

use of org.apache.cxf.hello_world_jms.NoSuchCodeLitFault in project cxf by apache.

the class TwoWayJMSImplBase method testRpcLitFault.

public TestRpcLitFaultResponse testRpcLitFault(String faultType) throws BadRecordLitFault, NoSuchCodeLitFault {
    BadRecordLit badRecord = new BadRecordLit();
    badRecord.setReason("BadRecordLitFault");
    if (faultType.equals(BadRecordLitFault.class.getSimpleName())) {
        throw new BadRecordLitFault("TestBadRecordLit", badRecord);
    }
    if (faultType.equals(NoSuchCodeLitFault.class.getSimpleName())) {
        ErrorCode ec = new ErrorCode();
        ec.setMajor((short) 1);
        ec.setMinor((short) 1);
        NoSuchCodeLit nscl = new NoSuchCodeLit();
        nscl.setCode(ec);
        throw new NoSuchCodeLitFault("TestNoSuchCodeLit", nscl);
    }
    return new TestRpcLitFaultResponse();
}
Also used : TestRpcLitFaultResponse(org.apache.cxf.hello_world_jms.types.TestRpcLitFaultResponse) BadRecordLitFault(org.apache.cxf.hello_world_jms.BadRecordLitFault) NoSuchCodeLit(org.apache.cxf.hello_world_jms.types.NoSuchCodeLit) NoSuchCodeLitFault(org.apache.cxf.hello_world_jms.NoSuchCodeLitFault) ErrorCode(org.apache.cxf.hello_world_jms.types.ErrorCode) BadRecordLit(org.apache.cxf.hello_world_jms.types.BadRecordLit)

Aggregations

BadRecordLitFault (org.apache.cxf.hello_world_jms.BadRecordLitFault)4 NoSuchCodeLitFault (org.apache.cxf.hello_world_jms.NoSuchCodeLitFault)4 Endpoint (javax.xml.ws.Endpoint)2 HelloWorldPortType (org.apache.cxf.hello_world_jms.HelloWorldPortType)2 BadRecordLit (org.apache.cxf.hello_world_jms.types.BadRecordLit)2 ErrorCode (org.apache.cxf.hello_world_jms.types.ErrorCode)2 NoSuchCodeLit (org.apache.cxf.hello_world_jms.types.NoSuchCodeLit)2 TestRpcLitFaultResponse (org.apache.cxf.hello_world_jms.types.TestRpcLitFaultResponse)2 Test (org.junit.Test)2 Closeable (java.io.Closeable)1 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)1 URL (java.net.URL)1 ExecutionException (java.util.concurrent.ExecutionException)1 QName (javax.xml.namespace.QName)1 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)1 HelloWorldOneWayPort (org.apache.cxf.hello_world_jms.HelloWorldOneWayPort)1 HelloWorldService (org.apache.cxf.hello_world_jms.HelloWorldService)1 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)1