use of org.apache.sling.hc.core.impl.executor.ExtendedHealthCheckExecutor in project sling by apache.
the class HealthCheckMBeanTest method testBean.
@Test
public void testBean() throws Exception {
final ServiceReference ref = new ServiceReference() {
@Override
public boolean isAssignableTo(Bundle bundle, String className) {
return false;
}
@Override
public Bundle[] getUsingBundles() {
return null;
}
@Override
public String[] getPropertyKeys() {
return null;
}
@Override
public Object getProperty(String key) {
return null;
}
@Override
public Bundle getBundle() {
return null;
}
@Override
public int compareTo(Object reference) {
return 0;
}
};
final HealthCheckMBean mbean = new HealthCheckMBean(ref, new ExtendedHealthCheckExecutor() {
@SuppressWarnings("deprecation")
@Override
public List<HealthCheckExecutionResult> execute(String... tags) {
return null;
}
@Override
public HealthCheckExecutionResult execute(ServiceReference ref) {
// TODO Auto-generated method stub
return new HealthCheckExecutionResult() {
@Override
public Result getHealthCheckResult() {
// TODO Auto-generated method stub
return testHealthCheck.execute();
}
@Override
public HealthCheckMetadata getHealthCheckMetadata() {
// TODO Auto-generated method stub
return null;
}
@Override
public Date getFinishedAt() {
// TODO Auto-generated method stub
return null;
}
@Override
public long getElapsedTimeInMs() {
// TODO Auto-generated method stub
return 0;
}
@Override
public boolean hasTimedOut() {
// TODO Auto-generated method stub
return false;
}
};
}
@SuppressWarnings("deprecation")
@Override
public List<HealthCheckExecutionResult> execute(HealthCheckExecutionOptions options, String... tags) {
return null;
}
@Override
public List<HealthCheckExecutionResult> execute(HealthCheckSelector selector) {
return null;
}
@Override
public List<HealthCheckExecutionResult> execute(HealthCheckSelector selector, HealthCheckExecutionOptions options) {
return null;
}
});
final ObjectName name = new ObjectName(OBJECT_NAME);
jmxServer.registerMBean(mbean, name);
try {
resultOk = true;
assertJmxValue(OBJECT_NAME, "ok", "true", true);
Thread.sleep(1500);
resultOk = false;
assertJmxValue(OBJECT_NAME, "ok", "true", false);
Thread.sleep(1500);
assertJmxValue(OBJECT_NAME, "log", "contains message=Result is not ok!", true);
} finally {
jmxServer.unregisterMBean(name);
}
}
Aggregations