Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.springframework.boot.actuate.endpoint.web.annotation.EndpointWebExtension;
import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.HealthWebEndpointResponseMapper;
import org.springframework.boot.actuate.health.ShowDetails;

/**
* @author qilong.zql
Expand All @@ -39,7 +40,7 @@ public class ReadinessEndpointWebExtension {

@ReadOperation
public WebEndpointResponse<Health> getHealth(SecurityContext securityContext) {
return this.responseMapper.map(this.delegate.health(), securityContext);
return this.responseMapper.map(this.delegate.health(), securityContext, ShowDetails.ALWAYS);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import com.alipay.sofa.healthcheck.base.SofaBootTestApplication;
import com.alipay.sofa.healthcheck.service.SofaBootReadinessCheckEndpoint;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -27,7 +28,6 @@
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.util.Assert;

/**
* @author qilong.zql
Expand All @@ -44,17 +44,20 @@ public class HealthEndpointDefaultConfigurationTest {
private TestRestTemplate restTemplate;

@Test
public void testReadinessCheckSuccessHttpCode() {
public void testReadinessCheckSuccess() {
ResponseEntity<String> response = restTemplate.getForEntity("/actuator/readiness",
String.class);
org.junit.Assert.assertEquals(HttpStatus.OK, response.getStatusCode());
Assert.assertEquals(HttpStatus.OK, response.getStatusCode());
Assert.assertNotNull(response.getBody());
Assert.assertTrue(response.getBody().contains(
"\"details\":{\"SOFABootReadinessHealthCheckInfo\":{\"status\":\"UP\"}"));
}

@Test
public void test() {
SofaBootReadinessCheckEndpoint sofaBootReadinessCheckEndpoint = ctx
.getBean(SofaBootReadinessCheckEndpoint.class);
Assert.notNull(sofaBootReadinessCheckEndpoint);
Assert.assertNotNull(sofaBootReadinessCheckEndpoint);
}

}