/**********************************************************************
- * 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.IBaseEventInfo;
import org.eclipse.linuxtools.internal.lttng2.core.control.model.IFieldInfo;
import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceEventType;
import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceLogLevel;
import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.BaseEventInfo;
import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.FieldInfo;
+import org.junit.Before;
+import org.junit.Test;
/**
- * The class <code>BaseEventInfoTest</code> contains test for the class <code>{@link BaseEventInfo}</code>.
+ * The class <code>BaseEventInfoTest</code> contains test for the class
+ * <code>{@link BaseEventInfo}</code>.
*/
-@SuppressWarnings({"nls", "javadoc"})
-public class BaseEventInfoTest extends TestCase {
+@SuppressWarnings("nls")
+public class BaseEventInfoTest {
// ------------------------------------------------------------------------
// Test data
// ------------------------------------------------------------------------
+
private IBaseEventInfo fEventInfo1 = null;
private IBaseEventInfo fEventInfo2 = null;
// ------------------------------------------------------------------------
/**
* Perform pre-test initialization.
- *
- * @throws Exception if the initialization fails for some reason
- *
*/
- @Override
- public void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() {
ModelImplFactory factory = new ModelImplFactory();
fEventInfo1 = factory.getBaseEventInfo1();
fEventInfo2 = factory.getBaseEventInfo2();
}
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception if the clean-up fails for some reason
- *
- */
- @Override
- public void tearDown() throws Exception {
- }
-
// ------------------------------------------------------------------------
// Tests
// ------------------------------------------------------------------------
/**
* Run the BaseEventInfo() constructor test.
- *
*/
+ @Test
public void testBaseEventInfo() {
BaseEventInfo fixture = new BaseEventInfo("event");
assertNotNull(fixture);
/**
* Test Copy Constructor
*/
+ @Test
public void testEventInfoCopy() {
BaseEventInfo info = new BaseEventInfo((BaseEventInfo)fEventInfo1);
/**
* Test Copy Constructor
*/
+ @Test
public void testEventCopy2() {
try {
BaseEventInfo info = null;
/**
* Run the TraceEventType getEventType() method test.
- *
- * @throws Exception
- *
*/
+ @Test
public void testGetEventType_1() {
BaseEventInfo fixture = new BaseEventInfo("event");
fixture.setEventType("unknown");
/**
* Run the void setEventType(TraceEventType) method test.
- *
*/
+ @Test
public void testSetEventType_2() {
BaseEventInfo fixture = new BaseEventInfo("event");
fixture.setEventType(TraceEventType.TRACEPOINT);
/**
* Run the void setLogLevel(TraceLogLevel) method test.
* Run the TraceLogLevel getLogLevel() method test
- *
*/
+ @Test
public void testSetLogLevel1() {
BaseEventInfo fixture = new BaseEventInfo("event");
fixture.setEventType(TraceEventType.TRACEPOINT);
/**
* Run the void setLogLevel(String) method test.
* Run the TraceLogLevel getLogLevel() method test
- *
*/
+ @Test
public void testSetLogLevel2() {
BaseEventInfo fixture = new BaseEventInfo("event");
fixture.setEventType(TraceEventType.TRACEPOINT);
/**
* test filter expression
*/
+ @Test
public void testSetFields() {
BaseEventInfo info = new BaseEventInfo((BaseEventInfo)fEventInfo2);
info.setFilterExpression("stringfield==test");
/**
* test add field
*/
+ @Test
public void testAddField() {
BaseEventInfo info = new BaseEventInfo((BaseEventInfo)fEventInfo2);
/**
* test set fields
*/
+ @Test
public void testFields() {
BaseEventInfo info = new BaseEventInfo((BaseEventInfo)fEventInfo2);
/**
* Run the String toString() method test.
- *
*/
+ @Test
public void testToString_1() {
BaseEventInfo fixture = new BaseEventInfo("event");
fixture.setName("testName");
// equals
// ------------------------------------------------------------------------
+ /**
+ * Test the .equals() method.
+ */
+ @Test
public void testEqualsReflexivity() {
assertTrue("equals", fEventInfo1.equals(fEventInfo1));
assertTrue("equals", fEventInfo2.equals(fEventInfo2));
assertTrue("equals", !fEventInfo2.equals(fEventInfo1));
}
+ /**
+ * Test the .equals() method.
+ */
+ @Test
public void testEqualsSymmetry() {
BaseEventInfo info1 = new BaseEventInfo((BaseEventInfo)fEventInfo1);
BaseEventInfo info2 = new BaseEventInfo((BaseEventInfo)fEventInfo2);
assertTrue("equals", fEventInfo2.equals(info2));
}
+ /**
+ * Test the .equals() method.
+ */
+ @Test
public void testEqualsTransivity() {
BaseEventInfo info1 = new BaseEventInfo((BaseEventInfo)fEventInfo1);
BaseEventInfo info2 = new BaseEventInfo((BaseEventInfo)fEventInfo1);
assertTrue("equals", info1.equals(info3));
}
+ /**
+ * Test the .equals() method.
+ */
+ @Test
public void testEqualsNull() {
assertTrue("equals", !fEventInfo1.equals(null));
assertTrue("equals", !fEventInfo2.equals(null));
// hashCode
// ------------------------------------------------------------------------
+ /**
+ * Test the hashCode() method.
+ */
+ @Test
public void testHashCode() {
BaseEventInfo info1 = new BaseEventInfo((BaseEventInfo)fEventInfo1);
BaseEventInfo info2 = new BaseEventInfo((BaseEventInfo)fEventInfo2);