Copied: qpid/branches/grkvlt-network-20110301/qpid/java/common/src/test/java/org/apache/qpid/transport/network/mina/MinaNetworkTransportTest.java (from r1076486, qpid/branches/grkvlt-network-20110301/qpid/java/common/src/test/java/org/apache/qpid/transport/network/mina/MINANetworkDriverTest.java) URL: http://svn.apache.org/viewvc/qpid/branches/grkvlt-network-20110301/qpid/java/common/src/test/java/org/apache/qpid/transport/network/mina/MinaNetworkTransportTest.java?p2=qpid/branches/grkvlt-network-20110301/qpid/java/common/src/test/java/org/apache/qpid/transport/network/mina/MinaNetworkTransportTest.java&p1=qpid/branches/grkvlt-network-20110301/qpid/java/common/src/test/java/org/apache/qpid/transport/network/mina/MINANetworkDriverTest.java&r1=1076486&r2=1076489&rev=1076489&view=diff ============================================================================== --- qpid/branches/grkvlt-network-20110301/qpid/java/common/src/test/java/org/apache/qpid/transport/network/mina/MINANetworkDriverTest.java (original) +++ qpid/branches/grkvlt-network-20110301/qpid/java/common/src/test/java/org/apache/qpid/transport/network/mina/MinaNetworkTransportTest.java Thu Mar 3 01:49:08 2011 @@ -24,38 +24,50 @@ package org.apache.qpid.transport.networ import java.net.BindException; import java.net.InetAddress; import java.net.InetSocketAddress; -import java.net.SocketAddress; import java.net.UnknownHostException; import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import junit.framework.TestCase; - +import org.apache.mina.util.AvailablePortFinder; import org.apache.qpid.framing.AMQDataBlock; -import org.apache.qpid.protocol.ProtocolEngine; -import org.apache.qpid.protocol.ProtocolEngineFactory; -import org.apache.qpid.transport.NetworkDriver; +import org.apache.qpid.protocol.ReceiverFactory; +import org.apache.qpid.test.utils.QpidTestCase; +import org.apache.qpid.transport.ConnectionSettings; import org.apache.qpid.transport.OpenException; +import org.apache.qpid.transport.Receiver; +import org.apache.qpid.transport.TransportException; +import org.apache.qpid.transport.network.IncomingNetworkTransport; +import org.apache.qpid.transport.network.NetworkConnection; +import org.apache.qpid.transport.network.NetworkTransport; +import org.apache.qpid.transport.network.OutgoingNetworkTransport; -public class MINANetworkDriverTest extends TestCase +public class MinaNetworkTransportTest extends QpidTestCase { + public void testNothing() { assertTrue(true); } private static final String TEST_DATA = "YHALOTHAR"; - private static int TEST_PORT = 2323; - private NetworkDriver _server; - private NetworkDriver _client; - private CountingProtocolEngine _countingEngine; // Keeps a count of how many bytes it's read + private static int TEST_PORT = AvailablePortFinder.getNextAvailable(10000); + private IncomingNetworkTransport _server; + private OutgoingNetworkTransport _client; + private CountingReceiver _countingEngine; // Keeps a count of how many bytes it's read private Exception _thrownEx; + private ConnectionSettings _settings; + private NetworkConnection _network; @Override - public void setUp() + public void setUp() throws Exception { - _server = new MINANetworkDriver(); - _client = new MINANetworkDriver(); + _settings = new ConnectionSettings(); + _settings.setHost(InetAddress.getLocalHost().getHostName()); + _settings.setPort(TEST_PORT); + + _server = new MinaNetworkTransport(); + _client = new MinaNetworkTransport(); _thrownEx = null; - _countingEngine = new CountingProtocolEngine(); + _countingEngine = new CountingReceiver(); + // increment the port to prevent tests clashing with each other when // the port is in TIMED_WAIT state. TEST_PORT++; @@ -86,18 +98,18 @@ public class MINANetworkDriverTest exten { try { - _client.open(TEST_PORT, InetAddress.getLocalHost(), _countingEngine, null, null); + _client.connect(_settings, _countingEngine, null); } - catch (OpenException e) + catch (Exception e) { _thrownEx = e; } assertNotNull("Open should have failed since no engine bound", _thrownEx); - _server.bind(TEST_PORT, null, new EchoProtocolEngineSingletonFactory(), null, null); + _server.accept(_settings, null, null); - _client.open(TEST_PORT, InetAddress.getLocalHost(), _countingEngine, null, null); + _client.connect(_settings, _countingEngine, null); } /** @@ -108,16 +120,16 @@ public class MINANetworkDriverTest exten */ public void testBindOpenCloseOpen() throws BindException, UnknownHostException, OpenException { - _server.bind(TEST_PORT, null, new EchoProtocolEngineSingletonFactory(), null, null); - _client.open(TEST_PORT, InetAddress.getLocalHost(), _countingEngine, null, null); + _server.accept(_settings, new EchoSingletonFactory(), null); + _client.connect(_settings, _countingEngine, null); _client.close(); _server.close(); try { - _client.open(TEST_PORT, InetAddress.getLocalHost(), _countingEngine, null, null); + _client.connect(_settings, _countingEngine, null); } - catch (OpenException e) + catch (Exception e) { _thrownEx = e; } @@ -132,18 +144,19 @@ public class MINANetworkDriverTest exten { try { - _server.bind(TEST_PORT, null, new EchoProtocolEngineSingletonFactory(), null, null); + _server.accept(_settings, new EchoSingletonFactory(), null); } - catch (BindException e) + catch (TransportException e) { fail("First bind should not fail"); } try { - _client.bind(TEST_PORT, null, new EchoProtocolEngineSingletonFactory(), null, null); + IncomingNetworkTransport second = new MinaNetworkTransport(); + second.accept(_settings, new EchoSingletonFactory(), null); } - catch (BindException e) + catch (TransportException e) { _thrownEx = e; } @@ -161,14 +174,14 @@ public class MINANetworkDriverTest exten public void testSend() throws UnknownHostException, OpenException, InterruptedException, BindException { // Open a connection from a counting engine to an echo engine - _server.bind(TEST_PORT, null, new EchoProtocolEngineSingletonFactory(), null, null); - _client.open(TEST_PORT, InetAddress.getLocalHost(), _countingEngine, null, null); + _server.accept(_settings, new EchoSingletonFactory(), null); + _network = _client.connect(_settings, _countingEngine, null); // Tell the counting engine how much data we're sending _countingEngine.setNewLatch(TEST_DATA.getBytes().length); // Send the data and wait for up to 2 seconds to get it back - _client.send(ByteBuffer.wrap(TEST_DATA.getBytes())); + _network.getSender().send(ByteBuffer.wrap(TEST_DATA.getBytes())); _countingEngine.getLatch().await(2, TimeUnit.SECONDS); // Check what we got @@ -180,15 +193,14 @@ public class MINANetworkDriverTest exten * @throws BindException * @throws OpenException * @throws UnknownHostException - * */ public void testSetReadIdle() throws BindException, UnknownHostException, OpenException { // Open a connection from a counting engine to an echo engine - _server.bind(TEST_PORT, null, new EchoProtocolEngineSingletonFactory(), null, null); - _client.open(TEST_PORT, InetAddress.getLocalHost(), _countingEngine, null, null); + _server.accept(_settings, new EchoSingletonFactory(), null); + _network = _client.connect(_settings, _countingEngine, null); assertFalse("Reader should not have been idle", _countingEngine.getReaderHasBeenIdle()); - _client.setMaxReadIdle(1); + _network.getSender().setIdleTimeout(1); sleepForAtLeast(1500); assertTrue("Reader should have been idle", _countingEngine.getReaderHasBeenIdle()); } @@ -203,10 +215,10 @@ public class MINANetworkDriverTest exten public void testSetWriteIdle() throws BindException, UnknownHostException, OpenException { // Open a connection from a counting engine to an echo engine - _server.bind(TEST_PORT, null, new EchoProtocolEngineSingletonFactory(), null, null); - _client.open(TEST_PORT, InetAddress.getLocalHost(), _countingEngine, null, null); + _server.accept(_settings, new EchoSingletonFactory(), null); + _network = _client.connect(_settings, _countingEngine, null); assertFalse("Reader should not have been idle", _countingEngine.getWriterHasBeenIdle()); - _client.setMaxWriteIdle(1); + _network.getSender().setIdleTimeout(1); sleepForAtLeast(1500); assertTrue("Reader should have been idle", _countingEngine.getWriterHasBeenIdle()); } @@ -223,10 +235,10 @@ public class MINANetworkDriverTest exten public void testClosed() throws BindException, UnknownHostException, OpenException { // Open a connection from a counting engine to an echo engine - EchoProtocolEngineSingletonFactory factory = new EchoProtocolEngineSingletonFactory(); - _server.bind(TEST_PORT, null, factory, null, null); - _client.open(TEST_PORT, InetAddress.getLocalHost(), _countingEngine, null, null); - EchoProtocolEngine serverEngine = null; + EchoSingletonFactory factory = new EchoSingletonFactory(); + _server.accept(_settings, factory, null); + _network = _client.connect(_settings, _countingEngine, null); + EchoReceiver serverEngine = null; while (serverEngine == null) { serverEngine = factory.getEngine(); @@ -253,7 +265,7 @@ public class MINANetworkDriverTest exten } assertTrue("Server should have been closed", serverEngine.getClosed()); - _client.open(TEST_PORT, InetAddress.getLocalHost(), _countingEngine, null, null); + _client.connect(_settings, _countingEngine, null); _countingEngine.setClosed(false); assertFalse("Client should not have been closed", _countingEngine.getClosed()); _countingEngine.setNewLatch(1); @@ -278,15 +290,14 @@ public class MINANetworkDriverTest exten */ public void testExceptionCaught() throws BindException, UnknownHostException, OpenException, InterruptedException { - _server.bind(TEST_PORT, null, new EchoProtocolEngineSingletonFactory(), null, null); - _client.open(TEST_PORT, InetAddress.getLocalHost(), _countingEngine, null, null); - + _server.accept(_settings, new EchoSingletonFactory(), null); + _network = _client.connect(_settings, _countingEngine, null); assertEquals("Exception should not have been thrown", 1, _countingEngine.getExceptionLatch().getCount()); _countingEngine.setErrorOnNextRead(true); _countingEngine.setNewLatch(TEST_DATA.getBytes().length); - _client.send(ByteBuffer.wrap(TEST_DATA.getBytes())); + _network.getSender().send(ByteBuffer.wrap(TEST_DATA.getBytes())); _countingEngine.getExceptionLatch().await(2, TimeUnit.SECONDS); assertEquals("Exception should have been thrown", 0, _countingEngine.getExceptionLatch().getCount()); @@ -300,36 +311,34 @@ public class MINANetworkDriverTest exten */ public void testGetRemoteAddress() throws BindException, UnknownHostException, OpenException { - _server.bind(TEST_PORT, null, new EchoProtocolEngineSingletonFactory(), null, null); - _client.open(TEST_PORT, InetAddress.getLocalHost(), _countingEngine, null, null); + _server.accept(_settings, new EchoSingletonFactory(), null); + _network = _client.connect(_settings, _countingEngine, null); assertEquals(new InetSocketAddress(InetAddress.getLocalHost(), TEST_PORT), - _client.getRemoteAddress()); + _network.getRemoteAddress()); } - private class EchoProtocolEngineSingletonFactory implements ProtocolEngineFactory + private class EchoSingletonFactory implements ReceiverFactory { - EchoProtocolEngine _engine = null; + EchoReceiver _engine = null; - public ProtocolEngine newProtocolEngine(NetworkDriver driver) + public Receiver<ByteBuffer> newReceiver(NetworkTransport transport, NetworkConnection network) { if (_engine == null) { - _engine = new EchoProtocolEngine(); - _engine.setNetworkDriver(driver); + _engine = new EchoReceiver(); } return getEngine(); } - public EchoProtocolEngine getEngine() + public EchoReceiver getEngine() { return _engine; } } - public class CountingProtocolEngine implements ProtocolEngine + public class CountingReceiver implements Receiver<ByteBuffer> { - - protected NetworkDriver _driver; + protected NetworkConnection _network; public ArrayList<ByteBuffer> _receivedBytes = new ArrayList<ByteBuffer>(); private int _readBytes; private CountDownLatch _latch = new CountDownLatch(0); @@ -360,43 +369,14 @@ public class MINANetworkDriverTest exten return _readBytes; } - public SocketAddress getRemoteAddress() - { - if (_driver != null) - { - return _driver.getRemoteAddress(); - } - else - { - return null; - } - } - - public SocketAddress getLocalAddress() - { - if (_driver != null) - { - return _driver.getLocalAddress(); - } - else - { - return null; - } - } - - public long getWrittenBytes() - { - return 0; - } - public void readerIdle() { _readerHasBeenIdle = true; } - public void setNetworkDriver(NetworkDriver driver) + public void setNetworkConnection(NetworkConnection network) { - _driver = driver; + _network = network; } public void writeFrame(AMQDataBlock frame) @@ -463,14 +443,12 @@ public class MINANetworkDriverTest exten } - private class EchoProtocolEngine extends CountingProtocolEngine + private class EchoReceiver extends CountingReceiver { - public void received(ByteBuffer msg) { super.received(msg); msg.rewind(); - _driver.send(msg); } }
Modified: qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/client/AMQQueueDeferredOrderingTest.java URL: http://svn.apache.org/viewvc/qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/client/AMQQueueDeferredOrderingTest.java?rev=1076489&r1=1076488&r2=1076489&view=diff ============================================================================== --- qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/client/AMQQueueDeferredOrderingTest.java (original) +++ qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/client/AMQQueueDeferredOrderingTest.java Thu Mar 3 01:49:08 2011 @@ -30,7 +30,6 @@ import javax.jms.TextMessage; import org.apache.qpid.framing.AMQShortString; import org.apache.qpid.test.utils.QpidBrokerTestCase; -import org.apache.qpid.client.transport.TransportConnection; import org.slf4j.Logger; import org.slf4j.LoggerFactory; Modified: qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/client/DispatcherTest.java URL: http://svn.apache.org/viewvc/qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/client/DispatcherTest.java?rev=1076489&r1=1076488&r2=1076489&view=diff ============================================================================== --- qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/client/DispatcherTest.java (original) +++ qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/client/DispatcherTest.java Thu Mar 3 01:49:08 2011 @@ -20,12 +20,10 @@ */ package org.apache.qpid.client; -import java.util.Hashtable; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import javax.jms.Connection; -import javax.jms.ConnectionFactory; import javax.jms.JMSException; import javax.jms.Message; import javax.jms.MessageConsumer; @@ -34,10 +32,7 @@ import javax.jms.MessageProducer; import javax.jms.Queue; import javax.jms.Session; import javax.naming.Context; -import javax.naming.spi.InitialContextFactory; -import org.apache.qpid.client.transport.TransportConnection; -import org.apache.qpid.jndi.PropertiesFileInitialContextFactory; import org.apache.qpid.test.utils.QpidBrokerTestCase; import org.slf4j.Logger; import org.slf4j.LoggerFactory; Modified: qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/client/MultipleJCAProviderRegistrationTest.java URL: http://svn.apache.org/viewvc/qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/client/MultipleJCAProviderRegistrationTest.java?rev=1076489&r1=1076488&r2=1076489&view=diff ============================================================================== --- qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/client/MultipleJCAProviderRegistrationTest.java (original) +++ qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/client/MultipleJCAProviderRegistrationTest.java Thu Mar 3 01:49:08 2011 @@ -21,11 +21,7 @@ package org.apache.qpid.client; import org.apache.qpid.test.utils.QpidBrokerTestCase; -import org.apache.qpid.server.registry.ConfigurationFileApplicationRegistry; -import org.apache.qpid.server.registry.ApplicationRegistry; -import org.apache.qpid.client.transport.TransportConnection; -import java.io.File; import java.security.Provider; import java.security.Security; import java.util.List; Modified: qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/server/failover/FailoverMethodTest.java URL: http://svn.apache.org/viewvc/qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/server/failover/FailoverMethodTest.java?rev=1076489&r1=1076488&r2=1076489&view=diff ============================================================================== --- qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/server/failover/FailoverMethodTest.java (original) +++ qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/server/failover/FailoverMethodTest.java Thu Mar 3 01:49:08 2011 @@ -26,10 +26,10 @@ import org.apache.qpid.AMQDisconnectedEx import org.apache.qpid.AMQException; import org.apache.qpid.client.AMQConnection; import org.apache.qpid.client.AMQConnectionURL; -import org.apache.qpid.client.transport.TransportConnection; -import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException; import org.apache.qpid.server.registry.ApplicationRegistry; import org.apache.qpid.server.util.InternalBrokerBaseCase; +import org.apache.qpid.transport.vm.VMBrokerCreationException; +import org.apache.qpid.transport.vm.VmBroker; import org.apache.qpid.url.URLSyntaxException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -47,13 +47,13 @@ public class FailoverMethodTest extends public void createBroker() throws Exception { super.createBroker(); - TransportConnection.createVMBroker(ApplicationRegistry.DEFAULT_INSTANCE); + VmBroker.createVMBroker(); } @Override public void stopBroker() { - TransportConnection.killVMBroker(ApplicationRegistry.DEFAULT_INSTANCE); + VmBroker.killVMBrokers(); super.stopBroker(); } @@ -112,7 +112,7 @@ public class FailoverMethodTest extends } } - public void testFailoverSingleDelay() throws URLSyntaxException, AMQVMBrokerCreationException, + public void testFailoverSingleDelay() throws URLSyntaxException, VMBrokerCreationException, InterruptedException, JMSException { String connectionString = "amqp://guest:guest@/test?brokerlist='vm://:1?connectdelay='2000',retries='3''"; @@ -174,7 +174,7 @@ public class FailoverMethodTest extends * @throws InterruptedException * @throws JMSException */ - public void testNoFailover() throws URLSyntaxException, AMQVMBrokerCreationException, + public void testNoFailover() throws URLSyntaxException, VMBrokerCreationException, InterruptedException, JMSException { int CONNECT_DELAY = 2000; Modified: qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/BrokerLoggingTest.java URL: http://svn.apache.org/viewvc/qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/BrokerLoggingTest.java?rev=1076489&r1=1076488&r2=1076489&view=diff ============================================================================== --- qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/BrokerLoggingTest.java (original) +++ qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/BrokerLoggingTest.java Thu Mar 3 01:49:08 2011 @@ -21,6 +21,9 @@ package org.apache.qpid.server.logging; import junit.framework.AssertionFailedError; + +import org.apache.qpid.BrokerOptions; +import org.apache.qpid.qmf.schema.BrokerSchema.AgentClass.BrokerBankProperty; import org.apache.qpid.server.Main; import org.apache.qpid.transport.ConnectionException; import org.apache.qpid.util.LogMonitor; @@ -203,7 +206,7 @@ public class BrokerLoggingTest extends A 1, findMatches(TESTID).size()); //3 - String defaultLog4j = _configFile.getParent() + "/" + Main.DEFAULT_LOG_CONFIG_FILENAME; + String defaultLog4j = _configFile.getParent() + "/" + BrokerOptions.DEFAULT_LOG_CONFIG_FILENAME; assertTrue("Log4j file(" + defaultLog4j + ") details not correctly logged:" + getMessageString(log), getMessageString(log).endsWith(defaultLog4j)); Modified: qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/PriorityTest.java URL: http://svn.apache.org/viewvc/qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/PriorityTest.java?rev=1076489&r1=1076488&r2=1076489&view=diff ============================================================================== --- qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/PriorityTest.java (original) +++ qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/PriorityTest.java Thu Mar 3 01:49:08 2011 @@ -20,26 +20,15 @@ */ package org.apache.qpid.server.queue; -import junit.framework.TestCase; -import junit.framework.Assert; import org.apache.log4j.Logger; -import org.apache.qpid.client.transport.TransportConnection; -import org.apache.qpid.client.AMQConnection; import org.apache.qpid.client.AMQSession; -import org.apache.qpid.client.AMQQueue; import org.apache.qpid.client.AMQDestination; -import org.apache.qpid.jndi.PropertiesFileInitialContextFactory; import org.apache.qpid.test.utils.QpidBrokerTestCase; -import org.apache.qpid.url.URLSyntaxException; import org.apache.qpid.AMQException; import org.apache.qpid.framing.AMQShortString; -import org.apache.qpid.framing.FieldTable; import javax.jms.*; import javax.naming.NamingException; -import javax.naming.Context; -import javax.naming.spi.InitialContextFactory; -import java.util.Hashtable; import java.util.HashMap; import java.util.Map; @@ -47,7 +36,6 @@ public class PriorityTest extends QpidBr { private static final int TIMEOUT = 1500; - private static final Logger _logger = Logger.getLogger(PriorityTest.class); protected final String QUEUE = "PriorityQueue"; Modified: qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/QueueDepthWithSelectorTest.java URL: http://svn.apache.org/viewvc/qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/QueueDepthWithSelectorTest.java?rev=1076489&r1=1076488&r2=1076489&view=diff ============================================================================== --- qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/QueueDepthWithSelectorTest.java (original) +++ qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/QueueDepthWithSelectorTest.java Thu Mar 3 01:49:08 2011 @@ -21,6 +21,17 @@ package org.apache.qpid.server.queue; +import org.apache.log4j.Level; +import org.apache.log4j.Logger; + +import org.apache.qpid.AMQException; +import org.apache.qpid.client.AMQDestination; +import org.apache.qpid.client.AMQSession; +import org.apache.qpid.jndi.PropertiesFileInitialContextFactory; +import org.apache.qpid.server.registry.ApplicationRegistry; +import org.apache.qpid.server.util.InternalBrokerBaseCase; +import org.apache.qpid.transport.vm.VmBroker; + import javax.jms.Connection; import javax.jms.JMSException; import javax.jms.Message; Modified: qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/qpid/CauseFailureInVM.java URL: http://svn.apache.org/viewvc/qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/qpid/CauseFailureInVM.java?rev=1076489&r1=1076488&r2=1076489&view=diff ============================================================================== --- qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/qpid/CauseFailureInVM.java (original) +++ qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/qpid/CauseFailureInVM.java Thu Mar 3 01:49:08 2011 @@ -20,10 +20,10 @@ */ package org.apache.qpid.test.framework.qpid; -import org.apache.qpid.client.transport.TransportConnection; import org.apache.qpid.server.registry.ApplicationRegistry; import org.apache.qpid.test.framework.CauseFailure; import org.apache.qpid.test.framework.BrokerLifecycleAware; +import org.apache.qpid.transport.vm.VmBroker; /** * <p/><table id="crc"><caption>CRC Card</caption> @@ -64,7 +64,7 @@ public class CauseFailureInVM implements { int liveBroker = inVMTest.getLiveBroker(); - TransportConnection.killVMBroker(liveBroker); + VmBroker.killVMBroker(); ApplicationRegistry.remove(liveBroker); } } Modified: qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/qpid/InVMBrokerDecorator.java URL: http://svn.apache.org/viewvc/qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/qpid/InVMBrokerDecorator.java?rev=1076489&r1=1076488&r2=1076489&view=diff ============================================================================== --- qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/qpid/InVMBrokerDecorator.java (original) +++ qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/qpid/InVMBrokerDecorator.java Thu Mar 3 01:49:08 2011 @@ -23,11 +23,11 @@ package org.apache.qpid.test.framework.q import junit.framework.Test; import junit.framework.TestResult; -import org.apache.qpid.client.transport.TransportConnection; -import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException; import org.apache.qpid.server.registry.ApplicationRegistry; import org.apache.qpid.test.framework.BrokerLifecycleAware; import org.apache.qpid.test.framework.FrameworkBaseCase; +import org.apache.qpid.transport.vm.VMBrokerCreationException; +import org.apache.qpid.transport.vm.VmBroker; import org.apache.qpid.junit.extensions.SetupTaskAware; import org.apache.qpid.junit.extensions.WrappedSuiteTestDecorator; @@ -89,9 +89,9 @@ public class InVMBrokerDecorator extends try { ApplicationRegistry.getInstance(1); - TransportConnection.createVMBroker(1); + VmBroker.createVMBroker(); } - catch (AMQVMBrokerCreationException e) + catch (VMBrokerCreationException e) { throw new RuntimeException("In-VM broker creation failed: " + e.getMessage(), e); } @@ -103,7 +103,7 @@ public class InVMBrokerDecorator extends public void run() { // Ensure that the in-vm broker is cleaned up so that the next test starts afresh. - TransportConnection.killVMBroker(1); + VmBroker.killVMBroker(); ApplicationRegistry.remove(1); } }); Modified: qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/MultipleConnectionTest.java URL: http://svn.apache.org/viewvc/qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/MultipleConnectionTest.java?rev=1076489&r1=1076488&r2=1076489&view=diff ============================================================================== --- qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/MultipleConnectionTest.java (original) +++ qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/MultipleConnectionTest.java Thu Mar 3 01:49:08 2011 @@ -23,7 +23,6 @@ import org.apache.qpid.client.AMQConnect import org.apache.qpid.client.AMQDestination; import org.apache.qpid.client.AMQSession; import org.apache.qpid.client.AMQTopic; -import org.apache.qpid.client.transport.TransportConnection; import org.apache.qpid.exchange.ExchangeDefaults; import org.apache.qpid.test.utils.QpidBrokerTestCase; Modified: qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseOkTest.java URL: http://svn.apache.org/viewvc/qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseOkTest.java?rev=1076489&r1=1076488&r2=1076489&view=diff ============================================================================== --- qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseOkTest.java (original) +++ qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseOkTest.java Thu Mar 3 01:49:08 2011 @@ -24,7 +24,6 @@ import junit.textui.TestRunner; import org.apache.qpid.client.AMQConnection; import org.apache.qpid.client.AMQQueue; -import org.apache.qpid.client.transport.TransportConnection; import org.apache.qpid.test.utils.QpidBrokerTestCase; import org.slf4j.Logger; Modified: qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseTest.java URL: http://svn.apache.org/viewvc/qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseTest.java?rev=1076489&r1=1076488&r2=1076489&view=diff ============================================================================== --- qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseTest.java (original) +++ qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseTest.java Thu Mar 3 01:49:08 2011 @@ -25,7 +25,6 @@ import org.apache.qpid.test.utils.QpidBr import org.apache.qpid.client.AMQConnection; import org.apache.qpid.client.failover.FailoverException; import org.apache.qpid.client.protocol.AMQProtocolHandler; -import org.apache.qpid.client.transport.TransportConnection; import org.apache.qpid.framing.*; import org.apache.qpid.jms.ConnectionListener; import org.apache.qpid.protocol.AMQConstant; Modified: qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/protocol/AMQProtocolSessionTest.java URL: http://svn.apache.org/viewvc/qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/protocol/AMQProtocolSessionTest.java?rev=1076489&r1=1076488&r2=1076489&view=diff ============================================================================== --- qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/protocol/AMQProtocolSessionTest.java (original) +++ qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/protocol/AMQProtocolSessionTest.java Thu Mar 3 01:49:08 2011 @@ -31,21 +31,21 @@ import org.apache.qpid.client.protocol.A import org.apache.qpid.client.protocol.AMQProtocolSession; import org.apache.qpid.framing.AMQShortString; import org.apache.qpid.test.utils.QpidBrokerTestCase; -import org.apache.qpid.transport.TestNetworkDriver; +import org.apache.qpid.transport.TestNetworkConnection; +import org.apache.qpid.transport.network.NetworkConnection; public class AMQProtocolSessionTest extends QpidBrokerTestCase { - private static class AMQProtSession extends AMQProtocolSession + private static class TestProtocolSession extends AMQProtocolSession { - - public AMQProtSession(AMQProtocolHandler protocolHandler, AMQConnection connection) + public TestProtocolSession(AMQProtocolHandler protocolHandler, AMQConnection connection) { super(protocolHandler,connection); } - public TestNetworkDriver getNetworkDriver() + public NetworkConnection getNetworkConnection() { - return (TestNetworkDriver) _protocolHandler.getNetworkDriver(); + return new TestNetworkConnection(); } public AMQShortString genQueueName() @@ -54,7 +54,7 @@ public class AMQProtocolSessionTest exte } } - private AMQProtSession _testSession; + private TestProtocolSession _testSession; protected void setUp() throws Exception { @@ -62,10 +62,9 @@ public class AMQProtocolSessionTest exte AMQConnection con = (AMQConnection) getConnection("guest", "guest"); AMQProtocolHandler protocolHandler = new AMQProtocolHandler(con); - protocolHandler.setNetworkDriver(new TestNetworkDriver()); //don't care about the values set here apart from the dummy IoSession - _testSession = new AMQProtSession(protocolHandler , con); + _testSession = new TestProtocolSession(protocolHandler , con); } public void testTemporaryQueueWildcard() throws UnknownHostException @@ -100,7 +99,7 @@ public class AMQProtocolSessionTest exte private void checkTempQueueName(SocketAddress address, String queueName) { - _testSession.getNetworkDriver().setLocalAddress(address); + ((TestNetworkConnection) _testSession.getNetworkConnection()).setAddress(address); assertEquals("Wrong queue name", queueName, _testSession.genQueueName().asString()); } } Modified: qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java URL: http://svn.apache.org/viewvc/qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java?rev=1076489&r1=1076488&r2=1076489&view=diff ============================================================================== --- qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java (original) +++ qpid/branches/grkvlt-network-20110301/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java Thu Mar 3 01:49:08 2011 @@ -17,6 +17,8 @@ */ package org.apache.qpid.test.utils; +import static org.apache.qpid.client.AMQConnection.*; + import java.io.File; import java.io.FileOutputStream; import java.io.IOException; @@ -54,18 +56,20 @@ import org.apache.commons.lang.StringUti import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.qpid.AMQException; +import org.apache.qpid.BrokerOptions; import org.apache.qpid.client.AMQConnection; import org.apache.qpid.client.AMQConnectionFactory; import org.apache.qpid.client.AMQQueue; -import org.apache.qpid.client.transport.TransportConnection; import org.apache.qpid.exchange.ExchangeDefaults; import org.apache.qpid.jms.BrokerDetails; import org.apache.qpid.jms.ConnectionURL; import org.apache.qpid.management.common.mbeans.ConfigurationManagement; import org.apache.qpid.server.configuration.ServerConfiguration; import org.apache.qpid.server.registry.ApplicationRegistry; -import org.apache.qpid.server.registry.ConfigurationFileApplicationRegistry; import org.apache.qpid.server.store.DerbyMessageStore; +import org.apache.qpid.transport.network.Transport; +import org.apache.qpid.transport.network.mina.MinaNetworkTransport; +import org.apache.qpid.transport.vm.VmBroker; import org.apache.qpid.url.URLSyntaxException; import org.apache.qpid.util.LogMonitor; @@ -82,8 +86,6 @@ public class QpidBrokerTestCase extends protected long RECEIVE_TIMEOUT = 1000l; - private Map<String, String> _propertiesSetForTestOnly = new HashMap<String, String>(); - private Map<String, String> _propertiesSetForBroker = new HashMap<String, String>(); private Map<Logger, Level> _loggerLevelSetForTest = new HashMap<Logger, Level>(); private XMLConfiguration _testConfiguration = new XMLConfiguration(); @@ -122,8 +124,6 @@ public class QpidBrokerTestCase extends protected static final String CPP = "cpp"; protected static final String VM = "vm"; protected static final String EXTERNAL = "external"; - private static final String VERSION_08 = "0-8"; - private static final String VERSION_010 = "0-10"; private static final String VERSION_0_8 = "0-8"; private static final String VERSION_0_9 = "0-9"; @@ -142,7 +142,7 @@ public class QpidBrokerTestCase extends protected String _broker = System.getProperty(BROKER, VM); private String _brokerClean = System.getProperty(BROKER_CLEAN, null); private Boolean _brokerCleanBetweenTests = Boolean.getBoolean(BROKER_CLEAN_BETWEEN_TESTS); - private String _brokerVersion = System.getProperty(BROKER_VERSION, VERSION_08); + private String _brokerVersion = System.getProperty(BROKER_VERSION, VERSION_0_8); protected String _output = System.getProperty(TEST_OUTPUT); protected Boolean _brokerPersistent = Boolean.getBoolean(BROKER_PERSITENT); @@ -284,6 +284,11 @@ public class QpidBrokerTestCase extends @Override protected void setUp() throws Exception { + if (isVmBroker()) + { + Transport.registerOutgoingTransport(MinaNetworkTransport.class); + } + if (!_configFile.exists()) { fail("Unable to test without config file:" + _configFile); @@ -456,26 +461,13 @@ public class QpidBrokerTestCase extends setConfigurationProperty(ServerConfiguration.MGMT_CUSTOM_REGISTRY_SOCKET, String.valueOf(false)); saveTestConfiguration(); - // create an in_VM broker - final ConfigurationFileApplicationRegistry registry = new ConfigurationFileApplicationRegistry(_configFile); - try - { - ApplicationRegistry.initialise(registry, port); - } - catch (Exception e) - { - _logger.error("Broker initialise failed due to:",e); - try - { - registry.close(); - } - catch (Throwable closeE) - { - closeE.printStackTrace(); - } - throw e; - } - TransportConnection.createVMBroker(port); + BrokerOptions options = new BrokerOptions(); + options.setProtocol(VM); + options.setBind("localhost"); + options.setPorts(port); + options.setConfigFile(_configFile.getAbsolutePath()); + + VmBroker.createVMBroker(options); } else if (!_broker.equals(EXTERNAL)) { @@ -661,7 +653,7 @@ public class QpidBrokerTestCase extends { port = getPort(port); - _logger.info("stopping broker: " + getBrokerCommand(port)); + _logger.info("stopping broker: " + getBrokerCommand(port) + " on port " + port); Process process = _brokers.remove(port); if (process != null) { @@ -671,8 +663,7 @@ public class QpidBrokerTestCase extends } else if (_broker.equals(VM)) { - TransportConnection.killVMBroker(port); - ApplicationRegistry.remove(port); + VmBroker.killVMBroker(); } } @@ -760,105 +751,6 @@ public class QpidBrokerTestCase extends } /** - * Set a System property that is to be applied only to the external test - * broker. - * - * This is a convenience method to enable the setting of a -Dproperty=value - * entry in QPID_OPTS - * - * This is only useful for the External Java Broker tests. - * - * @param property the property name - * @param value the value to set the property to - */ - protected void setBrokerOnlySystemProperty(String property, String value) - { - if (!_propertiesSetForBroker.containsKey(property)) - { - _propertiesSetForBroker.put(property, value); - } - - } - - /** - * Set a System (-D) property for this test run. - * - * This convenience method copies the current VMs System Property - * for the external VM Broker. - * - * @param property the System property to set - */ - protected void setSystemProperty(String property) - { - setSystemProperty(property, System.getProperty(property)); - } - - /** - * Set a System property for the duration of this test. - * - * When the test run is complete the value will be reverted. - * - * The values set using this method will also be propogated to the external - * Java Broker via a -D value defined in QPID_OPTS. - * - * If the value should not be set on the broker then use - * setTestClientSystemProperty(). - * - * @param property the property to set - * @param value the new value to use - */ - protected void setSystemProperty(String property, String value) - { - // Record the value for the external broker - _propertiesSetForBroker.put(property, value); - - //Set the value for the test client vm aswell. - setTestClientSystemProperty(property, value); - } - - /** - * Set a System (-D) property for the external Broker of this test. - * - * @param property The property to set - * @param value the value to set it to. - */ - protected void setTestClientSystemProperty(String property, String value) - { - if (!_propertiesSetForTestOnly.containsKey(property)) - { - // Record the current value so we can revert it later. - _propertiesSetForTestOnly.put(property, System.getProperty(property)); - } - - System.setProperty(property, value); - } - - /** - * Restore the System property values that were set before this test run. - */ - protected void revertSystemProperties() - { - for (String key : _propertiesSetForTestOnly.keySet()) - { - String value = _propertiesSetForTestOnly.get(key); - if (value != null) - { - System.setProperty(key, value); - } - else - { - System.clearProperty(key); - } - } - - _propertiesSetForTestOnly.clear(); - - // We don't change the current VMs settings for Broker only properties - // so we can just clear this map - _propertiesSetForBroker.clear(); - } - - /** * Add an environtmen variable for the external broker environment * * @param property the property to set @@ -910,27 +802,39 @@ public class QpidBrokerTestCase extends */ public boolean isBroker08() { - return _brokerVersion.equals(VERSION_08); + return _brokerVersion.equals(VERSION_0_8); + } + + public boolean isBroker09() + { + return _brokerVersion.equals(VERSION_0_9) || + _brokerVersion.equals(VERSION_0_9_1) || + _brokerVersion.equals(VERSION_0_91); } public boolean isBroker010() { - return _brokerVersion.equals(VERSION_010); + return _brokerVersion.equals(VERSION_0_10); + } + + protected boolean isVmBroker() + { + return _broker.equals(VM); } protected boolean isJavaBroker() { - return _brokerLanguage.equals("java") || _broker.equals("vm"); + return _brokerLanguage.equals(JAVA) || _broker.equals(VM); } protected boolean isCppBroker() { - return _brokerLanguage.equals("cpp"); + return _brokerLanguage.equals(CPP); } protected boolean isExternalBroker() { - return !_broker.equals("vm"); + return !_broker.equals(VM); } protected boolean isBrokerStorePersistent() @@ -1085,7 +989,7 @@ public class QpidBrokerTestCase extends } - protected void tearDown() throws java.lang.Exception + protected void tearDown() throws Exception { try { @@ -1095,9 +999,10 @@ public class QpidBrokerTestCase extends c.close(); } } - finally{ + finally + { // Ensure any problems with close does not interfer with property resets - revertSystemProperties(); + super.tearDown(); revertLoggingLevels(); } } Modified: qpid/branches/grkvlt-network-20110301/qpid/java/test-profiles/Java010Excludes URL: http://svn.apache.org/viewvc/qpid/branches/grkvlt-network-20110301/qpid/java/test-profiles/Java010Excludes?rev=1076489&r1=1076488&r2=1076489&view=diff ============================================================================== --- qpid/branches/grkvlt-network-20110301/qpid/java/test-profiles/Java010Excludes (original) +++ qpid/branches/grkvlt-network-20110301/qpid/java/test-profiles/Java010Excludes Thu Mar 3 01:49:08 2011 @@ -31,6 +31,10 @@ org.apache.qpid.test.testcases.Mandatory org.apache.qpid.test.testcases.MandatoryMessageTest#test_QPID_508_MandatoryFailsNoRouteNoTxPubSub org.apache.qpid.test.testcases.MandatoryMessageTest#test_QPID_508_MandatoryFailsNoRouteTxPubSub +// Failover for transacted sessions does not work (QPID-2994) +org.apache.qpid.test.client.QueueBrowserTransactedTest#testFailoverAsQueueBrowserCreated +org.apache.qpid.test.client.QueueBrowserTransactedTest#testFailoverWithQueueBrowser + //this test checks explicitly for 0-8 flow control semantics org.apache.qpid.test.client.FlowControlTest#* @@ -74,8 +78,11 @@ org.apache.qpid.test.unit.publish.DirtyT org.apache.qpid.test.client.RollbackOrderTest#testOrderingAfterRollbackOnMessage org.apache.qpid.test.unit.ack.RecoverTest#testRecoverInAutoAckListener +// Mina does not suopport idle timeouts +org.apache.qpid.transport.network.mina.MinaNetworkTransportTest#testSetReadIdle +org.apache.qpid.transport.network.mina.MinaNetworkTransportTest#testSetWriteIdle + //Temporarily adding the following until the issues are sorted out. //Should probably raise JIRAs for them. -org.apache.qpid.transport.network.mina.MINANetworkDriverTest#* org.apache.qpid.test.client.destination.AddressBasedDestinationTest#testCreateExchange org.apache.qpid.test.client.destination.AddressBasedDestinationTest#testBrowseMode Modified: qpid/branches/grkvlt-network-20110301/qpid/java/test-profiles/default.testprofile URL: http://svn.apache.org/viewvc/qpid/branches/grkvlt-network-20110301/qpid/java/test-profiles/default.testprofile?rev=1076489&r1=1076488&r2=1076489&view=diff ============================================================================== --- qpid/branches/grkvlt-network-20110301/qpid/java/test-profiles/default.testprofile (original) +++ qpid/branches/grkvlt-network-20110301/qpid/java/test-profiles/default.testprofile Thu Mar 3 01:49:08 2011 @@ -19,7 +19,8 @@ java.naming.factory.initial=org.apache.qpid.jndi.PropertiesFileInitialContextFactory java.naming.provider.url=${test.profiles}/test-provider.properties -broker.version=0-8 +broker.version=0-9-1 +qpid.amqp.version= broker=vm broker.clean=${test.profiles}/clean-dir ${build.data} ${project.root}/build/work broker.ready=Listening on TCP port --------------------------------------------------------------------- Apache Qpid - AMQP Messaging Implementation Project: http://qpid.apache.org Use/Interact: mailto:[email protected]
