use of org.apache.cxf.service.model.ServiceInfo in project cxf by apache.
the class UndertowHTTPDestinationTest method testGetMultiple.
@Test
public void testGetMultiple() throws Exception {
bus = BusFactory.getDefaultBus(true);
transportFactory = new HTTPTransportFactory();
ServiceInfo serviceInfo = new ServiceInfo();
serviceInfo.setName(new QName("bla", "Service"));
EndpointInfo ei = new EndpointInfo(serviceInfo, "");
ei.setName(new QName("bla", "Port"));
ei.setAddress("http://foo");
Destination d1 = transportFactory.getDestination(ei, bus);
Destination d2 = transportFactory.getDestination(ei, bus);
// Second get should not generate a new destination. It should just retrieve the existing one
assertEquals(d1, d2);
d2.shutdown();
Destination d3 = transportFactory.getDestination(ei, bus);
// Now a new destination should have been created
assertNotSame(d1, d3);
}
use of org.apache.cxf.service.model.ServiceInfo in project cxf by apache.
the class UndertowHTTPDestinationTest method setUpDestination.
private UndertowHTTPDestination setUpDestination(boolean contextMatchOnStem, boolean mockedBus) throws Exception {
policy = new HTTPServerPolicy();
address = getEPR("bar/foo");
transportFactory = new HTTPTransportFactory();
final ConduitInitiator ci = new ConduitInitiator() {
public Conduit getConduit(EndpointInfo targetInfo, Bus b) throws IOException {
return decoupledBackChannel;
}
public Conduit getConduit(EndpointInfo localInfo, EndpointReferenceType target, Bus b) throws IOException {
return decoupledBackChannel;
}
public List<String> getTransportIds() {
return null;
}
public Set<String> getUriPrefixes() {
return new HashSet<>(Collections.singletonList("http"));
}
};
ConduitInitiatorManager mgr = new ConduitInitiatorManager() {
public void deregisterConduitInitiator(String name) {
}
public ConduitInitiator getConduitInitiator(String name) throws BusException {
return null;
}
public ConduitInitiator getConduitInitiatorForUri(String uri) {
return ci;
}
public void registerConduitInitiator(String name, ConduitInitiator factory) {
}
};
if (!mockedBus) {
bus = new ExtensionManagerBus();
bus.setExtension(mgr, ConduitInitiatorManager.class);
} else {
bus = EasyMock.createMock(Bus.class);
bus.getExtension(EndpointResolverRegistry.class);
EasyMock.expectLastCall().andReturn(null);
bus.getExtension(ContinuationProviderFactory.class);
EasyMock.expectLastCall().andReturn(null).anyTimes();
bus.getExtension(PolicyDataEngine.class);
EasyMock.expectLastCall().andReturn(null).anyTimes();
bus.hasExtensionByName("org.apache.cxf.ws.policy.PolicyEngine");
EasyMock.expectLastCall().andReturn(false);
bus.getExtension(ClassLoader.class);
EasyMock.expectLastCall().andReturn(this.getClass().getClassLoader());
EasyMock.replay(bus);
}
engine = EasyMock.createNiceMock(UndertowHTTPServerEngine.class);
ServiceInfo serviceInfo = new ServiceInfo();
serviceInfo.setName(new QName("bla", "Service"));
endpointInfo = new EndpointInfo(serviceInfo, "");
endpointInfo.setName(new QName("bla", "Port"));
endpointInfo.setAddress(NOWHERE + "bar/foo");
endpointInfo.addExtensor(policy);
engine.addServant(EasyMock.eq(new URL(NOWHERE + "bar/foo")), EasyMock.isA(UndertowHTTPHandler.class));
EasyMock.expectLastCall();
engine.getContinuationsEnabled();
EasyMock.expectLastCall().andReturn(true);
EasyMock.replay(engine);
UndertowHTTPDestination dest = new EasyMockUndertowHTTPDestination(bus, transportFactory.getRegistry(), endpointInfo, null, engine);
dest.retrieveEngine();
policy = dest.getServer();
observer = new MessageObserver() {
public void onMessage(Message m) {
inMessage = m;
threadDefaultBus = BusFactory.getThreadDefaultBus();
}
};
dest.setMessageObserver(observer);
return dest;
}
use of org.apache.cxf.service.model.ServiceInfo in project cxf by apache.
the class PolicyAttachmentTest method testAppliesToService.
@Test
public void testAppliesToService() {
ServiceInfo si1 = control.createMock(ServiceInfo.class);
ServiceInfo si2 = control.createMock(ServiceInfo.class);
DomainExpression de = control.createMock(DomainExpression.class);
Collection<DomainExpression> des = Collections.singletonList(de);
PolicyAttachment pa = new PolicyAttachment();
pa.setDomainExpressions(des);
EasyMock.expect(de.appliesTo(si1)).andReturn(false);
EasyMock.expect(de.appliesTo(si2)).andReturn(true);
control.replay();
assertFalse(pa.appliesTo(si1));
assertTrue(pa.appliesTo(si2));
control.verify();
}
use of org.apache.cxf.service.model.ServiceInfo in project cxf by apache.
the class ExternalAttachmentProviderTest method setUpAttachment.
void setUpAttachment(Object subject, boolean applies, ExternalAttachmentProvider eap) {
attachments.clear();
attachment = control.createMock(PolicyAttachment.class);
attachments.add(attachment);
policy = new Policy();
assertion = new PrimitiveAssertion(TEST_ASSERTION_TYPE);
policy.addAssertion(assertion);
eap.setAttachments(attachments);
if (subject instanceof ServiceInfo) {
EasyMock.expect(attachment.appliesTo((ServiceInfo) subject)).andReturn(applies);
} else if (subject instanceof EndpointInfo) {
EasyMock.expect(attachment.appliesTo((EndpointInfo) subject)).andReturn(applies);
} else if (subject instanceof BindingOperationInfo) {
EasyMock.expect(attachment.appliesTo((BindingOperationInfo) subject)).andReturn(applies);
} else if (subject instanceof BindingMessageInfo) {
EasyMock.expect(attachment.appliesTo((BindingMessageInfo) subject)).andReturn(applies);
} else if (subject instanceof BindingFaultInfo) {
EasyMock.expect(attachment.appliesTo((BindingFaultInfo) subject)).andReturn(applies);
} else {
System.err.println("subject class: " + subject.getClass());
}
if (applies) {
EasyMock.expect(attachment.getPolicy()).andReturn(policy);
}
}
use of org.apache.cxf.service.model.ServiceInfo in project cxf by apache.
the class ExternalAttachmentProviderTest method testGetEffectiveServicePolicy.
@Test
public void testGetEffectiveServicePolicy() {
ExternalAttachmentProvider eap = new ExternalAttachmentProvider();
ServiceInfo si = control.createMock(ServiceInfo.class);
setUpAttachment(si, false, eap);
control.replay();
assertNull(eap.getEffectivePolicy(si, null));
control.verify();
control.reset();
setUpAttachment(si, true, eap);
control.replay();
assertSame(assertion, eap.getEffectivePolicy(si, null).getAssertions().get(0));
control.verify();
}
Aggregations