Package org.springframework.boot.actuate.health

Examples of org.springframework.boot.actuate.health.Health


    if (!this.delegate.isEnabled()) {
      // Shouldn't happen because the request mapping should not be registered
      return new ResponseEntity<Map<String, String>>(Collections.singletonMap(
          "message", "This endpoint is disabled"), HttpStatus.NOT_FOUND);
    }
    Health health = getHealth(principal);
    Status status = health.getStatus();
    if (this.statusMapping.containsKey(status.getCode())) {
      return new ResponseEntity<Health>(health, this.statusMapping.get(status
          .getCode()));
    }
    return health;
View Full Code Here


    }
    return health;
  }

  private Health getHealth(Principal principal) {
    Health health = (useCachedValue(principal) ? this.cached : (Health) this.delegate
        .invoke());
    // Not too worried about concurrent access here, the worst that can happen is the
    // odd extra call to delegate.invoke()
    this.cached = health;
    if (!secure(principal)) {
      // If not secure we only expose the status
      health = Health.status(health.getStatus()).build();
    }
    return health;
  }
View Full Code Here

    Object result = this.mvc.invoke(this.user);
    assertTrue(result instanceof Health);
    assertTrue(((Health) result).getStatus() == Status.UP);
    given(this.endpoint.invoke()).willReturn(new Health.Builder().down().build());
    result = this.mvc.invoke(this.user);
    @SuppressWarnings("unchecked")
    Health health = ((ResponseEntity<Health>) result).getBody();
    assertTrue(health.getStatus() == Status.DOWN);
  }
View Full Code Here

    Object result = this.mvc.invoke(this.user);
    assertTrue(result instanceof Health);
    assertTrue(((Health) result).getStatus() == Status.UP);
    given(this.endpoint.invoke()).willReturn(new Health.Builder().down().build());
    result = this.mvc.invoke(null); // insecure now
    Health health = (Health) result;
    // so the result is cached
    assertTrue(health.getStatus() == Status.UP);
  }
View Full Code Here

  public void healthEndpoint() {
    load(EmbeddedDataSourceConfiguration.class, EndpointAutoConfiguration.class,
        HealthIndicatorAutoConfiguration.class);
    HealthEndpoint bean = this.context.getBean(HealthEndpoint.class);
    assertNotNull(bean);
    Health result = bean.invoke();
    assertNotNull(result);
    assertTrue("Wrong result: " + result, result.getDetails().containsKey("db"));
  }
View Full Code Here

  @Test
  public void healthEndpointWithDefaultHealthIndicator() {
    load(EndpointAutoConfiguration.class, HealthIndicatorAutoConfiguration.class);
    HealthEndpoint bean = this.context.getBean(HealthEndpoint.class);
    assertNotNull(bean);
    Health result = bean.invoke();
    assertNotNull(result);
  }
View Full Code Here

TOP

Related Classes of org.springframework.boot.actuate.health.Health

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.