Search in sources :

Example 96 with ServiceInfo

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);
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) Destination(org.apache.cxf.transport.Destination) AbstractHTTPDestination(org.apache.cxf.transport.http.AbstractHTTPDestination) QName(javax.xml.namespace.QName) HTTPTransportFactory(org.apache.cxf.transport.http.HTTPTransportFactory) Test(org.junit.Test)

Example 97 with ServiceInfo

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;
}
Also used : Bus(org.apache.cxf.Bus) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus) HTTPServerPolicy(org.apache.cxf.transports.http.configuration.HTTPServerPolicy) EndpointReferenceType(org.apache.cxf.ws.addressing.EndpointReferenceType) MessageObserver(org.apache.cxf.transport.MessageObserver) Message(org.apache.cxf.message.Message) QName(javax.xml.namespace.QName) HTTPTransportFactory(org.apache.cxf.transport.http.HTTPTransportFactory) HttpString(io.undertow.util.HttpString) URL(java.net.URL) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) ConduitInitiatorManager(org.apache.cxf.transport.ConduitInitiatorManager) ConduitInitiator(org.apache.cxf.transport.ConduitInitiator) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus) HashSet(java.util.HashSet)

Example 98 with ServiceInfo

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();
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) Test(org.junit.Test)

Example 99 with ServiceInfo

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);
    }
}
Also used : Policy(org.apache.neethi.Policy) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) BindingMessageInfo(org.apache.cxf.service.model.BindingMessageInfo) PrimitiveAssertion(org.apache.cxf.ws.policy.builder.primitive.PrimitiveAssertion) BindingFaultInfo(org.apache.cxf.service.model.BindingFaultInfo)

Example 100 with ServiceInfo

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();
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) Test(org.junit.Test)

Aggregations

ServiceInfo (org.apache.cxf.service.model.ServiceInfo)195 QName (javax.xml.namespace.QName)89 Test (org.junit.Test)76 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)63 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)47 BindingInfo (org.apache.cxf.service.model.BindingInfo)43 OperationInfo (org.apache.cxf.service.model.OperationInfo)37 InterfaceInfo (org.apache.cxf.service.model.InterfaceInfo)36 Service (org.apache.cxf.service.Service)33 Endpoint (org.apache.cxf.endpoint.Endpoint)31 MessagePartInfo (org.apache.cxf.service.model.MessagePartInfo)29 File (java.io.File)28 ArrayList (java.util.ArrayList)27 Bus (org.apache.cxf.Bus)26 InputStream (java.io.InputStream)23 Definition (javax.wsdl.Definition)20 Method (java.lang.reflect.Method)16 SchemaCollection (org.apache.cxf.common.xmlschema.SchemaCollection)15 HTTPTransportFactory (org.apache.cxf.transport.http.HTTPTransportFactory)15 IOException (java.io.IOException)12