Skip to content

Commit

Permalink
[WFCORE-4553] Enabled the JBoss Log Manager embedded tests for the IB…
Browse files Browse the repository at this point in the history
…M JVM. Also fix a minor file name issue with the host controller tests.
  • Loading branch information
jamezp committed Jul 8, 2019
1 parent aefc1d2 commit 1bc4782
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import java.util.concurrent.TimeoutException;
import java.util.function.Function;

import org.jboss.as.test.shared.TestSuiteEnvironment;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
Expand Down Expand Up @@ -160,6 +161,12 @@ private void test(final EmbeddedManagedProcess server, final String filename, fi
}
} finally {
server.stop();
// We want to delete the log file in case another test checks for the same file. However on Windows the
// log manager would still have the file open and the delete will fail. For Windows we need to ignore the
// deleting the file to avoid the file lock failure.
if (!TestSuiteEnvironment.isWindows()) {
Files.deleteIfExists(logFile);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@

package org.wildfly.core.test.embedded.host.controller;

import org.junit.Assume;
import java.io.InputStream;
import java.util.logging.LogManager;

import org.junit.Assert;
import org.junit.Test;
import org.wildfly.core.embedded.Configuration;
import org.wildfly.core.test.embedded.LoggingTestCase;
Expand All @@ -32,12 +35,17 @@ public class JBossLogManagerHostControllerTestCase extends LoggingTestCase {

@Test
public void testLogManager() throws Exception {
// The IBM JDK creates a logger early on doesn't allow the JBoss Log Manager to be used. For now we will ignore
// the test when the IBM JDK is being used.
Assume.assumeFalse(isIbmJdk());
System.setProperty("test.log.file", "test-standalone-jbl.log");
System.setProperty("logging.configuration", getClass().getResource("/logging.properties").toExternalForm());
System.setProperty("test.log.file", "test-hc-jbl.log");
// The IBM JVM creates a logger early on and requires the log manager to be reconfigured
if (isIbmJdk()) {
// We need to reconfigure logging as the log manager is likely already setup
try (InputStream in = getClass().getResourceAsStream("/jbl-logging.properties")) {
Assert.assertNotNull("Failed to find the logging.properties file", in);
LogManager.getLogManager().readConfiguration(in);
}
}
System.setProperty("logging.configuration", getClass().getResource("/jbl-logging.properties").toExternalForm());
System.setProperty("java.util.logging.manager", "org.jboss.logmanager.LogManager");
testHostController(Configuration.LoggerHint.JBOSS_LOG_MANAGER, "test-standalone-jbl.log", "[jboss-logmanager]");
testHostController(Configuration.LoggerHint.JBOSS_LOG_MANAGER, "test-hc-jbl.log", "[jboss-logmanager]");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@

package org.wildfly.core.test.embedded.standalone;

import org.junit.Assume;
import java.io.InputStream;
import java.util.logging.LogManager;

import org.junit.Assert;
import org.junit.Test;
import org.wildfly.core.embedded.Configuration;
import org.wildfly.core.test.embedded.LoggingTestCase;
Expand All @@ -32,11 +35,16 @@ public class JBossLogManagerStandaloneTestCase extends LoggingTestCase {

@Test
public void testLogManager() throws Exception {
// The IBM JDK creates a logger early on doesn't allow the JBoss Log Manager to be used. For now we will ignore
// the test when the IBM JDK is being used.
Assume.assumeFalse(isIbmJdk());
System.setProperty("test.log.file", "test-standalone-jbl.log");
System.setProperty("logging.configuration", getClass().getResource("/logging.properties").toExternalForm());
// The IBM JVM creates a logger early on and requires the log manager to be reconfigured
if (isIbmJdk()) {
// We need to reconfigure logging as the log manager is likely already setup
try (InputStream in = getClass().getResourceAsStream("/jbl-logging.properties")) {
Assert.assertNotNull("Failed to find the logging.properties file", in);
LogManager.getLogManager().readConfiguration(in);
}
}
System.setProperty("logging.configuration", getClass().getResource("/jbl-logging.properties").toExternalForm());
System.setProperty("java.util.logging.manager", "org.jboss.logmanager.LogManager");
testStandalone(Configuration.LoggerHint.JBOSS_LOG_MANAGER, "test-standalone-jbl.log", "[jboss-logmanager]");
}
Expand Down
4 changes: 1 addition & 3 deletions testsuite/manualmode/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,6 @@
as the risk of cross-test pollution is too high -->
<reuseForks>false</reuseForks>

<argLine>-Djava.util.logging.manager=org.jboss.logmanager.LogManager</argLine>

<!-- Parameters to test cases. -->
<systemPropertyVariables combine.children="append">
<byteman.server.ipaddress>${node0}</byteman.server.ipaddress>
Expand All @@ -208,7 +206,7 @@
<environmentVariables>
<JBOSS_HOME>${wildfly.home}</JBOSS_HOME>
</environmentVariables>
<argLine>-Dmaven.repo.local=${settings.localRepository} ${surefire.system.args}</argLine>
<argLine>-Djava.util.logging.manager=org.jboss.logmanager.LogManager -Dmaven.repo.local=${settings.localRepository} ${surefire.system.args}</argLine>
</configuration>
</plugin>
<plugin>
Expand Down

0 comments on commit 1bc4782

Please sign in to comment.