+/*******************************************************************************
+ * Copyright (c) 2012, 2014 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:
+ * Matthew Khouzam - Initial generation with CodePro tools
+ * Alexandre Montplaisir - Clean up, consolidate redundant tests
+ *******************************************************************************/
+
package org.eclipse.linuxtools.tmf.core.tests.ctfadaptor;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfLocation;
-import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
-import org.junit.After;
+import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfLocationInfo;
+import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
import org.junit.Before;
import org.junit.Test;
/**
- * The class <code>CtfLocationTest</code> contains tests for the class <code>{@link CtfLocation}</code>.
+ * The class <code>CtfLocationTest</code> contains tests for the class
+ * <code>{@link CtfLocation}</code>.
*
- * @generatedBy CodePro at 03/05/12 2:29 PM
* @author ematkho
- * @version $Revision: 1.0 $
+ * @version 1.0
*/
public class CtfLocationTest {
+
+ private CtfLocation fixture;
+
+ /**
+ * Perform pre-test initialization.
+ */
+ @Before
+ public void setUp() {
+ fixture = new CtfLocation(new CtfLocationInfo(1, 0));
+ }
+
/**
* Run the CtfLocation(Long) constructor test.
- *
- * @generatedBy CodePro at 03/05/12 2:29 PM
*/
- @SuppressWarnings("static-method")
@Test
- public void testCtfLocation_1() {
- Long location = Long.valueOf(1);
-
+ public void testCtfLocation_long() {
+ CtfLocationInfo location = new CtfLocationInfo(1, 0);
CtfLocation result = new CtfLocation(location);
- // add additional test code here
assertNotNull(result);
- assertEquals(Long.valueOf(1), result.getLocation());
+ assertEquals(1L, result.getLocationInfo().getTimestamp());
}
/**
* Run the CtfLocation(ITmfTimestamp) constructor test.
- *
- * @generatedBy CodePro at 03/05/12 2:29 PM
*/
- @SuppressWarnings("static-method")
@Test
- public void testCtfLocation_2() {
+ public void testCtfLocation_timestamp() {
ITmfTimestamp timestamp = new TmfTimestamp();
-
CtfLocation result = new CtfLocation(timestamp);
- // add additional test code here
- assertNotNull(result);
- assertEquals(new Long(0L), result.getLocation());
- }
-
- /**
- * Run the CtfLocation clone() method test.
- *
- * @generatedBy CodePro at 03/05/12 2:29 PM
- */
- @SuppressWarnings("static-method")
- @Test
- public void testClone_1() {
- CtfLocation fixture = new CtfLocation(Long.valueOf(1));
- fixture.setLocation(Long.valueOf(1));
-
- CtfLocation result = fixture.clone();
-
- // add additional test code here
assertNotNull(result);
- assertEquals(Long.valueOf(1), result.getLocation());
+ assertEquals(0L, result.getLocationInfo().getTimestamp());
}
/**
* Run the Long getLocation() method test.
- *
- * @generatedBy CodePro at 03/05/12 2:29 PM
*/
- @SuppressWarnings("static-method")
@Test
- public void testGetLocation_1() {
- CtfLocation fixture = new CtfLocation(Long.valueOf(1));
- fixture.setLocation(Long.valueOf(1));
-
- Long result = fixture.getLocation();
-
- // add additional test code here
- assertNotNull(result);
- assertEquals("1", result.toString()); //$NON-NLS-1$
- assertEquals((byte) 1, result.byteValue());
- assertEquals((short) 1, result.shortValue());
- assertEquals(1, result.intValue());
- assertEquals(1L, result.longValue());
- assertEquals(1.0f, result.floatValue(), 1.0f);
- assertEquals(1.0, result.doubleValue(), 1.0);
+ public void testGetLocation() {
+ CtfLocationInfo location = fixture.getLocationInfo();
+ long result = location.getTimestamp();
+ assertEquals(1L, result);
}
/**
* Run the void setLocation(Long) method test.
- *
- * @generatedBy CodePro at 03/05/12 2:29 PM
*/
- @SuppressWarnings("static-method")
@Test
- public void testSetLocation_1() {
- CtfLocation fixture = new CtfLocation(Long.valueOf(1));
- fixture.setLocation(Long.valueOf(1));
- Long location = Long.valueOf(1);
-
- fixture.setLocation(location);
-
- // add additional test code here
- }
-
- @SuppressWarnings("static-method")
- @Test
- public void testToString1(){
- CtfLocation fixture = new CtfLocation(new Long(1337L));
- assertEquals("CtfLocation: 1337",fixture.toString()); //$NON-NLS-1$
- }
-
- @SuppressWarnings("static-method")
- @Test
- public void testToString2(){
- CtfLocation fixture = new CtfLocation(new Long(-1L));
- assertEquals("CtfLocation: INVALID",fixture.toString()); //$NON-NLS-1$
- }
-
- /**
- * Perform pre-test initialization.
- *
- * @generatedBy CodePro at 03/05/12 2:29 PM
- */
- @Before
- public void setUp() {
- // add additional set up code here
+ public void testSetLocation() {
+ CtfLocationInfo location = new CtfLocationInfo(1337, 7331);
+ fixture = new CtfLocation(location);
}
/**
- * Perform post-test clean-up.
- *
- * @generatedBy CodePro at 03/05/12 2:29 PM
+ * Test the toString() method with a valid location.
*/
- @After
- public void tearDown() {
- // Add additional tear down code here
+ @Test
+ public void testToString_valid(){
+ CtfLocation fixture2 = new CtfLocation(new CtfLocationInfo(1337, 7331));
+ assertEquals("CtfLocation [fLocationInfo=Element [1337/7331]]", fixture2.toString());
}
/**
- * Launch the test.
- *
- * @param args the command line arguments
- *
- * @generatedBy CodePro at 03/05/12 2:29 PM
+ * Test the toString() method with an invalid location.
*/
- public static void main(String[] args) {
- new org.junit.runner.JUnitCore().run(CtfLocationTest.class);
+ @Test
+ public void testToString_invalid(){
+ CtfLocation fixture2 = new CtfLocation(new CtfLocationInfo(-1, -1));
+ assertEquals("CtfLocation [INVALID]", fixture2.toString());
}
-}
\ No newline at end of file
+}