use of org.apache.cxf.greeter_control.types.GreetMe in project cxf by apache.
the class WSRMWithWSSecurityPolicyTest method testContextProperty.
@Test
public void testContextProperty() throws Exception {
try (ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("org/apache/cxf/systest/ws/rm/sec/client-policy.xml")) {
Bus bus = (Bus) context.getBean("bus");
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
Greeter greeter = (Greeter) context.getBean("GreeterCombinedClientNoProperty");
Client client = ClientProxy.getClient(greeter);
QName operationQName = new QName("http://cxf.apache.org/greeter_control", "greetMe");
BindingOperationInfo boi = client.getEndpoint().getBinding().getBindingInfo().getOperation(operationQName);
Map<String, Object> invocationContext = new HashMap<>();
Map<String, Object> requestContext = new HashMap<>();
Map<String, Object> responseContext = new HashMap<>();
invocationContext.put(Client.REQUEST_CONTEXT, requestContext);
invocationContext.put(Client.RESPONSE_CONTEXT, responseContext);
requestContext.put(SecurityConstants.USERNAME, "Alice");
requestContext.put(SecurityConstants.CALLBACK_HANDLER, "org.apache.cxf.systest.ws.rm.sec.UTPasswordCallback");
requestContext.put(SecurityConstants.ENCRYPT_PROPERTIES, "bob.properties");
requestContext.put(SecurityConstants.ENCRYPT_USERNAME, "bob");
requestContext.put(SecurityConstants.SIGNATURE_PROPERTIES, "alice.properties");
requestContext.put(SecurityConstants.SIGNATURE_USERNAME, "alice");
RMManager manager = bus.getExtension(RMManager.class);
boolean empty = manager.getRetransmissionQueue().isEmpty();
assertTrue("RetransmissionQueue is not empty", empty);
GreetMe param = new GreetMe();
param.setRequestType("testContextProperty");
Object[] answer = client.invoke(boi, new Object[] { param }, invocationContext);
Assert.assertEquals("TESTCONTEXTPROPERTY", answer[0].toString());
Thread.sleep(5000);
empty = manager.getRetransmissionQueue().isEmpty();
assertTrue("RetransmissionQueue not empty", empty);
}
}
Aggregations