use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.
the class AbstractMessageResponseTimeInterceptor method getOperationCounterName.
protected ObjectName getOperationCounterName(Exchange ex, ObjectName sericeCounterName) {
BindingOperationInfo bop = ex.getBindingOperationInfo();
OperationInfo opInfo = bop == null ? null : bop.getOperationInfo();
if (opInfo != null) {
ObjectName o = opInfo.getProperty("javax.management.ObjectName", ObjectName.class);
if (o != null) {
return o;
}
}
String operationName = opInfo == null ? null : "\"" + opInfo.getName().getLocalPart() + "\"";
if (operationName == null) {
Object nameProperty = ex.get("org.apache.cxf.resource.operation.name");
if (nameProperty != null) {
operationName = "\"" + escapePatternChars(nameProperty.toString()) + "\"";
}
}
StringBuilder buffer = new StringBuilder(sericeCounterName.toString());
if (operationName != null) {
buffer.append("," + ManagementConstants.OPERATION_NAME_PROP + "=" + operationName);
}
String operationCounterName = buffer.toString();
ObjectName operationCounter = null;
try {
operationCounter = new ObjectName(operationCounterName);
if (opInfo != null) {
opInfo.setProperty("javax.management.ObjectName", operationCounter);
}
} catch (MalformedObjectNameException e) {
LOG.log(Level.WARNING, "CREATE_COUNTER_OBJECTNAME_FAILED", e);
}
return operationCounter;
}
use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.
the class AbstractMessageResponseTestBase method setupOperationForMessage.
protected void setupOperationForMessage() {
OperationInfo op = EasyMock.createMock(OperationInfo.class);
BindingOperationInfo bop = EasyMock.createMock(BindingOperationInfo.class);
EasyMock.expect(exchange.getBindingOperationInfo()).andReturn(bop);
EasyMock.expect(bop.getOperationInfo()).andReturn(op);
EasyMock.expect(op.getName()).andReturn(OPERATION_NAME);
EasyMock.expect(op.getProperty("javax.management.ObjectName", ObjectName.class)).andReturn(null).anyTimes();
op.setProperty(EasyMock.eq("javax.management.ObjectName"), EasyMock.anyObject(ObjectName.class));
EasyMock.expectLastCall();
EasyMock.replay(bop, op);
}
use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.
the class ProxyTest method testInvoke.
@Test
public void testInvoke() throws Exception {
Method m = Proxy.class.getDeclaredMethod("createClient", new Class[] { Bus.class, Endpoint.class, ProtocolVariation.class, Conduit.class, org.apache.cxf.ws.addressing.EndpointReferenceType.class });
Proxy proxy = EasyMock.createMockBuilder(Proxy.class).addMockedMethod(m).createMock(control);
proxy.setReliableEndpoint(rme);
RMManager manager = control.createMock(RMManager.class);
EasyMock.expect(rme.getManager()).andReturn(manager).anyTimes();
Bus bus = control.createMock(Bus.class);
EasyMock.expect(manager.getBus()).andReturn(bus).anyTimes();
Endpoint endpoint = control.createMock(Endpoint.class);
EasyMock.expect(rme.getEndpoint(ProtocolVariation.RM10WSA200408)).andReturn(endpoint).anyTimes();
BindingInfo bi = control.createMock(BindingInfo.class);
EasyMock.expect(rme.getBindingInfo(ProtocolVariation.RM10WSA200408)).andReturn(bi).anyTimes();
Conduit conduit = control.createMock(Conduit.class);
EasyMock.expect(rme.getConduit()).andReturn(conduit).anyTimes();
org.apache.cxf.ws.addressing.EndpointReferenceType replyTo = control.createMock(org.apache.cxf.ws.addressing.EndpointReferenceType.class);
EasyMock.expect(rme.getReplyTo()).andReturn(replyTo).anyTimes();
OperationInfo oi = control.createMock(OperationInfo.class);
BindingOperationInfo boi = control.createMock(BindingOperationInfo.class);
EasyMock.expect(bi.getOperation(oi)).andReturn(boi).anyTimes();
Client client = control.createMock(Client.class);
EasyMock.expect(client.getRequestContext()).andReturn(new HashMap<String, Object>()).anyTimes();
EasyMock.expect(proxy.createClient(bus, endpoint, ProtocolVariation.RM10WSA200408, conduit, replyTo)).andReturn(client).anyTimes();
Object[] args = new Object[] {};
Map<String, Object> context = new HashMap<>();
Object[] results = new Object[] { "a", "b", "c" };
Exchange exchange = control.createMock(Exchange.class);
EasyMock.expect(client.invoke(boi, args, context, exchange)).andReturn(results).anyTimes();
control.replay();
assertEquals("a", proxy.invoke(oi, ProtocolVariation.RM10WSA200408, args, context, exchange));
}
use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.
the class ProxyTest method testLastMessage.
@Test
public void testLastMessage() throws NoSuchMethodException, RMException {
Method m = Proxy.class.getDeclaredMethod("invoke", new Class[] { OperationInfo.class, ProtocolVariation.class, Object[].class, Map.class, Level.class });
Proxy proxy = EasyMock.createMockBuilder(Proxy.class).addMockedMethod(m).createMock(control);
proxy.setReliableEndpoint(rme);
SourceSequence ss = control.createMock(SourceSequence.class);
EasyMock.expect(ss.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408).anyTimes();
EasyMock.expect(ss.getTarget()).andReturn(null).anyTimes();
control.replay();
proxy.lastMessage(ss);
control.verify();
control.reset();
org.apache.cxf.ws.addressing.EndpointReferenceType target = RMUtils.createAnonymousReference();
EasyMock.expect(ss.getTarget()).andReturn(target).anyTimes();
control.replay();
proxy.lastMessage(ss);
control.verify();
control.reset();
target = RMUtils.createReference("http://localhost:9000/greeterPort");
EasyMock.expect(ss.getTarget()).andReturn(target).anyTimes();
EasyMock.expect(ss.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408).anyTimes();
Endpoint endpoint = control.createMock(Endpoint.class);
EasyMock.expect(rme.getEndpoint(ProtocolVariation.RM10WSA200408)).andReturn(endpoint).anyTimes();
EndpointInfo epi = control.createMock(EndpointInfo.class);
EasyMock.expect(endpoint.getEndpointInfo()).andReturn(epi).anyTimes();
ServiceInfo si = control.createMock(ServiceInfo.class);
EasyMock.expect(epi.getService()).andReturn(si).anyTimes();
InterfaceInfo ii = control.createMock(InterfaceInfo.class);
EasyMock.expect(si.getInterface()).andReturn(ii).anyTimes();
OperationInfo oi = control.createMock(OperationInfo.class);
EasyMock.expect(ii.getOperation(RM10Constants.CLOSE_SEQUENCE_QNAME)).andReturn(oi).anyTimes();
expectInvokeWithContext(proxy, oi, null);
control.replay();
proxy.lastMessage(ss);
}
use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.
the class ProxyTest method testAcknowledge.
@Test
public void testAcknowledge() throws NoSuchMethodException, RMException {
Method m = Proxy.class.getDeclaredMethod("invoke", new Class[] { OperationInfo.class, ProtocolVariation.class, Object[].class, Map.class });
Proxy proxy = EasyMock.createMockBuilder(Proxy.class).addMockedMethod(m).createMock(control);
proxy.setReliableEndpoint(rme);
DestinationSequence ds = control.createMock(DestinationSequence.class);
EasyMock.expect(ds.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408).anyTimes();
EndpointReferenceType acksToEPR = control.createMock(EndpointReferenceType.class);
EasyMock.expect(ds.getAcksTo()).andReturn(acksToEPR).anyTimes();
AttributedURIType acksToURI = control.createMock(AttributedURIType.class);
EasyMock.expect(acksToEPR.getAddress()).andReturn(acksToURI).anyTimes();
String acksToAddress = "acksTo";
EasyMock.expect(acksToURI.getValue()).andReturn(acksToAddress).anyTimes();
Endpoint endpoint = control.createMock(Endpoint.class);
EasyMock.expect(rme.getEndpoint(ProtocolVariation.RM10WSA200408)).andReturn(endpoint).anyTimes();
EndpointInfo epi = control.createMock(EndpointInfo.class);
EasyMock.expect(endpoint.getEndpointInfo()).andReturn(epi).anyTimes();
ServiceInfo si = control.createMock(ServiceInfo.class);
EasyMock.expect(epi.getService()).andReturn(si).anyTimes();
InterfaceInfo ii = control.createMock(InterfaceInfo.class);
EasyMock.expect(si.getInterface()).andReturn(ii).anyTimes();
OperationInfo oi = control.createMock(OperationInfo.class);
EasyMock.expect(ii.getOperation(RM10Constants.SEQUENCE_ACK_QNAME)).andReturn(oi).anyTimes();
expectInvoke(proxy, oi, null);
control.replay();
proxy.acknowledge(ds);
}
Aggregations