@RunWith(CassandraRunner.class)
public class StatusDataStoreTest {
@Test
public void statuses() throws InterruptedException, IllegalAccessException {
final CassandraStatusDataStore store = IoCs.processInstance(new CassandraStatusDataStore() {
@Created
protected void forceMarker() {
marker = "test";
}
@Override
protected NodeStatusReporter newNodeStatusReporter() {
return new NodeStatusReporter() {
@Override
public synchronized NodeStatus computeStatus() {
return new NodeStatus(new ValidationResult[]{new ValidationResult("sample", Status.OK, "msg")}, new Date());
}
};
}
@Override
protected int getPeriod(final String prefix) {
return 100;
}
});
assertEquals(0, store.statuses().size());
Thread.sleep(250);
store.shutdown();
final Map<String,NodeStatus> statuses = store.statuses();
assertEquals(1, statuses.size());
assertTrue(statuses.containsKey("test"));
final ValidationResult[] results = statuses.get("test").getResults();
assertEquals(1, results.length);