use of org.apache.hello_world_soap_http.SOAPService in project cxf by apache.
the class UndertowBasicAuthTest method setUp.
@Before
public void setUp() throws Exception {
URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
greeter = new SOAPService(wsdl, SERVICE_NAME).getPort(Greeter.class);
BindingProvider bp = (BindingProvider) greeter;
ClientProxy.getClient(greeter).getInInterceptors().add(new LoggingInInterceptor());
ClientProxy.getClient(greeter).getOutInterceptors().add(new LoggingOutInterceptor());
bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, ADDRESS);
bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "ffang");
bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "pswd");
greeter1 = new SOAPService(wsdl, SERVICE_NAME).getPort(Greeter.class);
bp = (BindingProvider) greeter1;
ClientProxy.getClient(greeter1).getInInterceptors().add(new LoggingInInterceptor());
ClientProxy.getClient(greeter1).getOutInterceptors().add(new LoggingOutInterceptor());
bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, ADDRESS1);
bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "ffang");
bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "pswd");
}
use of org.apache.hello_world_soap_http.SOAPService in project cxf by apache.
the class UndertowDigestAuthTest method setupClient.
private HTTPConduit setupClient(boolean async) throws Exception {
URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
greeter = new SOAPService(wsdl, SERVICE_NAME).getPort(Greeter.class);
BindingProvider bp = (BindingProvider) greeter;
ClientProxy.getClient(greeter).getInInterceptors().add(new LoggingInInterceptor());
ClientProxy.getClient(greeter).getOutInterceptors().add(new LoggingOutInterceptor());
bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, ADDRESS);
HTTPConduit cond = (HTTPConduit) ClientProxy.getClient(greeter).getConduit();
HTTPClientPolicy client = new HTTPClientPolicy();
client.setConnectionTimeout(600000);
client.setReceiveTimeout(600000);
cond.setClient(client);
if (async) {
if (cond instanceof AsyncHTTPConduit) {
UsernamePasswordCredentials creds = new UsernamePasswordCredentials("ffang", "pswd");
bp.getRequestContext().put(Credentials.class.getName(), creds);
bp.getRequestContext().put(AsyncHTTPConduit.USE_ASYNC, Boolean.TRUE);
client.setAutoRedirect(true);
} else {
fail("Not an async conduit");
}
} else {
bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "ffang");
bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "pswd");
cond.setAuthSupplier(new DigestAuthSupplier());
}
ClientProxy.getClient(greeter).getOutInterceptors().add(new AbstractPhaseInterceptor<Message>(Phase.PRE_STREAM_ENDING) {
public void handleMessage(Message message) throws Fault {
Map<String, ?> headers = CastUtils.cast((Map<?, ?>) message.get(Message.PROTOCOL_HEADERS));
if (headers.containsKey("Proxy-Authorization")) {
throw new RuntimeException("Should not have Proxy-Authorization");
}
}
});
client.setAllowChunking(false);
return cond;
}
use of org.apache.hello_world_soap_http.SOAPService in project cxf by apache.
the class OutBoundConnectionTest method testBasicConnection.
@Test
@org.junit.Ignore
public void testBasicConnection() throws Exception {
URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
assertNotNull(wsdl);
SOAPService service = new SOAPService(wsdl, serviceName);
assertNotNull(service);
CXFConnectionRequestInfo cri = new CXFConnectionRequestInfo(Greeter.class, wsdl, service.getServiceName(), portName);
cri.setAddress("http://localhost:" + PORT + "/SoapContext/SoapPort");
ManagedConnectionFactory managedFactory = new ManagedConnectionFactoryImpl();
Subject subject = new Subject();
ManagedConnection mc = managedFactory.createManagedConnection(subject, cri);
Object o = mc.getConnection(subject, cri);
// test for the Object hash()
try {
o.hashCode();
o.toString();
} catch (WebServiceException ex) {
fail("The connection object should support Object method");
}
verifyResult(o);
}
use of org.apache.hello_world_soap_http.SOAPService in project cxf by apache.
the class CountersClientServerTest method testCountersWithInstrumentationManager.
@Test
public void testCountersWithInstrumentationManager() throws Exception {
// create Client with other bus
Bus bus = getStaticBus();
BusFactory.setDefaultBus(bus);
bus.getExtension(WorkQueueManager.class);
CounterRepository cr = bus.getExtension(CounterRepository.class);
InstrumentationManager im = bus.getExtension(InstrumentationManager.class);
assertNotNull(im);
InstrumentationManagerImpl impl = (InstrumentationManagerImpl) im;
assertTrue(impl.isEnabled());
assertNotNull(impl.getMBeanServer());
MBeanServer mbs = im.getMBeanServer();
ObjectName name = new ObjectName(ManagementConstants.DEFAULT_DOMAIN_NAME + ":" + ManagementConstants.BUS_ID_PROP + "=cxf" + bus.hashCode() + ",*");
SOAPService service = new SOAPService();
assertNotNull(service);
Greeter greeter = service.getPort(portName, Greeter.class);
updateAddressPort(greeter, PORT);
String response = new String("Bonjour");
String reply = greeter.sayHi();
// assertNotNull("no response received from service", reply);
// assertEquals(response, reply);
assertEquals("The Counters are not create yet", 4, cr.getCounters().size());
Set<?> counterNames = mbs.queryNames(name, null);
assertEquals("The Counters are not export to JMX: " + counterNames, 4 + 3, counterNames.size());
ObjectName sayHiCounter = new ObjectName(ManagementConstants.DEFAULT_DOMAIN_NAME + ":operation=\"sayHi\",*");
Set<?> s = mbs.queryNames(sayHiCounter, null);
Iterator<?> it = s.iterator();
while (it.hasNext()) {
ObjectName counterName = (ObjectName) it.next();
Object val = mbs.getAttribute(counterName, "NumInvocations");
assertEquals("Wrong Counters Number of Invocations", val, 1);
}
reply = greeter.sayHi();
assertNotNull("no response received from service", reply);
assertEquals(response, reply);
s = mbs.queryNames(sayHiCounter, null);
it = s.iterator();
while (it.hasNext()) {
ObjectName counterName = (ObjectName) it.next();
Object val = mbs.getAttribute(counterName, "NumInvocations");
assertEquals("Wrong Counters Number of Invocations", val, 2);
}
greeter.greetMeOneWay("hello");
for (int count = 0; count < 10; count++) {
if (6 != cr.getCounters().size()) {
Thread.sleep(100);
} else {
break;
}
}
assertEquals("The Counters are not create yet", 6, cr.getCounters().size());
for (int count = 0; count < 10; count++) {
if (10 > mbs.queryNames(name, null).size()) {
Thread.sleep(100);
} else {
break;
}
}
counterNames = mbs.queryNames(name, null);
assertEquals("The Counters are not export to JMX " + counterNames, 6 + 4, counterNames.size());
ObjectName greetMeOneWayCounter = new ObjectName(ManagementConstants.DEFAULT_DOMAIN_NAME + ":operation=\"greetMeOneWay\",*");
s = mbs.queryNames(greetMeOneWayCounter, null);
it = s.iterator();
while (it.hasNext()) {
ObjectName counterName = (ObjectName) it.next();
Object val = mbs.getAttribute(counterName, "NumInvocations");
assertEquals("Wrong Counters Number of Invocations", val, 1);
}
}
use of org.apache.hello_world_soap_http.SOAPService in project cxf by apache.
the class ManagedClientServerTest method testManagedEndpoint.
@Test
public void testManagedEndpoint() throws Exception {
Bus bus = getStaticBus();
BusFactory.setDefaultBus(bus);
InstrumentationManager im = bus.getExtension(InstrumentationManager.class);
assertNotNull(im);
InstrumentationManagerImpl impl = (InstrumentationManagerImpl) im;
assertTrue(impl.isEnabled());
assertNotNull(impl.getMBeanServer());
MBeanServer mbs = im.getMBeanServer();
ObjectName name = new ObjectName(ManagementConstants.DEFAULT_DOMAIN_NAME + ":type=Bus.Service.Endpoint,*");
Set<?> s = mbs.queryNames(name, null);
assertEquals(1, s.size());
name = (ObjectName) s.iterator().next();
Object val = mbs.invoke(name, "getState", new Object[0], new String[0]);
assertEquals("Service should have been started.", "STARTED", val);
SOAPService service = new SOAPService();
assertNotNull(service);
Greeter greeter = service.getPort(portName, Greeter.class);
updateAddressPort(greeter, PORT);
String response = new String("Bonjour");
String reply = greeter.sayHi();
assertNotNull("no response received from service", reply);
assertEquals(response, reply);
mbs.invoke(name, "stop", new Object[0], new String[0]);
val = mbs.getAttribute(name, "State");
assertEquals("Service should have been stopped.", "STOPPED", val);
try {
reply = greeter.sayHi();
fail("Endpoint should not be active at this point.");
} catch (Exception ex) {
// Expected
}
mbs.invoke(name, "start", new Object[0], new String[0]);
val = mbs.invoke(name, "getState", new Object[0], new String[0]);
assertEquals("Service should have been started.", "STARTED", val);
reply = greeter.sayHi();
assertNotNull("no response received from service", reply);
assertEquals(response, reply);
mbs.invoke(name, "destroy", new Object[0], new String[0]);
try {
mbs.getMBeanInfo(name);
fail("destroy failed to unregister MBean.");
} catch (InstanceNotFoundException e) {
// Expected
}
}
Aggregations