-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactoring negative scenario for MIME types multiple deployment / deployment with subdeployments scenario new health version test JavaDoc
- Loading branch information
Showing
11 changed files
with
500 additions
and
17 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
15 changes: 15 additions & 0 deletions
15
...file-health/src/main/java/org/jboss/eap/qe/microprofile/health/SimplifiedHealthCheck.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,15 @@ | ||
package org.jboss.eap.qe.microprofile.health; | ||
|
||
import org.eclipse.microprofile.health.HealthCheck; | ||
import org.eclipse.microprofile.health.HealthCheckResponse; | ||
import org.eclipse.microprofile.health.Liveness; | ||
import org.eclipse.microprofile.health.Readiness; | ||
|
||
@Liveness | ||
@Readiness | ||
public class SimplifiedHealthCheck implements HealthCheck { | ||
@Override | ||
public HealthCheckResponse call() { | ||
return HealthCheckResponse.up("simplified"); | ||
} | ||
} |
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
163 changes: 163 additions & 0 deletions
163
...profile-health/src/test/java/org/jboss/eap/qe/microprofile/health/MimeTypeHealthTest.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,163 @@ | ||
package org.jboss.eap.qe.microprofile.health; | ||
|
||
import static org.hamcrest.Matchers.containsInAnyOrder; | ||
import static org.hamcrest.Matchers.containsString; | ||
import static org.hamcrest.Matchers.hasItems; | ||
import static org.hamcrest.Matchers.hasSize; | ||
import static org.hamcrest.Matchers.is; | ||
import static org.hamcrest.Matchers.not; | ||
|
||
import org.jboss.arquillian.container.test.api.Deployment; | ||
import org.jboss.arquillian.container.test.api.RunAsClient; | ||
import org.jboss.arquillian.junit.Arquillian; | ||
import org.jboss.as.arquillian.api.ContainerResource; | ||
import org.jboss.as.arquillian.container.ManagementClient; | ||
import org.jboss.shrinkwrap.api.Archive; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.asset.EmptyAsset; | ||
import org.jboss.shrinkwrap.api.spec.WebArchive; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import io.restassured.RestAssured; | ||
import io.restassured.http.ContentType; | ||
|
||
@RunAsClient | ||
@RunWith(Arquillian.class) | ||
public class MimeTypeHealthTest { | ||
|
||
@ContainerResource | ||
ManagementClient managementClient; | ||
|
||
String healthURL; | ||
|
||
@Before | ||
public void composeHealthEndpointURL() { | ||
healthURL = "http://" + managementClient.getMgmtAddress() + ":" + managementClient.getMgmtPort() + "/health"; | ||
} | ||
|
||
@Deployment(testable = false) | ||
public static Archive<?> deployment() { | ||
WebArchive war = ShrinkWrap.create(WebArchive.class, MimeTypeHealthTest.class.getSimpleName() + ".war") | ||
.addClasses(BothHealthCheck.class, LivenessHealthCheck.class, ReadinessHealthCheck.class) | ||
.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); | ||
return war; | ||
} | ||
|
||
/** | ||
* @tpTestDetails Negative scenario where health check contains customer data. Request accepts invalid MIME type | ||
* @tpPassCrit Overall and the health check status is up and checks contains expected data. | ||
* @tpSince EAP 7.3.0.CD19 | ||
*/ | ||
@Test | ||
public void testHealthXJSON() { | ||
test("application/x-json"); | ||
} | ||
|
||
/** | ||
* @tpTestDetails Negative scenario where health check contains customer data. Request accepts invalid MIME type | ||
* @tpPassCrit Overall and the health check status is up and checks contains expected data. | ||
* @tpSince EAP 7.3.0.CD19 | ||
*/ | ||
@Test | ||
public void testHealthJSONP() { | ||
test("application/json-p"); | ||
} | ||
|
||
/** | ||
* @tpTestDetails Negative scenario where health check contains customer data. Request accepts invalid MIME type | ||
* @tpPassCrit Overall and the health check status is up and checks contains expected data. | ||
* @tpSince EAP 7.3.0.CD19 | ||
*/ | ||
@Test | ||
public void testHealtTextPlain() { | ||
test("text/plain"); | ||
} | ||
|
||
/** | ||
* @tpTestDetails Negative scenario where health check contains customer data. Request accepts invalid MIME type | ||
* @tpPassCrit Overall and the health check status is up and checks contains expected data. | ||
* @tpSince EAP 7.3.0.CD19 | ||
*/ | ||
@Test | ||
public void testHealtTextCSV() { | ||
test("text/csv"); | ||
} | ||
|
||
/** | ||
* @tpTestDetails Negative scenario where health check contains customer data. Request accepts invalid MIME type | ||
* @tpPassCrit Overall and the health check status is up and checks contains expected data. | ||
* @tpSince EAP 7.3.0.CD19 | ||
*/ | ||
@Test | ||
public void testHealtModelVML() { | ||
test("model/vml"); | ||
} | ||
|
||
/** | ||
* @tpTestDetails Negative scenario where health check contains customer data. Request accepts invalid MIME type | ||
* @tpPassCrit Overall and the health check status is up and checks contains expected data. | ||
* @tpSince EAP 7.3.0.CD19 | ||
*/ | ||
@Test | ||
public void testHealtTextJSON() { | ||
test("text/json"); | ||
} | ||
|
||
private void test(String mimeType) { | ||
testHealthEndpoint(mimeType); | ||
testLiveEndpoint(mimeType); | ||
testReadyEndpoint(mimeType); | ||
} | ||
|
||
private void testHealthEndpoint(String mimeType) { | ||
RestAssured.given() | ||
.baseUri(healthURL) | ||
.accept(mimeType) | ||
.get() | ||
.then() | ||
.contentType(ContentType.JSON) | ||
.header("Content-Type", containsString("application/json")) | ||
.body("status", is("UP"), | ||
"checks", hasSize(4), // BothHealthCheck contains both annotations: @Liveness and @Readiness | ||
"checks.status", hasItems("UP"), | ||
"checks.status", not(hasItems("DOWN")), | ||
"checks.name", containsInAnyOrder("both", "live", "ready", "both"), | ||
"checks.data", hasSize(4), | ||
"checks.data[0].key", is("value"), | ||
"checks.data[0..3].key", hasItems("value")); | ||
} | ||
|
||
private void testLiveEndpoint(String mimeType) { | ||
RestAssured.given() | ||
.baseUri(healthURL + "/live") | ||
.accept(mimeType) | ||
.get() | ||
.then() | ||
.contentType(ContentType.JSON) | ||
.header("Content-Type", containsString("application/json")) | ||
.body("status", is("UP"), | ||
"checks", hasSize(2), | ||
"checks.status", hasItems("UP"), | ||
"checks.name", containsInAnyOrder("both", "live"), | ||
"checks.data", hasSize(2), | ||
"checks.data[0..1].key", hasItems("value")); | ||
} | ||
|
||
private void testReadyEndpoint(String mimeType) { | ||
RestAssured.given() | ||
.baseUri(healthURL + "/ready") | ||
.accept(mimeType) | ||
.get() | ||
.then() | ||
.contentType(ContentType.JSON) | ||
.header("Content-Type", containsString("application/json")) | ||
.body("status", is("UP"), | ||
"checks", hasSize(2), | ||
"checks.status", hasItems("UP"), | ||
"checks.name", containsInAnyOrder("both", "ready"), | ||
"checks.data", hasSize(2), | ||
"checks.data[0..1].key", hasItems("value")); | ||
} | ||
} |
Oops, something went wrong.