use of org.apache.activemq.artemis.ra.ConnectionFactoryProperties in project activemq-artemis by apache.
the class ConnectionFactoryPropertiesTest method testEquality.
@Test
public void testEquality() 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", "0");
connectionParameters2.add(params2);
cfp2.setParsedConnectionParameters(connectionParameters2);
cfp2.setAutoGroup(true);
assertTrue(cfp1.equals(cfp2));
}
use of org.apache.activemq.artemis.ra.ConnectionFactoryProperties in project activemq-artemis by apache.
the class ResourceAdapterTest method testCreateConnectionFactoryNoOverrides.
@Test
public void testCreateConnectionFactoryNoOverrides() throws Exception {
ActiveMQResourceAdapter ra = new ActiveMQResourceAdapter();
ra.setConnectorClassName(InVMConnectorFactory.class.getName());
ActiveMQConnectionFactory factory = ra.getConnectionFactory(new ConnectionFactoryProperties());
Assert.assertEquals(factory.getCallTimeout(), ActiveMQClient.DEFAULT_CALL_TIMEOUT);
Assert.assertEquals(factory.getClientFailureCheckPeriod(), ActiveMQClient.DEFAULT_CLIENT_FAILURE_CHECK_PERIOD);
Assert.assertEquals(factory.getClientID(), null);
Assert.assertEquals(factory.getConnectionLoadBalancingPolicyClassName(), ActiveMQClient.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME);
Assert.assertEquals(factory.getConnectionTTL(), ActiveMQClient.DEFAULT_CONNECTION_TTL);
Assert.assertEquals(factory.getConsumerMaxRate(), ActiveMQClient.DEFAULT_CONSUMER_MAX_RATE);
Assert.assertEquals(factory.getConsumerWindowSize(), ActiveMQClient.DEFAULT_CONSUMER_WINDOW_SIZE);
Assert.assertEquals(factory.getDupsOKBatchSize(), ActiveMQClient.DEFAULT_ACK_BATCH_SIZE);
Assert.assertEquals(factory.getMinLargeMessageSize(), ActiveMQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE);
Assert.assertEquals(factory.getProducerMaxRate(), ActiveMQClient.DEFAULT_PRODUCER_MAX_RATE);
Assert.assertEquals(factory.getConfirmationWindowSize(), ActiveMQClient.DEFAULT_CONFIRMATION_WINDOW_SIZE);
// by default, reconnect attempts is set to -1
Assert.assertEquals(-1, factory.getReconnectAttempts());
Assert.assertEquals(factory.getRetryInterval(), ActiveMQClient.DEFAULT_RETRY_INTERVAL);
Assert.assertEquals(factory.getRetryIntervalMultiplier(), ActiveMQClient.DEFAULT_RETRY_INTERVAL_MULTIPLIER, 0.000001);
Assert.assertEquals(factory.getScheduledThreadPoolMaxSize(), ActiveMQClient.DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE);
Assert.assertEquals(factory.getThreadPoolMaxSize(), ActiveMQClient.DEFAULT_THREAD_POOL_MAX_SIZE);
Assert.assertEquals(factory.getTransactionBatchSize(), ActiveMQClient.DEFAULT_ACK_BATCH_SIZE);
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);
}
use of org.apache.activemq.artemis.ra.ConnectionFactoryProperties in project activemq-artemis by apache.
the class ResourceAdapterTest method testCreateConnectionFactoryThrowsException.
@Test
public void testCreateConnectionFactoryThrowsException() throws Exception {
ActiveMQResourceAdapter ra = new ActiveMQResourceAdapter();
ConnectionFactoryProperties connectionFactoryProperties = new ConnectionFactoryProperties();
try {
ra.getConnectionFactory(connectionFactoryProperties);
Assert.fail("should throw exception");
} catch (IllegalArgumentException e) {
// pass
}
}
use of org.apache.activemq.artemis.ra.ConnectionFactoryProperties in project activemq-artemis by apache.
the class ResourceAdapterTest method testCreateConnectionFactoryMultipleConnectors.
@Test
public void testCreateConnectionFactoryMultipleConnectors() {
ActiveMQResourceAdapter ra = new ActiveMQResourceAdapter();
ra.setConnectorClassName(NETTY_CONNECTOR_FACTORY + "," + INVM_CONNECTOR_FACTORY + "," + NETTY_CONNECTOR_FACTORY);
ActiveMQConnectionFactory factory = ra.getConnectionFactory(new ConnectionFactoryProperties());
TransportConfiguration[] configurations = factory.getServerLocator().getStaticTransportConfigurations();
assertNotNull(configurations);
assertEquals(3, configurations.length);
assertEquals(NETTY_CONNECTOR_FACTORY, configurations[0].getFactoryClassName());
assertEquals(2, configurations[0].getParams().size());
assertEquals(INVM_CONNECTOR_FACTORY, configurations[1].getFactoryClassName());
assertEquals(1, configurations[1].getParams().size());
assertEquals(NETTY_CONNECTOR_FACTORY, configurations[2].getFactoryClassName());
assertEquals(2, configurations[2].getParams().size());
}
use of org.apache.activemq.artemis.ra.ConnectionFactoryProperties in project activemq-artemis by apache.
the class ResourceAdapterTest method testCreateConnectionFactoryMultipleConnectorsAndParams.
@Test
public void testCreateConnectionFactoryMultipleConnectorsAndParams() {
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");
ActiveMQConnectionFactory factory = ra.getConnectionFactory(new ConnectionFactoryProperties());
TransportConfiguration[] configurations = factory.getServerLocator().getStaticTransportConfigurations();
assertNotNull(configurations);
assertEquals(3, configurations.length);
assertEquals(NETTY_CONNECTOR_FACTORY, configurations[0].getFactoryClassName());
assertEquals(2, configurations[0].getParams().size());
assertEquals("host1", configurations[0].getParams().get("host"));
assertEquals("61616", configurations[0].getParams().get("port"));
assertEquals(INVM_CONNECTOR_FACTORY, configurations[1].getFactoryClassName());
assertEquals(1, configurations[1].getParams().size());
assertEquals("0", configurations[1].getParams().get("serverid"));
assertEquals(NETTY_CONNECTOR_FACTORY, configurations[2].getFactoryClassName());
assertEquals(2, configurations[2].getParams().size());
assertEquals("host2", configurations[2].getParams().get("host"));
assertEquals("61617", configurations[2].getParams().get("port"));
}
Aggregations