aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Lenz <thomas.lenz@egiz.gv.at>2021-01-27 11:19:29 +0100
committerThomas Lenz <thomas.lenz@egiz.gv.at>2021-01-27 11:19:29 +0100
commit0b703512f08bfc1cda18e6688c39fdc536045fdd (patch)
tree10c1ee7aa9b4dd98b97b21502bcee013eb4a0f9f
parente36aedb5b1acd1b985d09acb818f1f85175cb826 (diff)
downloadNational_eIDAS_Gateway-0b703512f08bfc1cda18e6688c39fdc536045fdd.tar.gz
National_eIDAS_Gateway-0b703512f08bfc1cda18e6688c39fdc536045fdd.tar.bz2
National_eIDAS_Gateway-0b703512f08bfc1cda18e6688c39fdc536045fdd.zip
fix problem in jUnit tests that depends on static Apache-Ignite holder in eIDAS Ref. implementation and occurin case of a start-up error
-rw-r--r--connector/src/test/java/at/asitplus/eidas/specific/connector/test/FullStartUpAndProcessTest.java12
-rw-r--r--connector/src/test/java/at/asitplus/eidas/specific/connector/test/MainClassExecutableModeTest.java10
-rw-r--r--connector/src/test/java/at/asitplus/eidas/specific/connector/test/MainClassWebAppModeTest.java7
3 files changed, 25 insertions, 4 deletions
diff --git a/connector/src/test/java/at/asitplus/eidas/specific/connector/test/FullStartUpAndProcessTest.java b/connector/src/test/java/at/asitplus/eidas/specific/connector/test/FullStartUpAndProcessTest.java
index 77037415..fcb0e73a 100644
--- a/connector/src/test/java/at/asitplus/eidas/specific/connector/test/FullStartUpAndProcessTest.java
+++ b/connector/src/test/java/at/asitplus/eidas/specific/connector/test/FullStartUpAndProcessTest.java
@@ -6,6 +6,7 @@ import static org.powermock.api.mockito.PowerMockito.when;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
+import java.lang.reflect.Field;
import java.net.URISyntaxException;
import java.util.Map;
import java.util.Timer;
@@ -71,6 +72,7 @@ import at.gv.egiz.eaaf.modules.pvp2.impl.opensaml.OpenSaml3ResourceAdapter;
import at.gv.egiz.eaaf.modules.pvp2.impl.opensaml.initialize.EaafOpenSaml3xInitializer;
import at.gv.egiz.eaaf.modules.pvp2.impl.utils.Saml2Utils;
import at.gv.egiz.eaaf.modules.pvp2.sp.impl.utils.AssertionAttributeExtractor;
+import eu.eidas.auth.cache.IgniteInstanceInitializerSpecificCommunication;
import eu.eidas.auth.commons.attribute.AttributeDefinition;
import eu.eidas.auth.commons.attribute.ImmutableAttributeMap;
import eu.eidas.auth.commons.light.ILightRequest;
@@ -151,13 +153,19 @@ public class FullStartUpAndProcessTest {
/**
* Test shut-down.
*
- * @throws IOException In case of an error
+ * @throws Exception In case of an error
*/
@AfterClass
- public static void closeIgniteNode() throws IOException {
+ public static void closeIgniteNode() throws Exception {
System.out.println("Closiong Ignite Node ... ");
Ignition.stopAll(true);
+
+ //set Ignite-node holder to 'null' because static holders are shared between different tests
+ final Field field = IgniteInstanceInitializerSpecificCommunication.class.getDeclaredField("instance");
+ field.setAccessible(true);
+ field.set(null, null);
+
}
/**
diff --git a/connector/src/test/java/at/asitplus/eidas/specific/connector/test/MainClassExecutableModeTest.java b/connector/src/test/java/at/asitplus/eidas/specific/connector/test/MainClassExecutableModeTest.java
index 86df55df..708560b2 100644
--- a/connector/src/test/java/at/asitplus/eidas/specific/connector/test/MainClassExecutableModeTest.java
+++ b/connector/src/test/java/at/asitplus/eidas/specific/connector/test/MainClassExecutableModeTest.java
@@ -22,6 +22,7 @@ import org.junit.runners.BlockJUnit4ClassRunner;
import at.asitplus.eidas.specific.connector.SpringBootApplicationInitializer;
import at.gv.egiz.eaaf.core.impl.logging.DummyStatusMessager;
import at.gv.egiz.eaaf.core.impl.logging.LogMessageProviderFactory;
+import eu.eidas.auth.cache.IgniteInstanceInitializerSpecificCommunication;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@@ -50,17 +51,22 @@ public class MainClassExecutableModeTest {
/**
* Initializer.
- * @throws InterruptedException In case of an error
+ * @throws Exception In case of an error
*
*/
@AfterClass
- public static void closeIgniteNode() throws InterruptedException {
+ public static void closeIgniteNode() throws Exception {
System.out.println("Closing Ignite Node ... ");
log.info("Stopping already running Apache Ignite nodes ... ");
Ignition.stopAll(true);
Thread.sleep(1000);
+ //set Ignite-node holder to 'null' because static holders are shared between different tests
+ final Field field = IgniteInstanceInitializerSpecificCommunication.class.getDeclaredField("instance");
+ field.setAccessible(true);
+ field.set(null, null);
+
}
/**
diff --git a/connector/src/test/java/at/asitplus/eidas/specific/connector/test/MainClassWebAppModeTest.java b/connector/src/test/java/at/asitplus/eidas/specific/connector/test/MainClassWebAppModeTest.java
index 07ef4968..79d062ae 100644
--- a/connector/src/test/java/at/asitplus/eidas/specific/connector/test/MainClassWebAppModeTest.java
+++ b/connector/src/test/java/at/asitplus/eidas/specific/connector/test/MainClassWebAppModeTest.java
@@ -22,6 +22,7 @@ import org.junit.runners.BlockJUnit4ClassRunner;
import at.asitplus.eidas.specific.connector.SpringBootApplicationInitializer;
import at.gv.egiz.eaaf.core.impl.logging.DummyStatusMessager;
import at.gv.egiz.eaaf.core.impl.logging.LogMessageProviderFactory;
+import eu.eidas.auth.cache.IgniteInstanceInitializerSpecificCommunication;
@RunWith(BlockJUnit4ClassRunner.class)
public class MainClassWebAppModeTest {
@@ -68,6 +69,12 @@ public class MainClassWebAppModeTest {
System.clearProperty("eidas.ms.configuration");
SpringBootApplicationInitializer.exit();
+
+
+ //set Ignite-node holder to 'null' because static holders are shared between different tests
+ final Field field1 = IgniteInstanceInitializerSpecificCommunication.class.getDeclaredField("instance");
+ field1.setAccessible(true);
+ field1.set(null, null);
}