use of org.apache.activemq.artemis.ra.ConnectionFactoryProperties in project activemq-artemis by apache.
the class ResourceAdapterTest method testCreateConnectionFactoryOverrideConnector.
@Test
public void testCreateConnectionFactoryOverrideConnector() throws Exception {
ActiveMQResourceAdapter ra = new ActiveMQResourceAdapter();
ra.setConnectorClassName(InVMConnectorFactory.class.getName());
ConnectionFactoryProperties connectionFactoryProperties = new ConnectionFactoryProperties();
ArrayList<String> value = new ArrayList<>();
value.add(NettyConnectorFactory.class.getName());
connectionFactoryProperties.setParsedConnectorClassNames(value);
ActiveMQConnectionFactory factory = ra.getConnectionFactory(connectionFactoryProperties);
ActiveMQConnectionFactory defaultFactory = ra.getDefaultActiveMQConnectionFactory();
Assert.assertNotSame(factory, defaultFactory);
}
use of org.apache.activemq.artemis.ra.ConnectionFactoryProperties in project activemq-artemis by apache.
the class ResourceAdapterTest method testCreateConnectionFactoryOverrideDiscovery.
@Test
public void testCreateConnectionFactoryOverrideDiscovery() throws Exception {
ActiveMQResourceAdapter ra = new ActiveMQResourceAdapter();
ra.setConnectorClassName(InVMConnectorFactory.class.getName());
ConnectionFactoryProperties connectionFactoryProperties = new ConnectionFactoryProperties();
connectionFactoryProperties.setDiscoveryAddress("myhost");
connectionFactoryProperties.setDiscoveryPort(5678);
connectionFactoryProperties.setDiscoveryLocalBindAddress("newAddress");
ActiveMQConnectionFactory factory = ra.getConnectionFactory(connectionFactoryProperties);
ActiveMQConnectionFactory defaultFactory = ra.getDefaultActiveMQConnectionFactory();
Assert.assertNotSame(factory, defaultFactory);
DiscoveryGroupConfiguration dc = factory.getServerLocator().getDiscoveryGroupConfiguration();
UDPBroadcastEndpointFactory udpDg = (UDPBroadcastEndpointFactory) dc.getBroadcastEndpointFactory();
Assert.assertEquals(udpDg.getLocalBindAddress(), "newAddress");
Assert.assertEquals(udpDg.getGroupAddress(), "myhost");
Assert.assertEquals(udpDg.getGroupPort(), 5678);
}
use of org.apache.activemq.artemis.ra.ConnectionFactoryProperties in project activemq-artemis by apache.
the class ConnectionFactoryPropertiesTest method testInequality2.
@Test
public void testInequality2() throws Exception {
ConnectionFactoryProperties cfp1 = new ConnectionFactoryProperties();
List<String> connectorClassNames1 = new ArrayList<>();
connectorClassNames1.add("myConnector");
cfp1.setParsedConnectorClassNames(connectorClassNames1);
List<Map<String, Object>> connectionParameters1 = new ArrayList<>();
Map<String, Object> params1 = new HashMap<>();
params1.put("port", "0");
connectionParameters1.add(params1);
cfp1.setParsedConnectionParameters(connectionParameters1);
cfp1.setAutoGroup(true);
ConnectionFactoryProperties cfp2 = new ConnectionFactoryProperties();
List<String> connectorClassNames2 = new ArrayList<>();
connectorClassNames2.add("myConnector2");
cfp2.setParsedConnectorClassNames(connectorClassNames2);
List<Map<String, Object>> connectionParameters2 = new ArrayList<>();
Map<String, Object> params2 = new HashMap<>();
params2.put("port", "0");
connectionParameters2.add(params2);
cfp2.setParsedConnectionParameters(connectionParameters2);
cfp2.setAutoGroup(true);
assertFalse(cfp1.equals(cfp2));
}
use of org.apache.activemq.artemis.ra.ConnectionFactoryProperties in project activemq-artemis by apache.
the class ConnectionFactoryPropertiesTest method testInequality.
@Test
public void testInequality() throws Exception {
ConnectionFactoryProperties cfp1 = new ConnectionFactoryProperties();
List<String> connectorClassNames1 = new ArrayList<>();
connectorClassNames1.add("myConnector");
cfp1.setParsedConnectorClassNames(connectorClassNames1);
List<Map<String, Object>> connectionParameters1 = new ArrayList<>();
Map<String, Object> params1 = new HashMap<>();
params1.put("port", "0");
connectionParameters1.add(params1);
cfp1.setParsedConnectionParameters(connectionParameters1);
cfp1.setAutoGroup(true);
ConnectionFactoryProperties cfp2 = new ConnectionFactoryProperties();
List<String> connectorClassNames2 = new ArrayList<>();
connectorClassNames2.add("myConnector");
cfp2.setParsedConnectorClassNames(connectorClassNames2);
List<Map<String, Object>> connectionParameters2 = new ArrayList<>();
Map<String, Object> params2 = new HashMap<>();
params2.put("port", "1");
connectionParameters2.add(params2);
cfp2.setParsedConnectionParameters(connectionParameters2);
cfp2.setAutoGroup(true);
assertFalse(cfp1.equals(cfp2));
}
use of org.apache.activemq.artemis.ra.ConnectionFactoryProperties in project activemq-artemis by apache.
the class ResourceAdapterTest method testCreateConnectionFactoryOverrides.
@Test
public void testCreateConnectionFactoryOverrides() throws Exception {
ActiveMQResourceAdapter ra = new ActiveMQResourceAdapter();
ra.setConnectorClassName(InVMConnectorFactory.class.getName());
ConnectionFactoryProperties connectionFactoryProperties = new ConnectionFactoryProperties();
connectionFactoryProperties.setAutoGroup(!ActiveMQClient.DEFAULT_AUTO_GROUP);
connectionFactoryProperties.setBlockOnAcknowledge(!ActiveMQClient.DEFAULT_BLOCK_ON_ACKNOWLEDGE);
connectionFactoryProperties.setBlockOnNonDurableSend(!ActiveMQClient.DEFAULT_BLOCK_ON_NON_DURABLE_SEND);
connectionFactoryProperties.setBlockOnDurableSend(!ActiveMQClient.DEFAULT_BLOCK_ON_DURABLE_SEND);
connectionFactoryProperties.setCallTimeout(1L);
connectionFactoryProperties.setClientFailureCheckPeriod(2L);
connectionFactoryProperties.setClientID("myid");
connectionFactoryProperties.setConnectionLoadBalancingPolicyClassName("mlbcn");
connectionFactoryProperties.setConnectionTTL(3L);
connectionFactoryProperties.setConsumerMaxRate(4);
connectionFactoryProperties.setConsumerWindowSize(5);
connectionFactoryProperties.setDiscoveryInitialWaitTimeout(6L);
connectionFactoryProperties.setDiscoveryRefreshTimeout(7L);
connectionFactoryProperties.setDupsOKBatchSize(8);
connectionFactoryProperties.setMinLargeMessageSize(10);
connectionFactoryProperties.setPreAcknowledge(!ActiveMQClient.DEFAULT_PRE_ACKNOWLEDGE);
connectionFactoryProperties.setProducerMaxRate(11);
connectionFactoryProperties.setConfirmationWindowSize(12);
connectionFactoryProperties.setReconnectAttempts(13);
connectionFactoryProperties.setRetryInterval(14L);
connectionFactoryProperties.setRetryIntervalMultiplier(15d);
connectionFactoryProperties.setScheduledThreadPoolMaxSize(16);
connectionFactoryProperties.setThreadPoolMaxSize(17);
connectionFactoryProperties.setTransactionBatchSize(18);
connectionFactoryProperties.setUseGlobalPools(!ActiveMQClient.DEFAULT_USE_GLOBAL_POOLS);
ActiveMQConnectionFactory factory = ra.getConnectionFactory(connectionFactoryProperties);
Assert.assertEquals(factory.getCallTimeout(), 1);
Assert.assertEquals(factory.getClientFailureCheckPeriod(), 2);
Assert.assertEquals(factory.getClientID(), "myid");
Assert.assertEquals(factory.getConnectionLoadBalancingPolicyClassName(), "mlbcn");
Assert.assertEquals(factory.getConnectionTTL(), 3);
Assert.assertEquals(factory.getConsumerMaxRate(), 4);
Assert.assertEquals(factory.getConsumerWindowSize(), 5);
Assert.assertEquals(factory.getDupsOKBatchSize(), 8);
Assert.assertEquals(factory.getMinLargeMessageSize(), 10);
Assert.assertEquals(factory.getProducerMaxRate(), 11);
Assert.assertEquals(factory.getConfirmationWindowSize(), 12);
Assert.assertEquals(factory.getReconnectAttempts(), 13);
Assert.assertEquals(factory.getRetryInterval(), 14);
Assert.assertEquals(factory.getRetryIntervalMultiplier(), 15d, 0.000001);
Assert.assertEquals(factory.getScheduledThreadPoolMaxSize(), 16);
Assert.assertEquals(factory.getThreadPoolMaxSize(), 17);
Assert.assertEquals(factory.getTransactionBatchSize(), 18);
Assert.assertEquals(factory.isAutoGroup(), !ActiveMQClient.DEFAULT_AUTO_GROUP);
Assert.assertEquals(factory.isBlockOnAcknowledge(), !ActiveMQClient.DEFAULT_BLOCK_ON_ACKNOWLEDGE);
Assert.assertEquals(factory.isBlockOnNonDurableSend(), !ActiveMQClient.DEFAULT_BLOCK_ON_NON_DURABLE_SEND);
Assert.assertEquals(factory.isBlockOnDurableSend(), !ActiveMQClient.DEFAULT_BLOCK_ON_DURABLE_SEND);
Assert.assertEquals(factory.isPreAcknowledge(), !ActiveMQClient.DEFAULT_PRE_ACKNOWLEDGE);
Assert.assertEquals(factory.isUseGlobalPools(), !ActiveMQClient.DEFAULT_USE_GLOBAL_POOLS);
}
Aggregations