Search in sources :

Example 1 with Metronome

use of com.hazelcast.simulator.worker.metronome.Metronome in project hazelcast-simulator by hazelcast.

the class MetronomeConstructorTest method withCustomMetronome.

@Test
public void withCustomMetronome() {
    PropertyBinding propertyBinding = new PropertyBinding(new TestCase("foo").setProperty("interval", "10ns").setProperty("metronomeClass", BusySpinningMetronome.class));
    MetronomeConstructor metronomeConstructor = new MetronomeConstructor("", propertyBinding, 1);
    Metronome m = metronomeConstructor.newInstance();
    assertEquals(BusySpinningMetronome.class, m.getClass());
    BusySpinningMetronome metronome = (BusySpinningMetronome) m;
    assertEquals(10, metronome.getIntervalNanos());
}
Also used : TestCase(com.hazelcast.simulator.common.TestCase) Metronome(com.hazelcast.simulator.worker.metronome.Metronome) BusySpinningMetronome(com.hazelcast.simulator.worker.metronome.BusySpinningMetronome) EmptyMetronome(com.hazelcast.simulator.worker.metronome.EmptyMetronome) SleepingMetronome(com.hazelcast.simulator.worker.metronome.SleepingMetronome) BusySpinningMetronome(com.hazelcast.simulator.worker.metronome.BusySpinningMetronome) Test(org.junit.Test)

Example 2 with Metronome

use of com.hazelcast.simulator.worker.metronome.Metronome in project hazelcast-simulator by hazelcast.

the class MetronomeConstructorTest method test.

public void test(long expectedInterval, String actualInterval) {
    PropertyBinding propertyBinding = new PropertyBinding(new TestCase("foo").setProperty("interval", actualInterval));
    MetronomeConstructor metronomeConstructor = new MetronomeConstructor("", propertyBinding, 1);
    Metronome m = metronomeConstructor.newInstance();
    assertEquals(SleepingMetronome.class, m.getClass());
    SleepingMetronome metronome = (SleepingMetronome) m;
    assertEquals(expectedInterval, metronome.getIntervalNanos());
}
Also used : SleepingMetronome(com.hazelcast.simulator.worker.metronome.SleepingMetronome) TestCase(com.hazelcast.simulator.common.TestCase) Metronome(com.hazelcast.simulator.worker.metronome.Metronome) BusySpinningMetronome(com.hazelcast.simulator.worker.metronome.BusySpinningMetronome) EmptyMetronome(com.hazelcast.simulator.worker.metronome.EmptyMetronome) SleepingMetronome(com.hazelcast.simulator.worker.metronome.SleepingMetronome)

Example 3 with Metronome

use of com.hazelcast.simulator.worker.metronome.Metronome in project hazelcast-simulator by hazelcast.

the class MetronomeConstructorTest method testThreadCount.

@Test
public void testThreadCount() {
    PropertyBinding propertyBinding = new PropertyBinding(new TestCase("foo").setProperty("interval", "20ns"));
    MetronomeConstructor metronomeConstructor = new MetronomeConstructor("", propertyBinding, 10);
    Metronome m = metronomeConstructor.newInstance();
    assertEquals(SleepingMetronome.class, m.getClass());
    SleepingMetronome metronome = (SleepingMetronome) m;
    assertEquals(200, metronome.getIntervalNanos());
}
Also used : SleepingMetronome(com.hazelcast.simulator.worker.metronome.SleepingMetronome) TestCase(com.hazelcast.simulator.common.TestCase) Metronome(com.hazelcast.simulator.worker.metronome.Metronome) BusySpinningMetronome(com.hazelcast.simulator.worker.metronome.BusySpinningMetronome) EmptyMetronome(com.hazelcast.simulator.worker.metronome.EmptyMetronome) SleepingMetronome(com.hazelcast.simulator.worker.metronome.SleepingMetronome) Test(org.junit.Test)

Example 4 with Metronome

use of com.hazelcast.simulator.worker.metronome.Metronome in project hazelcast-simulator by hazelcast.

the class MetronomeConstructorTest method whenZeroInterval.

@Test
public void whenZeroInterval() {
    PropertyBinding propertyBinding = new PropertyBinding(new TestCase("foo"));
    MetronomeConstructor metronomeConstructor = new MetronomeConstructor("", propertyBinding, 5);
    Metronome m = metronomeConstructor.newInstance();
    assertEquals(EmptyMetronome.class, m.getClass());
}
Also used : TestCase(com.hazelcast.simulator.common.TestCase) Metronome(com.hazelcast.simulator.worker.metronome.Metronome) BusySpinningMetronome(com.hazelcast.simulator.worker.metronome.BusySpinningMetronome) EmptyMetronome(com.hazelcast.simulator.worker.metronome.EmptyMetronome) SleepingMetronome(com.hazelcast.simulator.worker.metronome.SleepingMetronome) Test(org.junit.Test)

Aggregations

TestCase (com.hazelcast.simulator.common.TestCase)4 BusySpinningMetronome (com.hazelcast.simulator.worker.metronome.BusySpinningMetronome)4 EmptyMetronome (com.hazelcast.simulator.worker.metronome.EmptyMetronome)4 Metronome (com.hazelcast.simulator.worker.metronome.Metronome)4 SleepingMetronome (com.hazelcast.simulator.worker.metronome.SleepingMetronome)4 Test (org.junit.Test)3