use of org.apache.cxf.endpoint.Server in project cxf by apache.
the class PolicyAnnotationTest method testAnnotationImplNoInterface.
@org.junit.Test
public void testAnnotationImplNoInterface() throws Exception {
Bus bus = BusFactory.getDefaultBus();
JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
factory.setBus(bus);
factory.setServiceBean(new TestImplNoInterface());
factory.setStart(false);
List<String> tp = Arrays.asList("http://schemas.xmlsoap.org/soap/http", "http://schemas.xmlsoap.org/wsdl/http/", "http://schemas.xmlsoap.org/wsdl/soap/http", "http://www.w3.org/2003/05/soap/bindings/HTTP/", "http://cxf.apache.org/transports/http/configuration", "http://cxf.apache.org/bindings/xformat");
LocalTransportFactory f = new LocalTransportFactory();
f.getUriPrefixes().add("http");
f.setTransportIds(tp);
Server s = factory.create();
try {
ServiceWSDLBuilder builder = new ServiceWSDLBuilder(bus, s.getEndpoint().getService().getServiceInfos());
Definition def = builder.build();
WSDLWriter wsdlWriter = bus.getExtension(WSDLManager.class).getWSDLFactory().newWSDLWriter();
def.setExtensionRegistry(bus.getExtension(WSDLManager.class).getExtensionRegistry());
Element wsdl = wsdlWriter.getDocument(def).getDocumentElement();
Map<String, String> ns = new HashMap<>();
ns.put("wsdl", WSDLConstants.NS_WSDL11);
ns.put("wsu", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd");
ns.put("wsp", Constants.URI_POLICY_13_NS);
XPathUtils xpu = new XPathUtils(ns);
// org.apache.cxf.helpers.XMLUtils.printDOM(wsdl);
assertEquals(1, xpu.getValueList("/wsdl:definitions/wsdl:binding/" + "wsp:PolicyReference[@URI='#TestImplNoInterfaceServiceSoapBindingBindingPolicy']", wsdl).getLength());
final EndpointPolicy policy = bus.getExtension(PolicyEngine.class).getServerEndpointPolicy(s.getEndpoint().getEndpointInfo(), null, null);
assertNotNull(policy);
} finally {
bus.shutdown(true);
}
}
use of org.apache.cxf.endpoint.Server in project cxf by apache.
the class ColocOutInterceptorTest method verifyIsColocatedWithSameOperation.
private void verifyIsColocatedWithSameOperation() {
colocOut = new TestColocOutInterceptor1();
// Funtion Param
Server s1 = control.createMock(Server.class);
List<Server> list = new ArrayList<>();
list.add(s1);
Endpoint sep = control.createMock(Endpoint.class);
BindingOperationInfo sboi = control.createMock(BindingOperationInfo.class);
// Local var
Service ses = control.createMock(Service.class);
EndpointInfo sei = control.createMock(EndpointInfo.class);
BindingInfo rbi = control.createMock(BindingInfo.class);
Endpoint rep = control.createMock(Endpoint.class);
Service res = control.createMock(Service.class);
EndpointInfo rei = control.createMock(EndpointInfo.class);
BindingOperationInfo rboi = control.createMock(BindingOperationInfo.class);
QName op = new QName("E", "F");
QName intf = new QName("G", "H");
QName inmi = new QName("M", "in");
QName outmi = new QName("M", "out");
ServiceInfo ssi = new ServiceInfo();
InterfaceInfo sii = new InterfaceInfo(ssi, intf);
sii.addOperation(op);
OperationInfo soi = sii.getOperation(op);
MessageInfo mii = new MessageInfo(soi, MessageInfo.Type.INPUT, inmi);
MessageInfo mio = new MessageInfo(soi, MessageInfo.Type.OUTPUT, outmi);
soi.setInput("in", mii);
soi.setOutput("out", mio);
ServiceInfo rsi = new ServiceInfo();
InterfaceInfo rii = new InterfaceInfo(rsi, intf);
rii.addOperation(op);
OperationInfo roi = rii.getOperation(op);
roi.setInput("in", mii);
roi.setOutput("out", mio);
EasyMock.expect(sep.getService()).andReturn(ses);
EasyMock.expect(sep.getEndpointInfo()).andReturn(sei);
EasyMock.expect(s1.getEndpoint()).andReturn(rep);
EasyMock.expect(rep.getService()).andReturn(res);
EasyMock.expect(rep.getEndpointInfo()).andReturn(rei);
EasyMock.expect(ses.getName()).andReturn(new QName("A", "B"));
EasyMock.expect(res.getName()).andReturn(new QName("A", "B"));
EasyMock.expect(rei.getName()).andReturn(new QName("C", "D"));
EasyMock.expect(sei.getName()).andReturn(new QName("C", "D"));
EasyMock.expect(rei.getBinding()).andReturn(rbi);
EasyMock.expect(sboi.getName()).andReturn(op);
EasyMock.expect(sboi.getOperationInfo()).andReturn(soi);
EasyMock.expect(rboi.getName()).andReturn(op);
EasyMock.expect(rboi.getOperationInfo()).andReturn(roi);
EasyMock.expect(rbi.getOperation(op)).andReturn(rboi);
control.replay();
Server val = colocOut.isColocated(list, sep, sboi);
assertEquals("Expecting a colocated call", s1, val);
control.reset();
}
use of org.apache.cxf.endpoint.Server in project cxf by apache.
the class ColocOutInterceptorTest method verifyIsColocatedWithDifferentService.
private void verifyIsColocatedWithDifferentService() {
// Funtion Param
Server s1 = control.createMock(Server.class);
List<Server> list = new ArrayList<>();
list.add(s1);
Endpoint sep = control.createMock(Endpoint.class);
// Local var
Service ses = control.createMock(Service.class);
Endpoint rep = control.createMock(Endpoint.class);
Service res = control.createMock(Service.class);
EasyMock.expect(sep.getService()).andReturn(ses);
EasyMock.expect(s1.getEndpoint()).andReturn(rep);
EasyMock.expect(rep.getService()).andReturn(res);
EasyMock.expect(ses.getName()).andReturn(new QName("A", "C"));
EasyMock.expect(res.getName()).andReturn(new QName("A", "B"));
control.replay();
Server val = colocOut.isColocated(list, sep, null);
assertEquals("Is not a colocated call", null, val);
control.reset();
}
use of org.apache.cxf.endpoint.Server in project cxf by apache.
the class ColocOutInterceptorTest method verifyIsColocatedWithCompatibleOperation.
private void verifyIsColocatedWithCompatibleOperation() {
colocOut = new TestColocOutInterceptor1();
// Funtion Param
Server s1 = control.createMock(Server.class);
List<Server> list = new ArrayList<>();
list.add(s1);
Endpoint sep = control.createMock(Endpoint.class);
BindingOperationInfo sboi = control.createMock(BindingOperationInfo.class);
// Local var
Service ses = control.createMock(Service.class);
EndpointInfo sei = control.createMock(EndpointInfo.class);
BindingInfo rbi = control.createMock(BindingInfo.class);
Endpoint rep = control.createMock(Endpoint.class);
Service res = control.createMock(Service.class);
EndpointInfo rei = control.createMock(EndpointInfo.class);
BindingOperationInfo rboi = control.createMock(BindingOperationInfo.class);
QName op = new QName("E", "F");
QName intf = new QName("G", "H");
QName inmi = new QName("M", "in");
QName outmi = new QName("M", "out");
ServiceInfo ssi = new ServiceInfo();
InterfaceInfo sii = new InterfaceInfo(ssi, intf);
sii.addOperation(op);
OperationInfo soi = sii.getOperation(op);
MessageInfo mii = new MessageInfo(soi, MessageInfo.Type.INPUT, inmi);
MessagePartInfo mpi = mii.addMessagePart("parameters");
mpi.setTypeClass(Source.class);
MessageInfo mio = new MessageInfo(soi, MessageInfo.Type.OUTPUT, outmi);
mpi = mio.addMessagePart("parameters");
mpi.setTypeClass(Source.class);
soi.setInput("in", mii);
soi.setOutput("out", mio);
ServiceInfo rsi = new ServiceInfo();
InterfaceInfo rii = new InterfaceInfo(rsi, intf);
rii.addOperation(op);
OperationInfo roi = rii.getOperation(op);
mii = new MessageInfo(roi, MessageInfo.Type.INPUT, inmi);
mpi = mii.addMessagePart("parameters");
mpi.setTypeClass(Object.class);
mio = new MessageInfo(roi, MessageInfo.Type.OUTPUT, outmi);
mpi = mio.addMessagePart("parameters");
mpi.setTypeClass(Object.class);
roi.setInput("in", mii);
roi.setOutput("out", mio);
EasyMock.expect(sep.getService()).andReturn(ses);
EasyMock.expect(sep.getEndpointInfo()).andReturn(sei);
EasyMock.expect(s1.getEndpoint()).andReturn(rep);
EasyMock.expect(rep.getService()).andReturn(res);
EasyMock.expect(rep.getEndpointInfo()).andReturn(rei);
EasyMock.expect(ses.getName()).andReturn(new QName("A", "B"));
EasyMock.expect(res.getName()).andReturn(new QName("A", "B"));
EasyMock.expect(rei.getName()).andReturn(new QName("C", "D"));
EasyMock.expect(sei.getName()).andReturn(new QName("C", "D"));
EasyMock.expect(rei.getBinding()).andReturn(rbi);
EasyMock.expect(sboi.getName()).andReturn(op);
EasyMock.expect(sboi.getOperationInfo()).andReturn(soi);
EasyMock.expect(rboi.getName()).andReturn(op);
EasyMock.expect(rboi.getOperationInfo()).andReturn(roi);
EasyMock.expect(rbi.getOperation(op)).andReturn(rboi);
control.replay();
Server val = colocOut.isColocated(list, sep, sboi);
assertEquals("Expecting a colocated call", s1, val);
control.reset();
}
use of org.apache.cxf.endpoint.Server in project cxf by apache.
the class ColocOutInterceptorTest method verifyIsColocatedWithDifferentOperation.
private void verifyIsColocatedWithDifferentOperation() {
// Funtion Param
Server s1 = control.createMock(Server.class);
List<Server> list = new ArrayList<>();
list.add(s1);
Endpoint sep = control.createMock(Endpoint.class);
BindingOperationInfo sboi = control.createMock(BindingOperationInfo.class);
// Local var
Service ses = control.createMock(Service.class);
ServiceInfo ssi = control.createMock(ServiceInfo.class);
EndpointInfo sei = control.createMock(EndpointInfo.class);
TestBindingInfo rbi = new TestBindingInfo(ssi, "testBinding");
Endpoint rep = control.createMock(Endpoint.class);
Service res = control.createMock(Service.class);
EndpointInfo rei = control.createMock(EndpointInfo.class);
EasyMock.expect(sep.getService()).andReturn(ses);
EasyMock.expect(sep.getEndpointInfo()).andReturn(sei);
EasyMock.expect(s1.getEndpoint()).andReturn(rep);
EasyMock.expect(rep.getService()).andReturn(res);
EasyMock.expect(rep.getEndpointInfo()).andReturn(rei);
EasyMock.expect(ses.getName()).andReturn(new QName("A", "B"));
EasyMock.expect(res.getName()).andReturn(new QName("A", "B"));
EasyMock.expect(rei.getName()).andReturn(new QName("C", "D"));
EasyMock.expect(sei.getName()).andReturn(new QName("C", "D"));
EasyMock.expect(rei.getBinding()).andReturn(rbi);
EasyMock.expect(sboi.getName()).andReturn(new QName("E", "F"));
// Causes ConcurrentModification intermittently
// QName op = new QName("E", "F");
// EasyMock.expect(rbi.getOperation(op).andReturn(null);
control.replay();
Server val = colocOut.isColocated(list, sep, sboi);
assertEquals("Is not a colocated call", null, val);
assertEquals("BindingOperation.getOperation was not called", 1, rbi.getOpCount());
control.reset();
}
Aggregations