You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by iv...@apache.org on 2010/02/12 02:27:43 UTC

svn commit: r909200 [1/2] - in /wicket/trunk/wicket/src: main/disabled/org/apache/wicket/util/tester/ main/java/org/apache/wicket/ main/java/org/apache/wicket/ng/mock/ main/java/org/apache/wicket/ng/request/component/ main/java/org/apache/wicket/ng/req...

Author: ivaynberg
Date: Fri Feb 12 01:27:28 2010
New Revision: 909200

URL: http://svn.apache.org/viewvc?rev=909200&view=rev
Log:
cleaning up tests wip. wicket tester mostly working, need to check formtester. some tests are fixed and working. long road ahead.

Added:
    wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java   (contents, props changed)
      - copied, changed from r908343, wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/BaseWicketTester.java
    wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/DummyHomePage.html   (contents, props changed)
      - copied, changed from r908343, wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/DummyHomePage.html
    wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/DummyHomePage.java   (contents, props changed)
      - copied, changed from r908343, wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/DummyHomePage.java
    wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/DummyPanelPage.html   (contents, props changed)
      - copied, changed from r908343, wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/DummyPanelPage.html
    wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/DummyPanelPage.java   (contents, props changed)
      - copied, changed from r908343, wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/DummyPanelPage.java
    wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/FormTester.java   (contents, props changed)
      - copied, changed from r908343, wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/FormTester.java
    wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/ITestPageSource.java   (contents, props changed)
      - copied, changed from r908343, wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/ITestPageSource.java
    wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/Result.java   (contents, props changed)
      - copied, changed from r908343, wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/Result.java
    wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/TagTester.java   (contents, props changed)
      - copied, changed from r908343, wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/TagTester.java
    wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/TestPanelSource.java   (contents, props changed)
      - copied, changed from r908343, wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/TestPanelSource.java
    wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/WicketTester.java   (contents, props changed)
      - copied, changed from r908343, wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/WicketTester.java
    wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/WicketTesterHelper.java   (contents, props changed)
      - copied, changed from r908343, wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/WicketTesterHelper.java
    wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/package.html   (contents, props changed)
      - copied, changed from r908343, wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/package.html
Removed:
    wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/BaseWicketTester.java
    wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/DummyHomePage.html
    wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/DummyHomePage.java
    wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/DummyPanelPage.html
    wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/DummyPanelPage.java
    wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/FormTester.java
    wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/ITestPageSource.java
    wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/Result.java
    wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/TagTester.java
    wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/TestPanelSource.java
    wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/WicketTester.java
    wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/WicketTesterHelper.java
    wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/package.html
    wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/link/IndexedParamUrlCodingTest.java
Modified:
    wicket/trunk/wicket/src/main/java/org/apache/wicket/RequestListenerInterface.java
    wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/mock/MockRequestParameters.java
    wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/component/PageParameters.java
    wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/cycle/RequestCycle.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/AttributeModifierComponentTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/DisabledComponentTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/FeedbackMessagesTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/FormDispatchEventTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/LocalizerTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/PageFactoryTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/PageMarkupLoadingTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/PageParametersTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/ParentResourceEscapePathTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/RemoveTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/ResourceTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/SharedResourceUrlTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/WicketTestCase.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/AjaxBehaviorEnabledTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/HomePage2.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/MockComponent3.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/form/OnChangeAjaxBehaviorTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/markup/html/ajaxLink/AjaxLinkPageToNormalPage.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/ComponentCreateTagTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/MarkupInheritanceTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/PackageResourceTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/autolink/Index.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/basic/SimpleResponsePageClass.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/basic/SimpleResponsePageClassTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/border/BoxBorderTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/ValidatorPropertiesTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/border/HomePage.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/imagebutton/Home.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/login/InterceptTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/HomePage.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/HomePage1.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/header/inheritance/InheritanceHeadTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/image/Home.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/image/InvalidImageTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_4.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosurePage_5.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosureTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/link/BookmarkableHomePageLinksPage.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/link/BookmarkablePageLinkTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/link/BookmarkableThrowsInterceptPage.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/parser/HomePage.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/parser/filter/HeaderSectionTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/parser/filter/PanelWithHeaderPart.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/resolver/HomePage_1.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/resolver/HomePage_2.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/model/HomePage.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/model/StringResourceModelTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/ng/request/mapper/BookmarkableMapperTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/ng/request/mapper/MountedMapperTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/ng/request/mapper/PageInstanceMapperTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/properties/PropertiesTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/protocol/http/MockWebApplicationTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/protocol/http/WebExternalResourceTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/protocol/http/WebRequestCodingStrategyTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/protocol/http/WicketFilterTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/protocol/http/request/HomePage.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/protocol/http/request/WicketApplication.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/protocol/http/request/urlcompressing/MyPage.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/protocol/http/request/urlcompressing/UrlCompressingWebRequestProcessorTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/ProtectedPage.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/abort/AbortExceptionPage.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/abort/AbortExceptionTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/encodingtest/A.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/encodingtest/HomePage.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/encodingtest/RequestEncodingTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/encodingtest/WicketApplication.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/intercept/InterceptPage.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/intercept/InterceptTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/intercept/TargetPage.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/request/target/coding/IndexParamWithStatelessIFrameTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/request/target/coding/IndexedHybridUrlCodingStrategyTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/request/target/coding/IndexedSharedResourceCodingStrategyTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/request/target/coding/QueryStringUrlCodingStrategyTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/request/target/coding/TestPageWithIFrame.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/request/target/coding/UrlMountingTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/response/StringResponseTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/session/DefaultPageFactoryTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/session/InvalidateSessionTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/stateless/ImageStatelessTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/stateless/StatelessComponentPageWithParams.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/stateless/StatelessComponentTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/stateless/pages/StatelessFormTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/util/cookies/CookieUtilsTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/util/crypt/Base64Test.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/util/io/WicketOutputStreamTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/util/lang/PropertyResolverTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/util/parse/metapattern/parsers/IndexedParamTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/util/parse/metapattern/parsers/Page2.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/util/tester/BlockedResourceLinkPage.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/util/tester/FormTesterTest.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/util/tester/MockFormFileUploadPage.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/util/tester/MockPageParameterPage.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/util/tester/MockResourceLinkPage.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/util/tester/WicketTesterTest.java

Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/RequestListenerInterface.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/RequestListenerInterface.java?rev=909200&r1=909199&r2=909200&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/RequestListenerInterface.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/RequestListenerInterface.java Fri Feb 12 01:27:28 2010
@@ -18,6 +18,7 @@
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
@@ -76,6 +77,8 @@
 	 */
 	private boolean renderPageAfterInvocation = true;
 
+	final Class<? extends IRequestListener> listenerInterfaceClass;
+
 	/**
 	 * Constructor.
 	 * 
@@ -84,6 +87,8 @@
 	 */
 	public RequestListenerInterface(final Class<? extends IRequestListener> listenerInterfaceClass)
 	{
+		this.listenerInterfaceClass = listenerInterfaceClass;
+
 		// Ensure that it extends IRequestListener
 		if (!IRequestListener.class.isAssignableFrom(listenerInterfaceClass))
 		{
@@ -121,6 +126,13 @@
 		register();
 	}
 
+
+	public Class<? extends IRequestListener> getListenerInterfaceClass()
+	{
+		return listenerInterfaceClass;
+	}
+
+
 	/**
 	 * @param includeRenderCount
 	 * @return self
@@ -196,7 +208,7 @@
 		try
 		{
 			// Invoke the interface method on the component
-			method.invoke(component, new Object[] {});
+			method.invoke(component, new Object[] { });
 		}
 		catch (InvocationTargetException e)
 		{
@@ -242,7 +254,7 @@
 		try
 		{
 			// Invoke the interface method on the component
-			method.invoke(behavior, new Object[] {});
+			method.invoke(behavior, new Object[] { });
 		}
 		catch (InvocationTargetException e)
 		{
@@ -314,4 +326,15 @@
 
 		log.info("registered listener interface " + this);
 	}
+
+	/**
+	 * 
+	 * @return collection of all registered interfaces
+	 */
+	public static Collection<RequestListenerInterface> getRegisteredInterfaces()
+	{
+		return Collections.unmodifiableCollection(interfaces.values());
+	}
+
+
 }

Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/mock/MockRequestParameters.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/mock/MockRequestParameters.java?rev=909200&r1=909199&r2=909200&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/mock/MockRequestParameters.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/mock/MockRequestParameters.java Fri Feb 12 01:27:28 2010
@@ -50,10 +50,15 @@
 	public List<StringValue> getParameterValues(String name)
 	{
 		List<StringValue> values = parameters.get(name);
-
 		return values != null ? Collections.unmodifiableList(values) : null;
 	}
 
+	public void setParameterValues(String name, List<StringValue> values)
+	{
+		parameters.put(name, values);
+	}
+
+
 	/**
 	 * Sets value for given key.
 	 * 

Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/component/PageParameters.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/component/PageParameters.java?rev=909200&r1=909199&r2=909200&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/component/PageParameters.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/component/PageParameters.java Fri Feb 12 01:27:28 2010
@@ -25,9 +25,13 @@
 import java.util.TreeSet;
 
 import org.apache.wicket.ng.request.IRequestMapper;
+import org.apache.wicket.protocol.http.RequestUtils;
 import org.apache.wicket.util.lang.Checks;
 import org.apache.wicket.util.lang.Objects;
+import org.apache.wicket.util.string.IStringIterator;
+import org.apache.wicket.util.string.StringList;
 import org.apache.wicket.util.string.StringValue;
+import org.apache.wicket.util.value.ValueMap;
 
 /**
  * Mutable class that holds parameters of a Page. Page parameters consist of indexed parameters and
@@ -81,6 +85,75 @@
 		}
 	}
 
+
+	/**
+	 * Construct.
+	 * 
+	 * @param keyValuePairs
+	 *            List of key value pairs separated by commas. For example, "param1=foo,param2=bar"
+	 * @see ValueMap#ValueMap(String)
+	 */
+	@Deprecated
+	public PageParameters(final String keyValuePairs)
+	{
+		this(keyValuePairs, ",");
+	}
+
+	/**
+	 * Construct.
+	 * 
+	 * @param keyValuePairs
+	 *            List of key value pairs separated by commas. For example, "param1=foo,param2=bar"
+	 * @param delimiter
+	 *            Delimiter string used to separate key/value pairs
+	 * @see ValueMap#ValueMap(String)
+	 * 
+	 * @deprecated Please use {@link RequestUtils#decodeParameters(String, ValueMap)} to decode a
+	 *             request URL, or {@link ValueMap#ValueMap(String, String)} for other usecases.
+	 */
+	@Deprecated
+	public PageParameters(final String keyValuePairs, final String delimiter)
+	{
+		super();
+
+		// We can not use ValueMaps constructor as it uses
+		// VariableAssignmentParser which is more suitable for markup
+		// attributes, rather than URL parameters. URL param keys for
+		// examples are allowed to start with a digit (e.g. 0=xxx)
+		// and quotes are not "quotes".
+
+		// Get list of strings separated by the delimiter
+		final StringList pairs = StringList.tokenize(keyValuePairs, delimiter);
+
+		// Go through each string in the list
+		for (IStringIterator iterator = pairs.iterator(); iterator.hasNext();)
+		{
+			// Get the next key value pair
+			final String pair = iterator.next();
+
+			final int pos = pair.indexOf('=');
+			if (pos == 0)
+			{
+				throw new IllegalArgumentException("URL parameter is missing the lvalue: " + pair);
+			}
+			else if (pos != -1)
+			{
+				final String key = pair.substring(0, pos).trim();
+				final String value = pair.substring(pos + 1).trim();
+
+				addNamedParameter(key, value);
+			}
+			else
+			{
+				final String key = pair.trim();
+				final String value = null;
+
+				addNamedParameter(key, value);
+			}
+		}
+	}
+
+
 	/**
 	 * @return count of indexed parameters
 	 */
@@ -218,6 +291,7 @@
 	 * 
 	 * @author Matej Knopp
 	 */
+	// TODO rename to NamedParameter
 	public static class NamedParameterPair
 	{
 		private final String key;

Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/cycle/RequestCycle.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/cycle/RequestCycle.java?rev=909200&r1=909199&r2=909200&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/cycle/RequestCycle.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/cycle/RequestCycle.java Fri Feb 12 01:27:28 2010
@@ -29,8 +29,8 @@
 import org.apache.wicket.ng.request.Url;
 import org.apache.wicket.ng.request.component.IRequestablePage;
 import org.apache.wicket.ng.request.component.PageParameters;
-import org.apache.wicket.ng.request.handler.PageProvider;
 import org.apache.wicket.ng.request.handler.IPageProvider;
+import org.apache.wicket.ng.request.handler.PageProvider;
 import org.apache.wicket.ng.request.handler.impl.RenderPageRequestHandler;
 import org.apache.wicket.protocol.http.request.WebClientInfo;
 import org.apache.wicket.request.ClientInfo;
@@ -431,10 +431,24 @@
 	 */
 	public void setResponsePage(IRequestablePage page)
 	{
-		scheduleRequestHandlerAfterCurrent(new RenderPageRequestHandler(new PageProvider(
-			page), RenderPageRequestHandler.RedirectPolicy.AUTO_REDIRECT));
+		scheduleRequestHandlerAfterCurrent(new RenderPageRequestHandler(new PageProvider(page),
+			RenderPageRequestHandler.RedirectPolicy.AUTO_REDIRECT));
 	}
 
+
+	/**
+	 * Convenience method for setting next page to be rendered.
+	 * 
+	 * @param pageClass
+	 */
+	public void setResponsePage(Class<? extends IRequestablePage> pageClass)
+	{
+		IPageProvider provider = new PageProvider(pageClass, null);
+		scheduleRequestHandlerAfterCurrent(new RenderPageRequestHandler(provider,
+			RenderPageRequestHandler.RedirectPolicy.AUTO_REDIRECT));
+	}
+
+
 	/**
 	 * Convenience method for setting next page to be rendered.
 	 * 

Copied: wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java (from r908343, wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/BaseWicketTester.java)
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java?p2=wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java&p1=wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/BaseWicketTester.java&r1=908343&r2=909200&rev=909200&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/BaseWicketTester.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java Fri Feb 12 01:27:28 2010
@@ -21,20 +21,20 @@
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 import java.util.regex.Pattern;
 
 import org.apache.wicket.Component;
+import org.apache.wicket.IRequestHandler;
 import org.apache.wicket.MarkupContainer;
 import org.apache.wicket.Page;
-import org.apache.wicket.PageParameters;
-import org.apache.wicket.RequestCycle;
+import org.apache.wicket.RequestListenerInterface;
 import org.apache.wicket.Session;
 import org.apache.wicket.WicketRuntimeException;
 import org.apache.wicket.Component.IVisitor;
-import org.apache.wicket.ajax.AjaxEventBehavior;
+import org.apache.wicket.ajax.AbstractAjaxTimerBehavior;
 import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.ajax.AjaxSelfUpdatingTimerBehavior;
 import org.apache.wicket.ajax.form.AjaxFormSubmitBehavior;
 import org.apache.wicket.ajax.markup.html.AjaxFallbackLink;
 import org.apache.wicket.ajax.markup.html.AjaxLink;
@@ -46,25 +46,34 @@
 import org.apache.wicket.feedback.FeedbackMessages;
 import org.apache.wicket.feedback.IFeedbackMessageFilter;
 import org.apache.wicket.markup.html.basic.Label;
-import org.apache.wicket.markup.html.form.Button;
-import org.apache.wicket.markup.html.form.CheckGroup;
 import org.apache.wicket.markup.html.form.Form;
 import org.apache.wicket.markup.html.form.FormComponent;
-import org.apache.wicket.markup.html.form.IFormSubmittingComponent;
-import org.apache.wicket.markup.html.form.IFormVisitorParticipant;
-import org.apache.wicket.markup.html.form.RadioGroup;
+import org.apache.wicket.markup.html.form.IFormSubmitListener;
 import org.apache.wicket.markup.html.form.SubmitLink;
 import org.apache.wicket.markup.html.link.AbstractLink;
 import org.apache.wicket.markup.html.link.BookmarkablePageLink;
+import org.apache.wicket.markup.html.link.ILinkListener;
 import org.apache.wicket.markup.html.link.Link;
 import org.apache.wicket.markup.html.list.ListView;
 import org.apache.wicket.markup.html.panel.Panel;
-import org.apache.wicket.protocol.http.MockHttpServletResponse;
-import org.apache.wicket.protocol.http.MockWebApplication;
-import org.apache.wicket.protocol.http.WebApplication;
-import org.apache.wicket.protocol.http.WebRequestCycle;
-import org.apache.wicket.session.HttpSessionStore;
-import org.apache.wicket.session.ISessionStore;
+import org.apache.wicket.ng.ThreadContext;
+import org.apache.wicket.ng.mock.MockApplication;
+import org.apache.wicket.ng.mock.MockRequestCycle;
+import org.apache.wicket.ng.mock.MockWebRequest;
+import org.apache.wicket.ng.mock.MockWebResponse;
+import org.apache.wicket.ng.mock.WicketTester;
+import org.apache.wicket.ng.request.IRequestMapper;
+import org.apache.wicket.ng.request.Url;
+import org.apache.wicket.ng.request.component.IRequestablePage;
+import org.apache.wicket.ng.request.component.PageParameters;
+import org.apache.wicket.ng.request.cycle.RequestCycle;
+import org.apache.wicket.ng.request.handler.IPageProvider;
+import org.apache.wicket.ng.request.handler.PageAndComponentProvider;
+import org.apache.wicket.ng.request.handler.PageProvider;
+import org.apache.wicket.ng.request.handler.impl.ListenerInterfaceRequestHandler;
+import org.apache.wicket.ng.request.handler.impl.RenderPageRequestHandler;
+import org.apache.wicket.protocol.http.WebSession;
+import org.apache.wicket.settings.IRequestCycleSettings.RenderStrategy;
 import org.apache.wicket.util.diff.DiffUtil;
 import org.apache.wicket.util.lang.Classes;
 import org.apache.wicket.util.string.Strings;
@@ -81,9 +90,12 @@
  * @author Ingram Chen
  * @author Juergen Donnerstag
  * @author Frank Bille
+ * @author Igor Vaynberg
+ * 
  * @since 1.2.6
+ * 
  */
-public class BaseWicketTester extends MockWebApplication
+public class BaseWicketTester
 {
 	/** log. */
 	private static final Logger log = LoggerFactory.getLogger(BaseWicketTester.class);
@@ -113,31 +125,20 @@
 		}
 	}
 
-	/**
-	 * @author frankbille
-	 */
-	public static class DummyWebApplication extends WebApplication
-	{
-		@Override
-		public Class<? extends Page> getHomePage()
-		{
-			return DummyHomePage.class;
-		}
 
-		@Override
-		protected void outputDevelopmentModeWarning()
-		{
-			// Do nothing.
-		}
+	private final MockApplication application;
 
-		@Override
-		protected ISessionStore newSessionStore()
-		{
-			// Don't use a filestore, or we spawn lots of threads, which makes
-			// things slow.
-			return new HttpSessionStore();
-		}
-	}
+	private boolean followRedirects = true;
+	private int redirectCount;
+
+	private MockWebRequest lastRequest;
+	private MockWebResponse lastResponse;
+
+	private final List<MockWebRequest> previousRequests = new ArrayList<MockWebRequest>();
+	private final List<MockWebResponse> previousResponses = new ArrayList<MockWebResponse>();
+
+	private final ThreadContext oldThreadContext;
+	private final Session session;
 
 	/**
 	 * Creates <code>WicketTester</code> and automatically create a <code>WebApplication</code>, but
@@ -145,7 +146,7 @@
 	 */
 	public BaseWicketTester()
 	{
-		this(new DummyWebApplication(), null);
+		this(new MockApplication());
 	}
 
 	/**
@@ -158,7 +159,7 @@
 	 */
 	public <C extends Page> BaseWicketTester(final Class<C> homePage)
 	{
-		this(new WebApplication()
+		this(new MockApplication()
 		{
 			/**
 			 * @see org.apache.wicket.Application#getHomePage()
@@ -175,15 +176,7 @@
 				// Do nothing.
 			}
 
-			@Override
-			protected ISessionStore newSessionStore()
-			{
-				// Don't use a filestore, or we spawn lots of threads, which
-				// makes things slow.
-				return new HttpSessionStore();
-			}
-
-		}, null);
+		});
 	}
 
 	/**
@@ -192,11 +185,21 @@
 	 * @param application
 	 *            a <code>WicketTester</code> <code>WebApplication</code> object
 	 */
-	public BaseWicketTester(final WebApplication application)
+	public BaseWicketTester(final MockApplication application)
 	{
-		this(application, null);
+		oldThreadContext = ThreadContext.detach();
+
+		this.application = new MockApplication();
+		this.application.setName("WicketTesterApplication");
+		this.application.set();
+		this.application.initApplication();
+
+		session = new WebSession(new MockWebRequest(Url.parse("/")));
+		getApplication().getSessionStore().bind(null, session);
+		ThreadContext.setSession(session);
 	}
 
+
 	/**
 	 * Creates a <code>WicketTester</code> for unit testing.
 	 * 
@@ -209,12 +212,221 @@
 	 * @see org.apache.wicket.protocol.http.MockWebApplication#MockWebApplication(org.apache.wicket.protocol.http.WebApplication,
 	 *      String)
 	 */
-	public BaseWicketTester(final WebApplication application, final String path)
+// public BaseWicketTester(final WebApplication application, final String path)
+// {
+// super(application, path);
+// }
+
+
+	public Session getSession()
+	{
+		return session;
+	}
+
+	/**
+	 * Returns the {@link MockApplication} for this environment.
+	 * 
+	 * @return application
+	 */
+	public MockApplication getApplication()
+	{
+		return application;
+	}
+
+	/**
+	 * Destroys the tester. Restores {@link ThreadContext} to state before instance of
+	 * {@link WicketTester} was created.
+	 */
+	public void destroy()
+	{
+		ThreadContext.restore(oldThreadContext);
+		application.internalDestroy();
+	}
+
+	/**
+	 * Processes the request in mocked Wicket environment.
+	 * 
+	 * @param request
+	 *            request to process
+	 * 
+	 */
+	public void processRequest(MockWebRequest request)
+	{
+		processRequest(request);
+	}
+
+	/**
+	 * Processes the request in mocked Wicket environment.
+	 * 
+	 * @param request
+	 *            request to process
+	 * 
+	 * @param forcedRequestHandler
+	 *            optional parameter to override parsing the request URL and force
+	 *            {@link IRequestHandler}
+	 */
+	public void processRequest(MockWebRequest request, IRequestHandler forcedRequestHandler)
+	{
+		try
+		{
+			if (lastRequest != null)
+			{
+				previousRequests.add(lastRequest);
+			}
+			if (lastResponse != null)
+			{
+				previousResponses.add(lastResponse);
+			}
+
+			lastRequest = request;
+			lastResponse = new MockWebResponse();
+
+			MockRequestCycle cycle = (MockRequestCycle)application.createRequestCycle(request,
+				lastResponse);
+
+			ThreadContext.setRequestCycle(cycle);
+
+			if (forcedRequestHandler != null)
+			{
+				cycle.forceRequestHandler(forcedRequestHandler);
+			}
+
+			cycle.processRequestAndDetach();
+
+			if (followRedirects && lastResponse.isRedirect())
+			{
+				if (redirectCount == 100)
+				{
+					throw new IllegalStateException(
+						"Possible infinite redirect detected. Bailing out.");
+				}
+				++redirectCount;
+				Url newUrl = Url.parse(lastResponse.getRedirectUrl());
+				if (newUrl.isAbsolute())
+				{
+					throw new WicketRuntimeException("Can not follow absolute redirect URL.");
+				}
+
+				// append redirect URL to current URL (what browser would do)
+				Url mergedURL = new Url(request.getUrl().getSegments(), newUrl.getQueryParameters());
+				mergedURL.concatSegments(newUrl.getSegments());
+
+				processRequest(new MockWebRequest(mergedURL), null);
+
+				--redirectCount;
+			}
+		}
+		finally
+		{
+			redirectCount = 0;
+		}
+	}
+
+	/**
+	 * Renders the page specified by given {@link IPageProvider}. After render the page instance can
+	 * be retreived using {@link #getLastRenderedPage()} and the rendered document will be available
+	 * in {@link #getLastResponse()}.
+	 * 
+	 * Depending on {@link RenderStrategy} invoking this method can mean that a redirect will happen
+	 * before the actual render.
+	 * 
+	 * @param pageProvider
+	 * @return last rendered page
+	 */
+	public Page startPage(IPageProvider pageProvider)
+	{
+		MockWebRequest request = new MockWebRequest(new Url());
+		IRequestHandler handler = new RenderPageRequestHandler(pageProvider);
+		processRequest(request, handler);
+		return getLastRenderedPage();
+	}
+
+	/**
+	 * Renders the page.
+	 * 
+	 * @see #startPage(IPageProvider)
+	 * 
+	 * @param page
+	 */
+	public Page startPage(Page page)
+	{
+		return startPage(new PageProvider(page));
+	}
+
+	/**
+	 * @return last request or <code>null</code> if no request has happened yet.
+	 */
+	public MockWebRequest getLastRequest()
+	{
+		return lastRequest;
+	}
+
+	/**
+	 * @return last response or <code>null</code>> if no response has been produced yet.
+	 */
+	public MockWebResponse getLastResponse()
+	{
+		return lastResponse;
+	}
+
+	/**
+	 * @return list of prior requests
+	 */
+	public List<MockWebRequest> getPreviousRequests()
+	{
+		return Collections.unmodifiableList(previousRequests);
+	}
+
+	/**
+	 * @return list of prior responses
+	 */
+	public List<MockWebResponse> getPreviousResponses()
+	{
+		return Collections.unmodifiableList(previousResponses);
+	}
+
+	/**
+	 * @return last rendered page
+	 */
+	public Page getLastRenderedPage()
+	{
+		return (Page)application.getLastRenderedPage();
+	}
+
+	/**
+	 * Sets whether responses with redirects will be followed automatically.
+	 * 
+	 * @param followRedirects
+	 */
+	public void setFollowRedirects(boolean followRedirects)
+	{
+		this.followRedirects = followRedirects;
+	}
+
+	/**
+	 * @return <code>true</code> if redirect responses will be followed automatically,
+	 *         <code>false</code> otherwise.
+	 */
+	public boolean isFollowRedirects()
 	{
-		super(application, path);
+		return followRedirects;
 	}
 
 	/**
+	 * Encodes the {@link IRequestHandler} to {@link Url}. It should be safe to call this method
+	 * outside request thread as log as no registered {@link IRequestMapper} requires a
+	 * {@link RequestCycle}.
+	 * 
+	 * @param handler
+	 * @return {@link Url} for handler.
+	 */
+	public Url urlFor(IRequestHandler handler)
+	{
+		return application.getRootRequestMapper().mapHandler(handler);
+	}
+
+
+	/**
 	 * Renders a <code>Page</code> defined in <code>TestPageSource</code>. This is usually used when
 	 * a page does not have default constructor. For example, a <code>ViewBook</code> page requires
 	 * a <code>Book</code> instance:
@@ -236,14 +448,53 @@
 	 */
 	public final Page startPage(final ITestPageSource testPageSource)
 	{
-		startPage(DummyHomePage.class);
-		DummyHomePage page = (DummyHomePage)getLastRenderedPage();
-		page.setTestPageSource(testPageSource);
+		return startPage(new IPageProvider()
+		{
+			public void detach()
+			{
+			}
 
-		executeListener(page.getTestPageLink());
-		return getLastRenderedPage();
+			public Class<? extends IRequestablePage> getPageClass()
+			{
+				return null;
+			}
+
+			public IRequestablePage getPageInstance()
+			{
+				return testPageSource.getTestPage();
+			}
+
+			public PageParameters getPageParameters()
+			{
+				return null;
+			}
+
+		});
+	}
+
+	/**
+	 * Simulates processing URL that invokes specified {@link RequestListenerInterface} on
+	 * component.
+	 * 
+	 * After the listener interface is invoked the page containing the component will be rendered
+	 * (with an optional redirect - depending on {@link RenderStrategy}).
+	 * 
+	 * @param component
+	 * @param listener
+	 */
+	public void executeListener(Component component, RequestListenerInterface listener)
+	{
+		// there are two ways to do this. RequestCycle could be forced to call the handler
+		// directly but constructing and parsing the URL increases the chance of triggering bugs
+		IRequestHandler handler = new ListenerInterfaceRequestHandler(new PageAndComponentProvider(
+			component.getPage(), component), listener);
+
+		Url url = urlFor(handler);
+
+		processRequest(new MockWebRequest(url), null);
 	}
 
+
 	/**
 	 * Builds and processes a request suitable for invoking a listener. The <code>Component</code>
 	 * must implement any of the known <code>IListener</code> interfaces.
@@ -253,9 +504,13 @@
 	 */
 	public void executeListener(Component component)
 	{
-		WebRequestCycle cycle = setupRequestAndResponse();
-		getServletRequest().setRequestToComponent(component);
-		processRequestCycle(cycle);
+		for (RequestListenerInterface iface : RequestListenerInterface.getRegisteredInterfaces())
+		{
+			if (iface.getListenerInterfaceClass().isAssignableFrom(component.getClass()))
+			{
+				executeListener(component, iface);
+			}
+		}
 	}
 
 	/**
@@ -266,22 +521,8 @@
 	 */
 	public void executeBehavior(final AbstractAjaxBehavior behavior)
 	{
-		CharSequence url = behavior.getCallbackUrl(false);
-		WebRequestCycle cycle = setupRequestAndResponse(true);
-		getServletRequest().setRequestToRedirectString(url.toString());
-		processRequestCycle(cycle);
-	}
-
-	/**
-	 * Renders the <code>Page</code>.
-	 * 
-	 * @param page
-	 *            a <code>Page</code> to render
-	 * @return the rendered <code>Page</code>
-	 */
-	public final Page startPage(final Page page)
-	{
-		return startPage(new TestPageSource(page));
+		Url url = Url.parse(behavior.getCallbackUrl().toString());
+		processRequest(new MockWebRequest(url), null);
 	}
 
 	/**
@@ -295,8 +536,7 @@
 	 */
 	public final <C extends Page> Page startPage(Class<C> pageClass)
 	{
-		processRequestCycle(pageClass);
-		return getLastRenderedPage();
+		return startPage(new PageProvider(pageClass));
 	}
 
 	/**
@@ -312,8 +552,7 @@
 	 */
 	public final <C extends Page> Page startPage(Class<C> pageClass, PageParameters parameters)
 	{
-		processRequestCycle(pageClass, parameters);
-		return getLastRenderedPage();
+		return startPage(new PageProvider(pageClass, parameters));
 	}
 
 	/**
@@ -572,8 +811,9 @@
 	public Result ifContains(String pattern)
 	{
 		return isTrue("pattern '" + pattern + "' not found in:\n" +
-			getServletResponse().getDocument(), getServletResponse().getDocument().matches(
-			"(?s).*" + pattern + ".*"));
+			getLastResponse().getTextResponse(), getLastResponse().getTextResponse()
+			.toString()
+			.matches("(?s).*" + pattern + ".*"));
 	}
 
 	/**
@@ -645,34 +885,14 @@
 					"not be invoked when AJAX (javascript) is disabled.");
 			}
 
-			AjaxLink<?> link = (AjaxLink<?>)linkComponent;
-
-			setupRequestAndResponse(true);
-			WebRequestCycle requestCycle = createRequestCycle();
-			AjaxRequestTarget target = getApplication().newAjaxRequestTarget(link.getPage());
-			requestCycle.setRequestTarget(target);
-
-			link.onClick(target);
-
-			// process the request target
-			processRequestCycle(requestCycle);
+			executeBehavior(WicketTesterHelper.findAjaxEventBehavior(linkComponent, "onclick"));
 		}
 		// AjaxFallbackLinks is processed like an AjaxLink if isAjax is true
 		// If it's not handling of the linkComponent is passed through to the
 		// Link.
 		else if (linkComponent instanceof AjaxFallbackLink && isAjax)
 		{
-			AjaxFallbackLink<?> link = (AjaxFallbackLink<?>)linkComponent;
-
-			setupRequestAndResponse(true);
-			WebRequestCycle requestCycle = createRequestCycle();
-			AjaxRequestTarget target = getApplication().newAjaxRequestTarget(link.getPage());
-			requestCycle.setRequestTarget(target);
-
-			link.onClick(target);
-
-			// process the request target
-			processRequestCycle(requestCycle);
+			executeBehavior(WicketTesterHelper.findAjaxEventBehavior(linkComponent, "onclick"));
 		}
 		// if the link is an AjaxSubmitLink, we need to find the form
 		// from it using reflection so we know what to submit.
@@ -686,32 +906,8 @@
 			}
 
 			AjaxSubmitLink link = (AjaxSubmitLink)linkComponent;
-
-			// We cycle through the attached behaviors and select the
-			// LAST matching behavior as the one we handle.
-			List<IBehavior> behaviors = link.getBehaviors();
-			AjaxFormSubmitBehavior ajaxFormSubmitBehavior = null;
-			for (IBehavior behavior : behaviors)
-			{
-				if (behavior instanceof AjaxFormSubmitBehavior)
-				{
-					AjaxFormSubmitBehavior submitBehavior = (AjaxFormSubmitBehavior)behavior;
-					ajaxFormSubmitBehavior = submitBehavior;
-				}
-			}
-
-			String failMessage = "No form submit behavior found on the submit link. Strange!!";
-			notNull(failMessage, ajaxFormSubmitBehavior);
-
-			WebRequestCycle requestCycle = setupRequestAndResponse(true);
-
-			submitAjaxFormSubmitBehavior(linkComponent, ajaxFormSubmitBehavior);
-
-			// Ok, finally we "click" the link
-			ajaxFormSubmitBehavior.onRequest();
-
-			// process the request target
-			processRequestCycle(requestCycle);
+			submitAjaxFormSubmitBehavior(link,
+				(AjaxFormSubmitBehavior)WicketTesterHelper.findAjaxEventBehavior(link, "onclick"));
 		}
 		/*
 		 * If the link is a submitlink then we pretend to have clicked it
@@ -721,23 +917,7 @@
 			SubmitLink submitLink = (SubmitLink)linkComponent;
 
 			String pageRelativePath = submitLink.getInputName();
-			getParametersForNextRequest().put(pageRelativePath, new String[] { "x" });
-
-			Form<?> form = submitLink.getForm();
-			form.visitFormComponents(new FormComponent.IVisitor()
-			{
-				public Object formComponent(IFormVisitorParticipant formComponent)
-				{
-					FormComponent<?> component = (FormComponent<?>)formComponent;
-					if (getParametersForNextRequest().containsKey(component.getInputName()) == false)
-					{
-						getParametersForNextRequest().put(component.getInputName(),
-							new String[] { component.getDefaultModelObjectAsString() });
-					}
-
-					return IVisitor.CONTINUE_TRAVERSAL;
-				}
-			});
+			getLastRequest().getPostRequestParameters().setParameterValue(pageRelativePath, "x");
 
 			submitForm(submitLink.getForm().getPageRelativePath());
 		}
@@ -762,7 +942,8 @@
 
 					PageParameters parameters = (PageParameters)getParametersMethod.invoke(
 						bookmarkablePageLink, (Object[])null);
-					setParametersForNextRequest(parameters.toRequestParameters());
+
+					startPage(bookmarkablePageLink.getPageClass(), parameters);
 				}
 				catch (Exception e)
 				{
@@ -772,7 +953,7 @@
 
 			}
 
-			executeListener(link);
+			executeListener(link, ILinkListener.INTERFACE);
 		}
 		else
 		{
@@ -789,44 +970,13 @@
 	public void submitForm(String path)
 	{
 		Form<?> form = (Form<?>)getComponentFromLastRenderedPage(path);
-		executeListener(form);
+		Url url = Url.parse(form.urlFor(IFormSubmitListener.INTERFACE).toString());
+		processRequest(getLastRequest().requestWithUrl(url));
 	}
 
-	/**
-	 * Sets a parameter for the <code>Component</code> with the given path to be used with the next
-	 * request.
-	 * <p>
-	 * NOTE: this method only works when a <code>Page</code> was rendered first.
-	 * 
-	 * @param componentPath
-	 *            path to the <code>Component</code>
-	 * @param value
-	 *            the parameter value to set
-	 */
-	public void setParameterForNextRequest(String componentPath, Object value)
+	public void setParameterForNextRequest(String param, String value)
 	{
-		if (getLastRenderedPage() == null)
-		{
-			fail("before using this method, at least one page has to be rendered");
-		}
-
-		Component c = getComponentFromLastRenderedPage(componentPath);
-		if (c == null)
-		{
-			fail("component " + componentPath + " was not found");
-			return;
-		}
-
-		if (c instanceof FormComponent)
-		{
-			getParametersForNextRequest().put(((FormComponent<?>)c).getInputName(),
-				new String[] { value.toString() });
-		}
-		else
-		{
-			getParametersForNextRequest().put(c.getPath(), new String[] { value.toString() });
-		}
-
+		getLastRequest().getPostRequestParameters().setParameterValue(param, value);
 	}
 
 	/**
@@ -871,7 +1021,7 @@
 	public void assertResultPage(final Class<?> pageClass, final String filename) throws Exception
 	{
 		// Validate the document
-		String document = getServletResponse().getDocument();
+		String document = getLastResponse().getTextResponse().toString();
 		DiffUtil.validatePage(document, pageClass, filename, true);
 	}
 
@@ -887,7 +1037,7 @@
 	public Result isResultPage(final String expectedDocument) throws Exception
 	{
 		// Validate the document
-		String document = getServletResponse().getDocument();
+		String document = getLastResponse().getTextResponse().toString();
 		return isTrue("expected rendered page equals", document.equals(expectedDocument));
 	}
 
@@ -949,7 +1099,7 @@
 	 */
 	public void dumpPage()
 	{
-		log.info(getServletResponse().getDocument());
+		log.info(getLastResponse().getTextResponse().toString());
 	}
 
 	/**
@@ -1012,7 +1162,7 @@
 		}
 
 		// Get the AJAX response
-		String ajaxResponse = getServletResponse().getDocument();
+		String ajaxResponse = getLastResponse().getTextResponse().toString();
 
 		// Test that the previous response was actually a AJAX response
 		failMessage = "The Previous response was not an AJAX response. "
@@ -1078,16 +1228,17 @@
 				// get the AbstractAjaxBehaviour which is responsible for
 				// getting the contents of the lazy panel
 				List<IBehavior> behaviors = BehaviorsUtil.getBehaviors(component,
-					AjaxSelfUpdatingTimerBehavior.class);
+					AbstractAjaxTimerBehavior.class);
 				for (IBehavior b : behaviors)
 				{
-					if (b instanceof AjaxSelfUpdatingTimerBehavior)
+					if (b instanceof AbstractAjaxTimerBehavior)
 					{
 						log.debug("Triggering AjaxSelfUpdatingTimerBehavior: " +
 							component.getClassRelativePath());
-						AjaxSelfUpdatingTimerBehavior abstractAjaxBehaviour = (AjaxSelfUpdatingTimerBehavior)b;
-						if (!abstractAjaxBehavior.isStopped()) {
-						executeBehavior(abstractAjaxBehaviour);
+						AbstractAjaxTimerBehavior timer = (AbstractAjaxTimerBehavior)b;
+						if (!timer.isStopped())
+						{
+							executeBehavior(timer);
 						}
 					}
 				}
@@ -1135,8 +1286,6 @@
 	 */
 	public void executeAjaxEvent(final Component component, final String event)
 	{
-		setCreateAjaxRequest(true);
-
 		String failMessage = "Can't execute event on a component which is null.";
 		notNull(failMessage, component);
 
@@ -1149,79 +1298,36 @@
 				" Component: " + component + "; Event: " + event);
 		}
 
-		// Run through all the behavior and select the LAST ADDED behavior which
-		// matches the event parameter.
-		AjaxEventBehavior ajaxEventBehavior = null;
-		List<IBehavior> behaviors = component.getBehaviors();
-		for (IBehavior behavior : behaviors)
-		{
-			// AjaxEventBehavior is the one to look for
-			if (behavior instanceof AjaxEventBehavior)
-			{
-				AjaxEventBehavior tmp = (AjaxEventBehavior)behavior;
-				if (event.equals(tmp.getEvent()))
-				{
-					ajaxEventBehavior = tmp;
-				}
-			}
-		}
-
-		// If there haven't been found any event behaviors on the component
-		// which matches the parameters we fail.
-		failMessage = "No AjaxEventBehavior found on component: " + component.getId() +
-			" which matches the event: " + event;
-		notNull(failMessage, ajaxEventBehavior);
-
-		// when the requestcycle is not created via setupRequestAndResponse(true), than create a new
-		// one
-		WebRequestCycle requestCycle = resolveRequestCycle();
-		if (!requestCycle.getWebRequest().isAjax())
-		{
-			throw new IllegalStateException(
-				"The ServletWebRequest was created without wicket-ajax header. Please use tester.setCreateAjaxRequest(true)");
-		}
-
-		// If the event is an FormSubmitBehavior then also "submit" the form
-		if (ajaxEventBehavior instanceof AjaxFormSubmitBehavior)
-		{
-			AjaxFormSubmitBehavior ajaxFormSubmitBehavior = (AjaxFormSubmitBehavior)ajaxEventBehavior;
-			submitAjaxFormSubmitBehavior(component, ajaxFormSubmitBehavior);
-		}
-
-		// process the event
-		ajaxEventBehavior.onRequest();
-
-		// process the request target
-		processRequestCycle(requestCycle);
+		executeBehavior(WicketTesterHelper.findAjaxEventBehavior(component, event));
 	}
 
 	/**
 	 * 
 	 * @return WebRequestCycle
 	 */
-	protected WebRequestCycle resolveRequestCycle()
-	{
-		// initialize the request only if needed to allow the user to pass
-		// request parameters, see WICKET-254
-		WebRequestCycle requestCycle;
-		if (RequestCycle.get() == null)
-		{
-			requestCycle = setupRequestAndResponse();
-		}
-		else
-		{
-			requestCycle = (WebRequestCycle)RequestCycle.get();
-
-			// If a ajax request is requested but the existing is not, than we still need to create
-			// a new one
-			if ((requestCycle.getWebRequest().isAjax() == false) && (isCreateAjaxRequest() == true))
-			{
-				setParametersForNextRequest(requestCycle.getWebRequest().getParameterMap());
-				requestCycle = setupRequestAndResponse();
-			}
-		}
-		return requestCycle;
-	}
+// protected WebRequestCycle resolveRequestCycle()
+// {
+// // initialize the request only if needed to allow the user to pass
+// // request parameters, see WICKET-254
+// WebRequestCycle requestCycle;
+// if (RequestCycle.get() == null)
+// {
+// requestCycle = setupRequestAndResponse();
+// }
+// else
+// {
+// requestCycle = (WebRequestCycle)RequestCycle.get();
+//
+// // If a ajax request is requested but the existing is not, than we still need to create
+// // a new one
+// if ((requestCycle.getWebRequest().isAjax() == false) && (isCreateAjaxRequest() == true))
+// {
+// setParametersForNextRequest(requestCycle.getWebRequest().getParameterMap());
+// requestCycle = setupRequestAndResponse();
+// }
+// }
+// return requestCycle;
+// }
 
 	/**
 	 * Retrieves a <code>TagTester</code> based on a <code>wicket:id</code>. If more
@@ -1234,8 +1340,8 @@
 	 */
 	public TagTester getTagByWicketId(String wicketId)
 	{
-		return TagTester.createTagByAttribute(getServletResponse().getDocument(), "wicket:id",
-			wicketId);
+		return TagTester.createTagByAttribute(getLastResponse().getTextResponse().toString(),
+			"wicket:id", wicketId);
 	}
 
 	/**
@@ -1244,9 +1350,9 @@
 	 * 
 	 * @see BaseWicketTester#getTagByWicketId(String)
 	 */
-	public static List<TagTester> getTagsByWicketId(WicketTester tester, String wicketId)
+	public List<TagTester> getTagsByWicketId(String wicketId)
 	{
-		return TagTester.createTagsByAttribute(tester.getServletResponse().getDocument(),
+		return TagTester.createTagsByAttribute(getLastResponse().getTextResponse().toString(),
 			"wicket:id", wicketId, false);
 	}
 
@@ -1260,7 +1366,8 @@
 	 */
 	public TagTester getTagById(String id)
 	{
-		return TagTester.createTagByAttribute(getServletResponse().getDocument(), "id", id);
+		return TagTester.createTagByAttribute(getLastResponse().getTextResponse().toString(), "id",
+			id);
 	}
 
 	/**
@@ -1281,33 +1388,8 @@
 		String failMessage = "No form attached to the submitlink.";
 		notNull(failMessage, form);
 
-		form.visitFormComponents(new FormComponent.AbstractVisitor()
-		{
-			@Override
-			public void onFormComponent(FormComponent<?> formComponent)
-			{
-				if (!(formComponent instanceof RadioGroup) &&
-					!(formComponent instanceof CheckGroup) &&
-					!formComponent.getClass().isAssignableFrom(Button.class) &&
-					formComponent.isVisible() && formComponent.isEnabledInHierarchy())
-				{
-					if (!((formComponent instanceof IFormSubmittingComponent) && (component instanceof IFormSubmittingComponent)) ||
-						(component == formComponent))
-					{
-						String name = formComponent.getInputName();
-						String value = formComponent.getValue();
-
-						// Set request parameter with the field value, but do not modify an
-						// existing request parameter explicitly set using
-						// FormTester.setValue()
-						if (getServletRequest().getParameterMap().get(name) == null)
-						{
-							getServletRequest().setParameter(name, value);
-						}
-					}
-				}
-			}
-		});
+		Url url = Url.parse(behavior.getCallbackUrl().toString());
+		processRequest(getLastRequest().requestWithUrl(url), null);
 	}
 
 	/**
@@ -1317,7 +1399,7 @@
 	 */
 	public String getContentTypeFromResponseHeader()
 	{
-		String contentType = ((MockHttpServletResponse)getWicketResponse().getHttpServletResponse()).getHeader("Content-Type");
+		String contentType = getLastResponse().getHeader("Content-Type");
 		if (contentType == null)
 		{
 			throw new WicketRuntimeException("No Content-Type header found");
@@ -1332,7 +1414,7 @@
 	 */
 	public int getContentLengthFromResponseHeader()
 	{
-		String contentLength = ((MockHttpServletResponse)getWicketResponse().getHttpServletResponse()).getHeader("Content-Length");
+		String contentLength = getLastResponse().getHeader("Content-Length");
 		if (contentLength == null)
 		{
 			throw new WicketRuntimeException("No Content-Length header found");
@@ -1347,7 +1429,7 @@
 	 */
 	public String getLastModifiedFromResponseHeader()
 	{
-		return ((MockHttpServletResponse)getWicketResponse().getHttpServletResponse()).getHeader("Last-Modified");
+		return getLastResponse().getHeader("Last-Modified");
 	}
 
 	/**
@@ -1357,7 +1439,7 @@
 	 */
 	public String getContentDispositionFromResponseHeader()
 	{
-		return ((MockHttpServletResponse)getWicketResponse().getHttpServletResponse()).getHeader("Content-Disposition");
+		return getLastResponse().getHeader("Content-Disposition");
 	}
 
 	private Result isTrue(String message, boolean condition)

Propchange: wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/DummyHomePage.html (from r908343, wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/DummyHomePage.html)
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/DummyHomePage.html?p2=wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/DummyHomePage.html&p1=wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/DummyHomePage.html&r1=908343&r2=909200&rev=909200&view=diff
==============================================================================
    (empty)

Propchange: wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/DummyHomePage.html
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/DummyHomePage.html
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/DummyHomePage.java (from r908343, wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/DummyHomePage.java)
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/DummyHomePage.java?p2=wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/DummyHomePage.java&p1=wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/DummyHomePage.java&r1=908343&r2=909200&rev=909200&view=diff
==============================================================================
    (empty)

Propchange: wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/DummyHomePage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/DummyHomePage.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/DummyPanelPage.html (from r908343, wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/DummyPanelPage.html)
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/DummyPanelPage.html?p2=wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/DummyPanelPage.html&p1=wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/DummyPanelPage.html&r1=908343&r2=909200&rev=909200&view=diff
==============================================================================
    (empty)

Propchange: wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/DummyPanelPage.html
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/DummyPanelPage.html
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/DummyPanelPage.java (from r908343, wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/DummyPanelPage.java)
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/DummyPanelPage.java?p2=wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/DummyPanelPage.java&p1=wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/DummyPanelPage.java&r1=908343&r2=909200&rev=909200&view=diff
==============================================================================
    (empty)

Propchange: wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/DummyPanelPage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/DummyPanelPage.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/FormTester.java (from r908343, wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/FormTester.java)
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/FormTester.java?p2=wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/FormTester.java&p1=wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/FormTester.java&r1=908343&r2=909200&rev=909200&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/FormTester.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/FormTester.java Fri Feb 12 01:27:28 2010
@@ -19,12 +19,10 @@
 import java.lang.reflect.Field;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
-import java.util.Arrays;
+import java.util.ArrayList;
 import java.util.Collection;
-import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
-import java.util.Map;
 
 import org.apache.wicket.Component;
 import org.apache.wicket.WicketRuntimeException;
@@ -42,13 +40,9 @@
 import org.apache.wicket.markup.html.form.Radio;
 import org.apache.wicket.markup.html.form.RadioChoice;
 import org.apache.wicket.markup.html.form.RadioGroup;
-import org.apache.wicket.markup.html.form.upload.FileUploadField;
-import org.apache.wicket.protocol.http.MockHttpServletRequest;
-import org.apache.wicket.protocol.http.WebRequestCycle;
-import org.apache.wicket.util.file.File;
+import org.apache.wicket.util.string.StringValue;
 import org.apache.wicket.util.string.Strings;
 
-
 /**
  * A helper class for testing validation and submission of <code>FormComponent</code>s.
  * 
@@ -373,7 +367,6 @@
 		this.path = path;
 		this.workingForm = workingForm;
 		baseWicketTester = wicketTester;
-		baseWicketTester.setupRequestAndResponse();
 
 		// fill blank String for Text Component.
 		workingForm.visitFormComponents(new FormComponent.AbstractVisitor()
@@ -631,22 +624,22 @@
 	 * @param contentType
 	 *            the content type of the file. Must be a valid mime type.
 	 */
-	public void setFile(final String formComponentId, final File file, final String contentType)
-	{
-		checkClosed();
-
-		FormComponent<?> formComponent = (FormComponent<?>)workingForm.get(formComponentId);
-
-		if (formComponent instanceof FileUploadField == false)
-		{
-			throw new IllegalArgumentException("'" + formComponentId + "' is not " +
-				"a FileUploadField. You can only attach a file to form " +
-				"component of this type.");
-		}
-
-		MockHttpServletRequest servletRequest = baseWicketTester.getServletRequest();
-		servletRequest.addFile(formComponent.getInputName(), file, contentType);
-	}
+// public void setFile(final String formComponentId, final File file, final String contentType)
+// {
+// checkClosed();
+//
+// FormComponent<?> formComponent = (FormComponent<?>)workingForm.get(formComponentId);
+//
+// if (formComponent instanceof FileUploadField == false)
+// {
+// throw new IllegalArgumentException("'" + formComponentId + "' is not " +
+// "a FileUploadField. You can only attach a file to form " +
+// "component of this type.");
+// }
+//
+// MockHttpServletRequest servletRequest = baseWicketTester.getServletRequest();
+// servletRequest.addFile(formComponent.getInputName(), file, contentType);
+// }
 
 	/**
 	 * Submits the <code>Form</code>. Note that <code>submit</code> can be executed only once.
@@ -656,15 +649,9 @@
 		checkClosed();
 		try
 		{
-			baseWicketTester.getWicketSession().cleanupFeedbackMessages();
-
-			MockHttpServletRequest servletRequest = baseWicketTester.getServletRequest();
-
-			WebRequestCycle requestCycle = baseWicketTester.createRequestCycle();
-			servletRequest.setRequestToComponent(workingForm);
-
-			servletRequest.setUseMultiPartContentType(isMultiPart());
-			baseWicketTester.processRequestCycle(requestCycle);
+			baseWicketTester.getLastRenderedPage().getSession().cleanupFeedbackMessages();
+			baseWicketTester.submitForm(path);
+// servletRequest.setUseMultiPartContentType(isMultiPart());
 		}
 		finally
 		{
@@ -751,14 +738,25 @@
 	{
 		if (parameterExist(formComponent))
 		{
-			String[] values = baseWicketTester.getServletRequest().getParameterValues(
-				formComponent.getInputName());
+			List<StringValue> values = baseWicketTester.getLastRequest()
+				.getPostRequestParameters()
+				.getParameterValues(formComponent.getInputName());
 			// remove duplicated
-			HashSet<String> all = new HashSet<String>(Arrays.asList(values));
+
+			HashSet<String> all = new HashSet<String>();
+			for (StringValue val : values)
+			{
+				all.add(val.toString());
+			}
 			all.add(value);
-			Map<String, String[]> newParameters = new HashMap<String, String[]>();
-			newParameters.put(formComponent.getInputName(), all.toArray(new String[all.size()]));
-			baseWicketTester.getServletRequest().setParameters(newParameters);
+
+			values = new ArrayList<StringValue>();
+			for (String val : all)
+			{
+				values.add(StringValue.valueOf(val));
+			}
+			baseWicketTester.getLastRequest().getPostRequestParameters().setParameterValues(
+				formComponent.getInputName(), values);
 		}
 		else
 		{
@@ -788,8 +786,10 @@
 	 */
 	private boolean parameterExist(FormComponent<?> formComponent)
 	{
-		String parameter = baseWicketTester.getServletRequest().getParameter(
-			formComponent.getInputName());
+		String parameter = baseWicketTester.getLastRequest()
+			.getPostRequestParameters()
+			.getParameterValue(formComponent.getInputName())
+			.toString();
 		return parameter != null && parameter.trim().length() > 0;
 	}
 
@@ -803,7 +803,8 @@
 	 */
 	private void setFormComponentValue(FormComponent<?> formComponent, String value)
 	{
-		baseWicketTester.getServletRequest().setParameter(formComponent.getInputName(), value);
+		baseWicketTester.getLastRequest().getPostRequestParameters().setParameterValue(
+			formComponent.getInputName(), value);
 	}
 
 	/**
@@ -816,7 +817,8 @@
 	 */
 	private void setFormSubmittingComponentValue(IFormSubmittingComponent component, String value)
 	{
-		baseWicketTester.getServletRequest().setParameter(component.getInputName(), value);
+		baseWicketTester.getLastRequest().getPostRequestParameters().setParameterValue(
+			component.getInputName(), value);
 	}
 
 	private void fail(String message)

Propchange: wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/FormTester.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/FormTester.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/ITestPageSource.java (from r908343, wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/ITestPageSource.java)
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/ITestPageSource.java?p2=wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/ITestPageSource.java&p1=wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/ITestPageSource.java&r1=908343&r2=909200&rev=909200&view=diff
==============================================================================
    (empty)

Propchange: wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/ITestPageSource.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/ITestPageSource.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/Result.java (from r908343, wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/Result.java)
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/Result.java?p2=wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/Result.java&p1=wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/Result.java&r1=908343&r2=909200&rev=909200&view=diff
==============================================================================
    (empty)

Propchange: wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/Result.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/TagTester.java (from r908343, wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/TagTester.java)
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/TagTester.java?p2=wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/TagTester.java&p1=wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/TagTester.java&r1=908343&r2=909200&rev=909200&view=diff
==============================================================================
    (empty)

Propchange: wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/TagTester.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/TagTester.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/TestPanelSource.java (from r908343, wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/TestPanelSource.java)
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/TestPanelSource.java?p2=wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/TestPanelSource.java&p1=wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/TestPanelSource.java&r1=908343&r2=909200&rev=909200&view=diff
==============================================================================
    (empty)

Propchange: wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/TestPanelSource.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/TestPanelSource.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/WicketTester.java (from r908343, wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/WicketTester.java)
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/WicketTester.java?p2=wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/WicketTester.java&p1=wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/WicketTester.java&r1=908343&r2=909200&rev=909200&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/WicketTester.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/WicketTester.java Fri Feb 12 01:27:28 2010
@@ -22,8 +22,6 @@
 import java.util.Iterator;
 import java.util.List;
 
-import javax.servlet.http.HttpServletResponse;
-
 import junit.framework.Assert;
 import junit.framework.AssertionFailedError;
 
@@ -34,12 +32,7 @@
 import org.apache.wicket.feedback.FeedbackMessage;
 import org.apache.wicket.markup.html.basic.Label;
 import org.apache.wicket.markup.html.list.ListView;
-import org.apache.wicket.pageStore.IPageStore;
-import org.apache.wicket.protocol.http.MockHttpServletResponse;
-import org.apache.wicket.protocol.http.WebApplication;
-import org.apache.wicket.protocol.http.WebResponse;
-import org.apache.wicket.session.HttpSessionStore;
-import org.apache.wicket.session.ISessionStore;
+import org.apache.wicket.ng.mock.MockApplication;
 import org.apache.wicket.util.diff.DiffUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -158,53 +151,7 @@
  */
 public class WicketTester extends BaseWicketTester
 {
-	/**
-	 * Default dummy web application for testing. Uses {@link HttpSessionStore} to store pages and
-	 * the <code>Session</code>.
-	 */
-	public static class DummyWebApplication extends WebApplication
-	{
-		/**
-		 * @see org.apache.wicket.Application#getHomePage()
-		 */
-		@Override
-		public Class<? extends Page> getHomePage()
-		{
-			return DummyHomePage.class;
-		}
-
-		@Override
-		protected ISessionStore newSessionStore()
-		{
-			// Don't use a filestore, or we spawn lots of threads, which makes
-			// things slow.
-			return new HttpSessionStore();
-		}
-
-		/**
-		 * @see org.apache.wicket.protocol.http.WebApplication#newWebResponse(javax.servlet.http.HttpServletResponse)
-		 */
-		@Override
-		protected WebResponse newWebResponse(final HttpServletResponse servletResponse)
-		{
-			return new WebResponse(servletResponse);
-		}
 
-		@Override
-		protected void outputDevelopmentModeWarning()
-		{
-			// do nothing
-		}
-	}
-
-	/**
-	 * Dummy web application that does not support back button support but is cheaper to use for
-	 * unit tests. Uses {@link SecondLevelCacheSessionStore} with a noop {@link IPageStore}.
-	 */
-	public static class NonPageCachingDummyWebApplication extends DummyWebApplication
-	{
-
-	}
 
 	/** log. */
 	private static final Logger log = LoggerFactory.getLogger(WicketTester.class);
@@ -215,7 +162,6 @@
 	 */
 	public WicketTester()
 	{
-		this(new DummyWebApplication());
 	}
 
 	/**
@@ -226,37 +172,7 @@
 	 */
 	public WicketTester(final Class<? extends Page> homePage)
 	{
-		this(new WebApplication()
-		{
-			/**
-			 * @see org.apache.wicket.Application#getHomePage()
-			 */
-			@Override
-			public Class<? extends Page> getHomePage()
-			{
-				return homePage;
-			}
-
-			@Override
-			protected ISessionStore newSessionStore()
-			{
-				// Don't use a filestore, or we spawn lots of threads, which
-				// makes things slow.
-				return new HttpSessionStore();
-			}
-
-			@Override
-			protected WebResponse newWebResponse(final HttpServletResponse servletResponse)
-			{
-				return new WebResponse(servletResponse);
-			}
-
-			@Override
-			protected void outputDevelopmentModeWarning()
-			{
-				// Do nothing.
-			}
-		});
+		super(homePage);
 	}
 
 	/**
@@ -265,9 +181,9 @@
 	 * @param application
 	 *            a <code>WicketTester</code> <code>WebApplication</code> object
 	 */
-	public WicketTester(final WebApplication application)
+	public WicketTester(final MockApplication application)
 	{
-		this(application, null);
+		super(application);
 	}
 
 	/**
@@ -282,10 +198,10 @@
 	 * @see org.apache.wicket.protocol.http.MockWebApplication#MockWebApplication(org.apache.wicket.protocol.http.WebApplication,
 	 *      String)
 	 */
-	public WicketTester(final WebApplication application, final String path)
-	{
-		super(application, path);
-	}
+// public WicketTester(final WebApplication application, final String path)
+// {
+// super(application, path);
+// }
 
 
 	/**
@@ -293,19 +209,19 @@
 	 */
 	public void assertAjaxLocation()
 	{
-		if (null != ((MockHttpServletResponse)getWicketResponse().getHttpServletResponse()).getRedirectLocation())
+		if (null != getLastResponse().getHeader("Location"))
 		{
 			throw new AssertionFailedError(
 				"Location header should *not* be present when using Ajax");
 		}
 
-		String ajaxLocation = ((MockHttpServletResponse)getWicketResponse().getHttpServletResponse()).getHeader("Ajax-Location");
+		String ajaxLocation = getLastResponse().getHeader("Ajax-Location");
 		if (null == ajaxLocation)
 		{
 			throw new AssertionFailedError("Ajax-Location header should be present when using Ajax");
 		}
 
-		int statusCode = ((MockHttpServletResponse)getWicketResponse().getHttpServletResponse()).getStatus();
+		int statusCode = getLastResponse().getStatus();
 		if (statusCode != 200)
 		{
 			throw new AssertionFailedError("Expected HTTP status code to be 200 (OK)");
@@ -500,7 +416,7 @@
 	@Override
 	public void assertResultPage(final Class<?> clazz, final String filename) throws Exception
 	{
-		String document = getServletResponse().getDocument();
+		String document = getLastResponse().getTextResponse().toString();
 		DiffUtil.validatePage(document, clazz, filename, true);
 	}
 
@@ -515,7 +431,7 @@
 	public void assertResultPage(final String expectedDocument) throws Exception
 	{
 		// Validate the document
-		String document = getServletResponse().getDocument();
+		String document = getLastResponse().getTextResponse().toString();
 		Assert.assertEquals(expectedDocument, document);
 	}
 

Propchange: wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/WicketTester.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/WicketTester.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/WicketTesterHelper.java (from r908343, wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/WicketTesterHelper.java)
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/WicketTesterHelper.java?p2=wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/WicketTesterHelper.java&p1=wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/WicketTesterHelper.java&r1=908343&r2=909200&rev=909200&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/WicketTesterHelper.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/WicketTesterHelper.java Fri Feb 12 01:27:28 2010
@@ -27,6 +27,8 @@
 import org.apache.wicket.IClusterable;
 import org.apache.wicket.Page;
 import org.apache.wicket.Component.IVisitor;
+import org.apache.wicket.ajax.AjaxEventBehavior;
+import org.apache.wicket.behavior.IBehavior;
 import org.apache.wicket.util.string.Strings;
 
 /**
@@ -160,4 +162,33 @@
 		}
 		return lined.toString();
 	}
+
+	public static AjaxEventBehavior findAjaxEventBehavior(Component component, String event)
+	{
+		for (IBehavior behavior : component.getBehaviors())
+		{
+			if (behavior instanceof AjaxEventBehavior)
+			{
+				if (event.equalsIgnoreCase(((AjaxEventBehavior)behavior).getEvent()))
+				{
+					return (AjaxEventBehavior)behavior;
+				}
+			}
+		}
+		return null;
+	}
+
+	public static IBehavior findBehavior(Component component,
+		Class<? extends IBehavior> behaviorClass)
+	{
+		for (IBehavior behavior : component.getBehaviors())
+		{
+			if (behaviorClass.isAssignableFrom(behavior.getClass()))
+			{
+				return behavior;
+			}
+		}
+		return null;
+	}
+
 }

Propchange: wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/WicketTesterHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/WicketTesterHelper.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/package.html (from r908343, wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/package.html)
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/package.html?p2=wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/package.html&p1=wicket/trunk/wicket/src/main/disabled/org/apache/wicket/util/tester/package.html&r1=908343&r2=909200&rev=909200&view=diff
==============================================================================
    (empty)

Propchange: wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/package.html
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/package.html
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: wicket/trunk/wicket/src/test/java/org/apache/wicket/AttributeModifierComponentTest.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/AttributeModifierComponentTest.java?rev=909200&r1=909199&r2=909200&view=diff
==============================================================================
--- wicket/trunk/wicket/src/test/java/org/apache/wicket/AttributeModifierComponentTest.java (original)
+++ wicket/trunk/wicket/src/test/java/org/apache/wicket/AttributeModifierComponentTest.java Fri Feb 12 01:27:28 2010
@@ -72,7 +72,7 @@
 	public void testComponentTagAttributeModification() throws Exception
 	{
 		// Validate the document
-		String document = tester.getServletResponse().getDocument();
+		String document = tester.getLastResponse().getTextResponse().toString();
 		log.info(document);
 		Assert.assertTrue(validateDocument(document));
 	}

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=909200&r1=909199&r2=909200&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 Fri Feb 12 01:27:28 2010
@@ -51,7 +51,6 @@
 	{
 		executeTest(DisabledComponentPage1.class, "DisabledComponentPage1a_result.html");
 		Link link = ((DisabledComponentPage1)tester.getLastRenderedPage()).link;
-		tester.createRequestCycle();
 		link.setEnabled(false);
 		executedListener(DisabledComponentPage1.class, link, "DisabledComponentPage1b_result.html");
 	}

Modified: wicket/trunk/wicket/src/test/java/org/apache/wicket/FeedbackMessagesTest.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/FeedbackMessagesTest.java?rev=909200&r1=909199&r2=909200&view=diff
==============================================================================
--- wicket/trunk/wicket/src/test/java/org/apache/wicket/FeedbackMessagesTest.java (original)
+++ wicket/trunk/wicket/src/test/java/org/apache/wicket/FeedbackMessagesTest.java Fri Feb 12 01:27:28 2010
@@ -17,31 +17,15 @@
 package org.apache.wicket;
 
 import junit.framework.Assert;
-import junit.framework.TestCase;
 
 import org.apache.wicket.feedback.FeedbackMessage;
-import org.apache.wicket.util.tester.WicketTester;
 
 /**
  * @author oli
  */
-public class FeedbackMessagesTest extends TestCase
+public class FeedbackMessagesTest extends WicketTestCase
 {
 
-	WicketTester tester;
-
-	@Override
-	protected void setUp() throws Exception
-	{
-		tester = new WicketTester();
-	}
-
-	@Override
-	protected void tearDown() throws Exception
-	{
-		tester.destroy();
-	}
-
 	/**
 	 * Test method for
 	 * {@link org.apache.wicket.feedback.FeedbackMessages#hasMessageFor(org.apache.wicket.Component, int)}
@@ -49,12 +33,14 @@
 	 */
 	public void testHasMessageForComponentInt()
 	{
-		Session session = tester.setupRequestAndResponse().getSession();
 		final Page page = new TestPage_1();
 		tester.startPage(page);
 		page.debug("debug message");
 		page.info("info message");
 		page.error("error message");
-		Assert.assertTrue(session.getFeedbackMessages().hasMessageFor(page, FeedbackMessage.ERROR));
+		Assert.assertTrue(tester.getLastRenderedPage()
+			.getSession()
+			.getFeedbackMessages()
+			.hasMessageFor(page, FeedbackMessage.ERROR));
 	}
 }

Modified: wicket/trunk/wicket/src/test/java/org/apache/wicket/FormDispatchEventTest.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/FormDispatchEventTest.java?rev=909200&r1=909199&r2=909200&view=diff
==============================================================================
--- wicket/trunk/wicket/src/test/java/org/apache/wicket/FormDispatchEventTest.java (original)
+++ wicket/trunk/wicket/src/test/java/org/apache/wicket/FormDispatchEventTest.java Fri Feb 12 01:27:28 2010
@@ -40,8 +40,6 @@
 	{
 		tester.startPage(MockPageWithForm.class);
 
-		// FIXME should not be needed
-		tester.createRequestCycle();
 
 		FormTester formTester = tester.newFormTester("form");
 		formTester.select("dropdown", 0);

Modified: wicket/trunk/wicket/src/test/java/org/apache/wicket/LocalizerTest.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/LocalizerTest.java?rev=909200&r1=909199&r2=909200&view=diff
==============================================================================
--- wicket/trunk/wicket/src/test/java/org/apache/wicket/LocalizerTest.java (original)
+++ wicket/trunk/wicket/src/test/java/org/apache/wicket/LocalizerTest.java Fri Feb 12 01:27:28 2010
@@ -30,11 +30,9 @@
 import org.apache.wicket.model.IModel;
 import org.apache.wicket.model.Model;
 import org.apache.wicket.model.PropertyModel;
-import org.apache.wicket.resource.DummyApplication;
 import org.apache.wicket.resource.loader.ComponentStringResourceLoader;
 import org.apache.wicket.settings.IResourceSettings;
 import org.apache.wicket.util.string.Strings;
-import org.apache.wicket.util.tester.WicketTester;
 import org.apache.wicket.util.value.ValueMap;
 
 /**
@@ -91,7 +89,7 @@
 	@Override
 	protected void setUp() throws Exception
 	{
-		tester = new WicketTester(new DummyApplication());
+		super.setUp();
 		settings = tester.getApplication().getResourceSettings();
 		localizer = tester.getApplication().getResourceSettings().getLocalizer();
 	}

Modified: wicket/trunk/wicket/src/test/java/org/apache/wicket/PageFactoryTest.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/PageFactoryTest.java?rev=909200&r1=909199&r2=909200&view=diff
==============================================================================
--- wicket/trunk/wicket/src/test/java/org/apache/wicket/PageFactoryTest.java (original)
+++ wicket/trunk/wicket/src/test/java/org/apache/wicket/PageFactoryTest.java Fri Feb 12 01:27:28 2010
@@ -16,6 +16,7 @@
  */
 package org.apache.wicket;
 
+import org.apache.wicket.ng.request.component.PageParameters;
 import org.apache.wicket.session.DefaultPageFactory;
 
 

Modified: wicket/trunk/wicket/src/test/java/org/apache/wicket/PageMarkupLoadingTest.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/PageMarkupLoadingTest.java?rev=909200&r1=909199&r2=909200&view=diff
==============================================================================
--- wicket/trunk/wicket/src/test/java/org/apache/wicket/PageMarkupLoadingTest.java (original)
+++ wicket/trunk/wicket/src/test/java/org/apache/wicket/PageMarkupLoadingTest.java Fri Feb 12 01:27:28 2010
@@ -19,7 +19,6 @@
 import java.util.Locale;
 
 import org.apache.wicket.markup.html.WebPage;
-import org.apache.wicket.protocol.http.WebRequestCycle;
 
 /**
  * Tests markup loading.
@@ -33,9 +32,7 @@
 	 */
 	public void testDefault() throws Exception
 	{
-		tester.setupRequestAndResponse();
-		WebRequestCycle cycle = tester.createRequestCycle();
-		cycle.getSession().setLocale(Locale.ENGLISH);
+		tester.getSession().setLocale(Locale.ENGLISH);
 		tester.startPage(Page1.class);
 		tester.assertRenderedPage(Page1.class);
 		tester.assertResultPage(getClass(), "PageMarkupLoadingTest$Page1_expected.html");
@@ -48,9 +45,7 @@
 	 */
 	public void testDutch() throws Exception
 	{
-		tester.setupRequestAndResponse();
-		WebRequestCycle cycle = tester.createRequestCycle();
-		cycle.getSession().setLocale(new Locale("nl"));
+		tester.getSession().setLocale(new Locale("nl"));
 		tester.startPage(Page1.class);
 		tester.assertRenderedPage(Page1.class);
 		tester.assertResultPage(getClass(), "PageMarkupLoadingTest$Page1_nl_expected.html");
@@ -63,10 +58,8 @@
 	 */
 	public void testDutchMyStyle() throws Exception
 	{
-		tester.setupRequestAndResponse();
-		WebRequestCycle cycle = tester.createRequestCycle();
-		cycle.getSession().setLocale(new Locale("nl"));
-		cycle.getSession().setStyle("mystyle");
+		tester.getSession().setLocale(new Locale("nl"));
+		tester.getSession().setStyle("mystyle");
 		tester.startPage(Page1.class);
 		tester.assertRenderedPage(Page1.class);
 		tester.assertResultPage(getClass(), "PageMarkupLoadingTest$Page1_mystyle_nl_expected.html");
@@ -79,10 +72,8 @@
 	 */
 	public void testDutchMyStyleMyVar() throws Exception
 	{
-		tester.setupRequestAndResponse();
-		WebRequestCycle cycle = tester.createRequestCycle();
-		cycle.getSession().setLocale(new Locale("nl"));
-		cycle.getSession().setStyle("mystyle");
+		tester.getSession().setLocale(new Locale("nl"));
+		tester.getSession().setStyle("mystyle");
 		tester.startPage(Page2.class);
 		tester.assertRenderedPage(Page2.class);
 		tester.assertResultPage(getClass(),

Modified: wicket/trunk/wicket/src/test/java/org/apache/wicket/PageParametersTest.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/PageParametersTest.java?rev=909200&r1=909199&r2=909200&view=diff
==============================================================================
--- wicket/trunk/wicket/src/test/java/org/apache/wicket/PageParametersTest.java (original)
+++ wicket/trunk/wicket/src/test/java/org/apache/wicket/PageParametersTest.java Fri Feb 12 01:27:28 2010
@@ -22,6 +22,8 @@
 
 import junit.framework.TestCase;
 
+import org.apache.wicket.ng.request.component.PageParameters;
+
 /**
  * Unit test for the PageParameters, introduced for bug [ 1213889 ] PageParameter keyValuePair
  * disallows negatives.