Last part of bug 393449.
Split up some Sequence Diagram unit test methods in separate
test cases, now that we can use @BeforeClass.
Change-Id: I7416241ccb82b4825f6c790e655b276b5c1655ef
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Reviewed-on: https://git.eclipse.org/r/10119
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
IP-Clean: Patrick Tasse <patrick.tasse@gmail.com>
Tested-by: Hudson CI
/*******************************************************************************
- * Copyright (c) 2011, 2012 Ericsson
+ * Copyright (c) 2011-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
* Bernd Hufmann - Initial API and implementation
* Bernd Hufmann - Add UML2SD tests
* Mathieu Denis <mathieu.denis@polymtl.ca> - Add Statistics test
+ * Alexandre Montplaisir - Port to JUnit4
*******************************************************************************/
package org.eclipse.linuxtools.tmf.ui.tests;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
/**
- * <b><u>AllTmfUITests</u></b>
- *
* Master test suite for TMF UI Core.
*/
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ org.eclipse.linuxtools.tmf.ui.tests.histogram.AllTests.class,
+ org.eclipse.linuxtools.tmf.ui.tests.statistics.AllTests.class,
+ org.eclipse.linuxtools.tmf.ui.tests.views.uml2sd.dialogs.AllTests.class,
+ org.eclipse.linuxtools.tmf.ui.tests.views.uml2sd.load.AllTests.class,
+ org.eclipse.linuxtools.tmf.ui.tests.views.uml2sd.loader.AllTests.class
+})
public class AllTmfUITests {
- /**
- * @return the TMF UI test suite
- */
- public static Test suite() {
- TestSuite suite = new TestSuite(AllTmfUITests.class.getName());
- // $JUnit-BEGIN$
- suite.addTest(org.eclipse.linuxtools.tmf.ui.tests.statistics.AllTests.suite());
- suite.addTest(org.eclipse.linuxtools.tmf.ui.tests.views.uml2sd.dialogs.AllTests.suite());
- suite.addTest(org.eclipse.linuxtools.tmf.ui.tests.views.uml2sd.loader.AllTests.suite());
- suite.addTest(org.eclipse.linuxtools.tmf.ui.tests.views.uml2sd.load.AllTests.suite());
- suite.addTest(org.eclipse.linuxtools.tmf.ui.tests.histogram.AllTests.suite());
- // $JUnit-END$
- return suite;
- }
}
/*******************************************************************************
- * Copyright (c) 2011 Ericsson
+ * Copyright (c) 2011, 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.tmf.ui.tests.histogram;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
/**
- *
* Test suite class for histogram tests.
*/
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ HistogramDataModelTest.class
+})
public class AllTests {
- /**
- * @return the test suite
- */
- public static Test suite() {
-
- TestSuite suite = new TestSuite(AllTests.class.getName());
- //$JUnit-BEGIN$
- suite.addTestSuite(HistogramDataModelTest.class);
- //$JUnit-END$
- return suite;
- }
}
/*******************************************************************************
- * Copyright (c) 2011 Ericsson
+ * Copyright (c) 2011, 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:
* Francois Chouinard - Initial API and implementation
* Bernd Hufmann - Adapt to junit.framework.TestCase
+ * Alexandre Montplaisir - Port to JUnit4
*******************************************************************************/
package org.eclipse.linuxtools.tmf.ui.tests.histogram;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramDataModel;
import org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramScaledData;
import org.eclipse.linuxtools.tmf.ui.views.histogram.IHistogramModelListener;
+import org.junit.Test;
/**
- *
* Unit tests for the HistogramDataModel class.
*/
-public class HistogramDataModelTest extends TestCase {
-
- // ------------------------------------------------------------------------
- // Test data
- // ------------------------------------------------------------------------
+public class HistogramDataModelTest {
- // ------------------------------------------------------------------------
- // Housekeeping
- // ------------------------------------------------------------------------
-
- @Override
- public void setUp() throws Exception {
- }
-
- @Override
- public void tearDown() throws Exception {
- }
-
- // ------------------------------------------------------------------------
- // Tests
- // ------------------------------------------------------------------------
+ private static final double DELTA = 1e-15;
/**
- * Test method for
- * {@link org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramDataModel#HistogramDataModel()}
- * .
+ * Test method for {@link HistogramDataModel#HistogramDataModel()}.
*/
+ @Test
public void testHistogramDataModel() {
HistogramDataModel model = new HistogramDataModel();
assertTrue(model.getNbBuckets() == HistogramDataModel.DEFAULT_NUMBER_OF_BUCKETS);
}
/**
- * Test method for
- * {@link org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramDataModel#HistogramDataModel(int)}
- * .
+ * Test method for {@link HistogramDataModel#HistogramDataModel(int)}.
*/
+ @Test
public void testHistogramDataModelInt() {
final int nbBuckets = 5 * 1000;
HistogramDataModel model = new HistogramDataModel(nbBuckets);
}
/**
- * Test methods for
- * {@link org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramDataModel#countEvent(long,long)}
- * .
+ * Test methods for {@link HistogramDataModel#countEvent(long,long)}.
*/
+ @Test
public void testClear() {
final int nbBuckets = 100;
HistogramDataModel model = new HistogramDataModel(nbBuckets);
}
/**
- * Test methods for
- * {@link org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramDataModel#countEvent(long,long)}
- * .
+ * Test methods for {@link HistogramDataModel#countEvent(long,long)}.
*/
+ @Test
public void testCountEvent_0() {
final int nbBuckets = 100;
HistogramDataModel model = new HistogramDataModel(nbBuckets);
}
/**
- * Test methods for
- * {@link org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramDataModel#countEvent(long,long)}
- * {@link org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramDataModel#scaleTo(int,int,int)}
- * .
+ * Test methods for {@link HistogramDataModel#countEvent(long,long)} and
+ * {@link HistogramDataModel#scaleTo(int,int,int)}.
*/
+ @Test
public void testCountEvent_1() {
-
final int nbBuckets = 100;
final int maxHeight = 10;
}
/**
- * Test methods for
- * {@link org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramDataModel#countEvent(long,long)}
- * {@link org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramDataModel#scaleTo(int,int,int)}
- * .
+ * Test methods for {@link HistogramDataModel#countEvent(long,long)} and
+ * {@link HistogramDataModel#scaleTo(int,int,int)}.
*/
+ @Test
public void testCountEvent_2() {
final int nbBuckets = 100;
final int maxHeight = 10;
}
/**
- * Test methods for
- * {@link org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramDataModel#countEvent(long,long)}
- * {@link org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramDataModel#scaleTo(int,int,int)}
- * .
+ * Test methods for {@link HistogramDataModel#countEvent(long,long)} and
+ * {@link HistogramDataModel#scaleTo(int,int,int)}.
*/
+ @Test
public void testCountEvent_3() {
final int nbBuckets = 100;
final int maxHeight = 10;
}
/**
- * Test methods for
- * {@link org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramDataModel#countEvent(long,long)}
- * {@link org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramDataModel#scaleTo(int,int,int)}
- * .
+ * Test methods for {@link HistogramDataModel#countEvent(long,long)} and
+ * {@link HistogramDataModel#scaleTo(int,int,int)}.
*/
+ @Test
public void testCountEvent_4() {
final int nbBuckets = 100;
final int maxHeight = 10;
}
/**
- * Test methods for
- * {@link org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramDataModel#countEvent(long,long)}
- * {@link org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramDataModel#scaleTo(int,int,int)}
- * .
+ * Test methods for {@link HistogramDataModel#countEvent(long,long)} and
+ * {@link HistogramDataModel#scaleTo(int,int,int)}.
*/
+ @Test
public void testCountEvent_5() {
final int nbBuckets = 100;
final int startTime = 25;
}
/**
- * Test method for
- * {@link org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramDataModel#scaleTo(int,int,int)}
- * .
+ * Test method for {@link HistogramDataModel#scaleTo(int,int,int)}.
*/
+ @Test
public void testScaleTo_0() {
HistogramDataModel model = new HistogramDataModel(10);
try {
}
}
}
-
fail("Uncaught assertion error"); //$NON-NLS-1$
}
/**
- * Test method for
- * {@link org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramDataModel#scaleTo(int,int,int)}
- * .
+ * Test method for {@link HistogramDataModel#scaleTo(int,int,int)}.
*/
+ @Test
public void testScaleTo_1() {
final int nbBuckets = 10;
final int maxHeight = 10;
}
/**
- * Test method for
- * {@link org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramDataModel#scaleTo(int,int,int)}
- * .
+ * Test method for {@link HistogramDataModel#scaleTo(int,int,int)}.
*/
+ @Test
public void testScaleTo_2() {
final int nbBuckets = 10;
final int maxHeight = 10;
}
/**
- * Test method for
- * {@link org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramDataModel#scaleTo(int,int,int)}
- * .
+ * Test method for {@link HistogramDataModel#scaleTo(int,int,int)}.
*/
+ @Test
public void testScaleTo_3() {
final int nbBuckets = 10;
final int maxHeight = 10;
}
/**
- * Test method for
- * {@link org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramDataModel#scaleTo(int,int,int)}
- * .
+ * Test method for {@link HistogramDataModel#scaleTo(int,int,int)}.
*/
+ @Test
public void testScaleTo_4() {
final int nbBuckets = 10;
final int maxHeight = 10;
}
/**
- * Test method for
- * {@link org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramDataModel#scaleTo(int,int,int)}
- * .
+ * Test method for {@link HistogramDataModel#scaleTo(int,int,int)}.
*/
+ @Test
public void testScaleTo_5() {
final int nbBuckets = 100;
final int maxHeight = 20;
}
/**
- * Test method for
- * {@link org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramDataModel#scaleTo(int,int,int)}
- * .
+ * Test method for {@link HistogramDataModel#scaleTo(int,int,int)}.
*/
+ @Test
public void testScaleTo_6() {
final int nbBuckets = 100;
final int maxHeight = 24;
}
/**
- * Test method for
- * {@link org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramDataModel#scaleTo(int,int,int)}
- * .
+ * Test method for {@link HistogramDataModel#scaleTo(int,int,int)}.
*/
+ @Test
public void testScaleTo_7() {
// verify scaleTo with barWidth > 1
final int nbBuckets = 100;
assertEquals(0, result.fFirstEventTime);
assertEquals(1, result.fLastBucket);
assertEquals(104, result.fMaxValue);
- assertEquals((double)maxHeight/104, result.fScalingFactor);
+ assertEquals((double)maxHeight/104, result.fScalingFactor, DELTA);
assertEquals(maxHeight, result.fHeight);
assertEquals(width, result.fWidth);
assertEquals(barWidth, result.fBarWidth);
}
/**
- * Test method for
- * {@link org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramDataModel#scaleTo(int,int,int)}
- * .
+ * Test method for {@link HistogramDataModel#scaleTo(int,int,int)}.
*/
+ @Test
public void testScaleToReverse_1() {
final int nbBuckets = 100;
final int maxHeight = 24;
assertEquals(0, result.fFirstEventTime);
assertEquals(9, result.fLastBucket);
assertEquals(24, result.fMaxValue);
- assertEquals((double)maxHeight/24, result.fScalingFactor);
+ assertEquals((double)maxHeight/24, result.fScalingFactor, DELTA);
assertEquals(maxHeight, result.fHeight);
assertEquals(width, result.fWidth);
assertEquals(barWidth, result.fBarWidth);
}
/**
- * Test method for
- * {@link org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramDataModel#scaleTo(int,int,int)}
- * .
+ * Test method for {@link HistogramDataModel#scaleTo(int,int,int)}.
*/
+ @Test
public void testScaleToReverse_2() {
final int nbBuckets = 100;
final int maxHeight = 24;
assertEquals(result.fCurrentBucket, revResult.fCurrentBucket);
assertEquals(result.fFirstBucketTime, revResult.fFirstBucketTime);
assertEquals(result.fMaxValue, revResult.fMaxValue);
- assertEquals(result.fScalingFactor, revResult.fScalingFactor);
+ assertEquals(result.fScalingFactor, revResult.fScalingFactor, DELTA);
assertEquals(result.fLastBucket, revResult.fLastBucket);
assertEquals(result.getBucketEndTime(0), revResult.getBucketEndTime(0));
assertEquals(result.getBucketStartTime(0), revResult.getBucketStartTime(0));
/**
* Test method for testing model listener.
*/
+ @Test
public void testModelListener() {
final int nbBuckets = 2000;
final int nbEvents = 10 * nbBuckets + 256;
/*******************************************************************************
- * Copyright (c) 2011 Ericsson
+ * Copyright (c) 2011, 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:
* Mathieu Denis <mathieu.denis@polymtl.ca> - Initial API and Implementation
* Bernd Hufmann - Fixed suite name
+ * Alexandre Montplaisir - Port to JUnit4
*******************************************************************************/
-package org.eclipse.linuxtools.tmf.ui.tests.statistics;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+package org.eclipse.linuxtools.tmf.ui.tests.statistics;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
/**
* Test suite for statistic tests.
*/
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ TmfBaseColumnDataProviderTest.class,
+ TmfBaseColumnDataTest.class,
+ TmfBaseStatisticsDataTest.class,
+ TmfStatisticsTest.class,
+ TmfStatisticsTreeNodeTest.class,
+ TmfStatisticsTreeManagerTest.class,
+ TmfTreeContentProviderTest.class
+})
public class AllTests {
- /**
- * @return the test suite
- */
- public static Test suite() {
- TestSuite suite = new TestSuite(AllTests.class.getName());
- // $JUnit-BEGIN$
- suite.addTestSuite(TmfBaseColumnDataProviderTest.class);
- suite.addTestSuite(TmfBaseColumnDataTest.class);
- suite.addTestSuite(TmfBaseStatisticsDataTest.class);
- suite.addTestSuite(TmfStatisticsTreeNodeTest.class);
- suite.addTestSuite(TmfStatisticsTreeManagerTest.class);
- suite.addTestSuite(TmfTreeContentProviderTest.class);
- suite.addTestSuite(TmfStatisticsTest.class);
- // $JUnit-END$
- return suite;
- }
}
/*******************************************************************************
- * Copyright (c) 2011 Ericsson
+ * Copyright (c) 2011, 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:
* Mathieu Denis <mathieu.denis@polymtl.ca> - Initial API and Implementation
* Bernd Hufmann - Fixed header and warnings
+ * Alexandre Montplaisir - Port to JUnit4
*******************************************************************************/
+
package org.eclipse.linuxtools.tmf.ui.tests.statistics;
-import java.util.List;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
-import junit.framework.TestCase;
+import java.util.List;
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfBaseColumnDataProvider;
import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfStatisticsTree;
import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfStatisticsTreeNode;
+import org.junit.Test;
/**
* TmfBaseColumnDataProvider test cases.
*/
@SuppressWarnings("nls")
-public class TmfBaseColumnDataProviderTest extends TestCase {
+public class TmfBaseColumnDataProviderTest {
// ------------------------------------------------------------------------
// Fields
// ------------------------------------------------------------------------
+
+ private static final double DELTA = 1e-15;
+
private final static String LEVEL_COLUMN = Messages.TmfStatisticsView_LevelColumn;
private final static String EVENTS_COUNT_COLUMN = Messages.TmfStatisticsView_NbEventsColumn;
private TmfBaseColumnDataProvider provider;
- private String fTestName;
+ private static final String fTestName = "ColumnDataProviderTest";
private final String fContext = "UnitTest";
/**
* Constructor
- * @param name trace name to set
*/
- public TmfBaseColumnDataProviderTest(final String name) {
- super(name);
-
- fTestName = name;
-
+ public TmfBaseColumnDataProviderTest() {
fContent1 = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, "Some content");
fEvent1 = new TmfEvent(null, fTimestamp1, fSource, fType1, fContent1, fReference);
// ------------------------------------------------------------------------
// Get Column Data
// ------------------------------------------------------------------------
+
/**
* Method with test cases.
*/
+ @Test
public void testGetColumnData() {
List<TmfBaseColumnData> columnsData = provider.getColumnData();
assertNotNull("getColumnData", columnsData);
assertNull("getColumnData", percentProvider);
} else if (columnData.getHeader().compareTo(EVENTS_COUNT_COLUMN) == 0) {
double percentage = (double) treeNode1.getValues().getTotal() / parentNode.getValues().getTotal();
- assertEquals("getColumnData", percentage, percentProvider.getPercentage(treeNode1));
+ assertEquals("getColumnData", percentage, percentProvider.getPercentage(treeNode1), DELTA);
}
}
}
/*******************************************************************************
- * Copyright (c) 2011 Ericsson
+ * Copyright (c) 2011, 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:
* Mathieu Denis <mathieu.denis@polymtl.ca> - Initial design and implementation
+ * Alexandre Montplaisir - Port to JUnit4
*******************************************************************************/
package org.eclipse.linuxtools.tmf.ui.tests.statistics;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
+import org.junit.Before;
+import org.junit.Test;
/**
* TmfBaseColumnData Test Case.
*/
@SuppressWarnings("nls")
-public class TmfBaseColumnDataTest extends TestCase {
+public class TmfBaseColumnDataTest {
// ------------------------------------------------------------------------
// Fields
// Housekeeping
// ------------------------------------------------------------------------
- private void init() {
+ /**
+ * Pre-test setup
+ */
+ @Before
+ public void init() {
fHeader = "test Column1";
fWidth = 300;
fAlignment = SWT.LEFT;
fBaseColumnData = new TmfBaseColumnData(fHeader, fWidth, fAlignment, fToolTip, fLabelProvider, fComparator, fPercentageProvider);
}
- @Override
- public void setUp() throws Exception {
- super.setUp();
- init();
- }
-
- @Override
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
// ------------------------------------------------------------------------
- // getHeader
+ // Test methods
// ------------------------------------------------------------------------
/**
* Test get header
*/
+ @Test
public void testGetHeader() {
assertEquals("getHeader", 0, fBaseColumnData.getHeader().compareTo(fHeader));
}
- // ------------------------------------------------------------------------
- // getWidth
- // ------------------------------------------------------------------------
-
/**
* Test getting of column width.
*/
+ @Test
public void testGetWidth() {
assertEquals("getWidth", fWidth, fBaseColumnData.getWidth());
}
- // ------------------------------------------------------------------------
- // getAlignment
- // ------------------------------------------------------------------------
-
/**
* Test getting of alignment value
*/
+ @Test
public void testGetAlignment() {
assertEquals("getAlignment", fAlignment, fBaseColumnData.getAlignment());
}
- // ------------------------------------------------------------------------
- // getToolTip
- // ------------------------------------------------------------------------
-
/**
* Test getting of tooltip.
*/
+ @Test
public void testGetTooltip() {
assertEquals("getTooltip", fToolTip, fBaseColumnData.getTooltip());
}
- // ------------------------------------------------------------------------
- // getLabelProvider
- // ------------------------------------------------------------------------
-
/**
* Test getting of label provider
*/
+ @Test
public void testGetLabelProvider() {
assertEquals("getLabelProvider", 0, fBaseColumnData.getLabelProvider().getText(fTreeNode).compareTo(fLabelProvider.getText(fTreeNode)));
assertTrue("getLabelProvider", fBaseColumnData.getLabelProvider().getImage(fTreeNode).equals(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_ELEMENT)));
assertTrue("getLabelProvider", fBaseColumnData.getLabelProvider().equals(fLabelProvider));
}
- // ------------------------------------------------------------------------
- // getComparator
- // ------------------------------------------------------------------------
-
/**
* Test getting of comparator.
*/
+ @Test
public void testGetComparator() {
assertTrue("getComparator", fBaseColumnData.getComparator().equals(fComparator));
}
- // ------------------------------------------------------------------------
- // getPercentageProvider
- // ------------------------------------------------------------------------
-
/**
* Test getting of percentage provider.
*/
+ @Test
public void testGetPercentageProvider() {
assertTrue("getPercentageProvider", fBaseColumnData.getPercentageProvider().equals(fPercentageProvider));
}
/*******************************************************************************
- * Copyright (c) 2011 Ericsson
+ * Copyright (c) 2011, 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:
* Mathieu Denis <mathieu.denis@polymtl.ca> - Initial design and implementation
* Bernd Hufmann - Fixed warnings
+ * Alexandre Montplaisir - Port to JUnit4
*******************************************************************************/
package org.eclipse.linuxtools.tmf.ui.tests.statistics;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.Vector;
-import junit.framework.TestCase;
-
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.Messages;
import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfStatisticsTree;
import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfStatisticsTreeNode;
+import org.junit.Test;
/**
* TmfBaseStatistics Test Cases.
*/
@SuppressWarnings("nls")
-public class TmfBaseStatisticsDataTest extends TestCase {
+public class TmfBaseStatisticsDataTest {
// ------------------------------------------------------------------------
// Fields
// ------------------------------------------------------------------------
- private String fTestName = null;
+
+ private static final String fTestName = "StatisticsDataTest";
private final String fContext = "UnitTest";
private final String fTypeId1 = "Some type1";
// ------------------------------------------------------------------------
/**
- * @param name
- * Test name
+ * Constructor
*/
- public TmfBaseStatisticsDataTest(final String name) {
- super(name);
-
- fTestName = name;
-
+ public TmfBaseStatisticsDataTest() {
fContent1 = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, "Some content");
fEvent1 = new TmfEvent(null, fTimestamp1, fSource, fType1, fContent1, fReference);
}
// ------------------------------------------------------------------------
- // GetChildren
+ // Test methods
// ------------------------------------------------------------------------
/**
* Test getting of children.
*/
+ @Test
public void testGetChildren() {
// Getting children of the ROOT
Collection<TmfStatisticsTreeNode> childrenTreeNode = fStatsTree.getRootNode().getChildren();
assertEquals("getChildren", 0, childrenTreeNode.size());
}
- // ------------------------------------------------------------------------
- // RegisterEvent
- // ------------------------------------------------------------------------
-
/**
* Test registering of events.
*/
+ @Test
public void testRegisterEvent() {
TmfStatisticsTreeNode trace = fStatsTree.getNode(fTestName);
assertEquals("registerEvent", 3, trace.getValues().getTotal());
}
}
- // ------------------------------------------------------------------------
- // Get a node
- // ------------------------------------------------------------------------
-
/**
* Test getter.
*/
+ @Test
public void testGet() {
TmfStatisticsTreeNode traceRoot = fStatsTree.getNode(fTestName);
assertNotNull("get", traceRoot);
assertEquals("get", 1, traceRoot.getNbChildren());
}
- // ------------------------------------------------------------------------
- // GetOrCreate
- // ------------------------------------------------------------------------
-
/**
* Test getting or creating of node entries.
*/
+ @Test
public void testGetOrCreate() {
String[] newEventType = new String[] { fTestName, Messages.TmfStatisticsData_EventTypes, "Fancy Type" };
TmfStatisticsTreeNode newEventTypeNode;
assertTrue(Arrays.equals(newEventType, newEventTypeNode.getPath()));
}
- // ------------------------------------------------------------------------
- // GetParent
- // ------------------------------------------------------------------------
-
/**
* Test getting of parent node.
*/
+ @Test
public void testGetParent() {
TmfStatisticsTreeNode parentNode = fStatsTree.getRootNode().getParent();
assertNull(parentNode);
assertEquals(parentNode.getPath().toString(), fStatsTree.getNode(fTestName).getPath().toString());
}
- // ------------------------------------------------------------------------
- // Reset
- // ------------------------------------------------------------------------
-
/**
* Test reset method
*/
+ @Test
public void testReset() {
fStatsTree.getNode(fTestName, Messages.TmfStatisticsData_EventTypes).reset();
+/*******************************************************************************
+ * Copyright (c) 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
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexandre Montplaisir - Port to JUnit4
+ *******************************************************************************/
+
package org.eclipse.linuxtools.tmf.ui.tests.statistics;
-import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfStatisticsValues;
+import static org.junit.Assert.assertEquals;
-import junit.framework.TestCase;
+import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfStatisticsValues;
+import org.junit.Test;
/**
* TmfStatistics Test Cases.
*/
-public class TmfStatisticsTest extends TestCase {
+public class TmfStatisticsTest {
- // ------------------------------------------------------------------------
- // Fields
- // ------------------------------------------------------------------------
-
- TmfStatisticsValues stats = new TmfStatisticsValues();
-
- // ------------------------------------------------------------------------
- // Checks initial state
- // ------------------------------------------------------------------------
+ private TmfStatisticsValues stats = new TmfStatisticsValues();
/**
* Test the initial state of the counters
*/
+ @Test
public void testInitialState() {
assertEquals(0, stats.getTotal());
assertEquals(0, stats.getPartial());
}
- // ------------------------------------------------------------------------
- // Increment Total no parameter
- // ------------------------------------------------------------------------
-
/**
* Test incrementing the total counter by an amount
*/
+ @Test
public void testSetValue() {
final int i = 100;
/**
* Test of the reset for the total counter
*/
+ @Test
public void testResetTotal() {
stats.setValue(true, 123);
assertEquals(123, stats.getTotal());
/**
* Test of the reset for the partial counter
*/
+ @Test
public void testResetPartial() {
stats.setValue(false, 456);
assertEquals(456, stats.getPartial());
/*******************************************************************************
- * Copyright (c) 2011 Ericsson
+ * Copyright (c) 2011, 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:
* Mathieu Denis <mathieu.denis@polymtl.ca> - Initial design and implementation
* Bernd Hufmann - Fixed warnings
+ * Alexandre Montplaisir - Port to JUnit4
*******************************************************************************/
package org.eclipse.linuxtools.tmf.ui.tests.statistics;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfStatisticsTree;
import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfStatisticsTreeManager;
import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfStatisticsTreeNode;
+import org.junit.Before;
+import org.junit.Test;
/**
* TmfStatisticsTreeRootFactory Test Case.
*/
@SuppressWarnings("nls")
-public class TmfStatisticsTreeManagerTest extends TestCase {
+public class TmfStatisticsTreeManagerTest {
// ------------------------------------------------------------------------
// Fields
// ------------------------------------------------------------------------
- TmfStatisticsTree fStatisticsData1;
- TmfStatisticsTree fStatisticsData2;
- TmfStatisticsTree fStatisticsData3;
- String fDataKey1 = "key1";
- String fDataKey2 = "key2";
- String fDataKey3 = "key3";
+ private TmfStatisticsTree fStatisticsData1;
+ private TmfStatisticsTree fStatisticsData2;
+ private TmfStatisticsTree fStatisticsData3;
+ private String fDataKey1 = "key1";
+ private String fDataKey2 = "key2";
+ private String fDataKey3 = "key3";
+
// ------------------------------------------------------------------------
// Housekeeping
// ------------------------------------------------------------------------
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- addStatsTreeRoot();
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
/**
- * Adding of statistics tree root.
+ * Initialization
*/
- public void addStatsTreeRoot() {
+ @Before
+ public void setUp() {
fStatisticsData1 = new TmfStatisticsTree();
fStatisticsData2 = new TmfStatisticsTree();
fStatisticsData3 = new TmfStatisticsTree();
/**
* Clean the statistics tree
*/
- public void removeStatsTreeRoot() {
+ private static void removeStatsTreeRoot() {
TmfStatisticsTreeManager.removeAll();
}
/**
* Test adding of statistics tree root. It should not throw exceptions
*/
+ @Test
public void testaddStatsTreeRoot() {
removeStatsTreeRoot();
/**
* Test getting of statistics tree root.
*/
+ @Test
public void testGetStatTreeRoot() {
TmfStatisticsTreeNode value1 = TmfStatisticsTreeManager.getStatTreeRoot(fDataKey1);
TmfStatisticsTreeNode value2 = TmfStatisticsTreeManager.getStatTreeRoot(fDataKey2);
/**
* Test getting statistics tree.
*/
+ @Test
public void testGetStatTree() {
TmfStatisticsTree value1 = TmfStatisticsTreeManager.getStatTree(fDataKey1);
TmfStatisticsTree value2 = TmfStatisticsTreeManager.getStatTree(fDataKey2);
/**
* Test checking for tree root existence.
*/
+ @Test
public void testContainsTreeRoot() {
assertTrue("containsTreeRoot", TmfStatisticsTreeManager.containsTreeRoot(fDataKey1));
assertTrue("containsTreeRoot", TmfStatisticsTreeManager.containsTreeRoot(fDataKey2));
/**
* Test removal of statistics tree node.
*/
+ @Test
public void testRemoveStatTreeRoot() {
TmfStatisticsTreeManager.removeStatTreeRoot(fDataKey1);
assertNull("removeStatTreeRoot", TmfStatisticsTreeManager.getStatTree(fDataKey1));
/**
* Test removal of all root nodes.
*/
+ @Test
public void testRemoveAll() {
TmfStatisticsTreeManager.removeAll();
assertNull("removeAll", TmfStatisticsTreeManager.getStatTreeRoot(fDataKey2));
/*******************************************************************************
- * Copyright (c) 2011 Ericsson
+ * Copyright (c) 2011, 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:
* Mathieu Denis <mathieu.denis@polymtl.ca> - Initial design and implementation
* Bernd Hufmann - Fixed warnings
+ * Alexandre Montplaisir - Port to JUnit4
*******************************************************************************/
package org.eclipse.linuxtools.tmf.ui.tests.statistics;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.util.Collection;
import java.util.Iterator;
import java.util.Vector;
-import junit.framework.TestCase;
-
import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.Messages;
import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfStatisticsTree;
import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfStatisticsTreeNode;
+import org.junit.Test;
/**
* TmfStatisticsTreeNode Test Cases.
*/
-public class TmfStatisticsTreeNodeTest extends TestCase {
+public class TmfStatisticsTreeNodeTest {
// ------------------------------------------------------------------------
// Fields
private final TmfStatisticsTree fStatsTree;
- private String fTestName = null;
+ private static final String fTestName = "StatisticsTreeNodeTest"; //$NON-NLS-1$
// ------------------------------------------------------------------------
// Housekeeping
// ------------------------------------------------------------------------
/**
- * @param name
- * Test name
+ * Constructor
*/
- public TmfStatisticsTreeNodeTest(final String name) {
- super(name);
-
- fTestName = name;
+ public TmfStatisticsTreeNodeTest() {
fStatsTree = new TmfStatisticsTree();
/* Enter some global values */
fStatsTree.setTypeCount(fTestName, fTypeId3, false, 4);
}
- // ------------------------------------------------------------------------
- // ContainsChild
- // ------------------------------------------------------------------------
-
/**
* Test checking for child.
*/
+ @Test
public void testContainsChild() {
TmfStatisticsTreeNode rootNode = fStatsTree.getRootNode();
TmfStatisticsTreeNode traceNode = fStatsTree.getNode(fTestName);
assertFalse(catNode.containsChild(null));
}
- // ------------------------------------------------------------------------
- // GetChildren
- // ------------------------------------------------------------------------
-
/**
* Test getting of children.
*/
+ @Test
public void testGetChildren() {
// Getting children of the ROOT
Collection<TmfStatisticsTreeNode> childrenTreeNode = fStatsTree.getRootNode().getChildren();
assertEquals(0, childrenTreeNode.size());
}
- // ------------------------------------------------------------------------
- // GetNbChildren
- // ------------------------------------------------------------------------
-
/**
* Test getting of number of children.
*/
+ @Test
public void testGetNbChildren() {
TmfStatisticsTreeNode rootNode = fStatsTree.getRootNode();
TmfStatisticsTreeNode traceNode = fStatsTree.getNode(fTestName);
assertEquals(0, elementNode.getNbChildren());
}
- // ------------------------------------------------------------------------
- // HasChildren
- // ------------------------------------------------------------------------
-
/**
* Test checking for children.
*/
+ @Test
public void testHasChildren() {
TmfStatisticsTreeNode rootNode = fStatsTree.getRootNode();
TmfStatisticsTreeNode traceNode = fStatsTree.getNode(fTestName);
assertFalse(elementNode.hasChildren());
}
- // ------------------------------------------------------------------------
- // GetParent
- // ------------------------------------------------------------------------
-
/**
* Test getting of parent.
*/
+ @Test
public void testGetParent() {
final TmfStatisticsTreeNode rootNode = fStatsTree.getRootNode();
TmfStatisticsTreeNode parentNode = rootNode.getParent();
assertTrue(arraysEqual(parentNode.getPath(), fTestName, Messages.TmfStatisticsData_EventTypes));
}
- // ------------------------------------------------------------------------
- // GetKey
- // ------------------------------------------------------------------------
-
/**
* Test getting of key.
*/
+ @Test
public void testgetName() {
TmfStatisticsTreeNode rootNode = fStatsTree.getRootNode();
TmfStatisticsTreeNode traceNode = fStatsTree.getNode(fTestName);
assertEquals(0, elementNode.getName().compareTo(fTypeId1));
}
- // ------------------------------------------------------------------------
- // GetPath
- // ------------------------------------------------------------------------
-
/**
* Test getting of path to node.
*/
+ @Test
public void testGetPath() {
TmfStatisticsTreeNode rootNode = fStatsTree.getRootNode();
TmfStatisticsTreeNode traceNode = fStatsTree.getNode(fTestName);
fTestName, Messages.TmfStatisticsData_EventTypes, fTypeId1));
}
- // ------------------------------------------------------------------------
- // GetValue
- // ------------------------------------------------------------------------
-
/**
* Test getting statistic value.
*/
+ @Test
public void testGetValue() {
TmfStatisticsTreeNode rootNode, traceNode, catNode, elementNode1, elementNode2, elementNode3;
rootNode = fStatsTree.getRootNode();
assertEquals(4, elementNode3.getValues().getPartial());
}
- // ------------------------------------------------------------------------
- // Reset
- // ------------------------------------------------------------------------
-
/**
* Test reset of tree.
*/
+ @Test
public void testReset() {
TmfStatisticsTreeNode rootNode, traceNode, catNode, elementNode;
rootNode = fStatsTree.getRootNode();
* Test reset global value of the node in the tree. It should only clear
* the global value without removing any node from the tree.
*/
+ @Test
public void testResetGlobalValue() {
TmfStatisticsTreeNode rootNode, traceNode, catNode, eventTypeNode1, eventTypeNode2, eventTypeNode3;
rootNode = fStatsTree.getRootNode();
* Test reset time range value of the node in the tree. It should only clear
* the time range value without removing any node from the tree.
*/
+ @Test
public void testResetTimeRangeValue() {
TmfStatisticsTreeNode rootNode, traceNode, catNode, eventTypeNode1, eventTypeNode2, eventTypeNode3;
rootNode = fStatsTree.getRootNode();
/*******************************************************************************
- * Copyright (c) 2011 Ericsson
+ * Copyright (c) 2011, 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:
* Mathieu Denis <mathieu.denis@polymtl.ca> - Initial design and implementation
* Bernd Hufmann - Fixed warnings
+ * Alexandre Montplaisir - Port to JUnit4
*******************************************************************************/
package org.eclipse.linuxtools.tmf.ui.tests.statistics;
-import java.util.Arrays;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
-import junit.framework.TestCase;
+import java.util.Arrays;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfStatisticsTree;
import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfStatisticsTreeNode;
import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfTreeContentProvider;
+import org.junit.Test;
/**
* TmfTreeContentProvider Test Cases.
*/
@SuppressWarnings("nls")
-public class TmfTreeContentProviderTest extends TestCase {
+public class TmfTreeContentProviderTest {
// ------------------------------------------------------------------------
// Fields
// ------------------------------------------------------------------------
- private String fTestName = null;
+ private static final String fTestName = "TreeContentProviderTest";
private final String fContext = "UnitTest";
private final String fTypeId1 = "Some type1";
// ------------------------------------------------------------------------
/**
- * @param name
- * of the test
+ * Constructor
*/
- public TmfTreeContentProviderTest(final String name) {
- super(name);
-
- fTestName = name;
-
+ public TmfTreeContentProviderTest() {
fContent1 = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, "Some content");
fEvent1 = new TmfEvent(null, fTimestamp1, fSource, fType1, fContent1, fReference);
}
// ------------------------------------------------------------------------
- // GetChildren
+ // Test methods
// ------------------------------------------------------------------------
/**
* FIXME this test was quickly adapted when we removed the TmfFixedArray,
* but it could be rewritten to be much more simple...
*/
+ @Test
public void testGetChildren() {
Object[] objectArray = treeProvider.getChildren(fStatsData.getOrCreateNode(fTestName, Messages.TmfStatisticsData_EventTypes));
TmfStatisticsTreeNode[] childrenNode = Arrays.asList(objectArray).toArray(new TmfStatisticsTreeNode[0]);
return true;
}
- // ------------------------------------------------------------------------
- // GetParent
- // ------------------------------------------------------------------------
-
/**
* Test getting of parent.
*/
+ @Test
public void testGetParent() {
TmfStatisticsTreeNode parent = (TmfStatisticsTreeNode) treeProvider.getParent(fStatsData.getNode(fTestName));
assertTrue("getParent", parent.getPath().equals(fStatsData.getRootNode().getPath()));
}
- // ------------------------------------------------------------------------
- // HasChildren
- // ------------------------------------------------------------------------
/**
* Test checking for children.
*/
+ @Test
public void testHasChildren() {
Boolean hasChildren = treeProvider.hasChildren(fStatsData.getRootNode());
assertTrue("hasChildren", hasChildren);
assertFalse("hasChildren", hasChildren);
}
- // ------------------------------------------------------------------------
- // GetElements
- // ------------------------------------------------------------------------
-
/**
* Test getting of elements.
*/
+ @Test
public void testGetElements() {
Object[] objectElements = treeProvider.getElements(fStatsData.getRootNode());
TmfStatisticsTreeNode[] nodeElements = Arrays.asList(objectElements).toArray(new TmfStatisticsTreeNode[0]);
/*******************************************************************************
- * Copyright (c) 2011, 2012 Ericsson
+ * Copyright (c) 2011-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.tmf.ui.tests.views.uml2sd.dialogs;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
/**
* Test suite of UML2SD dialog tests.
*/
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ CriteriaTest.class
+})
public class AllTests {
- /**
- * @return the test suite of UML2SD dialog tests
- */
- public static Test suite() {
-
- TestSuite suite = new TestSuite(AllTests.class.getName());
- //$JUnit-BEGIN$
- suite.addTestSuite(CriteriaTest.class);
- //$JUnit-END$
- return suite;
- }
}
/*******************************************************************************
- * Copyright (c) 2011, 2012 Ericsson
+ * Copyright (c) 2011-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.tmf.ui.tests.views.uml2sd.dialogs;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
import java.util.List;
import java.util.regex.Pattern;
-import junit.framework.TestCase;
-
import org.eclipse.jface.dialogs.DialogSettings;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.dialogs.Criteria;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDFilterProvider;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDGraphNodeSupporter;
+import org.junit.Test;
/**
* Test cases to test Criteria class.
*/
@SuppressWarnings("nls")
-public class CriteriaTest extends TestCase {
-
- @Override
- public void setUp() throws Exception {
- }
-
- @Override
- public void tearDown() throws Exception {
- }
+public class CriteriaTest {
/**
* Test default constructor.
*/
+ @Test
public void testCriteria() {
Criteria criteria = new Criteria();
assertFalse("testCriteria", criteria.isAsyncMessageReturnSelected());
/**
* Test copy constructor.
*/
+ @Test
public void testCriteriaCriteria() {
Criteria criteria = new Criteria();
criteria.setExpression("test");
/**
* Test accessor methods.
*/
+ @Test
public void testAccessors() {
Criteria criteria = new Criteria();
criteria.setAsyncMessageReturnSelected(true);
/**
* Test compartTo method.
*/
+ @Test
public void testCompareTo() {
Criteria criteria = new Criteria();
criteria.setExpression("test");
/**
* Test save to disk.
*/
+ @Test
public void testSave() {
DialogSettings settings = new DialogSettings("mysettings");
/**
* Test restore from disk.
*/
+ @Test
public void testLoad() {
DialogSettings settings = new DialogSettings("mysettings");
/**
* Test graph node summary usage.
*/
+ @Test
public void testGetGraphNodeSummary() {
// Create a dummy provider
/**
* Test matches algorithm.
*/
+ @Test
public void testMatches() {
Criteria criteria = new Criteria();
criteria.setExpression("BALL_.*");
/*******************************************************************************
- * Copyright (c) 2011 Ericsson
+ * Copyright (c) 2011, 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.tmf.ui.tests.views.uml2sd.load;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
/**
* Test suite for testing loader manager of UML2SD extension point.
*/
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ LoadersManagerTest.class
+})
public class AllTests {
- /**
- * @return the test suite.
- */
- public static Test suite() {
-
- TestSuite suite = new TestSuite(AllTests.class.getName());
- //$JUnit-BEGIN$
- suite.addTestSuite(LoadersManagerTest.class);
- //$JUnit-END$
- return suite;
- }
}
/**********************************************************************
- * Copyright (c) 2011 Ericsson.
+ * Copyright (c) 2011, 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 accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Bernd Hufmann - Initial API and implementation
+ * Bernd Hufmann - Initial API and implementation
+ * Alexandre Montplaisir - Port to JUnit4
**********************************************************************/
+
package org.eclipse.linuxtools.tmf.ui.tests.views.uml2sd.load;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.linuxtools.internal.tmf.ui.Activator;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDView;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.load.IUml2SDLoader;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.load.LoadersManager;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;
+import org.junit.Test;
/**
* Test cases class to test loader manager of UML2SD extension point.
*/
-public class LoadersManagerTest extends TestCase {
-
- private final static String SDVIEW_WITH_ONE_LOADER = "org.eclipse.linuxtools.tmf.ui.tests.testSDView1Loader"; //$NON-NLS-1$
- private final static String SDVIEW_WITH_MULTIPLE_LOADER = "org.eclipse.linuxtools.tmf.ui.tests.testSDView2Loaders"; //$NON-NLS-1$
- private final static String TEST_LOADER_CLASS_NAME = "org.eclipse.linuxtools.tmf.ui.tests.uml2sd.load.TestLoaders"; //$NON-NLS-1$
- private final static String TMF_UML2SD_LOADER_CLASS_NAME = "org.eclipse.linuxtools.tmf.ui.views.uml2sd.loader.TmfUml2SDSyncLoader"; //$NON-NLS-1$
+@SuppressWarnings("nls")
+public class LoadersManagerTest {
- private static final String LOADER_TAG = "uml2SDLoader"; //$NON-NLS-1$
- private static final String LOADER_PREFIX = LOADER_TAG + "."; //$NON-NLS-1$
+ private final static String SDVIEW_WITH_ONE_LOADER = "org.eclipse.linuxtools.tmf.ui.tests.testSDView1Loader";
+ private final static String SDVIEW_WITH_MULTIPLE_LOADER = "org.eclipse.linuxtools.tmf.ui.tests.testSDView2Loaders";
+ private final static String TEST_LOADER_CLASS_NAME = "org.eclipse.linuxtools.tmf.ui.tests.uml2sd.load.TestLoaders";
+ private final static String TMF_UML2SD_LOADER_CLASS_NAME = "org.eclipse.linuxtools.tmf.ui.views.uml2sd.loader.TmfUml2SDSyncLoader";
- @Override
- public void setUp() throws Exception {
- super.setUp();
- }
-
- @Override
- public void tearDown() throws Exception {
- super.tearDown();
- }
+ private static final String LOADER_TAG = "uml2SDLoader";
+ private static final String LOADER_PREFIX = LOADER_TAG + ".";
/**
* Tests of loader manager singleton class.
*/
- @SuppressWarnings("nls")
+ @Test
public void testLoaderManager() {
-
SDView view = null;
try {
}
}
- @SuppressWarnings("unused")
- private static void delay(long waitTimeMillis) {
- Display display = Display.getCurrent();
- if (display != null) {
- long endTimeMillis = System.currentTimeMillis() + waitTimeMillis;
- while(System.currentTimeMillis() < endTimeMillis) {
- if (!display.readAndDispatch()) {
- display.sleep();
- }
- display.update();
- }
- } else {
- try {
- Thread.sleep(waitTimeMillis);
- } catch (InterruptedException e) {
- // Ignored
- }
- }
- }
-
private static String getSavedLoader(String viewId) {
IPreferenceStore p = Activator.getDefault().getPreferenceStore();
return p.getString(LOADER_PREFIX + viewId);
/*******************************************************************************
- * Copyright (c) 2011, 2012 Ericsson
+ * Copyright (c) 2011-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.tmf.ui.tests.views.uml2sd.loader;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
/**
* Test suite for testing the TmfUml2SDSyncLoader class.
- * @author Bernd Hufmann
+ *
+ * @author Bernd Hufmann
*/
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ TmfUml2SDSyncLoaderExpTest.class,
+ TmfUml2SDSyncLoaderFilterTest.class,
+ TmfUml2SDSyncLoaderFindTest.class,
+ TmfUml2SDSyncLoaderPagesTest.class,
+ TmfUml2SDSyncLoaderSignalTest.class,
+ TmfUml2SDSyncLoaderTimeTest.class
+})
public class AllTests {
- /**
- * @return the test suite.
- */
- public static Test suite() {
- TestSuite suite = new TestSuite(AllTests.class.getName());
- //$JUnit-BEGIN$
- suite.addTestSuite(TmfUml2SDSyncLoaderExpTest.class);
- suite.addTestSuite(TmfUml2SDSyncLoaderPagesTest.class);
- suite.addTestSuite(TmfUml2SDSyncLoaderTimeTest.class);
- suite.addTestSuite(TmfUml2SDSyncLoaderSignalTest.class);
- suite.addTestSuite(TmfUml2SDSyncLoaderFindTest.class);
- suite.addTestSuite(TmfUml2SDSyncLoaderFilterTest.class);
- //$JUnit-END$
- return new Uml2SDTestSetup(suite);
- }
}
/*******************************************************************************
- * Copyright (c) 2011, 2012 Ericsson
+ * Copyright (c) 2011-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.tmf.ui.tests.views.uml2sd.loader;
-import java.util.List;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import java.util.List;
import org.eclipse.linuxtools.tmf.core.signal.TmfSignalManager;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.dialogs.FilterCriteria;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDAdvancedPagingProvider;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDPagingProvider;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.loader.TmfUml2SDSyncLoader;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
/**
* Test cases for Experiment handling.
*
* @author Bernd Hufmann
- *
*/
@SuppressWarnings("nls")
-public class TmfUml2SDSyncLoaderExpTest extends TestCase {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- private Uml2SDTestFacility fFacility;
+public class TmfUml2SDSyncLoaderExpTest {
- // ------------------------------------------------------------------------
- // Static methods
- // ------------------------------------------------------------------------
+ private static Uml2SDTestFacility fFacility;
/**
- * Returns test setup used when executing test case stand-alone.
- * @return Test setup class
+ * Initialization
*/
- public static Test suite() {
- return new Uml2SDTestSetup(new TestSuite(TmfUml2SDSyncLoaderExpTest.class));
- }
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- /**
- * Constructor
- */
- public TmfUml2SDSyncLoaderExpTest() {
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- @Override
- public void setUp() throws Exception {
- super.setUp();
+ @BeforeClass
+ public static void setUpClass() {
fFacility = Uml2SDTestFacility.getInstance();
// create filter criteria (incl. save)
fFacility.createFilterCriteria();
fFacility.selectExperiment();
}
-
- @Override
- public void tearDown() throws Exception {
+ /**
+ * Cleanup
+ */
+ @AfterClass
+ public static void tearDownClass() {
+ fFacility.disposeExperiment();
fFacility = null;
- super.tearDown();
}
-
/**
- * Main method with test cases.
+ * Verify setup
+ *
+ * Verified Methods: loader.getTitleString()
+ * view.getPartName()
+ * view.getFrame()
+ * Expected result: Title, view name are set properly.
*/
- public void testExperimentHandling() {
-
- /*
- * Test Case: 001
- * Description: Verify setup
- * Verified Methods: loader.getTitleString()
- * view.getPartName()
- * view.getFrame()
- * Expected result: Title, view name are set properly.
- */
-
+ @Test
+ public void verifySetup() {
assertEquals("getTitleString", "Component Interactions", fFacility.getLoader().getTitleString());
assertEquals("getPartName", "Sequence Diagram", fFacility.getSdView().getPartName());
assertNotNull("getFrame", fFacility.getSdView().getFrame());
fFacility.delay(IUml2SDTestConstants.GUI_REFESH_DELAY);
verifyPage(0, 0, false, false, 0);
+ }
- /*
- * Test Case: 002
- * Description: Verifies cancellation of ongoing indexing.
- * Verified Methods: loader.experimentSelected(), loader.experimentDisposed(), loader.nextPage()
- * Expected result: No exceptions during cancellation and nextPage() operation..
- *
- * Note this test is not sufficient to verify the concurrent access of the loader attributes
- * by multiple threads. Contention might happen but it's not guaranteed.
- */
-
+ /**
+ * Verify cancellation of ongoing indexing.
+ *
+ * Verified Methods: loader.experimentSelected(), loader.experimentDisposed(), loader.nextPage()
+ * Expected result: No exceptions during cancellation and nextPage() operation.
+ *
+ * Note this test is not sufficient to verify the concurrent access of the loader attributes
+ * by multiple threads. Contention might happen but it's not guaranteed.
+ */
+ @Test
+ public void verifyCancel() {
for(int i = 0; i < 5; i++) {
fFacility.selectExperiment(false);
fFacility.delay(IUml2SDTestConstants.INITIAL_INDEX_DELAY);
fail("exp.select/exp.dispose");
}
}
+ }
- /*
- * Test Case: 003
- * Description: Verifies disposed experiment.
- * Verified Methods: loader.nextPage(),
- * loader.pagesCount(), loader.hasNextPage(), loader.hasPrevPage(),
- * frame.syncMessagesCount, frame.lifeLinesCount
- * Expected result: Page values and filter are reset.
- *
- * Note this test is not sufficient to verify the concurrent access ofthe loader attributes
- * by multiple threads. Contention might happen but it's not guaranteed.
- */
-
+ /**
+ * Verify disposed experiment.
+ *
+ * Verified Methods: loader.nextPage(),
+ * loader.pagesCount(), loader.hasNextPage(), loader.hasPrevPage(),
+ * frame.syncMessagesCount, frame.lifeLinesCount
+ * Expected result: Page values and filter are reset.
+ *
+ * Note this test is not sufficient to verify the concurrent access of the loader attributes
+ * by multiple threads. Contention might happen but it's not guaranteed.
+ */
+ @Test
+ public void verifyDispose() {
verifyPage(0, 0, false, false, 0);
// verify that all enable filters are disabled after disposal
for (FilterCriteria filterCriteria : filter) {
assertFalse("exp.dispose", filterCriteria.isActive());
}
+ }
- /*
- * Test Case: 004
- * Description: Verifies the disposal of the loader.
- * Verified Methods: loader.dispose(),
- * Expected result: All providers are removed from SDView.
- */
+ /**
+ * Verify the disposal of the loader.
+ *
+ * Verified Methods: loader.dispose()
+ * Expected result: All providers are removed from SDView.
+ */
+ @Test
+ public void verifyLoaderDispose() {
fFacility.getLoader().dispose();
assertTrue("loader.dispose", fFacility.getSdView().getSDPagingProvider() == null);
assertTrue("loader.dispose", fFacility.getSdView().getSDFindProvider() == null);
// Set again loader as signal handler, which was removed by the the dispose above
TmfSignalManager.register(fFacility.getLoader());
+ }
- /*
- * Test Case: 005
- * Description: Verifies setViewer.
- * Verified Methods: loader.setViewer
- * Expected result: Paging, find and filter provider are set
- */
-
+ /**
+ * Verify setViewer.
+ *
+ * Verified Methods: loader.setViewer
+ * Expected result: Paging, find and filter provider are set
+ */
+ @Test
+ public void testSetViewer() {
fFacility.getLoader().setViewer(fFacility.getSdView());
ISDPagingProvider pagingProvider = fFacility.getSdView().getSDPagingProvider();
assertTrue("loader.setViewer", pagingProvider != null);
assertTrue("loader.setViewer", fFacility.getSdView().getExtendedFilterProvider() == null);
}
- private void verifyPage(int currentPage, int numMsg, boolean hasNext, boolean hasPrev, int lifelineCount) {
+ private static void verifyPage(int currentPage, int numMsg, boolean hasNext,
+ boolean hasPrev, int lifelineCount) {
assertEquals("currentPage", currentPage, fFacility.getLoader().currentPage());
assertEquals("syncMessageCount, ", numMsg, fFacility.getSdView().getFrame().syncMessageCount());
if (hasNext) {
/*******************************************************************************
- * Copyright (c) 2011, 2012 Ericsson
+ * Copyright (c) 2011-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.tmf.ui.tests.views.uml2sd.loader;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import java.util.ArrayList;
import java.util.List;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.Lifeline;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.SyncMessage;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.dialogs.Criteria;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.dialogs.FilterCriteria;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.loader.TmfSyncMessage;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
/**
* Filter test cases.
*
* @author Bernd Hufmann
- *
*/
@SuppressWarnings("nls")
-public class TmfUml2SDSyncLoaderFilterTest extends TestCase {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- private Uml2SDTestFacility fFacility;
+public class TmfUml2SDSyncLoaderFilterTest {
- // ------------------------------------------------------------------------
- // Static methods
- // ------------------------------------------------------------------------
+ private static Uml2SDTestFacility fFacility;
+ private static List<FilterCriteria> filterToSave;
/**
- * Returns test setup used when executing test case stand-alone.
- * @return Test setup class
+ * Initialization
*/
- public static Test suite() {
- return new Uml2SDTestSetup(new TestSuite(TmfUml2SDSyncLoaderFilterTest.class));
- }
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
- /**
- * Constructor
- */
- public TmfUml2SDSyncLoaderFilterTest() {
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- @Override
- public void setUp() throws Exception {
- super.setUp();
+ @BeforeClass
+ public static void setUpClass() {
fFacility = Uml2SDTestFacility.getInstance();
fFacility.selectExperiment();
- }
-
-
- @Override
- public void tearDown() throws Exception {
- fFacility.disposeExperiment();
- fFacility = null;
- super.tearDown();
- }
- /**
- * Main method with test cases.
- */
- public void testFilterHandling() {
-
- // Create Filter Criteria
- List<FilterCriteria> filterToSave = new ArrayList<FilterCriteria>();
+ /* Create Filter Criteria */
+ filterToSave = new ArrayList<FilterCriteria>();
Criteria criteria = new Criteria();
criteria.setLifeLineSelected(true);
criteria.setExpression(IUml2SDTestConstants.FIRST_PLAYER_NAME);
criteria.setSyncMessageSelected(true);
criteria.setExpression("BALL_.*"); //$NON-NLS-1$
filterToSave.add(new FilterCriteria(criteria, false, false));
+ }
- /*
- * Test Case: 001
- * Description: Verify the filter lifelines (1 out of 2 is hidden)
- * Verified Methods: loader.filter()
- * Expected result: Only one lifeline is visible with no messages
- */
+ /**
+ * Cleanup
+ */
+ @AfterClass
+ public static void tearDownClass() {
+ fFacility.disposeExperiment();
+ fFacility = null;
+ }
+
+ /**
+ * Verify the filter lifelines (1 out of 2 is hidden)
+ *
+ * Verified Methods: loader.filter()
+ * Expected result: Only one lifeline is visible with no messages
+ */
+ @Test
+ public void verifyFilter1of2() {
fFacility.getLoader().filter(filterToSave);
fFacility.delay(IUml2SDTestConstants.GUI_REFESH_DELAY);
assertEquals("filter", 1, fFacility.getSdView().getFrame().lifeLinesCount());
assertEquals("filter", IUml2SDTestConstants.MASTER_PLAYER_NAME, fFacility.getSdView().getFrame().getLifeline(0).getName());
assertEquals("filter", 0, fFacility.getSdView().getFrame().syncMessageCount());
+ }
- /*
- * Test Case: 002
- * Description: Verify the filter lifelines (2 out of 2 are hidden)
- * Verified Methods: loader.filter(), loader.fillCurrentPage()
- * Expected result: Neiter liflines nor messages are visible
- */
+ /**
+ * Verify the filter lifelines (2 out of 2 are hidden)
+ *
+ * Verified Methods: loader.filter(), loader.fillCurrentPage()
+ * Expected result: Neiter liflines nor messages are visible
+ */
+ @Test
+ public void verifyFilter2of2() {
filterToSave.get(1).setActive(true);
fFacility.getLoader().filter(filterToSave);
fFacility.delay(IUml2SDTestConstants.GUI_REFESH_DELAY);
assertEquals("filter", 0, fFacility.getSdView().getFrame().lifeLinesCount());
assertEquals("filter", 0, fFacility.getSdView().getFrame().syncMessageCount());
+ }
- /*
- * Test Case: 003
- * Description: Verify removal of all filters
- * Verified Methods: loader.filter(), loader.fillCurrentPage()
- * Expected result: Everything is shown
- */
+ /**
+ * Verify removal of all filters
+ *
+ * Verified Methods: loader.filter(), loader.fillCurrentPage()
+ * Expected result: Everything is shown
+ */
+ @Test
+ public void verifyRemoval() {
filterToSave.get(0).setActive(false);
filterToSave.get(1).setActive(false);
fFacility.getLoader().filter(filterToSave);
fFacility.delay(IUml2SDTestConstants.GUI_REFESH_DELAY);
assertEquals("filter", 2, fFacility.getSdView().getFrame().lifeLinesCount());
- assertEquals("filter", IUml2SDTestConstants.MAX_MESSEAGES_PER_PAGE, fFacility.getSdView().getFrame().syncMessageCount());
-
- /*
- * Test Case: 004
- * Description: Verify filter of messages
- * Verified Methods: loader.filter(), loader.fillCurrentPage()
- * Expected result: Only particular messages are shown
- */
+ assertEquals("filter", IUml2SDTestConstants.MAX_MESSEAGES_PER_PAGE,
+ fFacility.getSdView().getFrame().syncMessageCount());
+ }
+
+ /**
+ * Verify filter of messages
+ *
+ * Verified Methods: loader.filter(), loader.fillCurrentPage()
+ * Expected result: Only particular messages are shown
+ */
+ @Test
+ public void verifyMessageFilter() {
filterToSave.get(2).setActive(true);
fFacility.getLoader().filter(filterToSave);
fFacility.delay(IUml2SDTestConstants.GUI_REFESH_DELAY);
assertEquals("filter", 2, fFacility.getSdView().getFrame().lifeLinesCount());
assertEquals("filter", 6, fFacility.getSdView().getFrame().syncMessageCount());
- String messages[] = { "REGISTER_PLAYER_REQUEST", "REGISTER_PLAYER_REPLY", "GAME_REQUEST", "GAME_REPLY", "START_GAME_REQUEST", "START_GAME_REPLY" };
+ String messages[] = { "REGISTER_PLAYER_REQUEST", "REGISTER_PLAYER_REPLY",
+ "GAME_REQUEST", "GAME_REPLY", "START_GAME_REQUEST", "START_GAME_REPLY" };
for (int i = 0; i < messages.length; i++) {
SyncMessage msg = fFacility.getSdView().getFrame().getSyncMessage(i);
assertTrue("filter", msg instanceof TmfSyncMessage);
assertEquals("filter", messages[i], msg.getName());
}
+ }
- /*
- * Test Case: 005
- * Description: Verify filter lifeline (1 out of three lifelines).
- * Note that filter was set during change of page.
- * Verified Methods: loader.filter(), loader.fillCurrentPage()
- * Expected result: Only 2 lifelines and their interactions are shown
- */
+ /**
+ * Verify filter lifeline (1 out of three lifelines). Note that filter was
+ * set during change of page.
+ *
+ * Verified Methods: loader.filter(), loader.fillCurrentPage()
+ * Expected result: Only 2 lifelines and their interactions are shown
+ */
+ @Test
+ public void verifyFilter1of3() {
filterToSave.get(0).setActive(true);
filterToSave.get(2).setActive(false);
fFacility.setPage(IUml2SDTestConstants.PAGE_OF_ALL_LIFELINES);
/*******************************************************************************
- * Copyright (c) 2011, 2012 Ericsson
+ * Copyright (c) 2011-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.tmf.ui.tests.views.uml2sd.loader;
-import java.util.List;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import java.util.List;
import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.dialogs.Criteria;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDGraphNodeSupporter;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.loader.TmfSyncMessage;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
/**
* Search Test Cases.
*
* @author Bernd Hufmann
*/
-public class TmfUml2SDSyncLoaderFindTest extends TestCase {
+@SuppressWarnings("nls")
+public class TmfUml2SDSyncLoaderFindTest {
// ------------------------------------------------------------------------
// Attributes
// Test case 002 expected values
final static private Uml2SDTestTimestamp TC_002_TIME_VALUE = new Uml2SDTestTimestamp(9788642104149L);
- final static private String TC_002_MESSAGE_NAME = "GAME_REQUEST"; //$NON-NLS-1$
+ final static private String TC_002_MESSAGE_NAME = "GAME_REQUEST";
final static private int TC_002_PAGE_VALUE = 0;
final static private int TC_002_START_OCCURRANCE = 3;
final static private int TC_002_END_OCCURRANCE = TC_002_START_OCCURRANCE;
// Test case 003 expected values
final static private Uml2SDTestTimestamp TC_003_TIME_VALUE = new Uml2SDTestTimestamp(9788642113228L);
- final static private String TC_003_MESSAGE_NAME = "GAME_REPLY"; //$NON-NLS-1$
+ final static private String TC_003_MESSAGE_NAME = "GAME_REPLY";
final static private int TC_003_PAGE_VALUE = 0;
final static private int TC_003_START_OCCURRANCE = 4;
final static private int TC_003_END_OCCURRANCE = TC_003_START_OCCURRANCE;
// Test case 004 expected values
final static private Uml2SDTestTimestamp TC_004_TIME_VALUE = new Uml2SDTestTimestamp(9791893030834L);
- final static private String TC_004_MESSAGE_NAME = "GAME_REQUEST"; //$NON-NLS-1$
+ final static private String TC_004_MESSAGE_NAME = "GAME_REQUEST";
final static private int TC_004_PAGE_VALUE = 4;
final static private int TC_004_START_OCCURRANCE = 19;
final static private int TC_004_END_OCCURRANCE = TC_004_START_OCCURRANCE;
final static private int TC_006_PAGE_VALUE = 4;
final static private String TC_006_LIFELINE_NAME = IUml2SDTestConstants.SECOND_PLAYER_NAME;
- private Uml2SDTestFacility fFacility;
- private Uml2SDSignalValidator fTmfComponent;
+ // Fields used in tests
+ private static Uml2SDTestFacility fFacility;
+ private static Uml2SDSignalValidator fTmfComponent;
+ private static Criteria criteria;
+ private static List<GraphNode> selection;
+ private static TmfSyncMessage msg;
+ private static Lifeline lifeline;
// ------------------------------------------------------------------------
- // Static methods
+ // Operations
// ------------------------------------------------------------------------
/**
- * Returns test setup used when executing test case stand-alone.
- * @return Test setup class
- */
- public static Test suite() {
- return new Uml2SDTestSetup(new TestSuite(TmfUml2SDSyncLoaderFindTest.class));
- }
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
- /**
- * Constructor
+ * Initialization
*/
- public TmfUml2SDSyncLoaderFindTest() {
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- @Override
- public void setUp() throws Exception {
- super.setUp();
+ @BeforeClass
+ public static void setUpClass() {
fFacility = Uml2SDTestFacility.getInstance();
fFacility.selectExperiment();
}
- @Override
- public void tearDown() throws Exception {
+ /**
+ * Cleanup
+ */
+ @AfterClass
+ public static void tearDownClass() {
fFacility.disposeExperiment();
fFacility = null;
- super.tearDown();
}
/**
- * Main method with test cases.
+ * Verify the ISDGraphNodeSupporter implementation.
+ *
+ * Verified Methods: loader.isNodeSupported(), loader.getNodeName()
+ * Expected result: Correct values are returned, i.e. only lifelines and
+ * sync. messages are supported.
*/
- @SuppressWarnings("nls")
- public void testFindHandling() {
+ @Test
+ public void verifyISDGraphNodeSupporter() {
fTmfComponent = new Uml2SDSignalValidator();
- /*
- * Test Case: 001
- * Description: Verify the ISDGraphNodeSupporter implementation
- * Verified Methods: loader.isNodeSupported(), loader.getNodeName()
- * Expected result: Correct values are returned, i.e. only lifelines and sync. messages are supported
- */
assertTrue("isNodeSupported", fFacility.getLoader().isNodeSupported(ISDGraphNodeSupporter.LIFELINE));
assertTrue("isNodeSupported", fFacility.getLoader().isNodeSupported(ISDGraphNodeSupporter.SYNCMESSAGE));
assertFalse("isNodeSupported", fFacility.getLoader().isNodeSupported(ISDGraphNodeSupporter.SYNCMESSAGERETURN));
assertEquals("getNodeName", "", fFacility.getLoader().getNodeName(ISDGraphNodeSupporter.STOP, null));
fFacility.getLoader().cancel();
+ }
- /*
- * Test Case: 002
- * Description: Verify 1st message find within page
- * Verified Methods: loader.find(), loader.moveToMessage()
- * Expected result: Correct message is selected
- */
- Criteria criteria = new Criteria();
+ /**
+ * Verify 1st message find within page.
+ *
+ * Verified Methods: loader.find(), loader.moveToMessage()
+ * Expected result: Correct message is selected
+ */
+ @Test
+ public void verifyFirstMessage() {
+ criteria = new Criteria();
criteria.setSyncMessageSelected(true);
criteria.setExpression("GAME_.*");
assertFalse("find", fTmfComponent.isSourceError());
assertEquals("find", TC_002_PAGE_VALUE, fFacility.getLoader().currentPage());
- List<GraphNode> selection = fFacility.getSdView().getSDWidget().getSelection();
+ selection = fFacility.getSdView().getSDWidget().getSelection();
assertNotNull(selection);
assertEquals("find", 1, selection.size());
assertTrue(selection.get(0) instanceof TmfSyncMessage);
- TmfSyncMessage msg = (TmfSyncMessage) selection.get(0);
+ msg = (TmfSyncMessage) selection.get(0);
assertEquals("find", TC_002_MESSAGE_NAME, msg.getName());
assertEquals("find", 0, TC_002_TIME_VALUE.compareTo(msg.getStartTime(), false));
assertEquals("find", TC_002_START_OCCURRANCE, msg.getStartOccurrence());
assertEquals("find", TC_002_END_OCCURRANCE, msg.getEndOccurrence());
assertEquals("find", TC_002_START_LIFELINE, msg.getStartLifeline().getName());
assertEquals("find", TC_002_END_LIFELINE, msg.getEndLifeline().getName());
+ }
- /*
- * Test Case: 003
- * Description: Verify 2nd message find within page
- * Verified Methods: loader.find(), loader.moveToMessage()
- * Expected result: Correct message is selected
- */
+ /**
+ * Verify 2nd message find within page.
+ *
+ * Verified Methods: loader.find(), loader.moveToMessage()
+ * Expected result: Correct message is selected
+ */
+ @Test
+ public void verifySecondMessage() {
// set expected values
fTmfComponent.setSource(fFacility.getLoader());
fTmfComponent.setCurrentTime(TC_003_TIME_VALUE);
assertEquals("find", TC_003_END_OCCURRANCE, msg.getEndOccurrence());
assertEquals("find", TC_003_START_LIFELINE, msg.getStartLifeline().getName());
assertEquals("find", TC_003_END_LIFELINE, msg.getEndLifeline().getName());
+ }
- /*
- * Test Case: 004
- * Description: Verify 1st message across page
- * Verified Methods: loader.find(), loader.moveToPage(), loader.moveToMessage()
- * Expected result: Correct message is selected
- */
+ /**
+ * Verify 1st message across page.
+ *
+ * Verified Methods: loader.find(), loader.moveToPage(), loader.moveToMessage()
+ * Expected result: Correct message is selected
+ */
+ @Test
+ public void verifyFirstMesage() {
// set expected values
fTmfComponent.setSource(fFacility.getLoader());
fTmfComponent.setCurrentTime(TC_004_TIME_VALUE);
// cancel find and go back to first page
fFacility.getLoader().cancel();
fFacility.firstPage();
+ }
- /*
- * Test Case: 005
- * Description: Verify find of lifeline within page
- * Verified Methods: loader.find(), loader.moveToPage(), loader.moveToMessage()
- * Expected result: Correct message is selected
- */
+ /**
+ * Verify find of lifeline within page.
+ *
+ * Verified Methods: loader.find(), loader.moveToPage(), loader.moveToMessage()
+ * Expected result: Correct message is selected
+ */
+ @Test
+ public void verifyFind() {
criteria = new Criteria();
criteria.setLifeLineSelected(true);
criteria.setExpression(IUml2SDTestConstants.FIRST_PLAYER_NAME);
assertNotNull(selection);
assertEquals("find", 1, selection.size());
assertTrue(selection.get(0) instanceof Lifeline);
- Lifeline lifeline = (Lifeline) selection.get(0);
+ lifeline = (Lifeline) selection.get(0);
assertEquals("find", TC_005_LIFELINE_NAME, lifeline.getName());
+ }
- /*
- * Test Case: 006
- * Description: Verify lifeline across page
- * Verified Methods: loader.find(), loader.moveToPage(), loader.moveToMessage()
- * Expected result: Correct message is selected
- */
+ /**
+ * Verify lifeline across page.
+ *
+ * Verified Methods: loader.find(), loader.moveToPage(), loader.moveToMessage()
+ * Expected result: Correct message is selected
+ */
+ @Test
+ public void verifyLifeline() {
criteria = new Criteria();
criteria.setLifeLineSelected(true);
criteria.setExpression(IUml2SDTestConstants.SECOND_PLAYER_NAME);
// cancel find and go back to first page
fFacility.getLoader().cancel();
fFacility.firstPage();
+ }
- /*
- * Test Case: 007
- * Description: Verify cancel ongoing search job
- * Verified Methods: loader.find(), loader.find()
- * Expected result: Cancelled find
- */
+ /**
+ * Verify cancel ongoing search job.
+ *
+ * Verified Methods: loader.find(), loader.find()
+ * Expected result: Cancelled find
+ */
+ @Test
+ public void verifyCancelSearch() {
criteria = new Criteria();
criteria.setLifeLineSelected(true);
criteria.setExpression(IUml2SDTestConstants.SECOND_PLAYER_NAME);
/*******************************************************************************
- * Copyright (c) 2011, 2012 Ericsson
+ * Copyright (c) 2011-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.tmf.ui.tests.views.uml2sd.loader;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
/**
* Test cases for pages handling.
*
* @author Bernd Hufmann
- *
*/
-public class TmfUml2SDSyncLoaderPagesTest extends TestCase {
+public class TmfUml2SDSyncLoaderPagesTest {
// ------------------------------------------------------------------------
// Attributes
// ------------------------------------------------------------------------
- private Uml2SDTestFacility fFacility;
- // ------------------------------------------------------------------------
- // Static methods
- // ------------------------------------------------------------------------
-
- /**
- * Returns test setup used when executing test case stand-alone.
- * @return Test setup class
- */
- public static Test suite() {
- return new Uml2SDTestSetup(new TestSuite(TmfUml2SDSyncLoaderPagesTest.class));
- }
+ private static Uml2SDTestFacility fFacility;
// ------------------------------------------------------------------------
- // Constructors
+ // Operations
// ------------------------------------------------------------------------
+
/**
- * Constructor
+ * Initialization
*/
- public TmfUml2SDSyncLoaderPagesTest() {
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- @Override
- public void setUp() throws Exception {
- super.setUp();
+ @BeforeClass
+ public static void setUpClass() {
fFacility = Uml2SDTestFacility.getInstance();
fFacility.selectExperiment();
}
-
- @Override
- public void tearDown() throws Exception {
+ /**
+ * Cleanup
+ */
+ @AfterClass
+ public static void tearDownClass() {
fFacility.disposeExperiment();
fFacility = null;
- super.tearDown();
}
/**
- * Main method with test cases.
+ * Test Case: 001
+ * Description: Test number of pages.
+ * Verified Methods: loader.pagesCount().
+ * Expected result: ITestConstants.TOTAL_NUMBER_OF_PAGES of pages
*/
- public void testPageHandling() {
-
- verifyPagesCount();
- verifyNextPage();
- verifyPrevPage();
- verifyFirstPage();
- verifyLastPage();
- verifyPageNumberChanged();
-
- }
-
- private void verifyPagesCount() {
-
- /*
- * Test Case: 001
- * Description: Test number of pages.
- * Verified Methods: loader.pagesCount().
- * Expected result: ITestConstants.TOTAL_NUMBER_OF_PAGES of pages
- */
+ @Test
+ public void verifyPagesCount() {
assertEquals(IUml2SDTestConstants.TOTAL_NUMBER_OF_PAGES, fFacility.getLoader().pagesCount());
}
- private void verifyNextPage() {
- // assuming we are at the first page
-
- /*
- * Test Case: 002
- * Description: Tests next page feature.
- * Verified Methods: loader.nextPage(), loader.fillCurrentPage(), loader.pagesCount(),
- * loader.hasNextPage(), loader.hasPrevPage(),
- * frame.syncMessagesCount, frame.lifeLinesCount
- * Expected result: Expected values are return.
- */
+ /**
+ * Test Case: 002
+ * Description: Tests next page feature.
+ * Verified Methods: loader.nextPage(), loader.fillCurrentPage(), loader.pagesCount(),
+ * loader.hasNextPage(), loader.hasPrevPage(),
+ * frame.syncMessagesCount, frame.lifeLinesCount
+ * Expected result: Expected values are return.
+ */
+ @Test
+ public void verifyNextPage() {
+ // assuming we are at the first page
for(int i = 0; i < IUml2SDTestConstants.TOTAL_NUMBER_OF_PAGES-2; i++) {
fFacility.nextPage();
fFacility.firstPage();
}
-
- private void verifyPrevPage() {
- // assuming we are at the first page
-
- /*
- * Test Case: 003
- * Description: Test previous page feature.
- * Verified Methods: loader.prevPage(), loader.fillCurrentPage(), loader.pagesCount(),
- * loader.hasNextPage(), loader.hasPrevPage(),
- * frame.syncMessagesCount, frame.lifeLinesCount
- * Expected result: Expected values are return.
- */
-
+ /**
+ * Test Case: 003
+ * Description: Test previous page feature.
+ * Verified Methods: loader.prevPage(), loader.fillCurrentPage(), loader.pagesCount(),
+ * loader.hasNextPage(), loader.hasPrevPage(),
+ * frame.syncMessagesCount, frame.lifeLinesCount
+ * Expected result: Expected values are return.
+ */
+ @Test
+ public void verifyPrevPage() {
// Last Page
fFacility.lastPage();
assertEquals(IUml2SDTestConstants.TOTAL_NUMBER_OF_PAGES - 1, fFacility.getLoader().currentPage());
}
}
- private void verifyFirstPage() {
+ /**
+ * Test Case: 004
+ * Description: Test first page feature.
+ * Verified Methods: loader.firstPage(), loader.fillCurrentPage(), loader.pagesCount(),
+ * loader.hasNextPage(), loader.hasPrevPage(),
+ * frame.syncMessagesCount, frame.lifeLinesCount
+ * Expected result: Expected values are return.
+ */
+ @Test
+ public void verifyFirstPage() {
fFacility.lastPage();
- /*
- * Test Case: 004
- * Description: Test first page feature.
- * Verified Methods: loader.firstPage(), loader.fillCurrentPage(), loader.pagesCount(),
- * loader.hasNextPage(), loader.hasPrevPage(),
- * frame.syncMessagesCount, frame.lifeLinesCount
- * Expected result: Expected values are return.
- */
// First Page
fFacility.firstPage();
verifyPage(0, IUml2SDTestConstants.MAX_MESSEAGES_PER_PAGE, true, false);
}
-
- private void verifyLastPage() {
- /*
- * Test Case: 005
- * Description: Test last page feature.
- * Verified Methods: loader.lastPage(), loader.pagesCount(), loader.hasNextPage(), loader.hasPrevPage()
- * frame.syncMessagesCount, frame.lifeLinesCount
- * Expected result: Expected values are return.
- */
+ /**
+ * Test Case: 005
+ * Description: Test last page feature.
+ * Verified Methods: loader.lastPage(), loader.pagesCount(), loader.hasNextPage(), loader.hasPrevPage()
+ * frame.syncMessagesCount, frame.lifeLinesCount
+ * Expected result: Expected values are return.
+ */
+ @Test
+ public void verifyLastPage() {
fFacility.lastPage();
verifyPage(IUml2SDTestConstants.TOTAL_NUMBER_OF_PAGES - 1, IUml2SDTestConstants.NUM_MESSAGES_OF_LAST_PAGE, false, true);
fFacility.firstPage();
}
- private void verifyPageNumberChanged() {
-
- /*
- * Test Case: 006
- * Description: Test move to any page feature.
- * Verified Methods: loader.pageNumberChanged(), loader.fillCurrentPage(), loader.pagesCount(),
- * loader.hasNextPage(), loader.hasPrevPage(),
- * frame.syncMessagesCount, frame.lifeLinesCount
- * Expected result: Expected values are return.
- */
-
+ /**
+ * Test Case: 006
+ * Description: Test move to any page feature.
+ * Verified Methods: loader.pageNumberChanged(), loader.fillCurrentPage(), loader.pagesCount(),
+ * loader.hasNextPage(), loader.hasPrevPage(),
+ * frame.syncMessagesCount, frame.lifeLinesCount
+ * Expected result: Expected values are return.
+ */
+ @Test
+ public void verifyPageNumberChanged() {
// any page
fFacility.setPage(IUml2SDTestConstants.PAGE_OF_ALL_LIFELINES);
- verifyPage(IUml2SDTestConstants.PAGE_OF_ALL_LIFELINES, IUml2SDTestConstants.MAX_MESSEAGES_PER_PAGE, true, true, IUml2SDTestConstants.NUM_OF_ALL_LIFELINES);
+ verifyPage(IUml2SDTestConstants.PAGE_OF_ALL_LIFELINES,
+ IUml2SDTestConstants.MAX_MESSEAGES_PER_PAGE, true, true,
+ IUml2SDTestConstants.NUM_OF_ALL_LIFELINES);
fFacility.firstPage();
}
- private void verifyPage(int currentPage, int numMsg, boolean hasNext, boolean hasPrev) {
+ private static void verifyPage(int currentPage, int numMsg, boolean hasNext, boolean hasPrev) {
verifyPage(currentPage, numMsg, hasNext, hasPrev, IUml2SDTestConstants.DEFAULT_NUM_LIFELINES);
}
@SuppressWarnings("nls")
- private void verifyPage(int currentPage, int numMsg, boolean hasNext, boolean hasPrev, int lifelineCount) {
+ private static void verifyPage(int currentPage, int numMsg, boolean hasNext,
+ boolean hasPrev, int lifelineCount) {
assertEquals("currentPage", currentPage, fFacility.getLoader().currentPage());
assertEquals("syncMessageCount, ", numMsg, fFacility.getSdView().getFrame().syncMessageCount());
if (hasNext) {
/*******************************************************************************
- * Copyright (c) 2011, 2012 Ericsson
+ * Copyright (c) 2011-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.tmf.ui.tests.views.uml2sd.loader;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
import org.eclipse.linuxtools.tmf.core.signal.TmfRangeSynchSignal;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
/**
* Test cases for signal handling.
*
* @author Bernd Hufmann
- *
*/
-public class TmfUml2SDSyncLoaderSignalTest extends TestCase {
+@SuppressWarnings("nls")
+public class TmfUml2SDSyncLoaderSignalTest {
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
- private Uml2SDTestFacility fFacility;
- private Uml2SDSignalValidator fTmfComponent;
+ private static Uml2SDTestFacility fFacility;
+ private static Uml2SDSignalValidator fTmfComponent;
- // ------------------------------------------------------------------------
- // Static methods
- // ------------------------------------------------------------------------
+ private static TmfTimeRange range;
+ private static TmfTimestamp rangeWindow;
+ private static TmfTimestamp currentTime;
/**
- * Returns test setup used when executing test case stand-alone.
- * @return Test setup class
+ * Initialization
*/
- public static Test suite() {
- return new Uml2SDTestSetup(new TestSuite(TmfUml2SDSyncLoaderSignalTest.class));
- }
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
- /**
- * Constructor
- */
- public TmfUml2SDSyncLoaderSignalTest() {
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- @Override
- public void setUp() throws Exception {
- super.setUp();
+ @BeforeClass
+ public static void setUpClass() {
fFacility = Uml2SDTestFacility.getInstance();
fFacility.selectExperiment();
+
+ range = new TmfTimeRange(new Uml2SDTestTimestamp(9789689220871L), new Uml2SDTestTimestamp(9789773881426L));
+ // Get range window for tests below
+ rangeWindow = (TmfTimestamp) range.getEndTime().getDelta(range.getStartTime());
+ currentTime = new Uml2SDTestTimestamp(9789773782043L);
+
+ fFacility.getTrace().broadcast(new TmfRangeSynchSignal(fFacility, range, currentTime));
+ fFacility.delay(IUml2SDTestConstants.BROADCAST_DELAY);
+
+ fTmfComponent = new Uml2SDSignalValidator();
}
- @Override
- public void tearDown() throws Exception {
+ /**
+ * Cleanup
+ */
+ @AfterClass
+ public static void tearDownClass() {
fFacility.disposeExperiment();
fFacility = null;
- super.tearDown();
}
/**
- * Main method with test cases.
+ * Test Case: 001
+ * Description: Verify that time range signal is send with correct values when going to first page
+ * Verified Methods: broadcast()
+ * Expected result: Time range sync signal is sent with correct range and current time.
*/
- @SuppressWarnings("nls")
- public void testSignalHandling() {
-
- TmfTimeRange range = new TmfTimeRange(new Uml2SDTestTimestamp(9789689220871L), new Uml2SDTestTimestamp(9789773881426L));
- // Get range window for tests below
- TmfTimestamp rangeWindow = (TmfTimestamp) range.getEndTime().getDelta(range.getStartTime());
- TmfTimestamp currentTime = new Uml2SDTestTimestamp(9789773782043L);
-
- fFacility.getTrace().broadcast(new TmfRangeSynchSignal(this, range, currentTime));
- fFacility.delay(IUml2SDTestConstants.BROADCAST_DELAY);
-
- fTmfComponent = new Uml2SDSignalValidator();
-
- /*
- * Test Case: 001
- * Description: Verify that time range signal is send with correct values when going to first page
- * Verified Methods: broadcast()
- * Expected result: Time range sync signal is sent with correct range and current time.
- */
+ @Test
+ public void verifyFirstPageSignal() {
currentTime = new Uml2SDTestTimestamp(9788641608418L);
range = new TmfTimeRange(currentTime, new Uml2SDTestTimestamp(currentTime.getValue() + rangeWindow.getValue()));
assertFalse("TmfRangeSynchSignal", fTmfComponent.isCurrentTimeError());
assertFalse("TmfRangeSynchSignal", fTmfComponent.isSourceError());
assertFalse("TmfRangeSynchSignal", fTmfComponent.isRangeError());
+ }
- /*
- * Test Case: 002
- * Description: Verify that time sync signal is sent correctly after selection
- * Verified Methods: loader.broadcast(), testSelectionChanged
- * Expected result: Time sync signal is sent with correct current time.
- */
+ /**
+ * Test Case: 002
+ * Description: Verify that time sync signal is sent correctly after selection
+ * Verified Methods: loader.broadcast(), testSelectionChanged
+ * Expected result: Time sync signal is sent with correct current time.
+ */
+ @Test
+ public void verifySelectionSignal() {
fTmfComponent.setSignalReceived(false);
int count = fFacility.getSdView().getFrame().syncMessageCount();
/*******************************************************************************
- * Copyright (c) 2011, 2012 Ericsson
+ * Copyright (c) 2011-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.tmf.ui.tests.views.uml2sd.loader;
-import java.util.List;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import java.util.List;
import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
import org.eclipse.linuxtools.tmf.core.signal.TmfTimeSynchSignal;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.loader.TmfSyncMessage;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
/**
* Test cases for time synchronization handling.
*
* @author Bernd Hufmann
- *
*/
-public class TmfUml2SDSyncLoaderTimeTest extends TestCase {
+@SuppressWarnings("nls")
+public class TmfUml2SDSyncLoaderTimeTest {
// ------------------------------------------------------------------------
// Attributes
// ------------------------------------------------------------------------
+
// Test case 001 expected values
final static private Uml2SDTestTimestamp TC_001_TIME_VALUE = new Uml2SDTestTimestamp(9788642228395L);
final static private String TC_001_MESSAGE_NAME = "START_GAME_REPLY"; //$NON-NLS-1$
final static private Uml2SDTestTimestamp TC_009_START_TIME_VALUE = TC_009_TIME_VALUE;
final static private Uml2SDTestTimestamp TC_009_END_TIME_VALUE = new Uml2SDTestTimestamp(9789773881426L);
- private Uml2SDTestFacility fFacility;
+ // Fields used in tests
+ private static Uml2SDTestFacility fFacility;
+ private static List<GraphNode> selection;
+ private static TmfSyncMessage msg;
// ------------------------------------------------------------------------
- // Static methods
+ // Operations
// ------------------------------------------------------------------------
/**
- * Returns test setup used when executing test case stand-alone.
- * @return Test setup class
- */
- public static Test suite() {
- return new Uml2SDTestSetup(new TestSuite(TmfUml2SDSyncLoaderTimeTest.class));
- }
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
- /**
- * Constructor
+ * Initialization
*/
- public TmfUml2SDSyncLoaderTimeTest() {
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
- @Override
- public void setUp() throws Exception {
- super.setUp();
+ @BeforeClass
+ public static void setUpClass() {
fFacility = Uml2SDTestFacility.getInstance();
fFacility.selectExperiment();
}
-
- @Override
- public void tearDown() throws Exception {
+ /**
+ * Cleanup
+ */
+ @AfterClass
+ public static void tearDownClass() {
fFacility.disposeExperiment();
fFacility = null;
- super.tearDown();
}
/**
- * Main method with test cases.
+ * Test Case: 001
+ * Description: Verify synchToTime (exact time in page), selection of message in page
+ * Verified Methods: loader.syncToTime(), loader.moveToMessage(), loader.moveToMessageInPage()
+ * Expected result: Correct message is selected.
*/
- @SuppressWarnings("nls")
- public void testTimeHandling() {
- /*
- * Test Case: 001
- * Description: Verify synchToTime (exact time in page), selection of message in page
- * Verified Methods: loader.syncToTime(), loader.moveToMessage(), loader.moveToMessageInPage()
- * Expected result: Correct message is selected.
- */
+ @Test
+ public void verifySynchToTimeInPage() {
fFacility.getTrace().broadcast(new TmfTimeSynchSignal(this, TC_001_TIME_VALUE));
fFacility.getLoader().waitForCompletion();
fFacility.delay(IUml2SDTestConstants.GUI_REFESH_DELAY);
assertEquals("synchToTime", TC_001_PAGE_VALUE, fFacility.getLoader().currentPage());
- List<GraphNode> selection = fFacility.getSdView().getSDWidget().getSelection();
+ selection = fFacility.getSdView().getSDWidget().getSelection();
assertNotNull(selection);
assertEquals("synchToTime", 1, selection.size());
assertTrue(selection.get(0) instanceof TmfSyncMessage);
- TmfSyncMessage msg = (TmfSyncMessage) selection.get(0);
+ msg = (TmfSyncMessage) selection.get(0);
assertEquals("synchToTime", TC_001_MESSAGE_NAME, msg.getName());
assertEquals("synchToTime", 0, TC_001_TIME_VALUE.compareTo(msg.getStartTime(), false));
assertEquals("synchToTime", TC_001_START_OCCURRANCE, msg.getStartOccurrence());
assertEquals("synchToTime", TC_001_END_OCCURRANCE, msg.getEndOccurrence());
assertEquals("synchToTime", TC_001_START_LIFELINE, msg.getStartLifeline().getName());
assertEquals("synchToTime", TC_001_END_LIFELINE, msg.getEndLifeline().getName());
+ }
- /*
- * Test Case: 002
- * Description: Verify synchToTime (exact time outside of page), selection of message in page
- * Verified Methods: loader.syncToTime(), loader.moveToMessage(), loader.moveToPage()
- * Expected result: Correct message is selected.
- */
+ /**
+ * Test Case: 002
+ * Description: Verify synchToTime (exact time outside of page), selection of message in page
+ * Verified Methods: loader.syncToTime(), loader.moveToMessage(), loader.moveToPage()
+ * Expected result: Correct message is selected.
+ */
+ @Test
+ public void verifySynchToTimeOutsidePage() {
fFacility.getTrace().broadcast(new TmfTimeSynchSignal(this, TC_002_TIME_VALUE));
fFacility.getLoader().waitForCompletion();
fFacility.delay(IUml2SDTestConstants.GUI_REFESH_DELAY);
assertEquals("synchToTime", TC_002_END_OCCURRANCE, msg.getEndOccurrence());
assertEquals(TC_002_START_LIFELINE, msg.getStartLifeline().getName());
assertEquals(TC_002_END_LIFELINE, msg.getEndLifeline().getName());
+ }
- /*
- * Test Case: 003
- * Description: Verify synchToTime (timestamp doesn't exist in trace), no selection of message in page
- * Verified Methods: loader.syncToTime(), loader.moveToMessage(), loader.moveToPage()
- * Expected result: Move to correct page, currentTime is updated so that focus on the currentTime, but no selection.
- */
+ /**
+ * Test Case: 003
+ * Description: Verify synchToTime (timestamp doesn't exist in trace), no selection of message in page
+ * Verified Methods: loader.syncToTime(), loader.moveToMessage(), loader.moveToPage()
+ * Expected result: Move to correct page, currentTime is updated so that focus on the currentTime, but no selection.
+ */
+ @Test
+ public void verifySynchToTimeNonExisting() {
fFacility.getLoader().firstPage();
fFacility.getTrace().broadcast(new TmfTimeSynchSignal(this, TC_003_TIME_VALUE));
selection = fFacility.getSdView().getSDWidget().getSelection();
assertNotNull("synchToTime", selection);
assertEquals("synchToTime", 0, selection.size());
+ }
- /*
- * Test Case: 004
- * Description: Verify synchToTime (timestamp < experiment time range start)
- * Verified Methods: loader.syncToTime(), loader.moveToMessage(), loader.moveToPage()
- * Expected result: Move to first page, focus on the beginning of the page, but no selection.
- */
+ /**
+ * Test Case: 004
+ * Description: Verify synchToTime (timestamp < experiment time range start)
+ * Verified Methods: loader.syncToTime(), loader.moveToMessage(), loader.moveToPage()
+ * Expected result: Move to first page, focus on the beginning of the page, but no selection.
+ */
+ @Test
+ public void verifySynchToTimeBeforeExpStart() {
fFacility.getTrace().broadcast(new TmfTimeSynchSignal(this, TmfTimestamp.BIG_BANG));
fFacility.getLoader().waitForCompletion();
fFacility.delay(IUml2SDTestConstants.GUI_REFESH_DELAY);
selection = fFacility.getSdView().getSDWidget().getSelection();
assertNotNull("synchToTime", selection);
assertEquals("synchToTime", 0, selection.size());
+ }
- /*
- * Test Case: 005
- * Description: Verify synchToTime (timestamp > experiment time range end)
- * Verified Methods: loader.syncToTime(), loader.moveToMessage(), loader.moveToPage()
- * Expected result: Move to last page, focus on the end of the page, but no selection.
- */
+ /**
+ * Test Case: 005
+ * Description: Verify synchToTime (timestamp > experiment time range end)
+ * Verified Methods: loader.syncToTime(), loader.moveToMessage(), loader.moveToPage()
+ * Expected result: Move to last page, focus on the end of the page, but no selection.
+ */
+ @Test
+ public void verifySynchToTimeAfterExpEnd() {
fFacility.getTrace().broadcast(new TmfTimeSynchSignal(this, TmfTimestamp.BIG_CRUNCH));
fFacility.getLoader().waitForCompletion();
fFacility.delay(IUml2SDTestConstants.GUI_REFESH_DELAY);
selection = fFacility.getSdView().getSDWidget().getSelection();
assertNotNull(selection);
assertEquals("synchToTime", 0, selection.size());
+ }
- /*
- * Test Case: 006
- * Description: Verify synchToTime (timestamp of last message in page)
- * Verified Methods: loader.syncToTime(), loader.moveToMessage(), loader.moveToPage(), loader.moveToMessageInPage()
- * Expected result: Move to correct page, selection of last message in page.
- */
+ /**
+ * Test Case: 006
+ * Description: Verify synchToTime (timestamp of last message in page)
+ * Verified Methods: loader.syncToTime(), loader.moveToMessage(), loader.moveToPage(), loader.moveToMessageInPage()
+ * Expected result: Move to correct page, selection of last message in page.
+ */
+ @Test
+ public void verifySynchToTimeEqualsLast() {
fFacility.getTrace().broadcast(new TmfTimeSynchSignal(this, TC_006_TIME_VALUE));
fFacility.getLoader().waitForCompletion();
fFacility.delay(IUml2SDTestConstants.GUI_REFESH_DELAY);
msg = (TmfSyncMessage) selection.get(0);
assertEquals("synchToTime", TC_006_START_OCCURRANCE, msg.getStartOccurrence());
assertEquals("synchToTime", TC_006_END_OCCURRANCE, msg.getEndOccurrence());
+ }
- /*
- * Test Case: 007
- * Description: Verify synchToTime (timestamp of first message in page)
- * Verified Methods: loader.syncToTime(), loader.moveToMessage(), loader.moveToPage()
- * Expected result: Move to correct page, selection of last message in page.
- */
+ /**
+ * Test Case: 007
+ * Description: Verify synchToTime (timestamp of first message in page)
+ * Verified Methods: loader.syncToTime(), loader.moveToMessage(), loader.moveToPage()
+ * Expected result: Move to correct page, selection of last message in page.
+ */
+ @Test
+ public void verifySynchToTimeFirst() {
fFacility.getTrace().broadcast(new TmfTimeSynchSignal(this, TC_007_TIME_VALUE));
fFacility.getLoader().waitForCompletion();
fFacility.delay(IUml2SDTestConstants.GUI_REFESH_DELAY);
assertEquals("synchToTime", 1, selection.size());
assertEquals("synchToTime", TC_007_START_OCCURRANCE, msg.getStartOccurrence());
assertEquals("synchToTime", TC_007_END_OCCURRANCE, msg.getEndOccurrence());
+ }
- /*
- * Test Case: 008
- * Description: Verify time range signal (start, end time and current time are in same page)
- * Verified Methods: loader.synchToTimeRange(), loader.moveToMessage(), loader.moveToMessageInPage()
- * Expected result: Move to correct page(=page of start time of range), set focus on start time of range, but no selection of message.
- */
+ /**
+ * Test Case: 008
+ * Description: Verify time range signal (start, end time and current time are in same page)
+ * Verified Methods: loader.synchToTimeRange(), loader.moveToMessage(), loader.moveToMessageInPage()
+ * Expected result: Move to correct page(=page of start time of range), set focus on start time of range, but no selection of message.
+ */
+ @Test
+ public void verifyTimeRangeSamePage() {
// 9788.642228395 (page 0) -> 9789.164833324 (page 0) with selected time 9788.642228395 (page 0)
fFacility.getLoader().firstPage();
TmfTimeRange range = new TmfTimeRange(TC_008_START_TIME_VALUE, TC_008_END_TIME_VALUE);
// We actually don't want something to be selected!!!
assertNotNull("synchToTimeRange", selection);
assertEquals("synchToTimeRange", 0, selection.size());
+ }
- /*
- * Test Case: 009
- * Description: Verify time range signal (start and end time are across 2 pages)
- * Verified Methods: loader.synchToTimeRange(), loader.moveToMessage(), loader.moveToPage()
- * Expected result: Move to correct page (=page of start time of range), set focus on start time of range, but no selection of message.
- */
- range = new TmfTimeRange(TC_009_START_TIME_VALUE, TC_009_END_TIME_VALUE);
+ /**
+ * Test Case: 009
+ * Description: Verify time range signal (start and end time are across 2 pages)
+ * Verified Methods: loader.synchToTimeRange(), loader.moveToMessage(), loader.moveToPage()
+ * Expected result: Move to correct page (=page of start time of range), set focus on start time of range, but no selection of message.
+ */
+ @Test
+ public void verifyTimeRangeDifferentPages() {
+ TmfTimeRange range = new TmfTimeRange(TC_009_START_TIME_VALUE, TC_009_END_TIME_VALUE);
fFacility.getTrace().broadcast(new TmfRangeSynchSignal(this, range, TC_009_TIME_VALUE));
fFacility.getLoader().waitForCompletion();
fFacility.delay(IUml2SDTestConstants.GUI_REFESH_DELAY);
// We actually don't want something to be selected!!!
assertNotNull("synchToTimeRange", selection);
assertEquals("synchToTimeRange", 0, selection.size());
-
}
}
\ No newline at end of file