From 49a2d9656ecd53c5a83ab911ca47a378e1458310 Mon Sep 17 00:00:00 2001 From: "Hiram R. Chirino" Date: Mon, 20 May 2013 15:02:09 +0000 Subject: [PATCH] Convert some tests to junit 4 style and add test timeouts. git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1484496 13f79535-47bb-0310-9956-ffa450edef68 --- .../leveldb/test/ElectingLevelDBStoreTest.java | 15 ++++++++++----- .../leveldb/test/MasterLevelDBStoreTest.java | 8 ++++++-- .../leveldb/test/ReplicatedLevelDBStoreTest.java | 11 ++++++++--- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/activemq-leveldb-store/src/test/java/org/apache/activemq/leveldb/test/ElectingLevelDBStoreTest.java b/activemq-leveldb-store/src/test/java/org/apache/activemq/leveldb/test/ElectingLevelDBStoreTest.java index 7c9273c2e1..b8293a6795 100644 --- a/activemq-leveldb-store/src/test/java/org/apache/activemq/leveldb/test/ElectingLevelDBStoreTest.java +++ b/activemq-leveldb-store/src/test/java/org/apache/activemq/leveldb/test/ElectingLevelDBStoreTest.java @@ -27,6 +27,9 @@ import org.apache.activemq.store.MessageStore; import org.apache.zookeeper.server.NIOServerCnxnFactory; import org.apache.zookeeper.server.ZooKeeperServer; import org.apache.zookeeper.server.persistence.FileTxnSnapLog; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -36,10 +39,11 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.concurrent.TimeUnit; import static org.apache.activemq.leveldb.test.ReplicationTestSupport.*; +import static org.junit.Assert.*; /** */ -public class ElectingLevelDBStoreTest extends TestCase { +public class ElectingLevelDBStoreTest { protected static final Logger LOG = LoggerFactory.getLogger(ElectingLevelDBStoreTest.class); NIOServerCnxnFactory connector; @@ -49,8 +53,8 @@ public class ElectingLevelDBStoreTest extends TestCase { } - @Override - protected void setUp() throws Exception { + @Before + public void setUp() throws Exception { FileSupport.toRichFile(data_dir()).recursiveDelete(); System.out.println("Starting ZooKeeper"); @@ -63,14 +67,15 @@ public class ElectingLevelDBStoreTest extends TestCase { System.out.println("ZooKeeper Started"); } - @Override - protected void tearDown() throws Exception { + @After + public void tearDown() throws Exception { if( connector!=null ) { connector.shutdown(); connector = null; } } + @Test(timeout = 1000*60*60) public void testElection() throws Exception { ArrayList stores = new ArrayList(); diff --git a/activemq-leveldb-store/src/test/java/org/apache/activemq/leveldb/test/MasterLevelDBStoreTest.java b/activemq-leveldb-store/src/test/java/org/apache/activemq/leveldb/test/MasterLevelDBStoreTest.java index 5557e2565c..d9a9793ba5 100644 --- a/activemq-leveldb-store/src/test/java/org/apache/activemq/leveldb/test/MasterLevelDBStoreTest.java +++ b/activemq-leveldb-store/src/test/java/org/apache/activemq/leveldb/test/MasterLevelDBStoreTest.java @@ -16,8 +16,8 @@ */ package org.apache.activemq.leveldb.test; -import junit.framework.TestCase; import org.apache.activemq.leveldb.replicated.MasterLevelDBStore; +import org.junit.Test; import java.net.BindException; import java.net.InetSocketAddress; @@ -26,11 +26,15 @@ import java.net.URI; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import static org.junit.Assert.*; + + /** * @author Christian Posta */ -public class MasterLevelDBStoreTest extends TestCase { +public class MasterLevelDBStoreTest { + @Test(timeout = 1000*60*60) public void testStoppingStoreStopsTransport() throws Exception { final MasterLevelDBStore store = new MasterLevelDBStore(); store.setReplicas(0); diff --git a/activemq-leveldb-store/src/test/java/org/apache/activemq/leveldb/test/ReplicatedLevelDBStoreTest.java b/activemq-leveldb-store/src/test/java/org/apache/activemq/leveldb/test/ReplicatedLevelDBStoreTest.java index 84ac7ba650..7f1f361d77 100644 --- a/activemq-leveldb-store/src/test/java/org/apache/activemq/leveldb/test/ReplicatedLevelDBStoreTest.java +++ b/activemq-leveldb-store/src/test/java/org/apache/activemq/leveldb/test/ReplicatedLevelDBStoreTest.java @@ -16,7 +16,6 @@ */ package org.apache.activemq.leveldb.test; -import junit.framework.TestCase; import org.apache.activemq.command.ActiveMQQueue; import org.apache.activemq.leveldb.CountDownFuture; import org.apache.activemq.leveldb.LevelDBStore; @@ -24,6 +23,7 @@ import org.apache.activemq.leveldb.replicated.MasterLevelDBStore; import org.apache.activemq.leveldb.replicated.SlaveLevelDBStore; import org.apache.activemq.leveldb.util.FileSupport; import org.apache.activemq.store.MessageStore; +import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -31,13 +31,17 @@ import java.io.File; import java.util.ArrayList; import java.util.LinkedList; import java.util.concurrent.TimeUnit; -import static org.apache.activemq.leveldb.test.ReplicationTestSupport.*; + +import static org.apache.activemq.leveldb.test.ReplicationTestSupport.addMessage; +import static org.apache.activemq.leveldb.test.ReplicationTestSupport.getMessages; +import static org.junit.Assert.*; /** */ -public class ReplicatedLevelDBStoreTest extends TestCase { +public class ReplicatedLevelDBStoreTest { protected static final Logger LOG = LoggerFactory.getLogger(ReplicatedLevelDBStoreTest.class); + @Test(timeout = 1000*60*60) public void testMinReplicaEnforced() throws Exception { File masterDir = new File("target/activemq-data/leveldb-node1"); @@ -99,6 +103,7 @@ public class ReplicatedLevelDBStoreTest extends TestCase { } + @Test(timeout = 1000*60*60) public void testReplication() throws Exception { LinkedList directories = new LinkedList();