You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by kl...@apache.org on 2016/05/03 22:37:10 UTC
[3/3] incubator-geode git commit: Finish new tests
Finish new tests
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/0fc02aee
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/0fc02aee
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/0fc02aee
Branch: refs/heads/feature/GEODE-1255
Commit: 0fc02aeee732cd0ff22976235987ed95c7dbec22
Parents: fa7106e
Author: Kirk Lund <kl...@apache.org>
Authored: Tue May 3 13:36:46 2016 -0700
Committer: Kirk Lund <kl...@apache.org>
Committed: Tue May 3 13:36:46 2016 -0700
----------------------------------------------------------------------
...stractServerLauncherIntegrationTestCase.java | 2 +
...ServerLauncherRemoteIntegrationTestCase.java | 95 ++++++++++++
...rRemoteWithCustomLoggingIntegrationTest.java | 103 +++----------
.../ServerLauncherRemoteIntegrationTest.java | 58 +------
...rRemoteWithCustomLoggingIntegrationTest.java | 122 +++++++++++++++
.../logging/log4j/custom/BasicAppender.java | 4 +
.../CustomConfigWithCacheIntegrationTest.java | 154 +++++++++++++++++++
...stomConfigWithLogServiceIntegrationTest.java | 119 ++++++++++++++
.../log4j/custom/CustomConfiguration.java | 64 ++++++++
...ustom_log4j2_custom_xml_IntegrationTest.java | 140 -----------------
.../Custom_log4j2_xml_IntegrationTest.java | 139 -----------------
...om_log4j2_xml_MinimalistIntegrationTest.java | 127 ---------------
..._xml_MinimalistWithCacheIntegrationTest.java | 133 ----------------
...alistWithLocatorLauncherIntegrationTest.java | 144 -----------------
...ithLocatorLauncherRemoteIntegrationTest.java | 140 -----------------
...malistWithServerLauncherIntegrationTest.java | 143 -----------------
.../logging/log4j/custom/log4j2-custom.xml | 10 +-
.../internal/logging/log4j/custom/log4j2.xml | 27 ----
18 files changed, 589 insertions(+), 1135 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/0fc02aee/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractServerLauncherIntegrationTestCase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractServerLauncherIntegrationTestCase.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractServerLauncherIntegrationTestCase.java
index bbb170c..5f4fd6f 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractServerLauncherIntegrationTestCase.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractServerLauncherIntegrationTestCase.java
@@ -39,6 +39,7 @@ public abstract class AbstractServerLauncherIntegrationTestCase extends Abstract
protected volatile int serverPort;
protected volatile ServerLauncher launcher;
+ protected volatile String workingDirectory;
@Rule
public ErrorCollector errorCollector= new ErrorCollector();
@@ -52,6 +53,7 @@ public abstract class AbstractServerLauncherIntegrationTestCase extends Abstract
final int port = AvailablePortHelper.getRandomAvailableTCPPort();
System.setProperty(AbstractCacheServer.TEST_OVERRIDE_DEFAULT_PORT_PROPERTY, String.valueOf(port));
this.serverPort = port;
+ this.workingDirectory = this.temporaryFolder.getRoot().getCanonicalPath();
}
@After
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/0fc02aee/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractServerLauncherRemoteIntegrationTestCase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractServerLauncherRemoteIntegrationTestCase.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractServerLauncherRemoteIntegrationTestCase.java
new file mode 100644
index 0000000..ec7a23b
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractServerLauncherRemoteIntegrationTestCase.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.distributed;
+
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Callable;
+
+import org.junit.After;
+import org.junit.Before;
+
+import com.gemstone.gemfire.internal.process.ProcessStreamReader;
+
+public abstract class AbstractServerLauncherRemoteIntegrationTestCase extends AbstractServerLauncherIntegrationTestCase {
+
+ protected volatile Process process;
+ protected volatile ProcessStreamReader processOutReader;
+ protected volatile ProcessStreamReader processErrReader;
+
+ @Before
+ public final void setUpAbstractServerLauncherRemoteIntegrationTestCase() throws Exception {
+ }
+
+ @After
+ public final void tearDownAbstractServerLauncherRemoteIntegrationTestCase() throws Exception {
+ if (this.process != null) {
+ this.process.destroy();
+ this.process = null;
+ }
+ if (this.processOutReader != null && this.processOutReader.isRunning()) {
+ this.processOutReader.stop();
+ }
+ if (this.processErrReader != null && this.processErrReader.isRunning()) {
+ this.processErrReader.stop();
+ }
+ }
+
+ /**
+ * Override as needed.
+ */
+ protected List<String> getJvmArguments() {
+ final List<String> jvmArguments = new ArrayList<String>();
+ jvmArguments.add("-Dgemfire.log-level=config");
+ return jvmArguments;
+ }
+
+ /**
+ * Remove final if a test needs to override.
+ */
+ protected final AbstractLauncher.Status getExpectedStopStatusForNotRunning() {
+ return AbstractLauncher.Status.NOT_RESPONDING;
+ }
+
+ protected void waitForServerToStart() throws Exception {
+ assertEventuallyTrue("waiting for local Server to start: " + launcher.status(), new Callable<Boolean>() {
+ @Override
+ public Boolean call() throws Exception {
+ try {
+ assertNotNull(process);
+ try {
+ final int value = process.exitValue();
+ fail("Process has died with exit value " + value + " while waiting for it to start.");
+ } catch (IllegalThreadStateException e) {
+ // expected
+ }
+ final ServerLauncher.ServerState serverState = launcher.status();
+ assertNotNull(serverState);
+ logger.info("serverState: "+serverState);
+ return AbstractLauncher.Status.ONLINE.equals(serverState.getStatus());
+ }
+ catch (RuntimeException e) {
+ logger.error(e, e);
+ return false;
+ }
+ }
+ }, TIMEOUT_MILLISECONDS, INTERVAL_MILLISECONDS);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/0fc02aee/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherRemoteWithCustomLoggingIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherRemoteWithCustomLoggingIntegrationTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherRemoteWithCustomLoggingIntegrationTest.java
index 3677bb4..2e84905 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherRemoteWithCustomLoggingIntegrationTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherRemoteWithCustomLoggingIntegrationTest.java
@@ -16,15 +16,22 @@
*/
package com.gemstone.gemfire.distributed;
+import static com.gemstone.gemfire.internal.logging.log4j.custom.CustomConfiguration.CONFIG_LAYOUT_PREFIX;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.*;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
+import org.apache.logging.log4j.core.config.ConfigurationFactory;
+import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.contrib.java.lang.system.SystemOutRule;
import org.junit.experimental.categories.Category;
+import com.gemstone.gemfire.internal.logging.log4j.custom.CustomConfiguration;
import com.gemstone.gemfire.internal.process.ProcessStreamReader;
import com.gemstone.gemfire.internal.process.ProcessType;
import com.gemstone.gemfire.internal.process.ProcessUtils;
@@ -36,78 +43,18 @@ import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
@Category(IntegrationTest.class)
public class LocatorLauncherRemoteWithCustomLoggingIntegrationTest extends AbstractLocatorLauncherRemoteIntegrationTestCase {
- @Test
- public void testStartUsesCustomLoggingConfiguration() throws Throwable {
- // TODO: create working dir, copy custom xml to that dir and point log4j at it
-
- String workingDirectory = this.temporaryFolder.getRoot().getCanonicalPath();
- System.out.println("KIRK: workingDirectory=" + workingDirectory);
-
-
- // build and start the locator
- final List<String> jvmArguments = getJvmArguments();
-
- final List<String> command = new ArrayList<String>();
- command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
- for (String jvmArgument : jvmArguments) {
- command.add(jvmArgument);
- }
- command.add("-Dlog4j.configurationFile=/Users/klund/dev/gemfire/open/geode-core/src/test/resources/com/gemstone/gemfire/internal/logging/log4j/custom/log4j2.xml");
- //command.add("-D" + ConfigurationFactory.CONFIGURATION_FILE_PROPERTY + "=/Users/klund/dev/doesnotexist.xml");
- command.add("-cp");
- command.add(System.getProperty("java.class.path"));
- command.add(LocatorLauncher.class.getName());
- command.add(LocatorLauncher.Command.START.getName());
- command.add(getUniqueName());
- command.add("--port=" + this.locatorPort);
- command.add("--redirect-output");
-
- for (String line : command) {
- System.out.println("KIRK:testStartUsesCustomLoggingConfiguration:stdout: " + line);
- }
-
- this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
- this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).inputListener(new ToSystemOut()).build().start();
- this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).inputListener(new ToSystemOut()).build().start();
-
- int pid = 0;
- this.launcher = new LocatorLauncher.Builder()
- .setWorkingDirectory(workingDirectory)
- .build();
- try {
- waitForLocatorToStart(this.launcher);
+ private File customConfigFile;
- // validate the pid file and its contents
- this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
- assertTrue(this.pidFile.exists());
- pid = readPid(this.pidFile);
- assertTrue(pid > 0);
- assertTrue(ProcessUtils.isProcessAlive(pid));
-
- final String logFileName = getUniqueName()+".log";
- assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
-
- // check the status
- final LocatorLauncher.LocatorState locatorState = this.launcher.status();
- assertNotNull(locatorState);
- assertEquals(AbstractLauncher.Status.ONLINE, locatorState.getStatus());
- } catch (Throwable e) {
- this.errorCollector.addError(e);
- }
+ @Rule
+ public SystemOutRule systemOutRule = new SystemOutRule().enableLog();
- // stop the locator
- try {
- assertEquals(AbstractLauncher.Status.STOPPED, this.launcher.stop().getStatus());
- waitForPidToStop(pid);
- } catch (Throwable e) {
- this.errorCollector.addError(e);
- }
+ @Before
+ public void setUpLocatorLauncherRemoteWithCustomLoggingIntegrationTest() throws Exception {
+ this.customConfigFile = CustomConfiguration.createConfigFileIn(this.temporaryFolder.getRoot());
}
@Test
- public void testStartUsesCustomLoggingConfigurationWithLauncherLifecycleCommands() throws Throwable {
- // TODO: create working dir, copy custom xml to that dir and point log4j at it
-
+ public void testStartUsesCustomLoggingConfiguration() throws Throwable {
// build and start the locator
final List<String> jvmArguments = getJvmArguments();
@@ -116,8 +63,7 @@ public class LocatorLauncherRemoteWithCustomLoggingIntegrationTest extends Abstr
for (String jvmArgument : jvmArguments) {
command.add(jvmArgument);
}
- command.add("-Dlog4j.configurationFile=/Users/klund/dev/gemfire/open/geode-core/src/test/resources/com/gemstone/gemfire/internal/logging/log4j/custom/log4j2.xml");
- //command.add("-D" + ConfigurationFactory.CONFIGURATION_FILE_PROPERTY + "=/Users/klund/dev/doesnotexist.xml");
+ command.add("-D" + ConfigurationFactory.CONFIGURATION_FILE_PROPERTY + "=" + this.customConfigFile.getCanonicalPath());
command.add("-cp");
command.add(System.getProperty("java.class.path"));
command.add(LocatorLauncher.class.getName());
@@ -126,17 +72,11 @@ public class LocatorLauncherRemoteWithCustomLoggingIntegrationTest extends Abstr
command.add("--port=" + this.locatorPort);
command.add("--redirect-output");
- for (String line : command) {
- System.out.println("KIRK:testStartUsesCustomLoggingConfiguration:stdout: " + line);
- }
-
- this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
+ this.process = new ProcessBuilder(command).directory(new File(this.workingDirectory)).start();
this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).inputListener(new ToSystemOut()).build().start();
this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).inputListener(new ToSystemOut()).build().start();
int pid = 0;
- String workingDirectory = this.temporaryFolder.getRoot().getCanonicalPath();
- System.out.println("KIRK: workingDirectory=" + workingDirectory);
this.launcher = new LocatorLauncher.Builder()
.setWorkingDirectory(workingDirectory)
.build();
@@ -157,6 +97,10 @@ public class LocatorLauncherRemoteWithCustomLoggingIntegrationTest extends Abstr
final LocatorLauncher.LocatorState locatorState = this.launcher.status();
assertNotNull(locatorState);
assertEquals(AbstractLauncher.Status.ONLINE, locatorState.getStatus());
+
+ assertThat(systemOutRule.getLog()).contains("log4j.configurationFile = " + this.customConfigFile.getCanonicalPath());
+ assertThat(systemOutRule.getLog()).contains(CONFIG_LAYOUT_PREFIX);
+
} catch (Throwable e) {
this.errorCollector.addError(e);
}
@@ -170,13 +114,6 @@ public class LocatorLauncherRemoteWithCustomLoggingIntegrationTest extends Abstr
}
}
- @Override
- protected final List<String> getJvmArguments() {
- final List<String> jvmArguments = new ArrayList<String>();
- jvmArguments.add("-Dgemfire.log-level=config");
- return jvmArguments;
- }
-
private static class ToSystemOut implements ProcessStreamReader.InputListener {
@Override
public void notifyInputLine(String line) {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/0fc02aee/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherRemoteIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherRemoteIntegrationTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherRemoteIntegrationTest.java
index 0f80b8c..4cd21a2 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherRemoteIntegrationTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherRemoteIntegrationTest.java
@@ -74,33 +74,7 @@ import com.gemstone.gemfire.test.process.ProcessWrapper;
* @since 8.0
*/
@Category(IntegrationTest.class)
-public class ServerLauncherRemoteIntegrationTest extends AbstractServerLauncherIntegrationTestCase {
-
- protected volatile Process process;
- protected volatile ProcessStreamReader processOutReader;
- protected volatile ProcessStreamReader processErrReader;
-
- @Before
- public final void setUpServerLauncherRemoteTest() throws Exception {
- }
-
- @After
- public final void tearDownServerLauncherRemoteTest() throws Exception {
- if (this.process != null) {
- this.process.destroy();
- this.process = null;
- }
- if (this.processOutReader != null && this.processOutReader.isRunning()) {
- this.processOutReader.stop();
- }
- if (this.processErrReader != null && this.processErrReader.isRunning()) {
- this.processErrReader.stop();
- }
- }
-
- protected Status getExpectedStopStatusForNotRunning() {
- return Status.NOT_RESPONDING;
- }
+public class ServerLauncherRemoteIntegrationTest extends AbstractServerLauncherRemoteIntegrationTestCase {
@Test
public void testIsAttachAPIFound() throws Exception {
@@ -1334,32 +1308,8 @@ public class ServerLauncherRemoteIntegrationTest extends AbstractServerLauncherI
}
}
- protected void waitForServerToStart() throws Exception {
- assertEventuallyTrue("waiting for local Server to start: " + launcher.status(), new Callable<Boolean>() {
- @Override
- public Boolean call() throws Exception {
- try {
- assertNotNull(process);
- try {
- final int value = process.exitValue();
- fail("Process has died with exit value " + value + " while waiting for it to start.");
- } catch (IllegalThreadStateException e) {
- // expected
- }
- final ServerState serverState = launcher.status();
- assertNotNull(serverState);
- logger.info("serverState: "+serverState);
- return Status.ONLINE.equals(serverState.getStatus());
- }
- catch (RuntimeException e) {
- logger.error(e, e);
- return false;
- }
- }
- }, TIMEOUT_MILLISECONDS, INTERVAL_MILLISECONDS);
- }
-
- protected static List<String> getJvmArguments() {
+ @Override
+ protected List<String> getJvmArguments() {
final List<String> jvmArguments = new ArrayList<String>();
jvmArguments.add("-Dgemfire.log-level=config");
jvmArguments.add("-Dgemfire.mcast-port=0");
@@ -1381,7 +1331,7 @@ public class ServerLauncherRemoteIntegrationTest extends AbstractServerLauncherI
try {
// launch ServerLauncher
- final List<String> jvmArguments = getJvmArguments();
+ final List<String> jvmArguments = null;//getJvmArguments();
assertTrue(jvmArguments.size() == 2);
final List<String> command = new ArrayList<String>();
command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/0fc02aee/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherRemoteWithCustomLoggingIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherRemoteWithCustomLoggingIntegrationTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherRemoteWithCustomLoggingIntegrationTest.java
new file mode 100644
index 0000000..d6bfe82
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherRemoteWithCustomLoggingIntegrationTest.java
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.distributed;
+
+import static com.gemstone.gemfire.internal.logging.log4j.custom.CustomConfiguration.*;
+import static org.assertj.core.api.Assertions.*;
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.logging.log4j.core.config.ConfigurationFactory;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.contrib.java.lang.system.SystemOutRule;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.internal.process.ProcessStreamReader;
+import com.gemstone.gemfire.internal.process.ProcessType;
+import com.gemstone.gemfire.internal.process.ProcessUtils;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+
+/**
+ * Integration tests for launching a Server in a forked process with custom logging configuration
+ */
+@Category(IntegrationTest.class)
+public class ServerLauncherRemoteWithCustomLoggingIntegrationTest extends AbstractServerLauncherRemoteIntegrationTestCase {
+
+ private File customConfigFile;
+
+ @Rule
+ public SystemOutRule systemOutRule = new SystemOutRule().enableLog();
+
+ @Before
+ public void setUpLocatorLauncherRemoteWithCustomLoggingIntegrationTest() throws Exception {
+ this.customConfigFile = createConfigFileIn(this.temporaryFolder.getRoot());
+ }
+
+ @Test
+ public void testStartUsesCustomLoggingConfiguration() throws Throwable {
+ // build and start the server
+ final List<String> jvmArguments = getJvmArguments();
+
+ final List<String> command = new ArrayList<String>();
+ command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
+ for (String jvmArgument : jvmArguments) {
+ command.add(jvmArgument);
+ }
+ command.add("-D" + ConfigurationFactory.CONFIGURATION_FILE_PROPERTY + "=" + this.customConfigFile.getCanonicalPath());
+ command.add("-cp");
+ command.add(System.getProperty("java.class.path"));
+ command.add(ServerLauncher.class.getName());
+ command.add(ServerLauncher.Command.START.getName());
+ command.add(getUniqueName());
+ command.add("--disable-default-server");
+ command.add("--redirect-output");
+
+ this.process = new ProcessBuilder(command).directory(new File(this.workingDirectory)).start();
+ this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).inputListener(new ToSystemOut()).build().start();
+ this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).inputListener(new ToSystemOut()).build().start();
+
+ int pid = 0;
+ this.launcher = new ServerLauncher.Builder()
+ .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
+ .build();
+ try {
+ waitForServerToStart();
+
+ // validate the pid file and its contents
+ this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
+ assertTrue(this.pidFile.exists());
+ pid = readPid(this.pidFile);
+ assertTrue(pid > 0);
+ assertTrue(ProcessUtils.isProcessAlive(pid));
+
+ final String logFileName = getUniqueName()+".log";
+ assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
+
+ // check the status
+ final ServerLauncher.ServerState serverState = this.launcher.status();
+ assertNotNull(serverState);
+ assertEquals(AbstractLauncher.Status.ONLINE, serverState.getStatus());
+
+ assertThat(systemOutRule.getLog()).contains("log4j.configurationFile = " + this.customConfigFile.getCanonicalPath());
+ assertThat(systemOutRule.getLog()).contains(CONFIG_LAYOUT_PREFIX);
+
+ } catch (Throwable e) {
+ this.errorCollector.addError(e);
+ }
+
+ // stop the server
+ try {
+ assertEquals(AbstractLauncher.Status.STOPPED, this.launcher.stop().getStatus());
+ waitForPidToStop(pid);
+ } catch (Throwable e) {
+ this.errorCollector.addError(e);
+ }
+ }
+
+ private static class ToSystemOut implements ProcessStreamReader.InputListener {
+ @Override
+ public void notifyInputLine(String line) {
+ System.out.println(line);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/0fc02aee/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/BasicAppender.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/BasicAppender.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/BasicAppender.java
index 7783931..0b04379 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/BasicAppender.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/BasicAppender.java
@@ -61,6 +61,10 @@ public class BasicAppender extends AbstractAppender {
instance = null;
}
+ public static void clearEvents() {
+ instance.events.clear();
+ }
+
@Override
public void append(final LogEvent event) {
this.events.add(event);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/0fc02aee/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/CustomConfigWithCacheIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/CustomConfigWithCacheIntegrationTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/CustomConfigWithCacheIntegrationTest.java
new file mode 100644
index 0000000..18faed1
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/CustomConfigWithCacheIntegrationTest.java
@@ -0,0 +1,154 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.internal.logging.log4j.custom;
+
+import static com.gemstone.gemfire.internal.logging.log4j.custom.CustomConfiguration.*;
+import static org.assertj.core.api.Assertions.*;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.net.URL;
+import java.util.Properties;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.config.ConfigurationFactory;
+import org.apache.logging.log4j.status.StatusLogger;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.contrib.java.lang.system.RestoreSystemProperties;
+import org.junit.contrib.java.lang.system.SystemErrRule;
+import org.junit.contrib.java.lang.system.SystemOutRule;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.ExternalResource;
+import org.junit.rules.TemporaryFolder;
+import org.junit.rules.TestName;
+
+import com.gemstone.gemfire.LogWriter;
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.internal.logging.LogService;
+import com.gemstone.gemfire.internal.logging.log4j.Configurator;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+
+/**
+ * Integration tests with custom log4j2 configuration.
+ */
+@Category(IntegrationTest.class)
+public class CustomConfigWithCacheIntegrationTest {
+
+ private String beforeConfigFileProp;
+ private Level beforeLevel;
+
+ private File customConfigFile;
+ private Cache cache;
+
+ @Rule
+ public SystemErrRule systemErrRule = new SystemErrRule().enableLog();
+
+ @Rule
+ public SystemOutRule systemOutRule = new SystemOutRule().enableLog();
+
+ @Rule
+ public TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+ @Rule
+ public TestName testName = new TestName();
+
+ @Before
+ public void setUp() throws Exception {
+ Configurator.shutdown();
+ BasicAppender.clearInstance();
+
+ this.beforeConfigFileProp = System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
+ this.beforeLevel = StatusLogger.getLogger().getLevel();
+
+ this.customConfigFile = createConfigFileIn(this.temporaryFolder.getRoot());
+
+ System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, this.customConfigFile.getAbsolutePath());
+
+ Properties gemfireProperties = new Properties();
+ gemfireProperties.put(DistributionConfig.LOCATORS_NAME, "");
+ gemfireProperties.put(DistributionConfig.MCAST_PORT_NAME, "0");
+ gemfireProperties.put(DistributionConfig.LOG_LEVEL_NAME, "info");
+ this.cache = new CacheFactory(gemfireProperties).create();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ if (this.cache != null) {
+ this.cache.getDistributedSystem().disconnect();
+ }
+
+ Configurator.shutdown();
+
+ System.clearProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
+ if (this.beforeConfigFileProp != null) {
+ System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, this.beforeConfigFileProp);
+ }
+ StatusLogger.getLogger().setLevel(this.beforeLevel);
+
+ LogService.reconfigure();
+ assertThat(LogService.isUsingGemFireDefaultConfig()).as(LogService.getConfigInformation()).isTrue();
+
+ BasicAppender.clearInstance();
+
+ assertThat(this.systemErrRule.getLog()).isEmpty();
+ }
+
+ @Test
+ public void cacheLogWriterMessageShouldMatchCustomConfig() throws Exception {
+ String logLogger = LogService.MAIN_LOGGER_NAME;
+ Level logLevel = Level.INFO;
+ String logMessage = "this is a log statement from " + testName.getMethodName();
+
+ LogWriter logger = this.cache.getLogger();
+ assertThat(LogService.isUsingGemFireDefaultConfig()).as(LogService.getConfigInformation()).isFalse();
+
+ BasicAppender.clearEvents();
+
+ logger.info(logMessage);
+
+ BasicAppender appender = BasicAppender.getInstance();
+ assertThat(appender).isNotNull();
+ assertThat(appender.events().size()).isGreaterThan(0);
+
+ LogEvent event = null;
+ for (LogEvent logEvent : appender.events()) {
+ if (logEvent.getMessage().getFormattedMessage().contains(logMessage)) {
+ event = logEvent;
+ break;
+ }
+ }
+
+ assertThat(event).isNotNull();
+
+ assertThat(event.getLoggerName()).isEqualTo(logLogger);
+ assertThat(event.getLevel()).isEqualTo(logLevel);
+ assertThat(event.getMessage().getFormattedMessage()).isEqualTo(logMessage);
+
+ assertThat(systemOutRule.getLog()).contains(logLevel.name());
+ assertThat(systemOutRule.getLog()).contains(logMessage);
+ assertThat(systemOutRule.getLog()).contains(CONFIG_LAYOUT_PREFIX);
+ assertThat(systemOutRule.getLog()).containsPattern(defineLogStatementRegex(logLevel, logMessage));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/0fc02aee/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/CustomConfigWithLogServiceIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/CustomConfigWithLogServiceIntegrationTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/CustomConfigWithLogServiceIntegrationTest.java
new file mode 100644
index 0000000..631f232
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/CustomConfigWithLogServiceIntegrationTest.java
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.internal.logging.log4j.custom;
+
+import static com.gemstone.gemfire.internal.logging.log4j.custom.CustomConfiguration.*;
+import static org.assertj.core.api.Assertions.*;
+
+import java.io.File;
+
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.config.ConfigurationFactory;
+import org.apache.logging.log4j.status.StatusLogger;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.contrib.java.lang.system.SystemErrRule;
+import org.junit.contrib.java.lang.system.SystemOutRule;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TemporaryFolder;
+
+import com.gemstone.gemfire.internal.logging.LogService;
+import com.gemstone.gemfire.internal.logging.log4j.Configurator;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+
+/**
+ * Integration tests with custom log4j2 configuration.
+ */
+@Category(IntegrationTest.class)
+public class CustomConfigWithLogServiceIntegrationTest {
+
+ private String beforeConfigFileProp;
+ private Level beforeLevel;
+
+ private File customConfigFile;
+
+ @Rule
+ public SystemErrRule systemErrRule = new SystemErrRule().enableLog();
+
+ @Rule
+ public SystemOutRule systemOutRule = new SystemOutRule().enableLog();
+
+ @Rule
+ public TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+ @Before
+ public void setUp() throws Exception {
+ Configurator.shutdown();
+ BasicAppender.clearInstance();
+
+ this.beforeConfigFileProp = System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
+ this.beforeLevel = StatusLogger.getLogger().getLevel();
+
+ this.customConfigFile = createConfigFileIn(this.temporaryFolder.getRoot());
+
+ System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, this.customConfigFile.getAbsolutePath());
+ LogService.reconfigure();
+ assertThat(LogService.isUsingGemFireDefaultConfig()).as(LogService.getConfigInformation()).isFalse();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ Configurator.shutdown();
+
+ System.clearProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
+ if (this.beforeConfigFileProp != null) {
+ System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, this.beforeConfigFileProp);
+ }
+ StatusLogger.getLogger().setLevel(this.beforeLevel);
+
+ LogService.reconfigure();
+ assertThat(LogService.isUsingGemFireDefaultConfig()).as(LogService.getConfigInformation()).isTrue();
+
+ BasicAppender.clearInstance();
+
+ assertThat(this.systemErrRule.getLog()).isEmpty();
+ }
+
+ @Test
+ public void logEventShouldMatchCustomConfig() throws Exception {
+ String logLogger = getClass().getName();
+ Level logLevel = Level.DEBUG;
+ String logMessage = "this is a log statement";
+
+ Logger logger = LogService.getLogger();
+ logger.debug(logMessage);
+
+ BasicAppender appender = BasicAppender.getInstance();
+ assertThat(appender).isNotNull();
+ assertThat(appender.events()).hasSize(1);
+
+ LogEvent event = appender.events().get(0);
+ assertThat(event.getLoggerName()).isEqualTo(logLogger);
+ assertThat(event.getLevel()).isEqualTo(logLevel);
+ assertThat(event.getMessage().getFormattedMessage()).isEqualTo(logMessage);
+
+ assertThat(systemOutRule.getLog()).contains(logLevel.name());
+ assertThat(systemOutRule.getLog()).contains(logMessage);
+ assertThat(systemOutRule.getLog()).contains(CONFIG_LAYOUT_PREFIX);
+ assertThat(systemOutRule.getLog()).matches(defineLogStatementRegex(logLevel, logMessage));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/0fc02aee/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/CustomConfiguration.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/CustomConfiguration.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/CustomConfiguration.java
new file mode 100644
index 0000000..05c72d6
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/CustomConfiguration.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.internal.logging.log4j.custom;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.logging.log4j.Level;
+
+public class CustomConfiguration {
+
+ public static final String CONFIG_FILE_NAME = "log4j2-custom.xml";
+ public static final String CONFIG_LAYOUT_PREFIX = "CUSTOM";
+
+ protected CustomConfiguration() {
+ }
+
+ public static URL openConfigResource() {
+ return new CustomConfiguration().getClass().getResource(CONFIG_FILE_NAME);
+ }
+
+ public static File createConfigFileIn(final File targetFolder) throws IOException, URISyntaxException {
+ URL resource = openConfigResource();
+ File targetFile = new File(targetFolder, CONFIG_FILE_NAME);
+ IOUtils.copy(resource.openStream(), new FileOutputStream(targetFile));
+ assertThat(targetFile).hasSameContentAs(new File(resource.toURI()));
+ return targetFile;
+ }
+
+ private static final String DATE = "((?:19|20)\\\\d\\\\d)/(0?[1-9]|1[012])/([12][0-9]|3[01]|0?[1-9])";
+
+ private static final String TIME = "\\b(?<!')([xXzZ])(?!')\\b";
+
+ public static String defineLogStatementRegex(final Level level, final String message) {
+ // CUSTOM: level=%level time=%date{yyyy/MM/dd HH:mm:ss.SSS z} message=%message%nthrowable=%throwable%n
+ return CONFIG_LAYOUT_PREFIX + ": level=" + level.toString() + " time=" + ".*" + " message=" + message + "\nthrowable=\n";
+ }
+
+ public static String defineLogStatementRegex(final Level level, final String message, final String throwable) {
+ // CUSTOM: level=%level time=%date{yyyy/MM/dd HH:mm:ss.SSS z} message=%message%nthrowable=%throwable%n
+ return CONFIG_LAYOUT_PREFIX + ": level=" + level.toString() + " time=" + ".*" + " message=" + message + "\nthrowable=" + throwable + "\n";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/0fc02aee/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_custom_xml_IntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_custom_xml_IntegrationTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_custom_xml_IntegrationTest.java
deleted file mode 100644
index 314d028..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_custom_xml_IntegrationTest.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.gemstone.gemfire.internal.logging.log4j.custom;
-
-import static org.assertj.core.api.Assertions.*;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.net.URL;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.contrib.java.lang.system.RestoreSystemProperties;
-import org.junit.contrib.java.lang.system.SystemErrRule;
-import org.junit.contrib.java.lang.system.SystemOutRule;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.ExternalResource;
-import org.junit.rules.TemporaryFolder;
-
-import com.gemstone.gemfire.internal.logging.LogService;
-import com.gemstone.gemfire.internal.logging.log4j.Configurator;
-import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-
-/**
- * Integration tests with custom log4j2 configuration.
- */
-@Category(IntegrationTest.class)
-public class Custom_log4j2_custom_xml_IntegrationTest {
-
- private static final String CUSTOM_CONFIG_FILE_NAME = "log4j2-custom.xml";
-
- @Rule
- public SystemErrRule systemErrRule = new SystemErrRule().enableLog();
-
- @Rule
- public SystemOutRule systemOutRule = new SystemOutRule().enableLog();
-
- @Rule
- public TemporaryFolder temporaryFolder = new TemporaryFolder();
-
- private String beforeConfigFileProp;
- private Level beforeLevel;
-
- private File customConfigFile;
-
- @Before
- public void setUp() throws Exception {
- Configurator.shutdown();
- BasicAppender.clearInstance();
-
- this.beforeConfigFileProp = System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
- this.beforeLevel = StatusLogger.getLogger().getLevel();
-
- URL customConfigResource = getClass().getResource(CUSTOM_CONFIG_FILE_NAME);
- File temporaryFile = this.temporaryFolder.newFile(CUSTOM_CONFIG_FILE_NAME);
-
- IOUtils.copy(customConfigResource.openStream(), new FileOutputStream(temporaryFile));
- assertThat(temporaryFile).hasSameContentAs(new File(customConfigResource.toURI()));
-
- System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, temporaryFile.getAbsolutePath());
- LogService.reconfigure();
- assertThat(LogService.isUsingGemFireDefaultConfig()).as(LogService.getConfigInformation()).isFalse();
-
- this.customConfigFile = temporaryFile;
- }
-
- @After
- public void tearDown() throws Exception {
- Configurator.shutdown();
-
- System.clearProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
- if (this.beforeConfigFileProp != null) {
- System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, this.beforeConfigFileProp);
- }
- StatusLogger.getLogger().setLevel(this.beforeLevel);
-
- LogService.reconfigure();
- assertThat(LogService.isUsingGemFireDefaultConfig()).as(LogService.getConfigInformation()).isTrue();
-
- BasicAppender.clearInstance();
-
- //assertThat(this.systemErrRule.getLog()).isEmpty();
- //assertThat(this.systemOutRule.getLog()).isEmpty();
- }
-
- @Test
- public void foo() throws Exception {
- String logLogger = getClass().getName();
- Level logLevel = Level.DEBUG;
- String logMessage = "this is a log statement";
-
- Logger logger = LogService.getLogger();
- logger.debug(logMessage);
-
- String systemOut = systemOutRule.getLog();
- String systemErr = systemErrRule.getLog();
-
- System.out.println("this.customConfigFile=" + this.customConfigFile);
- System.out.println("BasicAppender=" + BasicAppender.getInstance());
- System.out.println("CONFIGURATION_FILE_PROPERTY=" + System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY));
- System.out.println("out=" + systemOut.trim());
-
- BasicAppender appender = BasicAppender.getInstance();
- assertThat(appender).isNotNull();
- assertThat(appender.events()).hasSize(1);
-
- LogEvent event = appender.events().get(0);
- System.out.println("event=" + event);
-
- assertThat(event.getLoggerName()).isEqualTo(logLogger);
- assertThat(event.getLevel()).isEqualTo(logLevel);
- assertThat(event.getMessage().getFormattedMessage()).isEqualTo(logMessage);
-
- assertThat(systemOut).contains(logLevel.name());
- assertThat(systemOut).contains(logMessage);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/0fc02aee/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_xml_IntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_xml_IntegrationTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_xml_IntegrationTest.java
deleted file mode 100644
index b749c13..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_xml_IntegrationTest.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.gemstone.gemfire.internal.logging.log4j.custom;
-
-import static org.assertj.core.api.Assertions.*;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.net.URL;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.contrib.java.lang.system.RestoreSystemProperties;
-import org.junit.contrib.java.lang.system.SystemErrRule;
-import org.junit.contrib.java.lang.system.SystemOutRule;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.ExternalResource;
-import org.junit.rules.TemporaryFolder;
-
-import com.gemstone.gemfire.internal.logging.LogService;
-import com.gemstone.gemfire.internal.logging.log4j.Configurator;
-import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-
-/**
- * Integration tests with custom log4j2 configuration.
- */
-@Category(IntegrationTest.class)
-public class Custom_log4j2_xml_IntegrationTest {
-
- private static final String CUSTOM_CONFIG_FILE_NAME = "log4j2.xml";
-
- @Rule
- public SystemErrRule systemErrRule = new SystemErrRule().enableLog();
-
- @Rule
- public SystemOutRule systemOutRule = new SystemOutRule().enableLog();
-
- @Rule
- public TemporaryFolder temporaryFolder = new TemporaryFolder();
-
- private String beforeConfigFileProp;
- private Level beforeLevel;
-
- private File customConfigFile;
-
- @Before
- public void setUp() throws Exception {
- Configurator.shutdown();
- BasicAppender.clearInstance();
-
- this.beforeConfigFileProp = System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
- this.beforeLevel = StatusLogger.getLogger().getLevel();
-
- URL customConfigResource = getClass().getResource(CUSTOM_CONFIG_FILE_NAME);
- File temporaryFile = this.temporaryFolder.newFile(CUSTOM_CONFIG_FILE_NAME);
-
- IOUtils.copy(customConfigResource.openStream(), new FileOutputStream(temporaryFile));
- assertThat(temporaryFile).hasSameContentAs(new File(customConfigResource.toURI()));
-
- System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, temporaryFile.getAbsolutePath());
- LogService.reconfigure();
- assertThat(LogService.isUsingGemFireDefaultConfig()).as(LogService.getConfigInformation()).isFalse();
-
- this.customConfigFile = temporaryFile;
- }
-
- @After
- public void tearDown() throws Exception {
- Configurator.shutdown();
-
- System.clearProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
- if (this.beforeConfigFileProp != null) {
- System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, this.beforeConfigFileProp);
- }
- StatusLogger.getLogger().setLevel(this.beforeLevel);
-
- LogService.reconfigure();
- assertThat(LogService.isUsingGemFireDefaultConfig()).as(LogService.getConfigInformation()).isTrue();
-
- BasicAppender.clearInstance();
-
- //assertThat(this.systemErrRule.getLog()).isEmpty();
- //assertThat(this.systemOutRule.getLog()).isEmpty();
- }
-
- @Test
- public void foo() throws Exception {
- String logLogger = getClass().getName();
- Level logLevel = Level.DEBUG;
- String logMessage = "this is a log statement";
-
- Logger logger = LogService.getLogger();
- logger.debug(logMessage);
-
- String systemOut = systemOutRule.getLog();
- String systemErr = systemErrRule.getLog();
-
- System.out.println("this.customConfigFile=" + this.customConfigFile);
- System.out.println("BasicAppender=" + BasicAppender.getInstance());
- System.out.println("CONFIGURATION_FILE_PROPERTY=" + System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY));
- System.out.println("out=" + systemOut.trim());
-
- BasicAppender appender = BasicAppender.getInstance();
- assertThat(appender).isNotNull();
- assertThat(appender.events()).hasSize(1);
-
- LogEvent event = appender.events().get(0);
- System.out.println("event=" + event);
-
- assertThat(event.getLoggerName()).isEqualTo(logLogger);
- assertThat(event.getLevel()).isEqualTo(logLevel);
- assertThat(event.getMessage().getFormattedMessage()).isEqualTo(logMessage);
-
- assertThat(systemOut).contains(logLevel.name());
- assertThat(systemOut).contains(logMessage);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/0fc02aee/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_xml_MinimalistIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_xml_MinimalistIntegrationTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_xml_MinimalistIntegrationTest.java
deleted file mode 100644
index 1d9d87f..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_xml_MinimalistIntegrationTest.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.gemstone.gemfire.internal.logging.log4j.custom;
-
-import static org.assertj.core.api.Assertions.*;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.net.URL;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.contrib.java.lang.system.RestoreSystemProperties;
-import org.junit.contrib.java.lang.system.SystemErrRule;
-import org.junit.contrib.java.lang.system.SystemOutRule;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.ExternalResource;
-import org.junit.rules.TemporaryFolder;
-
-import com.gemstone.gemfire.distributed.ServerLauncher;
-import com.gemstone.gemfire.internal.logging.LogService;
-import com.gemstone.gemfire.internal.logging.log4j.Configurator;
-import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-
-/**
- * Integration tests with custom log4j2 configuration.
- */
-@Category(IntegrationTest.class)
-public class Custom_log4j2_xml_MinimalistIntegrationTest {
-
-
- private static final String CUSTOM_CONFIG_FILE_NAME = "log4j2.xml";
-
- @Rule
- public SystemErrRule systemErrRule = new SystemErrRule().enableLog();
-
- @Rule
- public SystemOutRule systemOutRule = new SystemOutRule().enableLog();
-
- @Rule
- public TemporaryFolder temporaryFolder = new TemporaryFolder();
-
- private String beforeConfigFileProp;
- private Level beforeLevel;
-
- private File customConfigFile;
-
- @Before
- public void setUp() throws Exception {
- URL customConfigResource = getClass().getResource(CUSTOM_CONFIG_FILE_NAME);
- File temporaryFile = this.temporaryFolder.newFile(CUSTOM_CONFIG_FILE_NAME);
-
- IOUtils.copy(customConfigResource.openStream(), new FileOutputStream(temporaryFile));
- assertThat(temporaryFile).hasSameContentAs(new File(customConfigResource.toURI()));
-
- System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, temporaryFile.getAbsolutePath());
-
- //assertThat(LogService.isUsingGemFireDefaultConfig()).as(LogService.getConfigInformation()).isFalse();
-
- this.customConfigFile = temporaryFile;
- }
-
- @After
- public void tearDown() throws Exception {
- BasicAppender.clearInstance();
- }
-
- @Test
- public void foo() throws Exception {
- String logLogger = getClass().getName();
- Level logLevel = Level.DEBUG;
- String logMessage = "this is a log statement";
-
- Logger logger = LogService.getLogger();
- assertThat(LogService.isUsingGemFireDefaultConfig()).as(LogService.getConfigInformation()).isFalse();
-
- logger.debug(logMessage);
-
- String systemOut = systemOutRule.getLog();
- String systemErr = systemErrRule.getLog();
-
- System.out.println("this.customConfigFile=" + this.customConfigFile);
- System.out.println("BasicAppender=" + BasicAppender.getInstance());
- System.out.println("CONFIGURATION_FILE_PROPERTY=" + System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY));
- System.out.println("out=" + systemOut.trim());
-
- BasicAppender appender = BasicAppender.getInstance();
- assertThat(appender).isNotNull();
- assertThat(appender.events()).hasSize(1);
-
- LogEvent event = appender.events().get(0);
- System.out.println("event=" + event);
-
- assertThat(event.getLoggerName()).isEqualTo(logLogger);
- assertThat(event.getLevel()).isEqualTo(logLevel);
- assertThat(event.getMessage().getFormattedMessage()).isEqualTo(logMessage);
-
- assertThat(systemOut).contains(logLevel.name());
- assertThat(systemOut).contains(logMessage);
- }
-
- public void bar() {
- new ServerLauncher.Builder().setMemberName("Kirk").set("locators", "").build().start();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/0fc02aee/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_xml_MinimalistWithCacheIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_xml_MinimalistWithCacheIntegrationTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_xml_MinimalistWithCacheIntegrationTest.java
deleted file mode 100644
index 05b3dc0..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_xml_MinimalistWithCacheIntegrationTest.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.gemstone.gemfire.internal.logging.log4j.custom;
-
-import static org.assertj.core.api.Assertions.*;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.net.URL;
-import java.util.Properties;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.contrib.java.lang.system.RestoreSystemProperties;
-import org.junit.contrib.java.lang.system.SystemErrRule;
-import org.junit.contrib.java.lang.system.SystemOutRule;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.ExternalResource;
-import org.junit.rules.TemporaryFolder;
-
-import com.gemstone.gemfire.cache.Cache;
-import com.gemstone.gemfire.cache.CacheFactory;
-import com.gemstone.gemfire.distributed.internal.DistributionConfig;
-import com.gemstone.gemfire.internal.logging.LogService;
-import com.gemstone.gemfire.internal.logging.log4j.Configurator;
-import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-
-/**
- * Integration tests with custom log4j2 configuration.
- */
-@Category(IntegrationTest.class)
-public class Custom_log4j2_xml_MinimalistWithCacheIntegrationTest {
-
- private static final String CUSTOM_CONFIG_FILE_NAME = "log4j2.xml";
-
- @Rule
- public SystemErrRule systemErrRule = new SystemErrRule().enableLog();
-
- @Rule
- public SystemOutRule systemOutRule = new SystemOutRule().enableLog();
-
- @Rule
- public TemporaryFolder temporaryFolder = new TemporaryFolder();
-
- private String beforeConfigFileProp;
- private Level beforeLevel;
-
- private File customConfigFile;
-
- @Before
- public void setUp() throws Exception {
- URL customConfigResource = getClass().getResource(CUSTOM_CONFIG_FILE_NAME);
- File temporaryFile = this.temporaryFolder.newFile(CUSTOM_CONFIG_FILE_NAME);
-
- IOUtils.copy(customConfigResource.openStream(), new FileOutputStream(temporaryFile));
- assertThat(temporaryFile).hasSameContentAs(new File(customConfigResource.toURI()));
-
- System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, temporaryFile.getAbsolutePath());
-
- //assertThat(LogService.isUsingGemFireDefaultConfig()).as(LogService.getConfigInformation()).isFalse();
-
- this.customConfigFile = temporaryFile;
- }
-
- @After
- public void tearDown() throws Exception {
- BasicAppender.clearInstance();
- }
-
- @Test
- public void foo() throws Exception {
- Properties gemfireProperties = new Properties();
- gemfireProperties.put(DistributionConfig.LOCATORS_NAME, "");
- gemfireProperties.put(DistributionConfig.MCAST_PORT_NAME, "0");
- gemfireProperties.put(DistributionConfig.LOG_LEVEL_NAME, "info");
- Cache cache = new CacheFactory(gemfireProperties).create();
-
- cache.getLogger().info("hey kirk");
-
- String logLogger = getClass().getName();
- Level logLevel = Level.DEBUG;
- String logMessage = "this is a log statement";
-
- Logger logger = LogService.getLogger();
- assertThat(LogService.isUsingGemFireDefaultConfig()).as(LogService.getConfigInformation()).isFalse();
-
- logger.debug(logMessage);
-
- String systemOut = systemOutRule.getLog();
- String systemErr = systemErrRule.getLog();
-
- System.out.println("this.customConfigFile=" + this.customConfigFile);
- System.out.println("BasicAppender=" + BasicAppender.getInstance());
- System.out.println("CONFIGURATION_FILE_PROPERTY=" + System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY));
- System.out.println("out=" + systemOut.trim());
-
- BasicAppender appender = BasicAppender.getInstance();
- assertThat(appender).isNotNull();
-// assertThat(appender.events()).hasSize(1);
-
- LogEvent event = appender.events().get(0);
- System.out.println("event=" + event);
-
-// assertThat(event.getLoggerName()).isEqualTo(logLogger);
-// assertThat(event.getLevel()).isEqualTo(logLevel);
-// assertThat(event.getMessage().getFormattedMessage()).isEqualTo(logMessage);
-//
-// assertThat(systemOut).contains(logLevel.name());
-// assertThat(systemOut).contains(logMessage);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/0fc02aee/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_xml_MinimalistWithLocatorLauncherIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_xml_MinimalistWithLocatorLauncherIntegrationTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_xml_MinimalistWithLocatorLauncherIntegrationTest.java
deleted file mode 100644
index f556f1f..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_xml_MinimalistWithLocatorLauncherIntegrationTest.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.gemstone.gemfire.internal.logging.log4j.custom;
-
-import static org.assertj.core.api.Assertions.*;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.net.URL;
-import java.util.Properties;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.contrib.java.lang.system.RestoreSystemProperties;
-import org.junit.contrib.java.lang.system.SystemErrRule;
-import org.junit.contrib.java.lang.system.SystemOutRule;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.ExternalResource;
-import org.junit.rules.TemporaryFolder;
-
-import com.gemstone.gemfire.cache.Cache;
-import com.gemstone.gemfire.cache.CacheFactory;
-import com.gemstone.gemfire.distributed.LocatorLauncher;
-import com.gemstone.gemfire.distributed.internal.DistributionConfig;
-import com.gemstone.gemfire.internal.AvailablePort;
-import com.gemstone.gemfire.internal.cache.AbstractCacheServer;
-import com.gemstone.gemfire.internal.logging.LogService;
-import com.gemstone.gemfire.internal.logging.log4j.Configurator;
-import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-
-/**
- * Integration tests with custom log4j2 configuration.
- */
-@Category(IntegrationTest.class)
-public class Custom_log4j2_xml_MinimalistWithLocatorLauncherIntegrationTest {
-
- private static final String CUSTOM_CONFIG_FILE_NAME = "log4j2.xml";
-
- @Rule
- public SystemErrRule systemErrRule = new SystemErrRule().enableLog();
-
- @Rule
- public SystemOutRule systemOutRule = new SystemOutRule().enableLog();
-
- @Rule
- public TemporaryFolder temporaryFolder = new TemporaryFolder();
-
- private String beforeConfigFileProp;
- private Level beforeLevel;
-
- private File customConfigFile;
-
- @Before
- public void setUp() throws Exception {
- URL customConfigResource = getClass().getResource(CUSTOM_CONFIG_FILE_NAME);
- File temporaryFile = this.temporaryFolder.newFile(CUSTOM_CONFIG_FILE_NAME);
-
- IOUtils.copy(customConfigResource.openStream(), new FileOutputStream(temporaryFile));
- assertThat(temporaryFile).hasSameContentAs(new File(customConfigResource.toURI()));
-
- System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, temporaryFile.getAbsolutePath());
-
- //assertThat(LogService.isUsingGemFireDefaultConfig()).as(LogService.getConfigInformation()).isFalse();
-
- this.customConfigFile = temporaryFile;
-
- System.setProperty(AbstractCacheServer.TEST_OVERRIDE_DEFAULT_PORT_PROPERTY, String.valueOf(0));
- }
-
- @After
- public void tearDown() throws Exception {
- BasicAppender.clearInstance();
- }
-
- @Test
- public void foo() throws Exception {
- System.out.println("KIRK:foo: customConfigFile=" + this.customConfigFile.getAbsolutePath());
- System.setProperty("log4j.configurationFile", this.customConfigFile.getAbsolutePath());
- System.out.println("KIRK:foo: log4j.configurationFile=" + System.getProperty("log4j.configurationFile"));
-
- LocatorLauncher launcher = new LocatorLauncher.Builder()
- .setCommand(LocatorLauncher.Command.START)
- .setMemberName("membername")
- //.set(DistributionConfig.LOCATORS_NAME, "")
- .setPort(AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET))
- .setRedirectOutput(true)
- .build();
-
- launcher.start();
-
- String logLogger = getClass().getName();
- Level logLevel = Level.DEBUG;
- String logMessage = "this is a log statement";
-
- Logger logger = LogService.getLogger();
- assertThat(LogService.isUsingGemFireDefaultConfig()).as(LogService.getConfigInformation()).isFalse();
-
- logger.debug(logMessage);
-
- String systemOut = systemOutRule.getLog();
- String systemErr = systemErrRule.getLog();
-
- System.out.println("this.customConfigFile=" + this.customConfigFile);
- System.out.println("BasicAppender=" + BasicAppender.getInstance());
- System.out.println("CONFIGURATION_FILE_PROPERTY=" + System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY));
- System.out.println("out=" + systemOut.trim());
-
- BasicAppender appender = BasicAppender.getInstance();
- assertThat(appender).isNotNull();
-// assertThat(appender.events()).hasSize(1);
-
- LogEvent event = appender.events().get(0);
- System.out.println("event=" + event);
-
-// assertThat(event.getLoggerName()).isEqualTo(logLogger);
-// assertThat(event.getLevel()).isEqualTo(logLevel);
-// assertThat(event.getMessage().getFormattedMessage()).isEqualTo(logMessage);
-//
-// assertThat(systemOut).contains(logLevel.name());
-// assertThat(systemOut).contains(logMessage);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/0fc02aee/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_xml_MinimalistWithLocatorLauncherRemoteIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_xml_MinimalistWithLocatorLauncherRemoteIntegrationTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_xml_MinimalistWithLocatorLauncherRemoteIntegrationTest.java
deleted file mode 100644
index 19c8162..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_xml_MinimalistWithLocatorLauncherRemoteIntegrationTest.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.gemstone.gemfire.internal.logging.log4j.custom;
-
-import static org.assertj.core.api.Assertions.*;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.net.URL;
-import java.util.Properties;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.contrib.java.lang.system.RestoreSystemProperties;
-import org.junit.contrib.java.lang.system.SystemErrRule;
-import org.junit.contrib.java.lang.system.SystemOutRule;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.ExternalResource;
-import org.junit.rules.TemporaryFolder;
-
-import com.gemstone.gemfire.cache.Cache;
-import com.gemstone.gemfire.cache.CacheFactory;
-import com.gemstone.gemfire.distributed.LocatorLauncher;
-import com.gemstone.gemfire.distributed.internal.DistributionConfig;
-import com.gemstone.gemfire.internal.AvailablePort;
-import com.gemstone.gemfire.internal.cache.AbstractCacheServer;
-import com.gemstone.gemfire.internal.logging.LogService;
-import com.gemstone.gemfire.internal.logging.log4j.Configurator;
-import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-
-/**
- * Integration tests with custom log4j2 configuration.
- */
-@Category(IntegrationTest.class)
-public class Custom_log4j2_xml_MinimalistWithLocatorLauncherRemoteIntegrationTest {
-
- private static final String CUSTOM_CONFIG_FILE_NAME = "log4j2.xml";
-
- @Rule
- public SystemErrRule systemErrRule = new SystemErrRule().enableLog();
-
- @Rule
- public SystemOutRule systemOutRule = new SystemOutRule().enableLog();
-
- @Rule
- public TemporaryFolder temporaryFolder = new TemporaryFolder();
-
- private String beforeConfigFileProp;
- private Level beforeLevel;
-
- private File customConfigFile;
-
- @Before
- public void setUp() throws Exception {
- URL customConfigResource = getClass().getResource(CUSTOM_CONFIG_FILE_NAME);
- File temporaryFile = this.temporaryFolder.newFile(CUSTOM_CONFIG_FILE_NAME);
-
- IOUtils.copy(customConfigResource.openStream(), new FileOutputStream(temporaryFile));
- assertThat(temporaryFile).hasSameContentAs(new File(customConfigResource.toURI()));
-
- System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, temporaryFile.getAbsolutePath());
-
- //assertThat(LogService.isUsingGemFireDefaultConfig()).as(LogService.getConfigInformation()).isFalse();
-
- this.customConfigFile = temporaryFile;
-
- System.setProperty(AbstractCacheServer.TEST_OVERRIDE_DEFAULT_PORT_PROPERTY, String.valueOf(0));
- }
-
- @After
- public void tearDown() throws Exception {
- BasicAppender.clearInstance();
- }
-
- @Test
- public void foo() throws Exception {
- LocatorLauncher launcher = new LocatorLauncher.Builder()
- .setCommand(LocatorLauncher.Command.START)
- .set(DistributionConfig.LOCATORS_NAME, "")
- .set(DistributionConfig.MCAST_PORT_NAME, "0")
- .setMemberName("membername")
- .setPort(AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET))
- .build();
-
- launcher.start();
-
- String logLogger = getClass().getName();
- Level logLevel = Level.DEBUG;
- String logMessage = "this is a log statement";
-
- Logger logger = LogService.getLogger();
- assertThat(LogService.isUsingGemFireDefaultConfig()).as(LogService.getConfigInformation()).isFalse();
-
- logger.debug(logMessage);
-
- String systemOut = systemOutRule.getLog();
- String systemErr = systemErrRule.getLog();
-
- System.out.println("this.customConfigFile=" + this.customConfigFile);
- System.out.println("BasicAppender=" + BasicAppender.getInstance());
- System.out.println("CONFIGURATION_FILE_PROPERTY=" + System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY));
- System.out.println("out=" + systemOut.trim());
-
- BasicAppender appender = BasicAppender.getInstance();
- assertThat(appender).isNotNull();
-// assertThat(appender.events()).hasSize(1);
-
- LogEvent event = appender.events().get(0);
- System.out.println("event=" + event);
-
-// assertThat(event.getLoggerName()).isEqualTo(logLogger);
-// assertThat(event.getLevel()).isEqualTo(logLevel);
-// assertThat(event.getMessage().getFormattedMessage()).isEqualTo(logMessage);
-//
-// assertThat(systemOut).contains(logLevel.name());
-// assertThat(systemOut).contains(logMessage);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/0fc02aee/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_xml_MinimalistWithServerLauncherIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_xml_MinimalistWithServerLauncherIntegrationTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_xml_MinimalistWithServerLauncherIntegrationTest.java
deleted file mode 100644
index 53b5d2b..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_xml_MinimalistWithServerLauncherIntegrationTest.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.gemstone.gemfire.internal.logging.log4j.custom;
-
-import static org.assertj.core.api.Assertions.*;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.net.URL;
-import java.util.Properties;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.contrib.java.lang.system.RestoreSystemProperties;
-import org.junit.contrib.java.lang.system.SystemErrRule;
-import org.junit.contrib.java.lang.system.SystemOutRule;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.ExternalResource;
-import org.junit.rules.TemporaryFolder;
-
-import com.gemstone.gemfire.cache.Cache;
-import com.gemstone.gemfire.cache.CacheFactory;
-import com.gemstone.gemfire.distributed.ServerLauncher;
-import com.gemstone.gemfire.distributed.internal.DistributionConfig;
-import com.gemstone.gemfire.internal.cache.AbstractCacheServer;
-import com.gemstone.gemfire.internal.logging.LogService;
-import com.gemstone.gemfire.internal.logging.log4j.Configurator;
-import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-
-/**
- * Integration tests with custom log4j2 configuration.
- */
-@Category(IntegrationTest.class)
-public class Custom_log4j2_xml_MinimalistWithServerLauncherIntegrationTest {
-
- private static final String CUSTOM_CONFIG_FILE_NAME = "log4j2.xml";
-
- @Rule
- public SystemErrRule systemErrRule = new SystemErrRule().enableLog();
-
- @Rule
- public SystemOutRule systemOutRule = new SystemOutRule().enableLog();
-
- @Rule
- public TemporaryFolder temporaryFolder = new TemporaryFolder();
-
- private String beforeConfigFileProp;
- private Level beforeLevel;
-
- private File customConfigFile;
-
- @Before
- public void setUp() throws Exception {
- URL customConfigResource = getClass().getResource(CUSTOM_CONFIG_FILE_NAME);
- File temporaryFile = this.temporaryFolder.newFile(CUSTOM_CONFIG_FILE_NAME);
-
- IOUtils.copy(customConfigResource.openStream(), new FileOutputStream(temporaryFile));
- assertThat(temporaryFile).hasSameContentAs(new File(customConfigResource.toURI()));
-
- System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, temporaryFile.getAbsolutePath());
-
- //assertThat(LogService.isUsingGemFireDefaultConfig()).as(LogService.getConfigInformation()).isFalse();
-
- this.customConfigFile = temporaryFile;
-
- System.setProperty(AbstractCacheServer.TEST_OVERRIDE_DEFAULT_PORT_PROPERTY, String.valueOf(0));
- }
-
- @After
- public void tearDown() throws Exception {
- BasicAppender.clearInstance();
- }
-
- @Test
- public void foo() throws Exception {
- Properties gemfireProperties = new Properties();
- gemfireProperties.put(DistributionConfig.LOCATORS_NAME, "");
- gemfireProperties.put(DistributionConfig.MCAST_PORT_NAME, "0");
- gemfireProperties.put(DistributionConfig.LOG_LEVEL_NAME, "info");
-
- ServerLauncher launcher = new ServerLauncher.Builder()
- .setCommand(ServerLauncher.Command.START)
- .set(DistributionConfig.LOCATORS_NAME, "")
- .set(DistributionConfig.MCAST_PORT_NAME, "0")
- .setMemberName("membername")
- .build();
-
- launcher.start();
-
- String logLogger = getClass().getName();
- Level logLevel = Level.DEBUG;
- String logMessage = "this is a log statement";
-
- Logger logger = LogService.getLogger();
- assertThat(LogService.isUsingGemFireDefaultConfig()).as(LogService.getConfigInformation()).isFalse();
-
- logger.debug(logMessage);
-
- String systemOut = systemOutRule.getLog();
- String systemErr = systemErrRule.getLog();
-
- System.out.println("this.customConfigFile=" + this.customConfigFile);
- System.out.println("BasicAppender=" + BasicAppender.getInstance());
- System.out.println("CONFIGURATION_FILE_PROPERTY=" + System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY));
- System.out.println("out=" + systemOut.trim());
-
- BasicAppender appender = BasicAppender.getInstance();
- assertThat(appender).isNotNull();
-// assertThat(appender.events()).hasSize(1);
-
- LogEvent event = appender.events().get(0);
- System.out.println("event=" + event);
-
-// assertThat(event.getLoggerName()).isEqualTo(logLogger);
-// assertThat(event.getLevel()).isEqualTo(logLevel);
-// assertThat(event.getMessage().getFormattedMessage()).isEqualTo(logMessage);
-//
-// assertThat(systemOut).contains(logLevel.name());
-// assertThat(systemOut).contains(logMessage);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/0fc02aee/geode-core/src/test/resources/com/gemstone/gemfire/internal/logging/log4j/custom/log4j2-custom.xml
----------------------------------------------------------------------
diff --git a/geode-core/src/test/resources/com/gemstone/gemfire/internal/logging/log4j/custom/log4j2-custom.xml b/geode-core/src/test/resources/com/gemstone/gemfire/internal/logging/log4j/custom/log4j2-custom.xml
index 27a9757..dbdd402 100644
--- a/geode-core/src/test/resources/com/gemstone/gemfire/internal/logging/log4j/custom/log4j2-custom.xml
+++ b/geode-core/src/test/resources/com/gemstone/gemfire/internal/logging/log4j/custom/log4j2-custom.xml
@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="FATAL" shutdownHook="disable" packages="com.gemstone.gemfire.internal.logging.log4j.custom">
+ <Properties>
+ <Property name="custom-pattern">CUSTOM: level=%level time=%date{yyyy/MM/dd HH:mm:ss.SSS z} message=%message%nthrowable=%throwable%n</Property>
+ </Properties>
<Appenders>
<Console name="STDOUT" target="SYSTEM_OUT">
- <PatternLayout pattern="%level %date{yyyy/MM/dd HH:mm:ss.SSS z} %message%n %throwable%n"/>
+ <PatternLayout pattern="${custom-pattern}"/>
</Console>
- <!--Appender type="Basic" name="CUSTOM">
- <PatternLayout pattern="level=%level time=%date{yyyy/MM/dd HH:mm:ss.SSS z} message=%message%n throwable=%throwable%n"/>
- </Appender-->
<Basic name="CUSTOM">
- <PatternLayout pattern="level=%level time=%date{yyyy/MM/dd HH:mm:ss.SSS z} message=%message%n throwable=%throwable%n"/>
+ <PatternLayout pattern="${custom-pattern}"/>
</Basic>
</Appenders>
<Loggers>
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/0fc02aee/geode-core/src/test/resources/com/gemstone/gemfire/internal/logging/log4j/custom/log4j2.xml
----------------------------------------------------------------------
diff --git a/geode-core/src/test/resources/com/gemstone/gemfire/internal/logging/log4j/custom/log4j2.xml b/geode-core/src/test/resources/com/gemstone/gemfire/internal/logging/log4j/custom/log4j2.xml
deleted file mode 100644
index 27a9757..0000000
--- a/geode-core/src/test/resources/com/gemstone/gemfire/internal/logging/log4j/custom/log4j2.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<Configuration status="FATAL" shutdownHook="disable" packages="com.gemstone.gemfire.internal.logging.log4j.custom">
- <Appenders>
- <Console name="STDOUT" target="SYSTEM_OUT">
- <PatternLayout pattern="%level %date{yyyy/MM/dd HH:mm:ss.SSS z} %message%n %throwable%n"/>
- </Console>
- <!--Appender type="Basic" name="CUSTOM">
- <PatternLayout pattern="level=%level time=%date{yyyy/MM/dd HH:mm:ss.SSS z} message=%message%n throwable=%throwable%n"/>
- </Appender-->
- <Basic name="CUSTOM">
- <PatternLayout pattern="level=%level time=%date{yyyy/MM/dd HH:mm:ss.SSS z} message=%message%n throwable=%throwable%n"/>
- </Basic>
- </Appenders>
- <Loggers>
- <Logger name="com.gemstone" level="INFO" additivity="true">
- <filters>
- <MarkerFilter marker="GEMFIRE_VERBOSE" onMatch="DENY" onMismatch="NEUTRAL"/>
- </filters>
- </Logger>
- <Logger name="org.jgroups" level="FATAL" additivity="true"/>
- <Logger name="com.gemstone.gemfire.internal.logging.log4j.custom" level="DEBUG" additivity="true"/>
- <Root level="INFO">
- <AppenderRef ref="CUSTOM"/>
- <AppenderRef ref="STDOUT"/>
- </Root>
- </Loggers>
-</Configuration>