You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2020/12/11 07:58:26 UTC
[skywalking] branch master updated: Fix logger-plugin module
directory structure problem(Maven cannot trigger junit testing). (#5987)
This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking.git
The following commit(s) were added to refs/heads/master by this push:
new a57c158 Fix logger-plugin module directory structure problem(Maven cannot trigger junit testing). (#5987)
a57c158 is described below
commit a57c158c7724f1fbe2537c230c40a2517d9a0dd5
Author: zifeihan <de...@gmail.com>
AuthorDate: Fri Dec 11 15:58:06 2020 +0800
Fix logger-plugin module directory structure problem(Maven cannot trigger junit testing). (#5987)
---
.../skywalking/apm/plugin/logger/ContextConfig.java | 8 ++++++++
.../apm/plugin/logger/ContextConfigDefaultTest.java | 3 ++-
.../apm/plugin/logger/ContextConfigExceptionTest.java | 15 +++++++++------
.../skywalking/apm/plugin/logger/ContextConfigTest.java | 13 ++++++-------
4 files changed, 25 insertions(+), 14 deletions(-)
diff --git a/apm-sniffer/optional-plugins/logger-plugin/src/main/java/org/apache/skywalking/apm/plugin/logger/ContextConfig.java b/apm-sniffer/optional-plugins/logger-plugin/src/main/java/org/apache/skywalking/apm/plugin/logger/ContextConfig.java
index 7213590..5725ee6 100644
--- a/apm-sniffer/optional-plugins/logger-plugin/src/main/java/org/apache/skywalking/apm/plugin/logger/ContextConfig.java
+++ b/apm-sniffer/optional-plugins/logger-plugin/src/main/java/org/apache/skywalking/apm/plugin/logger/ContextConfig.java
@@ -58,6 +58,14 @@ public class ContextConfig {
return HolderContextConfig.INSTANCE;
}
+ /**
+ * For testing use only.
+ * Avoid to use config cache. Load the configuration every time.
+ */
+ static ContextConfig getLatestConfig() {
+ return HolderContextConfig.initContextConfig();
+ }
+
//use singleton
private static class HolderContextConfig {
private final static ContextConfig INSTANCE = initContextConfig();
diff --git a/apm-sniffer/optional-plugins/logger-plugin/src/test/org/apache/skywalking/apm/plugin/logger/ContextConfigDefaultTest.java b/apm-sniffer/optional-plugins/logger-plugin/src/test/java/org/apache/skywalking/apm/plugin/logger/ContextConfigDefaultTest.java
similarity index 96%
rename from apm-sniffer/optional-plugins/logger-plugin/src/test/org/apache/skywalking/apm/plugin/logger/ContextConfigDefaultTest.java
rename to apm-sniffer/optional-plugins/logger-plugin/src/test/java/org/apache/skywalking/apm/plugin/logger/ContextConfigDefaultTest.java
index dbdd27f..64f9f33 100644
--- a/apm-sniffer/optional-plugins/logger-plugin/src/test/org/apache/skywalking/apm/plugin/logger/ContextConfigDefaultTest.java
+++ b/apm-sniffer/optional-plugins/logger-plugin/src/test/java/org/apache/skywalking/apm/plugin/logger/ContextConfigDefaultTest.java
@@ -15,6 +15,7 @@
* limitations under the License.
*
*/
+
package org.apache.skywalking.apm.plugin.logger;
import org.junit.Test;
@@ -24,7 +25,7 @@ import static org.junit.Assert.assertEquals;
public class ContextConfigDefaultTest {
@Test
public void testDefaultConfig() {
- ContextConfig config = ContextConfig.getInstance();
+ ContextConfig config = ContextConfig.getLatestConfig();
ContextConfig.LoggerConfig log4jConfig = config.getLog4jConfig();
ContextConfig.LoggerConfig log4j2Config = config.getLog4j2Config();
ContextConfig.LoggerConfig logbackConfig = config.getLogbackConfig();
diff --git a/apm-sniffer/optional-plugins/logger-plugin/src/test/org/apache/skywalking/apm/plugin/logger/ContextConfigExceptionTest.java b/apm-sniffer/optional-plugins/logger-plugin/src/test/java/org/apache/skywalking/apm/plugin/logger/ContextConfigExceptionTest.java
similarity index 93%
rename from apm-sniffer/optional-plugins/logger-plugin/src/test/org/apache/skywalking/apm/plugin/logger/ContextConfigExceptionTest.java
rename to apm-sniffer/optional-plugins/logger-plugin/src/test/java/org/apache/skywalking/apm/plugin/logger/ContextConfigExceptionTest.java
index 2b9f579..779dc30 100644
--- a/apm-sniffer/optional-plugins/logger-plugin/src/test/org/apache/skywalking/apm/plugin/logger/ContextConfigExceptionTest.java
+++ b/apm-sniffer/optional-plugins/logger-plugin/src/test/java/org/apache/skywalking/apm/plugin/logger/ContextConfigExceptionTest.java
@@ -15,20 +15,21 @@
* limitations under the License.
*
*/
-package org.apache.skywalking.apm.plugin.logger;
-import org.apache.skywalking.apm.agent.core.boot.AgentPackageNotFoundException;
-import org.apache.skywalking.apm.agent.core.boot.AgentPackagePath;
-import org.junit.*;
+package org.apache.skywalking.apm.plugin.logger;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Properties;
+import org.apache.skywalking.apm.agent.core.boot.AgentPackageNotFoundException;
+import org.apache.skywalking.apm.agent.core.boot.AgentPackagePath;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
import static org.junit.Assert.assertEquals;
-
public class ContextConfigExceptionTest {
@Before
public void setup() throws AgentPackageNotFoundException, IOException {
@@ -52,6 +53,8 @@ public class ContextConfigExceptionTest {
properties.setProperty("logback.packages", "package1,package2");
properties.setProperty("log4j.level", "debug");
properties.setProperty("log4j.packages", "*");
+ properties.setProperty("log4j2.level", "error");
+ properties.setProperty("log4j.packages", "*");
FileWriter writer = new FileWriter(configFilePath);
properties.store(writer, "set fatal level for logback");
writer.flush();
@@ -61,7 +64,7 @@ public class ContextConfigExceptionTest {
@Test
public void testHasConfigError() {
- ContextConfig config = ContextConfig.getInstance();
+ ContextConfig config = ContextConfig.getLatestConfig();
ContextConfig.LoggerConfig logbackConfig = config.getLogbackConfig();
ContextConfig.LoggerConfig log4jConfig = config.getLog4jConfig();
ContextConfig.LoggerConfig log4j2Config = config.getLog4j2Config();
diff --git a/apm-sniffer/optional-plugins/logger-plugin/src/test/org/apache/skywalking/apm/plugin/logger/ContextConfigTest.java b/apm-sniffer/optional-plugins/logger-plugin/src/test/java/org/apache/skywalking/apm/plugin/logger/ContextConfigTest.java
similarity index 97%
rename from apm-sniffer/optional-plugins/logger-plugin/src/test/org/apache/skywalking/apm/plugin/logger/ContextConfigTest.java
rename to apm-sniffer/optional-plugins/logger-plugin/src/test/java/org/apache/skywalking/apm/plugin/logger/ContextConfigTest.java
index 895c75f..d24b274 100644
--- a/apm-sniffer/optional-plugins/logger-plugin/src/test/org/apache/skywalking/apm/plugin/logger/ContextConfigTest.java
+++ b/apm-sniffer/optional-plugins/logger-plugin/src/test/java/org/apache/skywalking/apm/plugin/logger/ContextConfigTest.java
@@ -15,20 +15,19 @@
* limitations under the License.
*
*/
+
package org.apache.skywalking.apm.plugin.logger;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.Properties;
import org.apache.skywalking.apm.agent.core.boot.AgentPackageNotFoundException;
import org.apache.skywalking.apm.agent.core.boot.AgentPackagePath;
import org.junit.After;
-import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.Properties;
-
import static org.junit.Assert.assertEquals;
public class ContextConfigTest {
@@ -64,7 +63,7 @@ public class ContextConfigTest {
@Test
public void testTwoLogger() {
// test
- ContextConfig config = ContextConfig.getInstance();
+ ContextConfig config = ContextConfig.getLatestConfig();
ContextConfig.LoggerConfig logbackConfig = config.getLogbackConfig();
ContextConfig.LoggerConfig log4jConfig = config.getLog4jConfig();
ContextConfig.LoggerConfig log4j2Config = config.getLog4j2Config();