Search in sources :

Example 11 with ConnectionFactoryProperties

use of org.apache.activemq.artemis.ra.ConnectionFactoryProperties in project activemq-artemis by apache.

the class ResourceAdapterTest method testActivationDeserializationParameters.

@Test
public void testActivationDeserializationParameters() throws Exception {
    ActiveMQServer server = createServer(false);
    try {
        server.start();
        ActiveMQResourceAdapter ra = new ActiveMQResourceAdapter();
        ra.setConnectorClassName(INVM_CONNECTOR_FACTORY);
        ra.setUserName("userGlobal");
        ra.setPassword("passwordGlobal");
        ra.setDeserializationWhiteList("a.b.c.d.e");
        ra.setDeserializationBlackList("f.g.h.i.j");
        ra.start(new BootstrapContext());
        ActiveMQConnectionFactory factory = ra.getDefaultActiveMQConnectionFactory();
        assertEquals("a.b.c.d.e", factory.getDeserializationWhiteList());
        assertEquals("f.g.h.i.j", factory.getDeserializationBlackList());
        ConnectionFactoryProperties overrides = new ConnectionFactoryProperties();
        overrides.setDeserializationWhiteList("k.l.m.n");
        overrides.setDeserializationBlackList("o.p.q.r");
        factory = ra.newConnectionFactory(overrides);
        assertEquals("k.l.m.n", factory.getDeserializationWhiteList());
        assertEquals("o.p.q.r", factory.getDeserializationBlackList());
        ra.stop();
    } finally {
        server.stop();
    }
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory) ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) ConnectionFactoryProperties(org.apache.activemq.artemis.ra.ConnectionFactoryProperties) ActiveMQResourceAdapter(org.apache.activemq.artemis.ra.ActiveMQResourceAdapter) Test(org.junit.Test)

Example 12 with ConnectionFactoryProperties

use of org.apache.activemq.artemis.ra.ConnectionFactoryProperties in project activemq-artemis by apache.

the class ResourceAdapterTest method testCreateConnectionFactoryMultipleConnectorsOverrideAndParams.

@Test
public void testCreateConnectionFactoryMultipleConnectorsOverrideAndParams() {
    ActiveMQResourceAdapter ra = new ActiveMQResourceAdapter();
    ra.setConnectorClassName(NETTY_CONNECTOR_FACTORY + "," + INVM_CONNECTOR_FACTORY + "," + NETTY_CONNECTOR_FACTORY);
    ra.setConnectionParameters("host=host1;port=61616, serverid=0, host=host2;port=61617");
    ConnectionFactoryProperties overrideProperties = new ConnectionFactoryProperties();
    ArrayList<String> value = new ArrayList<>();
    value.add(INVM_CONNECTOR_FACTORY);
    value.add(NETTY_CONNECTOR_FACTORY);
    value.add(INVM_CONNECTOR_FACTORY);
    overrideProperties.setParsedConnectorClassNames(value);
    ArrayList<Map<String, Object>> connectionParameters = new ArrayList<>();
    Map<String, Object> map1 = new HashMap<>();
    map1.put("serverid", "0");
    connectionParameters.add(map1);
    Map<String, Object> map2 = new HashMap<>();
    map2.put("host", "myhost");
    map2.put("port", "61616");
    connectionParameters.add(map2);
    Map<String, Object> map3 = new HashMap<>();
    map3.put("serverid", "1");
    connectionParameters.add(map3);
    overrideProperties.setParsedConnectionParameters(connectionParameters);
    ActiveMQConnectionFactory factory = ra.getConnectionFactory(overrideProperties);
    TransportConfiguration[] configurations = factory.getServerLocator().getStaticTransportConfigurations();
    assertNotNull(configurations);
    assertEquals(3, configurations.length);
    assertEquals(INVM_CONNECTOR_FACTORY, configurations[0].getFactoryClassName());
    assertEquals(1, configurations[0].getParams().size());
    assertEquals("0", configurations[0].getParams().get("serverid"));
    assertEquals(NETTY_CONNECTOR_FACTORY, configurations[1].getFactoryClassName());
    assertEquals(2, configurations[1].getParams().size());
    assertEquals("myhost", configurations[1].getParams().get("host"));
    assertEquals("61616", configurations[1].getParams().get("port"));
    assertEquals(INVM_CONNECTOR_FACTORY, configurations[2].getFactoryClassName());
    assertEquals(1, configurations[2].getParams().size());
    assertEquals("1", configurations[2].getParams().get("serverid"));
}
Also used : ConnectionFactoryProperties(org.apache.activemq.artemis.ra.ConnectionFactoryProperties) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) ActiveMQConnectionFactory(org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory) ActiveMQResourceAdapter(org.apache.activemq.artemis.ra.ActiveMQResourceAdapter) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 13 with ConnectionFactoryProperties

use of org.apache.activemq.artemis.ra.ConnectionFactoryProperties in project activemq-artemis by apache.

the class ResourceAdapterTest method testCreateConnectionFactoryMultipleConnectorsOverride.

@Test
public void testCreateConnectionFactoryMultipleConnectorsOverride() {
    ActiveMQResourceAdapter ra = new ActiveMQResourceAdapter();
    ra.setConnectorClassName(NETTY_CONNECTOR_FACTORY + "," + INVM_CONNECTOR_FACTORY + "," + NETTY_CONNECTOR_FACTORY);
    ConnectionFactoryProperties overrideProperties = new ConnectionFactoryProperties();
    ArrayList<String> value = new ArrayList<>();
    value.add(INVM_CONNECTOR_FACTORY);
    value.add(NETTY_CONNECTOR_FACTORY);
    value.add(INVM_CONNECTOR_FACTORY);
    overrideProperties.setParsedConnectorClassNames(value);
    ActiveMQConnectionFactory factory = ra.getConnectionFactory(overrideProperties);
    TransportConfiguration[] configurations = factory.getServerLocator().getStaticTransportConfigurations();
    assertNotNull(configurations);
    assertEquals(3, configurations.length);
    assertEquals(INVM_CONNECTOR_FACTORY, configurations[0].getFactoryClassName());
    assertEquals(1, configurations[0].getParams().size());
    assertEquals(NETTY_CONNECTOR_FACTORY, configurations[1].getFactoryClassName());
    assertEquals(2, configurations[1].getParams().size());
    assertEquals(INVM_CONNECTOR_FACTORY, configurations[2].getFactoryClassName());
    assertEquals(1, configurations[2].getParams().size());
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory) ConnectionFactoryProperties(org.apache.activemq.artemis.ra.ConnectionFactoryProperties) ArrayList(java.util.ArrayList) ActiveMQResourceAdapter(org.apache.activemq.artemis.ra.ActiveMQResourceAdapter) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) Test(org.junit.Test)

Aggregations

ConnectionFactoryProperties (org.apache.activemq.artemis.ra.ConnectionFactoryProperties)13 Test (org.junit.Test)13 ActiveMQResourceAdapter (org.apache.activemq.artemis.ra.ActiveMQResourceAdapter)10 ActiveMQConnectionFactory (org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory)9 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)4 Map (java.util.Map)4 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)4 InVMConnectorFactory (org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory)4 DiscoveryGroupConfiguration (org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration)1 UDPBroadcastEndpointFactory (org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory)1 NettyConnectorFactory (org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory)1 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)1