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.
}
}
}
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);
}
}
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());
}
}
}
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);
}
}
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
}
}
}
Aggregations