Author: clebert.suconic(a)jboss.com
Date: 2009-11-13 14:14:02 -0500 (Fri, 13 Nov 2009)
New Revision: 8282
Modified:
trunk/tests/src/org/hornetq/tests/integration/replication/ReplicationTest.java
Log:
Adding a test that I had here to the ReplicationTEst
Modified: trunk/tests/src/org/hornetq/tests/integration/replication/ReplicationTest.java
===================================================================
---
trunk/tests/src/org/hornetq/tests/integration/replication/ReplicationTest.java 2009-11-13
18:57:52 UTC (rev 8281)
+++
trunk/tests/src/org/hornetq/tests/integration/replication/ReplicationTest.java 2009-11-13
19:14:02 UTC (rev 8282)
@@ -504,6 +504,89 @@
}
}
+ public void testOrderOnNonPersistency() throws Exception
+ {
+
+ Configuration config = createDefaultConfig(false);
+
+ config.setBackup(true);
+
+ HornetQServer server = new HornetQServerImpl(config);
+
+ server.start();
+
+ FailoverManager failoverManager = createFailoverManager();
+
+ final ArrayList<Integer> executions = new ArrayList<Integer>();
+
+ try
+ {
+ ReplicationManagerImpl manager = new ReplicationManagerImpl(failoverManager,
+
ConfigurationImpl.DEFAULT_BACKUP_WINDOW_SIZE);
+ manager.start();
+
+ Journal replicatedJournal = new ReplicatedJournal((byte)1, new FakeJournal(),
manager);
+
+ int numberOfAdds = 200;
+
+ final CountDownLatch latch = new CountDownLatch(numberOfAdds);
+
+ for (int i = 0; i < numberOfAdds; i++)
+ {
+ final int nAdd = i;
+
+ if (i % 2 == 0)
+ {
+ replicatedJournal.appendPrepareRecord(i, new FakeData(), false);
+ }
+ else
+ {
+ manager.sync();
+ }
+
+
+ manager.afterReplicated(new Runnable()
+ {
+
+ public void run()
+ {
+ executions.add(nAdd);
+ latch.countDown();
+ }
+
+ });
+
+ manager.closeContext();
+ }
+
+ assertTrue(latch.await(10, TimeUnit.SECONDS));
+
+
+ for (int i = 0; i < numberOfAdds; i++)
+ {
+ assertEquals(i, executions.get(i).intValue());
+ }
+
+ for (int i = 0; i < 100; i++)
+ {
+ // This is asynchronous. Have to wait completion
+ if (manager.getActiveTokens().size() == 0)
+ {
+ break;
+ }
+ Thread.sleep(1);
+ }
+
+
+ assertEquals(0, manager.getActiveTokens().size());
+ manager.stop();
+ }
+ finally
+ {
+ server.stop();
+ }
+ }
+
class FakeData implements EncodingSupport
{