Java Code Examples for org.apache.cxf.service.model.EndpointInfo#setName()

The following examples show how to use org.apache.cxf.service.model.EndpointInfo#setName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JettyHTTPDestinationTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 2
Source File: NettyHttpDestinationTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetMultiple() throws Exception {
    transportFactory = new HTTPTransportFactory();
    bus = BusFactory.getDefaultBus();

    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);
}
 
Example 3
Source File: JettyHTTPDestinationTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testServerPolicyInServiceModel()
    throws Exception {
    policy = new HTTPServerPolicy();
    address = getEPR("bar/foo");
    bus = BusFactory.getDefaultBus(true);

    transportFactory = new HTTPTransportFactory();

    ServiceInfo serviceInfo = new ServiceInfo();
    serviceInfo.setName(new QName("bla", "Service"));
    endpointInfo = new EndpointInfo(serviceInfo, "");
    endpointInfo.setName(new QName("bla", "Port"));
    endpointInfo.addExtensor(policy);

    engine = EasyMock.createMock(JettyHTTPServerEngine.class);
    EasyMock.replay();
    endpointInfo.setAddress(NOWHERE + "bar/foo");

    JettyHTTPDestination dest =
        new EasyMockJettyHTTPDestination(
                bus, transportFactory.getRegistry(), endpointInfo, null, engine);
    assertEquals(policy, dest.getServer());
}
 
Example 4
Source File: AtmosphereWebSocketJettyDestinationTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testUseCustomAtmoosphereInterceptor() throws Exception {
    Bus bus = new ExtensionManagerBus();
    bus.setProperty("atmosphere.interceptors", new CustomInterceptor1());
    DestinationRegistry registry = new HTTPTransportFactory().getRegistry();
    EndpointInfo endpoint = new EndpointInfo();
    endpoint.setAddress(ENDPOINT_ADDRESS);
    endpoint.setName(ENDPOINT_NAME);

    AtmosphereWebSocketServletDestination dest =
        new AtmosphereWebSocketServletDestination(bus, registry, endpoint, ENDPOINT_ADDRESS);

    List<AtmosphereInterceptor> ais = dest.getAtmosphereFramework().interceptors();
    int added = 0;
    for (AtmosphereInterceptor a : ais) {
        if (CustomInterceptor1.class.equals(a.getClass())) {
            added++;
            break;
        }
    }
    assertEquals(1, added);
}
 
Example 5
Source File: AtmosphereWebSocketJettyDestinationTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testUseCustomAtmoosphereInterceptors() throws Exception {
    Bus bus = new ExtensionManagerBus();
    bus.setProperty("atmosphere.interceptors", Arrays.asList(new CustomInterceptor1(), new CustomInterceptor2()));
    DestinationRegistry registry = new HTTPTransportFactory().getRegistry();
    EndpointInfo endpoint = new EndpointInfo();
    endpoint.setAddress(ENDPOINT_ADDRESS);
    endpoint.setName(ENDPOINT_NAME);

    AtmosphereWebSocketServletDestination dest =
        new AtmosphereWebSocketServletDestination(bus, registry, endpoint, ENDPOINT_ADDRESS);

    List<AtmosphereInterceptor> ais = dest.getAtmosphereFramework().interceptors();
    int added = 0;
    for (AtmosphereInterceptor a : ais) {
        if (CustomInterceptor1.class.equals(a.getClass())) {
            added++;
        } else if (CustomInterceptor2.class.equals(a.getClass())) {
            added++;
            break;
        }
    }
    assertEquals(2, added);
}
 
Example 6
Source File: AtmosphereWebSocketServletDestinationTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testRegisteration() throws Exception {
    Bus bus = new ExtensionManagerBus();
    DestinationRegistry registry = new HTTPTransportFactory().getRegistry();
    EndpointInfo endpoint = new EndpointInfo();
    endpoint.setAddress(ENDPOINT_ADDRESS);
    endpoint.setName(ENDPOINT_NAME);

    TestAtmosphereWebSocketServletDestination dest =
        new TestAtmosphereWebSocketServletDestination(bus, registry, endpoint, ENDPOINT_ADDRESS);

    dest.activate();

    assertNotNull(registry.getDestinationForPath(ENDPOINT_ADDRESS));

    dest.deactivate();

    assertNull(registry.getDestinationForPath(ENDPOINT_ADDRESS));
}
 
Example 7
Source File: AtmosphereWebSocketServletDestinationTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testUseCustomAtmoosphereInterceptor() throws Exception {
    Bus bus = new ExtensionManagerBus();
    bus.setProperty("atmosphere.interceptors", new CustomInterceptor1());
    DestinationRegistry registry = new HTTPTransportFactory().getRegistry();
    EndpointInfo endpoint = new EndpointInfo();
    endpoint.setAddress(ENDPOINT_ADDRESS);
    endpoint.setName(ENDPOINT_NAME);

    AtmosphereWebSocketServletDestination dest =
        new AtmosphereWebSocketServletDestination(bus, registry, endpoint, ENDPOINT_ADDRESS);

    List<AtmosphereInterceptor> ais = dest.getAtmosphereFramework().interceptors();
    int added = 0;
    for (AtmosphereInterceptor a : ais) {
        if (CustomInterceptor1.class.equals(a.getClass())) {
            added++;
            break;
        }
    }
    assertEquals(1, added);
}
 
Example 8
Source File: JettyHTTPDestinationTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testRandomPortAllocation() 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"));

    Destination d1 = transportFactory.getDestination(ei, bus);
    URL url = new URL(d1.getAddress().getAddress().getValue());
    assertTrue("No random port has been allocated",
               url.getPort() > 0);

}
 
Example 9
Source File: NettyHttpConduitFactoryTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testShutdownEventLoopGroup() throws Exception {
    bus = BusFactory.getDefaultBus(true);

    assertNotNull("Cannot get bus", bus);

    // Make sure we got the Transport Factory.
    NettyHttpTransportFactory factory =
            bus.getExtension(NettyHttpTransportFactory.class);
    assertNotNull("Cannot get NettyHttpTransportFactory", factory);

    ServiceInfo serviceInfo = new ServiceInfo();
    serviceInfo.setName(new QName("bla", "Service"));
    EndpointInfo ei = new EndpointInfo(serviceInfo, "");
    ei.setName(new QName("bla", "Port"));
    ei.setAddress("netty://foo");

    // The EventLoopGroup is put into bus when create a new netty http conduit
    factory.getConduit(ei, null, bus);

    bus.shutdown(true);

    EventLoopGroup eventLoopGroup = bus.getExtension(EventLoopGroup.class);
    assertNotNull("We should find the EventLoopGroup here.", eventLoopGroup);
    assertTrue("The eventLoopGroup should be shutdown.", eventLoopGroup.isShutdown());

}
 
Example 10
Source File: ServiceUtils.java    From fuchsia with Apache License 2.0 5 votes vote down vote up
public static EndpointInfo createEndpointInfo(Bus bus, ServiceInfo serviceInfo,
                                              BindingInfo bindingInfo, String address) {
    String transportURI = getTransportId(bus, address);
    EndpointInfo endpointInfo = new EndpointInfo(serviceInfo, transportURI);

    if (address != null) {
        endpointInfo.setName(new QName(address));
        endpointInfo.setAddress(address);
    }

    System.out.println("seting binding info:" + bindingInfo);
    endpointInfo.setBinding(bindingInfo);

    return endpointInfo;
}
 
Example 11
Source File: DestinationRegistryImplTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void setUpDestinations() {
    for (int i = 0; i < REGISTERED_PATHS.length; i++) {
        AbstractHTTPDestination destination = control.createMock(AbstractHTTPDestination.class);
        EndpointInfo endpoint = new EndpointInfo();
        endpoint.setAddress(REGISTERED_PATHS[i]);
        endpoint.setName(QNAME);
        EasyMock.expect(destination.getEndpointInfo()).andReturn(endpoint);

        control.replay();
        registry.addDestination(destination);
        control.reset();
    }

}
 
Example 12
Source File: ApplicationContextTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private EndpointInfo getEndpointInfo(String serviceNS,
                                     String endpointLocal,
                                     String address) {
    ServiceInfo serviceInfo2 = new ServiceInfo();
    serviceInfo2.setName(new QName(serviceNS, "Service"));
    EndpointInfo info2 = new EndpointInfo(serviceInfo2, "");
    info2.setName(new QName("urn:test:ns", endpointLocal));
    info2.setAddress(address);
    return info2;
}
 
Example 13
Source File: NettyHttpDestinationTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testContinuationsIgnored() throws Exception {

    HttpServletRequest httpRequest = EasyMock.createMock(HttpServletRequest.class);

    ServiceInfo serviceInfo = new ServiceInfo();
    serviceInfo.setName(new QName("bla", "Service"));
    EndpointInfo ei = new EndpointInfo(serviceInfo, "");
    ei.setName(new QName("bla", "Port"));

    // Just create a fake engine
    final NettyHttpServerEngine httpEngine = new NettyHttpServerEngine("localhost", 8080);
    //httpEngine.setContinuationsEnabled(false);
    NettyHttpServerEngineFactory factory = new NettyHttpServerEngineFactory() {
        @Override
        public NettyHttpServerEngine retrieveNettyHttpServerEngine(int port) {
            return httpEngine;
        }
    };
    transportFactory = new HTTPTransportFactory();
    bus = BusFactory.getDefaultBus();
    bus.setExtension(factory, NettyHttpServerEngineFactory.class);

    TestJettyDestination testDestination =
        new TestJettyDestination(bus,
                                 transportFactory.getRegistry(),
                                 ei,
                                 factory);
    testDestination.finalizeConfig();
    Message mi = testDestination.retrieveFromContinuation(httpRequest);
    assertNull("Continuations must be ignored", mi);
}
 
Example 14
Source File: JettyHTTPDestinationTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testContinuationsIgnored() throws Exception {

    HttpServletRequest httpRequest = EasyMock.createMock(HttpServletRequest.class);

    ServiceInfo serviceInfo = new ServiceInfo();
    serviceInfo.setName(new QName("bla", "Service"));
    EndpointInfo ei = new EndpointInfo(serviceInfo, "");
    ei.setName(new QName("bla", "Port"));

    final JettyHTTPServerEngine httpEngine = new JettyHTTPServerEngine();
    httpEngine.setContinuationsEnabled(false);
    JettyHTTPServerEngineFactory factory = new JettyHTTPServerEngineFactory() {
        @Override
        public JettyHTTPServerEngine retrieveJettyHTTPServerEngine(int port) {
            return httpEngine;
        }
    };
    Bus b2 = new ExtensionManagerBus();
    transportFactory = new HTTPTransportFactory();
    b2.setExtension(factory, JettyHTTPServerEngineFactory.class);

    TestJettyDestination testDestination =
        new TestJettyDestination(b2,
                                 transportFactory.getRegistry(),
                                 ei,
                                 factory);
    testDestination.finalizeConfig();
    Message mi = testDestination.retrieveFromContinuation(httpRequest);
    assertNull("Continuations must be ignored", mi);
}
 
Example 15
Source File: UndertowHTTPDestinationTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testContinuationsIgnored() throws Exception {

    HttpServletRequest httpRequest = EasyMock.createMock(HttpServletRequest.class);

    ServiceInfo serviceInfo = new ServiceInfo();
    serviceInfo.setName(new QName("bla", "Service"));
    EndpointInfo ei = new EndpointInfo(serviceInfo, "");
    ei.setName(new QName("bla", "Port"));

    final UndertowHTTPServerEngine httpEngine = new UndertowHTTPServerEngine();
    httpEngine.setContinuationsEnabled(false);
    UndertowHTTPServerEngineFactory factory = new UndertowHTTPServerEngineFactory() {
        @Override
        public UndertowHTTPServerEngine retrieveUndertowHTTPServerEngine(int port) {
            return httpEngine;
        }
    };
    Bus b2 = new ExtensionManagerBus();
    transportFactory = new HTTPTransportFactory();
    b2.setExtension(factory, UndertowHTTPServerEngineFactory.class);

    TestUndertowDestination testDestination =
        new TestUndertowDestination(b2,
                                 transportFactory.getRegistry(),
                                 ei,
                                 factory);
    testDestination.finalizeConfig();
    Message mi = testDestination.retrieveFromContinuation(httpRequest);
    assertNull("Continuations must be ignored", mi);
}
 
Example 16
Source File: ManagedRMManagerTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private Endpoint createTestEndpoint() throws Exception {
    ServiceInfo svci = new ServiceInfo();
    svci.setName(new QName(TEST_URI, "testService"));
    Service svc = new ServiceImpl(svci);
    SoapBindingInfo binding = new SoapBindingInfo(svci, WSDLConstants.NS_SOAP11);
    binding.setTransportURI(WSDLConstants.NS_SOAP_HTTP_TRANSPORT);
    EndpointInfo ei = new EndpointInfo();
    ei.setAddress(TEST_URI);
    ei.setName(new QName(TEST_URI, "testPort"));
    ei.setBinding(binding);
    ei.setService(svci);
    return new EndpointImpl(bus, svc, ei);
}
 
Example 17
Source File: AbstractJAXRSFactoryBean.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected EndpointInfo createEndpointInfo(Service service) throws BusException {
    String transportId = getTransportId();
    if (transportId == null && getAddress() != null) {
        DestinationFactory df = getDestinationFactory();
        if (df == null) {
            DestinationFactoryManager dfm = getBus().getExtension(DestinationFactoryManager.class);
            df = dfm.getDestinationFactoryForUri(getAddress());
            super.setDestinationFactory(df);
        }

        if (df != null) {
            transportId = df.getTransportIds().get(0);
        }
    }

    //default to http transport
    if (transportId == null) {
        transportId = "http://cxf.apache.org/transports/http";
    }

    setTransportId(transportId);

    //EndpointInfo ei = new EndpointInfo(service.getServiceInfos().get(0), transportId);
    EndpointInfo ei = new EndpointInfo();
    ei.setTransportId(transportId);
    ei.setName(serviceFactory.getService().getName());
    ei.setAddress(getAddress());

    BindingInfo bindingInfo = createBindingInfo();
    ei.setBinding(bindingInfo);

    if (!StringUtils.isEmpty(publishedEndpointUrl)) {
        ei.setProperty("publishedEndpointUrl", publishedEndpointUrl);
    }
    ei.setName(service.getName());
    serviceFactory.sendEvent(FactoryBeanListener.Event.ENDPOINTINFO_CREATED, ei);

    return ei;
}
 
Example 18
Source File: UndertowHTTPDestinationTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testRandomPortAllocation() 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"));

    Destination d1 = transportFactory.getDestination(ei, bus);
    URL url = new URL(d1.getAddress().getAddress().getValue());
    assertTrue("No random port has been allocated",
               url.getPort() > 0);

}
 
Example 19
Source File: MAPAggregatorTest.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Test
public void testGetReplyToUsingBaseAddress() throws Exception {
    Message message = new MessageImpl();
    Exchange exchange = new ExchangeImpl();
    message.setExchange(exchange);

    final String localReplyTo = "/SoapContext/decoupled";
    final String decoupledEndpointBase = "http://localhost:8181/cxf";
    final String replyTo = decoupledEndpointBase + localReplyTo;

    ServiceInfo s = new ServiceInfo();
    Service svc = new ServiceImpl(s);
    EndpointInfo ei = new EndpointInfo();
    InterfaceInfo ii = s.createInterface(new QName("FooInterface"));
    s.setInterface(ii);
    ii.addOperation(new QName("fooOp"));
    SoapBindingInfo b = new SoapBindingInfo(s, "http://schemas.xmlsoap.org/soap/", Soap11.getInstance());
    b.setTransportURI("http://schemas.xmlsoap.org/soap/http");
    ei.setBinding(b);

    ei.setAddress("http://nowhere.com/bar/foo");
    ei.setName(new QName("http://nowhere.com/port", "foo"));
    Bus bus = new ExtensionManagerBus();
    DestinationFactoryManager dfm = control.createMock(DestinationFactoryManager.class);
    DestinationFactory df = control.createMock(DestinationFactory.class);
    Destination d = control.createMock(Destination.class);
    bus.setExtension(dfm, DestinationFactoryManager.class);
    EasyMock.expect(dfm.getDestinationFactoryForUri(localReplyTo)).andReturn(df);
    EasyMock.expect(df.getDestination(
        EasyMock.anyObject(EndpointInfo.class), EasyMock.anyObject(Bus.class))).andReturn(d);
    EasyMock.expect(d.getAddress()).andReturn(EndpointReferenceUtils.getEndpointReference(localReplyTo));

    Endpoint ep = new EndpointImpl(bus, svc, ei);
    exchange.put(Endpoint.class, ep);
    exchange.put(Bus.class, bus);
    exchange.setOutMessage(message);
    setUpMessageProperty(message,
                         REQUESTOR_ROLE,
                         Boolean.TRUE);
    message.getContextualProperty(WSAContextUtils.REPLYTO_PROPERTY);
    message.put(WSAContextUtils.REPLYTO_PROPERTY, localReplyTo);
    message.put(WSAContextUtils.DECOUPLED_ENDPOINT_BASE_PROPERTY, decoupledEndpointBase);

    AddressingProperties maps = new AddressingProperties();
    AttributedURIType id =
        ContextUtils.getAttributedURI("urn:uuid:12345");
    maps.setMessageID(id);
    maps.setAction(ContextUtils.getAttributedURI(""));
    setUpMessageProperty(message,
                         CLIENT_ADDRESSING_PROPERTIES,
                         maps);
    control.replay();
    aggregator.mediate(message, false);
    AddressingProperties props =
        (AddressingProperties)message.get(JAXWSAConstants.ADDRESSING_PROPERTIES_OUTBOUND);

    assertEquals(replyTo, props.getReplyTo().getAddress().getValue());
    control.verify();
}
 
Example 20
Source File: PolicyEngineTest.java    From cxf with Apache License 2.0 4 votes vote down vote up
private EndpointInfo createMockEndpointInfo() throws Exception {
    EndpointInfo ei = new EndpointInfo();
    ei.setName(new QName("mock", "mock"));
    return ei;
}