lttng.control: Document and test the JUL domain in the Control view
authorBruno Roy <bruno.roy@ericsson.com>
Tue, 26 Jul 2016 14:12:17 +0000 (10:12 -0400)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Sat, 6 Aug 2016 03:01:15 +0000 (23:01 -0400)
Add the documentation and tests for enable loggers of the JUL domain in
the Control view.

Change-Id: Idad308ed06ced482bda4aff1e2da2156b937095d
Signed-off-by: Bruno Roy <bruno.roy@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/78280
Reviewed-by: Hudson CI
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
21 files changed:
doc/org.eclipse.tracecompass.doc.user/doc/User-Guide.mediawiki
doc/org.eclipse.tracecompass.doc.user/doc/images/LTTng2EnabledAllJulLoggers.png [new file with mode: 0644]
doc/org.eclipse.tracecompass.doc.user/doc/images/LTTng2JulLoggerEventsDialog.png [new file with mode: 0644]
doc/org.eclipse.tracecompass.doc.user/doc/images/LTTng2JulLoglevelEventsDialog.png [new file with mode: 0644]
lttng/org.eclipse.tracecompass.lttng2.control.core.tests/src/org/eclipse/tracecompass/lttng2/control/core/tests/model/impl/BaseLoggerInfoTest.java [new file with mode: 0644]
lttng/org.eclipse.tracecompass.lttng2.control.core.tests/src/org/eclipse/tracecompass/lttng2/control/core/tests/model/impl/LoggerInfoTest.java [new file with mode: 0644]
lttng/org.eclipse.tracecompass.lttng2.control.core.tests/src/org/eclipse/tracecompass/lttng2/control/core/tests/model/impl/ModelImplFactory.java
lttng/org.eclipse.tracecompass.lttng2.control.core.tests/src/org/eclipse/tracecompass/lttng2/control/core/tests/model/impl/UstProviderInfoTest.java
lttng/org.eclipse.tracecompass.lttng2.control.core/src/org/eclipse/tracecompass/internal/lttng2/control/core/model/TraceJulLogLevel.java
lttng/org.eclipse.tracecompass.lttng2.control.core/src/org/eclipse/tracecompass/internal/lttng2/control/core/model/impl/BaseLoggerInfo.java
lttng/org.eclipse.tracecompass.lttng2.control.core/src/org/eclipse/tracecompass/internal/lttng2/control/core/model/impl/UstProviderInfo.java
lttng/org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/control/ui/swtbot/tests/ControlViewJulLoggerTest.java [new file with mode: 0644]
lttng/org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/control/ui/swtbot/tests/ControlViewSwtBotUtil.java
lttng/org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests/testfiles/CreateSessionTestLTTng2_8.cfg
lttng/org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests/testfiles/Profile.cfg
lttng/org.eclipse.tracecompass.lttng2.control.ui.tests/src/org/eclipse/tracecompass/lttng2/control/ui/tests/service/LTTngControlServiceMiTest.java
lttng/org.eclipse.tracecompass.lttng2.control.ui.tests/src/org/eclipse/tracecompass/lttng2/control/ui/tests/service/LTTngControlServiceTest.java
lttng/org.eclipse.tracecompass.lttng2.control.ui.tests/testfiles/LTTngServiceMi3Test.cfg
lttng/org.eclipse.tracecompass.lttng2.control.ui.tests/testfiles/LTTngServiceMiTest.cfg
lttng/org.eclipse.tracecompass.lttng2.control.ui.tests/testfiles/LTTngServiceTest.cfg
lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/property/TraceLoggerPropertySource.java

index 00cc335ae3c370d7cc809ee9f44be6dd49e4901d..98fe2d3048c19634d4123e408232115aa9393ca2 100644 (file)
@@ -1272,6 +1272,8 @@ A dialog box will open for entering information about the channel to be created.
 
 By default the domain '''Kernel''' is selected. To create a UST channel, select '''UST''' under the domain section. The label <Default> in any text box indicates that the default value of the tracer will be configured. To initialize the dialog box press button '''Default'''.
 
+'''Note''': You cannot create a channel under the '''JUL''' domain. Instead this domain uses a default channel of the '''UST global''' domain named '''lttng_jul_channel'''. This is the channel that LTTng uses to trace Java application (using '''JUL''') and you cannot add '''UST''' events to this channel.
+
 If required update the following channel information and then press '''Ok'''.
 
 * '''Channel Name''': The name of the channel.
@@ -1422,21 +1424,39 @@ For UST it is possible to enable '''Tracepoint''' events using log levels. To en
 Upon successful operation, the event with the given event name and event type '''TRACEPOINT''' will be added under the default channel (channel0). If necessary the domain '''UST global''' and the channel '''channel0''' will be created.
 
 [[Image:images/LTTng2EnabledUstLoglevelEvents.png]]
+=== Enabling JUL Events On Session Level ===
+
+For enabling JUL loggers, first open the enable events dialog as described in section [[#Enabling Kernel Events On Session Level | Enabling Kernel Events On Session Level]] and select domain '''JUL'''.
+
+To enable '''Loggers''', first select the corresponding '''Select''' button, then select either all loggers (select '''All''') or select selectively one or more loggers in the displayed tree of loggers and finally press '''Ok'''.
+
+[[Image:images/LTTng2JulLoggerEventsDialog.png]]
+
+Upon successful operation, the domain '''JUL''' will be created in the tree (if neccessary). With JUL loggers there is no channel, you see the enabled loggers directly under the '''JUL''' domain. Note that for the case that '''All''' loggers were selected the wildcard '''*''' is used which will be shown in the Control View as below.
+
+[[Image:images/LTTng2EnabledAllJulLoggers.png]]
+
+For JUL it is possible to enable '''Logger''' events using log levels. To enable '''Logger''' events using log levels, check the corresponding '''Select''' button, select a log level from the drop down menu, fill in the relevant information (see below) and press '''Ok'''.
+
+* '''loglevel''': To specify if a range of log levels (0 to selected log level) shall be configured
+* '''loglevel-only''': To specify that only the specified log level shall be configured
+
+[[Image:images/LTTng2JulLoglevelEventsDialog.png]]
 
 === Enabling Events On Domain Level ===
 
-Kernel events can also be enabled on the domain level. For that select the relevant domain tree node, click the right mouse button and the select '''Enable Event (default channel)...'''. A new dialog box will open for providing information about the events to be enabled. Depending on the domain, '''Kernel''' or '''UST global''', the domain specifc fields are shown and the domain selector is preselected and read-only.
+Kernel events can also be enabled on the domain level. For that select the relevant domain tree node, click the right mouse button and the select '''Enable Event (default channel)...'''. A new dialog box will open for providing information about the events to be enabled. Depending on the domain, '''Kernel''', '''UST global''' or '''JUL''', the domain specifc fields are shown and the domain selector is preselected and read-only.
 
 [[Image:images/LTTng2EventOnDomainAction.png]]
 
-To enable events for domain '''Kernel''' follow the instructions in section [[#Enabling Kernel Events On Session Level | Enabling Kernel Events On Session Level]], for domain '''UST global''', see section [[#Enabling UST Events On Session Level | Enabling UST Events On Session Level]].
+To enable events for domain '''Kernel''' follow the instructions in section [[#Enabling Kernel Events On Session Level | Enabling Kernel Events On Session Level]], for domain '''UST global''', see section [[#Enabling UST Events On Session Level | Enabling UST Events On Session Level]] and for the domain '''JUL''', see section [[#Enabling JUL Events On Session Level | Enabling JUL Events On Session Level]].
 The events will be add to the default channel '''channel0'''. This channel will be created by on the server side if neccessary.
 
 === Enabling Events On Channel Level ===
 
 Kernel events can also be enabled on the channel level. If necessary, create a channel as described in sections [[#Enabling Channels On Session Level | Enabling Channels On Session Level]] or [[#Enabling Channels On Domain Level | Enabling Channels On Domain Level]].
 
-Then select the relevant channel tree node, click the right mouse button and the select '''Enable Event...'''. A new dialog box will open for providing information about the events to be enabled. Depending on the domain, '''Kernel''' or '''UST global''', the domain specifc fields are shown and the domain selector is preselected and read-only.
+Then select the relevant channel tree node, click the right mouse button and the select '''Enable Event...'''. A new dialog box will open for providing information about the events to be enabled. Depending on the domain, '''Kernel''' or '''UST global''', the domain specifc fields are shown and the domain selector is preselected and read-only. Since there is no channel under the '''JUL''' domain you cannot enable a '''JUL''' logger directly from a channel. 
 
 [[Image:images/LTTng2EventOnChannelAction.png]]
 
@@ -1656,6 +1676,9 @@ The Control View provides property information of selected tree component. Depen
 ** '''Event Type''': The event type ('''TRACEPOINT''' only).
 ** '''Fields''': Shows a list of fields defined for the selected event. (UST only, since support for LTTng Tools v2.1.0)
 ** '''Log Level''': The log level of the event.
+* '''Logger''' Properties (Provider)
+** '''Logger Name''': The name of the logger.
+** '''Logger Type''': The event type ('''TRACEPOINT''' only).
 * '''Session''' Properties
 ** '''Session Name''': The name of the Session.
 ** '''Session Path''': The path on the remote host where the traces will be stored. (Not shown for snapshot sessions).
@@ -1683,6 +1706,11 @@ The Control View provides property information of selected tree component. Depen
 ** '''Log Level''': The log level of the event. (For LTTng Tools v2.4.0 or later, '''<=''' prior the log level name will indicate a range of log levels and '''==''' a single log level.)
 ** '''State''': The Event state ('''ENABLED''' or '''DISABLED''')
 ** '''Filter''': Shows '''with filter''' if a filter expression is configured else property '''Filter''' is omitted. (since support for LTTng Tools v2.1.0)
+* '''Logger''' Properties (Domain)
+** '''Logger Name''': The name of the logger.
+** '''Logger Type''': The logger type ('''TRACEPOINT''').
+** '''Log Level''': The log level of the logger. (For LTTng Tools v2.4.0 or later, '''<=''' prior the log level name will indicate a range of log levels and '''==''' a single log level.)
+** '''State''': The logger state ('''ENABLED''' or '''DISABLED''')
 
 == LTTng Tracer Control Preferences ==
 
diff --git a/doc/org.eclipse.tracecompass.doc.user/doc/images/LTTng2EnabledAllJulLoggers.png b/doc/org.eclipse.tracecompass.doc.user/doc/images/LTTng2EnabledAllJulLoggers.png
new file mode 100644 (file)
index 0000000..fa043b9
Binary files /dev/null and b/doc/org.eclipse.tracecompass.doc.user/doc/images/LTTng2EnabledAllJulLoggers.png differ
diff --git a/doc/org.eclipse.tracecompass.doc.user/doc/images/LTTng2JulLoggerEventsDialog.png b/doc/org.eclipse.tracecompass.doc.user/doc/images/LTTng2JulLoggerEventsDialog.png
new file mode 100644 (file)
index 0000000..cc22b95
Binary files /dev/null and b/doc/org.eclipse.tracecompass.doc.user/doc/images/LTTng2JulLoggerEventsDialog.png differ
diff --git a/doc/org.eclipse.tracecompass.doc.user/doc/images/LTTng2JulLoglevelEventsDialog.png b/doc/org.eclipse.tracecompass.doc.user/doc/images/LTTng2JulLoglevelEventsDialog.png
new file mode 100644 (file)
index 0000000..5dc1e23
Binary files /dev/null and b/doc/org.eclipse.tracecompass.doc.user/doc/images/LTTng2JulLoglevelEventsDialog.png differ
diff --git a/lttng/org.eclipse.tracecompass.lttng2.control.core.tests/src/org/eclipse/tracecompass/lttng2/control/core/tests/model/impl/BaseLoggerInfoTest.java b/lttng/org.eclipse.tracecompass.lttng2.control.core.tests/src/org/eclipse/tracecompass/lttng2/control/core/tests/model/impl/BaseLoggerInfoTest.java
new file mode 100644 (file)
index 0000000..0572a65
--- /dev/null
@@ -0,0 +1,325 @@
+/**********************************************************************
+ * Copyright (c) 2016 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Bruno Roy- Initial API and implementation
+ **********************************************************************/
+package org.eclipse.tracecompass.lttng2.control.core.tests.model.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.eclipse.tracecompass.internal.lttng2.control.core.model.IBaseLoggerInfo;
+import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceDomainType;
+import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceJulLogLevel;
+import org.eclipse.tracecompass.internal.lttng2.control.core.model.impl.BaseLoggerInfo;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * The class <code>BaseLoggerInfoTest</code> contains test for the class
+ * <code>{@link BaseLoggerInfo}</code>.
+ */
+public class BaseLoggerInfoTest {
+
+    // ------------------------------------------------------------------------
+    // Test data
+    // ------------------------------------------------------------------------
+
+    private IBaseLoggerInfo fBaseLoggerInfo1 = null;
+    private IBaseLoggerInfo fBaseLoggerInfo2 = null;
+
+    // ------------------------------------------------------------------------
+    // Housekeeping
+    // ------------------------------------------------------------------------
+    /**
+     * Perform pre-test initialization.
+     */
+    @Before
+    public void setUp() {
+        ModelImplFactory factory = new ModelImplFactory();
+        fBaseLoggerInfo1 = factory.getBaseLoggerInfo1();
+        fBaseLoggerInfo2 = factory.getBaseLoggerInfo2();
+    }
+
+    // ------------------------------------------------------------------------
+    // Tests
+    // ------------------------------------------------------------------------
+
+    /**
+     * Run the BaseLoggerInfo() constructor test.
+     */
+    @Test
+    public void testBaseLoggerInfo() {
+        BaseLoggerInfo fixture = new BaseLoggerInfo("logger");
+        assertNotNull(fixture);
+
+        // Name
+        String name = fixture.getName();
+        assertEquals("logger", name);
+
+        // Domain
+        TraceDomainType domain = fixture.getDomain();
+        assertEquals("Unknown domain type", domain.getInName());
+        assertEquals("UNKNOWN", domain.name());
+        assertEquals("UNKNOWN", domain.toString());
+        assertEquals(5, domain.ordinal());
+
+        // Log level
+        TraceJulLogLevel logLevel = (TraceJulLogLevel) fixture.getLogLevel();
+        assertEquals("LEVEL_UNKNOWN", logLevel.getInName());
+        assertEquals("LEVEL_UNKNOWN", logLevel.name());
+        assertEquals("LEVEL_UNKNOWN", logLevel.toString());
+        assertEquals(9, logLevel.ordinal());
+    }
+
+    /**
+     * Test Copy Constructor
+     */
+    @Test
+    public void testBaseLoggerInfoCopy() {
+        BaseLoggerInfo fixture = new BaseLoggerInfo((BaseLoggerInfo) fBaseLoggerInfo1);
+
+        assertEquals(fBaseLoggerInfo1.getName(), fixture.getName());
+        assertEquals(fBaseLoggerInfo1.getDomain(), fBaseLoggerInfo1.getDomain());
+        assertEquals(fBaseLoggerInfo1.getLogLevel(), fixture.getLogLevel());
+    }
+
+    /**
+     * Test Copy Constructor
+     */
+    @Test
+    public void testBaseLoggerInfoCopy2() {
+        try {
+            BaseLoggerInfo info = null;
+            new BaseLoggerInfo(info);
+            fail("null copy");
+        }
+        catch (IllegalArgumentException e) {
+            // Success
+        }
+    }
+
+    /**
+     * Run the void setLogLevel(TraceJulLogLevel) method test.
+     * Run the TraceJulLogLevel getLogLevel() method test
+     */
+    @Test
+    public void testSetLogLevel1() {
+        BaseLoggerInfo fixture = new BaseLoggerInfo("logger");
+
+        // Case 1 : JUL_ALL
+        fixture.setLogLevel(TraceJulLogLevel.JUL_ALL);
+        TraceJulLogLevel result = (TraceJulLogLevel) fixture.getLogLevel();
+        assertNotNull(result);
+        assertEquals("All", result.getInName());
+        assertEquals("JUL_ALL", result.name());
+        assertEquals("JUL_ALL", result.toString());
+        assertEquals(8, result.ordinal());
+
+        // Case 2 : JUL_WARNING
+        fixture.setLogLevel(TraceJulLogLevel.JUL_WARNING);
+        result = (TraceJulLogLevel) fixture.getLogLevel();
+        assertNotNull(result);
+        assertEquals("Warning", result.getInName());
+        assertEquals("JUL_WARNING", result.name());
+        assertEquals("JUL_WARNING", result.toString());
+        assertEquals(2, result.ordinal());
+    }
+
+    /**
+     * Run the void setLogLevel(String) method test.
+     * Run the TraceJulLogLevel getLogLevel() method test
+     */
+    @Test
+    public void testSetLogLevel2() {
+        BaseLoggerInfo fixture = new BaseLoggerInfo("logger");
+
+        fixture.setLogLevel("Off");
+
+        TraceJulLogLevel result = (TraceJulLogLevel) fixture.getLogLevel();
+        assertNotNull(result);
+        assertEquals("Off", result.getInName());
+        assertEquals("JUL_OFF", result.name());
+        assertEquals(0, result.ordinal());
+
+        //------------------------
+        fixture.setLogLevel("Severe");
+
+        result = (TraceJulLogLevel) fixture.getLogLevel();
+        assertNotNull(result);
+        assertEquals("Severe", result.getInName());
+        assertEquals("JUL_SEVERE", result.name());
+        assertEquals(1, result.ordinal());
+
+        //------------------------
+        fixture.setLogLevel("Warning");
+
+        result = (TraceJulLogLevel) fixture.getLogLevel();
+        assertNotNull(result);
+        assertEquals("Warning", result.getInName());
+        assertEquals("JUL_WARNING", result.name());
+        assertEquals(2, result.ordinal());
+
+        //------------------------
+        fixture.setLogLevel("Info");
+
+        result = (TraceJulLogLevel) fixture.getLogLevel();
+        assertNotNull(result);
+        assertEquals("Info", result.getInName());
+        assertEquals("JUL_INFO", result.name());
+        assertEquals(3, result.ordinal());
+
+        //------------------------
+        fixture.setLogLevel("Config");
+
+        result = (TraceJulLogLevel) fixture.getLogLevel();
+        assertNotNull(result);
+        assertEquals("Config", result.getInName());
+        assertEquals("JUL_CONFIG", result.name());
+        assertEquals(4, result.ordinal());
+
+        //------------------------
+        fixture.setLogLevel("Fine");
+
+        result = (TraceJulLogLevel) fixture.getLogLevel();
+        assertNotNull(result);
+        assertEquals("Fine", result.getInName());
+        assertEquals("JUL_FINE", result.name());
+        assertEquals(5, result.ordinal());
+
+        //------------------------
+        fixture.setLogLevel("Finer");
+
+        result = (TraceJulLogLevel) fixture.getLogLevel();
+        assertNotNull(result);
+        assertEquals("Finer", result.getInName());
+        assertEquals("JUL_FINER", result.name());
+        assertEquals(6, result.ordinal());
+
+        //------------------------
+        fixture.setLogLevel("Finest");
+
+        result = (TraceJulLogLevel) fixture.getLogLevel();
+        assertNotNull(result);
+        assertEquals("Finest", result.getInName());
+        assertEquals("JUL_FINEST", result.name());
+        assertEquals(7, result.ordinal());
+
+        //------------------------
+        fixture.setLogLevel("All");
+
+        result = (TraceJulLogLevel) fixture.getLogLevel();
+        assertNotNull(result);
+        assertEquals("All", result.getInName());
+        assertEquals("JUL_ALL", result.name());
+        assertEquals(8, result.ordinal());
+
+        //------------------------
+        fixture.setLogLevel("LEVEL_UNKNOWN");
+
+        result = (TraceJulLogLevel) fixture.getLogLevel();
+        assertNotNull(result);
+        assertEquals("LEVEL_UNKNOWN", result.getInName());
+        assertEquals("LEVEL_UNKNOWN", result.name());
+        assertEquals(9, result.ordinal());
+    }
+
+    /**
+     * Run the String toString() method test.
+     */
+    @Test
+    public void testToString_1() {
+        BaseLoggerInfo fixture = new BaseLoggerInfo("logger");
+        fixture.setName("testName");
+        fixture.setLogLevel(TraceJulLogLevel.JUL_ALL);
+
+        fixture.setDomain(TraceDomainType.JUL);
+        String result = fixture.toString();
+        assertEquals("[BaseLoggerInfo([TraceInfo(Name=testName)],domain=JUL,level=JUL_ALL)]", result);
+
+        fixture.setDomain(TraceDomainType.LOG4J);
+        result = fixture.toString();
+        assertEquals("[BaseLoggerInfo([TraceInfo(Name=testName)],domain=LOG4J,level=JUL_ALL)]", result);
+    }
+
+    // ------------------------------------------------------------------------
+    // equals
+    // ------------------------------------------------------------------------
+
+    /**
+     * Test the .equals() method.
+     */
+    @Test
+    public void testEqualsReflexivity() {
+        assertTrue("equals", fBaseLoggerInfo1.equals(fBaseLoggerInfo1));
+        assertTrue("equals", fBaseLoggerInfo2.equals(fBaseLoggerInfo2));
+
+        assertTrue("equals", !fBaseLoggerInfo1.equals(fBaseLoggerInfo2));
+        assertTrue("equals", !fBaseLoggerInfo2.equals(fBaseLoggerInfo1));
+    }
+
+    /**
+     * Test the .equals() method.
+     */
+    @Test
+    public void testEqualsSymmetry() {
+        BaseLoggerInfo info1 = new BaseLoggerInfo((BaseLoggerInfo) fBaseLoggerInfo1);
+        BaseLoggerInfo info2 = new BaseLoggerInfo((BaseLoggerInfo) fBaseLoggerInfo2);
+
+        assertTrue("equals", info1.equals(fBaseLoggerInfo1));
+        assertTrue("equals", fBaseLoggerInfo1.equals(info1));
+
+        assertTrue("equals", info2.equals(fBaseLoggerInfo2));
+        assertTrue("equals", fBaseLoggerInfo2.equals(info2));
+    }
+
+    /**
+     * Test the .equals() method.
+     */
+    @Test
+    public void testEqualsTransivity() {
+        BaseLoggerInfo info1 = new BaseLoggerInfo((BaseLoggerInfo) fBaseLoggerInfo1);
+        BaseLoggerInfo info2 = new BaseLoggerInfo((BaseLoggerInfo) fBaseLoggerInfo1);
+        BaseLoggerInfo info3 = new BaseLoggerInfo((BaseLoggerInfo) fBaseLoggerInfo1);
+
+        assertTrue("equals", info1.equals(info2));
+        assertTrue("equals", info2.equals(info3));
+        assertTrue("equals", info1.equals(info3));
+    }
+
+    /**
+     * Test the .equals() method.
+     */
+    @Test
+    public void testEqualsNull() {
+        assertTrue("equals", !fBaseLoggerInfo1.equals(null));
+        assertTrue("equals", !fBaseLoggerInfo2.equals(null));
+    }
+
+    // ------------------------------------------------------------------------
+    // hashCode
+    // ------------------------------------------------------------------------
+
+    /**
+     * Test the hashCode() method.
+     */
+    @Test
+    public void testHashCode() {
+        BaseLoggerInfo info1 = new BaseLoggerInfo((BaseLoggerInfo) fBaseLoggerInfo1);
+        BaseLoggerInfo info2 = new BaseLoggerInfo((BaseLoggerInfo) fBaseLoggerInfo2);
+
+        assertTrue("hashCode", fBaseLoggerInfo1.hashCode() == info1.hashCode());
+        assertTrue("hashCode", fBaseLoggerInfo2.hashCode() == info2.hashCode());
+
+        assertTrue("hashCode", fBaseLoggerInfo1.hashCode() != info2.hashCode());
+        assertTrue("hashCode", fBaseLoggerInfo2.hashCode() != info1.hashCode());
+    }
+}
diff --git a/lttng/org.eclipse.tracecompass.lttng2.control.core.tests/src/org/eclipse/tracecompass/lttng2/control/core/tests/model/impl/LoggerInfoTest.java b/lttng/org.eclipse.tracecompass.lttng2.control.core.tests/src/org/eclipse/tracecompass/lttng2/control/core/tests/model/impl/LoggerInfoTest.java
new file mode 100644 (file)
index 0000000..1b10049
--- /dev/null
@@ -0,0 +1,330 @@
+/**********************************************************************
+ * Copyright (c) 2016 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Bruno Roy- Initial API and implementation
+ **********************************************************************/
+package org.eclipse.tracecompass.lttng2.control.core.tests.model.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.eclipse.tracecompass.internal.lttng2.control.core.model.ILoggerInfo;
+import org.eclipse.tracecompass.internal.lttng2.control.core.model.LogLevelType;
+import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceDomainType;
+import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceEnablement;
+import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceJulLogLevel;
+import org.eclipse.tracecompass.internal.lttng2.control.core.model.impl.LoggerInfo;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * The class <code>LoggerInfoTest</code> contains test for the class
+ * <code>{@link LoggerInfo}</code>.
+ */
+public class LoggerInfoTest {
+
+    // ------------------------------------------------------------------------
+    // Test data
+    // ------------------------------------------------------------------------
+
+    private ILoggerInfo fLoggerInfo1 = null;
+    private ILoggerInfo fLoggerInfo2 = null;
+
+    // ------------------------------------------------------------------------
+    // Housekeeping
+    // ------------------------------------------------------------------------
+
+    /**
+     * Perform pre-test initialization.
+     */
+    @Before
+    public void setUp() {
+        ModelImplFactory factory = new ModelImplFactory();
+        fLoggerInfo1 = factory.getLoggerInfo1();
+        fLoggerInfo2 = factory.getLoggerInfo2();
+    }
+
+    // ------------------------------------------------------------------------
+    // Tests
+    // ------------------------------------------------------------------------
+
+    /**
+     * Run the LoggerInfo() constructor test.
+     */
+    @Test
+    public void testLoggerInfo() {
+        LoggerInfo fixture = new LoggerInfo("logger");
+        assertNotNull(fixture);
+
+        // Name
+        String name = fixture.getName();
+        assertEquals("logger", name);
+
+        // Domain
+        TraceDomainType result = fixture.getDomain();
+        assertEquals("UNKNOWN", result.name());
+        assertEquals("UNKNOWN", result.toString());
+        assertEquals(5, result.ordinal());
+
+        // State
+        TraceEnablement state = fixture.getState();
+        assertEquals("disabled", state.getInName());
+        assertEquals("DISABLED", state.name());
+        assertEquals("DISABLED", state.toString());
+        assertEquals(0, state.ordinal());
+
+        // Log level type
+        LogLevelType logType = fixture.getLogLevelType();
+        assertEquals("", logType.getShortName());
+        assertEquals("LOGLEVEL_ALL", logType.name());
+        assertEquals("LOGLEVEL_ALL", logType.toString());
+        assertEquals(0, state.ordinal());
+
+        // Log level
+        TraceJulLogLevel logLevel = (TraceJulLogLevel) fixture.getLogLevel();
+        assertEquals("LEVEL_UNKNOWN", logLevel.getInName());
+        assertEquals("LEVEL_UNKNOWN", logLevel.name());
+        assertEquals("LEVEL_UNKNOWN", logLevel.toString());
+        assertEquals(9, logLevel.ordinal());
+    }
+
+    /**
+     * Test Copy Constructor
+     */
+    @Test
+    public void testLoggerInfoCopy() {
+        LoggerInfo info = new LoggerInfo((LoggerInfo) fLoggerInfo1);
+
+        assertEquals(fLoggerInfo1.getName(), info.getName());
+        assertEquals(fLoggerInfo1.getState(), info.getState());
+        assertEquals(fLoggerInfo1.getLogLevelType(), info.getLogLevelType());
+        assertEquals(fLoggerInfo1.getLogLevel(), info.getLogLevel());
+        assertEquals(fLoggerInfo1.getDomain(), info.getDomain());
+    }
+
+    /**
+     * Test Copy Constructor
+     */
+    @Test
+    public void testEventCopy2() {
+        try {
+            LoggerInfo info = null;
+            new LoggerInfo(info);
+            fail("null copy");
+        }
+        catch (IllegalArgumentException e) {
+            // Success
+        }
+    }
+
+    /**
+     *  Getter/Setter tests
+     */
+    @Test
+    public void testGetAndSetter() {
+        LoggerInfo fixture = new LoggerInfo("logger");
+
+        // setState(String stateName)
+        fixture.setState("disabled");
+        TraceEnablement state = fixture.getState();
+        assertEquals("disabled", state.getInName());
+        assertEquals("DISABLED", state.name());
+        assertEquals("DISABLED", state.toString());
+        assertEquals(0, state.ordinal());
+
+        fixture.setState("true");
+        state = fixture.getState();
+        assertEquals("true", state.getInMiName());
+        assertEquals("ENABLED", state.name());
+        assertEquals("ENABLED", state.toString());
+        assertEquals(1, state.ordinal());
+
+        fixture.setState("false");
+        state = fixture.getState();
+        assertEquals("false", state.getInMiName());
+        assertEquals("DISABLED", state.name());
+        assertEquals("DISABLED", state.toString());
+        assertEquals(0, state.ordinal());
+
+        fixture.setState("enabled");
+        state = fixture.getState();
+        assertEquals("enabled", state.getInName());
+        assertEquals("ENABLED", state.name());
+        assertEquals("ENABLED", state.toString());
+        assertEquals(1, state.ordinal());
+
+        fixture.setState("bla");
+        state = fixture.getState();
+        assertEquals("disabled", state.getInName());
+        assertEquals("DISABLED", state.name());
+        assertEquals("DISABLED", state.toString());
+        assertEquals(0, state.ordinal());
+
+        // setState(TraceEnablement state)
+        fixture.setState(TraceEnablement.ENABLED);
+        state = fixture.getState();
+        assertEquals("enabled", state.getInName());
+        assertEquals("ENABLED", state.name());
+        assertEquals("ENABLED", state.toString());
+        assertEquals(1, state.ordinal());
+
+        fixture.setState(TraceEnablement.DISABLED);
+        state = fixture.getState();
+        assertEquals("disabled", state.getInName());
+        assertEquals("DISABLED", state.name());
+        assertEquals("DISABLED", state.toString());
+        assertEquals(0, state.ordinal());
+
+        // setLogLevelType(String name)
+        fixture.setLogLevelType("==");
+        assertEquals("LOGLEVEL_ONLY", fixture.getLogLevelType().name());
+        assertEquals("==", fixture.getLogLevelType().getShortName());
+
+        fixture.setLogLevelType("<=");
+        assertEquals("LOGLEVEL", fixture.getLogLevelType().name());
+        assertEquals("<=", fixture.getLogLevelType().getShortName());
+
+        fixture.setLogLevelType("");
+        assertEquals("LOGLEVEL_ALL", fixture.getLogLevelType().name());
+        assertEquals("", fixture.getLogLevelType().getShortName());
+
+        fixture.setLogLevelType(LogLevelType.LOGLEVEL_ONLY);
+        assertEquals("LOGLEVEL_ONLY", fixture.getLogLevelType().name());
+        assertEquals("==", fixture.getLogLevelType().getShortName());
+
+        fixture.setLogLevelType(LogLevelType.LOGLEVEL);
+        assertEquals("LOGLEVEL", fixture.getLogLevelType().name());
+        assertEquals("<=", fixture.getLogLevelType().getShortName());
+
+        fixture.setLogLevelType(LogLevelType.LOGLEVEL_ALL);
+        assertEquals("LOGLEVEL_ALL", fixture.getLogLevelType().name());
+        assertEquals("", fixture.getLogLevelType().getShortName());
+
+        fixture.setLogLevelType(LogLevelType.LOGLEVEL_NONE);
+        assertEquals("LOGLEVEL_NONE", fixture.getLogLevelType().name());
+        assertEquals("", fixture.getLogLevelType().getShortName());
+
+        // setLogLevelType(String name)
+        fixture.setLogLevelType("SINGLE");
+        assertEquals("LOGLEVEL_ONLY", fixture.getLogLevelType().name());
+        assertEquals("SINGLE", fixture.getLogLevelType().getMiName());
+
+        fixture.setLogLevelType("RANGE");
+        assertEquals("LOGLEVEL", fixture.getLogLevelType().name());
+        assertEquals("RANGE", fixture.getLogLevelType().getMiName());
+
+        fixture.setLogLevelType("ALL");
+        assertEquals("LOGLEVEL_ALL", fixture.getLogLevelType().name());
+        assertEquals("ALL", fixture.getLogLevelType().getMiName());
+
+        fixture.setLogLevelType("UNKNOWN");
+        assertEquals("LOGLEVEL_NONE", fixture.getLogLevelType().name());
+        assertEquals("UNKNOWN", fixture.getLogLevelType().getMiName());
+
+    }
+
+    /**
+     * Run the String toString() method test.
+     */
+    @Test
+    public void testToString() {
+        LoggerInfo fixture = new LoggerInfo("logger");
+        fixture.setName("testName");
+
+        String result = fixture.toString();
+        assertEquals("[LoggerInfo([BaseLoggerInfo([TraceInfo(Name=testName)],domain=UNKNOWN,level=LEVEL_UNKNOWN)],State=DISABLED,levelType=LOGLEVEL_ALL)]", result);
+
+        fixture.setDomain(TraceDomainType.JUL);
+        result = fixture.toString();
+        assertEquals("[LoggerInfo([BaseLoggerInfo([TraceInfo(Name=testName)],domain=JUL,level=LEVEL_UNKNOWN)],State=DISABLED,levelType=LOGLEVEL_ALL)]", result);
+
+        fixture.setLogLevel(TraceJulLogLevel.JUL_FINE);
+        result = fixture.toString();
+        assertEquals("[LoggerInfo([BaseLoggerInfo([TraceInfo(Name=testName)],domain=JUL,level=JUL_FINE)],State=DISABLED,levelType=LOGLEVEL_ALL)]", result);
+
+        fixture.setState(TraceEnablement.ENABLED);
+        result = fixture.toString();
+        assertEquals("[LoggerInfo([BaseLoggerInfo([TraceInfo(Name=testName)],domain=JUL,level=JUL_FINE)],State=ENABLED,levelType=LOGLEVEL_ALL)]", result);
+    }
+
+    // ------------------------------------------------------------------------
+    // equals
+    // ------------------------------------------------------------------------
+
+    /**
+     * Run the equals() method test.
+     */
+    @Test
+    public void testEqualsReflexivity() {
+        assertTrue("equals", fLoggerInfo1.equals(fLoggerInfo1));
+        assertTrue("equals", fLoggerInfo2.equals(fLoggerInfo2));
+
+        assertTrue("equals", !fLoggerInfo1.equals(fLoggerInfo2));
+        assertTrue("equals", !fLoggerInfo2.equals(fLoggerInfo1));
+    }
+
+    /**
+     * Run the equals() method test.
+     */
+    @Test
+    public void testEqualsSymmetry() {
+        LoggerInfo info1 = new LoggerInfo((LoggerInfo)fLoggerInfo1);
+        LoggerInfo info2 = new LoggerInfo((LoggerInfo)fLoggerInfo2);
+
+        assertTrue("equals", info1.equals(fLoggerInfo1));
+        assertTrue("equals", fLoggerInfo1.equals(info1));
+
+        assertTrue("equals", info2.equals(fLoggerInfo2));
+        assertTrue("equals", fLoggerInfo2.equals(info2));
+    }
+
+    /**
+     * Run the equals() method test.
+     */
+    @Test
+    public void testEqualsTransivity() {
+        LoggerInfo info1 = new LoggerInfo((LoggerInfo)fLoggerInfo1);
+        LoggerInfo info2 = new LoggerInfo((LoggerInfo)fLoggerInfo1);
+        LoggerInfo info3 = new LoggerInfo((LoggerInfo)fLoggerInfo1);
+
+        assertTrue("equals", info1.equals(info2));
+        assertTrue("equals", info2.equals(info3));
+        assertTrue("equals", info1.equals(info3));
+    }
+
+    /**
+     * Run the equals() method test.
+     */
+    @Test
+    public void testEqualsNull() {
+        assertTrue("equals", !fLoggerInfo1.equals(null));
+        assertTrue("equals", !fLoggerInfo2.equals(null));
+    }
+
+    // ------------------------------------------------------------------------
+    // hashCode
+    // ------------------------------------------------------------------------
+
+    /**
+     * Run the hashCode() method test.
+     */
+    @Test
+    public void testHashCode() {
+        LoggerInfo info1 = new LoggerInfo((LoggerInfo)fLoggerInfo1);
+        LoggerInfo info2 = new LoggerInfo((LoggerInfo)fLoggerInfo2);
+
+        assertTrue("hashCode", fLoggerInfo1.hashCode() == info1.hashCode());
+        assertTrue("hashCode", fLoggerInfo2.hashCode() == info2.hashCode());
+
+        assertTrue("hashCode", fLoggerInfo1.hashCode() != info2.hashCode());
+        assertTrue("hashCode", fLoggerInfo2.hashCode() != info1.hashCode());
+    }
+}
index 41901cca8b6130eec91359fb78ae4f65ae4b2d10..62e4c84858847369b2821e48cdb279420a294019 100644 (file)
 package org.eclipse.tracecompass.lttng2.control.core.tests.model.impl;
 
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.IBaseEventInfo;
+import org.eclipse.tracecompass.internal.lttng2.control.core.model.IBaseLoggerInfo;
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.IChannelInfo;
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.IDomainInfo;
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.IEventInfo;
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.IFieldInfo;
+import org.eclipse.tracecompass.internal.lttng2.control.core.model.ILoggerInfo;
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.IProbeEventInfo;
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.ISessionInfo;
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.ISnapshotInfo;
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.IUstProviderInfo;
+import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceDomainType;
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceEnablement;
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceEventType;
+import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceJulLogLevel;
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceLogLevel;
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceSessionState;
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.impl.BaseEventInfo;
+import org.eclipse.tracecompass.internal.lttng2.control.core.model.impl.BaseLoggerInfo;
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.impl.ChannelInfo;
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.impl.DomainInfo;
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.impl.EventInfo;
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.impl.FieldInfo;
+import org.eclipse.tracecompass.internal.lttng2.control.core.model.impl.LoggerInfo;
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.impl.ProbeEventInfo;
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.impl.SessionInfo;
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.impl.SnapshotInfo;
@@ -50,10 +56,14 @@ public class ModelImplFactory {
     private IEventInfo fEventInfo1 = null;
     private IEventInfo fEventInfo2 = null;
     private IEventInfo fEventInfo3 = null;
+    private ILoggerInfo fLoggerInfo1 = null;
+    private ILoggerInfo fLoggerInfo2 = null;
     private IFieldInfo fFieldInfo1 = null;
     private IFieldInfo fFieldInfo2 = null;
     private IBaseEventInfo fBaseEventInfo1 = null;
     private IBaseEventInfo fBaseEventInfo2 = null;
+    private IBaseLoggerInfo fBaseLoggerInfo1 = null;
+    private IBaseLoggerInfo fBaseLoggerInfo2 = null;
     private IUstProviderInfo fUstProviderInfo1 = null;
     private IUstProviderInfo fUstProviderInfo2 = null;
     private IProbeEventInfo fProbeEventInfo1 = null;
@@ -77,7 +87,15 @@ public class ModelImplFactory {
 
         fBaseEventInfo2 = new BaseEventInfo("event2");
         fBaseEventInfo2.setEventType(TraceEventType.TRACEPOINT);
-        fBaseEventInfo1.setLogLevel(TraceLogLevel.TRACE_DEBUG);
+        fBaseEventInfo2.setLogLevel(TraceLogLevel.TRACE_DEBUG);
+
+        fBaseLoggerInfo1 = new BaseLoggerInfo("logger1");
+        fBaseLoggerInfo1.setDomain(TraceDomainType.JUL);
+        fBaseLoggerInfo1.setLogLevel(TraceJulLogLevel.JUL_FINE);
+
+        fBaseLoggerInfo2 = new BaseLoggerInfo("logger2");
+        fBaseLoggerInfo2.setDomain(TraceDomainType.LOG4J);
+        fBaseLoggerInfo1.setLogLevel(TraceJulLogLevel.JUL_FINER);
 
         fEventInfo1 = new EventInfo("event1");
         fEventInfo1.setEventType(TraceEventType.TRACEPOINT);
@@ -95,14 +113,27 @@ public class ModelImplFactory {
         fEventInfo3.setEventType(TraceEventType.TRACEPOINT);
         fEventInfo3.setState(TraceEnablement.DISABLED);
 
+        fLoggerInfo1 = new LoggerInfo("logger1");
+        fLoggerInfo1.setDomain(TraceDomainType.JUL);
+        fLoggerInfo1.setLogLevel(TraceJulLogLevel.JUL_CONFIG);
+        fLoggerInfo1.setState("false");
+
+        fLoggerInfo2 = new LoggerInfo("logger2");
+        fLoggerInfo2.setDomain(TraceDomainType.LOG4J);
+        fLoggerInfo1.setLogLevel(TraceJulLogLevel.JUL_INFO);
+        fLoggerInfo1.setState("true");
+
         fUstProviderInfo1 = new UstProviderInfo("myUST1");
         fUstProviderInfo1.setPid(1234);
         fUstProviderInfo1.addEvent(fBaseEventInfo1);
+        fUstProviderInfo1.addLogger(fLoggerInfo1);
 
         fUstProviderInfo2 = new UstProviderInfo("myUST2");
         fUstProviderInfo2.setPid(2345);
         fUstProviderInfo2.addEvent(fBaseEventInfo1);
         fUstProviderInfo2.addEvent(fBaseEventInfo2);
+        fUstProviderInfo2.addLogger(fLoggerInfo1);
+        fUstProviderInfo2.addLogger(fLoggerInfo2);
 
         fChannelInfo1 = new ChannelInfo("channel1");
         fChannelInfo1.setSwitchTimer(10L);
@@ -214,6 +245,22 @@ public class ModelImplFactory {
         return fBaseEventInfo2;
     }
 
+    public ILoggerInfo getLoggerInfo1() {
+        return fLoggerInfo1;
+    }
+
+    public ILoggerInfo getLoggerInfo2() {
+        return fLoggerInfo2;
+    }
+
+    public IBaseLoggerInfo getBaseLoggerInfo1() {
+        return fBaseLoggerInfo1;
+    }
+
+    public IBaseLoggerInfo getBaseLoggerInfo2() {
+        return fBaseLoggerInfo2;
+    }
+
     public IUstProviderInfo getUstProviderInfo1() {
         return fUstProviderInfo1;
     }
index 7e5e7dab2d12bbcc3cd61312ec2e2a9b6f76909f..c9c8fe00cbda2eeeb98876e8e38ca74aa1928b96 100644 (file)
@@ -22,8 +22,10 @@ import java.util.LinkedList;
 import java.util.List;
 
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.IBaseEventInfo;
+import org.eclipse.tracecompass.internal.lttng2.control.core.model.ILoggerInfo;
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.IUstProviderInfo;
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.impl.BaseEventInfo;
+import org.eclipse.tracecompass.internal.lttng2.control.core.model.impl.LoggerInfo;
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.impl.UstProviderInfo;
 import org.junit.Before;
 import org.junit.Test;
@@ -44,6 +46,9 @@ public class UstProviderInfoTest {
     private IBaseEventInfo fEventInfo1 = null;
     private IBaseEventInfo fEventInfo2 = null;
 
+    private ILoggerInfo fLoggerInfo1 = null;
+    private ILoggerInfo fLoggerInfo2 = null;
+
     // ------------------------------------------------------------------------
     // Housekeeping
     // ------------------------------------------------------------------------
@@ -58,6 +63,8 @@ public class UstProviderInfoTest {
         fUstProviderInfo2 = factory.getUstProviderInfo2();
         fEventInfo1 = factory.getBaseEventInfo1();
         fEventInfo2 = factory.getBaseEventInfo2();
+        fLoggerInfo1 = factory.getLoggerInfo1();
+        fLoggerInfo2 = factory.getLoggerInfo2();
     }
 
     // ------------------------------------------------------------------------
@@ -79,6 +86,7 @@ public class UstProviderInfoTest {
         assertEquals("test", result.getName());
         assertEquals(0, result.getPid());
         assertEquals(0, result.getEvents().length);
+        assertEquals(0, result.getLoggers().size());
     }
 
     /**
@@ -91,12 +99,19 @@ public class UstProviderInfoTest {
         assertEquals(fUstProviderInfo1.getName(), providerInf.getName());
         assertEquals(fUstProviderInfo1.getPid(), providerInf.getPid());
         assertEquals(fUstProviderInfo1.getEvents().length, providerInf.getEvents().length);
+        assertEquals(fUstProviderInfo1.getLoggers().size(), providerInf.getLoggers().size());
 
         IBaseEventInfo[] orignalEvents = fUstProviderInfo1.getEvents();
         IBaseEventInfo[] resultEvents = providerInf.getEvents();
         for (int i = 0; i < orignalEvents.length; i++) {
             assertEquals(orignalEvents[i], resultEvents[i]);
         }
+
+        List<ILoggerInfo> originalLoggers = fUstProviderInfo1.getLoggers();
+        List<ILoggerInfo> resultLoggers = providerInf.getLoggers();
+        for (int i = 0; i < originalLoggers.size(); i++) {
+            assertEquals(originalLoggers.get(i), resultLoggers.get(i));
+        }
     }
 
     /**
@@ -120,21 +135,31 @@ public class UstProviderInfoTest {
     @Test
     public void testGetAndSetters() {
         IUstProviderInfo fixture = new UstProviderInfo("test");
+
         fixture.setPid(2468);
+        assertEquals(2468, fixture.getPid());
 
         // add an event
         IBaseEventInfo event = new BaseEventInfo("event");
         fixture.addEvent(event);
 
-        // Verify the stored events
-        IBaseEventInfo[] result = fixture.getEvents();
-
-        assertNotNull(result);
-        assertEquals(1, result.length);
-        assertNotNull(result[0]);
-        assertTrue(event.equals(result[0]));
-
-        assertEquals(2468, fixture.getPid());
+        // verify the stored events
+        IBaseEventInfo[] events = fixture.getEvents();
+        assertNotNull(events);
+        assertEquals(1, events.length);
+        assertNotNull(events[0]);
+        assertTrue(event.equals(events[0]));
+
+        // add a logger
+        ILoggerInfo logger = new LoggerInfo("logger");
+        fixture.addLogger(logger);
+
+        // verify the stored loggers
+        List<ILoggerInfo> loggers = fixture.getLoggers();
+        assertNotNull(loggers);
+        assertEquals(1, loggers.size());
+        assertNotNull(loggers.get(0));
+        assertTrue(logger.equals(loggers.get(0)));
     }
 
     /**
@@ -143,7 +168,6 @@ public class UstProviderInfoTest {
     @Test
     public void testSetEvents_1() {
         UstProviderInfo fixture = new UstProviderInfo("test");
-        fixture.setPid(2468);
         List<IBaseEventInfo> events = new LinkedList<>();
         events.add(fEventInfo1);
         events.add(fEventInfo2);
@@ -158,6 +182,26 @@ public class UstProviderInfoTest {
         }
     }
 
+    /**
+     * Run the void setLoggers(List<ILoggerInfo>) method test.
+     */
+    @Test
+    public void testSetLoggers_1() {
+        UstProviderInfo fixture = new UstProviderInfo("test");
+        List<ILoggerInfo> originalLoggers = new LinkedList<>();
+        originalLoggers.add(fLoggerInfo1);
+        originalLoggers.add(fLoggerInfo2);
+        fixture.setLoggers(originalLoggers);
+
+        List<ILoggerInfo> resultLoggers = fixture.getLoggers();
+
+        assertEquals(originalLoggers.size(), resultLoggers.size());
+
+        for (int i = 0; i < resultLoggers.size(); i++) {
+            assertEquals(originalLoggers.get(i), resultLoggers.get(i));
+        }
+    }
+
     /**
      * Run the String toString() method test.
      */
@@ -177,9 +221,11 @@ public class UstProviderInfoTest {
         String result = fUstProviderInfo2.toString();
 
         assertEquals("[UstProviderInfo([TraceInfo(Name=myUST2)],PID=2345,Events=[BaseEventInfo([TraceInfo(Name=event1)],"
-                + "type=UNKNOWN,level=TRACE_DEBUG,Fields=[FieldInfo([TraceInfo(Name=intfield)],"
-                + "type=int[FieldInfo([TraceInfo(Name=stringfield)],type=string,Filter=intField==10)][BaseEventInfo([TraceInfo(Name=event2)],"
-                + "type=TRACEPOINT,level=TRACE_DEBUG)],Loggers=None)]", result);
+                + "type=UNKNOWN,level=TRACE_ERR,Fields=[FieldInfo([TraceInfo(Name=intfield)],type=int[FieldInfo([TraceInfo(Name=stringfield)],"
+                + "type=string,Filter=intField==10)][BaseEventInfo([TraceInfo(Name=event2)],type=TRACEPOINT,level=TRACE_DEBUG)]"
+                + ",Loggers=[LoggerInfo([BaseLoggerInfo([TraceInfo(Name=logger1)],domain=JUL,level=JUL_INFO)],"
+                + "State=ENABLED,levelType=LOGLEVEL_ALL)][LoggerInfo([BaseLoggerInfo([TraceInfo(Name=logger2)],"
+                + "domain=LOG4J,level=LEVEL_UNKNOWN)],State=DISABLED,levelType=LOGLEVEL_ALL)])]", result);
     }
 
     // ------------------------------------------------------------------------
index 394e8c6c596ef294686fa42abde999a3dfbe30bc..d0a1ea3d71735aa8d1eef69c8b07484950528ed8 100644 (file)
@@ -90,7 +90,7 @@ public enum TraceJulLogLevel implements ITraceLogLevel{
             throw new IllegalArgumentException();
         }
         for (TraceJulLogLevel tllevel : TraceJulLogLevel.values()) {
-            if (tllevel.name().equals(name)) {
+            if (tllevel.name().equals(name) || tllevel.getInName().equals(name)) {
                 return tllevel;
             }
         }
index da456ae6dc8bf2cf78c682d593a801001b267ff1..1cfdd80d6f9a1d168c720a46e954a165e212ccc0 100644 (file)
@@ -116,7 +116,7 @@ public class BaseLoggerInfo extends TraceInfo implements IBaseLoggerInfo {
         StringBuffer output = new StringBuffer();
         output.append("[BaseLoggerInfo(");
         output.append(super.toString());
-        output.append(",domain");
+        output.append(",domain=");
         output.append(fDomain);
         output.append(",level=");
         output.append(fLogLevel);
index 3e6b2cb0f2cab51b9311d59d03258e360b1da1ac..b31f109dbf0987952a9f852545f5a8733120a1b9 100644 (file)
@@ -16,7 +16,6 @@ import java.util.Iterator;
 import java.util.List;
 
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.IBaseEventInfo;
-import org.eclipse.tracecompass.internal.lttng2.control.core.model.IBaseLoggerInfo;
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.ILoggerInfo;
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.IUstProviderInfo;
 
@@ -76,6 +75,14 @@ public class UstProviderInfo extends TraceInfo implements IUstProviderInfo {
                 fEvents.add(event);
             }
         }
+        for (Iterator<ILoggerInfo> iterator = other.fLoggers.iterator(); iterator.hasNext();) {
+            ILoggerInfo logger = iterator.next();
+            if (logger instanceof LoggerInfo) {
+                fLoggers.add(new LoggerInfo((LoggerInfo)logger));
+            } else {
+                fLoggers.add(logger);
+            }
+        }
     }
 
     // ------------------------------------------------------------------------
@@ -188,7 +195,7 @@ public class UstProviderInfo extends TraceInfo implements IUstProviderInfo {
             if (fLoggers.isEmpty()) {
                 output.append("None");
             } else {
-                for (IBaseLoggerInfo logger : fLoggers) {
+                for (ILoggerInfo logger : fLoggers) {
                     output.append(logger.toString());
                 }
             }
diff --git a/lttng/org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/control/ui/swtbot/tests/ControlViewJulLoggerTest.java b/lttng/org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/control/ui/swtbot/tests/ControlViewJulLoggerTest.java
new file mode 100644 (file)
index 0000000..c9d7e26
--- /dev/null
@@ -0,0 +1,266 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests;
+
+import static org.junit.Assert.assertEquals;
+
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceSessionState;
+import org.eclipse.tracecompass.internal.lttng2.control.ui.views.ControlView;
+import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.ConditionHelpers;
+import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils;
+import org.junit.Test;
+
+/**
+ * Test for the Control view in Trace Compass. This will test the JUL loggers.
+ *
+ * @author Bruno Roy
+ */
+public class ControlViewJulLoggerTest extends ControlViewTest {
+
+    // ------------------------------------------------------------------------
+    // Constants
+    // ------------------------------------------------------------------------
+    private static final String TEST_STREAM = "CreateSessionTestLTTng2_8.cfg";
+    private static final String CREATE_SESSION_JUL_SCENARIO_NAME = "JulLogger";
+
+    private static final String SESSION_NAME = "mysession";
+    private static final String PROPERTIES_VIEW = "Properties";
+    private static final String LOGLEVEL_PROPERTY_NAME = "Log Level";
+
+    @Override
+    protected String getTestStream() {
+        return TEST_STREAM;
+    }
+
+    @Override
+    protected String getSessionName() {
+        return SESSION_NAME;
+    }
+
+    /**
+     * Testing the trace session tree.
+     */
+    @Override
+    @Test
+    public void testTraceSessionTree() {
+
+        fProxy.setTestFile(fTestFile);
+        fProxy.setScenario(INIT_SCENARIO_NAME);
+        testConnectToNode();
+
+        // Enable all JUL loggers
+        fProxy.setScenario(CREATE_SESSION_JUL_SCENARIO_NAME);
+        testCreateSession();
+        testEnableJulLoggers();
+        testStartStopTracing(TraceSessionState.ACTIVE);
+        testStartStopTracing(TraceSessionState.INACTIVE);
+
+        // Verify that the Properties view shows to right logger log level
+        testLoggerProperties();
+
+        // Clean session
+        testDestroySession();
+        testDisconnectFromNode();
+    }
+
+    /**
+     * Enable JUL loggers with different log level and log level type
+     */
+    protected void testEnableJulLoggers() {
+        // Case 1: Enabling all loggers
+        // Getting the 'Sessions' tree
+        SWTBotTreeItem sessionItem = SWTBotUtils.getTreeItem(fBot, fTree,
+                getNodeName(),
+                ControlViewSwtBotUtil.SESSION_GROUP_NAME,
+                getSessionName());
+        sessionItem.select();
+
+        // Clicking on the 'Enable Event (default channel)...'
+        SWTBotMenu menuBot = sessionItem.contextMenu(ControlViewSwtBotUtil.ENABLE_EVENT_DEFAULT_CHANNEL_MENU_ITEM);
+        menuBot.click();
+
+        SWTBotShell shell = fBot.shell(ControlViewSwtBotUtil.ENABLE_EVENT_DIALOG_TITLE).activate();
+
+        // Switching to the JUL domain
+        shell.bot().radioInGroup(ControlViewSwtBotUtil.JUL_DOMAIN_NAME, ControlViewSwtBotUtil.DOMAIN_GROUP_NAME).click();
+
+        // Selecting all JUL loggers
+        SWTBotTree loggersTree = shell.bot().treeInGroup(ControlViewSwtBotUtil.LOGGERS_GROUP_NAME);
+        SWTBotTreeItem treeItem = loggersTree.getTreeItem(ControlViewSwtBotUtil.ALL_TREE_NODE);
+        treeItem.check();
+
+        // Click the Ok at the bottom of the dialog window
+        shell.bot().button(ControlViewSwtBotUtil.DIALOG_OK_BUTTON).click();
+        SWTBotUtils.waitForJobs();
+        fBot.waitUntil(ConditionHelpers.IsTreeChildNodeAvailable(ControlViewSwtBotUtil.JUL_DOMAIN_NAME, sessionItem));
+
+        // Assert that the domain is JUL
+        SWTBotTreeItem julDomainItem = SWTBotUtils.getTreeItem(fBot, fTree,
+                getNodeName(),
+                ControlViewSwtBotUtil.SESSION_GROUP_NAME,
+                getSessionName(),
+                ControlViewSwtBotUtil.JUL_DOMAIN_NAME);
+        assertEquals(ControlViewSwtBotUtil.JUL_DOMAIN_NAME, julDomainItem.getText());
+
+        // Assert that the logger type in the domain node are correct (all events = *)
+        SWTBotTreeItem loggerItem = SWTBotUtils.getTreeItem(fBot, fTree,
+                getNodeName(),
+                ControlViewSwtBotUtil.SESSION_GROUP_NAME,
+                getSessionName(),
+                ControlViewSwtBotUtil.JUL_DOMAIN_NAME,
+                ControlViewSwtBotUtil.ALL_EVENTS_NAME);
+        assertEquals(ControlViewSwtBotUtil.ALL_EVENTS_NAME, loggerItem.getText());
+
+        // Case 2: Enabling a specific logger with no particular log level
+        sessionItem.select();
+        menuBot = sessionItem.contextMenu(ControlViewSwtBotUtil.ENABLE_EVENT_DEFAULT_CHANNEL_MENU_ITEM);
+        menuBot.click();
+        shell = fBot.shell(ControlViewSwtBotUtil.ENABLE_EVENT_DIALOG_TITLE).activate();
+        shell.bot().radioInGroup(ControlViewSwtBotUtil.JUL_DOMAIN_NAME, ControlViewSwtBotUtil.DOMAIN_GROUP_NAME).click();
+        loggersTree = shell.bot().treeInGroup(ControlViewSwtBotUtil.LOGGERS_GROUP_NAME);
+        // Expand the "All" and "All - application name" node
+        SWTBotTreeItem allItem = loggersTree.getTreeItem(ControlViewSwtBotUtil.ALL_TREE_NODE);
+        allItem.expand();
+        allItem = SWTBotUtils.getTreeItem(fBot, loggersTree, ControlViewSwtBotUtil.ALL_TREE_NODE, ControlViewSwtBotUtil.JUL_APPLICATION_NAME);
+        allItem.expand();
+        treeItem = SWTBotUtils.getTreeItem(fBot, loggersTree,
+                ControlViewSwtBotUtil.ALL_TREE_NODE,
+                ControlViewSwtBotUtil.JUL_APPLICATION_NAME,
+                ControlViewSwtBotUtil.LOGGER_NAME);
+        treeItem.check();
+
+        // Click the Ok at the bottom of the dialog window
+        shell.bot().button(ControlViewSwtBotUtil.DIALOG_OK_BUTTON).click();
+        SWTBotUtils.waitForJobs();
+        fBot.waitUntil(ConditionHelpers.IsTreeChildNodeAvailable(ControlViewSwtBotUtil.JUL_DOMAIN_NAME, sessionItem));
+
+        // Assert that the domain is JUL global
+        julDomainItem = SWTBotUtils.getTreeItem(fBot, fTree,
+                getNodeName(),
+                ControlViewSwtBotUtil.SESSION_GROUP_NAME,
+                getSessionName(),
+                ControlViewSwtBotUtil.JUL_DOMAIN_NAME);
+        assertEquals(ControlViewSwtBotUtil.JUL_DOMAIN_NAME, julDomainItem.getText());
+
+        // Assert that the logger type in the domain node are correct (all events = *)
+        loggerItem = SWTBotUtils.getTreeItem(fBot, fTree,
+                getNodeName(),
+                ControlViewSwtBotUtil.SESSION_GROUP_NAME,
+                getSessionName(),
+                ControlViewSwtBotUtil.JUL_DOMAIN_NAME,
+                ControlViewSwtBotUtil.LOGGER_NAME);
+        assertEquals(ControlViewSwtBotUtil.LOGGER_NAME, loggerItem.getText());
+
+        // Case 3: Enabling a specific logger with WARNING log level
+        sessionItem.select();
+        menuBot = sessionItem.contextMenu(ControlViewSwtBotUtil.ENABLE_EVENT_DEFAULT_CHANNEL_MENU_ITEM);
+        menuBot.click();
+        shell = fBot.shell(ControlViewSwtBotUtil.ENABLE_EVENT_DIALOG_TITLE).activate();
+        shell.bot().radioInGroup(ControlViewSwtBotUtil.JUL_DOMAIN_NAME, ControlViewSwtBotUtil.DOMAIN_GROUP_NAME).click();
+        loggersTree = shell.bot().treeInGroup(ControlViewSwtBotUtil.LOGGERS_GROUP_NAME);
+        // Expand the "All" and "All - application name" node
+        allItem = loggersTree.getTreeItem(ControlViewSwtBotUtil.ALL_TREE_NODE);
+        allItem.expand();
+        allItem = SWTBotUtils.getTreeItem(fBot, loggersTree, ControlViewSwtBotUtil.ALL_TREE_NODE, "All - ./client_bin/challenger [PID=14237] (With logger)");
+        allItem.expand();
+        treeItem = SWTBotUtils.getTreeItem(fBot, loggersTree, ControlViewSwtBotUtil.ALL_TREE_NODE, "All - ./client_bin/challenger [PID=14237] (With logger)", ControlViewSwtBotUtil.ANOTHER_LOGGER_NAME);
+        treeItem.check();
+        // Select a log level
+        shell.bot().checkBoxInGroup(LOGLEVEL_PROPERTY_NAME).select();
+        shell.bot().ccomboBoxInGroup(LOGLEVEL_PROPERTY_NAME).setSelection("Warning");
+        // Click the Ok at the bottom of the dialog window
+        shell.bot().button(ControlViewSwtBotUtil.DIALOG_OK_BUTTON).click();
+        SWTBotUtils.waitForJobs();
+        fBot.waitUntil(ConditionHelpers.IsTreeChildNodeAvailable(ControlViewSwtBotUtil.JUL_DOMAIN_NAME, sessionItem));
+
+        // Assert that the domain is JUL global
+        julDomainItem = SWTBotUtils.getTreeItem(fBot, fTree,
+                getNodeName(),
+                ControlViewSwtBotUtil.SESSION_GROUP_NAME,
+                getSessionName(),
+                ControlViewSwtBotUtil.JUL_DOMAIN_NAME);
+        assertEquals(ControlViewSwtBotUtil.JUL_DOMAIN_NAME, julDomainItem.getText());
+
+        // Assert that the logger type in the domain node are correct (all events = *)
+        loggerItem = SWTBotUtils.getTreeItem(fBot, fTree,
+                getNodeName(),
+                ControlViewSwtBotUtil.SESSION_GROUP_NAME,
+                getSessionName(),
+                ControlViewSwtBotUtil.JUL_DOMAIN_NAME,
+                ControlViewSwtBotUtil.ANOTHER_LOGGER_NAME);
+        assertEquals(ControlViewSwtBotUtil.ANOTHER_LOGGER_NAME, loggerItem.getText());
+    }
+
+    /**
+     * Test that the Properties view has been update and shows the the right
+     * information.
+     */
+    protected void testLoggerProperties() {
+        // Open the properties view (by id)
+        SWTBotUtils.openView("org.eclipse.ui.views.PropertySheet");
+
+        // Case 1: Select the "logger" logger in the Control view
+        fBot.viewById(ControlView.ID).show();
+        SWTBotTreeItem loggerItem = SWTBotUtils.getTreeItem(fBot, fTree,
+                getNodeName(),
+                ControlViewSwtBotUtil.SESSION_GROUP_NAME,
+                getSessionName(),
+                ControlViewSwtBotUtil.JUL_DOMAIN_NAME,
+                ControlViewSwtBotUtil.LOGGER_NAME);
+        loggerItem.select();
+
+        // Get a bot and open the Properties view
+        SWTBotView propertiesViewBot = fBot.viewByTitle(PROPERTIES_VIEW);
+        propertiesViewBot.show();
+
+        // Get the Log Level field in the tree
+        SWTBotTree propertiesViewTree = propertiesViewBot.bot().tree();
+        SWTBotTreeItem loglevelTreeItem = propertiesViewTree.getTreeItem(LOGLEVEL_PROPERTY_NAME);
+        // We want the VALUE of the 'Log Level' row so the cell index is 1
+        String loglevelExpression = loglevelTreeItem.cell(1);
+
+        // Assert that the expression in the Properties view is the same as
+        // the one we entered
+        assertEquals("All", loglevelExpression);
+
+        // Case 2: Select the "anotherLogger" logger in the Control view
+        fBot.viewById(ControlView.ID).show();
+        loggerItem = SWTBotUtils.getTreeItem(fBot, fTree,
+                getNodeName(),
+                ControlViewSwtBotUtil.SESSION_GROUP_NAME,
+                getSessionName(),
+                ControlViewSwtBotUtil.JUL_DOMAIN_NAME,
+                ControlViewSwtBotUtil.ANOTHER_LOGGER_NAME);
+        loggerItem.select();
+
+        // Get a bot and open the Properties view
+        propertiesViewBot = fBot.viewByTitle(PROPERTIES_VIEW);
+        propertiesViewBot.show();
+
+        // Get the Log Level field in the tree
+        propertiesViewTree = propertiesViewBot.bot().tree();
+        loglevelTreeItem = propertiesViewTree.getTreeItem(LOGLEVEL_PROPERTY_NAME);
+        // We want the VALUE of the 'Log Level' row so the cell index is 1
+        loglevelExpression = loglevelTreeItem.cell(1);
+
+        // Assert that the expression in the Properties view is the same as
+        // the one we entered
+        assertEquals("<= Warning", loglevelExpression);
+
+        // Close the Properties view
+        SWTBotUtils.closeView(PROPERTIES_VIEW, fBot);
+    }
+
+}
index cc7ee114ad89214b5e627eb9a07196187cc18a3e..a0e2f509d3bb0ac2f8c312eaa6ba9b4b3bfb1b9b 100644 (file)
@@ -30,6 +30,7 @@ class ControlViewSwtBotUtil {
     public static final String DEFAULT_CHANNEL_NAME = "channel0";
     public static final String KERNEL_DOMAIN_NAME = "Kernel";
     public static final String UST_DOMAIN_NAME = "UST global";
+    public static final String JUL_DOMAIN_NAME = "JUL";
     public static final String SESSION_GROUP_NAME = "Sessions";
     public static final String PROVIDER_GROUP_NAME = "Provider";
     public static final String ALL_EVENTS_NAME = "*";
@@ -38,6 +39,8 @@ class ControlViewSwtBotUtil {
     public static final String SCHED_PROCESSWAIT_EVENT_NAME = "sched_process_wait";
     public static final String SCHED_PROCESSFORK_EVENT_NAME = "sched_process_fork";
     public static final String SCHED_PROCESSEXEC_EVENT_NAME = "sched_process_exec";
+    public static final String LOGGER_NAME = "logger";
+    public static final String ANOTHER_LOGGER_NAME = "anotherLogger";
     public static final String PROFILE_SUFFIX = ".lttng";
     public static final String KERNEL_TRACE_NAME = "kernel";
 
@@ -69,10 +72,12 @@ class ControlViewSwtBotUtil {
     public static final String SYSCALL_WRITE_EVENT = "write";
     public static final String SYSCALL_READ_EVENT = "read";
     public static final String SYSCALL_CLOSE_EVENT = "close";
+    public static final String LOGGERS_GROUP_NAME = "Loggers";
     public static final String GROUP_SELECT_NAME = "Select";
     public static final String ENABLE_CHANNEL_DIALOG_TITLE = "Enable Channel";
     public static final String DOMAIN_GROUP_NAME = "Domain";
     public static final String UST_GROUP_NAME = "UST";
+    public static final String JUL_APPLICATION_NAME = "All - ./client_bin/challenger [PID=14237] (With logger)";
     public static final String BUFFERTYPE_GROUP_NAME = "Buffer Type";
     public static final String BUFFERTYPE_PER_UID = "Per UID buffers";
     public static final String FILTER_EXPRESSION_LABEL = "Filter Expression";
index 61dd7039937b15bf08ae1d397aa4e4cc4e47d7b3..d911e1a6066738c4794a492003490bb6b0105778 100644 (file)
@@ -48,7 +48,8 @@ lttng --mi xml list -j
 </COMMAND_RESULT>
 <COMMAND_OUTPUT>
 <?xml version="1.0" encoding="UTF-8"?>
-<command xmlns="http://lttng.org/xml/ns/lttng-mi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://lttng.org/xml/ns/lttng-mi http://lttng.org/xml/schemas/lttng-mi/3/lttng-mi-3.0.xsd" schemaVersion="3.0"><name>list</name><output><domains><domain><type>JUL</type><buffer_type>PER_PID</buffer_type><pids><pid><id>18275</id><name>java</name><events><event><name>anotherLogger</name><type>TRACEPOINT</type><enabled>true</enabled><loglevel>UNKNOWN</loglevel><loglevel_type>ALL</loglevel_type></event><event><name>logger</name><type>TRACEPOINT</type><enabled>true</enabled><loglevel>UNKNOWN</loglevel><loglevel_type>ALL</loglevel_type></event><event><name>global</name><type>TRACEPOINT</type><enabled>true</enabled><loglevel>UNKNOWN</loglevel><loglevel_type>ALL</loglevel_type></event></events></pid></pids></domain></domains></output></command>
+# When listing a logger type, you have to manually change its pid for the same as the UST process listing (loggers goes under the UST provider)
+<command xmlns="http://lttng.org/xml/ns/lttng-mi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://lttng.org/xml/ns/lttng-mi http://lttng.org/xml/schemas/lttng-mi/3/lttng-mi-3.0.xsd" schemaVersion="3.0"><name>list</name><output><domains><domain><type>JUL</type><buffer_type>PER_PID</buffer_type><pids><pid><id>14237</id><name>java</name><events><event><name>anotherLogger</name><type>TRACEPOINT</type><enabled>true</enabled><loglevel>UNKNOWN</loglevel><loglevel_type>ALL</loglevel_type><exclusions/></event><event><name>logger</name><type>TRACEPOINT</type><enabled>true</enabled><loglevel>UNKNOWN</loglevel><loglevel_type>ALL</loglevel_type><exclusions/></event></events></pid></pids></domain></domains></output></command>
 </COMMAND_OUTPUT>
 <COMMAND_INPUT>
 lttng --mi xml list -l
@@ -694,3 +695,119 @@ lttng --mi xml destroy mysession
 <command xmlns="http://lttng.org/xml/ns/lttng-mi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://lttng.org/xml/ns/lttng-mi http://lttng.org/xml/schemas/lttng-mi/3/lttng-mi-3.0.xsd" schemaVersion="3.0"><name>destroy</name><output><sessions><session><name>mysession</name><path>${workspace}/lttng-traces/mysession-20160105-151744</path><enabled>false</enabled><snapshot_mode>0</snapshot_mode><live_timer_interval>0</live_timer_interval></session></sessions></output><success>true</success></command>
 </COMMAND_OUTPUT>
 </SCENARIO>
+###############################################################################
+# Enable JUL loggers
+###############################################################################
+<SCENARIO>
+JulLogger
+<COMMAND_INPUT>
+lttng --mi xml create mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+<?xml version="1.0" encoding="UTF-8"?>
+<command xmlns="http://lttng.org/xml/ns/lttng-mi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://lttng.org/xml/ns/lttng-mi http://lttng.org/xml/schemas/lttng-mi/3/lttng-mi-3.0.xsd" schemaVersion="3.0"><name>create</name><output><session><name>mysession</name><path>${workspace}/lttng-traces/mysession-20160105-151744</path><enabled>false</enabled><snapshot_mode>0</snapshot_mode><live_timer_interval>0</live_timer_interval></session></output><success>true</success></command>
+</COMMAND_OUTPUT>
+<COMMAND_INPUT>
+lttng --mi xml list mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+<?xml version="1.0" encoding="UTF-8"?>
+<command xmlns="http://lttng.org/xml/ns/lttng-mi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://lttng.org/xml/ns/lttng-mi http://lttng.org/xml/schemas/lttng-mi/3/lttng-mi-3.0.xsd" schemaVersion="3.0"><name>list</name><output><sessions><session><name>mysession</name><path>${workspace}/lttng-traces/mysession-20160105-151744</path><enabled>false</enabled><snapshot_mode>0</snapshot_mode><live_timer_interval>0</live_timer_interval><domains/></session></sessions></output></command>
+</COMMAND_OUTPUT>
+<COMMAND_INPUT>
+lttng --mi xml enable-event -a -j -s mysession --tracepoint
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+<?xml version="1.0" encoding="UTF-8"?>
+<command xmlns="http://lttng.org/xml/ns/lttng-mi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://lttng.org/xml/ns/lttng-mi http://lttng.org/xml/schemas/lttng-mi/3/lttng-mi-3.0.xsd" schemaVersion="3.0"><name>enable-event</name><output><events><event><name>*</name><type>TRACEPOINT</type><enabled>true</enabled><loglevel>JUL_ALL</loglevel><loglevel_type>ALL</loglevel_type><exclusions/><success>true</success></event></events></output><success>true</success></command>
+</COMMAND_OUTPUT>
+<COMMAND_INPUT>
+lttng --mi xml list mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+<?xml version="1.0" encoding="UTF-8"?>
+<command xmlns="http://lttng.org/xml/ns/lttng-mi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://lttng.org/xml/ns/lttng-mi http://lttng.org/xml/schemas/lttng-mi/3/lttng-mi-3.0.xsd" schemaVersion="3.0"><name>list</name><output><sessions><session><name>mysession</name><path>${workspace}/lttng-traces/mysession-20160729-170007</path><enabled>false</enabled><snapshot_mode>0</snapshot_mode><live_timer_interval>0</live_timer_interval><domains><domain><type>UST</type><buffer_type>PER_UID</buffer_type><trackers/><channels><channel><name>lttng_jul_channel</name><enabled>true</enabled><attributes><overwrite_mode>DISCARD</overwrite_mode><subbuffer_size>131072</subbuffer_size><subbuffer_count>4</subbuffer_count><switch_timer_interval>0</switch_timer_interval><read_timer_interval>0</read_timer_interval><output_type>MMAP</output_type><tracefile_size>0</tracefile_size><tracefile_count>0</tracefile_count><live_timer_interval>0</live_timer_interval><discarded_events>0</discarded_events><lost_packets>0</lost_packets></attributes><events/></channel></channels></domain><domain><type>JUL</type><buffer_type>PER_UID</buffer_type><events><event><name>*</name><type>TRACEPOINT</type><enabled>true</enabled><loglevel>JUL_ALL</loglevel><loglevel_type>ALL</loglevel_type><exclusions/></event></events></domain></domains></session></sessions></output></command>
+</COMMAND_OUTPUT>
+<COMMAND_INPUT>
+lttng --mi xml enable-event logger -j -s mysession --tracepoint
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+<?xml version="1.0" encoding="UTF-8"?>
+<command xmlns="http://lttng.org/xml/ns/lttng-mi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://lttng.org/xml/ns/lttng-mi http://lttng.org/xml/schemas/lttng-mi/3/lttng-mi-3.0.xsd" schemaVersion="3.0"><name>enable-event</name><output><events><event><name>logger</name><type>TRACEPOINT</type><enabled>true</enabled><loglevel>JUL_ALL</loglevel><loglevel_type>ALL</loglevel_type><exclusions/><success>true</success></event></events></output><success>true</success></command>
+</COMMAND_OUTPUT>
+<COMMAND_INPUT>
+lttng --mi xml list mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+<?xml version="1.0" encoding="UTF-8"?>
+<command xmlns="http://lttng.org/xml/ns/lttng-mi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://lttng.org/xml/ns/lttng-mi http://lttng.org/xml/schemas/lttng-mi/3/lttng-mi-3.0.xsd" schemaVersion="3.0"><name>list</name><output><sessions><session><name>mysession</name><path>${workspace}/lttng-traces/mysession-20160729-170007</path><enabled>false</enabled><snapshot_mode>0</snapshot_mode><live_timer_interval>0</live_timer_interval><domains><domain><type>UST</type><buffer_type>PER_UID</buffer_type><trackers/><channels><channel><name>lttng_jul_channel</name><enabled>true</enabled><attributes><overwrite_mode>DISCARD</overwrite_mode><subbuffer_size>131072</subbuffer_size><subbuffer_count>4</subbuffer_count><switch_timer_interval>0</switch_timer_interval><read_timer_interval>0</read_timer_interval><output_type>MMAP</output_type><tracefile_size>0</tracefile_size><tracefile_count>0</tracefile_count><live_timer_interval>0</live_timer_interval><discarded_events>0</discarded_events><lost_packets>0</lost_packets></attributes><events/></channel></channels></domain><domain><type>JUL</type><buffer_type>PER_UID</buffer_type><events><event><name>*</name><type>TRACEPOINT</type><enabled>true</enabled><loglevel>JUL_ALL</loglevel><loglevel_type>ALL</loglevel_type><exclusions/></event><event><name>logger</name><type>TRACEPOINT</type><enabled>true</enabled><filter_expression>logger_name == &quot;logger&quot;</filter_expression><loglevel>JUL_ALL</loglevel><loglevel_type>ALL</loglevel_type><exclusions/></event></events></domain></domains></session></sessions></output></command>
+</COMMAND_OUTPUT>
+<COMMAND_INPUT>
+lttng --mi xml enable-event anotherLogger -j -s mysession --loglevel Warning
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+<?xml version="1.0" encoding="UTF-8"?>
+<command xmlns="http://lttng.org/xml/ns/lttng-mi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://lttng.org/xml/ns/lttng-mi http://lttng.org/xml/schemas/lttng-mi/3/lttng-mi-3.0.xsd" schemaVersion="3.0"><name>enable-event</name><output><events><event><name>anotherLogger</name><type>TRACEPOINT</type><enabled>true</enabled><loglevel>JUL_WARNING</loglevel><loglevel_type>RANGE</loglevel_type><exclusions/><success>true</success></event></events></output><success>true</success></command>
+</COMMAND_OUTPUT>
+<COMMAND_INPUT>
+lttng --mi xml list mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+<?xml version="1.0" encoding="UTF-8"?>
+<command xmlns="http://lttng.org/xml/ns/lttng-mi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://lttng.org/xml/ns/lttng-mi http://lttng.org/xml/schemas/lttng-mi/3/lttng-mi-3.0.xsd" schemaVersion="3.0"><name>list</name><output><sessions><session><name>mysession</name><path>${workspace}/lttng-traces/mysession-20160729-170007</path><enabled>false</enabled><snapshot_mode>0</snapshot_mode><live_timer_interval>0</live_timer_interval><domains><domain><type>UST</type><buffer_type>PER_UID</buffer_type><trackers/><channels><channel><name>lttng_jul_channel</name><enabled>true</enabled><attributes><overwrite_mode>DISCARD</overwrite_mode><subbuffer_size>131072</subbuffer_size><subbuffer_count>4</subbuffer_count><switch_timer_interval>0</switch_timer_interval><read_timer_interval>0</read_timer_interval><output_type>MMAP</output_type><tracefile_size>0</tracefile_size><tracefile_count>0</tracefile_count><live_timer_interval>0</live_timer_interval><discarded_events>0</discarded_events><lost_packets>0</lost_packets></attributes><events/></channel></channels></domain><domain><type>JUL</type><buffer_type>PER_UID</buffer_type><events><event><name>*</name><type>TRACEPOINT</type><enabled>true</enabled><loglevel>JUL_ALL</loglevel><loglevel_type>ALL</loglevel_type><exclusions/></event><event><name>anotherLogger</name><type>TRACEPOINT</type><enabled>true</enabled><filter_expression>(logger_name == &quot;anotherLogger&quot;) &amp;&amp; (int_loglevel &gt;= 900)</filter_expression><loglevel>JUL_WARNING</loglevel><loglevel_type>RANGE</loglevel_type><exclusions/></event><event><name>logger</name><type>TRACEPOINT</type><enabled>true</enabled><filter_expression>logger_name == &quot;logger&quot;</filter_expression><loglevel>JUL_ALL</loglevel><loglevel_type>ALL</loglevel_type><exclusions/></event></events></domain></domains></session></sessions></output></command>
+</COMMAND_OUTPUT>
+<COMMAND_INPUT>
+lttng --mi xml start mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+<?xml version="1.0" encoding="UTF-8"?>
+<command xmlns="http://lttng.org/xml/ns/lttng-mi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://lttng.org/xml/ns/lttng-mi http://lttng.org/xml/schemas/lttng-mi/3/lttng-mi-3.0.xsd" schemaVersion="3.0"><name>start</name><output><sessions><session><name>mysession</name><enabled>true</enabled></session></sessions></output><success>true</success></command>
+</COMMAND_OUTPUT>
+<COMMAND_INPUT>
+lttng --mi xml stop mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+<?xml version="1.0" encoding="UTF-8"?>
+<command xmlns="http://lttng.org/xml/ns/lttng-mi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://lttng.org/xml/ns/lttng-mi http://lttng.org/xml/schemas/lttng-mi/3/lttng-mi-3.0.xsd" schemaVersion="3.0"><name>stop</name><output><sessions><session><name>mysession</name><enabled>false</enabled></session></sessions></output><success>true</success></command>
+</COMMAND_OUTPUT>
+<COMMAND_INPUT>
+lttng --mi xml destroy mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+<?xml version="1.0" encoding="UTF-8"?>
+<command xmlns="http://lttng.org/xml/ns/lttng-mi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://lttng.org/xml/ns/lttng-mi http://lttng.org/xml/schemas/lttng-mi/3/lttng-mi-3.0.xsd" schemaVersion="3.0"><name>destroy</name><output><sessions><session><name>mysession</name><path>${workspace}/lttng-traces/mysession-20160105-151744</path><enabled>false</enabled><snapshot_mode>0</snapshot_mode><live_timer_interval>0</live_timer_interval></session></sessions></output><success>true</success></command>
+</COMMAND_OUTPUT>
+</SCENARIO>
index a5e38c74989b9350fb8420de354d6c1eb9166c34..8114912a82c713ec17058fba3946202636693d61 100644 (file)
@@ -48,7 +48,7 @@ lttng --mi xml list -j
 </COMMAND_RESULT>
 <COMMAND_OUTPUT>
 <?xml version="1.0" encoding="UTF-8"?>
-<command><name>list</name><output><domains><domain><type>JUL</type><buffer_type>PER_PID</buffer_type><pids><pid><id>18275</id><name>java</name><events><event><name>anotherLogger</name><type>TRACEPOINT</type><enabled>true</enabled><loglevel>UNKNOWN</loglevel><loglevel_type>ALL</loglevel_type></event><event><name>logger</name><type>TRACEPOINT</type><enabled>true</enabled><loglevel>UNKNOWN</loglevel><loglevel_type>ALL</loglevel_type></event><event><name>global</name><type>TRACEPOINT</type><enabled>true</enabled><loglevel>UNKNOWN</loglevel><loglevel_type>ALL</loglevel_type></event></events></pid></pids></domain></domains></output></command>
+<command><name>list</name><output><domains><domain><type>JUL</type><buffer_type>PER_PID</buffer_type><pids><pid><id>32598</id><name>java</name><events><event><name>anotherLogger</name><type>TRACEPOINT</type><enabled>true</enabled><filter>false</filter><loglevel>UNKNOWN</loglevel><loglevel_type>ALL</loglevel_type><exclusion>false</exclusion></event><event><name>logger</name><type>TRACEPOINT</type><enabled>true</enabled><filter>false</filter><loglevel>UNKNOWN</loglevel><loglevel_type>ALL</loglevel_type><exclusion>false</exclusion></event><event><name>global</name><type>TRACEPOINT</type><enabled>true</enabled><filter>false</filter><loglevel>UNKNOWN</loglevel><loglevel_type>ALL</loglevel_type><exclusion>false</exclusion></event></events></pid></pids></domain></domains></output></command>
 </COMMAND_OUTPUT>
 <COMMAND_INPUT>
 lttng --mi xml list -l
@@ -149,7 +149,7 @@ lttng --mi xml list -j
 </COMMAND_RESULT>
 <COMMAND_OUTPUT>
 <?xml version="1.0" encoding="UTF-8"?>
-<command><name>list</name><output><domains><domain><type>JUL</type><buffer_type>PER_PID</buffer_type><pids><pid><id>18275</id><name>java</name><events><event><name>anotherLogger</name><type>TRACEPOINT</type><enabled>true</enabled><loglevel>UNKNOWN</loglevel><loglevel_type>ALL</loglevel_type></event><event><name>logger</name><type>TRACEPOINT</type><enabled>true</enabled><loglevel>UNKNOWN</loglevel><loglevel_type>ALL</loglevel_type></event><event><name>global</name><type>TRACEPOINT</type><enabled>true</enabled><loglevel>UNKNOWN</loglevel><loglevel_type>ALL</loglevel_type></event></events></pid></pids></domain></domains></output></command>
+<command><name>list</name><output><domains><domain><type>JUL</type><buffer_type>PER_PID</buffer_type><pids><pid><id>32598</id><name>java</name><events><event><name>anotherLogger</name><type>TRACEPOINT</type><enabled>true</enabled><loglevel>UNKNOWN</loglevel><loglevel_type>ALL</loglevel_type></event><event><name>logger</name><type>TRACEPOINT</type><enabled>true</enabled><loglevel>UNKNOWN</loglevel><loglevel_type>ALL</loglevel_type></event><event><name>global</name><type>TRACEPOINT</type><enabled>true</enabled><loglevel>UNKNOWN</loglevel><loglevel_type>ALL</loglevel_type></event></events></pid></pids></domain></domains></output></command>
 </COMMAND_OUTPUT>
 <COMMAND_INPUT>
 lttng --mi xml list -l
index 4fb1365d21a0b1a074145ed4999a4b31a34b872e..7697cef3d89de80c89488cfb54354a5e72fa45d8 100644 (file)
@@ -17,18 +17,23 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
+import java.util.ArrayList;
 import java.util.List;
 
 import org.eclipse.core.commands.ExecutionException;
 import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.IChannelInfo;
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.IDomainInfo;
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.IEventInfo;
+import org.eclipse.tracecompass.internal.lttng2.control.core.model.ILoggerInfo;
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.ISessionInfo;
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.LogLevelType;
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceChannelOutputType;
+import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceDomainType;
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceEnablement;
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceEventType;
+import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceJulLogLevel;
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceLogLevel;
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceSessionState;
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.impl.SessionInfo;
@@ -48,6 +53,7 @@ public class LTTngControlServiceMiTest extends LTTngControlServiceTest {
 
     private static final String SCEN_SESSION_WITH_SYSCALLS = "GetSessionWithSyscalls";
     private static final String SCEN_LIST_SESSION_2_7_COMPAT = "ListSession2.7Compat";
+    private static final String SCEN_ENABLING_JUL_LOGGERS = "EnableJulLoggers";
 
     @Override
     protected ILttngControlService getControlService() {
@@ -304,4 +310,53 @@ public class LTTngControlServiceMiTest extends LTTngControlServiceTest {
             fail(e.toString());
         }
     }
+
+    @Override
+    public void testEnableJulLoggers() {
+        try {
+            String sessionName = "mysession";
+            // Lists
+            List<String> loggerList = new ArrayList<>();
+            // Events
+            String loggerName1 = "logger";
+            String loggerName2 = "anotherLogger";
+            String allLoggerName = "*";
+
+            fShell.setScenario(SCEN_ENABLING_JUL_LOGGERS);
+
+            // 1) Enabling all loggers
+            loggerList.add(allLoggerName);
+            fService.enableEvents(sessionName, null, loggerList, TraceDomainType.JUL, null, null, new NullProgressMonitor());
+            loggerList.clear();
+
+            // 2) Enabling one logger
+            loggerList.add(loggerName1);
+            fService.enableEvents(sessionName, null, loggerList, TraceDomainType.JUL, null, null, new NullProgressMonitor());
+
+            // 3) Enabling two loggers with loglevel-only JUL_WARNING and
+            //    verifying the attributes of one of them
+            loggerList.add(loggerName2);
+            fService.enableLogLevel(sessionName, null, loggerList, LogLevelType.LOGLEVEL_ONLY, TraceJulLogLevel.JUL_WARNING, null, TraceDomainType.JUL, new NullProgressMonitor());
+
+            @Nullable
+            ISessionInfo session = fService.getSession(sessionName, new NullProgressMonitor());
+            assertNotNull(session);
+            // Get the list of loggers
+            List<ILoggerInfo> loggers = session.getDomains()[1].getLoggers();
+            assertNotNull(loggers);
+            assertEquals(loggers.size(), 4);
+            // Get the "anotherLogger" logger
+            ILoggerInfo loggerInfo = loggers.stream()
+                    .filter(logger -> logger.getName().equals(loggerName2))
+                    .findFirst().get();
+            // Verify attributes
+            assertEquals(loggerName2, loggerInfo.getName());
+            assertEquals(TraceDomainType.JUL, loggerInfo.getDomain());
+            assertEquals(TraceJulLogLevel.JUL_WARNING, loggerInfo.getLogLevel());
+            assertEquals(LogLevelType.LOGLEVEL_ONLY, loggerInfo.getLogLevelType());
+            assertEquals(TraceEnablement.ENABLED, loggerInfo.getState());
+        } catch (ExecutionException e) {
+            fail(e.toString());
+        }
+    }
 }
index e96f1f3c8006e798f499ce72c460b044a1e10df7..12b9d56c68e76598009b662337d506d1d4872043 100644 (file)
@@ -1154,6 +1154,12 @@ public class LTTngControlServiceTest {
         }
     }
 
+    @Test
+    public void testEnableJulLoggers() {
+        // Trace Compass only supports JUL starting with LTTng 2.6 that supports MI.
+        // The implementation of this test is the LTTngControlServiceMiTest.java.
+    }
+
     @Test
     public void testEventExcluded() {
         try {
index b4455d97c081efe64276db2763c911c75d5a4ab9..5064bba33dd8a6f5e7c98db89dc10c3621f900f6 100644 (file)
@@ -2242,6 +2242,192 @@ lttng --mi xml enable-event -a -k -s mysession2
 
 </SCENARIO>
 
+####################################################################
+# Scenario: Test "lttng enable-events ..." with JUL loggers
+####################################################################
+<SCENARIO>
+EnableJulLoggers
+
+<COMMAND_INPUT>
+lttng --mi xml enable-event -a -j -s mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+<?xml version="1.0" encoding="UTF-8"?>
+<command xmlns="http://lttng.org/xml/ns/lttng-mi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://lttng.org/xml/ns/lttng-mi http://lttng.org/xml/schemas/lttng-mi/3/lttng-mi-3.0.xsd" schemaVersion="3.0">
+  <name>enable-event</name>
+  <output>
+    <events>
+      <event>
+        <name>*</name>
+        <type>TRACEPOINT</type>
+        <enabled>true</enabled>
+        <loglevel>JUL_ALL</loglevel>
+        <loglevel_type>ALL</loglevel_type>
+        <exclusions />
+        <success>true</success>
+      </event>
+    </events>
+  </output>
+  <success>true</success>
+</command>
+</COMMAND_OUTPUT>
+<COMMAND_INPUT>
+lttng --mi xml enable-event logger -j -s mysession --tracepoint
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+<?xml version="1.0" encoding="UTF-8"?>
+<command xmlns="http://lttng.org/xml/ns/lttng-mi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://lttng.org/xml/ns/lttng-mi http://lttng.org/xml/schemas/lttng-mi/3/lttng-mi-3.0.xsd" schemaVersion="3.0">
+  <name>enable-event</name>
+  <output>
+    <events>
+      <event>
+        <name>logger</name>
+        <type>TRACEPOINT</type>
+        <enabled>true</enabled>
+        <loglevel>JUL_ALL</loglevel>
+        <loglevel_type>ALL</loglevel_type>
+        <exclusions />
+        <success>true</success>
+      </event>
+    </events>
+  </output>
+  <success>true</success>
+</command>
+</COMMAND_OUTPUT>
+<COMMAND_INPUT>
+lttng --mi xml enable-event logger,anotherLogger -j -s mysession --loglevel-only Warning
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+<?xml version="1.0" encoding="UTF-8"?>
+<command xmlns="http://lttng.org/xml/ns/lttng-mi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://lttng.org/xml/ns/lttng-mi http://lttng.org/xml/schemas/lttng-mi/3/lttng-mi-3.0.xsd" schemaVersion="3.0">
+  <name>enable-event</name>
+  <output>
+    <events>
+      <event>
+        <name>logger</name>
+        <type>TRACEPOINT</type>
+        <enabled>true</enabled>
+        <loglevel>JUL_WARNING</loglevel>
+        <loglevel_type>SINGLE</loglevel_type>
+        <exclusions />
+        <success>true</success>
+      </event>
+      <event>
+        <name>anotherLogger</name>
+        <type>TRACEPOINT</type>
+        <enabled>true</enabled>
+        <loglevel>JUL_WARNING</loglevel>
+        <loglevel_type>SINGLE</loglevel_type>
+        <exclusions />
+        <success>true</success>
+      </event>
+    </events>
+  </output>
+  <success>true</success>
+</command>
+</COMMAND_OUTPUT>
+<COMMAND_INPUT>
+lttng --mi xml list mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+<?xml version="1.0" encoding="UTF-8"?>
+<command xmlns="http://lttng.org/xml/ns/lttng-mi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://lttng.org/xml/ns/lttng-mi http://lttng.org/xml/schemas/lttng-mi/3/lttng-mi-3.0.xsd" schemaVersion="3.0">
+  <name>list</name>
+  <output>
+    <sessions>
+      <session>
+        <name>mysession</name>
+        <path>${workspace}/lttng-traces/mysession-20160801-150841</path>
+        <enabled>false</enabled>
+        <snapshot_mode>0</snapshot_mode>
+        <live_timer_interval>0</live_timer_interval>
+        <domains>
+          <domain>
+            <type>UST</type>
+            <buffer_type>PER_UID</buffer_type>
+            <trackers />
+            <channels>
+              <channel>
+                <name>lttng_jul_channel</name>
+                <enabled>true</enabled>
+                <attributes>
+                  <overwrite_mode>DISCARD</overwrite_mode>
+                  <subbuffer_size>131072</subbuffer_size>
+                  <subbuffer_count>4</subbuffer_count>
+                  <switch_timer_interval>0</switch_timer_interval>
+                  <read_timer_interval>0</read_timer_interval>
+                  <output_type>MMAP</output_type>
+                  <tracefile_size>0</tracefile_size>
+                  <tracefile_count>0</tracefile_count>
+                  <live_timer_interval>0</live_timer_interval>
+                  <discarded_events>0</discarded_events>
+                  <lost_packets>0</lost_packets>
+                </attributes>
+                <events />
+              </channel>
+            </channels>
+          </domain>
+          <domain>
+            <type>JUL</type>
+            <buffer_type>PER_UID</buffer_type>
+            <events>
+              <event>
+                <name>*</name>
+                <type>TRACEPOINT</type>
+                <enabled>true</enabled>
+                <loglevel>JUL_ALL</loglevel>
+                <loglevel_type>ALL</loglevel_type>
+                <exclusions />
+              </event>
+              <event>
+                <name>anotherLogger</name>
+                <type>TRACEPOINT</type>
+                <enabled>true</enabled>
+                <filter_expression>(logger_name == "anotherLogger") &amp;&amp; (int_loglevel == 900)</filter_expression>
+                <loglevel>JUL_WARNING</loglevel>
+                <loglevel_type>SINGLE</loglevel_type>
+                <exclusions />
+              </event>
+              <event>
+                <name>logger</name>
+                <type>TRACEPOINT</type>
+                <enabled>true</enabled>
+                <filter_expression>(logger_name == "logger") &amp;&amp; (int_loglevel == 900)</filter_expression>
+                <loglevel>JUL_WARNING</loglevel>
+                <loglevel_type>SINGLE</loglevel_type>
+                <exclusions />
+              </event>
+              <event>
+                <name>logger</name>
+                <type>TRACEPOINT</type>
+                <enabled>true</enabled>
+                <filter_expression>logger_name == "logger"</filter_expression>
+                <loglevel>JUL_ALL</loglevel>
+                <loglevel_type>ALL</loglevel_type>
+                <exclusions />
+              </event>
+            </events>
+          </domain>
+        </domains>
+      </session>
+    </sessions>
+  </output>
+</command>
+</COMMAND_OUTPUT>
+</SCENARIO>
+
 ####################################################################
 # Scenario: Test "lttng enable-events ..." with exclusion
 ####################################################################
@@ -2481,7 +2667,7 @@ lttng --mi xml list mysession2
         <sessions>
             <session>
                 <name>mysession2</name>
-                <path>/home/bruno/lttng-traces/mysession2-20160630-171503</path>
+                <path>${workspace}/lttng-traces/mysession2-20160630-171503</path>
                 <enabled>false</enabled>
                 <snapshot_mode>0</snapshot_mode>
                 <live_timer_interval>0</live_timer_interval>
index bcf10ba42edba2073abb96c6740f174a076b411d..342e999ced1bc34def300be534f721db424363b6 100644 (file)
@@ -2202,6 +2202,195 @@ lttng --mi xml enable-event -a -k -s mysession2
 
 </SCENARIO>
 
+####################################################################
+# Scenario: Test "lttng enable-events ..." with JUL loggers
+####################################################################
+<SCENARIO>
+EnableJulLoggers
+
+<COMMAND_INPUT>
+lttng --mi xml enable-event -a -j -s mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+<?xml version="1.0" encoding="UTF-8"?>
+<command>
+  <name>enable-event</name>
+  <output>
+    <events>
+      <event>
+        <name>*</name>
+        <type>TRACEPOINT</type>
+        <enabled>true</enabled>
+        <filter>false</filter>
+        <loglevel>JUL_ALL</loglevel>
+        <loglevel_type>ALL</loglevel_type>
+        <exclusion>false</exclusion>
+        <success>true</success>
+      </event>
+    </events>
+  </output>
+  <success>true</success>
+</command>
+</COMMAND_OUTPUT>
+<COMMAND_INPUT>
+lttng --mi xml enable-event logger -j -s mysession --tracepoint
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+<?xml version="1.0" encoding="UTF-8"?>
+<command>
+  <name>enable-event</name>
+  <output>
+    <events>
+      <event>
+        <name>logger</name>
+        <type>TRACEPOINT</type>
+        <enabled>true</enabled>
+        <filter>false</filter>
+        <loglevel>JUL_ALL</loglevel>
+        <loglevel_type>ALL</loglevel_type>
+        <exclusion>false</exclusion>
+        <success>true</success>
+      </event>
+    </events>
+  </output>
+  <success>true</success>
+</command>
+</COMMAND_OUTPUT>
+<COMMAND_INPUT>
+lttng --mi xml enable-event logger,anotherLogger -j -s mysession --loglevel-only Warning
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+<?xml version="1.0" encoding="UTF-8"?>
+<command>
+  <name>enable-event</name>
+  <output>
+    <events>
+      <event>
+        <name>logger</name>
+        <type>TRACEPOINT</type>
+        <enabled>true</enabled>
+        <filter>false</filter>
+        <loglevel>JUL_WARNING</loglevel>
+        <loglevel_type>SINGLE</loglevel_type>
+        <exclusion>false</exclusion>
+        <success>true</success>
+      </event>
+      <event>
+        <name>anotherLogger</name>
+        <type>TRACEPOINT</type>
+        <enabled>true</enabled>
+        <filter>false</filter>
+        <loglevel>JUL_WARNING</loglevel>
+        <loglevel_type>SINGLE</loglevel_type>
+        <exclusion>false</exclusion>
+        <success>true</success>
+      </event>
+    </events>
+  </output>
+  <success>true</success>
+</command>
+</COMMAND_OUTPUT>
+<COMMAND_INPUT>
+lttng --mi xml list mysession
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+<?xml version="1.0" encoding="UTF-8"?>
+<command>
+  <name>list</name>
+  <output>
+    <sessions>
+      <session>
+        <name>mysession</name>
+        <path>${workspace}/lttng-traces/mysession-20160801-150625</path>
+        <enabled>false</enabled>
+        <snapshot_mode>0</snapshot_mode>
+        <live_timer_interval>0</live_timer_interval>
+        <domains>
+          <domain>
+            <type>UST</type>
+            <buffer_type>PER_UID</buffer_type>
+            <trackers />
+            <channels>
+              <channel>
+                <name>lttng_jul_channel</name>
+                <enabled>true</enabled>
+                <attributes>
+                  <overwrite_mode>DISCARD</overwrite_mode>
+                  <subbuffer_size>131072</subbuffer_size>
+                  <subbuffer_count>4</subbuffer_count>
+                  <switch_timer_interval>0</switch_timer_interval>
+                  <read_timer_interval>0</read_timer_interval>
+                  <output_type>MMAP</output_type>
+                  <tracefile_size>0</tracefile_size>
+                  <tracefile_count>0</tracefile_count>
+                  <live_timer_interval>0</live_timer_interval>
+                </attributes>
+                <events />
+              </channel>
+            </channels>
+          </domain>
+          <domain>
+            <type>JUL</type>
+            <buffer_type>PER_UID</buffer_type>
+            <events>
+              <event>
+                <name>logger</name>
+                <type>TRACEPOINT</type>
+                <enabled>true</enabled>
+                <filter>false</filter>
+                <loglevel>JUL_WARNING</loglevel>
+                <loglevel_type>SINGLE</loglevel_type>
+                <exclusion>false</exclusion>
+              </event>
+              <event>
+                <name>logger</name>
+                <type>TRACEPOINT</type>
+                <enabled>true</enabled>
+                <filter>false</filter>
+                <loglevel>JUL_ALL</loglevel>
+                <loglevel_type>ALL</loglevel_type>
+                <exclusion>false</exclusion>
+              </event>
+              <event>
+                <name>*</name>
+                <type>TRACEPOINT</type>
+                <enabled>true</enabled>
+                <filter>false</filter>
+                <loglevel>JUL_ALL</loglevel>
+                <loglevel_type>ALL</loglevel_type>
+                <exclusion>false</exclusion>
+              </event>
+              <event>
+                <name>anotherLogger</name>
+                <type>TRACEPOINT</type>
+                <enabled>true</enabled>
+                <filter>false</filter>
+                <loglevel>JUL_WARNING</loglevel>
+                <loglevel_type>SINGLE</loglevel_type>
+                <exclusion>false</exclusion>
+              </event>
+            </events>
+          </domain>
+        </domains>
+      </session>
+    </sessions>
+  </output>
+</command>
+</COMMAND_OUTPUT>
+</SCENARIO>
+
 ####################################################################
 # Scenario: Test "lttng enable-events ..." with exclusion
 ####################################################################
@@ -2248,7 +2437,7 @@ lttng --mi xml list mysession2
         <sessions>
             <session>
                 <name>mysession2</name>
-                <path>/home/ebruroy/lttng-traces/mysession2-20160621-125643</path>
+                <path>${workspace}/lttng-traces/mysession2-20160621-125643</path>
                 <enabled>false</enabled>
                 <snapshot_mode>0</snapshot_mode>
                 <live_timer_interval>0</live_timer_interval>
@@ -2331,7 +2520,7 @@ lttng --mi xml list mysession2
         <sessions>
             <session>
                 <name>mysession2</name>
-                <path>/home/ebruroy/lttng-traces/mysession2-20160621-125933</path>
+                <path>${workspace}/lttng-traces/mysession2-20160621-125933</path>
                 <enabled>false</enabled>
                 <snapshot_mode>0</snapshot_mode>
                 <live_timer_interval>0</live_timer_interval>
@@ -2414,7 +2603,7 @@ lttng --mi xml list mysession2
         <sessions>
             <session>
                 <name>mysession2</name>
-                <path>/home/ebruroy/lttng-traces/mysession2-20160630-171241</path>
+                <path>${workspace}/lttng-traces/mysession2-20160630-171241</path>
                 <enabled>false</enabled>
                 <snapshot_mode>0</snapshot_mode>
                 <live_timer_interval>0</live_timer_interval>
index ac4623db9eadbf9f2312f1b34b3862d6c189fb58..49060646323ad410cde7e4bf223d199443f32452 100644 (file)
@@ -1195,7 +1195,7 @@ lttng list mysession2
 </COMMAND_RESULT>
 <COMMAND_OUTPUT>
 Tracing session mysession2: [inactive]
-    Trace path: /home/ebruroy/lttng-traces/mysession2-20160630-135750
+    Trace path: ${workspace}/lttng-traces/mysession2-20160630-135750
 
 === Domain: UST global ===
 
index 5ffb8ef2ce9779e74666748d00b2979b2aca9863..70fed4d0be337c64ee3ba462e91adc3ca368f0d2 100644 (file)
@@ -102,8 +102,9 @@ public class TraceLoggerPropertySource extends BasePropertySource {
             return fLogger.getName();
         } else if (TRACE_LOGGER_LOGLEVEL_PROPERTY_ID.equals(id)) {
             StringBuffer buffer = new StringBuffer();
-            if (!fLogger.getLogLevelType().equals(LogLevelType.LOGLEVEL_NONE)) {
-                buffer.append(fLogger.getLogLevelType().getShortName()).append(' ');
+            if (!fLogger.getLogLevelType().equals(LogLevelType.LOGLEVEL_NONE) &&
+                !fLogger.getLogLevelType().equals(LogLevelType.LOGLEVEL_ALL)) {
+                buffer.append(fLogger.getLogLevelType().getShortName()).append(" "); //$NON-NLS-1$
             }
             buffer.append(fLogger.getLogLevel().getInName());
             return buffer.toString();
This page took 0.056161 seconds and 5 git commands to generate.