use of org.apache.activemq.artemis.ra.inflow.ActiveMQActivationSpec in project activemq-artemis by apache.
the class ActiveMQMessageHandlerTest method testInvalidAckMode.
@Test
public void testInvalidAckMode() throws Exception {
ActiveMQResourceAdapter qResourceAdapter = newResourceAdapter();
MyBootstrapContext ctx = new MyBootstrapContext();
qResourceAdapter.start(ctx);
ActiveMQActivationSpec spec = new ActiveMQActivationSpec();
try {
spec.setAcknowledgeMode("CLIENT_ACKNOWLEDGE");
fail("should throw exception");
} catch (java.lang.IllegalArgumentException e) {
// pass
}
qResourceAdapter.stop();
}
use of org.apache.activemq.artemis.ra.inflow.ActiveMQActivationSpec in project activemq-artemis by apache.
the class ResourceAdapterTest method testMaskPassword.
@Test
public void testMaskPassword() throws Exception {
ActiveMQResourceAdapter qResourceAdapter = new ActiveMQResourceAdapter();
qResourceAdapter.setConnectorClassName(INVM_CONNECTOR_FACTORY);
ActiveMQRATestBase.MyBootstrapContext ctx = new ActiveMQRATestBase.MyBootstrapContext();
DefaultSensitiveStringCodec codec = new DefaultSensitiveStringCodec();
String mask = codec.encode("helloworld");
qResourceAdapter.setUseMaskedPassword(true);
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 = (String) 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);
}
use of org.apache.activemq.artemis.ra.inflow.ActiveMQActivationSpec in project activemq-artemis by apache.
the class ResourceAdapterTest method testResourceAdapterSetupReconnectAttemptsOverride.
@Test
public void testResourceAdapterSetupReconnectAttemptsOverride() 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.setReconnectAttempts(100);
ActiveMQConnectionFactory fac = qResourceAdapter.getConnectionFactory(spec);
assertEquals(100, fac.getReconnectAttempts());
qResourceAdapter.stop();
assertTrue(spec.isHasBeenUpdated());
}
use of org.apache.activemq.artemis.ra.inflow.ActiveMQActivationSpec in project activemq-artemis by apache.
the class ResourceAdapterTest method testMaskPassword2ENC.
@Test
public void testMaskPassword2ENC() throws Exception {
ActiveMQResourceAdapter qResourceAdapter = new ActiveMQResourceAdapter();
qResourceAdapter.setConnectorClassName(INVM_CONNECTOR_FACTORY);
ActiveMQRATestBase.MyBootstrapContext ctx = new ActiveMQRATestBase.MyBootstrapContext();
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(PasswordMaskingUtil.wrap(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(PasswordMaskingUtil.wrap(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);
}
use of org.apache.activemq.artemis.ra.inflow.ActiveMQActivationSpec in project activemq-artemis by apache.
the class ResourceAdapterTest method testResourceAdapterSetupNoOverrideDiscovery.
@Test
public void testResourceAdapterSetupNoOverrideDiscovery() throws Exception {
ActiveMQResourceAdapter qResourceAdapter = new ActiveMQResourceAdapter();
qResourceAdapter.setDiscoveryAddress("231.6.6.6");
qResourceAdapter.setDiscoveryPort(1234);
qResourceAdapter.setDiscoveryRefreshTimeout(1L);
qResourceAdapter.setDiscoveryInitialWaitTimeout(1L);
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);
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();
}
Aggregations