Author: rgodfrey
Date: Mon Apr 28 16:32:02 2014
New Revision: 1590699
URL: http://svn.apache.org/r1590699
Log:
QPID-5578 : Address Review comment from Keith Wall re: r1589912
Added:
qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/NoFactoryForCategoryException.java
qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/NoFactoryForTypeException.java
Removed:
qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/AMQUnknownExchangeType.java
Modified:
qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectFactoryImpl.java
qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java
qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostImpl.java
qpid/trunk/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSessionDelegate.java
qpid/trunk/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ExchangeDeclareHandler.java
qpid/trunk/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/VirtualHostManagerMBean.java
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/client/destination/AddressBasedDestinationTest.java
Modified:
qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectFactoryImpl.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectFactoryImpl.java?rev=1590699&r1=1590698&r2=1590699&view=diff
==============================================================================
---
qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectFactoryImpl.java
(original)
+++
qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectFactoryImpl.java
Mon Apr 28 16:32:02 2014
@@ -44,49 +44,42 @@ public class ConfiguredObjectFactoryImpl
public ConfiguredObjectFactoryImpl(Model model)
{
_model = model;
- try
+ QpidServiceLoader<ConfiguredObjectTypeFactory> serviceLoader =
+ new QpidServiceLoader<ConfiguredObjectTypeFactory>();
+ Iterable<ConfiguredObjectTypeFactory> allFactories =
+ serviceLoader.instancesOf(ConfiguredObjectTypeFactory.class);
+ for (ConfiguredObjectTypeFactory factory : allFactories)
{
- QpidServiceLoader<ConfiguredObjectTypeFactory> serviceLoader =
- new QpidServiceLoader<ConfiguredObjectTypeFactory>();
- Iterable<ConfiguredObjectTypeFactory> allFactories =
-
serviceLoader.instancesOf(ConfiguredObjectTypeFactory.class);
- for (ConfiguredObjectTypeFactory factory : allFactories)
- {
- final Class<? extends ConfiguredObject> categoryClass =
factory.getCategoryClass();
- final String categoryName = categoryClass.getSimpleName();
-
- Map<String, ConfiguredObjectTypeFactory> categoryFactories =
_allFactories.get(categoryName);
- if (categoryFactories == null)
- {
- categoryFactories = new HashMap<String,
ConfiguredObjectTypeFactory>();
- _allFactories.put(categoryName, categoryFactories);
- _supportedTypes.put(categoryName, new ArrayList<String>());
- ManagedObject annotation =
categoryClass.getAnnotation(ManagedObject.class);
- if (annotation != null &&
!"".equals(annotation.defaultType()))
- {
- _defaultTypes.put(categoryName,
annotation.defaultType());
- }
- else
- {
- _defaultTypes.put(categoryName, categoryName);
- }
+ final Class<? extends ConfiguredObject> categoryClass =
factory.getCategoryClass();
+ final String categoryName = categoryClass.getSimpleName();
- }
- if (categoryFactories.put(factory.getType(), factory) != null)
+ Map<String, ConfiguredObjectTypeFactory> categoryFactories =
_allFactories.get(categoryName);
+ if (categoryFactories == null)
+ {
+ categoryFactories = new HashMap<String,
ConfiguredObjectTypeFactory>();
+ _allFactories.put(categoryName, categoryFactories);
+ _supportedTypes.put(categoryName, new ArrayList<String>());
+ ManagedObject annotation =
categoryClass.getAnnotation(ManagedObject.class);
+ if (annotation != null && !"".equals(annotation.defaultType()))
{
- throw new ServerScopedRuntimeException(
- "Misconfiguration - there is more than one factory
defined for class " + categoryName
- + " with type " + factory.getType());
+ _defaultTypes.put(categoryName, annotation.defaultType());
}
- if (factory.getType() != null)
+ else
{
- _supportedTypes.get(categoryName).add(factory.getType());
+ _defaultTypes.put(categoryName, categoryName);
}
+
+ }
+ if (categoryFactories.put(factory.getType(), factory) != null)
+ {
+ throw new ServerScopedRuntimeException(
+ "Misconfiguration - there is more than one factory
defined for class " + categoryName
+ + " with type " + factory.getType());
+ }
+ if (factory.getType() != null)
+ {
+ _supportedTypes.get(categoryName).add(factory.getType());
}
- }
- catch (RuntimeException | Error e)
- {
- e.printStackTrace();
}
}
@@ -103,7 +96,7 @@ public class ConfiguredObjectFactoryImpl
if(factory == null)
{
- throw new ServerScopedRuntimeException("No factory defined for
ConfiguredObject of category " + category + " and type " + type);
+ throw new NoFactoryForTypeException(category, type);
}
return factory.recover(this, record, parents);
@@ -115,10 +108,7 @@ public class ConfiguredObjectFactoryImpl
final
ConfiguredObject<?>... parents)
{
ConfiguredObjectTypeFactory<X> factory =
getConfiguredObjectTypeFactory(clazz, attributes);
- if(factory == null)
- {
- throw new ServerScopedRuntimeException("No factory defined for
ConfiguredObject of category " + clazz.getSimpleName() + " and attributes " +
attributes);
- }
+
return factory.create(this, attributes, parents);
}
@@ -130,7 +120,7 @@ public class ConfiguredObjectFactoryImpl
Map<String, ConfiguredObjectTypeFactory> categoryFactories =
_allFactories.get(category);
if(categoryFactories == null)
{
- throw new ServerScopedRuntimeException("No factory defined for
ConfiguredObject of category " + category);
+ throw new NoFactoryForCategoryException(category);
}
String type = (String) attributes.get(ConfiguredObject.TYPE);
@@ -139,6 +129,10 @@ public class ConfiguredObjectFactoryImpl
if(type != null)
{
factory = getConfiguredObjectTypeFactory(category, type);
+ if(factory == null)
+ {
+ throw new NoFactoryForTypeException(category, type);
+ }
}
else
{
@@ -147,6 +141,10 @@ public class ConfiguredObjectFactoryImpl
{
ManagedObject annotation =
categoryClass.getAnnotation(ManagedObject.class);
factory = getConfiguredObjectTypeFactory(category,
annotation.defaultType());
+ if(factory == null)
+ {
+ throw new NoFactoryForTypeException(category,
annotation.defaultType());
+ }
}
}
return factory;
@@ -159,12 +157,16 @@ public class ConfiguredObjectFactoryImpl
Map<String, ConfiguredObjectTypeFactory> categoryFactories =
_allFactories.get(category);
if(categoryFactories == null)
{
- throw new ServerScopedRuntimeException("No factory defined for
ConfiguredObject of category " + category);
+ throw new NoFactoryForCategoryException(category);
}
ConfiguredObjectTypeFactory factory = categoryFactories.get(type);
if(factory == null)
{
factory = categoryFactories.get(_defaultTypes.get(category));
+ if(factory == null)
+ {
+ throw new NoFactoryForTypeException(category,
_defaultTypes.get(category));
+ }
}
return factory;
}
Added:
qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/NoFactoryForCategoryException.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/NoFactoryForCategoryException.java?rev=1590699&view=auto
==============================================================================
---
qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/NoFactoryForCategoryException.java
(added)
+++
qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/NoFactoryForCategoryException.java
Mon Apr 28 16:32:02 2014
@@ -0,0 +1,37 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.server.model;
+
+public class NoFactoryForCategoryException extends RuntimeException
+{
+ private final String _category;
+
+ public NoFactoryForCategoryException(final String category)
+ {
+ super("Unknown category: " + category);
+ _category = category;
+ }
+
+ public String getCategory()
+ {
+ return _category;
+ }
+}
Added:
qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/NoFactoryForTypeException.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/NoFactoryForTypeException.java?rev=1590699&view=auto
==============================================================================
---
qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/NoFactoryForTypeException.java
(added)
+++
qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/NoFactoryForTypeException.java
Mon Apr 28 16:32:02 2014
@@ -0,0 +1,45 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.server.model;
+
+public class NoFactoryForTypeException extends RuntimeException
+{
+ private final String _category;
+ private final String _type;
+
+ public NoFactoryForTypeException(final String category,
+ final String type)
+ {
+ super("Unknown configured object type '"+type+"' of category '" +
category +"'");
+ _category = category;
+ _type = type;
+ }
+
+ public String getCategory()
+ {
+ return _category;
+ }
+
+ public String getType()
+ {
+ return _type;
+ }
+}
Modified:
qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java?rev=1590699&r1=1590698&r2=1590699&view=diff
==============================================================================
---
qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java
(original)
+++
qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java
Mon Apr 28 16:32:02 2014
@@ -41,12 +41,12 @@ import java.util.concurrent.atomic.Atomi
import javax.security.auth.Subject;
import org.apache.log4j.Logger;
+
import org.apache.qpid.exchange.ExchangeDefaults;
import org.apache.qpid.server.configuration.BrokerProperties;
import org.apache.qpid.server.configuration.IllegalConfigurationException;
import org.apache.qpid.server.connection.ConnectionRegistry;
import org.apache.qpid.server.connection.IConnectionRegistry;
-import org.apache.qpid.server.exchange.AMQUnknownExchangeType;
import org.apache.qpid.server.exchange.DefaultDestination;
import org.apache.qpid.server.exchange.ExchangeImpl;
import org.apache.qpid.server.logging.EventLogger;
@@ -671,7 +671,7 @@ public abstract class AbstractVirtualHos
@Override
public ExchangeImpl createExchange(Map<String,Object> attributes)
throws ExchangeExistsException, ReservedExchangeNameException,
- AMQUnknownExchangeType
+ NoFactoryForTypeException
{
checkVHostStateIsActive();
ExchangeImpl child = addExchange(attributes);
@@ -682,7 +682,7 @@ public abstract class AbstractVirtualHos
private ExchangeImpl addExchange(Map<String,Object> attributes)
throws ExchangeExistsException, ReservedExchangeNameException,
- AMQUnknownExchangeType
+ NoFactoryForTypeException
{
try
{
@@ -1329,7 +1329,7 @@ public abstract class AbstractVirtualHos
// We're ok if the exchange already exists
dlExchange = e.getExistingExchange();
}
- catch (ReservedExchangeNameException | AMQUnknownExchangeType |
UnknownConfiguredObjectException e)
+ catch (ReservedExchangeNameException | NoFactoryForTypeException |
UnknownConfiguredObjectException e)
{
throw new ConnectionScopedRuntimeException("Attempt to create an
alternate exchange for a queue failed",e);
}
Modified:
qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostImpl.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostImpl.java?rev=1590699&r1=1590698&r2=1590699&view=diff
==============================================================================
---
qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostImpl.java
(original)
+++
qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostImpl.java
Mon Apr 28 16:32:02 2014
@@ -27,12 +27,12 @@ import java.util.concurrent.ScheduledFut
import org.apache.qpid.common.Closeable;
import org.apache.qpid.server.connection.IConnectionRegistry;
-import org.apache.qpid.server.exchange.AMQUnknownExchangeType;
import org.apache.qpid.server.exchange.ExchangeImpl;
import org.apache.qpid.server.logging.EventLogger;
import org.apache.qpid.server.logging.EventLoggerProvider;
import org.apache.qpid.server.message.MessageDestination;
import org.apache.qpid.server.message.MessageSource;
+import org.apache.qpid.server.model.NoFactoryForTypeException;
import org.apache.qpid.server.model.VirtualHost;
import org.apache.qpid.server.protocol.LinkRegistry;
import org.apache.qpid.server.queue.AMQQueue;
@@ -66,7 +66,7 @@ public interface VirtualHostImpl< X exte
E createExchange(Map<String,Object> attributes)
throws ExchangeExistsException, ReservedExchangeNameException,
- AMQUnknownExchangeType;
+ NoFactoryForTypeException;
void removeExchange(E exchange, boolean force) throws
ExchangeIsAlternateException,
RequiredExchangeException;
Modified:
qpid/trunk/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSessionDelegate.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSessionDelegate.java?rev=1590699&r1=1590698&r2=1590699&view=diff
==============================================================================
---
qpid/trunk/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSessionDelegate.java
(original)
+++
qpid/trunk/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSessionDelegate.java
Mon Apr 28 16:32:02 2014
@@ -33,7 +33,6 @@ import java.util.UUID;
import org.apache.log4j.Logger;
import org.apache.qpid.server.consumer.ConsumerImpl;
-import org.apache.qpid.server.exchange.AMQUnknownExchangeType;
import org.apache.qpid.server.exchange.DirectExchange;
import org.apache.qpid.server.exchange.ExchangeImpl;
import org.apache.qpid.server.exchange.HeadersExchange;
@@ -47,6 +46,7 @@ import org.apache.qpid.server.message.Me
import org.apache.qpid.server.message.MessageSource;
import org.apache.qpid.server.model.ExclusivityPolicy;
import org.apache.qpid.server.model.LifetimePolicy;
+import org.apache.qpid.server.model.NoFactoryForTypeException;
import org.apache.qpid.server.model.Queue;
import org.apache.qpid.server.model.UnknownConfiguredObjectException;
import org.apache.qpid.server.plugin.ExchangeType;
@@ -755,7 +755,7 @@ public class ServerSessionDelegate exten
exception(session, method, ExecutionErrorCode.NOT_FOUND,
"Unknown
alternate exchange " + e.getName());
}
- catch(AMQUnknownExchangeType e)
+ catch(NoFactoryForTypeException e)
{
exception(session, method, ExecutionErrorCode.NOT_FOUND,
"Unknown Exchange Type: " + method.getType());
}
Modified:
qpid/trunk/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ExchangeDeclareHandler.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ExchangeDeclareHandler.java?rev=1590699&r1=1590698&r2=1590699&view=diff
==============================================================================
---
qpid/trunk/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ExchangeDeclareHandler.java
(original)
+++
qpid/trunk/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ExchangeDeclareHandler.java
Mon Apr 28 16:32:02 2014
@@ -33,10 +33,10 @@ import org.apache.qpid.framing.AMQShortS
import org.apache.qpid.framing.ExchangeDeclareBody;
import org.apache.qpid.framing.MethodRegistry;
import org.apache.qpid.protocol.AMQConstant;
-import org.apache.qpid.server.exchange.AMQUnknownExchangeType;
import org.apache.qpid.server.exchange.DirectExchange;
import org.apache.qpid.server.exchange.ExchangeImpl;
import org.apache.qpid.server.model.LifetimePolicy;
+import org.apache.qpid.server.model.NoFactoryForTypeException;
import org.apache.qpid.server.model.UnknownConfiguredObjectException;
import org.apache.qpid.server.protocol.v0_8.AMQChannel;
import org.apache.qpid.server.protocol.v0_8.AMQProtocolSession;
@@ -147,7 +147,7 @@ public class ExchangeDeclareHandler impl
body.getMajor(),
body.getMinor(),null);
}
}
- catch(AMQUnknownExchangeType e)
+ catch(NoFactoryForTypeException e)
{
throw
body.getConnectionException(AMQConstant.COMMAND_INVALID, "Unknown exchange: " +
exchangeName,e);
}
Modified:
qpid/trunk/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/VirtualHostManagerMBean.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/VirtualHostManagerMBean.java?rev=1590699&r1=1590698&r2=1590699&view=diff
==============================================================================
---
qpid/trunk/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/VirtualHostManagerMBean.java
(original)
+++
qpid/trunk/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/VirtualHostManagerMBean.java
Mon Apr 28 16:32:02 2014
@@ -42,10 +42,10 @@ import org.apache.qpid.management.common
import org.apache.qpid.management.common.mbeans.annotations.MBeanConstructor;
import org.apache.qpid.management.common.mbeans.annotations.MBeanDescription;
import
org.apache.qpid.management.common.mbeans.annotations.MBeanOperationParameter;
-import org.apache.qpid.server.exchange.AMQUnknownExchangeType;
import org.apache.qpid.server.jmx.ManagedObject;
import org.apache.qpid.server.model.Exchange;
import org.apache.qpid.server.model.LifetimePolicy;
+import org.apache.qpid.server.model.NoFactoryForTypeException;
import org.apache.qpid.server.model.Queue;
import org.apache.qpid.server.model.VirtualHost;
import org.apache.qpid.server.queue.QueueArgumentsConverter;
@@ -187,7 +187,7 @@ public class VirtualHostManagerMBean ext
{
throw new UnsupportedOperationException("'" + name + "' is a
reserved exchange name");
}
- catch(AMQUnknownExchangeType e)
+ catch(NoFactoryForTypeException e)
{
JMException jme = new JMException(e.getMessage());
throw new MBeanException(jme, "Error in creating exchange " +
name);
Modified:
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/client/destination/AddressBasedDestinationTest.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/client/destination/AddressBasedDestinationTest.java?rev=1590699&r1=1590698&r2=1590699&view=diff
==============================================================================
---
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/client/destination/AddressBasedDestinationTest.java
(original)
+++
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/client/destination/AddressBasedDestinationTest.java
Mon Apr 28 16:32:02 2014
@@ -56,6 +56,7 @@ import org.apache.qpid.client.AMQSession
import org.apache.qpid.client.message.QpidMessageProperties;
import org.apache.qpid.jndi.PropertiesFileInitialContextFactory;
import org.apache.qpid.messaging.Address;
+import org.apache.qpid.protocol.AMQConstant;
import org.apache.qpid.test.utils.QpidBrokerTestCase;
import org.apache.qpid.transport.ExecutionErrorCode;
@@ -270,7 +271,7 @@ public class AddressBasedDestinationTest
public void testCreateExchange() throws Exception
{
- createExchangeImpl(false, false);
+ createExchangeImpl(false, false, false);
}
/**
@@ -279,7 +280,7 @@ public class AddressBasedDestinationTest
*/
public void testCreateExchangeWithArgs() throws Exception
{
- createExchangeImpl(true, false);
+ createExchangeImpl(true, false, false);
}
/**
@@ -289,11 +290,12 @@ public class AddressBasedDestinationTest
*/
public void testCreateExchangeWithNonsenseArgs() throws Exception
{
- createExchangeImpl(true, true);
+ createExchangeImpl(true, true, false);
}
private void createExchangeImpl(final boolean withExchangeArgs,
- final boolean useNonsenseArguments) throws Exception
+ final boolean useNonsenseArguments,
+ final boolean useNonsenseExchangeType)
throws Exception
{
Session jmsSession =
_connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
@@ -305,7 +307,9 @@ public class AddressBasedDestinationTest
"type: topic, " +
"x-declare: " +
"{ " +
- "type:direct, " +
+ "type:" +
+ (useNonsenseExchangeType ? "nonsense" :
"direct") +
+ ", " +
"auto-delete: true" +
createExchangeArgsString(withExchangeArgs,
useNonsenseArguments) +
"}" +
@@ -318,7 +322,7 @@ public class AddressBasedDestinationTest
try
{
cons = jmsSession.createConsumer(dest);
- if(useNonsenseArguments)
+ if(useNonsenseArguments || useNonsenseExchangeType)
{
fail("Expected execution exception during exchange declare did
not occur");
}
@@ -331,6 +335,10 @@ public class AddressBasedDestinationTest
//for. We can't do the rest of the test as a result of the
exception, just stop.
return;
}
+ else if(useNonsenseExchangeType &&
(e.getErrorCode().equals(String.valueOf(AMQConstant.NOT_FOUND.getCode()))))
+ {
+ return;
+ }
else
{
fail("Unexpected exception whilst creating consumer: " + e);
@@ -1239,8 +1247,11 @@ public class AddressBasedDestinationTest
{
assertEquals("Failure code is not as expected", "404",
e.getErrorCode());
}
+ }
-
+ public void testUnknownExchangeType() throws Exception
+ {
+ createExchangeImpl(false, false, true);
}
public void testQueueBrowserWithSelectorAutoAcknowledgement() throws
Exception
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]