*
* 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.IBaseEventInfo;
import org.eclipse.linuxtools.internal.lttng2.core.control.model.IUstProviderInfo;
import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.BaseEventInfo;
import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.UstProviderInfo;
+import org.junit.Before;
+import org.junit.Test;
/**
- * The class <code>ChannelInfoTest</code> contains tests for the class <code>{@link UstProviderInfo}</code>.
- *
+ * The class <code>ChannelInfoTest</code> contains tests for the class
+ * <code>{@link UstProviderInfo}</code>.
*/
-@SuppressWarnings({"nls", "javadoc"})
-public class UstProviderInfoTest extends TestCase {
+@SuppressWarnings("nls")
+public class UstProviderInfoTest {
+
// ------------------------------------------------------------------------
// Test data
// ------------------------------------------------------------------------
+
private IUstProviderInfo fUstProviderInfo1 = null;
private IUstProviderInfo fUstProviderInfo2 = null;
/**
* Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
*/
- @Override
+ @Before
public void setUp() {
ModelImplFactory factory = new ModelImplFactory();
fUstProviderInfo1 = factory.getUstProviderInfo1();
fEventInfo2 = factory.getBaseEventInfo2();
}
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- */
- @Override
- public void tearDown() {
- }
-
// ------------------------------------------------------------------------
// Tests
// ------------------------------------------------------------------------
/**
* Run the UstProviderInfo() constructor test.
- *
*/
+ @Test
public void testUstProviderInfo() {
IUstProviderInfo result = new UstProviderInfo("test");
assertNotNull(result);
assertEquals(0, result.getEvents().length);
}
+ /**
+ * Test the copy constructor.
+ */
+ @Test
public void testUstProviderInfoCopy() {
IUstProviderInfo providerInf = new UstProviderInfo((UstProviderInfo)fUstProviderInfo1);
}
}
+ /**
+ * Test the copy constructor.
+ */
+ @Test
public void testUstProviderCopy2() {
try {
UstProviderInfo providerInfo = null;
/**
* Run the IEventInfo[] getEvents() method test.
- *
*/
+ @Test
public void testGetAndSetters() {
IUstProviderInfo fixture = new UstProviderInfo("test");
fixture.setPid(2468);
/**
* Run the void setEvents(List<IBaseEventInfo>) method test.
- *
*/
+ @Test
public void testSetEvents_1() {
UstProviderInfo fixture = new UstProviderInfo("test");
fixture.setPid(2468);
}
}
+ /**
+ * Run the String toString() method test.
+ */
+ @Test
public void testToString_1() {
UstProviderInfo fixture = new UstProviderInfo("test");
fixture.setPid(2468);
/**
* Run the String toString() method test.
- *
*/
+ @Test
public void testToString_2() {
String result = fUstProviderInfo2.toString();
assertEquals("[EventInfo([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)])]", result);
+ "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)])]", result);
}
// ------------------------------------------------------------------------
// equals
// ------------------------------------------------------------------------
+ /**
+ * Run the equals() method test.
+ */
+ @Test
public void testEqualsReflexivity() {
assertTrue("equals", fUstProviderInfo1.equals(fUstProviderInfo1));
assertTrue("equals", fUstProviderInfo2.equals(fUstProviderInfo2));
assertTrue("equals", !fUstProviderInfo2.equals(fUstProviderInfo1));
}
+ /**
+ * Run the equals() method test.
+ */
+ @Test
public void testEqualsSymmetry() {
UstProviderInfo event1 = new UstProviderInfo((UstProviderInfo)fUstProviderInfo1);
UstProviderInfo event2 = new UstProviderInfo((UstProviderInfo)fUstProviderInfo2);
assertTrue("equals", fUstProviderInfo2.equals(event2));
}
+ /**
+ * Run the equals() method test.
+ */
+ @Test
public void testEqualsTransivity() {
UstProviderInfo UstProvider1 = new UstProviderInfo((UstProviderInfo)fUstProviderInfo1);
UstProviderInfo UstProvider2 = new UstProviderInfo((UstProviderInfo)fUstProviderInfo1);
assertTrue("equals", UstProvider1.equals(UstProvider3));
}
+ /**
+ * Run the equals() method test.
+ */
+ @Test
public void testEqualsNull() {
assertTrue("equals", !fUstProviderInfo1.equals(null));
assertTrue("equals", !fUstProviderInfo2.equals(null));
// hashCode
// ------------------------------------------------------------------------
+ /**
+ * Run the hashCode() method test.
+ */
+ @Test
public void testHashCode() {
UstProviderInfo UstProvider1 = new UstProviderInfo((UstProviderInfo)fUstProviderInfo1);
UstProviderInfo UstProvider2 = new UstProviderInfo((UstProviderInfo)fUstProviderInfo2);