You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2010/11/25 20:24:19 UTC

svn commit: r1039152 - in /wicket/trunk/wicket/src/test/java/org/apache/wicket: BehaviorRequestTest.java DisabledComponentTest.java markup/html/form/FormParentDisabledRawInputTest.java markup/html/form/FormSubmitTest.java util/tester/FormTesterTest.java

Author: mgrigorov
Date: Thu Nov 25 19:24:19 2010
New Revision: 1039152

URL: http://svn.apache.org/viewvc?rev=1039152&view=rev
Log:
Fix the unit tests after the introduction of Component#canCallListenerInterface() and ListenerInvocationNotAllowedException

Modified:
    wicket/trunk/wicket/src/test/java/org/apache/wicket/BehaviorRequestTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/DisabledComponentTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/FormParentDisabledRawInputTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/FormSubmitTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/util/tester/FormTesterTest.java

Modified: wicket/trunk/wicket/src/test/java/org/apache/wicket/BehaviorRequestTest.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/BehaviorRequestTest.java?rev=1039152&r1=1039151&r2=1039152&view=diff
==============================================================================
--- wicket/trunk/wicket/src/test/java/org/apache/wicket/BehaviorRequestTest.java (original)
+++ wicket/trunk/wicket/src/test/java/org/apache/wicket/BehaviorRequestTest.java Thu Nov 25 19:24:19 2010
@@ -26,6 +26,7 @@ import org.apache.wicket.markup.IMarkupR
 import org.apache.wicket.markup.html.WebMarkupContainer;
 import org.apache.wicket.markup.html.WebPage;
 import org.apache.wicket.request.handler.ListenerInterfaceRequestHandler;
+import org.apache.wicket.request.handler.ListenerInvocationNotAllowedException;
 import org.apache.wicket.request.handler.PageAndComponentProvider;
 import org.apache.wicket.util.resource.IResourceStream;
 import org.apache.wicket.util.resource.StringResourceStream;
@@ -56,8 +57,15 @@ public class BehaviorRequestTest extends
 
 	public void testDisabledBehaviorRequest()
 	{
-		tester.executeUrl(urlForBehavior(page.disabledBehavior));
-		assertTrue(!page.disabledBehavior.isCalled());
+		try
+		{
+			tester.executeUrl(urlForBehavior(page.disabledBehavior));
+			fail("Executing the listener on disabled component is not allowed.");
+		}
+		catch (ListenerInvocationNotAllowedException expected)
+		{
+			assertTrue(!page.disabledBehavior.isCalled());
+		}
 	}
 
 	private String urlForBehavior(IBehavior behaviorUnderTest)

Modified: wicket/trunk/wicket/src/test/java/org/apache/wicket/DisabledComponentTest.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/DisabledComponentTest.java?rev=1039152&r1=1039151&r2=1039152&view=diff
==============================================================================
--- wicket/trunk/wicket/src/test/java/org/apache/wicket/DisabledComponentTest.java (original)
+++ wicket/trunk/wicket/src/test/java/org/apache/wicket/DisabledComponentTest.java Thu Nov 25 19:24:19 2010
@@ -17,6 +17,7 @@
 package org.apache.wicket;
 
 import org.apache.wicket.markup.html.link.Link;
+import org.apache.wicket.request.handler.ListenerInvocationNotAllowedException;
 
 /**
  * @author jcompagner
@@ -52,6 +53,14 @@ public class DisabledComponentTest exten
 		executeTest(DisabledComponentPage1.class, "DisabledComponentPage1a_result.html");
 		Link link = ((DisabledComponentPage1)tester.getLastRenderedPage()).link;
 		link.setEnabled(false);
-		executeListener(link, "DisabledComponentPage1b_result.html");
+		try
+		{
+			executeListener(link, "DisabledComponentPage1b_result.html");
+			fail("Executing the listener on disabled component is not allowed.");
+		}
+		catch (ListenerInvocationNotAllowedException expected)
+		{
+			;
+		}
 	}
 }

Modified: wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/FormParentDisabledRawInputTest.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/FormParentDisabledRawInputTest.java?rev=1039152&r1=1039151&r2=1039152&view=diff
==============================================================================
--- wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/FormParentDisabledRawInputTest.java (original)
+++ wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/FormParentDisabledRawInputTest.java Thu Nov 25 19:24:19 2010
@@ -16,24 +16,25 @@
  */
 package org.apache.wicket.markup.html.form;
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
 import org.apache.wicket.Component;
 import org.apache.wicket.markup.html.WebMarkupContainer;
 import org.apache.wicket.markup.html.WebPage;
-import org.apache.wicket.markup.html.form.CheckBox;
-import org.apache.wicket.markup.html.form.Form;
 import org.apache.wicket.model.PropertyModel;
+import org.apache.wicket.request.handler.ListenerInvocationNotAllowedException;
 import org.apache.wicket.util.tester.WicketTester;
+import org.junit.Before;
+import org.junit.Test;
 
-public class FormParentDisabledRawInputTest extends TestCase
+public class FormParentDisabledRawInputTest
 {
 	private WicketTester tester;
 
-	@Override
-	protected void setUp() throws Exception
+	@Before
+	public void setUp() throws Exception
 	{
-		super.setUp();
 		tester = new WicketTester();
 	}
 
@@ -59,6 +60,7 @@ public class FormParentDisabledRawInputT
 		}
 	}
 
+	@Test(expected = ListenerInvocationNotAllowedException.class)
 	public void testDisabledParent() throws Exception
 	{
 		TestPage page = new TestPage();
@@ -72,10 +74,5 @@ public class FormParentDisabledRawInputT
 
 		// nothing should change with a submit that changes no values
 		tester.newFormTester("container:form").submit();
-		check = tester.getComponentFromLastRenderedPage("container:form:check");
-		assertTrue(check.isEnabled());
-		assertFalse(check.isEnabledInHierarchy());
-		tester.assertContains("disabled=\"disabled\"");
-		tester.assertContains("checked=\"checked\"");
 	}
 }

Modified: wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/FormSubmitTest.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/FormSubmitTest.java?rev=1039152&r1=1039151&r2=1039152&view=diff
==============================================================================
--- wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/FormSubmitTest.java (original)
+++ wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/FormSubmitTest.java Thu Nov 25 19:24:19 2010
@@ -19,6 +19,7 @@ package org.apache.wicket.markup.html.fo
 import org.apache.wicket.Page;
 import org.apache.wicket.WicketTestCase;
 import org.apache.wicket.markup.html.form.NestedFormsPage.NestableForm;
+import org.apache.wicket.request.handler.ListenerInvocationNotAllowedException;
 import org.apache.wicket.util.tester.FormTester;
 
 /**
@@ -134,8 +135,15 @@ public class FormSubmitTest extends Wick
 		assertEnabledState(false, true, true);
 
 		FormTester formTester = tester.newFormTester("outerForm");
-		formTester.submit("submit");
-
+		try
+		{
+			formTester.submit("submit");
+			fail("Executing the listener on disabled component is not allowed.");
+		}
+		catch (ListenerInvocationNotAllowedException expected)
+		{
+			;
+		}
 		assertOnSubmitCalled(false, false, false);
 		assertOnErrorCalled(false, false, false);
 	}

Modified: wicket/trunk/wicket/src/test/java/org/apache/wicket/util/tester/FormTesterTest.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/util/tester/FormTesterTest.java?rev=1039152&r1=1039151&r2=1039152&view=diff
==============================================================================
--- wicket/trunk/wicket/src/test/java/org/apache/wicket/util/tester/FormTesterTest.java (original)
+++ wicket/trunk/wicket/src/test/java/org/apache/wicket/util/tester/FormTesterTest.java Thu Nov 25 19:24:19 2010
@@ -22,6 +22,7 @@ import org.apache.wicket.Component;
 import org.apache.wicket.Session;
 import org.apache.wicket.WicketTestCase;
 import org.apache.wicket.markup.html.form.upload.FileUpload;
+import org.apache.wicket.request.handler.ListenerInvocationNotAllowedException;
 import org.apache.wicket.request.mapper.parameter.PageParameters;
 import org.apache.wicket.util.file.File;
 import org.apache.wicket.util.tester.MockFormFileUploadPage.MockDomainObjectFileUpload;
@@ -185,7 +186,7 @@ public class FormTesterTest extends Wick
 	 */
 	public void testSubmitMultipartForm()
 	{
-		tester.startPage(MockFormFileUploadPage.class, new PageParameters().set("required" , false));
+		tester.startPage(MockFormFileUploadPage.class, new PageParameters().set("required", false));
 		MockFormFileUploadPage page = (MockFormFileUploadPage)tester.getLastRenderedPage();
 		MockDomainObjectFileUpload domainObject = page.getDomainObject();
 
@@ -229,6 +230,14 @@ public class FormTesterTest extends Wick
 		assertTrue(check.isEnabled());
 		assertFalse(check.isEnabledInHierarchy());
 		FormTester formTester = tester.newFormTester("form");
-		formTester.submit();
+		try
+		{
+			formTester.submit();
+			fail("Executing the listener on disabled component is not allowed.");
+		}
+		catch (ListenerInvocationNotAllowedException expected)
+		{
+			;
+		}
 	}
 }