use of com.hazelcast.simulator.common.TestCase in project hazelcast-simulator by hazelcast.
the class Registry method addTests.
public synchronized List<TestData> addTests(TestSuite testSuite) {
List<TestData> result = new ArrayList<TestData>(testSuite.size());
for (TestCase testCase : testSuite.getTestCaseList()) {
String id = testCase.getId();
AtomicLong count = ids.get(id);
if (count == null) {
ids.put(id, new AtomicLong(1));
} else {
id = id + "__" + count.getAndIncrement();
}
int testIndex = testIndexGenerator.incrementAndGet();
testCase.setId(id);
TestData test = new TestData(testIndex, testCase, testSuite);
result.add(test);
tests.put(id, test);
}
return result;
}
use of com.hazelcast.simulator.common.TestCase in project hazelcast-simulator by hazelcast.
the class FailureCollectorTest method notify_enrich.
@Test
public void notify_enrich() {
TestCase testCase = new TestCase("test1");
TestSuite suite1 = new TestSuite().addTest(testCase);
TestSuite suite2 = new TestSuite().addTest(new TestCase("test2"));
registry.addTests(suite1);
registry.addTests(suite2);
FailureOperation failure = new FailureOperation("exception", WORKER_EXCEPTION, workerAddress, agentAddress.toString(), "workerId", testCase.getId(), null);
FailureListener listener = mock(FailureListener.class);
failureCollector.addListener(listener);
failureCollector.notify(failure);
ArgumentCaptor<FailureOperation> failureCaptor = ArgumentCaptor.forClass(FailureOperation.class);
verify(listener).onFailure(failureCaptor.capture(), eq(false), eq(true));
assertSame(suite1.getTestCaseList().get(0), failureCaptor.getValue().getTestCase());
}
use of com.hazelcast.simulator.common.TestCase in project hazelcast-simulator by hazelcast.
the class MetronomeConstructorTest method withCustomMetronome.
@Test
public void withCustomMetronome() {
PropertyBinding propertyBinding = new PropertyBinding(new TestCase("foo").setProperty("interval", "10ns").setProperty("metronomeClass", BusySpinningMetronome.class));
MetronomeConstructor metronomeConstructor = new MetronomeConstructor("", propertyBinding, 1);
Metronome m = metronomeConstructor.newInstance();
assertEquals(BusySpinningMetronome.class, m.getClass());
BusySpinningMetronome metronome = (BusySpinningMetronome) m;
assertEquals(10, metronome.getIntervalNanos());
}
use of com.hazelcast.simulator.common.TestCase in project hazelcast-simulator by hazelcast.
the class MetronomeConstructorTest method test.
public void test(long expectedInterval, String actualInterval) {
PropertyBinding propertyBinding = new PropertyBinding(new TestCase("foo").setProperty("interval", actualInterval));
MetronomeConstructor metronomeConstructor = new MetronomeConstructor("", propertyBinding, 1);
Metronome m = metronomeConstructor.newInstance();
assertEquals(SleepingMetronome.class, m.getClass());
SleepingMetronome metronome = (SleepingMetronome) m;
assertEquals(expectedInterval, metronome.getIntervalNanos());
}
use of com.hazelcast.simulator.common.TestCase in project hazelcast-simulator by hazelcast.
the class PropertyBindingSupport_nestedPropertiesTest method testReconstructObjectGraph.
@Test
public void testReconstructObjectGraph() {
TestCase testCase = new TestCase("id").setProperty("nullArm.finger.length", 10);
Person person = new Person();
Set<String> usedProperties = bindAll(person, testCase);
assertNotNull(person.nullArm);
assertNotNull(person.nullArm.finger);
assertEquals(10, person.nullArm.finger.length);
assertEquals(asSet("nullArm.finger.length"), usedProperties);
}
Aggregations