use of org.apache.hello_world_soap_http.GreeterImpl 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.hello_world_soap_http.GreeterImpl 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.hello_world_soap_http.GreeterImpl in project cxf by apache.
the class ConfiguredEndpointTest method doTestDefaultServerEndpoint.
private void doTestDefaultServerEndpoint() {
Object implementor = new GreeterImpl();
EndpointImpl ei = (EndpointImpl) (javax.xml.ws.Endpoint.create(implementor));
ei.publish("http://localhost/greeter");
JaxWsEndpointImpl endpoint = (JaxWsEndpointImpl) ei.getEndpoint();
assertEquals("Unexpected bean name", PORT_NAME.toString() + ".endpoint", endpoint.getBeanName());
assertFalse("Unexpected value for property validating", Boolean.TRUE.equals(endpoint.get(Message.SCHEMA_VALIDATION_ENABLED)));
List<Interceptor<? extends Message>> interceptors = endpoint.getInInterceptors();
assertNull("Unexpected test interceptor", findTestInterceptor(interceptors));
interceptors = endpoint.getOutInterceptors();
assertNull("Unexpected test interceptor", findTestInterceptor(interceptors));
interceptors = endpoint.getInFaultInterceptors();
assertNull("Unexpected test interceptor", findTestInterceptor(interceptors));
interceptors = endpoint.getOutFaultInterceptors();
assertNull("Unexpected test interceptor", findTestInterceptor(interceptors));
org.apache.cxf.service.ServiceImpl svc = (org.apache.cxf.service.ServiceImpl) endpoint.getService();
assertEquals("Unexpected bean name", SERVICE_NAME.toString(), svc.getBeanName());
interceptors = svc.getInInterceptors();
assertNull("Unexpected test interceptor", findTestInterceptor(interceptors));
interceptors = svc.getOutInterceptors();
assertNull("Unexpected test interceptor", findTestInterceptor(interceptors));
interceptors = svc.getInFaultInterceptors();
assertNull("Unexpected test interceptor", findTestInterceptor(interceptors));
interceptors = svc.getOutFaultInterceptors();
assertNull("Unexpected test interceptor", findTestInterceptor(interceptors));
}
use of org.apache.hello_world_soap_http.GreeterImpl in project cxf by apache.
the class ConfiguredEndpointTest method doTestConfiguredServerEndpoint.
private void doTestConfiguredServerEndpoint(Object expectedValidionValue, String configFile) {
SpringBusFactory sf = new SpringBusFactory();
factory = sf;
BusFactory.setDefaultBus(null);
BusFactory.setDefaultBus(sf.createBus(configFile));
initializeBus();
System.setProperty(BusFactory.BUS_FACTORY_PROPERTY_NAME, SpringBusFactory.class.getName());
Object implementor = new GreeterImpl();
EndpointImpl ei = (EndpointImpl) (javax.xml.ws.Endpoint.create(implementor));
ei.publish("http://localhost/greeter");
JaxWsEndpointImpl endpoint = (JaxWsEndpointImpl) ei.getEndpoint();
assertEquals("Unexpected bean name", PORT_NAME.toString() + ".endpoint", endpoint.getBeanName());
assertEquals("Unexpected value for property validating", expectedValidionValue, ei.getProperties().get(Message.SCHEMA_VALIDATION_ENABLED));
List<Interceptor<? extends Message>> interceptors = endpoint.getInInterceptors();
assertEquals("Unexpected number of interceptors.", 5, interceptors.size());
assertEquals("Unexpected interceptor id.", "endpoint-in", findTestInterceptor(interceptors).getId());
interceptors = endpoint.getOutInterceptors();
assertEquals("Unexpected number of interceptors.", 5, interceptors.size());
assertEquals("Unexpected interceptor id.", "endpoint-out", findTestInterceptor(interceptors).getId());
interceptors = endpoint.getInFaultInterceptors();
assertEquals("Unexpected number of interceptors.", 2, interceptors.size());
assertEquals("Unexpected interceptor id.", "endpoint-in-fault", findTestInterceptor(interceptors).getId());
interceptors = endpoint.getOutFaultInterceptors();
assertEquals("Unexpected number of interceptors.", 2, interceptors.size());
assertEquals("Unexpected interceptor id.", "endpoint-out-fault", findTestInterceptor(interceptors).getId());
org.apache.cxf.service.ServiceImpl svc = (org.apache.cxf.service.ServiceImpl) endpoint.getService();
assertEquals("Unexpected bean name.", SERVICE_NAME.toString(), svc.getBeanName());
interceptors = svc.getInInterceptors();
assertEquals("Unexpected number of interceptors.", 1, interceptors.size());
assertEquals("Unexpected interceptor id.", "service-in", findTestInterceptor(interceptors).getId());
interceptors = svc.getOutInterceptors();
assertEquals("Unexpected number of interceptors.", 1, interceptors.size());
assertEquals("Unexpected interceptor id.", "service-out", findTestInterceptor(interceptors).getId());
interceptors = svc.getInFaultInterceptors();
assertEquals("Unexpected number of interceptors.", 1, interceptors.size());
assertEquals("Unexpected interceptor id.", "service-in-fault", findTestInterceptor(interceptors).getId());
interceptors = svc.getOutFaultInterceptors();
assertEquals("Unexpected number of interceptors.", 1, interceptors.size());
assertEquals("Unexpected interceptor id.", "service-out-fault", findTestInterceptor(interceptors).getId());
}
use of org.apache.hello_world_soap_http.GreeterImpl in project cxf by apache.
the class EndpointReferenceTest method testEndpointGetEndpointReferenceSOAPBinding.
@Test
public void testEndpointGetEndpointReferenceSOAPBinding() throws Exception {
GreeterImpl greeter = new GreeterImpl();
try (EndpointImpl endpoint = new EndpointImpl(getBus(), greeter, (String) null)) {
endpoint.publish("http://localhost:8080/test");
InputStream is = getClass().getResourceAsStream("resources/hello_world_soap_http_infoset.xml");
Document doc = StaxUtils.read(is);
Element referenceParameters = fetchElementByNameAttribute(doc.getDocumentElement(), "wsa:ReferenceParameters", "");
EndpointReference endpointReference = endpoint.getEndpointReference(referenceParameters);
assertNotNull(endpointReference);
assertTrue(endpointReference instanceof W3CEndpointReference);
// A returned W3CEndpointReferenceMUST also contain the specified referenceParameters.
// W3CEndpointReference wer = (W3CEndpointReference)endpointReference;
endpoint.stop();
}
}
Aggregations