Author: ritchiem Date: Mon Aug 3 13:31:23 2009 New Revision: 800372 URL: http://svn.apache.org/viewvc?rev=800372&view=rev Log: QPID-1230 : Removed MockProtocolSession, Updated all references to use InternalTestProtocolSession IPTS was also updated to take a VirtualHost parameter that is then used to configured the AMQProtocolSession
Removed: qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/MockProtocolSession.java Modified: qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/AbstractHeadersExchangeTestBase.java qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/DestWildExchangeTest.java qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/HeadersExchangeTest.java qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/AMQPChannelActorTest.java qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/AMQPConnectionActorTest.java qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/CurrentActorTest.java qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/AbstractTestLogSubject.java qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/ChannelLogSubjectTest.java qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/ConnectionLogSubjectTest.java qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/SubscriptionLogSubjectTest.java qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/protocol/InternalTestProtocolSession.java qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueAlertTest.java qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueMBeanTest.java qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AckTest.java qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/security/access/ACLManagerTest.java qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/store/MessageStoreTest.java qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/util/InternalBrokerBaseCase.java Modified: qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/AbstractHeadersExchangeTestBase.java URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/AbstractHeadersExchangeTestBase.java?rev=800372&r1=800371&r2=800372&view=diff ============================================================================== --- qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/AbstractHeadersExchangeTestBase.java (original) +++ qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/AbstractHeadersExchangeTestBase.java Mon Aug 3 13:31:23 2009 @@ -33,6 +33,7 @@ import org.apache.qpid.server.txn.NonTransactionalContext; import org.apache.qpid.server.txn.TransactionalContext; import org.apache.qpid.server.RequiredDeliveryException; +import org.apache.qpid.server.virtualhost.VirtualHost; import org.apache.qpid.server.subscription.Subscription; import org.apache.qpid.server.protocol.AMQProtocolSession; import org.apache.log4j.Logger; @@ -463,14 +464,14 @@ new LinkedList<RequiredDeliveryException>() ); - Message(String id, String... headers) throws AMQException + Message(AMQProtocolSession protocolSession, String id, String... headers) throws AMQException { - this(id, getHeaders(headers)); + this(protocolSession, id, getHeaders(headers)); } - Message(String id, FieldTable headers) throws AMQException + Message(AMQProtocolSession protocolSession, String id, FieldTable headers) throws AMQException { - this(_messageStore.getNewMessageId(),getPublishRequest(id), getContentHeader(headers), null); + this(protocolSession, _messageStore.getNewMessageId(),getPublishRequest(id), getContentHeader(headers), null); } public IncomingMessage getIncomingMessage() @@ -478,7 +479,7 @@ return _incoming; } - private Message(long messageId, + private Message(AMQProtocolSession protocolsession, long messageId, MessagePublishInfo publish, ContentHeaderBody header, List<ContentBody> bodies) throws AMQException @@ -487,7 +488,7 @@ - _incoming = new TestIncomingMessage(getMessageId(),publish,_txnContext,new MockProtocolSession(_messageStore)); + _incoming = new TestIncomingMessage(getMessageId(),publish, _txnContext, protocolsession); _incoming.setContentHeaderBody(header); Modified: qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/DestWildExchangeTest.java URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/DestWildExchangeTest.java?rev=800372&r1=800371&r2=800372&view=diff ============================================================================== --- qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/DestWildExchangeTest.java (original) +++ qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/DestWildExchangeTest.java Mon Aug 3 13:31:23 2009 @@ -57,7 +57,7 @@ _vhost = ApplicationRegistry.getInstance().getVirtualHostRegistry().getVirtualHosts().iterator().next(); _store = new MemoryMessageStore(); _context = new StoreContext(); - _protocolSession = new InternalTestProtocolSession(); + _protocolSession = new InternalTestProtocolSession(_vhost); } public void tearDown() Modified: qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/HeadersExchangeTest.java URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/HeadersExchangeTest.java?rev=800372&r1=800371&r2=800372&view=diff ============================================================================== --- qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/HeadersExchangeTest.java (original) +++ qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/HeadersExchangeTest.java Mon Aug 3 13:31:23 2009 @@ -23,14 +23,21 @@ import org.apache.qpid.AMQException; import org.apache.qpid.server.registry.ApplicationRegistry; import org.apache.qpid.server.util.NullApplicationRegistry; -import org.apache.qpid.framing.BasicPublishBody; +import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.protocol.InternalTestProtocolSession; +import org.apache.qpid.server.protocol.AMQProtocolSession; public class HeadersExchangeTest extends AbstractHeadersExchangeTestBase { + AMQProtocolSession _protocolSession; + protected void setUp() throws Exception { super.setUp(); ApplicationRegistry.initialise(new NullApplicationRegistry(), 1); + // Just use the first vhost. + VirtualHost virtualHost = ApplicationRegistry.getInstance(1).getVirtualHostRegistry().getVirtualHosts().iterator().next(); + _protocolSession = new InternalTestProtocolSession(virtualHost); } protected void tearDown() @@ -49,21 +56,21 @@ TestQueue q7 = bindDefault("F0000", "F0001=Bear"); TestQueue q8 = bindDefault("F0000=Aardvark", "F0001"); - routeAndTest(new Message("Message1", "F0000"), q1); - routeAndTest(new Message("Message2", "F0000=Aardvark"), q1, q2); - routeAndTest(new Message("Message3", "F0000=Aardvark", "F0001"), q1, q2, q3, q5, q8); - routeAndTest(new Message("Message4", "F0000", "F0001=Bear"), q1, q3, q4, q5, q7); - routeAndTest(new Message("Message5", "F0000=Aardvark", "F0001=Bear"), + routeAndTest(new Message(_protocolSession, "Message1", "F0000"), q1); + routeAndTest(new Message(_protocolSession, "Message2", "F0000=Aardvark"), q1, q2); + routeAndTest(new Message(_protocolSession, "Message3", "F0000=Aardvark", "F0001"), q1, q2, q3, q5, q8); + routeAndTest(new Message(_protocolSession, "Message4", "F0000", "F0001=Bear"), q1, q3, q4, q5, q7); + routeAndTest(new Message(_protocolSession, "Message5", "F0000=Aardvark", "F0001=Bear"), q1, q2, q3, q4, q5, q6, q7, q8); - routeAndTest(new Message("Message6", "F0002")); + routeAndTest(new Message(_protocolSession, "Message6", "F0002")); - Message m7 = new Message("Message7", "XXXXX"); + Message m7 = new Message(_protocolSession, "Message7", "XXXXX"); MessagePublishInfoImpl pb7 = (MessagePublishInfoImpl) (m7.getMessagePublishInfo()); pb7.setMandatory(true); routeAndTest(m7,true); - Message m8 = new Message("Message8", "F0000"); + Message m8 = new Message(_protocolSession, "Message8", "F0000"); MessagePublishInfoImpl pb8 = (MessagePublishInfoImpl)(m8.getMessagePublishInfo()); pb8.setMandatory(true); routeAndTest(m8,false,q1); @@ -79,19 +86,19 @@ TestQueue q4 = bindDefault("F0000=Aardvark", "F0001", "X-match=any"); TestQueue q6 = bindDefault("F0000=Apple", "F0001", "X-match=any"); - routeAndTest(new Message("Message1", "F0000"), q1, q3); - routeAndTest(new Message("Message2", "F0000=Aardvark"), q1, q2, q3, q4); - routeAndTest(new Message("Message3", "F0000=Aardvark", "F0001"), q1, q2, q3, q4, q6); - routeAndTest(new Message("Message4", "F0000", "F0001=Bear"), q1, q2, q3, q4, q6); - routeAndTest(new Message("Message5", "F0000=Aardvark", "F0001=Bear"), q1, q2, q3, q4, q6); - routeAndTest(new Message("Message6", "F0002")); + routeAndTest(new Message(_protocolSession, "Message1", "F0000"), q1, q3); + routeAndTest(new Message(_protocolSession, "Message2", "F0000=Aardvark"), q1, q2, q3, q4); + routeAndTest(new Message(_protocolSession, "Message3", "F0000=Aardvark", "F0001"), q1, q2, q3, q4, q6); + routeAndTest(new Message(_protocolSession, "Message4", "F0000", "F0001=Bear"), q1, q2, q3, q4, q6); + routeAndTest(new Message(_protocolSession, "Message5", "F0000=Aardvark", "F0001=Bear"), q1, q2, q3, q4, q6); + routeAndTest(new Message(_protocolSession, "Message6", "F0002")); } public void testMandatory() throws AMQException { bindDefault("F0000"); - Message m1 = new Message("Message1", "XXXXX"); - Message m2 = new Message("Message2", "F0000"); + Message m1 = new Message(_protocolSession, "Message1", "XXXXX"); + Message m2 = new Message(_protocolSession, "Message2", "F0000"); MessagePublishInfoImpl pb1 = (MessagePublishInfoImpl) (m1.getMessagePublishInfo()); pb1.setMandatory(true); MessagePublishInfoImpl pb2 = (MessagePublishInfoImpl) (m2.getMessagePublishInfo()); Modified: qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/AMQPChannelActorTest.java URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/AMQPChannelActorTest.java?rev=800372&r1=800371&r2=800372&view=diff ============================================================================== --- qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/AMQPChannelActorTest.java (original) +++ qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/AMQPChannelActorTest.java Mon Aug 3 13:31:23 2009 @@ -27,11 +27,9 @@ import org.apache.qpid.AMQException; import org.apache.qpid.server.configuration.ServerConfiguration; import org.apache.qpid.server.protocol.AMQProtocolSession; -import org.apache.qpid.server.queue.MockProtocolSession; +import org.apache.qpid.server.protocol.InternalTestProtocolSession; import org.apache.qpid.server.registry.ApplicationRegistry; -import org.apache.qpid.server.store.MemoryMessageStore; import org.apache.qpid.server.virtualhost.VirtualHost; -import org.apache.qpid.server.logging.actors.AMQPConnectionActor; import org.apache.qpid.server.logging.rawloggers.UnitTestMessageLogger; import org.apache.qpid.server.logging.RootMessageLogger; import org.apache.qpid.server.logging.RootMessageLoggerImpl; @@ -56,38 +54,33 @@ LogActor _amqpActor; UnitTestMessageLogger _rawLogger; + AMQProtocolSession _session; + AMQChannel _channel; public void setUp() throws ConfigurationException, AMQException { Configuration config = new PropertiesConfiguration(); ServerConfiguration serverConfig = new ServerConfiguration(config); + setUpWithConfig(serverConfig); + } + + private void setUpWithConfig(ServerConfiguration serverConfig) throws AMQException + { _rawLogger = new UnitTestMessageLogger(); RootMessageLogger rootLogger = new RootMessageLoggerImpl(serverConfig, _rawLogger); + VirtualHost virtualHost = ApplicationRegistry.getInstance(). + getVirtualHostRegistry().getVirtualHosts().iterator().next(); + // Create a single session for this test. - // Re-use is ok as we are testing the LogActor object is set correctly, - // not the value of the output. - AMQProtocolSession session = new MockProtocolSession(new MemoryMessageStore()); - // Use the first Virtualhost that has been defined to initialise - // the MockProtocolSession. This prevents a NPE when the - // AMQPActor attempts to lookup the name of the VHost. - try - { - session.setVirtualHost(ApplicationRegistry.getInstance(). - getVirtualHostRegistry().getVirtualHosts(). - toArray(new VirtualHost[1])[0]); - } - catch (AMQException e) - { - fail("Unable to set virtualhost on session:" + e.getMessage()); - } + _session = new InternalTestProtocolSession(virtualHost); - AMQChannel channel = new AMQChannel(session, 1, session.getVirtualHost().getMessageStore()); + _channel = new AMQChannel(_session, 1, _session.getVirtualHost().getMessageStore()); - _amqpActor = new AMQPChannelActor(channel, rootLogger); + _amqpActor = new AMQPChannelActor(_channel, rootLogger); } @@ -105,22 +98,7 @@ */ public void testChannel() { - final String message = "test logging"; - - _amqpActor.message(new LogSubject() - { - public String toString() - { - return "[AMQPActorTest]"; - } - - }, new LogMessage() - { - public String toString() - { - return message; - } - }); + final String message = sendTestMessage(); List<Object> logs = _rawLogger.getLogMessages(); @@ -146,40 +124,12 @@ } - public void testChannelLoggingOff() throws ConfigurationException, AMQException + /** + * Log a message using the test Actor + * @return the logged message + */ + private String sendTestMessage() { - Configuration config = new PropertiesConfiguration(); - config.addProperty("status-updates", "OFF"); - - ServerConfiguration serverConfig = new ServerConfiguration(config); - - _rawLogger = new UnitTestMessageLogger(); - RootMessageLogger rootLogger = - new RootMessageLoggerImpl(serverConfig, _rawLogger); - - // Create a single session for this test. - // Re-use is ok as we are testing the LogActor object is set correctly, - // not the value of the output. - AMQProtocolSession session = new MockProtocolSession(new MemoryMessageStore()); - // Use the first Virtualhost that has been defined to initialise - // the MockProtocolSession. This prevents a NPE when the - // AMQPActor attempts to lookup the name of the VHost. - try - { - session.setVirtualHost(ApplicationRegistry.getInstance(). - getVirtualHostRegistry().getVirtualHosts(). - toArray(new VirtualHost[1])[0]); - } - catch (AMQException e) - { - fail("Unable to set virtualhost on session:" + e.getMessage()); - } - - - AMQChannel channel = new AMQChannel(session, 1, session.getVirtualHost().getMessageStore()); - - _amqpActor = new AMQPChannelActor(channel, rootLogger); - final String message = "test logging"; _amqpActor.message(new LogSubject() @@ -196,6 +146,152 @@ return message; } }); + return message; + } + + /** + * Test that if logging is configured to be off in the configuration that + * no logging is presented + * @throws ConfigurationException + * @throws AMQException + */ + public void testChannelLoggingOFF() throws ConfigurationException, AMQException + { + Configuration config = new PropertiesConfiguration(); + config.addProperty("status-updates", "OFF"); + + ServerConfiguration serverConfig = new ServerConfiguration(config); + + _rawLogger = new UnitTestMessageLogger(); + + setUpWithConfig(serverConfig); + + sendTestMessage(); + + List<Object> logs = _rawLogger.getLogMessages(); + + assertEquals("Message log size not as expected.", 0, logs.size()); + + } + + /** + * Test that if logging is configured to be off in the configuration that + * no logging is presented + * @throws ConfigurationException + * @throws AMQException + */ + public void testChannelLoggingOfF() throws ConfigurationException, AMQException + { + Configuration config = new PropertiesConfiguration(); + config.addProperty("status-updates", "OfF"); + + ServerConfiguration serverConfig = new ServerConfiguration(config); + + _rawLogger = new UnitTestMessageLogger(); + + setUpWithConfig(serverConfig); + + sendTestMessage(); + + List<Object> logs = _rawLogger.getLogMessages(); + + assertEquals("Message log size not as expected.", 0, logs.size()); + + } + + /** + * Test that if logging is configured to be off in the configuration that + * no logging is presented + * @throws ConfigurationException + * @throws AMQException + */ + public void testChannelLoggingOff() throws ConfigurationException, AMQException + { + Configuration config = new PropertiesConfiguration(); + config.addProperty("status-updates", "Off"); + + ServerConfiguration serverConfig = new ServerConfiguration(config); + + _rawLogger = new UnitTestMessageLogger(); + + setUpWithConfig(serverConfig); + + sendTestMessage(); + + List<Object> logs = _rawLogger.getLogMessages(); + + assertEquals("Message log size not as expected.", 0, logs.size()); + + } + + /** + * Test that if logging is configured to be off in the configuration that + * no logging is presented + * @throws ConfigurationException + * @throws AMQException + */ + public void testChannelLoggingofF() throws ConfigurationException, AMQException + { + Configuration config = new PropertiesConfiguration(); + config.addProperty("status-updates", "ofF"); + + ServerConfiguration serverConfig = new ServerConfiguration(config); + + _rawLogger = new UnitTestMessageLogger(); + + setUpWithConfig(serverConfig); + + sendTestMessage(); + + List<Object> logs = _rawLogger.getLogMessages(); + + assertEquals("Message log size not as expected.", 0, logs.size()); + + } + + /** + * Test that if logging is configured to be off in the configuration that + * no logging is presented + * @throws ConfigurationException + * @throws AMQException + */ + public void testChannelLoggingoff() throws ConfigurationException, AMQException + { + Configuration config = new PropertiesConfiguration(); + config.addProperty("status-updates", "off"); + + ServerConfiguration serverConfig = new ServerConfiguration(config); + + _rawLogger = new UnitTestMessageLogger(); + + setUpWithConfig(serverConfig); + + sendTestMessage(); + + List<Object> logs = _rawLogger.getLogMessages(); + + assertEquals("Message log size not as expected.", 0, logs.size()); + + } + + /** + * Test that if logging is configured to be off in the configuration that + * no logging is presented + * @throws ConfigurationException + * @throws AMQException + */ + public void testChannelLoggingoFf() throws ConfigurationException, AMQException + { + Configuration config = new PropertiesConfiguration(); + config.addProperty("status-updates", "oFf"); + + ServerConfiguration serverConfig = new ServerConfiguration(config); + + _rawLogger = new UnitTestMessageLogger(); + + setUpWithConfig(serverConfig); + + sendTestMessage(); List<Object> logs = _rawLogger.getLogMessages(); Modified: qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/AMQPConnectionActorTest.java URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/AMQPConnectionActorTest.java?rev=800372&r1=800371&r2=800372&view=diff ============================================================================== --- qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/AMQPConnectionActorTest.java (original) +++ qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/AMQPConnectionActorTest.java Mon Aug 3 13:31:23 2009 @@ -26,18 +26,16 @@ import org.apache.commons.configuration.PropertiesConfiguration; import org.apache.qpid.AMQException; import org.apache.qpid.server.configuration.ServerConfiguration; +import org.apache.qpid.server.logging.LogActor; +import org.apache.qpid.server.logging.LogMessage; +import org.apache.qpid.server.logging.LogSubject; +import org.apache.qpid.server.logging.RootMessageLogger; +import org.apache.qpid.server.logging.RootMessageLoggerImpl; +import org.apache.qpid.server.logging.rawloggers.UnitTestMessageLogger; import org.apache.qpid.server.protocol.AMQProtocolSession; -import org.apache.qpid.server.queue.MockProtocolSession; +import org.apache.qpid.server.protocol.InternalTestProtocolSession; import org.apache.qpid.server.registry.ApplicationRegistry; -import org.apache.qpid.server.store.MemoryMessageStore; import org.apache.qpid.server.virtualhost.VirtualHost; -import org.apache.qpid.server.logging.actors.AMQPConnectionActor; -import org.apache.qpid.server.logging.rawloggers.UnitTestMessageLogger; -import org.apache.qpid.server.logging.RootMessageLogger; -import org.apache.qpid.server.logging.RootMessageLoggerImpl; -import org.apache.qpid.server.logging.LogSubject; -import org.apache.qpid.server.logging.LogMessage; -import org.apache.qpid.server.logging.LogActor; import java.util.List; @@ -56,41 +54,34 @@ LogActor _amqpActor; UnitTestMessageLogger _rawLogger; - public void setUp() throws ConfigurationException + public void setUp() throws ConfigurationException, AMQException { Configuration config = new PropertiesConfiguration(); ServerConfiguration serverConfig = new ServerConfiguration(config); + setUpWithConfig(serverConfig); + } + + public void tearDown() + { + _rawLogger.clearLogMessages(); + } + + private void setUpWithConfig(ServerConfiguration serverConfig) throws AMQException + { _rawLogger = new UnitTestMessageLogger(); RootMessageLogger rootLogger = new RootMessageLoggerImpl(serverConfig, _rawLogger); + VirtualHost virtualHost = ApplicationRegistry.getInstance(). + getVirtualHostRegistry().getVirtualHosts().iterator().next(); + // Create a single session for this test. - // Re-use is ok as we are testing the LogActor object is set correctly, - // not the value of the output. - AMQProtocolSession session = new MockProtocolSession(new MemoryMessageStore()); - // Use the first Virtualhost that has been defined to initialise - // the MockProtocolSession. This prevents a NPE when the - // AMQPActor attempts to lookup the name of the VHost. - try - { - session.setVirtualHost(ApplicationRegistry.getInstance(). - getVirtualHostRegistry().getVirtualHosts(). - toArray(new VirtualHost[1])[0]); - } - catch (AMQException e) - { - fail("Unable to set virtualhost on session:" + e.getMessage()); - } + AMQProtocolSession session = new InternalTestProtocolSession(virtualHost); _amqpActor = new AMQPConnectionActor(session, rootLogger); } - public void tearDown() - { - _rawLogger.clearLogMessages(); - } - /** * Test the AMQPActor logging as a Connection level. * @@ -98,26 +89,10 @@ * * The log message should be fully repalaced (no '{n}' values) and should * not contain any channel identification. - * */ public void testConnection() { - final String message = "test logging"; - - _amqpActor.message(new LogSubject() - { - public String toString() - { - return "[AMQPActorTest]"; - } - - }, new LogMessage() - { - public String toString() - { - return message; - } - }); + final String message = sendLogMessage(); List<Object> logs = _rawLogger.getLogMessages(); @@ -129,7 +104,7 @@ // Verify that the message has the correct type assertTrue("Message contains the [con: prefix", - logs.get(0).toString().contains("[con:")); + logs.get(0).toString().contains("[con:")); // Verify that all the values were presented to the MessageFormatter // so we will not end up with '{n}' entries in the log. @@ -138,11 +113,9 @@ // Verify that the logged message does not contains the 'ch:' marker assertFalse("Message was logged with a channel identifier." + logs.get(0), - logs.get(0).toString().contains("/ch:")); + logs.get(0).toString().contains("/ch:")); } - - public void testConnectionLoggingOff() throws ConfigurationException, AMQException { Configuration config = new PropertiesConfiguration(); @@ -150,31 +123,18 @@ ServerConfiguration serverConfig = new ServerConfiguration(config); - _rawLogger = new UnitTestMessageLogger(); - RootMessageLogger rootLogger = - new RootMessageLoggerImpl(serverConfig, _rawLogger); + setUpWithConfig(serverConfig); - // Create a single session for this test. - // Re-use is ok as we are testing the LogActor object is set correctly, - // not the value of the output. - AMQProtocolSession session = new MockProtocolSession(new MemoryMessageStore()); - // Use the first Virtualhost that has been defined to initialise - // the MockProtocolSession. This prevents a NPE when the - // AMQPActor attempts to lookup the name of the VHost. - try - { - session.setVirtualHost(ApplicationRegistry.getInstance(). - getVirtualHostRegistry().getVirtualHosts(). - toArray(new VirtualHost[1])[0]); - } - catch (AMQException e) - { - fail("Unable to set virtualhost on session:" + e.getMessage()); - } + sendLogMessage(); + List<Object> logs = _rawLogger.getLogMessages(); - _amqpActor = new AMQPConnectionActor(session, rootLogger); + assertEquals("Message log size not as expected.", 0, logs.size()); + + } + private String sendLogMessage() + { final String message = "test logging"; _amqpActor.message(new LogSubject() @@ -191,12 +151,7 @@ return message; } }); - - List<Object> logs = _rawLogger.getLogMessages(); - - assertEquals("Message log size not as expected.", 0, logs.size()); - + return message; } - } Modified: qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/CurrentActorTest.java URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/CurrentActorTest.java?rev=800372&r1=800371&r2=800372&view=diff ============================================================================== --- qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/CurrentActorTest.java (original) +++ qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/CurrentActorTest.java Mon Aug 3 13:31:23 2009 @@ -26,9 +26,8 @@ import org.apache.qpid.server.logging.LogMessage; import org.apache.qpid.server.logging.LogSubject; import org.apache.qpid.server.protocol.AMQProtocolSession; -import org.apache.qpid.server.queue.MockProtocolSession; +import org.apache.qpid.server.protocol.InternalTestProtocolSession; import org.apache.qpid.server.registry.ApplicationRegistry; -import org.apache.qpid.server.store.MemoryMessageStore; import org.apache.qpid.server.virtualhost.VirtualHost; /** @@ -61,27 +60,16 @@ final Exception[] _errors = new Exception[THREADS]; // Create a single session for this test. - AMQProtocolSession session; + AMQProtocolSession _session; - public void setUp() + public void setUp() throws AMQException { // Create a single session for this test. - // Re-use is ok as we are testing the LogActor object is set correctly, - // not the value of the output. - session = new MockProtocolSession(new MemoryMessageStore()); - // Use the first Virtualhost that has been defined to initialise - // the MockProtocolSession. This prevents a NPE when the - // AMQPActor attempts to lookup the name of the VHost. - try - { - session.setVirtualHost(ApplicationRegistry.getInstance(). - getVirtualHostRegistry().getVirtualHosts(). - toArray(new VirtualHost[1])[0]); - } - catch (AMQException e) - { - fail("Unable to set virtualhost on session:" + e.getMessage()); - } + VirtualHost virtualHost = ApplicationRegistry.getInstance(). + getVirtualHostRegistry().getVirtualHosts().iterator().next(); + + // Create a single session for this test. + _session = new InternalTestProtocolSession(virtualHost); } public void testFIFO() throws AMQException @@ -89,7 +77,7 @@ // Create a new actor using retrieving the rootMessageLogger from // the default ApplicationRegistry. //fixme reminder that we need a better approach for broker testing. - AMQPConnectionActor connectionActor = new AMQPConnectionActor(session, + AMQPConnectionActor connectionActor = new AMQPConnectionActor(_session, ApplicationRegistry.getInstance(). getRootMessageLogger()); @@ -120,7 +108,7 @@ * to push the actor on to the stack */ - AMQChannel channel = new AMQChannel(session, 1, session.getVirtualHost().getMessageStore()); + AMQChannel channel = new AMQChannel(_session, 1, _session.getVirtualHost().getMessageStore()); AMQPChannelActor channelActor = new AMQPChannelActor(channel, ApplicationRegistry.getInstance(). @@ -218,7 +206,7 @@ // Create a new actor using retrieving the rootMessageLogger from // the default ApplicationRegistry. //fixme reminder that we need a better approach for broker testing. - AMQPConnectionActor actor = new AMQPConnectionActor(session, + AMQPConnectionActor actor = new AMQPConnectionActor(_session, ApplicationRegistry.getInstance(). getRootMessageLogger()); Modified: qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/AbstractTestLogSubject.java URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/AbstractTestLogSubject.java?rev=800372&r1=800371&r2=800372&view=diff ============================================================================== --- qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/AbstractTestLogSubject.java (original) +++ qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/AbstractTestLogSubject.java Mon Aug 3 13:31:23 2009 @@ -36,6 +36,9 @@ import org.apache.qpid.server.logging.rawloggers.UnitTestMessageLogger; import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.registry.ApplicationRegistry; +import org.apache.qpid.server.protocol.InternalTestProtocolSession; +import org.apache.qpid.server.protocol.AMQProtocolSession; import java.util.List; @@ -44,6 +47,19 @@ protected Configuration _config = new PropertiesConfiguration(); protected LogSubject _subject = null; + AMQProtocolSession _session; + + public void setUp() throws Exception + { + super.setUp(); + + VirtualHost virtualHost = ApplicationRegistry.getInstance(). + getVirtualHostRegistry().getVirtualHosts().iterator().next(); + + // Create a single session for this test. + _session = new InternalTestProtocolSession(virtualHost); + } + protected List<Object> performLog() throws ConfigurationException { if (_subject == null) Modified: qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/ChannelLogSubjectTest.java URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/ChannelLogSubjectTest.java?rev=800372&r1=800371&r2=800372&view=diff ============================================================================== --- qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/ChannelLogSubjectTest.java (original) +++ qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/ChannelLogSubjectTest.java Mon Aug 3 13:31:23 2009 @@ -20,13 +20,7 @@ */ package org.apache.qpid.server.logging.subjects; -import org.apache.qpid.AMQException; import org.apache.qpid.server.AMQChannel; -import org.apache.qpid.server.protocol.AMQProtocolSession; -import org.apache.qpid.server.queue.MockProtocolSession; -import org.apache.qpid.server.registry.ApplicationRegistry; -import org.apache.qpid.server.store.MemoryMessageStore; -import org.apache.qpid.server.virtualhost.VirtualHost; public class ChannelLogSubjectTest extends ConnectionLogSubjectTest { @@ -37,24 +31,6 @@ { super.setUp(); - // Create a single session for this test. - // Re-use is ok as we are testing the LogActor object is set correctly, - // not the value of the output. - _session = new MockProtocolSession(new MemoryMessageStore()); - // Use the first Virtualhost that has been defined to initialise - // the MockProtocolSession. This prevents a NPE when the - // AMQPActor attempts to lookup the name of the VHost. - try - { - _session.setVirtualHost(ApplicationRegistry.getInstance(). - getVirtualHostRegistry().getVirtualHosts(). - toArray(new VirtualHost[1])[0]); - } - catch (AMQException e) - { - fail("Unable to set virtualhost on session:" + e.getMessage()); - } - AMQChannel channel = new AMQChannel(_session, _channelID, _session.getVirtualHost().getMessageStore()); _subject = new ChannelLogSubject(channel); Modified: qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/ConnectionLogSubjectTest.java URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/ConnectionLogSubjectTest.java?rev=800372&r1=800371&r2=800372&view=diff ============================================================================== --- qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/ConnectionLogSubjectTest.java (original) +++ qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/ConnectionLogSubjectTest.java Mon Aug 3 13:31:23 2009 @@ -20,39 +20,13 @@ */ package org.apache.qpid.server.logging.subjects; -import org.apache.qpid.AMQException; -import org.apache.qpid.server.protocol.AMQProtocolSession; -import org.apache.qpid.server.queue.MockProtocolSession; -import org.apache.qpid.server.registry.ApplicationRegistry; -import org.apache.qpid.server.store.MemoryMessageStore; -import org.apache.qpid.server.virtualhost.VirtualHost; - public class ConnectionLogSubjectTest extends AbstractTestLogSubject { - AMQProtocolSession _session; public void setUp() throws Exception { super.setUp(); - // Create a single session for this test. - // Re-use is ok as we are testing the LogActor object is set correctly, - // not the value of the output. - _session = new MockProtocolSession(new MemoryMessageStore()); - // Use the first Virtualhost that has been defined to initialise - // the MockProtocolSession. This prevents a NPE when the - // AMQPActor attempts to lookup the name of the VHost. - try - { - _session.setVirtualHost(ApplicationRegistry.getInstance(). - getVirtualHostRegistry().getVirtualHosts(). - toArray(new VirtualHost[1])[0]); - } - catch (AMQException e) - { - fail("Unable to set virtualhost on session:" + e.getMessage()); - } - _subject = new ConnectionLogSubject(_session); } @@ -63,7 +37,7 @@ */ protected void validateLogStatement(String message) { - verifyConnection(_session.getSessionID(), "MockProtocolSessionUser", "null", "test", message); + verifyConnection(_session.getSessionID(), "InternalTestProtocolSession", "127.0.0.1:1", "test", message); } } Modified: qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/SubscriptionLogSubjectTest.java URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/SubscriptionLogSubjectTest.java?rev=800372&r1=800371&r2=800372&view=diff ============================================================================== --- qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/SubscriptionLogSubjectTest.java (original) +++ qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/SubscriptionLogSubjectTest.java Mon Aug 3 13:31:23 2009 @@ -20,17 +20,13 @@ */ package org.apache.qpid.server.logging.subjects; -import org.apache.qpid.AMQException; import org.apache.qpid.framing.AMQShortString; import org.apache.qpid.framing.FieldTable; import org.apache.qpid.server.AMQChannel; import org.apache.qpid.server.flow.LimitlessCreditManager; -import org.apache.qpid.server.protocol.AMQProtocolSession; import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.queue.MockAMQQueue; -import org.apache.qpid.server.queue.MockProtocolSession; import org.apache.qpid.server.registry.ApplicationRegistry; -import org.apache.qpid.server.store.MemoryMessageStore; import org.apache.qpid.server.subscription.Subscription; import org.apache.qpid.server.subscription.SubscriptionFactory; import org.apache.qpid.server.subscription.SubscriptionFactoryImpl; @@ -57,31 +53,13 @@ _queue = new MockAMQQueue("QueueLogSubjectTest"); ((MockAMQQueue) _queue).setVirtualHost(_testVhost); - // Create a single session for this test. - // Re-use is ok as we are testing the LogActor object is set correctly, - // not the value of the output. - AMQProtocolSession session = new MockProtocolSession(new MemoryMessageStore()); - // Use the first Virtualhost that has been defined to initialise - // the MockProtocolSession. This prevents a NPE when the - // AMQPActor attempts to lookup the name of the VHost. - try - { - session.setVirtualHost(ApplicationRegistry.getInstance(). - getVirtualHostRegistry().getVirtualHosts(). - toArray(new VirtualHost[1])[0]); - } - catch (AMQException e) - { - fail("Unable to set virtualhost on session:" + e.getMessage()); - } + AMQChannel channel = new AMQChannel(_session, _channelID, _session.getVirtualHost().getMessageStore()); - AMQChannel channel = new AMQChannel(session, _channelID, session.getVirtualHost().getMessageStore()); - - session.addChannel(channel); + _session.addChannel(channel); SubscriptionFactory factory = new SubscriptionFactoryImpl(); - _subscription = factory.createSubscription(_channelID, session, new AMQShortString("cTag"), + _subscription = factory.createSubscription(_channelID, _session, new AMQShortString("cTag"), _acks, _filters, _noLocal, new LimitlessCreditManager()); @@ -102,13 +80,13 @@ String subscriptionSlice = getSlice("sub:" + _subscription.getSubscriptionID(), message); - + assertNotNull("Unable to locate subscription 'sub:" + _subscription.getSubscriptionID() + "'"); // Adding the ')' is a bit ugly but SubscriptionLogSubject is the only // Subject that nests () and so the simple parser of checking for the // next ')' falls down. - verifyQueue(subscriptionSlice+")", _queue); + verifyQueue(subscriptionSlice + ")", _queue); } } Modified: qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/protocol/InternalTestProtocolSession.java URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/protocol/InternalTestProtocolSession.java?rev=800372&r1=800371&r2=800372&view=diff ============================================================================== --- qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/protocol/InternalTestProtocolSession.java (original) +++ qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/protocol/InternalTestProtocolSession.java Mon Aug 3 13:31:23 2009 @@ -26,7 +26,7 @@ import org.apache.qpid.server.output.ProtocolOutputConverter; import org.apache.qpid.server.queue.AMQMessage; import org.apache.qpid.server.registry.ApplicationRegistry; -import org.apache.qpid.server.AMQChannel; +import org.apache.qpid.server.virtualhost.VirtualHost; import java.util.ArrayList; import java.util.HashMap; @@ -34,7 +34,7 @@ import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; -import java.net.SocketAddress; +import java.security.Principal; public class InternalTestProtocolSession extends AMQMinaProtocolSession implements ProtocolOutputConverter { @@ -42,7 +42,7 @@ final Map<Integer, Map<AMQShortString, LinkedList<DeliveryPair>>> _channelDelivers; private AtomicInteger _deliveryCount = new AtomicInteger(0); - public InternalTestProtocolSession() throws AMQException + public InternalTestProtocolSession(VirtualHost virtualHost) throws AMQException { super(new TestIoSession(), ApplicationRegistry.getInstance().getVirtualHostRegistry(), @@ -50,6 +50,16 @@ _channelDelivers = new HashMap<Integer, Map<AMQShortString, LinkedList<DeliveryPair>>>(); + // Need to authenticate session for it to be representative testing. + setAuthorizedID(new Principal() + { + public String getName() + { + return "InternalTestProtocolSession"; + } + }); + + setVirtualHost(virtualHost); } public ProtocolOutputConverter getProtocolOutputConverter() Modified: qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueAlertTest.java URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueAlertTest.java?rev=800372&r1=800371&r2=800372&view=diff ============================================================================== --- qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueAlertTest.java (original) +++ qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueAlertTest.java Mon Aug 3 13:31:23 2009 @@ -32,6 +32,7 @@ import org.apache.qpid.server.txn.NonTransactionalContext; import org.apache.qpid.server.RequiredDeliveryException; import org.apache.qpid.server.AMQChannel; +import org.apache.qpid.server.logging.actors.CurrentActor; import org.apache.qpid.server.subscription.Subscription; import org.apache.qpid.server.subscription.SubscriptionFactoryImpl; import org.apache.qpid.server.protocol.AMQMinaProtocolSession; @@ -49,6 +50,7 @@ import java.util.LinkedList; import java.util.Collections; import java.util.Set; +import java.security.Principal; /** This class tests all the alerts an AMQQueue can throw based on threshold values of different parameters */ public class AMQQueueAlertTest extends TestCase @@ -184,7 +186,6 @@ */ public void testQueueDepthAlertWithSubscribers() throws Exception { - _protocolSession = new InternalTestProtocolSession(); AMQChannel channel = new AMQChannel(_protocolSession, 2, _messageStore); _protocolSession.addChannel(channel); @@ -295,12 +296,13 @@ super.setUp(); IApplicationRegistry applicationRegistry = ApplicationRegistry.getInstance(1); _virtualHost = applicationRegistry.getVirtualHostRegistry().getVirtualHost("test"); - _protocolSession = new InternalTestProtocolSession(); - + _protocolSession = new InternalTestProtocolSession(_virtualHost); + CurrentActor.set(_protocolSession.getLogActor()); } protected void tearDown() { + CurrentActor.remove(); ApplicationRegistry.remove(1); } Modified: qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueMBeanTest.java URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueMBeanTest.java?rev=800372&r1=800371&r2=800372&view=diff ============================================================================== --- qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueMBeanTest.java (original) +++ qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueMBeanTest.java Mon Aug 3 13:31:23 2009 @@ -175,7 +175,8 @@ assertTrue(_queueMBean.getActiveConsumerCount() == 0); - InternalTestProtocolSession protocolSession = new InternalTestProtocolSession(); + InternalTestProtocolSession protocolSession = new InternalTestProtocolSession(_virtualHost); + AMQChannel channel = new AMQChannel(protocolSession, 1, _messageStore); protocolSession.addChannel(channel); @@ -372,7 +373,7 @@ null); _queueMBean = new AMQQueueMBean(_queue); - _protocolSession = new InternalTestProtocolSession(); + _protocolSession = new InternalTestProtocolSession(_virtualHost); } public void tearDown() Modified: qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AckTest.java URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AckTest.java?rev=800372&r1=800371&r2=800372&view=diff ============================================================================== --- qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AckTest.java (original) +++ qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AckTest.java Mon Aug 3 13:31:23 2009 @@ -29,6 +29,9 @@ import org.apache.qpid.framing.abstraction.MessagePublishInfo; import org.apache.qpid.server.AMQChannel; import org.apache.qpid.server.RequiredDeliveryException; +import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.protocol.InternalTestProtocolSession; +import org.apache.qpid.server.protocol.AMQProtocolSession; import org.apache.qpid.server.subscription.Subscription; import org.apache.qpid.server.subscription.SubscriptionFactoryImpl; import org.apache.qpid.server.flow.LimitlessCreditManager; @@ -55,7 +58,7 @@ private Subscription _subscription; - private MockProtocolSession _protocolSession; + private AMQProtocolSession _protocolSession; private TestMemoryMessageStore _messageStore; @@ -66,19 +69,21 @@ private AMQQueue _queue; private static final AMQShortString DEFAULT_CONSUMER_TAG = new AMQShortString("conTag"); + private VirtualHost _virtualHost; protected void setUp() throws Exception { super.setUp(); ApplicationRegistry.initialise(new NullApplicationRegistry(), 1); + _virtualHost = ApplicationRegistry.getInstance().getVirtualHostRegistry().getVirtualHost("test"); _messageStore = new TestMemoryMessageStore(); - _protocolSession = new MockProtocolSession(_messageStore); + _protocolSession = new InternalTestProtocolSession(_virtualHost); _channel = new AMQChannel(_protocolSession,5, _messageStore /*dont need exchange registry*/); _protocolSession.addChannel(_channel); - _queue = AMQQueueFactory.createAMQQueueImpl(new AMQShortString("myQ"), false, new AMQShortString("guest"), true, ApplicationRegistry.getInstance().getVirtualHostRegistry().getVirtualHost("test"), + _queue = AMQQueueFactory.createAMQQueueImpl(new AMQShortString("myQ"), false, new AMQShortString("guest"), true, _virtualHost, null); } Modified: qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/security/access/ACLManagerTest.java URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/security/access/ACLManagerTest.java?rev=800372&r1=800371&r2=800372&view=diff ============================================================================== --- qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/security/access/ACLManagerTest.java (original) +++ qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/security/access/ACLManagerTest.java Mon Aug 3 13:31:23 2009 @@ -31,15 +31,15 @@ import org.apache.commons.configuration.PropertiesConfiguration; import org.apache.commons.configuration.XMLConfiguration; import org.apache.qpid.server.configuration.SecurityConfiguration; -import org.apache.qpid.server.configuration.ServerConfiguration; import org.apache.qpid.server.exchange.Exchange; import org.apache.qpid.server.plugins.MockPluginManager; import org.apache.qpid.server.plugins.PluginManager; import org.apache.qpid.server.protocol.AMQProtocolSession; +import org.apache.qpid.server.protocol.InternalTestProtocolSession; import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.queue.MockAMQQueue; -import org.apache.qpid.server.queue.MockProtocolSession; -import org.apache.qpid.server.store.TestableMemoryMessageStore; +import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.registry.ApplicationRegistry; public class ACLManagerTest extends TestCase { @@ -64,8 +64,13 @@ _pluginManager = new MockPluginManager(""); _authzManager = new ACLManager(_conf, _pluginManager); - - _session = new MockProtocolSession(new TestableMemoryMessageStore()); + + + VirtualHost virtualHost = ApplicationRegistry.getInstance(). + getVirtualHostRegistry().getVirtualHosts().iterator().next(); + + // Create a single session for this test. + _session = new InternalTestProtocolSession(virtualHost); } public void testACLManagerConfigurationPluginManager() throws Exception Modified: qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/store/MessageStoreTest.java URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/store/MessageStoreTest.java?rev=800372&r1=800371&r2=800372&view=diff ============================================================================== --- qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/store/MessageStoreTest.java (original) +++ qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/store/MessageStoreTest.java Mon Aug 3 13:31:23 2009 @@ -352,7 +352,7 @@ messageInfo, new NonTransactionalContext(_virtualHost.getMessageStore(), new StoreContext(), null, null), - new InternalTestProtocolSession()); + new InternalTestProtocolSession(_virtualHost)); } catch (AMQException e) { Modified: qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/util/InternalBrokerBaseCase.java URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/util/InternalBrokerBaseCase.java?rev=800372&r1=800371&r2=800372&view=diff ============================================================================== --- qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/util/InternalBrokerBaseCase.java (original) +++ qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/util/InternalBrokerBaseCase.java Mon Aug 3 13:31:23 2009 @@ -32,6 +32,7 @@ import org.apache.qpid.framing.abstraction.MessagePublishInfo; import org.apache.qpid.server.AMQChannel; import org.apache.qpid.server.ConsumerTagNotUniqueException; +import org.apache.qpid.server.logging.actors.CurrentActor; import org.apache.qpid.server.configuration.ServerConfiguration; import org.apache.qpid.server.exchange.Exchange; import org.apache.qpid.server.protocol.InternalTestProtocolSession; @@ -79,17 +80,8 @@ _queue.bind(defaultExchange, QUEUE_NAME, null); - _session = new InternalTestProtocolSession(); - - _session.setAuthorizedID(new Principal() - { - public String getName() - { - return "InternalBrokerBaseCaseUser"; - } - }); - - _session.setVirtualHost(_virtualHost); + _session = new InternalTestProtocolSession(_virtualHost); + CurrentActor.set(_session.getLogActor()); _channel = new MockChannel(_session, 1, _messageStore); @@ -98,6 +90,7 @@ public void tearDown() throws Exception { + CurrentActor.remove(); ApplicationRegistry.remove(1); super.tearDown(); } --------------------------------------------------------------------- Apache Qpid - AMQP Messaging Implementation Project: http://qpid.apache.org Use/Interact: mailto:commits-subscr...@qpid.apache.org