/**********************************************************************
- * 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.IChannelInfo;
import org.eclipse.linuxtools.internal.lttng2.core.control.model.IEventInfo;
import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceEnablement;
import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.ChannelInfo;
import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.EventInfo;
+import org.junit.Before;
+import org.junit.Test;
/**
- * The class <code>ChannelInfoTest</code> contains tests for the class <code>{@link ChannelInfo}</code>.
- *
+ * The class <code>ChannelInfoTest</code> contains tests for the class
+ * <code>{@link ChannelInfo}</code>.
*/
-@SuppressWarnings({"nls", "javadoc"})
-public class ChannelInfoTest extends TestCase {
+@SuppressWarnings("nls")
+public class ChannelInfoTest {
+
// ------------------------------------------------------------------------
// Test data
// ------------------------------------------------------------------------
+
private IChannelInfo fChannelInfo1 = null;
private IChannelInfo fChannelInfo2 = null;
/**
* Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
*/
- @Override
+ @Before
public void setUp() {
ModelImplFactory factory = new ModelImplFactory();
fChannelInfo1 = factory.getChannel1();
fChannelInfo2 = factory.getChannel2();
}
- /**
- * 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 testChannelInfo() {
ChannelInfo result = new ChannelInfo("test");
assertNotNull(result);
assertEquals(0, result.getSwitchTimer());
}
+ /**
+ * Test copy constructor.
+ */
+ @Test
public void testChannelInfoCopy() {
ChannelInfo channelInfo = new ChannelInfo((ChannelInfo)fChannelInfo1);
}
}
+ /**
+ * Test copy constructor with a null value.
+ */
+ @Test
public void testChannelCopy2() {
try {
ChannelInfo channel = null;
/**
* Run the IEventInfo[] getEvents() method test.
- *
*/
+ @Test
public void testAddAndGetEvents_1() {
ChannelInfo fixture = new ChannelInfo("test");
fixture.setSwitchTimer(1L);
/**
* Run the long getNumberOfSubBuffers() method test.
- *
*/
+ @Test
public void testGetAndSetters() {
ChannelInfo fixture = new ChannelInfo("test");
fixture.setSwitchTimer(2L);
/**
* Run the void setEvents(List<IEventInfo>) method test.
- *
*/
+ @Test
public void testSetEvents_1() {
ChannelInfo fixture = new ChannelInfo("test");
fixture.setSwitchTimer(1L);
}
}
+ /**
+ * Run the String toString() method test.
+ */
+ @Test
public void testToString_1() {
ChannelInfo fixture = new ChannelInfo("channel");
fixture.setSwitchTimer(1L);
}
/**
- * Run the String toString() method test.
- *
+ * Run another String toString() method test.
*/
+ @Test
public void testToString_2() {
String result = fChannelInfo1.toString();
// equals
// ------------------------------------------------------------------------
+ /**
+ * Run the equals() method test.
+ */
+ @Test
public void testEqualsReflexivity() {
assertTrue("equals", fChannelInfo1.equals(fChannelInfo1));
assertTrue("equals", fChannelInfo2.equals(fChannelInfo2));
assertTrue("equals", !fChannelInfo2.equals(fChannelInfo1));
}
+ /**
+ * Run the equals() method test.
+ */
+ @Test
public void testEqualsSymmetry() {
ChannelInfo event1 = new ChannelInfo((ChannelInfo)fChannelInfo1);
ChannelInfo event2 = new ChannelInfo((ChannelInfo)fChannelInfo2);
assertTrue("equals", fChannelInfo2.equals(event2));
}
+ /**
+ * Run the equals() method test.
+ */
+ @Test
public void testEqualsTransivity() {
ChannelInfo channel1 = new ChannelInfo((ChannelInfo)fChannelInfo1);
ChannelInfo channel2 = new ChannelInfo((ChannelInfo)fChannelInfo1);
assertTrue("equals", channel1.equals(channel3));
}
+ /**
+ * Run the equals() method test.
+ */
+ @Test
public void testEqualsNull() {
assertTrue("equals", !fChannelInfo1.equals(null));
assertTrue("equals", !fChannelInfo2.equals(null));
// hashCode
// ------------------------------------------------------------------------
+ /**
+ * Run the hashCode() method test.
+ */
+ @Test
public void testHashCode() {
ChannelInfo channel1 = new ChannelInfo((ChannelInfo)fChannelInfo1);
ChannelInfo channel2 = new ChannelInfo((ChannelInfo)fChannelInfo2);