Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/css/swt')
-rw-r--r--tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/css/swt/helpers/CSSSWTColorHelperTest.java44
-rw-r--r--tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/css/swt/helpers/CSSSWTFontHelperTest.java28
-rw-r--r--tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/css/swt/helpers/CSSSWTHelperTestCase.java37
-rw-r--r--tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/css/swt/helpers/EclipsePreferencesHelperTest.java33
-rw-r--r--tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/css/swt/helpers/PreferenceOverriddenByCssChangeListenerTest.java30
-rw-r--r--tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/css/swt/properties/preference/EclipsePreferencesHandlerTest.java46
6 files changed, 154 insertions, 64 deletions
diff --git a/tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/css/swt/helpers/CSSSWTColorHelperTest.java b/tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/css/swt/helpers/CSSSWTColorHelperTest.java
index a65cc86e7f8..09a6c9c0c1f 100644
--- a/tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/css/swt/helpers/CSSSWTColorHelperTest.java
+++ b/tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/css/swt/helpers/CSSSWTColorHelperTest.java
@@ -1,48 +1,67 @@
/*******************************************************************************
- * Copyright (c) 2013 IBM Corporation and others. All rights reserved. This
+ * Copyright (c) 2013, 2014 IBM Corporation and others. All rights reserved. This
* program and the accompanying materials are made available under the terms of
* the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
+ * Thibault Le Ouay <thibaultleouay@gmail.com> - Bug 443094
*******************************************************************************/
package org.eclipse.e4.ui.css.swt.helpers;
import static org.eclipse.e4.ui.css.swt.helpers.CSSSWTColorHelper.getSWTColor;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Display;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
import org.w3c.dom.css.CSSValue;
@SuppressWarnings("restriction")
public class CSSSWTColorHelperTest extends CSSSWTHelperTestCase {
private Display display;
+ private Color result;
+
+ @Before
+ public void setUp() {
- @Override
- protected void setUp() throws Exception {
display = Display.getDefault();
}
- public void testGetSWTColor() throws Exception {
- Color result = getSWTColor(colorValue("red"), display);
+ @After
+ public void tearDown() {
+ if (result != null) {
+ result.dispose();
+ }
+ display.dispose();
+ }
+ @Test
+ public void testGetSWTColor() {
+ result = getSWTColor(colorValue("red"), display);
assertNotNull(result);
assertEquals(255, result.getRed());
assertEquals(0, result.getBlue());
assertEquals(0, result.getGreen());
}
- public void testGetSWTColorWhenNotSupportedColorType() throws Exception {
- Color result = getSWTColor(colorValue("123213", CSSValue.CSS_CUSTOM),
+ @Test
+ public void testGetSWTColorWhenNotSupportedColorType() {
+ result = getSWTColor(colorValue("123213", CSSValue.CSS_CUSTOM),
display);
assertNull(result);
}
- public void testGetSWTColorWhenInvalidColorValue() throws Exception {
- Color result = getSWTColor(colorValue("asdsad12"), display);
+ @Test
+ public void testGetSWTColorWhenInvalidColorValue() {
+ result = getSWTColor(colorValue("asdsad12"), display);
assertNotNull(result);
assertEquals(0, result.getRed());
@@ -50,10 +69,11 @@ public class CSSSWTColorHelperTest extends CSSSWTHelperTestCase {
assertEquals(0, result.getGreen());
}
- public void testGetSWTColorWhenColorFromDefinition() throws Exception {
+ @Test
+ public void testGetSWTColorWhenColorFromDefinition() {
registerColorProviderWith("org.eclipse.jdt.debug.ui.InDeadlockColor", new RGB(0, 255, 0));
- Color result = getSWTColor(
+ result = getSWTColor(
colorValue(addColorDefinitionMarker("org-eclipse-jdt-debug-ui-InDeadlockColor")),
display);
diff --git a/tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/css/swt/helpers/CSSSWTFontHelperTest.java b/tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/css/swt/helpers/CSSSWTFontHelperTest.java
index e8287dc6e3f..f563bbb7237 100644
--- a/tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/css/swt/helpers/CSSSWTFontHelperTest.java
+++ b/tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/css/swt/helpers/CSSSWTFontHelperTest.java
@@ -1,22 +1,26 @@
/*******************************************************************************
- * Copyright (c) 2013 IBM Corporation and others. All rights reserved. This
+ * Copyright (c) 2013, 2014 IBM Corporation and others. All rights reserved. This
* program and the accompanying materials are made available under the terms of
* the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
+ * Thibault Le Ouay <thibaultleouay@gmail.com> - Bug 443094
*******************************************************************************/
package org.eclipse.e4.ui.css.swt.helpers;
import static org.eclipse.e4.ui.css.swt.helpers.CSSSWTFontHelper.getFontData;
+import static org.junit.Assert.assertEquals;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.FontData;
+import org.junit.Test;
@SuppressWarnings("restriction")
public class CSSSWTFontHelperTest extends CSSSWTHelperTestCase {
- public void testGetFontData() throws Exception {
+ @Test
+ public void testGetFontData() {
FontData result = getFontData(fontProperties("Times", 11, SWT.NORMAL),
new FontData());
@@ -25,7 +29,8 @@ public class CSSSWTFontHelperTest extends CSSSWTHelperTestCase {
assertEquals(SWT.NORMAL, result.getStyle());
}
- public void testGetFontDataWhenMissingFamilyInCss() throws Exception {
+ @Test
+ public void testGetFontDataWhenMissingFamilyInCss() {
FontData result = getFontData(fontProperties(null, 11, SWT.NORMAL),
new FontData("Courier", 5, SWT.ITALIC));
@@ -34,7 +39,8 @@ public class CSSSWTFontHelperTest extends CSSSWTHelperTestCase {
assertEquals(SWT.NORMAL, result.getStyle());
}
- public void testGetFontDataWhenMissingSizeInCss() throws Exception {
+ @Test
+ public void testGetFontDataWhenMissingSizeInCss() {
FontData result = getFontData(fontProperties("Arial", null, SWT.NORMAL),
new FontData("Courier", 5, SWT.ITALIC));
@@ -43,7 +49,8 @@ public class CSSSWTFontHelperTest extends CSSSWTHelperTestCase {
assertEquals(SWT.NORMAL, result.getStyle());
}
- public void testGetFontDataWhenMissingStyleInCss() throws Exception {
+ @Test
+ public void testGetFontDataWhenMissingStyleInCss() {
FontData result = getFontData(fontProperties("Times", 11, null),
new FontData("Courier", 5, SWT.ITALIC));
@@ -52,7 +59,8 @@ public class CSSSWTFontHelperTest extends CSSSWTHelperTestCase {
assertEquals(SWT.ITALIC, result.getStyle());
}
- public void testGetFontDataWhenFontFamilyFromDefinition() throws Exception {
+ @Test
+ public void testGetFontDataWhenFontFamilyFromDefinition() {
registerFontProviderWith("org.eclipse.jface.bannerfont", "Arial", 15, SWT.ITALIC);
FontData result = getFontData(
@@ -66,7 +74,8 @@ public class CSSSWTFontHelperTest extends CSSSWTHelperTestCase {
assertEquals(SWT.ITALIC, result.getStyle());
}
- public void testGetFontDataWhenFontFamilyAndSizeFromDefinition() throws Exception {
+ @Test
+ public void testGetFontDataWhenFontFamilyAndSizeFromDefinition() {
registerFontProviderWith("org.eclipse.jface.bannerfont", "Arial", 15, SWT.ITALIC);
FontData result = getFontData(
@@ -80,7 +89,8 @@ public class CSSSWTFontHelperTest extends CSSSWTHelperTestCase {
assertEquals(SWT.ITALIC, result.getStyle());
}
- public void testGetFontDataWhenFontFamilySizeAndStyleFromDefinition() throws Exception {
+ @Test
+ public void testGetFontDataWhenFontFamilySizeAndStyleFromDefinition() {
registerFontProviderWith("org.eclipse.jface.bannerfont", "Arial", 15, SWT.ITALIC);
FontData result = getFontData(
diff --git a/tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/css/swt/helpers/CSSSWTHelperTestCase.java b/tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/css/swt/helpers/CSSSWTHelperTestCase.java
index 50c9dceee21..6470115fff1 100644
--- a/tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/css/swt/helpers/CSSSWTHelperTestCase.java
+++ b/tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/css/swt/helpers/CSSSWTHelperTestCase.java
@@ -1,19 +1,20 @@
/*******************************************************************************
- * Copyright (c) 2013 IBM Corporation and others. All rights reserved. This
+ * Copyright (c) 2013, 2014 IBM Corporation and others. All rights reserved. This
* program and the accompanying materials are made available under the terms of
* the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
+ * Thibault Le Ouay <thibaultleouay@gmail.com> - Bug 443094
*******************************************************************************/
package org.eclipse.e4.ui.css.swt.helpers;
import static org.eclipse.e4.ui.css.swt.helpers.CSSSWTColorHelper.COLOR_DEFINITION_MARKER;
import static org.eclipse.e4.ui.css.swt.helpers.CSSSWTFontHelper.FONT_DEFINITION_MARKER;
+import static org.junit.Assert.fail;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
-import junit.framework.TestCase;
import org.eclipse.e4.ui.css.core.dom.properties.css2.CSS2FontProperties;
import org.eclipse.e4.ui.css.core.impl.dom.CSSValueImpl;
@@ -26,9 +27,9 @@ import org.w3c.dom.css.CSSPrimitiveValue;
import org.w3c.dom.css.CSSValue;
@SuppressWarnings("restriction")
-public abstract class CSSSWTHelperTestCase extends TestCase {
+public abstract class CSSSWTHelperTestCase {
protected void registerFontProviderWith(String expectedSymbolicName,
- String family, int size, int style) throws Exception {
+ String family, int size, int style) {
IColorAndFontProvider provider = mock(IColorAndFontProvider.class);
doReturn(new FontData[] { new FontData(family, size, style) }).when(
provider).getFont(expectedSymbolicName);
@@ -36,27 +37,33 @@ public abstract class CSSSWTHelperTestCase extends TestCase {
}
protected void registerColorProviderWith(String expectedSymbolicName,
- RGB rgb) throws Exception {
+ RGB rgb) {
IColorAndFontProvider provider = mock(IColorAndFontProvider.class);
doReturn(rgb).when(provider).getColor(expectedSymbolicName);
registerProvider(provider);
+
}
- private void registerProvider(final IColorAndFontProvider provider) throws Exception {
- new CSSActivator() {
- @Override
- public IColorAndFontProvider getColorAndFontProvider() {
- return provider;
- };
- }.start(null);
+ private void registerProvider(final IColorAndFontProvider provider) {
+ try {
+ new CSSActivator() {
+ @Override
+ public IColorAndFontProvider getColorAndFontProvider() {
+ return provider;
+ };
+ }.start(null);
+ } catch (Exception e) {
+ fail();
+ }
+
}
- protected CSS2FontProperties fontProperties(String family) throws Exception {
+ protected CSS2FontProperties fontProperties(String family) {
return fontProperties(family, null, null);
}
protected CSS2FontProperties fontProperties(String family, Object size,
- Object style) throws Exception {
+ Object style) {
CSS2FontProperties result = mock(CSS2FontProperties.class);
doReturn(valueImpl(family)).when(result).getFamily();
if (size != null) {
diff --git a/tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/css/swt/helpers/EclipsePreferencesHelperTest.java b/tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/css/swt/helpers/EclipsePreferencesHelperTest.java
index 6dfa746b514..2d8df9e4cfc 100644
--- a/tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/css/swt/helpers/EclipsePreferencesHelperTest.java
+++ b/tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/css/swt/helpers/EclipsePreferencesHelperTest.java
@@ -1,3 +1,14 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2014 IBM Corporation and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms of
+ * the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Thibault Le Ouay <thibaultleouay@gmail.com> - Bug 443094
+ *******************************************************************************/
+
package org.eclipse.e4.ui.css.swt.helpers;
import static org.eclipse.e4.ui.css.swt.helpers.EclipsePreferencesHelper.PROPS_OVERRIDDEN_BY_CSS_PROP;
@@ -7,19 +18,24 @@ import static org.eclipse.e4.ui.css.swt.helpers.EclipsePreferencesHelper.getOver
import static org.eclipse.e4.ui.css.swt.helpers.EclipsePreferencesHelper.getPreferenceChangeListener;
import static org.eclipse.e4.ui.css.swt.helpers.EclipsePreferencesHelper.removeOverriddenByCssProperty;
import static org.eclipse.e4.ui.css.swt.helpers.EclipsePreferencesHelper.removeOverriddenPropertyNames;
+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.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import java.util.List;
-import junit.framework.TestCase;
-
import org.eclipse.core.internal.preferences.EclipsePreferences;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.junit.Test;
-public class EclipsePreferencesHelperTest extends TestCase {
- public void testAppendOverriddenPropertyName() throws Exception {
+@SuppressWarnings("restriction")
+public class EclipsePreferencesHelperTest {
+ @Test
+ public void testAppendOverriddenPropertyName() {
// given
IEclipsePreferences preferences = spy(new EclipsePreferences());
@@ -43,7 +59,8 @@ public class EclipsePreferencesHelperTest extends TestCase {
getPreferenceChangeListener());
}
- public void testGetOverriddenPropertyNames() throws Exception {
+ @Test
+ public void testGetOverriddenPropertyNames() {
// given
IEclipsePreferences preferences = new EclipsePreferences();
appendOverriddenPropertyName(preferences, "prop1");
@@ -60,7 +77,8 @@ public class EclipsePreferencesHelperTest extends TestCase {
assertTrue(propertyNames.add("prop3"));
}
- public void testRemoveOverriddenPropertyNames() throws Exception {
+ @Test
+ public void testRemoveOverriddenPropertyNames() {
// given
IEclipsePreferences preferences = spy(new EclipsePreferences());
appendOverriddenPropertyName(preferences, "prop1");
@@ -75,7 +93,8 @@ public class EclipsePreferencesHelperTest extends TestCase {
getPreferenceChangeListener());
}
- public void testRemoveOverriddenByCssProperty() throws Exception {
+ @Test
+ public void testRemoveOverriddenByCssProperty() {
// given
IEclipsePreferences preferences = new EclipsePreferences();
diff --git a/tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/css/swt/helpers/PreferenceOverriddenByCssChangeListenerTest.java b/tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/css/swt/helpers/PreferenceOverriddenByCssChangeListenerTest.java
index d86129391a9..a9819eaa9fa 100644
--- a/tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/css/swt/helpers/PreferenceOverriddenByCssChangeListenerTest.java
+++ b/tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/css/swt/helpers/PreferenceOverriddenByCssChangeListenerTest.java
@@ -1,3 +1,14 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2014 IBM Corporation and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms of
+ * the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Thibault Le Ouay <thibaultleouay@gmail.com> - Bug 443094
+ *******************************************************************************/
+
package org.eclipse.e4.ui.css.swt.helpers;
import static org.eclipse.e4.ui.css.swt.helpers.EclipsePreferencesHelper.PROPS_OVERRIDDEN_BY_CSS_PROP;
@@ -6,15 +17,16 @@ import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-import junit.framework.TestCase;
import org.eclipse.core.internal.preferences.EclipsePreferences;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
import org.eclipse.e4.ui.css.swt.helpers.EclipsePreferencesHelper.PreferenceOverriddenByCssChangeListener;
+import org.junit.Test;
-public class PreferenceOverriddenByCssChangeListenerTest extends TestCase {
- public void testPreferenceChangeEvent() throws Exception {
+public class PreferenceOverriddenByCssChangeListenerTest {
+ @Test
+ public void testPreferenceChangeEvent() {
// given
IEclipsePreferences preferences = new EclipsePreferences();
preferences.put(PROPS_OVERRIDDEN_BY_CSS_PROP, SEPARATOR + "name"
@@ -33,8 +45,8 @@ public class PreferenceOverriddenByCssChangeListenerTest extends TestCase {
.removeOverriddenByCssProperty(event);
}
- public void testPreferenceChangeEventWhenAddPropertyEvent()
- throws Exception {
+ @Test
+ public void testPreferenceChangeEventWhenAddPropertyEvent() {
// given
IEclipsePreferences preferences = new EclipsePreferences();
preferences.put(PROPS_OVERRIDDEN_BY_CSS_PROP, SEPARATOR + "name"
@@ -53,8 +65,8 @@ public class PreferenceOverriddenByCssChangeListenerTest extends TestCase {
.removeOverriddenByCssProperty(event);
}
- public void testPreferenceChangeEventWhenRemovePropertyEvent()
- throws Exception {
+ @Test
+ public void testPreferenceChangeEventWhenRemovePropertyEvent() {
// given
IEclipsePreferences preferences = new EclipsePreferences();
preferences.put(PROPS_OVERRIDDEN_BY_CSS_PROP, SEPARATOR + "name"
@@ -73,8 +85,8 @@ public class PreferenceOverriddenByCssChangeListenerTest extends TestCase {
.removeOverriddenByCssProperty(event);
}
- public void testPreferenceChangeEventWhenModifyPropertyEventButPropertyIsNotOverriddenByCss()
- throws Exception {
+ @Test
+ public void testPreferenceChangeEventWhenModifyPropertyEventButPropertyIsNotOverriddenByCss() {
// given
IEclipsePreferences preferences = new EclipsePreferences();
diff --git a/tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/css/swt/properties/preference/EclipsePreferencesHandlerTest.java b/tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/css/swt/properties/preference/EclipsePreferencesHandlerTest.java
index 4f22e8e5f82..5b8d6c2211e 100644
--- a/tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/css/swt/properties/preference/EclipsePreferencesHandlerTest.java
+++ b/tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/css/swt/properties/preference/EclipsePreferencesHandlerTest.java
@@ -6,28 +6,36 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Thibault Le Ouay <thibaultleouay@gmail.com> - Bug 443094
*******************************************************************************/
package org.eclipse.e4.ui.css.swt.properties.preference;
import static org.eclipse.e4.ui.css.swt.helpers.EclipsePreferencesHelper.PROPS_OVERRIDDEN_BY_CSS_PROP;
import static org.eclipse.e4.ui.css.swt.properties.preference.EclipsePreferencesHandler.PREFERENCES_PROP;
+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 static org.mockito.Matchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-import junit.framework.TestCase;
import org.eclipse.core.internal.preferences.EclipsePreferences;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.e4.ui.css.core.engine.CSSEngine;
import org.eclipse.e4.ui.css.swt.dom.preference.EclipsePreferencesElement;
+import org.junit.Test;
import org.w3c.dom.css.CSSValue;
import org.w3c.dom.css.CSSValueList;
-public class EclipsePreferencesHandlerTest extends TestCase {
- public void testApplyCSSProperty() throws Exception {
+public class EclipsePreferencesHandlerTest {
+
+ @Test
+ public void testApplyCSSProperty() {
// given
CSSEngine engine = mock(CSSEngine.class);
@@ -42,13 +50,19 @@ public class EclipsePreferencesHandlerTest extends TestCase {
EclipsePreferencesHandlerTestable handler = spy(new EclipsePreferencesHandlerTestable());
// when
- handler.applyCSSProperty(element, PREFERENCES_PROP, value, null, engine);
+ try {
+ handler.applyCSSProperty(element, PREFERENCES_PROP, value, null, engine);
+ } catch (Exception e) {
+ fail("Apply CSSProperty should not throw exception");
+ }
// then
verify(handler, times(1)).overrideProperty(preferences, value);
+ engine.dispose();
}
- public void testApplyCSSPropertyWhenCssValueList() throws Exception {
+ @Test
+ public void testApplyCSSPropertyWhenCssValueList() {
// given
CSSEngine engine = mock(CSSEngine.class);
@@ -69,17 +83,23 @@ public class EclipsePreferencesHandlerTest extends TestCase {
EclipsePreferencesHandlerTestable handler = spy(new EclipsePreferencesHandlerTestable());
// when
- handler.applyCSSProperty(element, PREFERENCES_PROP, listValue, null,
- engine);
+ try {
+ handler.applyCSSProperty(element, PREFERENCES_PROP, listValue, null, engine);
+ } catch (Exception e) {
+ fail("Apply CSSProperty should not throw exception");
+
+ }
// then
verify(handler, times(2)).overrideProperty(
any(IEclipsePreferences.class), any(CSSValue.class));
verify(handler, times(1)).overrideProperty(preferences, values[0]);
verify(handler, times(1)).overrideProperty(preferences, values[1]);
+ engine.dispose();
}
- public void testOverridePropertyWithCSSValue() throws Exception {
+ @Test
+ public void testOverridePropertyWithCSSValue() {
// given
IEclipsePreferences preferences = new EclipsePreferences();
@@ -102,7 +122,8 @@ public class EclipsePreferencesHandlerTest extends TestCase {
"value2");
}
- public void testOverridePropertyWithNameAndValueSplit() throws Exception {
+ @Test
+ public void testOverridePropertyWithNameAndValueSplit() {
// given
IEclipsePreferences preferences = new EclipsePreferences();
@@ -117,8 +138,8 @@ public class EclipsePreferencesHandlerTest extends TestCase {
"name"));
}
- public void testOverridePropertyWithNameAndValueSplitAndNameAlreadyAddedByUser()
- throws Exception {
+ @Test
+ public void testOverridePropertyWithNameAndValueSplitAndNameAlreadyAddedByUser() {
// given
IEclipsePreferences preferences = new EclipsePreferences();
// pref is already set that means that user has overridden it with the
@@ -135,7 +156,8 @@ public class EclipsePreferencesHandlerTest extends TestCase {
assertNull(preferences.get(PROPS_OVERRIDDEN_BY_CSS_PROP, null));
}
- public void testCustomizePreferenceOverriddenByCSS() throws Exception {
+ @Test
+ public void testCustomizePreferenceOverriddenByCSS() {
// given
IEclipsePreferences preferences = new EclipsePreferences();

Back to the top