Search in sources :

Example 21 with BusException

use of org.apache.cxf.BusException in project cxf by apache.

the class EndpointImplTest method testEndpointStop.

@Test
public void testEndpointStop() throws Exception {
    String address = "http://localhost:8080/test";
    GreeterImpl greeter = new GreeterImpl();
    try (EndpointImpl endpoint = new EndpointImpl(getBus(), greeter, (String) null)) {
        WebServiceContext ctx = greeter.getContext();
        assertNull(ctx);
        try {
            endpoint.publish(address);
        } catch (IllegalArgumentException ex) {
            assertTrue(ex.getCause() instanceof BusException);
            assertEquals("BINDING_INCOMPATIBLE_ADDRESS_EXC", ((BusException) ex.getCause()).getCode());
        }
        ctx = greeter.getContext();
        assertNotNull(ctx);
        // Test that calling stop on the Endpoint works
        assertTrue(endpoint.isPublished());
        endpoint.stop();
        assertFalse(endpoint.isPublished());
        // Test that the Endpoint cannot be restarted.
        try {
            endpoint.publish(address);
            fail("stopped endpoint restarted.");
        } catch (IllegalStateException e) {
        // expected.
        }
    }
}
Also used : GreeterImpl(org.apache.hello_world_soap_http.GreeterImpl) WebServiceContext(javax.xml.ws.WebServiceContext) BusException(org.apache.cxf.BusException) Test(org.junit.Test)

Example 22 with BusException

use of org.apache.cxf.BusException in project cxf by apache.

the class EndpointImplTest method testAddWSAFeature.

@Test
public void testAddWSAFeature() throws Exception {
    GreeterImpl greeter = new GreeterImpl();
    JaxWsServiceFactoryBean serviceFactory = new JaxWsServiceFactoryBean();
    serviceFactory.setBus(getBus());
    serviceFactory.setInvoker(new BeanInvoker(greeter));
    serviceFactory.setServiceClass(GreeterImpl.class);
    try (EndpointImpl endpoint = new EndpointImpl(getBus(), greeter, new JaxWsServerFactoryBean(serviceFactory))) {
        endpoint.getFeatures().add(new WSAddressingFeature());
        try {
            String address = "http://localhost:8080/test";
            endpoint.publish(address);
        } catch (IllegalArgumentException ex) {
            assertTrue(ex.getCause() instanceof BusException);
            assertEquals("BINDING_INCOMPATIBLE_ADDRESS_EXC", ((BusException) ex.getCause()).getCode());
        }
        assertTrue(serviceFactory.getFeatures().size() == 1);
        assertTrue(serviceFactory.getFeatures().get(0) instanceof WSAddressingFeature);
    }
}
Also used : JaxWsServiceFactoryBean(org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean) WSAddressingFeature(org.apache.cxf.ws.addressing.WSAddressingFeature) BeanInvoker(org.apache.cxf.service.invoker.BeanInvoker) GreeterImpl(org.apache.hello_world_soap_http.GreeterImpl) BusException(org.apache.cxf.BusException) Test(org.junit.Test)

Example 23 with BusException

use of org.apache.cxf.BusException in project cxf by apache.

the class EndpointImplTest method testWSAnnoWithoutWSDLLocationInSEI.

@Test
public void testWSAnnoWithoutWSDLLocationInSEI() throws Exception {
    HelloImpl hello = new HelloImpl();
    JaxWsServiceFactoryBean serviceFactory = new JaxWsServiceFactoryBean();
    serviceFactory.setBus(getBus());
    serviceFactory.setInvoker(new BeanInvoker(hello));
    serviceFactory.setServiceClass(HelloImpl.class);
    try (EndpointImpl endpoint = new EndpointImpl(getBus(), hello, new JaxWsServerFactoryBean(serviceFactory))) {
        try {
            String address = "http://localhost:8080/test";
            endpoint.publish(address);
        } catch (IllegalArgumentException ex) {
            assertTrue(ex.getCause() instanceof BusException);
            assertEquals("BINDING_INCOMPATIBLE_ADDRESS_EXC", ((BusException) ex.getCause()).getCode());
        }
    }
}
Also used : HelloImpl(org.apache.hello_world_soap_http.HelloImpl) JaxWsServiceFactoryBean(org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean) BeanInvoker(org.apache.cxf.service.invoker.BeanInvoker) BusException(org.apache.cxf.BusException) Test(org.junit.Test)

Example 24 with BusException

use of org.apache.cxf.BusException in project cxf by apache.

the class EndpointImplTest method testJaxWsaFeature.

@Test
public void testJaxWsaFeature() throws Exception {
    HelloWsa greeter = new HelloWsa();
    JaxWsServiceFactoryBean serviceFactory = new JaxWsServiceFactoryBean();
    serviceFactory.setBus(getBus());
    serviceFactory.setInvoker(new BeanInvoker(greeter));
    serviceFactory.setServiceClass(HelloWsa.class);
    try (EndpointImpl endpoint = new EndpointImpl(getBus(), greeter, new JaxWsServerFactoryBean(serviceFactory))) {
        try {
            String address = "http://localhost:8080/test";
            endpoint.publish(address);
        } catch (IllegalArgumentException ex) {
            assertTrue(ex.getCause() instanceof BusException);
            assertEquals("BINDING_INCOMPATIBLE_ADDRESS_EXC", ((BusException) ex.getCause()).getCode());
        }
        assertEquals(1, serviceFactory.getFeatures().size());
        assertTrue(serviceFactory.getFeatures().get(0) instanceof WSAddressingFeature);
    }
}
Also used : JaxWsServiceFactoryBean(org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean) WSAddressingFeature(org.apache.cxf.ws.addressing.WSAddressingFeature) BeanInvoker(org.apache.cxf.service.invoker.BeanInvoker) BusException(org.apache.cxf.BusException) Test(org.junit.Test)

Example 25 with BusException

use of org.apache.cxf.BusException in project cxf by apache.

the class EndpointImplTest method testEndpoint.

@Test
public void testEndpoint() throws Exception {
    String address = "http://localhost:8080/test";
    GreeterImpl greeter = new GreeterImpl();
    try (EndpointImpl endpoint = new EndpointImpl(getBus(), greeter, (String) null)) {
        WebServiceContext ctx = greeter.getContext();
        assertNull(ctx);
        try {
            endpoint.publish(address);
        } catch (IllegalArgumentException ex) {
            assertTrue(ex.getCause() instanceof BusException);
            assertEquals("BINDING_INCOMPATIBLE_ADDRESS_EXC", ((BusException) ex.getCause()).getCode());
        }
        ctx = greeter.getContext();
        assertNotNull(ctx);
        try {
            endpoint.publish(address);
            fail("republished an already published endpoint.");
        } catch (IllegalStateException e) {
        // expected
        }
        try {
            endpoint.setMetadata(new ArrayList<Source>(0));
            fail("set metadata on an already published endpoint.");
        } catch (IllegalStateException e) {
        // expected
        }
    }
}
Also used : GreeterImpl(org.apache.hello_world_soap_http.GreeterImpl) WebServiceContext(javax.xml.ws.WebServiceContext) BusException(org.apache.cxf.BusException) Source(javax.xml.transform.Source) Test(org.junit.Test)

Aggregations

BusException (org.apache.cxf.BusException)28 DestinationFactoryManager (org.apache.cxf.transport.DestinationFactoryManager)7 Test (org.junit.Test)7 IOException (java.io.IOException)6 BindingFactoryManager (org.apache.cxf.binding.BindingFactoryManager)6 EndpointException (org.apache.cxf.endpoint.EndpointException)6 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)6 JaxWsServiceFactoryBean (org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean)5 BindingInfo (org.apache.cxf.service.model.BindingInfo)5 Bus (org.apache.cxf.Bus)4 Message (org.apache.cxf.common.i18n.Message)4 ServiceConstructionException (org.apache.cxf.service.factory.ServiceConstructionException)4 BeanInvoker (org.apache.cxf.service.invoker.BeanInvoker)4 ConduitInitiatorManager (org.apache.cxf.transport.ConduitInitiatorManager)4 DestinationFactory (org.apache.cxf.transport.DestinationFactory)4 WebServiceContext (javax.xml.ws.WebServiceContext)3 BindingFactory (org.apache.cxf.binding.BindingFactory)3 ClassLoaderHolder (org.apache.cxf.common.classloader.ClassLoaderUtils.ClassLoaderHolder)3 Endpoint (org.apache.cxf.endpoint.Endpoint)3 GreeterImpl (org.apache.hello_world_soap_http.GreeterImpl)3