use of com.hazelcast.simulator.test.BaseThreadState in project hazelcast-simulator by hazelcast.
the class TimeStepRunStrategyIntegrationTest method testWithThreadContext.
@Test
public void testWithThreadContext() throws Exception {
int threadCount = 2;
TestWithThreadState testInstance = new TestWithThreadState();
TestCase testCase = new TestCase("someid").setProperty("threadCount", threadCount).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 runFuture = spawn(new Callable() {
@Override
public Object call() throws Exception {
container.invoke(RUN);
return null;
}
});
Thread.sleep(5000);
testContext.stop();
runFuture.get();
container.invoke(TestPhase.LOCAL_TEARDOWN);
assertEquals(threadCount, testInstance.map.size());
// each context should be unique
Set<BaseThreadState> contexts = new HashSet<BaseThreadState>(testInstance.map.values());
assertEquals(threadCount, contexts.size());
}
use of com.hazelcast.simulator.test.BaseThreadState in project hazelcast-simulator by hazelcast.
the class TestContainer_TimeStepTest method testWithThreadState.
@Test
public void testWithThreadState() throws Exception {
int threadCount = 2;
TestWithThreadState testInstance = new TestWithThreadState();
TestCase testCase = new TestCase("id").setProperty("threadCount", threadCount).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 runFuture = spawn(new Callable() {
@Override
public Object call() throws Exception {
container.invoke(RUN);
return null;
}
});
Thread.sleep(5000);
testContext.stop();
runFuture.get();
container.invoke(TestPhase.LOCAL_TEARDOWN);
assertEquals(threadCount, testInstance.map.size());
// each context should be unique
Set<BaseThreadState> threadStates = new HashSet<BaseThreadState>(testInstance.map.values());
assertEquals(threadCount, threadStates.size());
}
Aggregations