Search in sources :

Example 1 with TestCase

use of com.hazelcast.simulator.common.TestCase in project hazelcast-simulator by hazelcast.

the class Registry method addTests.

public synchronized List<TestData> addTests(TestSuite testSuite) {
    List<TestData> result = new ArrayList<TestData>(testSuite.size());
    for (TestCase testCase : testSuite.getTestCaseList()) {
        String id = testCase.getId();
        AtomicLong count = ids.get(id);
        if (count == null) {
            ids.put(id, new AtomicLong(1));
        } else {
            id = id + "__" + count.getAndIncrement();
        }
        int testIndex = testIndexGenerator.incrementAndGet();
        testCase.setId(id);
        TestData test = new TestData(testIndex, testCase, testSuite);
        result.add(test);
        tests.put(id, test);
    }
    return result;
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) TestCase(com.hazelcast.simulator.common.TestCase) ArrayList(java.util.ArrayList)

Example 2 with TestCase

use of com.hazelcast.simulator.common.TestCase in project hazelcast-simulator by hazelcast.

the class FailureCollectorTest method notify_enrich.

@Test
public void notify_enrich() {
    TestCase testCase = new TestCase("test1");
    TestSuite suite1 = new TestSuite().addTest(testCase);
    TestSuite suite2 = new TestSuite().addTest(new TestCase("test2"));
    registry.addTests(suite1);
    registry.addTests(suite2);
    FailureOperation failure = new FailureOperation("exception", WORKER_EXCEPTION, workerAddress, agentAddress.toString(), "workerId", testCase.getId(), null);
    FailureListener listener = mock(FailureListener.class);
    failureCollector.addListener(listener);
    failureCollector.notify(failure);
    ArgumentCaptor<FailureOperation> failureCaptor = ArgumentCaptor.forClass(FailureOperation.class);
    verify(listener).onFailure(failureCaptor.capture(), eq(false), eq(true));
    assertSame(suite1.getTestCaseList().get(0), failureCaptor.getValue().getTestCase());
}
Also used : TestCase(com.hazelcast.simulator.common.TestCase) FailureOperation(com.hazelcast.simulator.coordinator.operations.FailureOperation) Test(org.junit.Test)

Example 3 with TestCase

use of com.hazelcast.simulator.common.TestCase 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 4 with TestCase

use of com.hazelcast.simulator.common.TestCase 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 5 with TestCase

use of com.hazelcast.simulator.common.TestCase in project hazelcast-simulator by hazelcast.

the class PropertyBindingSupport_nestedPropertiesTest method testReconstructObjectGraph.

@Test
public void testReconstructObjectGraph() {
    TestCase testCase = new TestCase("id").setProperty("nullArm.finger.length", 10);
    Person person = new Person();
    Set<String> usedProperties = bindAll(person, testCase);
    assertNotNull(person.nullArm);
    assertNotNull(person.nullArm.finger);
    assertEquals(10, person.nullArm.finger.length);
    assertEquals(asSet("nullArm.finger.length"), usedProperties);
}
Also used : TestCase(com.hazelcast.simulator.common.TestCase) Test(org.junit.Test)

Aggregations

TestCase (com.hazelcast.simulator.common.TestCase)74 Test (org.junit.Test)61 Server (com.hazelcast.simulator.protocol.Server)18 SuccessTest (com.hazelcast.simulator.tests.SuccessTest)13 Callable (java.util.concurrent.Callable)11 Future (java.util.concurrent.Future)11 FailingTest (com.hazelcast.simulator.tests.FailingTest)10 CreateTestOperation (com.hazelcast.simulator.worker.operations.CreateTestOperation)9 StoppingTest (com.hazelcast.simulator.tests.StoppingTest)8 TestPhase (com.hazelcast.simulator.common.TestPhase)7 StubPromise (com.hazelcast.simulator.protocol.StubPromise)6 StartPhaseOperation (com.hazelcast.simulator.worker.operations.StartPhaseOperation)6 StopException (com.hazelcast.simulator.test.StopException)5 TestSuite (com.hazelcast.simulator.coordinator.TestSuite)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 BaseThreadState (com.hazelcast.simulator.test.BaseThreadState)2 HashMap (java.util.HashMap)2