use of com.hazelcast.simulator.common.TestCase in project hazelcast-simulator by hazelcast.
the class TimeStepModel_probabilityTest method loadModel.
private TimeStepModel loadModel(String code, Map<String, Double> probs) {
String header = "import java.util.*;\n" + "import com.hazelcast.simulator.test.annotations.*;\n" + "import com.hazelcast.simulator.test.annotations.*;\n";
code = header + code;
String className = "CLAZZ" + UUID.randomUUID().toString().replace("-", "");
code = code.replace("CLAZZ", className);
Class clazz;
try {
clazz = InMemoryJavaCompiler.compile(className, code);
} catch (Exception e) {
throw new RuntimeException(e);
}
TestCase testCase = new TestCase("foo").setProperty("class", clazz);
for (Map.Entry<String, Double> entry : probs.entrySet()) {
testCase.setProperty(entry.getKey(), entry.getValue());
}
return new TimeStepModel(clazz, new PropertyBinding(testCase));
}
use of com.hazelcast.simulator.common.TestCase in project hazelcast-simulator by hazelcast.
the class TestContainer_NestedPropertyBindingTest method testNestProperties.
@Test
public void testNestProperties() {
TestCase testCase = new TestCase("id").setProperty("nested.intField", 10).setProperty("nested.booleanField", true).setProperty("nested.stringField", "somestring");
DummyTest test = new DummyTest();
testContainer = createTestContainer(test, testCase);
assertNotNull(test.nested);
assertEquals(10, test.nested.intField);
assertEquals(true, test.nested.booleanField);
assertEquals("somestring", test.nested.stringField);
}
use of com.hazelcast.simulator.common.TestCase in project hazelcast-simulator by hazelcast.
the class TestContainer_NestedPropertyBindingTest method testNestedPropertyNotFound.
@Test(expected = BindException.class)
public void testNestedPropertyNotFound() {
TestCase testCase = new TestCase("id").setProperty("nested.notexist", 10);
DummyTest test = new DummyTest();
createTestContainer(test, testCase);
}
use of com.hazelcast.simulator.common.TestCase in project hazelcast-simulator by hazelcast.
the class TestContainer_TimeStep_AsyncSupportTest method createContainerAndRunTestInstance.
private TestContainer createContainerAndRunTestInstance(Object testInstance, int totalIterationCount) throws Exception {
TestCase testCase = new TestCase("test").setProperty("iterations", totalIterationCount).setProperty("threadCount", 1).setProperty("class", testInstance.getClass());
TestContextImpl testContext = new TestContextImpl(testCase.getId(), "localhost", mock(Server.class));
TestContainer container = new TestContainer(testContext, testInstance, testCase);
for (TestPhase phase : TestPhase.values()) {
container.invoke(phase);
}
return container;
}
use of com.hazelcast.simulator.common.TestCase in project hazelcast-simulator by hazelcast.
the class TestContainer_TimeStep_MultipleExecutionGroupsTest method test.
@Test
public void test() throws Exception {
MultipleExecutionGroupsTest testInstance = new MultipleExecutionGroupsTest();
TestCase testCase = new TestCase("multipleExecutionGroupsTest").setProperty("group1ThreadCount", 2).setProperty("group2ThreadCount", 3).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();
assertEquals(2, testInstance.group1Threads.size());
assertEquals(3, testInstance.group2Threads.size());
assertTrue(disjoint(testInstance.group1Threads, testInstance.group2Threads));
}
Aggregations