Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 49485 invoked from network); 9 Jul 2008 05:54:07 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 9 Jul 2008 05:54:07 -0000 Received: (qmail 11365 invoked by uid 500); 9 Jul 2008 05:54:07 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 11345 invoked by uid 500); 9 Jul 2008 05:54:07 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 11336 invoked by uid 99); 9 Jul 2008 05:54:07 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 08 Jul 2008 22:54:07 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Jul 2008 05:53:24 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 4E13C23889FE; Tue, 8 Jul 2008 22:53:46 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@activemq.apache.org From: jstrachan@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080709055346.4E13C23889FE@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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; + } }