@Test
public void testSimpleIncrement() {

	Replicator replicator;
	MockReplicationSource source;
	MockReplicationDestination destination;
	MockTransactionSnapshotLoader snapshotLoader;
	MockSystemTimeLoader timeLoader;
	ReplicationState state;
	ReplicationQueryPredicates predicates;
	
	// Build initial replication state.
	state = new ReplicationState(
			200,
			200,
			Arrays.asList(new Long[]{}),
			Arrays.asList(new Long[]{}),
			buildDate("2009-10-11 12:13:14"),
			0);
	
	// Build the mocks.
	source = new MockReplicationSource();
	destination = new MockReplicationDestination(state);
	snapshotLoader = new MockTransactionSnapshotLoader();
	timeLoader = new MockSystemTimeLoader();
	
	// Instantiate the new replicator.
	replicator = new Replicator(source, destination, snapshotLoader, timeLoader, 1, 0, 0);
	
	// Set the snapshot loader to return a snapshot with higher xMax.
	snapshotLoader.getSnapshots().add(new TransactionSnapshot("100:220"));
	// We also want the clock time to have progressed.
	timeLoader.getTimes().add(buildDate("2009-10-11 12:13:15"));
	timeLoader.getTimes().add(buildDate("2009-10-11 12:13:15"));
	
	// Launch the replication process.
	replicator.replicate();
	
	// Verify that the final state is correct.
	state = destination.getCurrentState();
	Assert.assertEquals("Incorrect final state.",
			new ReplicationState(
					220,
					220,
					Arrays.asList(new Long[]{}),
					Arrays.asList(new Long[]{}),
					buildDate("2009-10-11 12:13:15"),
					1),
			state);
	
	// Verify that the correct changes were replicated.
	Assert.assertTrue("A single interval should have been replicated.", source.getPredicatesList().size() == 1);
	predicates = source.getPredicatesList().get(0);
	Assert.assertEquals("Incorrect active list.", Collections.emptyList(), predicates.getActiveList());
	Assert.assertEquals("Incorrect ready list.", Collections.emptyList(), predicates.getReadyList());
	Assert.assertEquals("Incorrect bottom transaction id.", 200, predicates.getBottomTransactionId());
	Assert.assertEquals("Incorrect top transaction id.", 220, predicates.getTopTransactionId());
}