Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Vogel2015-08-05 10:11:08 +0000
committerLars Vogel2015-08-10 17:11:55 +0000
commit06e78bd6a1fa76a63724ea2aaf06ce165f757442 (patch)
tree48e04ddc9c0bf258d539720eefda016ca8386723
parent513f1277bc46baf9407b99b22febef4e5e049e9d (diff)
downloadeclipse.platform.runtime-06e78bd6a1fa76a63724ea2aaf06ce165f757442.tar.gz
eclipse.platform.runtime-06e78bd6a1fa76a63724ea2aaf06ce165f757442.tar.xz
eclipse.platform.runtime-06e78bd6a1fa76a63724ea2aaf06ce165f757442.zip
Bug 474274 - [Tests] Move org.eclipse.e4.core.tests to JUnit 4
Change-Id: I86e25cbf397cd972b011afd5a12d3d572f050635 Signed-off-by: Lars Vogel <Lars.Vogel@vogella.com>
-rw-r--r--tests/org.eclipse.e4.core.tests/META-INF/MANIFEST.MF6
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/ActivationTest.java15
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/ContextDynamicTest.java23
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/DependenciesLeakTest.java18
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/EclipseContextTest.java33
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/ReparentingTest.java37
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/RunAndTrackTest.java31
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ActivationInjectionTest.java11
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/AnnotationsInjectionTest.java46
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/Bug317183Test.java10
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ComplexDisposalTest.java23
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ContextFunctionDynamicsTest.java15
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ContextInjectionDisposeTest.java36
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ContextInjectionFactoryTest.java19
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ContextInjectionTest.java32
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/DisposingReferencedContextTest.java20
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ExtraDependenciesTest.java18
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/GenericsInjectionTest.java14
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/GroupedUpdatesTest.java12
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/InjectStaticContextTest.java13
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/InjectionOrderTest.java10
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/InjectionUpdateTest.java20
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/InvokeInRATTest.java11
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ParentContextDisposalTest.java9
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ProviderInjectionTest.java26
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ServiceContextTest.java38
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/TestConstructorInjection.java21
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/performance/ContextPerformanceTest.java14
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/AutoConstructTest.java12
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/DisposeClassLinkTest.java26
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/InjectArraysTest.java12
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/InjectBaseTypeTest.java18
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/InjectionOrderTest.java12
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/InjectionResultLeakTest.java13
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/InvokeTest.java9
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/InvokeTestMissingAnnotation.java12
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/RecursiveObjectCreationTest.java13
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/RequestorTest.java26
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/extensions/ExtendedSupplierInjectionTests.java15
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/extensions/InjectionEventTest.java30
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/extensions/InjectionMixedSuppliersTest.java9
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/extensions/InjectionOSGiHandlerTest.java14
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/extensions/InjectionOSGiTest.java31
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/extensions/InjectionPreferencesTest.java20
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/manual/ComputedValueLimitationTest.java27
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/manual/InjectionErrorReportingTest.java19
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/nls/LocaleTransformationTest.java9
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/nls/MessageRegistryTest.java27
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/nls/NLSTest.java46
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/tests/CoreTestSuite.java109
50 files changed, 681 insertions, 409 deletions
diff --git a/tests/org.eclipse.e4.core.tests/META-INF/MANIFEST.MF b/tests/org.eclipse.e4.core.tests/META-INF/MANIFEST.MF
index 41e8e1664..263984570 100644
--- a/tests/org.eclipse.e4.core.tests/META-INF/MANIFEST.MF
+++ b/tests/org.eclipse.e4.core.tests/META-INF/MANIFEST.MF
@@ -4,8 +4,7 @@ Bundle-Name: E4 Core Tests
Bundle-SymbolicName: org.eclipse.e4.core.tests
Bundle-Version: 1.0.100.qualifier
Bundle-Activator: org.eclipse.e4.core.internal.tests.CoreTestsActivator
-Require-Bundle: org.junit;bundle-version="3.8.2",
- org.eclipse.osgi;bundle-version="3.6.0",
+Require-Bundle: org.eclipse.osgi;bundle-version="3.6.0",
org.eclipse.equinox.preferences;bundle-version="3.3.0",
org.eclipse.e4.core.di,
org.eclipse.e4.core.di.extensions,
@@ -14,7 +13,8 @@ Require-Bundle: org.junit;bundle-version="3.8.2",
com.google.code.atinject.tck;bundle-version="1.0.0",
org.eclipse.equinox.registry;bundle-version="3.5.0",
org.eclipse.core.tests.harness;bundle-version="3.6.0",
- org.eclipse.e4.core.services;bundle-version="1.1.0"
+ org.eclipse.e4.core.services;bundle-version="1.1.0",
+ org.junit;bundle-version="4.12.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Import-Package: javax.annotation;version="1.0.0",
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/ActivationTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/ActivationTest.java
index c8c0b1b26..8ba456740 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/ActivationTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/ActivationTest.java
@@ -7,21 +7,24 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Lars Vogel <Lars.Vogel@vogella.com> - Bug 474274
******************************************************************************/
package org.eclipse.e4.core.internal.tests.contexts;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
import javax.inject.Inject;
import javax.inject.Named;
-import junit.framework.TestCase;
-
import org.eclipse.e4.core.contexts.ContextFunction;
import org.eclipse.e4.core.contexts.EclipseContextFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.contexts.RunAndTrack;
+import org.junit.Test;
-public class ActivationTest extends TestCase {
+public class ActivationTest {
static public class TestRAT extends ContextFunction {
@Override
@@ -32,6 +35,7 @@ public class ActivationTest extends TestCase {
}
}
+ @Test
public void testContextActivation() {
IEclipseContext rootContext = EclipseContextFactory.create("root");
rootContext.set("testRAT", new TestRAT());
@@ -110,6 +114,7 @@ public class ActivationTest extends TestCase {
assertEquals("child22", child2.get("testRAT"));
}
+ @Test
public void testGetActive() {
IEclipseContext root = EclipseContextFactory.create("root");
@@ -140,6 +145,7 @@ public class ActivationTest extends TestCase {
assertEquals("5", child2.getActive("var"));
}
+ @Test
public void testGetActiveBug384425() {
IEclipseContext root = EclipseContextFactory.create("root");
@@ -161,6 +167,7 @@ public class ActivationTest extends TestCase {
assertNull(child2.getActive("var"));
}
+ @Test
public void testGetActiveRAT() {
IEclipseContext root = EclipseContextFactory.create("root");
@@ -200,6 +207,7 @@ public class ActivationTest extends TestCase {
assertEquals("2", result[0]);
}
+ @Test
public void testGetActiveRATNumberOfCalls() {
IEclipseContext root = EclipseContextFactory.create("root");
@@ -256,6 +264,7 @@ public class ActivationTest extends TestCase {
* A variation of {@link #testGetActiveRATNumberOfCalls()} that
* uses distinct values in the leaf contexts.
*/
+ @Test
public void testGetActiveRATNumberOfCalls2() {
IEclipseContext root = EclipseContextFactory.create("root");
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/ContextDynamicTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/ContextDynamicTest.java
index 576852bd5..c2ca11d7c 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/ContextDynamicTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/ContextDynamicTest.java
@@ -7,32 +7,27 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Lars Vogel <Lars.Vogel@vogella.com> - Bug 474274
*******************************************************************************/
package org.eclipse.e4.core.internal.tests.contexts;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
import org.eclipse.e4.core.contexts.ContextFunction;
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.EclipseContextFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.internal.tests.contexts.inject.ObjectBasic;
+import org.junit.Test;
/**
* Tests for the basic context functionality
*/
-public class ContextDynamicTest extends TestCase {
+public class ContextDynamicTest {
- public ContextDynamicTest() {
- super();
- }
-
- public ContextDynamicTest(String name) {
- super(name);
- }
+ @Test
public void testReplaceFunctionWithStaticValue() {
IEclipseContext parent = EclipseContextFactory.create();
IEclipseContext context = parent.createChild();
@@ -53,6 +48,7 @@ public class ContextDynamicTest extends TestCase {
/**
* Tests objects being added and removed from the context
*/
+ @Test
public synchronized void testAddRemove() {
Integer testInt = new Integer(123);
String testString = new String("abc");
@@ -115,6 +111,7 @@ public class ContextDynamicTest extends TestCase {
/**
* Tests objects being added and removed from the context
*/
+ @Test
public synchronized void testParentAddRemove() {
Integer testInt = new Integer(123);
String testString = new String("abc");
@@ -175,8 +172,4 @@ public class ContextDynamicTest extends TestCase {
assertNull(userObject.c);
}
- public static Test suite() {
- return new TestSuite(ContextDynamicTest.class);
- }
-
}
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/DependenciesLeakTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/DependenciesLeakTest.java
index 3b0b21d17..bdbeea59d 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/DependenciesLeakTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/DependenciesLeakTest.java
@@ -1,23 +1,27 @@
/*******************************************************************************
- * Copyright (c) 2010, 2013 IBM Corporation and others.
+ * Copyright (c) 2010, 2015 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:
- * Stefan M�cke - initial API and implementation
+ * Stefan Mücke - initial API and implementation
+ * Lars Vogel <Lars.Vogel@vogella.com> - Bug 474274
*******************************************************************************/
package org.eclipse.e4.core.internal.tests.contexts;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import org.eclipse.e4.core.contexts.ContextFunction;
import org.eclipse.e4.core.contexts.EclipseContextFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.internal.contexts.EclipseContext;
+import org.junit.Before;
+import org.junit.Test;
-public class DependenciesLeakTest extends TestCase {
+public class DependenciesLeakTest {
final static String LEGACY_H_ID = "legacy::handler::"; //$NON-NLS-1$
@@ -40,13 +44,14 @@ public class DependenciesLeakTest extends TestCase {
private IEclipseContext perspectiveContext;
private IEclipseContext partContext;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
windowContext = EclipseContextFactory.create("Window");
perspectiveContext = windowContext.createChild("Perspective");
partContext = perspectiveContext.createChild("Part");
}
+ @Test
public void testBug() {
// register a handler
Object handler = "<foo.bar.handler>";
@@ -72,6 +77,7 @@ public class DependenciesLeakTest extends TestCase {
assertNoListeners(partContext);
}
+ @Test
public void testInvalidateDirectly() {
windowContext.set("x", 42);
windowContext.set("y", 11);
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/EclipseContextTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/EclipseContextTest.java
index 63180ac05..ff448442a 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/EclipseContextTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/EclipseContextTest.java
@@ -7,10 +7,14 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Lars Vogel <Lars.Vogel@vogella.com> - Bug 474274
*******************************************************************************/
package org.eclipse.e4.core.internal.tests.contexts;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import org.eclipse.e4.core.contexts.ContextFunction;
import org.eclipse.e4.core.contexts.EclipseContextFactory;
@@ -18,9 +22,11 @@ import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.contexts.RunAndTrack;
import org.eclipse.e4.core.di.IInjector;
import org.eclipse.e4.core.internal.contexts.EclipseContext;
+import org.junit.Before;
+import org.junit.Test;
import org.osgi.framework.FrameworkUtil;
-public class EclipseContextTest extends TestCase {
+public class EclipseContextTest {
private static class ComputedValueBar extends ContextFunction {
@Override
@@ -34,14 +40,14 @@ public class EclipseContextTest extends TestCase {
private int runCounter;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- parentContext = EclipseContextFactory.create(getName() + "-parent");
- context = parentContext.createChild(getName());
+ @Before
+ public void setUp() throws Exception {
+ parentContext = EclipseContextFactory.create("EclipseContextTest" + "-parent");
+ context = parentContext.createChild("EclipseContextTest");
runCounter = 0;
}
+ @Test
public void testContainsKey() {
assertFalse("1.0", context.containsKey("function"));
assertFalse("1.1", context.containsKey("separator"));
@@ -57,6 +63,7 @@ public class EclipseContextTest extends TestCase {
assertFalse("4.0", context.containsKey("separator"));
}
+ @Test
public void testGet() {
assertNull(context.get("foo"));
context.set("foo", "bar");
@@ -72,6 +79,7 @@ public class EclipseContextTest extends TestCase {
assertEquals("baz", context.get("foo"));
}
+ @Test
public void testGetLocal() {
assertNull(context.getLocal("foo"));
context.set("foo", "bar");
@@ -90,6 +98,7 @@ public class EclipseContextTest extends TestCase {
/**
* Tests that a context no longer looks up values from its parent when disposed.
*/
+ @Test
public void testDisposeRemovesParentReference() {
assertNull(context.get("foo"));
parentContext.set("foo", "bar");
@@ -103,6 +112,7 @@ public class EclipseContextTest extends TestCase {
* Tests handling of a context function defined in the parent that uses values defined in the
* child
*/
+ @Test
public void testContextFunctionInParent() {
IEclipseContext parent = EclipseContextFactory.create();
final IEclipseContext child = parent.createChild();
@@ -124,6 +134,7 @@ public class EclipseContextTest extends TestCase {
assertEquals(11, ((Integer) child.get("sum")).intValue());
}
+ @Test
public void testRunAndTrack() {
final Object[] value = new Object[1];
context.runAndTrack(new RunAndTrack() {
@@ -167,6 +178,7 @@ public class EclipseContextTest extends TestCase {
/**
* Tests registering a single run and track instance multiple times with the same context.
*/
+ @Test
public void testRegisterRunAndTrackTwice() {
final Object[] value = new Object[1];
RunAndTrack runnable = new RunAndTrack() {
@@ -190,6 +202,7 @@ public class EclipseContextTest extends TestCase {
}
+ @Test
public void testRunAndTrackMultipleValues() {
IEclipseContext parent = EclipseContextFactory.create("ParentContext");
final IEclipseContext child = parent.createChild("ChildContext");
@@ -218,6 +231,7 @@ public class EclipseContextTest extends TestCase {
assertEquals(3, runCounter);
}
+ @Test
public void testModify() {
IEclipseContext grandParent = EclipseContextFactory.create();
IEclipseContext parent = grandParent.createChild();
@@ -299,6 +313,7 @@ public class EclipseContextTest extends TestCase {
assertTrue(exception);
}
+ @Test
public void testRemoveValueComputationOnDispose() {
IEclipseContext parent = EclipseContextFactory.create("ParentContext");
IEclipseContext child = parent.createChild("ChildContext");
@@ -312,6 +327,7 @@ public class EclipseContextTest extends TestCase {
assertEquals(0, listenersCount(parent));
}
+ @Test
public void testNullInheritance() {
IEclipseContext parent = EclipseContextFactory.create("ParentContext");
IEclipseContext child = parent.createChild("ChildContext");
@@ -320,6 +336,7 @@ public class EclipseContextTest extends TestCase {
assertNull(child.get("x"));
}
+ @Test
public void testGetCFNotAValue() {
IEclipseContext context = EclipseContextFactory.create("ParentContext");
context.set("x", new ContextFunction() {
@@ -345,6 +362,7 @@ public class EclipseContextTest extends TestCase {
context.dispose();
}
+ @Test
public void testGetCFNotAValueToParent() {
IEclipseContext parent = EclipseContextFactory.create("ParentContext");
IEclipseContext child = parent.createChild();
@@ -368,6 +386,7 @@ public class EclipseContextTest extends TestCase {
parent.dispose();
}
+ @Test
public void testContextFunctionOrdering() {
IEclipseContext osgiContext = EclipseContextFactory.getServiceContext(FrameworkUtil.getBundle(getClass()).getBundleContext());
assertEquals("High",osgiContext.get("test.contextfunction.ranking"));
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/ReparentingTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/ReparentingTest.java
index 14092c14b..f2df2cf5e 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/ReparentingTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/ReparentingTest.java
@@ -7,10 +7,16 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Lars Vogel <Lars.Vogel@vogella.com> - Bug 474274
******************************************************************************/
package org.eclipse.e4.core.internal.tests.contexts;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
import javax.inject.Inject;
import javax.inject.Named;
@@ -20,31 +26,19 @@ import org.eclipse.e4.core.contexts.EclipseContextFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.contexts.RunAndTrack;
import org.eclipse.e4.core.internal.tests.contexts.inject.ObjectSuperClass;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.Test;
/**
* Test for changing a context's parent.
*/
-public class ReparentingTest extends TestCase {
- public static Test suite() {
- return new TestSuite(ReparentingTest.class);
- }
+public class ReparentingTest {
- public ReparentingTest() {
- super();
- }
-
- public ReparentingTest(String name) {
- super(name);
- }
/**
* Tests handling of a context function defined in the parent when the parent is changed to no
* longer have the function.
*/
+ @Test
public void testContextFunctionInParentRemove() {
IEclipseContext parent = EclipseContextFactory.create("parent");
final IEclipseContext child = parent.createChild("child");
@@ -64,6 +58,7 @@ public class ReparentingTest extends TestCase {
* Tests handling of a context function defined in the parent when the parent is changed to have
* the function
*/
+ @Test
public void testContextFunctionInParentAdd() {
// setup
IEclipseContext parent = EclipseContextFactory.create();
@@ -87,6 +82,7 @@ public class ReparentingTest extends TestCase {
assertEquals(2, ((Integer) child.get("sum")).intValue());
}
+ @Test
public void testContextFunctionNullBecomeParent() {
final IEclipseContext child = EclipseContextFactory.create();
child.set("sum", new AddContextFunction());
@@ -99,6 +95,7 @@ public class ReparentingTest extends TestCase {
}
+ @Test
public void testContextFunctionParentBecomeNull() {
IEclipseContext parent = EclipseContextFactory.create();
final IEclipseContext child = parent.createChild();
@@ -110,6 +107,7 @@ public class ReparentingTest extends TestCase {
assertEquals(0, ((Integer) child.get("sum")).intValue());
}
+ @Test
public void testContextFunctionSwitchParent() {
IEclipseContext parent = EclipseContextFactory.create();
final IEclipseContext child = parent.createChild();
@@ -127,6 +125,7 @@ public class ReparentingTest extends TestCase {
/**
* Tests a child switching from a null parent to a non-null parent.
*/
+ @Test
public void testRunAndTrackNullBecomesParent() {
final String[] value = new String[1];
final IEclipseContext child = EclipseContextFactory.create();
@@ -147,6 +146,7 @@ public class ReparentingTest extends TestCase {
/**
* Tests a child switching from a non-null parent to a null parent.
*/
+ @Test
public void testRunAndTrackParentBecomeNull() {
final String[] value = new String[1];
IEclipseContext parent = EclipseContextFactory.create();
@@ -164,6 +164,7 @@ public class ReparentingTest extends TestCase {
assertNull(value[0]);
}
+ @Test
public void testRunAndTrackSwitchParent() {
final String[] value = new String[1];
IEclipseContext parent = EclipseContextFactory.create();
@@ -187,6 +188,7 @@ public class ReparentingTest extends TestCase {
* Tests an object consuming simple values from a parent context, and a parent change causes a
* change in simple values. TODO: Still fails
*/
+ @Test
public void testInjectSwitchParent() {
IEclipseContext oldParent = EclipseContextFactory.create();
@@ -214,6 +216,7 @@ public class ReparentingTest extends TestCase {
* Tests an object consuming services from a grandparent. A parent switch where the grandparent
* stays unchanged should ideally not cause changes for the injected object.
*/
+ @Test
public void testInjectSwitchParentSameGrandparent() {
IEclipseContext grandpa = EclipseContextFactory.create();
grandpa.set("String", "field");
@@ -232,6 +235,7 @@ public class ReparentingTest extends TestCase {
assertEquals(1, object.setStringCalled);
}
+ @Test
public void testUpdateSameParent() {
final Boolean[] called = new Boolean[1] ;
IEclipseContext parent = EclipseContextFactory.create("parent");
@@ -262,6 +266,7 @@ public class ReparentingTest extends TestCase {
// empty
}
+ @Test
public void testUpdateSameParentCalculated() {
final int[] testServiceCount = new int[1];
testServiceCount[0] = 0;
@@ -282,6 +287,7 @@ public class ReparentingTest extends TestCase {
assertEquals(1, testServiceCount[0]);
}
+ @Test
public void testBug468048_contextFunction() {
IEclipseContext p1 = EclipseContextFactory.create("parent1");
p1.set("sample", new ContextFunction() {
@@ -307,6 +313,7 @@ public class ReparentingTest extends TestCase {
assertEquals(Integer.valueOf(2), leaf.get("sample"));
}
+ @Test
public void testBug468048_injection() {
IEclipseContext p1 = EclipseContextFactory.create("parent1");
p1.set("sample", new ContextFunction() {
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/RunAndTrackTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/RunAndTrackTest.java
index 6f22b3447..810320ed8 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/RunAndTrackTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/RunAndTrackTest.java
@@ -7,26 +7,31 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Lars Vogel <Lars.Vogel@vogella.com> - Bug 474274
******************************************************************************/
package org.eclipse.e4.core.internal.tests.contexts;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import junit.framework.TestCase;
-
import org.eclipse.e4.core.contexts.ContextFunction;
import org.eclipse.e4.core.contexts.EclipseContextFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.contexts.RunAndTrack;
import org.eclipse.e4.core.internal.tests.CoreTestsActivator;
+import org.junit.After;
+import org.junit.Test;
/**
* Tests for {@link org.eclipse.e4.core.RunAndTrack.context.IRunAndTrack}.
*/
-public class RunAndTrackTest extends TestCase {
+public class RunAndTrackTest {
private static final class TestRAT extends RunAndTrack {
@@ -111,16 +116,16 @@ public class RunAndTrackTest extends TestCase {
return contexts;
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
for (Iterator<IEclipseContext> i = createdContexts.iterator(); i.hasNext();) {
IEclipseContext context = i.next();
context.dispose();
}
createdContexts.clear();
- super.tearDown();
}
+ @Test
public void testActiveChain() throws Exception {
final IEclipseContext workbenchContext = getGlobalContext();
workbenchContext.set("activePart", new ActivePartLookupFunction());
@@ -129,6 +134,7 @@ public class RunAndTrackTest extends TestCase {
assertEquals("part0", workbenchContext.get(ACTIVE_PART));
}
+ @Test
public void testActiveChange() throws Exception {
final IEclipseContext workbenchContext = getGlobalContext();
workbenchContext.set("activePart", new ActivePartLookupFunction());
@@ -147,6 +153,7 @@ public class RunAndTrackTest extends TestCase {
*
* @throws Exception
*/
+ @Test
public void testRunAndTrackComplex() throws Exception {
final IEclipseContext workbenchContext = getGlobalContext();
workbenchContext.set("activePart", new ActivePartLookupFunction());
@@ -203,6 +210,7 @@ public class RunAndTrackTest extends TestCase {
assertEquals("problemViews0", packageStack[0].get(ACTIVE_PART_ID));
}
+ @Test
public void testRunAndTrackSimple() throws Exception {
final IEclipseContext workbenchContext = getGlobalContext();
workbenchContext.set("activePart", new ActivePartLookupFunction());
@@ -233,6 +241,7 @@ public class RunAndTrackTest extends TestCase {
/**
* Test how a RAT responds to a change hidden from it; changed value is == to child value
*/
+ @Test
public void testSetHiddenValueToChildObject() {
final String newRootValue = "child";
@@ -242,6 +251,7 @@ public class RunAndTrackTest extends TestCase {
/**
* Test how a RAT responds to a change hidden from it; changed value is != to child value
*/
+ @Test
public void testSetHiddenValueToDifferentObject() {
final String newRootValue = "other";
@@ -251,6 +261,7 @@ public class RunAndTrackTest extends TestCase {
/**
* Test how a RAT responds to a change hidden from it; changed value is != to child value (but is .equals())
*/
+ @Test
public void testSetHiddenValueToObjectEqualToChild() {
// avoid compiler's pushing all my strings into a single string pool
final String newRootValue = new String("child");
@@ -261,6 +272,7 @@ public class RunAndTrackTest extends TestCase {
/**
* Test how a RAT responds to a change hidden from it; changed value is == to root value
*/
+ @Test
public void testSetHiddenValueToRootObject() {
final String newRootValue = "root";
@@ -270,6 +282,7 @@ public class RunAndTrackTest extends TestCase {
/**
* Test how a RAT responds to a change hidden from it; changed value is != to root value (but is .equals())
*/
+ @Test
public void testSetHiddenValueToEqualRootObject() {
// avoid compiler's pushing all my strings into a single string pool
final String newRootValue = new String("root");
@@ -280,6 +293,7 @@ public class RunAndTrackTest extends TestCase {
/**
* Test how a RAT responds to a change hidden from it; changed value is == to root value
*/
+ @Test
public void testSetHiddenValueToNull() {
final String newRootValue = null;
@@ -346,6 +360,7 @@ public class RunAndTrackTest extends TestCase {
* Test that a variable change in a context hidden from a RAT in
* a child context does not re-run the RAT.
*/
+ @Test
public void testRemoveHiddenVariable() {
doHiddenValueChangeTest(new ITestAction() {
@@ -361,6 +376,7 @@ public class RunAndTrackTest extends TestCase {
* Test that setting a context variable to it's existing
* value does not re-run dependent RATs
*/
+ @Test
public void testSetContextVarToSameObject() {
doSingleContextChangeTest(new ITestAction() {
@Override
@@ -374,6 +390,7 @@ public class RunAndTrackTest extends TestCase {
* Test that setting a context variable to a value that {@link Object#equals(Object) equals}
* the current value, but is same object DOES re-run dependent RATs.
*/
+ @Test
public void testSetContextVarToEqualObject() {
doSingleContextChangeTest(new ITestAction() {
@Override
@@ -387,6 +404,7 @@ public class RunAndTrackTest extends TestCase {
* Test that setting a context variable to a different object, not equal to the
* current value re-runs dependent RATs.
*/
+ @Test
public void testSetContextVarToOtherObject() {
doSingleContextChangeTest(new ITestAction() {
@Override
@@ -399,6 +417,7 @@ public class RunAndTrackTest extends TestCase {
/**
* Test that removing a context variable re-runs dependent RATs.
*/
+ @Test
public void testRemoveContextVar() {
doSingleContextChangeTest(new ITestAction() {
@Override
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ActivationInjectionTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ActivationInjectionTest.java
index 3dc1b57d3..971aecdaf 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ActivationInjectionTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ActivationInjectionTest.java
@@ -7,23 +7,25 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Lars Vogel <Lars.Vogel@vogella.com> - Bug 474274
******************************************************************************/
package org.eclipse.e4.core.internal.tests.contexts.inject;
+import static org.junit.Assert.assertEquals;
+
import javax.inject.Inject;
import javax.inject.Named;
-import junit.framework.TestCase;
-
import org.eclipse.e4.core.contexts.Active;
import org.eclipse.e4.core.contexts.ContextFunction;
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.EclipseContextFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.Optional;
+import org.junit.Test;
-public class ActivationInjectionTest extends TestCase {
+public class ActivationInjectionTest {
static public class TestRAT extends ContextFunction {
@Override
@@ -49,6 +51,7 @@ public class ActivationInjectionTest extends TestCase {
}
}
+ @Test
public void testContextActivation() {
IEclipseContext rootContext = EclipseContextFactory.create("root");
rootContext.set("testRAT", new TestRAT());
@@ -105,6 +108,7 @@ public class ActivationInjectionTest extends TestCase {
}
}
+ @Test
public void testActivationInjection() {
IEclipseContext rootContext = EclipseContextFactory.create("root");
@@ -153,6 +157,7 @@ public class ActivationInjectionTest extends TestCase {
public Integer number;
}
+ @Test
public void testInjection() {
IEclipseContext rootContext = EclipseContextFactory.create("root");
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/AnnotationsInjectionTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/AnnotationsInjectionTest.java
index 51c449f42..0e5230d84 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/AnnotationsInjectionTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/AnnotationsInjectionTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2013 IBM Corporation and others.
+ * Copyright (c) 2009, 2015 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
@@ -7,42 +7,35 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Lars Vogel <Lars.Vogel@vogella.com> - Bug 474274
*******************************************************************************/
package org.eclipse.e4.core.internal.tests.contexts.inject;
+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 javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.inject.Inject;
import javax.inject.Named;
-import junit.framework.AssertionFailedError;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.EclipseContextFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.core.di.annotations.Optional;
+import org.junit.Test;
+import junit.framework.AssertionFailedError;
/**
* Tests for the basic context injection functionality
*/
-public class AnnotationsInjectionTest extends TestCase {
-
- public static Test suite() {
- return new TestSuite(AnnotationsInjectionTest.class);
- }
+public class AnnotationsInjectionTest {
- public AnnotationsInjectionTest() {
- super();
- }
-
- public AnnotationsInjectionTest(String name) {
- super(name);
- }
+ @Test
public void testContextSetOneArg() {
class TestData {
// empty
@@ -79,6 +72,7 @@ public class AnnotationsInjectionTest extends TestCase {
assertEquals(1, object.contextSetCalled);
}
+ @Test
public void testPostConstruct() {
class TestData {
// empty
@@ -117,6 +111,7 @@ public class AnnotationsInjectionTest extends TestCase {
/**
* Tests basic context injection
*/
+ @Test
public synchronized void testInjection() {
Integer testInt = new Integer(123);
String testString = new String("abc");
@@ -154,6 +149,7 @@ public class AnnotationsInjectionTest extends TestCase {
/**
* Tests that fields are injected before methods.
*/
+ @Test
public void testFieldMethodOrder() {
final AssertionFailedError[] error = new AssertionFailedError[1];
class TestData {
@@ -181,23 +177,27 @@ public class AnnotationsInjectionTest extends TestCase {
context.set("valueMethod", methodValue);
Injected object = new Injected();
ContextInjectionFactory.inject(object, context);
- if (error[0] != null)
+ if (error[0] != null) {
throw error[0];
+ }
assertEquals(fieldValue, object.injectedField);
assertEquals(methodValue, object.methodValue);
// removing method value, the field should still have value
context.remove("valueMethod");
- if (error[0] != null)
+ if (error[0] != null) {
throw error[0];
+ }
assertEquals(fieldValue, object.injectedField);
assertNull(object.methodValue);
context.dispose();
- if (error[0] != null)
+ if (error[0] != null) {
throw error[0];
+ }
}
+ @Test
public void testOptionalInjection() {
Integer testInt = new Integer(123);
IEclipseContext context = EclipseContextFactory.create();
@@ -229,6 +229,7 @@ public class AnnotationsInjectionTest extends TestCase {
assertEquals(testFloat, userObject.f);
}
+ @Test
public void testOptionalInvoke() {
class TestObject {
@@ -260,6 +261,7 @@ public class AnnotationsInjectionTest extends TestCase {
/**
* Tests that a class with multiple inherited post-construct / pre-destroy methods.
*/
+ @Test
public void testInheritedSpecialMethods() {
IEclipseContext context = EclipseContextFactory.create();
context.set(Integer.class.getName(), new Integer(123));
@@ -287,6 +289,7 @@ public class AnnotationsInjectionTest extends TestCase {
assertEquals(1, userObject.overriddenPreDestroyCount);
}
+ @Test
public void testInvoke() {
class TestData {
public String value;
@@ -319,6 +322,7 @@ public class AnnotationsInjectionTest extends TestCase {
assertEquals("abc", object.myString);
}
+ @Test
public void testPreDestroy() {
class TestData {
// empty
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/Bug317183Test.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/Bug317183Test.java
index 29fcf2dfa..cc8b9f7d4 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/Bug317183Test.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/Bug317183Test.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others.
+ * Copyright (c) 2010, 2015 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
@@ -7,18 +7,21 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Lars Vogel <Lars.Vogel@vogella.com> - Bug 474274
******************************************************************************/
package org.eclipse.e4.core.internal.tests.contexts.inject;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertTrue;
import org.eclipse.e4.core.contexts.EclipseContextFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.contexts.RunAndTrack;
+import org.junit.Test;
-public class Bug317183Test extends TestCase {
+public class Bug317183Test {
+ @Test
public void testX() {
IEclipseContext appContext = EclipseContextFactory.create();
IEclipseContext windowContext = appContext.createChild();
@@ -37,6 +40,7 @@ public class Bug317183Test extends TestCase {
assertTrue(impl.called); // this fails
}
+ @Test
public void testY() {
IEclipseContext appContext = EclipseContextFactory.create();
IEclipseContext windowContext = appContext.createChild();
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ComplexDisposalTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ComplexDisposalTest.java
index b781273b5..32736d015 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ComplexDisposalTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ComplexDisposalTest.java
@@ -7,26 +7,28 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Lars Vogel <Lars.Vogel@vogella.com> - Bug 474274
******************************************************************************/
package org.eclipse.e4.core.internal.tests.contexts.inject;
+import static org.junit.Assert.assertEquals;
+
import javax.annotation.PreDestroy;
import javax.inject.Inject;
import javax.inject.Named;
-import junit.framework.TestCase;
-
import org.eclipse.e4.core.contexts.ContextFunction;
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.EclipseContextFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
+import org.junit.Test;
/**
* See bug 296337: duplicate disposal of an object
*/
-public class ComplexDisposalTest extends TestCase {
+public class ComplexDisposalTest {
- public static class Test {
+ public static class MyTest {
private int count = 0;
@Inject
@@ -46,17 +48,18 @@ public class ComplexDisposalTest extends TestCase {
public static class TestFunction extends ContextFunction {
@Override
public Object compute(IEclipseContext context, String contextKey) {
- return ContextInjectionFactory.make(Test.class, context);
+ return ContextInjectionFactory.make(MyTest.class, context);
}
}
+ @Test
public void testU() throws Exception {
IEclipseContext parentContext = EclipseContextFactory.create();
parentContext.set("aString", "");
- parentContext.set(Test.class.getName(), new TestFunction());
+ parentContext.set(MyTest.class.getName(), new TestFunction());
IEclipseContext context = parentContext.createChild();
- Test test = (Test) context.get(Test.class.getName());
+ MyTest test = (MyTest) context.get(MyTest.class.getName());
assertEquals(0, test.getCount());
context.dispose();
@@ -65,12 +68,13 @@ public class ComplexDisposalTest extends TestCase {
assertEquals("Parent context disposed, @PreDestroy should not have been called again", 1, test.getCount());
}
+ @Test
public void testV() throws Exception {
IEclipseContext parentContext = EclipseContextFactory.create();
parentContext.set("aString", "");
IEclipseContext context = parentContext.createChild();
- Test test = ContextInjectionFactory.make(Test.class, context);
+ MyTest test = ContextInjectionFactory.make(MyTest.class, context);
assertEquals(0, test.getCount());
context.dispose();
@@ -79,12 +83,13 @@ public class ComplexDisposalTest extends TestCase {
assertEquals("Parent context disposed, @PreDestroy should not have been called again", 1, test.getCount());
}
+ @Test
public void testW() throws Exception {
IEclipseContext parentContext = EclipseContextFactory.create();
parentContext.set("aString", "");
IEclipseContext context = parentContext.createChild();
- Test test = new Test();
+ MyTest test = new MyTest();
ContextInjectionFactory.inject(test, context);
assertEquals(0, test.getCount());
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ContextFunctionDynamicsTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ContextFunctionDynamicsTest.java
index 39ee3604f..ec11bf0ee 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ContextFunctionDynamicsTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ContextFunctionDynamicsTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2013 IBM Corporation and others.
+ * Copyright (c) 2010, 2015 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
@@ -7,21 +7,24 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Lars Vogel <Lars.Vogel@vogella.com> - Bug 474274
******************************************************************************/
package org.eclipse.e4.core.internal.tests.contexts.inject;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
import javax.inject.Inject;
import javax.inject.Named;
-import junit.framework.TestCase;
-
import org.eclipse.e4.core.contexts.ContextFunction;
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.EclipseContextFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.Optional;
+import org.junit.Test;
-public class ContextFunctionDynamicsTest extends TestCase {
+public class ContextFunctionDynamicsTest {
private static final String SELECTION = "selection"; //$NON-NLS-1$
@@ -38,6 +41,7 @@ public class ContextFunctionDynamicsTest extends TestCase {
/**
* Changing context function should update injected values
*/
+ @Test
public void testChangeICF() throws Exception {
IEclipseContext context1 = EclipseContextFactory.create("context1");
IEclipseContext context2 = context1.createChild("context2");
@@ -67,6 +71,7 @@ public class ContextFunctionDynamicsTest extends TestCase {
/**
* Overriding context function with a regular value on a child node
*/
+ @Test
public void testOverrideICF() throws Exception {
IEclipseContext context1 = EclipseContextFactory.create("context1");
IEclipseContext context2 = context1.createChild("context2");
@@ -93,6 +98,7 @@ public class ContextFunctionDynamicsTest extends TestCase {
/**
* Tests updates in a chain of 4 contexts
*/
+ @Test
public void testLongChain() throws Exception {
IEclipseContext context1 = EclipseContextFactory.create("context1");
IEclipseContext context2 = context1.createChild("context2");
@@ -137,6 +143,7 @@ public class ContextFunctionDynamicsTest extends TestCase {
+ @Test
public void testBug315109() throws Exception {
IEclipseContext appContext = EclipseContextFactory.create();
IEclipseContext windowContext = appContext.createChild();
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ContextInjectionDisposeTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ContextInjectionDisposeTest.java
index 1a8e6e3c8..48d659947 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ContextInjectionDisposeTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ContextInjectionDisposeTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2013 IBM Corporation and others.
+ * Copyright (c) 2009, 2015 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
@@ -7,38 +7,31 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Lars Vogel <Lars.Vogel@vogella.com> - Bug 474274
*******************************************************************************/
package org.eclipse.e4.core.internal.tests.contexts.inject;
+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 javax.annotation.PreDestroy;
import javax.inject.Inject;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.EclipseContextFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.Optional;
+import org.junit.Test;
/**
- * Tests for injection handling of context dispose, and handling disposal of injected objects.
+ * Tests for injection handling of context dispose, and handling disposal of
+ * injected objects.
*/
-public class ContextInjectionDisposeTest extends TestCase {
-
- public static Test suite() {
- return new TestSuite(ContextInjectionDisposeTest.class);
- }
-
- public ContextInjectionDisposeTest() {
- super();
- }
-
- public ContextInjectionDisposeTest(String name) {
- super(name);
- }
+public class ContextInjectionDisposeTest {
+ @Test
public void testContextDisposedNoArg() {
class Injected {
@@ -61,6 +54,7 @@ public class ContextInjectionDisposeTest extends TestCase {
assertTrue(object.disposeInvoked);
}
+ @Test
public void testDisposeContext() {
class Injected {
boolean disposeInvoked = false;
@@ -90,13 +84,15 @@ public class ContextInjectionDisposeTest extends TestCase {
assertEquals(fieldValue, object.Field);
assertEquals(methodValue, object.methodValue);
- // disposing context calls @PreDestory, but does not clear injected values
+ // disposing context calls @PreDestory, but does not clear injected
+ // values
context.dispose();
assertNotNull(object.Field);
assertNotNull(object.methodValue);
assertTrue(object.disposeInvoked);
}
+ @Test
public void testReleaseObject() {
class Injected {
boolean disposeInvoked = false;
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ContextInjectionFactoryTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ContextInjectionFactoryTest.java
index e1a94ed04..86baf7114 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ContextInjectionFactoryTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ContextInjectionFactoryTest.java
@@ -7,18 +7,24 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Lars Vogel <Lars.Vogel@vogella.com> - Bug 474274
******************************************************************************/
package org.eclipse.e4.core.internal.tests.contexts.inject;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.EclipseContextFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.CanExecute;
import org.eclipse.e4.core.di.annotations.Execute;
+import org.junit.Before;
+import org.junit.Test;
-public class ContextInjectionFactoryTest extends TestCase {
+public class ContextInjectionFactoryTest {
static class TestObject {
@@ -57,14 +63,13 @@ public class ContextInjectionFactoryTest extends TestCase {
private TestObject testObject;
private IEclipseContext context;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
+ @Before
+ public void setUp() throws Exception {
testObject = new TestObject();
context = EclipseContextFactory.create();
}
+ @Test
public void testInvoke() throws Exception {
ContextInjectionFactory.invoke(testObject, Execute.class, context, null);
@@ -72,6 +77,7 @@ public class ContextInjectionFactoryTest extends TestCase {
assertEquals(0, testObject.getExecutedWithParams());
}
+ @Test
public void testInvokeWithParameters() throws Exception {
context.set(String.class.getName(), "");
@@ -84,6 +90,7 @@ public class ContextInjectionFactoryTest extends TestCase {
/**
* If no other constructors are available, the default constructor should be used
*/
+ @Test
public void testConstructorInjectionBasic() {
IEclipseContext context = EclipseContextFactory.create();
// add an extra argument for the inner class constructors
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ContextInjectionTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ContextInjectionTest.java
index e07815c5c..d6f97e77e 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ContextInjectionTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ContextInjectionTest.java
@@ -7,41 +7,33 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Lars Vogel <Lars.Vogel@vogella.com> - Bug 474274
*******************************************************************************/
package org.eclipse.e4.core.internal.tests.contexts.inject;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import javax.annotation.PostConstruct;
import javax.inject.Inject;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.EclipseContextFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.contexts.RunAndTrack;
+import org.junit.Test;
/**
* Tests for the basic context injection functionality
*/
-public class ContextInjectionTest extends TestCase {
-
- public static Test suite() {
- return new TestSuite(ContextInjectionTest.class);
- }
+public class ContextInjectionTest {
- public ContextInjectionTest() {
- super();
- }
-
- public ContextInjectionTest(String name) {
- super(name);
- }
/**
* Test trivial method injection and finalize method with context as an argument
*/
+ @Test
public void testContextSetOneArg() {
class TestData {
}
@@ -80,6 +72,7 @@ public class ContextInjectionTest extends TestCase {
/**
* Test filnalize method - no args
*/
+ @Test
public void testContextSetZeroArgs() {
class TestData {
}
@@ -118,6 +111,7 @@ public class ContextInjectionTest extends TestCase {
/**
* Tests basic context injection
*/
+ @Test
public synchronized void testInjection() {
Integer testInt = new Integer(123);
String testString = new String("abc");
@@ -155,6 +149,7 @@ public class ContextInjectionTest extends TestCase {
/**
* Tests injection of objects from parent context
*/
+ @Test
public synchronized void testInjectionFromParent() {
Integer testInt = new Integer(123);
String testString = new String("abc");
@@ -195,6 +190,7 @@ public class ContextInjectionTest extends TestCase {
/**
* Tests injection into classes with inheritance
*/
+ @Test
public synchronized void testInjectionAndInheritance() {
Integer testInt = new Integer(123);
String testString = new String("abc");
@@ -277,6 +273,7 @@ public class ContextInjectionTest extends TestCase {
/**
* Tests injection of similar, but not overridden methods
*/
+ @Test
public synchronized void testInjectionCloseOverride() {
Integer testInt = new Integer(123);
String testString = new String("abc");
@@ -305,7 +302,8 @@ public class ContextInjectionTest extends TestCase {
assertTrue(userObject.finishOverrideCalled);
}
- public void testBug374421() {
+ @Test
+ public void testBug374421() {
try {
IEclipseContext context = EclipseContextFactory.create();
context.runAndTrack(new RunAndTrack() {
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/DisposingReferencedContextTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/DisposingReferencedContextTest.java
index 93963701e..5e92f2ae5 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/DisposingReferencedContextTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/DisposingReferencedContextTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others.
+ * Copyright (c) 2010, 2015 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
@@ -7,21 +7,23 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Lars Vogel <Lars.Vogel@vogella.com> - Bug 474274
******************************************************************************/
package org.eclipse.e4.core.internal.tests.contexts.inject;
+import static org.junit.Assert.assertEquals;
+
import javax.inject.Inject;
import javax.inject.Named;
-import junit.framework.TestCase;
-
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.EclipseContextFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.core.internal.contexts.EclipseContext;
+import org.junit.Test;
-public class DisposingReferencedContextTest extends TestCase {
+public class DisposingReferencedContextTest {
static class MandatoryTarget {
@Inject @Named("object")
@@ -29,8 +31,9 @@ public class DisposingReferencedContextTest extends TestCase {
@Inject
void setActiveContext(@Named(EclipseContext.ACTIVE_CHILD) IEclipseContext partContext) {
- if (partContext != null)
+ if (partContext != null) {
partContext.get("someVar");
+ }
}
}
@@ -40,23 +43,28 @@ public class DisposingReferencedContextTest extends TestCase {
@Inject
void setActiveContext(@Optional @Named(EclipseContext.ACTIVE_CHILD) IEclipseContext partContext) {
- if (partContext != null)
+ if (partContext != null) {
partContext.get("someVar");
+ }
}
}
+ @Test
public void testContextDisposeCausesCompleteUninjection_Mandatory_True() {
testContextDisposeCausesCompleteUninjection_Mandatory(true);
}
+ @Test
public void testContextDisposeCausesCompleteUninjection_Mandatory_False() {
testContextDisposeCausesCompleteUninjection_Mandatory(false);
}
+ @Test
public void testContextDisposeCausesCompleteUninjection_Optional_True() {
testContextDisposeCausesCompleteUninjection_Optional(true);
}
+ @Test
public void testContextDisposeCausesCompleteUninjection_Optional_False() {
testContextDisposeCausesCompleteUninjection_Optional(false);
}
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ExtraDependenciesTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ExtraDependenciesTest.java
index a97db903f..a0982bfec 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ExtraDependenciesTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ExtraDependenciesTest.java
@@ -7,22 +7,28 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Lars Vogel <Lars.Vogel@vogella.com> - Bug 474274
*******************************************************************************/
package org.eclipse.e4.core.internal.tests.contexts.inject;
+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.lang.reflect.InvocationTargetException;
import javax.annotation.PreDestroy;
import javax.inject.Inject;
import javax.inject.Named;
-import junit.framework.TestCase;
-
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.EclipseContextFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
+import org.junit.Test;
-public class ExtraDependenciesTest extends TestCase {
+public class ExtraDependenciesTest {
static public class TestObject {
@@ -41,10 +47,11 @@ public class ExtraDependenciesTest extends TestCase {
return;
}
IEclipseContext otherContext = (IEclipseContext) context.get("otherContext");
- if (otherContext == null)
+ if (otherContext == null) {
other = null;
- else
+ } else {
other = (String) otherContext.get("arg3");
+ }
}
@PreDestroy
@@ -53,6 +60,7 @@ public class ExtraDependenciesTest extends TestCase {
}
}
+ @Test
public void testExtraDependencies() throws InvocationTargetException, InstantiationException {
IEclipseContext context = EclipseContextFactory.create();
context.set("arg1", "abc");
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/GenericsInjectionTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/GenericsInjectionTest.java
index 25e67f7f6..e7a858d6a 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/GenericsInjectionTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/GenericsInjectionTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 IBM Corporation and others.
+ * Copyright (c) 2011, 2015 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
@@ -7,22 +7,24 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Lars Vogel <Lars.Vogel@vogella.com> - Bug 474274
*******************************************************************************/
package org.eclipse.e4.core.internal.tests.contexts.inject;
+import static org.junit.Assert.assertEquals;
+
import javax.inject.Inject;
import javax.inject.Named;
-import junit.framework.TestCase;
-
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.EclipseContextFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
+import org.junit.Test;
/**
* Tests for the generics context injection functionality
*/
-public class GenericsInjectionTest extends TestCase {
+public class GenericsInjectionTest {
static public class Animal {
}
@@ -54,6 +56,7 @@ public class GenericsInjectionTest extends TestCase {
}
}
+ @Test
public synchronized void testNamedInjection() {
Animal testAnimal = new Animal();
Bird testBird = new Bird();
@@ -72,6 +75,7 @@ public class GenericsInjectionTest extends TestCase {
assertEquals(testBirdHouse, userObject.field);
}
+ @Test
public synchronized void testGenericInjection() {
Animal testAnimal = new Animal();
Bird testBird = new Bird();
@@ -102,6 +106,7 @@ public class GenericsInjectionTest extends TestCase {
public Interface<Object> field;
}
+ @Test
public void testInterfaceGenericInjection() {
Implementation implementation = new Implementation();
// create context
@@ -126,6 +131,7 @@ public class GenericsInjectionTest extends TestCase {
public Superclass<Object> field;
}
+ @Test
public void testClassGenericInjection() {
Subclass implementation = new Subclass();
// create context
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/GroupedUpdatesTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/GroupedUpdatesTest.java
index 83cddb157..b91c2633d 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/GroupedUpdatesTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/GroupedUpdatesTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others.
+ * Copyright (c) 2010, 2015 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
@@ -7,20 +7,22 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Lars Vogel <Lars.Vogel@vogella.com> - Bug 474274
******************************************************************************/
package org.eclipse.e4.core.internal.tests.contexts.inject;
+import static org.junit.Assert.assertEquals;
+
import javax.inject.Inject;
import javax.inject.Named;
-import junit.framework.TestCase;
-
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.EclipseContextFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.GroupUpdates;
+import org.junit.Test;
-public class GroupedUpdatesTest extends TestCase {
+public class GroupedUpdatesTest {
static class InjectTarget {
@@ -66,6 +68,7 @@ public class GroupedUpdatesTest extends TestCase {
}
}
+ @Test
public void testNoGrouping() {
IEclipseContext context = EclipseContextFactory.create();
context.set("string1", "x");
@@ -87,6 +90,7 @@ public class GroupedUpdatesTest extends TestCase {
assertEquals(1, target.countSecondary);
}
+ @Test
public void testGrouping() {
final IEclipseContext context = EclipseContextFactory.create();
context.set("string1", "x");
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/InjectStaticContextTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/InjectStaticContextTest.java
index 8baa798e8..eafba1dd8 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/InjectStaticContextTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/InjectStaticContextTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others.
+ * Copyright (c) 2010, 2015 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
@@ -7,26 +7,29 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Lars Vogel <Lars.Vogel@vogella.com> - Bug 474274
*******************************************************************************/
package org.eclipse.e4.core.internal.tests.contexts.inject;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.inject.Inject;
import javax.inject.Named;
-import junit.framework.TestCase;
-
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.EclipseContextFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.core.di.annotations.Optional;
+import org.junit.Test;
/**
* Tests for the context injection functionality using 2 contexts
*/
-public class InjectStaticContextTest extends TestCase {
+public class InjectStaticContextTest {
static class TestClass {
public IEclipseContext injectedContext;
public String aString;
@@ -91,6 +94,7 @@ public class InjectStaticContextTest extends TestCase {
}
}
+ @Test
public void testStaticMake() {
IEclipseContext parentContext = EclipseContextFactory.create();
parentContext.set("a", "abc");
@@ -162,6 +166,7 @@ public class InjectStaticContextTest extends TestCase {
assertEquals(1, testObject.preDestroyCalled);
}
+ @Test
public void testStaticInvoke() {
IEclipseContext parentContext = EclipseContextFactory.create("main");
parentContext.set("a", "abc");
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/InjectionOrderTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/InjectionOrderTest.java
index d66582f1a..f54d4941b 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/InjectionOrderTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/InjectionOrderTest.java
@@ -7,20 +7,22 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Lars Vogel <Lars.Vogel@vogella.com> - Bug 474274
*******************************************************************************/
package org.eclipse.e4.core.internal.tests.contexts.inject;
+import static org.junit.Assert.assertTrue;
+
import javax.annotation.PreDestroy;
import javax.inject.Inject;
import javax.inject.Named;
-import junit.framework.TestCase;
-
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.EclipseContextFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
+import org.junit.Test;
-public class InjectionOrderTest extends TestCase {
+public class InjectionOrderTest {
public static class InjectTargetMethod {
@@ -60,6 +62,7 @@ public class InjectionOrderTest extends TestCase {
* See bug 304859.
* </p>
*/
+ @Test
public void testDisposeMethod() throws Exception {
// create a context
IEclipseContext appContext = EclipseContextFactory.create();
@@ -84,6 +87,7 @@ public class InjectionOrderTest extends TestCase {
* See bug 304859.
* </p>
*/
+ @Test
public void testDisposeField() throws Exception {
// create a context
IEclipseContext appContext = EclipseContextFactory.create();
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/InjectionUpdateTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/InjectionUpdateTest.java
index 90e70deff..3894caa73 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/InjectionUpdateTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/InjectionUpdateTest.java
@@ -7,26 +7,31 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Lars Vogel <Lars.Vogel@vogella.com> - Bug 474274
******************************************************************************/
package org.eclipse.e4.core.internal.tests.contexts.inject;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
+
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Named;
-import junit.framework.TestCase;
-
import org.eclipse.e4.core.contexts.ContextFunction;
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.EclipseContextFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.Optional;
+import org.junit.Before;
+import org.junit.Test;
/**
* Tests updates of injected values and calls to runnables
*/
-public class InjectionUpdateTest extends TestCase {
+public class InjectionUpdateTest {
private IEclipseContext c1; // common root
private IEclipseContext c21; // dependents of root - path 1
@@ -49,10 +54,8 @@ public class InjectionUpdateTest extends TestCase {
}
}
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
+ @Before
+ public void setUp() throws Exception {
c1 = EclipseContextFactory.create("c1");
c1.set("id", "c1");
@@ -65,6 +68,7 @@ public class InjectionUpdateTest extends TestCase {
c1.set("c22", c22);
}
+ @Test
public void testPropagation() {
c1.set("base", "abc");
@@ -123,6 +127,7 @@ public class InjectionUpdateTest extends TestCase {
}
}
+ @Test
public void testNestedUpdatesPostConstruct() throws Exception {
IEclipseContext appContext = EclipseContextFactory.create();
appContext.set(InjectTarget.class.getName(), new ContextFunction() {
@@ -159,6 +164,7 @@ public class InjectionUpdateTest extends TestCase {
}
}
+ @Test
public void testNestedUpdatesConstructor() throws Exception {
IEclipseContext appContext = EclipseContextFactory.create();
appContext.set(InjectTarget2.class.getName(), new ContextFunction() {
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/InvokeInRATTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/InvokeInRATTest.java
index e6b4acef3..4e0b7ecd0 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/InvokeInRATTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/InvokeInRATTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others.
+ * Copyright (c) 2010, 2015 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
@@ -7,12 +7,13 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Lars Vogel <Lars.Vogel@vogella.com> - Bug 474274
*******************************************************************************/
package org.eclipse.e4.core.internal.tests.contexts.inject;
-import javax.inject.Named;
+import static org.junit.Assert.assertEquals;
-import junit.framework.TestCase;
+import javax.inject.Named;
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.EclipseContextFactory;
@@ -20,11 +21,12 @@ import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.contexts.RunAndTrack;
import org.eclipse.e4.core.di.annotations.CanExecute;
import org.eclipse.e4.core.di.annotations.Optional;
+import org.junit.Test;
/**
* Tests for the context injection functionality using 2 contexts
*/
-public class InvokeInRATTest extends TestCase {
+public class InvokeInRATTest {
static class TestHandler {
@@ -38,6 +40,7 @@ public class InvokeInRATTest extends TestCase {
}
}
+ @Test
public void testStaticInvoke() {
IEclipseContext context = EclipseContextFactory.create();
final int[] count = new int[1];
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ParentContextDisposalTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ParentContextDisposalTest.java
index 3590a326a..977506abf 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ParentContextDisposalTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ParentContextDisposalTest.java
@@ -7,21 +7,23 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Lars Vogel <Lars.Vogel@vogella.com> - Bug 474274
******************************************************************************/
package org.eclipse.e4.core.internal.tests.contexts.inject;
+import static org.junit.Assert.assertEquals;
+
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.inject.Inject;
import javax.inject.Named;
-import junit.framework.TestCase;
-
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.EclipseContextFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
+import org.junit.Test;
-public class ParentContextDisposalTest extends TestCase {
+public class ParentContextDisposalTest {
static class Target {
int pc = 0;
int pd = 0;
@@ -41,6 +43,7 @@ public class ParentContextDisposalTest extends TestCase {
}
}
+ @Test
public void testParentContextDisposal() {
IEclipseContext context = EclipseContextFactory.create();
IEclipseContext child = context.createChild();
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ProviderInjectionTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ProviderInjectionTest.java
index 7ed841add..ccd7b7cff 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ProviderInjectionTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ProviderInjectionTest.java
@@ -7,27 +7,29 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Lars Vogel <Lars.Vogel@vogella.com> - Bug 474274
*******************************************************************************/
package org.eclipse.e4.core.internal.tests.contexts.inject;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
import javax.inject.Inject;
import javax.inject.Provider;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.EclipseContextFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.IInjector;
import org.eclipse.e4.core.di.InjectorFactory;
import org.eclipse.e4.core.di.annotations.Execute;
+import org.junit.Test;
+
/**
* Testing provider interface
*/
-public class ProviderInjectionTest extends TestCase {
+public class ProviderInjectionTest {
static public class TestData {
@@ -60,18 +62,7 @@ public class ProviderInjectionTest extends TestCase {
}
}
- public static Test suite() {
- return new TestSuite(ProviderInjectionTest.class);
- }
-
- public ProviderInjectionTest() {
- super();
- }
-
- public ProviderInjectionTest(String name) {
- super(name);
- }
-
+ @Test
public synchronized void testInvokeWithProvider() {
// create context
@@ -87,6 +78,7 @@ public class ProviderInjectionTest extends TestCase {
assertEquals("abc", userObject.provider.get().data);
}
+ @Test
public synchronized void testConstructorWithProvider() {
// create context
IEclipseContext context = EclipseContextFactory.create();
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ServiceContextTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ServiceContextTest.java
index 6313836fd..e3647edb4 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ServiceContextTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ServiceContextTest.java
@@ -7,17 +7,21 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Lars Vogel <Lars.Vogel@vogella.com> - Bug 474274
******************************************************************************/
package org.eclipse.e4.core.internal.tests.contexts.inject;
+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 java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
-import junit.framework.TestCase;
-
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.EclipseContextFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
@@ -25,6 +29,9 @@ import org.eclipse.e4.core.contexts.RunAndTrack;
import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.core.internal.tests.CoreTestsActivator;
import org.eclipse.osgi.service.debug.DebugOptions;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
@@ -33,7 +40,7 @@ import org.osgi.framework.ServiceRegistration;
/**
* Tests for contexts used in OSGi services.
*/
-public class ServiceContextTest extends TestCase {
+public class ServiceContextTest {
class Crayon {
@Inject
IPaletteService palette;
@@ -41,10 +48,11 @@ public class ServiceContextTest extends TestCase {
String msg;
public void draw() {
- if (palette == null)
+ if (palette == null) {
msg = "I'm out of ink!";
- else
+ } else {
msg = "My ink is " + palette.getColor();
+ }
}
}
@@ -74,26 +82,25 @@ public class ServiceContextTest extends TestCase {
PrintService printer;
public void print(String message) {
- if (printer != null)
+ if (printer != null) {
printer.print(message);
+ }
}
}
private IEclipseContext context;
private final List<ServiceRegistration<?>> registrations = new ArrayList<ServiceRegistration<?>>();
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
//don't use the global shared service context to avoid contamination across tests
BundleContext bundleContext = CoreTestsActivator.getDefault().getBundleContext();
context = EclipseContextFactory.getServiceContext(bundleContext);
registrations.clear();
}
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
+ @After
+ public void tearDown() throws Exception {
// Consumers must not dispose OSGi context as it is reused
//context.dispose();
for (ServiceRegistration<?> reg : registrations) {
@@ -107,6 +114,7 @@ public class ServiceContextTest extends TestCase {
context = null;
}
+ @Test
public void testDeclarativeService() {
assertTrue(context.containsKey("sum"));
assertEquals(0, context.get("sum"));
@@ -122,12 +130,14 @@ public class ServiceContextTest extends TestCase {
/**
* Tests accessing OSGi services through a child context that is not aware of them.
*/
+ @Test
public void testServiceContextAsParent() {
IEclipseContext child = context.createChild( "child");
DebugOptions service = (DebugOptions) child.get(DebugOptions.class.getName());
assertNotNull(service);
}
+ @Test
public void testServiceInjection() {
ServiceRegistration<?> reg1 = null;
ServiceRegistration<?> reg2 = null;
@@ -172,6 +182,7 @@ public class ServiceContextTest extends TestCase {
}
}
+ @Test
public void testServiceAddition() {
ServiceRegistration<?> reg1 = null;
try {
@@ -199,6 +210,7 @@ public class ServiceContextTest extends TestCase {
/**
* Tests that OSGi services are released when their context is disposed.
*/
+ @Test
public void testServiceRemovalOnContextDispose() {
StringPrintService stringPrint1 = new StringPrintService();
BundleContext bundleContext = CoreTestsActivator.getDefault()
@@ -230,6 +242,7 @@ public class ServiceContextTest extends TestCase {
}
}
+ @Test
public void testRecursiveServiceRemoval() {
BundleContext bundleContext = CoreTestsActivator.getDefault().getBundleContext();
ServiceRegistration<?> reg1 = bundleContext.registerService(PrintService.SERVICE_NAME, new StringPrintService(), null);
@@ -252,6 +265,7 @@ public class ServiceContextTest extends TestCase {
reg1.unregister();
}
+ @Test
public void testServiceExample() {
BundleContext bundleContext = CoreTestsActivator.getDefault().getBundleContext();
ServiceRegistration<?> reg = bundleContext.registerService(IPaletteService.class.getName(), new PaletteImpl(Color.BLUE), null);
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/TestConstructorInjection.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/TestConstructorInjection.java
index 3066cd9e3..0ad1ea5a3 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/TestConstructorInjection.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/TestConstructorInjection.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2010 IBM Corporation and others.
+ * Copyright (c) 2009, 2015 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
@@ -7,21 +7,27 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Lars Vogel <Lars.Vogel@vogella.com> - Bug 474274
******************************************************************************/
package org.eclipse.e4.core.internal.tests.contexts.inject;
+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.lang.reflect.InvocationTargetException;
import javax.inject.Inject;
-import junit.framework.TestCase;
-
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.EclipseContextFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
+import org.junit.Test;
-public class TestConstructorInjection extends TestCase {
+public class TestConstructorInjection {
static class TestConstructorObject {
@@ -58,8 +64,9 @@ public class TestConstructorInjection extends TestCase {
this.i = i;
this.b = b;
// the constructor should be called first
- if ((c != null) || (d != null) || (f != null))
+ if ((c != null) || (d != null) || (f != null)) {
orderCorrect = false;
+ }
}
@Inject
@@ -68,8 +75,9 @@ public class TestConstructorInjection extends TestCase {
this.d = d;
this.f = f;
// the method injection after constructor and field injection
- if ((c == null) || (i == null) || (b == null))
+ if ((c == null) || (i == null) || (b == null)) {
orderCorrect = false;
+ }
}
public void nonInjectedMethod(Double d) {
@@ -82,6 +90,7 @@ public class TestConstructorInjection extends TestCase {
}
}
+ @Test
public void testConstructorInjection() throws InvocationTargetException, InstantiationException {
IEclipseContext context = EclipseContextFactory.create();
Integer intValue = new Integer(123);
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/performance/ContextPerformanceTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/performance/ContextPerformanceTest.java
index c314ef88e..867fd47cb 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/performance/ContextPerformanceTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/performance/ContextPerformanceTest.java
@@ -7,14 +7,11 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Lars Vogel <Lars.Vogel@vogella.com> - Bug 474274
******************************************************************************/
package org.eclipse.e4.core.internal.tests.contexts.performance;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
import org.eclipse.core.runtime.IAdapterManager;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.preferences.IPreferencesService;
@@ -27,6 +24,10 @@ import org.eclipse.e4.core.internal.tests.CoreTestsActivator;
import org.eclipse.osgi.service.datalocation.Location;
import org.eclipse.osgi.service.debug.DebugOptions;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
/**
*
*/
@@ -45,11 +46,6 @@ public class ContextPerformanceTest extends TestCase {
super(name);
}
- /*
- * (non-Javadoc)
- *
- * @see junit.framework.TestCase#setUp()
- */
@Override
protected void setUp() throws Exception {
super.setUp();
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/AutoConstructTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/AutoConstructTest.java
index dd88fe290..ac7ab6975 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/AutoConstructTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/AutoConstructTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012 IBM Corporation and others.
+ * Copyright (c) 2012, 2015 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
@@ -7,20 +7,23 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Lars Vogel <Lars.Vogel@vogella.com> - Bug 474274
******************************************************************************/
package org.eclipse.e4.core.internal.tests.di;
-import javax.inject.Inject;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
-import junit.framework.TestCase;
+import javax.inject.Inject;
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.EclipseContextFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.InjectionException;
import org.eclipse.e4.core.di.annotations.Creatable;
+import org.junit.Test;
-public class AutoConstructTest extends TestCase {
+public class AutoConstructTest {
@Creatable
static class Dependent1 {
@@ -54,6 +57,7 @@ public class AutoConstructTest extends TestCase {
/**
* Checks that only classes with @Creatable are auto-constructed
*/
+ @Test
public void testCreatable() {
IEclipseContext context = EclipseContextFactory.create();
Consumer1 consumer1 = ContextInjectionFactory.make(Consumer1.class,
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/DisposeClassLinkTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/DisposeClassLinkTest.java
index 28ce78daa..09031219f 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/DisposeClassLinkTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/DisposeClassLinkTest.java
@@ -7,21 +7,23 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Lars Vogel <Lars.Vogel@vogella.com> - Bug 474274
******************************************************************************/
package org.eclipse.e4.core.internal.tests.di;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.inject.Inject;
-import junit.framework.TestCase;
-
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.EclipseContextFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.core.di.extensions.EventTopic;
-
+import org.junit.Test;
/**
* Checks that injected objects that do not have normal links
* established to the context are still notified on context
@@ -30,9 +32,9 @@ import org.eclipse.e4.core.di.extensions.EventTopic;
* or constructor injection was used.)
* See bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=301462 .
*/
-public class DisposeClassLinkTest extends TestCase {
+public class DisposeClassLinkTest {
- public static class Test {
+ public static class MyTest {
private int count = 0;
public int getCount() {
@@ -79,19 +81,21 @@ public class DisposeClassLinkTest extends TestCase {
}
}
+ @Test
public void testMake() throws Exception {
IEclipseContext context = EclipseContextFactory.create();
- Test test = ContextInjectionFactory.make(Test.class, context);
+ MyTest test = ContextInjectionFactory.make(MyTest.class, context);
assertEquals(0, test.getCount());
context.dispose();
assertEquals(1, test.getCount());
}
+ @Test
public void testDisposeParent() throws Exception {
IEclipseContext parentContext = EclipseContextFactory.create();
IEclipseContext context = parentContext.createChild();
- Test test = ContextInjectionFactory.make(Test.class, context);
+ MyTest test = ContextInjectionFactory.make(MyTest.class, context);
assertEquals(0, test.getCount());
context.dispose();
@@ -100,10 +104,11 @@ public class DisposeClassLinkTest extends TestCase {
assertEquals(1, test.getCount());
}
+ @Test
public void testInject() throws Exception {
IEclipseContext parentContext = EclipseContextFactory.create();
IEclipseContext context = parentContext.createChild();
- Test test = new Test();
+ MyTest test = new MyTest();
ContextInjectionFactory.inject(test, context);
assertEquals(0, test.getCount());
@@ -111,10 +116,11 @@ public class DisposeClassLinkTest extends TestCase {
assertEquals(1, test.getCount());
}
+ @Test
public void testDisposeParentFirst() throws Exception {
IEclipseContext parentContext = EclipseContextFactory.create();
IEclipseContext context = parentContext.createChild();
- Test test = new Test();
+ MyTest test = new MyTest();
ContextInjectionFactory.inject(test, context);
assertEquals(0, test.getCount());
@@ -124,6 +130,7 @@ public class DisposeClassLinkTest extends TestCase {
assertEquals(1, test.getCount());
}
+ @Test
public void testInjectedWithContext() throws Exception {
IEclipseContext context = EclipseContextFactory.create();
@@ -140,6 +147,7 @@ public class DisposeClassLinkTest extends TestCase {
assertEquals("@PreDestroy should have been called during uninjection", 1, obj.preDestroy);
}
+ @Test
public void testBug430041() {
IEclipseContext context = EclipseContextFactory.create();
TestBug430041 obj = ContextInjectionFactory.make(TestBug430041.class, context);
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/InjectArraysTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/InjectArraysTest.java
index ee38e96c6..9e2383f7a 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/InjectArraysTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/InjectArraysTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others.
+ * Copyright (c) 2010, 2015 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
@@ -7,22 +7,25 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Lars Vogel <Lars.Vogel@vogella.com> - Bug 474274
******************************************************************************/
package org.eclipse.e4.core.internal.tests.di;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
import javax.inject.Inject;
import javax.inject.Named;
-import junit.framework.TestCase;
-
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.EclipseContextFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
+import org.junit.Test;
/**
* Checks injection of arrays
*/
-public class InjectArraysTest extends TestCase {
+public class InjectArraysTest {
static class TestClass {
@Inject @Named("test_array_String")
@@ -42,6 +45,7 @@ public class InjectArraysTest extends TestCase {
}
}
+ @Test
public void testArrayInjection() {
String[] arrayString = new String[] { "abc", "xyz", "ttt" };
Integer[] arrayInteger = new Integer[] { 5, 6, 7 };
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/InjectBaseTypeTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/InjectBaseTypeTest.java
index 3071a134c..d37388546 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/InjectBaseTypeTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/InjectBaseTypeTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others.
+ * Copyright (c) 2010, 2015 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
@@ -10,20 +10,21 @@
******************************************************************************/
package org.eclipse.e4.core.internal.tests.di;
+import static org.junit.Assert.assertEquals;
+
import javax.inject.Inject;
import javax.inject.Named;
-import junit.framework.TestCase;
-
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.EclipseContextFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.Optional;
+import org.junit.Test;
/**
* Checks conversion of primitive types
*/
-public class InjectBaseTypeTest extends TestCase {
+public class InjectBaseTypeTest {
static class TestClass {
@Inject @Named("test_int")
@@ -66,6 +67,7 @@ public class InjectBaseTypeTest extends TestCase {
}
+ @Test
public void testPrimitiveTypes() {
IEclipseContext context = EclipseContextFactory.create();
context.set("test_int", 12);
@@ -82,8 +84,8 @@ public class InjectBaseTypeTest extends TestCase {
assertEquals(12, testClass.intField);
assertEquals(0, testClass.intFieldOptional);
assertEquals(124564523466L, testClass.longField);
- assertEquals(12.34f, testClass.floatField);
- assertEquals(12.34534534563463466546d, testClass.doubleField);
+ assertEquals(12.34f, testClass.floatField, 0);
+ assertEquals(12.34534534563463466546d, testClass.doubleField, 0);
assertEquals((short)10, testClass.shortField);
assertEquals((byte)55, testClass.byteField);
assertEquals(true, testClass.booleanField);
@@ -101,8 +103,8 @@ public class InjectBaseTypeTest extends TestCase {
assertEquals(12, testClass.intField);
assertEquals(0, testClass.intFieldOptional); // optional
assertEquals(124564523466L, testClass.longField);
- assertEquals(12.34f, testClass.floatField);
- assertEquals(12.34534534563463466546d, testClass.doubleField);
+ assertEquals(12.34f, testClass.floatField, 0);
+ assertEquals(12.34534534563463466546d, testClass.doubleField, 0);
assertEquals((short)10, testClass.shortField);
assertEquals((byte)55, testClass.byteField);
assertEquals(false, testClass.booleanField); // optional
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/InjectionOrderTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/InjectionOrderTest.java
index 7f69d33b7..d8f544995 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/InjectionOrderTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/InjectionOrderTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others.
+ * Copyright (c) 2010, 2015 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
@@ -7,21 +7,24 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Lars Vogel <Lars.Vogel@vogella.com> - Bug 474274
******************************************************************************/
package org.eclipse.e4.core.internal.tests.di;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.inject.Inject;
-import junit.framework.TestCase;
-
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.EclipseContextFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.InjectionException;
+import org.junit.Test;
-public class InjectionOrderTest extends TestCase {
+public class InjectionOrderTest {
public interface ITestObject {
@@ -50,6 +53,7 @@ public class InjectionOrderTest extends TestCase {
/**
* Make sure special methods are not getting called in case injection failed
*/
+ @Test
public void testSpecialMethodOnFailure() {
IEclipseContext appContext = EclipseContextFactory.create();
boolean exception = false;
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/InjectionResultLeakTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/InjectionResultLeakTest.java
index df95eaf4f..a8e847a7d 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/InjectionResultLeakTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/InjectionResultLeakTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 IBM Corporation and others.
+ * Copyright (c) 2011, 2015 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
@@ -7,17 +7,23 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Lars Vogel <Lars.Vogel@vogella.com> - Bug 474274
******************************************************************************/
package org.eclipse.e4.core.internal.tests.di;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
import java.lang.ref.WeakReference;
+
import javax.inject.Inject;
import javax.inject.Named;
-import junit.framework.TestCase;
+
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.EclipseContextFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.Optional;
+import org.junit.Test;
/**
* Test that we don't hold on to the values calculated during injection.
@@ -26,7 +32,7 @@ import org.eclipse.e4.core.di.annotations.Optional;
* so this test might not work on all VMs or might become invalid on
* future VMs.
*/
-public class InjectionResultLeakTest extends TestCase {
+public class InjectionResultLeakTest {
static class PartConsumer {
Object part;
@@ -37,6 +43,7 @@ public class InjectionResultLeakTest extends TestCase {
}
}
+ @Test
public void testLeaks() {
IEclipseContext context = EclipseContextFactory.create();
WeakReference<?> ref;
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/InvokeTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/InvokeTest.java
index 8968828ef..e5d108875 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/InvokeTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/InvokeTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others.
+ * Copyright (c) 2010, 2015 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
@@ -7,16 +7,18 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Lars Vogel <Lars.Vogel@vogella.com> - Bug 474274
******************************************************************************/
package org.eclipse.e4.core.internal.tests.di;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.EclipseContextFactory;
import org.eclipse.e4.core.di.annotations.Execute;
+import org.junit.Test;
-public class InvokeTest extends TestCase {
+public class InvokeTest {
/**
* Superclass
@@ -38,6 +40,7 @@ public class InvokeTest extends TestCase {
/**
* Checks that superclass methods are called
*/
+ @Test
public void testSuperclassMethods() {
TestSubclass editor = new TestSubclass();
ContextInjectionFactory.invoke(editor, Execute.class, EclipseContextFactory
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/InvokeTestMissingAnnotation.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/InvokeTestMissingAnnotation.java
index 7f6c4db7f..51acbfba3 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/InvokeTestMissingAnnotation.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/InvokeTestMissingAnnotation.java
@@ -1,26 +1,28 @@
/*******************************************************************************
- * Copyright (c) 2014 vogella GmbH and others.
+ * Copyright (c) 2014, 2015 vogella GmbH 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:
- * Lars Vogel <Lars.Vogel@gmail.com> - initial API and implementation
+ * Lars Vogel <Lars.Vogel@vogella.com> - initial API and implementation
+ * Lars Vogel <Lars.Vogel@vogella.com> - Bug 474274
******************************************************************************/
package org.eclipse.e4.core.internal.tests.di;
-import junit.framework.TestCase;
+import static org.junit.Assert.fail;
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.EclipseContextFactory;
import org.eclipse.e4.core.di.annotations.Execute;
+import org.junit.Test;
/**
* Tests that that no method is called, it the @Execute annotation is not
* present and that an exception is thrown from the DI framework
*/
-public class InvokeTestMissingAnnotation extends TestCase {
+public class InvokeTestMissingAnnotation {
/**
* Class to invoke for the test
@@ -37,6 +39,7 @@ public class InvokeTestMissingAnnotation extends TestCase {
/**
* Checks that no methods is called and that an execution is thrown
*/
+ @Test
public void testCallMethodsWithMissingAnnotation() {
TestSuperclass editor = new TestSuperclass();
try {
@@ -52,6 +55,7 @@ public class InvokeTestMissingAnnotation extends TestCase {
* Checks that no methods is called and that no execution is thrown if a
* default is provide
*/
+ @Test
public void testCallMethodsWithMissingAnnotationNoExecution() {
TestSuperclass editor = new TestSuperclass();
ContextInjectionFactory.invoke(editor, Execute.class,
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/RecursiveObjectCreationTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/RecursiveObjectCreationTest.java
index 12458795d..db8c449ce 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/RecursiveObjectCreationTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/RecursiveObjectCreationTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 IBM Corporation and others.
+ * Copyright (c) 2011, 2015 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
@@ -7,20 +7,23 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Lars Vogel <Lars.Vogel@vogella.com> - Bug 474274
******************************************************************************/
package org.eclipse.e4.core.internal.tests.di;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
import javax.annotation.PostConstruct;
import javax.inject.Inject;
-import junit.framework.TestCase;
-
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.EclipseContextFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.InjectionException;
+import org.junit.Test;
-public class RecursiveObjectCreationTest extends TestCase {
+public class RecursiveObjectCreationTest {
static public class CheckSelfInject {
@@ -35,6 +38,7 @@ public class RecursiveObjectCreationTest extends TestCase {
/**
* Checks a simple case of constructor needing the same class
*/
+ @Test
public void testSelfInject() {
IEclipseContext context = EclipseContextFactory.create();
boolean exceptionReceived = false;
@@ -74,6 +78,7 @@ public class RecursiveObjectCreationTest extends TestCase {
/**
* Checks inner class using outer class which is still being created
*/
+ @Test
public void testNested() {
IEclipseContext context = EclipseContextFactory.create();
boolean exceptionReceived = false;
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/RequestorTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/RequestorTest.java
index 671a8ec26..fa5b0a8d4 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/RequestorTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/RequestorTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013 IBM Corporation and others.
+ * Copyright (c) 2013, 2015 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
@@ -7,23 +7,29 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Lars Vogel <Lars.Vogel@vogella.com> - Bug 474274
*******************************************************************************/
package org.eclipse.e4.core.internal.tests.di;
-import java.lang.reflect.Field;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
-import junit.framework.TestCase;
+import java.lang.reflect.Field;
import org.eclipse.e4.core.contexts.EclipseContextFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.InjectorFactory;
import org.eclipse.e4.core.internal.contexts.ContextObjectSupplier;
import org.eclipse.e4.core.internal.di.FieldRequestor;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
-public class RequestorTest extends TestCase {
+public class RequestorTest {
public Object field;
public IEclipseContext context;
+ @Test
public void testHashCode() throws Exception {
Field field = getClass().getField("field");
assertNotNull(field);
@@ -36,15 +42,13 @@ public class RequestorTest extends TestCase {
assertEquals(hash, requestor.hashCode());
}
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- context = EclipseContextFactory.create(getName());
+ @Before
+ public void setUp() throws Exception {
+ context = EclipseContextFactory.create("RequestorTest");
}
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
+ @After
+ public void tearDown() throws Exception {
context.dispose();
}
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/extensions/ExtendedSupplierInjectionTests.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/extensions/ExtendedSupplierInjectionTests.java
index eb751f792..9588bfba5 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/extensions/ExtendedSupplierInjectionTests.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/extensions/ExtendedSupplierInjectionTests.java
@@ -7,17 +7,19 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Lars Vogel <Lars.Vogel@vogella.com> - Bug 474274
*******************************************************************************/
package org.eclipse.e4.core.internal.tests.di.extensions;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import java.util.Dictionary;
import java.util.Hashtable;
import javax.annotation.PreDestroy;
import javax.inject.Inject;
-import junit.framework.TestCase;
-
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.EclipseContextFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
@@ -28,12 +30,14 @@ import org.eclipse.e4.core.di.suppliers.IObjectDescriptor;
import org.eclipse.e4.core.di.suppliers.IRequestor;
import org.eclipse.e4.core.internal.di.osgi.ProviderHelper;
import org.eclipse.e4.core.internal.tests.di.extensions.InjectionEventTest.EventAdminHelper;
+import org.junit.Before;
+import org.junit.Test;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.ServiceRegistration;
-public class ExtendedSupplierInjectionTests extends TestCase {
+public class ExtendedSupplierInjectionTests {
static final String TOPIC = "org/eclipse/e4/core/tests/di/extensions/ExtendedSupplierInjectionTests";
static final String TOPIC_430041 = "org/eclipse/e4/core/tests/di/extensions/ExtendedSupplierInjectionTests430041";
@@ -72,7 +76,7 @@ public class ExtendedSupplierInjectionTests extends TestCase {
private EventAdminHelper helper;
- @Override
+ @Before
public void setUp() {
InjectionEventTest.ensureEventAdminStarted();
BundleContext bundleContext = FrameworkUtil.getBundle(getClass())
@@ -84,6 +88,7 @@ public class ExtendedSupplierInjectionTests extends TestCase {
}
/* Ensure extended suppliers are looked up first */
+ @Test
public void testBug398728() {
IEclipseContext context = EclipseContextFactory.create();
context.set(Object.class, new Object());
@@ -101,6 +106,7 @@ public class ExtendedSupplierInjectionTests extends TestCase {
assertEquals("event1data", target.injectedObject);
}
+ @Test
public void testBug430041() {
IEclipseContext context = EclipseContextFactory.create();
context.set(Object.class, new Object());
@@ -128,6 +134,7 @@ public class ExtendedSupplierInjectionTests extends TestCase {
}
/** bug 428837: ensure suppliers are ranked by service.ranking */
+ @Test
public void testSupplierOrdering() {
BundleContext bc = FrameworkUtil.getBundle(getClass())
.getBundleContext();
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/extensions/InjectionEventTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/extensions/InjectionEventTest.java
index 5ab589010..7efe2dc6b 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/extensions/InjectionEventTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/extensions/InjectionEventTest.java
@@ -7,9 +7,15 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Lars Vogel <Lars.Vogel@vogella.com> - Bug 474274
******************************************************************************/
package org.eclipse.e4.core.internal.tests.di.extensions;
+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 java.lang.reflect.InvocationTargetException;
import java.util.Dictionary;
import java.util.Hashtable;
@@ -17,8 +23,6 @@ import java.util.Hashtable;
import javax.inject.Inject;
import javax.inject.Singleton;
-import junit.framework.TestCase;
-
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.EclipseContextFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
@@ -28,6 +32,8 @@ import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.core.di.extensions.EventTopic;
import org.eclipse.e4.core.di.extensions.EventUtils;
import org.eclipse.e4.core.internal.tests.CoreTestsActivator;
+import org.junit.Before;
+import org.junit.Test;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
@@ -36,7 +42,7 @@ import org.osgi.service.event.EventAdmin;
import org.osgi.service.event.EventConstants;
// TBD add auto-conversion?
-public class InjectionEventTest extends TestCase {
+public class InjectionEventTest {
static protected boolean testFailed = false;
@@ -58,16 +64,18 @@ public class InjectionEventTest extends TestCase {
@Inject @Optional
public void receivedEvent1(@EventTopic("e4/test/event1") String string1) {
- if (!valid)
+ if (!valid) {
testFailed = true;
+ }
counter1++;
this.string1 = string1;
}
@Inject
public void receivedOptionalEvent(MyBinding myBinding, @Optional @EventTopic("e4/test/event3") String string3) {
- if (!valid)
+ if (!valid) {
testFailed = true;
+ }
counter3++;
this.myBinding = myBinding;
this.string3 = string3;
@@ -121,15 +129,15 @@ public class InjectionEventTest extends TestCase {
private EventAdminHelper helper;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
ensureEventAdminStarted();
BundleContext bundleContext = CoreTestsActivator.getDefault().getBundleContext();
IEclipseContext localContext = EclipseContextFactory.getServiceContext(bundleContext);
helper = ContextInjectionFactory.make(EventAdminHelper.class, localContext);
}
+ @Test
public void testEventInjection() throws InvocationTargetException, InstantiationException {
IInjector injector = InjectorFactory.getDefault();
@@ -182,6 +190,7 @@ public class InjectionEventTest extends TestCase {
assertNotNull(target.myBinding);
}
+ @Test
public void testInjectType() {
IEclipseContext context = EclipseContextFactory.create();
InjectTargetEvent target = ContextInjectionFactory.make(InjectTargetEvent.class, context);
@@ -208,6 +217,7 @@ public class InjectionEventTest extends TestCase {
// NOTE: this test relies on GC being actually done on the test object.
// Java does not guarantee that to happen, so, if this test starts to fail
// intermittently, feel free to comment it
+ @Test
public void testEventInjectionUnsubscribe() throws InvocationTargetException, InstantiationException {
IInjector injector = InjectorFactory.getDefault();
injector.addBinding(MyBinding.class);
@@ -220,6 +230,7 @@ public class InjectionEventTest extends TestCase {
assertFalse(testFailed); // target would have asserted if it is still subscribed
}
+ @Test
public void testInjectWildCard() {
IEclipseContext context = EclipseContextFactory.create();
InjectStarEvent target = ContextInjectionFactory.make(InjectStarEvent.class, context);
@@ -260,8 +271,9 @@ public class InjectionEventTest extends TestCase {
if (CoreTestsActivator.getDefault().getEventAdmin() == null) {
Bundle[] bundles = CoreTestsActivator.getDefault().getBundleContext().getBundles();
for (Bundle bundle : bundles) {
- if (!"org.eclipse.equinox.event".equals(bundle.getSymbolicName()))
+ if (!"org.eclipse.equinox.event".equals(bundle.getSymbolicName())) {
continue;
+ }
try {
bundle.start(Bundle.START_TRANSIENT);
} catch (BundleException e) {
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/extensions/InjectionMixedSuppliersTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/extensions/InjectionMixedSuppliersTest.java
index fb92da431..023e8b031 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/extensions/InjectionMixedSuppliersTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/extensions/InjectionMixedSuppliersTest.java
@@ -7,16 +7,17 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Lars Vogel <Lars.Vogel@vogella.com> - Bug 474274
******************************************************************************/
package org.eclipse.e4.core.internal.tests.di.extensions;
+import static org.junit.Assert.assertEquals;
+
import java.lang.reflect.InvocationTargetException;
import javax.inject.Inject;
import javax.inject.Named;
-import junit.framework.TestCase;
-
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
@@ -24,9 +25,10 @@ import org.eclipse.e4.core.contexts.EclipseContextFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.extensions.Preference;
import org.eclipse.e4.core.internal.tests.CoreTestsActivator;
+import org.junit.Test;
import org.osgi.service.prefs.BackingStoreException;
-public class InjectionMixedSuppliersTest extends TestCase {
+public class InjectionMixedSuppliersTest {
static class InjectTarget {
public String pref;
@@ -39,6 +41,7 @@ public class InjectionMixedSuppliersTest extends TestCase {
}
}
+ @Test
public void testPreferencesQualifier() throws BackingStoreException, InvocationTargetException, InstantiationException {
IEclipseContext context = EclipseContextFactory.create();
setPreference("injectedPrefs", "abc");
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/extensions/InjectionOSGiHandlerTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/extensions/InjectionOSGiHandlerTest.java
index 0f2e7e746..9c17c8b2f 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/extensions/InjectionOSGiHandlerTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/extensions/InjectionOSGiHandlerTest.java
@@ -6,10 +6,11 @@
*
* Contributors:
* Markus Alexander Kuppe - initial API and implementation
+ * Lars Vogel <Lars.Vogel@vogella.com> - Bug 474274
******************************************************************************/
package org.eclipse.e4.core.internal.tests.di.extensions;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertNotNull;
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.EclipseContextFactory;
@@ -17,11 +18,10 @@ import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.core.di.extensions.OSGiBundle;
import org.eclipse.e4.core.internal.tests.CoreTestsActivator;
-import org.junit.Before;
import org.junit.Test;
import org.osgi.framework.BundleContext;
-public class InjectionOSGiHandlerTest extends TestCase {
+public class InjectionOSGiHandlerTest {
public static class TestHandler {
@@ -37,14 +37,6 @@ public class InjectionOSGiHandlerTest extends TestCase {
}
}
- /**
- * @throws java.lang.Exception
- */
- @Override
- @Before
- public void setUp() throws Exception {
- }
-
@Test
public void testInjectBCinExecute() {
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/extensions/InjectionOSGiTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/extensions/InjectionOSGiTest.java
index 22a646085..9963949a6 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/extensions/InjectionOSGiTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/extensions/InjectionOSGiTest.java
@@ -1,17 +1,22 @@
/*******************************************************************************
- * Copyright (c) 2013 Markus Alexander Kuppe and others. All rights reserved.
+ * Copyright (c) 2013, 2015 Markus Alexander Kuppe 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:
* Markus Alexander Kuppe - initial API and implementation
+ * Lars Vogel <Lars.Vogel@vogella.com> - Bug 474274
******************************************************************************/
package org.eclipse.e4.core.internal.tests.di.extensions;
-import javax.inject.Inject;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
-import junit.framework.TestCase;
+import javax.inject.Inject;
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.EclipseContextFactory;
@@ -19,11 +24,14 @@ import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.core.di.extensions.OSGiBundle;
import org.eclipse.e4.core.internal.tests.CoreTestsActivator;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
-public class InjectionOSGiTest extends TestCase {
+public class InjectionOSGiTest {
// classed used as a user of the @OSGiBundle annotation
static class InjectionTarget {
@@ -69,8 +77,8 @@ public class InjectionOSGiTest extends TestCase {
private InjectionTarget target;
private Bundle bundle;
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
bundle.start();
final BundleContext bundleContext = CoreTestsActivator
@@ -79,14 +87,10 @@ public class InjectionOSGiTest extends TestCase {
.getServiceContext(bundleContext);
ContextInjectionFactory.uninject(target, localContext);
-
- super.tearDown();
}
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
+ @Before
+ public void setUp() throws Exception {
final BundleContext bundleContext = CoreTestsActivator
.getDefault().getBundleContext();
bundle = bundleContext.getBundle();
@@ -98,10 +102,12 @@ public class InjectionOSGiTest extends TestCase {
localContext);
}
+ @Test
public void testInject() {
assertTrue(target.hasContext());
}
+ @Test
public void testUnInject() throws BundleException, InterruptedException {
// inject
assertTrue(target.hasContext());
@@ -123,6 +129,7 @@ public class InjectionOSGiTest extends TestCase {
assertNotSame(firstContext, secondContext);
}
+ @Test
public void testBundleInject() throws BundleException {
// inject
assertNotNull(target.getBundle());
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/extensions/InjectionPreferencesTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/extensions/InjectionPreferencesTest.java
index 1a9d96370..27c419cd0 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/extensions/InjectionPreferencesTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/extensions/InjectionPreferencesTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2012 IBM Corporation and others.
+ * Copyright (c) 2010, 2015 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
@@ -7,12 +7,15 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Lars Vogel <Lars.Vogel@vogella.com> - Bug 474274
******************************************************************************/
package org.eclipse.e4.core.internal.tests.di.extensions;
-import javax.inject.Inject;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
-import junit.framework.TestCase;
+import javax.inject.Inject;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.InstanceScope;
@@ -22,12 +25,13 @@ import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.core.di.extensions.Preference;
import org.eclipse.e4.core.internal.tests.CoreTestsActivator;
+import org.junit.Test;
import org.osgi.service.prefs.BackingStoreException;
/**
* Note: we do not support byte arrays at this time.
*/
-public class InjectionPreferencesTest extends TestCase {
+public class InjectionPreferencesTest {
static final private String TEST_PREFS_KEY = "testPreferencesQualifier";
static final private String TEST_PREFS_NODE = "org.eclipse.e4.core.tests.ext";
@@ -144,6 +148,7 @@ public class InjectionPreferencesTest extends TestCase {
}
}
+ @Test
public void testPreferencesQualifier() throws BackingStoreException {
setPreference(TEST_PREFS_KEY, "abc");
setPreference(TEST_PREFS_KEY, TEST_PREFS_NODE, "123");
@@ -176,6 +181,7 @@ public class InjectionPreferencesTest extends TestCase {
assertEquals("xyz", target.prefOptional2);
}
+ @Test
public void testBaseTypeConversion() throws BackingStoreException {
// setup preferences
String nodePath = CoreTestsActivator.getDefault().getBundleContext().getBundle().getSymbolicName();
@@ -193,8 +199,8 @@ public class InjectionPreferencesTest extends TestCase {
assertEquals(12, target.intField);
assertEquals(true, target.booleanField);
- assertEquals(12.35345345345d, target.doubleField);
- assertEquals(5.13f, target.floatField);
+ assertEquals(12.35345345345d, target.doubleField, 0);
+ assertEquals(5.13f, target.floatField, 0);
assertEquals(131232343453453L, target.longField);
// assertNotNull(target.byteArrayField);
// assertEquals(4, target.byteArrayField.length);
@@ -217,6 +223,7 @@ public class InjectionPreferencesTest extends TestCase {
assertEquals(false, target.booleanArg);
}
+ @Test
public void testAutoConversion() throws BackingStoreException {
// setup preferences
String nodePath = CoreTestsActivator.getDefault().getBundleContext().getBundle().getSymbolicName();
@@ -267,6 +274,7 @@ public class InjectionPreferencesTest extends TestCase {
node.flush();
}
+ @Test
public void testPreferencesConstructor() throws BackingStoreException {
setPreference(TEST_PREFS_KEY, "abc");
setPreference(TEST_PREFS_KEY, TEST_PREFS_NODE, "123");
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/manual/ComputedValueLimitationTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/manual/ComputedValueLimitationTest.java
index 1d5d647b3..cbaa2ab19 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/manual/ComputedValueLimitationTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/manual/ComputedValueLimitationTest.java
@@ -7,19 +7,20 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Lars Vogel <Lars.Vogel@vogella.com> - Bug 474274
*******************************************************************************/
package org.eclipse.e4.core.internal.tests.manual;
-import javax.inject.Inject;
+import static org.junit.Assert.assertTrue;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import javax.inject.Inject;
import org.eclipse.e4.core.contexts.ContextFunction;
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.EclipseContextFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
+import org.junit.Test;
+
/**
* This is a demo of a scenario when computed values don't work. The basic idea here is that a
@@ -32,15 +33,8 @@ import org.eclipse.e4.core.contexts.IEclipseContext;
* We use a system timer here as an external input, but it can be pretty much anything not stored
* directly in the context.
*/
-public class ComputedValueLimitationTest extends TestCase {
+public class ComputedValueLimitationTest {
- public ComputedValueLimitationTest() {
- super();
- }
-
- public ComputedValueLimitationTest(String name) {
- super(name);
- }
/**
* Used as an injection target
@@ -83,11 +77,13 @@ public class ComputedValueLimitationTest extends TestCase {
}
}
+ @Test
public synchronized void testInjection() {
IEclipseContext context = EclipseContextFactory.create();
- for (int i = 0; i < 10; i++)
+ for (int i = 0; i < 10; i++) {
context.set("arg" + Integer.toString(i), Integer.toString(i));
+ }
context.set("computed", new CalcColor());
UserObject userObject = new UserObject();
@@ -107,6 +103,7 @@ public class ComputedValueLimitationTest extends TestCase {
}
}
+ @Test
public void testVolatileFunction() {
IEclipseContext context = EclipseContextFactory.create();
context.set("time", new Time());
@@ -120,8 +117,4 @@ public class ComputedValueLimitationTest extends TestCase {
assertTrue(time != newTime);
}
- public static Test suite() {
- return new TestSuite(ComputedValueLimitationTest.class);
- }
-
}
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/manual/InjectionErrorReportingTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/manual/InjectionErrorReportingTest.java
index 1baf1f530..46f3a5a83 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/manual/InjectionErrorReportingTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/manual/InjectionErrorReportingTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2012 IBM Corporation and others.
+ * Copyright (c) 2010, 2015 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
@@ -7,9 +7,13 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Lars Vogel <Lars.Vogel@vogella.com> - Bug 474274
*******************************************************************************/
package org.eclipse.e4.core.internal.tests.manual;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.inject.Inject;
@@ -20,14 +24,13 @@ import org.eclipse.e4.core.contexts.EclipseContextFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.InjectionException;
import org.eclipse.e4.core.di.annotations.Creatable;
-
-import junit.framework.TestCase;
+import org.junit.Test;
/**
* Manual test to observe error reporting. The JUnits in this
* test are expected to produce exceptions in the output stream.
*/
-public class InjectionErrorReportingTest extends TestCase {
+public class InjectionErrorReportingTest {
static class TestData {
}
@@ -121,6 +124,7 @@ public class InjectionErrorReportingTest extends TestCase {
/**
* Shows the error message for an unresolved method argument
*/
+ @Test
public void testMethodInjectionError() {
IEclipseContext context = EclipseContextFactory.create();
TestData methodValue = new TestData();
@@ -139,6 +143,7 @@ public class InjectionErrorReportingTest extends TestCase {
/**
* Shows the error message in case method call throws an exception
*/
+ @Test
public void testMethodInjectionNullError() {
IEclipseContext context = EclipseContextFactory.create();
TestData methodValue = new TestData();
@@ -157,6 +162,7 @@ public class InjectionErrorReportingTest extends TestCase {
/**
* Shows the error message for an unresolved constructor argument
*/
+ @Test
public void testConstructorInjectionError() {
IEclipseContext context = EclipseContextFactory.create();
TestData methodValue = new TestData();
@@ -174,6 +180,7 @@ public class InjectionErrorReportingTest extends TestCase {
/**
* Shows the error message for an exception in the injected constructor
*/
+ @Test
public void testConstructorCastError() {
IEclipseContext context = EclipseContextFactory.create();
TestData methodValue = new TestData();
@@ -191,6 +198,7 @@ public class InjectionErrorReportingTest extends TestCase {
/**
* Shows the error message for an unresolved field value
*/
+ @Test
public void testFieldInjectionError() {
IEclipseContext context = EclipseContextFactory.create();
TestData methodValue = new TestData();
@@ -209,6 +217,7 @@ public class InjectionErrorReportingTest extends TestCase {
/**
* Shows the error message in case @PostConstruct method call throws an exception
*/
+ @Test
public void testPostConstructError() {
IEclipseContext context = EclipseContextFactory.create();
TestData methodValue = new TestData();
@@ -226,6 +235,7 @@ public class InjectionErrorReportingTest extends TestCase {
/**
* Shows the error message in case @PreDestory method call throws an exception
*/
+ @Test
public void testPreDestoryError() {
IEclipseContext context = EclipseContextFactory.create();
TestData methodValue = new TestData();
@@ -247,6 +257,7 @@ public class InjectionErrorReportingTest extends TestCase {
* the fix for bug 457687 now exposes java.lang.Errors (such as
* StackOverflowError) rather than wrapping them in an InjectionException.
*/
+ @Test
public void testRecursionError() {
IEclipseContext context = EclipseContextFactory.create();
boolean exception = false;
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/nls/LocaleTransformationTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/nls/LocaleTransformationTest.java
index dc0863f6f..45cc50ab2 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/nls/LocaleTransformationTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/nls/LocaleTransformationTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2014 Dirk Fauth and others.
+ * Copyright (c) 2014, 2015 Dirk Fauth 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
@@ -7,17 +7,18 @@
*
* Contributors:
* Dirk Fauth <dirk.fauth@googlemail.com> - initial API and implementation
+ * Lars Vogel <Lars.Vogel@vogella.com> - Bug 474274
******************************************************************************/
package org.eclipse.e4.core.internal.tests.nls;
-import java.util.Locale;
+import static org.junit.Assert.assertEquals;
-import junit.framework.TestCase;
+import java.util.Locale;
import org.eclipse.e4.core.internal.services.ResourceBundleHelper;
import org.junit.Test;
-public class LocaleTransformationTest extends TestCase {
+public class LocaleTransformationTest {
@Test
public void testValidLanguageCountryVariant() {
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/nls/MessageRegistryTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/nls/MessageRegistryTest.java
index 09053753d..477b7afbc 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/nls/MessageRegistryTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/nls/MessageRegistryTest.java
@@ -1,18 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2014, 2015 Dirk Fauth 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:
+ * Dirk Fauth <dirk.fauth@googlemail.com> - initial API and implementation
+ * Lars Vogel <Lars.Vogel@vogella.com> - Bug 474274
+ ******************************************************************************/
+
package org.eclipse.e4.core.internal.tests.nls;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
import java.util.Locale;
import javax.inject.Inject;
-import junit.framework.TestCase;
-
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.EclipseContextFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.internal.tests.CoreTestsActivator;
import org.eclipse.e4.core.services.translation.TranslationService;
+import org.junit.Before;
+import org.junit.Test;
-public class MessageRegistryTest extends TestCase {
+public class MessageRegistryTest {
static class TestObject {
@Inject
@@ -33,12 +48,13 @@ public class MessageRegistryTest extends TestCase {
private IEclipseContext context;
- @Override
+ @Before
public void setUp() {
this.context = EclipseContextFactory.getServiceContext(CoreTestsActivator.getDefault().getBundleContext());
ContextInjectionFactory.setDefault(context);
}
+ @Test
public void testRegisterLocalizationByProperty() {
// ensure the en Locale is set for this test
this.context.set(TranslationService.LOCALE, Locale.ENGLISH);
@@ -54,6 +70,7 @@ public class MessageRegistryTest extends TestCase {
assertEquals("BundleMessage", control.getLocalizableValue());
}
+ @Test
public void testRegisterLocalizationByMethod() {
// ensure the en Locale is set for this test
this.context.set(TranslationService.LOCALE, Locale.ENGLISH);
@@ -69,6 +86,7 @@ public class MessageRegistryTest extends TestCase {
assertEquals("BundleMessage", control.getLocalizableValue());
}
+ @Test
public void testRegisterLocalizationByPropertyAndChangeLocale() {
// ensure the en Locale is set for this test
this.context.set(TranslationService.LOCALE, Locale.ENGLISH);
@@ -89,6 +107,7 @@ public class MessageRegistryTest extends TestCase {
assertEquals("BundleNachricht", control.getLocalizableValue());
}
+ @Test
public void testRegisterLocalizationByMethodAndChangeLocale() {
// ensure the en Locale is set for this test
this.context.set(TranslationService.LOCALE, Locale.ENGLISH);
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/nls/NLSTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/nls/NLSTest.java
index 99acec2d6..7881f3915 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/nls/NLSTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/nls/NLSTest.java
@@ -1,19 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2014, 2015 Dirk Fauth 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:
+ * Dirk Fauth <dirk.fauth@googlemail.com> - initial API and implementation
+ * Lars Vogel <Lars.Vogel@vogella.com> - Bug 474274
+ ******************************************************************************/
+
package org.eclipse.e4.core.internal.tests.nls;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
import java.util.Locale;
import javax.inject.Inject;
-import junit.framework.TestCase;
-
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.EclipseContextFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.internal.tests.CoreTestsActivator;
import org.eclipse.e4.core.services.nls.Translation;
import org.eclipse.e4.core.services.translation.TranslationService;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
-public class NLSTest extends TestCase {
+public class NLSTest {
static class TestSimpleObject {
@Inject
@@ -48,7 +64,7 @@ public class NLSTest extends TestCase {
private IEclipseContext context;
private Locale beforeLocale;
- @Override
+ @Before
public void setUp() {
this.context = EclipseContextFactory.getServiceContext(CoreTestsActivator.getDefault().getBundleContext());
ContextInjectionFactory.setDefault(context);
@@ -58,11 +74,12 @@ public class NLSTest extends TestCase {
Locale.setDefault(new Locale("en"));
}
- @Override
+ @After
public void tearDown() {
Locale.setDefault(beforeLocale);
}
+ @Test
public void testSimpleMessages() {
//ensure the en Locale is set for this test
this.context.set(TranslationService.LOCALE, Locale.ENGLISH);
@@ -98,6 +115,7 @@ public class NLSTest extends TestCase {
assertEquals("SimpleMessageCamelCaseAndUnderscoreDeUnderscorifiedAndDeCamelCasified", messages.messageNine_Sub);
}
+ @Test
public void testSimpleMessagesDifferentLocale() {
//set Locale to de
this.context.set(TranslationService.LOCALE, Locale.GERMAN);
@@ -136,6 +154,7 @@ public class NLSTest extends TestCase {
messages.messageNine_Sub);
}
+ @Test
public void testSimpleMessagesSkipDefaultLocaleForEquinoxRoot() {
//change the default Locale for this testcase
Locale.setDefault(new Locale("de"));
@@ -179,6 +198,7 @@ public class NLSTest extends TestCase {
assertEquals("SimpleMessageCamelCaseAndUnderscoreDeUnderscorifiedAndDeCamelCasified", messages.messageNine_Sub);
}
+ @Test
public void testSimpleMessagesUseDefaultLocaleForInvalidLocale() {
//change the default Locale for this testcase
Locale.setDefault(new Locale("de"));
@@ -220,6 +240,7 @@ public class NLSTest extends TestCase {
messages.messageNine_Sub);
}
+ @Test
public void testMessages() {
//ensure the en Locale is set for this test
this.context.set(TranslationService.LOCALE, Locale.ENGLISH);
@@ -255,6 +276,7 @@ public class NLSTest extends TestCase {
assertEquals("MessageCamelCaseAndUnderscoreDeUnderscorifiedAndDeCamelCasified", messages.messageNine_Sub);
}
+ @Test
public void testMessagesDifferentLocale() {
//set Locale to de
this.context.set(TranslationService.LOCALE, Locale.GERMAN);
@@ -293,6 +315,7 @@ public class NLSTest extends TestCase {
messages.messageNine_Sub);
}
+ @Test
public void testMessagesSkipDefaultLocaleForEquinoxRoot() {
//change the default Locale for this testcase
Locale.setDefault(new Locale("de"));
@@ -336,6 +359,7 @@ public class NLSTest extends TestCase {
assertEquals("MessageCamelCaseAndUnderscoreDeUnderscorifiedAndDeCamelCasified", messages.messageNine_Sub);
}
+ @Test
public void testMessagesUseDefaultLocaleForInvalidLocale() {
//change the default Locale for this testcase
Locale.setDefault(new Locale("de"));
@@ -377,6 +401,7 @@ public class NLSTest extends TestCase {
messages.messageNine_Sub);
}
+ @Test
public void testBundleMessages() {
//ensure the en Locale is set for this test
this.context.set(TranslationService.LOCALE, Locale.ENGLISH);
@@ -412,6 +437,7 @@ public class NLSTest extends TestCase {
assertEquals("BundleMessageCamelCaseAndUnderscoreDeUnderscorifiedAndDeCamelCasified", messages.messageNine_Sub);
}
+ @Test
public void testBundleMessagesDifferentLocale() {
//set Locale to de
this.context.set(TranslationService.LOCALE, Locale.GERMAN);
@@ -450,6 +476,7 @@ public class NLSTest extends TestCase {
messages.messageNine_Sub);
}
+ @Test
public void testBundleMessagesSkipDefaultLocaleForEquinoxRoot() {
//change the default Locale for this testcase
Locale.setDefault(new Locale("de"));
@@ -493,6 +520,7 @@ public class NLSTest extends TestCase {
assertEquals("BundleMessageCamelCaseAndUnderscoreDeUnderscorifiedAndDeCamelCasified", messages.messageNine_Sub);
}
+ @Test
public void testBundleMessagesUseDefaultLocaleForInvalidLocale() {
//change the default Locale for this testcase
Locale.setDefault(new Locale("de"));
@@ -534,6 +562,7 @@ public class NLSTest extends TestCase {
messages.messageNine_Sub);
}
+ @Test
public void testClassBasedResourceBundle() {
//ensure the en Locale is set for this test
this.context.set(TranslationService.LOCALE, Locale.ENGLISH);
@@ -571,6 +600,7 @@ public class NLSTest extends TestCase {
messages.messageNine_Sub);
}
+ @Test
public void testClassBasedResourceBundleDifferentLocale() {
//set Locale to de
this.context.set(TranslationService.LOCALE, Locale.GERMAN);
@@ -609,6 +639,7 @@ public class NLSTest extends TestCase {
messages.messageNine_Sub);
}
+ @Test
public void testClassBasedResourceBundleSkipDefaultLocaleForEquinoxRoot() {
//change the default Locale for this testcase
Locale.setDefault(new Locale("de"));
@@ -654,6 +685,7 @@ public class NLSTest extends TestCase {
messages.messageNine_Sub);
}
+ @Test
public void testClassBasedResourceBundleUseDefaultLocaleForInvalidLocale() {
//change the default Locale for this testcase
Locale.setDefault(new Locale("de"));
@@ -695,6 +727,7 @@ public class NLSTest extends TestCase {
messages.messageNine_Sub);
}
+ @Test
public void testResourcesBundle() {
//ensure the en Locale is set for this test
this.context.set(TranslationService.LOCALE, Locale.ENGLISH);
@@ -732,6 +765,7 @@ public class NLSTest extends TestCase {
messages.messageNine_Sub);
}
+ @Test
public void testResourcesBundleDifferentLocale() {
//set Locale to de
this.context.set(TranslationService.LOCALE, Locale.GERMAN);
@@ -770,6 +804,7 @@ public class NLSTest extends TestCase {
messages.messageNine_Sub);
}
+ @Test
public void testResourcesBundleSkipDefaultLocaleForEquinoxRoot() {
//change the default Locale for this testcase
Locale.setDefault(new Locale("de"));
@@ -815,6 +850,7 @@ public class NLSTest extends TestCase {
messages.messageNine_Sub);
}
+ @Test
public void testResourcesBundleUseDefaultLocaleForInvalidLocale() {
//change the default Locale for this testcase
Locale.setDefault(new Locale("de"));
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/tests/CoreTestSuite.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/tests/CoreTestSuite.java
index efdbe9ed0..e47c2e4a4 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/tests/CoreTestSuite.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/tests/CoreTestSuite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2012 IBM Corporation and others.
+ * Copyright (c) 2009, 2015 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
@@ -7,13 +7,11 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Lars Vogel <Lars.Vogel@vogella.com> - Bug 474274
******************************************************************************/
package org.eclipse.e4.core.tests;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.eclipse.e4.core.internal.tests.contexts.ActivationTest;
import org.eclipse.e4.core.internal.tests.contexts.ContextDynamicTest;
import org.eclipse.e4.core.internal.tests.contexts.DependenciesLeakTest;
@@ -56,63 +54,66 @@ import org.eclipse.e4.core.internal.tests.di.extensions.InjectionOSGiHandlerTest
import org.eclipse.e4.core.internal.tests.di.extensions.InjectionOSGiTest;
import org.eclipse.e4.core.internal.tests.di.extensions.InjectionPreferencesTest;
import org.eclipse.e4.core.internal.tests.nls.NLSTest;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
-public class CoreTestSuite extends TestSuite {
- public static Test suite() {
- return new CoreTestSuite();
- }
-
- public CoreTestSuite() {
- addTestSuite(ExtendedSupplierInjectionTests.class);
- addTestSuite(InjectionPreferencesTest.class);
- addTestSuite(InjectionMixedSuppliersTest.class);
- addTestSuite(InjectionEventTest.class);
- addTestSuite(InjectionOSGiTest.class);
- addTestSuite(InjectionOSGiHandlerTest.class);
+@RunWith(Suite.class)
+ @Suite.SuiteClasses({
+ ExtendedSupplierInjectionTests.class,
+ InjectionPreferencesTest.class,
+ InjectionMixedSuppliersTest.class,
+ InjectionEventTest.class,
+ InjectionOSGiTest.class,
+ InjectionOSGiHandlerTest.class,
// DI
- addTestSuite(InjectionOrderTest.class);
- addTestSuite(InvokeTest.class);
- addTestSuite(InjectBaseTypeTest.class);
- addTestSuite(InvokeTestMissingAnnotation.class);
- addTestSuite(InjectionResultLeakTest.class);
- addTest(AtInjectTest.suite());
- addTestSuite(AutoConstructTest.class);
+ InjectionOrderTest.class,
+ InvokeTest.class,
+ InjectBaseTypeTest.class,
+ InvokeTestMissingAnnotation.class,
+ InjectionResultLeakTest.class,
+ AtInjectTest.class,
+ AutoConstructTest.class,
// Contexts
- addTestSuite(EclipseContextTest.class);
- addTestSuite(ContextInjectionTest.class);
- addTestSuite(ContextInjectionDisposeTest.class);
- addTestSuite(ContextInjectionFactoryTest.class);
- addTestSuite(ContextDynamicTest.class);
- addTestSuite(ReparentingTest.class);
- addTestSuite(RunAndTrackTest.class);
- addTestSuite(ParentContextDisposalTest.class);
- addTestSuite(ComplexDisposalTest.class);
- addTestSuite(DisposeClassLinkTest.class);
- addTestSuite(InjectStaticContextTest.class);
- addTestSuite(ActivationTest.class);
+ EclipseContextTest.class,
+ ContextInjectionTest.class,
+ ContextInjectionDisposeTest.class,
+ ContextInjectionFactoryTest.class,
+ ContextDynamicTest.class,
+ ReparentingTest.class,
+ RunAndTrackTest.class,
+ ParentContextDisposalTest.class,
+ ComplexDisposalTest.class,
+ DisposeClassLinkTest.class,
+ InjectStaticContextTest.class,
+ ActivationTest.class,
// Contexts injection
- addTestSuite(AnnotationsInjectionTest.class);
- addTestSuite(TestConstructorInjection.class);
- addTestSuite(ServiceContextTest.class);
- addTestSuite(ProviderInjectionTest.class);
- addTestSuite(InjectionUpdateTest.class);
- addTestSuite(DisposingReferencedContextTest.class);
- addTestSuite(InjectionOrderTest.class);
- addTestSuite(GroupedUpdatesTest.class);
- addTestSuite(ExtraDependenciesTest.class);
- addTestSuite(ContextFunctionDynamicsTest.class);
- addTestSuite(InjectArraysTest.class);
- addTestSuite(InvokeInRATTest.class);
- addTestSuite(Bug317183Test.class);
- addTestSuite(DependenciesLeakTest.class);
- addTestSuite(ActivationInjectionTest.class);
- addTestSuite(GenericsInjectionTest.class);
- addTestSuite(RecursiveObjectCreationTest.class);
+ AnnotationsInjectionTest.class,
+ TestConstructorInjection.class,
+ ServiceContextTest.class,
+ ProviderInjectionTest.class,
+ InjectionUpdateTest.class,
+ DisposingReferencedContextTest.class,
+ InjectionOrderTest.class,
+ GroupedUpdatesTest.class,
+ ExtraDependenciesTest.class,
+ ContextFunctionDynamicsTest.class,
+ InjectArraysTest.class,
+ InvokeInRATTest.class,
+ Bug317183Test.class,
+ DependenciesLeakTest.class,
+ ActivationInjectionTest.class,
+ GenericsInjectionTest.class,
+ RecursiveObjectCreationTest.class,
// NLS
- addTestSuite(NLSTest.class);
+ NLSTest.class,
+ })
+ public class CoreTestSuite
+
+ {
+
}
-}
+

Back to the top