Search in sources :

Example 51 with TestCase

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

the class PropertyBindingSupport_nestedPropertiesTest method testBadMatch.

@Test(expected = BindException.class)
public void testBadMatch() {
    TestCase testCase = new TestCase("id").setProperty("arm.house.length", 10);
    Person person = new Person();
    bindAll(person, testCase);
}
Also used : TestCase(com.hazelcast.simulator.common.TestCase) Test(org.junit.Test)

Example 52 with TestCase

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

the class PropertyBindingSupport_nestedPropertiesTest method testNotAllPropertiesBound.

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

Example 53 with TestCase

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

the class PropertyBindingSupport_nestedPropertiesTest method testBindAll.

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

Example 54 with TestCase

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

the class TestManagerTest method test_startPhase_whenPreviousPhaseStillRunning.

@Test
public void test_startPhase_whenPreviousPhaseStillRunning() throws Exception {
    TestCase testCase = new TestCase("foo").setProperty("threadCount", 1).setProperty("class", SuccessTest.class);
    manager.createTest(new CreateTestOperation(testCase));
    final TestContainer container = manager.getContainers().iterator().next();
    // do the setup first (needed)
    StubPromise setupPromise = new StubPromise();
    manager.startTestPhase(new StartPhaseOperation(SETUP, "foo"), setupPromise);
    setupPromise.assertCompletesEventually();
    // then start with the run phase
    manager.startTestPhase(new StartPhaseOperation(RUN, "foo"), mock(Promise.class));
    awaitRunning(container);
    // and while the run phase is running, we'll try to do a tear down
    StubPromise promise = new StubPromise();
    manager.startTestPhase(new StartPhaseOperation(LOCAL_TEARDOWN, "foo"), promise);
    promise.assertCompletesEventually();
    assertTrue(promise.getAnswer() instanceof IllegalStateException);
}
Also used : CreateTestOperation(com.hazelcast.simulator.worker.operations.CreateTestOperation) StubPromise(com.hazelcast.simulator.protocol.StubPromise) Promise(com.hazelcast.simulator.protocol.Promise) TestCase(com.hazelcast.simulator.common.TestCase) StubPromise(com.hazelcast.simulator.protocol.StubPromise) StartPhaseOperation(com.hazelcast.simulator.worker.operations.StartPhaseOperation) SuccessTest(com.hazelcast.simulator.tests.SuccessTest) FailingTest(com.hazelcast.simulator.tests.FailingTest) Test(org.junit.Test) StoppingTest(com.hazelcast.simulator.tests.StoppingTest)

Example 55 with TestCase

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

the class TestManagerTest method test_createTest_whenTestExist.

@Test(expected = IllegalStateException.class)
public void test_createTest_whenTestExist() {
    TestCase testCase = new TestCase("foo").setProperty("class", SuccessTest.class);
    CreateTestOperation op = new CreateTestOperation(testCase);
    manager.createTest(op);
    // duplicate.
    manager.createTest(op);
}
Also used : CreateTestOperation(com.hazelcast.simulator.worker.operations.CreateTestOperation) TestCase(com.hazelcast.simulator.common.TestCase) SuccessTest(com.hazelcast.simulator.tests.SuccessTest) FailingTest(com.hazelcast.simulator.tests.FailingTest) Test(org.junit.Test) StoppingTest(com.hazelcast.simulator.tests.StoppingTest)

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