diff --git a/bridgeService-data/pom.xml b/bridgeService-data/pom.xml
index dd21c4f9..a056f6c3 100644
--- a/bridgeService-data/pom.xml
+++ b/bridgeService-data/pom.xml
@@ -19,6 +19,18 @@
true
+
+
+ org.apache.logging.log4j
+ log4j-core
+ 2.20.0
+
+
+ org.apache.logging.log4j
+ log4j-api
+ 2.20.0
+
+
com.adobe.campaign.tests.bridge
parent
diff --git a/bridgeService-data/src/main/java/com/adobe/campaign/tests/bridge/testdata/one/ClassWithLogger.java b/bridgeService-data/src/main/java/com/adobe/campaign/tests/bridge/testdata/one/ClassWithLogger.java
new file mode 100644
index 00000000..943549bd
--- /dev/null
+++ b/bridgeService-data/src/main/java/com/adobe/campaign/tests/bridge/testdata/one/ClassWithLogger.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2022 Adobe
+ * All Rights Reserved.
+ *
+ * NOTICE: Adobe permits you to use, modify, and distribute this file in
+ * accordance with the terms of the Adobe license agreement accompanying
+ * it.
+ */
+package com.adobe.campaign.tests.bridge.testdata.one;
+
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Random;
+
+public class ClassWithLogger {
+ protected static Logger log = LogManager.getLogger();
+
+
+
+ private static final List countries = Arrays.asList("AT", "AU",
+ "CA", "CH", "DE");
+
+ private static Random randomGen = new Random();
+
+ /**
+ * A getter for the Language Encodings
+ * @return
+ *
+
+ public static LanguageEncodings getLanguageEncoding(){
+ return languageEncoding;
+ }
+ */
+ public static List getCountries() {
+ return countries;
+ }
+
+
+
+ public static Random getRandomGen() {
+ return randomGen;
+ }
+
+
+ /**
+ * This method returns a random country ISOA2 code.
+ *
+ * @return ISOA2 country code
+ *
+ * @author lepolles
+ */
+ public static String fetchRandomCountry() {
+ int l_countryNr = countries.size();
+
+ return countries.get(getRandomGen().nextInt(l_countryNr));
+ }
+
+}
diff --git a/integroBridgeService/pom.xml b/integroBridgeService/pom.xml
index 7a05bdf1..a97847c7 100644
--- a/integroBridgeService/pom.xml
+++ b/integroBridgeService/pom.xml
@@ -49,6 +49,7 @@
org.apache.maven.plugins
maven-assembly-plugin
+ 3.6.0
diff --git a/integroBridgeService/src/main/java/com/adobe/campaign/tests/bridge/service/ConfigValueHandlerIBS.java b/integroBridgeService/src/main/java/com/adobe/campaign/tests/bridge/service/ConfigValueHandlerIBS.java
index 070dd5d9..1f90b960 100644
--- a/integroBridgeService/src/main/java/com/adobe/campaign/tests/bridge/service/ConfigValueHandlerIBS.java
+++ b/integroBridgeService/src/main/java/com/adobe/campaign/tests/bridge/service/ConfigValueHandlerIBS.java
@@ -46,11 +46,11 @@ public enum ConfigValueHandlerIBS {
"IBS.CLASSLOADER.INTEGRITY.MODE","semi-manual", false,
"This value defined the injection mode of packages and classes. We have three modes: automatic, manual, semi-automatic"),*/
INTEGRITY_PACKAGE_INJECTION_MODE(
- "IBS.CLASSLOADER.INTEGRITY.MODE","semi-manual", false,
+ "IBS.CLASSLOADER.INTEGRITY.MODE","automatic", false,
"This value defined the injection mode of packages and classes. We have three modes: automatic, manual, semi-automatic") {
public void activate(String in_value) {
//Use default if value is not in range
- if (Arrays.asList("manual","semi-manual").contains(in_value.toLowerCase())) {
+ if (Arrays.asList("manual","semi-manual","automatic").contains(in_value.toLowerCase())) {
System.setProperty(this.systemName, in_value);
}
}
diff --git a/integroBridgeService/src/main/java/com/adobe/campaign/tests/bridge/service/IntegroBridgeClassLoader.java b/integroBridgeService/src/main/java/com/adobe/campaign/tests/bridge/service/IntegroBridgeClassLoader.java
index 47d9cc42..2cf93162 100644
--- a/integroBridgeService/src/main/java/com/adobe/campaign/tests/bridge/service/IntegroBridgeClassLoader.java
+++ b/integroBridgeService/src/main/java/com/adobe/campaign/tests/bridge/service/IntegroBridgeClassLoader.java
@@ -47,10 +47,10 @@ private synchronized Class getClass(String in_classPath) throws ClassNotFoundEx
// is this class already loaded?
Class cls = super.findLoadedClass(in_classPath);
if (cls != null) {
- log.debug("Class {} has already been loaded.",in_classPath);
+ log.trace("Class {} has already been loaded.",in_classPath);
return cls;
} else {
- log.debug("Class {} has not been loaded. Loading now.", in_classPath);
+ log.trace("Class {} has not been loaded. Loading now.", in_classPath);
}
@@ -90,18 +90,18 @@ private synchronized Class getClass(String in_classPath) throws ClassNotFoundEx
*/
@Override
public Class loadClass(String in_classFullPath) throws ClassNotFoundException {
- log.debug("Preparing class {}", in_classFullPath);
+ log.trace("Preparing class {}", in_classFullPath);
if (ConfigValueHandlerIBS.INTEGRITY_PACKAGE_INJECTION_MODE.is("manual", "semi-manual")) {
if (isClassAmongPackagePaths(in_classFullPath)) {
return getClass(in_classFullPath);
}
}
- /* Removing until issue ##5 is resolved
+ /* Removing until issue #45 is resolved*/
else if (!in_classFullPath.startsWith("java")) {
return getClass(in_classFullPath);
}
- */
+
return super.loadClass(in_classFullPath);
}
diff --git a/integroBridgeService/src/main/resources/log4j2.xml b/integroBridgeService/src/main/resources/log4j2.xml
index 6eb84067..1931be23 100644
--- a/integroBridgeService/src/main/resources/log4j2.xml
+++ b/integroBridgeService/src/main/resources/log4j2.xml
@@ -24,7 +24,7 @@
-
+
diff --git a/integroBridgeService/src/test/java/com/adobe/campaign/tests/bridge/service/E2ETests.java b/integroBridgeService/src/test/java/com/adobe/campaign/tests/bridge/service/E2ETests.java
index 5e631ecb..dae4d476 100644
--- a/integroBridgeService/src/test/java/com/adobe/campaign/tests/bridge/service/E2ETests.java
+++ b/integroBridgeService/src/test/java/com/adobe/campaign/tests/bridge/service/E2ETests.java
@@ -31,7 +31,6 @@
public class E2ETests {
public static final String EndPointURL = "http://localhost:8080/";
private static final int port1 = 1111;
- protected static final boolean AUTOMATIC_FLAG = false;
ServerSocket serverSocket1 = null;
@BeforeGroups(groups = "E2E")
@@ -466,7 +465,7 @@ public void testIssue34Manual() {
}
- @Test(groups = "E2E", enabled = AUTOMATIC_FLAG)
+ @Test(groups = "E2E")
public void testIssue34Automatic() {
//long before = MemoryTools.fetchMemory();
ConfigValueHandlerIBS.INTEGRITY_PACKAGE_INJECTION_MODE.activate("automatic");
@@ -552,15 +551,23 @@ public void testIntegroIssue() {
JavaCalls l_myJavaCalls = new JavaCalls();
CallContent l_cc = new CallContent();
- l_cc.setClassName("com.adobe.campaign.tests.integro.tools.RandomManager");
+
+ l_cc.setClassName("com.adobe.campaign.tests.bridge.testdata.one.ClassWithLogger");
l_cc.setMethodName("fetchRandomCountry");
l_myJavaCalls.getCallContent().put("countries", l_cc);
System.out.println(given().body(l_myJavaCalls).post(EndPointURL + "call").then().extract().asPrettyString());
+
+ given().body(l_myJavaCalls).post(EndPointURL + "call").then().assertThat().statusCode(500).body("originalException", Matchers.equalTo(
+ "java.lang.IllegalAccessError")).body("originalMessage", Matchers.equalTo("class jdk.internal.reflect.ConstructorAccessorImpl loaded by com.adobe.campaign.tests.bridge.service.IntegroBridgeClassLoader @2a8337ef cannot access jdk/internal/reflect superclass jdk.internal.reflect.MagicAccessorImpl"));
+
+ given().body(l_myJavaCalls).post(EndPointURL + "call").then().assertThat().statusCode(200).body("returnValues.countries", Matchers.in(
+ new String[] { "AT", "AU", "CA" , "CH", "DE"}));
}
+
@AfterGroups(groups = "E2E", alwaysRun = true)
public void tearDown() throws IOException {
ConfigValueHandlerIBS.resetAllValues();
diff --git a/integroBridgeService/src/test/java/com/adobe/campaign/tests/bridge/service/IBSClassLoaderTests.java b/integroBridgeService/src/test/java/com/adobe/campaign/tests/bridge/service/IBSClassLoaderTests.java
index 0804c5d5..79910b7a 100644
--- a/integroBridgeService/src/test/java/com/adobe/campaign/tests/bridge/service/IBSClassLoaderTests.java
+++ b/integroBridgeService/src/test/java/com/adobe/campaign/tests/bridge/service/IBSClassLoaderTests.java
@@ -11,11 +11,8 @@
import com.adobe.campaign.tests.bridge.service.data.MyPropertiesHandler;
import com.adobe.campaign.tests.bridge.service.exceptions.ClassLoaderConflictException;
import com.adobe.campaign.tests.bridge.service.exceptions.IBSConfigurationException;
-import com.adobe.campaign.tests.bridge.testdata.issue34.pckg1.CalledClass1;
-import com.adobe.campaign.tests.bridge.testdata.issue34.pckg1.CalledClass2;
import com.adobe.campaign.tests.bridge.testdata.one.EnvironmentVariableHandler;
import org.hamcrest.Matchers;
-import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -131,7 +128,7 @@ public void testsearchClass_negativeNonexistantClassManual2_usingJavaClass() thr
}
- @Test(enabled = E2ETests.AUTOMATIC_FLAG)
+ @Test
public void testIssue34AutomaticLoading() {
ConfigValueHandlerIBS.INTEGRITY_PACKAGE_INJECTION_MODE.activate("automatic");
JavaCalls l_myJavaCalls = new JavaCalls();
@@ -174,12 +171,14 @@ public void testIssue34AutomaticLoading_negativeDefaultBehavior() {
l_cc2.setMethodName("calledMethod");
l_myJavaCalls.getCallContent().put("call2", l_cc2);
- Assert.assertThrows(IBSConfigurationException.class, () -> l_myJavaCalls.submitCalls());
- /* Related to issue #55
+ //Assert.assertThrows(IBSConfigurationException.class, () -> l_myJavaCalls.submitCalls());
+ //#43
+ l_myJavaCalls.submitCalls();
+
assertThat("The called class should be loaded.", l_myJavaCalls.getLocalClassLoader().isClassLoaded("com.adobe.campaign.tests.bridge.testdata.issue34.pckg1.CalledClass1"));
assertThat("The MiddleMan class should be loaded.", l_myJavaCalls.getLocalClassLoader().isClassLoaded("com.adobe.campaign.tests.bridge.testdata.issue34.pckg1.MiddleMan"));
assertThat("The MiddleManFactory class should be loaded.", l_myJavaCalls.getLocalClassLoader().isClassLoaded("com.adobe.campaign.tests.bridge.testdata.issue34.pckg2.MiddleManClassFactory"));
- */
+
}
@Test