예제 #1
0
 @Override
 protected URI internalNewURI(ActiveMQConnectionFactory bean) throws Exception {
   return InVMServerLocatorSchema.getUri(bean.getStaticConnectors());
 }
  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();
  }
  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);
  }
 public TransportConfiguration[] getStaticConnectors() {
   return cf.getStaticConnectors();
 }