You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by rg...@apache.org on 2006/11/24 15:07:41 UTC

svn commit: r478886 [3/6] - in /incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid: IBMPerfTest/ ack/ basic/ client/ client/channelclose/ client/message/ cluster/ codec/ config/ connection/ connectionurl/ cts/bin/ cts/con...

Modified: incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/mina/WriterTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/mina/WriterTest.java?view=diff&rev=478886&r1=478885&r2=478886
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/mina/WriterTest.java (original)
+++ incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/mina/WriterTest.java Fri Nov 24 06:07:34 2006
@@ -1,256 +1,256 @@
 /*
  *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  *
  */
 package org.apache.qpid.mina;
 
-import junit.framework.JUnit4TestAdapter;
 import org.apache.log4j.Logger;
 import org.apache.mina.common.*;
 import org.apache.mina.transport.socket.nio.SocketConnector;
 import org.apache.mina.transport.socket.nio.SocketConnectorConfig;
 import org.apache.mina.transport.socket.nio.SocketSessionConfig;
-import org.junit.Test;
 
 import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.util.concurrent.CountDownLatch;
 
-public class WriterTest implements Runnable
+import junit.framework.TestCase;
+
+public class WriterTest extends TestCase
 {
     private static final Logger _logger = Logger.getLogger(WriterTest.class);
 
-    private IoSession _session;
+    private static class RunnableWriterTest implements Runnable
+    {
+        private Logger _logger;
 
-    private long _startTime;
+        private IoSession _session;
 
-    private long[] _chunkTimes;
+        private long _startTime;
 
-    private int _chunkCount = 500000;
+        private long[] _chunkTimes;
 
-    private int _chunkSize = 1024;
+        private int _chunkCount = 500000;
 
-    private CountDownLatch _notifier;
+        private int _chunkSize = 1024;
 
-    public void run()
-    {
-        _startTime = System.currentTimeMillis();
-        _notifier = new CountDownLatch(1);
-        for (int i = 0; i < _chunkCount; i++)
-        {
-            ByteBuffer buf = ByteBuffer.allocate(_chunkSize, false);
-            byte check = (byte) (i % 128);
-            buf.put(check);
-            buf.fill((byte)88, buf.remaining());
-            buf.flip();
-            _session.write(buf);
-        }
+        private CountDownLatch _notifier;
 
-        try
-        {
-            _logger.info("All buffers sent; waiting for receipt from server");
-            _notifier.await();
-        }
-        catch (InterruptedException e)
+        public RunnableWriterTest(Logger logger)
         {
+            _logger = logger;
         }
-        _logger.info("Completed");
-        long totalTime = System.currentTimeMillis() - _startTime;
-        _logger.info("Total time: " + totalTime);
-        _logger.info("MB per second: " + (_chunkSize * _chunkCount)/totalTime);
-        long lastChunkTime = _startTime;
-        double average = 0;
-        for (int i = 0; i < _chunkTimes.length; i++)
+
+        public void run()
         {
-            if (i == 0)
+            _startTime = System.currentTimeMillis();
+            _notifier = new CountDownLatch(1);
+            for (int i = 0; i < _chunkCount; i++)
+            {
+                ByteBuffer buf = ByteBuffer.allocate(_chunkSize, false);
+                byte check = (byte) (i % 128);
+                buf.put(check);
+                buf.fill((byte)88, buf.remaining());
+                buf.flip();
+                _session.write(buf);
+            }
+
+            try
+            {
+                _logger.info("All buffers sent; waiting for receipt from server");
+                _notifier.await();
+            }
+            catch (InterruptedException e)
             {
-                average = _chunkTimes[i] - _startTime;
             }
-            else
+            _logger.info("Completed");
+            long totalTime = System.currentTimeMillis() - _startTime;
+            _logger.info("Total time: " + totalTime);
+            _logger.info("MB per second: " + (_chunkSize * _chunkCount)/totalTime);
+            long lastChunkTime = _startTime;
+            double average = 0;
+            for (int i = 0; i < _chunkTimes.length; i++)
             {
-                long delta = _chunkTimes[i] - lastChunkTime;
-                if (delta != 0)
+                if (i == 0)
+                {
+                    average = _chunkTimes[i] - _startTime;
+                }
+                else
                 {
-                    average = (average + delta)/2;
+                    long delta = _chunkTimes[i] - lastChunkTime;
+                    if (delta != 0)
+                    {
+                        average = (average + delta)/2;
+                    }
                 }
+                lastChunkTime = _chunkTimes[i];
             }
-            lastChunkTime = _chunkTimes[i];
+            _logger.info("Average chunk time: " + average + "ms");
+            CloseFuture cf = _session.close();
+            cf.join();
         }
-        _logger.info("Average chunk time: " + average + "ms");
-        CloseFuture cf = _session.close();
-        cf.join();
-    }
 
-    private class WriterHandler extends IoHandlerAdapter
-    {
-        private int _chunksReceived = 0;
+        private class WriterHandler extends IoHandlerAdapter
+        {
+            private int _chunksReceived = 0;
 
-        private int _partialBytesRead = 0;
+            private int _partialBytesRead = 0;
 
-        private byte _partialCheckNumber;
+            private byte _partialCheckNumber;
 
-        private int _totalBytesReceived = 0;
+            private int _totalBytesReceived = 0;
 
-        public void messageReceived(IoSession session, Object message) throws Exception
-        {
-            ByteBuffer result = (ByteBuffer) message;
-            _totalBytesReceived += result.remaining();
-            int size = result.remaining();
-            long now = System.currentTimeMillis();
-            if (_partialBytesRead > 0)
+            public void messageReceived(IoSession session, Object message) throws Exception
             {
-                int offset = _chunkSize - _partialBytesRead;
-                if (size >= offset)
+                ByteBuffer result = (ByteBuffer) message;
+                _totalBytesReceived += result.remaining();
+                int size = result.remaining();
+                long now = System.currentTimeMillis();
+                if (_partialBytesRead > 0)
                 {
-                    _chunkTimes[_chunksReceived++] = now;
-                    result.position(offset);
+                    int offset = _chunkSize - _partialBytesRead;
+                    if (size >= offset)
+                    {
+                        _chunkTimes[_chunksReceived++] = now;
+                        result.position(offset);
+                    }
+                    else
+                    {
+                        // have not read even one chunk, including the previous partial bytes
+                        _partialBytesRead += size;
+                        return;
+                    }
                 }
-                else
-                {
-                    // have not read even one chunk, including the previous partial bytes
-                    _partialBytesRead += size;
-                    return;
-                }
-            }
 
-            int chunkCount = result.remaining()/_chunkSize;
+                int chunkCount = result.remaining()/_chunkSize;
 
-            for (int i = 0; i < chunkCount; i++)
-            {
-                _chunkTimes[_chunksReceived++] = now;
-                byte check = result.get();
-                _logger.debug("Check number " + check + " read");
-                if (check !=  (byte)((_chunksReceived - 1)%128))
+                for (int i = 0; i < chunkCount; i++)
                 {
-                    _logger.error("Check number " + check + " read when expected " + (_chunksReceived%128));
+                    _chunkTimes[_chunksReceived++] = now;
+                    byte check = result.get();
+                    _logger.debug("Check number " + check + " read");
+                    if (check !=  (byte)((_chunksReceived - 1)%128))
+                    {
+                        _logger.error("Check number " + check + " read when expected " + (_chunksReceived%128));
+                    }
+                    _logger.debug("Chunk times recorded");
+
+                    try
+                    {
+                        result.skip(_chunkSize - 1);
+                    }
+                    catch (IllegalArgumentException e)
+                    {
+                        _logger.error("Position was: " + result.position());
+                        _logger.error("Tried to skip to: " + (_chunkSize * i));
+                        _logger.error("limit was; " + result.limit());
+                    }
                 }
-                _logger.debug("Chunk times recorded");
+                _logger.debug("Chunks received now " + _chunksReceived);
+                _logger.debug("Bytes received: " + _totalBytesReceived);
+                _partialBytesRead = result.remaining();
 
-                try
+                if (_partialBytesRead > 0)
                 {
-                    result.skip(_chunkSize - 1);
+                    _partialCheckNumber = result.get();
                 }
-                catch (IllegalArgumentException e)
+
+                if (_chunksReceived >= _chunkCount)
                 {
-                    _logger.error("Position was: " + result.position());
-                    _logger.error("Tried to skip to: " + (_chunkSize * i));
-                    _logger.error("limit was; " + result.limit());
+                    _notifier.countDown();
                 }
-            }
-            _logger.debug("Chunks received now " + _chunksReceived);
-            _logger.debug("Bytes received: " + _totalBytesReceived);
-            _partialBytesRead = result.remaining();
 
-            if (_partialBytesRead > 0)
-            {
-                _partialCheckNumber = result.get();
             }
 
-            if (_chunksReceived >= _chunkCount)
+            public void exceptionCaught(IoSession session, Throwable cause) throws Exception
             {
-                _notifier.countDown();
+                _logger.error("Error: " + cause, cause);
             }
-
         }
 
-        public void exceptionCaught(IoSession session, Throwable cause) throws Exception
+        public void startWriter(int chunkSize) throws IOException, InterruptedException
         {
-            _logger.error("Error: " + cause, cause);
-        }
-    }
+            _chunkSize = chunkSize;
 
-    public void startWriter() throws IOException, InterruptedException
-    {
-        IoConnector ioConnector = null;
+            IoConnector ioConnector = null;
 
-        ioConnector = new SocketConnector();
+            ioConnector = new SocketConnector();
         
-        SocketConnectorConfig cfg = (SocketConnectorConfig) ioConnector.getDefaultConfig();
-        cfg.setThreadModel(ThreadModel.MANUAL);
-        SocketSessionConfig scfg = (SocketSessionConfig) cfg.getSessionConfig();
-        scfg.setTcpNoDelay(true);
-        scfg.setSendBufferSize(32768);
-        scfg.setReceiveBufferSize(32768);
-
-        final InetSocketAddress address = new InetSocketAddress("localhost", AcceptorTest.PORT);
-        _logger.info("Attempting connection to " + address);
-        ConnectFuture future = ioConnector.connect(address, new WriterHandler());
-        // wait for connection to complete
-        future.join();
-        _logger.info("Connection completed");
-        // we call getSession which throws an IOException if there has been an error connecting
-        _session = future.getSession();
-        _chunkTimes = new long[_chunkCount];
-        Thread t = new Thread(this);
-        t.start();
-        t.join();
-        _logger.info("Test completed");
+            SocketConnectorConfig cfg = (SocketConnectorConfig) ioConnector.getDefaultConfig();
+            cfg.setThreadModel(ThreadModel.MANUAL);
+            SocketSessionConfig scfg = (SocketSessionConfig) cfg.getSessionConfig();
+            scfg.setTcpNoDelay(true);
+            scfg.setSendBufferSize(32768);
+            scfg.setReceiveBufferSize(32768);
+
+            final InetSocketAddress address = new InetSocketAddress("localhost", AcceptorTest.PORT);
+            _logger.info("Attempting connection to " + address);
+            ConnectFuture future = ioConnector.connect(address, new WriterHandler());
+            // wait for connection to complete
+            future.join();
+            _logger.info("Connection completed");
+            // we call getSession which throws an IOException if there has been an error connecting
+            _session = future.getSession();
+            _chunkTimes = new long[_chunkCount];
+            Thread t = new Thread(this);
+            t.start();
+            t.join();
+            _logger.info("Test completed");
+        }
     }
 
-    @Test
+    private RunnableWriterTest _runnableWriterTest = new RunnableWriterTest(_logger);
+
     public void test1k() throws IOException, InterruptedException
     {
         _logger.info("Starting 1k test");
-        _chunkSize = 1024;
-        startWriter();
+        _runnableWriterTest.startWriter(1024);
     }
 
-    @Test
     public void test2k() throws IOException, InterruptedException
     {
         _logger.info("Starting 2k test");
-        _chunkSize = 2048;
-        startWriter();
+        _runnableWriterTest.startWriter(2048);
     }
 
-    @Test
     public void test4k() throws IOException, InterruptedException
     {
         _logger.info("Starting 4k test");
-        _chunkSize = 4096;
-        startWriter();
+        _runnableWriterTest.startWriter(4096);
     }
 
-    @Test
     public void test8k() throws IOException, InterruptedException
     {
         _logger.info("Starting 8k test");
-        _chunkSize = 8192;
-        startWriter();
+        _runnableWriterTest.startWriter(8192);
     }
 
-    @Test
     public void test16k() throws IOException, InterruptedException
     {
         _logger.info("Starting 16k test");
-        _chunkSize = 16384;
-        startWriter();
+        _runnableWriterTest.startWriter(16384);
     }
 
-    @Test
     public void test32k() throws IOException, InterruptedException
     {
         _logger.info("Starting 32k test");
-        _chunkSize = 32768;
-        startWriter();
-    }
-
-    public static junit.framework.Test suite()
-    {
-        return new JUnit4TestAdapter(WriterTest.class);
+        _runnableWriterTest.startWriter(32768);
     }
 
     public static void main(String[] args) throws IOException, InterruptedException
@@ -262,5 +262,10 @@
         w.test8k();
         //w.test16k();
         //w.test32k();
+    }
+
+    public static junit.framework.Test suite()
+    {
+        return new junit.framework.TestSuite(WriterTest.class);
     }
 }

Modified: incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/multiconsumer/AMQTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/multiconsumer/AMQTest.java?view=diff&rev=478886&r1=478885&r2=478886
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/multiconsumer/AMQTest.java (original)
+++ incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/multiconsumer/AMQTest.java Fri Nov 24 06:07:34 2006
@@ -1,18 +1,21 @@
 /*
  *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  *
  */
 package org.apache.qpid.multiconsumer;

Modified: incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/ping/TestPingClient.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/ping/TestPingClient.java?view=diff&rev=478886&r1=478885&r2=478886
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/ping/TestPingClient.java (original)
+++ incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/ping/TestPingClient.java Fri Nov 24 06:07:34 2006
@@ -1,18 +1,21 @@
 /*
  *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  *
  */
 package org.apache.qpid.ping;

Modified: incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/ping/TestPingProducer.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/ping/TestPingProducer.java?view=diff&rev=478886&r1=478885&r2=478886
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/ping/TestPingProducer.java (original)
+++ incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/ping/TestPingProducer.java Fri Nov 24 06:07:34 2006
@@ -1,18 +1,21 @@
 /*
  *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  *
  */
 package org.apache.qpid.ping;

Modified: incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/ping/TestPingPublisher.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/ping/TestPingPublisher.java?view=diff&rev=478886&r1=478885&r2=478886
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/ping/TestPingPublisher.java (original)
+++ incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/ping/TestPingPublisher.java Fri Nov 24 06:07:34 2006
@@ -1,18 +1,21 @@
 /*
  *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  *
  */
 package org.apache.qpid.ping;

Modified: incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/ping/TestPingSubscriber.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/ping/TestPingSubscriber.java?view=diff&rev=478886&r1=478885&r2=478886
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/ping/TestPingSubscriber.java (original)
+++ incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/ping/TestPingSubscriber.java Fri Nov 24 06:07:34 2006
@@ -1,18 +1,21 @@
 /*
  *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  *
  */
 package org.apache.qpid.ping;

Modified: incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/pubsub1/TestPublisher.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/pubsub1/TestPublisher.java?view=diff&rev=478886&r1=478885&r2=478886
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/pubsub1/TestPublisher.java (original)
+++ incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/pubsub1/TestPublisher.java Fri Nov 24 06:07:34 2006
@@ -1,18 +1,21 @@
 /*
  *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  *
  */
 package org.apache.qpid.pubsub1;

Modified: incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/pubsub1/TestSubscriber.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/pubsub1/TestSubscriber.java?view=diff&rev=478886&r1=478885&r2=478886
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/pubsub1/TestSubscriber.java (original)
+++ incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/pubsub1/TestSubscriber.java Fri Nov 24 06:07:34 2006
@@ -1,18 +1,21 @@
 /*
  *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  *
  */
 package org.apache.qpid.pubsub1;

Modified: incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/requestreply1/ServiceProvidingClient.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/requestreply1/ServiceProvidingClient.java?view=diff&rev=478886&r1=478885&r2=478886
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/requestreply1/ServiceProvidingClient.java (original)
+++ incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/requestreply1/ServiceProvidingClient.java Fri Nov 24 06:07:34 2006
@@ -1,18 +1,21 @@
 /*
  *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  *
  */
 package org.apache.qpid.requestreply1;
@@ -40,8 +43,7 @@
     private AMQConnection _connection;
 
     public ServiceProvidingClient(String brokerDetails, String username, String password,
-                                  String clientName, String virtualPath, String serviceName,
-                                  final boolean persistent)
+                                  String clientName, String virtualPath, String serviceName)
             throws AMQException, JMSException, URLSyntaxException
     {
         _connection = new AMQConnection(brokerDetails, username, password,
@@ -107,8 +109,7 @@
                         _logger.info("About to create a producer");
                         _destinationProducer = session.createProducer(responseDest);
                         _destinationProducer.setDisableMessageTimestamp(true);
-                        _destinationProducer.setDeliveryMode(persistent?DeliveryMode.PERSISTENT:
-                                                             DeliveryMode.NON_PERSISTENT);
+                        _destinationProducer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
                         _logger.info("After create a producer");
                     }
                 }
@@ -176,7 +177,7 @@
         try
         {
             ServiceProvidingClient client = new ServiceProvidingClient(args[0], args[1], args[2],
-                                                                       clientId, args[3], args[4], true);
+                                                                       clientId, args[3], args[4]);
             client.run();
         }
         catch (JMSException e)

Modified: incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/requestreply1/ServiceRequestingClient.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/requestreply1/ServiceRequestingClient.java?view=diff&rev=478886&r1=478885&r2=478886
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/requestreply1/ServiceRequestingClient.java (original)
+++ incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/requestreply1/ServiceRequestingClient.java Fri Nov 24 06:07:34 2006
@@ -1,18 +1,21 @@
 /*
  *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  *
  */
 package org.apache.qpid.requestreply1;
@@ -165,15 +168,14 @@
     }
     public ServiceRequestingClient(String brokerHosts, String clientID, String username, String password,
                                    String vpath, String commandQueueName,
-                                   final int messageCount, final int messageDataLength, boolean persistent) throws AMQException, URLSyntaxException
+                                   final int messageCount, final int messageDataLength) throws AMQException, URLSyntaxException
     {
         _messageCount = messageCount;
         MESSAGE_DATA = createMessagePayload(messageDataLength);
         try
         {
             createConnection(brokerHosts, clientID, username, password, vpath);
-            //_session = (Session) _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-            _session = (Session) _connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
+            _session = (Session) _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
 
 
             _connection.setExceptionListener(this);
@@ -182,7 +184,7 @@
             AMQQueue destination = new AMQQueue(commandQueueName);
             _producer = (MessageProducer) _session.createProducer(destination);
             _producer.setDisableMessageTimestamp(true);
-            _producer.setDeliveryMode(persistent?DeliveryMode.PERSISTENT:DeliveryMode.NON_PERSISTENT);
+            _producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
 
             _tempDestination = new AMQQueue("TempResponse" +
                                             Long.toString(System.currentTimeMillis()), true);
@@ -193,7 +195,6 @@
             TextMessage first = _session.createTextMessage(MESSAGE_DATA);
             first.setJMSReplyTo(_tempDestination);
             _producer.send(first);
-            _session.commit(); // TODO REMOVE
             try
             {
                 Thread.sleep(1000);
@@ -233,7 +234,6 @@
             }
             _producer.send(msg);
         }
-        _session.commit(); // TODO REMOVE
         _log.info("Finished sending " + _messageCount + " messages");
     }
 
@@ -268,7 +268,7 @@
             String clientID = address.getHostName() + System.currentTimeMillis();
             ServiceRequestingClient client = new ServiceRequestingClient(args[0], clientID, args[1], args[2], args[3],
                                                                          args[4], Integer.parseInt(args[5]),
-                                                                         messageDataLength, true);
+                                                                         messageDataLength);
             Object waiter = new Object();
             client.run(waiter);
             synchronized (waiter)

Modified: incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/requestreply1/VmRequestReply.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/requestreply1/VmRequestReply.java?view=diff&rev=478886&r1=478885&r2=478886
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/requestreply1/VmRequestReply.java (original)
+++ incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/requestreply1/VmRequestReply.java Fri Nov 24 06:07:34 2006
@@ -1,63 +1,44 @@
 /*
  *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  *
  */
 package org.apache.qpid.requestreply1;
 
 import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
 import org.apache.qpid.client.transport.TransportConnection;
-import org.junit.Test;
-import org.junit.Before;
-import org.junit.Assert;
-import org.junit.After;
+import org.apache.qpid.test.VMBrokerSetup;
 import org.apache.log4j.Logger;
-import junit.framework.JUnit4TestAdapter;
 
-public class VmRequestReply
+import junit.framework.TestCase;
+
+public class VmRequestReply extends TestCase
 {
     private static final Logger _logger = Logger.getLogger(VmRequestReply.class);
 
-    @Before
-    public void startVmBrokers()
-    {
-        try
-        {
-            TransportConnection.createVMBroker(1);
-        }
-        catch (AMQVMBrokerCreationException e)
-        {
-            Assert.fail("Unable to create VM Broker");
-        }
-    }
-
-    @After
-    public void stopVmBrokers()
-    {
-        TransportConnection.killVMBroker(1);
-    }
-
-    @Test
-    public void simpleClient() throws Exception
+    public void testSimpleClient() throws Exception
     {
         ServiceProvidingClient serviceProvider = new ServiceProvidingClient("vm://:1", "guest", "guest",
                                                                             "serviceProvidingClient", "/test",
-                                                                            "serviceQ", false);
+                                                                            "serviceQ");
 
         ServiceRequestingClient serviceRequester = new ServiceRequestingClient("vm://:1", "myClient", "guest", "guest",
-                                                                               "/test", "serviceQ", 5000, 512, false);
+                                                                               "/test", "serviceQ", 5000, 512);
 
         serviceProvider.run();
         Object waiter = new Object();
@@ -71,21 +52,21 @@
         }
     }
 
-    public static junit.framework.Test suite()
-    {
-        return new JUnit4TestAdapter(VmRequestReply.class);
-    }
-
     public static void main(String[] args)
     {
         VmRequestReply rr = new VmRequestReply();
         try
         {
-            rr.simpleClient();
+            rr.testSimpleClient();
         }
         catch (Exception e)
         {
             _logger.error("Error: " + e, e);
         }
+    }
+
+    public static junit.framework.Test suite()
+    {
+        return new VMBrokerSetup(new junit.framework.TestSuite(VmRequestReply.class));
     }
 }

Added: incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/VMBrokerSetup.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/VMBrokerSetup.java?view=auto&rev=478886
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/VMBrokerSetup.java (added)
+++ incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/VMBrokerSetup.java Fri Nov 24 06:07:34 2006
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.test;
+
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+
+import org.apache.qpid.client.transport.TransportConnection;
+
+public class VMBrokerSetup extends TestSetup
+{
+    public VMBrokerSetup(Test t)
+    {
+        super(t);
+    }
+
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+        try
+        {
+            TransportConnection.createVMBroker(1);
+        }
+        catch (Exception e)
+        {
+            fail("Unable to create broker: " + e);
+        }
+    }
+
+    protected void tearDown() throws Exception
+    {
+        TransportConnection.killVMBroker(1);
+        super.tearDown();
+    }
+}

Propchange: incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/VMBrokerSetup.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/ack/RecoverTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/ack/RecoverTest.java?view=auto&rev=478886
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/ack/RecoverTest.java (added)
+++ incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/ack/RecoverTest.java Fri Nov 24 06:07:34 2006
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.test.unit.ack;
+
+import org.apache.qpid.client.AMQConnection;
+import org.apache.qpid.client.AMQQueue;
+import org.apache.qpid.client.AMQSession;
+import org.apache.qpid.client.transport.TransportConnection;
+import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
+import org.apache.log4j.Logger;
+import org.apache.log4j.xml.DOMConfigurator;
+import org.apache.qpid.test.VMBrokerSetup;
+
+import javax.jms.*;
+
+import junit.framework.TestCase;
+
+public class RecoverTest extends TestCase
+{
+    private static final Logger _logger = Logger.getLogger(RecoverTest.class);
+
+    static
+    {
+        String workdir = System.getProperty("QPID_WORK");
+        if (workdir == null || workdir.equals(""))
+        {
+            String tempdir = System.getProperty("java.io.tmpdir");
+            System.out.println("QPID_WORK not set using tmp directory: " + tempdir);
+            System.setProperty("QPID_WORK", tempdir);
+        }
+        DOMConfigurator.configure("../broker/etc/log4j.xml");
+    }
+
+    public void testRecoverResendsMsgs() throws Exception
+    {
+        Connection con = new AMQConnection("vm://:1", "guest", "guest", "consumer1", "/test");
+
+        Session consumerSession = con.createSession(false, Session.CLIENT_ACKNOWLEDGE);
+        Queue queue = new AMQQueue("someQ", "someQ", false, true);
+        MessageConsumer consumer = consumerSession.createConsumer(queue);
+        //force synch to ensure the consumer has resulted in a bound queue
+        ((AMQSession) consumerSession).declareExchangeSynch("amq.direct", "direct");
+
+        Connection con2 = new AMQConnection("vm://:1", "guest", "guest", "producer1", "/test");
+        Session producerSession = con2.createSession(false, Session.CLIENT_ACKNOWLEDGE);
+        MessageProducer producer = producerSession.createProducer(queue);
+
+        _logger.info("Sending four messages");
+        producer.send(producerSession.createTextMessage("msg1"));
+        producer.send(producerSession.createTextMessage("msg2"));
+        producer.send(producerSession.createTextMessage("msg3"));
+        producer.send(producerSession.createTextMessage("msg4"));
+
+        con2.close();
+
+        _logger.info("Starting connection");
+        con.start();
+        TextMessage tm = (TextMessage) consumer.receive();
+        tm.acknowledge();
+        _logger.info("Received and acknowledged first message");
+        consumer.receive();
+        consumer.receive();
+        consumer.receive();
+        _logger.info("Received all four messages. Calling recover with three outstanding messages");
+        // no ack for last three messages so when I call recover I expect to get three messages back
+        consumerSession.recover();
+        tm = (TextMessage) consumer.receive(3000);
+        assertEquals("msg2", tm.getText());
+
+        tm = (TextMessage) consumer.receive(3000);
+        assertEquals("msg3", tm.getText());
+
+        tm = (TextMessage) consumer.receive(3000);
+        assertEquals("msg4", tm.getText());
+
+        _logger.info("Received redelivery of three messages. Acknowledging last message");
+        tm.acknowledge();
+
+        _logger.info("Calling acknowledge with no outstanding messages");
+        // all acked so no messages to be delivered
+        consumerSession.recover();
+
+        tm = (TextMessage) consumer.receiveNoWait();
+        assertNull(tm);
+        _logger.info("No messages redelivered as is expected");
+
+        con.close();
+    }
+
+    public static junit.framework.Test suite()
+    {
+        return new VMBrokerSetup(new junit.framework.TestSuite(RecoverTest.class));
+    }
+}

Propchange: incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/ack/RecoverTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/basic/BytesMessageTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/basic/BytesMessageTest.java?view=auto&rev=478886
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/basic/BytesMessageTest.java (added)
+++ incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/basic/BytesMessageTest.java Fri Nov 24 06:07:34 2006
@@ -0,0 +1,237 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.test.unit.basic;
+
+import org.apache.qpid.client.AMQConnection;
+import org.apache.qpid.client.AMQDestination;
+import org.apache.qpid.client.AMQQueue;
+import org.apache.qpid.client.AMQSession;
+import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
+import org.apache.qpid.client.transport.TransportConnection;
+import org.apache.qpid.client.message.JMSBytesMessage;
+import org.apache.qpid.test.VMBrokerSetup;
+import org.apache.mina.common.ByteBuffer;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import javax.jms.*;
+
+import junit.framework.TestCase;
+import junit.framework.Assert;
+
+public class BytesMessageTest extends TestCase implements MessageListener
+{
+    private Connection _connection;
+    private Destination _destination;
+    private Session _session;
+    private final List<JMSBytesMessage> received = new ArrayList<JMSBytesMessage>();
+    private final List<byte[]> messages = new ArrayList<byte[]>();
+    private int _count = 100;
+    public String _connectionString = "vm://:1";
+
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+        init(new AMQConnection(_connectionString, "guest", "guest", randomize("Client"), "/test_path"));
+    }
+
+    protected void tearDown() throws Exception
+    {
+        super.tearDown();
+    }
+
+    void init(AMQConnection connection) throws Exception
+    {
+        init(connection, new AMQQueue(randomize("BytesMessageTest"), true));
+    }
+
+    void init(AMQConnection connection, AMQDestination destination) throws Exception
+    {
+        _connection = connection;
+        _destination = destination;
+        _session = connection.createSession(false, AMQSession.NO_ACKNOWLEDGE);
+
+        // Set up a slow consumer.
+        _session.createConsumer(destination).setMessageListener(this);
+        connection.start();
+    }
+
+    public void test() throws Exception
+    {
+        try
+        {
+            send(_count);
+            waitFor(_count);
+            check();
+            System.out.println("Completed without failure");
+        }
+        finally
+        {
+            _connection.close();
+        }
+    }
+
+    void send(int count) throws JMSException
+    {
+        //create a publisher
+        MessageProducer producer = _session.createProducer(_destination);
+        for (int i = 0; i < count; i++)
+        {
+            BytesMessage msg = _session.createBytesMessage();
+
+            try
+            {
+                msg.readFloat();
+                Assert.fail("Message should not be readable");
+            }
+            catch (MessageNotReadableException mnwe)
+            {
+                //normal execution
+            }
+
+            byte[] data = ("Message " + i).getBytes();
+            msg.writeBytes(data);
+            messages.add(data);
+            producer.send(msg);
+        }
+    }
+
+    void waitFor(int count) throws InterruptedException
+    {
+        synchronized(received)
+        {
+            while (received.size() < count)
+            {
+                received.wait();
+            }
+        }
+    }
+
+    void check() throws JMSException
+    {
+        List<byte[]> actual = new ArrayList<byte[]>();
+        for (JMSBytesMessage m : received)
+        {
+            ByteBuffer buffer = m.getData();
+            byte[] data = new byte[buffer.remaining()];
+            buffer.get(data);
+            actual.add(data);
+
+            try
+            {
+                m.writeBoolean(true);
+                Assert.fail("Message should not be writeable");
+            }
+            catch (MessageNotWriteableException mnwe)
+            {
+                //normal execution
+            }
+        }
+
+        assertEqual(messages.iterator(), actual.iterator());
+    }
+
+    private static void assertEqual(Iterator expected, Iterator actual)
+    {
+        List<String> errors = new ArrayList<String>();
+        while (expected.hasNext() && actual.hasNext())
+        {
+            try
+            {
+                assertEquivalent((byte[]) expected.next(), (byte[]) actual.next());
+            }
+            catch (Exception e)
+            {
+                errors.add(e.getMessage());
+            }
+        }
+        while (expected.hasNext())
+        {
+            errors.add("Expected " + expected.next() + " but no more actual values.");
+        }
+        while (actual.hasNext())
+        {
+            errors.add("Found " + actual.next() + " but no more expected values.");
+        }
+        if (!errors.isEmpty())
+        {
+            throw new RuntimeException(errors.toString());
+        }
+    }
+
+    private static void assertEquivalent(byte[] expected, byte[] actual)
+    {
+        if (expected.length != actual.length)
+        {
+            throw new RuntimeException("Expected length " + expected.length + " got " + actual.length);
+        }
+        for (int i = 0; i < expected.length; i++)
+        {
+            if (expected[i] != actual[i])
+            {
+                throw new RuntimeException("Failed on byte " + i + " of " + expected.length);
+            }
+        }
+    }
+
+    public void onMessage(Message message)
+    {
+        synchronized(received)
+        {
+            received.add((JMSBytesMessage) message);
+            received.notify();
+        }
+    }
+
+    private static String randomize(String in)
+    {
+        return in + System.currentTimeMillis();
+    }
+
+    public static void main(String[] argv) throws Exception
+    {
+        final String connectionString;
+        final int count;
+        if (argv.length == 0)
+        {
+            connectionString = "vm://:1";
+            count = 100;
+        }
+        else
+        {
+            connectionString = argv[0];
+            count = Integer.parseInt(argv[1]);
+        }
+
+        System.out.println("connectionString = " + connectionString);
+        System.out.println("count = " + count);
+
+        BytesMessageTest test = new BytesMessageTest();
+        test._connectionString = connectionString;
+        test._count = count;
+        test.test();
+    }
+
+    public static junit.framework.Test suite()
+    {
+        return new VMBrokerSetup(new junit.framework.TestSuite(BytesMessageTest.class));
+    }
+}

Propchange: incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/basic/BytesMessageTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableKeyEnumeratorTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableKeyEnumeratorTest.java?view=auto&rev=478886
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableKeyEnumeratorTest.java (added)
+++ incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableKeyEnumeratorTest.java Fri Nov 24 06:07:34 2006
@@ -0,0 +1,81 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.test.unit.basic;
+
+import org.apache.qpid.framing.FieldTable;
+import org.apache.qpid.client.message.JMSTextMessage;
+import org.apache.qpid.client.message.TestMessageHelper;
+
+import java.util.Enumeration;
+
+import javax.jms.JMSException;
+
+import junit.framework.TestCase;
+
+public class FieldTableKeyEnumeratorTest extends TestCase
+{
+    public void testKeyEnumeration()
+    {
+        FieldTable result = new FieldTable();
+        result.put("one", 1L);
+        result.put("two", 2L);
+        result.put("three", 3L);
+        result.put("four", 4L);
+        result.put("five", 5L);
+
+        Enumeration e = result.keys();
+
+        assertTrue("one".equals(e.nextElement()));
+        assertTrue("two".equals(e.nextElement()));
+        assertTrue("three".equals(e.nextElement()));
+        assertTrue("four".equals(e.nextElement()));
+        assertTrue("five".equals(e.nextElement()));
+    }
+
+    public void testPropertEnu()
+    {
+        try
+        {
+            JMSTextMessage text = TestMessageHelper.newJMSTextMessage();
+
+            text.setBooleanProperty("Boolean1", true);
+            text.setBooleanProperty("Boolean2", true);
+            text.setIntProperty("Int", 2);
+            text.setLongProperty("Long", 2);
+
+            Enumeration e = text.getPropertyNames();
+
+            assertTrue("Boolean1".equals(e.nextElement()));
+            assertTrue("Boolean2".equals(e.nextElement()));
+            assertTrue("Int".equals(e.nextElement()));
+            assertTrue("Long".equals(e.nextElement()));
+        }
+        catch (JMSException e)
+        {
+
+        }
+    }
+
+    public static junit.framework.Test suite()
+    {
+        return new junit.framework.TestSuite(FieldTableKeyEnumeratorTest.class);
+    }
+}

Propchange: incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableKeyEnumeratorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableMessageTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableMessageTest.java?view=auto&rev=478886
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableMessageTest.java (added)
+++ incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableMessageTest.java Fri Nov 24 06:07:34 2006
@@ -0,0 +1,163 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.test.unit.basic;
+
+import org.apache.qpid.client.AMQConnection;
+import org.apache.qpid.client.AMQDestination;
+import org.apache.qpid.client.AMQQueue;
+import org.apache.qpid.client.AMQSession;
+import org.apache.qpid.client.message.JMSBytesMessage;
+import org.apache.qpid.framing.AMQFrameDecodingException;
+import org.apache.qpid.framing.FieldTable;
+import org.apache.qpid.framing.FieldTableTest;
+import org.apache.qpid.test.VMBrokerSetup;
+import org.apache.mina.common.ByteBuffer;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import javax.jms.*;
+
+import junit.framework.TestCase;
+
+public class FieldTableMessageTest extends TestCase implements MessageListener
+{
+    private AMQConnection _connection;
+    private AMQDestination _destination;
+    private AMQSession _session;
+    private final ArrayList<JMSBytesMessage> received = new ArrayList<JMSBytesMessage>();
+    private FieldTable _expected;
+    private int _count = 10;
+    public String _connectionString = "vm://:1";
+
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+        init(new AMQConnection(_connectionString, "guest", "guest", randomize("Client"), "/test_path"));        
+    }
+
+    protected void tearDown() throws Exception
+    {
+        super.tearDown();
+    }
+
+
+    private void init(AMQConnection connection) throws Exception
+    {
+        init(connection, new AMQQueue(randomize("FieldTableMessageTest"), true));
+    }
+
+    private void init(AMQConnection connection, AMQDestination destination) throws Exception
+    {
+        _connection = connection;
+        _destination = destination;
+        _session = (AMQSession) connection.createSession(false, AMQSession.NO_ACKNOWLEDGE);
+
+        //set up a slow consumer
+        _session.createConsumer(destination).setMessageListener(this);
+        connection.start();
+
+        //_expected = new FieldTableTest().load("FieldTableTest2.properties");
+        _expected = load();
+    }
+
+    private FieldTable load() throws IOException
+    {
+        FieldTable result = new FieldTable();
+        result.put("one", 1L);
+        result.put("two", 2L);
+        result.put("three", 3L);
+        result.put("four", 4L);
+        result.put("five", 5L);
+
+        return result;
+    }
+
+    public void test() throws Exception
+    {
+        int count = _count;
+        send(count);
+        waitFor(count);
+        check();
+        System.out.println("Completed without failure");
+        _connection.close();
+    }
+
+    void send(int count) throws JMSException, IOException
+    {
+        //create a publisher
+        MessageProducer producer = _session.createProducer(_destination);
+        for (int i = 0; i < count; i++)
+        {
+            BytesMessage msg = _session.createBytesMessage();
+            msg.writeBytes(_expected.getDataAsBytes());
+            producer.send(msg);
+        }
+    }
+
+    void waitFor(int count) throws InterruptedException
+    {
+        synchronized(received)
+        {
+            while (received.size() < count)
+            {
+                received.wait();
+            }
+        }
+    }
+
+    void check() throws JMSException, AMQFrameDecodingException
+    {
+        for (Object m : received)
+        {
+            ByteBuffer buffer = ((JMSBytesMessage) m).getData();
+            FieldTable actual = new FieldTable(buffer, buffer.remaining());
+            new FieldTableTest().assertEquivalent(_expected, actual);
+        }
+    }
+
+    public void onMessage(Message message)
+    {
+        synchronized(received)
+        {
+            received.add((JMSBytesMessage) message);
+            received.notify();
+        }
+    }
+
+    private static String randomize(String in)
+    {
+        return in + System.currentTimeMillis();
+    }
+
+    public static void main(String[] argv) throws Exception
+    {
+        FieldTableMessageTest test = new FieldTableMessageTest();
+        test._connectionString = argv.length == 0 ? "vm://:1" : argv[0];
+        test.setUp();
+        test._count = argv.length > 1 ? Integer.parseInt(argv[1]) : 5;
+        test.test();
+    }
+
+    public static junit.framework.Test suite()
+    {
+        return new VMBrokerSetup(new junit.framework.TestSuite(FieldTableMessageTest.class));
+    }
+}

Propchange: incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableMessageTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/basic/MapMessageTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/basic/MapMessageTest.java?view=auto&rev=478886
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/basic/MapMessageTest.java (added)
+++ incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/basic/MapMessageTest.java Fri Nov 24 06:07:34 2006
@@ -0,0 +1,218 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.test.unit.basic;
+
+import org.apache.qpid.client.AMQConnection;
+import org.apache.qpid.client.AMQDestination;
+import org.apache.qpid.client.AMQQueue;
+import org.apache.qpid.client.AMQSession;
+import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
+import org.apache.qpid.client.transport.TransportConnection;
+import org.apache.qpid.client.message.JMSTextMessage;
+import org.apache.qpid.client.message.JMSMapMessage;
+import org.apache.qpid.test.VMBrokerSetup;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import javax.jms.*;
+
+import junit.framework.TestCase;
+import junit.framework.Assert;
+
+public class MapMessageTest extends TestCase implements MessageListener
+{
+    private AMQConnection _connection;
+    private Destination _destination;
+    private AMQSession _session;
+    private final List<JMSMapMessage> received = new ArrayList<JMSMapMessage>();
+    private final List<String> messages = new ArrayList<String>();
+    private int _count = 100;
+    public String _connectionString = "vm://:1";
+
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+        try
+        {
+            init(new AMQConnection(_connectionString, "guest", "guest", randomize("Client"), "/test_path"));
+        }
+        catch (Exception e)
+        {
+            fail("Unable to initialilse connection: " + e);
+        }
+    }
+
+    protected void tearDown() throws Exception
+    {
+        super.tearDown();
+    }
+
+    private void init(AMQConnection connection) throws Exception
+    {
+        Destination destination = new AMQQueue(randomize("MapMessageTest"), true);
+        init(connection, destination);
+    }
+
+    private void init(AMQConnection connection, Destination destination) throws Exception
+    {
+        _connection = connection;
+        _destination = destination;
+        _session = (AMQSession) connection.createSession(false, AMQSession.AUTO_ACKNOWLEDGE);
+
+        //set up a slow consumer
+        _session.createConsumer(destination).setMessageListener(this);
+        connection.start();
+    }
+
+    public void test() throws Exception
+    {
+        int count = _count;
+        send(count);
+        waitFor(count);
+        check();
+        System.out.println("Completed without failure");
+        _connection.close();
+    }
+
+    void send(int count) throws JMSException
+    {
+        //create a publisher
+        MessageProducer producer = _session.createProducer(_destination);
+        for (int i = 0; i < count; i++)
+        {
+            String text = "Message " + i;
+            messages.add(text);
+            MapMessage message = _session.createMapMessage();
+
+            message.setBoolean("odd", i / 2 == 0);
+            message.setInt("messageNumber", i);
+            message.setString("message", text);
+
+            producer.send(message);
+        }
+    }
+
+    void waitFor(int count) throws InterruptedException
+    {
+        synchronized(received)
+        {
+            while (received.size() < count)
+            {
+                received.wait();
+            }
+        }
+    }
+
+    void check() throws JMSException
+    {
+        List<String> actual = new ArrayList<String>();
+        int count = 0;
+        for (JMSMapMessage m : received)
+        {
+            actual.add(m.getString("message"));
+            assertEqual(m.getInt("messageNumber"), count);
+            assertEqual(m.getBoolean("odd"), count / 2 == 0);
+
+//            try
+//            {
+//                m.setInt("testint", 3);
+//                fail("Message should not be writeable");
+//            }
+//            catch (MessageNotWriteableException mnwe)
+//            {
+//                //normal execution
+//            }
+
+
+            count++;
+        }
+
+        assertEqual(messages.iterator(), actual.iterator());
+    }
+
+    private static void assertEqual(Iterator expected, Iterator actual)
+    {
+        List<String> errors = new ArrayList<String>();
+        while (expected.hasNext() && actual.hasNext())
+        {
+            try
+            {
+                assertEqual(expected.next(), actual.next());
+            }
+            catch (Exception e)
+            {
+                errors.add(e.getMessage());
+            }
+        }
+        while (expected.hasNext())
+        {
+            errors.add("Expected " + expected.next() + " but no more actual values.");
+        }
+        while (actual.hasNext())
+        {
+            errors.add("Found " + actual.next() + " but no more expected values.");
+        }
+        if (!errors.isEmpty())
+        {
+            throw new RuntimeException(errors.toString());
+        }
+    }
+
+    private static void assertEqual(Object expected, Object actual)
+    {
+        if (!expected.equals(actual))
+        {
+            throw new RuntimeException("Expected '" + expected + "' found '" + actual + "'");
+        }
+    }
+
+    public void onMessage(Message message)
+    {
+        synchronized(received)
+        {
+            received.add((JMSMapMessage) message);
+            received.notify();
+        }
+    }
+
+    private static String randomize(String in)
+    {
+        return in + System.currentTimeMillis();
+    }
+
+    public static void main(String[] argv) throws Exception
+    {
+        MapMessageTest test = new MapMessageTest();
+        test._connectionString = argv.length == 0 ? "vm://:1" : argv[0];
+        test.setUp();
+        if (argv.length > 1)
+        {
+            test._count = Integer.parseInt(argv[1]);
+        }
+        test.test();
+    }
+
+    public static junit.framework.Test suite()
+    {
+        return new VMBrokerSetup(new junit.framework.TestSuite(MapMessageTest.class));
+    }
+}

Propchange: incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/basic/MapMessageTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/basic/MultipleConnectionTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/basic/MultipleConnectionTest.java?view=auto&rev=478886
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/basic/MultipleConnectionTest.java (added)
+++ incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/basic/MultipleConnectionTest.java Fri Nov 24 06:07:34 2006
@@ -0,0 +1,214 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.test.unit.basic;
+
+import org.apache.qpid.client.AMQConnection;
+import org.apache.qpid.client.AMQDestination;
+import org.apache.qpid.client.AMQSession;
+import org.apache.qpid.client.AMQTopic;
+import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
+import org.apache.qpid.client.transport.TransportConnection;
+import org.apache.qpid.test.VMBrokerSetup;
+
+import javax.jms.*;
+
+import junit.framework.TestCase;
+
+public class MultipleConnectionTest extends TestCase
+{
+    public static final String _defaultBroker = "vm://:1";
+    public static String _connectionString = _defaultBroker;
+
+    private static class Receiver
+    {
+        private AMQConnection _connection;
+        private Session[] _sessions;
+        private MessageCounter[] _counters;
+
+        Receiver(String broker, AMQDestination dest, int sessions) throws Exception
+        {
+            this(new AMQConnection(broker, "guest", "guest", randomize("Client"), "/test_path"), dest, sessions);
+        }
+
+        Receiver(AMQConnection connection, AMQDestination dest, int sessions) throws Exception
+        {
+            _connection = connection;
+            _sessions = new AMQSession[sessions];
+            _counters = new MessageCounter[sessions];
+            for (int i = 0; i < sessions; i++)
+            {
+                _sessions[i] = _connection.createSession(false, AMQSession.NO_ACKNOWLEDGE);
+                _counters[i] = new MessageCounter(_sessions[i].toString());
+                _sessions[i].createConsumer(dest).setMessageListener(_counters[i]);
+            }
+            _connection.start();
+        }
+
+        void close() throws JMSException
+        {
+            _connection.close();
+        }
+    }
+
+    private static class Publisher
+    {
+        private AMQConnection _connection;
+        private Session _session;
+        private MessageProducer _producer;
+
+        Publisher(String broker, AMQDestination dest) throws Exception
+        {
+            this(new AMQConnection(broker, "guest", "guest", randomize("Client"), "/test_path"), dest);
+        }
+
+        Publisher(AMQConnection connection, AMQDestination dest) throws Exception
+        {
+            _connection = connection;
+            _session = _connection.createSession(false, AMQSession.NO_ACKNOWLEDGE);
+            _producer = _session.createProducer(dest);
+        }
+
+        void send(String msg) throws JMSException
+        {
+            _producer.send(_session.createTextMessage(msg));
+        }
+
+        void close() throws JMSException
+        {
+            _connection.close();
+        }
+    }
+
+    private static class MessageCounter implements MessageListener
+    {
+        private final String _name;
+        private int _count;
+
+        MessageCounter(String name)
+        {
+            _name = name;
+        }
+
+        public synchronized void onMessage(Message message)
+        {
+            _count++;
+            notify();
+        }
+
+        synchronized boolean waitUntil(int expected, long maxWait) throws InterruptedException
+        {
+            long start = System.currentTimeMillis();
+            while (expected > _count)
+            {
+                long timeLeft = maxWait - timeSince(start);
+                if (timeLeft < 0)
+                {
+                    break;
+                }
+                wait(timeLeft);
+            }
+            return expected <= _count;
+        }
+
+        private long timeSince(long start)
+        {
+            return System.currentTimeMillis() - start;
+        }
+
+        public synchronized String toString()
+        {
+            return _name + ": " + _count;
+        }
+    }
+
+    private static void waitForCompletion(int expected, long wait, Receiver[] receivers) throws InterruptedException
+    {
+        for (int i = 0; i < receivers.length; i++)
+        {
+            waitForCompletion(expected, wait, receivers[i]._counters);
+        }
+    }
+
+    private static void waitForCompletion(int expected, long wait, MessageCounter[] counters) throws InterruptedException
+    {
+        for (int i = 0; i < counters.length; i++)
+        {
+            if (!counters[i].waitUntil(expected, wait))
+            {
+                throw new RuntimeException("Expected: " + expected + " got " + counters[i]);
+            }
+        }
+    }
+
+    private static String randomize(String in)
+    {
+        return in + System.currentTimeMillis();
+    }
+
+    public static void main(String[] argv) throws Exception
+    {
+        String broker = argv.length > 0 ? argv[0] : _defaultBroker;
+
+        int connections = 7;
+        int sessions = 2;
+
+        MultipleConnectionTest test = new MultipleConnectionTest();
+        test._connectionString = broker;
+        test.test();
+    }
+
+    public void test() throws Exception
+    {
+        String broker = _connectionString;
+        int messages = 10;
+
+        AMQTopic topic = new AMQTopic("amq.topic");
+
+        Receiver[] receivers = new Receiver[]{
+                new Receiver(broker, topic, 2),
+                new Receiver(broker, topic, 14)
+        };
+
+        Publisher publisher = new Publisher(broker, topic);
+        for (int i = 0; i < messages; i++)
+        {
+            publisher.send("Message " + (i + 1));
+        }
+
+        try
+        {
+            waitForCompletion(messages, 5000, receivers);
+            System.out.println("All receivers received all expected messages");
+        }
+        finally
+        {
+            publisher.close();
+            for (int i = 0; i < receivers.length; i++)
+            {
+                receivers[i].close();
+            }
+        }
+    }
+
+    public static junit.framework.Test suite()
+    {
+        return new VMBrokerSetup(new junit.framework.TestSuite(MultipleConnectionTest.class));
+    }
+}

Propchange: incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/basic/MultipleConnectionTest.java
------------------------------------------------------------------------------
    svn:eol-style = native