activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r675098 - in /activemq/trunk/activemq-protocol-buffer/src/test/java/org/apache/activemq/protocolbuffer: MarshallTest.java OpenWirePerformanceTest.java Performance2Test.java PerformanceTest.java TestSupport.java
Date Wed, 09 Jul 2008 05:53:45 GMT
Author: jstrachan
Date: Tue Jul  8 22:53:45 2008
New Revision: 675098

URL: http://svn.apache.org/viewvc?rev=675098&view=rev
Log:
minor refactor in test cases which now demostrate a bug in PB

Added:
    activemq/trunk/activemq-protocol-buffer/src/test/java/org/apache/activemq/protocolbuffer/MarshallTest.java
  (contents, props changed)
      - copied, changed from r675094, activemq/trunk/activemq-protocol-buffer/src/test/java/org/apache/activemq/protocolbuffer/PerformanceTest.java
    activemq/trunk/activemq-protocol-buffer/src/test/java/org/apache/activemq/protocolbuffer/PerformanceTest.java
      - copied, changed from r675094, activemq/trunk/activemq-protocol-buffer/src/test/java/org/apache/activemq/protocolbuffer/Performance2Test.java
Removed:
    activemq/trunk/activemq-protocol-buffer/src/test/java/org/apache/activemq/protocolbuffer/Performance2Test.java
Modified:
    activemq/trunk/activemq-protocol-buffer/src/test/java/org/apache/activemq/protocolbuffer/OpenWirePerformanceTest.java
    activemq/trunk/activemq-protocol-buffer/src/test/java/org/apache/activemq/protocolbuffer/TestSupport.java

Copied: activemq/trunk/activemq-protocol-buffer/src/test/java/org/apache/activemq/protocolbuffer/MarshallTest.java
(from r675094, activemq/trunk/activemq-protocol-buffer/src/test/java/org/apache/activemq/protocolbuffer/PerformanceTest.java)
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-protocol-buffer/src/test/java/org/apache/activemq/protocolbuffer/MarshallTest.java?p2=activemq/trunk/activemq-protocol-buffer/src/test/java/org/apache/activemq/protocolbuffer/MarshallTest.java&p1=activemq/trunk/activemq-protocol-buffer/src/test/java/org/apache/activemq/protocolbuffer/PerformanceTest.java&r1=675094&r2=675098&rev=675098&view=diff
==============================================================================
--- activemq/trunk/activemq-protocol-buffer/src/test/java/org/apache/activemq/protocolbuffer/PerformanceTest.java
(original)
+++ activemq/trunk/activemq-protocol-buffer/src/test/java/org/apache/activemq/protocolbuffer/MarshallTest.java
Tue Jul  8 22:53:45 2008
@@ -27,12 +27,12 @@
 /**
  * @version $Revision: 1.1 $
  */
-public class PerformanceTest extends TestCase {
-    protected int messageCount = 10;
-    protected String fileName = "target/messages.openwire";
+public class MarshallTest extends TestCase {
+    protected int messageCount = 1000;
+    protected String fileName = "target/marshall.openwire";
 
 
-    public void testPerformance() throws Exception {
+    public void testMarshalling() throws Exception {
         FileOutputStream out = new FileOutputStream(fileName);
         CodedOutputStream cout = CodedOutputStream.newInstance(out);
         OpenWire.Destination destination = OpenWire.Destination.newBuilder().setName("FOO.BAR").setType(OpenWire.Destination.DestinationType.QUEUE).build();
@@ -63,6 +63,14 @@
             OpenWire.Message message = OpenWire.Message.parseFrom(cin);
             cin.popLimit(previous);
             System.out.println("Reading message: " + i + " = " + message);
+
+            assertEquals("message.getPersistent()", true, message.getPersistent());
+            assertEquals("message.getProducerId()", 1234, message.getProducerId());
+            assertEquals("message.getProducerCounter()", i, message.getProducerCounter());
+            OpenWire.Destination actualDestination = message.getDestination();
+            assertNotNull("message.getDestination() is null!", actualDestination);
+            assertEquals("destination.getName()", destination.getName(), actualDestination.getName());
+            assertEquals("destination.getType()", destination.getType(), actualDestination.getType());
         }
         in.close();
     }

Propchange: activemq/trunk/activemq-protocol-buffer/src/test/java/org/apache/activemq/protocolbuffer/MarshallTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: activemq/trunk/activemq-protocol-buffer/src/test/java/org/apache/activemq/protocolbuffer/OpenWirePerformanceTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-protocol-buffer/src/test/java/org/apache/activemq/protocolbuffer/OpenWirePerformanceTest.java?rev=675098&r1=675097&r2=675098&view=diff
==============================================================================
--- activemq/trunk/activemq-protocol-buffer/src/test/java/org/apache/activemq/protocolbuffer/OpenWirePerformanceTest.java
(original)
+++ activemq/trunk/activemq-protocol-buffer/src/test/java/org/apache/activemq/protocolbuffer/OpenWirePerformanceTest.java
Tue Jul  8 22:53:45 2008
@@ -27,7 +27,7 @@
  */
 public class OpenWirePerformanceTest extends TestSupport {
 
-    protected String fileName = "target/messages3.openwire";
+    protected String fileName = "target/openwire.openwire";
     protected OpenWireFormat openWireFormat = createOpenWireFormat();
     protected ActiveMQDestination destination = new ActiveMQQueue("FOO.BAR");
     protected ProducerId producerId = new ProducerId(new SessionId(new ConnectionId("abc"),
1), 1);
@@ -37,7 +37,7 @@
         DataOutputStream ds = new DataOutputStream(out);
 
         StopWatch watch = createStopWatch("writer");
-        for (int i = 0; i < messageCount; i++) {
+        for (long i = 0; i < messageCount; i++) {
             watch.start();
             Message message = new ActiveMQMessage();
 
@@ -72,7 +72,7 @@
         InputStream in = new BufferedInputStream(new FileInputStream(fileName));
         DataInput dis = new DataInputStream(in);
 
-        for (int i = 0; i < messageCount; i++) {
+        for (long i = 0; i < messageCount; i++) {
             watch2.start();
 
             Object message = openWireFormat.unmarshal(dis);
@@ -89,13 +89,6 @@
         in.close();
     }
 
-    private StopWatch createStopWatch(String name) {
-        StopWatch answer = new StopWatch(name);
-        answer.setLogFrequency(messageCount / 10);
-        return answer;
-    }
-
-
     protected OpenWireFormat createOpenWireFormat() {
         OpenWireFormat wf = new OpenWireFormat();
         wf.setCacheEnabled(true);

Copied: activemq/trunk/activemq-protocol-buffer/src/test/java/org/apache/activemq/protocolbuffer/PerformanceTest.java
(from r675094, activemq/trunk/activemq-protocol-buffer/src/test/java/org/apache/activemq/protocolbuffer/Performance2Test.java)
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-protocol-buffer/src/test/java/org/apache/activemq/protocolbuffer/PerformanceTest.java?p2=activemq/trunk/activemq-protocol-buffer/src/test/java/org/apache/activemq/protocolbuffer/PerformanceTest.java&p1=activemq/trunk/activemq-protocol-buffer/src/test/java/org/apache/activemq/protocolbuffer/Performance2Test.java&r1=675094&r2=675098&rev=675098&view=diff
==============================================================================
--- activemq/trunk/activemq-protocol-buffer/src/test/java/org/apache/activemq/protocolbuffer/Performance2Test.java
(original)
+++ activemq/trunk/activemq-protocol-buffer/src/test/java/org/apache/activemq/protocolbuffer/PerformanceTest.java
Tue Jul  8 22:53:45 2008
@@ -17,17 +17,17 @@
  */
 package org.apache.activemq.protocolbuffer;
 
-import com.google.protobuf.CodedOutputStream;
 import com.google.protobuf.CodedInputStream;
+import com.google.protobuf.CodedOutputStream;
 
 import java.io.*;
 
 /**
  * @version $Revision: 1.1 $
  */
-public class Performance2Test extends TestSupport {
+public class PerformanceTest extends TestSupport {
 
-    protected String fileName = "target/messages2.openwire";
+    protected String fileName = "target/performance.openwire";
     protected OpenWire.Destination destination = OpenWire.Destination.newBuilder().setName("FOO.BAR").setType(OpenWire.Destination.DestinationType.QUEUE).build();
 
     public void testPerformance() throws Exception {
@@ -35,7 +35,7 @@
         CodedOutputStream cout = CodedOutputStream.newInstance(out);
 
         StopWatch watch = createStopWatch("writer");
-        for (int i = 0; i < messageCount; i++) {
+        for (long i = 0; i < messageCount; i++) {
             watch.start();
             OpenWire.Message.Builder builder = OpenWire.Message.newBuilder()
                     .setDestination(destination)
@@ -43,8 +43,9 @@
                     .setCorrelationId("ABCD");
 
             if (useProducerId) {
+                int producerCounter = (int) i;
                 builder = builder.setProducerId(1234)
-                        .setProducerCounter(i);
+                        .setProducerCounter(producerCounter);
             }
 
             OpenWire.Message message = builder.build();
@@ -53,6 +54,7 @@
                 System.out.println("Writing message: " + i + " = " + message);
             }
             int size = message.getSerializedSize();
+
             cout.writeRawVarint32(size);
             message.writeTo(cout);
 
@@ -66,7 +68,7 @@
         InputStream in = new BufferedInputStream(new FileInputStream(fileName));
         CodedInputStream cin = CodedInputStream.newInstance(in);
 
-        for (int i = 0; i < messageCount; i++) {
+        for (long i = 0; i < messageCount; i++) {
             watch2.start();
 
             int size = cin.readRawVarint32();
@@ -78,15 +80,21 @@
             if (verbose) {
                 System.out.println("Reading message: " + i + " = " + message);
             }
+            if (doAssertions) {
+                if (useProducerId) {
+                    assertEquals("message.getProducerId()", 1234, message.getProducerId());
+                    assertEquals("message.getProducerCounter()", i, message.getProducerCounter());
+                }
+                assertEquals("message.getPersistent()", true, message.getPersistent());
+                assertEquals("message.getCorrelationId()", "ABCD", message.getCorrelationId());
+
+                OpenWire.Destination actualDestination = message.getDestination();
+                assertNotNull("message.getDestination() is null!", actualDestination);
+                assertEquals("destination.getName()", destination.getName(), actualDestination.getName());
+                assertEquals("destination.getType()", destination.getType(), actualDestination.getType());
+            }
             watch2.stop();
         }
         in.close();
     }
-
-    private StopWatch createStopWatch(String name) {
-        StopWatch answer = new StopWatch(name);
-        answer.setLogFrequency(messageCount / 10);
-        return answer;
-    }
-
 }
\ No newline at end of file

Modified: activemq/trunk/activemq-protocol-buffer/src/test/java/org/apache/activemq/protocolbuffer/TestSupport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-protocol-buffer/src/test/java/org/apache/activemq/protocolbuffer/TestSupport.java?rev=675098&r1=675097&r2=675098&view=diff
==============================================================================
--- activemq/trunk/activemq-protocol-buffer/src/test/java/org/apache/activemq/protocolbuffer/TestSupport.java
(original)
+++ activemq/trunk/activemq-protocol-buffer/src/test/java/org/apache/activemq/protocolbuffer/TestSupport.java
Tue Jul  8 22:53:45 2008
@@ -23,7 +23,15 @@
  * @version $Revision: 1.1 $
  */
 public class TestSupport extends TestCase {
-    protected int messageCount = 1000000;
+    // TODO seems like 4m messages cause Protocol Buffers to barf but 3m is fine :)
+    protected long messageCount = 4 * 1000 * 1000;
     protected boolean verbose = false;
+    protected boolean doAssertions = true;
     protected boolean useProducerId = false;
+
+    protected StopWatch createStopWatch(String name) {
+        StopWatch answer = new StopWatch(name);
+        answer.setLogFrequency((int) messageCount / 10);
+        return answer;
+    }
 }



Mime
View raw message