Search in sources :

Example 56 with ActiveMQResourceAdapter

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

the class ResourceAdapterTest method testSetters.

@Test
public void testSetters() throws Exception {
    Boolean b = Boolean.TRUE;
    Long l = (long) 1000;
    Integer i = 1000;
    Double d = (double) 1000;
    String className = "testConnector";
    String backupConn = "testBackupConnector";
    String testConfig = "key=val";
    String testid = "testid";
    String testBalancer = "testBalancer";
    String testParams = "key=val";
    String testaddress = "testaddress";
    String testpass = "testpass";
    String testuser = "testuser";
    ActiveMQResourceAdapter qResourceAdapter = new ActiveMQResourceAdapter();
    testParams(b, l, i, d, className, backupConn, testConfig, testid, testBalancer, testParams, testaddress, testpass, testuser, qResourceAdapter);
}
Also used : ActiveMQResourceAdapter(org.apache.activemq.artemis.ra.ActiveMQResourceAdapter) Test(org.junit.Test)

Example 57 with ActiveMQResourceAdapter

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

the class ResourceAdapterTest method testResourceAdapterSetupNoHADefault.

@Test
public void testResourceAdapterSetupNoHADefault() throws Exception {
    ActiveMQResourceAdapter qResourceAdapter = new ActiveMQResourceAdapter();
    qResourceAdapter.setConnectorClassName(INVM_CONNECTOR_FACTORY);
    qResourceAdapter.setConnectionParameters("server-id=0");
    ActiveMQRATestBase.MyBootstrapContext ctx = new ActiveMQRATestBase.MyBootstrapContext();
    qResourceAdapter.start(ctx);
    ActiveMQActivationSpec spec = new ActiveMQActivationSpec();
    spec.setResourceAdapter(qResourceAdapter);
    spec.setUseJNDI(false);
    spec.setDestinationType("javax.jms.Queue");
    spec.setDestination(MDBQUEUE);
    ActiveMQConnectionFactory fac = qResourceAdapter.getConnectionFactory(spec);
    assertFalse(fac.isHA());
    qResourceAdapter.stop();
    assertFalse(spec.isHasBeenUpdated());
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory) ActiveMQResourceAdapter(org.apache.activemq.artemis.ra.ActiveMQResourceAdapter) ActiveMQActivationSpec(org.apache.activemq.artemis.ra.inflow.ActiveMQActivationSpec) Test(org.junit.Test)

Example 58 with ActiveMQResourceAdapter

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

the class ResourceAdapterTest method testResourceAdapterSetupOverrideDiscovery.

@Test
public void testResourceAdapterSetupOverrideDiscovery() throws Exception {
    ActiveMQResourceAdapter qResourceAdapter = new ActiveMQResourceAdapter();
    qResourceAdapter.setDiscoveryAddress("231.7.7.7");
    ActiveMQRATestBase.MyBootstrapContext ctx = new ActiveMQRATestBase.MyBootstrapContext();
    qResourceAdapter.start(ctx);
    ActiveMQActivationSpec spec = new ActiveMQActivationSpec();
    spec.setResourceAdapter(qResourceAdapter);
    spec.setUseJNDI(false);
    spec.setDestinationType("javax.jms.Queue");
    spec.setDestination(MDBQUEUE);
    spec.setSetupAttempts(0);
    spec.setDiscoveryAddress("231.6.6.6");
    spec.setDiscoveryPort(1234);
    spec.setDiscoveryInitialWaitTimeout(1L);
    spec.setDiscoveryRefreshTimeout(1L);
    ActiveMQConnectionFactory fac = qResourceAdapter.getConnectionFactory(spec);
    DiscoveryGroupConfiguration dc = fac.getServerLocator().getDiscoveryGroupConfiguration();
    UDPBroadcastEndpointFactory udpDg = (UDPBroadcastEndpointFactory) dc.getBroadcastEndpointFactory();
    assertEquals(udpDg.getGroupAddress(), "231.6.6.6");
    assertEquals(udpDg.getGroupPort(), 1234);
    assertEquals(dc.getRefreshTimeout(), 1L);
    assertEquals(dc.getDiscoveryInitialWaitTimeout(), 1L);
    qResourceAdapter.stop();
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory) ActiveMQResourceAdapter(org.apache.activemq.artemis.ra.ActiveMQResourceAdapter) DiscoveryGroupConfiguration(org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration) ActiveMQActivationSpec(org.apache.activemq.artemis.ra.inflow.ActiveMQActivationSpec) UDPBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory) Test(org.junit.Test)

Example 59 with ActiveMQResourceAdapter

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

the class ResourceAdapterTest method testResourceAdapterSetupHAOverride.

@Test
public void testResourceAdapterSetupHAOverride() throws Exception {
    ActiveMQResourceAdapter qResourceAdapter = new ActiveMQResourceAdapter();
    qResourceAdapter.setConnectorClassName(INVM_CONNECTOR_FACTORY);
    qResourceAdapter.setConnectionParameters("server-id=0");
    ActiveMQRATestBase.MyBootstrapContext ctx = new ActiveMQRATestBase.MyBootstrapContext();
    qResourceAdapter.start(ctx);
    ActiveMQActivationSpec spec = new ActiveMQActivationSpec();
    spec.setResourceAdapter(qResourceAdapter);
    spec.setUseJNDI(false);
    spec.setDestinationType("javax.jms.Queue");
    spec.setDestination(MDBQUEUE);
    spec.setHA(true);
    ActiveMQConnectionFactory fac = qResourceAdapter.getConnectionFactory(spec);
    assertTrue(fac.isHA());
    qResourceAdapter.stop();
    assertTrue(spec.isHasBeenUpdated());
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory) ActiveMQResourceAdapter(org.apache.activemq.artemis.ra.ActiveMQResourceAdapter) ActiveMQActivationSpec(org.apache.activemq.artemis.ra.inflow.ActiveMQActivationSpec) Test(org.junit.Test)

Example 60 with ActiveMQResourceAdapter

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

the class ResourceAdapterTest method testMaskPassword2.

@Test
public void testMaskPassword2() throws Exception {
    ActiveMQResourceAdapter qResourceAdapter = new ActiveMQResourceAdapter();
    qResourceAdapter.setConnectorClassName(INVM_CONNECTOR_FACTORY);
    ActiveMQRATestBase.MyBootstrapContext ctx = new ActiveMQRATestBase.MyBootstrapContext();
    qResourceAdapter.setUseMaskedPassword(true);
    qResourceAdapter.setPasswordCodec(DefaultSensitiveStringCodec.class.getName() + ";key=anotherkey");
    DefaultSensitiveStringCodec codec = new DefaultSensitiveStringCodec();
    Map<String, String> prop = new HashMap<>();
    prop.put("key", "anotherkey");
    codec.init(prop);
    String mask = codec.encode("helloworld");
    qResourceAdapter.setPassword(mask);
    qResourceAdapter.start(ctx);
    assertEquals("helloworld", qResourceAdapter.getPassword());
    ActiveMQActivationSpec spec = new ActiveMQActivationSpec();
    spec.setResourceAdapter(qResourceAdapter);
    spec.setUseJNDI(false);
    spec.setDestinationType("javax.jms.Queue");
    spec.setDestination(MDBQUEUE);
    mask = codec.encode("mdbpassword");
    spec.setPassword(mask);
    qResourceAdapter.setConnectorClassName(INVM_CONNECTOR_FACTORY);
    CountDownLatch latch = new CountDownLatch(1);
    DummyMessageEndpoint endpoint = new DummyMessageEndpoint(latch);
    DummyMessageEndpointFactory endpointFactory = new DummyMessageEndpointFactory(endpoint, false);
    qResourceAdapter.endpointActivation(endpointFactory, spec);
    assertEquals("mdbpassword", spec.getPassword());
    qResourceAdapter.stop();
    assertTrue(endpoint.released);
}
Also used : HashMap(java.util.HashMap) DefaultSensitiveStringCodec(org.apache.activemq.artemis.utils.DefaultSensitiveStringCodec) ActiveMQResourceAdapter(org.apache.activemq.artemis.ra.ActiveMQResourceAdapter) ActiveMQActivationSpec(org.apache.activemq.artemis.ra.inflow.ActiveMQActivationSpec) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Aggregations

ActiveMQResourceAdapter (org.apache.activemq.artemis.ra.ActiveMQResourceAdapter)81 Test (org.junit.Test)72 ActiveMQActivationSpec (org.apache.activemq.artemis.ra.inflow.ActiveMQActivationSpec)54 CountDownLatch (java.util.concurrent.CountDownLatch)39 ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)28 ClientMessage (org.apache.activemq.artemis.api.core.client.ClientMessage)24 ClientProducer (org.apache.activemq.artemis.api.core.client.ClientProducer)24 ActiveMQConnectionFactory (org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory)24 InVMConnectorFactory (org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory)14 ConnectionFactoryProperties (org.apache.activemq.artemis.ra.ConnectionFactoryProperties)10 ActiveMQRAManagedConnectionFactory (org.apache.activemq.artemis.ra.ActiveMQRAManagedConnectionFactory)9 ActiveMQRAConnectionFactoryImpl (org.apache.activemq.artemis.ra.ActiveMQRAConnectionFactoryImpl)8 Binding (org.apache.activemq.artemis.core.postoffice.Binding)7 HashSet (java.util.HashSet)5 ClientSessionFactory (org.apache.activemq.artemis.api.core.client.ClientSessionFactory)5 Role (org.apache.activemq.artemis.core.security.Role)5 ActiveMQActivation (org.apache.activemq.artemis.ra.inflow.ActiveMQActivation)5 Before (org.junit.Before)5 ArrayList (java.util.ArrayList)4 Session (javax.jms.Session)4