-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
168 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
example-context/example-service/example-healthcheck/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>example-service</artifactId> | ||
<groupId>uk.gov.justice.services.example</groupId> | ||
<version>11.0.0-M1-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>example-healthcheck</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>javax</groupId> | ||
<artifactId>javaee-api</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>uk.gov.justice.services</groupId> | ||
<artifactId>framework-healthcheck</artifactId> | ||
<version>${framework.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>uk.gov.justice.event-store</groupId> | ||
<artifactId>healthchecks</artifactId> | ||
<version>${event-store.version}</version> | ||
</dependency> | ||
|
||
<!-- Test Dependencies --> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.mockito</groupId> | ||
<artifactId>mockito-core</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.hamcrest</groupId> | ||
<artifactId>hamcrest-library</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
22 changes: 22 additions & 0 deletions
22
...ustice/services/example/cakeshop/healthcheck/CakeShopIgnoredHealthcheckNamesProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package uk.gov.justice.services.example.cakeshop.healthcheck; | ||
|
||
import static java.util.Collections.singletonList; | ||
import static uk.gov.justice.services.healthcheck.healthchecks.JobStoreHealthcheck.JOB_STORE_HEALTHCHECK_NAME; | ||
|
||
import uk.gov.justice.services.healthcheck.api.DefaultIgnoredHealthcheckNamesProvider; | ||
import uk.gov.justice.services.healthcheck.healthchecks.JobStoreHealthcheck; | ||
|
||
import java.util.List; | ||
|
||
import javax.enterprise.inject.Specializes; | ||
|
||
@Specializes | ||
public class CakeShopIgnoredHealthcheckNamesProvider extends DefaultIgnoredHealthcheckNamesProvider { | ||
|
||
public CakeShopIgnoredHealthcheckNamesProvider() {} | ||
|
||
@Override | ||
public List<String> getNamesOfIgnoredHealthChecks() { | ||
return singletonList(JOB_STORE_HEALTHCHECK_NAME); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
example-context/example-service/example-healthcheck/src/main/resources/META-INF/beans.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<!-- Marker file indicating CDI should be enabled --> | ||
|
||
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns="http://xmlns.jcp.org/xml/ns/javaee" | ||
xsi:schemaLocation=" | ||
http://xmlns.jcp.org/xml/ns/javaee | ||
http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd" bean-discovery-mode="all"> | ||
</beans> |
28 changes: 28 additions & 0 deletions
28
...ce/services/example/cakeshop/healthcheck/CakeShopIgnoredHealthcheckNamesProviderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package uk.gov.justice.services.example.cakeshop.healthcheck; | ||
|
||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static uk.gov.justice.services.healthcheck.healthchecks.JobStoreHealthcheck.JOB_STORE_HEALTHCHECK_NAME; | ||
|
||
import java.util.List; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.runners.MockitoJUnitRunner; | ||
|
||
@RunWith(MockitoJUnitRunner.class) | ||
public class CakeShopIgnoredHealthcheckNamesProviderTest { | ||
|
||
@InjectMocks | ||
private CakeShopIgnoredHealthcheckNamesProvider ignoredHealthcheckNamesProvider; | ||
|
||
@Test | ||
public void shouldGetListOfAllHealthchecksToIgnore() throws Exception { | ||
|
||
final List<String> ignoredHealthChecks = ignoredHealthcheckNamesProvider.getNamesOfIgnoredHealthChecks(); | ||
|
||
assertThat(ignoredHealthChecks.size(), is(1)); | ||
assertThat(ignoredHealthChecks.get(0), is(JOB_STORE_HEALTHCHECK_NAME)); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...e/example-it/src/test/java/uk/gov/justice/services/example/cakeshop/it/HealthcheckIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package uk.gov.justice.services.example.cakeshop.it; | ||
|
||
import static com.jayway.jsonassert.JsonAssert.with; | ||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static uk.gov.justice.services.example.cakeshop.it.params.CakeShopUris.HEALTHCHECK_URI; | ||
|
||
import uk.gov.justice.services.example.cakeshop.it.helpers.RestEasyClientFactory; | ||
|
||
import javax.ws.rs.client.Client; | ||
import javax.ws.rs.core.Response; | ||
|
||
import org.junit.Test; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class HealthcheckIT { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(HealthcheckIT.class); | ||
|
||
private final Client client = new RestEasyClientFactory().createResteasyClient(); | ||
|
||
@Test | ||
public void shouldSuccessfullyCallHealthcheckServlet() throws Exception { | ||
|
||
final String healthcheckUri = HEALTHCHECK_URI; | ||
|
||
LOGGER.info("Making request to '" + healthcheckUri + "'"); | ||
final Response response = client.target(healthcheckUri) | ||
.request() | ||
.get(); | ||
|
||
final String healthcheckJson = response.readEntity(String.class); | ||
LOGGER.info(healthcheckJson); | ||
|
||
assertThat(response.getStatus(), is(200)); | ||
with(healthcheckJson).assertThat("$.allHealthchecksPassed", is(true)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters