Search in sources :

Example 16 with TestInfrastructure

use of net.dempsy.util.TestInfrastructure in project Dempsy by Dempsy.

the class TestOutputSchedulers method testCronSchedule.

/**
 * Test cron schedule.
 *
 * @throws Exception the exception
 */
@Test
public void testCronSchedule() throws Exception {
    try (final CronOutputSchedule cronOutputSchedule = new CronOutputSchedule("0/1 * * * * ?")) {
        cronOutputSchedule.setOutputInvoker(container);
        cronOutputSchedule.start(new TestInfrastructure(null));
        assertTrue(poll(outputInvoked, oi -> oi.get()));
    }
}
Also used : TimeUnit(java.util.concurrent.TimeUnit) NonLockingAltContainer(net.dempsy.container.altnonlocking.NonLockingAltContainer) ConditionPoll.poll(net.dempsy.utils.test.ConditionPoll.poll) TestInfrastructure(net.dempsy.util.TestInfrastructure) Assert.assertTrue(org.junit.Assert.assertTrue) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Container(net.dempsy.container.Container) Test(org.junit.Test) Before(org.junit.Before) TestInfrastructure(net.dempsy.util.TestInfrastructure) Test(org.junit.Test)

Example 17 with TestInfrastructure

use of net.dempsy.util.TestInfrastructure in project Dempsy by Dempsy.

the class TestOutputSchedulers method testRelativeScheduleWithConcurrency.

/**
 * Test relative schedule with concurrency.
 *
 * @throws Exception the exception
 */
@Test
public void testRelativeScheduleWithConcurrency() throws Exception {
    try (final RelativeOutputSchedule relativeOutputSchedule = new RelativeOutputSchedule(1, TimeUnit.SECONDS)) {
        relativeOutputSchedule.setOutputInvoker(container);
        relativeOutputSchedule.start(new TestInfrastructure(null));
        assertTrue(poll(outputInvoked, oi -> oi.get()));
    }
}
Also used : TimeUnit(java.util.concurrent.TimeUnit) NonLockingAltContainer(net.dempsy.container.altnonlocking.NonLockingAltContainer) ConditionPoll.poll(net.dempsy.utils.test.ConditionPoll.poll) TestInfrastructure(net.dempsy.util.TestInfrastructure) Assert.assertTrue(org.junit.Assert.assertTrue) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Container(net.dempsy.container.Container) Test(org.junit.Test) Before(org.junit.Before) TestInfrastructure(net.dempsy.util.TestInfrastructure) Test(org.junit.Test)

Aggregations

TestInfrastructure (net.dempsy.util.TestInfrastructure)17 Test (org.junit.Test)14 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)12 ConditionPoll.poll (net.dempsy.utils.test.ConditionPoll.poll)11 Assert.assertTrue (org.junit.Assert.assertTrue)11 DefaultThreadingModel (net.dempsy.threading.DefaultThreadingModel)10 AtomicLong (java.util.concurrent.atomic.AtomicLong)7 AtomicReference (java.util.concurrent.atomic.AtomicReference)7 Receiver (net.dempsy.transport.Receiver)7 Sender (net.dempsy.transport.Sender)7 SenderFactory (net.dempsy.transport.SenderFactory)7 Functional.chain (net.dempsy.util.Functional.chain)7 Infrastructure (net.dempsy.Infrastructure)6 ServiceTracker (net.dempsy.ServiceTracker)6 NonLockingAltContainer (net.dempsy.container.altnonlocking.NonLockingAltContainer)6 Inet4Address (java.net.Inet4Address)5 NetworkInterface (java.net.NetworkInterface)5 Arrays (java.util.Arrays)5 Collection (java.util.Collection)5 Collections (java.util.Collections)5