|
|
@ -1,5 +1,5 @@
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Copyright 2012-2014 the original author or authors.
|
|
|
|
* Copyright 2012-2015 the original author or authors.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
@ -44,6 +44,7 @@ import static org.mockito.Mockito.mock;
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @author Christian Dupuis
|
|
|
|
* @author Christian Dupuis
|
|
|
|
* @author Dave Syer
|
|
|
|
* @author Dave Syer
|
|
|
|
|
|
|
|
* @author Andy Wilkinson
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public class HealthMvcEndpointTests {
|
|
|
|
public class HealthMvcEndpointTests {
|
|
|
|
|
|
|
|
|
|
|
@ -115,23 +116,7 @@ public class HealthMvcEndpointTests {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void secureNotCached() {
|
|
|
|
public void healthIsCached() {
|
|
|
|
given(this.endpoint.getTimeToLive()).willReturn(10000L);
|
|
|
|
|
|
|
|
given(this.endpoint.isSensitive()).willReturn(false);
|
|
|
|
|
|
|
|
given(this.endpoint.invoke()).willReturn(
|
|
|
|
|
|
|
|
new Health.Builder().up().withDetail("foo", "bar").build());
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
public void unsecureCached() {
|
|
|
|
|
|
|
|
given(this.endpoint.getTimeToLive()).willReturn(10000L);
|
|
|
|
given(this.endpoint.getTimeToLive()).willReturn(10000L);
|
|
|
|
given(this.endpoint.isSensitive()).willReturn(true);
|
|
|
|
given(this.endpoint.isSensitive()).willReturn(true);
|
|
|
|
given(this.endpoint.invoke()).willReturn(
|
|
|
|
given(this.endpoint.invoke()).willReturn(
|
|
|
@ -164,9 +149,8 @@ public class HealthMvcEndpointTests {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void unsecureIsNotCachedWhenAnonymousAccessIsUnrestricted() {
|
|
|
|
public void noCachingWhenTimeToLiveIsZero() {
|
|
|
|
this.environment.getPropertySources().addLast(NON_SENSITIVE);
|
|
|
|
given(this.endpoint.getTimeToLive()).willReturn(0L);
|
|
|
|
given(this.endpoint.getTimeToLive()).willReturn(10000L);
|
|
|
|
|
|
|
|
given(this.endpoint.invoke()).willReturn(
|
|
|
|
given(this.endpoint.invoke()).willReturn(
|
|
|
|
new Health.Builder().up().withDetail("foo", "bar").build());
|
|
|
|
new Health.Builder().up().withDetail("foo", "bar").build());
|
|
|
|
Object result = this.mvc.invoke(null);
|
|
|
|
Object result = this.mvc.invoke(null);
|
|
|
|