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();
  }