diff options
Diffstat (limited to 'lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf')
3 files changed, 58 insertions, 117 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfContextTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfContextTest.java index 17be19fe84..4f04ba58a6 100644 --- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfContextTest.java +++ b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfContextTest.java @@ -37,21 +37,17 @@ public class TmfContextTest { // Variables // ------------------------------------------------------------------------ - private final String aString = "some location"; private final Long aLong = 12345L; private final TmfTimestamp aTimestamp = new TmfTimestamp(); - private final TmfStringLocation fLocation1 = new TmfStringLocation(aString); - private final TmfLongLocation fLocation2 = new TmfLongLocation(aLong); - private final TmfTimestampLocation fLocation3 = new TmfTimestampLocation(aTimestamp); + private final TmfLongLocation fLocation1 = new TmfLongLocation(aLong); + private final TmfTimestampLocation fLocation2 = new TmfTimestampLocation(aTimestamp); private final long fRank1 = 1; private final long fRank2 = 2; - private final long fRank3 = 3; private final TmfContext fContext1 = new TmfContext(fLocation1, fRank1); private final TmfContext fContext2 = new TmfContext(fLocation2, fRank2); - private final TmfContext fContext3 = new TmfContext(fLocation3, fRank3); // ------------------------------------------------------------------------ // Constructors @@ -68,41 +64,33 @@ public class TmfContextTest { public void testTmfContextNoRank() { final TmfContext context1 = new TmfContext(fLocation1); final TmfContext context2 = new TmfContext(fLocation2); - final TmfContext context3 = new TmfContext(fLocation3); assertEquals("getLocation", fLocation1, context1.getLocation()); assertEquals("getLocation", fLocation2, context2.getLocation()); - assertEquals("getLocation", fLocation3, context3.getLocation()); assertEquals("getRank", ITmfContext.UNKNOWN_RANK, context1.getRank()); assertEquals("getRank", ITmfContext.UNKNOWN_RANK, context2.getRank()); - assertEquals("getRank", ITmfContext.UNKNOWN_RANK, context3.getRank()); } @Test public void testTmfContext() { assertEquals("getLocation", fLocation1, fContext1.getLocation()); assertEquals("getLocation", fLocation2, fContext2.getLocation()); - assertEquals("getLocation", fLocation3, fContext3.getLocation()); assertEquals("getRank", fRank1, fContext1.getRank()); assertEquals("getRank", fRank2, fContext2.getRank()); - assertEquals("getRank", fRank3, fContext3.getRank()); } @Test public void testTmfContextCopy() { final TmfContext context1 = new TmfContext(fContext1); final TmfContext context2 = new TmfContext(fContext2); - final TmfContext context3 = new TmfContext(fContext3); assertEquals("getLocation", fLocation1, context1.getLocation()); assertEquals("getLocation", fLocation2, context2.getLocation()); - assertEquals("getLocation", fLocation3, context3.getLocation()); assertEquals("getRank", fRank1, context1.getRank()); assertEquals("getRank", fRank2, context2.getRank()); - assertEquals("getRank", fRank3, context3.getRank()); } @Test @@ -219,13 +207,11 @@ public class TmfContextTest { @Test public void testToString() { - final String expected1 = "TmfContext [fLocation=" + fLocation1 + ", fRank=" + 1 + "]"; - final String expected2 = "TmfContext [fLocation=" + fLocation2 + ", fRank=" + 2 + "]"; - final String expected3 = "TmfContext [fLocation=" + fLocation3 + ", fRank=" + 3 + "]"; + final String expected1 = "TmfContext [fLocation=" + fLocation1 + ", fRank=" + fRank1 + "]"; + final String expected2 = "TmfContext [fLocation=" + fLocation2 + ", fRank=" + fRank2 + "]"; assertEquals("toString", expected1, fContext1.toString()); assertEquals("toString", expected2, fContext2.toString()); - assertEquals("toString", expected3, fContext3.toString()); } // ------------------------------------------------------------------------ @@ -238,7 +224,7 @@ public class TmfContextTest { context1.setLocation(fContext2.getLocation()); assertEquals("getLocation", fLocation2, context1.getLocation()); - assertEquals("getRank", 1, context1.getRank()); + assertEquals("getRank", fRank1, context1.getRank()); } @Test diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfLocationTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfLocationTest.java index 82ff2679e8..c9916506f0 100644 --- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfLocationTest.java +++ b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfLocationTest.java @@ -23,6 +23,7 @@ import org.eclipse.linuxtools.internal.tmf.core.trace.TmfExperimentLocation; import org.eclipse.linuxtools.internal.tmf.core.trace.TmfLocationArray; import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp; import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation; +import org.eclipse.linuxtools.tmf.core.trace.TmfLocation; import org.eclipse.linuxtools.tmf.core.trace.TmfLongLocation; import org.eclipse.linuxtools.tmf.core.trace.TmfTimestampLocation; import org.junit.Before; @@ -38,15 +39,13 @@ public class TmfLocationTest { // Variables // ------------------------------------------------------------------------ - private String aString = "some location"; private Long aLong = 12345L; private TmfTimestamp aTimestamp = new TmfTimestamp(); private TmfLocationArray aLocationArray; - private TmfStringLocation fLocation1; - private TmfStringLocation fLocation2; - private TmfLongLocation fLocation3; - private TmfTimestampLocation fLocation4; + private TmfLongLocation fLocation1; + private TmfLongLocation fLocation2; + private TmfTimestampLocation fLocation3; private TmfExperimentLocation fExpLocation; // ------------------------------------------------------------------------ @@ -55,13 +54,12 @@ public class TmfLocationTest { @Before public void setUp() { - fLocation1 = new TmfStringLocation((String) null); - fLocation2 = new TmfStringLocation(aString); - fLocation3 = new TmfLongLocation(aLong); - fLocation4 = new TmfTimestampLocation(aTimestamp); + fLocation1 = new TmfLongLocation((Long) null); + fLocation2 = new TmfLongLocation(aLong); + fLocation3 = new TmfTimestampLocation(aTimestamp); aLocationArray = new TmfLocationArray( - new ITmfLocation[] { fLocation1, fLocation2, fLocation3, fLocation4 }, - new long[] { 1, 2, 3, 4 } + new ITmfLocation[] { fLocation1, fLocation2, fLocation3 }, + new long[] { 1, 2, 3 } ); fExpLocation = new TmfExperimentLocation(aLocationArray); } @@ -73,24 +71,21 @@ public class TmfLocationTest { @Test public void testTmfLocation() { assertNull("TmfLocation", fLocation1.getLocationInfo()); - assertEquals("TmfLocation", aString, fLocation2.getLocationInfo()); - assertEquals("TmfLocation", aLong, fLocation3.getLocationInfo()); - assertEquals("TmfLocation", aTimestamp, fLocation4.getLocationInfo()); + assertEquals("TmfLocation", aLong, fLocation2.getLocationInfo()); + assertEquals("TmfLocation", aTimestamp, fLocation3.getLocationInfo()); assertEquals("TmfLocation", aLocationArray, fExpLocation.getLocationInfo()); } @Test public void testTmfLocationCopy() { - TmfStringLocation location1 = new TmfStringLocation(fLocation1); - TmfStringLocation location2 = new TmfStringLocation(fLocation2); - TmfLongLocation location3 = new TmfLongLocation(fLocation3); - TmfTimestampLocation location4 = new TmfTimestampLocation(fLocation4); + TmfLongLocation location1 = new TmfLongLocation(fLocation1); + TmfLongLocation location2 = new TmfLongLocation(fLocation2); + TmfTimestampLocation location3 = new TmfTimestampLocation(fLocation3); TmfExperimentLocation expLocation = new TmfExperimentLocation(fExpLocation); assertNull("TmfLocation", location1.getLocationInfo()); - assertEquals("TmfLocation", aString, location2.getLocationInfo()); - assertEquals("TmfLocation", aLong, location3.getLocationInfo()); - assertEquals("TmfLocation", aTimestamp, location4.getLocationInfo()); + assertEquals("TmfLocation", aLong, location2.getLocationInfo()); + assertEquals("TmfLocation", aTimestamp, location3.getLocationInfo()); assertEquals("TmfLocation", aLocationArray, expLocation.getLocationInfo()); } @@ -100,17 +95,17 @@ public class TmfLocationTest { @Test public void testHashCode() { - TmfStringLocation location1 = new TmfStringLocation((String) null); - TmfStringLocation location2 = new TmfStringLocation(aString); - TmfLongLocation location3 = new TmfLongLocation(aLong); + TmfLongLocation location1 = new TmfLongLocation((Long) null); + TmfLongLocation location2 = new TmfLongLocation(aLong); + TmfTimestampLocation location3 = new TmfTimestampLocation(aTimestamp); TmfExperimentLocation expLocation = new TmfExperimentLocation(fExpLocation); - TmfLocationArray locationArray1 = new TmfLocationArray(aLocationArray, 3, fLocation4, 5); + TmfLocationArray locationArray1 = new TmfLocationArray(aLocationArray, 2, fLocation3, 5); TmfExperimentLocation expLocation1 = new TmfExperimentLocation(locationArray1); - TmfLocationArray locationArray2 = new TmfLocationArray(aLocationArray, 3, fLocation3, 4); + TmfLocationArray locationArray2 = new TmfLocationArray(aLocationArray, 2, fLocation2, 4); TmfExperimentLocation expLocation2 = new TmfExperimentLocation(locationArray2); TmfLocationArray locationArray3 = new TmfLocationArray( - new ITmfLocation[] { fLocation1, fLocation2, fLocation3 }, - new long[] { 1, 2, 3 } + new ITmfLocation[] { fLocation1, fLocation2 }, + new long[] { 1, 2 } ); TmfExperimentLocation expLocation3 = new TmfExperimentLocation(locationArray3); @@ -130,16 +125,22 @@ public class TmfLocationTest { // toEquals // ------------------------------------------------------------------------ - private static class TmfLocation2 extends TmfStringLocation { - public TmfLocation2(String location) { + private static class TmfTestLongLocation extends TmfLocation { + public TmfTestLongLocation(Long location) { + super(location); + } + } + + private static class TmfTestLongLocation2 extends TmfTestLongLocation { + public TmfTestLongLocation2(Long location) { super(location); } } @Test public void testEqualsWrongTypes() { - ITmfLocation location1 = new TmfStringLocation(aString); - TmfLocation2 location2 = new TmfLocation2(aString); + ITmfLocation location1 = new TmfTestLongLocation(aLong); + TmfTestLongLocation location2 = new TmfTestLongLocation2(aLong); assertFalse("equals", location1.equals(location2)); assertFalse("equals", location2.equals(location1)); @@ -147,8 +148,8 @@ public class TmfLocationTest { @Test public void testEqualsWithNulls() { - TmfStringLocation location1 = new TmfStringLocation(aString); - TmfStringLocation location2 = new TmfStringLocation((String) null); + ITmfLocation location1 = new TmfLongLocation(aLong); + ITmfLocation location2 = new TmfLongLocation((Long) null); assertFalse("equals", location1.equals(location2)); assertFalse("equals", location2.equals(location1)); @@ -156,19 +157,20 @@ public class TmfLocationTest { @Test public void testEqualsReflexivity() { + assertTrue("equals", fLocation1.equals(fLocation1)); assertTrue("equals", fLocation2.equals(fLocation2)); assertTrue("equals", fLocation3.equals(fLocation3)); assertTrue("equals", fExpLocation.equals(fExpLocation)); assertTrue("equals", !fLocation2.equals(fLocation3)); assertTrue("equals", !fLocation3.equals(fLocation2)); - TmfLocationArray locationArray1 = new TmfLocationArray(aLocationArray, 3, fLocation4, 5); + TmfLocationArray locationArray1 = new TmfLocationArray(aLocationArray, 2, fLocation3, 5); TmfExperimentLocation expLocation1 = new TmfExperimentLocation(locationArray1); - TmfLocationArray locationArray2 = new TmfLocationArray(aLocationArray, 3, fLocation3, 4); + TmfLocationArray locationArray2 = new TmfLocationArray(aLocationArray, 2, fLocation2, 4); TmfExperimentLocation expLocation2 = new TmfExperimentLocation(locationArray2); TmfLocationArray locationArray3 = new TmfLocationArray( new ITmfLocation[] { fLocation1, fLocation2, fLocation3 }, - new long[] { 1, 2, 3 } + new long[] { 1, 2 } ); TmfExperimentLocation expLocation3 = new TmfExperimentLocation(locationArray3); assertTrue("equals", !fExpLocation.equals(expLocation1)); @@ -181,8 +183,8 @@ public class TmfLocationTest { @Test public void testEqualsSymmetry() { - TmfStringLocation location2 = new TmfStringLocation(aString); - TmfLongLocation location3 = new TmfLongLocation(aLong); + TmfLongLocation location2 = new TmfLongLocation(aLong); + TmfTimestampLocation location3 = new TmfTimestampLocation(aTimestamp); TmfExperimentLocation expLocation = new TmfExperimentLocation(fExpLocation); assertTrue("equals", location2.equals(fLocation2)); @@ -197,9 +199,10 @@ public class TmfLocationTest { @Test public void testEqualsTransivity() { - TmfStringLocation location1 = new TmfStringLocation(aString); - TmfStringLocation location2 = new TmfStringLocation(aString); - TmfStringLocation location3 = new TmfStringLocation(aString); + TmfLongLocation location1 = new TmfLongLocation(aLong); + TmfLongLocation location2 = new TmfLongLocation(aLong); + TmfLongLocation location3 = new TmfLongLocation(aLong); + TmfExperimentLocation expLocation1 = new TmfExperimentLocation(aLocationArray); TmfExperimentLocation expLocation2 = new TmfExperimentLocation(aLocationArray); TmfExperimentLocation expLocation3 = new TmfExperimentLocation(aLocationArray); @@ -214,8 +217,9 @@ public class TmfLocationTest { @Test public void testEqualsNull() { + assertTrue("equals", !fLocation1.equals(null)); assertTrue("equals", !fLocation2.equals(null)); - assertTrue("equals", !fLocation2.equals(null)); + assertTrue("equals", !fLocation3.equals(null)); assertTrue("equals", !fExpLocation.equals(null)); } @@ -225,24 +229,19 @@ public class TmfLocationTest { @Test public void testToString() { - String str = "some location"; - Long lng = 12345L; TmfTimestamp ts = new TmfTimestamp(); - TmfStringLocation location1 = new TmfStringLocation(str); - TmfLongLocation location2 = new TmfLongLocation(lng); - TmfTimestampLocation location3 = new TmfTimestampLocation(ts); + TmfLongLocation location1 = new TmfLongLocation(aLong); + TmfTimestampLocation location2 = new TmfTimestampLocation(ts); TmfExperimentLocation expLocation = new TmfExperimentLocation(aLocationArray); - String expected1 = "TmfStringLocation [fLocationInfo=" + str + "]"; - String expected2 = "TmfLongLocation [fLocationInfo=" + lng + "]"; - String expected3 = "TmfTimestampLocation [fLocationInfo=" + ts + "]"; - String expected4 = "TmfExperimentLocation [" + aLocationArray + "]"; + String expected1 = "TmfLongLocation [fLocationInfo=" + aLong + "]"; + String expected2 = "TmfTimestampLocation [fLocationInfo=" + ts + "]"; + String expected3 = "TmfExperimentLocation [" + aLocationArray + "]"; assertEquals("toString", expected1, location1.toString()); assertEquals("toString", expected2, location2.toString()); - assertEquals("toString", expected3, location3.toString()); - assertEquals("toString", expected4, expLocation.toString()); + assertEquals("toString", expected3, expLocation.toString()); } } diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfStringLocation.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfStringLocation.java deleted file mode 100644 index aa707fb431..0000000000 --- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfStringLocation.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Ericsson - * - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Francois Chouinard - Initial API and implementation - *******************************************************************************/ - -package org.eclipse.linuxtools.tmf.core.tests.trace; - -import org.eclipse.linuxtools.tmf.core.trace.TmfLocation; - -/** - * <b><u>TmfStringLocation</u></b> - * <p> - * Implement me. Please. - * <p> - */ -public class TmfStringLocation extends TmfLocation { - - /** - * @param location the concrete trace location - */ - public TmfStringLocation(String location) { - super(location); - } - - /** - * @param other the other location - */ - public TmfStringLocation(TmfStringLocation other) { - super(other.getLocationInfo()); - } - - @Override - public String getLocationInfo() { - return (String) super.getLocationInfo(); - } - -} |