activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rajdav...@apache.org
Subject svn commit: r901188 [2/2] - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/broker/ main/java/org/apache/activemq/broker/region/ main/java/org/apache/activemq/broker/region/cursors/ main/java/org/apache/activemq/store/kahadb/plist/ ...
Date Wed, 20 Jan 2010 13:27:06 GMT
Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/PerfConsumer.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/PerfConsumer.java?rev=901188&r1=901187&r2=901188&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/PerfConsumer.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/PerfConsumer.java
Wed Jan 20 13:27:05 2010
@@ -25,7 +25,6 @@
 import javax.jms.MessageListener;
 import javax.jms.Session;
 import javax.jms.Topic;
-
 import org.apache.activemq.ActiveMQMessageAudit;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -42,6 +41,7 @@
     protected boolean enableAudit = false;
     protected ActiveMQMessageAudit audit = new ActiveMQMessageAudit(16 * 1024,20);
     protected boolean firstMessage =true;
+    protected String lastMsgId;
 
     protected PerfRate rate = new PerfRate();
 
@@ -91,11 +91,12 @@
         rate.increment();
         try {
             if (enableAudit && !this.audit.isInOrder(msg.getJMSMessageID())) {
-                LOG.error("Message out of order!!" + msg);
+                LOG.error("Message out of order!!" + msg.getJMSMessageID() + " LAST = " +
lastMsgId);
             }
             if (enableAudit && this.audit.isDuplicate(msg)){
                 LOG.error("Duplicate Message!" + msg);
             }
+            lastMsgId=msg.getJMSMessageID();
         } catch (JMSException e1) {
             // TODO Auto-generated catch block
             e1.printStackTrace();

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/SimpleNonPersistentQueueTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/SimpleNonPersistentQueueTest.java?rev=901188&r1=901187&r2=901188&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/SimpleNonPersistentQueueTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/SimpleNonPersistentQueueTest.java
Wed Jan 20 13:27:05 2010
@@ -31,27 +31,35 @@
  */
 public class SimpleNonPersistentQueueTest extends SimpleQueueTest {
 
+    @Override
     protected void setUp() throws Exception {
         numberOfConsumers = 1;
         numberofProducers = 1;
         super.setUp();
     }
+    @Override
     protected PerfProducer createProducer(ConnectionFactory fac, Destination dest, int number,
byte[] payload) throws JMSException {
         PerfProducer pp = new PerfProducer(fac, dest, payload);
         pp.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-        pp.setTimeToLive(100);
+        //pp.setTimeToLive(100);
         return pp;
     }
     
+    @Override
     protected PerfConsumer createConsumer(ConnectionFactory fac, Destination dest, int number)
throws JMSException {
         PerfConsumer result =  new PerfConsumer(fac, dest);
-        result.setInitialDelay(20*1000);
+        result.setInitialDelay(10*1000);
+        boolean enableAudit = numberOfConsumers <= 1;
+        System.err.println("Enable Audit = " + enableAudit);
+        result.setEnableAudit(enableAudit);
+
         return result;
     }
     
-    /*
+    
+    @Override
     protected void configureBroker(BrokerService answer,String uri) throws Exception {
-        answer.setPersistent(false);
+       // answer.setPersistent(false);
         final List<PolicyEntry> policyEntries = new ArrayList<PolicyEntry>();
         final PolicyEntry entry = new PolicyEntry();
         entry.setQueue(">");
@@ -66,5 +74,5 @@
         answer.setDestinationPolicy(policyMap);
         super.configureBroker(answer, uri);
     }
-    */
+    
 }

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/SimpleQueueTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/SimpleQueueTest.java?rev=901188&r1=901187&r2=901188&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/SimpleQueueTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/SimpleQueueTest.java
Wed Jan 20 13:27:05 2010
@@ -26,21 +26,24 @@
  */
 public class SimpleQueueTest extends SimpleTopicTest {
 
+    @Override
     protected Destination createDestination(Session s, String destinationName) throws JMSException
{
         return s.createQueue(destinationName);
     }
     
+    @Override
     protected void setUp() throws Exception {
         numberOfConsumers = 1;
         super.setUp();
     }
     
+    @Override
     protected PerfConsumer createConsumer(ConnectionFactory fac, Destination dest, int number)
throws JMSException {
         PerfConsumer consumer =  new PerfConsumer(fac, dest);
-        //consumer.setInitialDelay(2000);
+        consumer.setInitialDelay(10000);
         //consumer.setSleepDuration(10);
         boolean enableAudit = numberOfConsumers <= 1;
-        System.out.println("Enable Audit = " + enableAudit);
+        System.err.println("Enable Audit = " + enableAudit);
         consumer.setEnableAudit(enableAudit);
         return consumer;
     }

Added: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/store/kahadb/plist/PListTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/store/kahadb/plist/PListTest.java?rev=901188&view=auto
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/store/kahadb/plist/PListTest.java
(added)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/store/kahadb/plist/PListTest.java
Wed Jan 20 13:27:05 2010
@@ -0,0 +1,150 @@
+/**
+ * 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.activemq.store.kahadb.plist;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+import java.io.File;
+import java.io.IOException;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import org.apache.activemq.util.IOHelper;
+import org.apache.kahadb.util.ByteSequence;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class PListTest {
+
+    private PListStore store;
+    private PList plist;
+    
+
+    @Test
+    public void testIterator() throws Exception {
+        final int COUNT = 10;
+        Map<String, ByteSequence> map = new LinkedHashMap<String, ByteSequence>();
+        for (int i = 0; i < COUNT; i++) {
+            String test = new String("test" + i);
+            ByteSequence bs = new ByteSequence(test.getBytes());
+            map.put(test, bs);
+            plist.addLast(test, bs);
+        }
+        assertEquals(plist.size(), COUNT);
+        int number = 0;
+        PListEntry entry = plist.getFirst();
+        while (entry != null) {
+            entry = plist.getNext(entry);
+            number++;
+            if (entry != null) {
+            plist.remove(entry.copy());
+            }
+        }
+        assertEquals(COUNT, number);
+    }
+
+    @Test
+    public void testAddLast() throws Exception {
+        final int COUNT = 100;
+        Map<String, ByteSequence> map = new LinkedHashMap<String, ByteSequence>();
+        for (int i = 0; i < COUNT; i++) {
+            String test = new String("test" + i);
+            ByteSequence bs = new ByteSequence(test.getBytes());
+            map.put(test, bs);
+            plist.addLast(test, bs);
+        }
+        assertEquals(plist.size(), COUNT);
+        int count = 0;
+        for (ByteSequence bs : map.values()) {
+            String origStr = new String(bs.getData(), bs.getOffset(), bs.getLength());
+            PListEntry entry = plist.get(count);
+            String plistString = new String(entry.getByteSequence().getData(), entry.getByteSequence().getOffset(),
+                    entry.getByteSequence().getLength());
+            assertEquals(origStr, plistString);
+            count++;
+        }
+    }
+
+   @Test
+    public void testAddFirst() throws Exception {
+        final int COUNT = 100;
+        Map<String, ByteSequence> map = new LinkedHashMap<String, ByteSequence>();
+        for (int i = 0; i < COUNT; i++) {
+            String test = new String("test" + i);
+            ByteSequence bs = new ByteSequence(test.getBytes());
+            map.put(test, bs);
+            plist.addFirst(test, bs);
+        }
+        assertEquals(plist.size(), COUNT);
+        int count = plist.size() - 1;
+        for (ByteSequence bs : map.values()) {
+            String origStr = new String(bs.getData(), bs.getOffset(), bs.getLength());
+            PListEntry entry = plist.get(count);
+            String plistString = new String(entry.getByteSequence().getData(), entry.getByteSequence().getOffset(),
+                    entry.getByteSequence().getLength());
+            assertEquals(origStr, plistString);
+            count--;
+        }
+    }
+
+    @Test
+    public void testRemove() throws IOException {
+        final int COUNT = 200;
+        Map<String, ByteSequence> map = new LinkedHashMap<String, ByteSequence>();
+        for (int i = 0; i < COUNT; i++) {
+            String test = new String("test" + i);
+            ByteSequence bs = new ByteSequence(test.getBytes());
+            map.put(test, bs);
+            plist.addLast(test, bs);
+        }
+        assertEquals(plist.size(), COUNT);
+        PListEntry entry = plist.getFirst();
+        while (entry != null) {
+            plist.remove(entry.copy());
+            entry = plist.getFirst();
+        }
+        assertEquals(0,plist.size());
+
+    }
+
+    //@Test
+    public void testDestroy() {
+        fail("Not yet implemented");
+    }
+
+    @Before
+    public void setUp() throws Exception {
+        File directory = new File("target/test/PlistDB");
+        IOHelper.mkdirs(directory);
+        IOHelper.deleteChildren(directory);
+        startStore(directory);
+
+    }
+
+    protected void startStore(File directory) throws Exception {
+        store = new PListStore();
+        store.setDirectory(directory);
+        store.start();
+        plist = store.getPList("test");
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        store.stop();
+    }
+
+}

Propchange: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/store/kahadb/plist/PListTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/store/kahadb/plist/PListTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message