@Test
public void testGetStatusWithStatusChecker() {

    ChangeLogStore structStore = new ZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root",
            privateKey, "0");
    DataStore store = new DataStore(structStore, null);
    Principal principal = SimplePrincipal.create("user_domain", "user1",
            "v=U1;d=user_domain;n=user;s=signature", 0, null);
    ResourceContext context = createResourceContext(principal);
    // if the MockStatusCheckerNoException is set
    // the MockStatusCheckerNoException determines the server is healthy
    System.setProperty(ZTSConsts.ZTS_PROP_STATUS_CHECKER_FACTORY_CLASS, MockStatusCheckerNoException.class.getName());
    ZTSImpl ztsImpl = new ZTSImpl(mockCloudStore, store);
    ztsImpl.statusPort = 0;
    Status status = ztsImpl.getStatus(context);
    assertEquals(ResourceException.OK, status.getCode());
    // if the MockStatusCheckerThrowException is set
    // the MockStatusCheckerThrowException determines that there is a problem with the server
    System.setProperty(ZTSConsts.ZTS_PROP_STATUS_CHECKER_FACTORY_CLASS,
            MockStatusCheckerThrowException.NoArguments.class.getName());
    ztsImpl = new ZTSImpl(mockCloudStore, store);
    ztsImpl.statusPort = 0;
    try {
        ztsImpl.getStatus(context);
        fail();
    } catch (ResourceException ex) {
        int code = com.yahoo.athenz.common.server.rest.ResourceException.INTERNAL_SERVER_ERROR;
        String msg = com.yahoo.athenz.common.server.rest.ResourceException.symbolForCode(com.yahoo.athenz.zms.ResourceException.INTERNAL_SERVER_ERROR);
        assertEquals(new ResourceError().code(code).message(msg).toString(), ex.getData().toString());
    }
    System.setProperty(ZTSConsts.ZTS_PROP_STATUS_CHECKER_FACTORY_CLASS,
            MockStatusCheckerThrowException.NotFound.class.getName());
    ztsImpl = new ZTSImpl(mockCloudStore, store);
    ztsImpl.statusPort = 0;
    try {
        ztsImpl.getStatus(context);
        fail();
    } catch (ResourceException ex) {
        int code = com.yahoo.athenz.common.server.rest.ResourceException.NOT_FOUND;
        String msg = com.yahoo.athenz.common.server.rest.ResourceException.symbolForCode(com.yahoo.athenz.zms.ResourceException.NOT_FOUND);
        assertEquals(new ResourceError().code(code).message(msg).toString(), ex.getData().toString());
    }
    System.setProperty(ZTSConsts.ZTS_PROP_STATUS_CHECKER_FACTORY_CLASS,
            MockStatusCheckerThrowException.InternalServerErrorWithMessage.class.getName());
    ztsImpl = new ZTSImpl(mockCloudStore, store);
    ztsImpl.statusPort = 0;
    try {
        ztsImpl.getStatus(context);
        fail();
    } catch (ResourceException ex) {
        int code = com.yahoo.athenz.common.server.rest.ResourceException.INTERNAL_SERVER_ERROR;
        String msg = "error message";
        assertEquals(new ResourceError().code(code).message(msg).toString(), ex.getData().toString());
    }
    System.setProperty(ZTSConsts.ZTS_PROP_STATUS_CHECKER_FACTORY_CLASS,
            MockStatusCheckerThrowException.CauseRuntimeException.class.getName());
    ztsImpl = new ZTSImpl(mockCloudStore, store);
    ztsImpl.statusPort = 0;
    try {
        ztsImpl.getStatus(context);
        fail();
    } catch (ResourceException ex) {
        int code = com.yahoo.athenz.common.server.rest.ResourceException.INTERNAL_SERVER_ERROR;
        String msg = "runtime exception";
        assertEquals(new ResourceError().code(code).message(msg).toString(), ex.getData().toString());
    }
    System.clearProperty(ZTSConsts.ZTS_PROP_STATUS_CHECKER_FACTORY_CLASS);
}