Search in sources :

Example 31 with TestCase

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

the class TestContainer_TimeStep_ExceptionTest method test.

@Test
public void test() throws Exception {
    ExceptionTest testInstance = new ExceptionTest();
    TestCase testCase = new TestCase("exceptionTest").setProperty("threadCount", 1).setProperty("class", testInstance.getClass());
    TestContextImpl testContext = new TestContextImpl(testCase.getId(), "localhost", mock(Server.class));
    final TestContainer container = new TestContainer(testContext, testInstance, testCase);
    container.invoke(SETUP);
    Future f = spawn(new Callable() {

        @Override
        public Object call() throws Exception {
            container.invoke(RUN);
            return null;
        }
    });
    assertCompletesEventually(f);
    assertEquals(1L, testInstance.counter.get());
    assertException("IllegalStateException", 1);
}
Also used : Server(com.hazelcast.simulator.protocol.Server) TestCase(com.hazelcast.simulator.common.TestCase) Future(java.util.concurrent.Future) Callable(java.util.concurrent.Callable) TestUtils.assertException(com.hazelcast.simulator.utils.TestUtils.assertException) Test(org.junit.Test)

Example 32 with TestCase

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

the class TestContainer_TimeStep_LogFrequencyTest method test.

@Test
public void test() throws Exception {
    LogFrequencyTest testInstance = new LogFrequencyTest();
    TestCase testCase = new TestCase("test").setProperty("logFrequency", 1000).setProperty("threadCount", 1).setProperty("class", testInstance.getClass());
    TestContextImpl testContext = new TestContextImpl(testCase.getId(), "localhost", mock(Server.class));
    TestContainer container = new TestContainer(testContext, testInstance, testCase, mock(HazelcastInstance.class));
    for (TestPhase phase : TestPhase.values()) {
        container.invoke(phase);
    }
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Server(com.hazelcast.simulator.protocol.Server) TestCase(com.hazelcast.simulator.common.TestCase) TestPhase(com.hazelcast.simulator.common.TestPhase) AbstractTest(com.hazelcast.simulator.test.AbstractTest) Test(org.junit.Test)

Example 33 with TestCase

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

the class TestContainer_TimeStep_StopTest method test.

@Test
public void test() throws Exception {
    TimeStepStopTest testInstance = new TimeStepStopTest();
    TestCase testCase = new TestCase("stopRun").setProperty("threadCount", 1).setProperty("class", testInstance.getClass());
    TestContextImpl testContext = new TestContextImpl(testCase.getId(), "localhost", mock(Server.class));
    final TestContainer container = new TestContainer(testContext, testInstance, testCase);
    container.invoke(SETUP);
    Future f = spawn(new Callable() {

        @Override
        public Object call() throws Exception {
            container.invoke(RUN);
            return null;
        }
    });
    assertCompletesEventually(f);
    assertNoExceptions();
}
Also used : Server(com.hazelcast.simulator.protocol.Server) TestCase(com.hazelcast.simulator.common.TestCase) Future(java.util.concurrent.Future) Callable(java.util.concurrent.Callable) StopException(com.hazelcast.simulator.test.StopException) Test(org.junit.Test)

Example 34 with TestCase

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

the class FailureOperationTest method before.

@Before
public void before() {
    testCase = new TestCase(TEST_ID);
    cause = new TestException("expected exception");
    operation = new FailureOperation("FailureOperationTest", WORKER_EXCEPTION, workerAddress, null, cause);
    fullOperation = new FailureOperation("FailureOperationTest", WORKER_EXCEPTION, workerAddress, null, "A1_W1-member", TEST_ID, null).setTestCase(testCase);
}
Also used : TestException(com.hazelcast.simulator.test.TestException) TestCase(com.hazelcast.simulator.common.TestCase) Before(org.junit.Before)

Example 35 with TestCase

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

the class RegistryTest method testAddTests_testIdFixing.

@Test
public void testAddTests_testIdFixing() {
    TestCase test1 = new TestCase("foo");
    TestCase test2 = new TestCase("foo");
    TestCase test3 = new TestCase("foo");
    registry.addTests(new TestSuite().addTest(test1));
    registry.addTests(new TestSuite().addTest(test2));
    registry.addTests(new TestSuite().addTest(test3));
    assertEquals("foo", test1.getId());
    assertEquals("foo__1", test2.getId());
    assertEquals("foo__2", test3.getId());
}
Also used : TestSuite(com.hazelcast.simulator.coordinator.TestSuite) 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