/**********************************************************************
- * 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
*
* 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;
/**
* 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();
fDomainInfo2 = factory.getDomainInfo2();
}
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- */
- @Override
- public void tearDown() {
- }
-
// ------------------------------------------------------------------------
// Tests
// ------------------------------------------------------------------------
/**
* Run the ChannelInfo() constructor test.
- *
*/
+ @Test
public void testSessionInfo() {
ISessionInfo result = new SessionInfo("test");
assertNotNull(result);
assertEquals(0, result.getDomains().length);
}
+ /**
+ * Test copy constructor.
+ */
+ @Test
public void testSessionInfoCopy() {
SessionInfo sessionInfo = new SessionInfo((SessionInfo)fSessionInfo1);
}
}
+ /**
+ * Test copy constructor.
+ */
+ @Test
public void testSessionCopy2() {
try {
SessionInfo session = null;
/**
* Run the long getNumberOfSubBuffers() method test.
- *
*/
+ @Test
public void testGetAndSetters() {
// Note that addDomain() has been executed in setUp()
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));
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);
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);
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));
}
// hashCode
// ------------------------------------------------------------------------
+ /**
+ * Run the {@link SessionInfo#hashCode} method test.
+ */
+ @Test
public void testHashCode() {
SessionInfo channel1 = new SessionInfo((SessionInfo)fSessionInfo1);
SessionInfo channel2 = new SessionInfo((SessionInfo)fSessionInfo2);
assertTrue("hashCode", fSessionInfo1.hashCode() != channel2.hashCode());
assertTrue("hashCode", fSessionInfo2.hashCode() != channel1.hashCode());
- }}
\ No newline at end of file
+ }
+}
\ No newline at end of file