Author: borges
Date: 2011-09-26 06:39:02 -0400 (Mon, 26 Sep 2011)
New Revision: 11423
Modified:
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/PagingTest.java
branches/HORNETQ-720_Replication/tests/stress-tests/src/test/java/org/hornetq/tests/stress/paging/PageCursorStressTest.java
Log:
Avoid noise on std.out
Modified:
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/PagingTest.java
===================================================================
---
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/PagingTest.java 2011-09-26
10:38:04 UTC (rev 11422)
+++
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/client/PagingTest.java 2011-09-26
10:39:02 UTC (rev 11423)
@@ -1549,7 +1549,7 @@
for (int i = 0; i < 50; i++)
{
- System.out.println("Sending " + i);
+ // System.out.println("Sending " + i);
ClientMessage message = sessionNonTX.createMessage(true);
message.getBodyBuffer().writeBytes(body);
message.putIntProperty(new SimpleString("id"), i);
@@ -1559,7 +1559,7 @@
if (i % 2 == 0)
{
- System.out.println("Sending 20 msgs to make it page");
+ // System.out.println("Sending 20 msgs to make it page");
for (int j = 0; j < 20; j++)
{
ClientMessage msgSend = sessionNonTX.createMessage(true);
@@ -1571,7 +1571,7 @@
}
else
{
- System.out.println("Consuming 20 msgs to make it page");
+ // System.out.println("Consuming 20 msgs to make it page");
ClientConsumer consumer =
sessionNonTX.createConsumer(PagingTest.ADDRESS);
for (int j = 0; j < 20; j++)
{
@@ -1611,12 +1611,9 @@
Integer messageID = (Integer)message.getObjectProperty(new
SimpleString("id"));
- // System.out.println(messageID);
- Assert.assertNotNull(messageID);
- Assert.assertEquals("message received out of order", i,
messageID.intValue());
+ Assert.assertNotNull("MessageID", messageID);
+ Assert.assertEquals("message received out of order " + messageID,
i, messageID.intValue());
- System.out.println("MessageID = " + messageID);
-
message.acknowledge();
}
@@ -1877,8 +1874,7 @@
for (int i = 0; i < numberOfMessages; i++)
{
ClientMessage msg = consumer.receive(5000);
- assertNotNull(msg);
- System.out.println("Received " + i);
+ assertNotNull(String.valueOf(i), msg);
assertEquals(i, msg.getIntProperty("count").intValue());
msg.acknowledge();
}
@@ -2197,13 +2193,12 @@
session.start();
for (int i = 0; i < numberOfMessages; i++)
{
- System.out.println("Received " + i);
if (i == 55)
{
System.out.println("i = 55");
}
ClientMessage msg = consumer.receive(5000);
- Assert.assertNotNull(msg);
+ Assert.assertNotNull("Received " + i, msg);
msg.acknowledge();
session.commit();
}
@@ -2296,10 +2291,9 @@
// 347 = I just picked any odd number, not rounded, to make sure it's not at
the beggining of any page
for (int i = 0; i < 347; i++)
{
- System.out.println("Received " + i);
ClientMessage msg = consumer.receive(5000);
assertEquals(i, msg.getIntProperty("id").intValue());
- Assert.assertNotNull(msg);
+ Assert.assertNotNull("Received " + i, msg);
msg.acknowledge();
session.commit();
}
@@ -2329,10 +2323,9 @@
session.start();
for (int i = 347; i < numberOfMessages; i++)
{
- System.out.println("Received " + i);
ClientMessage msg = consumer.receive(5000);
assertEquals(i, msg.getIntProperty("id").intValue());
- Assert.assertNotNull(msg);
+ Assert.assertNotNull("Received " + i, msg);
msg.acknowledge();
session.commit();
}
Modified:
branches/HORNETQ-720_Replication/tests/stress-tests/src/test/java/org/hornetq/tests/stress/paging/PageCursorStressTest.java
===================================================================
---
branches/HORNETQ-720_Replication/tests/stress-tests/src/test/java/org/hornetq/tests/stress/paging/PageCursorStressTest.java 2011-09-26
10:38:04 UTC (rev 11422)
+++
branches/HORNETQ-720_Replication/tests/stress-tests/src/test/java/org/hornetq/tests/stress/paging/PageCursorStressTest.java 2011-09-26
10:39:02 UTC (rev 11423)
@@ -67,12 +67,12 @@
// Attributes ----------------------------------------------------
- private SimpleString ADDRESS = new SimpleString("test-add");
+ private final SimpleString ADDRESS = new SimpleString("test-add");
private HornetQServer server;
private Queue queue;
-
+
private List<Queue> queueList;
private static final int PAGE_MAX = -1;
@@ -120,7 +120,7 @@
final int NUM_MESSAGES = 100;
PageSubscription cursor =
lookupPageStore(ADDRESS).getCursorProvider().getSubscription(queue.getID());
-
+
Iterator<PagedReference> iterEmpty = cursor.iterator();
int numberOfPages = addMessages(NUM_MESSAGES, 1024 * 1024);
@@ -325,9 +325,8 @@
for (int i = firstPageSize; i < NUM_MESSAGES; i++)
{
- System.out.println("Received " + i);
PagedReference msg = iterator.next();
- assertNotNull(msg);
+ assertNotNull("Received " + i, msg);
assertEquals(i, msg.getMessage().getIntProperty("key").intValue());
cursor.ack(msg);
@@ -378,7 +377,7 @@
cursor.ack(msg);
}
}
-
+
server.getStorageManager().waitOnOperations();
server.stop();
@@ -498,7 +497,7 @@
.getSubscription(queue.getID());
System.out.println("Cursor: " + cursor);
-
+
RoutingContextImpl ctx = generateCTX();
LinkedListIterator<PagedReference> iterator = cursor.iterator();
@@ -527,7 +526,7 @@
}
OperationContextImpl.clearContext();
-
+
ctx = generateCTX();
pageStore = lookupPageStore(ADDRESS);
@@ -616,8 +615,8 @@
assertFalse(lookupPageStore(ADDRESS).isPaging());
}
-
+
public void testConsumeLivePageMultiThread() throws Exception
{
final PagingStoreImpl pageStore = lookupPageStore(ADDRESS);
@@ -625,9 +624,9 @@
pageStore.startPaging();
final int NUM_TX = 100;
-
+
final int MSGS_TX = 100;
-
+
final int TOTAL_MSG = NUM_TX * MSGS_TX;
final int messageSize = 1024;
@@ -641,31 +640,32 @@
.getSubscription(queue.getID());
System.out.println("Cursor: " + cursor);
-
+
final StorageManager storage = this.server.getStorageManager();
-
+
final AtomicInteger exceptions = new AtomicInteger(0);
-
+
Thread t1 = new Thread()
{
+ @Override
public void run()
{
try
{
int count = 0;
-
+
for (int txCount = 0; txCount < NUM_TX; txCount++)
{
-
+
Transaction tx = null;
-
+
if (txCount % 2 == 0)
{
tx = new TransactionImpl(storage);
}
RoutingContext ctx = generateCTX(tx);
-
+
for (int i = 0 ; i < MSGS_TX; i++)
{
//System.out.println("Sending " + count);
@@ -678,12 +678,12 @@
Assert.assertTrue(pageStore.page(msg, ctx,
ctx.getContextListing(ADDRESS)));
}
-
+
if (tx != null)
{
tx.commit();
}
-
+
}
}
catch (Throwable e)
@@ -693,12 +693,12 @@
}
}
};
-
+
t1.start();
-
-
+
+
LinkedListIterator<PagedReference> iterator = cursor.iterator();
-
+
for (int i = 0 ; i < TOTAL_MSG; i++ )
{
assertEquals(0, exceptions.get());
@@ -716,32 +716,32 @@
}
}
assertNotNull(ref);
-
+
ref.acknowledge();
assertNotNull(ref);
-
+
System.out.println("Consuming " +
ref.getMessage().getIntProperty("key"));
//assertEquals(i, ref.getMessage().getIntProperty("key").intValue());
}
assertEquals(0, exceptions.get());
}
-
+
private RoutingContextImpl generateCTX()
{
return generateCTX(null);
}
-
+
private RoutingContextImpl generateCTX(Transaction tx)
{
RoutingContextImpl ctx = new RoutingContextImpl(tx);
ctx.addQueue(ADDRESS, queue);
-
+
for (Queue q : this.queueList)
{
ctx.addQueue(ADDRESS, q);
}
-
+
return ctx;
}
@@ -813,11 +813,11 @@
assertNull(iterator.next());
cursor.printDebug();
-
+
txCommit.commit();
txRollback.rollback();
-
+
storage.waitOnOperations();
// Second:after pgtxCommit was done
@@ -830,7 +830,7 @@
}
assertNull(iterator.next());
-
+
server.getStorageManager().waitOnOperations();
server.stop();
@@ -888,9 +888,9 @@
}
assertNull(iterator.next());
-
+
txLazy.commit();
-
+
storage.waitOnOperations();
for (int i = 0; i < 100; i++)
@@ -955,7 +955,7 @@
// We can't proceed until the operation has finished
server.getStorageManager().waitOnOperations();
-
+
PagedMessage msg = cache.getMessage(startingPos.getMessageNr() + 1);
msg.initMessage(server.getStorageManager());
int initialKey = msg.getMessage().getIntProperty("key").intValue();
@@ -1000,7 +1000,7 @@
assertEquals(1, lookupPageStore(ADDRESS).getNumberOfPages());
}
-
+
private int tstProperty(ServerMessage msg)
{
return msg.getIntProperty("key").intValue();
@@ -1020,52 +1020,52 @@
PageSubscription cursor = cursorProvider.getSubscription(queue.getID());
LinkedListIterator<PagedReference> iter = cursor.iterator();
-
+
LinkedListIterator<PagedReference> iter2 = cursor.iterator();
-
+
assertTrue(iter.hasNext());
-
+
PagedReference msg1 = iter.next();
-
+
PagedReference msg2 = iter2.next();
-
+
assertEquals(tstProperty(msg1.getMessage()), tstProperty(msg2.getMessage()));
-
+
System.out.println("property = " + tstProperty(msg1.getMessage()));
msg1 = iter.next();
-
+
assertEquals(1, tstProperty(msg1.getMessage()));
-
+
iter.remove();
-
+
msg2 = iter2.next();
-
+
assertEquals(2, tstProperty(msg2.getMessage()));
-
+
iter2.repeat();
-
+
msg2 = iter2.next();
-
+
assertEquals(2, tstProperty(msg2.getMessage()));
-
+
iter2.repeat();
-
+
assertEquals(2, tstProperty(msg2.getMessage()));
-
+
msg1 = iter.next();
-
+
assertEquals(2, tstProperty(msg1.getMessage()));
-
+
iter.repeat();
-
+
msg1 = iter.next();
-
+
assertEquals(2, tstProperty(msg1.getMessage()));
-
+
assertTrue(iter2.hasNext());
-
-
+
+
}
private int addMessages(final int numMessages, final int messageSize) throws
Exception
@@ -1083,7 +1083,7 @@
PagingStoreImpl pageStore = lookupPageStore(ADDRESS);
pageStore.startPaging();
-
+
RoutingContext ctx = generateCTX();
for (int i = start; i < start + numMessages; i++)
@@ -1118,6 +1118,7 @@
// Protected -----------------------------------------------------
+ @Override
protected void tearDown() throws Exception
{
server.stop();
@@ -1127,6 +1128,7 @@
super.tearDown();
}
+ @Override
protected void setUp() throws Exception
{
super.setUp();
@@ -1134,7 +1136,7 @@
System.out.println("Tmp:" + getTemporaryDir());
queueList = new ArrayList<Queue>();
-
+
createServer();
}
@@ -1152,7 +1154,7 @@
server = createServer(true, config, PAGE_SIZE, PAGE_MAX, new HashMap<String,
AddressSettings>());
server.start();
-
+
queueList.clear();
try
@@ -1174,11 +1176,11 @@
long id = server.getStorageManager().generateUniqueID();
FakeQueue queue = new FakeQueue(new SimpleString(filter.toString()), id);
queueList.add(queue);
-
+
PageSubscription subs = lookupCursorProvider().createSubscription(id, filter,
false);
-
+
queue.setPageSubscription(subs);
-
+
return subs;
}
@@ -1207,9 +1209,9 @@
final int NUM_MESSAGES,
final int messageSize) throws Exception
{
-
+
TransactionImpl txImpl = new TransactionImpl(pgParameter, null, storage);
-
+
RoutingContext ctx = generateCTX(txImpl);
for (int i = start; i < start + NUM_MESSAGES; i++)
@@ -1220,7 +1222,7 @@
msg.putIntProperty("key", i);
pageStore.page(msg, ctx, ctx.getContextListing(ADDRESS));
}
-
+
return txImpl;
}