lttng: Add snapshot support - LTTng Tools v2.3
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.core.tests / src / org / eclipse / linuxtools / lttng2 / core / tests / control / model / impl / SessionInfoTest.java
index 69f937ef71145071acec4305a3f8577fe7297e33..f033772a0dbdeeb8a790a4757d1c712a5b7ec9a3 100644 (file)
@@ -1,5 +1,5 @@
 /**********************************************************************
- * Copyright (c) 2012 Ericsson
+ * Copyright (c) 2012, 2013 Ericsson
  *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
@@ -8,28 +8,33 @@
  *
  * Contributors:
  *   Bernd Hufmann - Initial API and implementation
+ *   Alexandre Montplaisir - Port to JUnit4
  **********************************************************************/
+
 package org.eclipse.linuxtools.lttng2.core.tests.control.model.impl;
 
+import static org.junit.Assert.*;
+
 import java.util.LinkedList;
 import java.util.List;
 
-import junit.framework.TestCase;
-
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.IDomainInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.ISessionInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceSessionState;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.SessionInfo;
+import org.junit.Before;
+import org.junit.Test;
 
 /**
- * The class <code>ChannelInfoTest</code> contains tests for the class <code>{@link SessionInfo}</code>.
- *
+ * The class <code>ChannelInfoTest</code> contains tests for the class
+ * <code>{@link SessionInfo}</code>.
  */
-@SuppressWarnings({"nls", "javadoc"})
-public class SessionInfoTest extends TestCase {
+public class SessionInfoTest {
+
     // ------------------------------------------------------------------------
     // Test data
     // ------------------------------------------------------------------------
+
     private ISessionInfo fSessionInfo1 = null;
     private ISessionInfo fSessionInfo2 = null;
 
@@ -42,12 +47,8 @@ public class SessionInfoTest extends TestCase {
 
     /**
      * Perform pre-test initialization.
-     *
-     * @throws Exception
-     *         if the initialization fails for some reason
-     *
      */
-    @Override
+    @Before
     public void setUp() {
         ModelImplFactory factory = new ModelImplFactory();
         fSessionInfo1 = factory.getSessionInfo1();
@@ -56,17 +57,6 @@ public class SessionInfoTest extends TestCase {
         fDomainInfo2 = factory.getDomainInfo2();
     }
 
-    /**
-     * Perform post-test clean-up.
-     *
-     * @throws Exception
-     *         if the clean-up fails for some reason
-     *
-     */
-    @Override
-    public void tearDown() {
-    }
-
     // ------------------------------------------------------------------------
     // Tests
     // ------------------------------------------------------------------------
@@ -77,8 +67,8 @@ public class SessionInfoTest extends TestCase {
 
     /**
      * Run the ChannelInfo() constructor test.
-     *
      */
+    @Test
     public void testSessionInfo() {
         ISessionInfo result = new SessionInfo("test");
         assertNotNull(result);
@@ -93,6 +83,10 @@ public class SessionInfoTest extends TestCase {
         assertEquals(0, result.getDomains().length);
     }
 
+    /**
+     * Test copy constructor.
+     */
+    @Test
     public void testSessionInfoCopy() {
         SessionInfo sessionInfo = new SessionInfo((SessionInfo)fSessionInfo1);
 
@@ -107,6 +101,10 @@ public class SessionInfoTest extends TestCase {
         }
     }
 
+    /**
+     * Test copy constructor.
+     */
+    @Test
     public void testSessionCopy2() {
         try {
             SessionInfo session = null;
@@ -120,8 +118,8 @@ public class SessionInfoTest extends TestCase {
 
     /**
      * Run the long getNumberOfSubBuffers() method test.
-     *
      */
+    @Test
     public void testGetAndSetters() {
 
         // Note that addDomain() has been executed in setUp()
@@ -181,30 +179,62 @@ public class SessionInfoTest extends TestCase {
         assertEquals(0, state.ordinal());
     }
 
+    /**
+     * Run the String toString() method test.
+     */
+    @Test
     public void testToString_1() {
         ISessionInfo fixture = new SessionInfo("sessionName");
 
         String result = fixture.toString();
 
         // add additional test code here
-        assertEquals("[SessionInfo([TraceInfo(Name=sessionName)],State=INACTIVE,Domains=)]", result);
+        assertEquals("[SessionInfo([TraceInfo(Name=sessionName)],Path=,State=INACTIVE,isStreamedTrace=false,Domains=)]", result);
     }
 
     /**
      * Run the String toString() method test.
-     *
      */
+    @Test
     public void testToString_2() {
         String result = fSessionInfo1.toString();
 
         // add additional test code here
-        assertEquals("[SessionInfo([TraceInfo(Name=session1)],State=ACTIVE,Domains=[DomainInfo([TraceInfo(Name=test1)],Channels=[ChannelInfo([TraceInfo(Name=channel1)],State=DISABLED,OverwriteMode=true,SubBuffersSize=13,NumberOfSubBuffers=12,SwitchTimer=10,ReadTimer=11,output=splice(),Events=[EventInfo([BaseEventInfo([TraceInfo(Name=event1)],type=TRACEPOINT,level=TRACE_DEBUG)],State=ENABLED)])],isKernel=false)])]", result);
+        assertEquals("[SessionInfo([TraceInfo(Name=session1)],Path=/home/user/lttng-trace/mysession/,State=ACTIVE,isStreamedTrace=false,snapshotInfo="
+                + "[SnapshotInfo([TraceInfo(Name=snapshot-1)],snapshotPath=/home/user/lttng-trace/mysession/,ID=1,isStreamedSnapshot=false)],"
+                    + "Domains=[DomainInfo([TraceInfo(Name=test1)],"
+                        + "Channels=[ChannelInfo([TraceInfo(Name=channel1)],State=DISABLED,OverwriteMode=true,SubBuffersSize=13,NumberOfSubBuffers=12,SwitchTimer=10,ReadTimer=11,output=splice(),"
+                            + "Events=[EventInfo([BaseEventInfo([TraceInfo(Name=event1)],type=TRACEPOINT,level=TRACE_DEBUG)],State=ENABLED)])],"
+                + "isKernel=false)])]", result);
+    }
+
+    /**
+     * Run the String toString() method test.
+     */
+    @Test
+    public void testToString_3() {
+        SessionInfo info = new SessionInfo((SessionInfo)fSessionInfo1);
+        info.setSnapshotInfo(null);
+        info.setSessionPath("/home/user/lttng-trace/mysession/");
+
+        String result = info.toString();
+
+        // add additional test code here
+        assertEquals("[SessionInfo([TraceInfo(Name=session1)],Path=/home/user/lttng-trace/mysession/,State=ACTIVE,isStreamedTrace=false,"
+                    + "Domains=[DomainInfo([TraceInfo(Name=test1)],"
+                        + "Channels=[ChannelInfo([TraceInfo(Name=channel1)],State=DISABLED,OverwriteMode=true,SubBuffersSize=13,NumberOfSubBuffers=12,SwitchTimer=10,ReadTimer=11,output=splice(),"
+                            + "Events=[EventInfo([BaseEventInfo([TraceInfo(Name=event1)],type=TRACEPOINT,level=TRACE_DEBUG)],State=ENABLED)])],"
+                + "isKernel=false)])]", result);
     }
 
     // ------------------------------------------------------------------------
     // equals
     // ------------------------------------------------------------------------
 
+    /**
+     * Run the {@link SessionInfo#equals} method test.
+     */
+    @Test
     public void testEqualsReflexivity() {
         assertTrue("equals", fSessionInfo1.equals(fSessionInfo1));
         assertTrue("equals", fSessionInfo2.equals(fSessionInfo2));
@@ -213,6 +243,10 @@ public class SessionInfoTest extends TestCase {
         assertTrue("equals", !fSessionInfo2.equals(fSessionInfo1));
     }
 
+    /**
+     * Run the {@link SessionInfo#equals} method test.
+     */
+    @Test
     public void testEqualsSymmetry() {
         SessionInfo event1 = new SessionInfo((SessionInfo)fSessionInfo1);
         SessionInfo event2 = new SessionInfo((SessionInfo)fSessionInfo2);
@@ -224,6 +258,10 @@ public class SessionInfoTest extends TestCase {
         assertTrue("equals", fSessionInfo2.equals(event2));
     }
 
+    /**
+     * Run the {@link SessionInfo#equals} method test.
+     */
+    @Test
     public void testEqualsTransivity() {
         SessionInfo channel1 = new SessionInfo((SessionInfo)fSessionInfo1);
         SessionInfo channel2 = new SessionInfo((SessionInfo)fSessionInfo1);
@@ -234,7 +272,11 @@ public class SessionInfoTest extends TestCase {
         assertTrue("equals", channel1.equals(channel3));
     }
 
-    public void testEqualsNull() throws Exception {
+    /**
+     * Run the {@link SessionInfo#equals} method test.
+     */
+    @Test
+    public void testEqualsNull() {
         assertTrue("equals", !fSessionInfo1.equals(null));
         assertTrue("equals", !fSessionInfo2.equals(null));
     }
@@ -243,6 +285,10 @@ public class SessionInfoTest extends TestCase {
     // hashCode
     // ------------------------------------------------------------------------
 
+    /**
+     * Run the {@link SessionInfo#hashCode} method test.
+     */
+    @Test
     public void testHashCode() {
         SessionInfo channel1 = new SessionInfo((SessionInfo)fSessionInfo1);
         SessionInfo channel2 = new SessionInfo((SessionInfo)fSessionInfo2);
@@ -252,4 +298,5 @@ public class SessionInfoTest extends TestCase {
 
         assertTrue("hashCode", fSessionInfo1.hashCode() != channel2.hashCode());
         assertTrue("hashCode", fSessionInfo2.hashCode() != channel1.hashCode());
-    }}
\ No newline at end of file
+    }
+}
\ No newline at end of file
This page took 0.026891 seconds and 5 git commands to generate.