aboutsummaryrefslogtreecommitdiff
path: root/connector/src/test/java/at/asitplus/eidas/specific/connector/test/health/EidasNodeMetadataHealthIndicatorTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'connector/src/test/java/at/asitplus/eidas/specific/connector/test/health/EidasNodeMetadataHealthIndicatorTest.java')
-rw-r--r--connector/src/test/java/at/asitplus/eidas/specific/connector/test/health/EidasNodeMetadataHealthIndicatorTest.java102
1 files changed, 0 insertions, 102 deletions
diff --git a/connector/src/test/java/at/asitplus/eidas/specific/connector/test/health/EidasNodeMetadataHealthIndicatorTest.java b/connector/src/test/java/at/asitplus/eidas/specific/connector/test/health/EidasNodeMetadataHealthIndicatorTest.java
deleted file mode 100644
index b044d4d2..00000000
--- a/connector/src/test/java/at/asitplus/eidas/specific/connector/test/health/EidasNodeMetadataHealthIndicatorTest.java
+++ /dev/null
@@ -1,102 +0,0 @@
-package at.asitplus.eidas.specific.connector.test.health;
-
-import java.io.IOException;
-
-import org.apache.commons.io.IOUtils;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.actuate.health.Health;
-import org.springframework.http.MediaType;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import org.springframework.test.context.web.WebAppConfiguration;
-
-import at.asitplus.eidas.specific.connector.health.EidasNodeMetadataHealthIndicator;
-import okhttp3.mockwebserver.MockResponse;
-import okhttp3.mockwebserver.MockWebServer;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration({
- "/spring/SpringTest-context_healthcheck.xml" })
-@TestPropertySource(locations = {"classpath:/config/junit_config_1_springboot.properties"})
-@WebAppConfiguration
-public class EidasNodeMetadataHealthIndicatorTest {
-
- @Autowired EidasNodeMetadataHealthIndicator health;
-
- private static MockWebServer mockWebServer = null;
-
- /**
- * Testclass initializer.
- *
- * @throws IOException In case of an error
- */
- @BeforeClass
- public static void classInitializer() throws IOException {
- mockWebServer = new MockWebServer();
- mockWebServer.start(40900);
- mockWebServer.url("/mockup");
-
- }
-
- @AfterClass
- public static void resetTestEnviroment() throws NoSuchFieldException, SecurityException,
- IllegalArgumentException, IllegalAccessException, IOException {
- mockWebServer.shutdown();
-
- }
-
- @Test
- public void httpStatusCode500() throws IOException {
- //set-up status
- mockWebServer.enqueue(new MockResponse().setResponseCode(500)
- .setBody(IOUtils.toString(EidasNodeMetadataHealthIndicatorTest.class
- .getResourceAsStream("/data/metadata_valid.xml"), "UTF-8"))
- .setHeader("Content-Type", MediaType.APPLICATION_XML));
-
- //perform test
- Health status = health.health();
-
- //validate state
- Assert.assertEquals("wrong healthState", Health.down().build().getStatus(), status.getStatus());
-
- }
-
- @Test
- public void httpStatusCode200() throws IOException {
- //set-up status
- mockWebServer.enqueue(new MockResponse().setResponseCode(200)
- .setBody(IOUtils.toString(EidasNodeMetadataHealthIndicatorTest.class
- .getResourceAsStream("/data/metadata_valid.xml"), "UTF-8"))
- .setHeader("Content-Type", MediaType.APPLICATION_XML));
-
- //perform test
- Health status = health.health();
-
- //validate state
- Assert.assertEquals("wrong healthState", Health.up().build().getStatus(), status.getStatus());
-
- }
-
- @Test
- public void noXmlResponse() throws IOException {
- //set-up status
- mockWebServer.enqueue(new MockResponse().setResponseCode(200)
- .setBody(IOUtils.toString(EidasNodeMetadataHealthIndicatorTest.class
- .getResourceAsStream("/config/log4j.properties"), "UTF-8"))
- .setHeader("Content-Type", MediaType.APPLICATION_XML));
-
- //perform test
- Health status = health.health();
-
- //validate state
- Assert.assertEquals("wrong healthState", Health.down().build().getStatus(), status.getStatus());
-
- }
-
-}