Add 'log4j2' domain tests to the Log4j 2.x agent
authorMichael Jeanson <mjeanson@efficios.com>
Wed, 2 Feb 2022 22:53:52 +0000 (22:53 +0000)
committerMichael Jeanson <mjeanson@efficios.com>
Tue, 15 Feb 2022 20:06:36 +0000 (20:06 +0000)
The Log4j 2.x agent now supports registering with 2 different tracing
domains, the existing 'log4j' domain and the new 'log4j2' domain.

The following tags were added to filter the tests when running the test
suite :

  - agent:jul
  - agent:log4j
  - agent:log4j2
  - domain:jul
  - domain:log4j
  - domain:log4j2
  - benchmark

For example, we can exclude all the log4j2 agent tests when testing a
version of LTTng that doesn't implement it :

  mvn clean verify -Dgroups='!agent:log4j2'

Or to run only the log4j domain tests on all agents that include them :

  mvn clean verify -Dgroups='domain:log4j'

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
81 files changed:
README.md
lttng-tools-java/src/main/java/org/lttng/tools/ILttngSession.java
lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/integration/filter/FilterListenerITBase.java
lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/integration/filter/FilterListenerOrderingITBase.java
lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/utils/EventRuleFactory.java
lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/utils/ILogLevelStrings.java
lttng-ust-java-tests-common/src/test/java/org/lttng/ust/agent/integration/client/TcpClientIT.java
lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/JulHandlerBenchmarkBase.java
lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/builtin/DummyHandlerBenchmark.java
lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/builtin/FileHandlerBenchmark.java
lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/builtin/NoHandlerBenchmark.java
lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/builtin/NoLoggerBenchmark.java
lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/LttngJulHandlerTracingDisabledBenchmark.java
lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/LttngJulHandlerTracingEnabledBenchmark.java
lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/old/OldLttngJulHandlerTracingDisabledBenchmark.java
lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/old/OldLttngJulHandlerTracingEnabledBenchmark.java
lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/context/JulAppContextIT.java
lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/context/JulAppContextOrderingIT.java
lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulEnabledEventsIT.java
lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulLegacyApiIT.java
lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulLegacyApiLoggerHierarchyListIT.java
lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulListEventsIT.java
lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulLoggerHierarchyListIT.java
lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulMultiSessionIT.java
lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/filter/JulFilterListenerIT.java
lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/filter/JulFilterListenerOrderingIT.java
lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/context/Log4jAppContextIT.java
lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/context/Log4jAppContextOrderingIT.java
lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/events/Log4jEnabledEventsIT.java
lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/events/Log4jLegacyApiIT.java
lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/events/Log4jListEventsIT.java
lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/events/Log4jMultiSessionIT.java
lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/filter/Log4jFilterListenerIT.java
lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/filter/Log4jFilterListenerOrderingIT.java
lttng-ust-java-tests-log4j2/.classpath
lttng-ust-java-tests-log4j2/pom.xml
lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/integration/context/Log4j2AppContextITBase.java [new file with mode: 0644]
lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/integration/context/Log4j2AppContextOrderingITBase.java [new file with mode: 0644]
lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/integration/events/Log4j2EnabledEventsITBase.java [new file with mode: 0644]
lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/integration/events/Log4j2ListEventsITBase.java [new file with mode: 0644]
lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/integration/events/Log4j2MultiSessionITBase.java [new file with mode: 0644]
lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/integration/filter/Log4j2FilterListenerITBase.java [new file with mode: 0644]
lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/integration/filter/Log4j2FilterListenerOrderingITBase.java [new file with mode: 0644]
lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/utils/Log4j2TestContext.java [new file with mode: 0644]
lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/utils/Log4j2TestUtils.java [new file with mode: 0644]
lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/context/Log4j2AppContextIT.java
lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/context/Log4j2AppContextOrderingIT.java
lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/context/Log4j2CompatAppContextIT.java [new file with mode: 0644]
lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/context/Log4j2CompatAppContextOrderingIT.java [new file with mode: 0644]
lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/events/Log4j2CompatEnabledEventsIT.java [new file with mode: 0644]
lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/events/Log4j2CompatListEventsIT.java [new file with mode: 0644]
lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/events/Log4j2CompatMultiSessionIT.java [new file with mode: 0644]
lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/events/Log4j2EnabledEventsIT.java
lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/events/Log4j2ListEventsIT.java
lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/events/Log4j2MultiSessionIT.java
lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/filter/Log4j2CompatFilterListenerIT.java [new file with mode: 0644]
lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/filter/Log4j2CompatFilterListenerOrderingIT.java [new file with mode: 0644]
lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/filter/Log4j2FilterListenerIT.java
lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/filter/Log4j2FilterListenerOrderingIT.java
lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/utils/Log4j2TestContext.java [deleted file]
lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/utils/Log4j2TestUtils.java [deleted file]
lttng-ust-java-tests-log4j2/src/test/resources/log4j2.LOG4J2testManyLoggersAllAttached.xml [new file with mode: 0644]
lttng-ust-java-tests-log4j2/src/test/resources/log4j2.LOG4J2testManyLoggersNoneAttached.xml [new file with mode: 0644]
lttng-ust-java-tests-log4j2/src/test/resources/log4j2.LOG4J2testManyLoggersSomeAttached.xml [new file with mode: 0644]
lttng-ust-java-tests-log4j2/src/test/resources/log4j2.LOG4JtestManyLoggersAllAttached.xml [new file with mode: 0644]
lttng-ust-java-tests-log4j2/src/test/resources/log4j2.LOG4JtestManyLoggersNoneAttached.xml [new file with mode: 0644]
lttng-ust-java-tests-log4j2/src/test/resources/log4j2.LOG4JtestManyLoggersSomeAttached.xml [new file with mode: 0644]
lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2AppContextIT.xml
lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2AppContextOrderingIT.xml
lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2CompatAppContextIT.xml [new file with mode: 0644]
lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2CompatAppContextOrderingIT.xml [new file with mode: 0644]
lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2CompatEnabledEventsIT.xml [new file with mode: 0644]
lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2CompatFilterListenerOrderingIT.xml [new file with mode: 0644]
lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2CompatMultiSessionIT.xml [new file with mode: 0644]
lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2EnabledEventsIT.xml
lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2FilterListenerOrderingIT.xml
lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2MultiSessionIT.xml
lttng-ust-java-tests-log4j2/src/test/resources/log4j2.testManyLoggersAllAttached.xml [deleted file]
lttng-ust-java-tests-log4j2/src/test/resources/log4j2.testManyLoggersNoneAttached.xml [deleted file]
lttng-ust-java-tests-log4j2/src/test/resources/log4j2.testManyLoggersSomeAttached.xml [deleted file]
pom.xml

index 6d1f5fa785918628757e2c4f1e19c7ff6b411c8b..cf1c566693b8c8af35620ba31a9028c01de7c3a4 100644 (file)
--- a/README.md
+++ b/README.md
@@ -98,6 +98,20 @@ the first test set that is empty. See [2] for more info.
 [1] http://maven.apache.org/surefire/maven-failsafe-plugin/index.html
 [2] http://maven.apache.org/surefire/maven-failsafe-plugin/examples/single-test.html
 
+Running tests by tags
+---------------------
+
+Tests can also be filtered by Junit tags or tag expressions [1], for example to
+run only the Log4 1.x agent tests:
+
+    mvn clean verify -Dgroups='agent:log4j'
+
+Or to exclude the tests of the Log4j2 domain:
+
+   mvn clean verify -Dgroups='!domain:log4j2'
+
+[1] https://junit.org/junit5/docs/current/user-guide/#running-tests-tags
+
 Debugging a test
 ----------------------
 
index 414e3fb03c19cd9dd42699f4c65f369e85885748..faecc0c96bda1fcd2305fac35d0ee078388f8533 100644 (file)
@@ -32,13 +32,18 @@ public interface ILttngSession extends AutoCloseable {
      */
     enum Domain {
         /** The JUL (java.util.logging) domain */
-        JUL("-j"), /** The log4j (org.apache.log4j) domain */
-        LOG4J("-l");
+        JUL("--jul", ">=", Integer.MIN_VALUE), /** The log4j (org.apache.log4j) domain */
+        LOG4J("--log4j", ">=", Integer.MIN_VALUE),
+        LOG4J2("--log4j2", "<=", Integer.MAX_VALUE);
 
         private final String flag;
+        private final String rangeOperator;
+        private final int levelAllValue;
 
-        private Domain(String flag) {
+        private Domain(String flag, String rangeOperator, int levelAllValue) {
             this.flag = flag;
+            this.rangeOperator = rangeOperator;
+            this.levelAllValue = levelAllValue;
         }
 
         /**
@@ -48,6 +53,14 @@ public interface ILttngSession extends AutoCloseable {
         public String flag() {
             return flag;
         }
+
+        public String rangeOperator() {
+            return rangeOperator;
+        }
+
+        public int levelAllValue() {
+            return levelAllValue;
+        }
     }
 
     // ------------------------------------------------------------------------
index 7712b46cd9f5509c98f8471e7f1500982f09a487..c3b54753bef692180f0a2b19696237829f4da0e2 100644 (file)
@@ -58,10 +58,19 @@ public abstract class FilterListenerITBase {
     private TestFilterListener listener;
     private ILttngHandler handler;
 
+    protected EventRuleFactory eventRuleFactory;
+
     protected abstract ILttngSession.Domain getSessionDomain();
     protected abstract ILttngHandler getLogHandler() throws SecurityException, IOException;
     protected abstract ILogLevelStrings getLogLevelStrings();
 
+    protected EventRuleFactory getEventRuleFactory() {
+        if (eventRuleFactory == null) {
+            eventRuleFactory = new EventRuleFactory(getSessionDomain());
+        }
+        return eventRuleFactory;
+    }
+
     /**
      * Test setup
      *
@@ -104,7 +113,7 @@ public abstract class FilterListenerITBase {
     @Test
     public void testOneRule() {
         Set<EventRule> rules = Collections.singleton(
-                EventRuleFactory.createRule(EVENT_NAME_A));
+                getEventRuleFactory().createRule(EVENT_NAME_A));
 
         session.enableEvent(EVENT_NAME_A, null, false, null);
 
@@ -118,9 +127,9 @@ public abstract class FilterListenerITBase {
     @Test
     public void testManyRules() {
         Set<EventRule> rules = Stream.of(
-                    EventRuleFactory.createRule(EVENT_NAME_A),
-                    EventRuleFactory.createRule(EVENT_NAME_B),
-                    EventRuleFactory.createRule(EVENT_NAME_C))
+                getEventRuleFactory().createRule(EVENT_NAME_A),
+                getEventRuleFactory().createRule(EVENT_NAME_B),
+                getEventRuleFactory().createRule(EVENT_NAME_C))
                 .collect(Collectors.toSet());
 
         session.enableEvent(EVENT_NAME_A, null, false, null);
@@ -137,7 +146,7 @@ public abstract class FilterListenerITBase {
     @Test
     public void testManyRulesDisableSome() {
         Set<EventRule> rules = Collections.singleton(
-                EventRuleFactory.createRule(EVENT_NAME_A));
+                getEventRuleFactory().createRule(EVENT_NAME_A));
 
         session.enableEvent(EVENT_NAME_A, null, false, null);
         session.enableEvent(EVENT_NAME_B, null, false, null);
@@ -179,9 +188,9 @@ public abstract class FilterListenerITBase {
         LogLevelSelector lls3 = new LogLevelSelector(getLogLevelStrings().infoInt(), LogLevelType.LTTNG_EVENT_LOGLEVEL_RANGE);
 
         Set<EventRule> rules = Stream.of(
-                    EventRuleFactory.createRule(EVENT_NAME_A, lls1),
-                    EventRuleFactory.createRule(EVENT_NAME_A, lls2),
-                    EventRuleFactory.createRule(EVENT_NAME_A, lls3))
+                getEventRuleFactory().createRule(EVENT_NAME_A, lls1),
+                getEventRuleFactory().createRule(EVENT_NAME_A, lls2),
+                getEventRuleFactory().createRule(EVENT_NAME_A, lls3))
                 .collect(Collectors.toSet());
 
         session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), false, null);
@@ -201,9 +210,9 @@ public abstract class FilterListenerITBase {
         String filterB = "filterB";
 
         Set<EventRule> rules = Stream.of(
-                    EventRuleFactory.createRule(EVENT_NAME_A),
-                    EventRuleFactory.createRule(EVENT_NAME_B, EventRuleFactory.LOG_LEVEL_UNSPECIFIED, filterA),
-                    EventRuleFactory.createRule(EVENT_NAME_C, EventRuleFactory.LOG_LEVEL_UNSPECIFIED, filterB))
+                getEventRuleFactory().createRule(EVENT_NAME_A),
+                getEventRuleFactory().createRule(EVENT_NAME_B, getEventRuleFactory().LOG_LEVEL_UNSPECIFIED, filterA),
+                getEventRuleFactory().createRule(EVENT_NAME_C, getEventRuleFactory().LOG_LEVEL_UNSPECIFIED, filterB))
                 .collect(Collectors.toSet());
 
         session.enableEvent(EVENT_NAME_A, null, false, null);
@@ -221,8 +230,8 @@ public abstract class FilterListenerITBase {
     @Test
     public void testDetachingListener() {
         Set<EventRule> rules = Stream.of(
-                        EventRuleFactory.createRule(EVENT_NAME_A),
-                        EventRuleFactory.createRule(EVENT_NAME_B))
+                getEventRuleFactory().createRule(EVENT_NAME_A),
+                getEventRuleFactory().createRule(EVENT_NAME_B))
                 .collect(Collectors.toSet());
 
         session.enableEvent(EVENT_NAME_A, null, false, null);
@@ -247,8 +256,8 @@ public abstract class FilterListenerITBase {
         fcn.registerListener(listener3);
 
         Set<EventRule> rules = Stream.of(
-                EventRuleFactory.createRule(EVENT_NAME_A),
-                EventRuleFactory.createRule(EVENT_NAME_B))
+                getEventRuleFactory().createRule(EVENT_NAME_A),
+                getEventRuleFactory().createRule(EVENT_NAME_B))
             .collect(Collectors.toSet());
 
         session.enableEvent(EVENT_NAME_A, null, false, null);
@@ -284,8 +293,8 @@ public abstract class FilterListenerITBase {
         fcn.unregisterListener(listener2);
 
         Set<EventRule> rules = Stream.of(
-                EventRuleFactory.createRule(EVENT_NAME_A),
-                EventRuleFactory.createRule(EVENT_NAME_B))
+                getEventRuleFactory().createRule(EVENT_NAME_A),
+                getEventRuleFactory().createRule(EVENT_NAME_B))
             .collect(Collectors.toSet());
 
         session.enableEvent(EVENT_NAME_A, null, false, null);
@@ -311,12 +320,12 @@ public abstract class FilterListenerITBase {
         TestFilterListener listener2 = new TestFilterListener();
 
         Set<EventRule> rules1 = Stream.of(
-                EventRuleFactory.createRule(EVENT_NAME_A),
-                EventRuleFactory.createRule(EVENT_NAME_B))
+                getEventRuleFactory().createRule(EVENT_NAME_A),
+                getEventRuleFactory().createRule(EVENT_NAME_B))
             .collect(Collectors.toSet());
         Set<EventRule> rules2 = Stream.of(
-                EventRuleFactory.createRule(EVENT_NAME_A),
-                EventRuleFactory.createRule(EVENT_NAME_C))
+                getEventRuleFactory().createRule(EVENT_NAME_A),
+                getEventRuleFactory().createRule(EVENT_NAME_C))
             .collect(Collectors.toSet());
 
         session.enableEvent(EVENT_NAME_A, null, false, null);
index 4e344e05d3c891bb3b3871e7badab359ae0fad43..fd707024c9e9194f6f95b8f878f831376051df30 100644 (file)
@@ -74,6 +74,8 @@ public abstract class FilterListenerOrderingITBase {
     protected static final String EVENT_NAME_A = "EventA";
     private static final String EVENT_NAME_B = "EventB";
 
+    protected EventRuleFactory eventRuleFactory;
+
     private ILttngSession session;
     private TestFilterListener listener;
 
@@ -116,6 +118,13 @@ public abstract class FilterListenerOrderingITBase {
         session = null;
     }
 
+    protected EventRuleFactory getEventRuleFactory() {
+        if (eventRuleFactory == null) {
+            eventRuleFactory = new EventRuleFactory(getDomain());
+        }
+        return eventRuleFactory;
+    }
+
     // ------------------------------------------------------------------------
     // Test methods
     // ------------------------------------------------------------------------
@@ -126,8 +135,8 @@ public abstract class FilterListenerOrderingITBase {
      */
     private void checkOngoingConditions() {
         Set<EventRule> exptectedRules = Stream.of(
-                EventRuleFactory.createRule(EVENT_NAME_A),
-                EventRuleFactory.createRule(EVENT_NAME_B))
+                getEventRuleFactory().createRule(EVENT_NAME_A),
+                getEventRuleFactory().createRule(EVENT_NAME_B))
                 .collect(Collectors.toSet());
 
         assertEquals(2, listener.getNbNotifications());
index fd1a46b34a2b9b5f098cd819469ae128ac5ebeae..2b99e32f08380524df42aa9b02484991a1702da2 100644 (file)
@@ -20,6 +20,7 @@ package org.lttng.ust.agent.utils;
 
 import java.util.StringJoiner;
 
+import org.lttng.tools.ILttngSession;
 import org.lttng.ust.agent.session.EventRule;
 import org.lttng.ust.agent.session.LogLevelSelector;
 
@@ -29,15 +30,25 @@ import org.lttng.ust.agent.session.LogLevelSelector;
  *
  * @author Alexandre Montplaisir
  */
-public final class EventRuleFactory {
+public class EventRuleFactory {
 
     /** Name of the "all" (-a) event */
     public static final String EVENT_NAME_ALL = "*";
 
     /** Log level set by default when it is not specified */
-    public static final LogLevelSelector LOG_LEVEL_UNSPECIFIED = new LogLevelSelector(Integer.MIN_VALUE, 0);
+    public final LogLevelSelector LOG_LEVEL_UNSPECIFIED;
 
-    private EventRuleFactory() {}
+    private final ILttngSession.Domain domain;
+
+    /**
+     * Constructor.
+     *
+     * @param domain
+     */
+    public EventRuleFactory(ILttngSession.Domain domain) {
+        this.domain = domain;
+        LOG_LEVEL_UNSPECIFIED = new LogLevelSelector(domain.levelAllValue(), 0);
+    }
 
     /**
      * Construct an event by only passing the event name on the command-line.
@@ -46,7 +57,7 @@ public final class EventRuleFactory {
      *            The event name
      * @return The corresponding event rule
      */
-    public static EventRule createRule(String eventName) {
+    public EventRule createRule(String eventName) {
         return new EventRule(eventName, LOG_LEVEL_UNSPECIFIED, filterStringFromEventName(eventName));
     }
 
@@ -59,7 +70,7 @@ public final class EventRuleFactory {
      *            The log level
      * @return The corresponding event rule
      */
-    public static EventRule createRule(String eventName, LogLevelSelector logLevelSelector) {
+    public EventRule createRule(String eventName, LogLevelSelector logLevelSelector) {
         StringJoiner sj = new StringJoiner(") && (", "(", ")");
         String filterStr = sj.add(filterStringFromEventName(eventName))
                 .add(filterStringFromLogLevel(logLevelSelector))
@@ -79,7 +90,7 @@ public final class EventRuleFactory {
      *            The filter string passed on the command-line
      * @return The corresponding event rule
      */
-    public static EventRule createRule(String eventName, LogLevelSelector logLevelSelector, String extraFilter) {
+    public EventRule createRule(String eventName, LogLevelSelector logLevelSelector, String extraFilter) {
         StringJoiner sj1 = new StringJoiner(") && (", "(", ")");
         sj1.add(extraFilter);
         sj1.add(filterStringFromEventName(eventName));
@@ -104,7 +115,7 @@ public final class EventRuleFactory {
      *
      * @return The corresponding event rule
      */
-    public static EventRule createRuleAllEvents() {
+    public EventRule createRuleAllEvents() {
         return new EventRule(EVENT_NAME_ALL, LOG_LEVEL_UNSPECIFIED, "");
     }
 
@@ -112,13 +123,13 @@ public final class EventRuleFactory {
         return "logger_name == \"" + eventName + "\"";
     }
 
-    private static String filterStringFromLogLevel(LogLevelSelector logLevelSelector) {
+    private String filterStringFromLogLevel(LogLevelSelector logLevelSelector) {
         StringBuilder sb = new StringBuilder();
         sb.append("int_loglevel ");
 
         switch (logLevelSelector.getLogLevelType()) {
         case LTTNG_EVENT_LOGLEVEL_RANGE:
-            sb.append(">=");
+            sb.append(domain.rangeOperator());
             break;
         case LTTNG_EVENT_LOGLEVEL_SINGLE:
             sb.append("==");
@@ -131,5 +142,4 @@ public final class EventRuleFactory {
         sb.append(" " + logLevelSelector.getLogLevel());
         return sb.toString();
     }
-
 }
index e46a7180857d1dc4209cd3120c5b1a5605fa01de..e5ba5ec71b22a1f560a58edc5dc289561c7c6317 100644 (file)
@@ -98,4 +98,29 @@ public interface ILogLevelStrings {
         }
     };
 
+    /**
+     * Values for log4j 2.x
+     */
+    ILogLevelStrings LOG4J2_LOGLEVEL_STRINGS = new ILogLevelStrings() {
+
+        @Override
+        public String warningName() {
+            return "warn";
+        }
+
+        @Override
+        public int warningInt() {
+            return 300;
+        }
+
+        @Override
+        public String infoName() {
+            return "info";
+        }
+
+        @Override
+        public int infoInt() {
+            return 400;
+        }
+    };
 }
index 0c0af7d68c9aa89ad5f3351440af8256e0992222..6313a6fd34134d1be05fe67023b8132acb6ab8cf 100644 (file)
@@ -77,6 +77,8 @@ public class TcpClientIT {
     private static LttngTcpSessiondClient client;
     private static Thread clientThread;
 
+    private static EventRuleFactory eventRuleFactory = new EventRuleFactory(SESSION_DOMAIN);
+
     private ILttngSession session;
 
     // ------------------------------------------------------------------------
@@ -179,7 +181,7 @@ public class TcpClientIT {
         session.enableEvent(EVENT_NAME_A, null, false, null);
 
         List<EventRule> expectedCommands = Collections.singletonList(
-                EventRuleFactory.createRule(EVENT_NAME_A));
+                eventRuleFactory.createRule(EVENT_NAME_A));
 
         List<EventRule> actualCommands = clientListener.getEnabledEventCommands();
         assertEquals(expectedCommands, actualCommands);
@@ -193,7 +195,7 @@ public class TcpClientIT {
         session.enableAllEvents();
 
         List<EventRule> expectedCommands = Collections.singletonList(
-                EventRuleFactory.createRuleAllEvents());
+                eventRuleFactory.createRuleAllEvents());
         List<EventRule> actualCommands = clientListener.getEnabledEventCommands();
 
         assertEquals(expectedCommands, actualCommands);
@@ -208,7 +210,7 @@ public class TcpClientIT {
         session.disableEvents(EVENT_NAME_A);
 
         List<EventRule> expectedEnableCommands = Collections.singletonList(
-                EventRuleFactory.createRule(EVENT_NAME_A));
+                eventRuleFactory.createRule(EVENT_NAME_A));
         List<String> expectedDisableCommands = Collections.singletonList(EVENT_NAME_A);
 
         assertEquals(expectedEnableCommands, clientListener.getEnabledEventCommands());
@@ -226,9 +228,9 @@ public class TcpClientIT {
         session.disableAllEvents();
 
         List<EventRule> expectedEnableCommands = Arrays.asList(
-                EventRuleFactory.createRule(EVENT_NAME_A),
-                EventRuleFactory.createRule(EVENT_NAME_B),
-                EventRuleFactory.createRule(EVENT_NAME_C));
+                eventRuleFactory.createRule(EVENT_NAME_A),
+                eventRuleFactory.createRule(EVENT_NAME_B),
+                eventRuleFactory.createRule(EVENT_NAME_C));
         /*
          * A "disable-event -a" will send one command for each enabled event.
          * The order may be different though.
@@ -248,7 +250,7 @@ public class TcpClientIT {
         session.enableAllEvents();
         session.disableAllEvents();
 
-        List<EventRule> expectedEnableCommands = Arrays.asList(EventRuleFactory.createRuleAllEvents());
+        List<EventRule> expectedEnableCommands = Arrays.asList(eventRuleFactory.createRuleAllEvents());
         List<String> expectedDisableCommands = Arrays.asList(EventRuleFactory.EVENT_NAME_ALL);
 
         assertEquals(expectedEnableCommands, clientListener.getEnabledEventCommands());
@@ -267,7 +269,7 @@ public class TcpClientIT {
             session2.enableEvent(EVENT_NAME_B, null, false, null);
         } // close(), aka destroy the session, sending "disable event" messages
 
-        List<EventRule> expectedEnabledCommands = Arrays.asList(EventRuleFactory.createRule(EVENT_NAME_A), EventRuleFactory.createRule(EVENT_NAME_B));
+        List<EventRule> expectedEnabledCommands = Arrays.asList(eventRuleFactory.createRule(EVENT_NAME_A), eventRuleFactory.createRule(EVENT_NAME_B));
         List<String> expectedDisabledCommands = Arrays.asList(EVENT_NAME_A, EVENT_NAME_B);
 
         assertEquals(expectedEnabledCommands, clientListener.getEnabledEventCommands());
@@ -284,7 +286,7 @@ public class TcpClientIT {
         session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), false, null);
 
         List<EventRule> expectedCommands = Collections.singletonList(
-                EventRuleFactory.createRule(EVENT_NAME_A, lls));
+                eventRuleFactory.createRule(EVENT_NAME_A, lls));
         List<EventRule> actualCommands = clientListener.getEnabledEventCommands();
 
         assertEquals(expectedCommands, actualCommands);
@@ -300,7 +302,7 @@ public class TcpClientIT {
         session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), true, null);
 
         List<EventRule> expectedCommands = Collections.singletonList(
-                EventRuleFactory.createRule(EVENT_NAME_A, lls));
+                eventRuleFactory.createRule(EVENT_NAME_A, lls));
         List<EventRule> actualCommands = clientListener.getEnabledEventCommands();
 
         assertEquals(expectedCommands, actualCommands);
@@ -318,8 +320,8 @@ public class TcpClientIT {
         session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), true, null);
 
         List<EventRule> expectedCommands = Arrays.asList(
-                EventRuleFactory.createRule(EVENT_NAME_A, lls1),
-                EventRuleFactory.createRule(EVENT_NAME_A, lls2)
+                eventRuleFactory.createRule(EVENT_NAME_A, lls1),
+                eventRuleFactory.createRule(EVENT_NAME_A, lls2)
                 );
         List<EventRule> actualCommands = clientListener.getEnabledEventCommands();
 
@@ -338,8 +340,8 @@ public class TcpClientIT {
         session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), false, null);
 
         List<EventRule> expectedCommands = Arrays.asList(
-                EventRuleFactory.createRule(EVENT_NAME_A, lls1),
-                EventRuleFactory.createRule(EVENT_NAME_A, lls2)
+                eventRuleFactory.createRule(EVENT_NAME_A, lls1),
+                eventRuleFactory.createRule(EVENT_NAME_A, lls2)
                 );
         List<EventRule> actualCommands = clientListener.getEnabledEventCommands();
 
@@ -361,8 +363,8 @@ public class TcpClientIT {
             session2.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), true, null);
 
             List<EventRule> expectedCommands = Arrays.asList(
-                    EventRuleFactory.createRule(EVENT_NAME_A, lls1),
-                    EventRuleFactory.createRule(EVENT_NAME_A, lls2));
+                    eventRuleFactory.createRule(EVENT_NAME_A, lls1),
+                    eventRuleFactory.createRule(EVENT_NAME_A, lls2));
             List<EventRule> actualCommands = clientListener.getEnabledEventCommands();
 
             assertEquals(expectedCommands, actualCommands);
@@ -382,9 +384,9 @@ public class TcpClientIT {
         session.enableEvent(EVENT_NAME_A, null, false, filter2);
 
         List<EventRule> expectedCommands = Arrays.asList(
-                EventRuleFactory.createRule(EVENT_NAME_A),
-                EventRuleFactory.createRule(EVENT_NAME_A, EventRuleFactory.LOG_LEVEL_UNSPECIFIED, filter1),
-                EventRuleFactory.createRule(EVENT_NAME_A, EventRuleFactory.LOG_LEVEL_UNSPECIFIED, filter2));
+                eventRuleFactory.createRule(EVENT_NAME_A),
+                eventRuleFactory.createRule(EVENT_NAME_A, eventRuleFactory.LOG_LEVEL_UNSPECIFIED, filter1),
+                eventRuleFactory.createRule(EVENT_NAME_A, eventRuleFactory.LOG_LEVEL_UNSPECIFIED, filter2));
         List<EventRule> actualCommands = clientListener.getEnabledEventCommands();
 
         assertEquals(expectedCommands, actualCommands);
@@ -405,10 +407,10 @@ public class TcpClientIT {
         session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), false, filter);
 
         List<EventRule> expectedCommands = Arrays.asList(
-                EventRuleFactory.createRule(EVENT_NAME_A),
-                EventRuleFactory.createRule(EVENT_NAME_A, lls),
-                EventRuleFactory.createRule(EVENT_NAME_A, EventRuleFactory.LOG_LEVEL_UNSPECIFIED, filter),
-                EventRuleFactory.createRule(EVENT_NAME_A, lls, filter));
+                eventRuleFactory.createRule(EVENT_NAME_A),
+                eventRuleFactory.createRule(EVENT_NAME_A, lls),
+                eventRuleFactory.createRule(EVENT_NAME_A, eventRuleFactory.LOG_LEVEL_UNSPECIFIED, filter),
+                eventRuleFactory.createRule(EVENT_NAME_A, lls, filter));
         List<EventRule> actualCommands = clientListener.getEnabledEventCommands();
 
         assertEquals(expectedCommands, actualCommands);
index 45324a2afaede658fea55560f1b799e3d3ed7dfe..eccf1b363459f6f024d48f5ecde5386a29ebfe46 100644 (file)
@@ -26,6 +26,7 @@ import java.util.logging.Logger;
 
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
 import org.lttng.ust.agent.utils.TestPrintExtension;
@@ -35,6 +36,9 @@ import org.lttng.ust.agent.utils.TestPrintExtension;
  * test different types of log handlers.
  */
 @ExtendWith(TestPrintExtension.class)
+@Tag("agent:jul")
+@Tag("domain:jul")
+@Tag("benchmark")
 public abstract class JulHandlerBenchmarkBase {
 
     // ------------------------------------------------------------------------
index c3b89535c3bbddf7f8a2cb0ba74726b0162778aa..23bec90d13e68e538e78698e8bc9130985048b1a 100644 (file)
@@ -22,12 +22,16 @@ import java.util.logging.Handler;
 import java.util.logging.LogRecord;
 
 import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
 import org.lttng.ust.agent.benchmarks.jul.handler.JulHandlerBenchmarkBase;
 
 /**
  * Test suite of using a "dummy" handler, which means a handler that does
  * exactly nothing.
  */
+@Tag("agent:jul")
+@Tag("domain:jul")
+@Tag("benchmark")
 public class DummyHandlerBenchmark extends JulHandlerBenchmarkBase {
 
        /**
index 5437754b8a4447553b3b42af4bf1b57ddeec8bfa..b6159b23cf6545da7cf01184a43fa0bd8605b49f 100644 (file)
@@ -26,11 +26,15 @@ import java.util.logging.SimpleFormatter;
 
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
 import org.lttng.ust.agent.benchmarks.jul.handler.JulHandlerBenchmarkBase;
 
 /**
  * Test class using a {@link FileHandler}, which a {@link SimpleFormatter}.
  */
+@Tag("agent:jul")
+@Tag("domain:jul")
+@Tag("benchmark")
 public class FileHandlerBenchmark extends JulHandlerBenchmarkBase {
 
     private Path outputFile;
index 09457d20ad9acac7ef8935dccc6d0e9ec5bb64d2..1fc5e9ca4b51e5fba90cbc5ab70bc8d88c3ae5b1 100644 (file)
 
 package org.lttng.ust.agent.benchmarks.jul.handler.builtin;
 
+import org.junit.jupiter.api.Tag;
 import org.lttng.ust.agent.benchmarks.jul.handler.JulHandlerBenchmarkBase;
 
 /**
  * Benchmark that will attach no {@link java.util.logging.Handler} to the
  * {@link java.util.logging.Logger} object.
  */
+@Tag("agent:jul")
+@Tag("domain:jul")
+@Tag("benchmark")
 public class NoHandlerBenchmark extends JulHandlerBenchmarkBase {
 
        /* Do not setup any handler */
index fc1661885129e48542c2f655f0ee4c31f8c42573..5b3da0b6e9fe62a72f6ab8776aeb6bc464353d5a 100644 (file)
@@ -20,12 +20,16 @@ package org.lttng.ust.agent.benchmarks.jul.handler.builtin;
 
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
 import org.lttng.ust.agent.benchmarks.jul.handler.JulHandlerBenchmarkBase;
 
 /**
  * Benchmark that will avoid creating a Logger entirely, to benchmark just the
  * bare worker.
  */
+@Tag("agent:jul")
+@Tag("domain:jul")
+@Tag("benchmark")
 public class NoLoggerBenchmark extends JulHandlerBenchmarkBase {
 
     /**
index df7eca3266610360b854c0c394195811d6ffb59e..e5af33acd9a59ff9b52853b133967a541af662b9 100644 (file)
@@ -24,6 +24,7 @@ import java.io.IOException;
 
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
 import org.lttng.tools.ILttngSession;
 import org.lttng.tools.ILttngSession.Domain;
 import org.lttng.ust.agent.benchmarks.jul.handler.JulHandlerBenchmarkBase;
@@ -33,6 +34,9 @@ import org.lttng.ust.agent.jul.LttngLogHandler;
  * Benchmark the LTTng-JUL handler, but with tracing disabled in the tracing
  * session.
  */
+@Tag("agent:jul")
+@Tag("domain:jul")
+@Tag("benchmark")
 public class LttngJulHandlerTracingDisabledBenchmark extends JulHandlerBenchmarkBase {
 
     private ILttngSession session;
index bdddedad0e5ea8b0f68bea351517b2feb8ed4590..ee3af1b95ce28b22903341951eb6868e3c21dd79 100644 (file)
@@ -24,6 +24,7 @@ import java.io.IOException;
 
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
 import org.lttng.tools.ILttngSession;
 import org.lttng.tools.ILttngSession.Domain;
 import org.lttng.ust.agent.benchmarks.jul.handler.JulHandlerBenchmarkBase;
@@ -32,6 +33,9 @@ import org.lttng.ust.agent.jul.LttngLogHandler;
 /**
  * Test the LTTng-JUL handler, with it actually sending events to the tracer.
  */
+@Tag("agent:jul")
+@Tag("domain:jul")
+@Tag("benchmark")
 public class LttngJulHandlerTracingEnabledBenchmark extends JulHandlerBenchmarkBase {
 
     private ILttngSession session;
index 17c67e039734922d208779bd845a229a03c32008..d6bf472594bfdd2f75a4a1a5199ad1c82a286d5f 100644 (file)
@@ -22,6 +22,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
 import org.lttng.tools.ILttngSession;
 import org.lttng.tools.ILttngSession.Domain;
 import org.lttng.ust.agent.LTTngAgent;
@@ -31,6 +32,9 @@ import org.lttng.ust.agent.benchmarks.jul.handler.JulHandlerBenchmarkBase;
  * Benchmark for the LTTng-UST handler, using the legacy API. Tracing is
  * disabled in the tracing session.
  */
+@Tag("agent:jul")
+@Tag("domain:jul")
+@Tag("benchmark")
 @SuppressWarnings("deprecation")
 public class OldLttngJulHandlerTracingDisabledBenchmark extends JulHandlerBenchmarkBase {
 
index a9985c4f3ef36d440879b6cb6401736ab4b8779e..70a19cf09d10d8f5d42b0f90a1ae8fe22a9346d8 100644 (file)
@@ -25,6 +25,7 @@ import java.lang.reflect.Field;
 
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
 import org.lttng.tools.ILttngSession;
 import org.lttng.tools.ILttngSession.Domain;
 import org.lttng.ust.agent.LTTngAgent;
@@ -35,6 +36,9 @@ import org.lttng.ust.agent.jul.LttngLogHandler;
  * Benchmark for the LTTng-UST handler, using the legacy API. Tracing is
  * enabled in the tracing session.
  */
+@Tag("agent:jul")
+@Tag("domain:jul")
+@Tag("benchmark")
 @SuppressWarnings("deprecation")
 public class OldLttngJulHandlerTracingEnabledBenchmark extends JulHandlerBenchmarkBase {
 
index b5735f2b99610703c522334697c1f01fd04b50ef..5ad024db7e24ed2aac7d5e75cc45e5026c790139 100644 (file)
@@ -27,6 +27,7 @@ import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
 import org.lttng.tools.ILttngSession.Domain;
 import org.lttng.ust.agent.jul.LttngLogHandler;
 import org.lttng.ust.agent.utils.JulTestUtils;
@@ -34,6 +35,8 @@ import org.lttng.ust.agent.utils.JulTestUtils;
 /**
  * Enabled app contexts test for the LTTng-UST JUL log handler.
  */
+@Tag("agent:jul")
+@Tag("domain:jul")
 public class JulAppContextIT extends AppContextITBase {
 
     private static final Domain DOMAIN = Domain.JUL;
index 1b488a4d5d81a82af8f904469e0e2749c06e262a..69a1e7ef80ff978c4a81525dda6ed35aaef14faa 100644 (file)
@@ -28,6 +28,7 @@ import java.util.logging.Logger;
 import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
 import org.lttng.tools.ILttngSession.Domain;
 import org.lttng.ust.agent.jul.LttngLogHandler;
 import org.lttng.ust.agent.utils.JulTestUtils;
@@ -35,6 +36,8 @@ import org.lttng.ust.agent.utils.JulTestUtils;
 /**
  * Implementation of {@link AppContextOrderingITBase} for the JUL API.
  */
+@Tag("agent:jul")
+@Tag("domain:jul")
 public class JulAppContextOrderingIT extends AppContextOrderingITBase {
 
     private Logger logger;
index 02c1c74574644d0f879a5737c16c53ee3114652a..a34f8a14332546a0488ddd361efbae14af4dee3d 100644 (file)
@@ -27,6 +27,7 @@ import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
 import org.lttng.tools.ILttngSession.Domain;
 import org.lttng.ust.agent.jul.LttngLogHandler;
 import org.lttng.ust.agent.utils.JulTestUtils;
@@ -34,6 +35,8 @@ import org.lttng.ust.agent.utils.JulTestUtils;
 /**
  * Enabled events test for the LTTng-UST JUL log handler.
  */
+@Tag("agent:jul")
+@Tag("domain:jul")
 public class JulEnabledEventsIT extends EnabledEventsITBase {
 
     private static final Domain DOMAIN = Domain.JUL;
index 7b993f3489a96344d84f40f71ada596c6e158481..9a21701904576cf990cebf3ac2817f8b4ea2ac35 100644 (file)
@@ -35,6 +35,7 @@ import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
 import org.lttng.tools.ILttngSession;
@@ -49,6 +50,8 @@ import org.lttng.ust.agent.utils.TestPrintExtension;
  */
 @ExtendWith(TestPrintExtension.class)
 @SuppressWarnings("deprecation")
+@Tag("agent:jul")
+@Tag("domain:jul")
 public class JulLegacyApiIT {
 
     private static final Domain DOMAIN = Domain.JUL;
index ed8a08d178e7d708d8fc22bcd79fd311fd4ffb82..4caec7bdc691f125d990d4f08d47b240d219d1a9 100644 (file)
@@ -31,6 +31,7 @@ import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
 import org.junit.jupiter.params.ParameterizedTest;
 import org.junit.jupiter.params.provider.MethodSource;
 import org.lttng.tools.ILttngSession.Domain;
@@ -45,6 +46,8 @@ import org.lttng.ust.agent.utils.JulTestUtils;
  */
 @SuppressWarnings("deprecation")
 //@RunWith(Parameterized.class)
+@Tag("agent:jul")
+@Tag("domain:jul")
 public class JulLegacyApiLoggerHierarchyListIT extends LoggerHierachyListITBase {
 
     private LTTngAgent agent;
index f3e2b1f988e7af24098b7b7af8f0fbafe042a33b..b493b02769f8388a6bf2146b1c92687ff2527b2c 100644 (file)
@@ -27,6 +27,7 @@ import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
 import org.lttng.tools.ILttngSession;
 import org.lttng.ust.agent.jul.LttngLogHandler;
 import org.lttng.ust.agent.utils.JulTestUtils;
@@ -34,6 +35,8 @@ import org.lttng.ust.agent.utils.JulTestUtils;
 /**
  * Test suite for the list events command for the JUL domain
  */
+@Tag("agent:jul")
+@Tag("domain:jul")
 public class JulListEventsIT extends ListEventsITBase {
 
     private Logger[] loggers;
index 0d588bf9e2a84f61cc9da30af615d5ed0e4a0ad6..9769798e44a0a70e9977e8bde99eeed780fe19cc 100644 (file)
@@ -27,6 +27,7 @@ import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
 import org.lttng.tools.ILttngSession.Domain;
 import org.lttng.ust.agent.jul.LttngLogHandler;
 import org.lttng.ust.agent.utils.JulTestUtils;
@@ -36,6 +37,8 @@ import org.lttng.ust.agent.utils.JulTestUtils;
  *
  * @author Alexandre Montplaisir
  */
+@Tag("agent:jul")
+@Tag("domain:jul")
 public class JulLoggerHierarchyListIT extends LoggerHierachyListITBase {
 
     private Logger parentLogger;
index 633f8f09ca0be8d9b759d8c9f1db24083d198100..d377b158bc4c4fee23acc413d14a9536f1ca7286 100644 (file)
@@ -27,6 +27,7 @@ import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
 import org.lttng.tools.ILttngSession.Domain;
 import org.lttng.ust.agent.jul.LttngLogHandler;
 import org.lttng.ust.agent.utils.JulTestUtils;
@@ -34,6 +35,8 @@ import org.lttng.ust.agent.utils.JulTestUtils;
 /**
  * JUL tests for multiple concurrent tracing sessions
  */
+@Tag("agent:jul")
+@Tag("domain:jul")
 public class JulMultiSessionIT extends MultiSessionITBase {
 
     private static final Domain DOMAIN = Domain.JUL;
index 04f04ec48c45666a215117f818c6166712239d73..9b3eeea4edd4f10e678325fdc2352b05e7b92113 100644 (file)
@@ -22,6 +22,7 @@ import java.io.IOException;
 
 import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
 import org.lttng.tools.ILttngSession;
 import org.lttng.ust.agent.ILttngHandler;
 import org.lttng.ust.agent.jul.LttngLogHandler;
@@ -33,6 +34,8 @@ import org.lttng.ust.agent.utils.JulTestUtils;
  *
  * @author Alexandre Montplaisir
  */
+@Tag("agent:jul")
+@Tag("domain:jul")
 public class JulFilterListenerIT extends FilterListenerITBase {
 
     /**
@@ -65,5 +68,4 @@ public class JulFilterListenerIT extends FilterListenerITBase {
     protected ILogLevelStrings getLogLevelStrings() {
         return ILogLevelStrings.JUL_LOGLEVEL_STRINGS;
     }
-
 }
index 5964c97fb5f73bf35e1036ed1aa5f459437fa099..b82c12c5a38808fd6d6702522ef60287d49e2eb8 100644 (file)
@@ -27,6 +27,7 @@ import java.util.logging.Logger;
 
 import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
 import org.lttng.tools.ILttngSession.Domain;
 import org.lttng.ust.agent.jul.LttngLogHandler;
 import org.lttng.ust.agent.utils.JulTestUtils;
@@ -34,6 +35,8 @@ import org.lttng.ust.agent.utils.JulTestUtils;
 /**
  * Implementation of {@link FilterListenerOrderingITBase} for the JUL API.
  */
+@Tag("agent:jul")
+@Tag("domain:jul")
 public class JulFilterListenerOrderingIT extends FilterListenerOrderingITBase {
 
     private Logger logger;
index c7670eaaf5f5b4f49407e311e1f4b6352cabac21..7c8470238e26474c24c696ebb02a201f4bd2122a 100644 (file)
@@ -27,6 +27,7 @@ import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
 import org.lttng.tools.ILttngSession.Domain;
 import org.lttng.ust.agent.log4j.LttngLogAppender;
 import org.lttng.ust.agent.utils.Log4jTestUtils;
@@ -34,6 +35,8 @@ import org.lttng.ust.agent.utils.Log4jTestUtils;
 /**
  * Enabled app contexts test for the LTTng-UST JUL log handler.
  */
+@Tag("agent:log4j")
+@Tag("domain:log4j")
 public class Log4jAppContextIT extends AppContextITBase {
 
     private static final Domain DOMAIN = Domain.LOG4J;
index 02e0ceaa85b605e9eb5deaf3e39a5ebe523afd95..cb3055a78e4c89d567e1854a43caf1525fadfacb 100644 (file)
@@ -28,6 +28,7 @@ import org.apache.log4j.Logger;
 import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
 import org.lttng.tools.ILttngSession.Domain;
 import org.lttng.ust.agent.log4j.LttngLogAppender;
 import org.lttng.ust.agent.utils.Log4jTestUtils;
@@ -35,6 +36,8 @@ import org.lttng.ust.agent.utils.Log4jTestUtils;
 /**
  * Implementation of {@link AppContextOrderingITBase} for the log4j API.
  */
+@Tag("agent:log4j")
+@Tag("domain:log4j")
 public class Log4jAppContextOrderingIT extends AppContextOrderingITBase {
 
     private Logger logger;
index 579d43c2a0865e935359900f2d6747896d445d40..0d293a6d4a6602ee03e811e4f41a8a4e03d806d7 100644 (file)
@@ -27,6 +27,7 @@ import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
 import org.junit.jupiter.api.Test;
 import org.lttng.tools.ILttngSession.Domain;
 import org.lttng.ust.agent.log4j.LttngLogAppender;
@@ -35,6 +36,8 @@ import org.lttng.ust.agent.utils.Log4jTestUtils;
 /**
  * Enabled events test for the LTTng-UST Log4j log handler.
  */
+@Tag("agent:log4j")
+@Tag("domain:log4j")
 public class Log4jEnabledEventsIT extends EnabledEventsITBase {
 
     private static final Domain DOMAIN = Domain.LOG4J;
index a82857cd3e17b3e3dd7095fec3e9524e85dc2cee..9cece276040de56af6bdaa965504cd9139bd0c8d 100644 (file)
@@ -33,6 +33,7 @@ import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
 import org.lttng.tools.ILttngSession;
@@ -48,6 +49,8 @@ import org.lttng.ust.agent.utils.TestPrintExtension;
  */
 @ExtendWith(TestPrintExtension.class)
 @SuppressWarnings("deprecation")
+@Tag("agent:log4j")
+@Tag("domain:log4j")
 public class Log4jLegacyApiIT {
 
     private static final Domain DOMAIN = Domain.LOG4J;
index 241e47c843765fc00f4ae5187a600717e0382826..90fa9634d6d6d15f55c358a8c73dd24f4f0caa92 100644 (file)
@@ -27,6 +27,7 @@ import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
 import org.lttng.tools.ILttngSession;
 import org.lttng.ust.agent.log4j.LttngLogAppender;
 import org.lttng.ust.agent.utils.Log4jTestUtils;
@@ -34,6 +35,8 @@ import org.lttng.ust.agent.utils.Log4jTestUtils;
 /**
  * Test suite for the list events command for the log4j domain
  */
+@Tag("agent:log4j")
+@Tag("domain:log4j")
 public class Log4jListEventsIT extends ListEventsITBase {
 
     private Logger[] loggers;
index 5040506737cc6e6299580395615acc3e0d11141d..3b0943fbaa59b1d7f5993856e467346427f49671 100644 (file)
@@ -27,6 +27,7 @@ import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
 import org.lttng.tools.ILttngSession.Domain;
 import org.lttng.ust.agent.log4j.LttngLogAppender;
 import org.lttng.ust.agent.utils.Log4jTestUtils;
@@ -34,6 +35,8 @@ import org.lttng.ust.agent.utils.Log4jTestUtils;
 /**
  * Log4j tests for multiple concurrent tracing sessions
  */
+@Tag("agent:log4j")
+@Tag("domain:log4j")
 public class Log4jMultiSessionIT extends MultiSessionITBase {
 
     private static final Domain DOMAIN = Domain.LOG4J;
index cc55f406cb0ce5b9df2cf0c595f2d3a55f12f4c1..d4e5aa67f81331677a78b315c810bccfb17e5bb7 100644 (file)
@@ -22,6 +22,7 @@ import java.io.IOException;
 
 import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
 import org.lttng.tools.ILttngSession;
 import org.lttng.ust.agent.ILttngHandler;
 import org.lttng.ust.agent.log4j.LttngLogAppender;
@@ -33,6 +34,8 @@ import org.lttng.ust.agent.utils.Log4jTestUtils;
  *
  * @author Alexandre Montplaisir
  */
+@Tag("agent:log4j")
+@Tag("domain:log4j")
 public class Log4jFilterListenerIT extends FilterListenerITBase {
 
     /**
@@ -65,5 +68,4 @@ public class Log4jFilterListenerIT extends FilterListenerITBase {
     protected ILogLevelStrings getLogLevelStrings() {
         return ILogLevelStrings.LOG4J_LOGLEVEL_STRINGS;
     }
-
 }
index 5b3d1d4ca875e28cbb0ba0f211474bfd3a3ccc11..7e92c97891c699edfb8e393fd9bfb36d0875ff55 100644 (file)
@@ -27,6 +27,7 @@ import org.apache.log4j.Level;
 import org.apache.log4j.Logger;
 import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
 import org.lttng.tools.ILttngSession.Domain;
 import org.lttng.ust.agent.log4j.LttngLogAppender;
 import org.lttng.ust.agent.utils.Log4jTestUtils;
@@ -34,6 +35,8 @@ import org.lttng.ust.agent.utils.Log4jTestUtils;
 /**
  * Implementation of {@link FilterListenerOrderingITBase} for the log4j API.
  */
+@Tag("agent:log4j")
+@Tag("domain:log4j")
 public class Log4jFilterListenerOrderingIT extends FilterListenerOrderingITBase {
 
     private Logger logger;
index 8f6300abf843f95f1f847d572e08612a7f86b8d2..3b348b78f092a975932be0a97de375183841ac47 100644 (file)
@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
+       <classpathentry combineaccessrules="false" exported="true" kind="src" path="/lttng-ust-java-tests-common"/>
        <classpathentry kind="src" output="target/classes" path="src/main/java">
                <attributes>
                        <attribute name="optional" value="true"/>
@@ -12,7 +13,6 @@
                        <attribute name="maven.pomderived" value="true"/>
                </attributes>
        </classpathentry>
-       <classpathentry combineaccessrules="false" exported="true" kind="src" path="/lttng-ust-java-tests-common"/>
        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
                <attributes>
                        <attribute name="module" value="true"/>
index 1eb7d27c4ad2513e0117889fb0a2c03ca3431393..03fb51e5740cdc2d1a29521361feded2adf67900 100644 (file)
@@ -61,7 +61,9 @@
     <dependency>
       <groupId>org.junit.jupiter</groupId>
       <artifactId>junit-jupiter</artifactId>
-      <scope>test</scope>
+      <!-- Special case here, we ship abstract test classes in the jar, so we
+           need the JUnit dependency all the time. -->
+      <scope>compile</scope>
     </dependency>
   </dependencies>
 
diff --git a/lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/integration/context/Log4j2AppContextITBase.java b/lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/integration/context/Log4j2AppContextITBase.java
new file mode 100644 (file)
index 0000000..8731b75
--- /dev/null
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2022, EfficiOS Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+package org.lttng.ust.agent.integration.context;
+
+import java.io.IOException;
+
+import org.apache.logging.log4j.core.Logger;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.TestInstance.Lifecycle;
+import org.lttng.ust.agent.ILttngHandler;
+import org.lttng.ust.agent.utils.Log4j2TestContext;
+import org.lttng.ust.agent.utils.Log4j2TestUtils;
+
+/**
+ * Enabled app contexts test for the LTTng-UST Log4j 2.x log handler.
+ */
+@TestInstance(Lifecycle.PER_CLASS)
+public abstract class Log4j2AppContextITBase extends AppContextITBase {
+
+    private Log4j2TestContext testContext;
+    private Logger logger;
+
+    /**
+     * Class setup
+     */
+    @BeforeAll
+    public void log4j2ClassSetup() {
+        Log4j2TestUtils.testClassSetup(getDomain());
+    }
+
+    /**
+     * Class cleanup
+     */
+    @AfterAll
+    public static void log4j2ClassCleanup() {
+        Log4j2TestUtils.testClassCleanup();
+    }
+
+    /**
+     * Test setup
+     *
+     * @throws SecurityException
+     * @throws IOException
+     */
+    @SuppressWarnings("resource")
+    @BeforeEach
+    public void log4j2Setup() throws SecurityException, IOException {
+        testContext = new Log4j2TestContext("log4j2." + this.getClass().getSimpleName() + ".xml");
+
+        testContext.beforeTest();
+
+        logger = testContext.getLoggerContext().getLogger(EVENT_NAME);
+
+        logHandler = (ILttngHandler) logger.getAppenders().get("Lttng");
+    }
+
+    /**
+     * Test teardown
+     */
+    @AfterEach
+    public void log4j2Teardown() {
+        testContext.afterTest();
+        logger = null;
+    }
+
+    @Override
+    protected boolean closeHandlers()
+    {
+        return false;
+    }
+
+    @Override
+    protected void sendEventsToLoggers() {
+        Log4j2TestUtils.send10Events(logger);
+    }
+}
diff --git a/lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/integration/context/Log4j2AppContextOrderingITBase.java b/lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/integration/context/Log4j2AppContextOrderingITBase.java
new file mode 100644 (file)
index 0000000..f53efac
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2022, EfficiOS Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+package org.lttng.ust.agent.integration.context;
+
+
+import org.apache.logging.log4j.core.Logger;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.TestInstance.Lifecycle;
+import org.lttng.ust.agent.ILttngHandler;
+import org.lttng.ust.agent.utils.Log4j2TestContext;
+import org.lttng.ust.agent.utils.Log4j2TestUtils;
+
+/**
+ * Implementation of {@link AppContextOrderingITBase} for the log4j API.
+ */
+@TestInstance(Lifecycle.PER_CLASS)
+public abstract class Log4j2AppContextOrderingITBase extends AppContextOrderingITBase {
+
+    private Log4j2TestContext testContext;
+    private Logger logger;
+
+    /**
+     * Class setup
+     */
+    @BeforeAll
+    public void log4j2ClassSetup() {
+        Log4j2TestUtils.testClassSetup(getDomain());
+    }
+
+    /**
+     * Class cleanup
+     */
+    @AfterAll
+    public static void log4j2ClassCleanup() {
+        Log4j2TestUtils.testClassCleanup();
+    }
+
+    /**
+     * Test teardown
+     */
+    @AfterEach
+    public void log4j2Teardown() {
+        logger = null;
+        logHandler = null;
+
+        testContext.afterTest();
+    }
+
+    @SuppressWarnings("resource")
+    @Override
+    protected void registerAgent() {
+        testContext = new Log4j2TestContext("log4j2." + this.getClass().getSimpleName() + ".xml");
+
+        testContext.beforeTest();
+
+        logger = testContext.getLoggerContext().getLogger(EVENT_NAME);
+
+        logHandler = (ILttngHandler) logger.getAppenders().get("Lttng");
+    }
+
+    @Override
+    protected void sendEventsToLoggers() {
+        Log4j2TestUtils.send10Events(logger);
+    }
+}
diff --git a/lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/integration/events/Log4j2EnabledEventsITBase.java b/lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/integration/events/Log4j2EnabledEventsITBase.java
new file mode 100644 (file)
index 0000000..7d21a77
--- /dev/null
@@ -0,0 +1,129 @@
+/*
+ * Copyright (C) 2022, EfficiOS Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+package org.lttng.ust.agent.integration.events;
+
+import java.io.IOException;
+
+import org.apache.logging.log4j.core.Logger;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.TestInstance.Lifecycle;
+import org.lttng.ust.agent.ILttngHandler;
+import org.lttng.ust.agent.utils.Log4j2TestContext;
+import org.lttng.ust.agent.utils.Log4j2TestUtils;
+
+/**
+ * Enabled events test for the LTTng-UST Log4j 2.x log handler.
+ */
+@TestInstance(Lifecycle.PER_CLASS)
+public abstract class Log4j2EnabledEventsITBase extends EnabledEventsITBase {
+
+    private static final String APPENDER_NAME_A = "LttngA";
+    private static final String APPENDER_NAME_B = "LttngB";
+    private static final String APPENDER_NAME_C = "LttngC";
+
+    private Log4j2TestContext testContext;
+
+    private Logger loggerA;
+    private Logger loggerB;
+    private Logger loggerC;
+    private Logger loggerD;
+
+    /**
+     * Class setup
+     */
+    @BeforeAll
+    public void log4j2ClassSetup() {
+        Log4j2TestUtils.testClassSetup(getDomain());
+    }
+
+    /**
+     * Class cleanup
+     */
+    @AfterAll
+    public static void log4j2ClassCleanup() {
+        Log4j2TestUtils.testClassCleanup();
+    }
+
+    /**
+     * Test setup
+     *
+     * @throws SecurityException
+     * @throws IOException
+     */
+    @SuppressWarnings("resource")
+    @BeforeEach
+    public void log4j2Setup() throws SecurityException, IOException {
+
+        testContext = new Log4j2TestContext("log4j2." + this.getClass().getSimpleName() + ".xml");
+
+        testContext.beforeTest();
+
+        loggerA = testContext.getLoggerContext().getLogger(EVENT_NAME_A);
+        loggerB = testContext.getLoggerContext().getLogger(EVENT_NAME_B);
+        loggerC = testContext.getLoggerContext().getLogger(EVENT_NAME_C);
+        loggerD = testContext.getLoggerContext().getLogger(EVENT_NAME_D);
+
+        handlerA = (ILttngHandler) loggerA.getAppenders().get(APPENDER_NAME_A);
+        handlerB = (ILttngHandler) loggerB.getAppenders().get(APPENDER_NAME_B);
+        handlerC = (ILttngHandler) loggerC.getAppenders().get(APPENDER_NAME_C);
+    }
+
+    /**
+     * Test teardown
+     */
+    @AfterEach
+    public void log4j2Teardown() {
+        loggerA = null;
+        loggerB = null;
+        loggerC = null;
+        loggerD = null;
+
+        testContext.afterTest();
+    }
+
+    @Override
+    protected boolean closeHandlers()
+    {
+        return false;
+    }
+
+    @Override
+    protected void sendEventsToLoggers() {
+        Log4j2TestUtils.send10Events(loggerA);
+        Log4j2TestUtils.send10Events(loggerB);
+        Log4j2TestUtils.send10Events(loggerC);
+        Log4j2TestUtils.send10Events(loggerD);
+    }
+
+    @Override
+    protected void sendLocalizedEvent(String rawString, Object[] params) {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    @Test
+    public void testLocalizedMessage() {
+        /* Does not apply to log4j 1.2.x */
+    }
+}
diff --git a/lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/integration/events/Log4j2ListEventsITBase.java b/lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/integration/events/Log4j2ListEventsITBase.java
new file mode 100644 (file)
index 0000000..3d1130f
--- /dev/null
@@ -0,0 +1,156 @@
+/*
+ * Copyright (C) 2022, EfficiOS Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+package org.lttng.ust.agent.integration.events;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.logging.log4j.Logger;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
+import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.TestInstance.Lifecycle;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.lttng.tools.ILttngSession;
+import org.lttng.tools.ILttngSession.Domain;
+import org.lttng.ust.agent.utils.Log4j2TestContext;
+import org.lttng.ust.agent.utils.Log4j2TestUtils;
+import org.lttng.ust.agent.utils.TestPrintExtension;
+
+/**
+ * Test suite for the list events command for the log4j domain
+ */
+@TestInstance(Lifecycle.PER_CLASS)
+@ExtendWith(TestPrintExtension.class)
+public abstract class Log4j2ListEventsITBase {
+
+    protected static final String LOGGER_NAME_1 = "org.lttng.somecomponent";
+    protected static final String LOGGER_NAME_2 = "org.lttng.mycomponent";
+    protected static final String LOGGER_NAME_3 = "org.lttng.myothercomponent-àéç";
+
+    @SuppressWarnings("unused")
+    private Logger logger1;
+    @SuppressWarnings("unused")
+    private Logger logger2;
+    @SuppressWarnings("unused")
+    private Logger logger3;
+
+    private ILttngSession session;
+    private Log4j2TestContext testContext;
+
+    protected abstract Domain getDomain();
+
+    /**
+     * Class setup
+     */
+    @BeforeAll
+    public void log4j2ClassSetup() {
+        Log4j2TestUtils.testClassSetup(getDomain());
+    }
+
+    /**
+     * Class cleanup
+     */
+    @AfterAll
+    public static void log4j2ClassCleanup() {
+        Log4j2TestUtils.testClassCleanup();
+    }
+
+    /**
+     * Create a new session before each test.
+     *
+     * @param testInfo
+     *            current test information
+     */
+    @SuppressWarnings("resource")
+    @BeforeEach
+    public void testSetup(TestInfo testInfo) {
+        session = ILttngSession.createSession("Log4j2ListEventsIT", getDomain());
+
+        testContext = new Log4j2TestContext(
+                "log4j2." + getDomain() + testInfo.getDisplayName().replaceAll("[()]", "") + ".xml");
+
+        testContext.beforeTest();
+
+        logger1 = testContext.getLoggerContext().getLogger(LOGGER_NAME_1);
+        logger2 = testContext.getLoggerContext().getLogger(LOGGER_NAME_2);
+        logger3 = testContext.getLoggerContext().getLogger(LOGGER_NAME_3);
+    }
+
+    /**
+     * Close the current session after each test.
+     */
+    @AfterEach
+    public void testTeardown() {
+        session.close();
+        testContext.afterTest();
+    }
+
+    /**
+     * Test with many loggers existing, but none of them having a LTTng handler
+     * attached.
+     */
+    @Test
+    public void testManyLoggersNoneAttached() {
+
+        /* Don't attach anything */
+        List<String> actualEvents = session.listEvents();
+        assertTrue(actualEvents.isEmpty());
+    }
+
+    /**
+     * Test with many loggers existing, but only a subset of them has a LTTng
+     * handler attached.
+     */
+    @Test
+    public void testManyLoggersSomeAttached() {
+
+        List<String> expectedEvents = Arrays.asList(LOGGER_NAME_1);
+        List<String> actualEvents = session.listEvents();
+
+        Collections.sort(expectedEvents);
+        Collections.sort(actualEvents);
+
+        assertEquals(expectedEvents, actualEvents);
+    }
+
+    /**
+     * Test with many loggers existing, and all of them having a LTTng handler
+     * attached.
+     */
+    @Test
+    public void testManyLoggersAllAttached() {
+
+        List<String> expectedEvents = Arrays.asList(LOGGER_NAME_1, LOGGER_NAME_2, LOGGER_NAME_3);
+        List<String> actualEvents = session.listEvents();
+
+        Collections.sort(expectedEvents);
+        Collections.sort(actualEvents);
+
+        assertEquals(expectedEvents, actualEvents);
+    }
+}
diff --git a/lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/integration/events/Log4j2MultiSessionITBase.java b/lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/integration/events/Log4j2MultiSessionITBase.java
new file mode 100644 (file)
index 0000000..3147d22
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ * Copyright (C) 2022, EfficiOS Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+package org.lttng.ust.agent.integration.events;
+
+import java.io.IOException;
+
+import org.apache.logging.log4j.core.Logger;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.TestInstance.Lifecycle;
+import org.lttng.ust.agent.ILttngHandler;
+import org.lttng.ust.agent.utils.Log4j2TestContext;
+import org.lttng.ust.agent.utils.Log4j2TestUtils;
+
+/**
+ * Log4j tests for multiple concurrent tracing sessions
+ */
+@TestInstance(Lifecycle.PER_CLASS)
+public abstract class Log4j2MultiSessionITBase extends MultiSessionITBase {
+
+    protected static final String APPENDER_NAME_A = "LttngA";
+    protected static final String APPENDER_NAME_B = "LttngB";
+    protected static final String APPENDER_NAME_C = "LttngC";
+    protected static final String APPENDER_NAME_D = "LttngD";
+
+    private Log4j2TestContext testContext;
+
+    private Logger loggerA;
+    private Logger loggerB;
+    private Logger loggerC;
+    private Logger loggerD;
+
+    /**
+     * Class setup
+     */
+    @BeforeAll
+    public void log4j2ClassSetup() {
+        Log4j2TestUtils.testClassSetup(getDomain());
+    }
+
+    /**
+     * Class cleanup
+     */
+    @AfterAll
+    public static void log4j2ClassCleanup() {
+        Log4j2TestUtils.testClassCleanup();
+    }
+
+    /**
+     * Test setup
+     *
+     * @throws SecurityException
+     * @throws IOException
+     */
+    @SuppressWarnings("resource")
+    @BeforeEach
+    public void log4j2Setup() throws SecurityException, IOException {
+
+        testContext = new Log4j2TestContext("log4j2." + this.getClass().getSimpleName() + ".xml");
+
+        testContext.beforeTest();
+
+        loggerA = testContext.getLoggerContext().getLogger(EVENT_NAME_A);
+        loggerB = testContext.getLoggerContext().getLogger(EVENT_NAME_B);
+        loggerC = testContext.getLoggerContext().getLogger(EVENT_NAME_C);
+        loggerD = testContext.getLoggerContext().getLogger(EVENT_NAME_D);
+
+        handlerA = (ILttngHandler) loggerA.getAppenders().get(APPENDER_NAME_A);
+        handlerB = (ILttngHandler) loggerB.getAppenders().get(APPENDER_NAME_B);
+        handlerC = (ILttngHandler) loggerC.getAppenders().get(APPENDER_NAME_C);
+        handlerD = (ILttngHandler) loggerD.getAppenders().get(APPENDER_NAME_D);
+    }
+
+    /**
+     * Test teardown
+     */
+    @AfterEach
+    public void log4j2Teardown() {
+        loggerA = null;
+        loggerB = null;
+        loggerC = null;
+        loggerD = null;
+
+        testContext.afterTest();
+    }
+
+    @Override
+    protected boolean closeHandlers() {
+        return false;
+    }
+
+    @Override
+    protected void sendEventsToLoggers() {
+        Log4j2TestUtils.send10Events(loggerA);
+        Log4j2TestUtils.send10Events(loggerB);
+        Log4j2TestUtils.send10Events(loggerC);
+        Log4j2TestUtils.send10Events(loggerD);
+    }
+}
diff --git a/lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/integration/filter/Log4j2FilterListenerITBase.java b/lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/integration/filter/Log4j2FilterListenerITBase.java
new file mode 100644 (file)
index 0000000..834b957
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2022, EfficiOS Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+package org.lttng.ust.agent.integration.filter;
+
+import java.io.IOException;
+
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.TestInstance.Lifecycle;
+import org.lttng.ust.agent.ILttngHandler;
+import org.lttng.ust.agent.log4j2.LttngLogAppender;
+
+import org.lttng.ust.agent.utils.Log4j2TestUtils;
+
+/**
+ * Filter notifications tests using the log4j logging API.
+ */
+@TestInstance(Lifecycle.PER_CLASS)
+public abstract class Log4j2FilterListenerITBase extends FilterListenerITBase {
+
+    /**
+     * Class setup
+     */
+    @BeforeAll
+    public void log4j2ClassSetup() {
+        Log4j2TestUtils.testClassSetup(getSessionDomain());
+    }
+
+    /**
+     * Class cleanup
+     */
+    @AfterAll
+    public static void log4j2ClassCleanup() {
+        Log4j2TestUtils.testClassCleanup();
+    }
+
+    @Override
+    protected ILttngHandler getLogHandler() throws SecurityException, IOException {
+        return LttngLogAppender.createAppender(this.getClass().getSimpleName(), getSessionDomain().toString(), null, null);
+    }
+}
diff --git a/lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/integration/filter/Log4j2FilterListenerOrderingITBase.java b/lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/integration/filter/Log4j2FilterListenerOrderingITBase.java
new file mode 100644 (file)
index 0000000..caa2dbf
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2022, EfficiOS Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+package org.lttng.ust.agent.integration.filter;
+
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.TestInstance.Lifecycle;
+import org.lttng.ust.agent.utils.Log4j2TestContext;
+import org.lttng.ust.agent.utils.Log4j2TestUtils;
+
+/**
+ * Implementation of {@link FilterListenerOrderingITBase} for the log4j API.
+ */
+@TestInstance(Lifecycle.PER_CLASS)
+public abstract class Log4j2FilterListenerOrderingITBase extends FilterListenerOrderingITBase {
+
+    private Log4j2TestContext testContext;
+
+    /**
+     * Class setup
+     */
+    @BeforeAll
+    public void log4j2ClassSetup() {
+        Log4j2TestUtils.testClassSetup(getDomain());
+    }
+
+    /**
+     * Class cleanup
+     */
+    @AfterAll
+    public static void log4j2ClassCleanup() {
+        Log4j2TestUtils.testClassCleanup();
+    }
+
+    @Override
+    protected void registerAgent() {
+        testContext = new Log4j2TestContext("log4j2." + this.getClass().getSimpleName() + ".xml");
+        testContext.beforeTest();
+    }
+
+    @Override
+    protected void deregisterAgent() {
+        testContext.afterTest();
+    }
+}
diff --git a/lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/utils/Log4j2TestContext.java b/lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/utils/Log4j2TestContext.java
new file mode 100644 (file)
index 0000000..301ff70
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2022, EfficiOS Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+package org.lttng.ust.agent.utils;
+
+import java.net.URI;
+import java.net.URL;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.core.LoggerContext;
+
+/**
+ * Log4j 2.x test context utilities.
+ */
+public class Log4j2TestContext {
+
+    private final URI configFileUri;
+
+    private LoggerContext loggerContext;
+
+    /**
+     * @param configFile path to the log4j configuration file.
+     */
+    public Log4j2TestContext(String configFile) {
+
+        URL resource = getClass().getClassLoader().getResource(configFile);
+
+        if (resource == null) {
+            throw new IllegalArgumentException("Config file not found: " + configFile);
+        }
+
+        try {
+            this.configFileUri = resource.toURI();
+        } catch (Exception e) {
+            throw new IllegalArgumentException("Config file invalid URI: " + resource);
+        }
+    }
+
+    /**
+     * @return the log4j2 logger context.
+     */
+    public synchronized LoggerContext getLoggerContext() {
+        return loggerContext;
+    }
+
+    /**
+     * Initialize the log4j2 context before running a test.
+     */
+    public synchronized void beforeTest() {
+        loggerContext = (LoggerContext) LogManager.getContext(
+                ClassLoader.getSystemClassLoader(), false, configFileUri);
+    }
+
+    /**
+     * Dispose of the log4j2 context after running a test.
+     */
+    public synchronized void afterTest() {
+        loggerContext.stop();
+    }
+}
diff --git a/lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/utils/Log4j2TestUtils.java b/lttng-ust-java-tests-log4j2/src/main/java/org/lttng/ust/agent/utils/Log4j2TestUtils.java
new file mode 100644 (file)
index 0000000..68e7ff4
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2022, EfficiOS Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+package org.lttng.ust.agent.utils;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
+import java.io.IOException;
+
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.Logger;
+import org.lttng.tools.ILttngSession.Domain;
+import org.lttng.tools.LttngToolsHelper;
+import org.lttng.ust.agent.log4j2.LttngLogAppender;
+
+
+/**
+ * Utility methods for log4j 2.x tests
+ */
+public final class Log4j2TestUtils {
+
+    private Log4j2TestUtils() {
+    }
+
+    /**
+     * Setup method common to most log4j tests. To be called in a @BeforeClass.
+     * @param domain the tracing domain to operate on
+     */
+    public static void testClassSetup(Domain domain) {
+        /* Make sure we can find the JNI library and lttng-tools */
+        checkForLog4jLibrary(domain);
+        assertTrue(LttngUtils.checkForLttngTools(domain), "lttng-tools is not working properly.");
+
+        LttngToolsHelper.destroyAllSessions();
+    }
+
+    /**
+     * Teardown method common to most log4j tests. To be called in a @AfterClass.
+     */
+    public static void testClassCleanup() {
+        LttngToolsHelper.deleteAllTraces();
+    }
+
+    /**
+     * Check the the Log4j native library is available, effectively allowing
+     * LTTng Log4j appenders to be used.
+     */
+    private static void checkForLog4jLibrary(Domain domain) {
+        try {
+            LttngLogAppender testAppender = LttngLogAppender.createAppender("checkForLttngTools", domain.toString(), null, null);
+            testAppender.close();
+        } catch (SecurityException e) {
+            fail(e.getMessage());
+        }
+    }
+
+    /**
+     * Send 10 dummy events through the provided logger
+     *
+     * @param logger
+     *            The logger to use to send events
+     */
+    public static void send10Events(Logger logger) {
+        // Levels/priorities are DEBUG, ERROR, FATAL, INFO, TRACE, WARN
+        logger.debug("Debug message. Lost among so many.");
+        logger.debug("Debug message with a throwable", new IOException());
+        logger.error("Error messsage. This might be bad.");
+        logger.error("Error message with a throwable", new IOException());
+        logger.fatal("A fatal message. You are already dead.");
+        logger.info("A info message. Lol, who cares.");
+        logger.trace("A trace message. No, no *that* trace");
+        logger.warn("A warn message. Yellow underline.");
+        logger.log(Level.DEBUG, "A debug message using .log()");
+        logger.log(Level.ERROR, "A error message using .log()");
+    }
+}
index 7a00b4b2fe91eec78cb596f6076ec3164bc40d55..f215aa43809b3158d55f2089874c34f662187fac 100644 (file)
 
 package org.lttng.ust.agent.integration.context;
 
-import java.io.IOException;
-
-import org.apache.logging.log4j.core.Logger;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
 import org.lttng.tools.ILttngSession.Domain;
-import org.lttng.ust.agent.ILttngHandler;
-import org.lttng.ust.agent.utils.Log4j2TestContext;
-import org.lttng.ust.agent.utils.Log4j2TestUtils;
+
 
 /**
  * Enabled app contexts test for the LTTng-UST Log4j 2.x log handler.
  */
-public class Log4j2AppContextIT extends AppContextITBase {
-
-    private static final Domain DOMAIN = Domain.LOG4J;
-
-    private Log4j2TestContext testContext;
-    private Logger logger;
-
-    /**
-     * Class setup
-     */
-    @BeforeAll
-    public static void log4j2ClassSetup() {
-        Log4j2TestUtils.testClassSetup();
-    }
-
-    /**
-     * Class cleanup
-     */
-    @AfterAll
-    public static void log4j2ClassCleanup() {
-        Log4j2TestUtils.testClassCleanup();
-    }
-
-    /**
-     * Test setup
-     *
-     * @throws SecurityException
-     * @throws IOException
-     */
-    @SuppressWarnings("resource")
-    @BeforeEach
-    public void log4j2Setup() throws SecurityException, IOException {
-        testContext = new Log4j2TestContext("log4j2.Log4j2AppContextIT.xml");
-
-        testContext.beforeTest();
-
-        logger = testContext.getLoggerContext().getLogger(EVENT_NAME);
-
-        logHandler = (ILttngHandler) logger.getAppenders().get("Lttng");
-    }
-
-    /**
-     * Test teardown
-     */
-    @AfterEach
-    public void log4j2Teardown() {
-        testContext.afterTest();
-        logger = null;
-    }
+@Tag("agent:log4j2")
+@Tag("domain:log4j2")
+public class Log4j2AppContextIT extends Log4j2AppContextITBase {
 
     @Override
     protected Domain getDomain() {
-        return DOMAIN;
-    }
-
-    @Override
-    protected boolean closeHandlers()
-    {
-        return false;
-    }
-
-    @Override
-    protected void sendEventsToLoggers() {
-        Log4j2TestUtils.send10Events(logger);
+        return Domain.LOG4J2;
     }
 }
index a015f13ec05990b2ec1120b4c1e1047f7ad9fa5c..2843ad666dc14e6e7c148caf3332a24db80ee582 100644 (file)
 
 package org.lttng.ust.agent.integration.context;
 
-
-import org.apache.logging.log4j.core.Logger;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
 import org.lttng.tools.ILttngSession.Domain;
-import org.lttng.ust.agent.ILttngHandler;
-import org.lttng.ust.agent.utils.Log4j2TestContext;
-import org.lttng.ust.agent.utils.Log4j2TestUtils;
+
 
 /**
  * Implementation of {@link AppContextOrderingITBase} for the log4j API.
  */
-public class Log4j2AppContextOrderingIT extends AppContextOrderingITBase {
-
-    private Log4j2TestContext testContext;
-    private Logger logger;
-
-    /**
-     * Class setup
-     */
-    @BeforeAll
-    public static void log4j2ClassSetup() {
-        Log4j2TestUtils.testClassSetup();
-    }
-
-    /**
-     * Class cleanup
-     */
-    @AfterAll
-    public static void log4j2ClassCleanup() {
-        Log4j2TestUtils.testClassCleanup();
-    }
-
-    /**
-     * Test teardown
-     */
-    @AfterEach
-    public void log4j2Teardown() {
-        logger = null;
-        logHandler = null;
-
-        testContext.afterTest();
-    }
+@Tag("agent:log4j2")
+@Tag("domain:log4j2")
+public class Log4j2AppContextOrderingIT extends Log4j2AppContextOrderingITBase {
 
     @Override
     protected Domain getDomain() {
-        return Domain.LOG4J;
-    }
-
-    @SuppressWarnings("resource")
-    @Override
-    protected void registerAgent() {
-        testContext = new Log4j2TestContext("log4j2.Log4j2AppContextOrderingIT.xml");
-
-        testContext.beforeTest();
-
-        logger = testContext.getLoggerContext().getLogger(EVENT_NAME);
-
-        logHandler = (ILttngHandler) logger.getAppenders().get("Lttng");
-    }
-
-    @Override
-    protected void sendEventsToLoggers() {
-        Log4j2TestUtils.send10Events(logger);
+        return Domain.LOG4J2;
     }
 }
diff --git a/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/context/Log4j2CompatAppContextIT.java b/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/context/Log4j2CompatAppContextIT.java
new file mode 100644 (file)
index 0000000..9de5a65
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2022, EfficiOS Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+package org.lttng.ust.agent.integration.context;
+
+import org.junit.jupiter.api.Tag;
+import org.lttng.tools.ILttngSession.Domain;
+
+
+/**
+ * Enabled app contexts test for the LTTng-UST Log4j 2.x log handler.
+ */
+@Tag("agent:log4j2")
+@Tag("domain:log4j")
+public class Log4j2CompatAppContextIT extends Log4j2AppContextITBase {
+
+    @Override
+    protected Domain getDomain() {
+        return Domain.LOG4J;
+    }
+}
diff --git a/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/context/Log4j2CompatAppContextOrderingIT.java b/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/context/Log4j2CompatAppContextOrderingIT.java
new file mode 100644 (file)
index 0000000..b558b35
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2022, EfficiOS Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+package org.lttng.ust.agent.integration.context;
+
+import org.junit.jupiter.api.Tag;
+import org.lttng.tools.ILttngSession.Domain;
+
+
+/**
+ * Implementation of {@link AppContextOrderingITBase} for the log4j API.
+ */
+@Tag("agent:log4j2")
+@Tag("domain:log4j")
+public class Log4j2CompatAppContextOrderingIT extends Log4j2AppContextOrderingITBase {
+
+    @Override
+    protected Domain getDomain() {
+        return Domain.LOG4J;
+    }
+}
diff --git a/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/events/Log4j2CompatEnabledEventsIT.java b/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/events/Log4j2CompatEnabledEventsIT.java
new file mode 100644 (file)
index 0000000..8fa3c8a
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2022, EfficiOS Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+package org.lttng.ust.agent.integration.events;
+
+import org.junit.jupiter.api.Tag;
+import org.lttng.tools.ILttngSession.Domain;
+
+
+/**
+ * Enabled events test for the LTTng-UST Log4j 2.x log handler.
+ */
+@Tag("agent:log4j2")
+@Tag("domain:log4j")
+public class Log4j2CompatEnabledEventsIT extends Log4j2EnabledEventsITBase {
+
+    @Override
+    protected Domain getDomain() {
+        return Domain.LOG4J;
+    }
+}
diff --git a/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/events/Log4j2CompatListEventsIT.java b/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/events/Log4j2CompatListEventsIT.java
new file mode 100644 (file)
index 0000000..8d845d7
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2022, EfficiOS Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+package org.lttng.ust.agent.integration.events;
+
+import org.junit.jupiter.api.Tag;
+import org.lttng.tools.ILttngSession.Domain;
+
+
+/**
+ * Test suite for the list events command for the log4j domain
+ */
+@Tag("agent:log4j2")
+@Tag("domain:log4j")
+public class Log4j2CompatListEventsIT extends Log4j2ListEventsITBase {
+
+    @Override
+    protected Domain getDomain() {
+        return Domain.LOG4J;
+    }
+}
diff --git a/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/events/Log4j2CompatMultiSessionIT.java b/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/events/Log4j2CompatMultiSessionIT.java
new file mode 100644 (file)
index 0000000..a28d935
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2022, EfficiOS Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+package org.lttng.ust.agent.integration.events;
+
+import org.junit.jupiter.api.Tag;
+import org.lttng.tools.ILttngSession.Domain;
+
+
+/**
+ * Log4j tests for multiple concurrent tracing sessions
+ */
+@Tag("agent:log4j2")
+@Tag("domain:log4j")
+public class Log4j2CompatMultiSessionIT extends Log4j2MultiSessionITBase {
+
+    @Override
+    protected Domain getDomain() {
+        return Domain.LOG4J;
+    }
+}
index 1bbf4e46365c5bce69c4f09319c0ac788f4f2164..de0d3a68bbcd43005cf1b9e42333ebc2d02a8a15 100644 (file)
 
 package org.lttng.ust.agent.integration.events;
 
-import java.io.IOException;
-
-import org.apache.logging.log4j.core.Logger;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Tag;
 import org.lttng.tools.ILttngSession.Domain;
-import org.lttng.ust.agent.ILttngHandler;
-import org.lttng.ust.agent.utils.Log4j2TestContext;
-import org.lttng.ust.agent.utils.Log4j2TestUtils;
+
 
 /**
- * Enabled events test for the LTTng-UST Log4j log handler.
+ * Enabled events test for the LTTng-UST Log4j 2.x log handler.
  */
-public class Log4j2EnabledEventsIT extends EnabledEventsITBase {
-
-    private static final String APPENDER_NAME_A = "LttngA";
-    private static final String APPENDER_NAME_B = "LttngB";
-    private static final String APPENDER_NAME_C = "LttngC";
-
-    private static final Domain DOMAIN = Domain.LOG4J;
-
-    private Log4j2TestContext testContext;
-
-    private Logger loggerA;
-    private Logger loggerB;
-    private Logger loggerC;
-    private Logger loggerD;
-
-    /**
-     * Class setup
-     */
-    @BeforeAll
-    public static void log4j2ClassSetup() {
-        Log4j2TestUtils.testClassSetup();
-    }
-
-    /**
-     * Class cleanup
-     */
-    @AfterAll
-    public static void log4j2ClassCleanup() {
-        Log4j2TestUtils.testClassCleanup();
-    }
-
-    /**
-     * Test setup
-     *
-     * @throws SecurityException
-     * @throws IOException
-     */
-    @SuppressWarnings("resource")
-    @BeforeEach
-    public void log4j2Setup() throws SecurityException, IOException {
-
-        testContext = new Log4j2TestContext("log4j2.Log4j2EnabledEventsIT.xml");
-
-        testContext.beforeTest();
-
-        loggerA = testContext.getLoggerContext().getLogger(EVENT_NAME_A);
-        loggerB = testContext.getLoggerContext().getLogger(EVENT_NAME_B);
-        loggerC = testContext.getLoggerContext().getLogger(EVENT_NAME_C);
-        loggerD = testContext.getLoggerContext().getLogger(EVENT_NAME_D);
-
-        handlerA = (ILttngHandler) loggerA.getAppenders().get(APPENDER_NAME_A);
-        handlerB = (ILttngHandler) loggerB.getAppenders().get(APPENDER_NAME_B);
-        handlerC = (ILttngHandler) loggerC.getAppenders().get(APPENDER_NAME_C);
-    }
-
-    /**
-     * Test teardown
-     */
-    @AfterEach
-    public void log4j2Teardown() {
-        loggerA = null;
-        loggerB = null;
-        loggerC = null;
-        loggerD = null;
-
-        testContext.afterTest();
-    }
+@Tag("agent:log4j2")
+@Tag("domain:log4j2")
+public class Log4j2EnabledEventsIT extends Log4j2EnabledEventsITBase {
 
     @Override
     protected Domain getDomain() {
-        return DOMAIN;
-    }
-
-    @Override
-    protected boolean closeHandlers()
-    {
-        return false;
-    }
-
-    @Override
-    protected void sendEventsToLoggers() {
-        Log4j2TestUtils.send10Events(loggerA);
-        Log4j2TestUtils.send10Events(loggerB);
-        Log4j2TestUtils.send10Events(loggerC);
-        Log4j2TestUtils.send10Events(loggerD);
-    }
-
-    @Override
-    protected void sendLocalizedEvent(String rawString, Object[] params) {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    @Test
-    public void testLocalizedMessage() {
-        /* Does not apply to log4j 1.2.x */
+        return Domain.LOG4J2;
     }
 }
index 04676b62b28eb99cec5876376c04388c23821775..6d0c18e30a759c45013dc421e2e017a5a3574b4b 100644 (file)
 
 package org.lttng.ust.agent.integration.events;
 
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import org.junit.jupiter.api.Tag;
+import org.lttng.tools.ILttngSession.Domain;
 
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.logging.log4j.Logger;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.TestInfo;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.lttng.tools.ILttngSession;
-import org.lttng.ust.agent.utils.Log4j2TestContext;
-import org.lttng.ust.agent.utils.Log4j2TestUtils;
-import org.lttng.ust.agent.utils.TestPrintExtension;
 
 /**
  * Test suite for the list events command for the log4j domain
  */
-@ExtendWith(TestPrintExtension.class)
-public class Log4j2ListEventsIT {
-
-    protected static final String LOGGER_NAME_1 = "org.lttng.somecomponent";
-    protected static final String LOGGER_NAME_2 = "org.lttng.mycomponent";
-    protected static final String LOGGER_NAME_3 = "org.lttng.myothercomponent-àéç";
-
-    @SuppressWarnings("unused")
-    private Logger logger1;
-    @SuppressWarnings("unused")
-    private Logger logger2;
-    @SuppressWarnings("unused")
-    private Logger logger3;
-
-    private ILttngSession session;
-    private Log4j2TestContext testContext;
-
-    /**
-     * Class setup
-     */
-    @BeforeAll
-    public static void log4j2ClassSetup() {
-        Log4j2TestUtils.testClassSetup();
-    }
-
-    /**
-     * Class cleanup
-     */
-    @AfterAll
-    public static void log4j2ClassCleanup() {
-        Log4j2TestUtils.testClassCleanup();
-    }
-
-    /**
-     * Create a new session before each test.
-     * @param testInfo current test information
-     */
-    @SuppressWarnings("resource")
-    @BeforeEach
-    public void testSetup(TestInfo testInfo) {
-        session = ILttngSession.createSession("Log4j2ListEventsIT", ILttngSession.Domain.LOG4J);
-
-        testContext = new Log4j2TestContext("log4j2." + testInfo.getDisplayName().replaceAll("[()]", "") + ".xml");
-
-        testContext.beforeTest();
-
-        logger1 = testContext.getLoggerContext().getLogger(LOGGER_NAME_1);
-        logger2 = testContext.getLoggerContext().getLogger(LOGGER_NAME_2);
-        logger3 = testContext.getLoggerContext().getLogger(LOGGER_NAME_3);
-    }
-
-    /**
-     * Close the current session after each test.
-     */
-    @AfterEach
-    public void testTeardown() {
-        session.close();
-        testContext.afterTest();
-    }
-
-    /**
-     * Test with many loggers existing, but none of them having a LTTng handler
-     * attached.
-     */
-    @Test
-    public void testManyLoggersNoneAttached() {
-
-        /* Don't attach anything */
-        List<String> actualEvents = session.listEvents();
-        assertTrue(actualEvents.isEmpty());
-    }
-
-    /**
-     * Test with many loggers existing, but only a subset of them has a LTTng
-     * handler attached.
-     */
-    @Test
-    public void testManyLoggersSomeAttached() {
-
-        List<String> expectedEvents = Arrays.asList(LOGGER_NAME_1);
-        List<String> actualEvents = session.listEvents();
-
-        Collections.sort(expectedEvents);
-        Collections.sort(actualEvents);
-
-        assertEquals(expectedEvents, actualEvents);
-    }
-
-    /**
-     * Test with many loggers existing, and all of them having a LTTng handler
-     * attached.
-     */
-    @Test
-    public void testManyLoggersAllAttached() {
-
-        List<String> expectedEvents = Arrays.asList(LOGGER_NAME_1, LOGGER_NAME_2, LOGGER_NAME_3);
-        List<String> actualEvents = session.listEvents();
-
-        Collections.sort(expectedEvents);
-        Collections.sort(actualEvents);
+@Tag("agent:log4j2")
+@Tag("domain:log4j2")
+public class Log4j2ListEventsIT extends Log4j2ListEventsITBase {
 
-        assertEquals(expectedEvents, actualEvents);
+    @Override
+    protected Domain getDomain() {
+        return Domain.LOG4J2;
     }
 }
index 36eb43539344008cb551cd189ebc75bfc3a9b496..1d2c99856dd7e7c514c1d6915091fb42b6a36666 100644 (file)
 
 package org.lttng.ust.agent.integration.events;
 
-import java.io.IOException;
-
-import org.apache.logging.log4j.core.Logger;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
 import org.lttng.tools.ILttngSession.Domain;
-import org.lttng.ust.agent.ILttngHandler;
-import org.lttng.ust.agent.utils.Log4j2TestContext;
-import org.lttng.ust.agent.utils.Log4j2TestUtils;
+
 
 /**
  * Log4j tests for multiple concurrent tracing sessions
  */
-public class Log4j2MultiSessionIT extends MultiSessionITBase {
-
-    private static final String APPENDER_NAME_A = "LttngA";
-    private static final String APPENDER_NAME_B = "LttngB";
-    private static final String APPENDER_NAME_C = "LttngC";
-    private static final String APPENDER_NAME_D = "LttngD";
-
-    private static final Domain DOMAIN = Domain.LOG4J;
-
-    private Log4j2TestContext testContext;
-
-    private Logger loggerA;
-    private Logger loggerB;
-    private Logger loggerC;
-    private Logger loggerD;
-
-    /**
-     * Class setup
-     */
-    @BeforeAll
-    public static void log4j2ClassSetup() {
-        Log4j2TestUtils.testClassSetup();
-    }
-
-    /**
-     * Class cleanup
-     */
-    @AfterAll
-    public static void log4j2ClassCleanup() {
-        Log4j2TestUtils.testClassCleanup();
-    }
-
-       /**
-        * Test setup
-        *
-        * @throws SecurityException
-        * @throws IOException
-        */
-    @SuppressWarnings("resource")
-    @BeforeEach
-    public void log4j2Setup() throws SecurityException, IOException {
-
-        testContext = new Log4j2TestContext("log4j2.Log4j2MultiSessionIT.xml");
-
-        testContext.beforeTest();
-
-        loggerA = testContext.getLoggerContext().getLogger(EVENT_NAME_A);
-        loggerB = testContext.getLoggerContext().getLogger(EVENT_NAME_B);
-        loggerC = testContext.getLoggerContext().getLogger(EVENT_NAME_C);
-        loggerD = testContext.getLoggerContext().getLogger(EVENT_NAME_D);
-
-        handlerA = (ILttngHandler) loggerA.getAppenders().get(APPENDER_NAME_A);
-        handlerB = (ILttngHandler) loggerB.getAppenders().get(APPENDER_NAME_B);
-        handlerC = (ILttngHandler) loggerC.getAppenders().get(APPENDER_NAME_C);
-        handlerD = (ILttngHandler) loggerD.getAppenders().get(APPENDER_NAME_D);
-    }
-
-    /**
-     * Test teardown
-     */
-    @AfterEach
-    public void log4j2Teardown() {
-        loggerA = null;
-        loggerB = null;
-        loggerC = null;
-        loggerD = null;
-
-        testContext.afterTest();
-    }
+@Tag("agent:log4j2")
+@Tag("domain:log4j2")
+public class Log4j2MultiSessionIT extends Log4j2MultiSessionITBase {
 
     @Override
     protected Domain getDomain() {
-        return DOMAIN;
-    }
-
-    @Override
-    protected boolean closeHandlers()
-    {
-        return false;
-    }
-
-    @Override
-    protected void sendEventsToLoggers() {
-        Log4j2TestUtils.send10Events(loggerA);
-        Log4j2TestUtils.send10Events(loggerB);
-        Log4j2TestUtils.send10Events(loggerC);
-        Log4j2TestUtils.send10Events(loggerD);
+        return Domain.LOG4J2;
     }
 }
diff --git a/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/filter/Log4j2CompatFilterListenerIT.java b/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/filter/Log4j2CompatFilterListenerIT.java
new file mode 100644 (file)
index 0000000..9f0c903
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2022, EfficiOS Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+package org.lttng.ust.agent.integration.filter;
+
+import org.junit.jupiter.api.Tag;
+import org.lttng.tools.ILttngSession;
+import org.lttng.ust.agent.utils.ILogLevelStrings;
+
+
+/**
+ * Filter notifications tests using the log4j logging API.
+ */
+@Tag("agent:log4j2")
+@Tag("domain:log4j")
+public class Log4j2CompatFilterListenerIT extends Log4j2FilterListenerITBase {
+
+    @Override
+    protected ILttngSession.Domain getSessionDomain() {
+        return ILttngSession.Domain.LOG4J;
+    }
+
+    @Override
+    protected ILogLevelStrings getLogLevelStrings() {
+        return ILogLevelStrings.LOG4J_LOGLEVEL_STRINGS;
+    }
+}
diff --git a/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/filter/Log4j2CompatFilterListenerOrderingIT.java b/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/integration/filter/Log4j2CompatFilterListenerOrderingIT.java
new file mode 100644 (file)
index 0000000..2849f4e
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2022, EfficiOS Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+package org.lttng.ust.agent.integration.filter;
+
+import org.junit.jupiter.api.Tag;
+import org.lttng.tools.ILttngSession.Domain;
+
+
+/**
+ * Implementation of {@link FilterListenerOrderingITBase} for the log4j API.
+ */
+@Tag("agent:log4j2")
+@Tag("domain:log4j")
+public class Log4j2CompatFilterListenerOrderingIT extends Log4j2FilterListenerOrderingITBase {
+
+    @Override
+    protected Domain getDomain() {
+        return Domain.LOG4J;
+    }
+}
index 7e2beb793d6e54a4acb7d26d6991c27cfc25c924..ecc1ba2003ed64c6b4a0e264b788a41033b438e6 100644 (file)
 
 package org.lttng.ust.agent.integration.filter;
 
-import java.io.IOException;
-
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
 import org.lttng.tools.ILttngSession;
-import org.lttng.ust.agent.ILttngHandler;
-import org.lttng.ust.agent.log4j2.LttngLogAppender;
 import org.lttng.ust.agent.utils.ILogLevelStrings;
-import org.lttng.ust.agent.utils.Log4j2TestUtils;
+
 
 /**
  * Filter notifications tests using the log4j logging API.
- *
- * @author Alexandre Montplaisir
  */
-public class Log4j2FilterListenerIT extends FilterListenerITBase {
-
-    /**
-     * Class setup
-     */
-    @BeforeAll
-    public static void log4j2ClassSetup() {
-        Log4j2TestUtils.testClassSetup();
-    }
-
-    /**
-     * Class cleanup
-     */
-    @AfterAll
-    public static void log4j2ClassCleanup() {
-        Log4j2TestUtils.testClassCleanup();
-    }
+@Tag("agent:log4j2")
+@Tag("domain:log4j2")
+public class Log4j2FilterListenerIT extends Log4j2FilterListenerITBase {
 
     @Override
     protected ILttngSession.Domain getSessionDomain() {
-        return ILttngSession.Domain.LOG4J;
-    }
-
-    @Override
-    protected ILttngHandler getLogHandler() throws SecurityException, IOException {
-        return LttngLogAppender.createAppender("Log4j2FilterListenerIT", null, null);
+        return ILttngSession.Domain.LOG4J2;
     }
 
     @Override
     protected ILogLevelStrings getLogLevelStrings() {
-        return ILogLevelStrings.LOG4J_LOGLEVEL_STRINGS;
+        return ILogLevelStrings.LOG4J2_LOGLEVEL_STRINGS;
     }
-
 }
index 03e8f9e12913bf656226a9c1e2963c2cc9b9e54d..7a60bb2524a09e6621eb3ffc4088c597c69bee35 100644 (file)
 
 package org.lttng.ust.agent.integration.filter;
 
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
 import org.lttng.tools.ILttngSession.Domain;
-import org.lttng.ust.agent.utils.Log4j2TestContext;
-import org.lttng.ust.agent.utils.Log4j2TestUtils;
+
 
 /**
  * Implementation of {@link FilterListenerOrderingITBase} for the log4j API.
  */
-public class Log4j2FilterListenerOrderingIT extends FilterListenerOrderingITBase {
-
-    private Log4j2TestContext testContext;
-
-    /**
-     * Class setup
-     */
-    @BeforeAll
-    public static void log4j2ClassSetup() {
-        Log4j2TestUtils.testClassSetup();
-    }
-
-    /**
-     * Class cleanup
-     */
-    @AfterAll
-    public static void log4j2ClassCleanup() {
-        Log4j2TestUtils.testClassCleanup();
-    }
+@Tag("agent:log4j2")
+@Tag("domain:log4j2")
+public class Log4j2FilterListenerOrderingIT extends Log4j2FilterListenerOrderingITBase {
 
     @Override
     protected Domain getDomain() {
-        return Domain.LOG4J;
-    }
-
-    @Override
-    protected void registerAgent() {
-        testContext = new Log4j2TestContext("log4j2.Log4j2FilterListenerOrderingIT.xml");
-        testContext.beforeTest();
-    }
-
-    @Override
-    protected void deregisterAgent() {
-        testContext.afterTest();
+        return Domain.LOG4J2;
     }
 }
diff --git a/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/utils/Log4j2TestContext.java b/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/utils/Log4j2TestContext.java
deleted file mode 100644 (file)
index 301ff70..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2022, EfficiOS Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-package org.lttng.ust.agent.utils;
-
-import java.net.URI;
-import java.net.URL;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.core.LoggerContext;
-
-/**
- * Log4j 2.x test context utilities.
- */
-public class Log4j2TestContext {
-
-    private final URI configFileUri;
-
-    private LoggerContext loggerContext;
-
-    /**
-     * @param configFile path to the log4j configuration file.
-     */
-    public Log4j2TestContext(String configFile) {
-
-        URL resource = getClass().getClassLoader().getResource(configFile);
-
-        if (resource == null) {
-            throw new IllegalArgumentException("Config file not found: " + configFile);
-        }
-
-        try {
-            this.configFileUri = resource.toURI();
-        } catch (Exception e) {
-            throw new IllegalArgumentException("Config file invalid URI: " + resource);
-        }
-    }
-
-    /**
-     * @return the log4j2 logger context.
-     */
-    public synchronized LoggerContext getLoggerContext() {
-        return loggerContext;
-    }
-
-    /**
-     * Initialize the log4j2 context before running a test.
-     */
-    public synchronized void beforeTest() {
-        loggerContext = (LoggerContext) LogManager.getContext(
-                ClassLoader.getSystemClassLoader(), false, configFileUri);
-    }
-
-    /**
-     * Dispose of the log4j2 context after running a test.
-     */
-    public synchronized void afterTest() {
-        loggerContext.stop();
-    }
-}
diff --git a/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/utils/Log4j2TestUtils.java b/lttng-ust-java-tests-log4j2/src/test/java/org/lttng/ust/agent/utils/Log4j2TestUtils.java
deleted file mode 100644 (file)
index 33eed8e..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2022, EfficiOS Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-package org.lttng.ust.agent.utils;
-
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
-
-import java.io.IOException;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Logger;
-import org.lttng.tools.ILttngSession.Domain;
-import org.lttng.tools.LttngToolsHelper;
-import org.lttng.ust.agent.log4j2.LttngLogAppender;
-
-
-/**
- * Utility methods for log4j 2.x tests
- */
-public final class Log4j2TestUtils {
-
-    private Log4j2TestUtils() {
-    }
-
-    /**
-     * Setup method common to most log4j tests. To be called in a @BeforeClass.
-     */
-    public static void testClassSetup() {
-        /* Make sure we can find the JNI library and lttng-tools */
-        checkForLog4jLibrary();
-        assertTrue(LttngUtils.checkForLttngTools(Domain.LOG4J), "lttng-tools is not working properly.");
-
-        LttngToolsHelper.destroyAllSessions();
-    }
-
-    /**
-     * Teardown method common to most log4j tests. To be called in a @AfterClass.
-     */
-    public static void testClassCleanup() {
-        LttngToolsHelper.deleteAllTraces();
-    }
-
-    /**
-     * Check the the Log4j native library is available, effectively allowing
-     * LTTng Log4j appenders to be used.
-     */
-    private static void checkForLog4jLibrary() {
-        try {
-            LttngLogAppender testAppender = LttngLogAppender.createAppender("checkForLttngTools", null, null);
-            testAppender.close();
-        } catch (SecurityException | IOException e) {
-            fail(e.getMessage());
-        }
-    }
-
-    /**
-     * Send 10 dummy events through the provided logger
-     *
-     * @param logger
-     *            The logger to use to send events
-     */
-    public static void send10Events(Logger logger) {
-        // Levels/priorities are DEBUG, ERROR, FATAL, INFO, TRACE, WARN
-        logger.debug("Debug message. Lost among so many.");
-        logger.debug("Debug message with a throwable", new IOException());
-        logger.error("Error messsage. This might be bad.");
-        logger.error("Error message with a throwable", new IOException());
-        logger.fatal("A fatal message. You are already dead.");
-        logger.info("A info message. Lol, who cares.");
-        logger.trace("A trace message. No, no *that* trace");
-        logger.warn("A warn message. Yellow underline.");
-        logger.log(Level.DEBUG, "A debug message using .log()");
-        logger.log(Level.ERROR, "A error message using .log()");
-    }
-}
diff --git a/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.LOG4J2testManyLoggersAllAttached.xml b/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.LOG4J2testManyLoggersAllAttached.xml
new file mode 100644 (file)
index 0000000..3cf465f
--- /dev/null
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration name="ManyLoggersAllAttached" status="debug">
+    <Appenders>
+        <Console name="Console" target="SYSTEM_OUT">
+          <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
+        </Console>
+        <Lttng name="Lttng1" domain="LOG4J2"/>
+        <Lttng name="Lttng2" domain="LOG4J2"/>
+        <Lttng name="Lttng3" domain="LOG4J2"/>
+    </Appenders>
+    <Loggers>
+        <Logger name="org.lttng.somecomponent">
+          <AppenderRef ref="Console"/>
+          <AppenderRef ref="Lttng1"/>
+        </Logger>
+        <Logger name="org.lttng.mycomponent">
+          <AppenderRef ref="Console"/>
+          <AppenderRef ref="Lttng2"/>
+        </Logger>
+        <Logger name="org.lttng.myothercomponent-àéç">
+          <AppenderRef ref="Console"/>
+          <AppenderRef ref="Lttng3"/>
+        </Logger>
+        <Root level="all"/>
+    </Loggers>
+</Configuration>
diff --git a/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.LOG4J2testManyLoggersNoneAttached.xml b/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.LOG4J2testManyLoggersNoneAttached.xml
new file mode 100644 (file)
index 0000000..3275ec9
--- /dev/null
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration name="ManyLoggersNoneAttached" status="debug">
+    <Appenders>
+        <Console name="Console" target="SYSTEM_OUT">
+          <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
+        </Console>
+        <Lttng name="Lttng1" domain="LOG4J2"/>
+        <Lttng name="Lttng2" domain="LOG4J2"/>
+        <Lttng name="Lttng3" domain="LOG4J2"/>
+    </Appenders>
+    <Loggers>
+        <Logger name="org.lttng.somecomponent">
+          <AppenderRef ref="Console"/>
+        </Logger>
+        <Logger name="org.lttng.mycomponent">
+          <AppenderRef ref="Console"/>
+        </Logger>
+        <Logger name="org.lttng.myothercomponent-àéç">
+          <AppenderRef ref="Console"/>
+        </Logger>
+        <Root level="all"/>
+    </Loggers>
+</Configuration>
diff --git a/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.LOG4J2testManyLoggersSomeAttached.xml b/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.LOG4J2testManyLoggersSomeAttached.xml
new file mode 100644 (file)
index 0000000..350e7a0
--- /dev/null
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration name="ManyLoggersSomeAttached" status="debug">
+    <Appenders>
+        <Console name="Console" target="SYSTEM_OUT">
+          <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
+        </Console>
+        <Lttng name="Lttng1" domain="LOG4J2"/>
+        <Lttng name="Lttng2" domain="LOG4J2"/>
+        <Lttng name="Lttng3" domain="LOG4J2"/>
+    </Appenders>
+    <Loggers>
+        <Logger name="org.lttng.somecomponent">
+          <AppenderRef ref="Console"/>
+          <AppenderRef ref="Lttng1"/>
+        </Logger>
+        <Logger name="org.lttng.mycomponent">
+          <AppenderRef ref="Console"/>
+        </Logger>
+        <Logger name="org.lttng.myothercomponent-àéç">
+          <AppenderRef ref="Console"/>
+        </Logger>
+        <Root level="all"/>
+    </Loggers>
+</Configuration>
diff --git a/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.LOG4JtestManyLoggersAllAttached.xml b/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.LOG4JtestManyLoggersAllAttached.xml
new file mode 100644 (file)
index 0000000..0a6714e
--- /dev/null
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration name="ManyLoggersAllAttached" status="debug">
+    <Appenders>
+        <Console name="Console" target="SYSTEM_OUT">
+          <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
+        </Console>
+        <Lttng name="Lttng1" domain="LOG4J"/>
+        <Lttng name="Lttng2" domain="LOG4J"/>
+        <Lttng name="Lttng3" domain="LOG4J"/>
+    </Appenders>
+    <Loggers>
+        <Logger name="org.lttng.somecomponent">
+          <AppenderRef ref="Console"/>
+          <AppenderRef ref="Lttng1"/>
+        </Logger>
+        <Logger name="org.lttng.mycomponent">
+          <AppenderRef ref="Console"/>
+          <AppenderRef ref="Lttng2"/>
+        </Logger>
+        <Logger name="org.lttng.myothercomponent-àéç">
+          <AppenderRef ref="Console"/>
+          <AppenderRef ref="Lttng3"/>
+        </Logger>
+        <Root level="all"/>
+    </Loggers>
+</Configuration>
diff --git a/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.LOG4JtestManyLoggersNoneAttached.xml b/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.LOG4JtestManyLoggersNoneAttached.xml
new file mode 100644 (file)
index 0000000..0e69868
--- /dev/null
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration name="ManyLoggersNoneAttached" status="debug">
+    <Appenders>
+        <Console name="Console" target="SYSTEM_OUT">
+          <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
+        </Console>
+        <Lttng name="Lttng1" domain="LOG4J"/>
+        <Lttng name="Lttng2" domain="LOG4J"/>
+        <Lttng name="Lttng3" domain="LOG4J"/>
+    </Appenders>
+    <Loggers>
+        <Logger name="org.lttng.somecomponent">
+          <AppenderRef ref="Console"/>
+        </Logger>
+        <Logger name="org.lttng.mycomponent">
+          <AppenderRef ref="Console"/>
+        </Logger>
+        <Logger name="org.lttng.myothercomponent-àéç">
+          <AppenderRef ref="Console"/>
+        </Logger>
+        <Root level="all"/>
+    </Loggers>
+</Configuration>
diff --git a/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.LOG4JtestManyLoggersSomeAttached.xml b/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.LOG4JtestManyLoggersSomeAttached.xml
new file mode 100644 (file)
index 0000000..cc93c0c
--- /dev/null
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration name="ManyLoggersSomeAttached" status="debug">
+    <Appenders>
+        <Console name="Console" target="SYSTEM_OUT">
+          <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
+        </Console>
+        <Lttng name="Lttng1" domain="LOG4J"/>
+        <Lttng name="Lttng2" domain="LOG4J"/>
+        <Lttng name="Lttng3" domain="LOG4J"/>
+    </Appenders>
+    <Loggers>
+        <Logger name="org.lttng.somecomponent">
+          <AppenderRef ref="Console"/>
+          <AppenderRef ref="Lttng1"/>
+        </Logger>
+        <Logger name="org.lttng.mycomponent">
+          <AppenderRef ref="Console"/>
+        </Logger>
+        <Logger name="org.lttng.myothercomponent-àéç">
+          <AppenderRef ref="Console"/>
+        </Logger>
+        <Root level="all"/>
+    </Loggers>
+</Configuration>
index 11016e18b8aba5e8f461e088c8a0f5fc070bd962..0f1f0b6f45779ae33bb273726f8df382f09637d1 100644 (file)
@@ -4,7 +4,7 @@
         <Console name="Console" target="SYSTEM_OUT">
           <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
         </Console>
-        <Lttng name="Lttng"/>
+        <Lttng name="Lttng" domain="LOG4J2"/>
     </Appenders>
     <Loggers>
         <Logger name="EventName">
index 6c812c54cd79a996f5ed0bfa7e92c441aec1679d..1509542e5344f3b674c9281cf1010ff60d5f566f 100644 (file)
@@ -4,7 +4,7 @@
         <Console name="Console" target="SYSTEM_OUT">
           <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
         </Console>
-        <Lttng name="Lttng"/>
+        <Lttng name="Lttng" domain="LOG4J2"/>
     </Appenders>
     <Loggers>
         <Logger name="EventName">
diff --git a/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2CompatAppContextIT.xml b/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2CompatAppContextIT.xml
new file mode 100644 (file)
index 0000000..bdc4d27
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration name="Log4j2CompatAppContextIT" status="debug">
+    <Appenders>
+        <Console name="Console" target="SYSTEM_OUT">
+          <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
+        </Console>
+        <Lttng name="Lttng" domain="LOG4J"/>
+    </Appenders>
+    <Loggers>
+        <Logger name="EventName">
+          <AppenderRef ref="Console"/>
+          <AppenderRef ref="Lttng"/>
+        </Logger>
+        <Root level="all"/>
+    </Loggers>
+</Configuration>
diff --git a/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2CompatAppContextOrderingIT.xml b/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2CompatAppContextOrderingIT.xml
new file mode 100644 (file)
index 0000000..79dd3f3
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration name="Log4j2CompatAppContextOrderingIT" status="debug">
+    <Appenders>
+        <Console name="Console" target="SYSTEM_OUT">
+          <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
+        </Console>
+        <Lttng name="Lttng" domain="LOG4J"/>
+    </Appenders>
+    <Loggers>
+        <Logger name="EventName">
+          <AppenderRef ref="Console"/>
+          <AppenderRef ref="Lttng"/>
+        </Logger>
+        <Root level="all"/>
+    </Loggers>
+</Configuration>
diff --git a/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2CompatEnabledEventsIT.xml b/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2CompatEnabledEventsIT.xml
new file mode 100644 (file)
index 0000000..56a0aaf
--- /dev/null
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration name="Log4j2CompatListEventsIT" status="debug">
+    <Appenders>
+        <Console name="Console" target="SYSTEM_OUT">
+          <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
+        </Console>
+        <Lttng name="LttngA" domain="LOG4J"/>
+        <Lttng name="LttngB" domain="LOG4J"/>
+        <Lttng name="LttngC" domain="LOG4J"/>
+    </Appenders>
+    <Loggers>
+        <Logger name="EventA">
+          <AppenderRef ref="Console"/>
+          <AppenderRef ref="LttngA"/>
+        </Logger>
+        <Logger name="EventAB">
+          <AppenderRef ref="Console"/>
+          <AppenderRef ref="LttngB"/>
+        </Logger>
+        <Logger name="EventABC">
+          <AppenderRef ref="Console"/>
+          <AppenderRef ref="LttngC"/>
+        </Logger>
+        <Logger name="EventABCDÉ">
+          <AppenderRef ref="Console"/>
+        </Logger>
+        <Root level="all"/>
+    </Loggers>
+</Configuration>
diff --git a/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2CompatFilterListenerOrderingIT.xml b/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2CompatFilterListenerOrderingIT.xml
new file mode 100644 (file)
index 0000000..aa95f59
--- /dev/null
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration name="Log4j2CompatFilterListenerOrderingIT" status="debug">
+    <Appenders>
+        <Console name="Console" target="SYSTEM_OUT">
+          <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
+        </Console>
+        <Lttng name="Lttng" domain="LOG4J"/>
+    </Appenders>
+    <Loggers>
+        <Logger name="EventA">
+          <AppenderRef ref="Console"/>
+          <AppenderRef ref="Lttng"/>
+        </Logger>
+        <Logger name="EventB">
+          <AppenderRef ref="Console"/>
+          <AppenderRef ref="Lttng"/>
+        </Logger>
+        <Root level="all"/>
+    </Loggers>
+</Configuration>
diff --git a/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2CompatMultiSessionIT.xml b/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.Log4j2CompatMultiSessionIT.xml
new file mode 100644 (file)
index 0000000..4c5f86d
--- /dev/null
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration name="Log4j2CompatMultiSessionIT" status="debug">
+    <Appenders>
+        <Console name="Console" target="SYSTEM_OUT">
+          <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
+        </Console>
+        <Lttng name="LttngA" domain="LOG4J"/>
+        <Lttng name="LttngB" domain="LOG4J"/>
+        <Lttng name="LttngC" domain="LOG4J"/>
+        <Lttng name="LttngD" domain="LOG4J"/>
+    </Appenders>
+    <Loggers>
+        <Logger name="EventA">
+          <AppenderRef ref="Console"/>
+          <AppenderRef ref="LttngA"/>
+        </Logger>
+        <Logger name="EventAB">
+          <AppenderRef ref="Console"/>
+          <AppenderRef ref="LttngB"/>
+        </Logger>
+        <Logger name="EventABC">
+          <AppenderRef ref="Console"/>
+          <AppenderRef ref="LttngC"/>
+        </Logger>
+        <Logger name="EventABCDÉ">
+          <AppenderRef ref="Console"/>
+          <AppenderRef ref="LttngD"/>
+        </Logger>
+        <Root level="all"/>
+    </Loggers>
+</Configuration>
index a55444c753e31cf12ab2356e5e183cd7d7c2abea..ab2e7d84ebc5944b593f528dcc2148dba3ed8928 100644 (file)
@@ -4,9 +4,9 @@
         <Console name="Console" target="SYSTEM_OUT">
           <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
         </Console>
-        <Lttng name="LttngA"/>
-        <Lttng name="LttngB"/>
-        <Lttng name="LttngC"/>
+        <Lttng name="LttngA" domain="LOG4J2"/>
+        <Lttng name="LttngB" domain="LOG4J2"/>
+        <Lttng name="LttngC" domain="LOG4J2"/>
     </Appenders>
     <Loggers>
         <Logger name="EventA">
index 54f5ce0cfa2c52c157ad0ca90d4e88d812ff1f22..46dba21bbbc0fc92619ee991835534265b40ea0c 100644 (file)
@@ -4,7 +4,7 @@
         <Console name="Console" target="SYSTEM_OUT">
           <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
         </Console>
-        <Lttng name="Lttng"/>
+        <Lttng name="Lttng" domain="LOG4J2"/>
     </Appenders>
     <Loggers>
         <Logger name="EventA">
index 22e5be154474884687b6487cb90ce142a7d77868..c4ab05d3da00243569c1cd52a5c76976ab815824 100644 (file)
@@ -4,10 +4,10 @@
         <Console name="Console" target="SYSTEM_OUT">
           <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
         </Console>
-        <Lttng name="LttngA"/>
-        <Lttng name="LttngB"/>
-        <Lttng name="LttngC"/>
-        <Lttng name="LttngD"/>
+        <Lttng name="LttngA" domain="LOG4J2"/>
+        <Lttng name="LttngB" domain="LOG4J2"/>
+        <Lttng name="LttngC" domain="LOG4J2"/>
+        <Lttng name="LttngD" domain="LOG4J2"/>
     </Appenders>
     <Loggers>
         <Logger name="EventA">
diff --git a/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.testManyLoggersAllAttached.xml b/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.testManyLoggersAllAttached.xml
deleted file mode 100644 (file)
index 979a1e2..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<Configuration name="ManyLoggersAllAttached" status="debug">
-    <Appenders>
-        <Console name="Console" target="SYSTEM_OUT">
-          <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
-        </Console>
-        <Lttng name="Lttng1"/>
-        <Lttng name="Lttng2"/>
-        <Lttng name="Lttng3"/>
-    </Appenders>
-    <Loggers>
-        <Logger name="org.lttng.somecomponent">
-          <AppenderRef ref="Console"/>
-          <AppenderRef ref="Lttng1"/>
-        </Logger>
-        <Logger name="org.lttng.mycomponent">
-          <AppenderRef ref="Console"/>
-          <AppenderRef ref="Lttng2"/>
-        </Logger>
-        <Logger name="org.lttng.myothercomponent-àéç">
-          <AppenderRef ref="Console"/>
-          <AppenderRef ref="Lttng3"/>
-        </Logger>
-        <Root level="all"/>
-    </Loggers>
-</Configuration>
diff --git a/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.testManyLoggersNoneAttached.xml b/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.testManyLoggersNoneAttached.xml
deleted file mode 100644 (file)
index ffbbd03..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<Configuration name="ManyLoggersNoneAttached" status="debug">
-    <Appenders>
-        <Console name="Console" target="SYSTEM_OUT">
-          <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
-        </Console>
-        <Lttng name="Lttng1"/>
-        <Lttng name="Lttng2"/>
-        <Lttng name="Lttng3"/>
-    </Appenders>
-    <Loggers>
-        <Logger name="org.lttng.somecomponent">
-          <AppenderRef ref="Console"/>
-        </Logger>
-        <Logger name="org.lttng.mycomponent">
-          <AppenderRef ref="Console"/>
-        </Logger>
-        <Logger name="org.lttng.myothercomponent-àéç">
-          <AppenderRef ref="Console"/>
-        </Logger>
-        <Root level="all"/>
-    </Loggers>
-</Configuration>
diff --git a/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.testManyLoggersSomeAttached.xml b/lttng-ust-java-tests-log4j2/src/test/resources/log4j2.testManyLoggersSomeAttached.xml
deleted file mode 100644 (file)
index de5e9cd..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<Configuration name="ManyLoggersSomeAttached" status="debug">
-    <Appenders>
-        <Console name="Console" target="SYSTEM_OUT">
-          <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
-        </Console>
-        <Lttng name="Lttng1"/>
-        <Lttng name="Lttng2"/>
-        <Lttng name="Lttng3"/>
-    </Appenders>
-    <Loggers>
-        <Logger name="org.lttng.somecomponent">
-          <AppenderRef ref="Console"/>
-          <AppenderRef ref="Lttng1"/>
-        </Logger>
-        <Logger name="org.lttng.mycomponent">
-          <AppenderRef ref="Console"/>
-        </Logger>
-        <Logger name="org.lttng.myothercomponent-àéç">
-          <AppenderRef ref="Console"/>
-        </Logger>
-        <Root level="all"/>
-    </Loggers>
-</Configuration>
diff --git a/pom.xml b/pom.xml
index 68c634aa01d7324cf69620962a200522f10b9ac0..97aa28c810c63ed9c202f53dadbe3591daf1776b 100644 (file)
--- a/pom.xml
+++ b/pom.xml
           </configuration>
         </plugin>
 
+       <!-- Set Surefire to the same version as Failsafe even if we don't use
+            it. Otherwise, Maven will invoke a random default version and if
+            we specify a user property used by both plugins on the command
+            line things could go wrong. -->
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-surefire-plugin</artifactId>
+          <version>3.0.0-M5</version>
+        </plugin>
+
         <plugin>
           <groupId>org.apache.maven.plugins</groupId>
           <artifactId>maven-failsafe-plugin</artifactId>
         <groupId>org.lttng.ust</groupId>
         <artifactId>lttng-ust-java-tests-common</artifactId>
         <version>1.1.0-SNAPSHOT</version>
-        <scope>test</scope>
       </dependency>
     </dependencies>
   </dependencyManagement>
This page took 0.077557 seconds and 4 git commands to generate.