From 62eec514cb5bb140efa51d9cc8f1c2969c6797b2 Mon Sep 17 00:00:00 2001 From: Alexei Barantsev Date: Mon, 18 Mar 2013 21:47:14 +0400 Subject: [PATCH] Unifying use of hamcrest matcher methods --- .../test/org/openqa/selenium/ArchitectureTest.java | 6 +++--- .../org/openqa/selenium/ElementAttributeTest.java | 2 +- .../selenium/JavascriptEnabledDriverTest.java | 14 ++++---------- .../test/org/openqa/selenium/VisibilityTest.java | 2 +- .../openqa/selenium/support/PageFactoryTest.java | 11 +++++------ .../support/pagefactory/AnnotationsTest.java | 4 ++-- .../pagefactory/DefaultFieldDecoratorTest.java | 6 +++--- .../openqa/selenium/testing/JUnit4TestBase.java | 2 +- 8 files changed, 20 insertions(+), 27 deletions(-) diff --git a/java/client/test/org/openqa/selenium/ArchitectureTest.java b/java/client/test/org/openqa/selenium/ArchitectureTest.java index 41d9c33b82686..f6946e7073e35 100644 --- a/java/client/test/org/openqa/selenium/ArchitectureTest.java +++ b/java/client/test/org/openqa/selenium/ArchitectureTest.java @@ -19,15 +19,15 @@ import org.junit.Test; -import static org.hamcrest.CoreMatchers.instanceOf; -import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.instanceOf; +import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -import static org.junit.matchers.JUnitMatchers.containsString; public class ArchitectureTest { diff --git a/java/client/test/org/openqa/selenium/ElementAttributeTest.java b/java/client/test/org/openqa/selenium/ElementAttributeTest.java index 4e422b68bc495..ae7bf2ae1622e 100644 --- a/java/client/test/org/openqa/selenium/ElementAttributeTest.java +++ b/java/client/test/org/openqa/selenium/ElementAttributeTest.java @@ -26,7 +26,7 @@ import static org.hamcrest.Matchers.anyOf; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.is; -import static org.hamcrest.core.IsNull.nullValue; +import static org.hamcrest.Matchers.nullValue; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; diff --git a/java/client/test/org/openqa/selenium/JavascriptEnabledDriverTest.java b/java/client/test/org/openqa/selenium/JavascriptEnabledDriverTest.java index 0d97e626aaf54..4d2e711cbf923 100644 --- a/java/client/test/org/openqa/selenium/JavascriptEnabledDriverTest.java +++ b/java/client/test/org/openqa/selenium/JavascriptEnabledDriverTest.java @@ -17,9 +17,6 @@ package org.openqa.selenium; -import org.hamcrest.Matcher; -import org.hamcrest.Matchers; -import org.hamcrest.core.CombinableMatcher; import org.junit.Test; import org.openqa.selenium.internal.Locatable; import org.openqa.selenium.testing.Ignore; @@ -30,7 +27,8 @@ import java.util.concurrent.TimeUnit; import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.core.Is.is; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.either; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThat; @@ -143,7 +141,7 @@ public void testShouldBeAbleToSubmitFormsByCausingTheOnClickEventToFire() { waitForTitleChange("We Arrive Here"); - assertThat(driver.getTitle(), Matchers.is("We Arrive Here")); + assertThat(driver.getTitle(), is("We Arrive Here")); } private void waitForTitleChange(String newTitle) { @@ -160,7 +158,7 @@ public void testShouldBeAbleToClickOnSubmitButtons() { waitForTitleChange("We Arrive Here"); - assertThat(driver.getTitle(), Matchers.is("We Arrive Here")); + assertThat(driver.getTitle(), is("We Arrive Here")); } @JavascriptEnabled @@ -227,10 +225,6 @@ public void testChangeEventIsFiredAppropriatelyWhenFocusIsLost() { .or(is("focus change blur focus change blur"))); // What Chrome does } - private static CombinableMatcher.CombinableEitherMatcher either(Matcher matcher) { - return Matchers.either(matcher); - } - /** * If the click handler throws an exception, the firefox driver freezes. This is suboptimal. */ diff --git a/java/client/test/org/openqa/selenium/VisibilityTest.java b/java/client/test/org/openqa/selenium/VisibilityTest.java index 09864cf81f2f7..7d7a069e73f06 100644 --- a/java/client/test/org/openqa/selenium/VisibilityTest.java +++ b/java/client/test/org/openqa/selenium/VisibilityTest.java @@ -25,7 +25,7 @@ import java.util.concurrent.Callable; import static org.hamcrest.Matchers.not; -import static org.hamcrest.core.Is.is; +import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertThat; diff --git a/java/client/test/org/openqa/selenium/support/PageFactoryTest.java b/java/client/test/org/openqa/selenium/support/PageFactoryTest.java index 026340d2493b7..056f9d66d1b06 100644 --- a/java/client/test/org/openqa/selenium/support/PageFactoryTest.java +++ b/java/client/test/org/openqa/selenium/support/PageFactoryTest.java @@ -16,14 +16,13 @@ package org.openqa.selenium.support; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsEqual.equalTo; -import static org.hamcrest.core.IsNull.notNullValue; -import static org.hamcrest.core.IsNull.nullValue; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.notNullValue; +import static org.hamcrest.Matchers.nullValue; import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; @@ -41,7 +40,7 @@ public class PageFactoryTest extends MockTestBase { public void shouldProxyElementsInAnInstantiatedPage() { PublicPage page = new PublicPage(); - Assert.assertThat(page.q, is(nullValue())); + assertThat(page.q, is(nullValue())); assertThat(page.list, is(nullValue())); PageFactory.initElements(driver, page); diff --git a/java/client/test/org/openqa/selenium/support/pagefactory/AnnotationsTest.java b/java/client/test/org/openqa/selenium/support/pagefactory/AnnotationsTest.java index 65dcaccc68040..5aaa7d22f719d 100644 --- a/java/client/test/org/openqa/selenium/support/pagefactory/AnnotationsTest.java +++ b/java/client/test/org/openqa/selenium/support/pagefactory/AnnotationsTest.java @@ -16,8 +16,8 @@ package org.openqa.selenium.support.pagefactory; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsEqual.equalTo; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; diff --git a/java/client/test/org/openqa/selenium/support/pagefactory/DefaultFieldDecoratorTest.java b/java/client/test/org/openqa/selenium/support/pagefactory/DefaultFieldDecoratorTest.java index aedda59e94186..098b765d0d5d2 100644 --- a/java/client/test/org/openqa/selenium/support/pagefactory/DefaultFieldDecoratorTest.java +++ b/java/client/test/org/openqa/selenium/support/pagefactory/DefaultFieldDecoratorTest.java @@ -16,9 +16,9 @@ package org.openqa.selenium.support.pagefactory; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsNull.notNullValue; -import static org.hamcrest.core.IsNull.nullValue; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.notNullValue; +import static org.hamcrest.Matchers.nullValue; import static org.junit.Assert.assertThat; import org.openqa.selenium.By; diff --git a/java/client/test/org/openqa/selenium/testing/JUnit4TestBase.java b/java/client/test/org/openqa/selenium/testing/JUnit4TestBase.java index ac6efbf2c4410..50b31d771735c 100644 --- a/java/client/test/org/openqa/selenium/testing/JUnit4TestBase.java +++ b/java/client/test/org/openqa/selenium/testing/JUnit4TestBase.java @@ -36,7 +36,7 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.is; -import static org.hamcrest.core.IsNot.not; +import static org.hamcrest.Matchers.not; import static org.junit.Assert.assertThat; @RunWith(SeleniumTestRunner.class)