details: https://code.openbravo.com/erp/devel/pi/rev/1500d4535914 changeset: 35038:1500d4535914 user: Javier Armendáriz <javier.armendariz <at> openbravo.com> date: Mon Nov 19 17:45:01 2018 +0100 summary: Related to issue 39504: Adjusted test case that fails after automatic migration.
Logger were referenced using its full qualified name and the migration script didn't notice that. So we're calling a new class in an incorrect package. diffstat: src-test/src/org/openbravo/test/dal/ADCachedMultiThreadTest.java | 31 ++++++++- src/org/openbravo/service/importprocess/ImportProcessUtils.java | 1 - 2 files changed, 25 insertions(+), 7 deletions(-) diffs (74 lines): diff -r 2e096148d8cb -r 1500d4535914 src-test/src/org/openbravo/test/dal/ADCachedMultiThreadTest.java --- a/src-test/src/org/openbravo/test/dal/ADCachedMultiThreadTest.java Mon Nov 19 11:03:46 2018 +0100 +++ b/src-test/src/org/openbravo/test/dal/ADCachedMultiThreadTest.java Mon Nov 19 17:45:01 2018 +0100 @@ -33,7 +33,12 @@ import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; -import org.apache.log4j.Level; +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.core.LoggerContext; +import org.apache.logging.log4j.core.config.Configuration; +import org.apache.logging.log4j.core.config.LoggerConfig; import org.hibernate.LazyInitializationException; import org.hibernate.query.Query; import org.junit.Test; @@ -45,8 +50,6 @@ import org.openbravo.model.ad.ui.Tab; import org.openbravo.test.base.HiddenObjectHelper; import org.openbravo.test.base.OBBaseTest; -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.LogManager; /** * Test cases to verify multiple ApplicationDictionaryCachedStructures behavior when working @@ -154,9 +157,9 @@ @Test public void testPropertyColumn() throws Exception { // Expecting LazyInitializationException, disabling log not to display it - org.apache.log4j.Logger category = org.apache.log4j.LogManager.getLogger(); + Logger category = LogManager.getLogger(); Level originalLevel = category.getLevel(); - category.setLevel(Level.FATAL); + setLoggerLevel(category, Level.FATAL); log.debug(" session id: {}", Integer.toString(System.identityHashCode(OBDal.getInstance().getSession()))); @@ -202,7 +205,23 @@ } } assertFalse("There are propeties that failed", failed); - category.setLevel(originalLevel); + setLoggerLevel(category, originalLevel); + } + + private void setLoggerLevel(Logger logger, Level level) { + final LoggerContext context = LoggerContext.getContext(false); + final Configuration config = context.getConfiguration(); + + LoggerConfig loggerConfig = config.getLoggerConfig(logger.getName()); + + LoggerConfig specificConfig = loggerConfig; + String loggerName = logger.getName(); + if (!loggerConfig.getName().equals(loggerName)) { + specificConfig = new LoggerConfig(loggerName, level, true); + specificConfig.setParent(loggerConfig); + config.addLogger(loggerName, specificConfig); + } + specificConfig.setLevel(level); } private void executeTestMultiCalls(boolean cache) throws Exception { diff -r 2e096148d8cb -r 1500d4535914 src/org/openbravo/service/importprocess/ImportProcessUtils.java --- a/src/org/openbravo/service/importprocess/ImportProcessUtils.java Mon Nov 19 11:03:46 2018 +0100 +++ b/src/org/openbravo/service/importprocess/ImportProcessUtils.java Mon Nov 19 17:45:01 2018 +0100 @@ -25,7 +25,6 @@ import java.util.Comparator; import java.util.List; -import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.codehaus.jettison.json.JSONArray; import org.codehaus.jettison.json.JSONException; _______________________________________________ Openbravo-commits mailing list Openbravo-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbravo-commits