BugĀ 448862 - [Tests] Migrate o.e.jface.tests.databinding to JUnit 4
Change-Id: Iec1cab7337dc5a18fc37e8e82e070e6abc13bf65
Signed-off-by: Conrad Groth <info@conrad-groth.de>
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/Adventure.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/Adventure.java
index 713260f..658508d 100644
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/Adventure.java
+++ b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/Adventure.java
@@ -111,5 +111,4 @@
public String getDescription() {
return description;
}
-
}
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/Cart.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/Cart.java
index 92ea666..651a957 100644
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/Cart.java
+++ b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/model/Cart.java
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.jface.examples.databinding.model;
+import java.beans.PropertyChangeListener;
+
public class Cart {
public void setAdventureDays(int i) {
@@ -22,4 +24,13 @@
return 0;
}
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ // not really necessary, but BeansObservables.observeValue(...) expects
+ // it.
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ // not really necessary, but BeansObservables.observeValue(...) expects
+ // it.
+ }
}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/AggregateValidationStatusTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/AggregateValidationStatusTest.java
index 28d5b06..62824ab 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/AggregateValidationStatusTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/AggregateValidationStatusTest.java
@@ -11,16 +11,20 @@
package org.eclipse.core.tests.databinding;
+import static org.junit.Assert.assertEquals;
+
import org.eclipse.core.databinding.AggregateValidationStatus;
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.observable.Realm;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.tests.databinding.AbstractSWTTestCase;
+import org.junit.Test;
/**
* @since 1.1
*/
public class AggregateValidationStatusTest extends AbstractSWTTestCase {
+ @Test
public void testAggregateValidationStatusValueType() throws Exception {
DataBindingContext dbc = new DataBindingContext();
AggregateValidationStatus status = new AggregateValidationStatus(dbc
@@ -28,6 +32,7 @@
assertEquals(IStatus.class, status.getValueType());
}
+ @Test
public void testConstructor_DefaultRealm() throws Exception {
DataBindingContext dbc = new DataBindingContext();
AggregateValidationStatus status = new AggregateValidationStatus(dbc
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/BindingTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/BindingTest.java
index ec49be3..d67acd8 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/BindingTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/BindingTest.java
@@ -11,12 +11,18 @@
package org.eclipse.core.tests.databinding;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import org.eclipse.core.databinding.Binding;
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.core.databinding.observable.value.WritableValue;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Before;
+import org.junit.Test;
public class BindingTest extends AbstractDefaultRealmTestCase {
private IObservable target;
@@ -25,8 +31,8 @@
private DataBindingContext dbc;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
target = WritableValue.withValueType(String.class);
@@ -34,6 +40,7 @@
dbc = new DataBindingContext();
}
+ @Test
public void testDisposeTargetDisposesBinding() {
Binding binding = createBinding();
assertFalse(binding.isDisposed());
@@ -41,6 +48,7 @@
assertTrue(binding.isDisposed());
}
+ @Test
public void testDisposeModelDisposesBinding() {
Binding binding = createBinding();
assertFalse(binding.isDisposed());
@@ -48,6 +56,7 @@
assertTrue(binding.isDisposed());
}
+ @Test
public void testPreDisposedTarget_FiresIllegalArgumentException() {
try {
target.dispose();
@@ -57,6 +66,7 @@
}
}
+ @Test
public void testPreDisposedModel_FiresIllegalArgumentException() {
try {
model.dispose();
@@ -66,18 +76,21 @@
}
}
+ @Test
public void testDisposeModelThenBinding() {
Binding binding = createBinding();
model.dispose();
binding.dispose();
}
+ @Test
public void testDisposeTargetThenBinding() {
Binding binding = createBinding();
target.dispose();
binding.dispose();
}
+ @Test
public void testDisposeObservablesThenBinding() {
Binding binding = createBinding();
model.dispose();
@@ -85,18 +98,21 @@
binding.dispose();
}
+ @Test
public void testDisposeBindingThenModel() {
Binding binding = createBinding();
binding.dispose();
model.dispose();
}
+ @Test
public void testDisposeBindingThenTarget() {
Binding binding = createBinding();
binding.dispose();
target.dispose();
}
+ @Test
public void testDisposeBindingThenObservables() {
Binding binding = createBinding();
binding.dispose();
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/DatabindingContextTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/DatabindingContextTest.java
index d2b87fb..d35bc85 100755
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/DatabindingContextTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/DatabindingContextTest.java
@@ -12,6 +12,12 @@
*******************************************************************************/
package org.eclipse.core.tests.databinding;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.util.ArrayList;
import org.eclipse.core.databinding.AggregateValidationStatus;
@@ -30,25 +36,29 @@
import org.eclipse.jface.databinding.conformance.util.ChangeEventTracker;
import org.eclipse.jface.databinding.conformance.util.ValueChangeEventTracker;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
public class DatabindingContextTest extends AbstractDefaultRealmTestCase {
private DataBindingContext dbc;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
dbc = new DataBindingContext();
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
if (dbc != null) {
dbc.dispose();
}
super.tearDown();
}
+ @Test
public void testDisposeBindings() throws Exception {
Binding binding = new BindingStub();
binding.init(dbc);
@@ -59,6 +69,7 @@
.isDisposed());
}
+ @Test
public void testBindValue() throws Exception {
IObservableValue target = WritableValue.withValueType(String.class);
IObservableValue model = WritableValue.withValueType(String.class);
@@ -68,6 +79,7 @@
.getName().endsWith("ValueBinding"));
}
+ @Test
public void testBindList() throws Exception {
IObservableList target = WritableList.withElementType(Object.class);
IObservableList model = WritableList.withElementType(Object.class);
@@ -83,6 +95,7 @@
*
* @throws Exception
*/
+ @Test
public void testValidationError() throws Exception {
WritableValue targetObservable = WritableValue
.withValueType(String.class);
@@ -130,6 +143,7 @@
*
* @throws Exception
*/
+ @Test
public void testBindValueAddBinding() throws Exception {
WritableValue targetValue = WritableValue.withValueType(String.class);
WritableValue modelValue = WritableValue.withValueType(String.class);
@@ -151,6 +165,7 @@
*
* @throws Exception
*/
+ @Test
public void testBindListAddBinding() throws Exception {
WritableList targetList = new WritableList(new ArrayList(),
Object.class);
@@ -166,6 +181,7 @@
assertEquals(binding, dbc.getBindings().get(0));
}
+ @Test
public void testGetBindingsImmutability() throws Exception {
BindingStub binding = new BindingStub();
binding.init(dbc);
@@ -177,6 +193,7 @@
}
}
+ @Test
public void testRemoveBinding() throws Exception {
BindingStub binding = new BindingStub();
binding.init(dbc);
@@ -195,6 +212,7 @@
*
* @throws Exception
*/
+ @Test
public void testValidateTargetAfterValueBindingCreation() throws Exception {
WritableValue target = new WritableValue("", String.class);
WritableValue model = new WritableValue("2", String.class);
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/ListBindingTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/ListBindingTest.java
index 4de5ba6..75f8283 100755
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/ListBindingTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/ListBindingTest.java
@@ -16,6 +16,10 @@
import static org.eclipse.core.databinding.UpdateListStrategy.POLICY_NEVER;
import static org.eclipse.core.databinding.UpdateListStrategy.POLICY_UPDATE;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -35,6 +39,9 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
import org.junit.Assert;
+import org.junit.Before;
+import org.junit.After;
+import org.junit.Test;
/**
* @since 1.1
@@ -44,8 +51,8 @@
private IObservableList model;
private DataBindingContext dbc;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
target = new WritableList(new ArrayList(), String.class);
@@ -53,13 +60,14 @@
dbc = new DataBindingContext();
}
- @Override
+ @After
public void tearDown() throws Exception {
dbc.dispose();
model.dispose();
target.dispose();
}
+ @Test
public void testUpdateModelFromTarget() throws Exception {
Binding binding = dbc.bindList(target, model,
new UpdateListStrategy(UpdateListStrategy.POLICY_ON_REQUEST),
@@ -77,6 +85,7 @@
assertEquals("target != model", target, model);
}
+ @Test
public void testUpdateTargetFromModel() throws Exception {
Binding binding = dbc.bindList(target, model,
new UpdateListStrategy(UpdateListStrategy.POLICY_ON_REQUEST),
@@ -95,21 +104,25 @@
assertEquals("model != target", model, target);
}
+ @Test
public void testGetTarget() throws Exception {
Binding binding = dbc.bindList(target, model);
assertEquals(target, binding.getTarget());
}
+ @Test
public void testGetModel() throws Exception {
Binding binding = dbc.bindList(target, model);
assertEquals(model, binding.getModel());
}
+ @Test
public void testStatusIsInstanceOfBindingStatus() throws Exception {
Binding binding = dbc.bindList(target, model);
assertTrue(binding.getValidationStatus().getValue() instanceof BindingStatus);
}
+ @Test
public void testAddValidationStatusContainsMultipleStatuses() throws Exception {
UpdateListStrategy strategy = new UpdateListStrategy() {
@Override
@@ -141,6 +154,7 @@
assertEquals("second status severity", IStatus.INFO, children[1].getSeverity());
}
+ @Test
public void testRemoveValidationStatusContainsMultipleStatuses() throws Exception {
List items = Arrays.asList(new String[] {"1", "2"});
model.addAll(items);
@@ -175,6 +189,7 @@
assertEquals("second status severity", IStatus.INFO, children[1].getSeverity());
}
+ @Test
public void testAddOKValidationStatus() throws Exception {
Binding binding = dbc.bindList(target, model);
target.add("1");
@@ -184,6 +199,7 @@
assertEquals(0, status.getChildren().length);
}
+ @Test
public void testRemoveOKValidationStatus() throws Exception {
model.add("1");
Binding binding = dbc.bindList(target, model);
@@ -198,6 +214,7 @@
* we test common functionality from UpdateStrategy here, because that base
* class would need much more stubbing and mocking to test it.
*/
+ @Test
public void testErrorDuringConversionIsLogged() {
UpdateListStrategy modelToTarget = new UpdateListStrategy();
modelToTarget.setConverter(new IConverter() {
@@ -243,6 +260,7 @@
* we test common functionality from UpdateStrategy here, because that base
* class would need much more stubbing and mocking to test it.
*/
+ @Test
public void testErrorDuringRemoveIsLogged() {
IObservableList<String> target = new WritableList<String>() {
@Override
@@ -273,6 +291,7 @@
* we test common functionality from UpdateStrategy here, because that base
* class would need much more stubbing and mocking to test it.
*/
+ @Test
public void testErrorDuringMoveIsLogged() {
IObservableList<String> target = new WritableList<String>() {
@Override
@@ -304,6 +323,7 @@
* we test common functionality from UpdateStrategy here, because that base
* class would need much more stubbing and mocking to test it.
*/
+ @Test
public void testErrorDuringReplaceIsLogged() {
IObservableList<String> target = new WritableList<String>() {
@Override
@@ -333,6 +353,7 @@
/**
* test for bug 491678
*/
+ @Test
public void testAddListenerAndInitialSyncAreUninterruptable() {
Policy.setLog(new ILogger() {
@Override
@@ -351,6 +372,7 @@
/**
* test for bug 491678
*/
+ @Test
public void testTargetValueIsSyncedToModelIfModelWasNotSyncedToTarget() {
target.add("first");
dbc.bindList(target, model, new UpdateListStrategy(POLICY_UPDATE), new UpdateListStrategy(POLICY_NEVER));
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/ObservablesManagerTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/ObservablesManagerTest.java
index 993b8a2..60d25ad 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/ObservablesManagerTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/ObservablesManagerTest.java
@@ -12,6 +12,9 @@
package org.eclipse.core.tests.databinding;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.ObservablesManager;
import org.eclipse.core.databinding.observable.IObservable;
@@ -19,6 +22,9 @@
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.core.databinding.observable.value.WritableValue;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
/**
* @since 3.2
@@ -27,21 +33,22 @@
public class ObservablesManagerTest extends AbstractDefaultRealmTestCase {
private DataBindingContext dbc;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
dbc = new DataBindingContext();
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
if (dbc != null) {
dbc.dispose();
}
super.tearDown();
}
+ @Test
public void testOnlyModelIsDisposed() throws Exception {
IObservableValue targetOv = new WritableValue();
IObservableValue modelOv = new WritableValue();
@@ -56,6 +63,7 @@
assertTrue(modelOv.isDisposed());
}
+ @Test
public void testOnlyTargetIsDisposed() throws Exception {
IObservableValue targetOv = new WritableValue();
IObservableValue modelOv = new WritableValue();
@@ -70,6 +78,7 @@
assertFalse(modelOv.isDisposed());
}
+ @Test
public void testTargetAndModelIsDisposed() throws Exception {
IObservableValue targetOv = new WritableValue();
IObservableValue modelOv = new WritableValue();
@@ -84,6 +93,7 @@
assertTrue(modelOv.isDisposed());
}
+ @Test
public void testDispose_Bug277966_NPEWhenManagedObservableAlreadyDisposed() {
ObservablesManager manager = new ObservablesManager();
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/SetBindingTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/SetBindingTest.java
index cb243e5..9a91b06 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/SetBindingTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/SetBindingTest.java
@@ -13,6 +13,7 @@
import static org.eclipse.core.databinding.UpdateSetStrategy.POLICY_NEVER;
import static org.eclipse.core.databinding.UpdateSetStrategy.POLICY_UPDATE;
+import static org.junit.Assert.assertEquals;
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.SetBinding;
@@ -23,7 +24,10 @@
import org.eclipse.core.databinding.util.Policy;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.After;
import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
public class SetBindingTest extends AbstractDefaultRealmTestCase {
private IObservableSet<String> target;
@@ -31,7 +35,8 @@
private DataBindingContext dbc;
@Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
target = new WritableSet<>();
@@ -40,12 +45,14 @@
}
@Override
+ @After
public void tearDown() throws Exception {
dbc.dispose();
model.dispose();
target.dispose();
}
+ @Test
public void testUpdateModelFromTarget() throws Exception {
target.add("1");
@@ -54,6 +61,7 @@
assertEquals("target != model", target, model);
}
+ @Test
public void testUpdateTargetFromModel() throws Exception {
model.add("1");
@@ -65,6 +73,7 @@
/**
* test for bug 491678
*/
+ @Test
public void testAddListenerAndInitialSyncAreUninterruptable() {
Policy.setLog(new ILogger() {
@Override
@@ -83,6 +92,7 @@
/**
* test for bug 491678
*/
+ @Test
public void testTargetValueIsSyncedToModelIfModelWasNotSyncedToTarget() {
target.add("first");
dbc.bindSet(target, model, new UpdateSetStrategy(POLICY_UPDATE), new UpdateSetStrategy(POLICY_NEVER));
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/SideEffectTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/SideEffectTest.java
index 53a2561..164112f 100755
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/SideEffectTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/SideEffectTest.java
@@ -21,7 +21,7 @@
import org.eclipse.core.databinding.observable.sideeffect.ISideEffect;
import org.eclipse.core.databinding.observable.value.ComputedValue;
import org.eclipse.core.databinding.observable.value.WritableValue;
-import org.eclipse.jface.tests.databinding.AbstractJUnit4RealmTestCase;
+import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
import org.junit.Before;
import org.junit.Test;
@@ -30,7 +30,7 @@
*
* @since 3.2
*/
-public class SideEffectTest extends AbstractJUnit4RealmTestCase {
+public class SideEffectTest extends AbstractDefaultRealmTestCase {
// TODO: Add test cases for {@link SideEffect#create(Runnable)},
// {@link SideEffect#create(java.util.function.Supplier,
// java.util.function.Consumer)}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/UpdateListStrategyTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/UpdateListStrategyTest.java
index c882814..35bed85 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/UpdateListStrategyTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/UpdateListStrategyTest.java
@@ -11,17 +11,21 @@
package org.eclipse.core.tests.databinding;
+import static org.junit.Assert.fail;
+
import org.eclipse.core.databinding.BindingException;
import org.eclipse.core.databinding.UpdateListStrategy;
import org.eclipse.core.databinding.observable.list.IObservableList;
import org.eclipse.core.databinding.observable.list.WritableList;
import org.eclipse.core.internal.databinding.conversion.IdentityConverter;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Test;
/**
* @since 1.1
*/
public class UpdateListStrategyTest extends AbstractDefaultRealmTestCase {
+ @Test
public void testFillDefaults_AssertSourceTypeExtendsConverterFromType() {
// Valid use: source type String extends converter from-type Object
UpdateListStrategyStub strategy = new UpdateListStrategyStub();
@@ -43,6 +47,7 @@
}
}
+ @Test
public void testFillDefaults_AssertConverterToTypeExtendsDestinationType() {
// Valid use: converter to-type String extends destination type Object
UpdateListStrategyStub strategy = new UpdateListStrategyStub();
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/UpdateSetStrategyTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/UpdateSetStrategyTest.java
index 8a6b46e..2009f36 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/UpdateSetStrategyTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/UpdateSetStrategyTest.java
@@ -11,17 +11,21 @@
package org.eclipse.core.tests.databinding;
+import static org.junit.Assert.fail;
+
import org.eclipse.core.databinding.BindingException;
import org.eclipse.core.databinding.UpdateSetStrategy;
import org.eclipse.core.databinding.observable.set.IObservableSet;
import org.eclipse.core.databinding.observable.set.WritableSet;
import org.eclipse.core.internal.databinding.conversion.IdentityConverter;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Test;
/**
* @since 1.1
*/
public class UpdateSetStrategyTest extends AbstractDefaultRealmTestCase {
+ @Test
public void testFillDefaults_AssertSourceTypeExtendsConverterFromType() {
// Valid use: source type String extends converter from-type Object
UpdateSetStrategyStub strategy = new UpdateSetStrategyStub();
@@ -43,6 +47,7 @@
}
}
+ @Test
public void testFillDefaults_AssertConverterToTypeExtendsDestinationType() {
// Valid use: converter to-type String extends destination type Object
UpdateSetStrategyStub strategy = new UpdateSetStrategyStub();
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/UpdateStrategyTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/UpdateStrategyTest.java
index 3a89d3b..5f2459f 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/UpdateStrategyTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/UpdateStrategyTest.java
@@ -11,6 +11,10 @@
package org.eclipse.core.tests.databinding;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Date;
@@ -41,204 +45,250 @@
import org.eclipse.core.internal.databinding.conversion.StringToShortConverter;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Test;
/**
* @since 1.1
*/
public class UpdateStrategyTest extends AbstractDefaultRealmTestCase {
+ @Test
public void testDefaultConverterForStringToInteger() throws Exception {
assertDefaultConverter(String.class, Integer.class, StringToNumberConverter.class);
}
+ @Test
public void testDefaultConverterForStringToIntegerPrimitive() throws Exception {
assertDefaultConverter(String.class, Integer.TYPE, StringToNumberConverter.class);
}
+ @Test
public void testDefaultConverterForStringToLong() throws Exception {
assertDefaultConverter(String.class, Long.class, StringToNumberConverter.class);
}
+ @Test
public void testDefaultConverterForStringToLongPrimitive() throws Exception {
assertDefaultConverter(String.class, Long.TYPE, StringToNumberConverter.class);
}
+ @Test
public void testDefaultConverterForStringToDouble() throws Exception {
assertDefaultConverter(String.class, Double.class, StringToNumberConverter.class);
}
+ @Test
public void testDefaultConverterForStringToDoublePrimitive() throws Exception {
assertDefaultConverter(String.class, Double.TYPE, StringToNumberConverter.class);
}
+ @Test
public void testDefaultConverterForStringToFloat() throws Exception {
assertDefaultConverter(String.class, Float.class, StringToNumberConverter.class);
}
+ @Test
public void testDefaultConverterForStringToFloatPrimitive() throws Exception {
assertDefaultConverter(String.class, Float.TYPE, StringToNumberConverter.class);
}
+ @Test
public void testDefaultConverterForStringToBigInteger() throws Exception {
assertDefaultConverter(String.class, BigInteger.class, StringToNumberConverter.class);
}
+ @Test
public void testDefaultConverterForIntegerToString() throws Exception {
assertDefaultConverter(Integer.class, String.class, NumberToStringConverter.class);
}
+ @Test
public void testDefaultConverterForIntegerPrimitiveToString() throws Exception {
assertDefaultConverter(Integer.TYPE, String.class, NumberToStringConverter.class);
}
+ @Test
public void testDefaultConverterForLongToString() throws Exception {
assertDefaultConverter(Long.class, String.class, NumberToStringConverter.class);
}
+ @Test
public void testDefaultConverterForLongPrimitiveToString() throws Exception {
assertDefaultConverter(Long.TYPE, String.class, NumberToStringConverter.class);
}
+ @Test
public void testDefaultConverterForDoubleToString() throws Exception {
assertDefaultConverter(Double.class, String.class, NumberToStringConverter.class);
}
+ @Test
public void testDefaultConverterForDoublePrimitiveToString() throws Exception {
assertDefaultConverter(Double.TYPE, String.class, NumberToStringConverter.class);
}
+ @Test
public void testDefaultConverterForFloatToString() throws Exception {
assertDefaultConverter(Float.class, String.class, NumberToStringConverter.class);
}
+ @Test
public void testDefaultConverterForFloatPrimitiveToString() throws Exception {
assertDefaultConverter(Float.TYPE, String.class, NumberToStringConverter.class);
}
+ @Test
public void testDefaultConverterForBigIntegerToString() throws Exception {
assertDefaultConverter(BigInteger.class, String.class, NumberToStringConverter.class);
}
+ @Test
public void testDefaultConverterForDateToString() throws Exception {
assertDefaultConverter(Date.class, String.class, DateToStringConverter.class);
}
+ @Test
public void testDefaultConverterForStringToBoolean() throws Exception {
assertDefaultConverter(String.class, Boolean.class, StringToBooleanConverter.class);
}
+ @Test
public void testDefaultConverterForStringToBooleanPrimitive() throws Exception {
assertDefaultConverter(String.class, Boolean.TYPE, StringToBooleanPrimitiveConverter.class);
}
+ @Test
public void testDefaultConverterForStringToByte() throws Exception {
assertDefaultConverter(String.class, Byte.class, StringToByteConverter.class);
}
+ @Test
public void testDefaultConverterForStringToBytePrimitive() throws Exception {
assertDefaultConverter(String.class, Byte.TYPE, StringToByteConverter.class);
}
+ @Test
public void testDefaultConverterForStringToCharacter() throws Exception {
assertDefaultConverter(String.class, Character.class, StringToCharacterConverter.class);
}
+ @Test
public void testDefaultConverterForStringToDate() throws Exception {
assertDefaultConverter(String.class, Date.class, StringToDateConverter.class);
}
+ @Test
public void testDefaultConverterForStringToShort() throws Exception {
assertDefaultConverter(String.class, Short.class, StringToShortConverter.class);
}
+ @Test
public void testDefaultConverterForStringToShortPrimitive() throws Exception {
assertDefaultConverter(String.class, Short.TYPE, StringToShortConverter.class);
}
+ @Test
public void testDefaultConverterForByteToString() throws Exception {
assertDefaultConverter(Byte.class, String.class, IntegerToStringConverter.class);
}
+ @Test
public void testDefaultConverterForBytePrimitiveToString() throws Exception {
assertDefaultConverter(Byte.TYPE, String.class, IntegerToStringConverter.class);
}
+ @Test
public void testDefaultConverterForShortToString() throws Exception {
assertDefaultConverter(Short.class, String.class, IntegerToStringConverter.class);
}
+ @Test
public void testDefaultConverterForShortPrimitiveToString() throws Exception {
assertDefaultConverter(Short.TYPE, String.class, IntegerToStringConverter.class);
}
+ @Test
public void testDefaultConverterForStatusToString() throws Exception {
assertDefaultConverter(IStatus.class, String.class, StatusToStringConverter.class);
}
+ @Test
public void testDefaultConverterForNumberToByte() throws Exception {
assertFromNumberToNumberConverter(Byte.class, Byte.TYPE,
NumberToByteConverter.class);
}
+ @Test
public void testDefaultConverterForNumberToShort() throws Exception {
assertFromNumberToNumberConverter(Short.class, Short.TYPE,
NumberToShortConverter.class);
}
+ @Test
public void testDefaultConverterForNumberToShortPrimitive()
throws Exception {
assertFromNumberToNumberConverter(Short.TYPE, Short.class,
NumberToShortConverter.class);
}
+ @Test
public void testDefaultConverterForNumberToInteger() throws Exception {
assertFromNumberToNumberConverter(Integer.class, Integer.TYPE,
NumberToIntegerConverter.class);
}
+ @Test
public void testDefaultConverterForNumberToIntegerPrimitive()
throws Exception {
assertFromNumberToNumberConverter(Integer.TYPE, Integer.class,
NumberToIntegerConverter.class);
}
+ @Test
public void testDefaultConverterForNumberToLong() throws Exception {
assertFromNumberToNumberConverter(Long.class, Long.TYPE,
NumberToLongConverter.class);
}
+ @Test
public void testDefaultConverterForNumberToLongPrimitive() throws Exception {
assertFromNumberToNumberConverter(Long.TYPE, Long.class,
NumberToLongConverter.class);
}
+ @Test
public void testDefaultConverterForNumberToFloat() throws Exception {
assertFromNumberToNumberConverter(Float.class, Float.TYPE,
NumberToFloatConverter.class);
}
+ @Test
public void testDefaultConverterForNumberToFloatPrimitive()
throws Exception {
assertFromNumberToNumberConverter(Float.TYPE, Float.class,
NumberToFloatConverter.class);
}
+ @Test
public void testDefaultConverterForNumberToDouble() throws Exception {
assertFromNumberToNumberConverter(Double.class, Double.TYPE,
NumberToDoubleConverter.class);
}
+ @Test
public void testDefaultConverterForNumberToDoublePrimitive()
throws Exception {
assertFromNumberToNumberConverter(Double.TYPE, Double.class,
NumberToDoubleConverter.class);
}
+ @Test
public void testDefaultConverterForNumberToBigInteger() throws Exception {
assertFromNumberToNumberConverter(BigInteger.class, null,
NumberToBigIntegerConverter.class);
}
+ @Test
public void testDefaultConverterForNumberToBigDecimal() throws Exception {
assertFromNumberToNumberConverter(BigDecimal.class, null,
NumberToBigDecimalConverter.class);
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/UpdateValueStrategyTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/UpdateValueStrategyTest.java
index 4b7c94d..a61ad9a 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/UpdateValueStrategyTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/UpdateValueStrategyTest.java
@@ -12,6 +12,11 @@
package org.eclipse.core.tests.databinding;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Date;
@@ -37,120 +42,143 @@
import org.eclipse.core.internal.databinding.validation.StringToLongValidator;
import org.eclipse.core.internal.databinding.validation.StringToShortValidator;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Test;
/**
* @since 1.1
*/
public class UpdateValueStrategyTest extends AbstractDefaultRealmTestCase {
+ @Test
public void testDefaultValidatorForStringToInteger() throws Exception {
assertDefaultValidator(String.class, Integer.class,
StringToIntegerValidator.class);
}
+ @Test
public void testDefaultValidatorForStringToIntegerPrimitive()
throws Exception {
assertDefaultValidator(String.class, Integer.TYPE,
StringToIntegerValidator.class);
}
+ @Test
public void testDefaultValidatorForStringToLong() throws Exception {
assertDefaultValidator(String.class, Long.class,
StringToLongValidator.class);
}
+ @Test
public void testDefaultValidatorForStringToLongPrimitive() throws Exception {
assertDefaultValidator(String.class, Long.TYPE,
StringToLongValidator.class);
}
+ @Test
public void testDefaultValidatorForStringToFloat() throws Exception {
assertDefaultValidator(String.class, Float.class,
StringToFloatValidator.class);
}
+ @Test
public void testDefaultValidatorForStringToFloatPrimitive()
throws Exception {
assertDefaultValidator(String.class, Float.TYPE,
StringToFloatValidator.class);
}
+ @Test
public void testDefaultValidatorForStringToDouble() throws Exception {
assertDefaultValidator(String.class, Double.class,
StringToDoubleValidator.class);
}
+ @Test
public void testDefaultValidatorForStringToDoublePrimitive()
throws Exception {
assertDefaultValidator(String.class, Double.TYPE,
StringToDoubleValidator.class);
}
+ @Test
public void testDefaultValidatorForStringToByte() throws Exception {
assertDefaultValidator(String.class, Byte.class,
StringToByteValidator.class);
}
+ @Test
public void testDefaultValidatorForStringToBytePrimitive() throws Exception {
assertDefaultValidator(String.class, Byte.TYPE,
StringToByteValidator.class);
}
+ @Test
public void testDefaultValidatorForStringToShort() throws Exception {
assertDefaultValidator(String.class, Short.class,
StringToShortValidator.class);
}
+ @Test
public void testDefaultValidatorForStringToShortPrimitive()
throws Exception {
assertDefaultValidator(String.class, Short.TYPE,
StringToShortValidator.class);
}
+ @Test
public void testDefaultValidatorForStringToDate() throws Exception {
assertDefaultValidator(String.class, Date.class,
StringToDateValidator.class);
}
+ @Test
public void testDefaultValidatorForNumberToByte() throws Exception {
assertDefaultValidator(Integer.class, Byte.class,
NumberToByteValidator.class);
}
+ @Test
public void testDefaultValidatorForNumberToShort() throws Exception {
assertDefaultValidator(Integer.class, Short.class,
NumberToShortValidator.class);
}
+ @Test
public void testDefaultValidatorForNumberToInteger() throws Exception {
assertDefaultValidator(Short.class, Integer.class,
NumberToIntegerValidator.class);
}
+ @Test
public void testDefaultValidatorForNumberToLong() throws Exception {
assertDefaultValidator(Short.class, Long.class,
NumberToLongValidator.class);
}
+ @Test
public void testDefaultValidatorForNumberToFloat() throws Exception {
assertDefaultValidator(Short.class, Float.class,
NumberToFloatValidator.class);
}
+ @Test
public void testDefaultValidatorForNumberToDouble() throws Exception {
assertDefaultValidator(Short.class, Double.class,
NumberToDoubleValidator.class);
}
+ @Test
public void testDefaultValidatorForNumberToBigInteger() throws Exception {
assertDefaultValidator(Short.class, BigInteger.class,
NumberToUnboundedNumberValidator.class);
}
+ @Test
public void testDefaultValidatorForNumberToBigDecimal() throws Exception {
assertDefaultValidator(Short.class, BigDecimal.class,
NumberToUnboundedNumberValidator.class);
}
+ @Test
public void testCachesDefaultedValidators() throws Exception {
WritableValue source = WritableValue.withValueType(String.class);
WritableValue destination = WritableValue.withValueType(Integer.class);
@@ -167,6 +195,7 @@
assertSame(validator, strategy.validator);
}
+ @Test
public void testFillDefaults_AssertSourceTypeExtendsConverterFromType() {
// Valid use: source type String extends converter from-type Object
UpdateValueStrategyStub strategy = new UpdateValueStrategyStub();
@@ -188,6 +217,7 @@
}
}
+ @Test
public void testFillDefaults_AssertConverterToTypeExtendsDestinationType() {
// Valid use: converter to-type String extends destination type Object
UpdateValueStrategyStub strategy = new UpdateValueStrategyStub();
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/ValueBindingTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/ValueBindingTest.java
index a54c12f..83de1dd 100755
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/ValueBindingTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/ValueBindingTest.java
@@ -16,6 +16,11 @@
import static org.eclipse.core.databinding.UpdateValueStrategy.POLICY_NEVER;
import static org.eclipse.core.databinding.UpdateValueStrategy.POLICY_UPDATE;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -39,6 +44,8 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Before;
+import org.junit.Test;
/**
* @since 1.1
@@ -53,8 +60,8 @@
private List log;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
target = WritableValue.withValueType(String.class);
@@ -75,6 +82,7 @@
*
* @throws Exception
*/
+ @Test
public void testNoUpdateTargetFromModel() throws Exception {
try {
new DataBindingContext().bindValue(new ObservableValueStub(),
@@ -86,6 +94,7 @@
}
}
+ @Test
public void testValuePropagation() throws Exception {
String initialValue = "value";
model.setValue(initialValue);
@@ -96,18 +105,21 @@
assertEquals(target.getValue(), model.getValue());
}
+ @Test
public void testGetTarget() throws Exception {
Binding binding = dbc.bindValue(target, model);
assertEquals(target, binding.getTarget());
}
+ @Test
public void testGetModel() throws Exception {
Binding binding = dbc.bindValue(target, model);
assertEquals(model, binding.getModel());
}
+ @Test
public void testOKStatusInValidationUpdatesModel() throws Exception {
Binding binding = dbc.bindValue(target, model);
@@ -119,6 +131,7 @@
assertTrue(((IStatus) binding.getValidationStatus().getValue()).isOK());
}
+ @Test
public void testWarningStatusInValidationUpdatesModel() throws Exception {
Binding binding = dbc.bindValue(target, model,
new UpdateValueStrategy()
@@ -133,6 +146,7 @@
.getValidationStatus().getValue()).getSeverity());
}
+ @Test
public void testInfoStatusInValidationUpdatesModel() throws Exception {
Binding binding = dbc
.bindValue(target, model, new UpdateValueStrategy()
@@ -147,6 +161,7 @@
.getValidationStatus().getValue()).getSeverity());
}
+ @Test
public void testErrorStatusInValidationDoesNotUpdateModel()
throws Exception {
Binding binding = dbc.bindValue(target, model,
@@ -162,6 +177,7 @@
.getValidationStatus().getValue()).getSeverity());
}
+ @Test
public void testCancelStatusInValidationDoesNotUpdateModel()
throws Exception {
Binding binding = dbc.bindValue(target, model,
@@ -177,6 +193,7 @@
.getValidationStatus().getValue()).getSeverity());
}
+ @Test
public void testStatusesFromEveryPhaseAreReturned() throws Exception {
UpdateValueStrategy strategy = new UpdateValueStrategy() {
@Override
@@ -214,11 +231,13 @@
assertEquals("doSet severity", IStatus.INFO, children[3].getSeverity());
}
+ @Test
public void testStatusIsInstanceOfBindingStatus() throws Exception {
Binding binding = dbc.bindValue(target, model);
assertTrue(binding.getValidationStatus().getValue() instanceof BindingStatus);
}
+ @Test
public void testDiffsAreCheckedForEqualityBeforeUpdate() throws Exception {
class WritableValueStub extends WritableValue {
public WritableValueStub() {
@@ -252,6 +271,7 @@
assertEquals("update does not occur", count, strategy.afterGetCount);
}
+ @Test
public void testPostInit_UpdatePolicy_UpdateToTarget_UpdateToModel() {
bindLoggingValue(
loggingTargetToModelStrategy(UpdateValueStrategy.POLICY_UPDATE),
@@ -262,6 +282,7 @@
"model-before-set" }), log);
}
+ @Test
public void testPostInit_UpdatePolicy_UpdateToTarget_ConvertToModel() {
bindLoggingValue(
loggingTargetToModelStrategy(UpdateValueStrategy.POLICY_CONVERT),
@@ -272,6 +293,7 @@
"model-before-set" }), log);
}
+ @Test
public void testPostInit_UpdatePolicy_UpdateToTarget_OnRequestToModel() {
bindLoggingValue(
loggingTargetToModelStrategy(UpdateValueStrategy.POLICY_ON_REQUEST),
@@ -297,6 +319,7 @@
"model-set" }), log);
}
+ @Test
public void testPostInit_UpdatePolicy_UpdateToTarget_NeverToModel() {
bindLoggingValue(
loggingTargetToModelStrategy(UpdateValueStrategy.POLICY_NEVER),
@@ -318,6 +341,7 @@
assertEquals(Collections.EMPTY_LIST, log);
}
+ @Test
public void testPostInit_UpdatePolicy_ConvertToTarget_UpdateToModel() {
bindLoggingValue(
loggingTargetToModelStrategy(UpdateValueStrategy.POLICY_UPDATE),
@@ -343,6 +367,7 @@
/**
* test for bug 491678
*/
+ @Test
public void testTargetValueIsSyncedToModelIfModelWasNotSyncedToTarget() {
bindLoggingValue(new UpdateValueStrategy(true, POLICY_UPDATE), new UpdateValueStrategy(true, POLICY_NEVER));
assertEquals(model.getValue(), target.getValue());
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/beans/AnonymousBeanValuePropertyTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/beans/AnonymousBeanValuePropertyTest.java
index 2370c69..2d6f105 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/beans/AnonymousBeanValuePropertyTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/beans/AnonymousBeanValuePropertyTest.java
@@ -11,11 +11,14 @@
package org.eclipse.core.tests.databinding.beans;
+import static org.junit.Assert.assertEquals;
+
import org.eclipse.core.databinding.beans.BeanProperties;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.core.databinding.observable.value.WritableValue;
import org.eclipse.core.databinding.property.value.IValueProperty;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Test;
/**
* @since 3.2
@@ -23,6 +26,7 @@
*/
public class AnonymousBeanValuePropertyTest extends
AbstractDefaultRealmTestCase {
+ @Test
public void testObserveDetailHavingNullValueType_UseExplicitValueType() {
IObservableValue master = WritableValue.withValueType(null);
IValueProperty prop = BeanProperties.value("value", String.class);
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/beans/AnonymousPojoValuePropertyTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/beans/AnonymousPojoValuePropertyTest.java
index 089ddb9..2ad2de7 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/beans/AnonymousPojoValuePropertyTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/beans/AnonymousPojoValuePropertyTest.java
@@ -11,11 +11,14 @@
package org.eclipse.core.tests.databinding.beans;
+import static org.junit.Assert.assertEquals;
+
import org.eclipse.core.databinding.beans.PojoProperties;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.core.databinding.observable.value.WritableValue;
import org.eclipse.core.databinding.property.value.IValueProperty;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Test;
/**
* @since 3.2
@@ -23,6 +26,7 @@
*/
public class AnonymousPojoValuePropertyTest extends
AbstractDefaultRealmTestCase {
+ @Test
public void testObserveDetailHavingNullValueType_UseExplicitValueType() {
IObservableValue master = WritableValue.withValueType(null);
IValueProperty prop = PojoProperties.value("value", String.class);
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/beans/BeanPropertiesTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/beans/BeanPropertiesTest.java
index c5b5be3..e2ece43 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/beans/BeanPropertiesTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/beans/BeanPropertiesTest.java
@@ -1,39 +1,47 @@
package org.eclipse.core.tests.databinding.beans;
+import static org.junit.Assert.assertTrue;
+
import org.eclipse.core.databinding.beans.BeanProperties;
import org.eclipse.core.databinding.beans.IBeanObservable;
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.tests.internal.databinding.beans.Bean;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Before;
+import org.junit.Test;
public class BeanPropertiesTest extends AbstractDefaultRealmTestCase {
private Bean bean;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
bean = new Bean();
}
+ @Test
public void testValue_ValueFactory_ProducesIBeanObservable() {
IObservable observable = BeanProperties.value(Bean.class, "value")
.valueFactory().createObservable(bean);
assertTrue(observable instanceof IBeanObservable);
}
+ @Test
public void testSet_SetFactory_ProducesIBeanObservable() {
IObservable observable = BeanProperties.set(Bean.class, "set")
.setFactory().createObservable(bean);
assertTrue(observable instanceof IBeanObservable);
}
+ @Test
public void testList_ListFactory_ProducesIBeanObservable() {
IObservable observable = BeanProperties.list(Bean.class, "list")
.listFactory().createObservable(bean);
assertTrue(observable instanceof IBeanObservable);
}
+ @Test
public void testMap_MapFactory_ProducesIBeanObservable() {
IObservable observable = BeanProperties.map(Bean.class, "map")
.mapFactory().createObservable(bean);
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/beans/BeansObservablesTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/beans/BeansObservablesTest.java
index 212abb2..751a2d4 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/beans/BeansObservablesTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/beans/BeansObservablesTest.java
@@ -15,6 +15,10 @@
package org.eclipse.core.tests.databinding.beans;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
import java.util.Arrays;
import org.eclipse.core.databinding.DataBindingContext;
@@ -33,6 +37,8 @@
import org.eclipse.core.internal.databinding.beans.BeanObservableValueDecorator;
import org.eclipse.core.tests.internal.databinding.beans.Bean;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Before;
+import org.junit.Test;
/**
* @since 3.2
@@ -42,8 +48,8 @@
Bean model = null;
Class<?> elementType = null;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
elements = new Bean[] { new Bean("1"), new Bean("2"), new Bean("3") };
@@ -52,12 +58,14 @@
elementType = Bean.class;
}
+ @Test
public void testObserveListArrayInferredElementType() throws Exception {
IObservableList list = BeansObservables.observeList(Realm.getDefault(),
model, "list", null);
assertEquals("element type", Object.class, list.getElementType());
}
+ @Test
public void testObserveListNonInferredElementType() throws Exception {
elementType = Object.class;
IObservableList list = BeansObservables.observeList(Realm.getDefault(),
@@ -65,6 +73,7 @@
assertEquals("element type", elementType, list.getElementType());
}
+ @Test
public void testListFactory() throws Exception {
IObservableFactory factory = BeansObservables.listFactory(
Realm.getDefault(), "list", elementType);
@@ -76,6 +85,7 @@
assertEquals("element type", elementType, list.getElementType());
}
+ @Test
public void testObserveDetailListElementType() throws Exception {
WritableValue parent = WritableValue.withValueType(Bean.class);
parent.setValue(model);
@@ -87,6 +97,7 @@
Arrays.equals(elements, list.toArray(new Bean[list.size()])));
}
+ @Test
public void testObserveDetailValueIBeanObservable() throws Exception {
WritableValue parent = WritableValue.withValueType(Bean.class);
Bean bean = new Bean();
@@ -104,6 +115,7 @@
.getName().endsWith("DetailObservableValue"));
}
+ @Test
public void testObserveDetailValueNullOuterElementType() throws Exception {
WritableValue parent = new WritableValue(new Bean(), null);
@@ -114,6 +126,7 @@
((IBeanObservable) detailValue).getPropertyDescriptor());
}
+ @Test
public void testObservableDetailListIBeanObservable() throws Exception {
WritableValue parent = WritableValue.withValueType(Bean.class);
Bean bean = new Bean();
@@ -135,6 +148,7 @@
.equals(detailList));
}
+ @Test
public void testObservableDetailListNullOuterElementType() throws Exception {
WritableValue parent = new WritableValue(new Bean(), null);
@@ -145,6 +159,7 @@
((IBeanObservable) detailList).getPropertyDescriptor());
}
+ @Test
public void testObservableDetailSetIBeanObservable() throws Exception {
WritableValue parent = WritableValue.withValueType(Bean.class);
Bean bean = new Bean();
@@ -166,6 +181,7 @@
.equals(detailSet));
}
+ @Test
public void testObservableDetailSetNullOuterElementType() throws Exception {
WritableValue parent = new WritableValue(new Bean(), null);
@@ -176,6 +192,7 @@
((IBeanObservable) detailSet).getPropertyDescriptor());
}
+ @Test
public void testObserveSetElementType() throws Exception {
Bean bean = new Bean();
IObservableSet observableSet = BeansObservables.observeSet(
@@ -183,6 +200,7 @@
assertEquals(Bean.class, observableSet.getElementType());
}
+ @Test
public void testObserveSetNonInferredElementType() throws Exception {
Bean bean = new Bean();
IObservableSet observableSet = BeansObservables.observeSet(
@@ -195,6 +213,7 @@
* BeansObservables.observeList() - error when external code modifies
* observed list.
*/
+ @Test
public void testHandleExternalChangeToProperty() {
Bean targetBean = new Bean();
IObservableList modelObservable = BeansObservables.observeList(
@@ -230,6 +249,7 @@
}
+ @Test
public void testObserveDetailValue_ValueType() {
Bean inner = new Bean("string");
Bean outer = new Bean(inner);
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/beans/PojoObservablesTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/beans/PojoObservablesTest.java
index 8c5f8e3..aa3684d 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/beans/PojoObservablesTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/beans/PojoObservablesTest.java
@@ -12,6 +12,11 @@
package org.eclipse.core.tests.databinding.beans;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
import org.eclipse.core.databinding.beans.IBeanObservable;
import org.eclipse.core.databinding.beans.PojoObservables;
import org.eclipse.core.databinding.beans.PojoProperties;
@@ -27,6 +32,8 @@
import org.eclipse.jface.databinding.conformance.util.ChangeEventTracker;
import org.eclipse.jface.databinding.conformance.util.CurrentRealm;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Before;
+import org.junit.Test;
/**
* @since 3.2
@@ -35,14 +42,15 @@
private Bean pojo;
private String propertyName;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
pojo = new Bean();
propertyName = "value";
}
+ @Test
public void testObserveValue_ReturnsIBeanObservable() throws Exception {
IObservableValue value = PojoObservables.observeValue(pojo,
propertyName);
@@ -51,6 +59,7 @@
assertTrue(value instanceof IBeanObservable);
}
+ @Test
public void testObserveValue_DoesNotAttachListeners() throws Exception {
IObservableValue value = PojoObservables.observeValue(pojo,
propertyName);
@@ -59,6 +68,7 @@
assertFalse(pojo.hasListeners(propertyName));
}
+ @Test
public void testObservableValueWithRealm_ReturnsIBeanObservable()
throws Exception {
CurrentRealm realm = new CurrentRealm(true);
@@ -69,6 +79,7 @@
assertTrue(value instanceof IBeanObservable);
}
+ @Test
public void testObservableMap_ReturnsIBeanObservable() throws Exception {
IObservableSet set = new WritableSet();
set.add(new Bean());
@@ -79,6 +90,7 @@
assertTrue(map instanceof IBeanObservable);
}
+ @Test
public void testObservableMap_DoesNotAttachListeners() throws Exception {
IObservableSet set = new WritableSet();
set.add(pojo);
@@ -90,6 +102,7 @@
assertFalse(pojo.hasListeners(propertyName));
}
+ @Test
public void testObserveMaps_ReturnsMaps() throws Exception {
IObservableSet set = new WritableSet();
set.add(pojo);
@@ -99,6 +112,7 @@
assertEquals(2, maps.length);
}
+ @Test
public void testObserveListWithElementType_ReturnsIBeanObservable()
throws Exception {
IObservableList list = PojoObservables.observeList(Realm.getDefault(),
@@ -106,6 +120,7 @@
assertTrue(list instanceof IBeanObservable);
}
+ @Test
public void testObserveListWithElementType_DoesNotAttachListeners()
throws Exception {
IObservableList observable = PojoObservables.observeList(Realm
@@ -115,12 +130,14 @@
assertFalse(pojo.hasListeners("list"));
}
+ @Test
public void testObserveList_ReturnsIBeanObservable() throws Exception {
IObservableList observable = PojoObservables.observeList(Realm
.getDefault(), pojo, "list");
assertTrue(observable instanceof IBeanObservable);
}
+ @Test
public void testObserveList_DoesNotAttachListeners() throws Exception {
IObservableList observable = PojoObservables.observeList(Realm
.getDefault(), pojo, "list");
@@ -129,6 +146,7 @@
assertFalse(pojo.hasListeners("list"));
}
+ @Test
public void testObserveSetWithElementType_ReturnsIBeanObservable()
throws Exception {
IObservableSet list = PojoObservables.observeSet(Realm.getDefault(),
@@ -136,6 +154,7 @@
assertTrue(list instanceof IBeanObservable);
}
+ @Test
public void testObserveSetWithElementType_DoesNotAttachListeners()
throws Exception {
IObservableSet observable = PojoObservables.observeSet(Realm
@@ -145,12 +164,14 @@
assertFalse(pojo.hasListeners("set"));
}
+ @Test
public void testObserveSet_ReturnsIBeanObservable() throws Exception {
IObservableSet list = PojoObservables.observeSet(Realm.getDefault(),
pojo, "set");
assertTrue(list instanceof IBeanObservable);
}
+ @Test
public void testObserveSet_DoesNotAttachListeners() throws Exception {
IObservableSet observable = PojoObservables.observeSet(Realm
.getDefault(), pojo, "set");
@@ -159,6 +180,7 @@
assertFalse(pojo.hasListeners("set"));
}
+ @Test
public void testValueFactory_DoesNotAttachListeners() throws Exception {
IObservableFactory factory = PojoObservables.valueFactory(Realm
.getDefault(), "value");
@@ -170,6 +192,7 @@
assertFalse(pojo.hasListeners("value"));
}
+ @Test
public void testListFactory_DoesNotAttachListeners() throws Exception {
IObservableFactory factory = PojoObservables.listFactory(Realm
.getDefault(), "list", String.class);
@@ -181,6 +204,7 @@
assertFalse(pojo.hasListeners("value"));
}
+ @Test
public void testSetFactory_DoesNotAttachListeners() throws Exception {
IObservableFactory factory = PojoObservables.setFactory(Realm
.getDefault(), propertyName);
@@ -192,6 +216,7 @@
assertFalse(pojo.hasListeners("set"));
}
+ @Test
public void testSetFactoryWithElementType_DoesNotAttachListeners()
throws Exception {
IObservableFactory factory = PojoObservables.setFactory(Realm
@@ -204,6 +229,7 @@
assertFalse(pojo.hasListeners("set"));
}
+ @Test
public void testObserveDetailValue_ValueType() {
Bean inner = new Bean("string");
Bean outer = new Bean(inner);
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/beans/PojoPropertiesTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/beans/PojoPropertiesTest.java
index 17c3d55..30011fb 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/beans/PojoPropertiesTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/beans/PojoPropertiesTest.java
@@ -1,39 +1,47 @@
package org.eclipse.core.tests.databinding.beans;
+import static org.junit.Assert.assertTrue;
+
import org.eclipse.core.databinding.beans.BeanProperties;
import org.eclipse.core.databinding.beans.IBeanObservable;
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.tests.internal.databinding.beans.Bean;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Before;
+import org.junit.Test;
public class PojoPropertiesTest extends AbstractDefaultRealmTestCase {
private Bean bean;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
bean = new Bean();
}
+ @Test
public void testValue_ValueFactory_ProducesIBeanObservable() {
IObservable observable = BeanProperties.value(Bean.class, "value")
.valueFactory().createObservable(bean);
assertTrue(observable instanceof IBeanObservable);
}
+ @Test
public void testSet_SetFactory_ProducesIBeanObservable() {
IObservable observable = BeanProperties.set(Bean.class, "set")
.setFactory().createObservable(bean);
assertTrue(observable instanceof IBeanObservable);
}
+ @Test
public void testList_ListFactory_ProducesIBeanObservable() {
IObservable observable = BeanProperties.list(Bean.class, "list")
.listFactory().createObservable(bean);
assertTrue(observable instanceof IBeanObservable);
}
+ @Test
public void testMap_MapFactory_ProducesIBeanObservable() {
IObservable observable = BeanProperties.map(Bean.class, "map")
.mapFactory().createObservable(bean);
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/beans/SetOnlyJavaBeanTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/beans/SetOnlyJavaBeanTest.java
index c3286f9..0fba45a1 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/beans/SetOnlyJavaBeanTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/beans/SetOnlyJavaBeanTest.java
@@ -12,17 +12,21 @@
package org.eclipse.core.tests.databinding.beans;
+import static org.junit.Assert.assertEquals;
+
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.UpdateValueStrategy;
import org.eclipse.core.databinding.beans.PojoProperties;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Test;
/**
* @since 1.1
*/
public class SetOnlyJavaBeanTest extends AbstractDefaultRealmTestCase {
+ @Test
public void testValidationError() throws Exception {
Model model = new Model();
model.setString("abc");
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/conversion/NumberToStringConverterTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/conversion/NumberToStringConverterTest.java
index 3aba8fa..fbffeac 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/conversion/NumberToStringConverterTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/conversion/NumberToStringConverterTest.java
@@ -12,31 +12,32 @@
package org.eclipse.core.tests.databinding.conversion;
+import static org.junit.Assert.assertEquals;
+
import java.lang.reflect.Constructor;
import java.math.BigDecimal;
import java.math.BigInteger;
-import junit.framework.TestCase;
-
import org.eclipse.core.databinding.conversion.NumberToStringConverter;
+import org.junit.Before;
+import org.junit.Test;
import com.ibm.icu.text.NumberFormat;
/**
* @since 1.1
*/
-public class NumberToStringConverterTest extends TestCase {
+public class NumberToStringConverterTest {
private NumberFormat numberFormat;
private NumberFormat integerFormat;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
+ @Before
+ public void setUp() throws Exception {
numberFormat = NumberFormat.getNumberInstance();
integerFormat = NumberFormat.getIntegerInstance();
}
+ @Test
public void testFromTypes() throws Exception {
assertEquals("Integer.class", Integer.class, NumberToStringConverter
.fromInteger(false).getFromType());
@@ -64,11 +65,13 @@
NumberToStringConverter.fromByte(false).getFromType());
}
+ @Test
public void testToTypeIsStringClass() throws Exception {
assertEquals(String.class, NumberToStringConverter.fromInteger(false)
.getToType());
}
+ @Test
public void testConvertIntegerToString() throws Exception {
Integer input = Integer.valueOf(1000);
String expected = integerFormat.format(input.longValue());
@@ -79,6 +82,7 @@
assertEquals(expected, result);
}
+ @Test
public void testConvertDoubleToString() throws Exception {
Double input = new Double(1000.1d);
String expected = numberFormat.format(input.doubleValue());
@@ -89,6 +93,7 @@
assertEquals(expected, result);
}
+ @Test
public void testConvertFloatToString() throws Exception {
Float input = new Float(1000.1f);
String expected = numberFormat.format(input.floatValue());
@@ -99,6 +104,7 @@
assertEquals(expected, result);
}
+ @Test
public void testConvertLongToString() throws Exception {
Long input = new Long(1000l);
String expected = integerFormat.format(input.longValue());
@@ -109,6 +115,7 @@
assertEquals(expected, result);
}
+ @Test
public void testConvertBigIntegerToString() throws Exception {
BigInteger input = BigInteger.valueOf(1000);
String expected = integerFormat.format(input);
@@ -148,6 +155,7 @@
}
throw new IllegalArgumentException("ICU not present. Cannot reliably format large BigDecimal values; needed for testing. Java platforms prior to 1.5 fail to format/parse these decimals correctly.");
}
+ @Test
public void testConvertBigDecimalToString() throws Exception {
NumberToStringConverter converter = NumberToStringConverter.fromBigDecimal();
// Test 1: Decimal
@@ -176,6 +184,7 @@
}
+ @Test
public void testNullSourceConvertsToEmptyString() throws Exception {
NumberToStringConverter converter = NumberToStringConverter
.fromInteger(false);
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/conversion/StringToNumberConverterTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/conversion/StringToNumberConverterTest.java
index dcacd66..ce1a619 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/conversion/StringToNumberConverterTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/conversion/StringToNumberConverterTest.java
@@ -12,32 +12,36 @@
package org.eclipse.core.tests.databinding.conversion;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
+
import java.lang.reflect.Constructor;
import java.math.BigDecimal;
import java.math.BigInteger;
-import junit.framework.TestCase;
-
import org.eclipse.core.databinding.conversion.StringToNumberConverter;
+import org.junit.Before;
+import org.junit.Test;
import com.ibm.icu.text.NumberFormat;
/**
* @since 1.1
*/
-public class StringToNumberConverterTest extends TestCase {
+public class StringToNumberConverterTest {
private NumberFormat numberFormat;
private NumberFormat numberIntegerFormat;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
numberFormat = NumberFormat.getNumberInstance();
numberFormat.setMaximumFractionDigits(305); // Used for BigDecimal test
numberFormat.setGroupingUsed(false); // Not really needed
numberIntegerFormat = NumberFormat.getIntegerInstance();
}
+ @Test
public void testToTypes() throws Exception {
assertEquals("Integer.class", Integer.class, StringToNumberConverter.toInteger(false).getToType());
assertEquals("Integer.TYPE", Integer.TYPE, StringToNumberConverter.toInteger(true).getToType());
@@ -55,11 +59,13 @@
assertEquals("Byte.TYPE", Byte.TYPE, StringToNumberConverter.toByte(true).getToType());
}
+ @Test
public void testFromTypeIsString() throws Exception {
assertEquals(String.class, StringToNumberConverter.toInteger(false)
.getFromType());
}
+ @Test
public void testConvertsToBigInteger() throws Exception {
BigInteger input = BigInteger.valueOf(1000);
@@ -100,6 +106,7 @@
throw new IllegalArgumentException("ICU not present. Cannot reliably format large BigDecimal values; needed for testing. Java platforms prior to 1.5 fail to format/parse these decimals correctly.");
}
+ @Test
public void testConvertsToBigDecimal() throws Exception {
StringToNumberConverter converter = StringToNumberConverter.toBigDecimal();
// Test 1: Decimal
@@ -123,6 +130,7 @@
assertEquals("Non-integer BigDecimal", input, result);
}
+ @Test
public void testConvertsToInteger() throws Exception {
Integer input = Integer.valueOf(1000);
@@ -132,6 +140,7 @@
assertEquals(input, result);
}
+ @Test
public void testConvertsToDouble() throws Exception {
Double input = new Double(1000);
@@ -142,6 +151,7 @@
assertEquals(input, result);
}
+ @Test
public void testConvertsToLong() throws Exception {
Long input = new Long(1000);
@@ -152,6 +162,7 @@
assertEquals(input, result);
}
+ @Test
public void testConvertsToFloat() throws Exception {
Float input = new Float(1000);
@@ -162,6 +173,7 @@
assertEquals(input, result);
}
+ @Test
public void testConvertedToIntegerPrimitive() throws Exception {
Integer input = Integer.valueOf(1000);
@@ -171,6 +183,7 @@
assertEquals(input, result);
}
+ @Test
public void testConvertsToDoublePrimitive() throws Exception {
Double input = new Double(1000);
@@ -181,6 +194,7 @@
assertEquals(input, result);
}
+ @Test
public void testConvertsToLongPrimitive() throws Exception {
Long input = new Long(1000);
@@ -191,6 +205,7 @@
assertEquals(input, result);
}
+ @Test
public void testConvertsToFloatPrimitive() throws Exception {
Float input = new Float(1000);
@@ -201,6 +216,7 @@
assertEquals(input, result);
}
+ @Test
public void testReturnsNullBoxedTypeForEmptyString() throws Exception {
StringToNumberConverter converter = StringToNumberConverter.toInteger(false);
try {
@@ -210,6 +226,7 @@
}
}
+ @Test
public void testThrowsIllegalArgumentExceptionIfAskedToConvertNonString()
throws Exception {
StringToNumberConverter converter = StringToNumberConverter.toInteger(false);
@@ -226,6 +243,7 @@
*
* @throws Exception
*/
+ @Test
public void testInvalidInteger() throws Exception {
StringToNumberConverter converter = StringToNumberConverter
.toInteger(false);
@@ -237,6 +255,7 @@
}
}
+ @Test
public void testThrowsIllegalArgumentExceptionIfNumberIsOutOfRange() throws Exception {
StringToNumberConverter converter = StringToNumberConverter.toInteger(false);
try {
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/AbstractObservableTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/AbstractObservableTest.java
index 6a71590..24b149e 100755
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/AbstractObservableTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/AbstractObservableTest.java
@@ -14,8 +14,10 @@
package org.eclipse.core.tests.databinding.observable;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
import org.eclipse.core.databinding.observable.AbstractObservable;
import org.eclipse.core.databinding.observable.DisposeEvent;
@@ -33,6 +35,10 @@
import org.eclipse.jface.databinding.conformance.util.RealmTester;
import org.eclipse.jface.databinding.conformance.util.StaleEventTracker;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Before;
+import org.junit.Test;
+
+import junit.framework.TestSuite;
/**
* Tests for AbstractObservable.
@@ -43,11 +49,13 @@
private ObservableStub observable;
@Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
observable = new ObservableStub(Realm.getDefault());
}
+ @Test
public void testStaleListener() throws Exception {
assertFalse(observable.hasListeners());
@@ -95,6 +103,7 @@
assertFalse(observable.hasListeners());
}
+ @Test
public void testChangeListener() throws Exception {
assertFalse(observable.hasListeners());
@@ -142,6 +151,7 @@
assertFalse(observable.hasListeners());
}
+ @Test
public void testHasListenersWithChangeAndStaleListeners() throws Exception {
ChangeEventTracker changeListener = new ChangeEventTracker();
StaleEventTracker staleListener = new StaleEventTracker();
@@ -175,6 +185,7 @@
assertTrue(observable.lastListenerRemoved);
}
+ @Test
public void testFireStaleRealmChecks() throws Exception {
RealmTester.setDefault(new CurrentRealm(true));
@@ -187,6 +198,7 @@
});
}
+ @Test
public void testFireChangeRealmChecks() throws Exception {
RealmTester.setDefault(new CurrentRealm(true));
@@ -199,6 +211,7 @@
});
}
+ @Test
public void testAddDisposeListener_HasListenersFalse() {
IDisposeListener disposeListener = new IDisposeListener() {
@Override
@@ -234,13 +247,10 @@
assertTrue(observable.lastListenerRemoved);
}
- public static Test suite() {
- TestSuite suite = new TestSuite(AbstractObservableTest.class.getName());
- suite.addTestSuite(AbstractObservableTest.class);
+ public static void addConformanceTest(TestSuite suite) {
Delegate delegate = new Delegate();
suite.addTest(ObservableContractTest.suite(delegate));
suite.addTest(ObservableStaleContractTest.suite(delegate));
- return suite;
}
/* package */static class Delegate extends
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/ChangeSupportTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/ChangeSupportTest.java
index ec80eed..ec02169 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/ChangeSupportTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/ChangeSupportTest.java
@@ -11,6 +11,10 @@
package org.eclipse.core.tests.databinding.observable;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -23,6 +27,8 @@
import org.eclipse.core.databinding.observable.Realm;
import org.eclipse.core.databinding.observable.StaleEvent;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Before;
+import org.junit.Test;
/**
* @since 3.2
@@ -31,13 +37,14 @@
public class ChangeSupportTest extends AbstractDefaultRealmTestCase {
private ChangeSupportStub changeSupport;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
changeSupport = new ChangeSupportStub(Realm.getDefault());
}
+ @Test
public void testAddDisposeListener_HasListenersFalse() {
IDisposeListener disposeListener = new IDisposeListener() {
@Override
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/DecoratingObservableTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/DecoratingObservableTest.java
index 040d80b..c9e5f94 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/DecoratingObservableTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/DecoratingObservableTest.java
@@ -11,12 +11,18 @@
package org.eclipse.core.tests.databinding.observable;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import org.eclipse.core.databinding.observable.AbstractObservable;
import org.eclipse.core.databinding.observable.DecoratingObservable;
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.Realm;
import org.eclipse.jface.databinding.conformance.util.DisposeEventTracker;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Before;
+import org.junit.Test;
/**
* @since 3.2
@@ -26,13 +32,14 @@
private IObservable decorated;
private DecoratingObservable decorator;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
decorated = new ObservableStub(Realm.getDefault());
decorator = new DecoratingObservable(decorated, false);
}
+ @Test
public void testDisposeDecorated_DisposesDecorator() {
DisposeEventTracker tracker = DisposeEventTracker.observe(decorator);
assertFalse(decorator.isDisposed());
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/DiffsTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/DiffsTest.java
index 8e8623b..11939cf 100755
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/DiffsTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/DiffsTest.java
@@ -11,22 +11,25 @@
package org.eclipse.core.tests.databinding.observable;
-import java.util.Set;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
-import junit.framework.TestCase;
+import java.util.Set;
import org.eclipse.core.databinding.observable.set.SetDiff;
import org.eclipse.core.databinding.observable.value.ValueDiff;
+import org.junit.Test;
/**
* @since 3.2
*
*/
-public class DiffsTest extends TestCase {
+public class DiffsTest {
/**
* Asserts that the {@link SetDiff#toString()} implementation doesn't throw
* a NPE if any of its properties are <code>null</code>.
*/
+ @Test
public void test_SetDiff() {
SetDiff diff = new SetDiff() {
@Override
@@ -53,6 +56,7 @@
* throw a NPE if any of its properties are <code>null</code>.
*
*/
+ @Test
public void test_ValueDiff() {
ValueDiff diff = new ValueDiff() {
@Override
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/Diffs_ListDiffTests.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/Diffs_ListDiffTests.java
index 026a4cf..c4885b1 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/Diffs_ListDiffTests.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/Diffs_ListDiffTests.java
@@ -12,21 +12,25 @@
package org.eclipse.core.tests.databinding.observable;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import junit.framework.TestCase;
-
import org.eclipse.core.databinding.observable.Diffs;
import org.eclipse.core.databinding.observable.list.ListDiff;
import org.eclipse.core.databinding.observable.list.ListDiffEntry;
import org.eclipse.core.databinding.observable.list.ListDiffVisitor;
+import org.junit.Test;
/**
* @since 1.1
*/
-public class Diffs_ListDiffTests extends TestCase {
+public class Diffs_ListDiffTests {
+ @Test
public void testListDiffEntryToStringDoesNotThrowNPEForNullListDiffEntry() {
ListDiffEntry entry = new ListDiffEntry() {
@Override
@@ -53,6 +57,7 @@
}
}
+ @Test
public void testListDiffToStringDoesNotThrowNPEForNullListDiff() {
ListDiff diff = new ListDiff() {
@Override
@@ -69,6 +74,7 @@
}
}
+ @Test
public void testListDiffToStringDoesNotThrowNPEForNullListDiffEntry() {
ListDiff diff = new ListDiff() {
@Override
@@ -85,6 +91,7 @@
}
}
+ @Test
public void testDiffScenario1() throws Exception {
ListDiff diff = diff(null, null);
assertEquals(0, diff.getDifferences().length);
@@ -97,23 +104,27 @@
return Diffs.computeListDiff(a, b);
}
+ @Test
public void testDiffScenario2() throws Exception {
ListDiff diff = diff(new String[] { "a" }, null);
assertEquals(1, diff.getDifferences().length);
assertEntry(diff.getDifferences()[0], false, 0, "a");
}
+ @Test
public void testDiffScenario3() throws Exception {
ListDiff diff = diff(null, new String[] { "a" });
assertEquals(1, diff.getDifferences().length);
assertEntry(diff.getDifferences()[0], true, 0, "a");
}
+ @Test
public void testDiffScenario4() throws Exception {
ListDiff diff = diff(new String[] { "a" }, new String[] { "a" });
assertEquals(0, diff.getDifferences().length);
}
+ @Test
public void testDiffScenario5() throws Exception {
ListDiff diff = diff(new String[] { "a" }, new String[] { "b" });
assertEquals(2, diff.getDifferences().length);
@@ -122,6 +133,7 @@
assertEntry(diff.getDifferences()[1], false, 1, "a");
}
+ @Test
public void testDiffScenario6() throws Exception {
ListDiff diff = diff(new String[] { "a" }, new String[] { "a", "b" });
@@ -129,6 +141,7 @@
assertEntry(diff.getDifferences()[0], true, 1, "b");
}
+ @Test
public void testDiffScenario7() throws Exception {
ListDiff diff = diff(new String[] { "a" }, new String[] { "b", "a" });
@@ -136,6 +149,7 @@
assertEntry(diff.getDifferences()[0], true, 0, "b");
}
+ @Test
public void testDiffScenario8() throws Exception {
ListDiff diff = diff(new String[] { "a" }, new String[] { "b", "b" });
@@ -145,6 +159,7 @@
assertEntry(diff.getDifferences()[2], false, 2, "a");
}
+ @Test
public void testDiffScenario9() throws Exception {
ListDiff diff = diff(new String[] { "a" }, new String[] { "a", "b", "c" });
@@ -153,6 +168,7 @@
assertEntry(diff.getDifferences()[1], true, 2, "c");
}
+ @Test
public void testDiffScenario10() throws Exception {
ListDiff diff = diff(new String[] { "b" }, new String[] { "a", "b", "c" });
@@ -161,6 +177,7 @@
assertEntry(diff.getDifferences()[1], true, 2, "c");
}
+ @Test
public void testDiffScenario11() throws Exception {
ListDiff diff = diff(new String[] { "c" }, new String[] { "a", "b", "c" });
@@ -169,12 +186,14 @@
assertEntry(diff.getDifferences()[1], true, 1, "b");
}
+ @Test
public void testDiffScenario12() throws Exception {
ListDiff diff = diff(new String[] { "a", "b", "c" }, new String[] { "a", "b", "c" });
assertEquals(0, diff.getDifferences().length);
}
+ @Test
public void testDiffScenario13() throws Exception {
ListDiff diff = diff(new String[] { "a", "b", "c" }, new String[] { "b", "c" });
@@ -182,6 +201,7 @@
assertEntry(diff.getDifferences()[0], false, 0, "a");
}
+ @Test
public void testDiffScenarios14() throws Exception {
ListDiff diff = diff(new String[] { "a", "b", "c" }, new String[] { "a", "c" });
@@ -189,6 +209,7 @@
assertEntry(diff.getDifferences()[0], false, 1, "b");
}
+ @Test
public void testDiffScenarios15() throws Exception {
ListDiff diff = diff(new String[] { "a", "b", "c" }, new String[] { "a", "b" });
@@ -196,6 +217,7 @@
assertEntry(diff.getDifferences()[0], false, 2, "c");
}
+ @Test
public void testDiffScenarios16() throws Exception {
ListDiff diff = diff(new String[] { "a", "b", "c" }, new String[] { "c", "b", "a" });
@@ -206,6 +228,7 @@
assertEntry(diff.getDifferences()[3], true, 1, "b");
}
+ @Test
public void testDiffScenarios17() throws Exception {
ListDiff diff = diff(new String[] { "a", "b", "c" }, new String[] { "c", "b" });
@@ -221,33 +244,40 @@
assertEquals("element", element, entry.getElement());
}
+ @Test
public void testComputeListDiff_SingleInsert() {
checkComputedListDiff(Arrays.asList(new Object[] { "a", "c" }), Arrays.asList(new Object[] { "a", "b", "c" }));
}
+ @Test
public void testComputeListDiff_SingleAppend() {
checkComputedListDiff(Arrays.asList(new Object[] { "a", "b" }), Arrays.asList(new Object[] { "a", "b", "c" }));
}
+ @Test
public void testComputeListDiff_SingleRemove() {
checkComputedListDiff(Arrays.asList(new Object[] { "a", "b", "c" }), Arrays.asList(new Object[] { "a", "b" }));
checkComputedListDiff(Arrays.asList(new Object[] { "a", "b", "c" }), Arrays.asList(new Object[] { "a", "c" }));
checkComputedListDiff(Arrays.asList(new Object[] { "a", "b", "c" }), Arrays.asList(new Object[] { "b", "c" }));
}
+ @Test
public void testComputeListDiff_MoveDown1() {
checkComputedListDiff(Arrays.asList(new Object[] { "a", "b" }), Arrays.asList(new Object[] { "b", "a" }));
}
+ @Test
public void testComputeListDiff_MoveDown2() {
checkComputedListDiff(Arrays.asList(new Object[] { "a", "b", "c" }),
Arrays.asList(new Object[] { "b", "c", "a" }));
}
+ @Test
public void testComputeListDiff_MoveUp1() {
checkComputedListDiff(Arrays.asList(new Object[] { "a", "b" }), Arrays.asList(new Object[] { "b", "a" }));
}
+ @Test
public void testComputeListDiff_MoveUp2() {
checkComputedListDiff(Arrays.asList(new Object[] { "a", "b", "c" }),
Arrays.asList(new Object[] { "c", "a", "b" }));
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/ObservableTrackerTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/ObservableTrackerTest.java
index 60d42f4..abd9462 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/ObservableTrackerTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/ObservableTrackerTest.java
@@ -12,6 +12,11 @@
package org.eclipse.core.tests.databinding.observable;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -28,8 +33,10 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.databinding.conformance.util.CurrentRealm;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Test;
public class ObservableTrackerTest extends AbstractDefaultRealmTestCase {
+ @Test
public void testRunAndMonitor_GetterCalled() throws Exception {
final IObservable observable = new ObservableStub();
IObservable[] result = ObservableTracker.runAndMonitor(new Runnable() {
@@ -42,6 +49,7 @@
assertSame(observable, result[0]);
}
+ @Test
public void testGetterCalled_ObservableDisposed() throws Exception {
try {
IObservable observable = new ObservableStub();
@@ -54,6 +62,7 @@
}
}
+ @Test
public void testGetterCalled_ObservableRealmNotCurrent() throws Exception {
try {
IObservable observable = new ObservableStub(new CurrentRealm(false));
@@ -65,6 +74,7 @@
}
}
+ @Test
public void testRunAndCollect() throws Exception {
final IObservable[] created = new IObservable[1];
IObservable[] collected = ObservableTracker.runAndCollect(new Runnable() {
@@ -77,6 +87,7 @@
assertSame(created[0], collected[0]);
}
+ @Test
public void testRunAndIgnore_RunAndMonitor() throws Exception {
final IObservable observable = new ObservableStub();
IObservable[] result = ObservableTracker.runAndMonitor(new Runnable() {
@@ -93,6 +104,7 @@
assertEquals(0, result.length);
}
+ @Test
public void testRunAndIgnore_RunAndCollect() throws Exception {
IObservable[] result = ObservableTracker.runAndCollect(new Runnable() {
@Override
@@ -108,6 +120,7 @@
assertEquals(0, result.length);
}
+ @Test
public void testSetIgnore_RunAndMonitor() throws Exception {
final IObservable observable = new ObservableStub();
IObservable[] result = ObservableTracker.runAndMonitor(new Runnable() {
@@ -121,6 +134,7 @@
assertEquals(0, result.length);
}
+ @Test
public void testSetIgnore_RunAndCollect() throws Exception {
IObservable[] result = ObservableTracker.runAndCollect(new Runnable() {
@Override
@@ -133,6 +147,7 @@
assertEquals(0, result.length);
}
+ @Test
public void testSetIgnore_Nested_RunAndCollect() throws Exception {
final List<ObservableStub> list = new ArrayList<ObservableStub>();
@@ -159,6 +174,7 @@
assertEquals(expected, collected);
}
+ @Test
public void testSetIgnore_Nested_RunAndMonitor() throws Exception {
final IObservable[] observables = { new ObservableStub(), new ObservableStub(), new ObservableStub(),
new ObservableStub(), new ObservableStub() };
@@ -186,6 +202,7 @@
assertEquals(expected, result);
}
+ @Test
public void testSetIgnore_RunAndMonitor_UnmatchedIgnore_LogsError() {
final List<IStatus> log = new ArrayList<IStatus>();
Policy.setLog(new ILogger() {
@@ -209,6 +226,7 @@
assertTrue(status.getMessage().indexOf("setIgnore") != -1);
}
+ @Test
public void testSetIgnore_RunAndCollect_UnmatchedIgnore_LogsError() {
final List<IStatus> log = new ArrayList<IStatus>();
Policy.setLog(new ILogger() {
@@ -232,6 +250,7 @@
assertTrue(status.getMessage().indexOf("setIgnore") != -1);
}
+ @Test
public void testSetIgnore_UnmatchedUnignore() {
try {
ObservableTracker.setIgnore(false);
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/ObservablesTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/ObservablesTest.java
index 0a7f8c7..5c187fb 100755
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/ObservablesTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/ObservablesTest.java
@@ -11,6 +11,9 @@
package org.eclipse.core.tests.databinding.observable;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.util.ArrayList;
import java.util.List;
@@ -19,8 +22,10 @@
import org.eclipse.core.databinding.observable.list.ObservableList;
import org.eclipse.core.internal.databinding.observable.UnmodifiableObservableList;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Test;
public class ObservablesTest extends AbstractDefaultRealmTestCase {
+ @Test
public void testUnmodifableObservableListExceptions() throws Exception {
try {
Observables.unmodifiableObservableList(null);
@@ -29,6 +34,7 @@
}
}
+ @Test
public void testUnmodifiableObservableList() throws Exception {
IObservableList unmodifiable = Observables.unmodifiableObservableList(new ObservableListStub(
new ArrayList<Object>(0), String.class));
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/RealmTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/RealmTest.java
index 4985fde..42ef788 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/RealmTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/RealmTest.java
@@ -11,16 +11,18 @@
package org.eclipse.core.tests.databinding.observable;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
import org.eclipse.core.databinding.observable.Realm;
import org.eclipse.jface.databinding.conformance.util.CurrentRealm;
import org.eclipse.jface.databinding.conformance.util.RealmTester;
+import org.junit.Test;
/**
* @since 3.2
*/
-public class RealmTest extends TestCase {
+public class RealmTest {
+ @Test
public void testSetDefaultWithRunnable() throws Exception {
Realm oldRealm = new CurrentRealm(true);
final Realm newRealm = new CurrentRealm(true);
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/list/AbstractObservableListTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/list/AbstractObservableListTest.java
index 7d4facc..d37f30d 100755
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/list/AbstractObservableListTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/list/AbstractObservableListTest.java
@@ -13,14 +13,12 @@
package org.eclipse.core.tests.databinding.observable.list;
+import static org.junit.Assert.assertEquals;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
import org.eclipse.core.databinding.observable.ChangeEvent;
import org.eclipse.core.databinding.observable.Diffs;
import org.eclipse.core.databinding.observable.DisposeEvent;
@@ -41,24 +39,30 @@
import org.eclipse.jface.databinding.conformance.delegate.AbstractObservableCollectionContractDelegate;
import org.eclipse.jface.databinding.conformance.util.CurrentRealm;
import org.eclipse.jface.databinding.conformance.util.RealmTester;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import junit.framework.TestSuite;
/**
* @since 3.2
*/
-public class AbstractObservableListTest extends TestCase {
+public class AbstractObservableListTest {
private AbstractObservableListStub list;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
RealmTester.setDefault(new CurrentRealm(true));
list = new AbstractObservableListStub();
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
RealmTester.setDefault(null);
}
+ @Test
public void testFireChangeRealmChecks() throws Exception {
RealmTester.exerciseCurrent(new Runnable() {
@Override
@@ -68,6 +72,7 @@
});
}
+ @Test
public void testFireStaleRealmChecks() throws Exception {
RealmTester.exerciseCurrent(new Runnable() {
@Override
@@ -77,6 +82,7 @@
});
}
+ @Test
public void testFireListChangeRealmChecks() throws Exception {
RealmTester.exerciseCurrent(new Runnable() {
@Override
@@ -86,6 +92,7 @@
});
}
+ @Test
public void testMove_FiresListChanges() throws Exception {
list = new MutableObservableListStub();
final Object element = new Object();
@@ -115,6 +122,7 @@
assertEquals(1, entry.getPosition());
}
+ @Test
public void testMove_MovesElement() throws Exception {
list = new MutableObservableListStub();
final Object element0 = new Object();
@@ -128,6 +136,7 @@
assertEquals(element0, list.get(1));
}
+ @Test
public void testAddListChangeListener_AfterDispose() {
list.dispose();
list.addListChangeListener(new IListChangeListener() {
@@ -138,6 +147,7 @@
});
}
+ @Test
public void testRemoveListChangeListener_AfterDispose() {
list.dispose();
list.removeListChangeListener(new IListChangeListener() {
@@ -148,6 +158,7 @@
});
}
+ @Test
public void testAddChangeListener_AfterDispose() {
list.dispose();
list.addChangeListener(new IChangeListener() {
@@ -158,6 +169,7 @@
});
}
+ @Test
public void testRemoveChangeListener_AfterDispose() {
list.dispose();
list.removeChangeListener(new IChangeListener() {
@@ -168,6 +180,7 @@
});
}
+ @Test
public void testAddStaleListener_AfterDispose() {
list.dispose();
list.addStaleListener(new IStaleListener() {
@@ -178,6 +191,7 @@
});
}
+ @Test
public void testRemoveStaleListener_AfterDispose() {
list.dispose();
list.removeStaleListener(new IStaleListener() {
@@ -188,6 +202,7 @@
});
}
+ @Test
public void testAddDisposeListener_AfterDispose() {
list.dispose();
list.addDisposeListener(new IDisposeListener() {
@@ -198,6 +213,7 @@
});
}
+ @Test
public void testRemoveDisposeListener_AfterDispose() {
list.dispose();
list.removeDisposeListener(new IDisposeListener() {
@@ -208,16 +224,14 @@
});
}
+ @Test
public void testHasListeners_AfterDispose() {
list.dispose();
list.hasListeners();
}
- public static Test suite() {
- TestSuite suite = new TestSuite(AbstractObservableListTest.class.getName());
- suite.addTestSuite(AbstractObservableListTest.class);
+ public static void addConformanceTest(TestSuite suite) {
suite.addTest(ObservableListContractTest.suite(new Delegate()));
- return suite;
}
/* package */static class Delegate extends AbstractObservableCollectionContractDelegate {
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/list/ComputedListTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/list/ComputedListTest.java
index 3d11032..659f20a 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/list/ComputedListTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/list/ComputedListTest.java
@@ -12,12 +12,14 @@
package org.eclipse.core.tests.databinding.observable.list;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.util.ArrayList;
import java.util.List;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.eclipse.core.databinding.observable.AbstractObservable;
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.IObservableCollection;
@@ -30,23 +32,30 @@
import org.eclipse.jface.databinding.conformance.delegate.AbstractObservableCollectionContractDelegate;
import org.eclipse.jface.databinding.conformance.util.ListChangeEventTracker;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Before;
+import org.junit.Test;
+
+import junit.framework.TestSuite;
public class ComputedListTest extends AbstractDefaultRealmTestCase {
ComputedListStub list;
@Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
list = new ComputedListStub();
list.size(); // Force list to compute
}
+ @Test
public void testDependency_Staleness() {
assertFalse(list.isStale());
list.dependency.fireStale();
assertTrue(list.isStale());
}
+ @Test
public void testDependency_FiresListChange() {
assertEquals(list.nextComputation, list);
@@ -60,6 +69,7 @@
assertEquals(expectedList, list);
}
+ @Test
public void testDependency_NoStaleEventIfAlreadyDirty() {
list.dependency.fireChange();
list.addStaleListener(new IStaleListener() {
@@ -71,6 +81,7 @@
list.dependency.fireStale();
}
+ @Test
public void testDependency_ListChangeEventFiresOnlyWhenNotDirty() {
ListChangeEventTracker tracker = ListChangeEventTracker.observe(list);
@@ -135,11 +146,8 @@
}
}
- public static Test suite() {
- TestSuite suite = new TestSuite(ComputedListTest.class.getName());
- suite.addTestSuite(ComputedListTest.class);
+ public static void addConformanceTest(TestSuite suite) {
suite.addTest(ObservableListContractTest.suite(new Delegate()));
- return suite;
}
static class Delegate extends AbstractObservableCollectionContractDelegate {
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/list/DecoratingObservableListTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/list/DecoratingObservableListTest.java
index 748d12a..2b13093 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/list/DecoratingObservableListTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/list/DecoratingObservableListTest.java
@@ -16,9 +16,6 @@
import java.util.ArrayList;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.IObservableCollection;
import org.eclipse.core.databinding.observable.Realm;
@@ -28,16 +25,15 @@
import org.eclipse.jface.databinding.conformance.MutableObservableListContractTest;
import org.eclipse.jface.databinding.conformance.delegate.AbstractObservableCollectionContractDelegate;
+import junit.framework.TestSuite;
+
/**
* @since 3.2
*
*/
public class DecoratingObservableListTest {
- public static Test suite() {
- TestSuite suite = new TestSuite(DecoratingObservableListTest.class
- .getName());
+ public static void addConformanceTest(TestSuite suite) {
suite.addTest(MutableObservableListContractTest.suite(new Delegate()));
- return suite;
}
static class Delegate extends AbstractObservableCollectionContractDelegate {
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/list/ListDiffTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/list/ListDiffTest.java
index e635edf..bde2010 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/list/ListDiffTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/list/ListDiffTest.java
@@ -12,53 +12,61 @@
package org.eclipse.core.tests.databinding.observable.list;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotSame;
import org.eclipse.core.databinding.observable.Diffs;
import org.eclipse.core.databinding.observable.list.ListDiff;
import org.eclipse.core.databinding.observable.list.ListDiffEntry;
import org.eclipse.core.databinding.observable.list.ListDiffVisitor;
+import org.junit.Before;
+import org.junit.Test;
/**
* Tests for ListDiff class
*
* @since 1.1
*/
-public class ListDiffTest extends TestCase {
+public class ListDiffTest {
ListDiffVisitorStub visitor;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
visitor = new ListDiffVisitorStub();
}
+ @Test
public void testAccept_Add() {
createListDiff(add(0, "element")).accept(visitor);
assertEquals("add(0,element)", visitor.log);
}
+ @Test
public void testAccept_Remove() {
createListDiff(remove(0, "element")).accept(visitor);
assertEquals("remove(0,element)", visitor.log);
}
+ @Test
public void testAccept_MoveForward_RemoveBeforeAdd() {
createListDiff(remove(0, "element"), add(1, "element")).accept(visitor);
assertEquals("move(0,1,element)", visitor.log);
}
+ @Test
public void testAccept_MoveForward_AddBeforeRemove() {
// Add at index 2 then remove at index 0 leaves the element at index 1
createListDiff(add(2, "element"), remove(0, "element")).accept(visitor);
assertEquals("move(0,1,element)", visitor.log);
}
+ @Test
public void testAccept_MoveBackward_RemoveBeforeAdd() {
createListDiff(remove(4, "element"), add(1, "element")).accept(visitor);
assertEquals("move(4,1,element)", visitor.log);
}
+ @Test
public void testAccept_MoveBackward_AddBeforeRemove() {
// Element is originally at position 4 in this test, but we must remove
// it at 5 since the adding it at 1 first changes the index
@@ -66,18 +74,21 @@
assertEquals("move(4,1,element)", visitor.log);
}
+ @Test
public void testAccept_Replace_RemoveBeforeAdd() {
createListDiff(remove(0, "element0"), add(0, "element1")).accept(
visitor);
assertEquals("replace(0,element0,element1)", visitor.log);
}
+ @Test
public void testAccept_Replace_AddBeforeRemove() {
createListDiff(add(0, "element1"), remove(1, "element0")).accept(
visitor);
assertEquals("replace(0,element0,element1)", visitor.log);
}
+ @Test
public void testAccept_AllPatterns() {
createListDiff(new ListDiffEntry[] {
// Replace (remove before add)
@@ -110,6 +121,7 @@
+ "add(12,element9), remove(12,element9)", visitor.log);
}
+ @Test
public void testAccept_MoveDetectionUsesEqualityNotSameness() {
Object element0 = new String("element");
Object element1 = new String("element");
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/list/ListDiffVisitorTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/list/ListDiffVisitorTest.java
index e86f3e2..8abcc7b 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/list/ListDiffVisitorTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/list/ListDiffVisitorTest.java
@@ -11,24 +11,26 @@
package org.eclipse.core.tests.databinding.observable.list;
-import org.eclipse.core.databinding.observable.list.ListDiffVisitor;
+import static org.junit.Assert.assertEquals;
-import junit.framework.TestCase;
+import org.eclipse.core.databinding.observable.list.ListDiffVisitor;
+import org.junit.Before;
+import org.junit.Test;
/**
* Tests for ListDiffVisitor class
*
* @since 1.1
*/
-public class ListDiffVisitorTest extends TestCase {
+public class ListDiffVisitorTest {
ListDiffVisitorStub visitor;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
visitor = new ListDiffVisitorStub();
}
+ @Test
public void testHandleMove_DelegatesByDefault() {
visitor.handleMove(0, 1, "element");
assertEquals(
@@ -36,6 +38,7 @@
"remove(0,element), add(1,element)", visitor.log);
}
+ @Test
public void testHandleReplace_DelegatesByDefault() {
visitor.handleReplace(2, "oldElement", "newElement");
assertEquals(
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/list/MultiListTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/list/MultiListTest.java
index 03504a6..f664fd8 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/list/MultiListTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/list/MultiListTest.java
@@ -11,12 +11,14 @@
package org.eclipse.core.tests.databinding.observable.list;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.util.ArrayList;
import java.util.List;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.IObservableCollection;
import org.eclipse.core.databinding.observable.IStaleListener;
@@ -29,18 +31,24 @@
import org.eclipse.jface.databinding.conformance.delegate.AbstractObservableCollectionContractDelegate;
import org.eclipse.jface.databinding.conformance.util.ListChangeEventTracker;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Before;
+import org.junit.Test;
+
+import junit.framework.TestSuite;
public class MultiListTest extends AbstractDefaultRealmTestCase {
MultiListStub multiList;
@Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
WritableList[] lists = new WritableList[] { new WritableList(),
new WritableList() };
multiList = new MultiListStub(Realm.getDefault(), lists);
}
+ @Test
public void testIsStale_FollowsSublist() {
assertFalse(multiList.isStale());
multiList.subLists[0].setStale(true);
@@ -49,6 +57,7 @@
assertFalse(multiList.isStale());
}
+ @Test
public void testDependency_FiresListChange() {
List expectedList = new ArrayList();
assertEquals(expectedList, multiList);
@@ -59,6 +68,7 @@
assertEquals(expectedList, multiList);
}
+ @Test
public void testStaleEvent_NoFireEventIfAlreadyStale() {
multiList.subLists[0].setStale(true);
multiList.addStaleListener(new IStaleListener() {
@@ -70,6 +80,7 @@
multiList.subLists[1].setStale(true);
}
+ @Test
public void testModifySubList_FiresListChangeEventFromMultiList() {
ListChangeEventTracker tracker = ListChangeEventTracker
.observe(multiList);
@@ -132,11 +143,8 @@
}
}
- public static Test suite() {
- TestSuite suite = new TestSuite(MultiListTest.class.getName());
- suite.addTestSuite(MultiListTest.class);
+ public static void addConformanceTest(TestSuite suite) {
suite.addTest(ObservableListContractTest.suite(new Delegate()));
- return suite;
}
static class Delegate extends AbstractObservableCollectionContractDelegate {
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/list/ObservableListTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/list/ObservableListTest.java
index 6f3a80e..5a335c6 100755
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/list/ObservableListTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/list/ObservableListTest.java
@@ -13,14 +13,12 @@
package org.eclipse.core.tests.databinding.observable.list;
+import static org.junit.Assert.assertEquals;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
import org.eclipse.core.databinding.observable.Diffs;
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.IObservableCollection;
@@ -34,25 +32,31 @@
import org.eclipse.jface.databinding.conformance.delegate.AbstractObservableCollectionContractDelegate;
import org.eclipse.jface.databinding.conformance.util.CurrentRealm;
import org.eclipse.jface.databinding.conformance.util.RealmTester;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import junit.framework.TestSuite;
/**
* @since 3.2
*/
-public class ObservableListTest extends TestCase {
+public class ObservableListTest {
private ObservableListStub list;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
RealmTester.setDefault(new CurrentRealm(true));
list = new ObservableListStub(new ArrayList(0), Object.class);
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
RealmTester.setDefault(null);
}
+ @Test
public void testIsStaleRealmChecks() throws Exception {
RealmTester.exerciseCurrent(new Runnable() {
@Override
@@ -62,6 +66,7 @@
});
}
+ @Test
public void testSetStaleRealmChecks() throws Exception {
RealmTester.exerciseCurrent(new Runnable() {
@Override
@@ -71,6 +76,7 @@
});
}
+ @Test
public void testMove_FiresListChanges() throws Exception {
list = new MutableObservableListStub();
final Object element = new Object();
@@ -100,6 +106,7 @@
assertEquals(1, entry.getPosition());
}
+ @Test
public void testMove_MovesElement() throws Exception {
list = new MutableObservableListStub();
final Object element0 = new Object();
@@ -113,11 +120,8 @@
assertEquals(element0, list.get(1));
}
- public static Test suite() {
- TestSuite suite = new TestSuite(ObservableListTest.class.getName());
- suite.addTestSuite(ObservableListTest.class);
+ public static void addConformanceTest(TestSuite suite) {
suite.addTest(ObservableListContractTest.suite(new Delegate()));
- return suite;
}
/* package */ static class Delegate extends AbstractObservableCollectionContractDelegate {
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/list/WritableListTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/list/WritableListTest.java
index 3c96967..4654bae 100755
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/list/WritableListTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/list/WritableListTest.java
@@ -13,6 +13,10 @@
package org.eclipse.core.tests.databinding.observable.list;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -29,26 +33,28 @@
import org.eclipse.jface.databinding.conformance.util.RealmTester;
import org.eclipse.jface.databinding.swt.DisplayRealm;
import org.eclipse.swt.widgets.Display;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
-import junit.framework.Test;
-import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* @since 3.2
*/
-public class WritableListTest extends TestCase {
+public class WritableListTest {
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
RealmTester.setDefault(new CurrentRealm(true));
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
RealmTester.setDefault(null);
}
+ @Test
public void testSetRealmChecks() throws Exception {
RealmTester.exerciseCurrent(new Runnable() {
@Override
@@ -60,6 +66,7 @@
});
}
+ @Test
public void testAddRealmChecks() throws Exception {
RealmTester.exerciseCurrent(new Runnable() {
@Override
@@ -70,6 +77,7 @@
});
}
+ @Test
public void testAddByIndexRealmChecks() throws Exception {
RealmTester.exerciseCurrent(new Runnable() {
@Override
@@ -80,6 +88,7 @@
});
}
+ @Test
public void testAddAllRealmChecks() throws Exception {
RealmTester.exerciseCurrent(new Runnable() {
@Override
@@ -90,6 +99,7 @@
});
}
+ @Test
public void testAddAllByIndexRealmChecks() throws Exception {
RealmTester.exerciseCurrent(new Runnable() {
@Override
@@ -100,6 +110,7 @@
});
}
+ @Test
public void testRemoveRealmChecks() throws Exception {
RealmTester.setDefault(new CurrentRealm(true));
final WritableList list = new WritableList();
@@ -115,6 +126,7 @@
RealmTester.setDefault(null);
}
+ @Test
public void testRemoveByIndexRealmChecks() throws Exception {
RealmTester.setDefault(new CurrentRealm(true));
final WritableList list = new WritableList();
@@ -131,6 +143,7 @@
RealmTester.setDefault(null);
}
+ @Test
public void testRemoveAllRealmChecks() throws Exception {
RealmTester.exerciseCurrent(new Runnable() {
@Override
@@ -141,6 +154,7 @@
});
}
+ @Test
public void testRetainAllRealmChecks() throws Exception {
RealmTester.exerciseCurrent(new Runnable() {
@Override
@@ -151,6 +165,7 @@
});
}
+ @Test
public void testClearRealmChecks() throws Exception {
RealmTester.exerciseCurrent(new Runnable() {
@Override
@@ -161,6 +176,7 @@
});
}
+ @Test
public void testNullElementType() throws Exception {
RealmTester.setDefault(DisplayRealm.getRealm(Display.getDefault()));
WritableList writableList = new WritableList();
@@ -170,6 +186,7 @@
assertNull(writableList.getElementType());
}
+ @Test
public void testWithElementType() throws Exception {
RealmTester.setDefault(DisplayRealm.getRealm(Display.getDefault()));
@@ -180,6 +197,7 @@
assertEquals(elementType, list.getElementType());
}
+ @Test
public void testListConstructorsDoNotCopy_1() {
RealmTester.setDefault(new CurrentRealm(true));
List list = new ArrayList(Arrays.asList(new Object[] { "a", "b", "c" }));
@@ -190,6 +208,7 @@
assertEquals(3, wlist.size());
}
+ @Test
public void testListConstructorsDoNotCopy_2() {
List list = new ArrayList(Arrays.asList(new Object[] { "a", "b", "c" }));
WritableList wlist = new WritableList(new CurrentRealm(true), list,
@@ -200,6 +219,7 @@
assertEquals(3, wlist.size());
}
+ @Test
public void testCollectionConstructorsCopy_1() {
RealmTester.setDefault(new CurrentRealm(true));
List list = new ArrayList(Arrays.asList(new Object[] { "a", "b", "c" }));
@@ -210,6 +230,7 @@
assertEquals(2, wlist.size());
}
+ @Test
public void testCollectionConstructorsCopy_2() {
List list = new ArrayList(Arrays.asList(new Object[] { "a", "b", "c" }));
WritableList wlist = new WritableList(new CurrentRealm(true),
@@ -220,11 +241,8 @@
assertEquals(2, wlist.size());
}
- public static Test suite() {
- TestSuite suite = new TestSuite(WritableListTest.class.getName());
- suite.addTestSuite(WritableListTest.class);
+ public static void addConformanceTest(TestSuite suite) {
suite.addTest(MutableObservableListContractTest.suite(new Delegate()));
- return suite;
}
/* package */static class Delegate extends
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/map/AbstractObservableMapTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/map/AbstractObservableMapTest.java
index c20ec9d..bcedcb7 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/map/AbstractObservableMapTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/map/AbstractObservableMapTest.java
@@ -14,8 +14,6 @@
import java.util.Set;
-import junit.framework.TestCase;
-
import org.eclipse.core.databinding.observable.ChangeEvent;
import org.eclipse.core.databinding.observable.DisposeEvent;
import org.eclipse.core.databinding.observable.IChangeListener;
@@ -28,24 +26,28 @@
import org.eclipse.core.databinding.observable.map.MapDiff;
import org.eclipse.jface.databinding.conformance.util.CurrentRealm;
import org.eclipse.jface.databinding.conformance.util.RealmTester;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
/**
* @since 3.2
*/
-public class AbstractObservableMapTest extends TestCase {
+public class AbstractObservableMapTest {
private AbstractObservableMapStub map;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
RealmTester.setDefault(new CurrentRealm(true));
map = new AbstractObservableMapStub();
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
RealmTester.setDefault(null);
}
+ @Test
public void testIsStaleRealmChecks() throws Exception {
RealmTester.exerciseCurrent(new Runnable() {
@Override
@@ -55,6 +57,7 @@
});
}
+ @Test
public void testSetStaleRealmChecks() throws Exception {
RealmTester.exerciseCurrent(new Runnable() {
@Override
@@ -64,6 +67,7 @@
});
}
+ @Test
public void testFireStaleRealmChecks() throws Exception {
RealmTester.exerciseCurrent(new Runnable() {
@Override
@@ -73,6 +77,7 @@
});
}
+ @Test
public void testFireChangeRealmChecks() throws Exception {
RealmTester.exerciseCurrent(new Runnable() {
@Override
@@ -82,6 +87,7 @@
});
}
+ @Test
public void testFireMapChangeRealmChecks() throws Exception {
RealmTester.exerciseCurrent(new Runnable() {
@Override
@@ -91,6 +97,7 @@
});
}
+ @Test
public void testAddListChangeListener_AfterDispose() {
map.dispose();
map.addMapChangeListener(new IMapChangeListener() {
@@ -101,6 +108,7 @@
});
}
+ @Test
public void testRemoveListChangeListener_AfterDispose() {
map.dispose();
map.removeMapChangeListener(new IMapChangeListener() {
@@ -111,6 +119,7 @@
});
}
+ @Test
public void testAddChangeListener_AfterDispose() {
map.dispose();
map.addChangeListener(new IChangeListener() {
@@ -121,6 +130,7 @@
});
}
+ @Test
public void testRemoveChangeListener_AfterDispose() {
map.dispose();
map.removeChangeListener(new IChangeListener() {
@@ -131,6 +141,7 @@
});
}
+ @Test
public void testAddStaleListener_AfterDispose() {
map.dispose();
map.addStaleListener(new IStaleListener() {
@@ -141,6 +152,7 @@
});
}
+ @Test
public void testRemoveStaleListener_AfterDispose() {
map.dispose();
map.removeStaleListener(new IStaleListener() {
@@ -151,6 +163,7 @@
});
}
+ @Test
public void testAddDisposeListener_AfterDispose() {
map.dispose();
map.addDisposeListener(new IDisposeListener() {
@@ -161,6 +174,7 @@
});
}
+ @Test
public void testRemoveDisposeListener_AfterDispose() {
map.dispose();
map.removeDisposeListener(new IDisposeListener() {
@@ -171,6 +185,7 @@
});
}
+ @Test
public void testHasListeners_AfterDispose() {
map.dispose();
map.hasListeners();
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/map/BidiObservableMapTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/map/BidiObservableMapTest.java
index 703b9f9..3ac6b9b 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/map/BidiObservableMapTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/map/BidiObservableMapTest.java
@@ -11,6 +11,11 @@
package org.eclipse.core.tests.databinding.observable.map;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@@ -21,6 +26,8 @@
import org.eclipse.core.databinding.observable.map.WritableMap;
import org.eclipse.jface.databinding.conformance.util.ChangeEventTracker;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Before;
+import org.junit.Test;
/**
* @since 3.2
@@ -34,8 +41,8 @@
private Object value1;
private Object value2;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
wrappedMap = new WritableMap();
bidiMap = new BidiObservableMap(wrappedMap);
@@ -45,6 +52,7 @@
value2 = new Object();
}
+ @Test
public void testConstructor_NullArgument() {
try {
new BidirectionalMap(null);
@@ -69,6 +77,7 @@
// assuming tearDown() afterward
}
+ @Test
public void testGetKeys_Empty() throws Exception {
withAndWithoutListeners(new Runnable() {
@Override
@@ -78,6 +87,7 @@
});
}
+ @Test
public void testGetKeys_NullKey() throws Exception {
withAndWithoutListeners(new Runnable() {
@Override
@@ -89,6 +99,7 @@
});
}
+ @Test
public void testGetKeys_NullValue() throws Exception {
withAndWithoutListeners(new Runnable() {
@Override
@@ -99,6 +110,7 @@
});
}
+ @Test
public void testGetKeys_SinglePut() throws Exception {
withAndWithoutListeners(new Runnable() {
@Override
@@ -110,6 +122,7 @@
});
}
+ @Test
public void testGetKeys_ReplaceValue() throws Exception {
withAndWithoutListeners(new Runnable() {
@Override
@@ -126,6 +139,7 @@
});
}
+ @Test
public void testGetKeys_MultipleKeysWithSameValue() throws Exception {
withAndWithoutListeners(new Runnable() {
@Override
@@ -141,6 +155,7 @@
});
}
+ @Test
public void testContainsValue_PutAndRemove() throws Exception {
withAndWithoutListeners(new Runnable() {
@Override
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/map/CompositeMapTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/map/CompositeMapTest.java
index 45cd537..b154b9e 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/map/CompositeMapTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/map/CompositeMapTest.java
@@ -11,6 +11,10 @@
package org.eclipse.core.tests.databinding.observable.map;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import java.lang.reflect.Method;
import java.util.Collections;
@@ -26,6 +30,8 @@
import org.eclipse.jface.examples.databinding.model.SimpleCart;
import org.eclipse.jface.examples.databinding.model.SimplePerson;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Before;
+import org.junit.Test;
/**
* @since 3.2
@@ -47,8 +53,8 @@
}
}
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
persons = new WritableSet();
first = BeansObservables.observeMap(persons,
@@ -62,6 +68,7 @@
});
}
+ @Test
public void testAddToFirstMap() {
MapChangeEventTracker tracker = new MapChangeEventTracker();
composedMap.addMapChangeListener(tracker);
@@ -78,6 +85,7 @@
assertEquals(Integer.valueOf(42), composedMap.get(newPerson));
}
+ @Test
public void testAddSharedToFirstMap() {
SimplePerson person1 = new SimplePerson("p1", "a1", "c1", "s1");
person1.getCart().setNumItems(42);
@@ -98,6 +106,7 @@
assertEquals(Integer.valueOf(42), composedMap.get(person1));
}
+ @Test
public void testRemoveFromFirstMap() {
MapChangeEventTracker tracker = new MapChangeEventTracker();
SimplePerson newPerson = new SimplePerson("p1", "a1", "c1", "s1");
@@ -116,6 +125,7 @@
assertFalse("newPerson should be removed", composedMap.containsKey(newPerson));
}
+ @Test
public void testRemoveSharedFromFirstMap() {
SimplePerson person1 = new SimplePerson("p1", "a1", "c1", "s1");
person1.getCart().setNumItems(42);
@@ -138,6 +148,7 @@
assertEquals(Integer.valueOf(42), composedMap.get(person1));
}
+ @Test
public void testChangeInFirstMap() {
SimplePerson person1 = new SimplePerson("p1", "a1", "c1", "s1");
person1.getCart().setNumItems(42);
@@ -156,6 +167,7 @@
assertEquals(Integer.valueOf(0), composedMap.get(person1));
}
+ @Test
public void testChangeInFirstMapToShared() {
SimplePerson person0 = new SimplePerson("p0", "a0", "c0", "s0");
person0.getCart().setNumItems(13);
@@ -177,6 +189,7 @@
assertEquals(Integer.valueOf(13), composedMap.get(person1));
}
+ @Test
public void testChangeInFirstMapFromShared() {
SimplePerson person0 = new SimplePerson("p0", "a0", "c0", "s0");
person0.getCart().setNumItems(13);
@@ -198,6 +211,7 @@
assertEquals(Integer.valueOf(0), composedMap.get(person1));
}
+ @Test
public void testChangeInSecondMap() {
SimplePerson person0 = new SimplePerson("p0", "a0", "c0", "s0");
person0.getCart().setNumItems(13);
@@ -216,6 +230,7 @@
assertEquals(Integer.valueOf(42), composedMap.get(person0));
}
+ @Test
public void testDispose() {
SimplePerson person0 = new SimplePerson("p0", "a0", "c0", "s0");
person0.getCart().setNumItems(13);
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/map/ComputedObservableMapTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/map/ComputedObservableMapTest.java
index a328e6a..031eee3 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/map/ComputedObservableMapTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/map/ComputedObservableMapTest.java
@@ -12,6 +12,11 @@
package org.eclipse.core.tests.databinding.observable.map;
+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 java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
@@ -23,6 +28,8 @@
import org.eclipse.core.tests.internal.databinding.beans.Bean;
import org.eclipse.jface.databinding.conformance.util.ChangeEventTracker;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Before;
+import org.junit.Test;
/**
* @since 3.2
@@ -34,8 +41,8 @@
private String propertyName;
private Bean bean;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
keySet = new WritableSet();
map = new ComputedObservableMapStub(keySet);
@@ -43,32 +50,38 @@
bean = new Bean("a");
}
+ @Test
public void testGet_ElementNotInKeySet() {
assertNull(map.get(bean));
}
+ @Test
public void testGet_ElementInKeySet() {
keySet.add(bean);
assertEquals("a", map.get(bean));
}
+ @Test
public void testPut_ElementNotInKeySet() {
assertNull(map.put(bean, "b"));
assertEquals("a", bean.getValue());
}
+ @Test
public void testPut_ElementInKeySet() {
keySet.add(bean);
assertEquals("a", map.put(bean, "b"));
assertEquals("b", map.get(bean));
}
+ @Test
public void testAddToKeySet_BeforeFirstListenerAdded_DoesNotAddListenerToKey() {
assertFalse(bean.hasListeners(propertyName));
keySet.add(bean);
assertFalse(bean.hasListeners(propertyName));
}
+ @Test
public void testAddToKeySet_AfterFirstListenerAdded_AddsListenerToKey() {
ChangeEventTracker.observe(map);
assertFalse(bean.hasListeners(propertyName));
@@ -76,6 +89,7 @@
assertTrue(bean.hasListeners(propertyName));
}
+ @Test
public void testRemoveFromKeySet_RemovesListenersFromKey() {
ChangeEventTracker.observe(map);
keySet.add(bean);
@@ -84,6 +98,7 @@
assertFalse(bean.hasListeners(propertyName));
}
+ @Test
public void testRemoveLastListener_DoNotDiscardKeySet() {
IChangeListener listener = new IChangeListener() {
@Override
@@ -97,6 +112,7 @@
assertEquals(1, map.size());
}
+ @Test
public void testDispose_RemoveListenersFromKeySetElements() {
ChangeEventTracker.observe(map);
keySet.add(bean);
@@ -105,12 +121,14 @@
assertFalse(bean.hasListeners(propertyName));
}
+ @Test
public void testDisposeKeySet_DisposesMap() {
assertFalse(map.isDisposed());
keySet.dispose();
assertTrue(map.isDisposed());
}
+ @Test
public void testDisposeKeySet_RemoveListenersFromKeySetElements() {
ChangeEventTracker.observe(map);
keySet.add(bean);
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/map/ObservableMapTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/map/ObservableMapTest.java
index faf61f8..0d03dda 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/map/ObservableMapTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/map/ObservableMapTest.java
@@ -13,36 +13,41 @@
package org.eclipse.core.tests.databinding.observable.map;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
-import junit.framework.TestCase;
-
import org.eclipse.core.databinding.observable.map.MapDiff;
import org.eclipse.core.databinding.observable.map.ObservableMap;
import org.eclipse.jface.databinding.conformance.util.CurrentRealm;
import org.eclipse.jface.databinding.conformance.util.MapChangeEventTracker;
import org.eclipse.jface.databinding.conformance.util.RealmTester;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
/**
* @since 3.2
*
*/
-public class ObservableMapTest extends TestCase {
+public class ObservableMapTest {
ObservableMapStub map;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
RealmTester.setDefault(new CurrentRealm(true));
map = new ObservableMapStub(new HashMap());
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
RealmTester.setDefault(null);
}
+ @Test
public void testDisposeMapChangeListeners() throws Exception {
MapChangeEventTracker listener = MapChangeEventTracker.observe(map);
@@ -61,6 +66,7 @@
listener.count);
}
+ @Test
public void testIsStaleRealmChecks() throws Exception {
RealmTester.exerciseCurrent(new Runnable() {
@Override
@@ -70,6 +76,7 @@
});
}
+ @Test
public void testSetStaleRealmChecks() throws Exception {
RealmTester.exerciseCurrent(new Runnable() {
@Override
@@ -79,6 +86,7 @@
});
}
+ @Test
public void testFireMapChangeRealmChecks() throws Exception {
RealmTester.exerciseCurrent(new Runnable() {
@Override
@@ -88,6 +96,7 @@
});
}
+ @Test
public void testEquals() {
assertTrue(map.equals(Collections.EMPTY_MAP));
}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/map/WritableMapTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/map/WritableMapTest.java
index 0a0bcd3..4e6f855 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/map/WritableMapTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/map/WritableMapTest.java
@@ -12,13 +12,14 @@
package org.eclipse.core.tests.databinding.observable.map;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
-import junit.framework.TestCase;
-
import org.eclipse.core.databinding.observable.Realm;
import org.eclipse.core.databinding.observable.map.MapChangeEvent;
import org.eclipse.core.databinding.observable.map.MapDiff;
@@ -26,22 +27,26 @@
import org.eclipse.jface.databinding.conformance.util.CurrentRealm;
import org.eclipse.jface.databinding.conformance.util.MapChangeEventTracker;
import org.eclipse.jface.databinding.conformance.util.RealmTester;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
/**
* @since 3.2
*
*/
-public class WritableMapTest extends TestCase {
- @Override
- protected void setUp() throws Exception {
+public class WritableMapTest {
+ @Before
+ public void setUp() throws Exception {
RealmTester.setDefault(new CurrentRealm(true));
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
RealmTester.setDefault(null);
}
+ @Test
public void testPutRealmChecks() throws Exception {
RealmTester.exerciseCurrent(new Runnable() {
@Override
@@ -52,6 +57,7 @@
});
}
+ @Test
public void testRemoveRealmChecks() throws Exception {
RealmTester.exerciseCurrent(new Runnable() {
@Override
@@ -68,6 +74,7 @@
});
}
+ @Test
public void testClearRealmChecks() throws Exception {
RealmTester.exerciseCurrent(new Runnable() {
@Override
@@ -78,6 +85,7 @@
});
}
+ @Test
public void testPutAllRealmChecks() throws Exception {
RealmTester.exerciseCurrent(new Runnable() {
@Override
@@ -88,6 +96,7 @@
});
}
+ @Test
public void testPutWithExistingKeyMapChangeEvent() throws Exception {
WritableMap map = new WritableMap();
String key = "key";
@@ -113,6 +122,7 @@
assertEquals(newValue, event.diff.getNewValue(key));
}
+ @Test
public void testPutSameValue_NoMapChangeEvent() {
WritableMap map = new WritableMap();
Object key = new Object();
@@ -130,6 +140,7 @@
}
+ @Test
public void testPutNullKey_SingleAdditionChangeEvent() {
WritableMap map = new WritableMap();
MapChangeEventTracker tracker = MapChangeEventTracker.observe(map);
@@ -148,6 +159,7 @@
assertEquals(value, diff.getNewValue(key));
}
+ @Test
public void testRemoveNullKey_SingleRemovalChangeEvent() {
WritableMap map = new WritableMap();
Object key = null;
@@ -166,6 +178,7 @@
assertEquals(value, diff.getOldValue(key));
}
+ @Test
public void testPutNullValue_SingleAdditionChangeEvent() {
WritableMap map = new WritableMap();
@@ -185,6 +198,7 @@
assertEquals(value, diff.getNewValue(key));
}
+ @Test
public void testPutNullOverNonNullValue_SingleChangeEvent() {
WritableMap map = new WritableMap();
Object key = new Object();
@@ -205,6 +219,7 @@
assertEquals(newValue, diff.getNewValue(key));
}
+ @Test
public void testPutNonNullOverNullValue_SingleChangeEvent() {
WritableMap map = new WritableMap();
Object key = new Object();
@@ -225,6 +240,7 @@
assertEquals(newValue, diff.getNewValue(key));
}
+ @Test
public void testRemoveNullValue_SingleRemovalChangeEvent() {
WritableMap map = new WritableMap();
Object key = new Object();
@@ -243,6 +259,7 @@
assertEquals(value, diff.getOldValue(key));
}
+ @Test
public void testPutAllNullValue_SingleAdditionChangeEvent() {
WritableMap map = new WritableMap();
@@ -262,6 +279,7 @@
assertEquals(value, diff.getNewValue(key));
}
+ @Test
public void testPutAllNullValueToNonNullValue_SingleChangeEvent() {
WritableMap map = new WritableMap();
Object key = new Object();
@@ -284,6 +302,7 @@
assertEquals(newValue, diff.getNewValue(key));
}
+ @Test
public void testPutAllNonNullValueToNullValue_SingleChangeEvent() {
WritableMap map = new WritableMap();
Object key = new Object();
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/set/AbstractObservableSetTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/set/AbstractObservableSetTest.java
index 0c47aba..7fd659c 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/set/AbstractObservableSetTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/set/AbstractObservableSetTest.java
@@ -15,10 +15,6 @@
import java.util.HashSet;
import java.util.Set;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
import org.eclipse.core.databinding.observable.Diffs;
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.IObservableCollection;
@@ -28,13 +24,13 @@
import org.eclipse.jface.databinding.conformance.ObservableCollectionContractTest;
import org.eclipse.jface.databinding.conformance.delegate.AbstractObservableCollectionContractDelegate;
+import junit.framework.TestSuite;
+
/**
*/
-public class AbstractObservableSetTest extends TestCase {
- public static Test suite() {
- TestSuite suite = new TestSuite(AbstractObservableSetTest.class.getName());
+public class AbstractObservableSetTest {
+ public static void addConformanceTest(TestSuite suite) {
suite.addTest(ObservableCollectionContractTest.suite(new Delegate()));
- return suite;
}
private static class Delegate extends
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/set/ComputedSetTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/set/ComputedSetTest.java
index c46989f..4adf14e 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/set/ComputedSetTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/set/ComputedSetTest.java
@@ -11,13 +11,15 @@
package org.eclipse.core.tests.databinding.observable.set;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.eclipse.core.databinding.observable.AbstractObservable;
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.IObservableCollection;
@@ -30,23 +32,30 @@
import org.eclipse.jface.databinding.conformance.delegate.AbstractObservableCollectionContractDelegate;
import org.eclipse.jface.databinding.conformance.util.SetChangeEventTracker;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Before;
+import org.junit.Test;
+
+import junit.framework.TestSuite;
public class ComputedSetTest extends AbstractDefaultRealmTestCase {
ComputedSetStub set;
@Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
set = new ComputedSetStub();
set.size(); // Force set to compute
}
+ @Test
public void testDependency_Staleness() {
assertFalse(set.isStale());
set.dependency.fireStale();
assertTrue(set.isStale());
}
+ @Test
public void testDependency_FiresSetChange() {
assertEquals(set.nextComputation, set);
@@ -58,6 +67,7 @@
assertEquals(Collections.singleton(element), set);
}
+ @Test
public void testDependency_NoStaleEventIfAlreadyDirty() {
set.dependency.fireChange();
set.addStaleListener(new IStaleListener() {
@@ -69,6 +79,7 @@
set.dependency.fireStale();
}
+ @Test
public void testDependency_SetChangeEventFiresOnlyWhenNotDirty() {
SetChangeEventTracker tracker = SetChangeEventTracker.observe(set);
@@ -133,11 +144,8 @@
}
}
- public static Test suite() {
- TestSuite suite = new TestSuite(ComputedSetTest.class.getName());
- suite.addTestSuite(ComputedSetTest.class);
+ public static void addConformanceTest(TestSuite suite) {
suite.addTest(ObservableCollectionContractTest.suite(new Delegate()));
- return suite;
}
static class Delegate extends AbstractObservableCollectionContractDelegate {
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/set/DecoratingObservableSetTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/set/DecoratingObservableSetTest.java
index bdd4892..db9c219 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/set/DecoratingObservableSetTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/set/DecoratingObservableSetTest.java
@@ -16,9 +16,6 @@
import java.util.Collections;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.IObservableCollection;
import org.eclipse.core.databinding.observable.Realm;
@@ -28,17 +25,15 @@
import org.eclipse.jface.databinding.conformance.MutableObservableCollectionContractTest;
import org.eclipse.jface.databinding.conformance.delegate.AbstractObservableCollectionContractDelegate;
+import junit.framework.TestSuite;
+
/**
* @since 3.2
*
*/
public class DecoratingObservableSetTest {
- public static Test suite() {
- TestSuite suite = new TestSuite(DecoratingObservableSetTest.class
- .getName());
- suite.addTest(MutableObservableCollectionContractTest
- .suite(new Delegate()));
- return suite;
+ public static void addConformanceTest(TestSuite suite) {
+ suite.addTest(MutableObservableCollectionContractTest.suite(new Delegate()));
}
static class Delegate extends AbstractObservableCollectionContractDelegate {
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/set/ObservableSetTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/set/ObservableSetTest.java
index 6be0f0f..4f6fe63 100755
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/set/ObservableSetTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/set/ObservableSetTest.java
@@ -15,10 +15,6 @@
import java.util.HashSet;
import java.util.Set;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
import org.eclipse.core.databinding.observable.Diffs;
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.IObservableCollection;
@@ -29,14 +25,14 @@
import org.eclipse.jface.databinding.conformance.ObservableCollectionContractTest;
import org.eclipse.jface.databinding.conformance.delegate.AbstractObservableCollectionContractDelegate;
+import junit.framework.TestSuite;
+
/**
* @since 1.1
*/
-public class ObservableSetTest extends TestCase {
- public static Test suite() {
- TestSuite suite = new TestSuite(ObservableSetTest.class.getName());
+public class ObservableSetTest {
+ public static void addConformanceTest(TestSuite suite) {
suite.addTest(ObservableCollectionContractTest.suite(new Delegate()));
- return suite;
}
private static class Delegate extends AbstractObservableCollectionContractDelegate {
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/set/UnionSetTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/set/UnionSetTest.java
index 9589c94..2abc978 100755
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/set/UnionSetTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/set/UnionSetTest.java
@@ -12,10 +12,6 @@
package org.eclipse.core.tests.databinding.observable.set;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.IObservableCollection;
import org.eclipse.core.databinding.observable.Realm;
@@ -25,13 +21,13 @@
import org.eclipse.jface.databinding.conformance.ObservableCollectionContractTest;
import org.eclipse.jface.databinding.conformance.delegate.AbstractObservableCollectionContractDelegate;
+import junit.framework.TestSuite;
+
/**
*/
-public class UnionSetTest extends TestCase {
- public static Test suite() {
- TestSuite suite = new TestSuite(UnionSetTest.class.getName());
+public class UnionSetTest {
+ public static void addConformanceTest(TestSuite suite) {
suite.addTest(ObservableCollectionContractTest.suite(new Delegate()));
- return suite;
}
private static class Delegate extends
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/set/WritableSetTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/set/WritableSetTest.java
index cfb6102..e9ac0fb 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/set/WritableSetTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/set/WritableSetTest.java
@@ -11,10 +11,10 @@
******************************************************************************/
package org.eclipse.core.tests.databinding.observable.set;
-import java.util.Collections;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import java.util.Collections;
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.IObservableCollection;
@@ -24,10 +24,14 @@
import org.eclipse.jface.databinding.conformance.MutableObservableSetContractTest;
import org.eclipse.jface.databinding.conformance.delegate.AbstractObservableCollectionContractDelegate;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Test;
+
+import junit.framework.TestSuite;
/**
*/
public class WritableSetTest extends AbstractDefaultRealmTestCase {
+ @Test
public void testWithElementType() throws Exception {
Object elementType = String.class;
WritableSet set = WritableSet.withElementType(elementType);
@@ -36,11 +40,8 @@
assertEquals(elementType, set.getElementType());
}
- public static Test suite() {
- TestSuite suite = new TestSuite(WritableSetTest.class.getName());
- suite.addTestSuite(WritableSetTest.class);
+ public static void addConformanceTest(TestSuite suite) {
suite.addTest(MutableObservableSetContractTest.suite(new Delegate()));
- return suite;
}
private static class Delegate extends
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/value/AbstractObservableValueTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/value/AbstractObservableValueTest.java
index fcf2d5d..9010f71 100755
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/value/AbstractObservableValueTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/value/AbstractObservableValueTest.java
@@ -11,18 +11,33 @@
package org.eclipse.core.tests.databinding.observable.value;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
import org.eclipse.core.databinding.observable.Realm;
import org.eclipse.core.databinding.observable.value.AbstractObservableValue;
import org.eclipse.core.databinding.observable.value.ValueDiff;
import org.eclipse.jface.databinding.conformance.util.CurrentRealm;
import org.eclipse.jface.databinding.conformance.util.RealmTester;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
/**
* @since 3.2
*/
-public class AbstractObservableValueTest extends TestCase {
+public class AbstractObservableValueTest {
+
+ @Before
+ public void setUp() throws Exception {
+ RealmTester.setDefault(new CurrentRealm(true));
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ RealmTester.setDefault(null);
+ }
+
+ @Test
public void testSetValueRealmChecks() throws Exception {
RealmTester.exerciseCurrent(new Runnable() {
@Override
@@ -37,6 +52,7 @@
});
}
+ @Test
public void testSetValueInvokesDoSetValue() throws Exception {
class ValueStub extends ObservableValueStub {
int doSetValue;
@@ -58,6 +74,7 @@
assertEquals("doSetValue should have been invoked", 1, stub.doSetValue);
}
+ @Test
public void testFireValueChangeRealmChecks() throws Exception {
RealmTester.exerciseCurrent(new Runnable() {
@Override
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/value/AbstractVetoableValueTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/value/AbstractVetoableValueTest.java
index 5b83d74..677899b 100755
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/value/AbstractVetoableValueTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/value/AbstractVetoableValueTest.java
@@ -11,19 +11,34 @@
package org.eclipse.core.tests.databinding.observable.value;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
import org.eclipse.core.databinding.observable.Realm;
import org.eclipse.core.databinding.observable.value.AbstractVetoableValue;
import org.eclipse.core.databinding.observable.value.ValueDiff;
import org.eclipse.jface.databinding.conformance.util.CurrentRealm;
import org.eclipse.jface.databinding.conformance.util.RealmTester;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
/**
* @since 3.2
*/
-public class AbstractVetoableValueTest extends TestCase {
- public void testSetValueInvokesDoSetApprovedValue() throws Exception {
+public class AbstractVetoableValueTest {
+
+ @Before
+ public void setUp() throws Exception {
+ RealmTester.setDefault(new CurrentRealm(true));
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ RealmTester.setDefault(null);
+ }
+
+ @Test
+ public void testSetValueInvokesDoSetApprovedValue() throws Exception {
class VetoableValue extends VetoableValueStub {
int count;
Object value;
@@ -50,7 +65,8 @@
assertEquals(value, vetoableValue.value);
}
- public void testFireValueChangeRealmChecks() throws Exception {
+ @Test
+ public void testFireValueChangeRealmChecks() throws Exception {
RealmTester.exerciseCurrent(new Runnable() {
@Override
public void run() {
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/value/ComputedValueTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/value/ComputedValueTest.java
index 48e50cf..850b9b1 100755
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/value/ComputedValueTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/value/ComputedValueTest.java
@@ -13,6 +13,12 @@
package org.eclipse.core.tests.databinding.observable.value;
+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 static org.junit.Assert.fail;
+
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -20,13 +26,15 @@
import org.eclipse.core.databinding.observable.value.ComputedValue;
import org.eclipse.core.databinding.observable.value.WritableValue;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Test;
/**
* @since 1.0
*
*/
public class ComputedValueTest extends AbstractDefaultRealmTestCase {
- public void testValueType() throws Exception {
+ @Test
+ public void testValueType() throws Exception {
ComputedValue cv = new ComputedValue(Integer.TYPE) {
@Override
protected Object calculate() {
@@ -46,7 +54,8 @@
assertNull(cv.getValueType());
}
- public void test_getValue() throws Exception {
+ @Test
+ public void test_getValue() throws Exception {
ComputedValue cv = new ComputedValue() {
@Override
protected Object calculate() {
@@ -56,7 +65,8 @@
assertEquals("Calculated value should be 42", Integer.valueOf(42), cv.getValue());
}
- public void testDependencyValueChange() throws Exception {
+ @Test
+ public void testDependencyValueChange() throws Exception {
final WritableValue value = new WritableValue(Integer.valueOf(42), Integer.TYPE);
ComputedValue cv = new ComputedValue() {
@@ -84,7 +94,8 @@
}
}
- public void testHookAndUnhookDependantObservables() throws Exception {
+ @Test
+ public void testHookAndUnhookDependantObservables() throws Exception {
final List values = new ArrayList();
ComputedValue cv = new ComputedValue() {
@@ -124,7 +135,8 @@
assertFalse("because value2 is not a part of the calculation the listeners should have been removed", value2.hasListeners());
}
- public void testSetValueUnsupportedOperationException() throws Exception {
+ @Test
+ public void testSetValueUnsupportedOperationException() throws Exception {
ComputedValue cv = new ComputedValue() {
@Override
protected Object calculate() {
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/value/DateAndTimeObservableValueTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/value/DateAndTimeObservableValueTest.java
index b494b47..9739c71 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/value/DateAndTimeObservableValueTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/value/DateAndTimeObservableValueTest.java
@@ -12,6 +12,9 @@
package org.eclipse.core.tests.databinding.observable.value;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
import java.util.Calendar;
import java.util.Date;
@@ -19,6 +22,8 @@
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.core.databinding.observable.value.WritableValue;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Before;
+import org.junit.Test;
/**
* @since 1.0
@@ -30,8 +35,8 @@
private IObservableValue time;
private IObservableValue dateAndTime;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
date = WritableValue.withValueType(Date.class);
@@ -66,18 +71,21 @@
return calendar.getTime();
}
+ @Test
public void testGetValue_NullDateNullResult() {
date.setValue(null);
time.setValue(time(12, 27, 17));
assertNull(dateAndTime.getValue());
}
+ @Test
public void testGetValue_NullTimeClearsTime() {
date.setValue(date(2009, 3, 3));
time.setValue(null);
assertEquals(timestamp(2009, 3, 3, 0, 0, 0), dateAndTime.getValue());
}
+ @Test
public void testGetValue() {
date.setValue(timestamp(2009, 3, 3, 12, 30, 33));
@@ -86,6 +94,7 @@
assertEquals(timestamp(2009, 3, 3, 23, 59, 59), dateAndTime.getValue());
}
+ @Test
public void testSetValue() {
date.setValue(date(2009, 3, 3));
time.setValue(time(12, 32, 55));
@@ -96,6 +105,7 @@
assertEquals(time(2, 3, 5), time.getValue());
}
+ @Test
public void testSetValue_NullNullsDateClearsTime() {
date.setValue(date(2009, 3, 3));
time.setValue(time(12, 25, 34));
@@ -105,6 +115,7 @@
assertEquals(time(0, 0, 0), time.getValue());
}
+ @Test
public void testSetValue_PreserveTimeOfDateAndDateOfTime() {
date.setValue(timestamp(2009, 3, 3, 12, 32, 55));
time.setValue(timestamp(2009, 3, 3, 12, 32, 55));
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/value/DecoratingObservableValueTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/value/DecoratingObservableValueTest.java
index aca3431..4c93761 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/value/DecoratingObservableValueTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/value/DecoratingObservableValueTest.java
@@ -11,9 +11,6 @@
package org.eclipse.core.tests.databinding.observable.value;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.Realm;
import org.eclipse.core.databinding.observable.value.DecoratingObservableValue;
@@ -22,16 +19,15 @@
import org.eclipse.jface.databinding.conformance.MutableObservableValueContractTest;
import org.eclipse.jface.databinding.conformance.delegate.AbstractObservableValueContractDelegate;
+import junit.framework.TestSuite;
+
/**
* @since 3.2
*
*/
public class DecoratingObservableValueTest {
- public static Test suite() {
- TestSuite suite = new TestSuite(DecoratingObservableValueTest.class
- .getName());
+ public static void addConformanceTest(TestSuite suite) {
suite.addTest(MutableObservableValueContractTest.suite(new Delegate()));
- return suite;
}
static class Delegate extends AbstractObservableValueContractDelegate {
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/value/DuplexingObservableValueTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/value/DuplexingObservableValueTest.java
index 226d59a..c848935 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/value/DuplexingObservableValueTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/value/DuplexingObservableValueTest.java
@@ -12,6 +12,9 @@
package org.eclipse.core.tests.databinding.observable.value;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
import java.util.ArrayList;
import java.util.Collection;
@@ -19,6 +22,8 @@
import org.eclipse.core.databinding.observable.list.WritableList;
import org.eclipse.core.databinding.observable.value.DuplexingObservableValue;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Before;
+import org.junit.Test;
/**
* @since 1.0
@@ -28,12 +33,13 @@
private IObservableList list;
private DuplexingObservableValue observable;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
list = new WritableList(new ArrayList(), String.class);
}
+ @Test
public void testValueType_InheritFromTargetList() throws Exception {
observable = new DuplexingObservableValue(list) {
@Override
@@ -46,6 +52,7 @@
String.class, observable.getValueType());
}
+ @Test
public void testValueType_ProvidedInConstructor() throws Exception {
observable = new DuplexingObservableValue(list, Object.class) {
@Override
@@ -57,6 +64,7 @@
Object.class, observable.getValueType());
}
+ @Test
public void test_getValue() throws Exception {
observable = DuplexingObservableValue.withDefaults(list, null,
"<Multiple Values>");
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/value/SelectObservableValueTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/value/SelectObservableValueTest.java
index 188e4c1..d0923d1 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/value/SelectObservableValueTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/value/SelectObservableValueTest.java
@@ -11,9 +11,6 @@
package org.eclipse.core.tests.databinding.observable.value;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.Realm;
import org.eclipse.core.databinding.observable.value.IObservableValue;
@@ -23,17 +20,15 @@
import org.eclipse.jface.databinding.conformance.delegate.AbstractObservableValueContractDelegate;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import junit.framework.TestSuite;
+
/**
* @since 3.2
*
*/
public class SelectObservableValueTest extends AbstractDefaultRealmTestCase {
- public static Test suite() {
- TestSuite suite = new TestSuite(SelectObservableValueTest.class
- .getName());
- // suite.addTestSuite(SelectObservableValueValueTest.class);
+ public static void addConformanceTest(TestSuite suite) {
suite.addTest(MutableObservableValueContractTest.suite(new Delegate()));
- return suite;
}
/* package */static class Delegate extends
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/value/WritableValueTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/value/WritableValueTest.java
index 831221f..072e0c9 100755
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/value/WritableValueTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/value/WritableValueTest.java
@@ -13,8 +13,9 @@
package org.eclipse.core.tests.databinding.observable.value;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.Realm;
@@ -25,6 +26,9 @@
import org.eclipse.jface.databinding.swt.DisplayRealm;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
import org.eclipse.swt.widgets.Display;
+import org.junit.Test;
+
+import junit.framework.TestSuite;
/**
* @since 3.2
@@ -35,6 +39,7 @@
*
* @throws Exception
*/
+ @Test
public void testConstructor() throws Exception {
WritableValue value = new WritableValue(DisplayRealm.getRealm(Display
.getDefault()));
@@ -42,6 +47,7 @@
assertNull(value.getValueType());
}
+ @Test
public void testWithValueType() throws Exception {
Object elementType = String.class;
WritableValue value = WritableValue.withValueType(elementType);
@@ -50,11 +56,8 @@
assertEquals(elementType, value.getValueType());
}
- public static Test suite() {
- TestSuite suite = new TestSuite(WritableValueTest.class.getName());
- suite.addTestSuite(WritableValueTest.class);
+ public static void addConformanceTest(TestSuite suite) {
suite.addTest(MutableObservableValueContractTest.suite(new Delegate()));
- return suite;
}
/* package */static class Delegate extends
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/util/PolicyTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/util/PolicyTest.java
index 7fb365b..2f603ea 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/util/PolicyTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/util/PolicyTest.java
@@ -11,27 +11,31 @@
******************************************************************************/
package org.eclipse.core.tests.databinding.util;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
-import junit.framework.TestCase;
-
import org.eclipse.core.databinding.util.ILogger;
import org.eclipse.core.databinding.util.Policy;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.junit.Test;
/**
* @since 3.2
*
*/
-public class PolicyTest extends TestCase {
+public class PolicyTest {
+ @Test
public void testConstructor() {
// cover the constructor too
new Policy();
}
+ @Test
public void testDummyLog() {
ILogger oldLog = Policy.getLog();
PrintStream oldErr = System.err;
@@ -60,6 +64,7 @@
}
}
+ @Test
public void testCustomLog() {
ILogger oldLog = Policy.getLog();
try {
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/validation/MultiValidatorTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/validation/MultiValidatorTest.java
index 250444d..700e371 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/validation/MultiValidatorTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/validation/MultiValidatorTest.java
@@ -13,6 +13,13 @@
package org.eclipse.core.tests.databinding.validation;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -39,14 +46,16 @@
import org.eclipse.jface.databinding.conformance.util.StaleEventTracker;
import org.eclipse.jface.databinding.conformance.util.ValueChangeEventTracker;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Before;
+import org.junit.Test;
public class MultiValidatorTest extends AbstractDefaultRealmTestCase {
private DependencyObservableValue dependency;
private MultiValidator validator;
private IObservableValue validationStatus;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
dependency = new DependencyObservableValue(null, IStatus.class);
validator = new MultiValidator() {
@@ -58,6 +67,7 @@
validationStatus = validator.getValidationStatus();
}
+ @Test
public void testConstructor_NullArgument() {
try {
new MultiValidator(null) {
@@ -71,11 +81,13 @@
}
}
+ @Test
public void testGetValidationStatus_NullResultYieldsOKStatus() {
IStatus status = (IStatus) validationStatus.getValue();
assertTrue(status.isOK()); // null -> OK
}
+ @Test
public void testGetValidationStatus_ExceptionThrownYieldsErrorStatus() {
final RuntimeException e = new RuntimeException("message");
validator = new MultiValidator() {
@@ -87,18 +99,21 @@
assertEquals(ValidationStatus.error("message", e), validator.getValidationStatus().getValue());
}
+ @Test
public void testGetValidationStatus_TracksWithDependency() {
IStatus newStatus = ValidationStatus.error("error");
dependency.setValue(newStatus);
assertEquals(newStatus, validationStatus.getValue());
}
+ @Test
public void testInit_AddsValidationProducer() {
DataBindingContext dbc = new DataBindingContext();
dbc.addValidationStatusProvider(validator);
assertTrue(dbc.getValidationStatusProviders().contains(validator));
}
+ @Test
public void testObserveValidatedValue_NullArgument() {
try {
validator.observeValidatedValue(null);
@@ -107,6 +122,7 @@
}
}
+ @Test
public void testObserveValidatedValue_WrongRealm() {
Realm otherRealm = new CurrentRealm(true);
try {
@@ -116,6 +132,7 @@
}
}
+ @Test
public void testObserveValidatedValue_ReturnValue() {
WritableValue target = new WritableValue();
ValidatedObservableValue validated = (ValidatedObservableValue) validator.observeValidatedValue(target);
@@ -135,6 +152,7 @@
assertFalse(validated.isStale());
}
+ @Test
public void testBug237884_DisposeCausesNPE() {
MultiValidator validator = new MultiValidator() {
@Override
@@ -149,11 +167,13 @@
}
}
+ @Test
public void testBug237884_MultipleDispose() {
validator.dispose();
validator.dispose();
}
+ @Test
public void testBug237884_Comment3_ValidationStatusAsDependencyCausesStackOverflow() {
dependency = new DependencyObservableValue(new Object(), Object.class);
validator = new MultiValidator() {
@@ -188,6 +208,7 @@
}
}
+ @Test
public void testBug237884_ValidationStatusListenerCausesLoopingDependency() {
validationStatus.addChangeListener(new IChangeListener() {
@Override
@@ -201,6 +222,7 @@
assertFalse(validator.getTargets().contains(validationStatus));
}
+ @Test
public void testRevalidate() {
// Use this as an easy way to inject a validation status into the
// validator without using an observable value.
@@ -234,6 +256,7 @@
assertSame(status[0], validator.getValidationStatus().getValue());
}
+ @Test
public void testBug237884_ValidationStatusAccessDuringValidationCausesLoopingDependency() {
validator = new MultiValidator() {
@Override
@@ -247,6 +270,7 @@
assertFalse(validator.getTargets().contains(validationStatus));
}
+ @Test
public void testBug240590_ValidationStatusSetWhileTrackingDependencies() {
final IObservableValue noDependency = new WritableValue();
validationStatus.addValueChangeListener(new IValueChangeListener() {
@@ -265,6 +289,7 @@
assertFalse(validator.getTargets().contains(noDependency));
}
+ @Test
public void testValidationStaleness() {
ValueChangeEventTracker validationChangeCounter = ValueChangeEventTracker.observe(validationStatus);
@@ -303,6 +328,7 @@
assertEquals(1, validationStaleCounter.count);
}
+ @Test
public void testStatusValueChangeWhileValidationStale() {
// Change to a stale state.
dependency.setStale(true);
@@ -318,6 +344,7 @@
assertEquals(dependency.getValue(), validationStatus.getValue());
}
+ @Test
public void testValidationStatusBecomesStaleThroughNewDependency() {
final DependencyObservableValue nonStaleDependency = new DependencyObservableValue(ValidationStatus.ok(),
IStatus.class);
@@ -351,6 +378,7 @@
assertEquals(1, validationStaleCounter.count);
}
+ @Test
public void testBug251003_CompareDependenciesByIdentity() {
DependencyObservable dependency1 = new DependencyObservable();
DependencyObservable dependency2 = new DependencyObservable();
@@ -382,6 +410,7 @@
assertSame(dependency2, targets.get(0));
}
+ @Test
public void testBug251003_MissingDependencies() {
final WritableList emptyListDependency = new WritableList();
validator = new MultiValidator() {
@@ -399,6 +428,7 @@
assertTrue(validator.getTargets().contains(emptyListDependency));
}
+ @Test
public void testBug357568_MultiValidatorTargetAsDependency() {
validator = new MultiValidator() {
@Override
@@ -414,6 +444,7 @@
dependency.setValue(ValidationStatus.info("foo"));
}
+ @Test
public void testBug357568_ValidationStatusAsDependency() {
validator = new MultiValidator() {
@Override
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/validation/ValidationStatusTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/validation/ValidationStatusTest.java
index 7458687..05a7a11 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/validation/ValidationStatusTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/validation/ValidationStatusTest.java
@@ -11,15 +11,17 @@
package org.eclipse.core.tests.databinding.validation;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
import org.eclipse.core.databinding.validation.ValidationStatus;
import org.eclipse.core.runtime.IStatus;
+import org.junit.Test;
/**
* @since 1.1
*/
-public class ValidationStatusTest extends TestCase {
+public class ValidationStatusTest {
+ @Test
public void testEqualsAndHashCode() throws Exception {
String message = "error";
Exception e = new IllegalArgumentException();
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/BindingMessagesTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/BindingMessagesTest.java
index 84f559a..22e5bff 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/BindingMessagesTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/BindingMessagesTest.java
@@ -1,7 +1,9 @@
package org.eclipse.core.tests.internal.databinding;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import org.eclipse.core.internal.databinding.BindingMessages;
+import org.junit.Test;
/*******************************************************************************
* Copyright (c) 2007 IBM Corporation and others.
@@ -18,13 +20,15 @@
* @since 3.2
*
*/
-public class BindingMessagesTest extends TestCase {
+public class BindingMessagesTest {
+ @Test
public void testFormatString() throws Exception {
String key = "Validate_NumberOutOfRangeError";
String result = BindingMessages.formatString(key, new Object[] {"1", "2"});
assertFalse("key should not be returned", key.equals(result));
}
+ @Test
public void testFormatStringForKeyNotFound() throws Exception {
String key = "key_that_does_not_exist";
String result = BindingMessages.formatString(key, null);
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/BindingStatusTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/BindingStatusTest.java
index a616429..8e581df 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/BindingStatusTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/BindingStatusTest.java
@@ -1,11 +1,15 @@
package org.eclipse.core.tests.internal.databinding;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
import org.eclipse.core.databinding.util.Policy;
import org.eclipse.core.databinding.validation.ValidationStatus;
import org.eclipse.core.internal.databinding.BindingStatus;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.junit.Before;
+import org.junit.Test;
/*******************************************************************************
* Copyright (c) 2007 IBM Corporation and others.
@@ -21,16 +25,15 @@
/**
* @since 1.1
*/
-public class BindingStatusTest extends TestCase {
+public class BindingStatusTest {
private BindingStatus bindingStatus;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
+ @Before
+ public void setUp() throws Exception {
bindingStatus = BindingStatus.ok();
}
+ @Test
public void testMessageIsFromStatus() throws Exception {
String message = "error message";
IStatus status = ValidationStatus.error(message);
@@ -39,6 +42,7 @@
assertEquals(message, bindingStatus.getMessage());
}
+ @Test
public void testExceptionIsFromStatus() throws Exception {
IllegalArgumentException e = new IllegalArgumentException();
Status status = new Status(0, Policy.JFACE_DATABINDING, 0, "", e);
@@ -47,6 +51,7 @@
assertEquals(e, bindingStatus.getException());
}
+ @Test
public void testPluginIsFromStatus() throws Exception {
String plugin = "test";
Status status = new Status(0, plugin, 0, "", null);
@@ -55,6 +60,7 @@
assertEquals(plugin, bindingStatus.getPlugin());
}
+ @Test
public void testCodeIsFromStatus() throws Exception {
int code = 1;
Status status = new Status(0, Policy.JFACE_DATABINDING, code, "", null);
@@ -63,6 +69,7 @@
assertEquals(code, status.getCode());
}
+ @Test
public void testSeverityIsFromStatus() throws Exception {
IStatus status = ValidationStatus.error("");
@@ -70,6 +77,7 @@
assertEquals(IStatus.ERROR, status.getSeverity());
}
+ @Test
public void testLowerSeverityDoesNotOverwriteGreaterSeverity() throws Exception {
String info = "info";
String error = "error";
@@ -88,6 +96,7 @@
assertEquals(IStatus.INFO, children[1].getSeverity());
}
+ @Test
public void testEqual() throws Exception {
BindingStatus status1 = BindingStatus.ok();
BindingStatus status2 = BindingStatus.ok();
@@ -95,6 +104,7 @@
assertEquals(status1, status2);
}
+ @Test
public void testNotEqual() throws Exception {
BindingStatus status1 = BindingStatus.ok();
BindingStatus status2 = BindingStatus.ok();
@@ -103,6 +113,7 @@
assertFalse(status1.equals(status2));
}
+ @Test
public void testHashCode() throws Exception {
BindingStatus status1 = BindingStatus.ok();
BindingStatus status2 = BindingStatus.ok();
@@ -110,6 +121,7 @@
assertEquals(status1.hashCode(), status2.hashCode());
}
+ @Test
public void testOkInitializesStatus() throws Exception {
BindingStatus status = BindingStatus.ok();
assertEquals(Policy.JFACE_DATABINDING, status.getPlugin());
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/ConverterValuePropertyTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/ConverterValuePropertyTest.java
index 3f123c2..7a19e02 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/ConverterValuePropertyTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/ConverterValuePropertyTest.java
@@ -11,12 +11,17 @@
package org.eclipse.core.tests.internal.databinding;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
import org.eclipse.core.databinding.BindingProperties;
import org.eclipse.core.databinding.conversion.IConverter;
import org.eclipse.core.databinding.property.value.IValueProperty;
import org.eclipse.core.internal.databinding.ConverterValueProperty;
import org.eclipse.core.internal.databinding.conversion.ObjectToStringConverter;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Before;
+import org.junit.Test;
/**
* Tests for the {@link ConverterValueProperty} class.
@@ -25,19 +30,21 @@
private IConverter converter;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
converter = new ObjectToStringConverter(Integer.class);
}
+ @Test
public void testGetValue() {
IValueProperty property = BindingProperties.convertedValue(converter);
assertEquals("123", property.getValue(Integer.valueOf(123)));
}
+ @Test
public void testGetValueForNullSource() {
// The converter converts null to "".
IValueProperty property = BindingProperties.convertedValue(converter);
@@ -46,6 +53,7 @@
assertEquals("", property.getValue(null));
}
+ @Test
public void testSetValue() {
IValueProperty property = BindingProperties.convertedValue(converter);
@@ -57,6 +65,7 @@
}
}
+ @Test
public void testGetValueType() {
IValueProperty property = BindingProperties.convertedValue(converter);
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/DifferentRealmsBindingTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/DifferentRealmsBindingTest.java
index 9a342e9..602bfae 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/DifferentRealmsBindingTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/DifferentRealmsBindingTest.java
@@ -10,6 +10,8 @@
******************************************************************************/
package org.eclipse.core.tests.internal.databinding;
+import static org.junit.Assert.assertTrue;
+
import java.util.ArrayList;
import java.util.List;
@@ -22,10 +24,11 @@
import org.eclipse.core.databinding.util.Policy;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.tests.databinding.observable.ThreadRealm;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
-import junit.framework.TestCase;
-
-public class DifferentRealmsBindingTest extends TestCase {
+public class DifferentRealmsBindingTest {
ThreadRealm targetAndModelRealm = new ThreadRealm();
ThreadRealm validationRealm = new ThreadRealm();
@@ -42,8 +45,8 @@
}
};
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
errorStatusses.clear();
new Thread() {
@Override
@@ -58,11 +61,12 @@
Policy.setLog(logger);
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
dbc.dispose();
}
+ @Test
public void testListBindingValidationRealm() throws Throwable {
final ObservableList model = new WritableList(targetAndModelRealm);
final ObservableList target = new WritableList(targetAndModelRealm);
@@ -74,6 +78,7 @@
assertTrue(errorStatusses.toString(), errorStatusses.isEmpty());
}
+ @Test
public void testSetBindingValidationRealm() throws Throwable {
final ObservableSet model = new WritableSet(targetAndModelRealm);
final ObservableSet target = new WritableSet(targetAndModelRealm);
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/IdentityMapTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/IdentityMapTest.java
index 73d5648..1b5e0bc 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/IdentityMapTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/IdentityMapTest.java
@@ -14,6 +14,13 @@
package org.eclipse.core.tests.internal.databinding;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
@@ -21,23 +28,22 @@
import java.util.Map;
import java.util.Set;
-import junit.framework.TestCase;
-
import org.eclipse.core.internal.databinding.identity.IdentityMap;
+import org.junit.Before;
+import org.junit.Test;
/**
* @since 1.2
*/
-public class IdentityMapTest extends TestCase {
+public class IdentityMapTest {
IdentityMap map;
Object key;
Object value;
Map.Entry entry;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
map = new IdentityMap();
key = new Object();
value = new Object();
@@ -59,6 +65,7 @@
};
}
+ @Test
public void testConstructor_NullComparer() {
try {
new IdentityMap(null);
@@ -67,6 +74,7 @@
}
}
+ @Test
public void testConstructorWithCollection_NullCollection() {
try {
new IdentityMap(null);
@@ -75,6 +83,7 @@
}
}
+ @Test
public void testConstructorWithCollection_ContainsAllEntries() {
Map<Object, Object> toCopy = new HashMap<Object, Object>();
toCopy.put(new Object(), new Object());
@@ -82,18 +91,21 @@
assertEquals(toCopy, map);
}
+ @Test
public void testIsEmpty() {
assertTrue(map.isEmpty());
map.put(key, value);
assertFalse(map.isEmpty());
}
+ @Test
public void testSize() {
assertEquals(0, map.size());
map.put(key, value);
assertEquals(1, map.size());
}
+ @Test
public void testClear() {
map.put(key, value);
assertFalse(map.isEmpty());
@@ -101,12 +113,14 @@
assertTrue(map.isEmpty());
}
+ @Test
public void testGet() {
assertNull(map.get(key));
map.put(key, value);
assertEquals(value, map.get(key));
}
+ @Test
public void testContainsKey() {
String key1 = new String("key");
String key2 = new String("key"); // equal but distinct instances
@@ -116,12 +130,14 @@
assertFalse(map.containsKey(key2));
}
+ @Test
public void testContainsValue() {
assertFalse(map.containsValue(value));
map.put(key, value);
assertTrue(map.containsValue(value));
}
+ @Test
public void testPutAll() {
Map<Object, Object> other = new HashMap<Object, Object>();
other.put(key, value);
@@ -133,6 +149,7 @@
assertEquals(value, map.get(key));
}
+ @Test
public void testRemove() {
map.put(key, value);
assertTrue(map.containsKey(key));
@@ -140,6 +157,7 @@
assertFalse(map.containsKey(key));
}
+ @Test
public void testValues() {
Collection<?> values = map.values();
assertTrue(values.isEmpty());
@@ -153,6 +171,7 @@
assertTrue(map.values().isEmpty());
}
+ @Test
public void testKeySet() {
Set<Object> keySet = map.keySet();
assertTrue(keySet.isEmpty());
@@ -165,6 +184,7 @@
assertTrue(keySet.isEmpty());
}
+ @Test
public void testKeySet_Add() {
try {
map.keySet().add(key);
@@ -173,6 +193,7 @@
}
}
+ @Test
public void testKeySet_AddAll() {
try {
map.keySet().addAll(Collections.singleton(key));
@@ -181,6 +202,7 @@
}
}
+ @Test
public void testKeySet_Clear() {
map.put(key, value);
Set<Object> keySet = map.keySet();
@@ -190,6 +212,7 @@
assertTrue(map.isEmpty());
}
+ @Test
public void testKeySet_Contains() {
Set<Object> keySet = map.keySet();
assertFalse(keySet.contains(key));
@@ -197,6 +220,7 @@
assertTrue(keySet.contains(key));
}
+ @Test
public void testKeySet_ContainsAll() {
Set<Object> keySet = map.keySet();
assertFalse(keySet.containsAll(Collections.singleton(key)));
@@ -204,6 +228,7 @@
assertTrue(keySet.containsAll(Collections.singleton(key)));
}
+ @Test
public void testKeySet_IsEmpty() {
Set<Object> keySet = map.keySet();
assertTrue(keySet.isEmpty());
@@ -211,6 +236,7 @@
assertFalse(keySet.isEmpty());
}
+ @Test
public void testKeySet_Iterator() {
map.put(key, value);
Iterator<Object> iterator = map.keySet().iterator();
@@ -224,6 +250,7 @@
assertFalse(iterator.hasNext());
}
+ @Test
public void testKeySet_Remove() {
map.put(key, value);
assertEquals(1, map.size());
@@ -231,6 +258,7 @@
assertTrue(map.isEmpty());
}
+ @Test
public void testKeySet_RemoveAll() {
map.put(key, value);
Set<Object> keySet = map.keySet();
@@ -240,6 +268,7 @@
assertTrue(map.isEmpty());
}
+ @Test
public void testKeySet_RetainAll() {
map.put(key, value);
Set<Object> keySet = map.keySet();
@@ -249,6 +278,7 @@
assertTrue(map.isEmpty());
}
+ @Test
public void testKeySet_Size() {
Set<Object> keySet = map.keySet();
assertEquals(0, keySet.size());
@@ -258,6 +288,7 @@
assertEquals(0, keySet.size());
}
+ @Test
public void testKeySet_ToArray() {
Set<Object> keySet = map.keySet();
map.put(key, value);
@@ -266,6 +297,7 @@
assertSame(key, array[0]);
}
+ @Test
public void testKeySet_ToArrayWithObjectArray() {
key = new String("key");
map.put(key, value);
@@ -274,6 +306,7 @@
assertSame(key, array[0]);
}
+ @Test
public void testKeySet_Equals() {
Set<Object> keySet = map.keySet();
assertFalse(keySet.equals(null));
@@ -284,6 +317,7 @@
assertTrue(keySet.equals(Collections.singleton(key)));
}
+ @Test
public void testKeySet_HashCode() {
Set<Object> keySet = map.keySet();
assertEquals(0, keySet.hashCode());
@@ -292,6 +326,7 @@
assertEquals(hash, keySet.hashCode());
}
+ @Test
public void testEntrySet() {
Set<Object> entrySet = map.entrySet();
assertTrue(entrySet.isEmpty());
@@ -306,6 +341,7 @@
assertTrue(entrySet.isEmpty());
}
+ @Test
public void testEntrySet_Add() {
try {
map.entrySet().add(entry);
@@ -314,6 +350,7 @@
}
}
+ @Test
public void testEntrySet_AddAll() {
try {
map.entrySet().addAll(Collections.EMPTY_SET);
@@ -322,6 +359,7 @@
}
}
+ @Test
public void testEntrySet_Clear() {
map.put(key, value);
assertEquals(1, map.size());
@@ -329,6 +367,7 @@
assertTrue(map.isEmpty());
}
+ @Test
public void testEntrySet_Contains() {
map.put(key, value);
Set<Object> entrySet = map.entrySet();
@@ -337,6 +376,7 @@
assertFalse(entrySet.contains(new MapEntryStub(key, value)));
}
+ @Test
public void testEntrySet_ContainsAll() {
Set<Object> entrySet = map.entrySet();
assertFalse(entrySet.containsAll(Collections.singleton(new MapEntryStub(key, value))));
@@ -346,6 +386,7 @@
assertTrue(entrySet.containsAll(Collections.singleton(new MapEntryStub(key, value))));
}
+ @Test
public void testEntrySet_IsEmpty() {
Set<Object> entrySet = map.entrySet();
assertTrue(entrySet.isEmpty());
@@ -353,6 +394,7 @@
assertFalse(entrySet.isEmpty());
}
+ @Test
public void testEntrySet_Iterator() {
map.put(key, value);
Iterator<Object> iterator = map.entrySet().iterator();
@@ -366,6 +408,7 @@
assertFalse(iterator.hasNext());
}
+ @Test
public void testEntrySet_Remove() {
map.put(key, value);
assertEquals(1, map.size());
@@ -374,6 +417,7 @@
assertTrue(map.isEmpty());
}
+ @Test
public void testEntrySet_RemoveAll() {
Set<Object> entrySet = map.entrySet();
assertFalse(entrySet.removeAll(Collections.EMPTY_SET));
@@ -384,6 +428,7 @@
assertTrue(map.isEmpty());
}
+ @Test
public void testEntrySet_RetainAll() {
Set<Object> entrySet = map.entrySet();
assertFalse(entrySet.retainAll(Collections.EMPTY_SET));
@@ -396,6 +441,7 @@
assertTrue(map.isEmpty());
}
+ @Test
public void testEntrySet_Size() {
Set<Object> entrySet = map.entrySet();
assertEquals(0, entrySet.size());
@@ -403,6 +449,7 @@
assertEquals(1, entrySet.size());
}
+ @Test
public void testEntrySet_ToArray() {
Set<Object> entrySet = map.entrySet();
assertEquals(0, entrySet.toArray().length);
@@ -413,6 +460,7 @@
assertTrue(array[0].equals(new MapEntryStub(key, value)));
}
+ @Test
public void testEntrySet_ToArrayWithObjectArray() {
Set<Object> entrySet = map.entrySet();
assertEquals(0, entrySet.toArray(new Object[0]).length);
@@ -423,6 +471,7 @@
assertTrue(array[0].equals(new MapEntryStub(key, value)));
}
+ @Test
public void testEntrySet_Equals() {
Set<Object> entrySet = map.entrySet();
assertFalse(entrySet.equals(null));
@@ -436,6 +485,7 @@
assertTrue(entrySet.equals(Collections.singleton(new MapEntryStub(key, value))));
}
+ @Test
public void testEntrySet_HashCode() {
// hash formula mandated by Map contract
Set<Object> entrySet = map.entrySet();
@@ -446,6 +496,7 @@
assertEquals(hash, entrySet.hashCode());
}
+ @Test
public void testEntrySet_Entry_SetValue() {
map.put(key, value);
@@ -458,6 +509,7 @@
assertEquals(newValue, map.get(key));
}
+ @Test
public void testEntrySet_Entry_Equals() {
map.put(key, value);
@@ -467,6 +519,7 @@
assertTrue(entry.equals(new MapEntryStub(key, value)));
}
+ @Test
public void testEntrySet_Entry_HashCode() {
map.put(key, value);
@@ -475,6 +528,7 @@
assertEquals(hash, map.entrySet().iterator().next().hashCode());
}
+ @Test
public void testEquals() {
assertFalse(map.equals(null));
assertTrue(map.equals(map));
@@ -491,6 +545,7 @@
assertTrue(map.equals(other));
}
+ @Test
public void testHashCode() {
assertEquals(0, map.hashCode());
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/IdentitySetTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/IdentitySetTest.java
index 6a51941..37d1e91 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/IdentitySetTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/IdentitySetTest.java
@@ -13,28 +13,35 @@
package org.eclipse.core.tests.internal.databinding;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
-import junit.framework.TestCase;
-
import org.eclipse.core.internal.databinding.identity.IdentitySet;
import org.eclipse.jface.internal.databinding.viewers.ViewerElementSet;
+import org.junit.Before;
+import org.junit.Test;
/**
* @since 1.2
*/
-public class IdentitySetTest extends TestCase {
+public class IdentitySetTest {
IdentitySet set;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
set = new IdentitySet();
}
+ @Test
public void testConstructor_NullComparer() {
try {
new ViewerElementSet(null);
@@ -43,6 +50,7 @@
}
}
+ @Test
public void testConstructorWithCollection_NullCollection() {
try {
new ViewerElementSet(null);
@@ -51,12 +59,14 @@
}
}
+ @Test
public void testConstructorWithCollection_AddsAllElements() {
Collection<Object> toCopy = Collections.singleton(new Object());
set = new IdentitySet(toCopy);
assertTrue(set.containsAll(toCopy));
}
+ @Test
public void testAdd_ContainsHonorsComparer() {
Object o1 = new String("string");
Object o2 = new String("string"); // distinct instances
@@ -69,6 +79,7 @@
assertFalse(set.contains(o2));
}
+ @Test
public void testAdd_FilterDuplicateElements() {
Object o = new Object();
@@ -79,6 +90,7 @@
assertTrue(set.contains(o));
}
+ @Test
public void testAddAll_ContainsAllHonorsComparer() {
String o1 = new String("o1");
String o2 = new String("o2");
@@ -90,6 +102,7 @@
assertFalse(set.containsAll(Collections.singleton(new String("o2"))));
}
+ @Test
public void testAddAll_FiltersDuplicateElements() {
Object o = new Object();
set.add(o);
@@ -97,6 +110,7 @@
assertFalse(set.addAll(Collections.singleton(o)));
}
+ @Test
public void testClear() {
set.add(new Object());
assertEquals(1, set.size());
@@ -105,12 +119,14 @@
assertEquals(0, set.size());
}
+ @Test
public void testIsEmpty() {
assertTrue(set.isEmpty());
set.add(new Object());
assertFalse(set.isEmpty());
}
+ @Test
public void testIterator() {
Object o = new Object();
set.add(o);
@@ -126,6 +142,7 @@
assertFalse(iterator.hasNext());
}
+ @Test
public void testRemove() {
Object o = new Object();
assertFalse(set.remove(o));
@@ -137,6 +154,7 @@
assertFalse(set.contains(o));
}
+ @Test
public void testRemoveAll() {
assertFalse(set.removeAll(Collections.EMPTY_SET));
@@ -152,6 +170,7 @@
assertFalse(set.contains(o2));
}
+ @Test
public void testRetainAll() {
Object o1 = new Object();
Object o2 = new Object();
@@ -170,6 +189,7 @@
assertFalse(set.contains(o1));
}
+ @Test
public void testSize() {
assertEquals(0, set.size());
@@ -181,6 +201,7 @@
assertEquals(0, set.size());
}
+ @Test
public void testToArray() {
assertEquals(0, set.toArray().length);
@@ -189,6 +210,7 @@
assertTrue(Arrays.equals(new Object[] { o }, set.toArray()));
}
+ @Test
public void testToArrayWithObjectArray() {
Object o = new String("unique");
set.add(o);
@@ -198,6 +220,7 @@
assertSame(o, array[0]);
}
+ @Test
public void testEquals() {
assertTrue(set.equals(set));
assertFalse(set.equals(null));
@@ -212,6 +235,7 @@
assertFalse(set.equals(Collections.singleton(distinct)));
}
+ @Test
public void testHashCode() {
// Hash code implementation is mandated
assertEquals(0, set.hashCode());
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/QueueTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/QueueTest.java
index 1e62fb1..ee324f2 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/QueueTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/QueueTest.java
@@ -11,23 +11,29 @@
package org.eclipse.core.tests.internal.databinding;
-import org.eclipse.core.internal.databinding.observable.Queue;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
-import junit.framework.TestCase;
+import org.eclipse.core.internal.databinding.observable.Queue;
+import org.junit.Before;
+import org.junit.Test;
/**
* @since 3.2
*
*/
-public class QueueTest extends TestCase {
+public class QueueTest {
private Queue queue;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
this.queue = new Queue();
}
+ @Test
public void testIsEmpty() {
assertTrue(queue.isEmpty());
queue.enqueue("foo");
@@ -40,6 +46,7 @@
assertTrue(queue.isEmpty());
}
+ @Test
public void testEnqueueAndDequeue() {
try {
queue.dequeue();
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/BeanObservableListDecoratorTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/BeanObservableListDecoratorTest.java
index 2bc1d6f..266ee67 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/BeanObservableListDecoratorTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/BeanObservableListDecoratorTest.java
@@ -12,11 +12,9 @@
package org.eclipse.core.tests.internal.databinding.beans;
-import java.beans.PropertyDescriptor;
+import static org.junit.Assert.assertSame;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import java.beans.PropertyDescriptor;
import org.eclipse.core.databinding.beans.BeansObservables;
import org.eclipse.core.databinding.observable.IObservable;
@@ -29,19 +27,22 @@
import org.eclipse.jface.databinding.conformance.delegate.AbstractObservableCollectionContractDelegate;
import org.eclipse.jface.databinding.swt.DisplayRealm;
import org.eclipse.swt.widgets.Display;
+import org.junit.Before;
+import org.junit.Test;
+
+import junit.framework.TestSuite;
/**
* @since 3.3
*/
-public class BeanObservableListDecoratorTest extends TestCase {
+public class BeanObservableListDecoratorTest {
private Bean bean;
private PropertyDescriptor propertyDescriptor;
private IObservableList observableList;
private BeanObservableListDecorator decorator;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
bean = new Bean();
propertyDescriptor = new PropertyDescriptor(
@@ -51,23 +52,23 @@
decorator = new BeanObservableListDecorator(observableList, propertyDescriptor);
}
+ @Test
public void testGetDelegate() throws Exception {
assertSame(observableList, decorator.getDecorated());
}
+ @Test
public void testGetObserved() throws Exception {
assertSame(bean, decorator.getObserved());
}
+ @Test
public void testGetPropertyDescriptor() throws Exception {
assertSame(propertyDescriptor, decorator.getPropertyDescriptor());
}
- public static Test suite() {
- TestSuite suite = new TestSuite(BeanObservableListDecoratorTest.class.getName());
- suite.addTestSuite(BeanObservableListDecoratorTest.class);
+ public static void addConformanceTest(TestSuite suite) {
suite.addTest(MutableObservableListContractTest.suite(new Delegate()));
- return suite;
}
static class Delegate extends AbstractObservableCollectionContractDelegate {
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/BeanObservableSetDecoratorTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/BeanObservableSetDecoratorTest.java
index 2e81f8e..5fbf086 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/BeanObservableSetDecoratorTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/BeanObservableSetDecoratorTest.java
@@ -12,28 +12,29 @@
package org.eclipse.core.tests.internal.databinding.beans;
-import java.beans.PropertyDescriptor;
+import static org.junit.Assert.assertSame;
-import junit.framework.TestCase;
+import java.beans.PropertyDescriptor;
import org.eclipse.core.databinding.beans.BeansObservables;
import org.eclipse.core.databinding.observable.set.IObservableSet;
import org.eclipse.core.internal.databinding.beans.BeanObservableSetDecorator;
import org.eclipse.jface.databinding.swt.DisplayRealm;
import org.eclipse.swt.widgets.Display;
+import org.junit.Before;
+import org.junit.Test;
/**
* @since 3.3
*/
-public class BeanObservableSetDecoratorTest extends TestCase {
+public class BeanObservableSetDecoratorTest {
private PropertyDescriptor propertyDescriptor;
private IObservableSet observableSet;
private BeanObservableSetDecorator decorator;
private Bean bean;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
bean = new Bean();
propertyDescriptor = new PropertyDescriptor("set", Bean.class);
@@ -43,14 +44,17 @@
propertyDescriptor);
}
+ @Test
public void testGetDecorated() throws Exception {
assertSame(observableSet, decorator.getDecorated());
}
+ @Test
public void testGetObserved() throws Exception {
assertSame(bean, decorator.getObserved());
}
+ @Test
public void testGetPropertyDescriptor() throws Exception {
assertSame(propertyDescriptor, decorator.getPropertyDescriptor());
}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/BeanObservableValueDecoratorTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/BeanObservableValueDecoratorTest.java
index 9a432dc..541202f 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/BeanObservableValueDecoratorTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/BeanObservableValueDecoratorTest.java
@@ -12,6 +12,8 @@
package org.eclipse.core.tests.internal.databinding.beans;
+import static org.junit.Assert.assertSame;
+
import java.beans.PropertyDescriptor;
import org.eclipse.core.databinding.beans.BeansObservables;
@@ -20,6 +22,8 @@
import org.eclipse.jface.databinding.swt.DisplayRealm;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
import org.eclipse.swt.widgets.Display;
+import org.junit.Before;
+import org.junit.Test;
/**
* @since 3.3
@@ -30,8 +34,8 @@
private BeanObservableValueDecorator decorator;
private PropertyDescriptor propertyDescriptor;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
bean = new Bean();
@@ -42,14 +46,17 @@
propertyDescriptor);
}
+ @Test
public void testGetDelegate() throws Exception {
assertSame(observableValue, decorator.getDecorated());
}
+ @Test
public void testGetObserved() throws Exception {
assertSame(bean, decorator.getObserved());
}
+ @Test
public void testGetPropertyDescriptor() throws Exception {
assertSame(propertyDescriptor, decorator.getPropertyDescriptor());
}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/BeanPropertyHelperTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/BeanPropertyHelperTest.java
index c17b595..61e68fd 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/BeanPropertyHelperTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/BeanPropertyHelperTest.java
@@ -12,17 +12,19 @@
package org.eclipse.core.tests.internal.databinding.beans;
+import static org.junit.Assert.assertEquals;
+
import java.beans.PropertyDescriptor;
-import junit.framework.TestCase;
-
import org.eclipse.core.internal.databinding.beans.BeanPropertyHelper;
+import org.junit.Test;
/**
* @since 3.2
*
*/
-public class BeanPropertyHelperTest extends TestCase {
+public class BeanPropertyHelperTest {
+ @Test
public void testGetPropertyDescriptor_ClassProperty()
throws SecurityException, NoSuchMethodException {
PropertyDescriptor pd = BeanPropertyHelper.getPropertyDescriptor(
@@ -33,6 +35,7 @@
pd.getWriteMethod());
}
+ @Test
public void testGetPropertyDescriptor_InterfaceProperty()
throws SecurityException, NoSuchMethodException {
PropertyDescriptor pd = BeanPropertyHelper.getPropertyDescriptor(
@@ -43,6 +46,7 @@
pd.getWriteMethod());
}
+ @Test
public void testGetPropertyDescriptor_SuperInterfaceProperty()
throws SecurityException, NoSuchMethodException {
PropertyDescriptor pd = BeanPropertyHelper.getPropertyDescriptor(
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/BeanPropertyListenerSupportTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/BeanPropertyListenerSupportTest.java
index d96f023..46bfd80 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/BeanPropertyListenerSupportTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/BeanPropertyListenerSupportTest.java
@@ -11,6 +11,10 @@
package org.eclipse.core.tests.internal.databinding.beans;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
@@ -20,6 +24,8 @@
import org.eclipse.core.internal.databinding.beans.BeanPropertyListenerSupport;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Before;
+import org.junit.Test;
/**
* @since 1.1
@@ -29,14 +35,15 @@
private PropertyChangeListenerStub listener;
private String propertyName;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
listener = new PropertyChangeListenerStub();
propertyName = "value";
}
+ @Test
public void testAddPropertyChangeListenerWithPropertyName()
throws Exception {
SpecificListenerBean bean = new SpecificListenerBean();
@@ -48,6 +55,7 @@
.hasListeners(propertyName));
}
+ @Test
public void testAddPropertyChangeListenerWithoutPropertyName()
throws Exception {
GenericListenerBean bean = new GenericListenerBean();
@@ -59,6 +67,7 @@
.hasListeners(propertyName));
}
+ @Test
public void testLogStatusWhenAddPropertyChangeListenerMethodIsNotFound()
throws Exception {
class BeanStub {
@@ -86,6 +95,7 @@
assertEquals(IStatus.WARNING, log.status.getSeverity());
}
+ @Test
public void testRemovePropertyChangeListenerWithPropertyName()
throws Exception {
SpecificListenerBean bean = new SpecificListenerBean();
@@ -99,6 +109,7 @@
.hasListeners(propertyName));
}
+ @Test
public void testRemovePropertyChangeListenerWithoutPropertyName()
throws Exception {
GenericListenerBean bean = new GenericListenerBean();
@@ -112,6 +123,7 @@
.hasListeners(propertyName));
}
+ @Test
public void testLogStatusWhenRemovePropertyChangeListenerMethodIsNotFound()
throws Exception {
class InvalidBean {
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/BeanPropertyListenerTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/BeanPropertyListenerTest.java
index 6784d77..728c95c 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/BeanPropertyListenerTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/BeanPropertyListenerTest.java
@@ -11,6 +11,8 @@
package org.eclipse.core.tests.internal.databinding.beans;
+import static org.junit.Assert.assertEquals;
+
import java.beans.PropertyChangeEvent;
import java.beans.PropertyDescriptor;
import java.util.ArrayList;
@@ -24,6 +26,8 @@
import org.eclipse.core.databinding.property.SimplePropertyEvent;
import org.eclipse.core.internal.databinding.beans.BeanPropertyListener;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Before;
+import org.junit.Test;
/**
* @since 1.1
@@ -34,8 +38,8 @@
private SimplePropertyListenerStub simpleListener;
private BeanPropertyListenerStub listener;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
property = new PropertyStub();
propertyDescriptor = new PropertyDescriptor("value", Bean.class);
@@ -44,6 +48,7 @@
simpleListener);
}
+ @Test
public void testPropertyChange_ExpectedPropertyName() {
Object source = new Object();
String propertyName = "value";
@@ -59,6 +64,7 @@
simpleListener.log);
}
+ @Test
public void testPropertyChange_OtherPropertyName() {
Object source = new Object();
String propertyName = "other";
@@ -70,6 +76,7 @@
assertEquals(Collections.EMPTY_LIST, simpleListener.log);
}
+ @Test
public void testPropertyChange_NullPropertyName() {
Object source = new Object();
String propertyName = null;
@@ -84,6 +91,7 @@
simpleListener.log);
}
+ @Test
public void testPropertyChange_NullPropertyName_IgnoreOldAndNewValues() {
Object source = new Object();
String propertyName = null;
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/BeanValuePropertyTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/BeanValuePropertyTest.java
index 37654da..85826be 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/BeanValuePropertyTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/BeanValuePropertyTest.java
@@ -12,6 +12,8 @@
package org.eclipse.core.tests.internal.databinding.beans;
+import static org.junit.Assert.assertEquals;
+
import org.eclipse.core.databinding.beans.BeanProperties;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.core.databinding.observable.value.IValueChangeListener;
@@ -20,12 +22,14 @@
import org.eclipse.core.tests.internal.databinding.beans.BeanPropertyListenerSupportTest.GenericListenerBean;
import org.eclipse.jface.databinding.conformance.util.CurrentRealm;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Test;
/**
* @since 3.2
*
*/
public class BeanValuePropertyTest extends AbstractDefaultRealmTestCase {
+ @Test
public void testChangeListenerIsOnlyNotifiedWhenWatchedPropertyChanges()
throws Exception {
GenericListenerBean bean = new GenericListenerBean();
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/JavaBeanObservableArrayBasedListTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/JavaBeanObservableArrayBasedListTest.java
index f649866..27798af 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/JavaBeanObservableArrayBasedListTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/JavaBeanObservableArrayBasedListTest.java
@@ -13,6 +13,11 @@
package org.eclipse.core.tests.internal.databinding.beans;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyDescriptor;
@@ -22,9 +27,6 @@
import java.util.Collections;
import java.util.List;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.eclipse.core.databinding.beans.BeanProperties;
import org.eclipse.core.databinding.beans.BeansObservables;
import org.eclipse.core.databinding.beans.IBeanObservable;
@@ -42,6 +44,10 @@
import org.eclipse.jface.databinding.swt.DisplayRealm;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
import org.eclipse.swt.widgets.Display;
+import org.junit.Before;
+import org.junit.Test;
+
+import junit.framework.TestSuite;
/**
* @since 1.1
@@ -58,7 +64,8 @@
private String propertyName;
@Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
propertyName = "array";
@@ -71,14 +78,17 @@
beanObservable = (IBeanObservable) list;
}
+ @Test
public void testGetObserved() throws Exception {
assertSame(bean, beanObservable.getObserved());
}
+ @Test
public void testGetPropertyDescriptor() throws Exception {
assertEquals(propertyDescriptor, beanObservable.getPropertyDescriptor());
}
+ @Test
public void testRegistersListenerAfterFirstListenerIsAdded()
throws Exception {
assertFalse(bean.changeSupport.hasListeners(propertyName));
@@ -86,6 +96,7 @@
assertTrue(bean.changeSupport.hasListeners(propertyName));
}
+ @Test
public void testRemovesListenerAfterLastListenerIsRemoved()
throws Exception {
ListChangeEventTracker listener = new ListChangeEventTracker();
@@ -96,6 +107,7 @@
assertFalse(bean.changeSupport.hasListeners(propertyName));
}
+ @Test
public void testFiresListChangeEvents() throws Exception {
ListChangeEventTracker listener = new ListChangeEventTracker();
list.addListChangeListener(listener);
@@ -105,6 +117,7 @@
assertEquals(1, listener.count);
}
+ @Test
public void testAddAddsElement() throws Exception {
int count = list.size();
String element = "1";
@@ -115,6 +128,7 @@
assertEquals(element, bean.getArray()[count]);
}
+ @Test
public void testAddListChangeEvent() throws Exception {
ListChangeEventTracker listener = new ListChangeEventTracker();
list.addListChangeListener(listener);
@@ -132,6 +146,7 @@
.singletonList("1"));
}
+ @Test
public void testAdd_FiresPropertyChangeEvent() throws Exception {
assertPropertyChangeEvent(bean, new Runnable() {
@Override
@@ -141,6 +156,7 @@
});
}
+ @Test
public void testAddWithIndex() throws Exception {
String element = "1";
assertEquals(0, list.size());
@@ -149,6 +165,7 @@
assertEquals(element, bean.getArray()[0]);
}
+ @Test
public void testAddAtIndexListChangeEvent() throws Exception {
String element = "1";
assertEquals(0, list.size());
@@ -163,6 +180,7 @@
.singletonList("1"));
}
+ @Test
public void testAddAtIndexPropertyChangeEvent() throws Exception {
assertPropertyChangeEvent(bean, new Runnable() {
@Override
@@ -172,6 +190,7 @@
});
}
+ @Test
public void testRemove() throws Exception {
String element = "1";
list.add(element);
@@ -181,6 +200,7 @@
assertEquals(0, bean.getArray().length);
}
+ @Test
public void testRemoveListChangeEvent() throws Exception {
String element = "1";
list.add(element);
@@ -199,6 +219,7 @@
Collections.EMPTY_LIST);
}
+ @Test
public void testRemovePropertyChangeEvent() throws Exception {
list.add("0");
@@ -210,6 +231,7 @@
});
}
+ @Test
public void testRemoveAtIndex() throws Exception {
String element = "1";
list.add(element);
@@ -220,6 +242,7 @@
assertEquals(0, bean.getArray().length);
}
+ @Test
public void testRemoveAtIndexListChangeEvent() throws Exception {
String element = "1";
list.add(element);
@@ -238,6 +261,7 @@
Collections.EMPTY_LIST);
}
+ @Test
public void testRemoveAtIndexPropertyChangeEvent() throws Exception {
list.add("0");
assertPropertyChangeEvent(bean, new Runnable() {
@@ -248,6 +272,7 @@
});
}
+ @Test
public void testAddAll() throws Exception {
Collection elements = Arrays.asList(new String[] { "1", "2" });
assertEquals(0, list.size());
@@ -257,6 +282,7 @@
assertEquals(2, bean.getArray().length);
}
+ @Test
public void testAddAllListChangEvent() throws Exception {
List elements = Arrays.asList(new String[] { "1", "2" });
assertEquals(0, list.size());
@@ -275,6 +301,7 @@
.asList(new String[] { "1", "2" }));
}
+ @Test
public void testAddAllPropertyChangeEvent() throws Exception {
assertPropertyChangeEvent(bean, new Runnable() {
@Override
@@ -284,6 +311,7 @@
});
}
+ @Test
public void testAddAllAtIndex() throws Exception {
List elements = Arrays.asList(new String[] { "1", "2" });
list.addAll(elements);
@@ -297,6 +325,7 @@
assertEquals(elements.get(1), bean.getArray()[1]);
}
+ @Test
public void testAddAllAtIndexListChangeEvent() throws Exception {
List elements = Arrays.asList(new String[] { "1", "2" });
list.addAll(elements);
@@ -316,6 +345,7 @@
.asList(new Object[] { "1", "2", "1", "2" }));
}
+ @Test
public void testAddAllAtIndexPropertyChangeEvent() throws Exception {
assertPropertyChangeEvent(bean, new Runnable() {
@Override
@@ -325,6 +355,7 @@
});
}
+ @Test
public void testRemoveAll() throws Exception {
list.addAll(Arrays.asList(new String[] { "1", "2", "3", "4" }));
assertEquals(4, bean.getArray().length);
@@ -336,6 +367,7 @@
assertEquals("3", bean.getArray()[1]);
}
+ @Test
public void testRemoveAllListChangeEvent() throws Exception {
List elements = Arrays.asList(new String[] { "1", "2" });
list.addAll(elements);
@@ -355,6 +387,7 @@
Collections.EMPTY_LIST);
}
+ @Test
public void testRemoveAllPropertyChangeEvent() throws Exception {
list.add("0");
assertPropertyChangeEvent(bean, new Runnable() {
@@ -365,6 +398,7 @@
});
}
+ @Test
public void testRetainAll() throws Exception {
List elements = Arrays.asList(new String[] { "0", "1", "2", "3" });
list.addAll(elements);
@@ -378,6 +412,7 @@
assertEquals(elements.get(1), bean.getArray()[1]);
}
+ @Test
public void testRetainAllListChangeEvent() throws Exception {
List elements = Arrays.asList(new String[] { "0", "1", "2", "3" });
list.addAll(elements);
@@ -397,6 +432,7 @@
.asList(new Object[] { "0", "1" }));
}
+ @Test
public void testRetainAllPropertyChangeEvent() throws Exception {
list.addAll(Arrays.asList(new String[] { "0", "1" }));
@@ -408,6 +444,7 @@
});
}
+ @Test
public void testSet() throws Exception {
String oldElement = "old";
String newElement = "new";
@@ -419,6 +456,7 @@
assertEquals(newElement, bean.getArray()[0]);
}
+ @Test
public void testMove() throws Exception {
String element0 = "element0";
String element1 = "element1";
@@ -436,6 +474,7 @@
assertEquals(element0, bean.getArray()[1]);
}
+ @Test
public void testSetListChangeEvent() throws Exception {
String oldElement = "old";
String newElement = "new";
@@ -455,6 +494,7 @@
Collections.singletonList(newElement));
}
+ @Test
public void testSetPropertyChangeEvent() throws Exception {
list.add("0");
assertPropertyChangeEvent(bean, new Runnable() {
@@ -465,6 +505,7 @@
});
}
+ @Test
public void testListChangeEventFiresWhenNewListIsSet() throws Exception {
Bean[] elements = new Bean[] { new Bean(), new Bean() };
@@ -476,6 +517,7 @@
assertEquals(1, listener.count);
}
+ @Test
public void testSetBeanProperty_CorrectForNullOldAndNewValues() {
// The java bean spec allows the old and new values in a
// PropertyChangeEvent to be null, which indicates that an unknown
@@ -499,6 +541,7 @@
assertEquals(Collections.singletonList("new"), list);
}
+ @Test
public void testModifyObservableList_FiresListChange() {
Bean bean = new Bean(new Object[] { "old" });
IObservableList observable = BeansObservables
@@ -513,6 +556,7 @@
Collections.singletonList("new"));
}
+ @Test
public void testSetBeanPropertyOutsideRealm_FiresEventInsideRealm() {
Bean bean = new Bean(new Object[0]);
CurrentRealm realm = new CurrentRealm(true);
@@ -571,12 +615,8 @@
}
}
- public static Test suite() {
- TestSuite suite = new TestSuite(
- JavaBeanObservableArrayBasedListTest.class.getName());
- suite.addTestSuite(JavaBeanObservableArrayBasedListTest.class);
+ public static void addConformanceTest(TestSuite suite) {
suite.addTest(MutableObservableListContractTest.suite(new Delegate()));
- return suite;
}
static class Delegate extends AbstractObservableCollectionContractDelegate {
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/JavaBeanObservableArrayBasedSetTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/JavaBeanObservableArrayBasedSetTest.java
index 3791b54..36a3684 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/JavaBeanObservableArrayBasedSetTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/JavaBeanObservableArrayBasedSetTest.java
@@ -13,6 +13,11 @@
package org.eclipse.core.tests.internal.databinding.beans;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyDescriptor;
@@ -22,9 +27,6 @@
import java.util.HashSet;
import java.util.Set;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.eclipse.core.databinding.beans.BeanProperties;
import org.eclipse.core.databinding.beans.BeansObservables;
import org.eclipse.core.databinding.beans.IBeanObservable;
@@ -42,6 +44,10 @@
import org.eclipse.jface.databinding.swt.DisplayRealm;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
import org.eclipse.swt.widgets.Display;
+import org.junit.Before;
+import org.junit.Test;
+
+import junit.framework.TestSuite;
/**
* @since 1.1
@@ -58,7 +64,8 @@
private String propertyName;
@Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
propertyName = "array";
@@ -71,14 +78,17 @@
beanObservable = (IBeanObservable) set;
}
+ @Test
public void testGetObserved() throws Exception {
assertEquals(bean, beanObservable.getObserved());
}
+ @Test
public void testGetPropertyDescriptor() throws Exception {
assertEquals(propertyDescriptor, beanObservable.getPropertyDescriptor());
}
+ @Test
public void testRegistersListenerAfterFirstListenerIsAdded()
throws Exception {
assertFalse(bean.changeSupport.hasListeners(propertyName));
@@ -86,6 +96,7 @@
assertTrue(bean.changeSupport.hasListeners(propertyName));
}
+ @Test
public void testRemovesListenerAfterLastListenerIsRemoved()
throws Exception {
SetChangeEventTracker listener = SetChangeEventTracker.observe(set);
@@ -95,6 +106,7 @@
assertFalse(bean.changeSupport.hasListeners(propertyName));
}
+ @Test
public void testSetBeanProperty_FiresSetChangeEvents() throws Exception {
SetChangeEventTracker listener = SetChangeEventTracker.observe(set);
@@ -103,6 +115,7 @@
assertEquals(1, listener.count);
}
+ @Test
public void testAdd_AddsElement() throws Exception {
assertEquals(0, set.size());
@@ -113,6 +126,7 @@
assertEquals(element, bean.getArray()[0]);
}
+ @Test
public void testAdd_SetChangeEvent() throws Exception {
SetChangeEventTracker listener = SetChangeEventTracker.observe(set);
assertEquals(0, listener.count);
@@ -128,6 +142,7 @@
assertEquals(Collections.EMPTY_SET, event.diff.getRemovals());
}
+ @Test
public void testAdd_FiresPropertyChangeEvent() throws Exception {
assertPropertyChangeEvent(bean, new Runnable() {
@Override
@@ -137,6 +152,7 @@
});
}
+ @Test
public void testRemove() throws Exception {
String element = "1";
set.add(element);
@@ -146,6 +162,7 @@
assertEquals(0, bean.getArray().length);
}
+ @Test
public void testRemove_SetChangeEvent() throws Exception {
String element = "1";
set.add(element);
@@ -163,6 +180,7 @@
assertEquals(Collections.EMPTY_SET, event.diff.getAdditions());
}
+ @Test
public void testRemovePropertyChangeEvent() throws Exception {
set.add("0");
@@ -174,6 +192,7 @@
});
}
+ @Test
public void testAddAll() throws Exception {
Collection elements = Arrays.asList(new String[] { "1", "2" });
assertEquals(0, set.size());
@@ -183,6 +202,7 @@
assertEquals(2, bean.getArray().length);
}
+ @Test
public void testAddAll_SetChangeEvent() throws Exception {
Collection elements = Arrays.asList(new String[] { "1", "2" });
assertEquals(0, set.size());
@@ -200,6 +220,7 @@
assertEquals(Collections.EMPTY_SET, event.diff.getRemovals());
}
+ @Test
public void testAddAllPropertyChangeEvent() throws Exception {
assertPropertyChangeEvent(bean, new Runnable() {
@Override
@@ -209,6 +230,7 @@
});
}
+ @Test
public void testRemoveAll() throws Exception {
Collection elements = Arrays.asList(new String[] { "1", "2" });
set.addAll(elements);
@@ -219,6 +241,7 @@
assertEquals(0, bean.getArray().length);
}
+ @Test
public void testRemoveAll_SetChangeEvent() throws Exception {
Collection elements = Arrays.asList(new String[] { "1", "2" });
set.addAll(elements);
@@ -234,6 +257,7 @@
assertEquals(new HashSet(elements), event.diff.getRemovals());
}
+ @Test
public void testRemoveAllPropertyChangeEvent() throws Exception {
set.add("0");
assertPropertyChangeEvent(bean, new Runnable() {
@@ -244,6 +268,7 @@
});
}
+ @Test
public void testRetainAll() throws Exception {
set.addAll(Arrays.asList(new String[] { "0", "1", "2", "3" }));
@@ -255,6 +280,7 @@
assertTrue(set.containsAll(Arrays.asList(new String[] { "1", "0" })));
}
+ @Test
public void testRetainAll_SetChangeEvent() throws Exception {
set.addAll(Arrays.asList(new String[] { "0", "1", "2", "3" }));
@@ -271,6 +297,7 @@
event.diff.getRemovals());
}
+ @Test
public void testRetainAllPropertyChangeEvent() throws Exception {
set.addAll(Arrays.asList(new String[] { "0", "1" }));
@@ -282,6 +309,7 @@
});
}
+ @Test
public void testSetChangeEventFiresWhenNewSetIsSet() throws Exception {
Bean[] elements = new Bean[] { new Bean(), new Bean() };
@@ -292,6 +320,7 @@
assertEquals(1, listener.count);
}
+ @Test
public void testSetBeanProperty_CorrectForNullOldAndNewValues() {
// The java bean spec allows the old and new values in a
// PropertyChangeEvent to be null, which indicates that an unknown
@@ -314,6 +343,7 @@
.getAdditions());
}
+ @Test
public void testModifyObservableSet_FiresSetChange() {
Bean bean = new Bean(new Object[] {});
IObservableSet observable = BeansObservables.observeSet(bean, "array");
@@ -327,6 +357,7 @@
.singleton("new"));
}
+ @Test
public void testSetBeanPropertyOutsideRealm_FiresEventInsideRealm() {
Bean bean = new Bean(new Object[0]);
CurrentRealm realm = new CurrentRealm(true);
@@ -385,12 +416,8 @@
}
}
- public static Test suite() {
- TestSuite suite = new TestSuite(
- JavaBeanObservableArrayBasedSetTest.class.getName());
- suite.addTestSuite(JavaBeanObservableArrayBasedSetTest.class);
+ public static void addConformanceTest(TestSuite suite) {
suite.addTest(MutableObservableSetContractTest.suite(new Delegate()));
- return suite;
}
static class Delegate extends AbstractObservableCollectionContractDelegate {
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/JavaBeanObservableListTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/JavaBeanObservableListTest.java
index 8f69230..08a2e52 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/JavaBeanObservableListTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/JavaBeanObservableListTest.java
@@ -13,6 +13,11 @@
package org.eclipse.core.tests.internal.databinding.beans;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyDescriptor;
@@ -22,9 +27,6 @@
import java.util.Collections;
import java.util.List;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.eclipse.core.databinding.beans.BeanProperties;
import org.eclipse.core.databinding.beans.BeansObservables;
import org.eclipse.core.databinding.beans.IBeanObservable;
@@ -44,6 +46,10 @@
import org.eclipse.jface.databinding.swt.DisplayRealm;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
import org.eclipse.swt.widgets.Display;
+import org.junit.Before;
+import org.junit.Test;
+
+import junit.framework.TestSuite;
/**
* @since 1.1
@@ -59,7 +65,8 @@
private String propertyName;
@Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
propertyName = "list";
@@ -72,14 +79,17 @@
beanObservable = (IBeanObservable) list;
}
+ @Test
public void testGetObserved() throws Exception {
assertEquals(bean, beanObservable.getObserved());
}
+ @Test
public void testGetPropertyDescriptor() throws Exception {
assertEquals(propertyDescriptor, beanObservable.getPropertyDescriptor());
}
+ @Test
public void testRegistersListenerAfterFirstListenerIsAdded()
throws Exception {
assertFalse(bean.changeSupport.hasListeners(propertyName));
@@ -87,6 +97,7 @@
assertTrue(bean.changeSupport.hasListeners(propertyName));
}
+ @Test
public void testRemovesListenerAfterLastListenerIsRemoved()
throws Exception {
ListChangeEventTracker listener = new ListChangeEventTracker();
@@ -97,6 +108,7 @@
assertFalse(bean.changeSupport.hasListeners(propertyName));
}
+ @Test
public void testFiresListChangeEvents() throws Exception {
ListChangeEventTracker listener = new ListChangeEventTracker();
list.addListChangeListener(listener);
@@ -106,6 +118,7 @@
assertEquals(1, listener.count);
}
+ @Test
public void testAddAddsElement() throws Exception {
int count = list.size();
String element = "1";
@@ -116,6 +129,7 @@
assertEquals(element, bean.getList().get(count));
}
+ @Test
public void testAddListChangeEvent() throws Exception {
ListChangeEventTracker listener = new ListChangeEventTracker();
list.addListChangeListener(listener);
@@ -133,6 +147,7 @@
.singletonList("1"));
}
+ @Test
public void testAddFiresPropertyChangeEvent() throws Exception {
assertPropertyChangeEvent(bean, new Runnable() {
@Override
@@ -142,6 +157,7 @@
});
}
+ @Test
public void testAddAtIndex() throws Exception {
String element = "1";
assertEquals(0, list.size());
@@ -150,6 +166,7 @@
assertEquals(element, bean.getList().get(0));
}
+ @Test
public void testAddAtIndexListChangeEvent() throws Exception {
String element = "1";
assertEquals(0, list.size());
@@ -164,6 +181,7 @@
.singletonList("1"));
}
+ @Test
public void testAddAtIndexPropertyChangeEvent() throws Exception {
assertPropertyChangeEvent(bean, new Runnable() {
@Override
@@ -173,6 +191,7 @@
});
}
+ @Test
public void testClear() throws Exception {
String element = "1";
list.add(element);
@@ -187,6 +206,7 @@
assertEquals(0, bean.getList().size());
}
+ @Test
public void testRemove() throws Exception {
String element = "1";
list.add(element);
@@ -196,6 +216,7 @@
assertEquals(0, bean.getList().size());
}
+ @Test
public void testRemoveListChangeEvent() throws Exception {
String element = "1";
list.add(element);
@@ -214,6 +235,7 @@
Collections.EMPTY_LIST);
}
+ @Test
public void testRemovePropertyChangeEvent() throws Exception {
list.add("0");
@@ -225,6 +247,7 @@
});
}
+ @Test
public void testRemoveAtIndex() throws Exception {
String element = "1";
list.add(element);
@@ -235,6 +258,7 @@
assertEquals(0, bean.getList().size());
}
+ @Test
public void testRemoveAtIndexListChangeEvent() throws Exception {
String element = "1";
list.add(element);
@@ -253,6 +277,7 @@
Collections.EMPTY_LIST);
}
+ @Test
public void testRemoveAtIndexPropertyChangeEvent() throws Exception {
list.add("0");
assertPropertyChangeEvent(bean, new Runnable() {
@@ -263,6 +288,7 @@
});
}
+ @Test
public void testAddAll() throws Exception {
Collection elements = Arrays.asList(new String[] { "1", "2" });
assertEquals(0, list.size());
@@ -272,6 +298,7 @@
assertEquals(2, bean.getList().size());
}
+ @Test
public void testAddAllListChangEvent() throws Exception {
List elements = Arrays.asList(new String[] { "1", "2" });
assertEquals(0, list.size());
@@ -290,6 +317,7 @@
.asList(new String[] { "1", "2" }));
}
+ @Test
public void testAddAllPropertyChangeEvent() throws Exception {
assertPropertyChangeEvent(bean, new Runnable() {
@Override
@@ -299,6 +327,7 @@
});
}
+ @Test
public void testAddAllAtIndex() throws Exception {
List elements = Arrays.asList(new String[] { "1", "2" });
list.addAll(elements);
@@ -312,6 +341,7 @@
assertEquals(elements.get(1), bean.getList().get(1));
}
+ @Test
public void testAddAllAtIndexListChangeEvent() throws Exception {
List elements = Arrays.asList(new String[] { "1", "2" });
list.addAll(elements);
@@ -331,6 +361,7 @@
.asList(new Object[] { "1", "2", "1", "2" }));
}
+ @Test
public void testAddAllAtIndexPropertyChangeEvent() throws Exception {
assertPropertyChangeEvent(bean, new Runnable() {
@Override
@@ -340,6 +371,7 @@
});
}
+ @Test
public void testRemoveAll() throws Exception {
list.addAll(Arrays.asList(new String[] { "1", "2", "3", "4" }));
assertEquals(4, bean.getList().size());
@@ -351,6 +383,7 @@
assertEquals("3", bean.getList().get(1));
}
+ @Test
public void testRemoveAllListChangeEvent() throws Exception {
List elements = Arrays.asList(new String[] { "1", "2" });
list.addAll(elements);
@@ -371,6 +404,7 @@
Collections.EMPTY_LIST);
}
+ @Test
public void testRemoveAllPropertyChangeEvent() throws Exception {
list.add("0");
assertPropertyChangeEvent(bean, new Runnable() {
@@ -381,6 +415,7 @@
});
}
+ @Test
public void testRetailAll() throws Exception {
List elements = Arrays.asList(new String[] { "0", "1", "2", "3" });
list.addAll(elements);
@@ -394,6 +429,7 @@
assertEquals(elements.get(1), bean.getList().get(1));
}
+ @Test
public void testRetainAllListChangeEvent() throws Exception {
List elements = Arrays.asList(new String[] { "0", "1", "2", "3" });
list.addAll(elements);
@@ -413,6 +449,7 @@
.asList(new Object[] { "0", "1" }));
}
+ @Test
public void testRetainAllPropertyChangeEvent() throws Exception {
list.addAll(Arrays.asList(new String[] { "0", "1" }));
@@ -424,6 +461,7 @@
});
}
+ @Test
public void testSet() throws Exception {
String oldElement = "old";
String newElement = "new";
@@ -435,6 +473,7 @@
assertEquals(newElement, bean.getList().get(0));
}
+ @Test
public void testMove() throws Exception {
String element0 = "element0";
String element1 = "element1";
@@ -452,6 +491,7 @@
assertEquals(element0, bean.getList().get(1));
}
+ @Test
public void testSetListChangeEvent() throws Exception {
String oldElement = "old";
String newElement = "new";
@@ -470,6 +510,7 @@
Collections.singletonList(newElement));
}
+ @Test
public void testSetPropertyChangeEvent() throws Exception {
list.add("0");
assertPropertyChangeEvent(bean, new Runnable() {
@@ -480,6 +521,7 @@
});
}
+ @Test
public void testListChangeEventFiresWhenNewListIsSet() throws Exception {
List elements = Arrays.asList(new String[] { "1", "2" });
@@ -491,6 +533,7 @@
assertEquals(1, listener.count);
}
+ @Test
public void testConstructor_RegistersListener() throws Exception {
Bean bean = new Bean();
IObservableList observable = BeansObservables.observeList(Realm
@@ -501,6 +544,7 @@
assertTrue(bean.hasListeners("list"));
}
+ @Test
public void testConstructor_SkipsRegisterListener() throws Exception {
Bean bean = new Bean();
IObservableList observable = PojoObservables.observeList(Realm
@@ -511,6 +555,7 @@
assertFalse(bean.hasListeners("list"));
}
+ @Test
public void testSetBeanProperty_CorrectForNullOldAndNewValues() {
// The java bean spec allows the old and new values in a
// PropertyChangeEvent to be null, which indicates that an unknown
@@ -535,6 +580,7 @@
assertEquals(Collections.singletonList("new"), list);
}
+ @Test
public void testModifyObservableList_FiresListChange() {
Bean bean = new Bean(new ArrayList());
IObservableList observable = BeansObservables.observeList(bean, "list");
@@ -549,6 +595,7 @@
.singletonList(element));
}
+ @Test
public void testSetBeanPropertyOutsideRealm_FiresEventInsideRealm() {
Bean bean = new Bean(Collections.EMPTY_LIST);
CurrentRealm realm = new CurrentRealm(true);
@@ -571,6 +618,7 @@
* Makes sure that the list set on the Bean model after changing the
* observable list is modifiable (see bugs 285307 and 301774).
*/
+ @Test
public void testUpdatedBeanListIsModifiable() {
Bean bean = new Bean(new ArrayList());
IObservableList observable = BeansObservables.observeList(bean, "list");
@@ -583,6 +631,7 @@
* Makes sure that the list set on the Pojo model after changing the
* observable list is modifiable (see bugs 285307 and 301774).
*/
+ @Test
public void testUpdatedPojoListIsModifiable() {
Bean bean = new Bean(new ArrayList());
IObservableList observable = PojoObservables.observeList(bean, "list");
@@ -629,12 +678,8 @@
}
}
- public static Test suite() {
- TestSuite suite = new TestSuite(JavaBeanObservableListTest.class
- .getName());
- suite.addTestSuite(JavaBeanObservableListTest.class);
+ public static void addConformanceTest(TestSuite suite) {
suite.addTest(MutableObservableListContractTest.suite(new Delegate()));
- return suite;
}
static class Delegate extends AbstractObservableCollectionContractDelegate {
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/JavaBeanObservableMapTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/JavaBeanObservableMapTest.java
index c6215c7..b8206dd 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/JavaBeanObservableMapTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/JavaBeanObservableMapTest.java
@@ -13,15 +13,16 @@
package org.eclipse.core.tests.internal.databinding.beans;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import java.beans.PropertyDescriptor;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.eclipse.core.databinding.beans.BeanProperties;
import org.eclipse.core.databinding.beans.BeansObservables;
import org.eclipse.core.databinding.beans.IBeanObservable;
@@ -36,6 +37,8 @@
import org.eclipse.jface.databinding.conformance.util.CurrentRealm;
import org.eclipse.jface.databinding.conformance.util.MapChangeEventTracker;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Before;
+import org.junit.Test;
/**
* @since 3.2
@@ -54,7 +57,8 @@
private IBeanObservable beanObservable;
@Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
ThreadRealm realm = new ThreadRealm();
@@ -73,18 +77,21 @@
beanObservable = (IBeanObservable) map;
}
+ @Test
public void testGetValue() throws Exception {
assertEquals(
"The 'value' from the map should be the value of the property of the model.",
model1.getValue(), map.get(model1));
}
+ @Test
public void testGetValue_KeyOutOfDomain() {
Bean model3 = new Bean("3");
assertFalse(map.containsKey(model3));
assertFalse(model3.getValue().equals(map.get(model3)));
}
+ @Test
public void testSetValueNotifications() throws Exception {
String oldValue = model1.getValue();
String newValue = model1.getValue() + model1.getValue();
@@ -101,6 +108,7 @@
assertFalse(listener.event.diff.getRemovedKeys().contains(model1));
}
+ @Test
public void testPutValue() throws Exception {
String oldValue = model1.getValue();
String newValue = model1.getValue() + model1.getValue();
@@ -118,6 +126,7 @@
assertFalse(listener.event.diff.getRemovedKeys().contains(model1));
}
+ @Test
public void testAddKey() throws Exception {
MapChangeEventTracker listener = new MapChangeEventTracker();
map.addMapChangeListener(listener);
@@ -136,6 +145,7 @@
assertEquals(3, map.size());
}
+ @Test
public void testRemoveKey() throws Exception {
MapChangeEventTracker listener = new MapChangeEventTracker();
map.addMapChangeListener(listener);
@@ -149,14 +159,17 @@
assertEquals(1, map.size());
}
+ @Test
public void testGetObserved() throws Exception {
assertEquals(set, beanObservable.getObserved());
}
+ @Test
public void testGetPropertyDescriptor() throws Exception {
assertEquals(propertyDescriptor, beanObservable.getPropertyDescriptor());
}
+ @Test
public void testConstructor_SkipRegisterListeners() throws Exception {
Realm realm = new CurrentRealm(true);
WritableSet set = new WritableSet(realm);
@@ -171,6 +184,7 @@
assertFalse(bean.hasListeners("value"));
}
+ @Test
public void testConstructor_RegistersListeners() throws Exception {
Realm realm = new CurrentRealm(true);
WritableSet set = new WritableSet(realm);
@@ -185,6 +199,7 @@
assertTrue(bean.hasListeners("value"));
}
+ @Test
public void testSetBeanProperty_CorrectForNullOldAndNewValues() {
// The java bean spec allows the old and new values in a
// PropertyChangeEvent to be null, which indicates that an unknown
@@ -216,6 +231,7 @@
assertEquals("new", tracker.event.diff.getNewValue(bean));
}
+ @Test
public void testModifyObservableMap_FiresMapChange() {
Bean bean = new Bean(Collections.singletonMap("key", "oldValue"));
IObservableMap observable = BeansObservables.observeMap(bean, "map");
@@ -229,6 +245,7 @@
"oldValue"), Collections.singletonMap("key", "newValue"));
}
+ @Test
public void testSetBeanPropertyOutsideRealm_FiresEventInsideRealm() {
Bean bean = new Bean(Collections.EMPTY_MAP);
CurrentRealm realm = new CurrentRealm(true);
@@ -254,11 +271,4 @@
assertEquals("applying diff to list did not produce expected result",
newMap, oldMap);
}
-
- public static Test suite() {
- TestSuite suite = new TestSuite(JavaBeanObservableMapTest.class
- .getName());
- suite.addTestSuite(JavaBeanObservableMapTest.class);
- return suite;
- }
}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/JavaBeanObservableSetTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/JavaBeanObservableSetTest.java
index e5c5602..7faa68d 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/JavaBeanObservableSetTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/JavaBeanObservableSetTest.java
@@ -13,6 +13,10 @@
package org.eclipse.core.tests.internal.databinding.beans;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import java.beans.PropertyDescriptor;
import java.util.ArrayList;
import java.util.Arrays;
@@ -20,9 +24,6 @@
import java.util.HashSet;
import java.util.Set;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.eclipse.core.databinding.beans.BeanProperties;
import org.eclipse.core.databinding.beans.BeansObservables;
import org.eclipse.core.databinding.beans.IBeanObservable;
@@ -41,6 +42,10 @@
import org.eclipse.jface.databinding.swt.DisplayRealm;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
import org.eclipse.swt.widgets.Display;
+import org.junit.Before;
+import org.junit.Test;
+
+import junit.framework.TestSuite;
/**
* @since 3.3
@@ -54,7 +59,8 @@
private SetChangeEventTracker listener;
@Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
bean = new Bean();
@@ -69,18 +75,22 @@
listener = new SetChangeEventTracker();
}
+ @Test
public void testGetObserved() throws Exception {
assertEquals(bean, beanObservable.getObserved());
}
+ @Test
public void testGetPropertyDescriptor() throws Exception {
assertEquals(propertyDescriptor, beanObservable.getPropertyDescriptor());
}
+ @Test
public void testGetElementType() throws Exception {
assertEquals(Bean.class, observableSet.getElementType());
}
+ @Test
public void testRegistersListenerAfterFirstListenerIsAdded()
throws Exception {
assertFalse(bean.changeSupport.hasListeners(propertyName));
@@ -88,6 +98,7 @@
assertTrue(bean.changeSupport.hasListeners(propertyName));
}
+ @Test
public void testRemovesListenerAfterLastListenerIsRemoved()
throws Exception {
observableSet.addSetChangeListener(listener);
@@ -97,6 +108,7 @@
assertFalse(bean.changeSupport.hasListeners(propertyName));
}
+ @Test
public void testFiresChangeEvents() throws Exception {
observableSet.addSetChangeListener(listener);
assertEquals(0, listener.count);
@@ -104,6 +116,7 @@
assertEquals(1, listener.count);
}
+ @Test
public void testConstructor_RegisterListeners() throws Exception {
bean = new Bean();
observableSet = BeansObservables.observeSet(new CurrentRealm(true),
@@ -113,6 +126,7 @@
assertTrue(bean.hasListeners(propertyName));
}
+ @Test
public void testConstructor_SkipsRegisterListeners() throws Exception {
bean = new Bean();
@@ -123,6 +137,7 @@
assertFalse(bean.hasListeners(propertyName));
}
+ @Test
public void testSetBeanProperty_CorrectForNullOldAndNewValues() {
// The java bean spec allows the old and new values in a
// PropertyChangeEvent to be null, which indicates that an unknown
@@ -145,6 +160,7 @@
.getAdditions());
}
+ @Test
public void testModifyObservableSet_FiresSetChange() {
Bean bean = new Bean(new HashSet());
IObservableSet observable = BeansObservables.observeSet(bean, "set");
@@ -159,6 +175,7 @@
.singleton(element));
}
+ @Test
public void testSetBeanPropertyOutsideRealm_FiresEventInsideRealm() {
Bean bean = new Bean(Collections.EMPTY_SET);
CurrentRealm realm = new CurrentRealm(true);
@@ -181,6 +198,7 @@
* Makes sure that the set set on the Bean model after changing the
* observable set is modifiable (see bugs 285307 and 301774).
*/
+ @Test
public void testUpdatedBeanSetIsModifiable() {
Bean bean = new Bean(new ArrayList());
IObservableSet observable = BeansObservables.observeSet(bean, "set");
@@ -193,6 +211,7 @@
* Makes sure that the set set on the Pojo model after changing the
* observable set is modifiable (see bugs 285307 and 301774).
*/
+ @Test
public void testUpdatedPojoSetIsModifiable() {
Bean bean = new Bean(new ArrayList());
IObservableSet observable = PojoObservables.observeSet(bean, "set");
@@ -209,12 +228,8 @@
newSet, oldSet);
}
- public static Test suite() {
- TestSuite suite = new TestSuite(JavaBeanObservableSetTest.class
- .getName());
- suite.addTestSuite(JavaBeanObservableSetTest.class);
+ public static void addConformanceTest(TestSuite suite) {
suite.addTest(MutableObservableSetContractTest.suite(new Delegate()));
- return suite;
}
private static class Delegate extends
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/JavaBeanObservableValueTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/JavaBeanObservableValueTest.java
index 4eab5c2..becf9c5 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/JavaBeanObservableValueTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/JavaBeanObservableValueTest.java
@@ -14,10 +14,12 @@
package org.eclipse.core.tests.internal.databinding.beans;
-import java.beans.PropertyDescriptor;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import java.beans.PropertyDescriptor;
import org.eclipse.core.databinding.beans.BeanProperties;
import org.eclipse.core.databinding.beans.BeansObservables;
@@ -38,6 +40,10 @@
import org.eclipse.jface.databinding.conformance.util.ValueChangeEventTracker;
import org.eclipse.jface.examples.databinding.model.SimplePerson;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Before;
+import org.junit.Test;
+
+import junit.framework.TestSuite;
/**
* @since 3.2
@@ -50,7 +56,8 @@
private String propertyName;
@Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
bean = new Bean();
@@ -61,14 +68,17 @@
beanObservable = (IBeanObservable) observableValue;
}
+ @Test
public void testGetObserved() throws Exception {
assertEquals(bean, beanObservable.getObserved());
}
+ @Test
public void testGetPropertyDescriptor() throws Exception {
assertEquals(propertyDescriptor, beanObservable.getPropertyDescriptor());
}
+ @Test
public void testSetValueThrowsExceptionThrownByBean() throws Exception {
ThrowsSetException temp = new ThrowsSetException();
IObservableValue observable = BeansObservables.observeValue(temp,
@@ -82,6 +92,7 @@
}
}
+ @Test
public void testGetValueThrowsExceptionThrownByBean() throws Exception {
ThrowsGetException temp = new ThrowsGetException();
IObservableValue observable = BeansObservables.observeValue(temp,
@@ -95,6 +106,7 @@
}
}
+ @Test
public void testBug198519() {
final SimplePerson person = new SimplePerson();
final ComputedValue cv = new ComputedValue() {
@@ -115,6 +127,7 @@
person.setName("foo");
}
+ @Test
public void testConstructor_RegistersListeners() throws Exception {
IObservableValue observable = BeansObservables.observeValue(bean,
propertyName);
@@ -123,6 +136,7 @@
assertTrue(bean.hasListeners(propertyName));
}
+ @Test
public void testConstructor_SkipRegisterListeners() throws Exception {
IObservableValue observable = PojoObservables.observeValue(bean,
propertyName);
@@ -131,6 +145,7 @@
assertFalse(bean.hasListeners(propertyName));
}
+ @Test
public void testSetBeanProperty_CorrectForNullOldAndNewValues() {
// The java bean spec allows the old and new values in a
// PropertyChangeEvent to
@@ -152,6 +167,7 @@
assertEquals("new", tracker.event.diff.getNewValue());
}
+ @Test
public void testSetBeanPropertyOutsideRealm_FiresEventInsideRealm() {
Bean bean = new Bean("old");
CurrentRealm realm = new CurrentRealm(true);
@@ -169,12 +185,8 @@
assertEquals(Diffs.createValueDiff("old", "new"), tracker.event.diff);
}
- public static Test suite() {
- TestSuite suite = new TestSuite(JavaBeanObservableValueTest.class
- .getName());
- suite.addTestSuite(JavaBeanObservableValueTest.class);
+ public static void addConformanceTest(TestSuite suite) {
suite.addTest(MutableObservableValueContractTest.suite(new Delegate()));
- return suite;
}
/* package */static class Delegate extends
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/JavaBeanPropertyObservableMapTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/JavaBeanPropertyObservableMapTest.java
index 40baee1..ac97984 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/JavaBeanPropertyObservableMapTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/JavaBeanPropertyObservableMapTest.java
@@ -12,6 +12,8 @@
package org.eclipse.core.tests.internal.databinding.beans;
+import static org.junit.Assert.assertEquals;
+
import java.util.ArrayList;
import java.util.Collections;
@@ -21,6 +23,7 @@
import org.eclipse.jface.databinding.conformance.util.CurrentRealm;
import org.eclipse.jface.databinding.conformance.util.MapChangeEventTracker;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Test;
/**
* @since 3.2
@@ -28,6 +31,7 @@
*/
public class JavaBeanPropertyObservableMapTest extends
AbstractDefaultRealmTestCase {
+ @Test
public void testSetBeanProperty_CorrectForNullOldAndNewValues() {
// The java bean spec allows the old and new values in a
// PropertyChangeEvent to be null, which indicates that an unknown
@@ -60,6 +64,7 @@
* Makes sure that the map set on the Bean model after changing the
* observable map is modifiable (see bugs 285307 and 301774).
*/
+ @Test
public void testUpdatedBeanMapIsModifiable() {
Bean bean = new Bean(new ArrayList());
IObservableMap observable = BeansObservables.observeMap(bean, "map");
@@ -72,6 +77,7 @@
* Makes sure that the map set on the Pojo model after changing the
* observable map is modifiable (see bugs 285307 and 301774).
*/
+ @Test
public void testUpdatedPojoMapIsModifiable() {
Bean bean = new Bean(new ArrayList());
IObservableMap observable = PojoObservables.observeMap(bean, "map");
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/DateConversionSupportTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/DateConversionSupportTest.java
index 8b74e2e..98c9597 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/DateConversionSupportTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/DateConversionSupportTest.java
@@ -12,12 +12,15 @@
package org.eclipse.core.tests.internal.databinding.conversion;
-import java.util.Date;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
-import junit.framework.TestCase;
+import java.util.Date;
import org.eclipse.core.internal.databinding.BindingMessages;
import org.eclipse.core.internal.databinding.conversion.DateConversionSupport;
+import org.junit.Test;
import com.ibm.icu.text.DateFormat;
import com.ibm.icu.text.SimpleDateFormat;
@@ -25,7 +28,8 @@
/**
* @since 1.1
*/
-public class DateConversionSupportTest extends TestCase {
+public class DateConversionSupportTest {
+ @Test
public void testDatePatternIsExternalized() throws Exception {
StubConverter stub = new StubConverter();
String key = "DateFormat_DateTime";
@@ -36,6 +40,7 @@
assertEquals(format, dateFormat.toPattern());
}
+ @Test
public void testTimePatternIsExternalized() throws Exception {
StubConverter stub = new StubConverter();
String key = "DateFormat_Time";
@@ -46,6 +51,7 @@
assertEquals(format, dateFormat.toPattern());
}
+ @Test
public void testFormat_NullDate() {
StubConverter stub = new StubConverter();
assertNull(stub.format(null));
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/IdentityConverterTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/IdentityConverterTest.java
index 88775ac..69605e9 100755
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/IdentityConverterTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/IdentityConverterTest.java
@@ -13,24 +13,30 @@
package org.eclipse.core.tests.internal.databinding.conversion;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import org.eclipse.core.databinding.BindingException;
import org.eclipse.core.internal.databinding.conversion.IdentityConverter;
+import org.junit.Before;
+import org.junit.Test;
/**
* @since 3.2
*
*/
-public class IdentityConverterTest extends TestCase {
+public class IdentityConverterTest {
private IdentityConverter c;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
c = new IdentityConverter(Integer.TYPE, Integer.TYPE);
}
+ @Test
public void testIsPrimitiveTypeMatchedWithBoxed() throws Exception {
assertTrue(c.isPrimitiveTypeMatchedWithBoxed(Integer.class,
Integer.TYPE));
@@ -66,6 +72,7 @@
Integer.TYPE));
}
+ @Test
public void testConvert_NullToPrimitive() {
IdentityConverter p2b = new IdentityConverter(Float.TYPE, Float.TYPE);
try {
@@ -76,21 +83,25 @@
}
}
+ @Test
public void testConvert_PrimitiveToBoxed() throws Exception {
IdentityConverter p2b = new IdentityConverter(Float.TYPE, Float.class);
assertEquals("4.2", new Float(4.2), p2b.convert(new Float(4.2)));
}
+ @Test
public void testConvert_BoxedToPrimitive() throws Exception {
IdentityConverter p2b = new IdentityConverter(Float.class, Float.TYPE);
assertEquals("4.2", new Float(4.2), p2b.convert(new Float(4.2)));
}
+ @Test
public void testConvert_PrimitiveToPrimitive() throws Exception {
IdentityConverter p2b = new IdentityConverter(Float.TYPE, Float.TYPE);
assertEquals("4.2", new Float(4.2), p2b.convert(new Float(4.2)));
}
+ @Test
public void testConvert_BoxedToBoxed() throws Exception {
IdentityConverter p2b = new IdentityConverter(Float.class, Float.class);
assertEquals("4.2", new Float(4.2), p2b.convert(new Float(4.2)));
@@ -104,6 +115,7 @@
public String name = "fido";
}
+ @Test
public void test_Convert_ValidAssignment() throws Exception {
IdentityConverter pc = new IdentityConverter(Object.class, Person.class);
Person orig = new Person();
@@ -112,6 +124,7 @@
assertTrue("Need correct Person", person.equals(orig));
}
+ @Test
public void test_Convert_ValidAssignment2() throws Exception {
IdentityConverter pc = new IdentityConverter(Person.class, Object.class);
Person orig = new Person();
@@ -120,6 +133,7 @@
assertTrue("Need correct Person", person.equals(orig));
}
+ @Test
public void testConvert_InvalidAssignment() throws Exception {
IdentityConverter pc = new IdentityConverter(Object.class, Person.class);
try {
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/IntegerToStringConverterTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/IntegerToStringConverterTest.java
index ff7e5a4..822a6b6 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/IntegerToStringConverterTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/IntegerToStringConverterTest.java
@@ -12,6 +12,8 @@
package org.eclipse.core.tests.internal.databinding.conversion;
import org.eclipse.core.internal.databinding.conversion.IntegerToStringConverter;
+import org.junit.Before;
+import org.junit.Test;
import com.ibm.icu.text.NumberFormat;
@@ -24,12 +26,14 @@
private NumberFormat integerFormat;
@Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
integerFormat = NumberFormat.getIntegerInstance();
}
+ @Test
public void testFromTypeShort() throws Exception {
assertEquals(Short.class, IntegerToStringConverter.fromShort(false)
.getFromType());
@@ -41,11 +45,13 @@
.getFromType());
}
+ @Test
public void testToTypeIsStringClass() throws Exception {
assertEquals(String.class, IntegerToStringConverter.fromShort(false)
.getToType());
}
+ @Test
public void testConvertShortToString() throws Exception {
Short value = Short.valueOf((short) 1);
String expected = integerFormat.format(value);
@@ -56,6 +62,7 @@
assertEquals(expected, result);
}
+ @Test
public void testConvertByteToString() throws Exception {
Byte value = Byte.valueOf((byte) 1);
String expected = integerFormat.format(value);
@@ -66,12 +73,14 @@
assertEquals(expected, result);
}
+ @Test
public void testNullSourceConvertsToEmptyString() throws Exception {
IntegerToStringConverter converter = IntegerToStringConverter
.fromByte(false);
assertEquals("", converter.convert(null));
}
+ @Test
public void testIllegalArgumentExceptionIfSourceIsNotExpectedType() throws Exception {
IntegerToStringConverter converter = IntegerToStringConverter.fromByte(false);
try {
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/NumberToBigIntegerConverterTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/NumberToBigIntegerConverterTest.java
index b217d9d..94d0a5d 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/NumberToBigIntegerConverterTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/NumberToBigIntegerConverterTest.java
@@ -25,11 +25,6 @@
private NumberFormat numberFormat;
@Override
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- @Override
protected Number doGetOutOfRangeNumber() {
return null;
}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/NumberToByteConverterTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/NumberToByteConverterTest.java
index 2427049..acaffff 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/NumberToByteConverterTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/NumberToByteConverterTest.java
@@ -13,6 +13,7 @@
import org.eclipse.core.databinding.conversion.IConverter;
import org.eclipse.core.internal.databinding.conversion.NumberToByteConverter;
+import org.junit.Before;
import com.ibm.icu.text.NumberFormat;
@@ -22,10 +23,8 @@
public class NumberToByteConverterTest extends NumberToNumberTestHarness {
private NumberFormat numberFormat;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
+ @Before
+ public void setUp() throws Exception {
numberFormat = NumberFormat.getInstance();
}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/NumberToFloatConverterTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/NumberToFloatConverterTest.java
index d848398..afc6494 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/NumberToFloatConverterTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/NumberToFloatConverterTest.java
@@ -13,6 +13,7 @@
import org.eclipse.core.databinding.conversion.IConverter;
import org.eclipse.core.internal.databinding.conversion.NumberToFloatConverter;
+import org.junit.Before;
import com.ibm.icu.text.NumberFormat;
@@ -22,10 +23,8 @@
public class NumberToFloatConverterTest extends NumberToNumberTestHarness {
private NumberFormat numberFormat;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
+ @Before
+ public void setUp() throws Exception {
numberFormat = NumberFormat.getInstance();
}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/NumberToIntegerConverterTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/NumberToIntegerConverterTest.java
index 5cedd48..a6b3331 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/NumberToIntegerConverterTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/NumberToIntegerConverterTest.java
@@ -13,6 +13,7 @@
import org.eclipse.core.databinding.conversion.IConverter;
import org.eclipse.core.internal.databinding.conversion.NumberToIntegerConverter;
+import org.junit.Before;
import com.ibm.icu.text.NumberFormat;
@@ -22,10 +23,8 @@
public class NumberToIntegerConverterTest extends NumberToNumberTestHarness {
private NumberFormat numberFormat;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
+ @Before
+ public void setUp() throws Exception {
numberFormat = NumberFormat.getInstance();
}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/NumberToLongConverterTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/NumberToLongConverterTest.java
index 5946c05..597b22f 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/NumberToLongConverterTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/NumberToLongConverterTest.java
@@ -13,6 +13,7 @@
import org.eclipse.core.databinding.conversion.IConverter;
import org.eclipse.core.internal.databinding.conversion.NumberToLongConverter;
+import org.junit.Before;
import com.ibm.icu.text.NumberFormat;
@@ -22,10 +23,8 @@
public class NumberToLongConverterTest extends NumberToNumberTestHarness {
private NumberFormat numberFormat;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
+ @Before
+ public void setUp() throws Exception {
numberFormat = NumberFormat.getInstance();
}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/NumberToNumberTestHarness.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/NumberToNumberTestHarness.java
index 00270d4..dcaa322 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/NumberToNumberTestHarness.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/NumberToNumberTestHarness.java
@@ -11,14 +11,20 @@
package org.eclipse.core.tests.internal.databinding.conversion;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import org.eclipse.core.databinding.conversion.IConverter;
+import org.junit.Test;
/**
* @since 1.1
*/
-public abstract class NumberToNumberTestHarness extends TestCase {
+public abstract class NumberToNumberTestHarness {
/**
* Invoked when a to primitive validator is needed.
@@ -51,11 +57,13 @@
*/
protected abstract Number doGetOutOfRangeNumber();
+ @Test
public void testFromType() throws Exception {
Class from = Integer.class;
assertEquals(from, doGetToBoxedTypeValidator(from).getFromType());
}
+ @Test
public void testToTypeIsPrimitive() throws Exception {
Class toType = doGetToType(true);
@@ -68,6 +76,7 @@
assertTrue("to type was not primitive", toType.isPrimitive());
}
+ @Test
public void testToTypeIsBoxedType() throws Exception {
Class toType = doGetToType(false);
assertEquals(toType, doGetToBoxedTypeValidator(Integer.class)
@@ -75,6 +84,7 @@
assertFalse(toType.isPrimitive());
}
+ @Test
public void testValidConversion() throws Exception {
Integer value = Integer.valueOf(1);
Number result = (Number) doGetToBoxedTypeValidator(Integer.class)
@@ -88,6 +98,7 @@
assertEquals(value, Integer.valueOf(result.intValue()));
}
+ @Test
public void testOutOfRangeConversion() throws Exception {
Number outOfRange = doGetOutOfRangeNumber();
@@ -102,6 +113,7 @@
}
}
+ @Test
public void testConvertNullValueForPrimitiveThrowsIllegalArgumentException()
throws Exception {
if (doGetToType(true) == null) {
@@ -117,10 +129,12 @@
}
}
+ @Test
public void testConvertNullValueForBoxedTypeReturnsNull() throws Exception {
assertNull(doGetToBoxedTypeValidator(Integer.class).convert(null));
}
+ @Test
public void testNonNumberThrowsIllegalArgumentException() throws Exception {
try {
doGetToBoxedTypeValidator(Integer.class).convert("");
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/NumberToShortConverterTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/NumberToShortConverterTest.java
index cd11091..cd26c3d 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/NumberToShortConverterTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/NumberToShortConverterTest.java
@@ -13,6 +13,7 @@
import org.eclipse.core.databinding.conversion.IConverter;
import org.eclipse.core.internal.databinding.conversion.NumberToShortConverter;
+import org.junit.Before;
import com.ibm.icu.text.NumberFormat;
@@ -22,10 +23,8 @@
public class NumberToShortConverterTest extends NumberToNumberTestHarness {
private NumberFormat numberFormat;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
+ @Before
+ public void setUp() throws Exception {
numberFormat = NumberFormat.getInstance();
}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/ObjectToPrimitiveValidatorTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/ObjectToPrimitiveValidatorTest.java
index b99246b..c004c08 100755
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/ObjectToPrimitiveValidatorTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/ObjectToPrimitiveValidatorTest.java
@@ -11,21 +11,24 @@
package org.eclipse.core.tests.internal.databinding.conversion;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import org.eclipse.core.internal.databinding.validation.ObjectToPrimitiveValidator;
import org.eclipse.core.runtime.IStatus;
+import org.junit.Before;
+import org.junit.Test;
/**
* @since 3.2
*
*/
-public class ObjectToPrimitiveValidatorTest extends TestCase {
+public class ObjectToPrimitiveValidatorTest {
private ObjectToPrimitiveValidator objectToPrimitiveValidator;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
this.objectToPrimitiveValidator = new ObjectToPrimitiveValidator(
Integer.TYPE);
}
@@ -34,6 +37,7 @@
* Test method for
* {@link org.eclipse.jface.internal.databinding.provisional.validation.ObjectToPrimitiveValidator#isValid(java.lang.Object)}.
*/
+ @Test
public void testIsValid() {
IStatus result = this.objectToPrimitiveValidator.validate(null);
assertEquals("The wrong validation error was found.", result
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/StatusToStringConverterTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/StatusToStringConverterTest.java
index a4415c7..227892a 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/StatusToStringConverterTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/StatusToStringConverterTest.java
@@ -11,39 +11,44 @@
package org.eclipse.core.tests.internal.databinding.conversion;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
import org.eclipse.core.databinding.validation.ValidationStatus;
import org.eclipse.core.internal.databinding.conversion.StatusToStringConverter;
import org.eclipse.core.runtime.IStatus;
+import org.junit.Before;
+import org.junit.Test;
/**
* @since 1.1
*/
-public class StatusToStringConverterTest extends TestCase {
+public class StatusToStringConverterTest {
private StatusToStringConverter converter;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
+ @Before
+ public void setUp() throws Exception {
converter = new StatusToStringConverter();
}
+ @Test
public void testConvertedValueIsMessageOfStatus() throws Exception {
String message = "this is my message";
IStatus status = ValidationStatus.error(message);
assertEquals(message, converter.convert(status));
}
+ @Test
public void testFromTypeIsIStatus() throws Exception {
assertEquals(IStatus.class, converter.getFromType());
}
+ @Test
public void testToTypeIsString() throws Exception {
assertEquals(String.class, converter.getToType());
}
+ @Test
public void testIllegalArgumentExceptionIsThrownWithNullInput() throws Exception {
try {
converter.convert(null);
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/StringToBooleanConverterTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/StringToBooleanConverterTest.java
index 27a2c00..da340db 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/StringToBooleanConverterTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/StringToBooleanConverterTest.java
@@ -11,29 +11,31 @@
package org.eclipse.core.tests.internal.databinding.conversion;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.StringTokenizer;
-import junit.framework.TestCase;
-import junit.framework.TestResult;
-
import org.eclipse.core.internal.databinding.BindingMessages;
import org.eclipse.core.internal.databinding.conversion.StringToBooleanConverter;
+import org.junit.Before;
+import org.junit.Test;
/**
* @since 1.1
*/
-public class StringToBooleanConverterTest extends TestCase {
+public class StringToBooleanConverterTest {
private StringToBooleanConverter converter;
private List trueValues;
private List falseValues;
- @Override
- public void run(TestResult result) {
+ @Before
+ public void setUp() {
trueValues = Collections.unmodifiableList(toValues(BindingMessages
.getString("ValueDelimiter"), BindingMessages
.getString("TrueStringValues")));
@@ -41,7 +43,9 @@
.getString("ValueDelimiter"), BindingMessages
.getString("FalseStringValues")));
- super.run(result);
+ converter = new StringToBooleanConverter();
+ assertTrue(trueValues.size() > 0);
+ assertTrue(falseValues.size() > 0);
}
private List toValues(String delimiter, String values) {
@@ -55,31 +59,26 @@
return result;
}
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
- converter = new StringToBooleanConverter();
- assertTrue(trueValues.size() > 0);
- assertTrue(falseValues.size() > 0);
- }
-
+ @Test
public void testConvertsToTrue() throws Exception {
Boolean result = (Boolean) converter.convert(trueValues.get(0));
assertTrue(result.booleanValue());
}
+ @Test
public void testConvertsToFalse() throws Exception {
Boolean result = (Boolean) converter.convert(falseValues.get(0));
assertFalse(result.booleanValue());
}
+ @Test
public void testUpperCaseStringConvertsToTrue() throws Exception {
Boolean result = (Boolean) converter.convert(((String) trueValues.get(0))
.toUpperCase());
assertTrue(result.booleanValue());
}
+ @Test
public void testUpperCaseStringConvertsToFalse() throws Exception {
Boolean result = (Boolean) converter.convert(((String) falseValues.get(0))
.toUpperCase());
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/StringToByteConverterTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/StringToByteConverterTest.java
index fb77518..a07f092 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/StringToByteConverterTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/StringToByteConverterTest.java
@@ -11,26 +11,30 @@
package org.eclipse.core.tests.internal.databinding.conversion;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
+
import org.eclipse.core.internal.databinding.conversion.StringToByteConverter;
+import org.junit.Before;
+import org.junit.Test;
import com.ibm.icu.text.NumberFormat;
-import junit.framework.TestCase;
-
/**
* @since 1.1
*/
-public class StringToByteConverterTest extends TestCase {
+public class StringToByteConverterTest {
private NumberFormat numberFormat;
private StringToByteConverter converter;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
numberFormat = NumberFormat.getIntegerInstance();
converter = StringToByteConverter.toByte(numberFormat, false);
}
+ @Test
public void testConvertsToByte() throws Exception {
Byte value = Byte.valueOf((byte) 1);
Byte result = (Byte) converter.convert(numberFormat.format(value));
@@ -38,6 +42,7 @@
assertEquals(value, result);
}
+ @Test
public void testConvertsToBytePrimitive() throws Exception {
converter = StringToByteConverter.toByte(numberFormat, true);
Byte value = Byte.valueOf((byte) 1);
@@ -45,23 +50,28 @@
assertEquals(value, result);
}
+ @Test
public void testFromTypeIsString() throws Exception {
assertEquals(String.class, converter.getFromType());
}
+ @Test
public void testToTypeIsShort() throws Exception {
assertEquals(Byte.class, converter.getToType());
}
+ @Test
public void testToTypeIsBytePrimitive() throws Exception {
converter = StringToByteConverter.toByte(true);
assertEquals(Byte.TYPE, converter.getToType());
}
+ @Test
public void testReturnsNullBoxedTypeForEmptyString() throws Exception {
assertNull(converter.convert(""));
}
+ @Test
public void testThrowsIllegalArgumentExceptionIfAskedToConvertNonString()
throws Exception {
try {
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/StringToCharacterConverterTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/StringToCharacterConverterTest.java
index a830a8b..3852675 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/StringToCharacterConverterTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/StringToCharacterConverterTest.java
@@ -11,25 +11,29 @@
package org.eclipse.core.tests.internal.databinding.conversion;
-import org.eclipse.core.internal.databinding.conversion.StringToCharacterConverter;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
-import junit.framework.TestCase;
+import org.eclipse.core.internal.databinding.conversion.StringToCharacterConverter;
+import org.junit.Before;
+import org.junit.Test;
/**
* @since 1.1
*/
-public class StringToCharacterConverterTest extends TestCase {
+public class StringToCharacterConverterTest {
private StringToCharacterConverter converter;
private StringToCharacterConverter primitiveConverter;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
converter = StringToCharacterConverter.toCharacter(false);
primitiveConverter = StringToCharacterConverter.toCharacter(true);
}
+ @Test
public void testConvertsToCharacter() throws Exception {
Character value = Character.valueOf('X');
Character result = (Character) converter.convert(Character
@@ -38,6 +42,7 @@
assertEquals(value, result);
}
+ @Test
public void testConvertsToCharacterPrimitive() throws Exception {
Character value = Character.valueOf('Y');
Character result = (Character) primitiveConverter.convert(String
@@ -45,26 +50,32 @@
assertEquals(value, result);
}
+ @Test
public void testFromTypeIsString() throws Exception {
assertEquals(String.class, converter.getFromType());
}
+ @Test
public void testToTypeIsCharacter() throws Exception {
assertEquals(Character.class, converter.getToType());
}
+ @Test
public void testToTypeIsCharacterPrimitive() throws Exception {
assertEquals(Character.TYPE, primitiveConverter.getToType());
}
+ @Test
public void testReturnsNullBoxedTypeForEmptyString() throws Exception {
assertNull(converter.convert(""));
}
+ @Test
public void testNullCharacterIsOK() throws Exception {
assertNull(converter.convert(null));
}
+ @Test
public void testNullCharacterIsNotOKForPrimitive() throws Exception {
try {
primitiveConverter.convert(null);
@@ -73,6 +84,7 @@
}
}
+ @Test
public void testThrowsIllegalArgumentExceptionIfAskedToConvertNonString()
throws Exception {
try {
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/StringToNumberParserTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/StringToNumberParserTest.java
index 54127c4..9c45011 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/StringToNumberParserTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/StringToNumberParserTest.java
@@ -11,26 +11,30 @@
package org.eclipse.core.tests.internal.databinding.conversion;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
import org.eclipse.core.internal.databinding.conversion.StringToNumberParser;
import org.eclipse.core.internal.databinding.conversion.StringToNumberParser.ParseResult;
+import org.junit.Before;
+import org.junit.Test;
import com.ibm.icu.text.NumberFormat;
/**
* @since 1.1
*/
-public class StringToNumberParserTest extends TestCase {
+public class StringToNumberParserTest {
private NumberFormat integerFormat;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
+ @Before
+ public void setUp() throws Exception {
integerFormat = NumberFormat.getIntegerInstance();
}
+ @Test
public void testParseNonStringThrowsIllegalArgumentException()
throws Exception {
try {
@@ -40,12 +44,14 @@
}
}
+ @Test
public void testEmptyStringReturnsNullIfNotPrimitive() throws Exception {
ParseResult result = StringToNumberParser.parse("",
integerFormat, false);
assertNull(result.getNumber());
}
+ @Test
public void testReturnsParsePositionWhenValueCannotBeParsed()
throws Exception {
ParseResult result = StringToNumberParser.parse("adsf",
@@ -54,6 +60,7 @@
assertNull(result.getNumber());
}
+ @Test
public void testReturnsNumberWhenSuccessfullyParsed() throws Exception {
Integer number = Integer.valueOf(5);
ParseResult result = StringToNumberParser.parse(integerFormat
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/StringToNumberParserTestHarness.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/StringToNumberParserTestHarness.java
index 8caa7e8..7aeb964 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/StringToNumberParserTestHarness.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/StringToNumberParserTestHarness.java
@@ -11,17 +11,20 @@
package org.eclipse.core.tests.internal.databinding.conversion;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import java.math.BigDecimal;
import java.math.BigInteger;
import org.eclipse.core.internal.databinding.conversion.StringToNumberParser;
-
-import junit.framework.TestCase;
+import org.junit.Test;
/**
* @since 1.1
*/
-public abstract class StringToNumberParserTestHarness extends TestCase {
+public abstract class StringToNumberParserTestHarness {
protected abstract Number getValidMax();
@@ -29,6 +32,7 @@
protected abstract boolean assertValid(Number number);
+ @Test
public void testRanges() throws Exception {
Number min = getValidMin();
Number max = getValidMax();
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/StringToShortConverterTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/StringToShortConverterTest.java
index 1d1db63..9073e9c 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/StringToShortConverterTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/conversion/StringToShortConverterTest.java
@@ -11,26 +11,30 @@
package org.eclipse.core.tests.internal.databinding.conversion;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
import org.eclipse.core.internal.databinding.conversion.StringToShortConverter;
+import org.junit.Before;
+import org.junit.Test;
import com.ibm.icu.text.NumberFormat;
/**
* @since 1.1
*/
-public class StringToShortConverterTest extends TestCase {
+public class StringToShortConverterTest {
private NumberFormat numberFormat;
private StringToShortConverter converter;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
numberFormat = NumberFormat.getIntegerInstance();
converter = StringToShortConverter.toShort(numberFormat, false);
}
+ @Test
public void testConvertsToShort() throws Exception {
Short value = Short.valueOf((short) 1);
Short result = (Short) converter.convert(numberFormat.format(value));
@@ -38,6 +42,7 @@
assertEquals(value, result);
}
+ @Test
public void testConvertsToShortPrimitive() throws Exception {
converter = StringToShortConverter.toShort(numberFormat, true);
Short value = Short.valueOf((short) 1);
@@ -45,23 +50,28 @@
assertEquals(value, result);
}
+ @Test
public void testFromTypeIsString() throws Exception {
assertEquals(String.class, converter.getFromType());
}
+ @Test
public void testToTypeIsShort() throws Exception {
assertEquals(Short.class, converter.getToType());
}
+ @Test
public void testToTypeIsShortPrimitive() throws Exception {
converter = StringToShortConverter.toShort(true);
assertEquals(Short.TYPE, converter.getToType());
}
+ @Test
public void testReturnsNullBoxedTypeForEmptyString() throws Exception {
assertNull(converter.convert(""));
}
+ @Test
public void testThrowsIllegalArgumentExceptionIfAskedToConvertNonString()
throws Exception {
try {
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/ConstantObservableValueTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/ConstantObservableValueTest.java
index 873a205..08e87fa 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/ConstantObservableValueTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/ConstantObservableValueTest.java
@@ -20,8 +20,8 @@
import org.eclipse.jface.databinding.conformance.delegate.IObservableValueContractDelegate;
import org.eclipse.jface.databinding.conformance.util.SuiteBuilder;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Test;
-import junit.framework.Test;
import junit.framework.TestSuite;
/**
@@ -30,20 +30,15 @@
* @since 1.1
*/
public class ConstantObservableValueTest extends AbstractDefaultRealmTestCase {
+
+ @Test(expected = RuntimeException.class)
public void testConstructor_NullRealm() {
- try {
- new ConstantObservableValue(null, null, null);
- fail("Constructor should throw an exception when null realm is passed in");
- } catch (RuntimeException expected) {
- }
+ new ConstantObservableValue(null, null, null);
}
- public static Test suite() {
- TestSuite suite = new TestSuite("ConstantValueTest");
- suite.addTestSuite(ConstantObservableValueTest.class);
- suite.addTest(UnchangeableObservableValueContractTest
- .suite(new Delegate()));
- return suite;
+ public static void addConformanceTest(TestSuite suite) {
+ suite.addTest(new SuiteBuilder()
+ .addObservableContractTest(UnchangeableObservableValueContractTest.class, new Delegate()).build());
}
private static class Delegate extends
@@ -71,80 +66,88 @@
}
@Override
- public void testChange_OrderOfNotifications() {
+ @Test
+ public void testChange_OrderOfNotifications() {
// disabled
}
@Override
- public void testChange_ValueChangeEvent() {
+ @Test
+ public void testChange_ValueChangeEvent() {
// disabled
}
@Override
- public void testChange_ValueChangeEventDiff() {
+ @Test
+ public void testChange_ValueChangeEventDiff() {
// disabled
}
@Override
- public void testChange_ValueChangeEventFiredAfterValueIsSet() {
+ @Test
+ public void testChange_ValueChangeEventFiredAfterValueIsSet() {
// disabled
}
@Override
- public void testRemoveValueChangeListener_RemovesListener()
+ @Test
+ public void testRemoveValueChangeListener_RemovesListener()
throws Exception {
// disabled
}
@Override
- public void testChange_ChangeEvent() {
+ @Test
+ public void testChange_ChangeEvent() {
// disabled
}
@Override
- public void testChange_EventObservable() {
+ @Test
+ public void testChange_EventObservable() {
// disabled
}
@Override
- public void testChange_ObservableRealmIsTheCurrentRealm() {
+ @Test
+ public void testChange_ObservableRealmIsTheCurrentRealm() {
// disabled
}
@Override
- public void testChange_RealmCheck() {
+ @Test
+ public void testChange_RealmCheck() {
// disabled
}
@Override
- public void testRemoveChangeListener_RemovesListener() {
+ @Test
+ public void testRemoveChangeListener_RemovesListener() {
// disabled
}
@Override
- public void testIsStale_RealmChecks() {
+ @Test
+ public void testIsStale_RealmChecks() {
// disabled
}
@Override
- public void testIsStale_GetterCalled() throws Exception {
+ @Test
+ public void testIsStale_GetterCalled() throws Exception {
// disabled
}
@Override
- public void testIsDisposed() throws Exception {
+ @Test
+ public void testIsDisposed() throws Exception {
// disabled
}
@Override
- public void testAddDisposeListener_HandleDisposeInvoked() {
+ @Test
+ public void testAddDisposeListener_HandleDisposeInvoked() {
// disabled
}
-
- public static Test suite(IObservableValueContractDelegate delegate) {
- return new SuiteBuilder().addObservableContractTest(
- UnchangeableObservableValueContractTest.class, delegate)
- .build();
- }
}
}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/DelayedObservableValueTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/DelayedObservableValueTest.java
index 81feda6..e0495c6 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/DelayedObservableValueTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/DelayedObservableValueTest.java
@@ -12,8 +12,9 @@
package org.eclipse.core.tests.internal.databinding.observable;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import org.eclipse.core.databinding.observable.Diffs;
import org.eclipse.core.databinding.observable.IObservable;
@@ -26,6 +27,11 @@
import org.eclipse.jface.databinding.conformance.util.ValueChangeEventTracker;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
import org.eclipse.swt.widgets.Display;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import junit.framework.TestSuite;
/**
* Tests for DelayedObservableValue
@@ -39,7 +45,8 @@
private IObservableValue delayed;
@Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
target = new ObservableValueStub(Realm.getDefault());
oldValue = new Object();
@@ -49,12 +56,14 @@
}
@Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
target.dispose();
target = null;
super.tearDown();
}
+ @Test
public void testIsStale_WhenTargetIsStale() {
assertFalse(target.isStale());
assertFalse(delayed.isStale());
@@ -65,6 +74,7 @@
assertTrue(delayed.isStale());
}
+ @Test
public void testIsStale_DuringDelay() {
assertFalse(target.isStale());
assertFalse(delayed.isStale());
@@ -75,10 +85,12 @@
assertTrue(delayed.isStale());
}
+ @Test
public void testGetValueType_SameAsTarget() {
assertEquals(target.getValueType(), delayed.getValueType());
}
+ @Test
public void testGetValue_FiresPendingValueChange() {
assertFiresPendingValueChange(new Runnable() {
@Override
@@ -89,6 +101,7 @@
});
}
+ @Test
public void testSetValue_PropagatesToTarget() {
assertEquals(oldValue, delayed.getValue());
assertEquals(oldValue, target.getValue());
@@ -99,6 +112,7 @@
assertEquals(newValue, delayed.getValue());
}
+ @Test
public void testSetValue_CachesGetValueFromTarget() {
Object overrideValue = target.overrideValue = new Object();
@@ -111,6 +125,7 @@
assertEquals(overrideValue, delayed.getValue());
}
+ @Test
public void testSetValue_FiresValueChangeEvent() {
ValueChangeEventTracker targetTracker = ValueChangeEventTracker
.observe(target);
@@ -128,6 +143,7 @@
assertEquals(newValue, delayedTracker.event.diff.getNewValue());
}
+ @Test
public void testWait_FiresPendingValueChange() {
assertFiresPendingValueChange(new Runnable() {
@Override
@@ -218,13 +234,8 @@
}
}
- public static Test suite() {
- TestSuite suite = new TestSuite(DelayedObservableValueTest.class
- .getName());
- suite.addTestSuite(DelayedObservableValueTest.class);
- suite.addTest(MutableObservableValueContractTest
- .suite(new Delegate()));
- return suite;
+ public static void addConformanceTest(TestSuite suite) {
+ suite.addTest(MutableObservableValueContractTest.suite(new Delegate()));
}
static class Delegate extends AbstractObservableValueContractDelegate {
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/EmptyObservableListTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/EmptyObservableListTest.java
index 21b49dd..0fa0b18 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/EmptyObservableListTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/EmptyObservableListTest.java
@@ -19,8 +19,8 @@
import org.eclipse.jface.databinding.conformance.delegate.AbstractObservableCollectionContractDelegate;
import org.eclipse.jface.databinding.conformance.delegate.IObservableCollectionContractDelegate;
import org.eclipse.jface.databinding.conformance.util.SuiteBuilder;
+import org.junit.Test;
-import junit.framework.Test;
import junit.framework.TestSuite;
/**
@@ -28,19 +28,14 @@
*
*/
public class EmptyObservableListTest {
- public static Test suite() {
- TestSuite suite = new TestSuite(EmptyObservableListTest.class.getName());
- suite.addTest(ImmutableObservableListContractTest.suite(new Delegate()));
- return suite;
+
+ public static void addConformanceTest(TestSuite suite) {
+ suite.addTest(new SuiteBuilder()
+ .addObservableContractTest(ImmutableObservableListContractTest.class, new Delegate()).build());
}
public static class ImmutableObservableListContractTest extends
ObservableListContractTest {
- public static Test suite(IObservableCollectionContractDelegate delegate) {
- return new SuiteBuilder().addObservableContractTest(
- ImmutableObservableListContractTest.class, delegate)
- .build();
- }
public ImmutableObservableListContractTest(
IObservableCollectionContractDelegate delegate) {
@@ -53,117 +48,140 @@
}
@Override
- public void testGet_GetterCalled() {
+ @Test
+ public void testGet_GetterCalled() {
// disabled
}
@Override
- public void testSubList_GetterCalled() {
+ @Test
+ public void testSubList_GetterCalled() {
// disabled
}
@Override
- public void testChange_ChangeEvent() {
+ @Test
+ public void testChange_ChangeEvent() {
// disabled
}
@Override
- public void testChange_EventObservable() {
+ @Test
+ public void testChange_EventObservable() {
// disabled
}
@Override
- public void testChange_ObservableRealmIsTheCurrentRealm() {
+ @Test
+ public void testChange_ObservableRealmIsTheCurrentRealm() {
// disabled
}
@Override
- public void testChange_RealmCheck() {
+ @Test
+ public void testChange_RealmCheck() {
// disabled
}
@Override
- public void testRemoveChangeListener_RemovesListener() {
+ @Test
+ public void testRemoveChangeListener_RemovesListener() {
// disabled
}
@Override
- public void testIndexOf_GetterCalled() {
+ @Test
+ public void testIndexOf_GetterCalled() {
// disabled
}
@Override
- public void testLastIndexOf_GetterCalled() {
+ @Test
+ public void testLastIndexOf_GetterCalled() {
// disabled
}
@Override
- public void testListIterator_GetterCalled() {
+ @Test
+ public void testListIterator_GetterCalled() {
// disabled
}
@Override
- public void testListIteratorAtIndex_GetterCalled() {
+ @Test
+ public void testListIteratorAtIndex_GetterCalled() {
// disabled
}
@Override
- public void testContains_GetterCalled() {
+ @Test
+ public void testContains_GetterCalled() {
// disabled
}
@Override
- public void testContainsAll_GetterCalled() {
+ @Test
+ public void testContainsAll_GetterCalled() {
// disabled
}
@Override
- public void testEquals_GetterCalled() {
+ @Test
+ public void testEquals_GetterCalled() {
// disabled
}
@Override
- public void testHashCode_GetterCalled() {
+ @Test
+ public void testHashCode_GetterCalled() {
// disabled
}
@Override
- public void testIsEmpty_GetterCalled() {
+ @Test
+ public void testIsEmpty_GetterCalled() {
// disabled
}
@Override
- public void testIterator_GetterCalled() {
+ @Test
+ public void testIterator_GetterCalled() {
// disabled
}
@Override
- public void testSize_GetterCalled() throws Exception {
+ @Test
+ public void testSize_GetterCalled() throws Exception {
// disabled
}
@Override
- public void testToArray_GetterCalled() throws Exception {
+ @Test
+ public void testToArray_GetterCalled() throws Exception {
// disabled
}
@Override
- public void testToArrayWithObjectArray_GetterCalled() throws Exception {
+ @Test
+ public void testToArrayWithObjectArray_GetterCalled() throws Exception {
// disabled
}
@Override
- public void testIsStale_GetterCalled() throws Exception {
+ @Test
+ public void testIsStale_GetterCalled() throws Exception {
// disabled
}
@Override
- public void testIsDisposed() throws Exception {
+ @Test
+ public void testIsDisposed() throws Exception {
// disabled
}
@Override
- public void testAddDisposeListener_HandleDisposeInvoked() {
+ @Test
+ public void testAddDisposeListener_HandleDisposeInvoked() {
// disabled
}
}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/EmptyObservableSetTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/EmptyObservableSetTest.java
index ec23508..0ca34c3 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/EmptyObservableSetTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/EmptyObservableSetTest.java
@@ -19,8 +19,8 @@
import org.eclipse.jface.databinding.conformance.delegate.AbstractObservableCollectionContractDelegate;
import org.eclipse.jface.databinding.conformance.delegate.IObservableCollectionContractDelegate;
import org.eclipse.jface.databinding.conformance.util.SuiteBuilder;
+import org.junit.Test;
-import junit.framework.Test;
import junit.framework.TestSuite;
/**
@@ -28,18 +28,14 @@
*
*/
public class EmptyObservableSetTest {
- public static Test suite() {
- TestSuite suite = new TestSuite(EmptyObservableSetTest.class.getName());
- suite.addTest(ImmutableObservableSetContractTest.suite(new Delegate()));
- return suite;
+
+ public static void addConformanceTest(TestSuite suite) {
+ suite.addTest(new SuiteBuilder()
+ .addObservableContractTest(ImmutableObservableSetContractTest.class, new Delegate()).build());
}
public static class ImmutableObservableSetContractTest extends
ObservableCollectionContractTest {
- public static Test suite(IObservableCollectionContractDelegate delegate) {
- return new SuiteBuilder().addObservableContractTest(
- ImmutableObservableSetContractTest.class, delegate).build();
- }
public ImmutableObservableSetContractTest(
IObservableCollectionContractDelegate delegate) {
@@ -52,87 +48,104 @@
}
@Override
- public void testChange_ChangeEvent() {
+ @Test
+ public void testChange_ChangeEvent() {
// disabled
}
@Override
- public void testChange_EventObservable() {
+ @Test
+ public void testChange_EventObservable() {
// disabled
}
@Override
- public void testChange_ObservableRealmIsTheCurrentRealm() {
+ @Test
+ public void testChange_ObservableRealmIsTheCurrentRealm() {
// disabled
}
@Override
- public void testChange_RealmCheck() {
+ @Test
+ public void testChange_RealmCheck() {
// disabled
}
@Override
- public void testRemoveChangeListener_RemovesListener() {
+ @Test
+ public void testRemoveChangeListener_RemovesListener() {
// disabled
}
@Override
- public void testContains_GetterCalled() {
+ @Test
+ public void testContains_GetterCalled() {
// disabled
}
@Override
- public void testContainsAll_GetterCalled() {
+ @Test
+ public void testContainsAll_GetterCalled() {
// disabled
}
@Override
- public void testEquals_GetterCalled() {
+ @Test
+ public void testEquals_GetterCalled() {
// disabled
}
@Override
- public void testHashCode_GetterCalled() {
+ @Test
+ public void testHashCode_GetterCalled() {
// disabled
}
@Override
- public void testIsEmpty_GetterCalled() {
+ @Test
+ public void testIsEmpty_GetterCalled() {
// disabled
}
@Override
- public void testIterator_GetterCalled() {
+ @Test
+ public void testIterator_GetterCalled() {
// disabled
}
@Override
- public void testSize_GetterCalled() {
+ @Test
+ public void testSize_GetterCalled() {
// disabled
}
@Override
- public void testToArray_GetterCalled() {
+ @Test
+ public void testToArray_GetterCalled() {
// disabled
}
@Override
- public void testToArrayWithObjectArray_GetterCalled() {
+ @Test
+ public void testToArrayWithObjectArray_GetterCalled() {
// disabled
}
@Override
- public void testIsStale_GetterCalled() throws Exception {
+ @Test
+ public void testIsStale_GetterCalled() throws Exception {
// disabled
}
@Override
- public void testIsDisposed() throws Exception {
+ @Test
+ public void testIsDisposed() throws Exception {
// disabled
}
@Override
- public void testAddDisposeListener_HandleDisposeInvoked() {
+ @Test
+ public void testAddDisposeListener_HandleDisposeInvoked() {
// disabled
}
}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/IdentityObservableSetTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/IdentityObservableSetTest.java
index 06125c7..89c4c5d 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/IdentityObservableSetTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/IdentityObservableSetTest.java
@@ -14,10 +14,6 @@
package org.eclipse.core.tests.internal.databinding.observable;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.IObservableCollection;
import org.eclipse.core.databinding.observable.Realm;
@@ -26,12 +22,11 @@
import org.eclipse.jface.databinding.conformance.MutableObservableSetContractTest;
import org.eclipse.jface.databinding.conformance.delegate.AbstractObservableCollectionContractDelegate;
-public class IdentityObservableSetTest extends TestCase {
- public static Test suite() {
- TestSuite suite = new TestSuite(IdentityObservableSetTest.class
- .getName());
+import junit.framework.TestSuite;
+
+public class IdentityObservableSetTest {
+ public static void addConformanceTest(TestSuite suite) {
suite.addTest(MutableObservableSetContractTest.suite(new Delegate()));
- return suite;
}
private static class Delegate extends
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/MapEntryObservableValueTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/MapEntryObservableValueTest.java
index 0575dac..5370262 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/MapEntryObservableValueTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/MapEntryObservableValueTest.java
@@ -12,8 +12,9 @@
package org.eclipse.core.tests.internal.databinding.observable;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.Observables;
@@ -29,6 +30,10 @@
import org.eclipse.jface.databinding.conformance.ObservableStaleContractTest;
import org.eclipse.jface.databinding.conformance.delegate.AbstractObservableValueContractDelegate;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Before;
+import org.junit.Test;
+
+import junit.framework.TestSuite;
/**
* @since 1.2
@@ -44,7 +49,8 @@
private MapEntryObservableValue observedValue;
@Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
this.map = new WritableMap();
this.observedValue = (MapEntryObservableValue) Observables
@@ -57,6 +63,7 @@
this.diff = p_event.diff;
}
+ @Test
public void testNullValue() {
// test entry added with value null
this.map.put(this.key, null);
@@ -72,6 +79,7 @@
assertNull(this.observedValue.getValue());
}
+ @Test
public void testNonNullValue() {
// test add non-null value
this.map.put(this.key, VALUE1);
@@ -89,6 +97,7 @@
assertSame(VALUE2, this.observedValue.getValue());
}
+ @Test
public void testTransitionBetweenNullAndNonNull() {
this.map.put(this.key, null);
@@ -107,6 +116,7 @@
assertNull(this.diff.getNewValue());
}
+ @Test
public void testRemoveKey() {
this.map.put(this.key, VALUE1);
@@ -117,6 +127,7 @@
assertNull(this.diff.getNewValue());
}
+ @Test
public void testGetAndSetValue() {
// test set null value
this.observedValue.setValue(null);
@@ -139,12 +150,9 @@
assertSame(VALUE2, this.diff.getNewValue());
}
- public static Test suite() {
- TestSuite suite = new TestSuite(MapEntryObservableValueTest.class.getName());
- suite.addTestSuite(MapEntryObservableValueTest.class);
+ public static void addConformanceTest(TestSuite suite) {
suite.addTest(MutableObservableValueContractTest.suite(new Delegate()));
suite.addTest(ObservableStaleContractTest.suite(new Delegate()));
- return suite;
}
private static class Delegate extends
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/StalenessObservableValueTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/StalenessObservableValueTest.java
index 61ecb2f..d199fb3 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/StalenessObservableValueTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/StalenessObservableValueTest.java
@@ -20,8 +20,6 @@
import org.eclipse.jface.databinding.conformance.ObservableValueContractTest;
import org.eclipse.jface.databinding.conformance.delegate.AbstractObservableValueContractDelegate;
-import junit.framework.Test;
-import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
@@ -29,11 +27,9 @@
*
* @since 1.1
*/
-public class StalenessObservableValueTest extends TestCase {
- public static Test suite() {
- TestSuite suite = new TestSuite(StalenessObservableValueTest.class.getName());
+public class StalenessObservableValueTest {
+ public static void addConformanceTest(TestSuite suite) {
suite.addTest(ObservableValueContractTest.suite(new Delegate()));
- return suite;
}
static class ObservableStub extends AbstractObservable {
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/UnmodifiableObservableListTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/UnmodifiableObservableListTest.java
index 2877c4c..97c1b6a 100755
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/UnmodifiableObservableListTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/UnmodifiableObservableListTest.java
@@ -13,12 +13,13 @@
package org.eclipse.core.tests.internal.databinding.observable;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import java.util.ArrayList;
import java.util.List;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.eclipse.core.databinding.observable.Diffs;
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.IObservableCollection;
@@ -35,6 +36,10 @@
import org.eclipse.jface.databinding.conformance.util.ListChangeEventTracker;
import org.eclipse.jface.databinding.conformance.util.StaleEventTracker;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Before;
+import org.junit.Test;
+
+import junit.framework.TestSuite;
public class UnmodifiableObservableListTest extends
AbstractDefaultRealmTestCase {
@@ -42,7 +47,8 @@
ObservableList mutable;
@Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
List list = new ArrayList();
@@ -53,6 +59,7 @@
unmodifiable = Observables.unmodifiableObservableList(mutable);
}
+ @Test
public void testFiresChangeEvents() throws Exception {
ChangeEventTracker mutableListener = new ChangeEventTracker();
ChangeEventTracker unmodifiableListener = new ChangeEventTracker();
@@ -67,6 +74,7 @@
assertEquals(1, unmodifiableListener.count);
}
+ @Test
public void testFiresListChangeEvents() throws Exception {
ListChangeEventTracker mutableListener = new ListChangeEventTracker();
ListChangeEventTracker unmodifiableListener = new ListChangeEventTracker();
@@ -98,6 +106,7 @@
assertEquals(3, unmodifiable.size());
}
+ @Test
public void testFiresStaleEvents() throws Exception {
StaleEventTracker mutableListener = new StaleEventTracker();
StaleEventTracker unmodifiableListener = new StaleEventTracker();
@@ -116,6 +125,7 @@
assertTrue(unmodifiable.isStale());
}
+ @Test
public void testIsStale() throws Exception {
assertFalse(mutable.isStale());
assertFalse(unmodifiable.isStale());
@@ -143,11 +153,8 @@
}
}
- public static Test suite() {
- TestSuite suite = new TestSuite(UnmodifiableObservableListTest.class.getName());
- suite.addTestSuite(UnmodifiableObservableListTest.class);
+ public static void addConformanceTest(TestSuite suite) {
suite.addTest(ObservableListContractTest.suite(new Delegate()));
- return suite;
}
private static class Delegate extends
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/UnmodifiableObservableSetTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/UnmodifiableObservableSetTest.java
index 693a002..d23677c 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/UnmodifiableObservableSetTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/UnmodifiableObservableSetTest.java
@@ -14,13 +14,14 @@
package org.eclipse.core.tests.internal.databinding.observable;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.eclipse.core.databinding.observable.Diffs;
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.IObservableCollection;
@@ -36,13 +37,18 @@
import org.eclipse.jface.databinding.conformance.util.SetChangeEventTracker;
import org.eclipse.jface.databinding.conformance.util.StaleEventTracker;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Before;
+import org.junit.Test;
+
+import junit.framework.TestSuite;
public class UnmodifiableObservableSetTest extends AbstractDefaultRealmTestCase {
UnmodifiableObservableSet unmodifiable;
MutableObservableSet mutable;
@Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
Set set = new HashSet();
@@ -54,6 +60,7 @@
.unmodifiableObservableSet(mutable);
}
+ @Test
public void testFiresChangeEvents() throws Exception {
ChangeEventTracker mutableListener = new ChangeEventTracker();
ChangeEventTracker unmodifiableListener = new ChangeEventTracker();
@@ -68,6 +75,7 @@
assertEquals(1, unmodifiableListener.count);
}
+ @Test
public void testFiresSetChangeEvents() throws Exception {
SetChangeEventTracker mutableListener = new SetChangeEventTracker();
SetChangeEventTracker unmodifiableListener = new SetChangeEventTracker();
@@ -97,6 +105,7 @@
assertEquals(3, unmodifiable.size());
}
+ @Test
public void testFiresStaleEvents() throws Exception {
StaleEventTracker mutableListener = new StaleEventTracker();
StaleEventTracker unmodifiableListener = new StaleEventTracker();
@@ -115,6 +124,7 @@
assertTrue(unmodifiable.isStale());
}
+ @Test
public void testIsStale() throws Exception {
assertFalse(mutable.isStale());
assertFalse(unmodifiable.isStale());
@@ -142,11 +152,8 @@
}
}
- public static Test suite() {
- TestSuite suite = new TestSuite(UnmodifiableObservableSetTest.class.getName());
- suite.addTestSuite(UnmodifiableObservableSetTest.class);
+ public static void addConformanceTest(TestSuite suite) {
suite.addTest(ObservableCollectionContractTest.suite(new Delegate()));
- return suite;
}
private static class Delegate extends
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/UnmodifiableObservableValueTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/UnmodifiableObservableValueTest.java
index f874867..e2e365c 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/UnmodifiableObservableValueTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/UnmodifiableObservableValueTest.java
@@ -13,8 +13,9 @@
package org.eclipse.core.tests.internal.databinding.observable;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import org.eclipse.core.databinding.observable.Diffs;
import org.eclipse.core.databinding.observable.IObservable;
@@ -27,6 +28,10 @@
import org.eclipse.jface.databinding.conformance.delegate.AbstractObservableValueContractDelegate;
import org.eclipse.jface.databinding.conformance.util.StaleEventTracker;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Before;
+import org.junit.Test;
+
+import junit.framework.TestSuite;
/**
* @since 3.2
@@ -37,15 +42,13 @@
private UnmodifiableObservableValueStub unmodifiable;
- public static Test suite() {
- TestSuite suite = new TestSuite(UnmodifiableObservableValueTest.class.getName());
- suite.addTestSuite(UnmodifiableObservableValueTest.class);
+ public static void addConformanceTest(TestSuite suite) {
suite.addTest(ObservableValueContractTest.suite(new Delegate()));
- return suite;
}
@Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
WrappedObservableValue wrapped = new WrappedObservableValue(Realm
@@ -53,6 +56,7 @@
unmodifiable = new UnmodifiableObservableValueStub(wrapped);
}
+ @Test
public void testFiresStaleEvents() {
StaleEventTracker wrappedListener = new StaleEventTracker();
StaleEventTracker unmodifiableListener = new StaleEventTracker();
@@ -72,6 +76,7 @@
assertTrue(unmodifiable.isStale());
}
+ @Test
public void testIsStale() {
assertFalse(unmodifiable.wrappedValue.isStale());
assertFalse(unmodifiable.isStale());
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/ValidatedObservableListTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/ValidatedObservableListTest.java
index 5a4867d..6a8e4d2 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/ValidatedObservableListTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/ValidatedObservableListTest.java
@@ -13,8 +13,6 @@
import java.util.ArrayList;
-import junit.framework.Test;
-
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.IObservableCollection;
import org.eclipse.core.databinding.observable.Realm;
@@ -29,9 +27,11 @@
import org.eclipse.jface.databinding.conformance.delegate.AbstractObservableCollectionContractDelegate;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import junit.framework.TestSuite;
+
public class ValidatedObservableListTest extends AbstractDefaultRealmTestCase {
- public static Test suite() {
- return MutableObservableListContractTest.suite(new Delegate());
+ public static void addConformanceTest(TestSuite suite) {
+ suite.addTest(MutableObservableListContractTest.suite(new Delegate()));
}
static class Delegate extends AbstractObservableCollectionContractDelegate {
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/ValidatedObservableSetTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/ValidatedObservableSetTest.java
index 5619d63..9d4478c 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/ValidatedObservableSetTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/ValidatedObservableSetTest.java
@@ -13,8 +13,6 @@
import java.util.Collections;
-import junit.framework.Test;
-
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.IObservableCollection;
import org.eclipse.core.databinding.observable.Realm;
@@ -29,9 +27,11 @@
import org.eclipse.jface.databinding.conformance.delegate.AbstractObservableCollectionContractDelegate;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import junit.framework.TestSuite;
+
public class ValidatedObservableSetTest extends AbstractDefaultRealmTestCase {
- public static Test suite() {
- return MutableObservableSetContractTest.suite(new Delegate());
+ public static void addConformanceTest(TestSuite suite) {
+ suite.addTest(MutableObservableSetContractTest.suite(new Delegate()));
}
static class Delegate extends AbstractObservableCollectionContractDelegate {
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/ValidatedObservableValueTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/ValidatedObservableValueTest.java
index 7083156..b0ff53a 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/ValidatedObservableValueTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/ValidatedObservableValueTest.java
@@ -11,8 +11,10 @@
package org.eclipse.core.tests.internal.databinding.observable;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import org.eclipse.core.databinding.observable.Diffs;
import org.eclipse.core.databinding.observable.IObservable;
@@ -28,6 +30,10 @@
import org.eclipse.jface.databinding.conformance.util.CurrentRealm;
import org.eclipse.jface.databinding.conformance.util.ValueChangeEventTracker;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Before;
+import org.junit.Test;
+
+import junit.framework.TestSuite;
/**
* @since 3.2
@@ -42,7 +48,8 @@
private Object newValue;
@Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
oldValue = new Object();
newValue = new Object();
@@ -53,6 +60,7 @@
validated = new ValidatedObservableValue(target, validationStatus);
}
+ @Test
public void testConstructor_RequireObservablesOnSameRealm() {
CurrentRealm realm1 = new CurrentRealm(true);
CurrentRealm realm2 = new CurrentRealm(true);
@@ -65,6 +73,7 @@
}
}
+ @Test
public void testIsStale_WhenTargetIsStale() {
assertFalse(target.isStale());
assertFalse(validated.isStale());
@@ -75,6 +84,7 @@
assertTrue(validated.isStale());
}
+ @Test
public void testIsStale_WhileChangesPending() {
assertFalse(target.isStale());
assertFalse(validated.isStale());
@@ -96,15 +106,18 @@
assertFalse(validated.isStale());
}
+ @Test
public void testGetValueType_SameAsTarget() {
assertEquals(target.getValueType(), validated.getValueType());
}
+ @Test
public void testGetValue_InitialValue() {
assertEquals(oldValue, target.getValue());
assertEquals(oldValue, validated.getValue());
}
+ @Test
public void testGetValue_WhileChangesPending() {
assertEquals(oldValue, target.getValue());
assertEquals(oldValue, validated.getValue());
@@ -124,6 +137,7 @@
assertEquals(newValue, validated.getValue());
}
+ @Test
public void testSetValue_PropagatesToTarget() {
validated.setValue(newValue);
@@ -131,6 +145,7 @@
assertEquals(newValue, target.getValue());
}
+ @Test
public void testSetValue_PropagatesToTargetWhileStatusNotOK() {
validationStatus.setValue(ValidationStatus.error("error"));
@@ -141,6 +156,7 @@
assertFalse(validated.isStale());
}
+ @Test
public void testSetValue_CachesGetValueFromTarget() {
Object overrideValue = target.overrideValue = new Object();
@@ -155,6 +171,7 @@
assertEquals(overrideValue, validated.getValue());
}
+ @Test
public void testSetValue_SingleValueChangeEvent() {
ValueChangeEventTracker tracker = ValueChangeEventTracker
.observe(validated);
@@ -165,6 +182,7 @@
assertEquals(newValue, tracker.event.diff.getNewValue());
}
+ @Test
public void testSetValue_SingleValueChangeEventWhileInvalid() {
ValueChangeEventTracker tracker = ValueChangeEventTracker
.observe(validated);
@@ -176,6 +194,7 @@
assertEquals(newValue, tracker.event.diff.getNewValue());
}
+ @Test
public void testSetValue_FiresSingleValueChangeEventWithTargetOverride() {
ValueChangeEventTracker tracker = ValueChangeEventTracker
.observe(validated);
@@ -189,6 +208,7 @@
assertEquals(overrideValue, tracker.event.diff.getNewValue());
}
+ @Test
public void testSetValue_FiresValueChangeEvent() {
ValueChangeEventTracker targetTracker = ValueChangeEventTracker
.observe(target);
@@ -206,6 +226,7 @@
assertEquals(newValue, validatedTracker.event.diff.getNewValue());
}
+ @Test
public void testIsStale_MatchTargetStaleness() {
target.forceStale = true;
target.fireStale();
@@ -262,11 +283,8 @@
}
}
- public static Test suite() {
- TestSuite suite = new TestSuite(ValidatedObservableValueTest.class.getName());
- suite.addTestSuite(ValidatedObservableValueTest.class);
+ public static void addConformanceTest(TestSuite suite) {
suite.addTest(MutableObservableValueContractTest.suite(new Delegate()));
- return suite;
}
static class Delegate extends AbstractObservableValueContractDelegate {
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/masterdetail/DetailObservableListTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/masterdetail/DetailObservableListTest.java
index fa556e2..8a2987b 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/masterdetail/DetailObservableListTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/masterdetail/DetailObservableListTest.java
@@ -14,12 +14,15 @@
package org.eclipse.core.tests.internal.databinding.observable.masterdetail;
+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 static org.junit.Assert.fail;
+
import java.util.ArrayList;
import java.util.Arrays;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.IObservableCollection;
import org.eclipse.core.databinding.observable.Realm;
@@ -37,6 +40,9 @@
import org.eclipse.jface.databinding.conformance.delegate.AbstractObservableCollectionContractDelegate;
import org.eclipse.jface.databinding.conformance.util.DisposeEventTracker;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Test;
+
+import junit.framework.TestSuite;
/**
* @since 3.2
@@ -48,6 +54,7 @@
*
* @throws Exception
*/
+ @Test
public void testElementTypeNull() throws Exception {
WritableValue observableValue = new WritableValue(new WritableList(
new ArrayList(), Object.class), null);
@@ -69,6 +76,7 @@
*
* @throws Exception
*/
+ @Test
public void testElementTypeNotNull() throws Exception {
WritableValue observableValue = new WritableValue(new WritableList(
new ArrayList(), Object.class), null);
@@ -91,6 +99,7 @@
* Asserts that the master observable value is not disposed upon disposing
* its detail observable value (bug 241318).
*/
+ @Test
public void testMasterNotDisposedWhenDetailDisposed() {
class OuterObservable extends WritableValue {
boolean disposed = false;
@@ -113,6 +122,7 @@
assertFalse(outerObservable.disposed);
}
+ @Test
public void testDisposeMasterDisposesDetail() {
IObservableValue master = new WritableValue();
WritableListFactory factory = new WritableListFactory();
@@ -129,6 +139,7 @@
assertTrue(detailObservable.isDisposed());
}
+ @Test
public void testDisposeWhileFiringEvents() {
IObservableValue master = new WritableValue();
WritableListFactory factory = new WritableListFactory();
@@ -158,12 +169,8 @@
}
}
- public static Test suite() {
- TestSuite suite = new TestSuite(DetailObservableListTest.class
- .getName());
- suite.addTestSuite(DetailObservableListTest.class);
+ public static void addConformanceTest(TestSuite suite) {
suite.addTest(MutableObservableListContractTest.suite(new Delegate()));
- return suite;
}
static class Delegate extends AbstractObservableCollectionContractDelegate {
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/masterdetail/DetailObservableMapTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/masterdetail/DetailObservableMapTest.java
index 8df8aa4..2ec7ec8 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/masterdetail/DetailObservableMapTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/masterdetail/DetailObservableMapTest.java
@@ -14,6 +14,12 @@
package org.eclipse.core.tests.internal.databinding.observable.masterdetail;
+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 static org.junit.Assert.fail;
+
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.map.IObservableMap;
import org.eclipse.core.databinding.observable.map.WritableMap;
@@ -27,6 +33,7 @@
import org.eclipse.core.runtime.AssertionFailedException;
import org.eclipse.jface.databinding.conformance.util.DisposeEventTracker;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Test;
/**
* @since 3.2
@@ -39,6 +46,7 @@
*
* @throws Exception
*/
+ @Test
public void testKeyValueTypeNull() throws Exception {
WritableValue observableValue = new WritableValue();
@@ -68,6 +76,7 @@
*
* @throws Exception
*/
+ @Test
public void testKeyValueTypeNotNull() throws Exception {
WritableValue observableValue = new WritableValue();
@@ -90,6 +99,7 @@
* Asserts that the master observable value is not disposed upon disposing
* its detail observable value (bug 241318).
*/
+ @Test
public void testMasterNotDisposedWhenDetailDisposed() {
class OuterObservable extends WritableValue {
boolean disposed = false;
@@ -112,6 +122,7 @@
assertFalse(outerObservable.disposed);
}
+ @Test
public void testDisposeMasterDisposesDetail() {
IObservableValue master = new WritableValue();
WritableMapFactory factory = new WritableMapFactory();
@@ -128,6 +139,7 @@
assertTrue(detailObservable.isDisposed());
}
+ @Test
public void testDisposeWhileFiringEvents() {
IObservableValue master = new WritableValue();
WritableMapFactory factory = new WritableMapFactory();
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/masterdetail/DetailObservableSetTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/masterdetail/DetailObservableSetTest.java
index a8c5200..7ec640e 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/masterdetail/DetailObservableSetTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/masterdetail/DetailObservableSetTest.java
@@ -14,13 +14,16 @@
package org.eclipse.core.tests.internal.databinding.observable.masterdetail;
+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 static org.junit.Assert.fail;
+
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.IObservableCollection;
import org.eclipse.core.databinding.observable.Realm;
@@ -38,6 +41,9 @@
import org.eclipse.jface.databinding.conformance.delegate.AbstractObservableCollectionContractDelegate;
import org.eclipse.jface.databinding.conformance.util.DisposeEventTracker;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Test;
+
+import junit.framework.TestSuite;
/**
* @since 3.2
@@ -50,6 +56,7 @@
*
* @throws Exception
*/
+ @Test
public void testElementTypeNull() throws Exception {
WritableValue observableValue = new WritableValue(new WritableSet(
new HashSet(), Object.class), null);
@@ -77,6 +84,7 @@
*
* @throws Exception
*/
+ @Test
public void testElementTypeNotNull() throws Exception {
WritableValue observableValue = new WritableValue(new WritableSet(
new HashSet(), Object.class), null);
@@ -99,6 +107,7 @@
* Asserts that the master observable value is not disposed upon disposing
* its detail observable value (bug 241318).
*/
+ @Test
public void testMasterNotDisposedWhenDetailDisposed() {
class OuterObservable extends WritableValue {
boolean disposed = false;
@@ -121,6 +130,7 @@
assertFalse(outerObservable.disposed);
}
+ @Test
public void testDisposeMasterDisposesDetail() {
IObservableValue master = new WritableValue();
WritableSetFactory factory = new WritableSetFactory();
@@ -137,6 +147,7 @@
assertTrue(detailObservable.isDisposed());
}
+ @Test
public void testDisposeWhileFiringEvents() {
IObservableValue master = new WritableValue();
WritableSetFactory factory = new WritableSetFactory();
@@ -166,11 +177,8 @@
}
}
- public static Test suite() {
- TestSuite suite = new TestSuite(DetailObservableSetTest.class.getName());
- suite.addTestSuite(DetailObservableSetTest.class);
+ public static void addConformanceTest(TestSuite suite) {
suite.addTest(MutableObservableSetContractTest.suite(new Delegate()));
- return suite;
}
static class Delegate extends AbstractObservableCollectionContractDelegate {
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/masterdetail/DetailObservableValueTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/masterdetail/DetailObservableValueTest.java
index 40f3227..402c053 100755
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/masterdetail/DetailObservableValueTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/masterdetail/DetailObservableValueTest.java
@@ -15,8 +15,10 @@
package org.eclipse.core.tests.internal.databinding.observable.masterdetail;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+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.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.Realm;
@@ -33,6 +35,10 @@
import org.eclipse.jface.databinding.conformance.util.DisposeEventTracker;
import org.eclipse.jface.databinding.conformance.util.RealmTester;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Before;
+import org.junit.Test;
+
+import junit.framework.TestSuite;
/**
* @since 3.2
@@ -41,11 +47,13 @@
private WritableValue outerObservable;
@Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
outerObservable = new WritableValue();
}
+ @Test
public void testSetValue() throws Exception {
WritableValueFactory factory = new WritableValueFactory();
outerObservable.setValue("");
@@ -60,6 +68,7 @@
assertEquals("inner value", value, innerObservable.getValue());
}
+ @Test
public void testGetValueType() throws Exception {
DetailObservableValue detailObservable = new DetailObservableValue(
outerObservable, null, String.class);
@@ -71,6 +80,7 @@
* type checking is performed and the value type is always <code>null</code>
* .
*/
+ @Test
public void testGetValueTypeNullValueType() throws Exception {
WritableValueFactory factory = new WritableValueFactory();
DetailObservableValue detailObservable = new DetailObservableValue(
@@ -95,6 +105,7 @@
* Asserts that the master observable value is not disposed upon disposing
* its detail observable value (bug 241318).
*/
+ @Test
public void testMasterNotDisposedWhenDetailDisposed() {
class OuterObservable extends WritableValue {
boolean disposed = false;
@@ -117,6 +128,7 @@
assertFalse(outerObservable.disposed);
}
+ @Test
public void testDisposeMasterDisposesDetail() {
IObservableValue master = new WritableValue();
WritableValueFactory factory = new WritableValueFactory();
@@ -133,6 +145,7 @@
assertTrue(detailObservable.isDisposed());
}
+ @Test
public void testDisposeWhileFiringEvents() {
IObservableValue master = new WritableValue();
WritableValueFactory factory = new WritableValueFactory();
@@ -168,12 +181,8 @@
}
}
- public static Test suite() {
- TestSuite suite = new TestSuite(DetailObservableValueTest.class
- .getName());
- suite.addTestSuite(DetailObservableValueTest.class);
+ public static void addConformanceTest(TestSuite suite) {
suite.addTest(MutableObservableValueContractTest.suite(new Delegate()));
- return suite;
}
private static class DetailObservableValueStub extends
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/masterdetail/ListDetailValueObservableListTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/masterdetail/ListDetailValueObservableListTest.java
index 13ecbce..f66de7e 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/masterdetail/ListDetailValueObservableListTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/masterdetail/ListDetailValueObservableListTest.java
@@ -11,13 +11,17 @@
package org.eclipse.core.tests.internal.databinding.observable.masterdetail;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.eclipse.core.databinding.beans.BeansObservables;
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.IObservableCollection;
@@ -34,6 +38,9 @@
import org.eclipse.jface.databinding.conformance.util.ListChangeEventTracker;
import org.eclipse.jface.examples.databinding.model.SimplePerson;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Test;
+
+import junit.framework.TestSuite;
/**
* @since 1.3
@@ -41,14 +48,11 @@
public class ListDetailValueObservableListTest extends
AbstractDefaultRealmTestCase {
- public static Test suite() {
- TestSuite suite = new TestSuite(
- ListDetailValueObservableListTest.class.getName());
- suite.addTestSuite(ListDetailValueObservableListTest.class);
+ public static void addConformanceTest(TestSuite suite) {
suite.addTest(ObservableListContractTest.suite(new Delegate()));
- return suite;
}
+ @Test
public void testUnmodifiability() {
WritableList masterObservableList = new WritableList();
masterObservableList.add(new SimplePerson());
@@ -93,6 +97,7 @@
}
}
+ @Test
public void testGetElementType() {
ListDetailValueObservableList ldol = new ListDetailValueObservableList(
new WritableList(), BeansObservables.valueFactory("name"),
@@ -101,6 +106,7 @@
assertSame(String.class, ldol.getElementType());
}
+ @Test
public void testGetObserved() {
WritableList masterList = new WritableList();
ListDetailValueObservableList ldol = new ListDetailValueObservableList(
@@ -110,6 +116,7 @@
assertSame(masterList, ldol.getObserved());
}
+ @Test
public void testMasterListInitiallyNotEmpty() {
WritableList masterList = new WritableList();
SimplePerson person = new SimplePerson();
@@ -123,6 +130,7 @@
assertEquals(person.getName(), ldol.get(0));
}
+ @Test
public void testAddRemove() {
WritableList masterList = new WritableList();
ListDetailValueObservableList ldol = new ListDetailValueObservableList(
@@ -156,6 +164,7 @@
assertTrue(ldol.isEmpty());
}
+ @Test
public void testChangeDetail() {
WritableList masterList = new WritableList();
ListDetailValueObservableList ldol = new ListDetailValueObservableList(
@@ -176,6 +185,7 @@
assertEquals(p2.getName(), ldol.get(0));
}
+ @Test
public void testSet() {
WritableList masterList = new WritableList();
ListDetailValueObservableList ldol = new ListDetailValueObservableList(
@@ -194,6 +204,7 @@
assertEquals(person.getName(), ldol.get(0));
}
+ @Test
public void testDuplicateMasterElements() {
WritableList masterList = new WritableList();
ListDetailValueObservableList ldol = new ListDetailValueObservableList(
@@ -228,6 +239,7 @@
assertEquals("name3", master.getName());
}
+ @Test
public void testDetailObservableChangeEvent() {
WritableList masterList = new WritableList();
ListDetailValueObservableList ldol = new ListDetailValueObservableList(
@@ -291,6 +303,7 @@
}
}
+ @Test
public void testMasterNull() {
WritableList masterObservableList = new WritableList();
ListDetailValueObservableList ldol = new ListDetailValueObservableList(
@@ -303,6 +316,7 @@
assertNull(ldol.get(0));
}
+ @Test
public void testDetailObservableValuesAreDisposed() {
final List detailObservables = new ArrayList();
IObservableFactory detailValueFactory = new IObservableFactory() {
@@ -340,6 +354,7 @@
assertTrue(((WritableValue) detailObservables.get(1)).isDisposed());
}
+ @Test
public void testDisposeOnMasterDisposed() {
WritableList masterList = new WritableList();
ListDetailValueObservableList ldol = new ListDetailValueObservableList(
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/masterdetail/MapDetailValueObservableMapTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/masterdetail/MapDetailValueObservableMapTest.java
index 5140e98..52433de 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/masterdetail/MapDetailValueObservableMapTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/masterdetail/MapDetailValueObservableMapTest.java
@@ -11,12 +11,15 @@
package org.eclipse.core.tests.internal.databinding.observable.masterdetail;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+
import java.util.HashMap;
import java.util.Map;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.eclipse.core.databinding.beans.BeansObservables;
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.map.WritableMap;
@@ -26,6 +29,7 @@
import org.eclipse.jface.databinding.conformance.util.MapChangeEventTracker;
import org.eclipse.jface.examples.databinding.model.SimplePerson;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Test;
/**
* @since 1.3
@@ -33,13 +37,7 @@
public class MapDetailValueObservableMapTest extends
AbstractDefaultRealmTestCase {
- public static Test suite() {
- TestSuite suite = new TestSuite(
- MapDetailValueObservableMapTest.class.getName());
- suite.addTestSuite(MapDetailValueObservableMapTest.class);
- return suite;
- }
-
+ @Test
public void testGetKeyType() {
MapDetailValueObservableMap mdom = new MapDetailValueObservableMap(
new WritableMap(SimplePerson.class, SimplePerson.class),
@@ -48,6 +46,7 @@
assertSame(SimplePerson.class, mdom.getKeyType());
}
+ @Test
public void testGetValueType() {
MapDetailValueObservableMap mdom = new MapDetailValueObservableMap(
new WritableMap(), BeansObservables.valueFactory("name"),
@@ -56,6 +55,7 @@
assertSame(String.class, mdom.getValueType());
}
+ @Test
public void testGetObserved() {
WritableMap masterMap = new WritableMap();
MapDetailValueObservableMap mdom = new MapDetailValueObservableMap(
@@ -65,6 +65,7 @@
assertSame(masterMap, mdom.getObserved());
}
+ @Test
public void testMasterSetInitiallyNotEmpty() {
WritableMap masterMap = new WritableMap();
SimplePerson person = new SimplePerson();
@@ -78,6 +79,7 @@
assertEquals(person.getName(), mdom.get(person));
}
+ @Test
public void testAddRemove() {
WritableMap masterMap = new WritableMap();
MapDetailValueObservableMap mdom = new MapDetailValueObservableMap(
@@ -111,6 +113,7 @@
assertTrue(mdom.isEmpty());
}
+ @Test
public void testChangeDetail() {
WritableMap masterMap = new WritableMap();
MapDetailValueObservableMap mdom = new MapDetailValueObservableMap(
@@ -131,6 +134,7 @@
assertEquals(p2.getName(), mdom.get(p1));
}
+ @Test
public void testPut() {
WritableMap masterMap = new WritableMap();
MapDetailValueObservableMap mdom = new MapDetailValueObservableMap(
@@ -149,6 +153,7 @@
assertEquals(person.getName(), mdom.get(person));
}
+ @Test
public void testContainsValue() {
WritableMap masterMap = new WritableMap();
MapDetailValueObservableMap mdom = new MapDetailValueObservableMap(
@@ -168,6 +173,7 @@
assertFalse(mdom.containsValue(person.getName()));
}
+ @Test
public void testRemove() {
WritableMap masterMap = new WritableMap();
MapDetailValueObservableMap mdom = new MapDetailValueObservableMap(
@@ -194,6 +200,7 @@
assertTrue(mdom.containsKey(p2));
}
+ @Test
public void testDetailObservableChangeEvent() {
WritableMap masterMap = new WritableMap();
MapDetailValueObservableMap mdom = new MapDetailValueObservableMap(
@@ -232,6 +239,7 @@
assertEquals("new name", changeTracker.event.diff.getNewValue(person));
}
+ @Test
public void testMasterNull() {
WritableMap masterMap = new WritableMap();
MapDetailValueObservableMap mdom = new MapDetailValueObservableMap(
@@ -243,6 +251,7 @@
assertNull(mdom.get(null));
}
+ @Test
public void testDetailObservableValuesAreDisposed() {
final Map detailObservables = new HashMap();
IObservableFactory detailValueFactory = new IObservableFactory() {
@@ -292,6 +301,7 @@
.isDisposed());
}
+ @Test
public void testDisposeOnMasterDisposed() {
WritableMap masterMap = new WritableMap();
MapDetailValueObservableMap mdom = new MapDetailValueObservableMap(
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/masterdetail/SetDetailValueObservableMapTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/masterdetail/SetDetailValueObservableMapTest.java
index b06950c..3fd7325 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/masterdetail/SetDetailValueObservableMapTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/observable/masterdetail/SetDetailValueObservableMapTest.java
@@ -11,12 +11,15 @@
package org.eclipse.core.tests.internal.databinding.observable.masterdetail;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+
import java.util.HashMap;
import java.util.Map;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.eclipse.core.databinding.beans.BeansObservables;
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.masterdetail.IObservableFactory;
@@ -26,6 +29,7 @@
import org.eclipse.jface.databinding.conformance.util.MapChangeEventTracker;
import org.eclipse.jface.examples.databinding.model.SimplePerson;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Test;
/**
* @since 1.3
@@ -33,13 +37,7 @@
public class SetDetailValueObservableMapTest extends
AbstractDefaultRealmTestCase {
- public static Test suite() {
- TestSuite suite = new TestSuite(SetDetailValueObservableMapTest.class
- .getName());
- suite.addTestSuite(SetDetailValueObservableMapTest.class);
- return suite;
- }
-
+ @Test
public void testGetValueType() {
SetDetailValueObservableMap sdom = new SetDetailValueObservableMap(
new WritableSet(), BeansObservables.valueFactory("name"),
@@ -48,6 +46,7 @@
assertSame(String.class, sdom.getValueType());
}
+ @Test
public void testGetObserved() {
WritableSet masterKeySet = new WritableSet();
SetDetailValueObservableMap sdom = new SetDetailValueObservableMap(
@@ -58,6 +57,7 @@
assertSame(masterKeySet, sdom.getObserved());
}
+ @Test
public void testMasterSetInitiallyNotEmpty() {
WritableSet masterKeySet = new WritableSet();
SimplePerson person = new SimplePerson();
@@ -72,6 +72,7 @@
assertEquals(person.getName(), sdom.get(person));
}
+ @Test
public void testAddRemove() {
WritableSet masterKeySet = new WritableSet();
SetDetailValueObservableMap sdom = new SetDetailValueObservableMap(
@@ -106,6 +107,7 @@
assertTrue(sdom.isEmpty());
}
+ @Test
public void testChangeDetail() {
WritableSet masterKeySet = new WritableSet();
SetDetailValueObservableMap sdom = new SetDetailValueObservableMap(
@@ -127,6 +129,7 @@
assertEquals(p2.getName(), sdom.get(p2));
}
+ @Test
public void testPut() {
WritableSet masterKeySet = new WritableSet();
SetDetailValueObservableMap sdom = new SetDetailValueObservableMap(
@@ -146,6 +149,7 @@
assertEquals(person.getName(), sdom.get(person));
}
+ @Test
public void testContainsValue() {
WritableSet masterKeySet = new WritableSet();
SetDetailValueObservableMap sdom = new SetDetailValueObservableMap(
@@ -166,6 +170,7 @@
assertFalse(sdom.containsValue(person.getName()));
}
+ @Test
public void testRemove() {
WritableSet masterKeySet = new WritableSet();
SetDetailValueObservableMap sdom = new SetDetailValueObservableMap(
@@ -193,6 +198,7 @@
assertTrue(sdom.containsKey(p2));
}
+ @Test
public void testDetailObservableChangeEvent() {
WritableSet masterKeySet = new WritableSet();
SetDetailValueObservableMap sdom = new SetDetailValueObservableMap(
@@ -232,6 +238,7 @@
assertEquals("new name", changeTracker.event.diff.getNewValue(person));
}
+ @Test
public void testMasterNull() {
WritableSet masterKeySet = new WritableSet();
SetDetailValueObservableMap sdom = new SetDetailValueObservableMap(
@@ -244,6 +251,7 @@
assertNull(sdom.get(null));
}
+ @Test
public void testDetailObservableValuesAreDisposed() {
final Map detailObservables = new HashMap();
IObservableFactory detailValueFactory = new IObservableFactory() {
@@ -293,6 +301,7 @@
.isDisposed());
}
+ @Test
public void testDisposeOnMasterDisposed() {
WritableSet masterKeySet = new WritableSet();
SetDetailValueObservableMap sdom = new SetDetailValueObservableMap(
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/property/value/ListSimpleValueObservableListTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/property/value/ListSimpleValueObservableListTest.java
index 8a02d8f..c1b7912 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/property/value/ListSimpleValueObservableListTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/property/value/ListSimpleValueObservableListTest.java
@@ -15,10 +15,12 @@
import org.eclipse.core.databinding.observable.list.WritableList;
import org.eclipse.core.tests.internal.databinding.beans.Bean;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Test;
public class ListSimpleValueObservableListTest extends
AbstractDefaultRealmTestCase {
+ @Test
public void testBug301410() {
BeanProperties.value(Bean.class, "value").observeDetail(
new WritableList()).dispose();
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/property/value/MapSimpleValueObservableMapTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/property/value/MapSimpleValueObservableMapTest.java
index 727b2ad..5c811ae 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/property/value/MapSimpleValueObservableMapTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/property/value/MapSimpleValueObservableMapTest.java
@@ -12,14 +12,19 @@
package org.eclipse.core.tests.internal.databinding.property.value;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+
import org.eclipse.core.databinding.observable.map.WritableMap;
import org.eclipse.core.internal.databinding.property.value.MapSimpleValueObservableMap;
import org.eclipse.core.internal.databinding.property.value.SelfValueProperty;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Test;
public class MapSimpleValueObservableMapTest extends
AbstractDefaultRealmTestCase {
+ @Test
public void testGetKeyValueType() {
WritableMap masterMap = new WritableMap(String.class, Integer.class);
SelfValueProperty detailProperty = new SelfValueProperty(Object.class);
@@ -31,6 +36,7 @@
assertEquals(detailProperty.getValueType(), detailMap.getValueType());
}
+ @Test
public void testPut_ReplacedOldValue() {
// Create any simple master map and detail property.
WritableMap masterMap = new WritableMap(String.class, Integer.class);
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/property/value/SetSimpleValueObservableMapTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/property/value/SetSimpleValueObservableMapTest.java
index c92e9b3..7a2443e 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/property/value/SetSimpleValueObservableMapTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/property/value/SetSimpleValueObservableMapTest.java
@@ -11,14 +11,18 @@
package org.eclipse.core.tests.internal.databinding.property.value;
+import static org.junit.Assert.assertEquals;
+
import org.eclipse.core.databinding.observable.set.WritableSet;
import org.eclipse.core.internal.databinding.property.value.SelfValueProperty;
import org.eclipse.core.internal.databinding.property.value.SetSimpleValueObservableMap;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Test;
public class SetSimpleValueObservableMapTest extends
AbstractDefaultRealmTestCase {
+ @Test
public void testGetKeyValueType() {
WritableSet masterSet = WritableSet.withElementType(String.class);
SelfValueProperty detailProperty = new SelfValueProperty(Object.class);
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/validation/AbstractStringToNumberValidatorTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/validation/AbstractStringToNumberValidatorTest.java
index 4cd3abb..d1c87f7 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/validation/AbstractStringToNumberValidatorTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/validation/AbstractStringToNumberValidatorTest.java
@@ -11,12 +11,14 @@
package org.eclipse.core.tests.internal.databinding.validation;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import org.eclipse.core.databinding.conversion.StringToNumberConverter;
import org.eclipse.core.internal.databinding.validation.AbstractStringToNumberValidator;
import org.eclipse.core.internal.databinding.validation.NumberFormatConverter;
import org.eclipse.core.runtime.IStatus;
+import org.junit.Test;
/**
* Tests for AbstractStringToNumberValidator. Most tests should be included in
@@ -24,12 +26,13 @@
*
* @since 3.2
*/
-public class AbstractStringToNumberValidatorTest extends TestCase {
+public class AbstractStringToNumberValidatorTest {
/**
* Test for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=194353.
*
* @throws Exception
*/
+ @Test
public void testErrorMessagesAreNotCached() throws Exception {
NumberFormatConverter c = StringToNumberConverter.toInteger(false);
ValidatorStub v = new ValidatorStub(c);
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/validation/NumberToNumberValidatorTestHarness.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/validation/NumberToNumberValidatorTestHarness.java
index abd3cd1..4ed2832 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/validation/NumberToNumberValidatorTestHarness.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/validation/NumberToNumberValidatorTestHarness.java
@@ -11,25 +11,30 @@
package org.eclipse.core.tests.internal.databinding.validation;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import org.eclipse.core.databinding.validation.IValidator;
import org.eclipse.core.internal.databinding.validation.NumberToNumberValidator;
import org.eclipse.core.runtime.IStatus;
+import org.junit.Test;
/**
* @since 1.1
*/
-public abstract class NumberToNumberValidatorTestHarness extends TestCase {
+public abstract class NumberToNumberValidatorTestHarness {
protected abstract NumberToNumberValidator doGetToPrimitiveValidator(Class fromType);
protected abstract NumberToNumberValidator doGetToBoxedTypeValidator(Class fromType);
protected abstract Number doGetOutOfRangeNumber();
+ @Test
public void testValidateNullForBoxedTypeIsOK() throws Exception {
IStatus status = doGetToBoxedTypeValidator(Integer.class).validate(null);
assertTrue(status.isOK());
}
+ @Test
public void testValidateNullForPrimitiveThrowsIllegalArgumentException()
throws Exception {
IValidator validator = doGetToPrimitiveValidator(Integer.class);
@@ -47,10 +52,12 @@
}
}
+ @Test
public void testValidReturnsOK() throws Exception {
assertTrue(doGetToBoxedTypeValidator(Integer.class).validate(Integer.valueOf(1)).isOK());
}
+ @Test
public void testOutOfRangeReturnsError() throws Exception {
Number number = doGetOutOfRangeNumber();
@@ -65,6 +72,7 @@
assertTrue(status.getMessage() != null);
}
+ @Test
public void testValidateIncorrectTypeThrowsIllegalArgumentException() throws Exception {
try {
doGetToBoxedTypeValidator(Integer.class).validate("");
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/validation/StringToCharacterValidatorTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/validation/StringToCharacterValidatorTest.java
index 7e30325..5492be4 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/validation/StringToCharacterValidatorTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/validation/StringToCharacterValidatorTest.java
@@ -11,22 +11,24 @@
package org.eclipse.core.tests.internal.databinding.validation;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import org.eclipse.core.internal.databinding.conversion.StringToCharacterConverter;
import org.eclipse.core.internal.databinding.validation.StringToCharacterValidator;
+import org.junit.Before;
+import org.junit.Test;
/**
* @since 1.1
*/
-public class StringToCharacterValidatorTest extends TestCase {
+public class StringToCharacterValidatorTest {
private StringToCharacterValidator validator;
private StringToCharacterValidator primitiveValidator;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
StringToCharacterConverter converter = StringToCharacterConverter
.toCharacter(false);
StringToCharacterConverter primitiveConverter = StringToCharacterConverter
@@ -35,30 +37,37 @@
primitiveValidator = new StringToCharacterValidator(primitiveConverter);
}
+ @Test
public void testValidatesCharacter() throws Exception {
assertTrue(validator.validate("X").isOK());
}
+ @Test
public void testValidatesCharacterPrimitive() throws Exception {
assertTrue(primitiveValidator.validate("X").isOK());
}
+ @Test
public void testNullCharacterIsValid() throws Exception {
assertTrue(validator.validate(null).isOK());
}
+ @Test
public void testEmptyStringCharacterIsValid() throws Exception {
assertTrue(validator.validate("").isOK());
}
+ @Test
public void testNullCharacterIsInvalidForPrimitive() throws Exception {
assertFalse(primitiveValidator.validate(null).isOK());
}
+ @Test
public void testNonStringIsInvalid() throws Exception {
assertFalse(primitiveValidator.validate(Integer.valueOf(4)).isOK());
}
+ @Test
public void testLongerThanOneCharacterIsInvalid() throws Exception {
assertFalse(primitiveValidator.validate("XYZ").isOK());
}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/validation/StringToNumberValidatorTestHarness.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/validation/StringToNumberValidatorTestHarness.java
index 549d157..0ab2362 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/validation/StringToNumberValidatorTestHarness.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/validation/StringToNumberValidatorTestHarness.java
@@ -11,10 +11,16 @@
package org.eclipse.core.tests.internal.databinding.validation;
-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.core.databinding.validation.IValidator;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.tests.databinding.BindingTestSetup;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
import com.ibm.icu.text.NumberFormat;
@@ -23,13 +29,15 @@
*
* @since 1.1
*/
-public abstract class StringToNumberValidatorTestHarness extends TestCase {
+public abstract class StringToNumberValidatorTestHarness {
private NumberFormat numberFormat;
private IValidator validator;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Rule
+ public BindingTestSetup testSetup = new BindingTestSetup();
+
+ @Before
+ public void setUp() throws Exception {
numberFormat = setupNumberFormat();
validator = setupValidator(numberFormat);
@@ -71,12 +79,14 @@
*/
protected abstract Number getInRangeNumber();
+ @Test
public void testInvalidValueReturnsError() throws Exception {
IStatus status = validator.validate(getInvalidString());
- assertEquals("error severify", IStatus.ERROR, status.getSeverity());
+ assertEquals("error severity", IStatus.ERROR, status.getSeverity());
assertNotNull("message not null", status.getMessage());
}
+ @Test
public void testOutOfRangeValueReturnsError() throws Exception {
String string = numberFormat.format(getOutOfRangeNumber());
IStatus status = validator.validate(string);
@@ -84,6 +94,7 @@
assertNotNull(status.getMessage());
}
+ @Test
public void testValidateValidValue() throws Exception {
String string = numberFormat.format(getInRangeNumber());
assertTrue(validator.validate(string).isOK());
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/AbstractDefaultRealmTestCase.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/AbstractDefaultRealmTestCase.java
index 43f678c..e9c0059 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/AbstractDefaultRealmTestCase.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/AbstractDefaultRealmTestCase.java
@@ -15,25 +15,26 @@
import org.eclipse.jface.databinding.conformance.util.RealmTester;
import org.eclipse.jface.databinding.swt.DisplayRealm;
import org.eclipse.swt.widgets.Display;
-
-import junit.framework.TestCase;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
/**
* Base class that sets the default realm to be the SWT realm.
*
* @since 3.3
*/
-public abstract class AbstractDefaultRealmTestCase extends TestCase {
+public abstract class AbstractDefaultRealmTestCase {
private Realm previousRealm;
+ @Rule
+ public BindingTestSetup testSetup = new BindingTestSetup();
+
/**
* Sets the default realm to be the realm for the default display.
- *
- * @see junit.framework.TestCase#setUp()
*/
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
previousRealm = Realm.getDefault();
@@ -56,9 +57,8 @@
/**
* Removes the default realm.
*/
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
+ @After
+ public void tearDown() throws Exception {
RealmTester.setDefault(previousRealm);
}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/AbstractJUnit4RealmTestCase.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/AbstractJUnit4RealmTestCase.java
deleted file mode 100644
index eec4600..0000000
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/AbstractJUnit4RealmTestCase.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Brad Reynolds 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:
- * Brad Reynolds - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.jface.tests.databinding;
-
-import org.eclipse.core.databinding.observable.Realm;
-import org.eclipse.jface.databinding.conformance.util.RealmTester;
-import org.eclipse.jface.databinding.swt.DisplayRealm;
-import org.eclipse.swt.widgets.Display;
-import org.junit.After;
-import org.junit.Before;
-
-/**
- * Base class that sets the default realm to be the SWT realm.
- *
- * @since 3.3
- */
-public class AbstractJUnit4RealmTestCase {
- private Realm previousRealm;
-
- /**
- * Sets the default realm to be the realm for the default display.
- *
- * @see junit.framework.TestCase#setUp()
- */
- @Before
- public void setUp() throws Exception {
-
- previousRealm = Realm.getDefault();
-
- Display display = Display.getCurrent() != null
- && !Display.getCurrent().isDisposed() ? Display.getCurrent()
- : Display.getDefault();
- RealmTester.setDefault(DisplayRealm.getRealm(display));
- }
-
- /**
- * Runs all currently-enqueued asynchronous events
- */
- protected void runAsync() {
- Display display = Display.getCurrent();
-
- while (display.readAndDispatch()) {
- }
- }
-
- /**
- * Removes the default realm.
- */
- @After
- public void tearDown() throws Exception {
- RealmTester.setDefault(previousRealm);
- }
-}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/AbstractSWTTestCase.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/AbstractSWTTestCase.java
index 4c509fd..a21d4dd 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/AbstractSWTTestCase.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/AbstractSWTTestCase.java
@@ -13,6 +13,8 @@
package org.eclipse.jface.tests.databinding;
import org.eclipse.swt.widgets.Shell;
+import org.junit.After;
+import org.junit.Before;
/**
* Abstract test case that handles disposing of the Shell after each test.
@@ -23,12 +25,14 @@
private Shell shell;
@Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
}
@Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
if (shell != null && !shell.isDisposed()) {
shell.dispose();
}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/BindingTestSetup.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/BindingTestSetup.java
index ac99e6f..f2b8d7c 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/BindingTestSetup.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/BindingTestSetup.java
@@ -11,63 +11,48 @@
package org.eclipse.jface.tests.databinding;
+import static org.junit.Assert.fail;
+
import java.util.Locale;
import org.eclipse.core.databinding.util.ILogger;
import org.eclipse.core.databinding.util.Policy;
import org.eclipse.core.runtime.IStatus;
-
-import junit.extensions.TestSetup;
-import junit.framework.Test;
+import org.junit.rules.TestWatcher;
+import org.junit.runner.Description;
/**
* @since 3.2
*
*/
-public class BindingTestSetup extends TestSetup {
+public class BindingTestSetup extends TestWatcher {
private Locale oldLocale;
private ILogger oldLogger;
private org.eclipse.jface.util.ILogger oldJFaceLogger;
- public BindingTestSetup(Test test) {
- super(test);
- }
-
@Override
- protected void setUp() throws Exception {
- super.setUp();
+ protected void starting(Description description) {
oldLocale = Locale.getDefault();
Locale.setDefault(Locale.US);
oldLogger = Policy.getLog();
- Policy.setLog(new ILogger() {
- @Override
- public void log(IStatus status) {
- // we are not expecting anything in the log while we test.
- if (status.getException() != null) {
- throw new RuntimeException(status.getException());
- }
- fail();
- }
- });
+ Policy.setLog(this::log);
oldJFaceLogger = org.eclipse.jface.util.Policy.getLog();
- org.eclipse.jface.util.Policy.setLog(new org.eclipse.jface.util.ILogger(){
- @Override
- public void log(IStatus status) {
- // we are not expecting anything in the log while we test.
- if (status.getException() != null) {
- throw new RuntimeException(status.getException());
- }
- fail();
- }
- });
+ org.eclipse.jface.util.Policy.setLog(this::log);
}
@Override
- protected void tearDown() throws Exception {
+ protected void finished(Description description) {
Locale.setDefault(oldLocale);
Policy.setLog(oldLogger);
org.eclipse.jface.util.Policy.setLog(oldJFaceLogger);
- super.tearDown();
+ }
+
+ private void log(IStatus status) {
+ // we are not expecting anything in the log while we test.
+ if (status.getException() != null) {
+ throw new RuntimeException(status.getException());
+ }
+ fail();
}
}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/BindingTestSuite.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/BindingTestSuite.java
index cd4ed20..841028c 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/BindingTestSuite.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/BindingTestSuite.java
@@ -23,36 +23,265 @@
*******************************************************************************/
package org.eclipse.jface.tests.databinding;
+import org.eclipse.core.tests.databinding.AggregateValidationStatusTest;
+import org.eclipse.core.tests.databinding.BindingTest;
+import org.eclipse.core.tests.databinding.DatabindingContextTest;
+import org.eclipse.core.tests.databinding.ListBindingTest;
+import org.eclipse.core.tests.databinding.ObservablesManagerTest;
import org.eclipse.core.tests.databinding.SideEffectTest;
+import org.eclipse.core.tests.databinding.UpdateListStrategyTest;
+import org.eclipse.core.tests.databinding.UpdateSetStrategyTest;
+import org.eclipse.core.tests.databinding.UpdateStrategyTest;
+import org.eclipse.core.tests.databinding.UpdateValueStrategyTest;
+import org.eclipse.core.tests.databinding.ValueBindingTest;
+import org.eclipse.core.tests.databinding.beans.AnonymousBeanValuePropertyTest;
+import org.eclipse.core.tests.databinding.beans.AnonymousPojoValuePropertyTest;
+import org.eclipse.core.tests.databinding.beans.BeanPropertiesTest;
+import org.eclipse.core.tests.databinding.beans.BeansObservablesTest;
+import org.eclipse.core.tests.databinding.beans.PojoObservablesTest;
+import org.eclipse.core.tests.databinding.beans.PojoPropertiesTest;
+import org.eclipse.core.tests.databinding.beans.SetOnlyJavaBeanTest;
+import org.eclipse.core.tests.databinding.conversion.NumberToStringConverterTest;
+import org.eclipse.core.tests.databinding.conversion.StringToNumberConverterTest;
+import org.eclipse.core.tests.databinding.observable.AbstractObservableTest;
+import org.eclipse.core.tests.databinding.observable.ChangeSupportTest;
+import org.eclipse.core.tests.databinding.observable.DecoratingObservableTest;
+import org.eclipse.core.tests.databinding.observable.DiffsTest;
+import org.eclipse.core.tests.databinding.observable.Diffs_ListDiffTests;
+import org.eclipse.core.tests.databinding.observable.ObservableTrackerTest;
+import org.eclipse.core.tests.databinding.observable.ObservablesTest;
+import org.eclipse.core.tests.databinding.observable.RealmTest;
+import org.eclipse.core.tests.databinding.observable.list.AbstractObservableListTest;
+import org.eclipse.core.tests.databinding.observable.list.ComputedListTest;
+import org.eclipse.core.tests.databinding.observable.list.ListDiffTest;
+import org.eclipse.core.tests.databinding.observable.list.ListDiffVisitorTest;
+import org.eclipse.core.tests.databinding.observable.list.MultiListTest;
+import org.eclipse.core.tests.databinding.observable.list.ObservableListTest;
+import org.eclipse.core.tests.databinding.observable.list.WritableListTest;
+import org.eclipse.core.tests.databinding.observable.map.AbstractObservableMapTest;
+import org.eclipse.core.tests.databinding.observable.map.BidiObservableMapTest;
+import org.eclipse.core.tests.databinding.observable.map.CompositeMapTest;
+import org.eclipse.core.tests.databinding.observable.map.ComputedObservableMapTest;
+import org.eclipse.core.tests.databinding.observable.map.ObservableMapTest;
+import org.eclipse.core.tests.databinding.observable.map.WritableMapTest;
+import org.eclipse.core.tests.databinding.observable.set.ComputedSetTest;
+import org.eclipse.core.tests.databinding.observable.set.WritableSetTest;
+import org.eclipse.core.tests.databinding.observable.value.AbstractObservableValueTest;
+import org.eclipse.core.tests.databinding.observable.value.AbstractVetoableValueTest;
+import org.eclipse.core.tests.databinding.observable.value.ComputedValueTest;
+import org.eclipse.core.tests.databinding.observable.value.DateAndTimeObservableValueTest;
+import org.eclipse.core.tests.databinding.observable.value.DuplexingObservableValueTest;
+import org.eclipse.core.tests.databinding.observable.value.WritableValueTest;
+import org.eclipse.core.tests.databinding.util.PolicyTest;
+import org.eclipse.core.tests.databinding.validation.MultiValidatorTest;
+import org.eclipse.core.tests.databinding.validation.ValidationStatusTest;
+import org.eclipse.core.tests.internal.databinding.BindingMessagesTest;
+import org.eclipse.core.tests.internal.databinding.BindingStatusTest;
+import org.eclipse.core.tests.internal.databinding.ConverterValuePropertyTest;
+import org.eclipse.core.tests.internal.databinding.DifferentRealmsBindingTest;
+import org.eclipse.core.tests.internal.databinding.IdentityMapTest;
+import org.eclipse.core.tests.internal.databinding.IdentitySetTest;
+import org.eclipse.core.tests.internal.databinding.QueueTest;
+import org.eclipse.core.tests.internal.databinding.beans.BeanObservableListDecoratorTest;
+import org.eclipse.core.tests.internal.databinding.beans.BeanObservableSetDecoratorTest;
+import org.eclipse.core.tests.internal.databinding.beans.BeanObservableValueDecoratorTest;
+import org.eclipse.core.tests.internal.databinding.beans.BeanPropertyHelperTest;
+import org.eclipse.core.tests.internal.databinding.beans.BeanPropertyListenerSupportTest;
+import org.eclipse.core.tests.internal.databinding.beans.BeanPropertyListenerTest;
+import org.eclipse.core.tests.internal.databinding.beans.BeanValuePropertyTest;
+import org.eclipse.core.tests.internal.databinding.beans.JavaBeanObservableArrayBasedListTest;
+import org.eclipse.core.tests.internal.databinding.beans.JavaBeanObservableArrayBasedSetTest;
+import org.eclipse.core.tests.internal.databinding.beans.JavaBeanObservableListTest;
+import org.eclipse.core.tests.internal.databinding.beans.JavaBeanObservableMapTest;
+import org.eclipse.core.tests.internal.databinding.beans.JavaBeanObservableSetTest;
+import org.eclipse.core.tests.internal.databinding.beans.JavaBeanObservableValueTest;
+import org.eclipse.core.tests.internal.databinding.beans.JavaBeanPropertyObservableMapTest;
+import org.eclipse.core.tests.internal.databinding.conversion.DateConversionSupportTest;
+import org.eclipse.core.tests.internal.databinding.conversion.IdentityConverterTest;
+import org.eclipse.core.tests.internal.databinding.conversion.IntegerToStringConverterTest;
+import org.eclipse.core.tests.internal.databinding.conversion.NumberToBigDecimalTest;
+import org.eclipse.core.tests.internal.databinding.conversion.NumberToBigIntegerConverterTest;
+import org.eclipse.core.tests.internal.databinding.conversion.NumberToByteConverterTest;
+import org.eclipse.core.tests.internal.databinding.conversion.NumberToDoubleConverterTest;
+import org.eclipse.core.tests.internal.databinding.conversion.NumberToFloatConverterTest;
+import org.eclipse.core.tests.internal.databinding.conversion.NumberToIntegerConverterTest;
+import org.eclipse.core.tests.internal.databinding.conversion.NumberToLongConverterTest;
+import org.eclipse.core.tests.internal.databinding.conversion.NumberToShortConverterTest;
+import org.eclipse.core.tests.internal.databinding.conversion.ObjectToPrimitiveValidatorTest;
+import org.eclipse.core.tests.internal.databinding.conversion.StatusToStringConverterTest;
+import org.eclipse.core.tests.internal.databinding.conversion.StringToBooleanConverterTest;
+import org.eclipse.core.tests.internal.databinding.conversion.StringToByteConverterTest;
+import org.eclipse.core.tests.internal.databinding.conversion.StringToCharacterConverterTest;
+import org.eclipse.core.tests.internal.databinding.conversion.StringToNumberParserByteTest;
+import org.eclipse.core.tests.internal.databinding.conversion.StringToNumberParserDoubleTest;
+import org.eclipse.core.tests.internal.databinding.conversion.StringToNumberParserFloatTest;
+import org.eclipse.core.tests.internal.databinding.conversion.StringToNumberParserIntegerTest;
+import org.eclipse.core.tests.internal.databinding.conversion.StringToNumberParserLongTest;
+import org.eclipse.core.tests.internal.databinding.conversion.StringToNumberParserShortTest;
+import org.eclipse.core.tests.internal.databinding.conversion.StringToNumberParserTest;
+import org.eclipse.core.tests.internal.databinding.conversion.StringToShortConverterTest;
+import org.eclipse.core.tests.internal.databinding.observable.ConstantObservableValueTest;
+import org.eclipse.core.tests.internal.databinding.observable.DelayedObservableValueTest;
+import org.eclipse.core.tests.internal.databinding.observable.MapEntryObservableValueTest;
+import org.eclipse.core.tests.internal.databinding.observable.UnmodifiableObservableListTest;
+import org.eclipse.core.tests.internal.databinding.observable.UnmodifiableObservableSetTest;
+import org.eclipse.core.tests.internal.databinding.observable.UnmodifiableObservableValueTest;
+import org.eclipse.core.tests.internal.databinding.observable.ValidatedObservableValueTest;
+import org.eclipse.core.tests.internal.databinding.observable.masterdetail.DetailObservableListTest;
+import org.eclipse.core.tests.internal.databinding.observable.masterdetail.DetailObservableMapTest;
+import org.eclipse.core.tests.internal.databinding.observable.masterdetail.DetailObservableSetTest;
+import org.eclipse.core.tests.internal.databinding.observable.masterdetail.DetailObservableValueTest;
+import org.eclipse.core.tests.internal.databinding.observable.masterdetail.ListDetailValueObservableListTest;
+import org.eclipse.core.tests.internal.databinding.observable.masterdetail.MapDetailValueObservableMapTest;
+import org.eclipse.core.tests.internal.databinding.observable.masterdetail.SetDetailValueObservableMapTest;
+import org.eclipse.core.tests.internal.databinding.property.value.ListSimpleValueObservableListTest;
+import org.eclipse.core.tests.internal.databinding.property.value.MapSimpleValueObservableMapTest;
+import org.eclipse.core.tests.internal.databinding.property.value.SetSimpleValueObservableMapTest;
+import org.eclipse.core.tests.internal.databinding.validation.AbstractStringToNumberValidatorTest;
+import org.eclipse.core.tests.internal.databinding.validation.NumberToByteValidatorTest;
+import org.eclipse.core.tests.internal.databinding.validation.NumberToDoubleValidatorTest;
+import org.eclipse.core.tests.internal.databinding.validation.NumberToFloatValidatorTest;
+import org.eclipse.core.tests.internal.databinding.validation.NumberToIntegerValidatorTest;
+import org.eclipse.core.tests.internal.databinding.validation.NumberToLongValidatorTest;
+import org.eclipse.core.tests.internal.databinding.validation.NumberToShortValidatorTest;
+import org.eclipse.core.tests.internal.databinding.validation.NumberToUnboundedNumberValidatorTest;
+import org.eclipse.core.tests.internal.databinding.validation.StringToByteValidatorTest;
+import org.eclipse.core.tests.internal.databinding.validation.StringToCharacterValidatorTest;
+import org.eclipse.core.tests.internal.databinding.validation.StringToDoubleValidatorTest;
+import org.eclipse.core.tests.internal.databinding.validation.StringToFloatValidatorTest;
+import org.eclipse.core.tests.internal.databinding.validation.StringToIntegerValidatorTest;
+import org.eclipse.core.tests.internal.databinding.validation.StringToLongValidatorTest;
+import org.eclipse.core.tests.internal.databinding.validation.StringToShortValidatorTest;
+import org.eclipse.jface.tests.databinding.preference.PreferencePageSupportTest;
+import org.eclipse.jface.tests.databinding.scenarios.BindingScenariosTestSuite;
+import org.eclipse.jface.tests.databinding.swt.SWTObservablesTest;
+import org.eclipse.jface.tests.databinding.swt.WidgetObservableThreadTest;
+import org.eclipse.jface.tests.databinding.swt.WidgetPropertiesTest;
+import org.eclipse.jface.tests.databinding.viewers.ObservableListContentProviderTest;
+import org.eclipse.jface.tests.databinding.viewers.ObservableListTreeContentProviderTest;
+import org.eclipse.jface.tests.databinding.viewers.ObservableMapLabelProviderTest;
+import org.eclipse.jface.tests.databinding.viewers.ObservableSetContentProviderTest;
+import org.eclipse.jface.tests.databinding.viewers.ObservableSetTreeContentProviderTest;
+import org.eclipse.jface.tests.databinding.viewers.ObservableValueEditingSupportTest;
+import org.eclipse.jface.tests.databinding.viewers.ViewerSupportTest;
+import org.eclipse.jface.tests.databinding.viewers.ViewersObservablesTest;
+import org.eclipse.jface.tests.databinding.wizard.WizardPageSupportTest;
+import org.eclipse.jface.tests.examples.databinding.mask.internal.EditMaskLexerAndTokenTest;
+import org.eclipse.jface.tests.examples.databinding.mask.internal.EditMaskParserTest;
+import org.eclipse.jface.tests.internal.databinding.swt.ButtonObservableValueTest;
+import org.eclipse.jface.tests.internal.databinding.swt.CComboObservableValueSelectionTest;
+import org.eclipse.jface.tests.internal.databinding.swt.CComboObservableValueTest;
+import org.eclipse.jface.tests.internal.databinding.swt.CComboObservableValueTextTest;
+import org.eclipse.jface.tests.internal.databinding.swt.CComboSingleSelectionObservableValueTest;
+import org.eclipse.jface.tests.internal.databinding.swt.CLabelObservableValueTest;
+import org.eclipse.jface.tests.internal.databinding.swt.ComboObservableValueSelectionTest;
+import org.eclipse.jface.tests.internal.databinding.swt.ComboObservableValueTest;
+import org.eclipse.jface.tests.internal.databinding.swt.ComboObservableValueTextTest;
+import org.eclipse.jface.tests.internal.databinding.swt.ComboSingleSelectionObservableValueTest;
+import org.eclipse.jface.tests.internal.databinding.swt.ControlObservableValueTest;
+import org.eclipse.jface.tests.internal.databinding.swt.DateTimeCalendarObservableValueTest;
+import org.eclipse.jface.tests.internal.databinding.swt.DateTimeDateObservableValueTest;
+import org.eclipse.jface.tests.internal.databinding.swt.DateTimeSelectionPropertyTest;
+import org.eclipse.jface.tests.internal.databinding.swt.DateTimeTimeObservableValueTest;
+import org.eclipse.jface.tests.internal.databinding.swt.GroupObservableValueTest;
+import org.eclipse.jface.tests.internal.databinding.swt.LabelObservableValueTest;
+import org.eclipse.jface.tests.internal.databinding.swt.ListSingleSelectionObservableValueTest;
+import org.eclipse.jface.tests.internal.databinding.swt.SWTDelayedObservableValueDecoratorTest;
+import org.eclipse.jface.tests.internal.databinding.swt.ScaleObservableValueMaxTest;
+import org.eclipse.jface.tests.internal.databinding.swt.ScaleObservableValueMinTest;
+import org.eclipse.jface.tests.internal.databinding.swt.ScaleObservableValueSelectionTest;
+import org.eclipse.jface.tests.internal.databinding.swt.ShellObservableValueTest;
+import org.eclipse.jface.tests.internal.databinding.swt.SpinnerObservableValueMaxTest;
+import org.eclipse.jface.tests.internal.databinding.swt.SpinnerObservableValueMinTest;
+import org.eclipse.jface.tests.internal.databinding.swt.SpinnerObservableValueSelectionTest;
+import org.eclipse.jface.tests.internal.databinding.swt.SpinnerObservableValueTest;
+import org.eclipse.jface.tests.internal.databinding.swt.StyledTextObservableValueFocusOutTest;
+import org.eclipse.jface.tests.internal.databinding.swt.StyledTextObservableValueTest;
+import org.eclipse.jface.tests.internal.databinding.swt.TableObservableValueTest;
+import org.eclipse.jface.tests.internal.databinding.swt.TableSingleSelectionObservableValueTest;
+import org.eclipse.jface.tests.internal.databinding.swt.TextEditableObservableValueTest;
+import org.eclipse.jface.tests.internal.databinding.swt.TextObservableValueFocusOutTest;
+import org.eclipse.jface.tests.internal.databinding.swt.TextObservableValueTest;
+import org.eclipse.jface.tests.internal.databinding.viewers.CheckableCheckedElementsObservableSetTest;
+import org.eclipse.jface.tests.internal.databinding.viewers.ObservableCollectionContentProviderTest;
+import org.eclipse.jface.tests.internal.databinding.viewers.ObservableCollectionTreeContentProviderTest;
+import org.eclipse.jface.tests.internal.databinding.viewers.SelectionProviderMultiSelectionObservableListTest;
+import org.eclipse.jface.tests.internal.databinding.viewers.SelectionProviderSingleSelectionObservableValueTest;
+import org.eclipse.jface.tests.internal.databinding.viewers.ViewerElementMapTest;
+import org.eclipse.jface.tests.internal.databinding.viewers.ViewerElementSetTest;
+import org.eclipse.jface.tests.internal.databinding.viewers.ViewerElementWrapperTest;
+import org.eclipse.jface.tests.internal.databinding.viewers.ViewerInputObservableValueTest;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
-
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class)
-@Suite.SuiteClasses({ BindingTestSuiteJunit3.class, SideEffectTest.class })
+@SuiteClasses({ AbstractObservableListTest.class, AbstractObservableMapTest.class, AbstractObservableTest.class,
+ AbstractObservableValueTest.class, AbstractStringToNumberValidatorTest.class, AbstractVetoableValueTest.class,
+ AggregateValidationStatusTest.class, AnonymousBeanValuePropertyTest.class, AnonymousPojoValuePropertyTest.class,
+ BeanObservableListDecoratorTest.class, BeanObservableListDecoratorTest.class,
+ BeanObservableSetDecoratorTest.class, BeanObservableValueDecoratorTest.class, BeanPropertiesTest.class,
+ BeanPropertyHelperTest.class, BeanPropertyListenerSupportTest.class, BeanPropertyListenerTest.class,
+ BeansObservablesTest.class, BeanValuePropertyTest.class, BidiObservableMapTest.class, BindingMessagesTest.class,
+ BindingScenariosTestSuite.class, BindingStatusTest.class, BindingTest.class, BindingTestSuiteJunit3.class,
+ ButtonObservableValueTest.class, CComboObservableValueSelectionTest.class, CComboObservableValueTest.class,
+ CComboObservableValueTextTest.class, CComboSingleSelectionObservableValueTest.class,
+ CComboSingleSelectionObservableValueTest.class, ChangeSupportTest.class,
+ CheckableCheckedElementsObservableSetTest.class, CLabelObservableValueTest.class,
+ ComboObservableValueSelectionTest.class, ComboObservableValueTest.class, ComboObservableValueTextTest.class,
+ ComboSingleSelectionObservableValueTest.class, CompositeMapTest.class, ComputedListTest.class,
+ ComputedObservableMapTest.class, ComputedSetTest.class, ComputedValueTest.class,
+ ConstantObservableValueTest.class, ControlObservableValueTest.class, ConverterValuePropertyTest.class,
+ DatabindingContextTest.class, DateAndTimeObservableValueTest.class, DateConversionSupportTest.class,
+ DateTimeCalendarObservableValueTest.class, DateTimeDateObservableValueTest.class,
+ DateTimeSelectionPropertyTest.class, DateTimeTimeObservableValueTest.class, DecoratingObservableTest.class,
+ DelayedObservableValueTest.class, DetailObservableListTest.class, DetailObservableMapTest.class,
+ DetailObservableSetTest.class, DetailObservableValueTest.class, DifferentRealmsBindingTest.class,
+ Diffs_ListDiffTests.class, DiffsTest.class, DuplexingObservableValueTest.class, EditMaskLexerAndTokenTest.class,
+ EditMaskParserTest.class, GroupObservableValueTest.class, IdentityConverterTest.class, IdentityMapTest.class,
+ IdentitySetTest.class, IntegerToStringConverterTest.class, JavaBeanObservableArrayBasedListTest.class,
+ JavaBeanObservableArrayBasedSetTest.class, JavaBeanObservableListTest.class, JavaBeanObservableMapTest.class,
+ JavaBeanObservableSetTest.class, JavaBeanObservableValueTest.class, JavaBeanPropertyObservableMapTest.class,
+ LabelObservableValueTest.class, ListBindingTest.class, ListDetailValueObservableListTest.class,
+ ListDiffTest.class, ListDiffVisitorTest.class, ListSimpleValueObservableListTest.class,
+ ListSingleSelectionObservableValueTest.class, MapDetailValueObservableMapTest.class,
+ MapEntryObservableValueTest.class, MapSimpleValueObservableMapTest.class, MultiListTest.class,
+ MultiValidatorTest.class, NumberToBigDecimalTest.class, NumberToBigIntegerConverterTest.class,
+ NumberToByteConverterTest.class, NumberToByteValidatorTest.class, NumberToDoubleConverterTest.class,
+ NumberToDoubleValidatorTest.class, NumberToFloatConverterTest.class, NumberToFloatValidatorTest.class,
+ NumberToIntegerConverterTest.class, NumberToIntegerValidatorTest.class, NumberToLongConverterTest.class,
+ NumberToLongValidatorTest.class, NumberToShortConverterTest.class, NumberToShortValidatorTest.class,
+ NumberToStringConverterTest.class, NumberToUnboundedNumberValidatorTest.class,
+ ObjectToPrimitiveValidatorTest.class, ObservableCollectionContentProviderTest.class,
+ ObservableCollectionTreeContentProviderTest.class, ObservableListContentProviderTest.class,
+ ObservableListTest.class, ObservableListTreeContentProviderTest.class, ObservableMapLabelProviderTest.class,
+ ObservableMapTest.class, ObservableSetContentProviderTest.class, ObservableSetTreeContentProviderTest.class,
+ ObservablesManagerTest.class, ObservablesTest.class, ObservableTrackerTest.class,
+ ObservableValueEditingSupportTest.class, PojoObservablesTest.class, PojoPropertiesTest.class, PolicyTest.class,
+ PreferencePageSupportTest.class, QueueTest.class, RealmTest.class, ScaleObservableValueMaxTest.class,
+ ScaleObservableValueMinTest.class, ScaleObservableValueSelectionTest.class,
+ SelectionProviderMultiSelectionObservableListTest.class,
+ SelectionProviderSingleSelectionObservableValueTest.class, SetDetailValueObservableMapTest.class,
+ SetOnlyJavaBeanTest.class, SetSimpleValueObservableMapTest.class, ShellObservableValueTest.class,
+ SideEffectTest.class, SpinnerObservableValueMaxTest.class, SpinnerObservableValueMinTest.class,
+ SpinnerObservableValueSelectionTest.class, SpinnerObservableValueTest.class, StatusToStringConverterTest.class,
+ StringToBooleanConverterTest.class, StringToByteConverterTest.class, StringToByteValidatorTest.class,
+ StringToCharacterConverterTest.class, StringToCharacterValidatorTest.class, StringToDoubleValidatorTest.class,
+ StringToFloatValidatorTest.class, StringToIntegerValidatorTest.class, StringToLongValidatorTest.class,
+ StringToNumberConverterTest.class, StringToNumberParserByteTest.class, StringToNumberParserDoubleTest.class,
+ StringToNumberParserFloatTest.class, StringToNumberParserIntegerTest.class, StringToNumberParserLongTest.class,
+ StringToNumberParserShortTest.class, StringToNumberParserTest.class, StringToShortConverterTest.class,
+ StringToShortValidatorTest.class, StyledTextObservableValueFocusOutTest.class,
+ StyledTextObservableValueTest.class, SWTDelayedObservableValueDecoratorTest.class, SWTObservablesTest.class,
+ TableObservableValueTest.class, TableSingleSelectionObservableValueTest.class,
+ TextEditableObservableValueTest.class, TextObservableValueFocusOutTest.class, TextObservableValueTest.class,
+ UnmodifiableObservableListTest.class, UnmodifiableObservableSetTest.class,
+ UnmodifiableObservableValueTest.class, UpdateListStrategyTest.class, UpdateSetStrategyTest.class,
+ UpdateStrategyTest.class, UpdateValueStrategyTest.class, ValidatedObservableValueTest.class,
+ ValidationStatusTest.class, ValueBindingTest.class, ViewerElementMapTest.class, ViewerElementSetTest.class,
+ ViewerElementWrapperTest.class, ViewerInputObservableValueTest.class, ViewersObservablesTest.class,
+ ViewerSupportTest.class, WidgetObservableThreadTest.class, WidgetPropertiesTest.class,
+ WizardPageSupportTest.class, WritableListTest.class, WritableMapTest.class, WritableSetTest.class,
+ WritableValueTest.class })
public class BindingTestSuite {
-
- /**
- * @param testCase
- * TODO
- * @return true if the given test is temporarily disabled
- */
- public static boolean failingTestsDisabled(TestCase testCase) {
- System.out.println("Ignoring disabled test: "
- + testCase.getClass().getName() + "." + testCase.getName());
- return true;
- }
-
- /**
- * @param testSuite
- * TODO
- * @return true if the given test is temporarily disabled
- */
- public static boolean failingTestsDisabled(TestSuite testSuite) {
- System.out.println("Ignoring disabled test: "
- + testSuite.getClass().getName() + "." + testSuite.getName());
- return true;
- }
}
\ No newline at end of file
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/BindingTestSuiteJunit3.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/BindingTestSuiteJunit3.java
index 30ebf84..3d14bdf 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/BindingTestSuiteJunit3.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/BindingTestSuiteJunit3.java
@@ -23,109 +23,28 @@
*******************************************************************************/
package org.eclipse.jface.tests.databinding;
-import org.eclipse.core.tests.databinding.AggregateValidationStatusTest;
-import org.eclipse.core.tests.databinding.BindingTest;
-import org.eclipse.core.tests.databinding.DatabindingContextTest;
-import org.eclipse.core.tests.databinding.ListBindingTest;
-import org.eclipse.core.tests.databinding.ObservablesManagerTest;
-import org.eclipse.core.tests.databinding.UpdateListStrategyTest;
-import org.eclipse.core.tests.databinding.UpdateSetStrategyTest;
-import org.eclipse.core.tests.databinding.UpdateStrategyTest;
-import org.eclipse.core.tests.databinding.UpdateValueStrategyTest;
-import org.eclipse.core.tests.databinding.ValueBindingTest;
-import org.eclipse.core.tests.databinding.beans.AnonymousBeanValuePropertyTest;
-import org.eclipse.core.tests.databinding.beans.AnonymousPojoValuePropertyTest;
-import org.eclipse.core.tests.databinding.beans.BeanPropertiesTest;
-import org.eclipse.core.tests.databinding.beans.BeansObservablesTest;
-import org.eclipse.core.tests.databinding.beans.PojoObservablesTest;
-import org.eclipse.core.tests.databinding.beans.PojoPropertiesTest;
-import org.eclipse.core.tests.databinding.beans.SetOnlyJavaBeanTest;
-import org.eclipse.core.tests.databinding.conversion.NumberToStringConverterTest;
-import org.eclipse.core.tests.databinding.conversion.StringToNumberConverterTest;
import org.eclipse.core.tests.databinding.observable.AbstractObservableTest;
-import org.eclipse.core.tests.databinding.observable.ChangeSupportTest;
-import org.eclipse.core.tests.databinding.observable.DecoratingObservableTest;
-import org.eclipse.core.tests.databinding.observable.DiffsTest;
-import org.eclipse.core.tests.databinding.observable.Diffs_ListDiffTests;
-import org.eclipse.core.tests.databinding.observable.ObservableTrackerTest;
-import org.eclipse.core.tests.databinding.observable.ObservablesTest;
-import org.eclipse.core.tests.databinding.observable.RealmTest;
import org.eclipse.core.tests.databinding.observable.list.AbstractObservableListTest;
import org.eclipse.core.tests.databinding.observable.list.ComputedListTest;
import org.eclipse.core.tests.databinding.observable.list.DecoratingObservableListTest;
-import org.eclipse.core.tests.databinding.observable.list.ListDiffTest;
-import org.eclipse.core.tests.databinding.observable.list.ListDiffVisitorTest;
import org.eclipse.core.tests.databinding.observable.list.MultiListTest;
import org.eclipse.core.tests.databinding.observable.list.ObservableListTest;
import org.eclipse.core.tests.databinding.observable.list.WritableListTest;
-import org.eclipse.core.tests.databinding.observable.map.AbstractObservableMapTest;
-import org.eclipse.core.tests.databinding.observable.map.BidiObservableMapTest;
-import org.eclipse.core.tests.databinding.observable.map.CompositeMapTest;
-import org.eclipse.core.tests.databinding.observable.map.ComputedObservableMapTest;
-import org.eclipse.core.tests.databinding.observable.map.ObservableMapTest;
-import org.eclipse.core.tests.databinding.observable.map.WritableMapTest;
import org.eclipse.core.tests.databinding.observable.set.AbstractObservableSetTest;
import org.eclipse.core.tests.databinding.observable.set.ComputedSetTest;
import org.eclipse.core.tests.databinding.observable.set.DecoratingObservableSetTest;
import org.eclipse.core.tests.databinding.observable.set.ObservableSetTest;
import org.eclipse.core.tests.databinding.observable.set.UnionSetTest;
import org.eclipse.core.tests.databinding.observable.set.WritableSetTest;
-import org.eclipse.core.tests.databinding.observable.value.AbstractObservableValueTest;
-import org.eclipse.core.tests.databinding.observable.value.AbstractVetoableValueTest;
-import org.eclipse.core.tests.databinding.observable.value.ComputedValueTest;
-import org.eclipse.core.tests.databinding.observable.value.DateAndTimeObservableValueTest;
import org.eclipse.core.tests.databinding.observable.value.DecoratingObservableValueTest;
-import org.eclipse.core.tests.databinding.observable.value.DuplexingObservableValueTest;
import org.eclipse.core.tests.databinding.observable.value.SelectObservableValueTest;
import org.eclipse.core.tests.databinding.observable.value.WritableValueTest;
-import org.eclipse.core.tests.databinding.util.PolicyTest;
-import org.eclipse.core.tests.databinding.validation.MultiValidatorTest;
-import org.eclipse.core.tests.databinding.validation.ValidationStatusTest;
-import org.eclipse.core.tests.internal.databinding.BindingMessagesTest;
-import org.eclipse.core.tests.internal.databinding.BindingStatusTest;
-import org.eclipse.core.tests.internal.databinding.ConverterValuePropertyTest;
-import org.eclipse.core.tests.internal.databinding.DifferentRealmsBindingTest;
-import org.eclipse.core.tests.internal.databinding.IdentityMapTest;
-import org.eclipse.core.tests.internal.databinding.IdentitySetTest;
-import org.eclipse.core.tests.internal.databinding.QueueTest;
import org.eclipse.core.tests.internal.databinding.beans.BeanObservableListDecoratorTest;
-import org.eclipse.core.tests.internal.databinding.beans.BeanObservableSetDecoratorTest;
-import org.eclipse.core.tests.internal.databinding.beans.BeanObservableValueDecoratorTest;
-import org.eclipse.core.tests.internal.databinding.beans.BeanPropertyHelperTest;
-import org.eclipse.core.tests.internal.databinding.beans.BeanPropertyListenerSupportTest;
-import org.eclipse.core.tests.internal.databinding.beans.BeanPropertyListenerTest;
-import org.eclipse.core.tests.internal.databinding.beans.BeanValuePropertyTest;
import org.eclipse.core.tests.internal.databinding.beans.JavaBeanObservableArrayBasedListTest;
import org.eclipse.core.tests.internal.databinding.beans.JavaBeanObservableArrayBasedSetTest;
import org.eclipse.core.tests.internal.databinding.beans.JavaBeanObservableListTest;
-import org.eclipse.core.tests.internal.databinding.beans.JavaBeanObservableMapTest;
import org.eclipse.core.tests.internal.databinding.beans.JavaBeanObservableSetTest;
import org.eclipse.core.tests.internal.databinding.beans.JavaBeanObservableValueTest;
-import org.eclipse.core.tests.internal.databinding.beans.JavaBeanPropertyObservableMapTest;
-import org.eclipse.core.tests.internal.databinding.conversion.DateConversionSupportTest;
-import org.eclipse.core.tests.internal.databinding.conversion.IdentityConverterTest;
-import org.eclipse.core.tests.internal.databinding.conversion.IntegerToStringConverterTest;
-import org.eclipse.core.tests.internal.databinding.conversion.NumberToBigDecimalTest;
-import org.eclipse.core.tests.internal.databinding.conversion.NumberToBigIntegerConverterTest;
-import org.eclipse.core.tests.internal.databinding.conversion.NumberToByteConverterTest;
-import org.eclipse.core.tests.internal.databinding.conversion.NumberToDoubleConverterTest;
-import org.eclipse.core.tests.internal.databinding.conversion.NumberToFloatConverterTest;
-import org.eclipse.core.tests.internal.databinding.conversion.NumberToIntegerConverterTest;
-import org.eclipse.core.tests.internal.databinding.conversion.NumberToLongConverterTest;
-import org.eclipse.core.tests.internal.databinding.conversion.NumberToShortConverterTest;
-import org.eclipse.core.tests.internal.databinding.conversion.ObjectToPrimitiveValidatorTest;
-import org.eclipse.core.tests.internal.databinding.conversion.StatusToStringConverterTest;
-import org.eclipse.core.tests.internal.databinding.conversion.StringToBooleanConverterTest;
-import org.eclipse.core.tests.internal.databinding.conversion.StringToByteConverterTest;
-import org.eclipse.core.tests.internal.databinding.conversion.StringToCharacterConverterTest;
-import org.eclipse.core.tests.internal.databinding.conversion.StringToNumberParserByteTest;
-import org.eclipse.core.tests.internal.databinding.conversion.StringToNumberParserDoubleTest;
-import org.eclipse.core.tests.internal.databinding.conversion.StringToNumberParserFloatTest;
-import org.eclipse.core.tests.internal.databinding.conversion.StringToNumberParserIntegerTest;
-import org.eclipse.core.tests.internal.databinding.conversion.StringToNumberParserLongTest;
-import org.eclipse.core.tests.internal.databinding.conversion.StringToNumberParserShortTest;
-import org.eclipse.core.tests.internal.databinding.conversion.StringToNumberParserTest;
-import org.eclipse.core.tests.internal.databinding.conversion.StringToShortConverterTest;
import org.eclipse.core.tests.internal.databinding.observable.ConstantObservableValueTest;
import org.eclipse.core.tests.internal.databinding.observable.DelayedObservableValueTest;
import org.eclipse.core.tests.internal.databinding.observable.EmptyObservableListTest;
@@ -140,64 +59,18 @@
import org.eclipse.core.tests.internal.databinding.observable.ValidatedObservableSetTest;
import org.eclipse.core.tests.internal.databinding.observable.ValidatedObservableValueTest;
import org.eclipse.core.tests.internal.databinding.observable.masterdetail.DetailObservableListTest;
-import org.eclipse.core.tests.internal.databinding.observable.masterdetail.DetailObservableMapTest;
import org.eclipse.core.tests.internal.databinding.observable.masterdetail.DetailObservableSetTest;
import org.eclipse.core.tests.internal.databinding.observable.masterdetail.DetailObservableValueTest;
import org.eclipse.core.tests.internal.databinding.observable.masterdetail.ListDetailValueObservableListTest;
-import org.eclipse.core.tests.internal.databinding.observable.masterdetail.MapDetailValueObservableMapTest;
-import org.eclipse.core.tests.internal.databinding.observable.masterdetail.SetDetailValueObservableMapTest;
-import org.eclipse.core.tests.internal.databinding.property.value.ListSimpleValueObservableListTest;
-import org.eclipse.core.tests.internal.databinding.property.value.MapSimpleValueObservableMapTest;
-import org.eclipse.core.tests.internal.databinding.property.value.SetSimpleValueObservableMapTest;
-import org.eclipse.core.tests.internal.databinding.validation.AbstractStringToNumberValidatorTest;
-import org.eclipse.core.tests.internal.databinding.validation.NumberToByteValidatorTest;
-import org.eclipse.core.tests.internal.databinding.validation.NumberToDoubleValidatorTest;
-import org.eclipse.core.tests.internal.databinding.validation.NumberToFloatValidatorTest;
-import org.eclipse.core.tests.internal.databinding.validation.NumberToIntegerValidatorTest;
-import org.eclipse.core.tests.internal.databinding.validation.NumberToLongValidatorTest;
-import org.eclipse.core.tests.internal.databinding.validation.NumberToShortValidatorTest;
-import org.eclipse.core.tests.internal.databinding.validation.NumberToUnboundedNumberValidatorTest;
-import org.eclipse.core.tests.internal.databinding.validation.StringToByteValidatorTest;
-import org.eclipse.core.tests.internal.databinding.validation.StringToCharacterValidatorTest;
-import org.eclipse.core.tests.internal.databinding.validation.StringToDoubleValidatorTest;
-import org.eclipse.core.tests.internal.databinding.validation.StringToFloatValidatorTest;
-import org.eclipse.core.tests.internal.databinding.validation.StringToIntegerValidatorTest;
-import org.eclipse.core.tests.internal.databinding.validation.StringToLongValidatorTest;
-import org.eclipse.core.tests.internal.databinding.validation.StringToShortValidatorTest;
-import org.eclipse.jface.tests.databinding.preference.PreferencePageSupportTest;
-import org.eclipse.jface.tests.databinding.scenarios.BindingScenariosTestSuite;
-import org.eclipse.jface.tests.databinding.swt.SWTObservablesTest;
-import org.eclipse.jface.tests.databinding.swt.WidgetObservableThreadTest;
-import org.eclipse.jface.tests.databinding.swt.WidgetPropertiesTest;
-import org.eclipse.jface.tests.databinding.viewers.ObservableListContentProviderTest;
-import org.eclipse.jface.tests.databinding.viewers.ObservableListTreeContentProviderTest;
-import org.eclipse.jface.tests.databinding.viewers.ObservableMapLabelProviderTest;
-import org.eclipse.jface.tests.databinding.viewers.ObservableSetContentProviderTest;
-import org.eclipse.jface.tests.databinding.viewers.ObservableSetTreeContentProviderTest;
-import org.eclipse.jface.tests.databinding.viewers.ObservableValueEditingSupportTest;
-import org.eclipse.jface.tests.databinding.viewers.ViewerSupportTest;
-import org.eclipse.jface.tests.databinding.viewers.ViewersObservablesTest;
-import org.eclipse.jface.tests.databinding.wizard.WizardPageSupportTest;
-import org.eclipse.jface.tests.examples.databinding.mask.internal.EditMaskLexerAndTokenTest;
-import org.eclipse.jface.tests.examples.databinding.mask.internal.EditMaskParserTest;
import org.eclipse.jface.tests.internal.databinding.swt.ButtonObservableValueTest;
import org.eclipse.jface.tests.internal.databinding.swt.CComboObservableValueSelectionTest;
-import org.eclipse.jface.tests.internal.databinding.swt.CComboObservableValueTest;
import org.eclipse.jface.tests.internal.databinding.swt.CComboObservableValueTextTest;
import org.eclipse.jface.tests.internal.databinding.swt.CComboSingleSelectionObservableValueTest;
import org.eclipse.jface.tests.internal.databinding.swt.CLabelObservableValueTest;
import org.eclipse.jface.tests.internal.databinding.swt.ComboObservableValueSelectionTest;
-import org.eclipse.jface.tests.internal.databinding.swt.ComboObservableValueTest;
import org.eclipse.jface.tests.internal.databinding.swt.ComboObservableValueTextTest;
-import org.eclipse.jface.tests.internal.databinding.swt.ComboSingleSelectionObservableValueTest;
-import org.eclipse.jface.tests.internal.databinding.swt.ControlObservableValueTest;
-import org.eclipse.jface.tests.internal.databinding.swt.DateTimeCalendarObservableValueTest;
-import org.eclipse.jface.tests.internal.databinding.swt.DateTimeDateObservableValueTest;
-import org.eclipse.jface.tests.internal.databinding.swt.DateTimeSelectionPropertyTest;
-import org.eclipse.jface.tests.internal.databinding.swt.DateTimeTimeObservableValueTest;
import org.eclipse.jface.tests.internal.databinding.swt.GroupObservableValueTest;
import org.eclipse.jface.tests.internal.databinding.swt.LabelObservableValueTest;
-import org.eclipse.jface.tests.internal.databinding.swt.ListSingleSelectionObservableValueTest;
import org.eclipse.jface.tests.internal.databinding.swt.SWTDelayedObservableValueDecoratorTest;
import org.eclipse.jface.tests.internal.databinding.swt.ScaleObservableValueMaxTest;
import org.eclipse.jface.tests.internal.databinding.swt.ScaleObservableValueMinTest;
@@ -206,305 +79,92 @@
import org.eclipse.jface.tests.internal.databinding.swt.SpinnerObservableValueMaxTest;
import org.eclipse.jface.tests.internal.databinding.swt.SpinnerObservableValueMinTest;
import org.eclipse.jface.tests.internal.databinding.swt.SpinnerObservableValueSelectionTest;
-import org.eclipse.jface.tests.internal.databinding.swt.SpinnerObservableValueTest;
import org.eclipse.jface.tests.internal.databinding.swt.StyledTextObservableValueDefaultSelectionTest;
import org.eclipse.jface.tests.internal.databinding.swt.StyledTextObservableValueFocusOutTest;
import org.eclipse.jface.tests.internal.databinding.swt.StyledTextObservableValueModifyTest;
-import org.eclipse.jface.tests.internal.databinding.swt.StyledTextObservableValueTest;
-import org.eclipse.jface.tests.internal.databinding.swt.TableObservableValueTest;
import org.eclipse.jface.tests.internal.databinding.swt.TableSingleSelectionObservableValueTest;
import org.eclipse.jface.tests.internal.databinding.swt.TextEditableObservableValueTest;
import org.eclipse.jface.tests.internal.databinding.swt.TextObservableValueDefaultSelectionTest;
import org.eclipse.jface.tests.internal.databinding.swt.TextObservableValueFocusOutTest;
import org.eclipse.jface.tests.internal.databinding.swt.TextObservableValueModifyTest;
-import org.eclipse.jface.tests.internal.databinding.swt.TextObservableValueTest;
-import org.eclipse.jface.tests.internal.databinding.viewers.CheckableCheckedElementsObservableSetTest;
-import org.eclipse.jface.tests.internal.databinding.viewers.ObservableCollectionContentProviderTest;
-import org.eclipse.jface.tests.internal.databinding.viewers.ObservableCollectionTreeContentProviderTest;
import org.eclipse.jface.tests.internal.databinding.viewers.ObservableViewerElementSetTest;
-import org.eclipse.jface.tests.internal.databinding.viewers.SelectionProviderMultiSelectionObservableListTest;
-import org.eclipse.jface.tests.internal.databinding.viewers.SelectionProviderSingleSelectionObservableValueTest;
-import org.eclipse.jface.tests.internal.databinding.viewers.ViewerElementMapTest;
-import org.eclipse.jface.tests.internal.databinding.viewers.ViewerElementSetTest;
-import org.eclipse.jface.tests.internal.databinding.viewers.ViewerElementWrapperTest;
import org.eclipse.jface.tests.internal.databinding.viewers.ViewerInputObservableValueTest;
import org.junit.runner.RunWith;
import org.junit.runners.AllTests;
-import junit.framework.Test;
import junit.framework.TestSuite;
@RunWith(AllTests.class)
-public class BindingTestSuiteJunit3 extends TestSuite {
+public class BindingTestSuiteJunit3 {
- public static Test suite() {
- return new BindingTestSetup(new BindingTestSuiteJunit3());
+ public static TestSuite suite() {
+ TestSuite suite = new TestSuite("Contract Tests");
+ AbstractObservableListTest.addConformanceTest(suite);
+ AbstractObservableSetTest.addConformanceTest(suite);
+ AbstractObservableTest.addConformanceTest(suite);
+ BeanObservableListDecoratorTest.addConformanceTest(suite);
+ ButtonObservableValueTest.addConformanceTest(suite);
+ CComboObservableValueSelectionTest.addConformanceTest(suite);
+ CComboObservableValueTextTest.addConformanceTest(suite);
+ CComboSingleSelectionObservableValueTest.addConformanceTest(suite);
+ CLabelObservableValueTest.addConformanceTest(suite);
+ ComboObservableValueSelectionTest.addConformanceTest(suite);
+ ComboObservableValueTextTest.addConformanceTest(suite);
+ ComputedListTest.addConformanceTest(suite);
+ ComputedSetTest.addConformanceTest(suite);
+ ConstantObservableValueTest.addConformanceTest(suite);
+ DecoratingObservableListTest.addConformanceTest(suite);
+ DecoratingObservableSetTest.addConformanceTest(suite);
+ DecoratingObservableValueTest.addConformanceTest(suite);
+ DelayedObservableValueTest.addConformanceTest(suite);
+ DetailObservableListTest.addConformanceTest(suite);
+ DetailObservableSetTest.addConformanceTest(suite);
+ DetailObservableValueTest.addConformanceTest(suite);
+ EmptyObservableListTest.addConformanceTest(suite);
+ EmptyObservableSetTest.addConformanceTest(suite);
+ GroupObservableValueTest.addConformanceTest(suite);
+ IdentityObservableSetTest.addConformanceTest(suite);
+ JavaBeanObservableArrayBasedListTest.addConformanceTest(suite);
+ JavaBeanObservableArrayBasedSetTest.addConformanceTest(suite);
+ JavaBeanObservableListTest.addConformanceTest(suite);
+ JavaBeanObservableSetTest.addConformanceTest(suite);
+ JavaBeanObservableValueTest.addConformanceTest(suite);
+ LabelObservableValueTest.addConformanceTest(suite);
+ ListDetailValueObservableListTest.addConformanceTest(suite);
+ MapEntryObservableValueTest.addConformanceTest(suite);
+ MultiListTest.addConformanceTest(suite);
+ ObservableListTest.addConformanceTest(suite);
+ ObservableSetTest.addConformanceTest(suite);
+ ObservableViewerElementSetTest.addConformanceTest(suite);
+ ScaleObservableValueMaxTest.addConformanceTest(suite);
+ ScaleObservableValueMinTest.addConformanceTest(suite);
+ ScaleObservableValueSelectionTest.addConformanceTest(suite);
+ SelectObservableValueTest.addConformanceTest(suite);
+ ShellObservableValueTest.addConformanceTest(suite);
+ SpinnerObservableValueMaxTest.addConformanceTest(suite);
+ SpinnerObservableValueMinTest.addConformanceTest(suite);
+ SpinnerObservableValueSelectionTest.addConformanceTest(suite);
+ StalenessObservableValueTest.addConformanceTest(suite);
+ StyledTextObservableValueDefaultSelectionTest.addConformanceTest(suite);
+ StyledTextObservableValueFocusOutTest.addConformanceTest(suite);
+ StyledTextObservableValueModifyTest.addConformanceTest(suite);
+ SWTDelayedObservableValueDecoratorTest.addConformanceTest(suite);
+ TableSingleSelectionObservableValueTest.addConformanceTest(suite);
+ TextEditableObservableValueTest.addConformanceTest(suite);
+ TextObservableValueDefaultSelectionTest.addConformanceTest(suite);
+ TextObservableValueFocusOutTest.addConformanceTest(suite);
+ TextObservableValueModifyTest.addConformanceTest(suite);
+ UnionSetTest.addConformanceTest(suite);
+ UnmodifiableObservableListTest.addConformanceTest(suite);
+ UnmodifiableObservableSetTest.addConformanceTest(suite);
+ UnmodifiableObservableValueTest.addConformanceTest(suite);
+ ValidatedObservableListTest.addConformanceTest(suite);
+ ValidatedObservableSetTest.addConformanceTest(suite);
+ ValidatedObservableValueTest.addConformanceTest(suite);
+ ViewerInputObservableValueTest.addConformanceTest(suite);
+ WritableListTest.addConformanceTest(suite);
+ WritableSetTest.addConformanceTest(suite);
+ WritableValueTest.addConformanceTest(suite);
+ return suite;
}
-
- public BindingTestSuiteJunit3() {
-
- // org.eclipse.core.tests.databinding
- addTestSuite(AggregateValidationStatusTest.class);
- addTestSuite(BindingTest.class);
- addTestSuite(DatabindingContextTest.class);
- addTestSuite(ListBindingTest.class);
- addTestSuite(UpdateStrategyTest.class);
- addTestSuite(UpdateListStrategyTest.class);
- addTestSuite(UpdateSetStrategyTest.class);
- addTestSuite(UpdateValueStrategyTest.class);
- addTestSuite(ValueBindingTest.class);
- addTestSuite(ObservablesManagerTest.class);
-
- // org.eclipse.core.tests.databinding.util
- addTestSuite(PolicyTest.class);
-
- // org.eclipse.core.tests.databinding.beans
- addTestSuite(AnonymousBeanValuePropertyTest.class);
- addTestSuite(AnonymousPojoValuePropertyTest.class);
- addTestSuite(BeanPropertiesTest.class);
- addTestSuite(BeansObservablesTest.class);
- addTestSuite(PojoObservablesTest.class);
- addTestSuite(PojoPropertiesTest.class);
- addTestSuite(SetOnlyJavaBeanTest.class);
-
- // org.eclipse.core.tests.databinding.conversion
- addTestSuite(NumberToStringConverterTest.class);
- addTestSuite(StringToNumberConverterTest.class);
-
- // org.eclipse.core.tests.databinding.observable
- addTest(AbstractObservableTest.suite());
- addTestSuite(ChangeSupportTest.class);
- addTestSuite(DecoratingObservableTest.class);
- addTestSuite(Diffs_ListDiffTests.class);
- addTestSuite(DiffsTest.class);
- addTestSuite(ObservablesTest.class);
- addTestSuite(ObservableTrackerTest.class);
- addTestSuite(RealmTest.class);
-
- // org.eclipse.core.tests.databinding.observable.list
- addTest(AbstractObservableListTest.suite());
- addTest(ComputedListTest.suite());
- addTest(DecoratingObservableListTest.suite());
- addTestSuite(ListDiffTest.class);
- addTestSuite(ListDiffVisitorTest.class);
- addTest(MultiListTest.suite());
- addTest(ObservableListTest.suite());
- addTest(WritableListTest.suite());
-
- // org.eclipse.core.tests.databinding.observable.map
- addTestSuite(AbstractObservableMapTest.class);
- addTestSuite(BidiObservableMapTest.class);
- addTestSuite(ObservableMapTest.class);
- addTestSuite(WritableMapTest.class);
- addTestSuite(CompositeMapTest.class);
- addTestSuite(ComputedObservableMapTest.class);
-
- // org.eclipse.core.tests.databinding.observable.set
- addTest(AbstractObservableSetTest.suite());
- addTest(ComputedSetTest.suite());
- addTest(DecoratingObservableSetTest.suite());
- addTest(ObservableSetTest.suite());
- addTest(UnionSetTest.suite());
- addTest(WritableSetTest.suite());
-
- // org.eclipse.core.tests.databinding.observable.value
- addTestSuite(AbstractObservableValueTest.class);
- addTestSuite(AbstractVetoableValueTest.class);
- addTestSuite(ComputedValueTest.class);
- addTestSuite(DateAndTimeObservableValueTest.class);
- addTest(DecoratingObservableValueTest.suite());
- addTestSuite(DuplexingObservableValueTest.class);
- addTest(SelectObservableValueTest.suite());
- addTest(WritableValueTest.suite());
-
- // org.eclipse.core.tests.databinding.validation
- addTestSuite(MultiValidatorTest.class);
- addTestSuite(ValidationStatusTest.class);
-
- // org.eclipse.core.tests.internal.databinding
- addTestSuite(BindingMessagesTest.class);
- addTestSuite(BindingStatusTest.class);
- addTestSuite(ConverterValuePropertyTest.class);
- addTestSuite(DifferentRealmsBindingTest.class);
- addTestSuite(IdentityMapTest.class);
- addTestSuite(IdentitySetTest.class);
- addTestSuite(QueueTest.class);
-
- // org.eclipse.core.tests.internal.databinding.conversion
- addTestSuite(DateConversionSupportTest.class);
- addTestSuite(IdentityConverterTest.class);
- addTestSuite(IntegerToStringConverterTest.class);
- addTestSuite(NumberToBigDecimalTest.class);
- addTestSuite(NumberToBigIntegerConverterTest.class);
- addTestSuite(NumberToByteConverterTest.class);
- addTestSuite(NumberToDoubleConverterTest.class);
- addTestSuite(NumberToFloatConverterTest.class);
- addTestSuite(NumberToIntegerConverterTest.class);
- addTestSuite(NumberToLongConverterTest.class);
- addTestSuite(NumberToShortConverterTest.class);
- addTestSuite(ObjectToPrimitiveValidatorTest.class);
- addTestSuite(StatusToStringConverterTest.class);
- addTestSuite(StringToBooleanConverterTest.class);
- addTestSuite(StringToByteConverterTest.class);
- addTestSuite(StringToCharacterConverterTest.class);
- addTestSuite(StringToNumberParserByteTest.class);
- addTestSuite(StringToNumberParserDoubleTest.class);
- addTestSuite(StringToNumberParserFloatTest.class);
- addTestSuite(StringToNumberParserIntegerTest.class);
- addTestSuite(StringToNumberParserLongTest.class);
- addTestSuite(StringToNumberParserShortTest.class);
- addTestSuite(StringToNumberParserTest.class);
- addTestSuite(StringToShortConverterTest.class);
-
- // org.eclipse.core.tests.internal.databinding.beans
- addTest(BeanObservableListDecoratorTest.suite());
- addTestSuite(BeanObservableSetDecoratorTest.class);
- addTestSuite(BeanObservableValueDecoratorTest.class);
- addTestSuite(BeanObservableListDecoratorTest.class);
- addTestSuite(BeanValuePropertyTest.class);
- addTest(JavaBeanObservableArrayBasedListTest.suite());
- addTest(JavaBeanObservableArrayBasedSetTest.suite());
- addTest(JavaBeanObservableListTest.suite());
- addTest(JavaBeanObservableMapTest.suite());
- addTest(JavaBeanObservableSetTest.suite());
- addTest(JavaBeanObservableValueTest.suite());
- addTestSuite(JavaBeanPropertyObservableMapTest.class);
- addTestSuite(BeanPropertyHelperTest.class);
- addTestSuite(BeanPropertyListenerSupportTest.class);
- addTestSuite(BeanPropertyListenerTest.class);
-
- // org.eclipse.core.tests.internal.databinding.observable
- addTest(ConstantObservableValueTest.suite());
- addTest(DelayedObservableValueTest.suite());
- addTest(EmptyObservableListTest.suite());
- addTest(EmptyObservableSetTest.suite());
- addTest(IdentityObservableSetTest.suite());
- addTest(MapEntryObservableValueTest.suite());
- addTest(StalenessObservableValueTest.suite());
- addTest(UnmodifiableObservableValueTest.suite());
- addTest(UnmodifiableObservableListTest.suite());
- addTest(UnmodifiableObservableSetTest.suite());
- addTest(ValidatedObservableValueTest.suite());
- addTest(ValidatedObservableListTest.suite());
- addTest(ValidatedObservableSetTest.suite());
- // addTest(ValidatedObservableMapTest.suite());
-
- // org.eclipse.core.tests.internal.databinding.observable.masterdetail
- addTest(DetailObservableListTest.suite());
- addTestSuite(DetailObservableMapTest.class);
- addTest(DetailObservableSetTest.suite());
- addTest(DetailObservableValueTest.suite());
- addTest(ListDetailValueObservableListTest.suite());
- addTest(MapDetailValueObservableMapTest.suite());
- addTest(SetDetailValueObservableMapTest.suite());
-
- // org.eclipse.core.tests.internal.databinding.property.value
- addTestSuite(MapSimpleValueObservableMapTest.class);
- addTestSuite(SetSimpleValueObservableMapTest.class);
- addTestSuite(ListSimpleValueObservableListTest.class);
-
- // org.eclipse.core.tests.internal.databinding.validation
- addTestSuite(AbstractStringToNumberValidatorTest.class);
- addTestSuite(NumberToByteValidatorTest.class);
- addTestSuite(NumberToDoubleValidatorTest.class);
- addTestSuite(NumberToFloatValidatorTest.class);
- addTestSuite(NumberToIntegerValidatorTest.class);
- addTestSuite(NumberToLongValidatorTest.class);
- addTestSuite(NumberToShortValidatorTest.class);
- addTestSuite(NumberToUnboundedNumberValidatorTest.class);
- addTestSuite(StringToByteValidatorTest.class);
- addTestSuite(StringToCharacterValidatorTest.class);
- addTestSuite(StringToDoubleValidatorTest.class);
- addTestSuite(StringToFloatValidatorTest.class);
- addTestSuite(StringToIntegerValidatorTest.class);
- addTestSuite(StringToLongValidatorTest.class);
- addTestSuite(StringToShortValidatorTest.class);
-
- // org.eclipse.jface.tests.databinding.scenarios
- addTest(BindingScenariosTestSuite.suite());
- // The files in this package are in the above test suite
-
- // org.eclipse.jface.tests.databinding.swt
- addTestSuite(SWTObservablesTest.class);
- addTestSuite(WidgetPropertiesTest.class);
- addTestSuite(WidgetObservableThreadTest.class);
-
- // org.eclipse.jface.tests.databinding.preference
- addTestSuite(PreferencePageSupportTest.class);
-
- // org.eclipse.jface.tests.databinding.viewers
- addTestSuite(ObservableListContentProviderTest.class);
- addTestSuite(ObservableListTreeContentProviderTest.class);
- addTestSuite(ObservableMapLabelProviderTest.class);
- addTestSuite(ObservableSetContentProviderTest.class);
- addTestSuite(ObservableSetTreeContentProviderTest.class);
- addTestSuite(ObservableValueEditingSupportTest.class);
- addTestSuite(ViewersObservablesTest.class);
- addTestSuite(ViewerSupportTest.class);
-
- // org.eclipse.jface.tests.databinding.wizard
- addTestSuite(WizardPageSupportTest.class);
-
- // org.eclipse.jface.tests.example.databinding.mask.internal
- addTestSuite(EditMaskLexerAndTokenTest.class);
- addTestSuite(EditMaskParserTest.class);
-
- // org.eclipse.jface.tests.internal.databinding.swt
- addTest(ButtonObservableValueTest.suite());
- addTestSuite(CComboObservableValueTest.class);
- addTest(CComboObservableValueSelectionTest.suite());
- addTest(CComboObservableValueTextTest.suite());
- addTestSuite(CComboSingleSelectionObservableValueTest.class);
- addTest(CComboSingleSelectionObservableValueTest.suite());
- addTest(CLabelObservableValueTest.suite());
- addTestSuite(ComboObservableValueTest.class);
- addTest(ComboObservableValueSelectionTest.suite());
- addTest(ComboObservableValueTextTest.suite());
- addTestSuite(ComboSingleSelectionObservableValueTest.class);
- addTestSuite(DateTimeCalendarObservableValueTest.class);
- addTestSuite(DateTimeDateObservableValueTest.class);
- addTestSuite(DateTimeSelectionPropertyTest.class);
- addTestSuite(DateTimeTimeObservableValueTest.class);
- addTest(SWTDelayedObservableValueDecoratorTest.suite());
-
- addTestSuite(ControlObservableValueTest.class);
- addTest(LabelObservableValueTest.suite());
- addTest(GroupObservableValueTest.suite());
- addTestSuite(ListSingleSelectionObservableValueTest.class);
- addTest(ScaleObservableValueMinTest.suite());
- addTest(ScaleObservableValueMaxTest.suite());
- addTest(ScaleObservableValueSelectionTest.suite());
-
- addTest(ShellObservableValueTest.suite());
-
- addTestSuite(SpinnerObservableValueTest.class);
- addTest(SpinnerObservableValueMinTest.suite());
- addTest(SpinnerObservableValueMaxTest.suite());
- addTest(SpinnerObservableValueSelectionTest.suite());
-
- addTestSuite(TableObservableValueTest.class);
- addTest(TableSingleSelectionObservableValueTest.suite());
- addTest(TextEditableObservableValueTest.suite());
- addTest(TextObservableValueDefaultSelectionTest.suite());
- addTest(TextObservableValueFocusOutTest.suite());
- addTest(TextObservableValueModifyTest.suite());
- addTestSuite(TextObservableValueTest.class);
- addTest(StyledTextObservableValueDefaultSelectionTest.suite());
- addTest(StyledTextObservableValueFocusOutTest.suite());
- addTest(StyledTextObservableValueModifyTest.suite());
- addTestSuite(StyledTextObservableValueTest.class);
-
- // org.eclipse.jface.tests.internal.databinding.viewers
- addTestSuite(CheckableCheckedElementsObservableSetTest.class);
- addTest(ObservableViewerElementSetTest.suite());
- addTestSuite(ObservableCollectionContentProviderTest.class);
- addTestSuite(ObservableCollectionTreeContentProviderTest.class);
- addTestSuite(SelectionProviderMultiSelectionObservableListTest.class);
- addTestSuite(SelectionProviderSingleSelectionObservableValueTest.class);
- addTestSuite(ViewerElementMapTest.class);
- addTestSuite(ViewerElementSetTest.class);
- addTestSuite(ViewerElementWrapperTest.class);
- addTest(ViewerInputObservableValueTest.suite());
- }
-
}
\ No newline at end of file
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/preference/PreferencePageSupportTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/preference/PreferencePageSupportTest.java
index fcd0e03..f14094e 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/preference/PreferencePageSupportTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/preference/PreferencePageSupportTest.java
@@ -18,6 +18,8 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.junit.Before;
+import org.junit.Test;
/**
* @since 3.2
@@ -28,14 +30,15 @@
// private PreferenceDialog dialog;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
page = new PreferencePageWithSupport();
page.setControl(getShell());
}
+ @Test
public void testCreateAndDestroySupport() {
page.createContents(getShell());
}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/BindingScenariosTestSuite.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/BindingScenariosTestSuite.java
index 69771e2..54c4725 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/BindingScenariosTestSuite.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/BindingScenariosTestSuite.java
@@ -11,14 +11,17 @@
*******************************************************************************/
package org.eclipse.jface.tests.databinding.scenarios;
-import junit.extensions.TestSetup;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+import junit.extensions.TestSetup;
+import junit.framework.JUnit4TestAdapter;
+
/**
* To run this test suite, right-click and select "Run As JUnit Plug-in Test".
@@ -27,7 +30,12 @@
* Mode" as the application to run. You can also run this class as an SWT
* application.
*/
-public class BindingScenariosTestSuite extends TestSuite {
+@RunWith(Suite.class)
+@SuiteClasses({ ButtonControlScenario.class, ComboScenarios.class, ComboUpdatingTest.class, ComboViewerScenario.class,
+ CustomConverterScenarios.class, CustomScenarios.class, ListViewerScenario.class, MasterDetailScenarios.class,
+ NewTableScenarios.class, NPETestScenario.class, PropertyScenarios.class, SpinnerControlScenario.class,
+ TableScenarios.class, TextControlScenario.class })
+public class BindingScenariosTestSuite {
public static void main(String[] args) {
junit.textui.TestRunner.run(suite());
@@ -37,17 +45,17 @@
private static Shell shell;
- public static Test suite() {
- return new TestSetup(new BindingScenariosTestSuite()) {
+ public static junit.framework.Test suite() {
+ return new TestSetup(new JUnit4TestAdapter(BindingScenariosTestSuite.class)) {
@Override
- protected void setUp() throws Exception {
+ public void setUp() throws Exception {
Display d = Display.getDefault();
shell = new Shell(d, SWT.SHELL_TRIM);
shell.setLayout(new FillLayout());
}
@Override
- protected void tearDown() throws Exception {
+ public void tearDown() throws Exception {
shell.close();
shell.dispose();
if (display != null) {
@@ -57,23 +65,6 @@
};
}
- public BindingScenariosTestSuite() {
- addTestSuite(ButtonControlScenario.class);
- addTestSuite(ComboScenarios.class);
- addTestSuite(ComboUpdatingTest.class);
- addTestSuite(ComboViewerScenario.class);
- addTestSuite(CustomConverterScenarios.class);
- addTestSuite(CustomScenarios.class);
- addTestSuite(ListViewerScenario.class);
- addTestSuite(MasterDetailScenarios.class);
- addTestSuite(NewTableScenarios.class);
- addTestSuite(NPETestScenario.class);
- addTestSuite(PropertyScenarios.class);
- addTestSuite(SpinnerControlScenario.class);
- addTestSuite(TableScenarios.class);
- addTestSuite(TextControlScenario.class);
- }
-
public static Shell getShell() {
return shell;
}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ButtonControlScenario.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ButtonControlScenario.java
index 6929e0e..9413431 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ButtonControlScenario.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ButtonControlScenario.java
@@ -12,12 +12,17 @@
*******************************************************************************/
package org.eclipse.jface.tests.databinding.scenarios;
+import static org.junit.Assert.assertEquals;
+
import org.eclipse.core.databinding.beans.BeansObservables;
import org.eclipse.jface.databinding.swt.SWTObservables;
import org.eclipse.jface.examples.databinding.model.Adventure;
import org.eclipse.jface.examples.databinding.model.SampleData;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
/**
* To run the tests in this class, right-click and select "Run As JUnit Plug-in
@@ -32,21 +37,22 @@
private Button button;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
// do any setup work here
button = new Button(getComposite(), SWT.CHECK);
adventure = SampleData.WINTER_HOLIDAY;
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
button.dispose();
super.tearDown();
}
- public void testScenario01() {
+ @Test
+ public void testScenario01() {
// Bind the button's selection to the adventure "isPetsAllowed"
getDbc().bindValue(SWTObservables.observeSelection(button),
BeansObservables.observeValue(adventure, "petsAllowed"));
@@ -71,7 +77,8 @@
}
- public void testScenario02() {
+ @Test
+ public void testScenario02() {
// Test with an SWT.Toggle button
button.dispose();
button = new Button(getComposite(), SWT.TOGGLE);
@@ -93,7 +100,8 @@
assertEquals(newBoolean, adventure.isPetsAllowed());
}
- public void testScenario03() {
+ @Test
+ public void testScenario03() {
// Test with an SWT.Radio button
button.dispose();
button = new Button(getComposite(), SWT.RADIO);
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ComboScenarios.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ComboScenarios.java
index 137dcbd..a6a1aa6 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ComboScenarios.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ComboScenarios.java
@@ -12,6 +12,8 @@
*******************************************************************************/
package org.eclipse.jface.tests.databinding.scenarios;
+import static org.junit.Assert.assertEquals;
+
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
@@ -42,6 +44,9 @@
import org.eclipse.swt.custom.CCombo;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Combo;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
public class ComboScenarios extends ScenariosTestCase {
@@ -65,8 +70,8 @@
}
};
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
getComposite().setLayout(new FillLayout());
@@ -76,8 +81,8 @@
catalog = SampleData.CATALOG_2005; // Lodging source
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
combo.dispose();
combo = null;
cviewer = null;
@@ -146,6 +151,7 @@
* property change of content elements, etc.
*
*/
+ @Test
public void test_ROCombo_Scenario03_vanilla() {
IObservableList lodgings = BeansObservables.observeList(Realm
.getDefault(), catalog, "lodgings");
@@ -189,6 +195,7 @@
*
* This test does not deal with the combo's selection.
*/
+ @Test
public void test_ROCombo_Scenario03_collectionBindings() {
// column binding
// Bind the ComboViewer's content to the available lodging
@@ -257,6 +264,7 @@
* This scenario tests a simple SWT combo with a set item list where the
* selection is bouded to a String property
*/
+ // @Test
// public void test_ROCombo_Scenario01() {
//
// // Read-Only Combo will not change its text property on a call to
@@ -297,6 +305,7 @@
*
* The Combo's selection is bounded to the Country property of an Account.
*/
+ // @Test
// public void test_ROCombo_Scenario02_SWTCombo() {
//
// // Create a list of Strings for the countries
@@ -326,6 +335,7 @@
*
* The Combo's selection is bounded to the Country property of an Account.
*/
+ // @Test
// public void test_ROCombo_Scenario02_ComboViewer() {
//
// // Account label provider will fill the combo with the country
@@ -362,6 +372,7 @@
* This test ensure that multiple combos can be bound to the same deomain
* model
*/
+ @Test
public void test_ROCombo_multipleBindings() {
Adventure skiAdventure = SampleData.WINTER_HOLIDAY; // for selection
@@ -419,6 +430,7 @@
*
* The Combo's selection is bounded to the Country property of an Account.
*/
+ @Test
public void test_ROCombo_SWTCCombo() {
// Create a list of Strings for the countries
@@ -455,6 +467,7 @@
*
* The Combo's selection is bounded to the Country property of an Account.
*/
+ @Test
public void test_WCombo_SWTCCombo() {
// Create a list of Strings for the countries
@@ -500,6 +513,7 @@
*
* The Combo's selection is bounded to the Country property of an Account.
*/
+ @Test
public void test_ROCombo_SWTList() {
// Create a list of Strings for the countries
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ComboUpdatingTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ComboUpdatingTest.java
index f7a8103..14e9818 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ComboUpdatingTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ComboUpdatingTest.java
@@ -13,6 +13,8 @@
package org.eclipse.jface.tests.databinding.scenarios;
+import static org.junit.Assert.assertEquals;
+
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.util.ArrayList;
@@ -23,10 +25,12 @@
import org.eclipse.core.databinding.observable.list.IObservableList;
import org.eclipse.core.databinding.observable.list.WritableList;
import org.eclipse.jface.databinding.swt.SWTObservables;
-import org.eclipse.jface.tests.databinding.BindingTestSuite;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Combo;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
/**
* @since 3.2
@@ -94,7 +98,8 @@
}
@Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
getComposite().setLayout(new FillLayout());
comboEditable = new Combo(getComposite(), SWT.DROP_DOWN);
@@ -104,6 +109,7 @@
//-------------------------------------------------------------------------
private static final String NEXT = "Next";
+ @Test
public void testBindText() throws Exception {
getDbc().bindValue(SWTObservables.observeText(comboEditable), BeansObservables.observeValue(this, "text"));
spinEventLoop(0);
@@ -113,10 +119,9 @@
assertEquals("Should find new value in text", NEXT, text);
}
+ @Test
+ @Ignore
public void testBindItems_listHasSameItems_editable() throws Exception {
- if (BindingTestSuite.failingTestsDisabled(this)) {
- return;
- }
text = "Apple";
getDbc().bindValue(SWTObservables.observeText(comboEditable), BeansObservables.observeValue(this, PROP_TEXT));
@@ -141,7 +146,8 @@
assertEquals("Should find value of text", "Banana", text);
}
-// public void testBindItems_listHasSameItems_readOnly() throws Exception {
+// @Test
+ // public void testBindItems_listHasSameItems_readOnly() throws Exception {
// text = "Apple";
// ComboObservableValue value = (ComboObservableValue) getDbc().createObservable(new Property(comboReadOnly, PROP_TEXT));
// getDbc().bind(value.getItems(), new Property(this, PROP_CHOICES), null);
@@ -165,10 +171,9 @@
// assertEquals("Should find value of text", "Banana", text);
// }
+ @Test
+ @Ignore
public void testBindItems_listHasDifferentItems_editable() throws Exception {
- if (BindingTestSuite.failingTestsDisabled(this)) {
- return;
- }
getDbc().bindValue(SWTObservables.observeText(comboEditable), BeansObservables.observeValue(this, PROP_TEXT));
@@ -193,7 +198,9 @@
assertEquals("Should find value of text", "Banana", text);
}
-// public void testBindItems_listHasDifferentItems_readOnly() throws Exception {
+// @Test
+ // public void testBindItems_listHasDifferentItems_readOnly() throws
+ // Exception {
// ComboObservableValue value = (ComboObservableValue) getDbc().createObservable(new Property(comboReadOnly, PROP_TEXT));
// getDbc().bind(value, new Property(this, PROP_TEXT), null);
// spinEventLoop(0);
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ComboViewerScenario.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ComboViewerScenario.java
index 5bfd990..899c416 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ComboViewerScenario.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ComboViewerScenario.java
@@ -13,6 +13,8 @@
*******************************************************************************/
package org.eclipse.jface.tests.databinding.scenarios;
+import static org.junit.Assert.assertEquals;
+
import org.eclipse.core.databinding.beans.BeanProperties;
import org.eclipse.core.databinding.beans.BeansObservables;
import org.eclipse.core.databinding.observable.list.IObservableList;
@@ -26,6 +28,9 @@
import org.eclipse.jface.viewers.ComboViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Combo;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
/**
* To run the tests in this class, right-click and select "Run As JUnit Plug-in
@@ -42,8 +47,8 @@
private ComboViewer comboViewer;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
// do any setup work here
combo = new Combo(getComposite(), SWT.READ_ONLY | SWT.DROP_DOWN);
@@ -51,14 +56,15 @@
catalog = SampleData.CATALOG_2005; // Lodging source
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
combo.dispose();
combo = null;
comboViewer = null;
super.tearDown();
}
+ @Test
public void testScenario01() {
// Bind the catalog's lodgings to the combo
IObservableList lodgings = BeansObservables.observeList(realm, catalog,
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/CustomConverterScenarios.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/CustomConverterScenarios.java
index 261c4f9..9aede62 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/CustomConverterScenarios.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/CustomConverterScenarios.java
@@ -12,6 +12,8 @@
*******************************************************************************/
package org.eclipse.jface.tests.databinding.scenarios;
+import static org.junit.Assert.assertEquals;
+
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.beans.BeansObservables;
import org.eclipse.jface.databinding.swt.SWTObservables;
@@ -20,6 +22,9 @@
import org.eclipse.jface.examples.databinding.model.SampleData;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Spinner;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
/**
* To run the tests in this class, right-click and select "Run As JUnit Plug-in
@@ -32,19 +37,20 @@
private Adventure skiTrip;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
skiTrip = SampleData.WINTER_HOLIDAY;
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
// do any teardown work here
super.tearDown();
}
- public void testScenario01() {
+ @Test
+ public void testScenario01() {
DataBindingContext dbc = getDbc();
Spinner spinner_dollars = new Spinner(getComposite(), SWT.NONE);
spinner_dollars.setMaximum(10000);
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/CustomScenarios.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/CustomScenarios.java
index 805cc11..c485ed9 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/CustomScenarios.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/CustomScenarios.java
@@ -12,6 +12,8 @@
*******************************************************************************/
package org.eclipse.jface.tests.databinding.scenarios;
+import static org.junit.Assert.assertEquals;
+
import org.eclipse.core.databinding.beans.BeansObservables;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.jface.databinding.swt.SWTObservables;
@@ -20,6 +22,9 @@
import org.eclipse.jface.examples.databinding.model.SampleData;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Text;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
/**
* To run the tests in this class, right-click and select "Run As JUnit Plug-in
@@ -30,19 +35,20 @@
public class CustomScenarios extends ScenariosTestCase {
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
// do any setup work here
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
// do any teardown work here
super.tearDown();
}
- public void testScenario01() {
+ @Test
+ public void testScenario01() {
// Binding the name property of an Adventure object to the contents of
// Text controls, no conversion, no validation.
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/LabelControlScenario.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/LabelControlScenario.java
index 771611f..25e9d30 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/LabelControlScenario.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/LabelControlScenario.java
@@ -12,12 +12,17 @@
*******************************************************************************/
package org.eclipse.jface.tests.databinding.scenarios;
+import static org.junit.Assert.assertEquals;
+
import org.eclipse.core.databinding.beans.BeansObservables;
import org.eclipse.jface.databinding.swt.SWTObservables;
import org.eclipse.jface.examples.databinding.model.Adventure;
import org.eclipse.jface.examples.databinding.model.SampleData;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Label;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
/**
* To run the tests in this class, right-click and select "Run As JUnit Plug-in
@@ -32,23 +37,24 @@
private Label label;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
// do any setup work here
label = new Label(getComposite(), SWT.NONE);
adventure = SampleData.WINTER_HOLIDAY;
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
// do any teardown work here
super.tearDown();
label.dispose();
label = null;
}
- public void testScenario01() {
+ @Test
+ public void testScenario01() {
// Bind the adventure "name" property to a label control
// Change the UI and verify the model and UI are the same value
// Change the model and verify the UI changes
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ListViewerScenario.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ListViewerScenario.java
index 01cb951..d41a8a6 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ListViewerScenario.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ListViewerScenario.java
@@ -12,6 +12,8 @@
*******************************************************************************/
package org.eclipse.jface.tests.databinding.scenarios;
+import static org.junit.Assert.assertEquals;
+
import org.eclipse.core.databinding.beans.BeanProperties;
import org.eclipse.core.databinding.beans.BeansObservables;
import org.eclipse.core.databinding.observable.Realm;
@@ -26,6 +28,9 @@
import org.eclipse.jface.viewers.ListViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.List;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
/**
* To run the tests in this class, right-click and select "Run As JUnit Plug-in
@@ -42,8 +47,8 @@
private ListViewer listViewer;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
// do any setup work here
list = new List(getComposite(), SWT.READ_ONLY | SWT.SINGLE);
@@ -51,14 +56,15 @@
catalog = SampleData.CATALOG_2005; // Lodging source
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
list.dispose();
list = null;
listViewer = null;
super.tearDown();
}
+ @Test
public void testScenario01() {
// Bind the catalog's lodgings to the combo
IObservableList lodgings = BeansObservables.observeList(Realm
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/MasterDetailScenarios.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/MasterDetailScenarios.java
index b27dabb..c5c9aff 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/MasterDetailScenarios.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/MasterDetailScenarios.java
@@ -12,6 +12,13 @@
*******************************************************************************/
package org.eclipse.jface.tests.databinding.scenarios;
+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.assertSame;
+import static org.junit.Assert.assertTrue;
+
import java.util.Arrays;
import java.util.List;
@@ -42,6 +49,7 @@
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Text;
+import org.junit.Test;
/**
* To run the tests in this class, right-click and select "Run As JUnit Plug-in
@@ -68,6 +76,7 @@
return null;
}
+ @Test
public void testScenario01() {
// Displaying the catalog's list of Lodging objects in a list viewer,
// using their names. The name of the currently selected Lodging can
@@ -131,6 +140,7 @@
// assertNotSame("barfoo", txtName.getText());
}
+ @Test
public void testScenario02() {
// Selecting from the list of lodgings for an adventure and editing the
// properties of the selected lodging in text widgets. If no lodging is
@@ -256,6 +266,7 @@
pushButtonWithEvents(removeButton);
}
+ @Test
public void testScenario03() {
// List adventures and for the selected adventure allow its default
// lodgingļæ½s name and description to be changed in text controls. If
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/NPETestScenario.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/NPETestScenario.java
index fb1b3a9..a7f53d0 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/NPETestScenario.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/NPETestScenario.java
@@ -13,10 +13,17 @@
package org.eclipse.jface.tests.databinding.scenarios;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import java.beans.PropertyChangeListener;
+
import org.eclipse.core.databinding.beans.BeansObservables;
import org.eclipse.jface.databinding.swt.SWTObservables;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Text;
+import org.junit.Before;
+import org.junit.Test;
/**
* @since 3.2
@@ -28,7 +35,8 @@
Person person;
@Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
person = new Person();
text = new Text(getComposite(), SWT.BORDER);
@@ -38,6 +46,7 @@
* Asserts the ability to have an initial value of <code>null</code> on the
* model and to update the value by changing the value of the view.
*/
+ @Test
public void test_InitialNullValue() {
Person person = new Person();
assertNull(person.getName());
@@ -69,5 +78,15 @@
public void setName(String name) {
this.name = name;
}
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ // not really necessary, but BeansObservables.observeValue(...)
+ // expects it.
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ // not really necessary, but BeansObservables.observeValue(...)
+ // expects it.
+ }
}
}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/NewTableScenarios.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/NewTableScenarios.java
index 93e5981..3236c89 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/NewTableScenarios.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/NewTableScenarios.java
@@ -18,6 +18,9 @@
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.TableColumn;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
/**
* To run the tests in this class, right-click and select "Run As JUnit Plug-in
@@ -44,8 +47,8 @@
private TableColumn fancyColumn;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
getComposite().setLayout(new FillLayout());
tableViewer = new TableViewer(getComposite());
@@ -69,8 +72,8 @@
getShell().getDisplay().getSystemImage(SWT.ICON_INFORMATION), };
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
// do any teardown work here
super.tearDown();
tableViewer.getTable().dispose();
@@ -86,6 +89,7 @@
return text;
}
+ @Test
public void testScenario01() {
// // Factory for directly creating IObservables for beans
// JavaBeans javaBeans = new JavaBeans();
@@ -126,6 +130,7 @@
// }
}
+ @Test
public void testScenario02() throws SecurityException,
IllegalArgumentException {
// // Show that a TableViewer with three columns can be used to update
@@ -155,6 +160,7 @@
// assertEquals("Bill", account.getFirstName());
}
+ @Test
public void testScenario04() {
// // Show that when an item is added to a collection the table gets an
// // extra item
@@ -243,6 +249,7 @@
//
}
+ @Test
public void testScenario03() {
// // Show that converters work for table columns
// Account[] accounts = catalog.getAccounts();
@@ -278,6 +285,7 @@
// }
}
+ @Test
public void testScenario05() {
// // Show that when the model changes then the UI refreshes to reflect
// // this
@@ -311,6 +319,7 @@
//
}
+ @Test
public void testScenario06() {
// // Check that explicit type means that defaulting of converters works
// TableViewerDescription tableViewerDescription = new TableViewerDescription(
@@ -332,6 +341,7 @@
}
+ @Test
public void testScenario07() {
// // Verify that even when a column's property type is not set, that it is
// // worked out lazily from the target type
@@ -356,6 +366,7 @@
//
}
+ @Test
public void testScenario08_00() {
// // Verify that binding to a Collection property (rather than an array)
// // works when specifying data type
@@ -382,6 +393,7 @@
//
}
+ @Test
public void testScenario08_01() {
// // Verify that binding to a Collection property (rather than an array)
// // works without specifying data type
@@ -408,6 +420,7 @@
//
}
+ @Test
public void testScenario09() {
// // Verify that nested properties work. Catalog has adventures. Adventure
// // has defaultLodging. Loding has name.
@@ -419,7 +432,8 @@
// new Property(category, "adventures"), null);
}
/**
- * public void testScenario10(){ // Verify that for TIME_EARLY updating
+ * @Test
+ public void testScenario10(){ // Verify that for TIME_EARLY updating
* occurs on a per key basic for a TextCellEditor // Show that converters
* work for table columns Account[] accounts = catalog.getAccounts();
* Account firstAccount = accounts[0];
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/PropertyScenarios.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/PropertyScenarios.java
index 64f4519..dce9e61 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/PropertyScenarios.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/PropertyScenarios.java
@@ -12,6 +12,10 @@
*******************************************************************************/
package org.eclipse.jface.tests.databinding.scenarios;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import java.text.ParseException;
import java.util.Date;
import java.util.Locale;
@@ -44,6 +48,9 @@
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Spinner;
import org.eclipse.swt.widgets.Text;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
import com.ibm.icu.text.NumberFormat;
@@ -58,20 +65,21 @@
private Adventure adventure;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
// do any setup work here
adventure = SampleData.WINTER_HOLIDAY;
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
// do any teardown work here
super.tearDown();
}
- public void testEnterText() {
+ @Test
+ public void testEnterText() {
// just to make sure enterText() generates a FocusOut event.
Text text = new Text(getComposite(), SWT.BORDER);
final boolean[] focusLostHolder = { false };
@@ -91,7 +99,8 @@
assertTrue(focusLostHolder[0]);
}
- public void testScenario01() {
+ @Test
+ public void testScenario01() {
Text text = new Text(getComposite(), SWT.BORDER);
getDbc().bindValue(SWTObservables.observeText(text, SWT.Modify),
BeansObservables.observeValue(adventure, "name"));
@@ -110,7 +119,8 @@
assertEquals("barfoo", text.getText());
}
- public void testScenario02() {
+ @Test
+ public void testScenario02() {
// Binding the name property of an Adventure object to the contents of
// Text controls, no conversion, no validation. The Text widget editable
// is set to false.by the developer (can not change the name)
@@ -121,7 +131,8 @@
assertEquals(adventure.getName(), text.getText());
}
- public void testScenario03() {
+ @Test
+ public void testScenario03() {
// Binding of a read-only property of an Adventure object to the
// contents of Text controls, no conversion, no validation. Text control
// is not editable as a side effect of binding to a read-only property..
@@ -138,7 +149,8 @@
assertEquals(Integer.valueOf(cart.getLodgingDays()).toString(), text.getText());
}
- public void testScenario04() {
+ @Test
+ public void testScenario04() {
// Binding a nested property of an Adventure object to the content of a
// Text control, no conversion, no validation.
Text text = new Text(getComposite(), SWT.BORDER);
@@ -179,7 +191,8 @@
}
- public void testScenario05() {
+ @Test
+ public void testScenario05() {
// Binding the name property of an Adventure object to the contents of
// Text controls where conversion occurs ļæ½ the model data is held all
// in
@@ -240,7 +253,8 @@
assertEquals("LOWERCASE", adventure.getName());
}
- public void testScenario06() {
+ @Test
+ public void testScenario06() {
// Binding the name property of an Adventure object to the contents of
// Text controls where validation occurs and the name cannot be longer
// than 15 characters and cannot contain spaces
@@ -289,7 +303,8 @@
assertEquals("anothervalid", adventure.getName());
}
- public void testScenario07() {
+ @Test
+ public void testScenario07() {
// Binding the price property of an Adventure to a Text control. Price
// is a double and Text accepts String so conversion will have to occur.
// Validation ensure that the value is positive
@@ -356,7 +371,8 @@
assertTrue(AggregateValidationStatus.getStatusMaxSeverity(getDbc().getBindings()).isOK());
}
- public void testScenario08() {
+ @Test
+ public void testScenario08() {
// Binding the price property of an Adventure to a Text control but with
// custom conversion ļæ½ the double will be validated to only have two
// decimal places and displayed with a leading currency symbol, and can
@@ -433,7 +449,8 @@
assertTrue(AggregateValidationStatus.getStatusMaxSeverity(getDbc().getBindings()).isOK());
}
- public void testScenario09() {
+ @Test
+ public void testScenario09() {
// Binding a boolean property to a CheckBox. Adventure will have a
// Boolean property ļæ½petsAllowedļæ½
Button checkbox = new Button(getComposite(), SWT.CHECK);
@@ -451,7 +468,8 @@
assertEquals(true, checkbox.getSelection());
}
- public void testScenario10() {
+ @Test
+ public void testScenario10() {
// Binding a Transportation departure time to a Text control that
// formats and validates the time to and from a String. There are
// property bindings that bind elements of the GUI to elements to GUI
@@ -459,7 +477,8 @@
// TODO fail("not implemented");
}
- public void testScenario11() {
+ @Test
+ public void testScenario11() {
// Binding the max value of a spinner to another spinner.
Spinner spinner1 = new Spinner(getComposite(), SWT.NONE);
spinner1.setSelection(10);
@@ -476,7 +495,8 @@
assertEquals(10, spinner2.getMaximum());
}
- public void testScenario12() {
+ @Test
+ public void testScenario12() {
// Binding the enabled state of several Text controls to a check box.
// There will be two check boxes, so as each is enabled/disabled the
// other one follows as do the states of the Text controls.
@@ -526,7 +546,8 @@
assertEquals(true, checkbox1.getSelection());
}
- public void testScenario13() {
+ @Test
+ public void testScenario13() {
Text text = new Text(getComposite(), SWT.BORDER);
getDbc().bindValue(SWTObservables.observeText(text, SWT.FocusOut), BeansObservables.observeValue(adventure, "name"));
@@ -546,7 +567,8 @@
assertEquals("barfoo", text.getText());
}
- public void testScenario14() {
+ @Test
+ public void testScenario14() {
Text t1 = new Text(getComposite(), SWT.BORDER);
Text t2 = new Text(getComposite(), SWT.BORDER);
@@ -578,7 +600,8 @@
}
- public void testScenario15() {
+ @Test
+ public void testScenario15() {
Text text = new Text(getComposite(), SWT.NONE);
Account account = new Account();
account.setExpiryDate(new Date());
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ScenariosTestCase.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ScenariosTestCase.java
index e4438fb..1a260fe 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ScenariosTestCase.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/ScenariosTestCase.java
@@ -11,15 +11,16 @@
*******************************************************************************/
package org.eclipse.jface.tests.databinding.scenarios;
-import java.util.Arrays;
+import static org.junit.Assert.assertEquals;
-import junit.framework.TestCase;
+import java.util.Arrays;
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.observable.Realm;
import org.eclipse.jface.databinding.conformance.util.RealmTester;
import org.eclipse.jface.databinding.swt.DisplayRealm;
import org.eclipse.jface.examples.databinding.model.SampleData;
+import org.eclipse.jface.tests.databinding.BindingTestSetup;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Button;
@@ -27,11 +28,17 @@
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
/**
* Abstract base class of the JFace binding scenario test classes.
*/
-abstract public class ScenariosTestCase extends TestCase {
+abstract public class ScenariosTestCase {
+
+ @Rule
+ public BindingTestSetup testSetup = new BindingTestSetup();
private Composite composite;
private DataBindingContext dbc;
@@ -54,7 +61,7 @@
return shell;
}
Shell result = BindingScenariosTestSuite.getShell();
- if (result == null) {
+ if (result == null || result.isDisposed()) {
display = Display.getDefault();
if (Display.getDefault() == null) {
display = new Display();
@@ -64,7 +71,8 @@
shell.setLayout(new FillLayout());
result = shell;
}
- result.setText(getName()); // In the case that the shell() becomes
+ result.setText(getClass().getSimpleName()); // In the case that the
+ // shell() becomes
// visible.
return result;
}
@@ -106,8 +114,8 @@
button.notifyListeners(SWT.Selection, null);
}
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
realm = DisplayRealm.getRealm(Display.getDefault());
RealmTester.setDefault(realm);
@@ -120,8 +128,8 @@
dummyText.setText("dummy");
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
realm = null;
getShell().setVisible(false); // same Shell may be reUsed across tests
composite.dispose();
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/SpinnerControlScenario.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/SpinnerControlScenario.java
index e9ed3df..e79fc67 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/SpinnerControlScenario.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/SpinnerControlScenario.java
@@ -12,12 +12,17 @@
*******************************************************************************/
package org.eclipse.jface.tests.databinding.scenarios;
+import static org.junit.Assert.assertEquals;
+
import org.eclipse.core.databinding.beans.BeansObservables;
import org.eclipse.jface.databinding.swt.SWTObservables;
import org.eclipse.jface.examples.databinding.model.Adventure;
import org.eclipse.jface.examples.databinding.model.SampleData;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Spinner;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
/**
* To run the tests in this class, right-click and select "Run As JUnit Plug-in
@@ -30,20 +35,21 @@
private Adventure adventure;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
// do any setup work here
adventure = SampleData.WINTER_HOLIDAY;
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
// do any teardown work here
super.tearDown();
}
- public void testScenario01() {
+ @Test
+ public void testScenario01() {
// Bind the adventure "maxNumberOfPeople" property to a spinner
// Change the UI and verify the model changes
// Change the model and verify the UI changes
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/TableScenarios.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/TableScenarios.java
index c9f67a7..201d2a2 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/TableScenarios.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/TableScenarios.java
@@ -13,6 +13,8 @@
*******************************************************************************/
package org.eclipse.jface.tests.databinding.scenarios;
+import static org.junit.Assert.assertEquals;
+
import java.util.ArrayList;
import java.util.Arrays;
@@ -31,6 +33,9 @@
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
/**
* To run the tests in this class, right-click and select "Run As JUnit Plug-in
@@ -57,8 +62,8 @@
private TableColumn fancyColumn;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
getComposite().setLayout(new FillLayout());
tableViewer = new TableViewer(getComposite());
@@ -82,8 +87,8 @@
getShell().getDisplay().getSystemImage(SWT.ICON_INFORMATION), };
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
// do any teardown work here
super.tearDown();
tableViewer.getTable().dispose();
@@ -93,6 +98,7 @@
stateColumn = null;
}
+ @Test
public void testScenario01() {
// Show that a TableViewer with three columns renders the accounts
Account[] accounts = catalog.getAccounts();
@@ -117,6 +123,7 @@
}
}
+ @Test
public void testScenario02() throws SecurityException,
IllegalArgumentException {
// Show that a TableViewer with three columns can be used to update
@@ -147,6 +154,7 @@
// assertEquals("Bill",account.getFirstName());
}
+ @Test
public void testScenario04() {
// // Show that when an item is added to a collection the table gets an
// extra item
@@ -234,6 +242,7 @@
//
}
+ @Test
public void testScenario03() {
// // Show that converters work for table columns
// Account[] accounts = catalog.getAccounts();
@@ -271,6 +280,7 @@
// }
}
+ @Test
public void testScenario05() {
// // Show that when the model changes then the UI refreshes to reflect
// this
@@ -307,6 +317,7 @@
//
}
+ @Test
public void testScenario06() {
// // Check that explicit type means that defaulting of converters works
// TableViewerDescription tableViewerDescription = new
@@ -329,6 +340,7 @@
}
+ @Test
public void testScenario07() {
// // Verify that even when a column's property type is not set, that it
// is worked out lazily from the target type
@@ -354,6 +366,7 @@
//
}
+ @Test
public void testScenario08_00() {
// // Verify that binding to a Collection property (rather than an
// array) works when specifying data type
@@ -381,6 +394,7 @@
//
}
+ @Test
public void testScenario08_01() {
// // Verify that binding to a Collection property (rather than an
// array) works without specifying data type
@@ -408,6 +422,7 @@
//
}
+ @Test
public void testScenario09() {
// // Verify that nested properties work. Catalog has adventures.
// Adventure has defaultLodging. Loding has name.
@@ -420,7 +435,8 @@
//
}
/**
- * public void testScenario10(){ // Verify that for TIME_EARLY updating
+ * @Test
+ public void testScenario10(){ // Verify that for TIME_EARLY updating
* occurs on a per key basic for a TextCellEditor // Show that converters
* work for table columns Account[] accounts = catalog.getAccounts();
* Account firstAccount = accounts[0];
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/TextControlScenario.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/TextControlScenario.java
index 5aa6467..191cfc3 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/TextControlScenario.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/scenarios/TextControlScenario.java
@@ -12,6 +12,9 @@
*******************************************************************************/
package org.eclipse.jface.tests.databinding.scenarios;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.beans.BeansObservables;
import org.eclipse.jface.databinding.swt.SWTObservables;
@@ -19,10 +22,13 @@
import org.eclipse.jface.examples.databinding.model.Adventure;
import org.eclipse.jface.examples.databinding.model.SampleData;
import org.eclipse.jface.examples.databinding.model.Transportation;
-import org.eclipse.jface.tests.databinding.BindingTestSuite;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
import com.ibm.icu.text.NumberFormat;
@@ -44,7 +50,8 @@
Account account;
@Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
// do any setup work here
adventure = SampleData.WINTER_HOLIDAY;
@@ -54,13 +61,15 @@
}
@Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
text.dispose();
text = null;
super.tearDown();
}
- public void testScenario01() {
+ @Test
+ public void testScenario01() {
// Bind the adventure "name" property to a text field
// Change the UI and verify the model changes
// Change the model and verify the UI changes
@@ -78,7 +87,8 @@
assertEquals("Germany", text.getText());
}
- public void testScenario02() {
+ @Test
+ public void testScenario02() {
// Bind the transportation "price" property to a text field
// This is a Double.TYPE so we check that conversion and validation
@@ -99,7 +109,8 @@
assertEquals(numberFormat.format(transportation.getPrice()), text.getText());
}
-// public void testScenario03() {
+// @Test
+ // public void testScenario03() {
// // Show that the Escape key can be pressed in the middle of editing and
// // the value will revert
// // the updatePolicy for this test is TIME_LATE so it occurs when focus
@@ -136,7 +147,8 @@
//
// }
-// public void testScenario04() {
+// @Test
+ // public void testScenario04() {
// // Show that the Escape key can be pressed in the middle of editing and
// // the value will revert
// // the updatePolicy for this test is TIME_EARLY so it occurs when each
@@ -178,13 +190,15 @@
// }
/**
- * public void testScenario05(){ // Show that nesting of properties works.
+ * @Test
+ public void testScenario05(){ // Show that nesting of properties works.
* Adventure has defaultLodging and Lodging has name getDbc().bind(text,new
* Property(adventure,"defaultLodging.name"),null); // Verify the GUI is
* showing the model value
* assertEquals(text.getText(),adventure.getDefaultLodging().getName()); }
*/
- public void testScenario06() {
+ @Test
+ public void testScenario06() {
// // Show that partial validation works for TIME_EARLY
// // We are using TIME_EARLY to verify that invalid states are not sent
// to the model
@@ -216,7 +230,8 @@
// assertEquals(account.getPhone(),"9998887777");
}
- public void testScenario07() {
+ @Test
+ public void testScenario07() {
// // Show that partial validation works for TIME_LATE
// getSWTObservableFactory().setUpdateTime(DataBindingContext.TIME_LATE);
// getDbc().bind(text, new Property(account, "phone"), new BindSpec(new
@@ -248,11 +263,9 @@
// assertEquals("2223334444",account.getPhone());
}
- public void testScenario08() {
-
- if (BindingTestSuite.failingTestsDisabled(this)) {
- return;
- }
+ @Test
+ @Ignore
+ public void testScenario08() {
// Show that the CustomBeanBindSupportFactory will automatically pick up
// the
@@ -273,7 +286,8 @@
dbc.dispose();
}
- public void testScenario09() {
+ @Test
+ public void testScenario09() {
// Verify direct binding between a Text and Label following bugzilla
// 118696
Label label = new Label(getComposite(), SWT.NONE);
@@ -289,7 +303,8 @@
}
- public void testScenario10() {
+ @Test
+ public void testScenario10() {
// Verify direct binding between a Text and Label following bugzilla
// 118696 with TIME_EARLY
Label label = new Label(getComposite(), SWT.NONE);
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/SWTObservablesTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/SWTObservablesTest.java
index 82ac5f3..e5cc3f0 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/SWTObservablesTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/SWTObservablesTest.java
@@ -13,6 +13,12 @@
package org.eclipse.jface.tests.databinding.swt;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import org.eclipse.core.databinding.observable.IDecoratingObservable;
import org.eclipse.core.databinding.property.IPropertyObservable;
import org.eclipse.jface.databinding.conformance.util.ChangeEventTracker;
@@ -91,6 +97,9 @@
import org.eclipse.swt.widgets.ToolTip;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.Widget;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
/**
* @since 1.1
@@ -98,16 +107,16 @@
public class SWTObservablesTest extends AbstractSWTTestCase {
private Shell shell;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
shell = getShell();
RealmTester.setDefault(DisplayRealm.getRealm(shell.getDisplay()));
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
super.tearDown();
RealmTester.setDefault(null);
@@ -118,78 +127,91 @@
return new Shell(SWT.V_SCROLL);
}
+ @Test
public void testObserveForeground() throws Exception {
ISWTObservableValue value = SWTObservables.observeForeground(shell);
assertWidgetObservable(value, shell, ControlForegroundProperty.class);
assertEquals(Color.class, value.getValueType());
}
+ @Test
public void testObserveBackground() throws Exception {
ISWTObservableValue value = SWTObservables.observeBackground(shell);
assertWidgetObservable(value, shell, ControlBackgroundProperty.class);
assertEquals(Color.class, value.getValueType());
}
+ @Test
public void testObserveFont() throws Exception {
ISWTObservableValue value = SWTObservables.observeFont(shell);
assertNotNull(value);
assertEquals(Font.class, value.getValueType());
}
+ @Test
public void testObserveSelectionOfSpinner() throws Exception {
Spinner spinner = new Spinner(shell, SWT.NONE);
ISWTObservableValue value = SWTObservables.observeSelection(spinner);
assertWidgetObservable(value, spinner, SpinnerSelectionProperty.class);
}
+ @Test
public void testObserveSelectionOfButton() throws Exception {
Button button = new Button(shell, SWT.PUSH);
ISWTObservableValue value = SWTObservables.observeSelection(button);
assertWidgetObservable(value, button, ButtonSelectionProperty.class);
}
+ @Test
public void testObserveSelectionOfCombo() throws Exception {
Combo combo = new Combo(shell, SWT.NONE);
ISWTObservableValue value = SWTObservables.observeSelection(combo);
assertWidgetObservable(value, combo, ComboSelectionProperty.class);
}
+ @Test
public void testObserveSelectionOfCCombo() throws Exception {
CCombo combo = new CCombo(shell, SWT.NONE);
ISWTObservableValue value = SWTObservables.observeSelection(combo);
assertWidgetObservable(value, combo, CComboSelectionProperty.class);
}
+ @Test
public void testObserveSelectionOfDateTime_Date() throws Exception {
DateTime dateTime = new DateTime(shell, SWT.DATE);
ISWTObservableValue value = SWTObservables.observeSelection(dateTime);
assertWidgetObservable(value, dateTime, DateTimeSelectionProperty.class);
}
+ @Test
public void testObserveSelectionOfDateTime_Calendar() throws Exception {
DateTime dateTime = new DateTime(shell, SWT.CALENDAR);
ISWTObservableValue value = SWTObservables.observeSelection(dateTime);
assertWidgetObservable(value, dateTime, DateTimeSelectionProperty.class);
}
+ @Test
public void testObserveSelectionOfDateTime_Time() throws Exception {
DateTime dateTime = new DateTime(shell, SWT.TIME);
ISWTObservableValue value = SWTObservables.observeSelection(dateTime);
assertWidgetObservable(value, dateTime, DateTimeSelectionProperty.class);
}
+ @Test
public void testObserveSelectionOfList() throws Exception {
List list = new List(shell, SWT.NONE);
ISWTObservableValue value = SWTObservables.observeSelection(list);
assertWidgetObservable(value, list, ListSelectionProperty.class);
}
+ @Test
public void testObserveSelectionOfScale() throws Exception {
Scale scale = new Scale(shell, SWT.NONE);
ISWTObservableValue value = SWTObservables.observeSelection(scale);
assertWidgetObservable(value, scale, ScaleSelectionProperty.class);
}
+ @Test
public void testObserveSelectionOfUnsupportedControl() throws Exception {
try {
Text text = new Text(shell, SWT.NONE);
@@ -199,6 +221,7 @@
}
}
+ @Test
public void testObserveTextWithEventOfText() throws Exception {
Text text = new Text(shell, SWT.NONE);
assertFalse(text.isListening(SWT.FocusOut));
@@ -212,6 +235,7 @@
assertTrue(text.isListening(SWT.FocusOut));
}
+ @Test
public void testObserveTextOfStyledText() throws Exception {
StyledText text = new StyledText(shell, SWT.NONE);
assertFalse(text.isListening(SWT.FocusOut));
@@ -225,6 +249,7 @@
assertTrue(text.isListening(SWT.FocusOut));
}
+ @Test
public void testObserveTextWithEventOfUnsupportedControl() throws Exception {
Label label = new Label(shell, SWT.NONE);
try {
@@ -234,24 +259,28 @@
}
}
+ @Test
public void testObserveTextOfButton() throws Exception {
Button button = new Button(shell, SWT.PUSH);
ISWTObservableValue value = SWTObservables.observeText(button);
assertWidgetObservable(value, button, ButtonTextProperty.class);
}
+ @Test
public void testObserveTextOfLabel() throws Exception {
Label label = new Label(shell, SWT.NONE);
ISWTObservableValue value = SWTObservables.observeText(label);
assertWidgetObservable(value, label, LabelTextProperty.class);
}
+ @Test
public void testObserveTextOfCLabel() throws Exception {
CLabel label = new CLabel(shell, SWT.NONE);
ISWTObservableValue value = SWTObservables.observeText(label);
assertWidgetObservable(value, label, CLabelTextProperty.class);
}
+ @Test
public void testObserveTextOfCombo() throws Exception {
Combo combo = new Combo(shell, SWT.NONE);
ISWTObservableValue value = SWTObservables.observeText(combo);
@@ -269,12 +298,14 @@
return propertyObservable;
}
+ @Test
public void testObserveTextOfCCombo() throws Exception {
CCombo combo = new CCombo(shell, SWT.NONE);
ISWTObservableValue value = SWTObservables.observeText(combo);
assertWidgetObservable(value, combo, CComboTextProperty.class);
}
+ @Test
public void testObserveTextOfText() throws Exception {
Text text = new Text(shell, SWT.NONE);
ISWTObservableValue value = SWTObservables.observeText(text);
@@ -285,6 +316,7 @@
assertFalse(text.isListening(SWT.FocusOut));
}
+ @Test
public void testObserveTextOfItem() throws Exception {
CTabFolder ctf = new CTabFolder(shell, SWT.NONE);
Item item = new CTabItem(ctf, SWT.NONE);
@@ -292,6 +324,7 @@
assertWidgetObservable(value, item, ItemTextProperty.class);
}
+ @Test
public void testObserveTextOfUnsupportedControl() throws Exception {
Table table = new Table(shell, SWT.NONE);
try {
@@ -301,18 +334,21 @@
}
}
+ @Test
public void testObserveImageOfButton() throws Exception {
Button button = new Button(shell, SWT.PUSH);
ISWTObservableValue value = SWTObservables.observeImage(button);
assertWidgetObservable(value, button, ButtonImageProperty.class);
}
+ @Test
public void testObserveImageOfCLabel() throws Exception {
CLabel cLabel = new CLabel(shell, SWT.NONE);
ISWTObservableValue value = SWTObservables.observeImage(cLabel);
assertWidgetObservable(value, cLabel, CLabelImageProperty.class);
}
+ @Test
public void testObserveImageOfItem() throws Exception {
CTabFolder ctf = new CTabFolder(shell, SWT.NONE);
Item item = new CTabItem(ctf, SWT.NONE);
@@ -320,12 +356,14 @@
assertWidgetObservable(value, item, ItemImageProperty.class);
}
+ @Test
public void testObserveImageOfLabel() throws Exception {
Label label = new Label(shell, SWT.NONE);
ISWTObservableValue value = SWTObservables.observeImage(label);
assertWidgetObservable(value, label, LabelImageProperty.class);
}
+ @Test
public void testObserveTooltipOfItem() throws Exception {
CTabFolder ctf = new CTabFolder(shell, SWT.NONE);
Item item = new CTabItem(ctf, SWT.NONE);
@@ -333,6 +371,7 @@
assertWidgetObservable(value, item, CTabItemTooltipTextProperty.class);
}
+ @Test
public void testObserveTooltipOfUnsupportedControl() throws Exception {
ToolTip ttip = new ToolTip(shell, SWT.NONE);
try {
@@ -342,12 +381,14 @@
}
}
+ @Test
public void testObserveTooltipOfControl() throws Exception {
Label label = new Label(shell, SWT.NONE);
ISWTObservableValue value = SWTObservables.observeTooltipText(label);
assertWidgetObservable(value, label, ControlTooltipTextProperty.class);
}
+ @Test
public void testObserveItemsOfCombo() throws Exception {
Combo combo = new Combo(shell, SWT.NONE);
ISWTObservableList list = (ISWTObservableList) SWTObservables
@@ -355,6 +396,7 @@
assertWidgetObservable(list, combo, ComboItemsProperty.class);
}
+ @Test
public void testObserveItemsOfCCombo() throws Exception {
CCombo ccombo = new CCombo(shell, SWT.NONE);
ISWTObservableList list = (ISWTObservableList) SWTObservables
@@ -362,6 +404,7 @@
assertWidgetObservable(list, ccombo, CComboItemsProperty.class);
}
+ @Test
public void testObserveItemsOfList() throws Exception {
List list = new List(shell, SWT.NONE);
ISWTObservableList observableList = (ISWTObservableList) SWTObservables
@@ -369,6 +412,7 @@
assertWidgetObservable(observableList, list, ListItemsProperty.class);
}
+ @Test
public void testObserveItemsOfUnsupportedControl() throws Exception {
Table table = new Table(shell, SWT.NONE);
try {
@@ -378,6 +422,7 @@
}
}
+ @Test
public void testObserveSingleSelectionIndexOfTable() throws Exception {
Table table = new Table(shell, SWT.NONE);
ISWTObservableValue value = SWTObservables
@@ -386,6 +431,7 @@
TableSingleSelectionIndexProperty.class);
}
+ @Test
public void testObserveSingleSelectionIndexOfCCombo_DeselectAll()
throws Exception {
CCombo cCombo = new CCombo(shell, SWT.NONE);
@@ -399,6 +445,7 @@
assertEquals(-1, cCombo.getSelectionIndex());
}
+ @Test
public void testObserveSingleSelectionIndexOfCCombo_SetValueNull()
throws Exception {
CCombo cCombo = new CCombo(shell, SWT.NONE);
@@ -412,6 +459,7 @@
assertEquals(-1, cCombo.getSelectionIndex());
}
+ @Test
public void testObserveSingleSelectionIndexOfCombo_DeselectAll()
throws Exception {
Combo combo = new Combo(shell, SWT.NONE);
@@ -425,6 +473,7 @@
assertEquals(-1, combo.getSelectionIndex());
}
+ @Test
public void testObserveSingleSelectionIndexOfCombo_SetValueNull()
throws Exception {
Combo combo = new Combo(shell, SWT.NONE);
@@ -438,6 +487,7 @@
assertEquals(-1, combo.getSelectionIndex());
}
+ @Test
public void testObserveSingleSelectionIndexOfList_DeselectAll()
throws Exception {
List list = new List(shell, SWT.NONE);
@@ -451,6 +501,7 @@
assertEquals(-1, list.getSelectionIndex());
}
+ @Test
public void testObserveSingleSelectionIndexOfList_SetValueNull()
throws Exception {
List list = new List(shell, SWT.NONE);
@@ -464,6 +515,7 @@
assertEquals(-1, list.getSelectionIndex());
}
+ @Test
public void testObserveSingleSelectionIndexOfTable_DeselectAll()
throws Exception {
Table table = new Table(shell, SWT.NONE);
@@ -477,6 +529,7 @@
assertEquals(-1, table.getSelectionIndex());
}
+ @Test
public void testObserveSingleSelectionIndexOfTable_SetValueNull()
throws Exception {
Table table = new Table(shell, SWT.NONE);
@@ -490,6 +543,7 @@
assertEquals(-1, table.getSelectionIndex());
}
+ @Test
public void testObserveSingleSelectionIndexOfUnsupportedControl()
throws Exception {
Tree tree = new Tree(shell, SWT.NONE);
@@ -501,18 +555,21 @@
}
}
+ @Test
public void testObserveMinOfSpinner() throws Exception {
Spinner spinner = new Spinner(shell, SWT.NONE);
ISWTObservableValue value = SWTObservables.observeMin(spinner);
assertWidgetObservable(value, spinner, SpinnerMinimumProperty.class);
}
+ @Test
public void testObserveMinOfScale() throws Exception {
Scale scale = new Scale(shell, SWT.NONE);
ISWTObservableValue value = SWTObservables.observeMin(scale);
assertWidgetObservable(value, scale, ScaleMinimumProperty.class);
}
+ @Test
public void testObserveMinOfUnsupportedControl() throws Exception {
Text text = new Text(shell, SWT.NONE);
try {
@@ -522,18 +579,21 @@
}
}
+ @Test
public void testObserveMaxOfSpinner() throws Exception {
Spinner spinner = new Spinner(shell, SWT.NONE);
ISWTObservableValue value = SWTObservables.observeMax(spinner);
assertWidgetObservable(value, spinner, SpinnerMaximumProperty.class);
}
+ @Test
public void testObserveMaxOfScale() throws Exception {
Scale scale = new Scale(shell, SWT.NONE);
ISWTObservableValue value = SWTObservables.observeMax(scale);
assertWidgetObservable(value, scale, ScaleMaximumProperty.class);
}
+ @Test
public void testObserveMaxOfUnsupportedControl() throws Exception {
Text text = new Text(shell, SWT.NONE);
try {
@@ -543,18 +603,21 @@
}
}
+ @Test
public void testObserveEditableOfText() throws Exception {
Text text = new Text(shell, SWT.NONE);
ISWTObservableValue value = SWTObservables.observeEditable(text);
assertWidgetObservable(value, text, TextEditableProperty.class);
}
+ @Test
public void testObserveEditableOfCCombo() throws Exception {
CCombo combo = new CCombo(shell, SWT.NONE);
ISWTObservableValue value = SWTObservables.observeEditable(combo);
assertWidgetObservable(value, combo, CComboEditableProperty.class);
}
+ @Test
public void testObserveEditableOfStyledText() throws Exception {
StyledText styledText = new StyledText(shell, SWT.NONE);
ISWTObservableValue value = SWTObservables.observeEditable(styledText);
@@ -562,12 +625,14 @@
StyledTextEditableProperty.class);
}
+ @Test
public void testObserveEnabledOfMenu() throws Exception {
Menu menu = new Menu(shell, SWT.BAR);
ISWTObservableValue value = SWTObservables.observeEnabled(menu);
assertWidgetObservable(value, menu, MenuEnabledProperty.class);
}
+ @Test
public void testObserveEnabledOfMenuItem() throws Exception {
Menu menu = new Menu(shell, SWT.DROP_DOWN);
MenuItem item = new MenuItem(menu, SWT.PUSH);
@@ -575,6 +640,7 @@
assertWidgetObservable(value, item, MenuItemEnabledProperty.class);
}
+ @Test
public void testObserveSelectionOfMenuItem() throws Exception {
Menu menu = new Menu(shell, SWT.DROP_DOWN);
MenuItem item = new MenuItem(menu, SWT.PUSH);
@@ -582,12 +648,14 @@
assertWidgetObservable(value, item, MenuItemSelectionProperty.class);
}
+ @Test
public void testObserveEnabledOfScrollBar() throws Exception {
ScrollBar scrollBar = shell.getVerticalBar();
ISWTObservableValue value = SWTObservables.observeEnabled(scrollBar);
assertWidgetObservable(value, scrollBar, ScrollBarEnabledProperty.class);
}
+ @Test
public void testObserveEnabledOfToolItem() throws Exception {
ToolBar bar = new ToolBar(shell, SWT.HORIZONTAL);
ToolItem item = new ToolItem(bar, SWT.PUSH);
@@ -603,6 +671,7 @@
assertTrue(propertyClass.isInstance(propertyObservable.getProperty()));
}
+ @Test
public void testObserveEditableOfUnsupportedControl() throws Exception {
Label label = new Label(shell, SWT.NONE);
try {
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/WidgetObservableThreadTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/WidgetObservableThreadTest.java
index 672a190..790047b 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/WidgetObservableThreadTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/WidgetObservableThreadTest.java
@@ -12,6 +12,8 @@
package org.eclipse.jface.tests.databinding.swt;
+import static org.junit.Assert.assertEquals;
+
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.beans.BeanProperties;
import org.eclipse.core.tests.databinding.observable.ThreadRealm;
@@ -22,6 +24,9 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Text;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
/**
* @since 3.2
@@ -31,8 +36,8 @@
protected ThreadRealm threadRealm;
private DataBindingContext ctx;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
threadRealm = new ThreadRealm();
new Thread() {
@@ -47,8 +52,8 @@
threadRealm.waitUntilBlocking();
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
if (ctx != null) {
threadRealm.exec(new Runnable() {
@Override
@@ -66,6 +71,7 @@
super.tearDown();
}
+ @Test
public void testBindWidgetObservableFromNonDisplayThread() {
final Text text = new Text(getShell(), SWT.BORDER);
final Bean bean = new Bean("oldValue");
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/WidgetPropertiesTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/WidgetPropertiesTest.java
index 8bb2fed..eb0aedc 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/WidgetPropertiesTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/swt/WidgetPropertiesTest.java
@@ -12,6 +12,9 @@
package org.eclipse.jface.tests.databinding.swt;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.jface.databinding.conformance.util.RealmTester;
import org.eclipse.jface.databinding.swt.DisplayRealm;
@@ -42,6 +45,9 @@
import org.eclipse.swt.widgets.TrayItem;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeColumn;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
/**
* @since 3.2
@@ -56,8 +62,8 @@
private Image image1;
private Image image2;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
shell = getShell();
@@ -71,8 +77,8 @@
RealmTester.setDefault(DisplayRealm.getRealm(shell.getDisplay()));
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
super.tearDown();
RealmTester.setDefault(null);
@@ -83,6 +89,7 @@
return new Shell(SWT.V_SCROLL);
}
+ @Test
public void testImage_ObserveButton() {
Button button = /* who's got the */new Button(shell, SWT.PUSH);
button.setImage(image1);
@@ -94,6 +101,7 @@
assertSame(image2, button.getImage());
}
+ @Test
public void testImage_ObserveCLabel() {
CLabel label = new CLabel(shell, SWT.NONE);
label.setImage(image1);
@@ -105,6 +113,7 @@
assertSame(image2, label.getImage());
}
+ @Test
public void testImage_ObserveLabel() {
Label label = new Label(shell, SWT.NONE);
label.setImage(image1);
@@ -116,6 +125,7 @@
assertSame(image2, label.getImage());
}
+ @Test
public void testText_ObserveButton() {
Button button = /* who's got a */new Button(shell, SWT.PUSH);
button.setText(string1);
@@ -127,6 +137,7 @@
assertEquals(string2, button.getText());
}
+ @Test
public void testTooltipText_ObserveCTabItem() {
CTabFolder tf = new CTabFolder(shell, SWT.NONE);
CTabItem item = new CTabItem(tf, SWT.NONE);
@@ -140,6 +151,7 @@
assertEquals(string2, item.getToolTipText());
}
+ @Test
public void testTooltipText_ObserveControl() {
Control control = new Label(shell, SWT.NONE);
control.setToolTipText(string1);
@@ -152,6 +164,7 @@
assertEquals(string2, control.getToolTipText());
}
+ @Test
public void testTooltipText_ObserveTabItem() {
TabFolder tf = new TabFolder(shell, SWT.NONE);
TabItem item = new TabItem(tf, SWT.NONE);
@@ -165,6 +178,7 @@
assertEquals(string2, item.getToolTipText());
}
+ @Test
public void testTooltipText_ObserveTableColumn() {
Table table = new Table(shell, SWT.NONE);
TableColumn column = new TableColumn(table, SWT.NONE);
@@ -178,6 +192,7 @@
assertEquals(string2, column.getToolTipText());
}
+ @Test
public void testTooltipText_ObserveToolItem() {
ToolBar bar = new ToolBar(shell, SWT.NONE);
ToolItem item = new ToolItem(bar, SWT.NONE);
@@ -191,6 +206,7 @@
assertEquals(string2, item.getToolTipText());
}
+ @Test
public void testTooltipText_ObserveTrayItem() {
Tray tray = shell.getDisplay().getSystemTray();
TrayItem item = new TrayItem(tray, SWT.NONE);
@@ -209,6 +225,7 @@
}
}
+ @Test
public void testTooltipText_ObserveTreeColumn() {
Tree tree = new Tree(shell, SWT.NONE);
TreeColumn column = new TreeColumn(tree, SWT.NONE);
@@ -222,6 +239,7 @@
assertEquals(string2, column.getToolTipText());
}
+ @Test
public void testEnabled_ObserveMenu() {
Menu menu = new Menu(shell, SWT.BAR);
IObservableValue observable = WidgetProperties.enabled().observe(menu);
@@ -235,6 +253,7 @@
assertEquals(false, menu.getEnabled());
}
+ @Test
public void testEnabled_ObserveMenuItem() {
Menu menu = new Menu(shell, SWT.BAR);
MenuItem item = new MenuItem(menu, SWT.PUSH);
@@ -249,6 +268,7 @@
assertEquals(false, item.getEnabled());
}
+ @Test
public void testSelection_ObserveMenuItem() {
Menu menu = new Menu(shell, SWT.BAR);
MenuItem item = new MenuItem(menu, SWT.CHECK);
@@ -264,6 +284,7 @@
assertEquals(false, item.getSelection());
}
+ @Test
public void testEnabled_ObserveScrollBar() {
ScrollBar bar = shell.getVerticalBar();
IObservableValue observable = WidgetProperties.enabled().observe(bar);
@@ -277,6 +298,7 @@
assertEquals(false, bar.getEnabled());
}
+ @Test
public void testEnabled_ObserveToolItem() {
ToolBar bar = new ToolBar(shell, SWT.HORIZONTAL);
ToolItem item = new ToolItem(bar, SWT.PUSH);
@@ -291,6 +313,7 @@
assertEquals(false, item.getEnabled());
}
+ @Test
public void testEditable_ObserveText() {
Text text = new Text(shell, SWT.NONE);
IObservableValue observable = WidgetProperties.editable().observe(text);
@@ -304,6 +327,7 @@
assertEquals(true, text.getEditable());
}
+ @Test
public void testEditable_ObserveCCombo() {
CCombo combo = new CCombo(shell, SWT.NONE);
IObservableValue observable = WidgetProperties.editable()
@@ -318,6 +342,7 @@
assertEquals(true, combo.getEditable());
}
+ @Test
public void testEditable_ObserveStyledText() {
StyledText styledText = new StyledText(shell, SWT.NONE);
IObservableValue observable = WidgetProperties.editable().observe(
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/viewers/ObservableListContentProviderTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/viewers/ObservableListContentProviderTest.java
index fb04a08..aec17d9 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/viewers/ObservableListContentProviderTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/viewers/ObservableListContentProviderTest.java
@@ -11,6 +11,9 @@
******************************************************************************/
package org.eclipse.jface.tests.databinding.viewers;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
@@ -27,6 +30,9 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
public class ObservableListContentProviderTest extends AbstractDefaultRealmTestCase {
private Shell shell;
@@ -34,8 +40,8 @@
private ObservableListContentProvider contentProvider;
private IObservableList input;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
shell = new Shell();
viewer = new TableViewer(shell, SWT.NONE);
@@ -47,24 +53,27 @@
viewer.setInput(input);
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
shell.dispose();
viewer = null;
input = null;
super.tearDown();
}
+ @Test
public void testKnownElements_Realm() throws Exception {
assertSame("realm for the known elements should be the SWT realm", DisplayRealm.getRealm(Display.getDefault()),
contentProvider.getKnownElements().getRealm());
}
+ @Test
public void testRealizedElements_Realm() {
assertSame("realm for the realized elements should be the SWT realm",
DisplayRealm.getRealm(Display.getDefault()), contentProvider.getRealizedElements().getRealm());
}
+ @Test
public void testKnownElementsAfterSetInput() {
assertEquals(0, contentProvider.getKnownElements().size());
Set<String> newElements = new HashSet<String>(Arrays.asList(new String[] { "one", "two", "three" }));
@@ -74,6 +83,7 @@
assertEquals(newElements, contentProvider.getKnownElements());
}
+ @Test
public void testViewerUpdate_RemoveElementAfterMutation() {
Mutable element = new Mutable(1);
input.add(element);
@@ -86,6 +96,7 @@
assertEquals(0, viewer.getTable().getItemCount());
}
+ @Test
public void testInputChanged_ClearsKnownElements() {
Object element = new Object();
input.add(element);
@@ -96,6 +107,7 @@
assertEquals(Collections.EMPTY_SET, knownElements);
}
+ @Test
public void testInputChanged_ClearsRealizedElements() {
// Realized elements must be allocated before adding the element
// otherwise we'd have to spin the event loop to see the new element
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/viewers/ObservableListTreeContentProviderTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/viewers/ObservableListTreeContentProviderTest.java
index 3c35dc5..fe488ec 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/viewers/ObservableListTreeContentProviderTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/viewers/ObservableListTreeContentProviderTest.java
@@ -12,6 +12,10 @@
package org.eclipse.jface.tests.databinding.viewers;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.util.Arrays;
import java.util.Collections;
@@ -27,6 +31,9 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Tree;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
public class ObservableListTreeContentProviderTest extends
AbstractDefaultRealmTestCase {
@@ -36,8 +43,8 @@
private ObservableListTreeContentProvider contentProvider;
private Object input;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
shell = new Shell();
tree = new Tree(shell, SWT.NONE);
@@ -45,8 +52,8 @@
input = new Object();
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
shell.dispose();
tree = null;
viewer = null;
@@ -60,6 +67,7 @@
viewer.setInput(input);
}
+ @Test
public void testConstructor_NullArgumentThrowsException() {
try {
initContentProvider(null);
@@ -68,6 +76,7 @@
}
}
+ @Test
public void testGetElements_ChangesFollowObservedList() {
final IObservableList elements = new WritableList();
final Object input = new Object();
@@ -94,6 +103,7 @@
contentProvider.getElements(input)));
}
+ @Test
public void testViewerUpdate_RemoveElementAfterMutation() {
final IObservableList children = new WritableList();
initContentProvider(new IObservableFactory() {
@@ -112,6 +122,7 @@
assertEquals(0, tree.getItemCount());
}
+ @Test
public void testInputChanged_ClearsKnownElements() {
input = new Object();
final Object input2 = new Object();
@@ -138,6 +149,7 @@
assertEquals(Collections.EMPTY_SET, knownElements);
}
+ @Test
public void testInputChanged_ClearsRealizedElements() {
input = new Object();
final Object input2 = new Object();
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/viewers/ObservableMapLabelProviderTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/viewers/ObservableMapLabelProviderTest.java
index 25f2572..68ae430 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/viewers/ObservableMapLabelProviderTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/viewers/ObservableMapLabelProviderTest.java
@@ -12,6 +12,9 @@
package org.eclipse.jface.tests.databinding.viewers;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
import java.util.HashSet;
import org.eclipse.core.databinding.beans.BeansObservables;
@@ -19,13 +22,15 @@
import org.eclipse.jface.databinding.viewers.ObservableMapLabelProvider;
import org.eclipse.jface.examples.databinding.ModelObject;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
+import org.junit.Test;
/**
* @since 1.1
*/
public class ObservableMapLabelProviderTest extends AbstractDefaultRealmTestCase {
- public void testGetColumnText() throws Exception {
+ @Test
+ public void testGetColumnText() throws Exception {
WritableSet set = new WritableSet(new HashSet(), Item.class);
Item item = new Item();
String value = "value";
@@ -36,7 +41,8 @@
assertEquals(item.getValue(), labelProvider.getColumnText(item, 0));
}
- public void testGetColumnTextNullValue() throws Exception {
+ @Test
+ public void testGetColumnTextNullValue() throws Exception {
WritableSet set = new WritableSet(new HashSet(), Item.class);
Item item = new Item();
set.add(item);
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/viewers/ObservableSetContentProviderTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/viewers/ObservableSetContentProviderTest.java
index 5239534..3091be2 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/viewers/ObservableSetContentProviderTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/viewers/ObservableSetContentProviderTest.java
@@ -13,6 +13,9 @@
package org.eclipse.jface.tests.databinding.viewers;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
@@ -28,6 +31,9 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
/**
* @since 3.3
@@ -39,8 +45,8 @@
private ObservableSetContentProvider contentProvider;
private IObservableSet input;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
shell = new Shell();
viewer = new TableViewer(shell, SWT.NONE);
@@ -52,24 +58,27 @@
viewer.setInput(input);
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
shell.dispose();
viewer = null;
input = null;
super.tearDown();
}
+ @Test
public void testKnownElements_Realm() throws Exception {
assertSame("realm for the known elements should be the SWT realm", DisplayRealm.getRealm(Display.getDefault()),
contentProvider.getKnownElements().getRealm());
}
+ @Test
public void testRealizedElements_Realm() {
assertSame("realm for the realized elements should be the SWT realm",
DisplayRealm.getRealm(Display.getDefault()), contentProvider.getRealizedElements().getRealm());
}
+ @Test
public void testKnownElementsAfterSetInput() {
assertEquals(0, contentProvider.getKnownElements().size());
Set<String> newElements = new HashSet<String>(Arrays.asList(new String[] { "one", "two", "three" }));
@@ -79,6 +88,7 @@
assertEquals(newElements, contentProvider.getKnownElements());
}
+ @Test
public void testViewerUpdate_RemoveElementAfterMutation() {
Mutable element = new Mutable(1);
input.add(element);
@@ -91,6 +101,7 @@
assertEquals(0, viewer.getTable().getItemCount());
}
+ @Test
public void testInputChanged_ClearsKnownElements() {
Object element = new Object();
input.add(element);
@@ -101,6 +112,7 @@
assertEquals(Collections.EMPTY_SET, knownElements);
}
+ @Test
public void testInputChanged_ClearsRealizedElements() {
// Realized elements must be allocated before adding the element
// otherwise we'd have to spin the event loop to see the new element
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/viewers/ObservableSetTreeContentProviderTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/viewers/ObservableSetTreeContentProviderTest.java
index 55e72e6..3a1b7d3 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/viewers/ObservableSetTreeContentProviderTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/viewers/ObservableSetTreeContentProviderTest.java
@@ -12,6 +12,10 @@
package org.eclipse.jface.tests.databinding.viewers;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -30,6 +34,9 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Tree;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
public class ObservableSetTreeContentProviderTest extends AbstractDefaultRealmTestCase {
private Shell shell;
@@ -38,8 +45,8 @@
private ObservableSetTreeContentProvider contentProvider;
private Object input;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
shell = new Shell();
tree = new Tree(shell, SWT.NONE);
@@ -47,8 +54,8 @@
input = new Object();
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
shell.dispose();
tree = null;
viewer = null;
@@ -62,6 +69,7 @@
viewer.setInput(input);
}
+ @Test
public void testConstructor_NullArgumentThrowsException() {
try {
initContentProvider(null);
@@ -70,6 +78,7 @@
}
}
+ @Test
public void testGetElements_ChangesFollowObservedList() {
final IObservableSet elements = new WritableSet();
final Object input = new Object();
@@ -95,6 +104,7 @@
assertTrue(elementList.containsAll(Arrays.asList(new Object[] { element0, element1 })));
}
+ @Test
public void testViewerUpdate_RemoveElementAfterMutation() {
IElementComparer comparer = new IElementComparer() {
@Override
@@ -126,6 +136,7 @@
assertEquals(0, tree.getItemCount());
}
+ @Test
public void testInputChanged_ClearsKnownElements() {
input = new Object();
final Object input2 = new Object();
@@ -152,6 +163,7 @@
assertEquals(Collections.EMPTY_SET, knownElements);
}
+ @Test
public void testInputChanged_ClearsRealizedElements() {
input = new Object();
final Object input2 = new Object();
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/viewers/ObservableValueEditingSupportTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/viewers/ObservableValueEditingSupportTest.java
index 92ac08c..0c10d85 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/viewers/ObservableValueEditingSupportTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/viewers/ObservableValueEditingSupportTest.java
@@ -12,6 +12,10 @@
package org.eclipse.jface.tests.databinding.viewers;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import org.eclipse.core.databinding.Binding;
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.beans.BeanProperties;
@@ -34,6 +38,8 @@
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
+import org.junit.Before;
+import org.junit.Test;
public class ObservableValueEditingSupportTest extends AbstractSWTTestCase {
private Shell shell;
@@ -46,8 +52,8 @@
private Bean bean;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
shell = getShell();
@@ -69,6 +75,7 @@
"value"));
}
+ @Test
public void testInitializeCellEditorValue_OrderOfOperations()
throws Exception {
assertEquals("precondition", 0, editingSupport.events.length());
@@ -79,6 +86,7 @@
editingSupport.events.toString());
}
+ @Test
public void testSaveCellEditorValue_UpdatesModel() throws Exception {
shell.open();
@@ -101,6 +109,7 @@
editingSupport.text.notifyListeners(SWT.DefaultSelection, new Event());
}
+ @Test
public void testSaveCellEditorValue_IgnoreIfNotDirty() throws Exception {
String initialValue = bean.getValue();
@@ -115,6 +124,7 @@
assertEquals(initialValue, bean.getValue());
}
+ @Test
public void testDisposesBinding() throws Exception {
shell.open();
@@ -125,6 +135,7 @@
assertTrue(editingSupport.binding.isDisposed());
}
+ @Test
public void testDisposesTargetObservable() throws Exception {
shell.open();
@@ -135,6 +146,7 @@
assertTrue(editingSupport.target.isDisposed());
}
+ @Test
public void testDisposesModelObservable() throws Exception {
shell.open();
@@ -145,6 +157,7 @@
assertTrue(editingSupport.model.isDisposed());
}
+ @Test
public void testCanEdit_DefaultIsTrue() throws Exception {
assertTrue(editingSupport.canEdit(bean));
}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/viewers/ViewerSupportTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/viewers/ViewerSupportTest.java
index 29b56d7..f5eb031 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/viewers/ViewerSupportTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/viewers/ViewerSupportTest.java
@@ -11,6 +11,8 @@
package org.eclipse.jface.tests.databinding.viewers;
+import static org.junit.Assert.fail;
+
import java.util.Arrays;
import java.util.HashSet;
@@ -36,6 +38,9 @@
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TreeViewer;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
public class ViewerSupportTest extends AbstractSWTTestCase {
private ILogger oldLog;
@@ -44,8 +49,8 @@
private AbstractTableViewer structuredViewer;
private AbstractTreeViewer treeViewer;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
oldLog = Policy.getLog();
@@ -71,8 +76,8 @@
});
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
if (structuredViewer != null)
structuredViewer.getControl().dispose();
if (treeViewer != null)
@@ -98,6 +103,7 @@
return treeViewer;
}
+ @Test
public void testBindList_Twice() {
StructuredViewer viewer = getStructuredViewer();
IObservableList input0 = WritableList.withElementType(Bean.class);
@@ -109,6 +115,7 @@
ViewerSupport.bind(viewer, input1, labelProp);
}
+ @Test
public void testBindSet_Twice() {
StructuredViewer viewer = getStructuredViewer();
IObservableSet input0 = WritableSet.withElementType(Bean.class);
@@ -120,6 +127,7 @@
ViewerSupport.bind(viewer, input1, labelProp);
}
+ @Test
public void testBindListTree_Twice() {
AbstractTreeViewer viewer = getTreeViewer();
Bean input0 = new Bean(Arrays.asList(new Bean[] { new Bean("elem0"), new Bean("elem1"), new Bean("elem2") }));
@@ -130,6 +138,7 @@
ViewerSupport.bind(viewer, input1, childrenProp, labelProp);
}
+ @Test
public void testBindSetTree_Twice() {
AbstractTreeViewer viewer = getTreeViewer();
Bean input0 = new Bean(new HashSet<Bean>(Arrays.asList(new Bean[] { new Bean("elem0"), new Bean("elem1"),
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/viewers/ViewersObservablesTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/viewers/ViewersObservablesTest.java
index 69ead76..5df29f0 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/viewers/ViewersObservablesTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/viewers/ViewersObservablesTest.java
@@ -12,6 +12,8 @@
package org.eclipse.jface.tests.databinding.viewers;
+import static org.junit.Assert.assertTrue;
+
import org.eclipse.core.databinding.observable.IDecoratingObservable;
import org.eclipse.core.databinding.observable.Realm;
import org.eclipse.core.databinding.property.IPropertyObservable;
@@ -24,6 +26,9 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
/**
* Tests for ViewersObservables
@@ -34,16 +39,16 @@
TableViewer viewer;
Realm realm;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
realm = DisplayRealm.getRealm(Display.getCurrent());
Shell shell = new Shell();
viewer = new TableViewer(shell, SWT.NONE);
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
Shell shell = viewer.getTable().getShell();
if (!shell.isDisposed())
shell.dispose();
@@ -52,6 +57,7 @@
super.tearDown();
}
+ @Test
public void testObserveInput_InstanceOfViewerInputObservableValue() {
IViewerObservableValue observable = (IViewerObservableValue) ViewersObservables
.observeInput(viewer);
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/wizard/WizardPageSupportTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/wizard/WizardPageSupportTest.java
index 13fefcb..92c09dc 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/wizard/WizardPageSupportTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/wizard/WizardPageSupportTest.java
@@ -12,6 +12,11 @@
package org.eclipse.jface.tests.databinding.wizard;
+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.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.ValidationStatusProvider;
import org.eclipse.core.databinding.observable.Diffs;
@@ -35,6 +40,7 @@
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.widgets.Composite;
+import org.junit.Test;
/**
* @since 1.2
@@ -44,6 +50,7 @@
/**
* Bug 235195.
*/
+ @Test
public void testPageComplete() {
IWizardPage page = new WizardPage("Page") {
@Override
@@ -79,6 +86,7 @@
loadWizardPage(page);
}
+ @Test
public void testPageCompleteOnValidationStaleness() {
IWizardPage page = new WizardPage("Page") {
@Override
@@ -106,6 +114,7 @@
loadWizardPage(page);
}
+ @Test
public void testValidationMessageProvider() {
IWizardPage page = new WizardPage("Page") {
@Override
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/examples/databinding/mask/internal/EditMaskLexerAndTokenTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/examples/databinding/mask/internal/EditMaskLexerAndTokenTest.java
index 7505b91..05461fd 100755
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/examples/databinding/mask/internal/EditMaskLexerAndTokenTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/examples/databinding/mask/internal/EditMaskLexerAndTokenTest.java
@@ -10,19 +10,26 @@
*******************************************************************************/
package org.eclipse.jface.tests.examples.databinding.mask.internal;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import org.eclipse.jface.examples.databinding.mask.internal.EditMaskLexerAndToken;
+import org.junit.Before;
+import org.junit.Test;
-public class EditMaskLexerAndTokenTest extends TestCase {
+public class EditMaskLexerAndTokenTest {
private EditMaskLexerAndToken token;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
token = new EditMaskLexerAndToken();
}
+ @Test
public void testInitWithNumeric() throws Exception {
token.initializeEditMask("#", 0);
assertTrue("Should accept a digit", token.accept("0"));
@@ -51,6 +58,7 @@
assertFalse("Placeholders are not read-only", token.isReadOnly());
}
+ @Test
public void testInitWithLiteral() throws Exception {
token.initializeEditMask("(", 0);
assertEquals("Literals automatically set their input", "(", token.getInput());
@@ -60,28 +68,33 @@
assertFalse("Literals cannot accept characters", token.canAcceptMoreCharacters());
}
+ @Test
public void testInitWithBackslashLiteral() throws Exception {
token.initializeEditMask("\\#", 0);
assertEquals("Should get backslash literal", "#", token.getInput());
}
+ @Test
public void testAcceptWithValidInputAndEmpty() throws Exception {
token.initializeEditMask("#", 0);
assertTrue("Should accept a 0", token.accept("0"));
}
+ @Test
public void testAcceptWhenParserCannotAcceptMoreCharacters() throws Exception {
token.initializeEditMask("#", 0);
assertTrue("Should accept a 0", token.accept("0"));
assertFalse("Should not accept a 0 -- input full", token.accept("0"));
}
+ @Test
public void testGetInput() throws Exception {
token.initializeEditMask("#", 0);
assertTrue("Should accept a #", token.accept("0"));
assertEquals(token.getInput(), "0");
}
+ @Test
public void testClear_withNonLiteral() throws Exception {
token.initializeEditMask("#", 0);
assertTrue("Should accept a 0", token.accept("0"));
@@ -90,6 +103,7 @@
assertNull("Input should be null after clear", token.getInput());
}
+ @Test
public void testClear_withLiteral() throws Exception {
token.initializeEditMask("(", 0);
assertNotNull("Input should not be null", token.getInput());
@@ -97,6 +111,7 @@
assertNotNull("Input should still not be null after clear of read-only literal", token.getInput());
}
+ @Test
public void testIsComplete_withNonLiteral() throws Exception {
token.initializeEditMask("#", 0);
assertFalse("should not be complete", token.isComplete());
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/examples/databinding/mask/internal/EditMaskParserTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/examples/databinding/mask/internal/EditMaskParserTest.java
index fee1b8e..239c1971 100755
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/examples/databinding/mask/internal/EditMaskParserTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/examples/databinding/mask/internal/EditMaskParserTest.java
@@ -11,27 +11,33 @@
package org.eclipse.jface.tests.examples.databinding.mask.internal;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import org.eclipse.jface.examples.databinding.mask.EditMaskParseException;
import org.eclipse.jface.examples.databinding.mask.internal.EditMaskParser;
+import org.junit.Before;
+import org.junit.Test;
/**
* @since 3.2
*
*/
-public class EditMaskParserTest extends TestCase {
+public class EditMaskParserTest {
private EditMaskParser parser;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
parser = new EditMaskParser("(###) ###-####");
}
/**
* Test method for {@link org.eclipse.jface.examples.databinding.mask.internal.EditMaskParser#EditMaskParser(java.lang.String)}.
*/
+ @Test
public void testEditMaskParser_validMask() {
new EditMaskParser("(###) ###-####");
}
@@ -39,6 +45,7 @@
/**
* Test method for {@link org.eclipse.jface.examples.databinding.mask.internal.EditMaskParser#EditMaskParser(java.lang.String)}.
*/
+ @Test
public void testEditMaskParser_invalidMask() {
try {
new EditMaskParser("(###) ###-####\\");
@@ -51,6 +58,7 @@
/**
* Test method for {@link org.eclipse.jface.examples.databinding.mask.internal.EditMaskParser#setInput(java.lang.String)}.
*/
+ @Test
public void testSetInput() {
parser.setInput("63a0) 5*55-1\\212abc9");
assertEquals("Unformatted input", "6305551212", parser.getRawResult());
@@ -60,6 +68,7 @@
/**
* Test method for {@link org.eclipse.jface.examples.databinding.mask.internal.EditMaskParser#setInput(java.lang.String)}.
*/
+ @Test
public void testSetInput_incomplete() {
parser.setInput("6a0) 5*5-1\\12");
assertEquals("Unformatted input", "6055112", parser.getRawResult());
@@ -69,6 +78,7 @@
/**
* Test method for {@link org.eclipse.jface.examples.databinding.mask.internal.EditMaskParser#isComplete()}.
*/
+ @Test
public void testIsComplete() {
parser.setInput("63a0) 5*55-1\\212");
assertTrue("complete", parser.isComplete());
@@ -76,6 +86,7 @@
assertFalse("incomplete", parser.isComplete());
}
+ @Test
public void testSetPlaceholder() throws Exception {
parser.setInput("6a0) 5*5-1\\12");
assertEquals("Formatted input", "(605) 511-2 ", parser.getFormattedResult());
@@ -86,12 +97,14 @@
/**
* Test method for {@link org.eclipse.jface.examples.databinding.mask.internal.EditMaskParser#getNextInputPosition(int)}.
*/
+ @Test
public void testGetNextInputPosition() {
assertEquals("Skip leading (", 1, parser.getNextInputPosition(0));
assertEquals("Position 1 is good", 1, parser.getNextInputPosition(1));
assertEquals("Skip )<space>", 6, parser.getNextInputPosition(4));
}
+ @Test
public void testGetFirstIncompleteInputPosition() throws Exception {
assertEquals("1st position incomplete", 1, parser.getFirstIncompleteInputPosition());
parser.setInput("6a0) 5*5-1\\12");
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/examples/model/PersonTests.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/examples/model/PersonTests.java
index e44f983..85a42d3 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/examples/model/PersonTests.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/examples/model/PersonTests.java
@@ -11,18 +11,22 @@
package org.eclipse.jface.tests.examples.model;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
-import junit.framework.TestCase;
-
import org.eclipse.jface.examples.databinding.model.SimplePerson;
+import org.junit.Test;
/**
* @since 3.2
*
*/
-public class PersonTests extends TestCase {
+public class PersonTests {
+ @Test
public void testSetName() {
SimplePerson person = new SimplePerson();
Listener listener = new Listener();
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/ButtonObservableValueTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/ButtonObservableValueTest.java
index d3e80b6..d950c0a 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/ButtonObservableValueTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/ButtonObservableValueTest.java
@@ -13,8 +13,9 @@
package org.eclipse.jface.tests.internal.databinding.swt;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.Realm;
@@ -29,6 +30,10 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Shell;
+import org.junit.Before;
+import org.junit.Test;
+
+import junit.framework.TestSuite;
/**
* @since 3.2
@@ -39,7 +44,8 @@
private ValueChangeEventTracker listener;
@Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
Shell shell = getShell();
@@ -48,6 +54,7 @@
listener = new ValueChangeEventTracker();
}
+ @Test
public void testSelection_ChangeNotifiesObservable() throws Exception {
observableValue.addValueChangeListener(listener);
button.setSelection(true);
@@ -60,6 +67,7 @@
listener.count);
}
+ @Test
public void testSelection_NoChange() throws Exception {
button.setSelection(true);
button.notifyListeners(SWT.Selection, null);
@@ -74,6 +82,7 @@
0, listener.count);
}
+ @Test
public void testSetValue_NullConvertedToFalse() {
button.setSelection(true);
assertEquals(Boolean.TRUE, observableValue.getValue());
@@ -82,6 +91,7 @@
assertEquals(Boolean.FALSE, observableValue.getValue());
}
+ @Test
public void testDispose() throws Exception {
ValueChangeEventTracker testCounterValueChangeListener = new ValueChangeEventTracker();
observableValue.addValueChangeListener(testCounterValueChangeListener);
@@ -104,13 +114,8 @@
assertEquals(1, testCounterValueChangeListener.count);
}
- public static Test suite() {
- TestSuite suite = new TestSuite(ButtonObservableValueTest.class
- .getName());
- suite.addTestSuite(ButtonObservableValueTest.class);
- suite.addTest(SWTMutableObservableValueContractTest
- .suite(new Delegate()));
- return suite;
+ public static void addConformanceTest(TestSuite suite) {
+ suite.addTest(SWTMutableObservableValueContractTest.suite(new Delegate()));
}
/* package */static class Delegate extends
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/CComboObservableValueSelectionTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/CComboObservableValueSelectionTest.java
index c6c2d12..2a977e8 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/CComboObservableValueSelectionTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/CComboObservableValueSelectionTest.java
@@ -12,9 +12,7 @@
package org.eclipse.jface.tests.internal.databinding.swt;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.Realm;
@@ -29,31 +27,33 @@
import org.eclipse.swt.custom.CCombo;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import junit.framework.TestSuite;
/**
* @since 3.2
*/
-public class CComboObservableValueSelectionTest extends TestCase {
+public class CComboObservableValueSelectionTest {
private Delegate delegate;
private CCombo combo;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
+ @Before
+ public void setUp() throws Exception {
delegate = new Delegate();
delegate.setUp();
combo = delegate.combo;
}
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
-
+ @After
+ public void tearDown() throws Exception {
delegate.tearDown();
}
+ @Test
public void testSelection_NotifiesObservable() throws Exception {
IObservableValue observable = (IObservableValue) delegate
.createObservable(DisplayRealm.getRealm(Display.getDefault()));
@@ -65,13 +65,8 @@
assertEquals("Observable was not notified.", 1, listener.count);
}
- public static Test suite() {
- TestSuite suite = new TestSuite(
- CComboObservableValueSelectionTest.class.getName());
- suite.addTestSuite(CComboObservableValueSelectionTest.class);
- suite.addTest(SWTMutableObservableValueContractTest
- .suite(new Delegate()));
- return suite;
+ public static void addConformanceTest(TestSuite suite) {
+ suite.addTest(SWTMutableObservableValueContractTest.suite(new Delegate()));
}
/* package */static class Delegate extends
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/CComboObservableValueTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/CComboObservableValueTest.java
index 035efbd..85d9181 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/CComboObservableValueTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/CComboObservableValueTest.java
@@ -14,6 +14,8 @@
package org.eclipse.jface.tests.internal.databinding.swt;
+import static org.junit.Assert.assertEquals;
+
import org.eclipse.core.databinding.observable.Realm;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.core.databinding.property.value.IValueProperty;
@@ -24,11 +26,13 @@
import org.eclipse.jface.tests.databinding.AbstractSWTTestCase;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CCombo;
+import org.junit.Test;
/**
* @since 3.2
*/
public class CComboObservableValueTest extends AbstractSWTTestCase {
+ @Test
public void testDispose() throws Exception {
CCombo combo = new CCombo(getShell(), SWT.NONE);
ISWTObservableValue observableValue = SWTObservables.observeText(combo);
@@ -55,6 +59,7 @@
assertEquals(expected2, combo.getText());
}
+ @Test
public void testSetValueWithNull() {
testSetValueWithNull(WidgetProperties.text());
testSetValueWithNull(WidgetProperties.selection());
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/CComboObservableValueTextTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/CComboObservableValueTextTest.java
index 7d8b858..cc83f99 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/CComboObservableValueTextTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/CComboObservableValueTextTest.java
@@ -12,9 +12,7 @@
package org.eclipse.jface.tests.internal.databinding.swt;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.Realm;
@@ -28,31 +26,33 @@
import org.eclipse.swt.custom.CCombo;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import junit.framework.TestSuite;
/**
* @since 3.2
*/
-public class CComboObservableValueTextTest extends TestCase {
+public class CComboObservableValueTextTest {
private Delegate delegate;
private CCombo combo;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
+ @Before
+ public void setUp() throws Exception {
delegate = new Delegate();
delegate.setUp();
combo = delegate.combo;
}
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
-
+ @After
+ public void tearDown() throws Exception {
delegate.tearDown();
}
+ @Test
public void testModify_NotifiesObservable() throws Exception {
IObservableValue observable = delegate
.createObservableValue(DisplayRealm.getRealm(Display
@@ -65,13 +65,8 @@
assertEquals("Observable was not notified.", 1, listener.count);
}
- public static Test suite() {
- TestSuite suite = new TestSuite(CComboObservableValueTextTest.class
- .getName());
- suite.addTestSuite(CComboObservableValueTextTest.class);
- suite.addTest(SWTMutableObservableValueContractTest
- .suite(new Delegate()));
- return suite;
+ public static void addConformanceTest(TestSuite suite) {
+ suite.addTest(SWTMutableObservableValueContractTest.suite(new Delegate()));
}
/* package */static class Delegate extends
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/CComboSingleSelectionObservableValueTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/CComboSingleSelectionObservableValueTest.java
index 8eca36b..28ec096 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/CComboSingleSelectionObservableValueTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/CComboSingleSelectionObservableValueTest.java
@@ -13,8 +13,7 @@
package org.eclipse.jface.tests.internal.databinding.swt;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.Realm;
@@ -27,12 +26,16 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CCombo;
import org.eclipse.swt.widgets.Shell;
+import org.junit.Test;
+
+import junit.framework.TestSuite;
/**
* @since 3.2
*/
public class CComboSingleSelectionObservableValueTest extends
AbstractSWTTestCase {
+ @Test
public void testSetValue() throws Exception {
CCombo combo = new CCombo(getShell(), SWT.NONE);
IObservableValue observableValue = SWTObservables
@@ -52,13 +55,8 @@
assertEquals("Item2", combo.getText());
}
- public static Test suite() {
- TestSuite suite = new TestSuite(
- CComboSingleSelectionObservableValueTest.class.getName());
- suite.addTestSuite(CComboSingleSelectionObservableValueTest.class);
- suite.addTest(SWTMutableObservableValueContractTest
- .suite(new Delegate()));
- return suite;
+ public static void addConformanceTest(TestSuite suite) {
+ suite.addTest(SWTMutableObservableValueContractTest.suite(new Delegate()));
}
/* package */static class Delegate extends
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/CLabelObservableValueTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/CLabelObservableValueTest.java
index 508838e..b1774a3 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/CLabelObservableValueTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/CLabelObservableValueTest.java
@@ -12,9 +12,7 @@
package org.eclipse.jface.tests.internal.databinding.swt;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.Realm;
@@ -27,20 +25,23 @@
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import junit.framework.TestSuite;
/**
* @since 3.2
*
*/
-public class CLabelObservableValueTest extends TestCase {
+public class CLabelObservableValueTest {
private Delegate delegate;
private IObservableValue observable;
private CLabel label;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
+ @Before
+ public void setUp() throws Exception {
delegate = new Delegate();
delegate.setUp();
label = delegate.label;
@@ -48,14 +49,13 @@
.getRealm(Display.getDefault()));
}
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
-
+ @After
+ public void tearDown() throws Exception {
delegate.tearDown();
observable.dispose();
}
+ @Test
public void testSetValue() throws Exception {
// preconditions
assertEquals(null, label.getText());
@@ -67,13 +67,8 @@
assertEquals("observable value", value, observable.getValue());
}
- public static Test suite() {
- TestSuite suite = new TestSuite(CLabelObservableValueTest.class
- .getName());
- suite.addTestSuite(CLabelObservableValueTest.class);
- suite.addTest(SWTMutableObservableValueContractTest
- .suite(new Delegate()));
- return suite;
+ public static void addConformanceTest(TestSuite suite) {
+ suite.addTest(SWTMutableObservableValueContractTest.suite(new Delegate()));
}
/* package */static class Delegate extends
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/ComboObservableValueSelectionTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/ComboObservableValueSelectionTest.java
index 7e70310..5e8efd3 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/ComboObservableValueSelectionTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/ComboObservableValueSelectionTest.java
@@ -12,9 +12,7 @@
package org.eclipse.jface.tests.internal.databinding.swt;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.Realm;
@@ -29,32 +27,34 @@
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import junit.framework.TestSuite;
/**
* @since 3.2
*
*/
-public class ComboObservableValueSelectionTest extends TestCase {
+public class ComboObservableValueSelectionTest {
private Delegate delegate;
private Combo combo;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
+ @Before
+ public void setUp() throws Exception {
delegate = new Delegate();
delegate.setUp();
combo = delegate.combo;
}
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
-
+ @After
+ public void tearDown() throws Exception {
delegate.tearDown();
}
+ @Test
public void testSelection_NotifiesObservable() throws Exception {
IObservableValue observable = (IObservableValue) delegate
.createObservable(DisplayRealm.getRealm(Display.getDefault()));
@@ -67,13 +67,8 @@
assertEquals("Observable was not notified.", 1, listener.count);
}
- public static Test suite() {
- TestSuite suite = new TestSuite(ComboObservableValueSelectionTest.class
- .toString());
- suite.addTestSuite(ComboObservableValueSelectionTest.class);
- suite.addTest(SWTMutableObservableValueContractTest
- .suite(new Delegate()));
- return suite;
+ public static void addConformanceTest(TestSuite suite) {
+ suite.addTest(SWTMutableObservableValueContractTest.suite(new Delegate()));
}
/* package */static class Delegate extends
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/ComboObservableValueTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/ComboObservableValueTest.java
index 31b60ef..379e5a4 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/ComboObservableValueTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/ComboObservableValueTest.java
@@ -13,6 +13,8 @@
package org.eclipse.jface.tests.internal.databinding.swt;
+import static org.junit.Assert.assertEquals;
+
import org.eclipse.core.databinding.observable.Realm;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.core.databinding.property.value.IValueProperty;
@@ -24,12 +26,14 @@
import org.eclipse.jface.tests.databinding.AbstractSWTTestCase;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Combo;
+import org.junit.Test;
/**
* @since 3.2
* @no
*/
public class ComboObservableValueTest extends AbstractSWTTestCase {
+ @Test
public void testDispose() throws Exception {
Combo combo = new Combo(getShell(), SWT.NONE);
IObservableValue observableValue = SWTObservables.observeText(combo);
@@ -55,6 +59,7 @@
assertEquals(expected2, combo.getText());
}
+ @Test
public void testSetValueWithNull() {
testSetValueWithNull(WidgetProperties.text());
testSetValueWithNull(WidgetProperties.selection());
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/ComboObservableValueTextTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/ComboObservableValueTextTest.java
index f4cc479..7493d5d 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/ComboObservableValueTextTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/ComboObservableValueTextTest.java
@@ -12,9 +12,7 @@
package org.eclipse.jface.tests.internal.databinding.swt;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.Realm;
@@ -28,32 +26,34 @@
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import junit.framework.TestSuite;
/**
* @since 3.2
*
*/
-public class ComboObservableValueTextTest extends TestCase {
+public class ComboObservableValueTextTest {
private Delegate delegate;
private Combo combo;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
+ @Before
+ public void setUp() throws Exception {
delegate = new Delegate();
delegate.setUp();
combo = delegate.combo;
}
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
-
+ @After
+ public void tearDown() throws Exception {
delegate.tearDown();
}
+ @Test
public void testModify_NotifiesObservable() throws Exception {
IObservableValue observable = delegate
.createObservableValue(DisplayRealm.getRealm(Display
@@ -66,13 +66,8 @@
assertEquals("Observable was not notified.", 1, listener.count);
}
- public static Test suite() {
- TestSuite suite = new TestSuite(ComboObservableValueTextTest.class
- .toString());
- suite.addTestSuite(ComboObservableValueTextTest.class);
- suite.addTest(SWTMutableObservableValueContractTest
- .suite(new Delegate()));
- return suite;
+ public static void addConformanceTest(TestSuite suite) {
+ suite.addTest(SWTMutableObservableValueContractTest.suite(new Delegate()));
}
/* package */static class Delegate extends
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/ComboSingleSelectionObservableValueTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/ComboSingleSelectionObservableValueTest.java
index f05b219..bb072ca 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/ComboSingleSelectionObservableValueTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/ComboSingleSelectionObservableValueTest.java
@@ -11,11 +11,14 @@
******************************************************************************/
package org.eclipse.jface.tests.internal.databinding.swt;
+import static org.junit.Assert.assertEquals;
+
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.jface.databinding.swt.SWTObservables;
import org.eclipse.jface.tests.databinding.AbstractSWTTestCase;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Combo;
+import org.junit.Test;
/**
* @since 3.2
@@ -23,6 +26,7 @@
*/
public class ComboSingleSelectionObservableValueTest extends
AbstractSWTTestCase {
+ @Test
public void testSetValue() throws Exception {
Combo combo = new Combo(getShell(), SWT.NONE);
IObservableValue observableValue = SWTObservables
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/ControlObservableValueTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/ControlObservableValueTest.java
index c3cc028..81c9c98 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/ControlObservableValueTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/ControlObservableValueTest.java
@@ -13,6 +13,10 @@
package org.eclipse.jface.tests.internal.databinding.swt;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.jface.databinding.conformance.util.ValueChangeEventTracker;
import org.eclipse.jface.databinding.swt.ISWTObservableValue;
@@ -28,6 +32,9 @@
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
/**
* @since 3.2
@@ -37,20 +44,23 @@
private Shell shell;
@Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
shell = new Shell();
}
@Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
if (shell != null && !shell.isDisposed()) {
shell.dispose();
shell = null;
}
}
+ @Test
public void testSetValueEnabled() throws Exception {
ISWTObservableValue observableValue = SWTObservables.observeEnabled(shell);
Boolean value = Boolean.FALSE;
@@ -58,34 +68,40 @@
assertFalse(shell.isEnabled());
}
+ @Test
public void testGetValueEnabled() throws Exception {
ISWTObservableValue value = SWTObservables.observeEnabled(shell);
shell.setEnabled(false);
assertEquals(Boolean.FALSE, value.getValue());
}
+ @Test
public void testGetValueTypeEnabled() throws Exception {
ISWTObservableValue value = SWTObservables.observeEnabled(shell);
assertEquals(boolean.class, value.getValueType());
}
+ @Test
public void testSetValueVisible() throws Exception {
ISWTObservableValue value = SWTObservables.observeVisible(shell);
value.setValue(Boolean.FALSE);
assertFalse(shell.isVisible());
}
+ @Test
public void testGetValueVisible() throws Exception {
ISWTObservableValue value = SWTObservables.observeVisible(shell);
shell.setVisible(false);
assertEquals(Boolean.FALSE, value.getValue());
}
+ @Test
public void testGetValueTypeVisible() throws Exception {
ISWTObservableValue value = SWTObservables.observeVisible(shell);
assertEquals(Boolean.TYPE, value.getValueType());
}
+ @Test
public void testSetValueForeground() throws Exception {
ISWTObservableValue value = SWTObservables.observeForeground(shell);
@@ -95,6 +111,7 @@
assertEquals(color, shell.getForeground());
}
+ @Test
public void testGetValueForeground() throws Exception {
ISWTObservableValue value = SWTObservables.observeForeground(shell);
@@ -103,11 +120,13 @@
assertEquals(color, value.getValue());
}
+ @Test
public void testGetValueTypeForgroundColor() throws Exception {
ISWTObservableValue value = SWTObservables.observeForeground(shell);
assertEquals(Color.class, value.getValueType());
}
+ @Test
public void testGetValueBackground() throws Exception {
ISWTObservableValue value = SWTObservables.observeBackground(shell);
@@ -116,6 +135,7 @@
assertEquals(color, value.getValue());
}
+ @Test
public void testSetValueBackground() throws Exception {
ISWTObservableValue value = SWTObservables.observeBackground(shell);
@@ -125,16 +145,19 @@
assertEquals(color, shell.getBackground());
}
+ @Test
public void testGetValueTypeBackgroundColor() throws Exception {
ISWTObservableValue value = SWTObservables.observeBackground(shell);
assertEquals(Color.class, value.getValueType());
}
+ @Test
public void testGetValueTypeTooltip() throws Exception {
ISWTObservableValue value = SWTObservables.observeTooltipText(shell);
assertEquals(String.class, value.getValueType());
}
+ @Test
public void testSetValueFont() throws Exception {
ISWTObservableValue value = SWTObservables.observeFont(shell);
@@ -144,6 +167,7 @@
assertEquals(font, shell.getFont());
}
+ @Test
public void testGetValueFont() throws Exception {
ISWTObservableValue value = SWTObservables.observeFont(shell);
@@ -152,11 +176,13 @@
assertEquals(font, value.getValue());
}
+ @Test
public void testGetValueTypeFont() throws Exception {
ISWTObservableValue value = SWTObservables.observeFont(shell);
assertEquals(Font.class, value.getValueType());
}
+ @Test
public void testSetValueTooltipText() throws Exception {
ISWTObservableValue value = SWTObservables.observeTooltipText(shell);
String text = "text";
@@ -164,6 +190,7 @@
assertEquals(text, shell.getToolTipText());
}
+ @Test
public void testGetValueTooltipText() throws Exception {
ISWTObservableValue value = SWTObservables.observeTooltipText(shell);
String text = "text";
@@ -171,11 +198,13 @@
assertEquals(text, value.getValue());
}
+ @Test
public void testGetValueTypeTooltipText() throws Exception {
ISWTObservableValue value = SWTObservables.observeTooltipText(shell);
assertEquals(String.class, value.getValueType());
}
+ @Test
public void testObserveFocus() {
System.out.println("ControlObservableValueTest.testObserveFocus() start active shell: "
+ shell.getDisplay().getActiveShell());
@@ -209,7 +238,7 @@
System.out.println("active shell (5): " + shell.getDisplay().getActiveShell());
System.out.println("Value (should be true): " + value.getValue());
- Screenshots.takeScreenshot(getClass(), getName(), System.out);
+ Screenshots.takeScreenshot(getClass(), getClass().getSimpleName(), System.out);
assertEquals(Boolean.TRUE, value.getValue());
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/DateTimeCalendarObservableValueTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/DateTimeCalendarObservableValueTest.java
index 6b24e1b..2ecb634 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/DateTimeCalendarObservableValueTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/DateTimeCalendarObservableValueTest.java
@@ -15,6 +15,8 @@
package org.eclipse.jface.tests.internal.databinding.swt;
+import static org.junit.Assert.assertEquals;
+
import java.util.Calendar;
import java.util.Date;
@@ -23,6 +25,8 @@
import org.eclipse.jface.tests.databinding.AbstractSWTTestCase;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.DateTime;
+import org.junit.Before;
+import org.junit.Test;
/**
* @since 3.2
@@ -32,13 +36,14 @@
private DateTime dateTime;
private IObservableValue dateObservable;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
dateTime = new DateTime(getShell(), SWT.CALENDAR);
dateObservable = WidgetProperties.selection().observe(dateTime);
}
+ @Test
public void testGetValue_ExcludesTimeComponent() {
Calendar calendar = Calendar.getInstance();
calendar.clear();
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/DateTimeDateObservableValueTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/DateTimeDateObservableValueTest.java
index 638e4e4..65ec4f0 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/DateTimeDateObservableValueTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/DateTimeDateObservableValueTest.java
@@ -15,6 +15,8 @@
package org.eclipse.jface.tests.internal.databinding.swt;
+import static org.junit.Assert.assertEquals;
+
import java.util.Calendar;
import java.util.Date;
@@ -23,6 +25,8 @@
import org.eclipse.jface.tests.databinding.AbstractSWTTestCase;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.DateTime;
+import org.junit.Before;
+import org.junit.Test;
/**
* @since 3.2
@@ -32,13 +36,14 @@
private DateTime dateTime;
private IObservableValue dateObservable;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
dateTime = new DateTime(getShell(), SWT.DATE);
dateObservable = WidgetProperties.selection().observe(dateTime);
}
+ @Test
public void testGetValue_ExcludesTimeComponent() {
Calendar calendar = Calendar.getInstance();
calendar.clear();
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/DateTimeSelectionPropertyTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/DateTimeSelectionPropertyTest.java
index cefaecc..c651df8 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/DateTimeSelectionPropertyTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/DateTimeSelectionPropertyTest.java
@@ -12,10 +12,14 @@
package org.eclipse.jface.tests.internal.databinding.swt;
+import static org.junit.Assert.fail;
+
import org.eclipse.jface.internal.databinding.swt.DateTimeSelectionProperty;
import org.eclipse.jface.tests.databinding.AbstractSWTTestCase;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.DateTime;
+import org.junit.Before;
+import org.junit.Test;
/**
* @since 3.2
@@ -25,13 +29,14 @@
DateTime dateTime;
DateTimeSelectionProperty property;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
dateTime = new DateTime(getShell(), SWT.DATE);
property = new DateTimeSelectionProperty();
}
+ @Test
public void testSetValue_NullNotThrowingNullPointerException() {
try {
property.setValue(dateTime, null);
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/DateTimeTimeObservableValueTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/DateTimeTimeObservableValueTest.java
index a49e02d..c67494f 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/DateTimeTimeObservableValueTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/DateTimeTimeObservableValueTest.java
@@ -15,6 +15,8 @@
package org.eclipse.jface.tests.internal.databinding.swt;
+import static org.junit.Assert.assertEquals;
+
import java.util.Calendar;
import java.util.Date;
@@ -23,6 +25,8 @@
import org.eclipse.jface.tests.databinding.AbstractSWTTestCase;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.DateTime;
+import org.junit.Before;
+import org.junit.Test;
/**
* @since 3.2
@@ -32,13 +36,14 @@
private DateTime dateTime;
private IObservableValue dateObservable;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
dateTime = new DateTime(getShell(), SWT.TIME);
dateObservable = WidgetProperties.selection().observe(dateTime);
}
+ @Test
public void testGetValue_ExcludesDateComponent() {
Calendar calendar = Calendar.getInstance();
calendar.clear();
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/GroupObservableValueTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/GroupObservableValueTest.java
index f0c3767..5bbb71e 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/GroupObservableValueTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/GroupObservableValueTest.java
@@ -25,8 +25,9 @@
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Shell;
+import org.junit.Before;
+import org.junit.Test;
-import junit.framework.Test;
import junit.framework.TestSuite;
/**
@@ -45,7 +46,8 @@
}
@Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
delegate = (Delegate) getObservableContractDelegate();
@@ -59,6 +61,7 @@
DisplayRealm.getRealm(Display.getDefault()));
}
+ @Test
public void testSetValue() throws Exception {
// preconditions
assertEquals("", group.getText());
@@ -70,13 +73,8 @@
assertEquals("observable value", value, observable.getValue());
}
- public static Test suite() {
- TestSuite suite = new TestSuite(GroupObservableValueTest.class
- .toString());
- suite.addTestSuite(GroupObservableValueTest.class);
- suite.addTest(SWTMutableObservableValueContractTest
- .suite(new Delegate()));
- return suite;
+ public static void addConformanceTest(TestSuite suite) {
+ suite.addTest(SWTMutableObservableValueContractTest.suite(new Delegate()));
}
/* package */static class Delegate extends
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/LabelObservableValueTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/LabelObservableValueTest.java
index 77c7a6b..d4c436b 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/LabelObservableValueTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/LabelObservableValueTest.java
@@ -12,9 +12,6 @@
package org.eclipse.jface.tests.internal.databinding.swt;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.Realm;
import org.eclipse.core.databinding.observable.value.IObservableValue;
@@ -27,6 +24,10 @@
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
+import org.junit.Before;
+import org.junit.Test;
+
+import junit.framework.TestSuite;
/**
* @since 3.2
@@ -45,7 +46,8 @@
}
@Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
delegate = (Delegate) getObservableContractDelegate();
@@ -59,6 +61,7 @@
DisplayRealm.getRealm(Display.getDefault()));
}
+ @Test
public void testSetValue() throws Exception {
// preconditions
assertEquals("", label.getText());
@@ -70,13 +73,8 @@
assertEquals("observable value", value, observable.getValue());
}
- public static Test suite() {
- TestSuite suite = new TestSuite(LabelObservableValueTest.class
- .toString());
- suite.addTestSuite(LabelObservableValueTest.class);
- suite.addTest(SWTMutableObservableValueContractTest
- .suite(new Delegate()));
- return suite;
+ public static void addConformanceTest(TestSuite suite) {
+ suite.addTest(SWTMutableObservableValueContractTest.suite(new Delegate()));
}
/* package */static class Delegate extends
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/ListSingleSelectionObservableValueTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/ListSingleSelectionObservableValueTest.java
index 47f794b..2a2476d 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/ListSingleSelectionObservableValueTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/ListSingleSelectionObservableValueTest.java
@@ -12,17 +12,21 @@
package org.eclipse.jface.tests.internal.databinding.swt;
+import static org.junit.Assert.assertEquals;
+
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.jface.databinding.swt.SWTObservables;
import org.eclipse.jface.tests.databinding.AbstractSWTTestCase;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.List;
+import org.junit.Test;
/**
* @since 3.2
*
*/
public class ListSingleSelectionObservableValueTest extends AbstractSWTTestCase {
+ @Test
public void testSetValue() throws Exception {
List list = new List(getShell(), SWT.NONE);
IObservableValue observableValue = SWTObservables
@@ -39,6 +43,7 @@
assertEquals("observable value", value, observableValue.getValue());
}
+ @Test
public void testDispose() throws Exception {
List list = new List(getShell(), SWT.NONE);
IObservableValue observableValue = SWTObservables
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/SWTDelayedObservableValueDecoratorTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/SWTDelayedObservableValueDecoratorTest.java
index cbcdaf5..06cb825 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/SWTDelayedObservableValueDecoratorTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/SWTDelayedObservableValueDecoratorTest.java
@@ -12,8 +12,9 @@
package org.eclipse.jface.tests.internal.databinding.swt;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.Realm;
@@ -31,6 +32,11 @@
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Shell;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import junit.framework.TestSuite;
/**
* Tests for DelayedObservableValue
@@ -47,7 +53,8 @@
private ISWTObservableValue delayed;
@Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
display = Display.getCurrent();
shell = new Shell(display);
@@ -60,7 +67,8 @@
}
@Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
delayed.dispose();
target.dispose();
target = null;
@@ -70,6 +78,7 @@
super.tearDown();
}
+ @Test
public void testFocusOut_FiresPendingValueChange() {
assertFiresPendingValueChange(new Runnable() {
@Override
@@ -96,13 +105,8 @@
assertEquals(newValue, tracker.event.diff.getNewValue());
}
- public static Test suite() {
- TestSuite suite = new TestSuite(
- SWTDelayedObservableValueDecoratorTest.class.getName());
- suite.addTestSuite(SWTDelayedObservableValueDecoratorTest.class);
- suite.addTest(SWTMutableObservableValueContractTest
- .suite(new Delegate()));
- return suite;
+ public static void addConformanceTest(TestSuite suite) {
+ suite.addTest(SWTMutableObservableValueContractTest.suite(new Delegate()));
}
static class Delegate extends AbstractObservableValueContractDelegate {
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/ScaleObservableValueMaxTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/ScaleObservableValueMaxTest.java
index fc76f1a..2513779 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/ScaleObservableValueMaxTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/ScaleObservableValueMaxTest.java
@@ -12,9 +12,6 @@
package org.eclipse.jface.tests.internal.databinding.swt;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.Realm;
import org.eclipse.core.databinding.observable.value.IObservableValue;
@@ -27,6 +24,10 @@
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Scale;
import org.eclipse.swt.widgets.Shell;
+import org.junit.Before;
+import org.junit.Test;
+
+import junit.framework.TestSuite;
/**
* @since 3.2
@@ -47,7 +48,8 @@
}
@Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
delegate = (Delegate) getObservableContractDelegate();
@@ -61,25 +63,22 @@
DisplayRealm.getRealm(Display.getDefault()));
}
+ @Test
public void testGetValue() throws Exception {
int max = 100;
scale.setMaximum(max);
assertEquals(Integer.valueOf(max), observable.getValue());
}
+ @Test
public void testSetValue() throws Exception {
int max = 100;
observable.setValue(Integer.valueOf(max));
assertEquals(max, scale.getMaximum());
}
- public static Test suite() {
- TestSuite suite = new TestSuite(ScaleObservableValueMaxTest.class
- .toString());
- suite.addTestSuite(ScaleObservableValueMaxTest.class);
- suite.addTest(SWTMutableObservableValueContractTest
- .suite(new Delegate()));
- return suite;
+ public static void addConformanceTest(TestSuite suite) {
+ suite.addTest(SWTMutableObservableValueContractTest.suite(new Delegate()));
}
/* package */static class Delegate extends
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/ScaleObservableValueMinTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/ScaleObservableValueMinTest.java
index 84521f3..10b1b61 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/ScaleObservableValueMinTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/ScaleObservableValueMinTest.java
@@ -12,9 +12,6 @@
package org.eclipse.jface.tests.internal.databinding.swt;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.Realm;
import org.eclipse.core.databinding.observable.value.IObservableValue;
@@ -27,6 +24,10 @@
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Scale;
import org.eclipse.swt.widgets.Shell;
+import org.junit.Before;
+import org.junit.Test;
+
+import junit.framework.TestSuite;
/**
* @since 3.2
@@ -47,7 +48,8 @@
}
@Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
delegate = (Delegate) getObservableContractDelegate();
@@ -61,25 +63,22 @@
DisplayRealm.getRealm(Display.getDefault()));
}
+ @Test
public void testGetValue() throws Exception {
int min = 100;
scale.setMinimum(min);
assertEquals(Integer.valueOf(min), observable.getValue());
}
+ @Test
public void testSetValue() throws Exception {
int min = 100;
observable.setValue(Integer.valueOf(min));
assertEquals(min, scale.getMinimum());
}
- public static Test suite() {
- TestSuite suite = new TestSuite(ScaleObservableValueMinTest.class
- .toString());
- suite.addTestSuite(ScaleObservableValueMinTest.class);
- suite.addTest(SWTMutableObservableValueContractTest
- .suite(new Delegate()));
- return suite;
+ public static void addConformanceTest(TestSuite suite) {
+ suite.addTest(SWTMutableObservableValueContractTest.suite(new Delegate()));
}
/* package */static class Delegate extends
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/ScaleObservableValueSelectionTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/ScaleObservableValueSelectionTest.java
index df9bccd..6d20246 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/ScaleObservableValueSelectionTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/ScaleObservableValueSelectionTest.java
@@ -12,9 +12,6 @@
package org.eclipse.jface.tests.internal.databinding.swt;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.Realm;
import org.eclipse.core.databinding.observable.value.IObservableValue;
@@ -27,6 +24,10 @@
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Scale;
import org.eclipse.swt.widgets.Shell;
+import org.junit.Before;
+import org.junit.Test;
+
+import junit.framework.TestSuite;
/**
* @since 3.2
@@ -47,7 +48,8 @@
}
@Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
delegate = (Delegate) getObservableContractDelegate();
@@ -61,25 +63,22 @@
DisplayRealm.getRealm(Display.getDefault()));
}
+ @Test
public void testGetValue() throws Exception {
int value = 100;
scale.setSelection(value);
assertEquals(Integer.valueOf(value), observable.getValue());
}
+ @Test
public void testSetValue() throws Exception {
int value = 100;
observable.setValue(Integer.valueOf(value));
assertEquals(value, scale.getSelection());
}
- public static Test suite() {
- TestSuite suite = new TestSuite(ScaleObservableValueSelectionTest.class
- .toString());
- suite.addTestSuite(ScaleObservableValueSelectionTest.class);
- suite.addTest(SWTMutableObservableValueContractTest
- .suite(new Delegate()));
- return suite;
+ public static void addConformanceTest(TestSuite suite) {
+ suite.addTest(SWTMutableObservableValueContractTest.suite(new Delegate()));
}
/* package */static class Delegate extends
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/ShellObservableValueTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/ShellObservableValueTest.java
index bd0708a..fb49f36 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/ShellObservableValueTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/ShellObservableValueTest.java
@@ -12,8 +12,7 @@
package org.eclipse.jface.tests.internal.databinding.swt;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.Realm;
@@ -25,6 +24,11 @@
import org.eclipse.jface.databinding.swt.WidgetProperties;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
import org.eclipse.swt.widgets.Shell;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import junit.framework.TestSuite;
/**
* Tests for ShellObservableValue
@@ -39,7 +43,8 @@
ValueChangeEventTracker tracker;
@Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
shell = new Shell();
observable = SWTObservables.observeText(shell);
@@ -50,6 +55,7 @@
}
@Override
+ @After
public void tearDown() throws Exception {
observable.dispose();
observable = null;
@@ -58,10 +64,12 @@
super.tearDown();
}
+ @Test
public void testGetValueType() {
assertEquals(String.class, observable.getValueType());
}
+ @Test
public void testSetValue_FiresValueChangeEvent() {
observable.setValue(newValue);
@@ -70,6 +78,7 @@
assertEquals(newValue, tracker.event.diff.getNewValue());
}
+ @Test
public void testSetValue_NullConvertedToEmptyString() {
observable.setValue(null);
@@ -77,6 +86,7 @@
assertEquals("", shell.getText());
}
+ @Test
public void testShellSetText_GetValueReturnsSame() {
assertEquals(oldValue, observable.getValue());
@@ -85,18 +95,14 @@
assertEquals(newValue, observable.getValue());
}
+ @Test
public void testShellSetText_NoValueChangeEvent() {
shell.setText(newValue);
assertEquals(0, tracker.count);
}
- public static Test suite() {
- TestSuite suite = new TestSuite(ShellObservableValueTest.class
- .toString());
- suite.addTestSuite(ShellObservableValueTest.class);
- suite.addTest(SWTMutableObservableValueContractTest
- .suite(new Delegate()));
- return suite;
+ public static void addConformanceTest(TestSuite suite) {
+ suite.addTest(SWTMutableObservableValueContractTest.suite(new Delegate()));
}
static class Delegate extends AbstractObservableValueContractDelegate {
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/SpinnerObservableValueMaxTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/SpinnerObservableValueMaxTest.java
index 2bb6de6..d0e5422 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/SpinnerObservableValueMaxTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/SpinnerObservableValueMaxTest.java
@@ -12,9 +12,6 @@
package org.eclipse.jface.tests.internal.databinding.swt;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.Realm;
import org.eclipse.core.databinding.observable.value.IObservableValue;
@@ -27,6 +24,10 @@
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Spinner;
+import org.junit.Before;
+import org.junit.Test;
+
+import junit.framework.TestSuite;
/**
* @since 3.2
@@ -47,7 +48,8 @@
}
@Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
delegate = (Delegate) getObservableContractDelegate();
@@ -61,25 +63,22 @@
DisplayRealm.getRealm(Display.getDefault()));
}
+ @Test
public void testGetValue() throws Exception {
int max = 100;
spinner.setMaximum(max);
assertEquals(Integer.valueOf(max), observable.getValue());
}
+ @Test
public void testSetValue() throws Exception {
int max = 100;
observable.setValue(Integer.valueOf(max));
assertEquals(max, spinner.getMaximum());
}
- public static Test suite() {
- TestSuite suite = new TestSuite(SpinnerObservableValueMaxTest.class
- .toString());
- suite.addTestSuite(SpinnerObservableValueMaxTest.class);
- suite.addTest(SWTMutableObservableValueContractTest
- .suite(new Delegate()));
- return suite;
+ public static void addConformanceTest(TestSuite suite) {
+ suite.addTest(SWTMutableObservableValueContractTest.suite(new Delegate()));
}
/* package */static class Delegate extends
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/SpinnerObservableValueMinTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/SpinnerObservableValueMinTest.java
index 99a5098..4ff3c7c 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/SpinnerObservableValueMinTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/SpinnerObservableValueMinTest.java
@@ -12,9 +12,6 @@
package org.eclipse.jface.tests.internal.databinding.swt;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.Realm;
import org.eclipse.core.databinding.observable.value.IObservableValue;
@@ -27,6 +24,10 @@
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Spinner;
+import org.junit.Before;
+import org.junit.Test;
+
+import junit.framework.TestSuite;
/**
* @since 3.2
@@ -47,7 +48,8 @@
}
@Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
delegate = (Delegate) getObservableContractDelegate();
@@ -61,25 +63,22 @@
DisplayRealm.getRealm(Display.getDefault()));
}
+ @Test
public void testGetValue() throws Exception {
int min = 100;
spinner.setMinimum(min);
assertEquals(Integer.valueOf(min), observable.getValue());
}
+ @Test
public void testSetValue() throws Exception {
int min = 100;
observable.setValue(Integer.valueOf(min));
assertEquals(min, spinner.getMinimum());
}
- public static Test suite() {
- TestSuite suite = new TestSuite(SpinnerObservableValueMinTest.class
- .toString());
- suite.addTestSuite(SpinnerObservableValueMinTest.class);
- suite.addTest(SWTMutableObservableValueContractTest
- .suite(new Delegate()));
- return suite;
+ public static void addConformanceTest(TestSuite suite) {
+ suite.addTest(SWTMutableObservableValueContractTest.suite(new Delegate()));
}
/* package */static class Delegate extends
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/SpinnerObservableValueSelectionTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/SpinnerObservableValueSelectionTest.java
index 12ff31e..f02e033 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/SpinnerObservableValueSelectionTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/SpinnerObservableValueSelectionTest.java
@@ -12,9 +12,6 @@
package org.eclipse.jface.tests.internal.databinding.swt;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.Realm;
import org.eclipse.core.databinding.observable.value.IObservableValue;
@@ -27,6 +24,10 @@
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Spinner;
+import org.junit.Before;
+import org.junit.Test;
+
+import junit.framework.TestSuite;
/**
* @since 3.2
@@ -47,7 +48,8 @@
}
@Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
delegate = (Delegate) getObservableContractDelegate();
@@ -61,25 +63,22 @@
DisplayRealm.getRealm(Display.getDefault()));
}
+ @Test
public void testGetValue() throws Exception {
int value = 100;
spinner.setSelection(value);
assertEquals(Integer.valueOf(value), observable.getValue());
}
+ @Test
public void testSetValue() throws Exception {
int value = 100;
observable.setValue(Integer.valueOf(value));
assertEquals(value, spinner.getSelection());
}
- public static Test suite() {
- TestSuite suite = new TestSuite(
- SpinnerObservableValueSelectionTest.class.toString());
- suite.addTestSuite(SpinnerObservableValueSelectionTest.class);
- suite.addTest(SWTMutableObservableValueContractTest
- .suite(new Delegate()));
- return suite;
+ public static void addConformanceTest(TestSuite suite) {
+ suite.addTest(SWTMutableObservableValueContractTest.suite(new Delegate()));
}
/* package */static class Delegate extends
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/SpinnerObservableValueTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/SpinnerObservableValueTest.java
index 6fd8df1..5059341 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/SpinnerObservableValueTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/SpinnerObservableValueTest.java
@@ -13,18 +13,22 @@
package org.eclipse.jface.tests.internal.databinding.swt;
+import static org.junit.Assert.assertEquals;
+
import org.eclipse.jface.databinding.conformance.util.ValueChangeEventTracker;
import org.eclipse.jface.databinding.swt.ISWTObservableValue;
import org.eclipse.jface.databinding.swt.SWTObservables;
import org.eclipse.jface.tests.databinding.AbstractSWTTestCase;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Spinner;
+import org.junit.Test;
/**
* @since 3.2
*
*/
public class SpinnerObservableValueTest extends AbstractSWTTestCase {
+ @Test
public void testDispose() throws Exception {
Spinner spinner = new Spinner(getShell(), SWT.NONE);
ISWTObservableValue observableValue = SWTObservables.observeSelection(spinner);
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/StyledTextObservableValueDefaultSelectionTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/StyledTextObservableValueDefaultSelectionTest.java
index 7b5498f..26b0720 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/StyledTextObservableValueDefaultSelectionTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/StyledTextObservableValueDefaultSelectionTest.java
@@ -15,10 +15,6 @@
package org.eclipse.jface.tests.internal.databinding.swt;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.Realm;
import org.eclipse.core.databinding.observable.value.IObservableValue;
@@ -29,16 +25,14 @@
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.widgets.Shell;
+import junit.framework.TestSuite;
+
/**
* Tests for the DefaultSelection version of StyledTextObservableValue.
*/
-public class StyledTextObservableValueDefaultSelectionTest extends TestCase {
- public static Test suite() {
- TestSuite suite = new TestSuite(
- StyledTextObservableValueDefaultSelectionTest.class.toString());
- suite.addTest(SWTMutableObservableValueContractTest
- .suite(new Delegate()));
- return suite;
+public class StyledTextObservableValueDefaultSelectionTest {
+ public static void addConformanceTest(TestSuite suite) {
+ suite.addTest(SWTMutableObservableValueContractTest.suite(new Delegate()));
}
/* package */static class Delegate extends
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/StyledTextObservableValueFocusOutTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/StyledTextObservableValueFocusOutTest.java
index 455e331..3636a00 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/StyledTextObservableValueFocusOutTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/StyledTextObservableValueFocusOutTest.java
@@ -13,8 +13,9 @@
package org.eclipse.jface.tests.internal.databinding.swt;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.Realm;
@@ -28,20 +29,19 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.widgets.Shell;
+import org.junit.Test;
+
+import junit.framework.TestSuite;
/**
* Tests for the FocusOut version of StyledTextObservableValue.
*/
public class StyledTextObservableValueFocusOutTest extends AbstractSWTTestCase {
- public static Test suite() {
- TestSuite suite = new TestSuite(
- StyledTextObservableValueFocusOutTest.class.toString());
- suite.addTestSuite(StyledTextObservableValueFocusOutTest.class);
- suite.addTest(SWTMutableObservableValueContractTest
- .suite(new Delegate()));
- return suite;
+ public static void addConformanceTest(TestSuite suite) {
+ suite.addTest(SWTMutableObservableValueContractTest.suite(new Delegate()));
}
+ @Test
public void testIsStale_AfterModifyBeforeFocusOut() {
StyledText text = new StyledText(getShell(), SWT.NONE);
text.setText("0");
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/StyledTextObservableValueModifyTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/StyledTextObservableValueModifyTest.java
index 016ff49..c96b709 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/StyledTextObservableValueModifyTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/StyledTextObservableValueModifyTest.java
@@ -13,10 +13,6 @@
package org.eclipse.jface.tests.internal.databinding.swt;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.Realm;
import org.eclipse.core.databinding.observable.value.IObservableValue;
@@ -27,16 +23,14 @@
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.widgets.Shell;
+import junit.framework.TestSuite;
+
/**
* Tests for the Modify version of StyledTextObservableValue.
*/
-public class StyledTextObservableValueModifyTest extends TestCase {
- public static Test suite() {
- TestSuite suite = new TestSuite(
- StyledTextObservableValueModifyTest.class.toString());
- suite.addTest(SWTMutableObservableValueContractTest
- .suite(new Delegate()));
- return suite;
+public class StyledTextObservableValueModifyTest {
+ public static void addConformanceTest(TestSuite suite) {
+ suite.addTest(SWTMutableObservableValueContractTest.suite(new Delegate()));
}
/* package */static class Delegate extends
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/StyledTextObservableValueTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/StyledTextObservableValueTest.java
index 2b22a13..2574fd2 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/StyledTextObservableValueTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/StyledTextObservableValueTest.java
@@ -13,6 +13,10 @@
package org.eclipse.jface.tests.internal.databinding.swt;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.jface.databinding.conformance.util.ValueChangeEventTracker;
import org.eclipse.jface.databinding.swt.SWTObservables;
@@ -21,6 +25,8 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.widgets.Shell;
+import org.junit.Before;
+import org.junit.Test;
/**
* Tests to assert the inputs of the StyledTextObservableValue constructor.
@@ -29,8 +35,8 @@
private StyledText text;
private ValueChangeEventTracker listener;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
Shell shell = new Shell();
@@ -43,6 +49,7 @@
* Asserts that only valid SWT event types are accepted on construction of
* StyledTextObservableValue.
*/
+ @Test
public void testConstructorUpdateEventTypes() {
try {
new StyledTextTextProperty(new int[] { SWT.None });
@@ -67,6 +74,7 @@
*
* @throws Exception
*/
+ @Test
public void testGetValueBeforeFocusOutChangeEventsFire() throws Exception {
IObservableValue observableValue = SWTObservables.observeText(text,
SWT.FocusOut);
@@ -90,6 +98,7 @@
assertEquals(b, listener.event.diff.getNewValue());
}
+ @Test
public void testDispose() throws Exception {
IObservableValue observableValue = SWTObservables.observeText(text,
SWT.Modify);
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/TableObservableValueTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/TableObservableValueTest.java
index a86e63c..4eb7293 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/TableObservableValueTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/TableObservableValueTest.java
@@ -13,17 +13,21 @@
package org.eclipse.jface.tests.internal.databinding.swt;
+import static org.junit.Assert.assertEquals;
+
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.jface.databinding.swt.SWTObservables;
import org.eclipse.jface.tests.databinding.AbstractSWTTestCase;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableItem;
+import org.junit.Test;
/**
* @since 3.2
*/
public class TableObservableValueTest extends AbstractSWTTestCase {
+ @Test
public void testDispose() throws Exception {
Table table = new Table(getShell(), SWT.NONE);
IObservableValue observableValue = SWTObservables
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/TableSingleSelectionObservableValueTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/TableSingleSelectionObservableValueTest.java
index 2ca2601..b1c6e17 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/TableSingleSelectionObservableValueTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/TableSingleSelectionObservableValueTest.java
@@ -12,9 +12,6 @@
package org.eclipse.jface.tests.internal.databinding.swt;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.Realm;
import org.eclipse.core.databinding.observable.value.IObservableValue;
@@ -29,6 +26,10 @@
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableItem;
+import org.junit.Before;
+import org.junit.Test;
+
+import junit.framework.TestSuite;
/**
* @since 3.2
@@ -48,7 +49,8 @@
}
@Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
observable = (IObservableValue) getObservable();
@@ -63,6 +65,7 @@
.getDefault()));
}
+ @Test
public void testSetValue() throws Exception {
// preconditions
assertEquals(-1, table.getSelectionIndex());
@@ -75,6 +78,7 @@
assertEquals("observable value", value, observable.getValue());
}
+ @Test
public void testGetValue() throws Exception {
int value = 1;
table.setSelection(value);
@@ -84,13 +88,8 @@
.getValue());
}
- public static Test suite() {
- TestSuite suite = new TestSuite(
- TableSingleSelectionObservableValueTest.class.toString());
- suite.addTestSuite(TableSingleSelectionObservableValueTest.class);
- suite.addTest(SWTMutableObservableValueContractTest
- .suite(new Delegate()));
- return suite;
+ public static void addConformanceTest(TestSuite suite) {
+ suite.addTest(SWTMutableObservableValueContractTest.suite(new Delegate()));
}
/* package */static class Delegate extends
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/TextEditableObservableValueTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/TextEditableObservableValueTest.java
index ffa23d5..4fd73ad 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/TextEditableObservableValueTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/TextEditableObservableValueTest.java
@@ -12,9 +12,6 @@
package org.eclipse.jface.tests.internal.databinding.swt;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.Realm;
import org.eclipse.core.databinding.observable.value.IObservableValue;
@@ -25,6 +22,10 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
+import org.junit.Before;
+import org.junit.Test;
+
+import junit.framework.TestSuite;
/**
* @since 1.1
@@ -44,7 +45,8 @@
}
@Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
delegate = (Delegate) getObservableContractDelegate();
@@ -57,6 +59,7 @@
return super.doCreateObservable();
}
+ @Test
public void testGetValue() throws Exception {
text.setEditable(false);
assertEquals(Boolean.valueOf(text.getEditable()), observable.getValue());
@@ -65,6 +68,7 @@
assertEquals(Boolean.valueOf(text.getEditable()), observable.getValue());
}
+ @Test
public void testSetValue() throws Exception {
text.setEditable(false);
observable.setValue(Boolean.TRUE);
@@ -74,13 +78,8 @@
assertEquals(Boolean.FALSE, Boolean.valueOf(text.getEditable()));
}
- public static Test suite() {
- TestSuite suite = new TestSuite(TextEditableObservableValueTest.class
- .toString());
- suite.addTestSuite(TextEditableObservableValueTest.class);
- suite.addTest(SWTMutableObservableValueContractTest
- .suite(new Delegate()));
- return suite;
+ public static void addConformanceTest(TestSuite suite) {
+ suite.addTest(SWTMutableObservableValueContractTest.suite(new Delegate()));
}
/* package */static class Delegate extends
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/TextObservableValueDefaultSelectionTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/TextObservableValueDefaultSelectionTest.java
index 9510970..cc5f264 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/TextObservableValueDefaultSelectionTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/TextObservableValueDefaultSelectionTest.java
@@ -14,10 +14,6 @@
package org.eclipse.jface.tests.internal.databinding.swt;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.Realm;
import org.eclipse.core.databinding.observable.value.IObservableValue;
@@ -28,16 +24,14 @@
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
+import junit.framework.TestSuite;
+
/**
* Tests for the DefaultSelection version of TextObservableValue.
*/
-public class TextObservableValueDefaultSelectionTest extends TestCase {
- public static Test suite() {
- TestSuite suite = new TestSuite(TextObservableValueDefaultSelectionTest.class
- .toString());
- suite.addTest(SWTMutableObservableValueContractTest
- .suite(new Delegate()));
- return suite;
+public class TextObservableValueDefaultSelectionTest {
+ public static void addConformanceTest(TestSuite suite) {
+ suite.addTest(SWTMutableObservableValueContractTest.suite(new Delegate()));
}
/* package */static class Delegate extends
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/TextObservableValueFocusOutTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/TextObservableValueFocusOutTest.java
index 558667b..e4348dd 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/TextObservableValueFocusOutTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/TextObservableValueFocusOutTest.java
@@ -12,8 +12,9 @@
package org.eclipse.jface.tests.internal.databinding.swt;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.Realm;
@@ -27,20 +28,19 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
+import org.junit.Test;
+
+import junit.framework.TestSuite;
/**
* Tests for the FocusOut version of TextObservableValue.
*/
public class TextObservableValueFocusOutTest extends AbstractSWTTestCase {
- public static Test suite() {
- TestSuite suite = new TestSuite(TextObservableValueFocusOutTest.class
- .toString());
- suite.addTestSuite(TextObservableValueFocusOutTest.class);
- suite.addTest(SWTMutableObservableValueContractTest
- .suite(new Delegate()));
- return suite;
+ public static void addConformanceTest(TestSuite suite) {
+ suite.addTest(SWTMutableObservableValueContractTest.suite(new Delegate()));
}
+ @Test
public void testIsStale_AfterModifyBeforeFocusOut() {
Text text = new Text(getShell(), SWT.NONE);
text.setText("0");
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/TextObservableValueModifyTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/TextObservableValueModifyTest.java
index 5e35c34..27f8f0c 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/TextObservableValueModifyTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/TextObservableValueModifyTest.java
@@ -12,10 +12,6 @@
package org.eclipse.jface.tests.internal.databinding.swt;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.Realm;
import org.eclipse.core.databinding.observable.value.IObservableValue;
@@ -26,16 +22,14 @@
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
+import junit.framework.TestSuite;
+
/**
* @since 3.2
*/
-public class TextObservableValueModifyTest extends TestCase {
- public static Test suite() {
- TestSuite suite = new TestSuite(TextObservableValueModifyTest.class
- .toString());
- suite.addTest(SWTMutableObservableValueContractTest
- .suite(new Delegate()));
- return suite;
+public class TextObservableValueModifyTest {
+ public static void addConformanceTest(TestSuite suite) {
+ suite.addTest(SWTMutableObservableValueContractTest.suite(new Delegate()));
}
/* package */static class Delegate extends
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/TextObservableValueTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/TextObservableValueTest.java
index ebd0bc4..4b9990a 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/TextObservableValueTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/TextObservableValueTest.java
@@ -14,6 +14,10 @@
package org.eclipse.jface.tests.internal.databinding.swt;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import org.eclipse.core.databinding.observable.Realm;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.jface.databinding.conformance.util.ValueChangeEventTracker;
@@ -22,6 +26,8 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
+import org.junit.Before;
+import org.junit.Test;
/**
* Tests to assert the inputs of the TextObservableValue constructor.
@@ -32,8 +38,8 @@
private Text text;
private ValueChangeEventTracker listener;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
Shell shell = new Shell();
@@ -46,6 +52,7 @@
* Asserts that only valid SWT event types are accepted on construction of
* TextObservableValue.
*/
+ @Test
public void testConstructorUpdateEventTypes() {
try {
WidgetProperties.text(SWT.None);
@@ -70,6 +77,7 @@
*
* @throws Exception
*/
+ @Test
public void testGetValueBeforeFocusOutChangeEventsFire() throws Exception {
IObservableValue observableValue = WidgetProperties.text(SWT.FocusOut)
.observe(Realm.getDefault(), text);
@@ -97,6 +105,7 @@
assertEquals(b, listener.event.diff.getNewValue());
}
+ @Test
public void testDispose() throws Exception {
IObservableValue observableValue = WidgetProperties.text(SWT.Modify)
.observe(Realm.getDefault(), text);
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/viewers/CheckableCheckedElementsObservableSetTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/viewers/CheckableCheckedElementsObservableSetTest.java
index 813247b..d6614bf 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/viewers/CheckableCheckedElementsObservableSetTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/viewers/CheckableCheckedElementsObservableSetTest.java
@@ -11,14 +11,18 @@
package org.eclipse.jface.tests.internal.databinding.viewers;
+import static org.junit.Assert.assertEquals;
+
import org.eclipse.core.databinding.observable.set.IObservableSet;
import org.eclipse.jface.databinding.viewers.ViewersObservables;
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
import org.eclipse.jface.viewers.ICheckStateListener;
import org.eclipse.jface.viewers.ICheckable;
+import org.junit.Test;
public class CheckableCheckedElementsObservableSetTest extends
AbstractDefaultRealmTestCase {
+ @Test
public void testClear() {
// init
ICheckable checkable = new ICheckable() {
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/viewers/ObservableCollectionContentProviderTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/viewers/ObservableCollectionContentProviderTest.java
index 5d0b79c..fb81ecb 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/viewers/ObservableCollectionContentProviderTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/viewers/ObservableCollectionContentProviderTest.java
@@ -11,6 +11,9 @@
package org.eclipse.jface.tests.internal.databinding.viewers;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import java.util.Collections;
import org.eclipse.core.databinding.observable.list.IObservableList;
@@ -22,6 +25,9 @@
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.swt.widgets.Shell;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
/**
* @since 3.2
@@ -33,21 +39,22 @@
private TableViewer viewer;
ObservableListContentProvider contentProvider;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
shell = new Shell();
viewer = new TableViewer(shell);
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
shell.dispose();
shell = null;
viewer = null;
super.tearDown();
}
+ @Test
public void testGetKnownElements_DisposedWithoutModificationOnContentProviderDispose() {
final IObservableList input = new WritableList(Collections
.singletonList("element"), null);
@@ -73,6 +80,7 @@
assertTrue(knownElements.isDisposed());
}
+ @Test
public void testKnownElementsAreFilledOnSettingAFilledCollectionAsInput() {
final IObservableList input = new WritableList(Collections.singletonList("element"), null);
contentProvider = new ObservableListContentProvider();
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/viewers/ObservableCollectionTreeContentProviderTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/viewers/ObservableCollectionTreeContentProviderTest.java
index ed713ba..ae62314 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/viewers/ObservableCollectionTreeContentProviderTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/viewers/ObservableCollectionTreeContentProviderTest.java
@@ -12,6 +12,10 @@
package org.eclipse.jface.tests.internal.databinding.viewers;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
@@ -27,6 +31,9 @@
import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.widgets.Shell;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
/**
* @since 3.2
@@ -37,21 +44,22 @@
private TreeViewer viewer;
ObservableListTreeContentProvider contentProvider;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
shell = new Shell();
viewer = new TreeViewer(shell);
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
shell.dispose();
shell = null;
viewer = null;
super.tearDown();
}
+ @Test
public void testGetKnownElements_ExcludesInput() {
final Object input = new Object();
Object[] rootElements = new Object[] { "one", "two", "three" };
@@ -72,6 +80,7 @@
assertEquals(new HashSet<Object>(Arrays.asList(rootElements)), knownElements);
}
+ @Test
public void testGetKnownElements_DisposedWithoutModificationOnContentProviderDispose() {
final Object input = new Object();
final IObservableList rootElementList = new WritableList(Collections.singletonList("element"), null);
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/viewers/ObservableViewerElementSetTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/viewers/ObservableViewerElementSetTest.java
index 4822c64..84e1f17 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/viewers/ObservableViewerElementSetTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/viewers/ObservableViewerElementSetTest.java
@@ -21,15 +21,11 @@
import org.eclipse.jface.internal.databinding.viewers.ObservableViewerElementSet;
import org.eclipse.jface.viewers.IElementComparer;
-import junit.framework.Test;
-import junit.framework.TestCase;
import junit.framework.TestSuite;
-public class ObservableViewerElementSetTest extends TestCase {
- public static Test suite() {
- TestSuite suite = new TestSuite(ObservableViewerElementSetTest.class.getName());
+public class ObservableViewerElementSetTest {
+ public static void addConformanceTest(TestSuite suite) {
suite.addTest(MutableObservableSetContractTest.suite(new Delegate()));
- return suite;
}
private static class Delegate extends
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/viewers/SelectionProviderMultiSelectionObservableListTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/viewers/SelectionProviderMultiSelectionObservableListTest.java
index 117d395..0ff2e35 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/viewers/SelectionProviderMultiSelectionObservableListTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/viewers/SelectionProviderMultiSelectionObservableListTest.java
@@ -13,6 +13,9 @@
*******************************************************************************/
package org.eclipse.jface.tests.internal.databinding.viewers;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -28,15 +31,16 @@
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Shell;
-
-import junit.framework.TestCase;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
/**
* Tests for SelectionProviderMultiSelectionObservableList.
*
* @since 1.2
*/
-public class SelectionProviderMultiSelectionObservableListTest extends TestCase {
+public class SelectionProviderMultiSelectionObservableListTest {
private IPostSelectionProvider selectionProvider;
private TableViewer viewer;
@@ -44,8 +48,8 @@
private static String[] model = new String[] { "element0", "element1",
"element2", "element3" };
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
Shell shell = new Shell();
viewer = new TableViewer(shell, SWT.MULTI);
viewer.setContentProvider(new ArrayContentProvider());
@@ -53,13 +57,14 @@
selectionProvider = viewer;
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
Shell shell = viewer.getTable().getShell();
if (!shell.isDisposed())
shell.dispose();
}
+ @Test
public void testConstructorIllegalArgumentException() {
try {
ViewersObservables.observeMultiSelection(null);
@@ -68,10 +73,12 @@
}
}
+ @Test
public void testAddRemove_NormalSelection() {
doTestAddRemove(false);
}
+ @Test
public void testAddRemove_PostSelection() {
doTestAddRemove(true);
}
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/viewers/SelectionProviderSingleSelectionObservableValueTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/viewers/SelectionProviderSingleSelectionObservableValueTest.java
index ec6f6c9..9b69afc 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/viewers/SelectionProviderSingleSelectionObservableValueTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/viewers/SelectionProviderSingleSelectionObservableValueTest.java
@@ -14,8 +14,6 @@
*******************************************************************************/
package org.eclipse.jface.tests.internal.databinding.viewers;
-import junit.framework.TestCase;
-
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.jface.databinding.conformance.util.ValueChangeEventTracker;
import org.eclipse.jface.databinding.viewers.ViewersObservables;
@@ -27,6 +25,11 @@
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Shell;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import junit.framework.TestCase;
/**
* Tests for SelectionProviderSingleSelectionObservableValue.
@@ -41,8 +44,8 @@
private static String[] model = new String[] { "0", "1" };
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
Shell shell = new Shell();
viewer = new TableViewer(shell, SWT.NONE);
viewer.setContentProvider(new ArrayContentProvider());
@@ -50,13 +53,14 @@
selectionProvider = viewer;
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
Shell shell = viewer.getTable().getShell();
if (!shell.isDisposed())
shell.dispose();
}
+ @Test
public void testConstructorIllegalArgumentException() {
try {
ViewersObservables.observeSingleSelection(null);
@@ -65,6 +69,7 @@
}
}
+ @Test
public void testSetValue() {
IObservableValue observable = ViewersObservables
.observeSingleSelection(selectionProvider);
@@ -89,10 +94,12 @@
assertEquals(3, listener.count);
}
+ @Test
public void testSelectionChangesTracked() {
doTestSelectionChangesTracked(false);
}
+ @Test
public void testPostSelectionChangesTracked() {
doTestSelectionChangesTracked(true);
}
@@ -144,6 +151,7 @@
assertEquals(null, observable.getValue());
}
+ @Test
public void testDispose() throws Exception {
IObservableValue observable = ViewersObservables
.observeSingleSelection(selectionProvider);
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/viewers/ViewerElementMapTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/viewers/ViewerElementMapTest.java
index 3dfaa7c..549c011a 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/viewers/ViewerElementMapTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/viewers/ViewerElementMapTest.java
@@ -12,6 +12,13 @@
package org.eclipse.jface.tests.internal.databinding.viewers;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
@@ -19,30 +26,30 @@
import java.util.Map;
import java.util.Set;
-import junit.framework.TestCase;
-
import org.eclipse.jface.internal.databinding.viewers.ViewerElementMap;
import org.eclipse.jface.viewers.IElementComparer;
+import org.junit.Before;
+import org.junit.Test;
/**
* @since 1.2
*/
-public class ViewerElementMapTest extends TestCase {
+public class ViewerElementMapTest {
IdentityElementComparer comparer;
ViewerElementMap map;
Object key;
Object value;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
comparer = new IdentityElementComparer();
map = new ViewerElementMap(comparer);
key = new Object();
value = new Object();
}
+ @Test
public void testConstructor_NullComparer() {
try {
new ViewerElementMap(null);
@@ -51,6 +58,7 @@
}
}
+ @Test
public void testConstructorWithCollection_NullCollection() {
try {
new ViewerElementMap(null, new IdentityElementComparer());
@@ -59,6 +67,7 @@
}
}
+ @Test
public void testConstructorWithCollection_ContainsAllEntries() {
Map<Object, Object> toCopy = new HashMap<Object, Object>();
toCopy.put(new Object(), new Object());
@@ -66,18 +75,21 @@
assertEquals(toCopy, map);
}
+ @Test
public void testIsEmpty() {
assertTrue(map.isEmpty());
map.put(key, value);
assertFalse(map.isEmpty());
}
+ @Test
public void testSize() {
assertEquals(0, map.size());
map.put(key, value);
assertEquals(1, map.size());
}
+ @Test
public void testClear() {
map.put(key, value);
assertFalse(map.isEmpty());
@@ -85,12 +97,14 @@
assertTrue(map.isEmpty());
}
+ @Test
public void testGet() {
assertNull(map.get(key));
map.put(key, value);
assertEquals(value, map.get(key));
}
+ @Test
public void testContainsKey() {
String key1 = new String("key");
String key2 = new String("key"); // equal but distinct instances
@@ -100,12 +114,14 @@
assertFalse(map.containsKey(key2));
}
+ @Test
public void testContainsValue() {
assertFalse(map.containsValue(value));
map.put(key, value);
assertTrue(map.containsValue(value));
}
+ @Test
public void testPutAll() {
Map<Object, Object> other = new HashMap<Object, Object>();
other.put(key, value);
@@ -117,6 +133,7 @@
assertEquals(value, map.get(key));
}
+ @Test
public void testRemove() {
map.put(key, value);
assertTrue(map.containsKey(key));
@@ -124,6 +141,7 @@
assertFalse(map.containsKey(key));
}
+ @Test
public void testValues() {
Collection values = map.values();
assertTrue(values.isEmpty());
@@ -137,6 +155,7 @@
assertTrue(map.values().isEmpty());
}
+ @Test
public void testKeySet() {
Set keySet = map.keySet();
assertTrue(keySet.isEmpty());
@@ -149,6 +168,7 @@
assertTrue(keySet.isEmpty());
}
+ @Test
public void testKeySet_Add() {
try {
map.keySet().add(key);
@@ -157,6 +177,7 @@
}
}
+ @Test
public void testKeySet_AddAll() {
try {
map.keySet().addAll(Collections.singleton(key));
@@ -165,6 +186,7 @@
}
}
+ @Test
public void testKeySet_Clear() {
map.put(key, value);
Set keySet = map.keySet();
@@ -174,6 +196,7 @@
assertTrue(map.isEmpty());
}
+ @Test
public void testKeySet_Contains() {
Set keySet = map.keySet();
assertFalse(keySet.contains(key));
@@ -181,6 +204,7 @@
assertTrue(keySet.contains(key));
}
+ @Test
public void testKeySet_ContainsAll() {
Set keySet = map.keySet();
assertFalse(keySet.containsAll(Collections.singleton(key)));
@@ -188,6 +212,7 @@
assertTrue(keySet.containsAll(Collections.singleton(key)));
}
+ @Test
public void testKeySet_IsEmpty() {
Set keySet = map.keySet();
assertTrue(keySet.isEmpty());
@@ -195,6 +220,7 @@
assertFalse(keySet.isEmpty());
}
+ @Test
public void testKeySet_Iterator() {
map.put(key, value);
Iterator iterator = map.keySet().iterator();
@@ -208,6 +234,7 @@
assertFalse(iterator.hasNext());
}
+ @Test
public void testKeySet_Remove() {
map.put(key, value);
assertEquals(1, map.size());
@@ -215,6 +242,7 @@
assertTrue(map.isEmpty());
}
+ @Test
public void testKeySet_RemoveAll() {
map.put(key, value);
Set keySet = map.keySet();
@@ -224,6 +252,7 @@
assertTrue(map.isEmpty());
}
+ @Test
public void testKeySet_RetainAll() {
map.put(key, value);
Set keySet = map.keySet();
@@ -233,6 +262,7 @@
assertTrue(map.isEmpty());
}
+ @Test
public void testKeySet_Size() {
Set keySet = map.keySet();
assertEquals(0, keySet.size());
@@ -242,6 +272,7 @@
assertEquals(0, keySet.size());
}
+ @Test
public void testKeySet_ToArray() {
Set keySet = map.keySet();
map.put(key, value);
@@ -250,6 +281,7 @@
assertSame(key, array[0]);
}
+ @Test
public void testKeySet_ToArrayWithObjectArray() {
key = new String("key");
map.put(key, value);
@@ -258,6 +290,7 @@
assertSame(key, array[0]);
}
+ @Test
public void testKeySet_Equals() {
Set keySet = map.keySet();
assertFalse(keySet.equals(null));
@@ -268,6 +301,7 @@
assertTrue(keySet.equals(Collections.singleton(key)));
}
+ @Test
public void testKeySet_HashCode() {
Set keySet = map.keySet();
assertEquals(0, keySet.hashCode());
@@ -276,6 +310,7 @@
assertEquals(hash, keySet.hashCode());
}
+ @Test
public void testEntrySet() {
Set entrySet = map.entrySet();
assertTrue(entrySet.isEmpty());
@@ -290,6 +325,7 @@
assertTrue(entrySet.isEmpty());
}
+ @Test
public void testEntrySet_Add() {
try {
map.entrySet().add(key);
@@ -298,6 +334,7 @@
}
}
+ @Test
public void testEntrySet_AddAll() {
try {
map.entrySet().addAll(Collections.EMPTY_SET);
@@ -306,6 +343,7 @@
}
}
+ @Test
public void testEntrySet_Clear() {
map.put(key, value);
assertEquals(1, map.size());
@@ -313,6 +351,7 @@
assertTrue(map.isEmpty());
}
+ @Test
public void testEntrySet_Contains() {
map.put(key, value);
Set entrySet = map.entrySet();
@@ -321,6 +360,7 @@
assertFalse(entrySet.contains(new MapEntryStub(key, value)));
}
+ @Test
public void testEntrySet_ContainsAll() {
Set entrySet = map.entrySet();
assertFalse(entrySet.containsAll(Collections.singleton(new MapEntryStub(key, value))));
@@ -330,6 +370,7 @@
assertTrue(entrySet.containsAll(Collections.singleton(new MapEntryStub(key, value))));
}
+ @Test
public void testEntrySet_IsEmpty() {
Set entrySet = map.entrySet();
assertTrue(entrySet.isEmpty());
@@ -337,6 +378,7 @@
assertFalse(entrySet.isEmpty());
}
+ @Test
public void testEntrySet_Iterator() {
map.put(key, value);
Iterator iterator = map.entrySet().iterator();
@@ -350,6 +392,7 @@
assertFalse(iterator.hasNext());
}
+ @Test
public void testEntrySet_Remove() {
map.put(key, value);
assertEquals(1, map.size());
@@ -358,6 +401,7 @@
assertTrue(map.isEmpty());
}
+ @Test
public void testEntrySet_RemoveAll() {
Set entrySet = map.entrySet();
assertFalse(entrySet.removeAll(Collections.EMPTY_SET));
@@ -368,6 +412,7 @@
assertTrue(map.isEmpty());
}
+ @Test
public void testEntrySet_RetainAll() {
Set entrySet = map.entrySet();
assertFalse(entrySet.retainAll(Collections.EMPTY_SET));
@@ -380,6 +425,7 @@
assertTrue(map.isEmpty());
}
+ @Test
public void testEntrySet_Size() {
Set entrySet = map.entrySet();
assertEquals(0, entrySet.size());
@@ -387,6 +433,7 @@
assertEquals(1, entrySet.size());
}
+ @Test
public void testEntrySet_ToArray() {
Set entrySet = map.entrySet();
assertEquals(0, entrySet.toArray().length);
@@ -397,6 +444,7 @@
assertTrue(array[0].equals(new MapEntryStub(key, value)));
}
+ @Test
public void testEntrySet_ToArrayWithObjectArray() {
Set entrySet = map.entrySet();
assertEquals(0, entrySet.toArray(new Object[0]).length);
@@ -407,6 +455,7 @@
assertTrue(array[0].equals(new MapEntryStub(key, value)));
}
+ @Test
public void testEntrySet_Equals() {
Set entrySet = map.entrySet();
assertFalse(entrySet.equals(null));
@@ -420,6 +469,7 @@
assertTrue(entrySet.equals(Collections.singleton(new MapEntryStub(key, value))));
}
+ @Test
public void testEntrySet_HashCode() {
// hash formula mandated by Map contract
Set entrySet = map.entrySet();
@@ -430,6 +480,7 @@
assertEquals(hash, entrySet.hashCode());
}
+ @Test
public void testEntrySet_Entry_SetValue() {
map.put(key, value);
@@ -442,6 +493,7 @@
assertEquals(newValue, map.get(key));
}
+ @Test
public void testEntrySet_Entry_Equals() {
map.put(key, value);
@@ -451,6 +503,7 @@
assertTrue(entry.equals(new MapEntryStub(key, value)));
}
+ @Test
public void testEntrySet_Entry_HashCode() {
map.put(key, value);
@@ -459,6 +512,7 @@
assertEquals(hash, map.entrySet().iterator().next().hashCode());
}
+ @Test
public void testEquals() {
assertFalse(map.equals(null));
assertTrue(map.equals(map));
@@ -475,6 +529,7 @@
assertTrue(map.equals(other));
}
+ @Test
public void testHashCode() {
assertEquals(0, map.hashCode());
@@ -483,6 +538,7 @@
assertEquals(hash, map.hashCode());
}
+ @Test
public void testWithComparer() {
assertFalse(ViewerElementMap.withComparer(null) instanceof ViewerElementMap);
assertTrue(ViewerElementMap.withComparer(comparer) instanceof ViewerElementMap);
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/viewers/ViewerElementSetTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/viewers/ViewerElementSetTest.java
index 32f4f47..d7b0818 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/viewers/ViewerElementSetTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/viewers/ViewerElementSetTest.java
@@ -11,30 +11,37 @@
package org.eclipse.jface.tests.internal.databinding.viewers;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
-import junit.framework.TestCase;
-
import org.eclipse.jface.internal.databinding.viewers.ViewerElementSet;
import org.eclipse.jface.viewers.IElementComparer;
+import org.junit.Before;
+import org.junit.Test;
/**
* @since 1.2
*/
-public class ViewerElementSetTest extends TestCase {
+public class ViewerElementSetTest {
IdentityElementComparer comparer;
ViewerElementSet set;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
comparer = new IdentityElementComparer();
set = new ViewerElementSet(comparer);
}
+ @Test
public void testConstructor_NullComparer() {
try {
new ViewerElementSet(null);
@@ -43,6 +50,7 @@
}
}
+ @Test
public void testConstructorWithCollection_NullCollection() {
try {
new ViewerElementSet(null, new IdentityElementComparer());
@@ -51,12 +59,14 @@
}
}
+ @Test
public void testConstructorWithCollection_AddsAllElements() {
Collection<Object> toCopy = Collections.singleton(new Object());
set = new ViewerElementSet(toCopy, new IdentityElementComparer());
assertTrue(set.containsAll(toCopy));
}
+ @Test
public void testAdd_ContainsHonorsComparer() {
Object o1 = new String("string");
Object o2 = new String("string"); // distinct instances
@@ -69,6 +79,7 @@
assertFalse(set.contains(o2));
}
+ @Test
public void testAdd_FilterDuplicateElements() {
Object o = new Object();
@@ -79,6 +90,7 @@
assertTrue(set.contains(o));
}
+ @Test
public void testAddAll_ContainsAllHonorsComparer() {
String o1 = new String("o1");
String o2 = new String("o2");
@@ -90,6 +102,7 @@
assertFalse(set.containsAll(Collections.singleton(new String("o2"))));
}
+ @Test
public void testAddAll_FiltersDuplicateElements() {
Object o = new Object();
set.add(o);
@@ -97,6 +110,7 @@
assertFalse(set.addAll(Collections.singleton(o)));
}
+ @Test
public void testClear() {
set.add(new Object());
assertEquals(1, set.size());
@@ -105,12 +119,14 @@
assertEquals(0, set.size());
}
+ @Test
public void testIsEmpty() {
assertTrue(set.isEmpty());
set.add(new Object());
assertFalse(set.isEmpty());
}
+ @Test
public void testIterator() {
Object o = new Object();
set.add(o);
@@ -126,6 +142,7 @@
assertFalse(iterator.hasNext());
}
+ @Test
public void testRemove() {
Object o = new Object();
assertFalse(set.remove(o));
@@ -137,6 +154,7 @@
assertFalse(set.contains(o));
}
+ @Test
public void testRemoveAll() {
assertFalse(set.removeAll(Collections.EMPTY_SET));
@@ -152,6 +170,7 @@
assertFalse(set.contains(o2));
}
+ @Test
public void testRetainAll() {
Object o1 = new Object();
Object o2 = new Object();
@@ -170,6 +189,7 @@
assertFalse(set.contains(o1));
}
+ @Test
public void testSize() {
assertEquals(0, set.size());
@@ -181,6 +201,7 @@
assertEquals(0, set.size());
}
+ @Test
public void testToArray() {
assertEquals(0, set.toArray().length);
@@ -189,6 +210,7 @@
assertTrue(Arrays.equals(new Object[] { o }, set.toArray()));
}
+ @Test
public void testToArrayWithObjectArray() {
Object o = new String("unique");
set.add(o);
@@ -198,6 +220,7 @@
assertSame(o, array[0]);
}
+ @Test
public void testEquals() {
assertTrue(set.equals(set));
assertFalse(set.equals(null));
@@ -212,6 +235,7 @@
assertFalse(set.equals(Collections.singleton(distinct)));
}
+ @Test
public void testHashCode() {
// Hash code implementation is mandated
assertEquals(0, set.hashCode());
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/viewers/ViewerElementWrapperTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/viewers/ViewerElementWrapperTest.java
index 5931d55..f48c65f 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/viewers/ViewerElementWrapperTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/viewers/ViewerElementWrapperTest.java
@@ -11,28 +11,33 @@
package org.eclipse.jface.tests.internal.databinding.viewers;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import org.eclipse.jface.internal.databinding.viewers.ViewerElementWrapper;
import org.eclipse.jface.viewers.IElementComparer;
-
-import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
/**
* @since 3.2
*
*/
-public class ViewerElementWrapperTest extends TestCase {
+public class ViewerElementWrapperTest {
private ViewerElementWrapper wrapper;
private Object element;
private IElementComparer comparer;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
element = new ElementStub(0);
comparer = new IdentityElementComparer();
wrapper = new ViewerElementWrapper(element, comparer);
}
+ @Test
public void testConstructor_NullComparer() {
try {
new ViewerElementWrapper(element, null);
@@ -41,12 +46,14 @@
}
}
+ @Test
public void testEquals() {
assertFalse(wrapper.equals(null));
assertTrue(wrapper.equals(wrapper));
assertTrue(wrapper.equals(new ViewerElementWrapper(element, comparer)));
}
+ @Test
public void testHashCode() {
int hash = 0;
element = new ElementStub(hash);
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/viewers/ViewerInputObservableValueTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/viewers/ViewerInputObservableValueTest.java
index 6f112ea..f89cc23 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/viewers/ViewerInputObservableValueTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/viewers/ViewerInputObservableValueTest.java
@@ -11,6 +11,11 @@
*******************************************************************************/
package org.eclipse.jface.tests.internal.databinding.viewers;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.fail;
+
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.Realm;
import org.eclipse.core.databinding.observable.value.IObservableValue;
@@ -25,8 +30,10 @@
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Shell;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
-import junit.framework.Test;
import junit.framework.TestSuite;
/**
@@ -39,7 +46,8 @@
private static String[] model = new String[] { "0", "1" };
@Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
Shell shell = new Shell();
viewer = new TableViewer(shell, SWT.NONE);
@@ -47,13 +55,15 @@
}
@Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
Shell shell = viewer.getTable().getShell();
if (!shell.isDisposed())
shell.dispose();
super.tearDown();
}
+ @Test
public void testConstructor_IllegalArgumentException() {
try {
ViewersObservables.observeInput(null);
@@ -62,6 +72,7 @@
}
}
+ @Test
public void testSetInputOnViewer_FiresChangeEventOnGetValue() {
IObservableValue observable = ViewersObservables.observeInput(viewer);
ValueChangeEventTracker listener = ValueChangeEventTracker
@@ -86,6 +97,7 @@
assertEquals(2, listener.count);
}
+ @Test
public void testGetSetValue_FiresChangeEvents() {
IObservableValue observable = ViewersObservables.observeInput(viewer);
ValueChangeEventTracker listener = new ValueChangeEventTracker();
@@ -107,11 +119,13 @@
assertValueChangeEventEquals(observable, model, null, listener.event);
}
+ @Test
public void testGetValueType_AlwaysNull() throws Exception {
IObservableValue observable = ViewersObservables.observeInput(viewer);
assertEquals(null, observable.getValueType());
}
+ @Test
public void testDispose() throws Exception {
IObservableValue observable = ViewersObservables.observeInput(viewer);
observable.dispose();
@@ -137,12 +151,8 @@
}
}
- public static Test suite() {
- TestSuite suite = new TestSuite(ViewerInputObservableValueTest.class
- .getName());
- suite.addTestSuite(ViewerInputObservableValueTest.class);
+ public static void addConformanceTest(TestSuite suite) {
suite.addTest(MutableObservableValueContractTest.suite(new Delegate()));
- return suite;
}
static class Delegate extends AbstractObservableValueContractDelegate {
diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/viewers/ViewerUpdaterTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/viewers/ViewerUpdaterTest.java
index d36d38f..d98d909 100644
--- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/viewers/ViewerUpdaterTest.java
+++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/viewers/ViewerUpdaterTest.java
@@ -23,6 +23,8 @@
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.ViewerComparator;
import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
/**
* @since 3.2
@@ -33,12 +35,14 @@
String[] elements = new String[] { "one", "two", "three" };
@Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
elementsList = new WritableList<>(Arrays.asList(elements), String.class);
}
+ @Test
public void testTableViewer_ReplacingSelectedItemSelectsNewItem() {
TableViewer tableViewer = new TableViewer(getShell());
// only with sorter the TableViewerUpdater.replace method delegates to
@@ -54,6 +58,7 @@
Assert.assertTrue(selection.toList().contains("foo"));
}
+ @Test
public void testTreeViewer_ReplacingSelectedItemSelectsNewItem() {
TreeViewer treeViewer = new TreeViewer(getShell());
Object input = new Object();