You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2012/11/15 00:31:35 UTC

svn commit: r1409554 [2/2] - in /activemq/trunk: activemq-core/src/test/java/org/apache/activemq/store/kahadb/disk/ activemq-kahadb-store/ activemq-kahadb-store/src/test/ activemq-kahadb-store/src/test/java/ activemq-kahadb-store/src/test/java/org/ act...

Added: activemq/trunk/activemq-kahadb-store/src/test/java/org/apache/activemq/store/kahadb/disk/util/SequenceSetTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-kahadb-store/src/test/java/org/apache/activemq/store/kahadb/disk/util/SequenceSetTest.java?rev=1409554&view=auto
==============================================================================
--- activemq/trunk/activemq-kahadb-store/src/test/java/org/apache/activemq/store/kahadb/disk/util/SequenceSetTest.java (added)
+++ activemq/trunk/activemq-kahadb-store/src/test/java/org/apache/activemq/store/kahadb/disk/util/SequenceSetTest.java Wed Nov 14 23:31:34 2012
@@ -0,0 +1,139 @@
+/**
+ * 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.disk.util;
+
+import static org.junit.Assert.*;
+
+import java.util.Iterator;
+
+import org.junit.Test;
+
+public class SequenceSetTest {
+
+    @Test
+    public void testAddLong() {
+        SequenceSet set = new SequenceSet();
+        set.add(1);
+        assertEquals(1, set.rangeSize());
+        set.add(10);
+        set.add(20);
+        assertEquals(3, set.rangeSize());
+    }
+
+    @Test
+    public void testRangeSize() {
+        SequenceSet set = new SequenceSet();
+        set.add(1);
+        assertEquals(1, set.rangeSize());
+        set.add(10);
+        set.add(20);
+        assertEquals(3, set.rangeSize());
+        set.clear();
+        assertEquals(0, set.rangeSize());
+    }
+
+    @Test
+    public void testIsEmpty() {
+        SequenceSet set = new SequenceSet();
+        assertTrue(set.isEmpty());
+        set.add(1);
+        assertFalse(set.isEmpty());
+    }
+
+    @Test
+    public void testClear() {
+        SequenceSet set = new SequenceSet();
+        set.clear();
+        assertTrue(set.isEmpty());
+        set.add(1);
+        assertFalse(set.isEmpty());
+        set.clear();
+        assertTrue(set.isEmpty());
+    }
+
+    @Test
+    public void testContains() {
+        SequenceSet set = new SequenceSet();
+        set.add(new Sequence(0, 10));
+        set.add(new Sequence(21, 42));
+        set.add(new Sequence(47, 90));
+        set.add(new Sequence(142, 512));
+
+        assertTrue(set.contains(0));
+        assertTrue(set.contains(42));
+        assertTrue(set.contains(49));
+        assertTrue(set.contains(153));
+
+        assertFalse(set.contains(43));
+        assertFalse(set.contains(99));
+        assertFalse(set.contains(-1));
+        assertFalse(set.contains(11));
+    }
+
+    @Test
+    public void testRemove() {
+        SequenceSet set = new SequenceSet();
+        set.add(new Sequence(0, 100));
+        assertEquals(101, set.rangeSize());
+
+        assertEquals(1, set.size());
+        assertFalse(set.remove(101));
+        assertTrue(set.remove(50));
+        assertEquals(2, set.size());
+        assertEquals(100, set.rangeSize());
+        assertFalse(set.remove(101));
+
+        set.remove(0);
+        assertEquals(2, set.size());
+        assertEquals(99, set.rangeSize());
+        set.remove(100);
+        assertEquals(2, set.size());
+        assertEquals(98, set.rangeSize());
+
+        set.remove(10);
+        assertEquals(3, set.size());
+        assertEquals(97, set.rangeSize());
+    }
+
+    @Test
+    public void testIterator() {
+        SequenceSet set = new SequenceSet();
+        set.add(new Sequence(0, 2));
+        set.add(new Sequence(4, 5));
+        set.add(new Sequence(7));
+        set.add(new Sequence(20, 21));
+
+        long expected[] = new long[]{0, 1, 2, 4, 5, 7, 20, 21};
+        int index = 0;
+
+        Iterator<Long> iterator = set.iterator();
+        while(iterator.hasNext()) {
+            assertEquals(expected[index++], iterator.next().longValue());
+        }
+    }
+
+    @Test
+    public void testIteratorEmptySequenceSet() {
+        SequenceSet set = new SequenceSet();
+
+        Iterator<Long> iterator = set.iterator();
+        while(iterator.hasNext()) {
+            fail("Should not have any elements");
+        }
+    }
+}

Propchange: activemq/trunk/activemq-kahadb-store/src/test/java/org/apache/activemq/store/kahadb/disk/util/SequenceSetTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/trunk/activemq-kahadb-store/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-kahadb-store/src/test/resources/log4j.properties?rev=1409554&view=auto
==============================================================================
--- activemq/trunk/activemq-kahadb-store/src/test/resources/log4j.properties (added)
+++ activemq/trunk/activemq-kahadb-store/src/test/resources/log4j.properties Wed Nov 14 23:31:34 2012
@@ -0,0 +1,42 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+#
+# The logging properties used during tests..
+#
+log4j.rootLogger=INFO, out, stdout
+
+#log4j.logger.org.apache.activemq.broker.scheduler=DEBUG
+#log4j.logger.org.apache.activemq.network.DemandForwardingBridgeSupport=DEBUG
+#log4j.logger.org.apache.activemq.transport.failover=TRACE
+#log4j.logger.org.apache.activemq.store.jdbc=TRACE
+#log4j.logger.org.apache.activemq.broker.region.cursors.AbstractStoreCursor=DEBUG
+#log4j.logger.org.apache.activemq.store.jdbc.JDBCMessageStore=DEBUG
+
+# CONSOLE appender not used by default
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] - %-5p %-30.30c{1} - %m%n
+#log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] - %-5p %-30.30c{1} - %-10.10X{activemq.broker} %-20.20X{activemq.connector} %-10.10X{activemq.destination} - %m%n
+
+# File appender
+log4j.appender.out=org.apache.log4j.FileAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] - %-5p %-30.30c{1} - %m%n
+#log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] - %-5p %-30.30c{1} - %-10.10X{activemq.broker} %-20.20X{activemq.connector} %-10.10X{activemq.destination} - %m%n
+log4j.appender.out.file=target/activemq-test.log
+log4j.appender.out.append=true

Propchange: activemq/trunk/activemq-kahadb-store/src/test/resources/log4j.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/trunk/activemq-kahadb-store/src/test/resources/log4j.properties
------------------------------------------------------------------------------
    svn:executable = *