Author: clebert.suconic(a)jboss.com
Date: 2011-04-08 09:16:19 -0400 (Fri, 08 Apr 2011)
New Revision: 10472
Modified:
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/client/LargeMessageTest.java
Log:
https://issues.jboss.org/browse/JBPAPP-6237 - just moving a test to the public section
Modified:
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/client/LargeMessageTest.java
===================================================================
---
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/client/LargeMessageTest.java 2011-04-08
13:11:08 UTC (rev 10471)
+++
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/client/LargeMessageTest.java 2011-04-08
13:16:19 UTC (rev 10472)
@@ -2449,7 +2449,159 @@
}
}
}
+
+ public void testPageOnLargeMessageMultipleQueues() throws Exception
+ {
+ Configuration config = createDefaultConfig(isNetty());
+ final int PAGE_MAX = 20 * 1024;
+
+ final int PAGE_SIZE = 10 * 1024;
+
+ HashMap<String, AddressSettings> map = new HashMap<String,
AddressSettings>();
+
+ AddressSettings value = new AddressSettings();
+ map.put(LargeMessageTest.ADDRESS.toString(), value);
+ server = createServer(true, config, PAGE_SIZE, PAGE_MAX, map);
+ server.start();
+
+ final int numberOfBytes = 1024;
+
+ final int numberOfBytesBigMessage = 400000;
+
+ try
+ {
+
+ locator.setBlockOnNonDurableSend(true);
+ locator.setBlockOnDurableSend(true);
+ locator.setBlockOnAcknowledge(true);
+
+ ClientSessionFactory sf = locator.createSessionFactory();
+
+ ClientSession session = sf.createSession(null, null, false, true, true, false,
0);
+
+ session.createQueue(LargeMessageTest.ADDRESS,
LargeMessageTest.ADDRESS.concat("-0"), null, true);
+ session.createQueue(LargeMessageTest.ADDRESS,
LargeMessageTest.ADDRESS.concat("-1"), null, true);
+
+ ClientProducer producer = session.createProducer(LargeMessageTest.ADDRESS);
+
+ ClientMessage message = null;
+
+ for (int i = 0; i < 100; i++)
+ {
+ message = session.createMessage(true);
+
+ message.getBodyBuffer().writerIndex(0);
+
+ message.getBodyBuffer().writeBytes(new byte[numberOfBytes]);
+
+ for (int j = 1; j <= numberOfBytes; j++)
+ {
+ message.getBodyBuffer().writeInt(j);
+ }
+
+ producer.send(message);
+ }
+
+ ClientMessage clientFile = createLargeClientMessage(session,
numberOfBytesBigMessage);
+ clientFile.putBooleanProperty("TestLarge", true);
+ producer.send(clientFile);
+
+ for (int i = 0; i < 100; i++)
+ {
+ message = session.createMessage(true);
+
+ message.getBodyBuffer().writeBytes(new byte[numberOfBytes]);
+
+ producer.send(message);
+ }
+
+ session.close();
+
+ server.stop();
+
+ server = createServer(true, config, PAGE_SIZE, PAGE_MAX, map);
+ server.start();
+
+ sf = locator.createSessionFactory();
+
+ for (int ad = 0; ad < 2; ad++)
+ {
+ session = sf.createSession(false, false, false);
+
+ ClientConsumer consumer =
session.createConsumer(LargeMessageTest.ADDRESS.concat("-" + ad));
+
+ session.start();
+
+ for (int i = 0; i < 100; i++)
+ {
+ ClientMessage message2 =
consumer.receive(LargeMessageTest.RECEIVE_WAIT_TIME);
+
+ Assert.assertNotNull(message2);
+
+ message2.acknowledge();
+
+ Assert.assertNotNull(message2);
+ }
+
+ session.commit();
+
+ for (int i = 0; i < 5; i++)
+ {
+ ClientMessage messageLarge = consumer.receive(RECEIVE_WAIT_TIME);
+
+ assertTrue(messageLarge.getBooleanProperty("TestLarge"));
+
+ Assert.assertNotNull(messageLarge);
+
+ ByteArrayOutputStream bout = new ByteArrayOutputStream();
+ messageLarge.acknowledge();
+ messageLarge.saveToOutputStream(bout);
+ byte[] body = bout.toByteArray();
+ assertEquals(numberOfBytesBigMessage, body.length);
+ for (int bi = 0; bi < body.length; bi++)
+ {
+ assertEquals(getSamplebyte(bi), body[bi]);
+ }
+
+ if (i < 4)
+ session.rollback();
+ else
+ session.commit();
+ }
+
+ for (int i = 0; i < 100; i++)
+ {
+ ClientMessage message2 =
consumer.receive(LargeMessageTest.RECEIVE_WAIT_TIME);
+
+ Assert.assertNotNull(message2);
+
+ message2.acknowledge();
+
+ Assert.assertNotNull(message2);
+ }
+
+ session.commit();
+
+ consumer.close();
+
+ session.close();
+
+ }
+ }
+ finally
+ {
+ try
+ {
+ server.stop();
+ }
+ catch (Throwable ignored)
+ {
+ }
+ }
+
+ }
+
public void testSendStreamingSingleMessage() throws Exception
{
ClientSession session = null;
@@ -2813,158 +2965,6 @@
}
- public void testPageOnLargeMessageMultipleQueues() throws Exception
- {
- Configuration config = createDefaultConfig(isNetty());
-
- final int PAGE_MAX = 20 * 1024;
-
- final int PAGE_SIZE = 10 * 1024;
-
- HashMap<String, AddressSettings> map = new HashMap<String,
AddressSettings>();
-
- AddressSettings value = new AddressSettings();
- map.put(LargeMessageTest.ADDRESS.toString(), value);
- server = createServer(true, config, PAGE_SIZE, PAGE_MAX, map);
- server.start();
-
- final int numberOfBytes = 1024;
-
- final int numberOfBytesBigMessage = 400000;
-
- try
- {
-
- locator.setBlockOnNonDurableSend(true);
- locator.setBlockOnDurableSend(true);
- locator.setBlockOnAcknowledge(true);
-
- ClientSessionFactory sf = locator.createSessionFactory();
-
- ClientSession session = sf.createSession(null, null, false, true, true, false,
0);
-
- session.createQueue(LargeMessageTest.ADDRESS,
LargeMessageTest.ADDRESS.concat("-0"), null, true);
- session.createQueue(LargeMessageTest.ADDRESS,
LargeMessageTest.ADDRESS.concat("-1"), null, true);
-
- ClientProducer producer = session.createProducer(LargeMessageTest.ADDRESS);
-
- ClientMessage message = null;
-
- for (int i = 0; i < 100; i++)
- {
- message = session.createMessage(true);
-
- message.getBodyBuffer().writerIndex(0);
-
- message.getBodyBuffer().writeBytes(new byte[numberOfBytes]);
-
- for (int j = 1; j <= numberOfBytes; j++)
- {
- message.getBodyBuffer().writeInt(j);
- }
-
- producer.send(message);
- }
-
- ClientMessage clientFile = createLargeClientMessage(session,
numberOfBytesBigMessage);
- clientFile.putBooleanProperty("TestLarge", true);
- producer.send(clientFile);
-
- for (int i = 0; i < 100; i++)
- {
- message = session.createMessage(true);
-
- message.getBodyBuffer().writeBytes(new byte[numberOfBytes]);
-
- producer.send(message);
- }
-
- session.close();
-
- server.stop();
-
- server = createServer(true, config, PAGE_SIZE, PAGE_MAX, map);
- server.start();
-
- sf = locator.createSessionFactory();
-
- for (int ad = 0; ad < 2; ad++)
- {
- session = sf.createSession(false, false, false);
-
- ClientConsumer consumer =
session.createConsumer(LargeMessageTest.ADDRESS.concat("-" + ad));
-
- session.start();
-
- for (int i = 0; i < 100; i++)
- {
- ClientMessage message2 =
consumer.receive(LargeMessageTest.RECEIVE_WAIT_TIME);
-
- Assert.assertNotNull(message2);
-
- message2.acknowledge();
-
- Assert.assertNotNull(message2);
- }
-
- session.commit();
-
- for (int i = 0; i < 5; i++)
- {
- ClientMessage messageLarge = consumer.receive(RECEIVE_WAIT_TIME);
-
- assertTrue(messageLarge.getBooleanProperty("TestLarge"));
-
- Assert.assertNotNull(messageLarge);
-
- ByteArrayOutputStream bout = new ByteArrayOutputStream();
- messageLarge.acknowledge();
- messageLarge.saveToOutputStream(bout);
- byte[] body = bout.toByteArray();
- assertEquals(numberOfBytesBigMessage, body.length);
- for (int bi = 0; bi < body.length; bi++)
- {
- assertEquals(getSamplebyte(bi), body[bi]);
- }
-
- if (i < 4)
- session.rollback();
- else
- session.commit();
- }
-
- for (int i = 0; i < 100; i++)
- {
- ClientMessage message2 =
consumer.receive(LargeMessageTest.RECEIVE_WAIT_TIME);
-
- Assert.assertNotNull(message2);
-
- message2.acknowledge();
-
- Assert.assertNotNull(message2);
- }
-
- session.commit();
-
- consumer.close();
-
- session.close();
-
- }
- }
- finally
- {
- try
- {
- server.stop();
- }
- catch (Throwable ignored)
- {
- }
- }
-
- }
-
// Private -------------------------------------------------------
// Inner classes -------------------------------------------------