tapestry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject svn commit: r494965 [2/2] - in /tapestry/tapestry5/tapestry-core/trunk/src: main/java/org/apache/tapestry/ main/java/org/apache/tapestry/corelib/base/ main/java/org/apache/tapestry/corelib/components/ main/java/org/apache/tapestry/corelib/pages/ main/j...
Date Wed, 10 Jan 2007 20:22:41 GMT
Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/TapestryTestCase.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/TapestryTestCase.java?view=diff&rev=494965&r1=494964&r2=494965
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/TapestryTestCase.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/TapestryTestCase.java Wed Jan 10 12:22:38 2007
@@ -34,18 +34,18 @@
 
 import org.apache.tapestry.Asset;
 import org.apache.tapestry.Binding;
+import org.apache.tapestry.ComponentEventHandler;
 import org.apache.tapestry.ComponentResources;
 import org.apache.tapestry.ComponentResourcesCommon;
 import org.apache.tapestry.Field;
 import org.apache.tapestry.FieldValidator;
+import org.apache.tapestry.Link;
 import org.apache.tapestry.MarkupWriter;
 import org.apache.tapestry.Translator;
-import org.apache.tapestry.ValidationDecorator;
 import org.apache.tapestry.ValidationTracker;
 import org.apache.tapestry.Validator;
 import org.apache.tapestry.annotations.Inject;
 import org.apache.tapestry.annotations.Parameter;
-import org.apache.tapestry.internal.DefaultValidationDecorator;
 import org.apache.tapestry.ioc.Location;
 import org.apache.tapestry.ioc.Messages;
 import org.apache.tapestry.ioc.Resource;
@@ -76,7 +76,6 @@
 import org.apache.tapestry.services.ValidationMessagesSource;
 import org.easymock.EasyMock;
 import org.easymock.IAnswer;
-import org.testng.annotations.Test;
 
 /**
  * Base test case that adds a number of convienience factory and training methods for the public
@@ -610,25 +609,6 @@
         return newMock(Translator.class);
     }
 
-    @Test
-    public void label_when_field_not_in_error()
-    {
-        Environment env = newEnvironment();
-        Field field = newField();
-        ValidationTracker tracker = newValidationTracker();
-    
-        train_peekRequired(env, ValidationTracker.class, tracker);
-        train_inError(tracker, field, false);
-    
-        replay();
-    
-        ValidationDecorator decorator = new DefaultValidationDecorator(env);
-    
-        decorator.insideLabel(field, null);
-    
-        verify();
-    }
-
     protected final ValidationTracker newValidationTracker()
     {
         return newMock(ValidationTracker.class);
@@ -642,5 +622,26 @@
     protected final void train_inError(ValidationTracker tracker, Field field, boolean inError)
     {
         expect(tracker.inError(field)).andReturn(inError);
+    }
+
+    protected final ComponentEventHandler newComponentEventHandler()
+    {
+        return newMock(ComponentEventHandler.class);
+    }
+
+    @SuppressWarnings("unchecked")
+    protected final void train_handleResult(ComponentEventHandler handler, Object result, Component component, String methodDescription, boolean abort)
+    {
+        expect(handler.handleResult(result, component, methodDescription)).andReturn(abort);
+    }
+
+    protected final void train_toRedirectURI(Link link, String URI)
+    {
+        expect(link.toRedirectURI()).andReturn(URI).atLeastOnce();
+    }
+
+    protected final Link newLink()
+    {
+        return newMock(Link.class);
     }
 }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/pagelevel/ActionLinkInvoker.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/pagelevel/ActionLinkInvoker.java?view=diff&rev=494965&r1=494964&r2=494965
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/pagelevel/ActionLinkInvoker.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/pagelevel/ActionLinkInvoker.java Wed Jan 10 12:22:38 2007
@@ -12,56 +12,85 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package org.apache.tapestry.test.pagelevel;
-
-import org.apache.tapestry.Link;
-import org.apache.tapestry.dom.Document;
-import org.apache.tapestry.internal.services.ActionLinkHandler;
-import org.apache.tapestry.internal.services.ComponentInvocation;
-import org.apache.tapestry.internal.services.LinkImpl;
-import org.apache.tapestry.ioc.Registry;
-
-/**
- * Simulates a click on an action link.
- */
-public class ActionLinkInvoker implements ComponentInvoker
-{
-    private final Registry _registry;
-
-    private final ComponentInvoker _followupInvoker;
-
-    private final ActionLinkHandler _actionLinkHandler;
-
-    public ActionLinkInvoker(Registry registry, ComponentInvoker followupInvoker)
-    {
-        _registry = registry;
-        _followupInvoker = followupInvoker;
-        _actionLinkHandler = _registry.getService(ActionLinkHandler.class);
-    }
-
-    /**
-     * Click on the action link and get another link in return. Then follow up the link with another
-     * {@link ComponentInvoker}.
-     * 
-     * @param invocation
-     *            The ComponentInvocation object corresponding to the action link.
-     * @return The DOM created. Typically you will assert against it.
-     */
-    public Document invoke(ComponentInvocation invocation)
-    {
-        Link followupLink = click(invocation);
-        return _followupInvoker.invoke(((LinkImpl) followupLink).getInvocation());
-    }
-
-    private Link click(ComponentInvocation invocation)
-    {
-        try
-        {
-            return _actionLinkHandler.handle(invocation);
-        }
-        finally
-        {
-            _registry.cleanupThread();
-        }
-    }
-}
+package org.apache.tapestry.test.pagelevel;
+
+import org.apache.tapestry.Link;
+import org.apache.tapestry.dom.Document;
+import org.apache.tapestry.internal.services.ActionLinkHandler;
+import org.apache.tapestry.internal.services.ComponentInvocation;
+import org.apache.tapestry.internal.services.ComponentInvocationMap;
+import org.apache.tapestry.internal.services.LinkActionResponseGenerator;
+import org.apache.tapestry.ioc.Registry;
+import org.apache.tapestry.services.ActionResponseGenerator;
+
+/**
+ * Simulates a click on an action link.
+ */
+public class ActionLinkInvoker implements ComponentInvoker
+{
+    private final Registry _registry;
+
+    private final ComponentInvoker _followupInvoker;
+
+    private final ActionLinkHandler _actionLinkHandler;
+
+    private final ComponentInvocationMap _componentInvocationMap;
+
+    public ActionLinkInvoker(Registry registry, ComponentInvoker followupInvoker,
+            ComponentInvocationMap componentInvocationMap)
+    {
+        _registry = registry;
+        _followupInvoker = followupInvoker;
+        _actionLinkHandler = _registry.getService(
+                "tapestry.ActionLinkHandler",
+                ActionLinkHandler.class);
+        _componentInvocationMap = componentInvocationMap;
+
+    }
+
+    /**
+     * Click on the action link and get another link in return. Then follow up the link with another
+     * {@link ComponentInvoker}.
+     * 
+     * @param invocation
+     *            The ComponentInvocation object corresponding to the action link.
+     * @return The DOM created. Typically you will assert against it.
+     */
+    public Document invoke(ComponentInvocation invocation)
+    {
+        ActionResponseGenerator generator = click(invocation);
+
+        if (generator instanceof LinkActionResponseGenerator)
+        {
+            LinkActionResponseGenerator linkGenerator = (LinkActionResponseGenerator) generator;
+
+            Link link = linkGenerator.getLink();
+
+            ComponentInvocation followup = _componentInvocationMap.get(link);
+
+            return _followupInvoker.invoke(followup);
+        }
+
+        String message = String
+                .format(
+                        "ActionResponseGenerator %s is an instance of class %s, which is not compatible with PageTester.",
+                        generator,
+                        generator.getClass());
+
+        throw new RuntimeException(message);
+    }
+
+    private ActionResponseGenerator click(ComponentInvocation invocation)
+    {
+        try
+        {
+            // Bypass most of the Tapestry stack, to get right in there.
+
+            return _actionLinkHandler.handle(invocation);
+        }
+        finally
+        {
+            _registry.cleanupThread();
+        }
+    }
+}

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=494965&r1=494964&r2=494965
==============================================================================
--- 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 Wed Jan 10 12:22:38 2007
@@ -12,33 +12,49 @@
 // 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.Map;
-
-import org.apache.tapestry.dom.Element;
-import org.apache.tapestry.internal.services.ComponentInvocation;
-import org.apache.tapestry.internal.services.ComponentInvocationMap;
-
-public class InAppInvocationMapForPageTester implements ComponentInvocationMap
-{
-    private Map<Element, ComponentInvocation> map = newMap();
-
-    public void clear()
-    {
-        map.clear();
-    }
-
-    public void put(Element element, ComponentInvocation invocation)
-    {
-        map.put(element, invocation);
-    }
-
-    public ComponentInvocation get(Element element)
-    {
-        return map.get(element);
-    }
-
-}
+package org.apache.tapestry.test.pagelevel;
+
+import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newMap;
+
+import java.util.Map;
+
+import org.apache.tapestry.Link;
+import org.apache.tapestry.dom.Element;
+import org.apache.tapestry.internal.services.ComponentInvocation;
+import org.apache.tapestry.internal.services.ComponentInvocationMap;
+
+public class InAppInvocationMapForPageTester implements ComponentInvocationMap
+{
+    private final Map<Element, Link> _elementToLink = newMap();
+
+    private final Map<Link, ComponentInvocation> _linkToInvocation = newMap();
+
+    public void store(Element element, Link link)
+    {
+        _elementToLink.put(element, link);
+    }
+
+    public void store(Link link, ComponentInvocation invocation)
+    {
+        _linkToInvocation.put(link, invocation);
+    }
+
+    public void clear()
+    {
+        _elementToLink.clear();
+        _linkToInvocation.clear();
+    }
+
+    public ComponentInvocation get(Element element)
+    {
+        Link link = _elementToLink.get(element);
+
+        return get(link);
+    }
+
+    public ComponentInvocation get(Link link)
+    {
+        return _linkToInvocation.get(link);
+    }
+
+}

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=494965&r1=494964&r2=494965
==============================================================================
--- 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 Wed Jan 10 12:22:38 2007
@@ -43,12 +43,12 @@
 {
     private Registry _registry;
 
-    private InAppInvocationMapForPageTester _invocationMap;
+    private InAppInvocationMapForPageTester _invocationMap = new InAppInvocationMapForPageTester();
 
-    private FormParameterLookupForPageTester _formParameterLookup;
+    private FormParameterLookupForPageTester _formParameterLookup = new FormParameterLookupForPageTester();
 
     // For the moment, a page tester instance works in a single session.
-    private SessionHolderForPageTester _sessionHolder;
+    private SessionHolderForPageTester _sessionHolder = new SessionHolderForPageTester();
 
     private StrategyRegistry<ComponentInvoker> _invokerRegistry;
 
@@ -122,15 +122,13 @@
     {
         Map<Class, ComponentInvoker> map = newMap();
         map.put(PageLinkTarget.class, new PageLinkInvoker(_registry));
-        map.put(ActionLinkTarget.class, new ActionLinkInvoker(_registry, this));
+        map.put(ActionLinkTarget.class, new ActionLinkInvoker(_registry, this, _invocationMap));
         _invokerRegistry = new StrategyRegistry<ComponentInvoker>(ComponentInvoker.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,
@@ -139,13 +137,14 @@
         addDefaultOverride(modifiedOverrides, "tapestry.internal.URLEncoder", new NoOpURLEncoder());
         addDefaultOverride(
                 modifiedOverrides,
-                "tapestry.internal.InAppInvocationMap",
+                "tapestry.internal.ComponentInvocationMap",
                 _invocationMap);
         addDefaultOverride(
                 modifiedOverrides,
                 "tapestry.internal.FormParameterLookup",
                 _formParameterLookup);
         addDefaultOverride(modifiedOverrides, "tapestry.internal.SessionHolder", _sessionHolder);
+
         return modifiedOverrides;
     }
 

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/corelib/pages/ExceptionReport.html
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/corelib/pages/ExceptionReport.html?view=diff&rev=494965&r1=494964&r2=494965
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/corelib/pages/ExceptionReport.html (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/corelib/pages/ExceptionReport.html Wed Jan 10 12:22:38 2007
@@ -18,7 +18,7 @@
                             </div>
                         </t:comp>
 
-                        <t:comp type="If" test="info.propertyNames">
+                        <t:comp type="If" test="showPropertyList">
                             <dl>
                                 <t:comp type="Loop" source="info.propertyNames" value="propertyName">
                                     <dt>${propertyName}</dt>

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/internal/services/ServicesStrings.properties
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/internal/services/ServicesStrings.properties?view=diff&rev=494965&r1=494964&r2=494965
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/internal/services/ServicesStrings.properties (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/internal/services/ServicesStrings.properties Wed Jan 10 12:22:38 2007
@@ -68,4 +68,5 @@
 unknown-validator-type=Unknown validator type '%s'.  Configured validators are %s.
 validator-specification-parse-error=Unexpected character '%s' at position %d of input string: %s
 unknown-translator-type=Unknown translator type '%s'.  Configured translators are %s.
-missing-from-environment=No object of type %s is available from the Environment.  Available types are %s.
\ No newline at end of file
+missing-from-environment=No object of type %s is available from the Environment.  Available types are %s.
+invalid-component-event-result=An event handler for component %s returned the value %s (from method %s).  Return type %s can not be handled.  Configured return types are %s.
\ No newline at end of file

Added: tapestry/tapestry5/tapestry-core/trunk/src/test/app1/WEB-INF/PasswordFieldDemo.html
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/app1/WEB-INF/PasswordFieldDemo.html?view=auto&rev=494965
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/app1/WEB-INF/PasswordFieldDemo.html (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/app1/WEB-INF/PasswordFieldDemo.html Wed Jan 10 12:22:38 2007
@@ -0,0 +1,30 @@
+<html t:type="Border" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
+    <h1>Simple Form</h1>
+
+    <p> This is the <em>very early</em> start to Tapestry 5 form support. </p>
+
+    <form t:id="form">
+
+        <span t:type="Errors"/>
+
+        <label t:type="Label" field="component:userName"/>
+        <input t:type="TextField" t:id="userName" t:validate="validate:required" size="30"/>
+        <br/>
+        <label t:type="Label" field="component:password"/>
+        <input t:id="password" t:validate="validate:required" size="30"/>
+        <br/>
+        <input type="submit" value="Login"/>
+    </form>
+
+    <hr/>
+
+    <p> Entered data: </p>
+
+    <ul>
+        <li>userName: [${userName}]</li>
+        <li>password: [${password}]</li>
+    </ul>
+
+
+
+</html>

Added: tapestry/tapestry5/tapestry-core/trunk/src/test/app1/WEB-INF/PostLogin.html
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/app1/WEB-INF/PostLogin.html?view=auto&rev=494965
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/app1/WEB-INF/PostLogin.html (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/app1/WEB-INF/PostLogin.html Wed Jan 10 12:22:38 2007
@@ -0,0 +1,9 @@
+<html t:type="Border" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
+
+<h1>Post Login</h1>
+    
+    <p>
+        You have provided the correct user name and password.
+    </p>    
+    
+</html>

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/app1/index.html
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/app1/index.html?view=diff&rev=494965&r1=494964&r2=494965
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/app1/index.html (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/app1/index.html Wed Jan 10 12:22:38 2007
@@ -66,6 +66,9 @@
             <li>
                 <a href="AnyDemo.html">AnyDemo</a>  -- test out the Any component
             </li>
+            <li>
+                <a href="PasswordFieldDemo.html">PasswordFieldDemo</a> -- test for the PasswordField component
+            </li>
             </ul>
         </p>
     </body>

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java?view=diff&rev=494965&r1=494964&r2=494965
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java Wed Jan 10 12:22:38 2007
@@ -344,6 +344,32 @@
     }
 
     @Test
+    public void password_field()
+    {
+        _selenium.open(BASE_URL);
+
+        clickAndWait("link=PasswordFieldDemo");
+
+        _selenium.type("userName", "howard");
+        _selenium.type("password", "wrong-password");
+
+        clickAndWait("//input[@type='submit']");
+
+        assertValue("userName", "howard");
+        // Verify that password fields do not render a non-blank password, even when it is known.
+        assertValue("password", "");
+
+        assertTextPresent("[howard]");
+        assertTextPresent("[wrong-password]");
+
+        _selenium.type("password", "tapestry");
+
+        clickAndWait("//input[@type='submit']");
+
+        assertTextPresent("You have provided the correct user name and password.");
+    }
+
+    @Test
     public void passivate_activate() throws Exception
     {
         _selenium.open(BASE_URL);

Added: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/pages/PasswordFieldDemo.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/pages/PasswordFieldDemo.java?view=auto&rev=494965
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/pages/PasswordFieldDemo.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/pages/PasswordFieldDemo.java Wed Jan 10 12:22:38 2007
@@ -0,0 +1,75 @@
+// Copyright 2007 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.app1.pages;
+
+import org.apache.tapestry.annotations.Component;
+import org.apache.tapestry.annotations.ComponentClass;
+import org.apache.tapestry.annotations.Inject;
+import org.apache.tapestry.annotations.Retain;
+import org.apache.tapestry.corelib.components.Form;
+import org.apache.tapestry.corelib.components.PasswordField;
+import org.apache.tapestry.integration.app1.services.UserAuthenticator;
+
+@ComponentClass
+public class PasswordFieldDemo
+{
+    @Retain
+    private String _userName;
+
+    // Normally not retained, just want to prove that the output value is always the blank string.
+    @Retain
+    private String _password;
+
+    @Inject
+    private UserAuthenticator _authenticator;
+
+    @Component(id = "password")
+    private PasswordField _passwordField;
+
+    @Component
+    private Form _form;
+
+    String onSuccess()
+    {
+        if (!_authenticator.isValid(_userName, _password))
+        {
+            _form.getTracker().recordError(_passwordField, "Invalid user name or password.");
+            return null;
+        }
+
+        return "PostLogin";
+    }
+
+    public String getPassword()
+    {
+        return _password;
+    }
+
+    public void setPassword(String password)
+    {
+        _password = password;
+    }
+
+    public String getUserName()
+    {
+        return _userName;
+    }
+
+    public void setUserName(String userName)
+    {
+        _userName = userName;
+    }
+
+}

Added: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/pages/PostLogin.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/pages/PostLogin.java?view=auto&rev=494965
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/pages/PostLogin.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/pages/PostLogin.java Wed Jan 10 12:22:38 2007
@@ -0,0 +1,23 @@
+// Copyright 2007 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.app1.pages;
+
+import org.apache.tapestry.annotations.ComponentClass;
+
+@ComponentClass
+public class PostLogin
+{
+
+}

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/services/AppModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/services/AppModule.java?view=diff&rev=494965&r1=494964&r2=494965
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/services/AppModule.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/services/AppModule.java Wed Jan 10 12:22:38 2007
@@ -37,8 +37,8 @@
     {
         return new RequestFilter()
         {
-            public boolean service(Request request, Response response,
-                    RequestHandler handler) throws IOException
+            public boolean service(Request request, Response response, RequestHandler handler)
+                    throws IOException
             {
                 long startTime = System.currentTimeMillis();
 
@@ -68,5 +68,16 @@
     public void contributeAliases(MappedConfiguration<String, String> configuration)
     {
         configuration.add("app1/", "org/apache/tapestry/integration/app1/");
+    }
+
+    public UserAuthenticator buildUserAuthenticator()
+    {
+        return new UserAuthenticator()
+        {
+            public boolean isValid(String userName, String plaintextPassword)
+            {
+                return plaintextPassword.equals("tapestry");
+            }
+        };
     }
 }

Added: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/services/UserAuthenticator.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/services/UserAuthenticator.java?view=auto&rev=494965
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/services/UserAuthenticator.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/services/UserAuthenticator.java Wed Jan 10 12:22:38 2007
@@ -0,0 +1,20 @@
+// Copyright 2007 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.app1.services;
+
+public interface UserAuthenticator
+{
+    boolean isValid(String userName, String plaintextPassword);
+}

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/DefaultValidationDecoratorTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/DefaultValidationDecoratorTest.java?view=diff&rev=494965&r1=494964&r2=494965
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/DefaultValidationDecoratorTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/DefaultValidationDecoratorTest.java Wed Jan 10 12:22:38 2007
@@ -145,4 +145,23 @@
 
         verify();
     }
+
+    @Test
+    public void label_when_field_not_in_error()
+    {
+        Environment env = newEnvironment();
+        Field field = newField();
+        ValidationTracker tracker = newValidationTracker();
+
+        train_peekRequired(env, ValidationTracker.class, tracker);
+        train_inError(tracker, field, false);
+
+        replay();
+
+        ValidationDecorator decorator = new DefaultValidationDecorator(env);
+
+        decorator.insideLabel(field, null);
+
+        verify();
+    }
 }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ComponentEventImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ComponentEventImplTest.java?view=diff&rev=494965&r1=494964&r2=494965
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ComponentEventImplTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ComponentEventImplTest.java Wed Jan 10 12:22:38 2007
@@ -12,213 +12,241 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package org.apache.tapestry.internal.services;
-
-import org.apache.tapestry.ComponentEventHandler;
-import org.apache.tapestry.internal.test.InternalBaseTestCase;
-import org.apache.tapestry.ioc.services.TypeCoercer;
-import org.apache.tapestry.runtime.ComponentEvent;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-public class ComponentEventImplTest extends InternalBaseTestCase
-{
-    private TypeCoercer _coercer;
-
-    @BeforeClass
-    public void setup_coercer()
-    {
-        _coercer = getObject("infrastructure:TypeCoercer", TypeCoercer.class);
-    }
-
-    @AfterClass
-    public void cleanup_coercer()
-    {
-        _coercer = null;
-    }
-
-    @Test
-    public void matches_on_event_type()
-    {
-        ComponentEventHandler handler = newComponentEventHandler();
-
-        replay();
-
-        ComponentEvent event = new ComponentEventImpl("eventType", "someId", null, handler,
-                _coercer);
-
-        assertTrue(event.matchesByEventType(new String[]
-        { "foo", "eventType", "bar" }));
-        assertFalse(event.matchesByEventType(new String[]
-        { "foo", "bar" }));
-
-        verify();
-    }
-
-    @Test
-    public void matches_on_component_id()
-    {
-        ComponentEventHandler handler = newComponentEventHandler();
-
-        replay();
-        ComponentEvent event = new ComponentEventImpl("eventType", "someId", null, handler,
-                _coercer);
-
-        assertTrue(event.matchesByComponentId(null, new String[]
-        { "foo", "someId", "bar" }));
-        assertFalse(event.matchesByComponentId(null, new String[]
-        { "foo", "bar" }));
-
-        verify();
-    }
-
-    @Test
-    public void coerce_context()
-    {
-        ComponentEventHandler handler = newComponentEventHandler();
-
-        replay();
-
-        ComponentEvent event = new ComponentEventImpl("eventType", "someId", new String[]
-        { "27" }, handler, _coercer);
-
-        assertEquals(event.coerceContext(0, "java.lang.Integer"), new Integer(27));
-
-        verify();
-    }
-
-    @Test
-    public void coerce_when_not_enough_context()
-    {
-        ComponentEventHandler handler = newComponentEventHandler();
-
-        replay();
-
-        ComponentEvent event = new ComponentEventImpl("eventType", "someId", new String[]
-        { "27" }, handler, _coercer);
-
-        event.setSource(null, "foo.Bar.baz()");
-
-        try
-        {
-            event.coerceContext(1, "java.lang.Integer");
-        }
-        catch (IllegalArgumentException ex)
-        {
-            assertEquals(
-                    ex.getMessage(),
-                    "Method foo.Bar.baz() has more parameters than there are context values for this component event.");
-        }
-
-        verify();
-    }
-
-    @Test
-    public void unable_to_coerce()
-    {
-        ComponentEventHandler handler = newComponentEventHandler();
-
-        replay();
-
-        ComponentEvent event = new ComponentEventImpl("eventType", "someId", new String[]
-        { "abc" }, handler, _coercer);
-
-        event.setSource(null, "foo.Bar.baz()");
-
-        try
-        {
-            event.coerceContext(0, "java.lang.Integer");
-            unreachable();
-        }
-        catch (IllegalArgumentException ex)
-        {
-            // Different JVMs will report the conversion error slightly differently,
-            // so we don't try to check that part of the error message.
-
-            assertTrue(ex.getMessage().startsWith(
-                    "Exception in method foo.Bar.baz(), parameter #1:"));
-        }
-
-        verify();
-    }
-
-    @Test
-    public void store_result()
-    {
-        Object result = new Object();
-        String methodDescription = "foo.Bar.baz()";
-
-        ComponentEventHandler handler = newComponentEventHandler();
-
-        handler.handleResult(result, null, methodDescription);
-
-        replay();
-
-        ComponentEvent event = new ComponentEventImpl("eventType", "someId", null, handler,
-                _coercer);
-
-        event.setSource(null, methodDescription);
-
-        assertFalse(event.isAborted());
-
-        assertTrue(event.storeResult(result));
-
-        assertTrue(event.isAborted());
-
-        verify();
-    }
-
-    @Test
-    public void store_null_result_does_not_abort_or_invoke_handler()
-    {
-        ComponentEventHandler handler = newComponentEventHandler();
-
-        replay();
-
-        ComponentEvent event = new ComponentEventImpl("eventType", "someId", null, handler,
-                _coercer);
-
-        assertFalse(event.storeResult(null));
-
-        assertFalse(event.isAborted());
-
-        verify();
-    }
-
-    protected final ComponentEventHandler newComponentEventHandler()
-    {
-        return newMock(ComponentEventHandler.class);
-    }
-
-    @Test
-    public void store_result_when_aborted_is_failure()
-    {
-        Object result = new Object();
-        ComponentEventHandler handler = newComponentEventHandler();
-
-        handler.handleResult(result, null, "foo.Bar.baz()");
-
-        replay();
-
-        ComponentEvent event = new ComponentEventImpl("eventType", "someId", null, handler,
-                _coercer);
-
-        event.setSource(null, "foo.Bar.baz()");
-        event.storeResult(result);
-
-        try
-        {
-            event.setSource(null, "foo.Bar.biff()");
-            event.storeResult(null);
-            unreachable();
-        }
-        catch (IllegalStateException ex)
-        {
-            assertEquals(ex.getMessage(), ServicesMessages
-                    .componentEventIsAborted("foo.Bar.biff()"));
-        }
-
-        verify();
-    }
-}
+package org.apache.tapestry.internal.services;
+
+import org.apache.tapestry.ComponentEventHandler;
+import org.apache.tapestry.internal.test.InternalBaseTestCase;
+import org.apache.tapestry.ioc.services.TypeCoercer;
+import org.apache.tapestry.runtime.Component;
+import org.apache.tapestry.runtime.ComponentEvent;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+public class ComponentEventImplTest extends InternalBaseTestCase
+{
+    private TypeCoercer _coercer;
+
+    @BeforeClass
+    public void setup_coercer()
+    {
+        _coercer = getObject("infrastructure:TypeCoercer", TypeCoercer.class);
+    }
+
+    @AfterClass
+    public void cleanup_coercer()
+    {
+        _coercer = null;
+    }
+
+    @Test
+    public void matches_on_event_type()
+    {
+        ComponentEventHandler handler = newComponentEventHandler();
+
+        replay();
+
+        ComponentEvent event = new ComponentEventImpl("eventType", "someId", null, handler,
+                _coercer);
+
+        assertTrue(event.matchesByEventType(new String[]
+        { "foo", "eventType", "bar" }));
+        assertFalse(event.matchesByEventType(new String[]
+        { "foo", "bar" }));
+
+        verify();
+    }
+
+    @Test
+    public void matches_on_component_id()
+    {
+        ComponentEventHandler handler = newComponentEventHandler();
+
+        replay();
+        ComponentEvent event = new ComponentEventImpl("eventType", "someId", null, handler,
+                _coercer);
+
+        assertTrue(event.matchesByComponentId(null, new String[]
+        { "foo", "someId", "bar" }));
+        assertFalse(event.matchesByComponentId(null, new String[]
+        { "foo", "bar" }));
+
+        verify();
+    }
+
+    @Test
+    public void coerce_context()
+    {
+        ComponentEventHandler handler = newComponentEventHandler();
+
+        replay();
+
+        ComponentEvent event = new ComponentEventImpl("eventType", "someId", new String[]
+        { "27" }, handler, _coercer);
+
+        assertEquals(event.coerceContext(0, "java.lang.Integer"), new Integer(27));
+
+        verify();
+    }
+
+    @Test
+    public void coerce_when_not_enough_context()
+    {
+        ComponentEventHandler handler = newComponentEventHandler();
+        Component component = newComponent();
+
+        replay();
+
+        ComponentEvent event = new ComponentEventImpl("eventType", "someId", new String[]
+        { "27" }, handler, _coercer);
+
+        event.setSource(component, "foo.Bar.baz()");
+
+        try
+        {
+            event.coerceContext(1, "java.lang.Integer");
+        }
+        catch (IllegalArgumentException ex)
+        {
+            assertEquals(
+                    ex.getMessage(),
+                    "Method foo.Bar.baz() has more parameters than there are context values for this component event.");
+        }
+
+        verify();
+    }
+
+    @Test
+    public void unable_to_coerce()
+    {
+        ComponentEventHandler handler = newComponentEventHandler();
+        Component component = newComponent();
+
+        replay();
+
+        ComponentEvent event = new ComponentEventImpl("eventType", "someId", new String[]
+        { "abc" }, handler, _coercer);
+
+        event.setSource(component, "foo.Bar.baz()");
+
+        try
+        {
+            event.coerceContext(0, "java.lang.Integer");
+            unreachable();
+        }
+        catch (IllegalArgumentException ex)
+        {
+            // Different JVMs will report the conversion error slightly differently,
+            // so we don't try to check that part of the error message.
+
+            assertTrue(ex.getMessage().startsWith(
+                    "Exception in method foo.Bar.baz(), parameter #1:"));
+        }
+
+        verify();
+    }
+
+    @Test
+    public void store_result_and_abort()
+    {
+        Object result = new Object();
+        String methodDescription = "foo.Bar.baz()";
+        Component component = newComponent();
+
+        ComponentEventHandler handler = newComponentEventHandler();
+
+        train_handleResult(handler, result, component, methodDescription, true);
+
+        replay();
+
+        ComponentEvent event = new ComponentEventImpl("eventType", "someId", null, handler,
+                _coercer);
+
+        event.setSource(component, methodDescription);
+
+        assertFalse(event.isAborted());
+
+        assertTrue(event.storeResult(result));
+
+        assertTrue(event.isAborted());
+
+        verify();
+    }
+
+    @Test
+    public void store_result_and_continue()
+    {
+        Object result = new Object();
+        String methodDescription = "foo.Bar.baz()";
+        Component component = newComponent();
+        ComponentEventHandler handler = newComponentEventHandler();
+
+        train_handleResult(handler, result, component, methodDescription, false);
+
+        replay();
+
+        ComponentEvent event = new ComponentEventImpl("eventType", "someId", null, handler,
+                _coercer);
+
+        event.setSource(component, methodDescription);
+
+        assertFalse(event.storeResult(result));
+
+        assertFalse(event.isAborted());
+
+        verify();
+    }
+
+    @Test
+    public void store_null_result_does_not_abort_or_invoke_handler()
+    {
+        Component component = newComponent();
+        ComponentEventHandler handler = newComponentEventHandler();
+
+        replay();
+
+        ComponentEvent event = new ComponentEventImpl("eventType", "someId", null, handler,
+                _coercer);
+
+        event.setSource(component, "foo.Bar.baz()");
+
+        assertFalse(event.storeResult(null));
+
+        assertFalse(event.isAborted());
+
+        verify();
+    }
+
+    @SuppressWarnings("unchecked")
+    @Test
+    public void store_result_when_aborted_is_failure()
+    {
+        Object result = new Object();
+        ComponentEventHandler handler = newComponentEventHandler();
+        Component component = newComponent();
+
+        expect(handler.handleResult(result, component, "foo.Bar.baz()")).andReturn(true);
+
+        replay();
+
+        ComponentEvent event = new ComponentEventImpl("eventType", "someId", null, handler,
+                _coercer);
+
+        event.setSource(component, "foo.Bar.baz()");
+        event.storeResult(result);
+
+        try
+        {
+            event.setSource(component, "foo.Bar.biff()");
+            event.storeResult(null);
+            unreachable();
+        }
+        catch (IllegalStateException ex)
+        {
+            assertEquals(ex.getMessage(), ServicesMessages
+                    .componentEventIsAborted("foo.Bar.biff()"));
+        }
+
+        verify();
+    }
+}

Copied: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ComponentInstanceResultProcessorTest.java (from r493881, tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ComponentInstanceEventHandlerTest.java)
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ComponentInstanceResultProcessorTest.java?view=diff&rev=494965&p1=tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ComponentInstanceEventHandlerTest.java&r1=493881&p2=tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ComponentInstanceResultProcessorTest.java&r2=494965
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ComponentInstanceEventHandlerTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ComponentInstanceResultProcessorTest.java Wed Jan 10 12:22:38 2007
@@ -15,21 +15,25 @@
 package org.apache.tapestry.internal.services;
 
 import org.apache.commons.logging.Log;
-import org.apache.tapestry.ComponentEventHandler;
 import org.apache.tapestry.ComponentResources;
+import org.apache.tapestry.Link;
 import org.apache.tapestry.internal.structure.Page;
 import org.apache.tapestry.internal.test.InternalBaseTestCase;
 import org.apache.tapestry.runtime.Component;
+import org.apache.tapestry.services.ComponentEventResultProcessor;
+import org.apache.tapestry.services.Response;
 import org.testng.annotations.Test;
 
-public class ComponentInstanceEventHandlerTest extends InternalBaseTestCase
+public class ComponentInstanceResultProcessorTest extends InternalBaseTestCase
 {
     private static final String PAGE_NAME = "foo.bar.Zoop";
 
     private static final String METHOD_DESCRIPTION = "foo.bar.Baz.biff()";
 
+    private static final String LINK_URI = "{LinkURI}";
+
     @Test
-    public void result_is_root_component()
+    public void result_is_root_component() throws Exception
     {
         Component result = newComponent();
         Component source = newComponent();
@@ -37,6 +41,9 @@
         Log log = newLog();
         RequestPageCache cache = newRequestPageCache();
         Page page = newPage();
+        LinkFactory factory = newLinkFactory();
+        Response response = newResponse();
+        Link link = newLink();
 
         train_getComponentResources(result, resources);
         train_getContainer(resources, null);
@@ -44,19 +51,24 @@
         train_getCompleteId(resources, PAGE_NAME);
         train_getByClassName(cache, PAGE_NAME, page);
 
-        cache.setActive(page);
+        train_createPageLink(factory, page, link);
+        train_toRedirectURI(link, LINK_URI);
+
+        response.sendRedirect(LINK_URI);
 
         replay();
 
-        ComponentEventHandler<Component> handler = new ComponentInstanceEventHandler(cache, log);
+        ComponentEventResultProcessor<Component> processor = new ComponentInstanceResultProcessor(
+                cache, factory, log);
 
-        handler.handleResult(result, source, METHOD_DESCRIPTION);
+        processor.processComponentEvent(result, source, METHOD_DESCRIPTION).sendClientResponse(
+                response);
 
         verify();
     }
 
     @Test
-    public void warning_for_component_is_not_root_component()
+    public void warning_for_component_is_not_root_component() throws Exception
     {
         Component child = newComponent();
         Component source = newComponent();
@@ -68,6 +80,9 @@
         Log log = newLog();
         RequestPageCache cache = newRequestPageCache();
         Page page = newPage();
+        LinkFactory factory = newLinkFactory();
+        Response response = newResponse();
+        Link link = newLink();
 
         train_getComponentResources(child, childResources);
 
@@ -84,16 +99,21 @@
         train_getCompleteId(rootResources, PAGE_NAME);
         train_getByClassName(cache, PAGE_NAME, page);
 
-        cache.setActive(page);
-
         log
                 .warn("Method foo.bar.Baz.biff() (for component foo.bar.Zoop:source) returned component foo.bar.Zoop:child, which is not a page component. The page containing the component will render the client response.");
 
+        train_createPageLink(factory, page, link);
+        train_toRedirectURI(link, LINK_URI);
+
+        response.sendRedirect(LINK_URI);
+
         replay();
 
-        ComponentEventHandler<Component> handler = new ComponentInstanceEventHandler(cache, log);
+        ComponentEventResultProcessor<Component> processor = new ComponentInstanceResultProcessor(
+                cache, factory, log);
 
-        handler.handleResult(child, source, METHOD_DESCRIPTION);
+        processor.processComponentEvent(child, source, METHOD_DESCRIPTION).sendClientResponse(
+                response);
 
         verify();
     }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/LinkFactoryImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/LinkFactoryImplTest.java?view=diff&rev=494965&r1=494964&r2=494965
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/LinkFactoryImplTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/LinkFactoryImplTest.java Wed Jan 10 12:22:38 2007
@@ -14,6 +14,8 @@
 
 package org.apache.tapestry.internal.services;
 
+import static org.easymock.EasyMock.isA;
+
 import org.apache.tapestry.ComponentEventHandler;
 import org.apache.tapestry.Link;
 import org.apache.tapestry.TapestryConstants;
@@ -30,6 +32,8 @@
 
 public class LinkFactoryImplTest extends InternalBaseTestCase
 {
+    private static final String ENCODED = "*encoded*";
+
     private static final String PAGE_LOGICAL_NAME = "sub/MyPage";
 
     private static final String PAGE_CLASS_NAME = "foo.pages.sub.MyPage";
@@ -74,6 +78,7 @@
         Page page = newPage();
         ComponentPageElement rootElement = newComponentPageElement();
         LinkFactoryListener listener = newLinkFactoryListener();
+        ComponentInvocationMap map = newComponentInvocationMap();
 
         final Holder<Link> holder = new Holder<Link>();
 
@@ -120,22 +125,23 @@
                         (Object[]) EasyMock.isNull(),
                         EasyMock.isA(ComponentEventHandler.class))).andAnswer(triggerEventAnswer);
 
-        train_encodeRedirectURL(
-                response,
-                "/barney/" + PAGE_LOGICAL_NAME + ".html/foo/bar",
-                "*encoded*");
+        train_encodeRedirectURL(response, "/barney/" + PAGE_LOGICAL_NAME + ".html/foo/bar", ENCODED);
 
         listener.createdPageLink(EasyMock.isA(Link.class));
         getMocksControl().andAnswer(createdPageLinkAnswer);
 
+        // This needs to be refactored a bit to be more testable.
+
+        map.store(isA(Link.class), isA(ComponentInvocation.class));
+
         replay();
 
-        LinkFactory factory = new LinkFactoryImpl(request, response, resolver);
+        LinkFactory factory = new LinkFactoryImpl(request, response, resolver, map);
         factory.addListener(listener);
 
         Link link = factory.createPageLink(page);
 
-        assertEquals(link.toRedirectURI(), "*encoded*");
+        assertEquals(link.toRedirectURI(), ENCODED);
 
         // Make sure the link was passed to the LinkFactoryListener
 
@@ -144,11 +150,6 @@
         verify();
     }
 
-    protected final LinkFactoryListener newLinkFactoryListener()
-    {
-        return newMock(LinkFactoryListener.class);
-    }
-
     @SuppressWarnings("unchecked")
     private void run(String pageClassName, String logicalPageName, String nestedId,
             String contextPath, String expectedURI, Object... context)
@@ -159,6 +160,7 @@
         ComponentPageElement element = newComponentPageElement();
         Page page = newPage();
         LinkFactoryListener listener = newLinkFactoryListener();
+        ComponentInvocationMap map = newComponentInvocationMap();
 
         final Holder<Link> holder = new Holder<Link>();
 
@@ -183,16 +185,20 @@
         listener.createdActionLink(EasyMock.isA(Link.class));
         getMocksControl().andAnswer(createActionLinkAnswer);
 
-        train_encodeURL(response, expectedURI, "*encoded*");
+        // This needs to be refactored a bit to be more testable.
+
+        map.store(isA(Link.class), isA(ComponentInvocation.class));
+
+        train_encodeURL(response, expectedURI, ENCODED);
 
         replay();
 
-        LinkFactory factory = new LinkFactoryImpl(request, response, resolver);
+        LinkFactory factory = new LinkFactoryImpl(request, response, resolver, map);
         factory.addListener(listener);
 
         Link link = factory.createActionLink(element, "someaction", false, context);
 
-        assertEquals(link.toURI(), "*encoded*");
+        assertEquals(link.toURI(), ENCODED);
         assertSame(link, holder.get());
 
         verify();

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/LinkImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/LinkImplTest.java?view=diff&rev=494965&r1=494964&r2=494965
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/LinkImplTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/LinkImplTest.java Wed Jan 10 12:22:38 2007
@@ -132,12 +132,12 @@
 
         replay();
 
-        Link link = new LinkImpl(response, "/foo", "bar");
+        Link link = new LinkImpl(response, "/foo", "bar", true);
 
         link.addParameter("fred", "flintstone");
         link.addParameter("barney", "rubble");
 
-        assertEquals(link.toFormURI(), ENCODED);
+        assertEquals(link.toURI(), ENCODED);
 
         verify();
     }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/MarkupWriterImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/MarkupWriterImplTest.java?view=diff&rev=494965&r1=494964&r2=494965
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/MarkupWriterImplTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/MarkupWriterImplTest.java Wed Jan 10 12:22:38 2007
@@ -14,18 +14,14 @@
 
 package org.apache.tapestry.internal.services;
 
-import java.util.Map;
-
 import org.apache.tapestry.Link;
 import org.apache.tapestry.MarkupWriter;
-import org.apache.tapestry.dom.DefaultMarkupModel;
 import org.apache.tapestry.dom.Element;
-import org.apache.tapestry.ioc.internal.util.CollectionFactory;
-import org.apache.tapestry.test.pagelevel.NoOpURLEncoder;
-import org.testng.Assert;
+import org.apache.tapestry.dom.XMLMarkupModel;
+import org.apache.tapestry.internal.test.InternalBaseTestCase;
 import org.testng.annotations.Test;
 
-public class MarkupWriterImplTest extends Assert
+public class MarkupWriterImplTest extends InternalBaseTestCase
 {
     @Test(expectedExceptions = IllegalStateException.class)
     public void write_with_no_current_element()
@@ -170,49 +166,21 @@
     }
 
     @Test
-    public void link_element()
+    public void writer_notifies_map_about_links()
     {
-        final Map<Element, ComponentInvocation> map = CollectionFactory.newMap();
-        MarkupWriter w = new MarkupWriterImpl(new DefaultMarkupModel(),
-                new ComponentInvocationMap()
-                {
-
-                    public void put(Element element, ComponentInvocation invocation)
-                    {
-                        map.put(element, invocation);
-
-                    }
-
-                });
-        ComponentInvocation invocation = new ComponentInvocation(new OpaqueConstantTarget("foo"),
-                new Object[0]);
-        Link link = new LinkImpl(new NoOpURLEncoder(), "", invocation);
-        Element element = w.linkElement("a", link, "href", "foo.png");
-        w.end();
-        assertEquals(w.toString(), "<a href=\"foo.png\"></a>");
-        assertEquals(map.size(), 1);
-        assertSame(map.get(element), invocation);
-    }
+        ComponentInvocationMap map = newComponentInvocationMap();
 
-    @Test
-    public void link_element_no_map()
-    {
-        final Map<Element, ComponentInvocation> map = CollectionFactory.newMap();
-        MarkupWriter w = new MarkupWriterImpl();
-        ComponentInvocation invocation = new ComponentInvocation(new OpaqueConstantTarget("foo"),
-                new Object[0]);
-        Link link = new LinkImpl(new NoOpURLEncoder(), "", invocation);
-        w.linkElement("a", link, "href", "foo.png");
-        w.end();
-        assertEquals(w.toString(), "<a href=\"foo.png\"></a>");
-        assertEquals(map.size(), 0);
-    }
+        MarkupWriter writer = new MarkupWriterImpl(new XMLMarkupModel(), map);
+        Link link = newLink();
 
-    @Test(expectedExceptions =
-    { IllegalArgumentException.class })
-    public void link_null()
-    {
-        MarkupWriter w = new MarkupWriterImpl();
-        w.linkElement("a", null, "href", "foo.png");
+        Element e = writer.element("form");
+
+        map.store(e, link);
+
+        replay();
+
+        writer.attributes("action", link);
+
+        verify();
     }
 }

Added: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ObjectComponentEventResultProcessorTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ObjectComponentEventResultProcessorTest.java?view=auto&rev=494965
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ObjectComponentEventResultProcessorTest.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ObjectComponentEventResultProcessorTest.java Wed Jan 10 12:22:38 2007
@@ -0,0 +1,52 @@
+package org.apache.tapestry.internal.services;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.tapestry.ComponentResources;
+import org.apache.tapestry.ioc.internal.util.CollectionFactory;
+import org.apache.tapestry.ioc.internal.util.TapestryException;
+import org.apache.tapestry.runtime.Component;
+import org.apache.tapestry.services.ComponentEventResultProcessor;
+import org.apache.tapestry.test.TapestryTestCase;
+import org.testng.annotations.Test;
+
+public class ObjectComponentEventResultProcessorTest extends TapestryTestCase
+{
+    @SuppressWarnings("unchecked")
+    @Test
+    public void invocation_is_failure()
+    {
+        ComponentResources resources = newComponentResources();
+        Component component = newComponent();
+        String result = "*INVALID*";
+
+        train_getComponentResources(component, resources);
+        train_getCompleteId(resources, "foo.Bar:gnip.gnop");
+
+        Set<Class> classes = CollectionFactory.newSet(Arrays.asList(
+                String.class,
+                Map.class,
+                List.class));
+
+        replay();
+
+        ComponentEventResultProcessor p = new ObjectComponentEventResultProcessor(classes);
+
+        try
+        {
+            p.processComponentEvent(result, component, "foo.component.Gnop.blip()");
+            unreachable();
+        }
+        catch (TapestryException ex)
+        {
+            assertEquals(
+                    ex.getMessage(),
+                    "An event handler for component foo.Bar:gnip.gnop returned the value *INVALID* (from method foo.component.Gnop.blip()).  "
+                            + "Return type java.lang.String can not be handled.  "
+                            + "Configured return types are java.lang.String, java.util.List, java.util.Map.");
+        }
+    }
+}



Mime
View raw message