@Test public void testReserveNextSubscriptionLinkNameExceptions() { String topicName = "myTopic"; String subscriptionName1 = "mySubscription1"; AmqpSubscriptionTracker tracker = new AmqpSubscriptionTracker(); JmsConsumerInfo consumerInfo = createConsumerInfo(subscriptionName1, topicName, true, true, true); try { tracker.reserveNextSubscriptionLinkName(null, consumerInfo); fail("Should throw IAE on null subscription name"); } catch (IllegalArgumentException iae) {} try { tracker.reserveNextSubscriptionLinkName("", consumerInfo); fail("Should throw IAE on empty subscription name"); } catch (IllegalArgumentException iae) {} try { tracker.reserveNextSubscriptionLinkName("test" + SUB_NAME_DELIMITER, consumerInfo); fail("Should throw IAE on subscription name with delimiter"); } catch (IllegalArgumentException iae) {} try { tracker.reserveNextSubscriptionLinkName("test", null); fail("Should throw IAE on null Consumer Info"); } catch (IllegalArgumentException iae) {} }
public String reserveNextSubscriptionLinkName(String subscriptionName, JmsConsumerInfo consumerInfo) { validateSubscriptionName(subscriptionName); if(consumerInfo == null) { throw new IllegalArgumentException("Consumer info must not be null."); } if (consumerInfo.isShared()) { if (consumerInfo.isDurable()) { return getSharedDurableSubLinkName(subscriptionName, consumerInfo); } else { return getSharedVolatileSubLinkName(subscriptionName, consumerInfo); } } else if (consumerInfo.isDurable()) { registerExclusiveDurableSub(subscriptionName); return subscriptionName; } else { throw new IllegalStateException("Non-shared non-durable sub link naming is not handled by the tracker."); } }
AmqpSubscriptionTracker { public String reserveNextSubscriptionLinkName(String subscriptionName, JmsConsumerInfo consumerInfo) { validateSubscriptionName(subscriptionName); if(consumerInfo == null) { throw new IllegalArgumentException("Consumer info must not be null."); } if (consumerInfo.isShared()) { if (consumerInfo.isDurable()) { return getSharedDurableSubLinkName(subscriptionName, consumerInfo); } else { return getSharedVolatileSubLinkName(subscriptionName, consumerInfo); } } else if (consumerInfo.isDurable()) { registerExclusiveDurableSub(subscriptionName); return subscriptionName; } else { throw new IllegalStateException("Non-shared non-durable sub link naming is not handled by the tracker."); } } }
AmqpSubscriptionTracker { public String reserveNextSubscriptionLinkName(String subscriptionName, JmsConsumerInfo consumerInfo) { validateSubscriptionName(subscriptionName); if(consumerInfo == null) { throw new IllegalArgumentException("Consumer info must not be null."); } if (consumerInfo.isShared()) { if (consumerInfo.isDurable()) { return getSharedDurableSubLinkName(subscriptionName, consumerInfo); } else { return getSharedVolatileSubLinkName(subscriptionName, consumerInfo); } } else if (consumerInfo.isDurable()) { registerExclusiveDurableSub(subscriptionName); return subscriptionName; } else { throw new IllegalStateException("Non-shared non-durable sub link naming is not handled by the tracker."); } }  }
AmqpSubscriptionTracker { public String reserveNextSubscriptionLinkName(String subscriptionName, JmsConsumerInfo consumerInfo) { validateSubscriptionName(subscriptionName); if(consumerInfo == null) { throw new IllegalArgumentException("Consumer info must not be null."); } if (consumerInfo.isShared()) { if (consumerInfo.isDurable()) { return getSharedDurableSubLinkName(subscriptionName, consumerInfo); } else { return getSharedVolatileSubLinkName(subscriptionName, consumerInfo); } } else if (consumerInfo.isDurable()) { registerExclusiveDurableSub(subscriptionName); return subscriptionName; } else { throw new IllegalStateException("Non-shared non-durable sub link naming is not handled by the tracker."); } }  String reserveNextSubscriptionLinkName(String subscriptionName, JmsConsumerInfo consumerInfo); String getFirstDurableSubscriptionLinkName(String subscriptionName, boolean hasClientID); boolean isActiveExclusiveDurableSub(String subscriptionName); boolean isActiveSharedDurableSub(String subscriptionName); boolean isActiveDurableSub(String subscriptionName); boolean isActiveSharedVolatileSub(String subscriptionName); void consumerRemoved(JmsConsumerInfo consumerInfo); }
AmqpSubscriptionTracker { public String reserveNextSubscriptionLinkName(String subscriptionName, JmsConsumerInfo consumerInfo) { validateSubscriptionName(subscriptionName); if(consumerInfo == null) { throw new IllegalArgumentException("Consumer info must not be null."); } if (consumerInfo.isShared()) { if (consumerInfo.isDurable()) { return getSharedDurableSubLinkName(subscriptionName, consumerInfo); } else { return getSharedVolatileSubLinkName(subscriptionName, consumerInfo); } } else if (consumerInfo.isDurable()) { registerExclusiveDurableSub(subscriptionName); return subscriptionName; } else { throw new IllegalStateException("Non-shared non-durable sub link naming is not handled by the tracker."); } }  String reserveNextSubscriptionLinkName(String subscriptionName, JmsConsumerInfo consumerInfo); String getFirstDurableSubscriptionLinkName(String subscriptionName, boolean hasClientID); boolean isActiveExclusiveDurableSub(String subscriptionName); boolean isActiveSharedDurableSub(String subscriptionName); boolean isActiveDurableSub(String subscriptionName); boolean isActiveSharedVolatileSub(String subscriptionName); void consumerRemoved(JmsConsumerInfo consumerInfo);  }