JBoss hornetq SVN: r11981 - branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/clientcrash.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2012-01-05 13:24:11 -0500 (Thu, 05 Jan 2012)
New Revision: 11981
Modified:
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/clientcrash/ClientTestBase.java
Log:
test fix (no code changes)
Modified: branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/clientcrash/ClientTestBase.java
===================================================================
--- branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/clientcrash/ClientTestBase.java 2012-01-05 17:48:44 UTC (rev 11980)
+++ branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/clientcrash/ClientTestBase.java 2012-01-05 18:24:11 UTC (rev 11981)
@@ -68,11 +68,21 @@
protected void assertActiveConnections(final int expectedActiveConnections) throws Exception
{
+ long timeout = System.currentTimeMillis() + 5000;
+ while (timeout > System.currentTimeMillis() && server.getHornetQServerControl().getConnectionCount() != expectedActiveConnections)
+ {
+ Thread.sleep(100);
+ }
Assert.assertEquals(expectedActiveConnections, server.getHornetQServerControl().getConnectionCount());
}
protected void assertActiveSession(final int expectedActiveSession) throws Exception
{
+ long timeout = System.currentTimeMillis() + 5000;
+ while (timeout > System.currentTimeMillis() && server.getSessions().size() != expectedActiveSession)
+ {
+ Thread.sleep(100);
+ }
Assert.assertEquals(expectedActiveSession, server.getSessions().size());
}
12 years, 11 months
JBoss hornetq SVN: r11980 - branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/unit/util.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2012-01-05 12:48:44 -0500 (Thu, 05 Jan 2012)
New Revision: 11980
Modified:
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/unit/util/LinkedListTest.java
Log:
JBPAPP-7856 - fix on test
Modified: branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/unit/util/LinkedListTest.java
===================================================================
--- branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/unit/util/LinkedListTest.java 2012-01-05 17:42:06 UTC (rev 11979)
+++ branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/unit/util/LinkedListTest.java 2012-01-05 17:48:44 UTC (rev 11980)
@@ -115,7 +115,7 @@
*/
private void assertCount(final int expected, final AtomicInteger count)
{
- long timeout = System.currentTimeMillis() + 5000;
+ long timeout = System.currentTimeMillis() + 15000;
int seqCount = 0;
while (timeout > System.currentTimeMillis() && count.get() != expected)
12 years, 11 months
JBoss hornetq SVN: r11979 - branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/unit/util.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2012-01-05 12:42:06 -0500 (Thu, 05 Jan 2012)
New Revision: 11979
Modified:
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/unit/util/LinkedListTest.java
Log:
JBPAPP-7856 - fix on test
Modified: branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/unit/util/LinkedListTest.java
===================================================================
--- branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/unit/util/LinkedListTest.java 2012-01-05 16:28:35 UTC (rev 11978)
+++ branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/unit/util/LinkedListTest.java 2012-01-05 17:42:06 UTC (rev 11979)
@@ -13,6 +13,8 @@
package org.hornetq.tests.unit.util;
+import java.lang.ref.WeakReference;
+import java.util.LinkedList;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.concurrent.atomic.AtomicInteger;
@@ -90,28 +92,12 @@
if (i % 1000 == 0)
{
System.out.println("Checking on " + i);
-
- for (int gcLoop = 0 ; gcLoop < 5; gcLoop++)
- {
- forceGC();
- if (count.get() == 1000)
- {
- break;
- }
- else
- {
- System.out.println("Trying a GC again");
- }
- }
-
- assertEquals(1000, count.get());
+ assertCount(1000, count);
}
}
- forceGC();
+ assertCount(1000, count);
- assertEquals(1000, count.get());
-
int removed = 0;
while (iter.hasNext())
{
@@ -119,11 +105,44 @@
iter.next();
iter.remove();
}
+
+ assertCount(0, count);
- forceGC();
+ }
- assertEquals(0, count.get());
+ /**
+ * @param count
+ */
+ private void assertCount(final int expected, final AtomicInteger count)
+ {
+ long timeout = System.currentTimeMillis() + 5000;
+
+ int seqCount = 0;
+ while (timeout > System.currentTimeMillis() && count.get() != expected)
+ {
+ seqCount ++;
+ if (seqCount > 5)
+ {
+ LinkedList<String> toOME = new LinkedList<String>();
+ int someCount = 0;
+ try
+ {
+ WeakReference<Object> ref = new WeakReference<Object>(new Object());
+ while (ref.get() != null)
+ {
+ toOME.add("sdlfkjshadlfkjhas dlfkjhas dlfkjhads lkjfhads lfkjhads flkjashdf " + someCount++);
+ }
+ }
+ catch (Throwable expectedThrowable)
+ {
+ }
+
+ toOME.clear();
+ }
+ forceGC();
+ }
+ assertEquals(expected, count.get());
}
public void testAddTail()
12 years, 11 months
JBoss hornetq SVN: r11978 - branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/client.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2012-01-05 11:28:35 -0500 (Thu, 05 Jan 2012)
New Revision: 11978
Modified:
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/client/ConsumerWindowSizeTest.java
Log:
small fix on test - no code changes besides the test
Modified: branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/client/ConsumerWindowSizeTest.java
===================================================================
--- branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/client/ConsumerWindowSizeTest.java 2012-01-05 14:07:02 UTC (rev 11977)
+++ branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/client/ConsumerWindowSizeTest.java 2012-01-05 16:28:35 UTC (rev 11978)
@@ -303,7 +303,7 @@
consumers.add(consumer);
session1.start();
sessions.add(session1);
- consumer.receive(10);
+ assertNull(consumer.receive(10));
}
@@ -321,7 +321,7 @@
senderSession.start();
ClientConsumer consumer = consumers.get(2);
- ClientMessage received = consumer.receiveImmediate();
+ ClientMessage received = consumer.receive(5000);
assertNotNull(received);
for (ClientSession tmpSess : sessions)
12 years, 11 months
JBoss hornetq SVN: r11977 - trunk/hornetq-core/src/main/java/org/hornetq/core/replication.
by do-not-reply@jboss.org
Author: borges
Date: 2012-01-05 09:07:02 -0500 (Thu, 05 Jan 2012)
New Revision: 11977
Modified:
trunk/hornetq-core/src/main/java/org/hornetq/core/replication/ReplicationEndpoint.java
Log:
Fix coding error: if executed cast would always fail.
Modified: trunk/hornetq-core/src/main/java/org/hornetq/core/replication/ReplicationEndpoint.java
===================================================================
--- trunk/hornetq-core/src/main/java/org/hornetq/core/replication/ReplicationEndpoint.java 2012-01-05 14:06:46 UTC (rev 11976)
+++ trunk/hornetq-core/src/main/java/org/hornetq/core/replication/ReplicationEndpoint.java 2012-01-05 14:07:02 UTC (rev 11977)
@@ -226,7 +226,9 @@
catch (Exception e)
{
ReplicationEndpoint.log.warn(e.getMessage(), e);
- response = new HornetQExceptionMessage((HornetQException)e);
+ response =
+ new HornetQExceptionMessage(new HornetQException(HornetQException.INTERNAL_ERROR,
+ "unhandled error during replication", e));
}
channel.send(response);
12 years, 11 months
JBoss hornetq SVN: r11976 - trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/client.
by do-not-reply@jboss.org
Author: borges
Date: 2012-01-05 09:06:46 -0500 (Thu, 05 Jan 2012)
New Revision: 11976
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/client/MessageTest.java
Log:
Close connection (fixes test)
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/client/MessageTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/client/MessageTest.java 2012-01-05 14:06:17 UTC (rev 11975)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/client/MessageTest.java 2012-01-05 14:06:46 UTC (rev 11976)
@@ -57,14 +57,17 @@
// Public --------------------------------------------------------
- //https://jira.jboss.org/jira/browse/HORNETQ-242
+ /**
+ * @see https://jira.jboss.org/jira/browse/HORNETQ-242
+ */
public void testStreamMessageReadsNull() throws Exception
{
Connection conn = cf.createConnection();
-
+ try
+ {
Queue queue = createQueue("testQueue");
- Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer prod = sess.createProducer(queue);
@@ -196,6 +199,11 @@
{
//Ok
}
+ }
+ finally
+ {
+ conn.close();
+ }
}
public void testNullProperties() throws Exception
12 years, 11 months
JBoss hornetq SVN: r11975 - in trunk: hornetq-core/src/main/java/org/hornetq/core/settings/impl and 5 other directories.
by do-not-reply@jboss.org
Author: borges
Date: 2012-01-05 09:06:17 -0500 (Thu, 05 Jan 2012)
New Revision: 11975
Modified:
trunk/hornetq-core/src/main/java/org/hornetq/core/server/impl/RoutingContextImpl.java
trunk/hornetq-core/src/main/java/org/hornetq/core/settings/impl/Match.java
trunk/hornetq-core/src/main/java/org/hornetq/utils/json/JSONObject.java
trunk/hornetq-jms/src/main/java/org/hornetq/jms/client/HornetQConnectionFactory.java
trunk/hornetq-journal/src/main/java/org/hornetq/core/journal/impl/AbstractSequentialFile.java
trunk/hornetq-journal/src/main/java/org/hornetq/core/journal/impl/JournalImpl.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailBackManualTest.java
trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/asyncio/MultiThreadAsynchronousFileTest.java
Log:
Fix more findbugs warnings.
Modified: trunk/hornetq-core/src/main/java/org/hornetq/core/server/impl/RoutingContextImpl.java
===================================================================
--- trunk/hornetq-core/src/main/java/org/hornetq/core/server/impl/RoutingContextImpl.java 2012-01-05 14:05:22 UTC (rev 11974)
+++ trunk/hornetq-core/src/main/java/org/hornetq/core/server/impl/RoutingContextImpl.java 2012-01-05 14:06:17 UTC (rev 11975)
@@ -33,7 +33,7 @@
*/
public class RoutingContextImpl implements RoutingContext
{
-
+
// The pair here is Durable and NonDurable
private final Map<SimpleString, RouteContextList> map = new HashMap<SimpleString, RouteContextList>();
@@ -45,13 +45,13 @@
{
this.transaction = transaction;
}
-
+
public void clear()
{
transaction = null;
map.clear();
-
+
queueCount = 0;
}
@@ -59,7 +59,7 @@
{
RouteContextList listing = getContextListing(address);
-
+
if (queue.isDurable())
{
listing.getDurableQueues().add(queue);
@@ -71,7 +71,7 @@
queueCount++;
}
-
+
public RouteContextList getContextListing(SimpleString address)
{
RouteContextList listing = map.get(address);
@@ -115,35 +115,31 @@
{
return this.map;
}
-
-
- private class ContextListing implements RouteContextList
+
+
+ private static class ContextListing implements RouteContextList
{
private final List<Queue> durableQueue = new ArrayList<Queue>(1);
-
+
private final List<Queue> nonDurableQueue = new ArrayList<Queue>(1);
-
+
public int getNumberOfDurableQueues()
{
return durableQueue.size();
}
-
+
public int getNumberOfNonDurableQueues()
{
return nonDurableQueue.size();
}
- /* (non-Javadoc)
- * @see org.hornetq.core.server.RouteContextList#getDurableQueues()
- */
+ @Override
public List<Queue> getDurableQueues()
{
return durableQueue;
}
- /* (non-Javadoc)
- * @see org.hornetq.core.server.RouteContextList#getNonDurableQueues()
- */
+ @Override
public List<Queue> getNonDurableQueues()
{
return nonDurableQueue;
Modified: trunk/hornetq-core/src/main/java/org/hornetq/core/settings/impl/Match.java
===================================================================
--- trunk/hornetq-core/src/main/java/org/hornetq/core/settings/impl/Match.java 2012-01-05 14:05:22 UTC (rev 11974)
+++ trunk/hornetq-core/src/main/java/org/hornetq/core/settings/impl/Match.java 2012-01-05 14:06:17 UTC (rev 11975)
@@ -20,13 +20,13 @@
*/
public class Match<T>
{
- public static String WORD_WILDCARD = "*";
+ public static final String WORD_WILDCARD = "*";
- private static String WORD_WILDCARD_REPLACEMENT = "[^.]+";
+ private static final String WORD_WILDCARD_REPLACEMENT = "[^.]+";
- public static String WILDCARD = "#";
+ public static final String WILDCARD = "#";
- private static String WILDCARD_REPLACEMENT = ".+";
+ private static final String WILDCARD_REPLACEMENT = ".+";
private static final String DOT = ".";
Modified: trunk/hornetq-core/src/main/java/org/hornetq/utils/json/JSONObject.java
===================================================================
--- trunk/hornetq-core/src/main/java/org/hornetq/utils/json/JSONObject.java 2012-01-05 14:05:22 UTC (rev 11974)
+++ trunk/hornetq-core/src/main/java/org/hornetq/utils/json/JSONObject.java 2012-01-05 14:06:17 UTC (rev 11975)
@@ -1090,7 +1090,7 @@
*/
public JSONObject put(final String key, final int value) throws JSONException
{
- put(key, new Integer(value));
+ put(key, Integer.valueOf(value));
return this;
}
@@ -1104,7 +1104,7 @@
*/
public JSONObject put(final String key, final long value) throws JSONException
{
- put(key, new Long(value));
+ put(key, Long.valueOf(value));
return this;
}
@@ -1328,7 +1328,7 @@
{
try
{
- return new Integer(Integer.parseInt(s.substring(2), 16));
+ return Integer.valueOf(Integer.parseInt(s.substring(2), 16));
}
catch (Exception e)
{
@@ -1339,7 +1339,7 @@
{
try
{
- return new Integer(Integer.parseInt(s, 8));
+ return Integer.valueOf(Integer.parseInt(s, 8));
}
catch (Exception e)
{
@@ -1355,10 +1355,10 @@
}
else
{
- Long myLong = new Long(s);
+ Long myLong = Long.valueOf(s);
if (myLong.longValue() == myLong.intValue())
{
- return new Integer(myLong.intValue());
+ return Integer.valueOf(myLong.intValue());
}
else
{
@@ -1440,7 +1440,7 @@
try
{
Iterator keys = keys();
- StringBuffer sb = new StringBuffer("{");
+ StringBuilder sb = new StringBuilder("{");
while (keys.hasNext())
{
Modified: trunk/hornetq-jms/src/main/java/org/hornetq/jms/client/HornetQConnectionFactory.java
===================================================================
--- trunk/hornetq-jms/src/main/java/org/hornetq/jms/client/HornetQConnectionFactory.java 2012-01-05 14:05:22 UTC (rev 11974)
+++ trunk/hornetq-jms/src/main/java/org/hornetq/jms/client/HornetQConnectionFactory.java 2012-01-05 14:06:17 UTC (rev 11975)
@@ -704,7 +704,7 @@
}
@Override
- public void finalize() throws Throwable
+ protected void finalize() throws Throwable
{
try
{
Modified: trunk/hornetq-journal/src/main/java/org/hornetq/core/journal/impl/AbstractSequentialFile.java
===================================================================
--- trunk/hornetq-journal/src/main/java/org/hornetq/core/journal/impl/AbstractSequentialFile.java 2012-01-05 14:05:22 UTC (rev 11974)
+++ trunk/hornetq-journal/src/main/java/org/hornetq/core/journal/impl/AbstractSequentialFile.java 2012-01-05 14:06:17 UTC (rev 11975)
@@ -23,6 +23,7 @@
import org.hornetq.api.core.HornetQBuffer;
import org.hornetq.api.core.HornetQBuffers;
+import org.hornetq.api.core.HornetQException;
import org.hornetq.core.journal.EncodingSupport;
import org.hornetq.core.journal.IOAsyncTask;
import org.hornetq.core.journal.SequentialFile;
@@ -145,7 +146,11 @@
if (!file.equals(newFile))
{
- file.renameTo(newFile);
+ if (!file.renameTo(newFile))
+ {
+ throw new HornetQException(HornetQException.IO_ERROR, "failed to rename file " + file.getName() + " to " +
+ newFileName);
+ }
file = newFile;
}
}
Modified: trunk/hornetq-journal/src/main/java/org/hornetq/core/journal/impl/JournalImpl.java
===================================================================
--- trunk/hornetq-journal/src/main/java/org/hornetq/core/journal/impl/JournalImpl.java 2012-01-05 14:05:22 UTC (rev 11974)
+++ trunk/hornetq-journal/src/main/java/org/hornetq/core/journal/impl/JournalImpl.java 2012-01-05 14:06:17 UTC (rev 11975)
@@ -1178,10 +1178,10 @@
journalLock.readLock().lock();
- JournalTransaction tx = transactions.remove(txID);
-
try
{
+ JournalTransaction tx = transactions.remove(txID);
+
if (tx == null)
{
throw new IllegalStateException("Cannot find tx with id " + txID);
@@ -2963,7 +2963,7 @@
}
}
- private class PerfBlast extends Thread
+ private final class PerfBlast extends Thread
{
private final int pages;
@@ -2977,9 +2977,9 @@
@Override
public void run()
{
+ lockAppend.lock();
try
{
- lockAppend.lock();
final ByteArrayEncoding byteEncoder = new ByteArrayEncoding(new byte[128 * 1024]);
@@ -3002,13 +3002,15 @@
{
appendRecord(blastRecord, false, false, null, null);
}
-
- lockAppend.unlock();
}
catch (Exception e)
{
JournalImpl.log.error("Failed to perf blast", e);
}
+ finally
+ {
+ lockAppend.unlock();
+ }
}
}
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailBackManualTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailBackManualTest.java 2012-01-05 14:05:22 UTC (rev 11974)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailBackManualTest.java 2012-01-05 14:06:17 UTC (rev 11975)
@@ -229,7 +229,7 @@
message.getBodyBuffer().writeString("message" + i);
}
- class ServerStarter implements Runnable
+ static class ServerStarter implements Runnable
{
private final TestableServer server;
Modified: trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/asyncio/MultiThreadAsynchronousFileTest.java
===================================================================
--- trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/asyncio/MultiThreadAsynchronousFileTest.java 2012-01-05 14:05:22 UTC (rev 11974)
+++ trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/asyncio/MultiThreadAsynchronousFileTest.java 2012-01-05 14:06:17 UTC (rev 11975)
@@ -31,13 +31,13 @@
import org.hornetq.utils.HornetQThreadFactory;
/**
- *
+ *
* you need to define -Djava.library.path=${project-root}/native/src/.libs when calling the JVM
* If you are running this test in eclipse you should do:
* I - Run->Open Run Dialog
- * II - Find the class on the list (you will find it if you already tried running this testcase before)
+ * II - Find the class on the list (you will find it if you already tried running this testcase before)
* III - Add -Djava.library.path=<your project place>/native/src/.libs
- *
+ *
* @author <a href="mailto:clebert.suconic@jboss.com">Clebert Suconic</a>.
* */
public class MultiThreadAsynchronousFileTest extends AIOTestBase
@@ -193,7 +193,7 @@
try
{
- // I'm aways reusing the same buffer, as I don't want any noise from
+ // I'm always reusing the same buffer, as I don't want any noise from
// malloc on the measurement
// Encoding buffer
MultiThreadAsynchronousFileTest.addString("Thread name=" + Thread.currentThread().getName() + ";" + "\n",
@@ -207,8 +207,6 @@
latchStart.countDown();
latchStart.await();
- long startTime = System.currentTimeMillis();
-
CountDownLatch latchFinishThread = null;
if (!sync)
12 years, 11 months
JBoss hornetq SVN: r11974 - in trunk: hornetq-core/src/test/java/org/hornetq/core and 8 other directories.
by do-not-reply@jboss.org
Author: borges
Date: 2012-01-05 09:05:22 -0500 (Thu, 05 Jan 2012)
New Revision: 11974
Added:
trunk/hornetq-core/src/test/java/org/hornetq/core/list/
trunk/hornetq-core/src/test/java/org/hornetq/core/list/PriorityLinkedListTest.java
trunk/hornetq-core/src/test/java/org/hornetq/core/security/
trunk/hornetq-core/src/test/java/org/hornetq/core/security/RoleTest.java
Removed:
trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/asyncio/LibaioDependencyCheckTest.java
trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/list/impl/PriorityLinkedListTest.java
trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/list/impl/PriorityLinkedListTestBase.java
trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/security/RoleTest.java
trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/version/impl/VersionImplTest.java
Modified:
trunk/hornetq-core/src/main/java/org/hornetq/utils/PriorityLinkedListImpl.java
trunk/hornetq-core/src/test/java/org/hornetq/core/version/impl/VersionImplTest.java
trunk/hornetq-journal/pom.xml
Log:
Move some tests into hornetq-core project
Modified: trunk/hornetq-core/src/main/java/org/hornetq/utils/PriorityLinkedListImpl.java
===================================================================
--- trunk/hornetq-core/src/main/java/org/hornetq/utils/PriorityLinkedListImpl.java 2012-01-05 14:00:21 UTC (rev 11973)
+++ trunk/hornetq-core/src/main/java/org/hornetq/utils/PriorityLinkedListImpl.java 2012-01-05 14:05:22 UTC (rev 11974)
@@ -16,8 +16,6 @@
import java.lang.reflect.Array;
import java.util.NoSuchElementException;
-import org.hornetq.core.logging.Logger;
-
/**
* A priority linked list implementation
*
@@ -31,8 +29,6 @@
*/
public class PriorityLinkedListImpl<T> implements PriorityLinkedList<T>
{
- private static final Logger log = Logger.getLogger(PriorityLinkedListImpl.class);
-
protected LinkedListImpl<T>[] levels;
private int size;
Copied: trunk/hornetq-core/src/test/java/org/hornetq/core/list/PriorityLinkedListTest.java (from rev 11969, trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/list/impl/PriorityLinkedListTestBase.java)
===================================================================
--- trunk/hornetq-core/src/test/java/org/hornetq/core/list/PriorityLinkedListTest.java (rev 0)
+++ trunk/hornetq-core/src/test/java/org/hornetq/core/list/PriorityLinkedListTest.java 2012-01-05 14:05:22 UTC (rev 11974)
@@ -0,0 +1,900 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat 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.hornetq.core.list;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.hornetq.utils.LinkedListIterator;
+import org.hornetq.utils.PriorityLinkedListImpl;
+
+/**
+ * @author <a href="tim.fox(a)jboss.com>Tim Fox</a>
+ */
+public final class PriorityLinkedListTest extends TestCase
+{
+ protected Wibble a;
+
+ protected Wibble b;
+
+ protected Wibble c;
+
+ protected Wibble d;
+
+ protected Wibble e;
+
+ protected Wibble f;
+
+ protected Wibble g;
+
+ protected Wibble h;
+
+ protected Wibble i;
+
+ protected Wibble j;
+
+ protected Wibble k;
+
+ protected Wibble l;
+
+ protected Wibble m;
+
+ protected Wibble n;
+
+ protected Wibble o;
+
+ protected Wibble p;
+
+ protected Wibble q;
+
+ protected Wibble r;
+
+ protected Wibble s;
+
+ protected Wibble t;
+
+ protected Wibble u;
+
+ protected Wibble v;
+
+ protected Wibble w;
+
+ protected Wibble x;
+
+ protected Wibble y;
+
+ protected Wibble z;
+
+ private PriorityLinkedListImpl<Wibble> list;
+
+ protected PriorityLinkedListImpl<Wibble> getList()
+ {
+ return new PriorityLinkedListImpl<Wibble>(10);
+ }
+
+ @Override
+ public void setUp() throws Exception
+ {
+ super.setUp();
+
+ list = getList();
+
+ a = new Wibble("a");
+ b = new Wibble("b");
+ c = new Wibble("c");
+ d = new Wibble("d");
+ e = new Wibble("e");
+ f = new Wibble("f");
+ g = new Wibble("g");
+ h = new Wibble("h");
+ i = new Wibble("i");
+ j = new Wibble("j");
+ k = new Wibble("k");
+ l = new Wibble("l");
+ m = new Wibble("m");
+ n = new Wibble("n");
+ o = new Wibble("o");
+ p = new Wibble("p");
+ q = new Wibble("q");
+ r = new Wibble("r");
+ s = new Wibble("s");
+ t = new Wibble("t");
+ u = new Wibble("u");
+ v = new Wibble("v");
+ w = new Wibble("w");
+ x = new Wibble("x");
+ y = new Wibble("y");
+ z = new Wibble("z");
+ }
+
+ @Override
+ public void tearDown() throws Exception
+ {
+ list = null;
+ super.tearDown();
+ }
+
+ public void testEmpty() throws Exception
+ {
+ Assert.assertTrue(list.isEmpty());
+
+ list.addHead(a, 0);
+
+ Assert.assertFalse(list.isEmpty());
+
+ Wibble w = list.poll();
+ Assert.assertEquals(a, w);
+ Assert.assertTrue(list.isEmpty());
+
+ assertEquals(0, list.size());
+ }
+
+ public void testaddHead() throws Exception
+ {
+ list.addHead(a, 0);
+ list.addHead(b, 0);
+ list.addHead(c, 0);
+ list.addHead(d, 0);
+ list.addHead(e, 0);
+
+ assertEquals(5, list.size());
+
+ Assert.assertEquals(e, list.poll());
+ Assert.assertEquals(d, list.poll());
+ Assert.assertEquals(c, list.poll());
+ Assert.assertEquals(b, list.poll());
+ Assert.assertEquals(a, list.poll());
+ Assert.assertNull(list.poll());
+
+ assertEquals(0, list.size());
+ }
+
+ public void testaddTail() throws Exception
+ {
+ list.addTail(a, 0);
+ list.addTail(b, 0);
+ list.addTail(c, 0);
+ list.addTail(d, 0);
+ list.addTail(e, 0);
+ assertEquals(5, list.size());
+
+ Assert.assertEquals(a, list.poll());
+ Assert.assertEquals(b, list.poll());
+ Assert.assertEquals(c, list.poll());
+ Assert.assertEquals(d, list.poll());
+ Assert.assertEquals(e, list.poll());
+ Assert.assertNull(list.poll());
+
+ assertEquals(0, list.size());
+
+ }
+
+ public void testAddLastAndFirst() throws Exception
+ {
+ list.addTail(a, 0);
+ list.addTail(b, 0);
+ list.addTail(c, 0);
+ list.addTail(d, 0);
+ list.addTail(e, 0);
+ list.addTail(f, 0);
+ list.addTail(g, 0);
+ list.addTail(h, 0);
+ list.addTail(i, 0);
+ list.addTail(j, 0);
+
+ list.addHead(k, 0);
+ list.addHead(l, 0);
+ list.addHead(m, 0);
+ list.addHead(n, 0);
+ list.addHead(o, 0);
+ list.addHead(p, 0);
+ list.addHead(q, 0);
+ list.addHead(r, 0);
+ list.addHead(s, 0);
+ list.addHead(t, 0);
+
+ assertEquals(t, list.poll());
+ assertEquals(s, list.poll());
+ assertEquals(r, list.poll());
+ assertEquals(q, list.poll());
+ assertEquals(p, list.poll());
+ assertEquals(o, list.poll());
+ assertEquals(n, list.poll());
+ assertEquals(m, list.poll());
+ assertEquals(l, list.poll());
+ assertEquals(k, list.poll());
+
+ assertEquals(a, list.poll());
+ assertEquals(b, list.poll());
+ assertEquals(c, list.poll());
+ assertEquals(d, list.poll());
+ assertEquals(e, list.poll());
+ assertEquals(f, list.poll());
+ assertEquals(g, list.poll());
+ assertEquals(h, list.poll());
+ assertEquals(i, list.poll());
+ assertEquals(j, list.poll());
+ }
+
+ public void testAddLastAndFirstWithIterator() throws Exception
+ {
+ list.addTail(a, 0);
+ list.addTail(b, 0);
+ list.addTail(c, 0);
+ list.addTail(d, 0);
+ list.addTail(e, 0);
+ list.addTail(f, 0);
+ list.addTail(g, 0);
+ list.addTail(h, 0);
+ list.addTail(i, 0);
+ list.addTail(j, 0);
+
+ list.addHead(k, 0);
+ list.addHead(l, 0);
+ list.addHead(m, 0);
+ list.addHead(n, 0);
+ list.addHead(o, 0);
+ list.addHead(p, 0);
+ list.addHead(q, 0);
+ list.addHead(r, 0);
+ list.addHead(s, 0);
+ list.addHead(t, 0);
+
+ LinkedListIterator<Wibble> iter = list.iterator();
+
+ assertTrue(iter.hasNext());
+ assertEquals(t, iter.next());
+ assertTrue(iter.hasNext());
+ assertEquals(s, iter.next());
+ assertTrue(iter.hasNext());
+ assertEquals(r, iter.next());
+ assertTrue(iter.hasNext());
+ assertEquals(q, iter.next());
+ assertTrue(iter.hasNext());
+ assertEquals(p, iter.next());
+ assertTrue(iter.hasNext());
+ assertEquals(o, iter.next());
+ assertTrue(iter.hasNext());
+ assertEquals(n, iter.next());
+ assertTrue(iter.hasNext());
+ assertEquals(m, iter.next());
+ assertTrue(iter.hasNext());
+ assertEquals(l, iter.next());
+ assertTrue(iter.hasNext());
+ assertEquals(k, iter.next());
+
+ assertTrue(iter.hasNext());
+ assertEquals(a, iter.next());
+ assertTrue(iter.hasNext());
+ assertEquals(b, iter.next());
+ assertTrue(iter.hasNext());
+ assertEquals(c, iter.next());
+ assertTrue(iter.hasNext());
+ assertEquals(d, iter.next());
+ assertTrue(iter.hasNext());
+ assertEquals(e, iter.next());
+ assertTrue(iter.hasNext());
+ assertEquals(f, iter.next());
+ assertTrue(iter.hasNext());
+ assertEquals(g, iter.next());
+ assertTrue(iter.hasNext());
+ assertEquals(h, iter.next());
+ assertTrue(iter.hasNext());
+ assertEquals(i, iter.next());
+ assertTrue(iter.hasNext());
+ assertEquals(j, iter.next());
+ }
+
+ public void testPoll() throws Exception
+ {
+ list.addTail(a, 0);
+ list.addTail(b, 1);
+ list.addTail(c, 2);
+ list.addTail(d, 3);
+ list.addTail(e, 4);
+ list.addTail(f, 5);
+ list.addTail(g, 6);
+ list.addTail(h, 7);
+ list.addTail(i, 8);
+ list.addTail(j, 9);
+
+ Assert.assertEquals(j, list.poll());
+ Assert.assertEquals(i, list.poll());
+ Assert.assertEquals(h, list.poll());
+ Assert.assertEquals(g, list.poll());
+ Assert.assertEquals(f, list.poll());
+ Assert.assertEquals(e, list.poll());
+ Assert.assertEquals(d, list.poll());
+ Assert.assertEquals(c, list.poll());
+ Assert.assertEquals(b, list.poll());
+ Assert.assertEquals(a, list.poll());
+
+ Assert.assertNull(list.poll());
+
+ list.addTail(a, 9);
+ list.addTail(b, 8);
+ list.addTail(c, 7);
+ list.addTail(d, 6);
+ list.addTail(e, 5);
+ list.addTail(f, 4);
+ list.addTail(g, 3);
+ list.addTail(h, 2);
+ list.addTail(i, 1);
+ list.addTail(j, 0);
+
+ Assert.assertEquals(a, list.poll());
+ Assert.assertEquals(b, list.poll());
+ Assert.assertEquals(c, list.poll());
+ Assert.assertEquals(d, list.poll());
+ Assert.assertEquals(e, list.poll());
+ Assert.assertEquals(f, list.poll());
+ Assert.assertEquals(g, list.poll());
+ Assert.assertEquals(h, list.poll());
+ Assert.assertEquals(i, list.poll());
+ Assert.assertEquals(j, list.poll());
+
+ Assert.assertNull(list.poll());
+
+ list.addTail(a, 9);
+ list.addTail(b, 0);
+ list.addTail(c, 8);
+ list.addTail(d, 1);
+ list.addTail(e, 7);
+ list.addTail(f, 2);
+ list.addTail(g, 6);
+ list.addTail(h, 3);
+ list.addTail(i, 5);
+ list.addTail(j, 4);
+
+ Assert.assertEquals(a, list.poll());
+ Assert.assertEquals(c, list.poll());
+ Assert.assertEquals(e, list.poll());
+ Assert.assertEquals(g, list.poll());
+ Assert.assertEquals(i, list.poll());
+ Assert.assertEquals(j, list.poll());
+ Assert.assertEquals(h, list.poll());
+ Assert.assertEquals(f, list.poll());
+ Assert.assertEquals(d, list.poll());
+ Assert.assertEquals(b, list.poll());
+
+ Assert.assertNull(list.poll());
+
+ list.addTail(a, 0);
+ list.addTail(b, 3);
+ list.addTail(c, 3);
+ list.addTail(d, 3);
+ list.addTail(e, 6);
+ list.addTail(f, 6);
+ list.addTail(g, 6);
+ list.addTail(h, 9);
+ list.addTail(i, 9);
+ list.addTail(j, 9);
+
+ Assert.assertEquals(h, list.poll());
+ Assert.assertEquals(i, list.poll());
+ Assert.assertEquals(j, list.poll());
+ Assert.assertEquals(e, list.poll());
+ Assert.assertEquals(f, list.poll());
+ Assert.assertEquals(g, list.poll());
+ Assert.assertEquals(b, list.poll());
+ Assert.assertEquals(c, list.poll());
+ Assert.assertEquals(d, list.poll());
+ Assert.assertEquals(a, list.poll());
+
+ Assert.assertNull(list.poll());
+
+ list.addTail(a, 5);
+ list.addTail(b, 5);
+ list.addTail(c, 5);
+ list.addTail(d, 5);
+ list.addTail(e, 5);
+ list.addTail(f, 5);
+ list.addTail(g, 5);
+ list.addTail(h, 5);
+ list.addTail(i, 5);
+ list.addTail(j, 5);
+
+ Assert.assertEquals(a, list.poll());
+ Assert.assertEquals(b, list.poll());
+ Assert.assertEquals(c, list.poll());
+ Assert.assertEquals(d, list.poll());
+ Assert.assertEquals(e, list.poll());
+ Assert.assertEquals(f, list.poll());
+ Assert.assertEquals(g, list.poll());
+ Assert.assertEquals(h, list.poll());
+ Assert.assertEquals(i, list.poll());
+ Assert.assertEquals(j, list.poll());
+
+ Assert.assertNull(list.poll());
+
+ list.addTail(j, 5);
+ list.addTail(i, 5);
+ list.addTail(h, 5);
+ list.addTail(g, 5);
+ list.addTail(f, 5);
+ list.addTail(e, 5);
+ list.addTail(d, 5);
+ list.addTail(c, 5);
+ list.addTail(b, 5);
+ list.addTail(a, 5);
+
+ Assert.assertEquals(j, list.poll());
+ Assert.assertEquals(i, list.poll());
+ Assert.assertEquals(h, list.poll());
+ Assert.assertEquals(g, list.poll());
+ Assert.assertEquals(f, list.poll());
+ Assert.assertEquals(e, list.poll());
+ Assert.assertEquals(d, list.poll());
+ Assert.assertEquals(c, list.poll());
+ Assert.assertEquals(b, list.poll());
+ Assert.assertEquals(a, list.poll());
+
+ Assert.assertNull(list.poll());
+
+ assertEquals(0, list.size());
+
+ }
+
+ public void testIterator()
+ {
+ list.addTail(a, 9);
+ list.addTail(b, 9);
+ list.addTail(c, 8);
+ list.addTail(d, 8);
+ list.addTail(e, 7);
+ list.addTail(f, 7);
+ list.addTail(g, 7);
+ list.addTail(h, 6);
+ list.addTail(i, 6);
+ list.addTail(j, 6);
+ list.addTail(k, 5);
+ list.addTail(l, 5);
+ list.addTail(m, 4);
+ list.addTail(n, 4);
+ list.addTail(o, 4);
+ list.addTail(p, 3);
+ list.addTail(q, 3);
+ list.addTail(r, 3);
+ list.addTail(s, 2);
+ list.addTail(t, 2);
+ list.addTail(u, 2);
+ list.addTail(v, 1);
+ list.addTail(w, 1);
+ list.addTail(x, 1);
+ list.addTail(y, 0);
+ list.addTail(z, 0);
+
+ LinkedListIterator<Wibble> iter = list.iterator();
+
+ int count = 0;
+ Wibble w;
+ while (iter.hasNext())
+ {
+ w = iter.next();
+ count++;
+ }
+ Assert.assertEquals(26, count);
+ Assert.assertEquals(26, list.size());
+
+ iter = list.iterator();
+
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ assertTrue(iter.hasNext());
+ Assert.assertEquals("a", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ assertTrue(iter.hasNext());
+ Assert.assertEquals("b", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("c", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("d", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("e", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("f", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("g", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("h", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("i", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("j", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("k", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("l", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("m", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("n", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("o", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("p", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("q", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("r", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("s", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("t", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("u", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("v", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("w", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("x", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("y", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("z", w.s);
+ assertFalse(iter.hasNext());
+
+ iter = list.iterator();
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("a", w.s);
+
+ iter.remove();
+
+ Assert.assertEquals(25, list.size());
+
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("b", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("c", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("d", w.s);
+
+ iter.remove();
+
+ Assert.assertEquals(24, list.size());
+
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("c", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("e", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("f", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("g", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("h", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("i", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("j", w.s);
+
+ iter.remove();
+
+ Assert.assertEquals(23, list.size());
+
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("i", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("k", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("l", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("m", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("n", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("o", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("p", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("q", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("r", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("s", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("t", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("u", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("v", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("w", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("x", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("y", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("z", w.s);
+ iter.remove();
+
+ iter = list.iterator();
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("b", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("c", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("e", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("f", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("g", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("h", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("i", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("k", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("l", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("m", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("n", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("o", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("p", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("q", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("r", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("s", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("t", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("u", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("v", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("w", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("x", w.s);
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("y", w.s);
+
+ assertFalse(iter.hasNext());
+ assertFalse(iter.hasNext());
+
+ // Test the elements added after iter created are seen
+
+ list.addTail(a, 4);
+ list.addTail(b, 4);
+
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("a", w.s);
+
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("b", w.s);
+
+ assertFalse(iter.hasNext());
+
+ list.addTail(c, 4);
+ list.addTail(d, 4);
+
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("c", w.s);
+
+ assertTrue(iter.hasNext());
+ w = iter.next();
+ Assert.assertEquals("d", w.s);
+
+ assertFalse(iter.hasNext());
+
+ }
+
+ public void testIteratorPicksUpHigherPriorities()
+ {
+ list.addTail(a, 4);
+ list.addTail(b, 4);
+ list.addTail(c, 4);
+
+ LinkedListIterator<Wibble> iter = list.iterator();
+
+ assertTrue(iter.hasNext());
+ assertEquals(a, iter.next());
+
+ assertTrue(iter.hasNext());
+ assertEquals(b, iter.next());
+
+ list.addTail(d, 5);
+ list.addTail(e, 5);
+
+ assertTrue(iter.hasNext());
+ assertEquals(d, iter.next());
+
+ assertTrue(iter.hasNext());
+ assertEquals(e, iter.next());
+
+ assertTrue(iter.hasNext());
+ assertEquals(c, iter.next());
+
+ list.addTail(f, 1);
+ list.addTail(g, 9);
+
+ assertTrue(iter.hasNext());
+ assertEquals(g, iter.next());
+
+ assertTrue(iter.hasNext());
+ assertEquals(f, iter.next());
+ }
+
+ public void testClear()
+ {
+ list.addTail(a, 0);
+ list.addTail(b, 3);
+ list.addTail(c, 3);
+ list.addTail(d, 3);
+ list.addTail(e, 6);
+ list.addTail(f, 6);
+ list.addTail(g, 6);
+ list.addTail(h, 9);
+ list.addTail(i, 9);
+ list.addTail(j, 9);
+
+ list.clear();
+
+ Assert.assertNull(list.poll());
+ }
+
+ public void testMixupIterator()
+ {
+ list.addTail(c, 5);
+ list.addTail(a, 4);
+ list.addTail(b, 4);
+
+ LinkedListIterator<Wibble> iter = list.iterator();
+
+ assertTrue(iter.hasNext());
+ assertEquals(c, iter.next());
+ assertTrue(iter.hasNext());
+ assertEquals(a, iter.next());
+ assertTrue(iter.hasNext());
+ assertEquals(b, iter.next());
+ list.addTail(d, 5);
+ assertTrue(iter.hasNext());
+ assertEquals(d, iter.next());
+ }
+
+ public void testMixupIterator2()
+ {
+ list.addTail(c, 5);
+
+ list.addTail(k, 0);
+
+ list.addTail(a, 2);
+ list.addTail(b, 2);
+
+ LinkedListIterator<Wibble> iter = list.iterator();
+
+ assertTrue(iter.hasNext());
+ assertEquals(c, iter.next());
+ iter.remove();
+
+ assertTrue(iter.hasNext());
+ assertEquals(a, iter.next());
+ iter.remove();
+
+ assertTrue(iter.hasNext());
+ assertEquals(b, iter.next());
+ iter.remove();
+
+ assertTrue(iter.hasNext());
+ assertEquals(k, iter.next());
+ iter.remove();
+
+ list.addTail(d, 2);
+
+ assertTrue(iter.hasNext());
+ assertEquals(d, iter.next());
+ iter.remove();
+ }
+
+ class Wibble
+ {
+ String s;
+
+ Wibble(final String s)
+ {
+ this.s = s;
+ }
+
+ @Override
+ public String toString()
+ {
+ return s;
+ }
+ }
+
+}
Copied: trunk/hornetq-core/src/test/java/org/hornetq/core/security/RoleTest.java (from rev 11969, trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/security/RoleTest.java)
===================================================================
--- trunk/hornetq-core/src/test/java/org/hornetq/core/security/RoleTest.java (rev 0)
+++ trunk/hornetq-core/src/test/java/org/hornetq/core/security/RoleTest.java 2012-01-05 14:05:22 UTC (rev 11974)
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat 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.hornetq.core.security;
+
+import static org.hornetq.core.security.CheckType.CONSUME;
+import static org.hornetq.core.security.CheckType.CREATE_DURABLE_QUEUE;
+import static org.hornetq.core.security.CheckType.CREATE_NON_DURABLE_QUEUE;
+import static org.hornetq.core.security.CheckType.DELETE_DURABLE_QUEUE;
+import static org.hornetq.core.security.CheckType.DELETE_NON_DURABLE_QUEUE;
+import static org.hornetq.core.security.CheckType.SEND;
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.hornetq.core.security.Role;
+
+/**
+ * @author <a href="mailto:jmesnil@redhat.com">Jeff Mesnil</a>
+ */
+public class RoleTest extends TestCase
+{
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ public void testReadRole() throws Exception
+ {
+ Role role = new Role("testReadRole", true, false, false, false, false, false, false);
+ Assert.assertTrue(SEND.hasRole(role));
+ Assert.assertFalse(CONSUME.hasRole(role));
+ Assert.assertFalse(CREATE_DURABLE_QUEUE.hasRole(role));
+ Assert.assertFalse(CREATE_NON_DURABLE_QUEUE.hasRole(role));
+ Assert.assertFalse(DELETE_DURABLE_QUEUE.hasRole(role));
+ Assert.assertFalse(DELETE_NON_DURABLE_QUEUE.hasRole(role));
+ }
+
+ public void testWriteRole() throws Exception
+ {
+ Role role = new Role("testWriteRole", false, true, false, false, false, false, false);
+ Assert.assertFalse(SEND.hasRole(role));
+ Assert.assertTrue(CONSUME.hasRole(role));
+ Assert.assertFalse(CREATE_DURABLE_QUEUE.hasRole(role));
+ Assert.assertFalse(CREATE_NON_DURABLE_QUEUE.hasRole(role));
+ Assert.assertFalse(DELETE_DURABLE_QUEUE.hasRole(role));
+ Assert.assertFalse(DELETE_NON_DURABLE_QUEUE.hasRole(role));
+ }
+
+ public void testCreateRole() throws Exception
+ {
+ Role role = new Role("testWriteRole", false, false, true, false, false, false, false);
+ Assert.assertFalse(SEND.hasRole(role));
+ Assert.assertFalse(CONSUME.hasRole(role));
+ Assert.assertTrue(CREATE_DURABLE_QUEUE.hasRole(role));
+ Assert.assertFalse(CREATE_NON_DURABLE_QUEUE.hasRole(role));
+ Assert.assertFalse(DELETE_DURABLE_QUEUE.hasRole(role));
+ Assert.assertFalse(DELETE_NON_DURABLE_QUEUE.hasRole(role));
+ }
+
+ public void testEqualsAndHashcode() throws Exception
+ {
+ Role role = new Role("testEquals", true, true, true, false, false, false, false);
+ Role sameRole = new Role("testEquals", true, true, true, false, false, false, false);
+ Role roleWithDifferentName = new Role("notEquals", true, true, true, false, false, false, false);
+ Role roleWithDifferentRead = new Role("testEquals", false, true, true, false, false, false, false);
+ Role roleWithDifferentWrite = new Role("testEquals", true, false, true, false, false, false, false);
+ Role roleWithDifferentCreate = new Role("testEquals", true, true, false, false, false, false, false);
+
+ Assert.assertTrue(role.equals(role));
+
+ Assert.assertTrue(role.equals(sameRole));
+ Assert.assertTrue(role.hashCode() == sameRole.hashCode());
+
+ Assert.assertFalse(role.equals(roleWithDifferentName));
+ Assert.assertFalse(role.hashCode() == roleWithDifferentName.hashCode());
+
+ Assert.assertFalse(role.equals(roleWithDifferentRead));
+ Assert.assertFalse(role.hashCode() == roleWithDifferentRead.hashCode());
+
+ Assert.assertFalse(role.equals(roleWithDifferentWrite));
+ Assert.assertFalse(role.hashCode() == roleWithDifferentWrite.hashCode());
+
+ Assert.assertFalse(role.equals(roleWithDifferentCreate));
+ Assert.assertFalse(role.hashCode() == roleWithDifferentCreate.hashCode());
+
+ Assert.assertFalse(role.equals(null));
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
Modified: trunk/hornetq-core/src/test/java/org/hornetq/core/version/impl/VersionImplTest.java
===================================================================
--- trunk/hornetq-core/src/test/java/org/hornetq/core/version/impl/VersionImplTest.java 2012-01-05 14:00:21 UTC (rev 11973)
+++ trunk/hornetq-core/src/test/java/org/hornetq/core/version/impl/VersionImplTest.java 2012-01-05 14:05:22 UTC (rev 11974)
@@ -19,17 +19,15 @@
import java.io.ObjectOutputStream;
import junit.framework.Assert;
+import junit.framework.TestCase;
-import org.hornetq.core.version.impl.VersionImpl;
-import org.hornetq.tests.util.UnitTestCase;
-
/**
* @author <a href="mailto:jmesnil@redhat.com">Jeff Mesnil</a>
*
* @version <tt>$Revision$</tt>
*
*/
-public class VersionImplTest extends UnitTestCase
+public class VersionImplTest extends TestCase
{
// Constants -----------------------------------------------------
Modified: trunk/hornetq-journal/pom.xml
===================================================================
--- trunk/hornetq-journal/pom.xml 2012-01-05 14:00:21 UTC (rev 11973)
+++ trunk/hornetq-journal/pom.xml 2012-01-05 14:05:22 UTC (rev 11974)
@@ -26,8 +26,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <!-- There are newer versions of the JUnit but thet break our tests -->
- <version>3.8.2</version>
+ <scope>test</scope>
</dependency>
</dependencies>
Deleted: trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/asyncio/LibaioDependencyCheckTest.java
===================================================================
--- trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/asyncio/LibaioDependencyCheckTest.java 2012-01-05 14:00:21 UTC (rev 11973)
+++ trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/asyncio/LibaioDependencyCheckTest.java 2012-01-05 14:05:22 UTC (rev 11974)
@@ -1,55 +0,0 @@
-/*
- * Copyright 2010 Red Hat, Inc.
- * Red Hat 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.hornetq.tests.unit.core.asyncio;
-
-import org.hornetq.core.asyncio.impl.AsynchronousFileImpl;
-import org.hornetq.tests.util.UnitTestCase;
-
-/**
- * A LibaioDependencyCheckTest
- *
- * @author <mailto:clebert.suconic@jboss.org">Clebert Suconic</a>
- *
- *
- */
-public class LibaioDependencyCheckTest extends UnitTestCase
-{
-
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- public void testDependency() throws Exception
- {
- if (System.getProperties().get("os.name").equals("Linux"))
- {
- assertTrue("Libaio is not available on this platform", AsynchronousFileImpl.isLoaded());
- }
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
-}
Deleted: trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/list/impl/PriorityLinkedListTest.java
===================================================================
--- trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/list/impl/PriorityLinkedListTest.java 2012-01-05 14:00:21 UTC (rev 11973)
+++ trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/list/impl/PriorityLinkedListTest.java 2012-01-05 14:05:22 UTC (rev 11974)
@@ -1,34 +0,0 @@
-/*
- * Copyright 2010 Red Hat, Inc.
- * Red Hat 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.hornetq.tests.unit.core.list.impl;
-
-import org.hornetq.utils.PriorityLinkedListImpl;
-
-/**
- * A PriorityLinkedListTest
- *
- * @author Tim Fox
- *
- *
- */
-public class PriorityLinkedListTest extends PriorityLinkedListTestBase
-{
-
- @Override
- protected PriorityLinkedListImpl<Wibble> getList()
- {
- return new PriorityLinkedListImpl<Wibble>(10);
- }
-
-}
Deleted: trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/list/impl/PriorityLinkedListTestBase.java
===================================================================
--- trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/list/impl/PriorityLinkedListTestBase.java 2012-01-05 14:00:21 UTC (rev 11973)
+++ trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/list/impl/PriorityLinkedListTestBase.java 2012-01-05 14:05:22 UTC (rev 11974)
@@ -1,897 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat 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.hornetq.tests.unit.core.list.impl;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import org.hornetq.tests.util.RandomUtil;
-import org.hornetq.utils.LinkedListIterator;
-import org.hornetq.utils.PriorityLinkedListImpl;
-
-/**
- * @author <a href="tim.fox(a)jboss.com>Tim Fox</a>
- *
- * $Id$
- */
-public abstract class PriorityLinkedListTestBase extends TestCase
-{
- protected Wibble a;
-
- protected Wibble b;
-
- protected Wibble c;
-
- protected Wibble d;
-
- protected Wibble e;
-
- protected Wibble f;
-
- protected Wibble g;
-
- protected Wibble h;
-
- protected Wibble i;
-
- protected Wibble j;
-
- protected Wibble k;
-
- protected Wibble l;
-
- protected Wibble m;
-
- protected Wibble n;
-
- protected Wibble o;
-
- protected Wibble p;
-
- protected Wibble q;
-
- protected Wibble r;
-
- protected Wibble s;
-
- protected Wibble t;
-
- protected Wibble u;
-
- protected Wibble v;
-
- protected Wibble w;
-
- protected Wibble x;
-
- protected Wibble y;
-
- protected Wibble z;
-
- private PriorityLinkedListImpl<Wibble> list;
-
- protected abstract PriorityLinkedListImpl<Wibble> getList();
-
- public void setUp() throws Exception
- {
- super.setUp();
-
- list = getList();
-
- a = new Wibble("a");
- b = new Wibble("b");
- c = new Wibble("c");
- d = new Wibble("d");
- e = new Wibble("e");
- f = new Wibble("f");
- g = new Wibble("g");
- h = new Wibble("h");
- i = new Wibble("i");
- j = new Wibble("j");
- k = new Wibble("k");
- l = new Wibble("l");
- m = new Wibble("m");
- n = new Wibble("n");
- o = new Wibble("o");
- p = new Wibble("p");
- q = new Wibble("q");
- r = new Wibble("r");
- s = new Wibble("s");
- t = new Wibble("t");
- u = new Wibble("u");
- v = new Wibble("v");
- w = new Wibble("w");
- x = new Wibble("x");
- y = new Wibble("y");
- z = new Wibble("z");
- }
-
- public void tearDown() throws Exception
- {
- list = null;
- super.tearDown();
- }
-
- public void testEmpty() throws Exception
- {
- Assert.assertTrue(list.isEmpty());
-
- list.addHead(a, 0);
-
- Assert.assertFalse(list.isEmpty());
-
- Wibble w = list.poll();
- Assert.assertEquals(a, w);
- Assert.assertTrue(list.isEmpty());
-
- assertEquals(0, list.size());
- }
-
- public void testaddHead() throws Exception
- {
- list.addHead(a, 0);
- list.addHead(b, 0);
- list.addHead(c, 0);
- list.addHead(d, 0);
- list.addHead(e, 0);
-
- assertEquals(5, list.size());
-
- Assert.assertEquals(e, list.poll());
- Assert.assertEquals(d, list.poll());
- Assert.assertEquals(c, list.poll());
- Assert.assertEquals(b, list.poll());
- Assert.assertEquals(a, list.poll());
- Assert.assertNull(list.poll());
-
- assertEquals(0, list.size());
- }
-
- public void testaddTail() throws Exception
- {
- list.addTail(a, 0);
- list.addTail(b, 0);
- list.addTail(c, 0);
- list.addTail(d, 0);
- list.addTail(e, 0);
- assertEquals(5, list.size());
-
- Assert.assertEquals(a, list.poll());
- Assert.assertEquals(b, list.poll());
- Assert.assertEquals(c, list.poll());
- Assert.assertEquals(d, list.poll());
- Assert.assertEquals(e, list.poll());
- Assert.assertNull(list.poll());
-
- assertEquals(0, list.size());
-
- }
-
- public void testAddLastAndFirst() throws Exception
- {
- list.addTail(a, 0);
- list.addTail(b, 0);
- list.addTail(c, 0);
- list.addTail(d, 0);
- list.addTail(e, 0);
- list.addTail(f, 0);
- list.addTail(g, 0);
- list.addTail(h, 0);
- list.addTail(i, 0);
- list.addTail(j, 0);
-
- list.addHead(k, 0);
- list.addHead(l, 0);
- list.addHead(m, 0);
- list.addHead(n, 0);
- list.addHead(o, 0);
- list.addHead(p, 0);
- list.addHead(q, 0);
- list.addHead(r, 0);
- list.addHead(s, 0);
- list.addHead(t, 0);
-
- assertEquals(t, list.poll());
- assertEquals(s, list.poll());
- assertEquals(r, list.poll());
- assertEquals(q, list.poll());
- assertEquals(p, list.poll());
- assertEquals(o, list.poll());
- assertEquals(n, list.poll());
- assertEquals(m, list.poll());
- assertEquals(l, list.poll());
- assertEquals(k, list.poll());
-
- assertEquals(a, list.poll());
- assertEquals(b, list.poll());
- assertEquals(c, list.poll());
- assertEquals(d, list.poll());
- assertEquals(e, list.poll());
- assertEquals(f, list.poll());
- assertEquals(g, list.poll());
- assertEquals(h, list.poll());
- assertEquals(i, list.poll());
- assertEquals(j, list.poll());
- }
-
- public void testAddLastAndFirstWithIterator() throws Exception
- {
- list.addTail(a, 0);
- list.addTail(b, 0);
- list.addTail(c, 0);
- list.addTail(d, 0);
- list.addTail(e, 0);
- list.addTail(f, 0);
- list.addTail(g, 0);
- list.addTail(h, 0);
- list.addTail(i, 0);
- list.addTail(j, 0);
-
- list.addHead(k, 0);
- list.addHead(l, 0);
- list.addHead(m, 0);
- list.addHead(n, 0);
- list.addHead(o, 0);
- list.addHead(p, 0);
- list.addHead(q, 0);
- list.addHead(r, 0);
- list.addHead(s, 0);
- list.addHead(t, 0);
-
- LinkedListIterator<Wibble> iter = list.iterator();
-
- assertTrue(iter.hasNext());
- assertEquals(t, iter.next());
- assertTrue(iter.hasNext());
- assertEquals(s, iter.next());
- assertTrue(iter.hasNext());
- assertEquals(r, iter.next());
- assertTrue(iter.hasNext());
- assertEquals(q, iter.next());
- assertTrue(iter.hasNext());
- assertEquals(p, iter.next());
- assertTrue(iter.hasNext());
- assertEquals(o, iter.next());
- assertTrue(iter.hasNext());
- assertEquals(n, iter.next());
- assertTrue(iter.hasNext());
- assertEquals(m, iter.next());
- assertTrue(iter.hasNext());
- assertEquals(l, iter.next());
- assertTrue(iter.hasNext());
- assertEquals(k, iter.next());
-
- assertTrue(iter.hasNext());
- assertEquals(a, iter.next());
- assertTrue(iter.hasNext());
- assertEquals(b, iter.next());
- assertTrue(iter.hasNext());
- assertEquals(c, iter.next());
- assertTrue(iter.hasNext());
- assertEquals(d, iter.next());
- assertTrue(iter.hasNext());
- assertEquals(e, iter.next());
- assertTrue(iter.hasNext());
- assertEquals(f, iter.next());
- assertTrue(iter.hasNext());
- assertEquals(g, iter.next());
- assertTrue(iter.hasNext());
- assertEquals(h, iter.next());
- assertTrue(iter.hasNext());
- assertEquals(i, iter.next());
- assertTrue(iter.hasNext());
- assertEquals(j, iter.next());
- }
-
- public void testPoll() throws Exception
- {
- list.addTail(a, 0);
- list.addTail(b, 1);
- list.addTail(c, 2);
- list.addTail(d, 3);
- list.addTail(e, 4);
- list.addTail(f, 5);
- list.addTail(g, 6);
- list.addTail(h, 7);
- list.addTail(i, 8);
- list.addTail(j, 9);
-
- Assert.assertEquals(j, list.poll());
- Assert.assertEquals(i, list.poll());
- Assert.assertEquals(h, list.poll());
- Assert.assertEquals(g, list.poll());
- Assert.assertEquals(f, list.poll());
- Assert.assertEquals(e, list.poll());
- Assert.assertEquals(d, list.poll());
- Assert.assertEquals(c, list.poll());
- Assert.assertEquals(b, list.poll());
- Assert.assertEquals(a, list.poll());
-
- Assert.assertNull(list.poll());
-
- list.addTail(a, 9);
- list.addTail(b, 8);
- list.addTail(c, 7);
- list.addTail(d, 6);
- list.addTail(e, 5);
- list.addTail(f, 4);
- list.addTail(g, 3);
- list.addTail(h, 2);
- list.addTail(i, 1);
- list.addTail(j, 0);
-
- Assert.assertEquals(a, list.poll());
- Assert.assertEquals(b, list.poll());
- Assert.assertEquals(c, list.poll());
- Assert.assertEquals(d, list.poll());
- Assert.assertEquals(e, list.poll());
- Assert.assertEquals(f, list.poll());
- Assert.assertEquals(g, list.poll());
- Assert.assertEquals(h, list.poll());
- Assert.assertEquals(i, list.poll());
- Assert.assertEquals(j, list.poll());
-
- Assert.assertNull(list.poll());
-
- list.addTail(a, 9);
- list.addTail(b, 0);
- list.addTail(c, 8);
- list.addTail(d, 1);
- list.addTail(e, 7);
- list.addTail(f, 2);
- list.addTail(g, 6);
- list.addTail(h, 3);
- list.addTail(i, 5);
- list.addTail(j, 4);
-
- Assert.assertEquals(a, list.poll());
- Assert.assertEquals(c, list.poll());
- Assert.assertEquals(e, list.poll());
- Assert.assertEquals(g, list.poll());
- Assert.assertEquals(i, list.poll());
- Assert.assertEquals(j, list.poll());
- Assert.assertEquals(h, list.poll());
- Assert.assertEquals(f, list.poll());
- Assert.assertEquals(d, list.poll());
- Assert.assertEquals(b, list.poll());
-
- Assert.assertNull(list.poll());
-
- list.addTail(a, 0);
- list.addTail(b, 3);
- list.addTail(c, 3);
- list.addTail(d, 3);
- list.addTail(e, 6);
- list.addTail(f, 6);
- list.addTail(g, 6);
- list.addTail(h, 9);
- list.addTail(i, 9);
- list.addTail(j, 9);
-
- Assert.assertEquals(h, list.poll());
- Assert.assertEquals(i, list.poll());
- Assert.assertEquals(j, list.poll());
- Assert.assertEquals(e, list.poll());
- Assert.assertEquals(f, list.poll());
- Assert.assertEquals(g, list.poll());
- Assert.assertEquals(b, list.poll());
- Assert.assertEquals(c, list.poll());
- Assert.assertEquals(d, list.poll());
- Assert.assertEquals(a, list.poll());
-
- Assert.assertNull(list.poll());
-
- list.addTail(a, 5);
- list.addTail(b, 5);
- list.addTail(c, 5);
- list.addTail(d, 5);
- list.addTail(e, 5);
- list.addTail(f, 5);
- list.addTail(g, 5);
- list.addTail(h, 5);
- list.addTail(i, 5);
- list.addTail(j, 5);
-
- Assert.assertEquals(a, list.poll());
- Assert.assertEquals(b, list.poll());
- Assert.assertEquals(c, list.poll());
- Assert.assertEquals(d, list.poll());
- Assert.assertEquals(e, list.poll());
- Assert.assertEquals(f, list.poll());
- Assert.assertEquals(g, list.poll());
- Assert.assertEquals(h, list.poll());
- Assert.assertEquals(i, list.poll());
- Assert.assertEquals(j, list.poll());
-
- Assert.assertNull(list.poll());
-
- list.addTail(j, 5);
- list.addTail(i, 5);
- list.addTail(h, 5);
- list.addTail(g, 5);
- list.addTail(f, 5);
- list.addTail(e, 5);
- list.addTail(d, 5);
- list.addTail(c, 5);
- list.addTail(b, 5);
- list.addTail(a, 5);
-
- Assert.assertEquals(j, list.poll());
- Assert.assertEquals(i, list.poll());
- Assert.assertEquals(h, list.poll());
- Assert.assertEquals(g, list.poll());
- Assert.assertEquals(f, list.poll());
- Assert.assertEquals(e, list.poll());
- Assert.assertEquals(d, list.poll());
- Assert.assertEquals(c, list.poll());
- Assert.assertEquals(b, list.poll());
- Assert.assertEquals(a, list.poll());
-
- Assert.assertNull(list.poll());
-
- assertEquals(0, list.size());
-
- }
-
- public void testIterator()
- {
- list.addTail(a, 9);
- list.addTail(b, 9);
- list.addTail(c, 8);
- list.addTail(d, 8);
- list.addTail(e, 7);
- list.addTail(f, 7);
- list.addTail(g, 7);
- list.addTail(h, 6);
- list.addTail(i, 6);
- list.addTail(j, 6);
- list.addTail(k, 5);
- list.addTail(l, 5);
- list.addTail(m, 4);
- list.addTail(n, 4);
- list.addTail(o, 4);
- list.addTail(p, 3);
- list.addTail(q, 3);
- list.addTail(r, 3);
- list.addTail(s, 2);
- list.addTail(t, 2);
- list.addTail(u, 2);
- list.addTail(v, 1);
- list.addTail(w, 1);
- list.addTail(x, 1);
- list.addTail(y, 0);
- list.addTail(z, 0);
-
- LinkedListIterator<Wibble> iter = list.iterator();
-
- int count = 0;
- Wibble w;
- while (iter.hasNext())
- {
- w = iter.next();
- count++;
- }
- Assert.assertEquals(26, count);
- Assert.assertEquals(26, list.size());
-
- iter = list.iterator();
-
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- assertTrue(iter.hasNext());
- Assert.assertEquals("a", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- assertTrue(iter.hasNext());
- Assert.assertEquals("b", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("c", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("d", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("e", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("f", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("g", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("h", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("i", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("j", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("k", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("l", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("m", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("n", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("o", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("p", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("q", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("r", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("s", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("t", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("u", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("v", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("w", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("x", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("y", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("z", w.s);
- assertFalse(iter.hasNext());
-
- iter = list.iterator();
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("a", w.s);
-
- iter.remove();
-
- Assert.assertEquals(25, list.size());
-
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("b", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("c", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("d", w.s);
-
- iter.remove();
-
- Assert.assertEquals(24, list.size());
-
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("c", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("e", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("f", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("g", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("h", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("i", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("j", w.s);
-
- iter.remove();
-
- Assert.assertEquals(23, list.size());
-
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("i", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("k", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("l", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("m", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("n", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("o", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("p", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("q", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("r", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("s", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("t", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("u", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("v", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("w", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("x", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("y", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("z", w.s);
- iter.remove();
-
- iter = list.iterator();
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("b", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("c", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("e", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("f", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("g", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("h", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("i", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("k", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("l", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("m", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("n", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("o", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("p", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("q", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("r", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("s", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("t", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("u", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("v", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("w", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("x", w.s);
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("y", w.s);
-
- assertFalse(iter.hasNext());
- assertFalse(iter.hasNext());
-
- // Test the elements added after iter created are seen
-
- list.addTail(a, 4);
- list.addTail(b, 4);
-
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("a", w.s);
-
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("b", w.s);
-
- assertFalse(iter.hasNext());
-
- list.addTail(c, 4);
- list.addTail(d, 4);
-
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("c", w.s);
-
- assertTrue(iter.hasNext());
- w = (Wibble)iter.next();
- Assert.assertEquals("d", w.s);
-
- assertFalse(iter.hasNext());
-
- }
-
- public void testIteratorPicksUpHigherPriorities()
- {
- list.addTail(a, 4);
- list.addTail(b, 4);
- list.addTail(c, 4);
-
- LinkedListIterator<Wibble> iter = list.iterator();
-
- assertTrue(iter.hasNext());
- assertEquals(a, iter.next());
-
- assertTrue(iter.hasNext());
- assertEquals(b, iter.next());
-
- list.addTail(d, 5);
- list.addTail(e, 5);
-
- assertTrue(iter.hasNext());
- assertEquals(d, iter.next());
-
- assertTrue(iter.hasNext());
- assertEquals(e, iter.next());
-
- assertTrue(iter.hasNext());
- assertEquals(c, iter.next());
-
- list.addTail(f, 1);
- list.addTail(g, 9);
-
- assertTrue(iter.hasNext());
- assertEquals(g, iter.next());
-
- assertTrue(iter.hasNext());
- assertEquals(f, iter.next());
- }
-
- public void testClear()
- {
- list.addTail(a, 0);
- list.addTail(b, 3);
- list.addTail(c, 3);
- list.addTail(d, 3);
- list.addTail(e, 6);
- list.addTail(f, 6);
- list.addTail(g, 6);
- list.addTail(h, 9);
- list.addTail(i, 9);
- list.addTail(j, 9);
-
- list.clear();
-
- Assert.assertNull(list.poll());
- }
-
- public void testMixupIterator()
- {
- list.addTail(c, 5);
- list.addTail(a, 4);
- list.addTail(b, 4);
-
- LinkedListIterator<Wibble> iter = list.iterator();
-
- assertTrue(iter.hasNext());
- assertEquals(c, iter.next());
- assertTrue(iter.hasNext());
- assertEquals(a, iter.next());
- assertTrue(iter.hasNext());
- assertEquals(b, iter.next());
- list.addTail(d, 5);
- assertTrue(iter.hasNext());
- assertEquals(d, iter.next());
- }
-
- public void testMixupIterator2()
- {
- list.addTail(c, 5);
-
- list.addTail(k, 0);
-
- list.addTail(a, 2);
- list.addTail(b, 2);
-
- LinkedListIterator<Wibble> iter = list.iterator();
-
- assertTrue(iter.hasNext());
- assertEquals(c, iter.next());
- iter.remove();
-
- assertTrue(iter.hasNext());
- assertEquals(a, iter.next());
- iter.remove();
-
- assertTrue(iter.hasNext());
- assertEquals(b, iter.next());
- iter.remove();
-
- assertTrue(iter.hasNext());
- assertEquals(k, iter.next());
- iter.remove();
-
- list.addTail(d, 2);
-
- assertTrue(iter.hasNext());
- assertEquals(d, iter.next());
- iter.remove();
- }
-
- class Wibble
- {
- String s;
-
- Wibble(final String s)
- {
- this.s = s;
- }
-
- public String toString()
- {
- return s;
- }
- }
-
-}
Deleted: trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/security/RoleTest.java
===================================================================
--- trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/security/RoleTest.java 2012-01-05 14:00:21 UTC (rev 11973)
+++ trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/security/RoleTest.java 2012-01-05 14:05:22 UTC (rev 11974)
@@ -1,114 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat 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.hornetq.tests.unit.core.security;
-
-import static org.hornetq.core.security.CheckType.CONSUME;
-import static org.hornetq.core.security.CheckType.CREATE_DURABLE_QUEUE;
-import static org.hornetq.core.security.CheckType.CREATE_NON_DURABLE_QUEUE;
-import static org.hornetq.core.security.CheckType.DELETE_DURABLE_QUEUE;
-import static org.hornetq.core.security.CheckType.DELETE_NON_DURABLE_QUEUE;
-import static org.hornetq.core.security.CheckType.SEND;
-import junit.framework.Assert;
-
-import org.hornetq.core.security.Role;
-import org.hornetq.tests.util.UnitTestCase;
-
-/**
- * @author <a href="mailto:jmesnil@redhat.com">Jeff Mesnil</a>
- *
- * @version <tt>$Revision$</tt>
- *
- */
-public class RoleTest extends UnitTestCase
-{
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- public void testReadRole() throws Exception
- {
- Role role = new Role("testReadRole", true, false, false, false, false, false, false);
- Assert.assertTrue(SEND.hasRole(role));
- Assert.assertFalse(CONSUME.hasRole(role));
- Assert.assertFalse(CREATE_DURABLE_QUEUE.hasRole(role));
- Assert.assertFalse(CREATE_NON_DURABLE_QUEUE.hasRole(role));
- Assert.assertFalse(DELETE_DURABLE_QUEUE.hasRole(role));
- Assert.assertFalse(DELETE_NON_DURABLE_QUEUE.hasRole(role));
- }
-
- public void testWriteRole() throws Exception
- {
- Role role = new Role("testWriteRole", false, true, false, false, false, false, false);
- Assert.assertFalse(SEND.hasRole(role));
- Assert.assertTrue(CONSUME.hasRole(role));
- Assert.assertFalse(CREATE_DURABLE_QUEUE.hasRole(role));
- Assert.assertFalse(CREATE_NON_DURABLE_QUEUE.hasRole(role));
- Assert.assertFalse(DELETE_DURABLE_QUEUE.hasRole(role));
- Assert.assertFalse(DELETE_NON_DURABLE_QUEUE.hasRole(role));
- }
-
- public void testCreateRole() throws Exception
- {
- Role role = new Role("testWriteRole", false, false, true, false, false, false, false);
- Assert.assertFalse(SEND.hasRole(role));
- Assert.assertFalse(CONSUME.hasRole(role));
- Assert.assertTrue(CREATE_DURABLE_QUEUE.hasRole(role));
- Assert.assertFalse(CREATE_NON_DURABLE_QUEUE.hasRole(role));
- Assert.assertFalse(DELETE_DURABLE_QUEUE.hasRole(role));
- Assert.assertFalse(DELETE_NON_DURABLE_QUEUE.hasRole(role));
- }
-
- public void testEqualsAndHashcode() throws Exception
- {
- Role role = new Role("testEquals", true, true, true, false, false, false, false);
- Role sameRole = new Role("testEquals", true, true, true, false, false, false, false);
- Role roleWithDifferentName = new Role("notEquals", true, true, true, false, false, false, false);
- Role roleWithDifferentRead = new Role("testEquals", false, true, true, false, false, false, false);
- Role roleWithDifferentWrite = new Role("testEquals", true, false, true, false, false, false, false);
- Role roleWithDifferentCreate = new Role("testEquals", true, true, false, false, false, false, false);
-
- Assert.assertTrue(role.equals(role));
-
- Assert.assertTrue(role.equals(sameRole));
- Assert.assertTrue(role.hashCode() == sameRole.hashCode());
-
- Assert.assertFalse(role.equals(roleWithDifferentName));
- Assert.assertFalse(role.hashCode() == roleWithDifferentName.hashCode());
-
- Assert.assertFalse(role.equals(roleWithDifferentRead));
- Assert.assertFalse(role.hashCode() == roleWithDifferentRead.hashCode());
-
- Assert.assertFalse(role.equals(roleWithDifferentWrite));
- Assert.assertFalse(role.hashCode() == roleWithDifferentWrite.hashCode());
-
- Assert.assertFalse(role.equals(roleWithDifferentCreate));
- Assert.assertFalse(role.hashCode() == roleWithDifferentCreate.hashCode());
-
- Assert.assertFalse(role.equals(null));
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-}
Deleted: trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/version/impl/VersionImplTest.java
===================================================================
--- trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/version/impl/VersionImplTest.java 2012-01-05 14:00:21 UTC (rev 11973)
+++ trunk/tests/unit-tests/src/test/java/org/hornetq/tests/unit/core/version/impl/VersionImplTest.java 2012-01-05 14:05:22 UTC (rev 11974)
@@ -1,109 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat 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.hornetq.tests.unit.core.version.impl;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-
-import junit.framework.Assert;
-
-import org.hornetq.core.version.impl.VersionImpl;
-import org.hornetq.tests.util.UnitTestCase;
-
-/**
- * @author <a href="mailto:jmesnil@redhat.com">Jeff Mesnil</a>
- *
- * @version <tt>$Revision$</tt>
- *
- */
-public class VersionImplTest extends UnitTestCase
-{
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- public void testVersionImpl() throws Exception
- {
-
- String versionName = "HORNETQ";
- int majorVersion = 2;
- int minorVersion = 0;
- int microVersion = 1;
- int incrementingVersion = 10;
- String versionSuffix = "suffix";
- String nettyVersion = "netty";
- int[] compatibleVersionList = {7,8,9,10};
- VersionImpl version = new VersionImpl(versionName,
- majorVersion,
- minorVersion,
- microVersion,
- incrementingVersion,
- versionSuffix,
- nettyVersion,
- compatibleVersionList);
-
- Assert.assertEquals(versionName, version.getVersionName());
- Assert.assertEquals(majorVersion, version.getMajorVersion());
- Assert.assertEquals(minorVersion, version.getMinorVersion());
- Assert.assertEquals(microVersion, version.getMicroVersion());
- Assert.assertEquals(incrementingVersion, version.getIncrementingVersion());
- Assert.assertEquals(versionSuffix, version.getVersionSuffix());
- }
-
- public void testEquals() throws Exception
- {
- String nettyVersion = "netty";
- VersionImpl version = new VersionImpl("HORNETQ", 2, 0, 1, 10, "suffix", nettyVersion, new int[]{7,8,9,10});
- VersionImpl sameVersion = new VersionImpl("HORNETQ", 2, 0, 1, 10, "suffix", nettyVersion, new int[]{7,8,9,10});
- VersionImpl differentVersion = new VersionImpl("HORNETQ", 2, 0, 1, 11, "suffix", nettyVersion, new int[]{7,8,9,10,11});
-
- Assert.assertFalse(version.equals(new Object()));
-
- Assert.assertTrue(version.equals(version));
- Assert.assertTrue(version.equals(sameVersion));
- Assert.assertFalse(version.equals(differentVersion));
- }
-
- public void testSerialize() throws Exception
- {
- String nettyVersion = "netty";
- VersionImpl version = new VersionImpl("uyiuy", 3, 7, 6, 12, "uhuhuh", nettyVersion, new int[]{9,10,11,12});
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(baos);
- oos.writeObject(version);
- oos.flush();
-
- ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
- ObjectInputStream ois = new ObjectInputStream(bais);
- VersionImpl version2 = (VersionImpl)ois.readObject();
-
- Assert.assertTrue(version.equals(version2));
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-}
12 years, 11 months
JBoss hornetq SVN: r11973 - in branches/Branch_2_2_EAP/src/main/org/hornetq/core: remoting/server/impl and 1 other directories.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2012-01-05 09:00:21 -0500 (Thu, 05 Jan 2012)
New Revision: 11973
Modified:
branches/Branch_2_2_EAP/src/main/org/hornetq/core/remoting/server/RemotingService.java
branches/Branch_2_2_EAP/src/main/org/hornetq/core/remoting/server/impl/RemotingServiceImpl.java
branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java
Log:
JBPAPP-7205 - Changes on Stopping RemotingService in case of a critical error
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/core/remoting/server/RemotingService.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/core/remoting/server/RemotingService.java 2012-01-05 13:57:59 UTC (rev 11972)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/core/remoting/server/RemotingService.java 2012-01-05 14:00:21 UTC (rev 11973)
@@ -16,7 +16,6 @@
import java.util.Set;
import org.hornetq.api.core.Interceptor;
-import org.hornetq.core.server.HornetQComponent;
import org.hornetq.spi.core.protocol.RemotingConnection;
/**
@@ -25,7 +24,7 @@
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
* @version <tt>$Revision$</tt>
*/
-public interface RemotingService extends HornetQComponent
+public interface RemotingService
{
/**
* Remove a connection from the connections held by the remoting service.
@@ -41,7 +40,13 @@
void addInterceptor(Interceptor interceptor);
boolean removeInterceptor(Interceptor interceptor);
+
+ void stop(boolean criticalError) throws Exception;
+
+ void start() throws Exception;
+ boolean isStarted();
+
void freeze();
RemotingConnection getServerSideReplicatingConnection();
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/core/remoting/server/impl/RemotingServiceImpl.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/core/remoting/server/impl/RemotingServiceImpl.java 2012-01-05 13:57:59 UTC (rev 11972)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/core/remoting/server/impl/RemotingServiceImpl.java 2012-01-05 14:00:21 UTC (rev 11973)
@@ -262,7 +262,7 @@
}
}
- public void stop() throws Exception
+ public void stop(final boolean criticalError) throws Exception
{
if (!started)
{
@@ -274,7 +274,7 @@
return;
}
- failureCheckAndFlushThread.close();
+ failureCheckAndFlushThread.close(criticalError);
// We need to stop them accepting first so no new connections are accepted after we send the disconnect message
for (Acceptor acceptor : acceptors)
@@ -291,9 +291,13 @@
log.debug("Sending disconnect on live connections");
}
+ HashSet<ConnectionEntry> connectionEntries = new HashSet<ConnectionEntry>();
+
+ connectionEntries.addAll(connections.values());
+
// Now we ensure that no connections will process any more packets after this method is complete
// then send a disconnect packet
- for (ConnectionEntry entry : connections.values())
+ for (ConnectionEntry entry : connectionEntries)
{
RemotingConnection conn = entry.connection;
@@ -320,12 +324,15 @@
}
threadPool.shutdown();
-
- boolean ok = threadPool.awaitTermination(10000, TimeUnit.MILLISECONDS);
-
- if (!ok)
+
+ if (!criticalError)
{
- log.warn("Timed out waiting for remoting thread pool to terminate");
+ boolean ok = threadPool.awaitTermination(10000, TimeUnit.MILLISECONDS);
+
+ if (!ok)
+ {
+ log.warn("Timed out waiting for remoting thread pool to terminate");
+ }
}
started = false;
@@ -534,7 +541,7 @@
this.pauseInterval = pauseInterval;
}
- public void close()
+ public void close(final boolean criticalError)
{
closed = true;
@@ -543,13 +550,16 @@
notify();
}
- try
+ if (!criticalError)
{
- join();
+ try
+ {
+ join();
+ }
+ catch (InterruptedException ignore)
+ {
+ }
}
- catch (InterruptedException ignore)
- {
- }
}
@Override
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java 2012-01-05 13:57:59 UTC (rev 11972)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java 2012-01-05 14:00:21 UTC (rev 11973)
@@ -492,7 +492,7 @@
}
- remotingService.stop();
+ remotingService.stop(criticalIOError);
// We close all the exception in an attempt to let any pending IO to finish
// to avoid scenarios where the send or ACK got to disk but the response didn't get to the client
12 years, 11 months
JBoss hornetq SVN: r11972 - branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/client.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2012-01-05 08:57:59 -0500 (Thu, 05 Jan 2012)
New Revision: 11972
Modified:
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/client/PagingTest.java
Log:
Fixing race on test
Modified: branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/client/PagingTest.java
===================================================================
--- branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/client/PagingTest.java 2012-01-05 13:12:52 UTC (rev 11971)
+++ branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/client/PagingTest.java 2012-01-05 13:57:59 UTC (rev 11972)
@@ -4350,26 +4350,7 @@
session.start();
- // ClientConsumer consumer = session.createConsumer(PagingTest.ADDRESS.concat("=1"));
- //
- // for (int i = 0; i < numberOfMessages; i++)
- // {
- // message = consumer.receive(500000);
- // assertNotNull(message);
- // message.acknowledge();
- //
- // // assertEquals(msg, message.getIntProperty("propTest").intValue());
- //
- // System.out.println("i = " + i + " msg = " + message.getIntProperty("propTest"));
- // }
- //
- // session.commit();
-
- // consumer.close();
-
session.deleteQueue(PagingTest.ADDRESS.concat("=1"));
- // server.stop();
- // server.start();
sf = locator.createSessionFactory();
@@ -4385,8 +4366,6 @@
assertNotNull(message);
message.acknowledge();
- // assertEquals(msg, message.getIntProperty("propTest").intValue());
-
System.out.println("i = " + i + " msg = " + message.getIntProperty("propTest"));
}
@@ -4395,8 +4374,17 @@
assertNull(consumer.receiveImmediate());
consumer.close();
+
+ long timeout = System.currentTimeMillis() + 10000;
+
+ PagingStore store = server.getPagingManager().getPageStore(ADDRESS);
// It's async, so need to wait a bit for it happening
+ while (timeout < System.currentTimeMillis() && store.isPaging())
+ {
+ Thread.sleep(100);
+ }
+
assertFalse(server.getPagingManager().getPageStore(ADDRESS).isPaging());
server.stop();
12 years, 11 months