use of org.apache.activemq.artemis.ra.ActiveMQResourceAdapter in project activemq-artemis by apache.
the class ResourceAdapterTest method testValidateProperties.
@Test
public void testValidateProperties() throws Exception {
validateGettersAndSetters(new ActiveMQResourceAdapter(), "backupTransportConfiguration", "connectionParameters", "jndiParams");
validateGettersAndSetters(new ActiveMQRAManagedConnectionFactory(), "connectionParameters", "sessionDefaultType", "backupConnectionParameters", "jndiParams");
validateGettersAndSetters(new ActiveMQActivationSpec(), "connectionParameters", "acknowledgeMode", "subscriptionDurability", "jndiParams");
ActiveMQActivationSpec spec = new ActiveMQActivationSpec();
spec.setAcknowledgeMode("DUPS_OK_ACKNOWLEDGE");
Assert.assertEquals("Dups-ok-acknowledge", spec.getAcknowledgeMode());
spec.setSubscriptionDurability("Durable");
Assert.assertEquals("Durable", spec.getSubscriptionDurability());
spec.setSubscriptionDurability("NonDurable");
Assert.assertEquals("NonDurable", spec.getSubscriptionDurability());
spec = new ActiveMQActivationSpec();
ActiveMQResourceAdapter adapter = new ActiveMQResourceAdapter();
adapter.setUserName("us1");
adapter.setPassword("ps1");
adapter.setClientID("cl1");
spec.setResourceAdapter(adapter);
Assert.assertEquals("us1", spec.getUser());
Assert.assertEquals("ps1", spec.getPassword());
spec.setUser("us2");
spec.setPassword("ps2");
spec.setClientID("cl2");
Assert.assertEquals("us2", spec.getUser());
Assert.assertEquals("ps2", spec.getPassword());
Assert.assertEquals("cl2", spec.getClientID());
}
use of org.apache.activemq.artemis.ra.ActiveMQResourceAdapter 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());
}
use of org.apache.activemq.artemis.ra.ActiveMQResourceAdapter in project activemq-artemis by apache.
the class OutgoingConnectionTest method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
ActiveMQJAASSecurityManager securityManager = (ActiveMQJAASSecurityManager) server.getSecurityManager();
securityManager.getConfiguration().addUser("testuser", "testpassword");
securityManager.getConfiguration().addUser("guest", "guest");
securityManager.getConfiguration().setDefaultUser("guest");
securityManager.getConfiguration().addRole("testuser", "arole");
securityManager.getConfiguration().addRole("guest", "arole");
Role role = new Role("arole", true, true, true, true, true, true, true, true, true, true);
Set<Role> roles = new HashSet<>();
roles.add(role);
server.getSecurityRepository().addMatch(MDBQUEUEPREFIXED, roles);
resourceAdapter = new ActiveMQResourceAdapter();
resourceAdapter.setEntries("[\"java://jmsXA\"]");
resourceAdapter.setConnectorClassName(InVMConnectorFactory.class.getName());
MyBootstrapContext ctx = new MyBootstrapContext();
resourceAdapter.start(ctx);
mcf = new ActiveMQRAManagedConnectionFactory();
mcf.setResourceAdapter(resourceAdapter);
qraConnectionFactory = new ActiveMQRAConnectionFactoryImpl(mcf, qraConnectionManager);
}
use of org.apache.activemq.artemis.ra.ActiveMQResourceAdapter in project activemq-artemis by apache.
the class OutgoingConnectionTest method testSharedActiveMQConnectionFactoryWithClose.
@Test
public void testSharedActiveMQConnectionFactoryWithClose() throws Exception {
Session s = null;
Session s2 = null;
ActiveMQRAManagedConnection mc = null;
ActiveMQRAManagedConnection mc2 = null;
try {
server.getConfiguration().setSecurityEnabled(false);
resourceAdapter = new ActiveMQResourceAdapter();
resourceAdapter.setConnectorClassName(InVMConnectorFactory.class.getName());
MyBootstrapContext ctx = new MyBootstrapContext();
resourceAdapter.start(ctx);
ActiveMQRAConnectionManager qraConnectionManager = new ActiveMQRAConnectionManager();
ActiveMQRAManagedConnectionFactory mcf = new ActiveMQRAManagedConnectionFactory();
mcf.setResourceAdapter(resourceAdapter);
ActiveMQRAConnectionFactory qraConnectionFactory = new ActiveMQRAConnectionFactoryImpl(mcf, qraConnectionManager);
QueueConnection queueConnection = qraConnectionFactory.createQueueConnection();
s = queueConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
mc = (ActiveMQRAManagedConnection) ((ActiveMQRASession) s).getManagedConnection();
QueueConnection queueConnection2 = qraConnectionFactory.createQueueConnection();
s2 = queueConnection2.createSession(false, Session.AUTO_ACKNOWLEDGE);
mc2 = (ActiveMQRAManagedConnection) ((ActiveMQRASession) s2).getManagedConnection();
mc.destroy();
MessageProducer producer = s2.createProducer(ActiveMQJMSClient.createQueue(MDBQUEUE));
producer.send(s2.createTextMessage("x"));
} finally {
if (s != null) {
s.close();
}
if (mc != null) {
mc.destroy();
}
if (s2 != null) {
s2.close();
}
if (mc2 != null) {
mc2.destroy();
}
}
}
use of org.apache.activemq.artemis.ra.ActiveMQResourceAdapter in project activemq-artemis by apache.
the class ResourceAdapterTest method testResourceAdapterSetupOverrideNoCFParams.
@Test
public void testResourceAdapterSetupOverrideNoCFParams() 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);
CountDownLatch latch = new CountDownLatch(1);
DummyMessageEndpoint endpoint = new DummyMessageEndpoint(latch);
DummyMessageEndpointFactory endpointFactory = new DummyMessageEndpointFactory(endpoint, false);
qResourceAdapter.endpointActivation(endpointFactory, spec);
qResourceAdapter.stop();
assertFalse(spec.isHasBeenUpdated());
assertTrue(endpoint.released);
}
Aggregations