@Test
public void testReplace() throws Exception
{

    ActivityQueue queue = new ActivityQueue();
    queue.start();
    try
    {
        final AtomicInteger     count = new AtomicInteger(0);
        final CountDownLatch    latch = new CountDownLatch(1);
        Activity                activity = new Activity()
        {
            @Override
            public void completed(boolean wasSuccessful)
            {
            }
            @Override
            public Boolean call() throws Exception
            {
                count.incrementAndGet();
                latch.countDown();
                return true;
            }
        };
        queue.add(QueueGroups.MAIN, activity, 1, TimeUnit.MINUTES);
        queue.replace(QueueGroups.MAIN, activity);
        Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
        Assert.assertEquals(count.get(), 1);
    }
    finally
    {
        CloseableUtils.closeQuietly(queue);
    }
}