Search in sources :

Example 61 with TestCase

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

the class TestContainer_TimeStep_ProbeInjectionTest method testMeasureLatency.

@Test
public void testMeasureLatency() throws Exception {
    TestClass testInstance = new TestClass();
    TestCase testCase = new TestCase("exceptionTest").setProperty("threadCount", 1).setProperty("measureLatency", true).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);
    assertInstanceOf(HdrProbe.class, testInstance.probe);
}
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 62 with TestCase

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

the class TestContainer_TimeStep_ProbeInjectionTest method testNoMeasureLatency.

@Test
public void testNoMeasureLatency() throws Exception {
    TestClass testInstance = new TestClass();
    TestCase testCase = new TestCase("exceptionTest").setProperty("threadCount", 1).setProperty("measureLatency", false).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);
    assertInstanceOf(EmptyProbe.class, testInstance.probe);
}
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 63 with TestCase

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

the class TestContainer_TimeStep_UnusedProbabilityTest method test.

@Test(expected = IllegalTestException.class)
public void test() throws Exception {
    UnusedProbabilityTest testInstance = new UnusedProbabilityTest();
    TestCase testCase = new TestCase("stopRun").setProperty("threadCount", 1).setProperty("iterations", 100).setProperty("unusedProb", "0.2").setProperty("class", testInstance.getClass());
    TestContextImpl testContext = new TestContextImpl(testCase.getId(), "localhost", mock(Server.class));
    TestContainer container = new TestContainer(testContext, testInstance, testCase);
    container.invoke(SETUP);
}
Also used : Server(com.hazelcast.simulator.protocol.Server) TestCase(com.hazelcast.simulator.common.TestCase) Test(org.junit.Test)

Example 64 with TestCase

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

the class TimeStepModel_IllegalTest method test_threadState_illegalArgumentTypeInConstructor.

@Test(expected = IllegalTestException.class)
public void test_threadState_illegalArgumentTypeInConstructor() {
    TestCase testCase = new TestCase("id");
    PropertyBinding binding = new PropertyBinding(testCase);
    new TimeStepModel(TestWithContextWithIllegalArgumentTypeInConstructor.class, binding);
}
Also used : TestCase(com.hazelcast.simulator.common.TestCase) Test(org.junit.Test)

Example 65 with TestCase

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

the class TimeStepModel_IllegalTest method test_threadState_notPublicClass.

@Test(expected = IllegalTestException.class)
public void test_threadState_notPublicClass() {
    TestCase testCase = new TestCase("id");
    PropertyBinding binding = new PropertyBinding(testCase);
    new TimeStepModel(TestWithPrivateThreadState.class, binding);
}
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