From 224feaeb6610f4c7240cc571f147a942bc64706d Mon Sep 17 00:00:00 2001 From: Martin Ritchie Date: Mon, 25 Sep 2006 10:59:23 +0000 Subject: AMQPFastProtocolHandler.java - Added (Integer appRegId) constructor to allow the AMQPFastProtocolHandler to request the ApplicationRegistry instance. ApplicationRegistry.java - Modified to allow multiple ARs to exist each indexed by an integer id. Default AR of 0 always exists. NullApplicationRegistry.java - Copied from Test cases but modified to have a simple MemoryMessageStore. MemoryMessageStore.java - Added a configure() that uses the class defaults. NullAuthenticationManager.java - Moved from Test Renamed NullApplicationRegistry.java to TestApplicationRegistry.java for the Test cases. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@449643 13f79535-47bb-0310-9956-ffa450edef68 --- .../qpid/server/exchange/HeadersExchangeTest.java | 4 +- .../src/org/apache/qpid/server/queue/AckTest.java | 4 +- .../qpid/server/queue/DeliveryManagerTest.java | 2 - .../qpid/server/queue/MessageTestHelper.java | 4 +- .../org/apache/qpid/server/queue/SendPerfTest.java | 4 +- .../qpid/server/util/NullApplicationRegistry.java | 103 -------------------- .../server/util/NullAuthenticationManager.java | 82 ---------------- .../qpid/server/util/TestApplicationRegistry.java | 104 +++++++++++++++++++++ 8 files changed, 112 insertions(+), 195 deletions(-) delete mode 100644 java/broker/test/src/org/apache/qpid/server/util/NullApplicationRegistry.java delete mode 100644 java/broker/test/src/org/apache/qpid/server/util/NullAuthenticationManager.java create mode 100644 java/broker/test/src/org/apache/qpid/server/util/TestApplicationRegistry.java (limited to 'java/broker/test/src') diff --git a/java/broker/test/src/org/apache/qpid/server/exchange/HeadersExchangeTest.java b/java/broker/test/src/org/apache/qpid/server/exchange/HeadersExchangeTest.java index 86414ffae2..1c594d4374 100644 --- a/java/broker/test/src/org/apache/qpid/server/exchange/HeadersExchangeTest.java +++ b/java/broker/test/src/org/apache/qpid/server/exchange/HeadersExchangeTest.java @@ -21,7 +21,7 @@ import org.junit.Test; import org.junit.Before; import org.apache.qpid.AMQException; import org.apache.qpid.server.registry.ApplicationRegistry; -import org.apache.qpid.server.util.NullApplicationRegistry; +import org.apache.qpid.server.util.TestApplicationRegistry; import junit.framework.JUnit4TestAdapter; public class HeadersExchangeTest extends AbstractHeadersExchangeTest @@ -29,7 +29,7 @@ public class HeadersExchangeTest extends AbstractHeadersExchangeTest @Before public void init() throws Exception { - ApplicationRegistry.initialise(new NullApplicationRegistry()); + ApplicationRegistry.initialise(new TestApplicationRegistry()); } @Test diff --git a/java/broker/test/src/org/apache/qpid/server/queue/AckTest.java b/java/broker/test/src/org/apache/qpid/server/queue/AckTest.java index 904665949c..8ce006b3ae 100644 --- a/java/broker/test/src/org/apache/qpid/server/queue/AckTest.java +++ b/java/broker/test/src/org/apache/qpid/server/queue/AckTest.java @@ -28,7 +28,7 @@ import org.apache.qpid.framing.ContentHeaderBody; import org.apache.qpid.server.AMQChannel; import org.apache.qpid.server.registry.ApplicationRegistry; import org.apache.qpid.server.store.TestableMemoryMessageStore; -import org.apache.qpid.server.util.NullApplicationRegistry; +import org.apache.qpid.server.util.TestApplicationRegistry; import org.apache.log4j.Logger; import java.util.Iterator; @@ -55,7 +55,7 @@ public class AckTest public AckTest() throws Exception { - ApplicationRegistry.initialise(new NullApplicationRegistry()); + ApplicationRegistry.initialise(new TestApplicationRegistry()); } @Before diff --git a/java/broker/test/src/org/apache/qpid/server/queue/DeliveryManagerTest.java b/java/broker/test/src/org/apache/qpid/server/queue/DeliveryManagerTest.java index d00cd55fa1..f84d426877 100644 --- a/java/broker/test/src/org/apache/qpid/server/queue/DeliveryManagerTest.java +++ b/java/broker/test/src/org/apache/qpid/server/queue/DeliveryManagerTest.java @@ -21,8 +21,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import org.junit.Test; import org.apache.qpid.server.handler.OnCurrentThreadExecutor; -import org.apache.qpid.server.registry.ApplicationRegistry; -import org.apache.qpid.server.util.NullApplicationRegistry; import org.apache.qpid.AMQException; import junit.framework.JUnit4TestAdapter; diff --git a/java/broker/test/src/org/apache/qpid/server/queue/MessageTestHelper.java b/java/broker/test/src/org/apache/qpid/server/queue/MessageTestHelper.java index f9baa77b65..6e8e78f74b 100644 --- a/java/broker/test/src/org/apache/qpid/server/queue/MessageTestHelper.java +++ b/java/broker/test/src/org/apache/qpid/server/queue/MessageTestHelper.java @@ -22,7 +22,7 @@ import org.apache.qpid.framing.ContentHeaderBody; import org.apache.qpid.server.store.MessageStore; import org.apache.qpid.server.store.SkeletonMessageStore; import org.apache.qpid.server.registry.ApplicationRegistry; -import org.apache.qpid.server.util.NullApplicationRegistry; +import org.apache.qpid.server.util.TestApplicationRegistry; import org.apache.qpid.AMQException; class MessageTestHelper @@ -31,7 +31,7 @@ class MessageTestHelper MessageTestHelper() throws Exception { - ApplicationRegistry.initialise(new NullApplicationRegistry()); + ApplicationRegistry.initialise(new TestApplicationRegistry()); } AMQMessage message() throws AMQException diff --git a/java/broker/test/src/org/apache/qpid/server/queue/SendPerfTest.java b/java/broker/test/src/org/apache/qpid/server/queue/SendPerfTest.java index eff65a9350..6d1b89176f 100644 --- a/java/broker/test/src/org/apache/qpid/server/queue/SendPerfTest.java +++ b/java/broker/test/src/org/apache/qpid/server/queue/SendPerfTest.java @@ -35,7 +35,7 @@ import org.apache.qpid.server.registry.IApplicationRegistry; import org.apache.qpid.server.store.MessageStore; import org.apache.qpid.server.store.SkeletonMessageStore; import org.apache.qpid.server.util.AveragedRun; -import org.apache.qpid.server.util.NullApplicationRegistry; +import org.apache.qpid.server.util.TestApplicationRegistry; import org.apache.qpid.server.util.TimedRun; import java.util.ArrayList; @@ -77,7 +77,7 @@ public class SendPerfTest extends TimedRun public static void main(String[] argv) throws Exception { - ApplicationRegistry.initialise(new NullApplicationRegistry()); + ApplicationRegistry.initialise(new TestApplicationRegistry()); int clients = Integer.parseInt(argv[0]); int messages = Integer.parseInt(argv[1]); int iterations = Integer.parseInt(argv[2]); diff --git a/java/broker/test/src/org/apache/qpid/server/util/NullApplicationRegistry.java b/java/broker/test/src/org/apache/qpid/server/util/NullApplicationRegistry.java deleted file mode 100644 index 3daf143561..0000000000 --- a/java/broker/test/src/org/apache/qpid/server/util/NullApplicationRegistry.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * - * Copyright (c) 2006 The Apache Software Foundation - * - * Licensed 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.util; - -import org.apache.qpid.server.exchange.DefaultExchangeFactory; -import org.apache.qpid.server.exchange.DefaultExchangeRegistry; -import org.apache.qpid.server.exchange.ExchangeFactory; -import org.apache.qpid.server.exchange.ExchangeRegistry; -import org.apache.qpid.server.management.ManagedObjectRegistry; -import org.apache.qpid.server.management.NoopManagedObjectRegistry; -import org.apache.qpid.server.queue.DefaultQueueRegistry; -import org.apache.qpid.server.queue.QueueRegistry; -import org.apache.qpid.server.registry.ApplicationRegistry; -import org.apache.qpid.server.security.auth.AuthenticationManager; -import org.apache.qpid.server.store.MessageStore; -import org.apache.qpid.server.store.TestableMemoryMessageStore; -import org.apache.commons.configuration.Configuration; -import org.apache.commons.configuration.MapConfiguration; - -import java.util.HashMap; - -public class NullApplicationRegistry extends ApplicationRegistry -{ - private QueueRegistry _queueRegistry; - - private ExchangeRegistry _exchangeRegistry; - - private ExchangeFactory _exchangeFactory; - - private ManagedObjectRegistry _managedObjectRegistry; - - private AuthenticationManager _authenticationManager; - - private MessageStore _messageStore; - - public NullApplicationRegistry() - { - super(new MapConfiguration(new HashMap())); - } - - public void initialise() throws Exception - { - _managedObjectRegistry = new NoopManagedObjectRegistry(); - _queueRegistry = new DefaultQueueRegistry(); - _exchangeFactory = new DefaultExchangeFactory(); - _exchangeRegistry = new DefaultExchangeRegistry(_exchangeFactory); - _authenticationManager = new NullAuthenticationManager(); - _messageStore = new TestableMemoryMessageStore(); - - _configuration.addProperty("heartbeat.delay", 10 * 60); // 10 minutes - } - - public Configuration getConfiguration() - { - return _configuration; - } - - public QueueRegistry getQueueRegistry() - { - return _queueRegistry; - } - - public ExchangeRegistry getExchangeRegistry() - { - return _exchangeRegistry; - } - - public ExchangeFactory getExchangeFactory() - { - return _exchangeFactory; - } - - public ManagedObjectRegistry getManagedObjectRegistry() - { - return _managedObjectRegistry; - } - - public AuthenticationManager getAuthenticationManager() - { - return _authenticationManager; - } - - public MessageStore getMessageStore() - { - return _messageStore; - } -} - diff --git a/java/broker/test/src/org/apache/qpid/server/util/NullAuthenticationManager.java b/java/broker/test/src/org/apache/qpid/server/util/NullAuthenticationManager.java deleted file mode 100644 index cdde505451..0000000000 --- a/java/broker/test/src/org/apache/qpid/server/util/NullAuthenticationManager.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * - * Copyright (c) 2006 The Apache Software Foundation - * - * Licensed 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.util; - -import org.apache.qpid.server.security.auth.AuthenticationManager; -import org.apache.qpid.server.security.auth.AuthenticationResult; - -import javax.security.sasl.SaslException; -import javax.security.sasl.SaslServer; - -public class NullAuthenticationManager implements AuthenticationManager -{ - public String getMechanisms() - { - return "PLAIN"; - } - - public SaslServer createSaslServer(String mechanism, String localFQDN) throws SaslException - { - return new SaslServer() - { - public String getMechanismName() - { - return "PLAIN"; - } - - public byte[] evaluateResponse(byte[] response) throws SaslException - { - return new byte[0]; - } - - public boolean isComplete() - { - return true; - } - - public String getAuthorizationID() - { - return "guest"; - } - - public byte[] unwrap(byte[] incoming, int offset, int len) throws SaslException - { - return new byte[0]; - } - - public byte[] wrap(byte[] outgoing, int offset, int len) throws SaslException - { - return new byte[0]; - } - - public Object getNegotiatedProperty(String propName) - { - return null; - } - - public void dispose() throws SaslException - { - } - }; - } - - public AuthenticationResult authenticate(SaslServer server, byte[] response) - { - return new AuthenticationResult(AuthenticationResult.AuthenticationStatus.SUCCESS); - } -} diff --git a/java/broker/test/src/org/apache/qpid/server/util/TestApplicationRegistry.java b/java/broker/test/src/org/apache/qpid/server/util/TestApplicationRegistry.java new file mode 100644 index 0000000000..69939b88e4 --- /dev/null +++ b/java/broker/test/src/org/apache/qpid/server/util/TestApplicationRegistry.java @@ -0,0 +1,104 @@ +/* + * + * Copyright (c) 2006 The Apache Software Foundation + * + * Licensed 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.util; + +import org.apache.qpid.server.exchange.DefaultExchangeFactory; +import org.apache.qpid.server.exchange.DefaultExchangeRegistry; +import org.apache.qpid.server.exchange.ExchangeFactory; +import org.apache.qpid.server.exchange.ExchangeRegistry; +import org.apache.qpid.server.management.ManagedObjectRegistry; +import org.apache.qpid.server.management.NoopManagedObjectRegistry; +import org.apache.qpid.server.queue.DefaultQueueRegistry; +import org.apache.qpid.server.queue.QueueRegistry; +import org.apache.qpid.server.registry.ApplicationRegistry; +import org.apache.qpid.server.security.auth.AuthenticationManager; +import org.apache.qpid.server.security.auth.NullAuthenticationManager; +import org.apache.qpid.server.store.MessageStore; +import org.apache.qpid.server.store.TestableMemoryMessageStore; +import org.apache.commons.configuration.Configuration; +import org.apache.commons.configuration.MapConfiguration; + +import java.util.HashMap; + +public class TestApplicationRegistry extends ApplicationRegistry +{ + private QueueRegistry _queueRegistry; + + private ExchangeRegistry _exchangeRegistry; + + private ExchangeFactory _exchangeFactory; + + private ManagedObjectRegistry _managedObjectRegistry; + + private AuthenticationManager _authenticationManager; + + private MessageStore _messageStore; + + public TestApplicationRegistry() + { + super(new MapConfiguration(new HashMap())); + } + + public void initialise() throws Exception + { + _managedObjectRegistry = new NoopManagedObjectRegistry(); + _queueRegistry = new DefaultQueueRegistry(); + _exchangeFactory = new DefaultExchangeFactory(); + _exchangeRegistry = new DefaultExchangeRegistry(_exchangeFactory); + _authenticationManager = new NullAuthenticationManager(); + _messageStore = new TestableMemoryMessageStore(); + + _configuration.addProperty("heartbeat.delay", 10 * 60); // 10 minutes + } + + public Configuration getConfiguration() + { + return _configuration; + } + + public QueueRegistry getQueueRegistry() + { + return _queueRegistry; + } + + public ExchangeRegistry getExchangeRegistry() + { + return _exchangeRegistry; + } + + public ExchangeFactory getExchangeFactory() + { + return _exchangeFactory; + } + + public ManagedObjectRegistry getManagedObjectRegistry() + { + return _managedObjectRegistry; + } + + public AuthenticationManager getAuthenticationManager() + { + return _authenticationManager; + } + + public MessageStore getMessageStore() + { + return _messageStore; + } +} + -- cgit v1.2.1