Search in sources :

Example 1 with JmsUriConfigurator

use of org.talend.esb.mep.requestcallback.beans.JmsUriConfigurator in project tesb-rt-se by Talend.

the class JmsUriConfiguratorTest method testCreateDispatch.

@Test
public void testCreateDispatch() {
    Service service = Service.create(SERVICE_NAME);
    service.addPort(PORT_NAME, SOAPBinding.SOAP11HTTP_BINDING, ADDRESS);
    Dispatch<Source> dispatch = service.createDispatch(PORT_NAME, Source.class, Service.Mode.PAYLOAD);
    Assert.assertNotNull(dispatch);
    JmsUriConfigurator conf = JmsUriConfigurator.create(dispatch);
    Assert.assertNotNull(conf);
    try {
        System.out.println(conf.createJmsAddress());
    } catch (Throwable t) {
        t.printStackTrace();
    }
    Assert.assertEquals("jms:jndi:dynamicQueues/libraryprovider.queue?jndiConnectionFactoryName=ConnectionFactory&jndiInitialContextFactory=org.apache.activemq.jndi.ActiveMQInitialContextFactory&jndiURL=tcp://localhost:61616", conf.getJmsAddress());
    dispatch = conf.configureDispatch(dispatch);
    Assert.assertNotNull(dispatch);
    Client cl = ((DispatchImpl<Source>) dispatch).getClient();
    Assert.assertEquals("jms:jndi:dynamicQueues/libraryprovider.queue?jndiConnectionFactoryName=ConnectionFactory&jndiInitialContextFactory=org.apache.activemq.jndi.ActiveMQInitialContextFactory&jndiURL=tcp://localhost:61616", cl.getRequestContext().get(Message.ENDPOINT_ADDRESS));
    Assert.assertEquals("jms:jndi:dynamicQueues/libraryprovider.queue?jndiConnectionFactoryName=ConnectionFactory&jndiInitialContextFactory=org.apache.activemq.jndi.ActiveMQInitialContextFactory&jndiURL=tcp://localhost:61616", cl.getEndpoint().getEndpointInfo().getAddress());
}
Also used : JmsUriConfigurator(org.talend.esb.mep.requestcallback.beans.JmsUriConfigurator) DispatchImpl(org.apache.cxf.jaxws.DispatchImpl) Service(javax.xml.ws.Service) Client(org.apache.cxf.endpoint.Client) Source(javax.xml.transform.Source) Test(org.junit.Test)

Example 2 with JmsUriConfigurator

use of org.talend.esb.mep.requestcallback.beans.JmsUriConfigurator in project tesb-rt-se by Talend.

the class RequestCallbackJmsTest method subTestServiceCall.

private void subTestServiceCall() throws Exception {
    // server.start();
    final Service service = Service.create(getClass().getResource(wsdlLocation), serviceName);
    service.addPort(portName, endpointInfo.getBinding().getBindingId(), endpointInfo.getAddress());
    // 1. Register a local callback endpoint on the client side
    final ClientProviderHandler callbackHandler = new ClientProviderHandler(errorTransfer, messageTransfer, callbackMap);
    final Endpoint ep = CallContext.createCallbackEndpoint(callbackHandler, wsdlLocation);
    callbackEndpoint = ep;
    JmsUriConfigurator cConfigurator = JmsUriConfigurator.create(ep);
    ep.publish(cConfigurator.getJmsAddress());
    // 2. Create a client
    final Dispatch<StreamSource> dispatcher = service.createDispatch(portName, StreamSource.class, Service.Mode.PAYLOAD);
    CallContext.setupDispatch(dispatcher, ep);
    JmsUriConfigurator configurator = JmsUriConfigurator.create(dispatcher);
    configurator.configureDispatch(dispatcher);
    if (mep == REQUEST_CALLBACK_ENFORCED) {
        final QName opName = new QName(serviceName.getNamespaceURI(), operation);
        CallContext.enforceOperation(opName, dispatcher);
    }
    // 3. Invoke the service operation
    final StreamSource request = new StreamSource(getClass().getResourceAsStream(requestLocation));
    dispatcher.invokeOneWay(request);
    assertTrue(messageTransfer.take() != null);
    sleep(1);
    checkError(false);
}
Also used : Endpoint(javax.xml.ws.Endpoint) JmsUriConfigurator(org.talend.esb.mep.requestcallback.beans.JmsUriConfigurator) QName(javax.xml.namespace.QName) StreamSource(javax.xml.transform.stream.StreamSource) Service(javax.xml.ws.Service) ClientProviderHandler(org.talend.esb.mep.requestcallback.sample.internal.ClientProviderHandler)

Example 3 with JmsUriConfigurator

use of org.talend.esb.mep.requestcallback.beans.JmsUriConfigurator in project tesb-rt-se by Talend.

the class RequestCallbackJmsTest method subTestServerStartup.

private void subTestServerStartup() throws Exception {
    final SeekBookInBasementHandler businessHandler = new SeekBookInBasementHandler(responseLocation, "classpath:" + wsdlLocation);
    final ServiceProviderHandler implementor = new ServiceProviderHandler(errorTransfer, messageTransfer, businessHandler, operation);
    final JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
    factory.setServiceName(serviceName);
    factory.setEndpointName(portName);
    factory.setWsdlLocation(wsdlLocation);
    factory.setServiceBean(implementor);
    CallContext.setupServerFactory(factory);
    JmsUriConfigurator configurator = JmsUriConfigurator.create(factory);
    factory.setAddress(configurator.getJmsAddress());
    server = factory.create();
    sleep(1);
    checkError(false);
}
Also used : ServiceProviderHandler(org.talend.esb.mep.requestcallback.sample.internal.ServiceProviderHandler) JmsUriConfigurator(org.talend.esb.mep.requestcallback.beans.JmsUriConfigurator) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean) SeekBookInBasementHandler(org.talend.esb.mep.requestcallback.sample.internal.SeekBookInBasementHandler)

Example 4 with JmsUriConfigurator

use of org.talend.esb.mep.requestcallback.beans.JmsUriConfigurator in project tesb-rt-se by Talend.

the class JmsUriConfiguratorTest method testCreateFactory.

@Test
public void testCreateFactory() {
    JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
    factory.setServiceName(new QName("http://internal.test.requestcallback.mep.esb.talend.org/", "HelloWorldImplService"));
    factory.setEndpointName(new QName("http://internal.test.requestcallback.mep.esb.talend.org/", "HelloWorldImplServiceInstance1"));
    JmsUriConfigurator conf = JmsUriConfigurator.create(factory);
    Assert.assertNotNull(conf);
    Assert.assertEquals("HelloWorldImplServiceInstance1", conf.getConfigurationPrefix());
    Assert.assertEquals(new QName("http://internal.test.requestcallback.mep.esb.talend.org/", "HelloWorldImplService"), conf.getServiceName());
}
Also used : JmsUriConfigurator(org.talend.esb.mep.requestcallback.beans.JmsUriConfigurator) QName(javax.xml.namespace.QName) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean) Test(org.junit.Test)

Example 5 with JmsUriConfigurator

use of org.talend.esb.mep.requestcallback.beans.JmsUriConfigurator in project tesb-rt-se by Talend.

the class JmsUriConfiguratorTest method testCreateEndpoint.

@Test
public void testCreateEndpoint() {
    HelloWorldImpl implementor = new HelloWorldImpl();
    String address = "local://JmsUriConfiguratorTest";
    ep = Endpoint.publish(address, implementor);
    Assert.assertNotNull(ep);
    Assert.assertTrue(ep instanceof EndpointImpl);
    JmsUriConfigurator conf = JmsUriConfigurator.create(ep);
    Assert.assertNotNull(conf);
    JmsUriConfiguration jmsConf = conf.createJmsUriConfiguration();
    Assert.assertNotNull(jmsConf);
    System.out.println("Configurator identifier is: " + conf.getConfiguration().getConfigurationIdentifier());
    Assert.assertNotNull(conf.getConfiguration().getProperty("jndiInitialContextFactory"));
    Assert.assertEquals("org.apache.activemq.jndi.ActiveMQInitialContextFactory", conf.getConfiguration().getProperty("jndiInitialContextFactory"));
    // --------------------------------------------------------------------------------------------------
    conf.setPresetJmsAddress("jms://");
    conf.setVariant(jmsConf.getVariant());
    conf.setDefaultVariant("jndi");
    conf.setDestinationName(jmsConf.getDestinationName());
    conf.setDefaultDestinationName("defaultDestinationName");
    conf.setEndpointName("JmsUriConfiguratorTest");
    Assert.assertEquals("jms://", conf.getPresetJmsAddress());
    Assert.assertEquals("jndi", conf.getVariant());
    Assert.assertEquals("jndi", conf.getDefaultVariant());
    Assert.assertEquals("dynamicQueues/libraryprovider.queue", conf.getDestinationName());
    Assert.assertEquals("defaultDestinationName", conf.getDefaultDestinationName());
    Assert.assertEquals("jms:jndi:dynamicQueues/libraryprovider.queue?jndiConnectionFactoryName=ConnectionFactory&jndiInitialContextFactory=org.apache.activemq.jndi.ActiveMQInitialContextFactory&jndiURL=tcp://localhost:61616", conf.getJmsAddress());
    Assert.assertEquals("http://internal.test.requestcallback.mep.esb.talend.org/", conf.getServiceName().getNamespaceURI());
    Assert.assertEquals("HelloWorldImplService", conf.getServiceName().getLocalPart());
    Assert.assertEquals(new QName(null, "JmsUriConfiguratorTest"), conf.getEndpointName());
    Assert.assertEquals("JmsUriConfiguratorTest", conf.getConfigurationPrefix());
    Map<String, Object> m = new HashMap<String, Object>();
    m.put("key1", "val1");
    conf.setDefaultParameters(m);
    Map m2 = conf.getDefaultParameters();
    Assert.assertNotNull(m2);
    Assert.assertEquals(1, m2.size());
    Assert.assertTrue(m2.containsKey("key1"));
    Assert.assertTrue(m2.containsValue("val1"));
    conf.setParameters(m);
    m2 = conf.getParameters();
    Assert.assertNotNull(m2);
    Assert.assertEquals(1, m2.size());
    Assert.assertTrue(m2.containsKey("key1"));
    Assert.assertTrue(m2.containsValue("val1"));
    String jmsAddr = conf.getJmsAddress();
    Assert.assertEquals(jmsAddr, conf.resetJmsAddress());
    Assert.assertNotNull(conf.getJmsAddress());
    conf.setServiceName("{http://example.com/}AService");
    Assert.assertEquals(new QName("http://example.com/", "AService"), conf.getServiceName());
    conf.setEndpointName(new QName("http://example.com/", "AService"));
    Assert.assertEquals(new QName("http://example.com/", "AService"), conf.getEndpointName());
    conf.setEncodeURI(true);
    Assert.assertTrue(conf.isEncodeURI());
    conf.setEncodeURI("none");
    Assert.assertFalse(conf.isEncodeURI());
    conf.setConfiguration(null);
    Assert.assertNull(conf.getConfiguration());
}
Also used : JmsUriConfiguration(org.talend.esb.mep.requestcallback.beans.JmsUriConfiguration) HelloWorldImpl(org.talend.esb.mep.requestcallback.test.internal.HelloWorldImpl) JmsUriConfigurator(org.talend.esb.mep.requestcallback.beans.JmsUriConfigurator) HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) EndpointImpl(org.apache.cxf.jaxws.EndpointImpl) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Aggregations

JmsUriConfigurator (org.talend.esb.mep.requestcallback.beans.JmsUriConfigurator)5 QName (javax.xml.namespace.QName)3 Test (org.junit.Test)3 Service (javax.xml.ws.Service)2 JaxWsServerFactoryBean (org.apache.cxf.jaxws.JaxWsServerFactoryBean)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Source (javax.xml.transform.Source)1 StreamSource (javax.xml.transform.stream.StreamSource)1 Endpoint (javax.xml.ws.Endpoint)1 Client (org.apache.cxf.endpoint.Client)1 DispatchImpl (org.apache.cxf.jaxws.DispatchImpl)1 EndpointImpl (org.apache.cxf.jaxws.EndpointImpl)1 JmsUriConfiguration (org.talend.esb.mep.requestcallback.beans.JmsUriConfiguration)1 ClientProviderHandler (org.talend.esb.mep.requestcallback.sample.internal.ClientProviderHandler)1 SeekBookInBasementHandler (org.talend.esb.mep.requestcallback.sample.internal.SeekBookInBasementHandler)1 ServiceProviderHandler (org.talend.esb.mep.requestcallback.sample.internal.ServiceProviderHandler)1 HelloWorldImpl (org.talend.esb.mep.requestcallback.test.internal.HelloWorldImpl)1