Fix deprecations * replace junit.Assert.assertThat() by MatcherAssert.assertThat() * replace new SWTNebulaBot() by new SWTGalleryBot() where it is not API * replace ExpectedException by assertThrows() * silence 2 remaining deprecation warnings Change-Id: I565240ed977d173d01b017b2cd07603d15124230
diff --git a/org.eclipse.swtbot.eclipse.core/src/org/eclipse/swtbot/eclipse/core/RemotePluginTestRunner.java b/org.eclipse.swtbot.eclipse.core/src/org/eclipse/swtbot/eclipse/core/RemotePluginTestRunner.java index 82ec662..67d67e1 100644 --- a/org.eclipse.swtbot.eclipse.core/src/org/eclipse/swtbot/eclipse/core/RemotePluginTestRunner.java +++ b/org.eclipse.swtbot.eclipse.core/src/org/eclipse/swtbot/eclipse/core/RemotePluginTestRunner.java
@@ -183,7 +183,6 @@ } } - @SuppressWarnings("restriction") private static ClassLoader getPluginClassLoader2(String getfTestPluginName) { Bundle bundle = Platform.getBundle(getfTestPluginName); if (bundle == null) {
diff --git a/org.eclipse.swtbot.generator.client/src/org/eclipse/swtbot/generator/client/Recorder.java b/org.eclipse.swtbot.generator.client/src/org/eclipse/swtbot/generator/client/Recorder.java index 6a5f11c..298da93 100644 --- a/org.eclipse.swtbot.generator.client/src/org/eclipse/swtbot/generator/client/Recorder.java +++ b/org.eclipse.swtbot.generator.client/src/org/eclipse/swtbot/generator/client/Recorder.java
@@ -165,6 +165,7 @@ */ private void insertInEditor(String code) { ICompilationUnit methodCompilationUnit = selectedMethod.getCompilationUnit(); + @SuppressWarnings("deprecation") ASTParser parser = ASTParser.newParser(AST.JLS8); parser.setSource(methodCompilationUnit); parser.setResolveBindings(true);
diff --git a/org.eclipse.swtbot.nebula.gallery.finder/src/org/eclipse/swtbot/nebula/gallery/finder/SWTBotNebulaTestCase.java b/org.eclipse.swtbot.nebula.gallery.finder/src/org/eclipse/swtbot/nebula/gallery/finder/SWTBotNebulaTestCase.java index 86b57b4..a01dc8a 100644 --- a/org.eclipse.swtbot.nebula.gallery.finder/src/org/eclipse/swtbot/nebula/gallery/finder/SWTBotNebulaTestCase.java +++ b/org.eclipse.swtbot.nebula.gallery.finder/src/org/eclipse/swtbot/nebula/gallery/finder/SWTBotNebulaTestCase.java
@@ -24,5 +24,7 @@ * @author Aurelien Pupier */ public class SWTBotNebulaTestCase extends SWTBotTestCase { + // cannot change the deprecated type here + @SuppressWarnings("deprecation") protected SWTNebulaBot bot = new SWTNebulaBot(); }
diff --git a/org.eclipse.swtbot.nebula.gallery.finder/src/org/eclipse/swtbot/nebula/gallery/finder/widgets/SWTBotGallery.java b/org.eclipse.swtbot.nebula.gallery.finder/src/org/eclipse/swtbot/nebula/gallery/finder/widgets/SWTBotGallery.java index b46f033..9c0285b 100644 --- a/org.eclipse.swtbot.nebula.gallery.finder/src/org/eclipse/swtbot/nebula/gallery/finder/widgets/SWTBotGallery.java +++ b/org.eclipse.swtbot.nebula.gallery.finder/src/org/eclipse/swtbot/nebula/gallery/finder/widgets/SWTBotGallery.java
@@ -20,7 +20,7 @@ import org.eclipse.nebula.widgets.gallery.Gallery; import org.eclipse.nebula.widgets.gallery.GalleryItem; import org.eclipse.swt.SWT; -import org.eclipse.swtbot.nebula.gallery.finder.SWTNebulaBot; +import org.eclipse.swtbot.nebula.gallery.finder.SWTGalleryBot; import org.eclipse.swtbot.swt.finder.SWTBot; import org.eclipse.swtbot.swt.finder.SWTBotWidget; import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException; @@ -159,7 +159,7 @@ public SWTBotGalleryItem getGalleryItem(final int index){ try { - new SWTNebulaBot().waitUntil(new DefaultCondition() { + new SWTGalleryBot().waitUntil(new DefaultCondition() { @Override public String getFailureMessage() { return "Could not find gallery item for index " + index; //$NON-NLS-1$
diff --git a/org.eclipse.swtbot.nebula.gallery.finder/src/org/eclipse/swtbot/nebula/gallery/finder/widgets/SWTBotGalleryItem.java b/org.eclipse.swtbot.nebula.gallery.finder/src/org/eclipse/swtbot/nebula/gallery/finder/widgets/SWTBotGalleryItem.java index 576a3e3..9599fe4 100644 --- a/org.eclipse.swtbot.nebula.gallery.finder/src/org/eclipse/swtbot/nebula/gallery/finder/widgets/SWTBotGalleryItem.java +++ b/org.eclipse.swtbot.nebula.gallery.finder/src/org/eclipse/swtbot/nebula/gallery/finder/widgets/SWTBotGalleryItem.java
@@ -21,7 +21,7 @@ import org.eclipse.nebula.widgets.gallery.Gallery; import org.eclipse.nebula.widgets.gallery.GalleryItem; import org.eclipse.swt.SWT; -import org.eclipse.swtbot.nebula.gallery.finder.SWTNebulaBot; +import org.eclipse.swtbot.nebula.gallery.finder.SWTGalleryBot; import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException; import org.eclipse.swtbot.swt.finder.results.IntResult; import org.eclipse.swtbot.swt.finder.results.ListResult; @@ -96,7 +96,7 @@ */ public SWTBotGalleryItem getGalleryItem(final int index){ try { - new SWTNebulaBot().waitUntil(new DefaultCondition() { + new SWTGalleryBot().waitUntil(new DefaultCondition() { @Override public String getFailureMessage() { return "Could not find gallery item for index " + index; //$NON-NLS-1$ @@ -132,7 +132,7 @@ */ public SWTBotGalleryItem getGalleryItem(final String itemText) throws WidgetNotFoundException { try { - new SWTNebulaBot().waitUntil(new DefaultCondition() { + new SWTGalleryBot().waitUntil(new DefaultCondition() { @Override public String getFailureMessage() { return "Could not find node with text " + itemText; //$NON-NLS-1$ @@ -180,7 +180,7 @@ */ public SWTBotGalleryItem getGalleryItem(final String itemText, final int textIndex) throws WidgetNotFoundException { try { - new SWTNebulaBot().waitUntil(new DefaultCondition() { + new SWTGalleryBot().waitUntil(new DefaultCondition() { @Override public String getFailureMessage() { return "Could not find node with text " + itemText; //$NON-NLS-1$
diff --git a/org.eclipse.swtbot.nebula.nattable.finder.test/src/org/eclipse/swtbot/nebula/nattable/finder/test1/TestRightClickXY.java b/org.eclipse.swtbot.nebula.nattable.finder.test/src/org/eclipse/swtbot/nebula/nattable/finder/test1/TestRightClickXY.java index 45c5c0d..1ac0bd3 100644 --- a/org.eclipse.swtbot.nebula.nattable.finder.test/src/org/eclipse/swtbot/nebula/nattable/finder/test1/TestRightClickXY.java +++ b/org.eclipse.swtbot.nebula.nattable.finder.test/src/org/eclipse/swtbot/nebula/nattable/finder/test1/TestRightClickXY.java
@@ -13,8 +13,8 @@ package org.eclipse.swtbot.nebula.nattable.finder.test1; import static org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable.syncExec; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; -import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertEquals;
diff --git a/org.eclipse.swtbot.nebula.nattable.finder.test/src/org/eclipse/swtbot/nebula/nattable/finder/test2/TestNatTableOtherFeatures.java b/org.eclipse.swtbot.nebula.nattable.finder.test/src/org/eclipse/swtbot/nebula/nattable/finder/test2/TestNatTableOtherFeatures.java index 745dd0a..c3f9e7b 100644 --- a/org.eclipse.swtbot.nebula.nattable.finder.test/src/org/eclipse/swtbot/nebula/nattable/finder/test2/TestNatTableOtherFeatures.java +++ b/org.eclipse.swtbot.nebula.nattable.finder.test/src/org/eclipse/swtbot/nebula/nattable/finder/test2/TestNatTableOtherFeatures.java
@@ -14,10 +14,10 @@ *******************************************************************************/ package org.eclipse.swtbot.nebula.nattable.finder.test2; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.lessThanOrEqualTo; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import org.eclipse.swtbot.nebula.nattable.finder.SWTNatTableBot;
diff --git a/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotShellTest.java b/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotShellTest.java index 363fed6..cf384db 100644 --- a/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotShellTest.java +++ b/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotShellTest.java
@@ -15,11 +15,11 @@ import static org.eclipse.swtbot.swt.finder.SWTBotTestCase.assertSameWidget; import static org.eclipse.swtbot.swt.finder.SWTBotTestCase.pass; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.Matchers.lessThan; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; import org.eclipse.swt.widgets.Composite;
diff --git a/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotTableItemTest.java b/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotTableItemTest.java index 87f3a52..077ffa2 100644 --- a/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotTableItemTest.java +++ b/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotTableItemTest.java
@@ -26,10 +26,9 @@ import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable; import org.eclipse.swtbot.swt.finder.results.Result; import org.eclipse.swtbot.swt.finder.test.AbstractControlExampleTest; +import org.junit.Assert; import org.junit.Before; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; /** * @author Vincent MAHE <vmahe [at] free [dot]fr> @@ -37,9 +36,6 @@ */ public class SWTBotTableItemTest extends AbstractControlExampleTest { - @Rule - public ExpectedException expectedException = ExpectedException.none(); - private SWTBotTable table; private SWTBotText listeners; @@ -210,10 +206,8 @@ @Test public void isGrayedTableNotChecked() throws Exception { - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("does not have the style SWT.CHECK"); - - table.getTableItem(0).isGrayed(); + Assert.assertThrows("does not have the style SWT.CHECK", IllegalArgumentException.class, + () -> table.getTableItem(0).isGrayed()); } private Point getCellCenter(final SWTBotTableItem node, final int columnIndex) {
diff --git a/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotTreeItemTest.java b/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotTreeItemTest.java index 0af9960..572fcb6 100644 --- a/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotTreeItemTest.java +++ b/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotTreeItemTest.java
@@ -32,10 +32,9 @@ import org.eclipse.swtbot.swt.finder.test.AbstractControlExampleTest; import org.eclipse.swtbot.swt.finder.utils.TableCollection; import org.eclipse.swtbot.swt.finder.utils.TableRow; +import org.junit.Assert; import org.junit.Before; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; /** * @author Ketan Padegaonkar <KetanPadegaonkar [at] gmail [dot] com> @@ -44,9 +43,6 @@ */ public class SWTBotTreeItemTest extends AbstractControlExampleTest { - @Rule - public ExpectedException expectedException = ExpectedException.none(); - private SWTBotTree tree; private SWTBotText listeners; @@ -453,10 +449,8 @@ @Test public void isGrayedTreeNotChecked() throws Exception { - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("does not have the style SWT.CHECK"); - - tree.getAllItems()[0].isGrayed(); + Assert.assertThrows("does not have the style SWT.CHECK", IllegalArgumentException.class, + () -> tree.getAllItems()[0].isGrayed()); } private Point getCellCenter(final SWTBotTreeItem node, final int columnIndex) {
diff --git a/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/matchers/WithMessage.java b/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/matchers/WithMessage.java index fa61e16..352c7b0 100644 --- a/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/matchers/WithMessage.java +++ b/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/matchers/WithMessage.java
@@ -16,7 +16,6 @@ import java.lang.reflect.Method; import org.eclipse.swt.widgets.Widget; -import org.eclipse.swtbot.swt.finder.matchers.AbstractMatcher; import org.eclipse.swtbot.swt.finder.utils.SWTUtils; import org.hamcrest.Description; import org.hamcrest.Factory;