@Test
  public void testDefaultConstructor() throws Exception {
    ActiveMQConnectionFactory cf =
        ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF);
    assertFactoryParams(
        cf,
        null,
        null,
        null,
        ActiveMQClient.DEFAULT_CLIENT_FAILURE_CHECK_PERIOD,
        ActiveMQClient.DEFAULT_CONNECTION_TTL,
        ActiveMQClient.DEFAULT_CALL_TIMEOUT,
        ActiveMQClient.DEFAULT_CALL_FAILOVER_TIMEOUT,
        ActiveMQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE,
        ActiveMQClient.DEFAULT_CONSUMER_WINDOW_SIZE,
        ActiveMQClient.DEFAULT_CONSUMER_MAX_RATE,
        ActiveMQClient.DEFAULT_CONFIRMATION_WINDOW_SIZE,
        ActiveMQClient.DEFAULT_PRODUCER_MAX_RATE,
        ActiveMQClient.DEFAULT_BLOCK_ON_ACKNOWLEDGE,
        ActiveMQClient.DEFAULT_BLOCK_ON_DURABLE_SEND,
        ActiveMQClient.DEFAULT_BLOCK_ON_NON_DURABLE_SEND,
        ActiveMQClient.DEFAULT_AUTO_GROUP,
        ActiveMQClient.DEFAULT_PRE_ACKNOWLEDGE,
        ActiveMQClient.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
        ActiveMQClient.DEFAULT_ACK_BATCH_SIZE,
        ActiveMQClient.DEFAULT_ACK_BATCH_SIZE,
        ActiveMQClient.DEFAULT_DISCOVERY_INITIAL_WAIT_TIMEOUT,
        ActiveMQClient.DEFAULT_USE_GLOBAL_POOLS,
        ActiveMQClient.DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE,
        ActiveMQClient.DEFAULT_THREAD_POOL_MAX_SIZE,
        ActiveMQClient.DEFAULT_RETRY_INTERVAL,
        ActiveMQClient.DEFAULT_RETRY_INTERVAL_MULTIPLIER,
        ActiveMQClient.DEFAULT_RECONNECT_ATTEMPTS);
    Connection conn = null;

    try {
      conn = cf.createConnection();

      conn.createSession(false, Session.AUTO_ACKNOWLEDGE);

      Assert.fail("Should throw exception");
    } catch (JMSException e) {
      // Ok
    }
    if (conn != null) {
      conn.close();
    }

    ActiveMQConnectionFactoryTest.log.info("Got here");

    testSettersThrowException(cf);
  }
  @Test
  public void testDiscoveryConstructor() throws Exception {
    DiscoveryGroupConfiguration groupConfiguration =
        new DiscoveryGroupConfiguration()
            .setBroadcastEndpointFactory(
                new UDPBroadcastEndpointFactory()
                    .setGroupAddress(groupAddress)
                    .setGroupPort(groupPort));
    ActiveMQConnectionFactory cf =
        ActiveMQJMSClient.createConnectionFactoryWithoutHA(groupConfiguration, JMSFactoryType.CF);
    assertFactoryParams(
        cf,
        null,
        groupConfiguration,
        null,
        ActiveMQClient.DEFAULT_CLIENT_FAILURE_CHECK_PERIOD,
        ActiveMQClient.DEFAULT_CONNECTION_TTL,
        ActiveMQClient.DEFAULT_CALL_TIMEOUT,
        ActiveMQClient.DEFAULT_CALL_FAILOVER_TIMEOUT,
        ActiveMQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE,
        ActiveMQClient.DEFAULT_CONSUMER_WINDOW_SIZE,
        ActiveMQClient.DEFAULT_CONSUMER_MAX_RATE,
        ActiveMQClient.DEFAULT_CONFIRMATION_WINDOW_SIZE,
        ActiveMQClient.DEFAULT_PRODUCER_MAX_RATE,
        ActiveMQClient.DEFAULT_BLOCK_ON_ACKNOWLEDGE,
        ActiveMQClient.DEFAULT_BLOCK_ON_DURABLE_SEND,
        ActiveMQClient.DEFAULT_BLOCK_ON_NON_DURABLE_SEND,
        ActiveMQClient.DEFAULT_AUTO_GROUP,
        ActiveMQClient.DEFAULT_PRE_ACKNOWLEDGE,
        ActiveMQClient.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
        ActiveMQClient.DEFAULT_ACK_BATCH_SIZE,
        ActiveMQClient.DEFAULT_ACK_BATCH_SIZE,
        ActiveMQClient.DEFAULT_DISCOVERY_INITIAL_WAIT_TIMEOUT,
        ActiveMQClient.DEFAULT_USE_GLOBAL_POOLS,
        ActiveMQClient.DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE,
        ActiveMQClient.DEFAULT_THREAD_POOL_MAX_SIZE,
        ActiveMQClient.DEFAULT_RETRY_INTERVAL,
        ActiveMQClient.DEFAULT_RETRY_INTERVAL_MULTIPLIER,
        ActiveMQClient.DEFAULT_RECONNECT_ATTEMPTS);
    Connection conn = cf.createConnection();

    conn.createSession(false, Session.AUTO_ACKNOWLEDGE);

    testSettersThrowException(cf);

    conn.close();
  }
  @Test
  public void testStaticConnectorLiveConstructor() throws Exception {
    ActiveMQConnectionFactory cf =
        ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, liveTC);
    assertFactoryParams(
        cf,
        new TransportConfiguration[] {liveTC},
        null,
        null,
        ActiveMQClient.DEFAULT_CLIENT_FAILURE_CHECK_PERIOD,
        ActiveMQClient.DEFAULT_CONNECTION_TTL,
        ActiveMQClient.DEFAULT_CALL_TIMEOUT,
        ActiveMQClient.DEFAULT_CALL_FAILOVER_TIMEOUT,
        ActiveMQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE,
        ActiveMQClient.DEFAULT_CONSUMER_WINDOW_SIZE,
        ActiveMQClient.DEFAULT_CONSUMER_MAX_RATE,
        ActiveMQClient.DEFAULT_CONFIRMATION_WINDOW_SIZE,
        ActiveMQClient.DEFAULT_PRODUCER_MAX_RATE,
        ActiveMQClient.DEFAULT_BLOCK_ON_ACKNOWLEDGE,
        ActiveMQClient.DEFAULT_BLOCK_ON_DURABLE_SEND,
        ActiveMQClient.DEFAULT_BLOCK_ON_NON_DURABLE_SEND,
        ActiveMQClient.DEFAULT_AUTO_GROUP,
        ActiveMQClient.DEFAULT_PRE_ACKNOWLEDGE,
        ActiveMQClient.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
        ActiveMQClient.DEFAULT_ACK_BATCH_SIZE,
        ActiveMQClient.DEFAULT_ACK_BATCH_SIZE,
        ActiveMQClient.DEFAULT_DISCOVERY_INITIAL_WAIT_TIMEOUT,
        ActiveMQClient.DEFAULT_USE_GLOBAL_POOLS,
        ActiveMQClient.DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE,
        ActiveMQClient.DEFAULT_THREAD_POOL_MAX_SIZE,
        ActiveMQClient.DEFAULT_RETRY_INTERVAL,
        ActiveMQClient.DEFAULT_RETRY_INTERVAL_MULTIPLIER,
        ActiveMQClient.DEFAULT_RECONNECT_ATTEMPTS);
    Connection conn = cf.createConnection();

    conn.createSession(false, Session.AUTO_ACKNOWLEDGE);

    testSettersThrowException(cf);

    cf.close();

    conn.close();
  }
  @Test
  public void testJmsConnectionFactoryBinding() throws Exception {
    final String clientId = "myClientId";
    final long clientFailureCheckPeriod = 1;
    final long connectionTTl = 2;
    final long callTimeout = 3;
    final long callFailoverTimeout = 4;
    final boolean cacheLargeMessagesClient = true;
    final int minLargeMessageSize = 5;
    final boolean compressLargeMessages = true;
    final int consumerWindowSize = 6;
    final int consumerMaxRate = 7;
    final int confirmationWindowSize = 8;
    final int producerWindowSize = 9;
    final int producerMaxrate = 10;
    final boolean blockOnAcknowledge = true;
    final boolean blockOnDurableSend = false;
    final boolean blockOnNonDurableSend = true;
    final boolean autoGroup = true;
    final boolean preacknowledge = true;
    final String loadBalancingPolicyClassName = "myPolicy";
    final int transactionBatchSize = 11;
    final int dupsOKBatchSize = 12;
    final boolean useGlobalPools = true;
    final int scheduledThreadPoolMaxSize = 13;
    final int threadPoolMaxSize = 14;
    final long retryInterval = 15;
    final double retryIntervalMultiplier = 10.0;
    final long maxRetryInterval = 16;
    final int reconnectAttempts = 17;
    final boolean failoverOnInitialConnection = true;
    final String groupId = "myGroupId";
    final String name = "myFirstConnectionFactoryName";
    final String jndi_binding1 = name + "Binding1";
    final String jndi_binding2 = name + "Binding2";
    final JMSFactoryType type = JMSFactoryType.CF;
    final boolean ha = true;
    final List connectors = Arrays.asList("in-vm1", "in-vm2");

    ClientSession session = basicSetUp();

    jmsServer.createConnectionFactory(
        name,
        ha,
        type,
        connectors,
        clientId,
        clientFailureCheckPeriod,
        connectionTTl,
        callTimeout,
        callFailoverTimeout,
        cacheLargeMessagesClient,
        minLargeMessageSize,
        compressLargeMessages,
        consumerWindowSize,
        consumerMaxRate,
        confirmationWindowSize,
        producerWindowSize,
        producerMaxrate,
        blockOnAcknowledge,
        blockOnDurableSend,
        blockOnNonDurableSend,
        autoGroup,
        preacknowledge,
        loadBalancingPolicyClassName,
        transactionBatchSize,
        dupsOKBatchSize,
        useGlobalPools,
        scheduledThreadPoolMaxSize,
        threadPoolMaxSize,
        retryInterval,
        retryIntervalMultiplier,
        maxRetryInterval,
        reconnectAttempts,
        failoverOnInitialConnection,
        groupId,
        jndi_binding1,
        jndi_binding2);

    jmsServer.createConnectionFactory(
        "mySecondConnectionFactoryName",
        false,
        JMSFactoryType.CF,
        Arrays.asList("in-vm1", "in-vm2"),
        "mySecondConnectionFactoryName1",
        "mySecondConnectionFactoryName2");

    session.close();
    locator.close();
    server.stop();

    ByteArrayOutputStream xmlOutputStream = new ByteArrayOutputStream();
    XmlDataExporter xmlDataExporter = new XmlDataExporter();
    xmlDataExporter.process(
        xmlOutputStream,
        server.getConfiguration().getBindingsLocation().getAbsolutePath(),
        server.getConfiguration().getJournalLocation().getAbsolutePath(),
        server.getConfiguration().getPagingLocation().getAbsolutePath(),
        server.getConfiguration().getLargeMessagesLocation().getAbsolutePath());
    System.out.print(new String(xmlOutputStream.toByteArray()));

    clearDataRecreateServerDirs();
    server.start();
    locator = createInVMNonHALocator();
    factory = createSessionFactory(locator);
    session = factory.createSession(false, true, true);

    ByteArrayInputStream xmlInputStream = new ByteArrayInputStream(xmlOutputStream.toByteArray());
    XmlDataImporter xmlDataImporter = new XmlDataImporter();
    xmlDataImporter.process(xmlInputStream, session);

    ConnectionFactory cf1 = (ConnectionFactory) namingContext.lookup(jndi_binding1);
    assertNotNull(cf1);
    ActiveMQConnectionFactory hcf1 = (ActiveMQConnectionFactory) cf1;
    assertEquals(ha, hcf1.isHA());
    assertEquals(type.intValue(), hcf1.getFactoryType());
    assertEquals(clientId, hcf1.getClientID());
    assertEquals(clientFailureCheckPeriod, hcf1.getClientFailureCheckPeriod());
    assertEquals(connectionTTl, hcf1.getConnectionTTL());
    assertEquals(callTimeout, hcf1.getCallTimeout());
    //      Assert.assertEquals(callFailoverTimeout, hcf1.getCallFailoverTimeout());  // this value
    // isn't currently persisted by
    // org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfigurationImpl.encode()
    //      Assert.assertEquals(cacheLargeMessagesClient, hcf1.isCacheLargeMessagesClient()); //
    // this value isn't currently supported by
    // org.apache.activemq.artemis.api.jms.management.JMSServerControl.createConnectionFactory(java.lang.String, boolean, boolean, int, java.lang.String, java.lang.String, java.lang.String, long, long, long, long, int, boolean, int, int, int, int, int, boolean, boolean, boolean, boolean, boolean, java.lang.String, int, int, boolean, int, int, long, double, long, int, boolean, java.lang.String)
    assertEquals(minLargeMessageSize, hcf1.getMinLargeMessageSize());
    //      Assert.assertEquals(compressLargeMessages, hcf1.isCompressLargeMessage());  // this
    // value isn't currently handled properly by
    // org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl.createConnectionFactory(java.lang.String, boolean, org.apache.activemq.artemis.api.jms.JMSFactoryType, java.util.List<java.lang.String>, java.lang.String, long, long, long, long, boolean, int, boolean, int, int, int, int, int, boolean, boolean, boolean, boolean, boolean, java.lang.String, int, int, boolean, int, int, long, double, long, int, boolean, java.lang.String, java.lang.String...)()
    assertEquals(consumerWindowSize, hcf1.getConsumerWindowSize());
    assertEquals(consumerMaxRate, hcf1.getConsumerMaxRate());
    assertEquals(confirmationWindowSize, hcf1.getConfirmationWindowSize());
    assertEquals(producerWindowSize, hcf1.getProducerWindowSize());
    assertEquals(producerMaxrate, hcf1.getProducerMaxRate());
    assertEquals(blockOnAcknowledge, hcf1.isBlockOnAcknowledge());
    assertEquals(blockOnDurableSend, hcf1.isBlockOnDurableSend());
    assertEquals(blockOnNonDurableSend, hcf1.isBlockOnNonDurableSend());
    assertEquals(autoGroup, hcf1.isAutoGroup());
    assertEquals(preacknowledge, hcf1.isPreAcknowledge());
    assertEquals(loadBalancingPolicyClassName, hcf1.getConnectionLoadBalancingPolicyClassName());
    assertEquals(transactionBatchSize, hcf1.getTransactionBatchSize());
    assertEquals(dupsOKBatchSize, hcf1.getDupsOKBatchSize());
    assertEquals(useGlobalPools, hcf1.isUseGlobalPools());
    assertEquals(scheduledThreadPoolMaxSize, hcf1.getScheduledThreadPoolMaxSize());
    assertEquals(threadPoolMaxSize, hcf1.getThreadPoolMaxSize());
    assertEquals(retryInterval, hcf1.getRetryInterval());
    assertEquals(retryIntervalMultiplier, hcf1.getRetryIntervalMultiplier(), 0);
    assertEquals(maxRetryInterval, hcf1.getMaxRetryInterval());
    assertEquals(reconnectAttempts, hcf1.getReconnectAttempts());
    assertEquals(failoverOnInitialConnection, hcf1.isFailoverOnInitialConnection());
    assertEquals(groupId, hcf1.getGroupID());

    assertNotNull(namingContext.lookup(jndi_binding2));
    assertNotNull(namingContext.lookup("mySecondConnectionFactoryName1"));
    assertNotNull(namingContext.lookup("mySecondConnectionFactoryName2"));
  }
Esempio n. 5
0
 @Override
 protected URI internalNewURI(ActiveMQConnectionFactory bean) throws Exception {
   return InVMServerLocatorSchema.getUri(bean.getStaticConnectors());
 }
  private void assertFactoryParams(
      final ActiveMQConnectionFactory cf,
      final TransportConfiguration[] staticConnectors,
      final DiscoveryGroupConfiguration discoveryGroupConfiguration,
      final String clientID,
      final long clientFailureCheckPeriod,
      final long connectionTTL,
      final long callTimeout,
      final long callFailoverTimeout,
      final int minLargeMessageSize,
      final int consumerWindowSize,
      final int consumerMaxRate,
      final int confirmationWindowSize,
      final int producerMaxRate,
      final boolean blockOnAcknowledge,
      final boolean blockOnDurableSend,
      final boolean blockOnNonDurableSend,
      final boolean autoGroup,
      final boolean preAcknowledge,
      final String loadBalancingPolicyClassName,
      final int dupsOKBatchSize,
      final int transactionBatchSize,
      final long initialWaitTimeout,
      final boolean useGlobalPools,
      final int scheduledThreadPoolMaxSize,
      final int threadPoolMaxSize,
      final long retryInterval,
      final double retryIntervalMultiplier,
      final int reconnectAttempts) {
    TransportConfiguration[] cfStaticConnectors = cf.getStaticConnectors();
    if (staticConnectors == null) {
      Assert.assertNull(staticConnectors);
    } else {
      Assert.assertEquals(staticConnectors.length, cfStaticConnectors.length);

      for (int i = 0; i < staticConnectors.length; i++) {
        Assert.assertEquals(staticConnectors[i], cfStaticConnectors[i]);
      }
    }
    Assert.assertEquals(cf.getClientID(), clientID);
    Assert.assertEquals(cf.getClientFailureCheckPeriod(), clientFailureCheckPeriod);
    Assert.assertEquals(cf.getConnectionTTL(), connectionTTL);
    Assert.assertEquals(cf.getCallTimeout(), callTimeout);
    Assert.assertEquals(cf.getCallFailoverTimeout(), callFailoverTimeout);
    Assert.assertEquals(cf.getMinLargeMessageSize(), minLargeMessageSize);
    Assert.assertEquals(cf.getConsumerWindowSize(), consumerWindowSize);
    Assert.assertEquals(cf.getConsumerMaxRate(), consumerMaxRate);
    Assert.assertEquals(cf.getConfirmationWindowSize(), confirmationWindowSize);
    Assert.assertEquals(cf.getProducerMaxRate(), producerMaxRate);
    Assert.assertEquals(cf.isBlockOnAcknowledge(), blockOnAcknowledge);
    Assert.assertEquals(cf.isBlockOnDurableSend(), blockOnDurableSend);
    Assert.assertEquals(cf.isBlockOnNonDurableSend(), blockOnNonDurableSend);
    Assert.assertEquals(cf.isAutoGroup(), autoGroup);
    Assert.assertEquals(cf.isPreAcknowledge(), preAcknowledge);
    Assert.assertEquals(
        cf.getConnectionLoadBalancingPolicyClassName(), loadBalancingPolicyClassName);
    Assert.assertEquals(cf.getDupsOKBatchSize(), dupsOKBatchSize);
    Assert.assertEquals(cf.getTransactionBatchSize(), transactionBatchSize);
    Assert.assertEquals(cf.isUseGlobalPools(), useGlobalPools);
    Assert.assertEquals(cf.getScheduledThreadPoolMaxSize(), scheduledThreadPoolMaxSize);
    Assert.assertEquals(cf.getThreadPoolMaxSize(), threadPoolMaxSize);
    Assert.assertEquals(cf.getRetryInterval(), retryInterval);
    Assert.assertEquals(cf.getRetryIntervalMultiplier(), retryIntervalMultiplier, 0.00001);
    Assert.assertEquals(cf.getReconnectAttempts(), reconnectAttempts);
  }
  private void testSettersThrowException(final ActiveMQConnectionFactory cf) {

    String discoveryAddress = RandomUtil.randomString();
    int discoveryPort = RandomUtil.randomPositiveInt();
    long discoveryRefreshTimeout = RandomUtil.randomPositiveLong();
    String clientID = RandomUtil.randomString();
    long clientFailureCheckPeriod = RandomUtil.randomPositiveLong();
    long connectionTTL = RandomUtil.randomPositiveLong();
    long callTimeout = RandomUtil.randomPositiveLong();
    int minLargeMessageSize = RandomUtil.randomPositiveInt();
    int consumerWindowSize = RandomUtil.randomPositiveInt();
    int consumerMaxRate = RandomUtil.randomPositiveInt();
    int confirmationWindowSize = RandomUtil.randomPositiveInt();
    int producerMaxRate = RandomUtil.randomPositiveInt();
    boolean blockOnAcknowledge = RandomUtil.randomBoolean();
    boolean blockOnDurableSend = RandomUtil.randomBoolean();
    boolean blockOnNonDurableSend = RandomUtil.randomBoolean();
    boolean autoGroup = RandomUtil.randomBoolean();
    boolean preAcknowledge = RandomUtil.randomBoolean();
    String loadBalancingPolicyClassName = RandomUtil.randomString();
    int dupsOKBatchSize = RandomUtil.randomPositiveInt();
    int transactionBatchSize = RandomUtil.randomPositiveInt();
    long initialWaitTimeout = RandomUtil.randomPositiveLong();
    boolean useGlobalPools = RandomUtil.randomBoolean();
    int scheduledThreadPoolMaxSize = RandomUtil.randomPositiveInt();
    int threadPoolMaxSize = RandomUtil.randomPositiveInt();
    long retryInterval = RandomUtil.randomPositiveLong();
    double retryIntervalMultiplier = RandomUtil.randomDouble();
    int reconnectAttempts = RandomUtil.randomPositiveInt();
    boolean failoverOnServerShutdown = RandomUtil.randomBoolean();

    try {
      cf.setClientID(clientID);
      Assert.fail("Should throw exception");
    } catch (IllegalStateException e) {
      // OK
    }
    try {
      cf.setClientFailureCheckPeriod(clientFailureCheckPeriod);
      Assert.fail("Should throw exception");
    } catch (IllegalStateException e) {
      // OK
    }
    try {
      cf.setConnectionTTL(connectionTTL);
      Assert.fail("Should throw exception");
    } catch (IllegalStateException e) {
      // OK
    }
    try {
      cf.setCallTimeout(callTimeout);
      Assert.fail("Should throw exception");
    } catch (IllegalStateException e) {
      // OK
    }
    try {
      cf.setMinLargeMessageSize(minLargeMessageSize);
      Assert.fail("Should throw exception");
    } catch (IllegalStateException e) {
      // OK
    }
    try {
      cf.setConsumerWindowSize(consumerWindowSize);
      Assert.fail("Should throw exception");
    } catch (IllegalStateException e) {
      // OK
    }
    try {
      cf.setConsumerMaxRate(consumerMaxRate);
      Assert.fail("Should throw exception");
    } catch (IllegalStateException e) {
      // OK
    }
    try {
      cf.setConfirmationWindowSize(confirmationWindowSize);
      Assert.fail("Should throw exception");
    } catch (IllegalStateException e) {
      // OK
    }
    try {
      cf.setProducerMaxRate(producerMaxRate);
      Assert.fail("Should throw exception");
    } catch (IllegalStateException e) {
      // OK
    }
    try {
      cf.setBlockOnAcknowledge(blockOnAcknowledge);
      Assert.fail("Should throw exception");
    } catch (IllegalStateException e) {
      // OK
    }
    try {
      cf.setBlockOnDurableSend(blockOnDurableSend);
      Assert.fail("Should throw exception");
    } catch (IllegalStateException e) {
      // OK
    }
    try {
      cf.setBlockOnNonDurableSend(blockOnNonDurableSend);
      Assert.fail("Should throw exception");
    } catch (IllegalStateException e) {
      // OK
    }
    try {
      cf.setAutoGroup(autoGroup);
      Assert.fail("Should throw exception");
    } catch (IllegalStateException e) {
      // OK
    }
    try {
      cf.setPreAcknowledge(preAcknowledge);
      Assert.fail("Should throw exception");
    } catch (IllegalStateException e) {
      // OK
    }
    try {
      cf.setConnectionLoadBalancingPolicyClassName(loadBalancingPolicyClassName);
      Assert.fail("Should throw exception");
    } catch (IllegalStateException e) {
      // OK
    }
    try {
      cf.setDupsOKBatchSize(dupsOKBatchSize);
      Assert.fail("Should throw exception");
    } catch (IllegalStateException e) {
      // OK
    }
    try {
      cf.setTransactionBatchSize(transactionBatchSize);
      Assert.fail("Should throw exception");
    } catch (IllegalStateException e) {
      // OK
    }
    try {
      cf.setUseGlobalPools(useGlobalPools);
      Assert.fail("Should throw exception");
    } catch (IllegalStateException e) {
      // OK
    }
    try {
      cf.setScheduledThreadPoolMaxSize(scheduledThreadPoolMaxSize);
      Assert.fail("Should throw exception");
    } catch (IllegalStateException e) {
      // OK
    }
    try {
      cf.setThreadPoolMaxSize(threadPoolMaxSize);
      Assert.fail("Should throw exception");
    } catch (IllegalStateException e) {
      // OK
    }
    try {
      cf.setRetryInterval(retryInterval);
      Assert.fail("Should throw exception");
    } catch (IllegalStateException e) {
      // OK
    }
    try {
      cf.setRetryIntervalMultiplier(retryIntervalMultiplier);
      Assert.fail("Should throw exception");
    } catch (IllegalStateException e) {
      // OK
    }
    try {
      cf.setReconnectAttempts(reconnectAttempts);
      Assert.fail("Should throw exception");
    } catch (IllegalStateException e) {
      // OK
    }

    cf.getStaticConnectors();
    cf.getClientID();
    cf.getClientFailureCheckPeriod();
    cf.getConnectionTTL();
    cf.getCallTimeout();
    cf.getMinLargeMessageSize();
    cf.getConsumerWindowSize();
    cf.getConsumerMaxRate();
    cf.getConfirmationWindowSize();
    cf.getProducerMaxRate();
    cf.isBlockOnAcknowledge();
    cf.isBlockOnDurableSend();
    cf.isBlockOnNonDurableSend();
    cf.isAutoGroup();
    cf.isPreAcknowledge();
    cf.getConnectionLoadBalancingPolicyClassName();
    cf.getDupsOKBatchSize();
    cf.getTransactionBatchSize();
    cf.isUseGlobalPools();
    cf.getScheduledThreadPoolMaxSize();
    cf.getThreadPoolMaxSize();
    cf.getRetryInterval();
    cf.getRetryIntervalMultiplier();
    cf.getReconnectAttempts();

    cf.close();
  }
  @Test
  public void testGettersAndSetters() {
    ActiveMQConnectionFactory cf =
        ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, liveTC);

    long clientFailureCheckPeriod = RandomUtil.randomPositiveLong();
    long connectionTTL = RandomUtil.randomPositiveLong();
    long callTimeout = RandomUtil.randomPositiveLong();
    int minLargeMessageSize = RandomUtil.randomPositiveInt();
    int consumerWindowSize = RandomUtil.randomPositiveInt();
    int consumerMaxRate = RandomUtil.randomPositiveInt();
    int confirmationWindowSize = RandomUtil.randomPositiveInt();
    int producerMaxRate = RandomUtil.randomPositiveInt();
    boolean blockOnAcknowledge = RandomUtil.randomBoolean();
    boolean blockOnDurableSend = RandomUtil.randomBoolean();
    boolean blockOnNonDurableSend = RandomUtil.randomBoolean();
    boolean autoGroup = RandomUtil.randomBoolean();
    boolean preAcknowledge = RandomUtil.randomBoolean();
    String loadBalancingPolicyClassName = RandomUtil.randomString();
    boolean useGlobalPools = RandomUtil.randomBoolean();
    int scheduledThreadPoolMaxSize = RandomUtil.randomPositiveInt();
    int threadPoolMaxSize = RandomUtil.randomPositiveInt();
    long retryInterval = RandomUtil.randomPositiveLong();
    double retryIntervalMultiplier = RandomUtil.randomDouble();
    int reconnectAttempts = RandomUtil.randomPositiveInt();
    cf.setClientFailureCheckPeriod(clientFailureCheckPeriod);
    cf.setConnectionTTL(connectionTTL);
    cf.setCallTimeout(callTimeout);
    cf.setMinLargeMessageSize(minLargeMessageSize);
    cf.setConsumerWindowSize(consumerWindowSize);
    cf.setConsumerMaxRate(consumerMaxRate);
    cf.setConfirmationWindowSize(confirmationWindowSize);
    cf.setProducerMaxRate(producerMaxRate);
    cf.setBlockOnAcknowledge(blockOnAcknowledge);
    cf.setBlockOnDurableSend(blockOnDurableSend);
    cf.setBlockOnNonDurableSend(blockOnNonDurableSend);
    cf.setAutoGroup(autoGroup);
    cf.setPreAcknowledge(preAcknowledge);
    cf.setConnectionLoadBalancingPolicyClassName(loadBalancingPolicyClassName);
    cf.setUseGlobalPools(useGlobalPools);
    cf.setScheduledThreadPoolMaxSize(scheduledThreadPoolMaxSize);
    cf.setThreadPoolMaxSize(threadPoolMaxSize);
    cf.setRetryInterval(retryInterval);
    cf.setRetryIntervalMultiplier(retryIntervalMultiplier);
    cf.setReconnectAttempts(reconnectAttempts);
    Assert.assertEquals(clientFailureCheckPeriod, cf.getClientFailureCheckPeriod());
    Assert.assertEquals(connectionTTL, cf.getConnectionTTL());
    Assert.assertEquals(callTimeout, cf.getCallTimeout());
    Assert.assertEquals(minLargeMessageSize, cf.getMinLargeMessageSize());
    Assert.assertEquals(consumerWindowSize, cf.getConsumerWindowSize());
    Assert.assertEquals(consumerMaxRate, cf.getConsumerMaxRate());
    Assert.assertEquals(confirmationWindowSize, cf.getConfirmationWindowSize());
    Assert.assertEquals(producerMaxRate, cf.getProducerMaxRate());
    Assert.assertEquals(blockOnAcknowledge, cf.isBlockOnAcknowledge());
    Assert.assertEquals(blockOnDurableSend, cf.isBlockOnDurableSend());
    Assert.assertEquals(blockOnNonDurableSend, cf.isBlockOnNonDurableSend());
    Assert.assertEquals(autoGroup, cf.isAutoGroup());
    Assert.assertEquals(preAcknowledge, cf.isPreAcknowledge());
    Assert.assertEquals(
        loadBalancingPolicyClassName, cf.getConnectionLoadBalancingPolicyClassName());
    Assert.assertEquals(useGlobalPools, cf.isUseGlobalPools());
    Assert.assertEquals(scheduledThreadPoolMaxSize, cf.getScheduledThreadPoolMaxSize());
    Assert.assertEquals(threadPoolMaxSize, cf.getThreadPoolMaxSize());
    Assert.assertEquals(retryInterval, cf.getRetryInterval());
    Assert.assertEquals(retryIntervalMultiplier, cf.getRetryIntervalMultiplier(), 0.0001);
    Assert.assertEquals(reconnectAttempts, cf.getReconnectAttempts());

    cf.close();
  }
 public boolean isCompressLargeMessages() {
   return cf.isCompressLargeMessage();
 }
 public DiscoveryGroupConfiguration getDiscoveryGroupConfiguration() {
   return cf.getDiscoveryGroupConfiguration();
 }
 public TransportConfiguration[] getStaticConnectors() {
   return cf.getStaticConnectors();
 }
 public int getInitialMessagePacketSize() {
   return cf.getInitialMessagePacketSize();
 }