Revision: 888 http://jwebunit.svn.sourceforge.net/jwebunit/?rev=888&view=rev Author: henryju Date: 2010-11-24 16:13:09 +0000 (Wed, 24 Nov 2010)
Log Message: ----------- [3116839] Deprecated assertTitleNotSame and replaced by a working assertTitleNotEquals. Thanks to Tony Qian for reporting the bug. Modified Paths: -------------- trunk/jwebunit-commons-tests/pom.xml trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/WebAssertionsTest.java trunk/jwebunit-core/pom.xml trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java trunk/jwebunit-htmlunit-plugin/pom.xml trunk/jwebunit-selenium-plugin/pom.xml trunk/pom.xml trunk/src/changes/changes.xml Modified: trunk/jwebunit-commons-tests/pom.xml =================================================================== --- trunk/jwebunit-commons-tests/pom.xml 2010-11-10 11:15:41 UTC (rev 887) +++ trunk/jwebunit-commons-tests/pom.xml 2010-11-24 16:13:09 UTC (rev 888) @@ -12,7 +12,7 @@ <dependencies> <dependency> <groupId>junit</groupId> - <artifactId>junit</artifactId> + <artifactId>junit-dep</artifactId> </dependency> <dependency> <groupId>org.mortbay.jetty</groupId> Modified: trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/WebAssertionsTest.java =================================================================== --- trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/WebAssertionsTest.java 2010-11-10 11:15:41 UTC (rev 887) +++ trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/WebAssertionsTest.java 2010-11-24 16:13:09 UTC (rev 888) @@ -53,46 +53,50 @@ beginAt("/testPage.html"); } - @Test public void testAssertTitleEquals() throws Throwable { + @Test + public void testAssertTitleEquals() throws Throwable { assertPass("assertTitleEquals", new String[] { "testPage" }); assertFail("assertTitleEquals", "wrong title"); } - @Test public void testAssertTitleMatch() throws Throwable { + @Test + public void testAssertTitleMatch() throws Throwable { assertPass("assertTitleMatch", new String[] { "test[Pp]age" }); assertFail("assertTitleMatch", "[Ww]rong title"); } - @Test public void testAssertTextPresent() throws Throwable { - assertPassFail("assertTextPresent", "This is a test.", - "no such text"); - } - @Test public void testAssertMatch() throws Throwable { + @Test + public void testAssertTitleNotEquals() throws Throwable { + assertPass("assertTitleNotEquals", new String[] { "wrong title" }); + assertFail("assertTitleNotEquals", "testPage"); + } + + @Test + public void testAssertTextPresent() throws Throwable { + assertPassFail("assertTextPresent", "This is a test.", "no such text"); + } + + @Test + public void testAssertMatch() throws Throwable { assertPassFail("assertMatch", "This (is)* a .* test.", "no.*text"); } - @Test public void testAssertTextNotPresent() throws Throwable { - assertTextNotPresent("no such text"); - //assertPassFail("assertTextNotPresent", "no such text", - // "This is a test page."); - } + @Test + public void testAssertTextNotPresent() throws Throwable { + assertPassFail("assertTextNotPresent", "no such text", "This is a test."); + } @Test public void testAssertNoMatch() throws Throwable { - assertNoMatch("no.*text"); - //assertPassFail("assertNoMatch", "no.*text", "This (is)* a .* page."); + assertPassFail("assertNoMatch", "no.*text", "This (is)* a .* test."); } /** * Check that {...@link #assertNoMatch(String)} can actually fail. */ - @Test public void testAssertNoMatchFails() throws Throwable { - try { - // 'Span Text' definitely exists in the source page text - assertNoMatch("Span Text"); - fail("assertNoMatch() did not throw expected failure"); // should not get this far - } catch (AssertionError e) { - // expected - } + @Test(expected=AssertionError.class) + public void testAssertNoMatchFails() throws Throwable { + // 'Span Text' definitely exists in the source page text + assertNoMatch("Span Text"); } @Test public void testAssertLinkPresentWithText() throws Throwable { Modified: trunk/jwebunit-core/pom.xml =================================================================== --- trunk/jwebunit-core/pom.xml 2010-11-10 11:15:41 UTC (rev 887) +++ trunk/jwebunit-core/pom.xml 2010-11-24 16:13:09 UTC (rev 888) @@ -14,13 +14,13 @@ <dependencies> <dependency> <groupId>junit</groupId> - <artifactId>junit</artifactId> + <artifactId>junit-dep</artifactId> </dependency> <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-all</artifactId> <version>1.7</version> - <scope>test</scope> + <scope>test</scope> </dependency> <dependency> <groupId>regexp</groupId> Modified: trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java =================================================================== --- trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java 2010-11-10 11:15:41 UTC (rev 887) +++ trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java 2010-11-24 16:13:09 UTC (rev 888) @@ -58,6 +58,7 @@ import org.apache.regexp.RE; import org.apache.regexp.RESyntaxException; +import static org.hamcrest.CoreMatchers.*; import static org.junit.Assert.*; /** @@ -420,12 +421,25 @@ * * @param title * unexpected title value + * @deprecated Replaced by {...@link #assertTitleNotEquals(String)} */ + @Deprecated public void assertTitleNotSame(String title) { - assertNotSame(title, getTestingEngine().getPageTitle()); + assertTitleNotEquals(title); } /** + * Assert title of current html page in conversation is not + * equal to another value. + * + * @param title + * unexpected title value + */ + public void assertTitleNotEquals(String title) { + assertThat(title, not(equalTo(getTestingEngine().getPageTitle()))); + } + + /** * Assert title of current html page in conversation matches an expected regexp. * * @param regexp expected title regexp @@ -2861,7 +2875,7 @@ assertNotNull("no label for id [" + id + "] found", label); List<IElement> fields = getFieldsForLabel(label); - assertNotSame("there should be at least one element referenced for label [" + id + "]", 0, fields.size()); + assertFalse("there should be at least one element referenced for label [" + id + "]", fields.size()==0); // find the first element that we can change for (IElement field : fields) { Modified: trunk/jwebunit-htmlunit-plugin/pom.xml =================================================================== --- trunk/jwebunit-htmlunit-plugin/pom.xml 2010-11-10 11:15:41 UTC (rev 887) +++ trunk/jwebunit-htmlunit-plugin/pom.xml 2010-11-24 16:13:09 UTC (rev 888) @@ -12,7 +12,7 @@ <dependencies> <dependency> <groupId>junit</groupId> - <artifactId>junit</artifactId> + <artifactId>junit-dep</artifactId> <scope>test</scope> </dependency> <dependency> Modified: trunk/jwebunit-selenium-plugin/pom.xml =================================================================== --- trunk/jwebunit-selenium-plugin/pom.xml 2010-11-10 11:15:41 UTC (rev 887) +++ trunk/jwebunit-selenium-plugin/pom.xml 2010-11-24 16:13:09 UTC (rev 888) @@ -49,7 +49,7 @@ <dependencies> <dependency> <groupId>junit</groupId> - <artifactId>junit</artifactId> + <artifactId>junit-dep</artifactId> <scope>test</scope> </dependency> <dependency> Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2010-11-10 11:15:41 UTC (rev 887) +++ trunk/pom.xml 2010-11-24 16:13:09 UTC (rev 888) @@ -357,7 +357,7 @@ <dependencies> <dependency> <groupId>junit</groupId> - <artifactId>junit</artifactId> + <artifactId>junit-dep</artifactId> <version>4.8.2</version> </dependency> <dependency> Modified: trunk/src/changes/changes.xml =================================================================== --- trunk/src/changes/changes.xml 2010-11-10 11:15:41 UTC (rev 887) +++ trunk/src/changes/changes.xml 2010-11-24 16:13:09 UTC (rev 888) @@ -32,6 +32,9 @@ </properties> <body> <release version="3.0" date="UNKNOW" description="Updated all internals to JUnit 4"> + <action type="fix" dev="henryju" issue="3116839" due-to="Tony Qian"> + assertTitleNotSame works incorrectly. Deprecated and replaced by a working assertTitleNotEquals. + </action> <action type="update" dev="henryju" issue="2837745"> Updated to JUnit 4. See migration section of the documentation. </action> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Increase Visibility of Your 3D Game App & Earn a Chance To Win $500! Tap into the largest installed PC base & get more eyes on your game by optimizing for Intel(R) Graphics Technology. Get started today with the Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs. http://p.sf.net/sfu/intelisp-dev2dev _______________________________________________ JWebUnit-development mailing list JWebUnit-development@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jwebunit-development