Applied John Sission's patch: https://issues.apache.org/activemq/browse/AMQ-705 Thanks John!

git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@399701 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Hiram R. Chirino 2006-05-04 13:42:06 +00:00
parent b36e9f804a
commit 3fc0546936
2 changed files with 19 additions and 0 deletions

View File

@ -381,6 +381,13 @@ public class ActiveMQActivationSpec implements ActivationSpec, Serializable {
}
private boolean isValidSubscriptionDurability(List errorMessages) {
// subscriptionDurability only applies to Topics
if ( DURABLE_SUBSCRIPTION.equals(subscriptionDurability) &&
getDestinationType() != null && !Topic.class.getName().equals(getDestinationType())) {
errorMessages.add("subscriptionDurability cannot be set to: "+DURABLE_SUBSCRIPTION+" when destinationType is set to "+
Queue.class.getName()+" as it is only valid when destinationType is set to "+Topic.class.getName()+".");
return false;
}
if (NON_DURABLE_SUBSCRIPTION.equals(subscriptionDurability) || DURABLE_SUBSCRIPTION.equals(subscriptionDurability))
return true;
errorMessages.add("subscriptionDurability must be set to: "+NON_DURABLE_SUBSCRIPTION+" or "+DURABLE_SUBSCRIPTION+".");

View File

@ -197,14 +197,25 @@ public class ActiveMQActivationSpecTest extends TestCase {
//----------- durable subscriber tests
public void testValidDurableSubscriber() {
activationSpec.setDestinationType(Topic.class.getName());
activationSpec.setSubscriptionDurability(ActiveMQActivationSpec.DURABLE_SUBSCRIPTION);
activationSpec.setClientId("foobar");
activationSpec.setSubscriptionName("foobar");
assertActivationSpecValid();
assertTrue(activationSpec.isDurableSubscription());
}
public void testDurableSubscriberWithQueueDestinationTypeFailure() {
activationSpec.setDestinationType(Queue.class.getName());
activationSpec.setSubscriptionDurability(ActiveMQActivationSpec.DURABLE_SUBSCRIPTION);
activationSpec.setClientId("foobar");
activationSpec.setSubscriptionName("foobar");
PropertyDescriptor[] expected = {subscriptionDurabilityProperty};
assertActivationSpecInvalid(expected);
}
public void testDurableSubscriberNoClientIdNoSubscriptionNameFailure() {
activationSpec.setDestinationType(Topic.class.getName());
activationSpec.setSubscriptionDurability(ActiveMQActivationSpec.DURABLE_SUBSCRIPTION);
activationSpec.setClientId(null);
assertNull(activationSpec.getClientId());
@ -215,6 +226,7 @@ public class ActiveMQActivationSpecTest extends TestCase {
}
public void testDurableSubscriberEmptyClientIdEmptySubscriptionNameFailure() {
activationSpec.setDestinationType(Topic.class.getName());
activationSpec.setSubscriptionDurability(ActiveMQActivationSpec.DURABLE_SUBSCRIPTION);
activationSpec.setClientId(EMPTY_STRING);
assertNull(activationSpec.getClientId());