Author: freemant
Date: Tue Dec 19 02:57:51 2006
New Revision: 488627

URL: http://svn.apache.org/viewvc?view=rev&rev=488627
Log:
1) Added support for Form submissions in PageTester.
2) Added support for sessions in PageTester.
3) Prayed that Jesse won't kill me :-)

Added:
    
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/FormParameterLookup.java
    
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/SessionHolder.java
    
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/pagelevel/FormParameterLookupForPageTester.java
    
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/pagelevel/SessionForPageTester.java
    
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/pagelevel/SessionHolderForPageTester.java
    
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app2/pages/TestPageForForm.java
    
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/pagelevel/FormTest.java
    
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/test/
    
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/test/pagelevel/
    
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/test/pagelevel/SessionForPageTesterTest.java
    
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/test/pagelevel/SessionHolderForPageTesterTest.java
    
tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app2/pages/TestPageForForm.html
Modified:
    
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/base/AbstractField.java
    
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/Checkbox.java
    
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/Form.java
    
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/TextArea.java
    
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/TextField.java
    
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/Element.java
    
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/InAppInvocationMap.java
    
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/InternalModule.java
    
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/NoOpInAppInvocationMap.java
    
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/SessionPersistentFieldStrategy.java
    
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/Request.java
    
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/TapestryModule.java
    
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/pagelevel/InAppInvocationMapForPageTester.java
    
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/pagelevel/PageTester.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/conf/testng.xml

Modified: 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/base/AbstractField.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/base/AbstractField.java?view=diff&rev=488627&r1=488626&r2=488627
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/base/AbstractField.java
 (original)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/base/AbstractField.java
 Tue Dec 19 02:57:51 2006
@@ -28,10 +28,10 @@
 import org.apache.tapestry.annotations.PostBeginRender;
 import org.apache.tapestry.annotations.SetupRender;
 import org.apache.tapestry.corelib.mixins.RenderInformals;
+import org.apache.tapestry.internal.services.FormParameterLookup;
 import org.apache.tapestry.ioc.internal.util.InternalUtils;
 import org.apache.tapestry.services.FormSupport;
 import org.apache.tapestry.services.PageRenderSupport;
-import org.apache.tapestry.services.Request;
 
 /**
  * Provides initialization of the clientId and elementName properties. In 
addition, adds the
@@ -97,8 +97,8 @@
     @Inject
     private ComponentResources _resources;
 
-    @Inject("infrastructure:Request")
-    private Request _request;
+    @Inject("service:tapestry.internal.FormParameterLookup")
+    private FormParameterLookup _paramLookup;
 
     @SetupRender
     final void setup()
@@ -145,7 +145,7 @@
     private final void processSubmission()
     {
         if (!_disabled)
-            processSubmission(_request, _elementName);
+            processSubmission(_paramLookup, _elementName);
     }
 
     /**
@@ -153,13 +153,15 @@
      * form. The element's elementName property will already have been set. 
This method is only
      * invoked if the field is <strong>not [EMAIL PROTECTED] #isDisabled() 
disabled}</strong>.
      * 
-     * @param request
-     *            the current request, presumably so that the component may 
extract a quert
-     *            parameter value that matches the component's element name.
+     * @param paramLookup
+     *            an object providing lookup access to form parameters, 
presumably so that the
+     *            component may extract a quert parameter value that matches 
the component's element
+     *            name. Usually this object is the current request but could 
be a mocked object if
+     *            the app is driven by a [EMAIL PROTECTED] 
org.apache.tapestry.test.pagelevel.PageTester}.
      * @param elementName
      *            the name of the element (used to find the correct parameter 
in the request)
      */
-    protected abstract void processSubmission(Request request, String 
elementName);
+    protected abstract void processSubmission(FormParameterLookup paramLookup, 
String elementName);
 
     public final String getLabel()
     {

Modified: 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/Checkbox.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/Checkbox.java?view=diff&rev=488627&r1=488626&r2=488627
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/Checkbox.java
 (original)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/Checkbox.java
 Tue Dec 19 02:57:51 2006
@@ -19,7 +19,7 @@
 import org.apache.tapestry.annotations.BeginRender;
 import org.apache.tapestry.annotations.Parameter;
 import org.apache.tapestry.corelib.base.AbstractField;
-import org.apache.tapestry.services.Request;
+import org.apache.tapestry.internal.services.FormParameterLookup;
 
 /** A Checkbox coponent is simply a &lt;input type="checkbox"&gt;. */
 public class Checkbox extends AbstractField
@@ -50,9 +50,9 @@
     }
 
     @Override
-    protected void processSubmission(Request request, String elementName)
+    protected void processSubmission(FormParameterLookup paramLookup, String 
elementName)
     {
-        String postedValue = request.getParameter(elementName);
+        String postedValue = paramLookup.getParameter(elementName);
 
         _value = postedValue != null;
     }

Modified: 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/Form.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/Form.java?view=diff&rev=488627&r1=488626&r2=488627
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/Form.java
 (original)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/Form.java
 Tue Dec 19 02:57:51 2006
@@ -36,6 +36,10 @@
 import org.apache.tapestry.annotations.SetupRender;
 import org.apache.tapestry.corelib.mixins.RenderInformals;
 import org.apache.tapestry.dom.Element;
+import org.apache.tapestry.internal.services.FormParameterLookup;
+import org.apache.tapestry.internal.services.InAppInvocationMap;
+import org.apache.tapestry.internal.services.InAppInvocationPathSource;
+import org.apache.tapestry.internal.services.LinkImpl;
 import org.apache.tapestry.internal.util.Base64ObjectInputStream;
 import org.apache.tapestry.internal.util.Base64ObjectOutputStream;
 import org.apache.tapestry.runtime.Component;
@@ -43,7 +47,6 @@
 import org.apache.tapestry.services.Environment;
 import org.apache.tapestry.services.FormSupport;
 import org.apache.tapestry.services.PageRenderSupport;
-import org.apache.tapestry.services.Request;
 
 /**
  * An HTML form, which will enclose other components to render out the various 
types of fields.
@@ -95,12 +98,15 @@
     @Environmental
     private PageRenderSupport _pageRenderSupport;
 
-    @Inject("infrastructure:Request")
-    private Request _request;
+    @Inject("service:tapestry.internal.FormParameterLookup")
+    private FormParameterLookup _paramLookup;
 
     @Inject("infrastructure:ComponentSource")
     private ComponentSource _source;
 
+    @Inject("service:tapestry.internal.InAppInvocationMap")
+    private InAppInvocationMap _invocationMap;
+
     // Collects a stream of component actions. Each action goes in as a UTF 
string (the component
     // component id),
     // followed by a ComponentAction
@@ -149,9 +155,13 @@
 
         Link link = 
_resources.createActionLink(TapestryConstants.DEFAULT_EVENT, true, 
contextArray);
 
-        writer.element("form", "name", name, "id", name, "method", "post", 
"action", link
+        Element element = writer.element("form", "name", name, "id", name, 
"method", "post", "action", link
                 .toFormURI());
 
+        // Allow the PageTester to extract the invocation object to invoke it 
later.
+        _invocationMap.put(element, ((InAppInvocationPathSource) ((LinkImpl) 
link).getPathSource())
+                .getInvocation());
+        
         // TODO: Informal parameters
 
         _div = writer.element("div", "style", "invisible");
@@ -201,7 +211,7 @@
 
         // TODO: Ajax stuff will eventually mean there are multiple values for 
this parameter name
 
-        String actionsBase64 = _request.getParameter(FORM_DATA);
+        String actionsBase64 = _paramLookup.getParameter(FORM_DATA);
 
         try
         {

Modified: 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/TextArea.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/TextArea.java?view=diff&rev=488627&r1=488626&r2=488627
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/TextArea.java
 (original)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/TextArea.java
 Tue Dec 19 02:57:51 2006
@@ -20,7 +20,7 @@
 import org.apache.tapestry.annotations.BeginRender;
 import org.apache.tapestry.annotations.Parameter;
 import org.apache.tapestry.corelib.base.AbstractField;
-import org.apache.tapestry.services.Request;
+import org.apache.tapestry.internal.services.FormParameterLookup;
 
 /**
  * TextArea component corresponds to a &lt;textarea&gt;. The value parameter 
is almost always bound
@@ -57,9 +57,9 @@
     }
 
     @Override
-    protected void processSubmission(Request request, String elementName)
+    protected void processSubmission(FormParameterLookup paramLookup, String 
elementName)
     {
-        _value = request.getParameter(elementName);
+        _value = paramLookup.getParameter(elementName);
     }
 
 }

Modified: 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/TextField.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/TextField.java?view=diff&rev=488627&r1=488626&r2=488627
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/TextField.java
 (original)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/TextField.java
 Tue Dec 19 02:57:51 2006
@@ -19,7 +19,7 @@
 import org.apache.tapestry.annotations.BeginRender;
 import org.apache.tapestry.annotations.Parameter;
 import org.apache.tapestry.corelib.base.AbstractField;
-import org.apache.tapestry.services.Request;
+import org.apache.tapestry.internal.services.FormParameterLookup;
 
 /**
  * TextField component corresponds to &lt;input type="text"&gt;. The value 
parameter will be
@@ -53,9 +53,9 @@
     }
 
     @Override
-    protected void processSubmission(Request request, String elementName)
+    protected void processSubmission(FormParameterLookup paramLookup, String 
elementName)
     {
-        _value = request.getParameter(elementName);
+        _value = paramLookup.getParameter(elementName);
     }
 
 }

Modified: 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/Element.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/Element.java?view=diff&rev=488627&r1=488626&r2=488627
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/Element.java
 (original)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/Element.java
 Tue Dec 19 02:57:51 2006
@@ -229,4 +229,8 @@
         return _attributes.get(attributeName);
     }
 
+    public String getName()
+    {
+        return _name;
+    }
 }

Added: 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/FormParameterLookup.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/FormParameterLookup.java?view=auto&rev=488627
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/FormParameterLookup.java
 (added)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/FormParameterLookup.java
 Tue Dec 19 02:57:51 2006
@@ -0,0 +1,25 @@
+// Copyright 2006 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry.internal.services;
+
+public interface FormParameterLookup
+{
+    /**
+     * Returns the query parameter value for the given name. Returns null if 
no such parameter is in
+     * the request. For a multi-valued parameter, returns just the first value.
+     */
+    String getParameter(String name);
+
+}

Modified: 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/InAppInvocationMap.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/InAppInvocationMap.java?view=diff&rev=488627&r1=488626&r2=488627
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/InAppInvocationMap.java
 (original)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/InAppInvocationMap.java
 Tue Dec 19 02:57:51 2006
@@ -16,11 +16,10 @@
 
 import org.apache.tapestry.dom.Element;
 
+/**
+ * Associates an in-app invocation object with an element (usually an action 
link or a form).
+ */
 public interface InAppInvocationMap
 {
-    void clear();
-
-    void put(Element link, InAppInvocation invocation);
-
-    InAppInvocation get(Element link);
+    void put(Element element, InAppInvocation invocation);
 }

Modified: 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/InternalModule.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/InternalModule.java?view=diff&rev=488627&r1=488626&r2=488627
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/InternalModule.java
 (original)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/InternalModule.java
 Tue Dec 19 02:57:51 2006
@@ -556,7 +556,7 @@
     /**
      * It is a map from a [EMAIL PROTECTED] org.apache.tapestry.dom.Element} 
to a [EMAIL PROTECTED] InAppInvocation}
      * Components rendering a link element that is intended to be "clickable" 
by the
-     * [EMAIL PROTECTED] org.apache.tapestry.test.pagelevel.PageTester} must 
map that element to an 
+     * [EMAIL PROTECTED] org.apache.tapestry.test.pagelevel.PageTester} must 
map that element to an
      * InAppInvocation so that the PageTester can find it.
      * <p>
      * By default (production mode), the map does nothing.
@@ -564,5 +564,15 @@
     public static InAppInvocationMap buildInAppInvocationMap()
     {
         return new NoOpInAppInvocationMap();
+    }
+
+    public FormParameterLookup buildFormParameterLookup()
+    {
+        return _request;
+    }
+
+    public SessionHolder buildSessionHolder()
+    {
+        return _request;
     }
 }

Modified: 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/NoOpInAppInvocationMap.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/NoOpInAppInvocationMap.java?view=diff&rev=488627&r1=488626&r2=488627
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/NoOpInAppInvocationMap.java
 (original)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/NoOpInAppInvocationMap.java
 Tue Dec 19 02:57:51 2006
@@ -16,22 +16,16 @@
 
 import org.apache.tapestry.dom.Element;
 
+/**
+ * The production implementation for InAppInvocationMap. It does absolutely 
nothing because it is
+ * not needed in production.
+ */
 public class NoOpInAppInvocationMap implements InAppInvocationMap
 {
 
-    public void clear()
+    public void put(Element element, InAppInvocation invocation)
     {
-        
-    }
 
-    public void put(Element link, InAppInvocation invocation)
-    {
-        
-    }
-
-    public InAppInvocation get(Element link)
-    {
-        return null;
     }
 
 }

Added: 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/SessionHolder.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/SessionHolder.java?view=auto&rev=488627
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/SessionHolder.java
 (added)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/SessionHolder.java
 Tue Dec 19 02:57:51 2006
@@ -0,0 +1,31 @@
+// Copyright 2006 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry.internal.services;
+
+import org.apache.tapestry.services.Session;
+
+public interface SessionHolder
+{
+    /**
+     * Gets the [EMAIL PROTECTED] Session}. If create is false and the session 
has not be created
+     * previously, returns null.
+     * 
+     * @param create
+     *            true to force the creation of the session
+     * @return the session (or null if create is false the session has not 
been previously created)
+     */
+    Session getSession(boolean create);
+
+}

Modified: 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/SessionPersistentFieldStrategy.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/SessionPersistentFieldStrategy.java?view=diff&rev=488627&r1=488626&r2=488627
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/SessionPersistentFieldStrategy.java
 (original)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/SessionPersistentFieldStrategy.java
 Tue Dec 19 02:57:51 2006
@@ -16,15 +16,14 @@
 
 import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newList;
 import static org.apache.tapestry.ioc.internal.util.Defense.notBlank;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.tapestry.services.PersistentFieldChange;
-import org.apache.tapestry.services.PersistentFieldStrategy;
-import org.apache.tapestry.services.Request;
-import org.apache.tapestry.services.Session;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.tapestry.services.PersistentFieldChange;
+import org.apache.tapestry.services.PersistentFieldStrategy;
+import org.apache.tapestry.services.Session;
 
 /**
  * A strategy for storing persistent page properties into the [EMAIL 
PROTECTED] Session session}.
@@ -40,17 +39,17 @@
      * field data.
      */
     public static final String PREFIX = "state:";
+
+    private final SessionHolder _sessionHolder;
 
-    private final Request _request;
-
-    public SessionPersistentFieldStrategy(final Request request)
+    public SessionPersistentFieldStrategy(final SessionHolder sessionHolder)
     {
-        _request = request;
+        _sessionHolder = sessionHolder;
     }
 
     public Collection<PersistentFieldChange> gatherFieldChanges(String 
pageName)
     {
-        Session session = _request.getSession(false);
+        Session session = _sessionHolder.getSession(false);
 
         if (session == null)
             return Collections.emptyList();
@@ -96,7 +95,7 @@
         builder.append(':');
         builder.append(fieldName);
 
-        Session session = _request.getSession(true);
+        Session session = _sessionHolder.getSession(true);
 
         session.setAttribute(builder.toString(), newValue);
     }

Modified: 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/Request.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/Request.java?view=diff&rev=488627&r1=488626&r2=488627
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/Request.java
 (original)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/Request.java
 Tue Dec 19 02:57:51 2006
@@ -18,23 +18,19 @@
 import java.util.Locale;
 
 import org.apache.tapestry.internal.services.ContextPathSource;
+import org.apache.tapestry.internal.services.FormParameterLookup;
+import org.apache.tapestry.internal.services.SessionHolder;
 
 /**
  * Generic version of [EMAIL PROTECTED] 
javax.servlet.http.HttpServletRequest}, used to encapsulate the
  * Servlet API version, and to help bridge the differences between Servlet API 
and Porlet API.
  */
-public interface Request extends ContextPathSource
+public interface Request extends ContextPathSource, FormParameterLookup, 
SessionHolder
 {
     /** Returns a list of query parameter names, in alphabetical order. */
     List<String> getParameterNames();
 
     /**
-     * Returns the query parameter value for the given name. Returns null if 
no such parameter is in
-     * the request. For a multi-valued parameter, returns just the first value.
-     */
-    String getParameter(String name);
-
-    /**
      * Returns the parameter values for the given name. Returns null if no 
such parameter is in the
      * request.
      */
@@ -47,16 +43,6 @@
      * @return
      */
     String getPath();
-
-    /**
-     * Gets the [EMAIL PROTECTED] Session}. If create is false and the session 
has not be created
-     * previously, returns null.
-     * 
-     * @param create
-     *            true to force the creation of the session
-     * @return the session (or null if create is false the session has not 
been previously created)
-     */
-    Session getSession(boolean create);
 
     /** Returns the locale of the client as determined from the request 
headers. */
     Locale getLocale();

Modified: 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/TapestryModule.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/TapestryModule.java?view=diff&rev=488627&r1=488626&r2=488627
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/TapestryModule.java
 (original)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/TapestryModule.java
 Tue Dec 19 02:57:51 2006
@@ -93,6 +93,7 @@
 import org.apache.tapestry.internal.services.ResourceStreamer;
 import org.apache.tapestry.internal.services.ResponseImpl;
 import org.apache.tapestry.internal.services.RetainWorker;
+import org.apache.tapestry.internal.services.SessionHolder;
 import org.apache.tapestry.internal.services.SessionPersistentFieldStrategy;
 import org.apache.tapestry.internal.services.StaticFilesFilter;
 import org.apache.tapestry.internal.services.StringEventHandler;
@@ -755,9 +756,11 @@
      * Contributes the "session" strategy.
      */
     public void contributePersistentFieldManager(
-            MappedConfiguration<String, PersistentFieldStrategy> configuration)
+            MappedConfiguration<String, PersistentFieldStrategy> configuration,
+            @InjectService("tapestry.internal.SessionHolder")
+            SessionHolder sessionHolder)
     {
-        configuration.add("session", new 
SessionPersistentFieldStrategy(_request));
+        configuration.add("session", new 
SessionPersistentFieldStrategy(sessionHolder));
     }
 
     public ComponentSource buildComponentSource(

Added: 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/pagelevel/FormParameterLookupForPageTester.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/pagelevel/FormParameterLookupForPageTester.java?view=auto&rev=488627
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/pagelevel/FormParameterLookupForPageTester.java
 (added)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/pagelevel/FormParameterLookupForPageTester.java
 Tue Dec 19 02:57:51 2006
@@ -0,0 +1,52 @@
+// Copyright 2006 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry.test.pagelevel;
+
+import java.util.Map;
+
+import org.apache.tapestry.internal.services.FormParameterLookup;
+import org.apache.tapestry.ioc.internal.util.CollectionFactory;
+import org.apache.tapestry.ioc.internal.util.Defense;
+
+public class FormParameterLookupForPageTester implements FormParameterLookup
+{
+
+    private Map<String, String> _fieldValues = CollectionFactory.newMap();
+
+    public String getParameter(String name)
+    {
+        return _fieldValues.get(name);
+    }
+
+    public void addFieldValues(Map<String, String> fieldValues)
+    {
+        Defense.notNull(fieldValues, "fieldValues");
+        _fieldValues.putAll(fieldValues);
+
+    }
+
+    public void addFieldValue(String name, String value)
+    {
+        Defense.notBlank(name, "name");
+        Defense.notNull(value, "value");
+        _fieldValues.put(name, value);
+    }
+
+    public void clear()
+    {
+        _fieldValues.clear();
+    }
+
+}

Modified: 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/pagelevel/InAppInvocationMapForPageTester.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/pagelevel/InAppInvocationMapForPageTester.java?view=diff&rev=488627&r1=488626&r2=488627
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/pagelevel/InAppInvocationMapForPageTester.java
 (original)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/pagelevel/InAppInvocationMapForPageTester.java
 Tue Dec 19 02:57:51 2006
@@ -31,14 +31,14 @@
         map.clear();
     }
 
-    public void put(Element link, InAppInvocation invocation)
+    public void put(Element element, InAppInvocation invocation)
     {
-        map.put(link, invocation);
+        map.put(element, invocation);
     }
 
-    public InAppInvocation get(Element link)
+    public InAppInvocation get(Element element)
     {
-        return map.get(link);
+        return map.get(element);
     }
 
 }

Modified: 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/pagelevel/PageTester.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/pagelevel/PageTester.java?view=diff&rev=488627&r1=488626&r2=488627
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/pagelevel/PageTester.java
 (original)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/pagelevel/PageTester.java
 Tue Dec 19 02:57:51 2006
@@ -12,148 +12,207 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package org.apache.tapestry.test.pagelevel;
-
-import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newMap;
-
-import java.util.Collections;
-import java.util.Map;
-
-import org.apache.tapestry.dom.Document;
-import org.apache.tapestry.dom.Element;
-import org.apache.tapestry.internal.TapestryAppInitializer;
-import org.apache.tapestry.internal.services.ActionLinkInvocation;
-import org.apache.tapestry.internal.services.InAppInvocation;
-import org.apache.tapestry.internal.services.InAppInvocationMap;
-import org.apache.tapestry.internal.services.PageLinkInvocation;
-import org.apache.tapestry.ioc.Registry;
-import org.apache.tapestry.ioc.internal.util.Defense;
-import org.apache.tapestry.ioc.util.StrategyRegistry;
-
-/**
- * This class is used to run a Tapestry app in an in-process testing 
environment. You can ask it to
- * render a certain page and check the DOM object created. You can also ask it 
to click on a link
- * element in the DOM object to get the next page. Because no servlet 
container is required, it is
- * very fast and you can directly debug into your code in your IDE.
- */
-public class PageTester implements InAppInvoker
-{
-    private Registry _registry;
-
-    private InAppInvocationMap _invocationMap;
-
-    private StrategyRegistry<InAppInvoker> _invokerRegistry;
-
-    /**
-     * Initializes a PageTester without overriding any services.
-     * 
-     * @see #PageTester(String, String, Map)
-     */
-    @SuppressWarnings("unchecked")
-    public PageTester(String appPackage, String appName)
-    {
-        this(appPackage, appName, Collections.EMPTY_MAP);
-    }
-
-    /**
-     * @param appPackage
-     *            The same value you would specify using the 
tapestry.app-package context parameter.
-     *            As this testing environment is not run in a servlet 
container, you need to specify
-     *            it.
-     * @param appName
-     *            The same value you would specify as the filter name. It is 
used to form the name
-     *            of the module builder for your app. If you don't have one, 
pass an empty string.
-     * @param serviceOverrides
-     *            The mock implementation (value) for some services (key).
-     */
-    public PageTester(String appPackage, String appName, Map<String, Object> 
serviceOverrides)
-    {
-        _registry = new TapestryAppInitializer(appPackage, appName, "test",
-                addDefaultOverrides(serviceOverrides)).getRegistry();
-        buildInvokersRegistry();
-    }
-
-    private void buildInvokersRegistry()
-    {
-        Map<Class, InAppInvoker> map = newMap();
-        map.put(PageLinkInvocation.class, new PageLinkInvoker(_registry));
-        map.put(ActionLinkInvocation.class, new ActionLinkInvoker(_registry, 
this));
-        _invokerRegistry = new 
StrategyRegistry<InAppInvoker>(InAppInvoker.class, map);
-    }
-
-    private Map<String, Object> addDefaultOverrides(Map<String, Object> 
serviceOverrides)
-    {
-        _invocationMap = new InAppInvocationMapForPageTester();
-        Map<String, Object> modifiedOverrides = newMap(serviceOverrides);
-        addDefaultOverride(
-                modifiedOverrides,
-                "tapestry.internal.ContextPathSource",
-                new FooContextPathSource());
-        addDefaultOverride(modifiedOverrides, "tapestry.internal.URLEncoder", 
new NoOpURLEncoder());
-        addDefaultOverride(
-                modifiedOverrides,
-                "tapestry.internal.InAppInvocationMap",
-                _invocationMap);
-        return modifiedOverrides;
-    }
-
-    private void addDefaultOverride(Map<String, Object> serviceOverrides, 
String serviceId,
-            Object overridingImpl)
-    {
-        if (!serviceOverrides.containsKey(serviceId))
-        {
-            serviceOverrides.put(serviceId, overridingImpl);
-        }
-
-    }
-
-    /** You should call it after use */
-    public void shutdown()
-    {
-        if (_registry != null)
-        {
-            _registry.shutdown();
-        }
-    }
-
-    /**
-     * Renders a page specified by its name.
-     * 
-     * @param pageName
-     *            The name of the page to be rendered.
-     * @return The DOM created. Typically you will assert against it.
-     */
-    public Document renderPage(String pageName)
-    {
-        return invoke(new PageLinkInvocation(pageName, new Object[0]));
-    }
-
-    /**
-     * Simulates a click on a link.
-     * 
-     * @param link
-     *            The Link object to be "clicked" on.
-     * @return The DOM created. Typically you will assert against it.
-     */
-    public Document clickLink(Element link)
-    {
-        Defense.notNull(link, "link");
-        InAppInvocation invocation = _invocationMap.get(link);
-        if (invocation == null)
-        {
-            throw new IllegalArgumentException(
-                    "No in-app invocation object is associated with the 
Element");
-        }
-        return invoke(invocation);
-    }
-
-    public Document invoke(InAppInvocation invocation)
-    {
-        // It is critical to clear the map before invoking an invocation 
(render a page or click a
-        // link).
-        _invocationMap.clear();
-        InAppInvoker invoker = _invokerRegistry.getByInstance(invocation);
-        return invoker.invoke(invocation);
-    }
-
-}
+package org.apache.tapestry.test.pagelevel;
+
+import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newMap;
+
+import java.util.Collections;
+import java.util.Map;
+
+import org.apache.tapestry.dom.Document;
+import org.apache.tapestry.dom.Element;
+import org.apache.tapestry.dom.Node;
+import org.apache.tapestry.internal.TapestryAppInitializer;
+import org.apache.tapestry.internal.services.ActionLinkInvocation;
+import org.apache.tapestry.internal.services.InAppInvocation;
+import org.apache.tapestry.internal.services.PageLinkInvocation;
+import org.apache.tapestry.ioc.Registry;
+import org.apache.tapestry.ioc.internal.util.Defense;
+import org.apache.tapestry.ioc.util.StrategyRegistry;
+
+/**
+ * This class is used to run a Tapestry app in an in-process testing 
environment. You can ask it to
+ * render a certain page and check the DOM object created. You can also ask it 
to click on a link
+ * element in the DOM object to get the next page. Because no servlet 
container is required, it is
+ * very fast and you can directly debug into your code in your IDE.
+ */
+public class PageTester implements InAppInvoker
+{
+    private Registry _registry;
+
+    private InAppInvocationMapForPageTester _invocationMap;
+
+    private FormParameterLookupForPageTester _formParameterLookup;
+
+    // For the moment, a page tester instance works in a single session.
+    private SessionHolderForPageTester _sessionHolder;
+
+    private StrategyRegistry<InAppInvoker> _invokerRegistry;
+
+    /**
+     * Initializes a PageTester without overriding any services.
+     * 
+     * @see #PageTester(String, String, Map)
+     */
+    @SuppressWarnings("unchecked")
+    public PageTester(String appPackage, String appName)
+    {
+        this(appPackage, appName, Collections.EMPTY_MAP);
+    }
+
+    /**
+     * @param appPackage
+     *            The same value you would specify using the 
tapestry.app-package context parameter.
+     *            As this testing environment is not run in a servlet 
container, you need to specify
+     *            it.
+     * @param appName
+     *            The same value you would specify as the filter name. It is 
used to form the name
+     *            of the module builder for your app. If you don't have one, 
pass an empty string.
+     * @param serviceOverrides
+     *            The mock implementation (value) for some services (key).
+     */
+    public PageTester(String appPackage, String appName, Map<String, Object> 
serviceOverrides)
+    {
+        _registry = new TapestryAppInitializer(appPackage, appName, "test",
+                addDefaultOverrides(serviceOverrides)).getRegistry();
+        buildInvokersRegistry();
+    }
+
+    private void buildInvokersRegistry()
+    {
+        Map<Class, InAppInvoker> map = newMap();
+        map.put(PageLinkInvocation.class, new PageLinkInvoker(_registry));
+        map.put(ActionLinkInvocation.class, new ActionLinkInvoker(_registry, 
this));
+        _invokerRegistry = new 
StrategyRegistry<InAppInvoker>(InAppInvoker.class, map);
+    }
+
+    private Map<String, Object> addDefaultOverrides(Map<String, Object> 
serviceOverrides)
+    {
+        _invocationMap = new InAppInvocationMapForPageTester();
+        _formParameterLookup = new FormParameterLookupForPageTester();
+        _sessionHolder = new SessionHolderForPageTester();
+        Map<String, Object> modifiedOverrides = newMap(serviceOverrides);
+        addDefaultOverride(
+                modifiedOverrides,
+                "tapestry.internal.ContextPathSource",
+                new FooContextPathSource());
+        addDefaultOverride(modifiedOverrides, "tapestry.internal.URLEncoder", 
new NoOpURLEncoder());
+        addDefaultOverride(
+                modifiedOverrides,
+                "tapestry.internal.InAppInvocationMap",
+                _invocationMap);
+        addDefaultOverride(
+                modifiedOverrides,
+                "tapestry.internal.FormParameterLookup",
+                _formParameterLookup);
+        addDefaultOverride(modifiedOverrides, 
"tapestry.internal.SessionHolder", _sessionHolder);
+        return modifiedOverrides;
+    }
+
+    private void addDefaultOverride(Map<String, Object> serviceOverrides, 
String serviceId,
+            Object overridingImpl)
+    {
+        if (!serviceOverrides.containsKey(serviceId))
+        {
+            serviceOverrides.put(serviceId, overridingImpl);
+        }
+
+    }
+
+    /** You should call it after use */
+    public void shutdown()
+    {
+        if (_registry != null)
+        {
+            _registry.shutdown();
+        }
+    }
+
+    /**
+     * Renders a page specified by its name.
+     * 
+     * @param pageName
+     *            The name of the page to be rendered.
+     * @return The DOM created. Typically you will assert against it.
+     */
+    public Document renderPage(String pageName)
+    {
+        return invoke(new PageLinkInvocation(pageName, new Object[0]));
+    }
+
+    /**
+     * Simulates a click on a link.
+     * 
+     * @param link
+     *            The Link object to be "clicked" on.
+     * @return The DOM created. Typically you will assert against it.
+     */
+    public Document clickLink(Element link)
+    {
+        Defense.notNull(link, "link");
+        InAppInvocation invocation = getInvocation(link);
+        return invoke(invocation);
+    }
+
+    private InAppInvocation getInvocation(Element element)
+    {
+        InAppInvocation invocation = _invocationMap.get(element);
+        if (invocation == null)
+        {
+            throw new IllegalArgumentException(
+                    "No in-app invocation object is associated with the 
Element");
+        }
+        return invocation;
+    }
+
+    public Document invoke(InAppInvocation invocation)
+    {
+        // It is critical to clear the map before invoking an invocation 
(render a page or click a
+        // link).
+        _invocationMap.clear();
+        InAppInvoker invoker = _invokerRegistry.getByInstance(invocation);
+        return invoker.invoke(invocation);
+    }
+
+    /**
+     * Simulates a submission of the form specified. The caller can specify 
values for the form
+     * fields.
+     * 
+     * @param form
+     *            the form to be submitted.
+     * @param fieldValues
+     *            the field values keyed on field names.
+     * @return The DOM created. Typically you will assert against it.
+     */
+    public Document submitForm(Element form, Map<String, String> fieldValues)
+    {
+        Defense.notNull(form, "form");
+        _formParameterLookup.clear();
+        _formParameterLookup.addFieldValues(fieldValues);
+        addHiddenFormFields(form);
+        InAppInvocation invocation = getInvocation(form);
+        return invoke(invocation);
+    }
+
+    private void addHiddenFormFields(Element element)
+    {
+        if (isHiddenFormField(element))
+        {
+            _formParameterLookup.addFieldValue(element.getAttribute("name"), 
element
+                    .getAttribute("value"));
+        }
+        for (Node child : element.getChildren())
+        {
+            if (child instanceof Element)
+            {
+                addHiddenFormFields((Element) child);
+            }
+        }
+
+    }
+
+    private boolean isHiddenFormField(Element element)
+    {
+        return element.getName().equals("input") && 
"hidden".equals(element.getAttribute("type"));
+    }
+}

Added: 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/pagelevel/SessionForPageTester.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/pagelevel/SessionForPageTester.java?view=auto&rev=488627
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/pagelevel/SessionForPageTester.java
 (added)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/pagelevel/SessionForPageTester.java
 Tue Dec 19 02:57:51 2006
@@ -0,0 +1,51 @@
+package org.apache.tapestry.test.pagelevel;
+
+import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newList;
+import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newMap;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tapestry.ioc.internal.util.InternalUtils;
+import org.apache.tapestry.services.Session;
+
+public class SessionForPageTester implements Session
+{
+    private Map<String, Object> attributes = newMap();
+
+    public List<String> getAttributeNames()
+    {
+        return InternalUtils.sortedKeys(attributes);
+    }
+
+    public List<String> getAttributeNames(String prefix)
+    {
+        List<String> result = newList();
+
+        for (String name : getAttributeNames())
+        {
+            if (name.startsWith(prefix))
+                result.add(name);
+        }
+        return result;
+    }
+
+    public Object getAttribute(String name)
+    {
+        return attributes.get(name);
+    }
+
+    public void setAttribute(String name, Object value)
+    {
+        if (value == null)
+        {
+            attributes.remove(name);
+        }
+        else
+        {
+            attributes.put(name, value);
+        }
+
+    }
+
+}

Added: 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/pagelevel/SessionHolderForPageTester.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/pagelevel/SessionHolderForPageTester.java?view=auto&rev=488627
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/pagelevel/SessionHolderForPageTester.java
 (added)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/pagelevel/SessionHolderForPageTester.java
 Tue Dec 19 02:57:51 2006
@@ -0,0 +1,24 @@
+package org.apache.tapestry.test.pagelevel;
+
+import org.apache.tapestry.internal.services.SessionHolder;
+import org.apache.tapestry.services.Session;
+
+public class SessionHolderForPageTester implements SessionHolder
+{
+    private Session _session;
+
+    public Session getSession(boolean create)
+    {
+        if (_session != null)
+        {
+            return _session;
+        }
+        if (!create)
+        {
+            return null;
+        }
+        _session = new SessionForPageTester();
+        return _session;
+    }
+
+}

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/conf/testng.xml
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/conf/testng.xml?view=diff&rev=488627&r1=488626&r2=488627
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/conf/testng.xml (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/conf/testng.xml Tue Dec 19 
02:57:51 2006
@@ -18,6 +18,7 @@
 <suite name="Tapestry Core" parallel="false" thread-count="10" 
annotations="1.5" verbose="2">
   <test name="Tapestry Core">
     <packages>
+      <package name="org.apache.tapestry.test.pagelevel"/>
       <package name="org.apache.tapestry.integration.pagelevel"/>
       <package name="org.apache.tapestry.integration"/>
       <package name="org.apache.tapestry"/>

Added: 
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app2/pages/TestPageForForm.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app2/pages/TestPageForForm.java?view=auto&rev=488627
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app2/pages/TestPageForForm.java
 (added)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app2/pages/TestPageForForm.java
 Tue Dec 19 02:57:51 2006
@@ -0,0 +1,35 @@
+// Copyright 2006 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry.integration.app2.pages;
+
+import org.apache.tapestry.annotations.ComponentClass;
+import org.apache.tapestry.annotations.Persist;
+
[EMAIL PROTECTED]
+public class TestPageForForm
+{
+    @Persist
+    private String value;
+    
+    public String getValue()
+    {
+        return value;
+    }
+
+    public void setValue(String value)
+    {
+        this.value = value;
+    }
+}

Added: 
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/pagelevel/FormTest.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/pagelevel/FormTest.java?view=auto&rev=488627
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/pagelevel/FormTest.java
 (added)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/pagelevel/FormTest.java
 Tue Dec 19 02:57:51 2006
@@ -0,0 +1,51 @@
+// Copyright 2006 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry.integration.pagelevel;
+
+import java.util.Map;
+
+import org.apache.tapestry.dom.Document;
+import org.apache.tapestry.dom.Element;
+import org.apache.tapestry.ioc.internal.util.CollectionFactory;
+import org.apache.tapestry.test.pagelevel.PageTester;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+public class FormTest extends Assert
+{
+    private PageTester _tester;
+
+    @Test
+    public void submit_form()
+    {
+        String appPackage = "org.apache.tapestry.integration.app2";
+        String appName = "";
+        _tester = new PageTester(appPackage, appName);
+        Document doc = _tester.renderPage("TestPageForForm");
+        Element form = doc.getElementById("form1");
+        Map<String, String> fieldValues = CollectionFactory.newMap();
+        fieldValues.put("t1", "hello");
+        doc = _tester.submitForm(form, fieldValues);
+        assertTrue(doc.toString().contains("You entered: hello"));
+    }
+
+    public void after()
+    {
+        if (_tester != null)
+        {
+            _tester.shutdown();
+        }
+    }
+}

Added: 
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/test/pagelevel/SessionForPageTesterTest.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/test/pagelevel/SessionForPageTesterTest.java?view=auto&rev=488627
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/test/pagelevel/SessionForPageTesterTest.java
 (added)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/test/pagelevel/SessionForPageTesterTest.java
 Tue Dec 19 02:57:51 2006
@@ -0,0 +1,68 @@
+// Copyright 2006 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry.test.pagelevel;
+
+import java.util.Arrays;
+import java.util.Collections;
+
+import org.testng.Assert;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+public class SessionForPageTesterTest extends Assert
+{
+    private SessionForPageTester _session;
+
+    @BeforeMethod
+    public void before()
+    {
+        _session = new SessionForPageTester();
+    }
+
+    @Test
+    public void empty()
+    {
+        assertEquals(_session.getAttributeNames(), Collections.EMPTY_LIST);
+        assertNull(_session.getAttribute("x"));
+    }
+
+    @Test
+    public void set_attributes()
+    {
+        _session.setAttribute("b", 10);
+        _session.setAttribute("a", 20);
+        assertEquals(_session.getAttribute("a"), 20);
+        assertEquals(_session.getAttribute("b"), 10);
+    }
+
+    @Test
+    public void remove_if_value_is_null()
+    {
+        _session.setAttribute("b", 10);
+        _session.setAttribute("a", 20);
+        assertEquals(_session.getAttributeNames().size(), 2);
+        _session.setAttribute("b", null);
+        assertEquals(_session.getAttributeNames().size(), 1);
+    }
+
+    @Test
+    public void names_sorted()
+    {
+        _session.setAttribute("b", 10);
+        _session.setAttribute("a", 20);
+        _session.setAttribute("c", 50);
+        assertEquals(_session.getAttributeNames(), Arrays.asList("a", "b", 
"c"));
+    }
+}

Added: 
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/test/pagelevel/SessionHolderForPageTesterTest.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/test/pagelevel/SessionHolderForPageTesterTest.java?view=auto&rev=488627
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/test/pagelevel/SessionHolderForPageTesterTest.java
 (added)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/test/pagelevel/SessionHolderForPageTesterTest.java
 Tue Dec 19 02:57:51 2006
@@ -0,0 +1,41 @@
+// Copyright 2006 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry.test.pagelevel;
+
+import java.util.Collections;
+
+import org.apache.tapestry.services.Session;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+public class SessionHolderForPageTesterTest extends Assert
+{
+    @Test
+    public void not_created()
+    {
+        SessionHolderForPageTester holder = new SessionHolderForPageTester();
+        assertNull(holder.getSession(false));
+    }
+
+    @Test
+    public void create()
+    {
+        SessionHolderForPageTester holder = new SessionHolderForPageTester();
+        Session session = holder.getSession(true);
+        assertNotNull(session);
+        assertEquals(session.getAttributeNames(), Collections.EMPTY_LIST);
+    }
+
+}

Added: 
tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app2/pages/TestPageForForm.html
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app2/pages/TestPageForForm.html?view=auto&rev=488627
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app2/pages/TestPageForForm.html
 (added)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app2/pages/TestPageForForm.html
 Tue Dec 19 02:57:51 2006
@@ -0,0 +1,8 @@
+<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd";>
+<p><t:comp id="form1" type="Form">
+       <t:comp type="TextField" id="t1" value="value" size="50"/>
+</t:comp></p>
+<p>
+       You entered: ${value}.
+</p>
+</html>


Reply via email to