Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Vogel2014-09-11 17:43:14 +0000
committerLars Vogel2014-09-26 08:34:00 +0000
commitcb0e7143a8eaaf14e6f56cf7c7f14b92cecc86dd (patch)
tree6d9ca7ce651073f116a289f612c61ad21e1b3a5d
parent7402ff8d42667cd3e8fa6837cad26f3f79cad4cb (diff)
downloadeclipse.platform.ui-cb0e7143a8eaaf14e6f56cf7c7f14b92cecc86dd.tar.gz
eclipse.platform.ui-cb0e7143a8eaaf14e6f56cf7c7f14b92cecc86dd.tar.xz
eclipse.platform.ui-cb0e7143a8eaaf14e6f56cf7c7f14b92cecc86dd.zip
Bug 443806 - [Tests] Update org.eclipse.ui.tests.harness to Junit 4
Change-Id: Ia9f7998c1968f6c4146de938ca1a45808e023ee3 Signed-off-by: Lars Vogel <Lars.Vogel@vogella.com>
-rw-r--r--tests/org.eclipse.ui.tests.harness/META-INF/MANIFEST.MF1
-rw-r--r--tests/org.eclipse.ui.tests.harness/src/org/eclipse/ui/tests/harness/AllTests.java27
-rw-r--r--tests/org.eclipse.ui.tests.harness/src/org/eclipse/ui/tests/harness/UITestHarnessPlugin.java66
-rw-r--r--tests/org.eclipse.ui.tests.harness/src/org/eclipse/ui/tests/harness/tests/MocksTest.java110
4 files changed, 75 insertions, 129 deletions
diff --git a/tests/org.eclipse.ui.tests.harness/META-INF/MANIFEST.MF b/tests/org.eclipse.ui.tests.harness/META-INF/MANIFEST.MF
index 874b9fcfcca..fab6d35d49d 100644
--- a/tests/org.eclipse.ui.tests.harness/META-INF/MANIFEST.MF
+++ b/tests/org.eclipse.ui.tests.harness/META-INF/MANIFEST.MF
@@ -4,7 +4,6 @@ Bundle-Name: Harness Plug-in
Bundle-SymbolicName: org.eclipse.ui.tests.harness;singleton:=true
Bundle-Version: 1.3.0.qualifier
Eclipse-BundleShape: dir
-Bundle-Activator: org.eclipse.ui.tests.harness.UITestHarnessPlugin
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.junit,
diff --git a/tests/org.eclipse.ui.tests.harness/src/org/eclipse/ui/tests/harness/AllTests.java b/tests/org.eclipse.ui.tests.harness/src/org/eclipse/ui/tests/harness/AllTests.java
index 42eeb6702f9..81ae661ba30 100644
--- a/tests/org.eclipse.ui.tests.harness/src/org/eclipse/ui/tests/harness/AllTests.java
+++ b/tests/org.eclipse.ui.tests.harness/src/org/eclipse/ui/tests/harness/AllTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * Copyright (c) 2000, 2014 IBM Corporation and others.
* 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
@@ -11,27 +11,20 @@
package org.eclipse.ui.tests.harness;
import org.eclipse.ui.tests.harness.tests.MocksTest;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
/**
- * Test the test harness :)
- *
+ * Test the test harness
+ *
* @since 3.3
*
*/
-public class AllTests extends TestSuite {
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
-
- public static Test suite() {
- return new AllTests();
- }
+@RunWith(Suite.class)
+@SuiteClasses(MocksTest.class)
+public class AllTests {
+
- public AllTests() {
- addTestSuite(MocksTest.class);
- }
}
diff --git a/tests/org.eclipse.ui.tests.harness/src/org/eclipse/ui/tests/harness/UITestHarnessPlugin.java b/tests/org.eclipse.ui.tests.harness/src/org/eclipse/ui/tests/harness/UITestHarnessPlugin.java
deleted file mode 100644
index e0d7b262b89..00000000000
--- a/tests/org.eclipse.ui.tests.harness/src/org/eclipse/ui/tests/harness/UITestHarnessPlugin.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.tests.harness;
-
-import org.eclipse.ui.plugin.*;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.osgi.framework.BundleContext;
-
-/**
- * The main plugin class to be used in the desktop.
- */
-public class UITestHarnessPlugin extends AbstractUIPlugin {
-
- //The shared instance.
- private static UITestHarnessPlugin plugin;
-
- /**
- * The constructor.
- */
- public UITestHarnessPlugin() {
- plugin = this;
- }
-
- /**
- * This method is called upon plug-in activation
- */
- public void start(BundleContext context) throws Exception {
- super.start(context);
- }
-
- /**
- * This method is called when the plug-in is stopped
- */
- public void stop(BundleContext context) throws Exception {
- super.stop(context);
- plugin = null;
- }
-
- /**
- * Returns the shared instance.
- *
- * @return the shared instance.
- */
- public static UITestHarnessPlugin getDefault() {
- return plugin;
- }
-
- /**
- * Returns an image descriptor for the image file at the given
- * plug-in relative path.
- *
- * @param path the path
- * @return the image descriptor
- */
- public static ImageDescriptor getImageDescriptor(String path) {
- return AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.ui.tests.harness", path);
- }
-}
diff --git a/tests/org.eclipse.ui.tests.harness/src/org/eclipse/ui/tests/harness/tests/MocksTest.java b/tests/org.eclipse.ui.tests.harness/src/org/eclipse/ui/tests/harness/tests/MocksTest.java
index b7a9f5cd095..af723c69a11 100644
--- a/tests/org.eclipse.ui.tests.harness/src/org/eclipse/ui/tests/harness/tests/MocksTest.java
+++ b/tests/org.eclipse.ui.tests.harness/src/org/eclipse/ui/tests/harness/tests/MocksTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006 Brad Reynolds.
+ * Copyright (c) 2006, 2014 Brad Reynolds.
* 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
@@ -7,22 +7,26 @@
*
* Contributors:
* Brad Reynolds - initial API and implementation
+ * Lars Vogel <Lars.Vogel@vogella.com> - Bug 443804
*******************************************************************************/
package org.eclipse.ui.tests.harness.tests;
-import java.lang.reflect.UndeclaredThrowableException;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
-import junit.framework.TestCase;
+import java.lang.reflect.UndeclaredThrowableException;
import org.eclipse.ui.tests.harness.util.Mocks;
+import org.junit.Before;
+import org.junit.Test;
/**
* Tests for the Mocks class.
- *
+ *
* @since 1.1
*/
-public class MocksTest extends TestCase {
+public class MocksTest {
private IPrimitive primitiveMock;
private static boolean uninitializedBoolean;
@@ -33,12 +37,14 @@ public class MocksTest extends TestCase {
private static long unitializedLong;
private static float unitializedFloat;
private static double unitializedDouble;
-
- protected void setUp() throws Exception {
+
+ @Before
+ public void setUp() {
primitiveMock = (IPrimitive) Mocks.createRelaxedMock(IPrimitive.class);
}
- public void testPrimitiveBooleanReturnType() throws Exception {
+ @Test
+ public void testPrimitiveBooleanReturnType() {
try {
boolean value = primitiveMock.getBoolean();
assertEquals(uninitializedBoolean, value);
@@ -46,17 +52,19 @@ public class MocksTest extends TestCase {
fail("exception should not have been thrown");
}
}
-
- public void testPrimitiveBooleanSetLastReturnValue() throws Exception {
+
+ @Test
+ public void testPrimitiveBooleanSetLastReturnValue() {
Boolean value = Boolean.TRUE;
primitiveMock.getBoolean();
Mocks.setLastReturnValue(primitiveMock, value);
Mocks.startChecking(primitiveMock);
-
- assertEquals(value.booleanValue(), primitiveMock.getBoolean());
+
+ assertEquals(value.booleanValue(), primitiveMock.getBoolean());
}
-
- public void testPrimitiveByteReturnType() throws Exception {
+
+ @Test
+ public void testPrimitiveByteReturnType() {
try {
byte value = primitiveMock.getByte();
assertEquals(unitializedByte, value);
@@ -64,17 +72,19 @@ public class MocksTest extends TestCase {
fail("exception should not have been thrown");
}
}
-
- public void testPrimitiveByteSetLastReturnValue() throws Exception {
+
+ @Test
+ public void testPrimitiveByteSetLastReturnValue() {
Byte value = new Byte((byte) 1);
primitiveMock.getByte();
Mocks.setLastReturnValue(primitiveMock, value);
Mocks.startChecking(primitiveMock);
-
+
assertEquals(value.byteValue(), primitiveMock.getByte());
}
-
- public void testPrimitiveCharReturnType() throws Exception {
+
+ @Test
+ public void testPrimitiveCharReturnType() {
try {
char value = primitiveMock.getChar();
assertEquals(unitializedChar, value);
@@ -82,17 +92,19 @@ public class MocksTest extends TestCase {
fail("exception should not have been thrown");
}
}
-
- public void testPrimitiveCharSetLastReturnValue() throws Exception {
+
+ @Test
+ public void testPrimitiveCharSetLastReturnValue() {
Character value = new Character('a');
primitiveMock.getChar();
Mocks.setLastReturnValue(primitiveMock, value);
Mocks.startChecking(primitiveMock);
-
+
assertEquals(value.charValue(), primitiveMock.getChar());
}
-
- public void testPrimitiveShortReturnType() throws Exception {
+
+ @Test
+ public void testPrimitiveShortReturnType() {
try {
short value = primitiveMock.getShort();
assertEquals(unitializedShort, value);
@@ -101,16 +113,18 @@ public class MocksTest extends TestCase {
}
}
- public void testPrimitiveShortSetLastReturnValue() throws Exception {
+ @Test
+ public void testPrimitiveShortSetLastReturnValue() {
Short value = new Short((short) 1);
primitiveMock.getShort();
Mocks.setLastReturnValue(primitiveMock, value);
Mocks.startChecking(primitiveMock);
-
+
assertEquals(value.shortValue(), primitiveMock.getShort());
}
-
- public void testPrimitiveIntReturnType() throws Exception {
+
+ @Test
+ public void testPrimitiveIntReturnType() {
try {
int value = primitiveMock.getInt();
assertEquals(unitializedInt, value);
@@ -118,17 +132,19 @@ public class MocksTest extends TestCase {
fail("exception should not have been thrown");
}
}
-
- public void testPrimitiveIntSetLastReturnValue() throws Exception {
+
+ @Test
+ public void testPrimitiveIntSetLastReturnValue() {
Integer value = new Integer(1);
primitiveMock.getInt();
Mocks.setLastReturnValue(primitiveMock, value);
Mocks.startChecking(primitiveMock);
-
+
assertEquals(value.intValue(), primitiveMock.getInt());
}
-
- public void testPrimitiveLongReturnType() throws Exception {
+
+ @Test
+ public void testPrimitiveLongReturnType() {
try {
long value = primitiveMock.getLong();
assertEquals(unitializedLong, value);
@@ -136,16 +152,17 @@ public class MocksTest extends TestCase {
fail("exception should not have been thrown");
}
}
-
- public void testPrimitiveLongSetLastReturnValue() throws Exception {
+
+ @Test
+ public void testPrimitiveLongSetLastReturnValue() {
Long value = new Long(1);
primitiveMock.getLong();
Mocks.setLastReturnValue(primitiveMock, value);
Mocks.startChecking(primitiveMock);
-
+
assertEquals(value.longValue(), primitiveMock.getLong());
}
-
+
public void testPrimitiveFloatReturnType() throws Exception {
try {
float value = primitiveMock.getFloat();
@@ -154,17 +171,19 @@ public class MocksTest extends TestCase {
fail("exception should not have been thrown");
}
}
-
- public void testPrimitiveFloatSetLastReturnValue() throws Exception {
+
+ @Test
+ public void testPrimitiveFloatSetLastReturnValue() {
Float value = new Float(1);
primitiveMock.getFloat();
Mocks.setLastReturnValue(primitiveMock, value);
Mocks.startChecking(primitiveMock);
-
+
assertEquals(value.floatValue(), primitiveMock.getFloat(), 0);
}
-
- public void testPrimitiveDoubleReturnType() throws Exception {
+
+ @Test
+ public void testPrimitiveDoubleReturnType() {
try {
double value = primitiveMock.getDouble();
assertEquals(unitializedDouble, value, 0);
@@ -172,13 +191,14 @@ public class MocksTest extends TestCase {
fail("exception should not have been thrown");
}
}
-
- public void testPrimitiveDoubleSetLastReturnValue() throws Exception {
+
+ @Test
+ public void testPrimitiveDoubleSetLastReturnValue() {
Double value = new Double(1);
primitiveMock.getDouble();
Mocks.setLastReturnValue(primitiveMock, value);
Mocks.startChecking(primitiveMock);
-
+
assertEquals(value.doubleValue(), primitiveMock.getDouble(), 0);
}

Back to the top