You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2009/02/17 16:25:17 UTC
svn commit: r745118 [2/2] - in /tapestry/tapestry5/trunk:
src/site/apt/guide/ tapestry-core/src/main/java/org/apache/tapestry5/
tapestry-core/src/main/java/org/apache/tapestry5/internal/
tapestry-core/src/main/java/org/apache/tapestry5/internal/model/ ...
Added: tapestry/tapestry5/trunk/tapestry-core/src/test/app1/DupeMixinDemo.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app1/DupeMixinDemo.tml?rev=745118&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app1/DupeMixinDemo.tml (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app1/DupeMixinDemo.tml Tue Feb 17 15:25:11 2009
@@ -0,0 +1,6 @@
+<t:border xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd"
+ xmlns:p="tapestry:parameter">
+
+ <t:form t:mixins="renderInformals"/>
+
+</t:border>
\ No newline at end of file
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/app1/Index.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app1/Index.tml?rev=745118&r1=745117&r2=745118&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app1/Index.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app1/Index.tml Tue Feb 17 15:25:11 2009
@@ -111,6 +111,18 @@
<a href="PublishUnknownParameterDemo">Publish Unknown Parameter Demo</a>
-- publishing a parameter which does not exist
</li>
+ <li>
+ <a href="BadMixinIdDemo">Bad Mixin Id Demo</a>
+ -- error reporting when a parameter specifies a mixin id that does not exist
+ </li>
+ <li>
+ <a href="DupeMixinDemo">Duplicate Mixin Demo</a>
+ -- error reporting for adding a duplicate mixin to a component
+ </li>
+ <li>
+ <a href="UnsupportedParameterBlockDemo">Unsupported Parameter Block Demo</a>
+ -- informal block parameter to a component that does not support informal parameters
+ </li>
</ul>
</html>
Added: tapestry/tapestry5/trunk/tapestry-core/src/test/app1/UnsupportedParameterBlockDemo.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app1/UnsupportedParameterBlockDemo.tml?rev=745118&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app1/UnsupportedParameterBlockDemo.tml (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app1/UnsupportedParameterBlockDemo.tml Tue Feb 17 15:25:11 2009
@@ -0,0 +1,7 @@
+<t:border xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd"
+ xmlns:p="tapestry:parameter">
+
+ <t:outputraw>
+ <p:unexpected>Informal parameter to component that does not support them.</p:unexpected>
+ </t:outputraw>
+</t:border>
\ No newline at end of file
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java?rev=745118&r1=745117&r2=745118&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java Tue Feb 17 15:25:11 2009
@@ -2595,4 +2595,29 @@
"is improperly published from embedded component 'publish1' (where it does not exist). " +
"This may be a typo in the publishParameters attribute of the @Component annotation.");
}
+
+ public void unknown_mixin_id()
+ {
+ start("Bad Mixin Id Demo");
+
+ assertTextPresent("Mixin id for parameter 'unknownmixinid.foo' not found. Attached mixins: RenderInformals.");
+ }
+
+ public void duplicate_mixin()
+ {
+ start("Duplicate Mixin Demo");
+
+ assertTextPresent(
+ "Failure creating embedded component 'form' of " +
+ "org.apache.tapestry5.integration.app1.pages.DupeMixinDemo: " +
+ "Mixins applied to a component must be unique. Mixin 'RenderInformals' has already been applied.");
+ }
+
+ public void unsupported_informal_block_parameter()
+ {
+ start("Unsupported Parameter Block Demo");
+
+ assertTextPresent("Exception assembling root component of page UnsupportedParameterBlockDemo:",
+ "Component UnsupportedParameterBlockDemo:outputraw does not include a formal parameter 'unexpected' (and does not support informal parameters).");
+ }
}
\ No newline at end of file
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/PageTesterTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/PageTesterTest.java?rev=745118&r1=745117&r2=745118&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/PageTesterTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/PageTesterTest.java Tue Feb 17 15:25:11 2009
@@ -1,4 +1,4 @@
-// Copyright 2008 The Apache Software Foundation
+// Copyright 2008, 2009 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.
@@ -15,8 +15,13 @@
package org.apache.tapestry5.integration;
import org.apache.tapestry5.dom.Document;
+import org.apache.tapestry5.integration.pagelevel.TestConstants;
+import org.apache.tapestry5.internal.InternalSymbols;
+import org.apache.tapestry5.ioc.services.SymbolSource;
import org.apache.tapestry5.test.PageTester;
import org.testng.Assert;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import java.util.Collections;
@@ -27,13 +32,25 @@
*/
public class PageTesterTest extends Assert
{
- private static final String PACKAGE = "org.apache.tapestry5.integration.app2";
+ private PageTester tester;
+
+ @BeforeClass
+ public void setup()
+ {
+ tester = new PageTester(TestConstants.APP2_PACKAGE, TestConstants.APP2_NAME, "src/test/app2");
+ }
+
+ @AfterClass
+ public void cleanup()
+ {
+ tester.shutdown();
+
+ tester = null;
+ }
@Test
public void on_activate_chain_is_followed()
{
- PageTester tester = new PageTester(PACKAGE, "", "src/test/app2");
-
Document launchDoc = tester.renderPage("Launch");
Map<String, String> parameters = Collections.emptyMap();
@@ -44,7 +61,13 @@
Document finalDoc = tester.submitForm(launchDoc.getElementById("form"), parameters);
assertEquals(finalDoc.getElementById("page-name").getChildMarkup(), "Final");
+ }
- tester.shutdown();
+ @Test
+ public void application_path_is_defined_as_a_symbol()
+ {
+ SymbolSource source = tester.getRegistry().getService(SymbolSource.class);
+
+ assertEquals(source.valueForSymbol(InternalSymbols.APP_PACKAGE_PATH), "org/apache/tapestry5/integration/app2");
}
}
Added: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/BadMixinIdDemo.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/BadMixinIdDemo.java?rev=745118&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/BadMixinIdDemo.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/BadMixinIdDemo.java Tue Feb 17 15:25:11 2009
@@ -0,0 +1,19 @@
+// Copyright 2009 ${ORG}
+//
+// 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.tapestry5.integration.app1.pages;
+
+public class BadMixinIdDemo
+{
+}
Added: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/DupeMixinDemo.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/DupeMixinDemo.java?rev=745118&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/DupeMixinDemo.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/DupeMixinDemo.java Tue Feb 17 15:25:11 2009
@@ -0,0 +1,19 @@
+// Copyright 2009 ${ORG}
+//
+// 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.tapestry5.integration.app1.pages;
+
+public class DupeMixinDemo
+{
+}
Added: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/UnsupportedParameterBlockDemo.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/UnsupportedParameterBlockDemo.java?rev=745118&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/UnsupportedParameterBlockDemo.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/UnsupportedParameterBlockDemo.java Tue Feb 17 15:25:11 2009
@@ -0,0 +1,19 @@
+// Copyright 2009 ${ORG}
+//
+// 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.tapestry5.integration.app1.pages;
+
+public class UnsupportedParameterBlockDemo
+{
+}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/ASOTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/ASOTest.java?rev=745118&r1=745117&r2=745118&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/ASOTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/ASOTest.java Tue Feb 17 15:25:11 2009
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007 The Apache Software Foundation
+// Copyright 2006, 2007, 2009 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.
@@ -27,9 +27,8 @@
@Test
public void submit_aso()
{
- String appPackage = "org.apache.tapestry5.integration.app2";
- String appName = "";
- tester = new PageTester(appPackage, appName);
+ tester = new PageTester(TestConstants.APP2_PACKAGE, TestConstants.APP2_NAME);
+
Document doc = tester.renderPage("TestPageForASO");
assertTrue(doc.toString().contains("bar"));
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/ActionLinkTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/ActionLinkTest.java?rev=745118&r1=745117&r2=745118&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/ActionLinkTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/ActionLinkTest.java Tue Feb 17 15:25:11 2009
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007 The Apache Software Foundation
+// Copyright 2006, 2007, 2009 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.
@@ -28,9 +28,9 @@
@Test
public void click_link()
{
- String appPackage = "org.apache.tapestry5.integration.app2";
- String appName = "";
- tester = new PageTester(appPackage, appName);
+
+ tester = new PageTester(TestConstants.APP2_PACKAGE, TestConstants.APP2_NAME);
+
Document doc = tester.renderPage("TestPageForActionLink");
Element link = doc.getElementById("link1");
doc = tester.clickLink(link);
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/AssetTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/AssetTest.java?rev=745118&r1=745117&r2=745118&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/AssetTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/AssetTest.java Tue Feb 17 15:25:11 2009
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007 The Apache Software Foundation
+// Copyright 2006, 2007, 2009 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.
@@ -27,10 +27,10 @@
@Test
public void submit_context_asset()
{
- String appPackage = "org.apache.tapestry5.integration.app2";
- String appName = "";
- tester = new PageTester(appPackage, appName, "src/test/app2");
+ tester = new PageTester(TestConstants.APP2_PACKAGE, TestConstants.APP2_NAME, "src/test/app2");
+
Document doc = tester.renderPage("TestPageForAsset");
+
assertTrue(doc.toString().contains("test.css"));
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/DTDTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/DTDTest.java?rev=745118&r1=745117&r2=745118&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/DTDTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/DTDTest.java Tue Feb 17 15:25:11 2009
@@ -42,9 +42,8 @@
@Test(dataProvider = "dtd_page_provider")
public void verify_correct_dtds(String pageName, String expectedDTD, String checkText)
{
- String appPackage = "org.apache.tapestry5.integration.app2";
- String appName = "";
- PageTester tester = new PageTester(appPackage, appName);
+ PageTester tester = new PageTester(TestConstants.APP2_PACKAGE, TestConstants.APP2_NAME);
+
Document doc = tester.renderPage(pageName);
String txt = doc.toString();
// use startsWith to make sure the DTD is getting into the right spot.
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/FormTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/FormTest.java?rev=745118&r1=745117&r2=745118&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/FormTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/FormTest.java Tue Feb 17 15:25:11 2009
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007 The Apache Software Foundation
+// Copyright 2006, 2007, 2009 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.
@@ -31,9 +31,8 @@
@Test
public void submit_form()
{
- String appPackage = "org.apache.tapestry5.integration.app2";
- String appName = "";
- tester = new PageTester(appPackage, appName);
+ tester = new PageTester(TestConstants.APP2_PACKAGE, TestConstants.APP2_NAME);
+
Document doc = tester.renderPage("TestPageForForm");
Element form = doc.getElementById("form1");
Map<String, String> fieldValues = CollectionFactory.newMap();
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/HeadTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/HeadTest.java?rev=745118&r1=745117&r2=745118&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/HeadTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/HeadTest.java Tue Feb 17 15:25:11 2009
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007 The Apache Software Foundation
+// Copyright 2006, 2007, 2009 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.
@@ -27,9 +27,8 @@
@Test
public void display()
{
- String appPackage = "org.apache.tapestry5.integration.app2";
- String appName = "";
- tester = new PageTester(appPackage, appName);
+ tester = new PageTester(TestConstants.APP2_PACKAGE, TestConstants.APP2_NAME);
+
Document doc = tester.renderPage("TestPageForHead");
assertTrue(doc.toString().contains("OK"));
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/IfTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/IfTest.java?rev=745118&r1=745117&r2=745118&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/IfTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/IfTest.java Tue Feb 17 15:25:11 2009
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007, 2008 The Apache Software Foundation
+// Copyright 2006, 2007, 2008, 2009 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.
@@ -27,9 +27,8 @@
@Test
public void render()
{
- String appPackage = "org.apache.tapestry5.integration.app2";
- String appName = "";
- tester = new PageTester(appPackage, appName);
+ tester = new PageTester(TestConstants.APP2_PACKAGE, TestConstants.APP2_NAME);
+
Document doc = tester.renderPage("TestPageForIf");
assertNotNull(doc.getElementById("1"));
assertNotNull(doc.getElementById("3"));
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/LocaleTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/LocaleTest.java?rev=745118&r1=745117&r2=745118&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/LocaleTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/LocaleTest.java Tue Feb 17 15:25:11 2009
@@ -46,7 +46,7 @@
public void change_language_in_browser()
{
tester.setPreferedLanguage(Locale.ENGLISH);
-
+
Document doc = tester.renderPage("TestPageForLocale");
assertEquals(doc.getElementById("id1").getChildMarkup(), "English page");
@@ -54,17 +54,15 @@
tester.setPreferedLanguage(Locale.CANADA_FRENCH);
doc = tester.renderPage("TestPageForLocale");
-
+
assertEquals(doc.getElementById("id1").getChildMarkup(), "French page");
}
@BeforeMethod
public void before()
{
- String appPackage = "org.apache.tapestry5.integration.app2";
// LocaleAppModule.java has configured support for a certain locales.
- String appName = "LocaleApp";
- tester = new PageTester(appPackage, appName);
+ tester = new PageTester(TestConstants.APP2_PACKAGE, TestConstants.APP2_NAME);
}
@AfterMethod
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/LoopTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/LoopTest.java?rev=745118&r1=745117&r2=745118&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/LoopTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/LoopTest.java Tue Feb 17 15:25:11 2009
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007 The Apache Software Foundation
+// Copyright 2006, 2007, 2009 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.
@@ -27,9 +27,8 @@
@Test
public void render()
{
- String appPackage = "org.apache.tapestry5.integration.app2";
- String appName = "";
- tester = new PageTester(appPackage, appName);
+ tester = new PageTester(TestConstants.APP2_PACKAGE, TestConstants.APP2_NAME);
+
Document doc = tester.renderPage("TestPageForLoop");
assertTrue(doc.toString().contains("abcabcabc"));
assertEquals(doc.getElementById("1").getChildMarkup(), "xyz");
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/PrefixMethodTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/PrefixMethodTest.java?rev=745118&r1=745117&r2=745118&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/PrefixMethodTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/PrefixMethodTest.java Tue Feb 17 15:25:11 2009
@@ -1,4 +1,4 @@
-// Copyright 2007 The Apache Software Foundation
+// Copyright 2007, 2009 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.
@@ -27,10 +27,9 @@
@Test
public void prefix_method() throws Exception
{
- // REFACTOR this happens in a bunch of places
- String appPackage = "org.apache.tapestry5.integration.app2";
- String appName = "";
- tester = new PageTester(appPackage, appName, PageTester.DEFAULT_CONTEXT_PATH, LocaleAppModule.class);
+ tester = new PageTester(TestConstants.APP2_PACKAGE, TestConstants.APP2_NAME, PageTester.DEFAULT_CONTEXT_PATH,
+ LocaleAppModule.class);
+
Document doc = tester.renderPage("TestPrefixMethod");
// make sure you can use on methods that have injected fields
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/SubmitTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/SubmitTest.java?rev=745118&r1=745117&r2=745118&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/SubmitTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/SubmitTest.java Tue Feb 17 15:25:11 2009
@@ -55,7 +55,7 @@
public void not_a_submit()
{
Element submitButton = doc.getElementById("t1");
-
+
tester.clickSubmit(submitButton, fieldValues);
}
@@ -79,9 +79,8 @@
@BeforeMethod
public void before()
{
- String appPackage = "org.apache.tapestry5.integration.app2";
- String appName = "";
- tester = new PageTester(appPackage, appName);
+ tester = new PageTester(TestConstants.APP2_PACKAGE, TestConstants.APP2_NAME);
+
doc = tester.renderPage("TestPageForSubmit");
fieldValues = CollectionFactory.newMap();
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/TemplateInContextTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/TemplateInContextTest.java?rev=745118&r1=745117&r2=745118&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/TemplateInContextTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/TemplateInContextTest.java Tue Feb 17 15:25:11 2009
@@ -1,4 +1,4 @@
-// Copyright 2007 The Apache Software Foundation
+// Copyright 2007, 2009 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.
@@ -27,9 +27,8 @@
@Test
public void template_in_web_context()
{
- String appPackage = "org.apache.tapestry5.integration.app2";
- String appName = "";
- tester = new PageTester(appPackage, appName, "src/test/app2");
+ tester = new PageTester(TestConstants.APP2_PACKAGE, TestConstants.APP2_NAME, "src/test/app2");
+
Document doc = tester.renderPage("TestPageForTemplateInContext");
assertTrue(doc.toString().contains("How are you?"));
}
Added: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/TestConstants.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/TestConstants.java?rev=745118&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/TestConstants.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/TestConstants.java Tue Feb 17 15:25:11 2009
@@ -0,0 +1,28 @@
+// Copyright 2009 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.tapestry5.integration.pagelevel;
+
+/**
+ * Constants for application name and package used by many of the unit tests.
+ */
+public class TestConstants
+{
+ /**
+ * @see org.apache.tapestry5.integration.app2.services.LocaleAppModule
+ */
+ public static final String APP2_NAME = "LocaleApp";
+
+ public static final String APP2_PACKAGE = "org.apache.tapestry5.integration.app2";
+}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/UnlessTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/UnlessTest.java?rev=745118&r1=745117&r2=745118&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/UnlessTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/UnlessTest.java Tue Feb 17 15:25:11 2009
@@ -1,4 +1,4 @@
-// Copyright 2008 The Apache Software Foundation
+// Copyright 2008, 2009 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.
@@ -27,9 +27,8 @@
@Test
public void render()
{
- String appPackage = "org.apache.tapestry5.integration.app2";
- String appName = "";
- tester = new PageTester(appPackage, appName);
+ tester = new PageTester(TestConstants.APP2_PACKAGE, TestConstants.APP2_NAME);
+
Document doc = tester.renderPage("TestPageForUnless");
assertNotNull(doc.getElementById("2"));
assertNotNull(doc.getElementById("4"));
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ComponentMessagesSourceImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ComponentMessagesSourceImplTest.java?rev=745118&r1=745117&r2=745118&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ComponentMessagesSourceImplTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ComponentMessagesSourceImplTest.java Tue Feb 17 15:25:11 2009
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007 The Apache Software Foundation
+// Copyright 2006, 2007, 2009 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.
@@ -36,7 +36,7 @@
// With control of the tracker, we can force changes as if underlying files were changed.
private static final String SIMPLE_COMPONENT_CLASS_NAME = "org.apache.tapestry5.internal.services.SimpleComponent";
-
+
private final ClasspathURLConverter converter = new ClasspathURLConverterImpl();
private final URLChangeTracker tracker = new URLChangeTracker(converter);
@@ -45,7 +45,7 @@
"org/apache/tapestry5/internal/services/SimpleComponent.class");
private final ComponentMessagesSourceImpl source = new ComponentMessagesSourceImpl(
- simpleComponentResource, "AppCatalog.properties", tracker);
+ simpleComponentResource.forFile("AppCatalog.properties"), tracker);
@Test
public void simple_component()
@@ -208,9 +208,8 @@
forceCacheClear();
- ComponentMessagesSource source = new ComponentMessagesSourceImpl(simpleComponentResource,
- "NoSuchAppCatalog.properties",
- converter);
+ ComponentMessagesSource source = new ComponentMessagesSourceImpl(
+ simpleComponentResource.forFile("NoSuchAppCatalog.properties"), converter);
Messages messages = source.getMessages(model, Locale.ENGLISH);
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/LinkSourceImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/LinkSourceImplTest.java?rev=745118&r1=745117&r2=745118&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/LinkSourceImplTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/LinkSourceImplTest.java Tue Feb 17 15:25:11 2009
@@ -17,10 +17,10 @@
import org.apache.tapestry5.EventConstants;
import org.apache.tapestry5.EventContext;
import org.apache.tapestry5.Link;
-import org.apache.tapestry5.internal.EmptyEventContext;
import org.apache.tapestry5.internal.structure.Page;
import org.apache.tapestry5.internal.test.InternalBaseTestCase;
import org.apache.tapestry5.ioc.services.TypeCoercer;
+import org.apache.tapestry5.services.ComponentClassResolver;
import org.apache.tapestry5.services.ComponentEventRequestParameters;
import org.apache.tapestry5.services.LinkCreationListener;
import org.apache.tapestry5.services.PageRenderRequestParameters;
@@ -31,8 +31,6 @@
{
private TypeCoercer typeCoercer;
- private final EventContext EMPTY = new EmptyEventContext();
-
@BeforeClass
public void setup()
{
@@ -85,22 +83,20 @@
@Test
public void create_page_render_link_by_name()
{
- String logicalName = "order/Edit";
+ String pageName = "order/Edit";
- Page page = mockPage();
PageActivationContextCollector collector = mockPageActivationContextCollector();
RequestPageCache pageCache = mockRequestPageCache();
LinkFactory factory = mockLinkFactory();
Link link = mockLink();
+ ComponentClassResolver resolver = mockComponentClassResolver();
- train_get(pageCache, logicalName, page);
-
- train_getName(page, logicalName);
+ train_canonicalizePageName(resolver, pageName, pageName);
- train_collectPageActivationContext(collector, page, 3);
+ train_collectPageActivationContext(collector, pageName, 3);
EventContext pageActivationContext = new ArrayEventContext(typeCoercer, 3);
- PageRenderRequestParameters parameters = new PageRenderRequestParameters(logicalName, pageActivationContext);
+ PageRenderRequestParameters parameters = new PageRenderRequestParameters(pageName, pageActivationContext);
expect(factory.createPageRenderLink(parameters)).andReturn(link);
@@ -108,10 +104,10 @@
LinkSource source = new LinkSourceImpl(pageCache, null,
- collector, factory, typeCoercer);
+ collector, factory, typeCoercer, resolver);
- Link actual = source.createPageRenderLink(logicalName, false);
+ Link actual = source.createPageRenderLink(pageName, false);
// Make sure the same link is returned.
@@ -123,19 +119,20 @@
private void testPageLinkCreation(String pageName, boolean overrideContext,
Object... context)
{
- Page page = mockPage();
PageActivationContextCollector collector = mockPageActivationContextCollector();
LinkCreationListener listener = mockLinkCreationListener();
LinkFactory factory = mockLinkFactory();
Link link = mockLink();
+ ComponentClassResolver resolver = mockComponentClassResolver();
+ String canonical = "CanonicalPageName";
- train_getName(page, pageName);
+ train_canonicalizePageName(resolver, pageName, canonical);
if (!overrideContext)
- train_collectPageActivationContext(collector, page, context);
+ train_collectPageActivationContext(collector, canonical, context);
PageRenderRequestParameters parameters =
- new PageRenderRequestParameters(pageName,
+ new PageRenderRequestParameters(canonical,
new ArrayEventContext(typeCoercer, context));
expect(factory.createPageRenderLink(parameters)).andReturn(link);
@@ -145,13 +142,13 @@
replay();
LinkSource source = new LinkSourceImpl(null, null,
- collector, factory, typeCoercer);
+ collector, factory, typeCoercer, resolver);
source.getLinkCreationHub().addListener(listener);
Object[] passedContext = overrideContext ? context : new Object[0];
- Link returnedLink = source.createPageRenderLink(page, overrideContext, passedContext);
+ Link returnedLink = source.createPageRenderLink(pageName, overrideContext, passedContext);
assertSame(returnedLink, link);
@@ -185,14 +182,12 @@
testEventLinkCreation("order/Edit", "foo.bar",
EventConstants.ACTION,
true, "fred", "barney");
-
- // assertEquals(link.getParameterValue(InternalConstants.PAGE_CONTEXT_NAME), "a/b");
}
@Test
public void component_event_from_other_page()
{
- String logicalName = "blocks/AppDisplay";
+ String primaryPageName = "blocks/AppDisplay";
Page primaryPage = mockPage();
Page activePage = mockPage();
@@ -201,18 +196,17 @@
LinkFactory factory = mockLinkFactory();
Link link = mockLink();
-
train_getRenderingPage(queue, activePage);
- train_getName(primaryPage, logicalName);
train_getName(activePage, "order/View");
+ train_getName(primaryPage, primaryPageName);
- train_collectPageActivationContext(collector, activePage, "x", "y");
+ train_collectPageActivationContext(collector, "order/View", "x", "y");
EventContext pageActivationContext = new ArrayEventContext(typeCoercer, "x", "y");
EventContext eventContext = new ArrayEventContext(typeCoercer, 3, 5, 9);
- ComponentEventRequestParameters parameters = new ComponentEventRequestParameters("order/View", logicalName,
+ ComponentEventRequestParameters parameters = new ComponentEventRequestParameters("order/View", primaryPageName,
"gnip.gnop", "myevent",
pageActivationContext,
eventContext);
@@ -222,16 +216,18 @@
replay();
LinkSource source = new LinkSourceImpl(null, queue,
- collector, factory, typeCoercer);
+ collector, factory, typeCoercer, null);
assertSame(source.createComponentEventLink(primaryPage, "gnip.gnop", "myevent", true, 3, 5, 9), link);
verify();
}
- private void testEventLinkCreation(String logicalName, String nestedId,
+ private void testEventLinkCreation(String pageName,
+ String nestedId,
String eventType,
- boolean forForm, Object... context)
+ boolean forForm,
+ Object... context)
{
Page primaryPage = mockPage();
PageRenderQueue queue = mockPageRenderQueue();
@@ -248,13 +244,13 @@
train_getRenderingPage(queue, null);
- train_getName(primaryPage, logicalName);
+ train_getName(primaryPage, pageName);
- train_collectPageActivationContext(collector, primaryPage, "a", "b");
+ train_collectPageActivationContext(collector, pageName, "a", "b");
ComponentEventRequestParameters parameters =
- new ComponentEventRequestParameters(logicalName, logicalName,
+ new ComponentEventRequestParameters(pageName, pageName,
nestedId, eventType,
pageEventContext, eventContext);
@@ -265,7 +261,7 @@
replay();
LinkSource source = new LinkSourceImpl(null, queue,
- collector, factory, typeCoercer);
+ collector, factory, typeCoercer, null);
source.getLinkCreationHub().addListener(listener);
@@ -278,10 +274,10 @@
verify();
}
- protected final void train_collectPageActivationContext(PageActivationContextCollector collector, Page page,
+ protected final void train_collectPageActivationContext(PageActivationContextCollector collector, String pageName,
Object... context)
{
- expect(collector.collectPageActivationContext(page)).andReturn(context);
+ expect(collector.collectPageActivationContext(pageName)).andReturn(context);
}
protected final PageActivationContextCollector mockPageActivationContextCollector()
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/MetaDataLocatorImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/MetaDataLocatorImplTest.java?rev=745118&r1=745117&r2=745118&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/MetaDataLocatorImplTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/MetaDataLocatorImplTest.java Tue Feb 17 15:25:11 2009
@@ -1,4 +1,4 @@
-// Copyright 2007, 2008 The Apache Software Foundation
+// Copyright 2007, 2008, 2009 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.
@@ -43,6 +43,7 @@
ComponentResources resources = mockComponentResources();
ComponentModel model = mockComponentModel();
SymbolSource symbolSource = mockSymbolSource();
+ ComponentModelSource modelSource = mockComponentModelSource();
String key = "foo.bar";
String value = "zaphod";
@@ -57,7 +58,7 @@
Map<String, String> configuration = Collections.emptyMap();
- MetaDataLocator locator = new MetaDataLocatorImpl(symbolSource, typeCoercer, configuration);
+ MetaDataLocator locator = new MetaDataLocatorImpl(symbolSource, typeCoercer, modelSource, configuration);
assertSame(locator.findMeta(key, resources, String.class), value);
@@ -82,6 +83,7 @@
ComponentModel model = mockComponentModel();
ComponentModel containerModel = mockComponentModel();
SymbolSource symbolSource = mockSymbolSource();
+ ComponentModelSource modelSource = mockComponentModelSource();
String key = "foo.bar";
String value = "zaphod";
@@ -99,7 +101,7 @@
Map<String, String> configuration = Collections.emptyMap();
- MetaDataLocator locator = new MetaDataLocatorImpl(symbolSource, typeCoercer, configuration);
+ MetaDataLocator locator = new MetaDataLocatorImpl(symbolSource, typeCoercer, modelSource, configuration);
assertSame(locator.findMeta(key, resources, String.class), value);
@@ -112,6 +114,7 @@
ComponentResources resources = mockComponentResources();
ComponentModel model = mockComponentModel();
SymbolSource symbolSource = mockSymbolSource();
+ ComponentModelSource modelSource = mockComponentModelSource();
String key = "foo.bar";
String value = "zaphod";
@@ -132,7 +135,7 @@
Map<String, String> configuration = newMap();
configuration.put(key, value);
- MetaDataLocator locator = new MetaDataLocatorImpl(symbolSource, typeCoercer, configuration);
+ MetaDataLocator locator = new MetaDataLocatorImpl(symbolSource, typeCoercer, modelSource, configuration);
assertSame(locator.findMeta(key, resources, String.class), value);
@@ -155,6 +158,7 @@
ComponentResources resources = mockComponentResources();
ComponentModel model = mockComponentModel();
SymbolSource symbolSource = mockSymbolSource();
+ ComponentModelSource modelSource = mockComponentModelSource();
String key = "foo.bar";
String value = "zaphod";
@@ -174,7 +178,7 @@
Map<String, String> configuration = newMap();
configuration.put(key.toUpperCase(), value);
- MetaDataLocator locator = new MetaDataLocatorImpl(symbolSource, typeCoercer, configuration);
+ MetaDataLocator locator = new MetaDataLocatorImpl(symbolSource, typeCoercer, modelSource, configuration);
assertSame(locator.findMeta(key, resources, String.class), value);
@@ -197,6 +201,7 @@
ComponentResources resources = mockComponentResources();
ComponentModel model = mockComponentModel();
SymbolSource symbolSource = mockSymbolSource();
+ ComponentModelSource modelSource = mockComponentModelSource();
String key = "foo.bar";
String value = "zaphod";
@@ -217,7 +222,7 @@
configuration.put(key, "xxx");
configuration.put("foo:" + key, value);
- MetaDataLocator locator = new MetaDataLocatorImpl(symbolSource, typeCoercer, configuration);
+ MetaDataLocator locator = new MetaDataLocatorImpl(symbolSource, typeCoercer, modelSource, configuration);
assertSame(locator.findMeta(key, resources, String.class), value);
@@ -240,6 +245,7 @@
ComponentResources resources = mockComponentResources();
ComponentModel model = mockComponentModel();
SymbolSource symbolSource = mockSymbolSource();
+ ComponentModelSource modelSource = mockComponentModelSource();
String key = "foo.bar";
String value = "zaphod";
@@ -255,7 +261,8 @@
Map<String, String> configuration = Collections.emptyMap();
- MetaDataLocatorImpl locator = new MetaDataLocatorImpl(symbolSource, typeCoercer, configuration);
+ MetaDataLocatorImpl locator = new MetaDataLocatorImpl(symbolSource, typeCoercer, modelSource, configuration
+ );
assertSame(locator.findMeta(key, resources, String.class), value);
@@ -287,6 +294,7 @@
ComponentResources resources = mockComponentResources();
ComponentModel model = mockComponentModel();
SymbolSource symbolSource = mockSymbolSource();
+ ComponentModelSource modelSource = mockComponentModelSource();
String key = "foo.bar";
String value = "${zaphod}";
@@ -302,7 +310,7 @@
Map<String, String> configuration = Collections.emptyMap();
- MetaDataLocator locator = new MetaDataLocatorImpl(symbolSource, typeCoercer, configuration);
+ MetaDataLocator locator = new MetaDataLocatorImpl(symbolSource, typeCoercer, modelSource, configuration);
assertEquals(locator.findMeta(key, resources, Integer.class), new Integer(99));
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/PageActivationContextCollectorImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/PageActivationContextCollectorImplTest.java?rev=745118&r1=745117&r2=745118&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/PageActivationContextCollectorImplTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/PageActivationContextCollectorImplTest.java Tue Feb 17 15:25:11 2009
@@ -1,4 +1,4 @@
-// Copyright 2008 The Apache Software Foundation
+// Copyright 2008, 2009 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.
@@ -20,6 +20,7 @@
import org.apache.tapestry5.internal.structure.Page;
import org.apache.tapestry5.internal.test.InternalBaseTestCase;
import org.apache.tapestry5.ioc.services.TypeCoercer;
+import org.apache.tapestry5.model.ComponentModel;
import org.easymock.EasyMock;
import org.easymock.IAnswer;
import org.testng.annotations.BeforeClass;
@@ -40,7 +41,7 @@
@Test
public void page_with_array_activation_context()
{
- tryWithContext(new Object[] {3, "four", null, "$100"},
+ tryWithContext("MyPage", new Object[] { 3, "four", null, "$100" },
3, "four", null, "$100");
}
@@ -49,27 +50,36 @@
{
Object value = 99;
- tryWithContext(value, value);
+ tryWithContext("MyPage", value, value);
}
@Test
public void page_with_list_context()
{
- tryWithContext(Arrays.asList(1, 2, 3),
+ tryWithContext("MyPage", Arrays.asList(1, 2, 3),
1, 2, 3);
}
@Test
public void page_with_empty_context()
{
- tryWithContext(new String[0]);
+ tryWithContext("MyPage", new String[0]);
}
@Test
public void page_with_no_context()
{
+ String pageName = "mypage";
+ ComponentModel model = mockComponentModel();
+ ComponentModelSource modelSource = mockComponentModelSource();
+ RequestPageCache pageCache = mockRequestPageCache();
Page page = mockPage();
ComponentPageElement element = mockComponentPageElement();
+ expect(modelSource.getPageModel(pageName)).andReturn(model);
+
+ expect(model.handlesEvent(EventConstants.PASSIVATE)).andReturn(true);
+
+ train_get(pageCache, pageName, page);
train_getRootElement(page, element);
@@ -80,17 +90,50 @@
replay();
PageActivationContextCollector collector
- = new PageActivationContextCollectorImpl(coercer);
+ = new PageActivationContextCollectorImpl(coercer, pageCache, modelSource);
- Object[] actual = collector.collectPageActivationContext(page);
+ Object[] actual = collector.collectPageActivationContext(pageName);
assertEquals(actual.length, 0);
}
- private void tryWithContext(final Object context, Object... expected)
+ @Test
+ public void page_does_not_handle_passivate_event()
{
- Page page = mockPage();
+ String pageName = "mypage";
+ ComponentModel model = mockComponentModel();
+ ComponentModelSource modelSource = mockComponentModelSource();
+ RequestPageCache pageCache = mockRequestPageCache();
+
+ expect(modelSource.getPageModel(pageName)).andReturn(model);
+
+ expect(model.handlesEvent(EventConstants.PASSIVATE)).andReturn(false);
+
+ replay();
+
+ PageActivationContextCollector collector
+ = new PageActivationContextCollectorImpl(coercer, pageCache, modelSource);
+
+ Object[] actual = collector.collectPageActivationContext(pageName);
+
+ assertEquals(actual.length, 0);
+
+ }
+
+
+ private void tryWithContext(String pageName, final Object context, Object... expected)
+ {
+ ComponentModelSource modelSource = mockComponentModelSource();
+ RequestPageCache pageCache = mockRequestPageCache();
ComponentPageElement element = mockComponentPageElement();
+ ComponentModel model = mockComponentModel();
+ Page page = mockPage();
+
+ expect(modelSource.getPageModel(pageName)).andReturn(model);
+
+ expect(model.handlesEvent(EventConstants.PASSIVATE)).andReturn(true);
+
+ train_get(pageCache, pageName, page);
train_getRootElement(page, element);
@@ -113,9 +156,9 @@
replay();
PageActivationContextCollector collector
- = new PageActivationContextCollectorImpl(coercer);
+ = new PageActivationContextCollectorImpl(coercer, pageCache, modelSource);
- Object[] actual = collector.collectPageActivationContext(page);
+ Object[] actual = collector.collectPageActivationContext(pageName);
assertArraysEqual(actual, expected);
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/RequestSecurityManagerImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/RequestSecurityManagerImplTest.java?rev=745118&r1=745117&r2=745118&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/RequestSecurityManagerImplTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/RequestSecurityManagerImplTest.java Tue Feb 17 15:25:11 2009
@@ -14,12 +14,9 @@
package org.apache.tapestry5.internal.services;
-import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.Link;
import org.apache.tapestry5.MetaDataConstants;
-import org.apache.tapestry5.internal.structure.Page;
import org.apache.tapestry5.internal.test.InternalBaseTestCase;
-import org.apache.tapestry5.runtime.Component;
import org.apache.tapestry5.services.BaseURLSource;
import org.apache.tapestry5.services.MetaDataLocator;
import org.apache.tapestry5.services.Request;
@@ -39,14 +36,13 @@
LinkSource linkSource = mockLinkSource();
MetaDataLocator locator = mockMetaDataLocator();
BaseURLSource source = mockBaseURLSource();
- RequestPageCache cache = mockRequestPageCache();
train_isSecure(request, true);
replay();
RequestSecurityManager manager
- = new RequestSecurityManagerImpl(request, response, linkSource, locator, source, cache);
+ = new RequestSecurityManagerImpl(request, response, linkSource, locator, source);
assertFalse(manager.checkForInsecureRequest(PAGE_NAME));
@@ -61,19 +57,15 @@
LinkSource linkSource = mockLinkSource();
MetaDataLocator locator = mockMetaDataLocator();
BaseURLSource source = mockBaseURLSource();
- RequestPageCache cache = mockRequestPageCache();
- Page page = mockPage();
train_isSecure(request, false);
- train_get(cache, PAGE_NAME, page);
-
- train_isSecure(locator, page, false);
+ train_isSecure(locator, PAGE_NAME, false);
replay();
RequestSecurityManager manager
- = new RequestSecurityManagerImpl(request, response, linkSource, locator, source, cache);
+ = new RequestSecurityManagerImpl(request, response, linkSource, locator, source);
assertFalse(manager.checkForInsecureRequest(PAGE_NAME));
@@ -88,30 +80,31 @@
LinkSource linkSource = mockLinkSource();
MetaDataLocator locator = mockMetaDataLocator();
BaseURLSource source = mockBaseURLSource();
- Page page = mockPage();
Link link = mockLink();
- RequestPageCache cache = mockRequestPageCache();
train_isSecure(request, false);
- train_get(cache, PAGE_NAME, page);
-
- train_isSecure(locator, page, true);
+ train_isSecure(locator, PAGE_NAME, true);
- train_createPageRenderLink(linkSource, page, link);
+ train_createPageRenderLink(linkSource, PAGE_NAME, link);
response.sendRedirect(link);
replay();
RequestSecurityManager manager
- = new RequestSecurityManagerImpl(request, response, linkSource, locator, source, cache);
+ = new RequestSecurityManagerImpl(request, response, linkSource, locator, source);
assertTrue(manager.checkForInsecureRequest(PAGE_NAME));
verify();
}
+ private void train_createPageRenderLink(LinkSource linkSource, String pageName, Link link)
+ {
+ expect(linkSource.createPageRenderLink(pageName, false)).andReturn(link);
+ }
+
@DataProvider
public Object[][] base_URL_data()
{
@@ -131,10 +124,10 @@
LinkSource linkSource = mockLinkSource();
MetaDataLocator locator = mockMetaDataLocator();
BaseURLSource source = mockBaseURLSource();
- Page page = mockPage();
train_isSecure(request, secureRequest);
- train_isSecure(locator, page, securePage);
+
+ train_isSecure(locator, PAGE_NAME, securePage);
if (expectedURL != null)
train_getBaseURL(source, securePage, expectedURL);
@@ -142,22 +135,17 @@
replay();
RequestSecurityManager manager
- = new RequestSecurityManagerImpl(request, response, linkSource, locator, source, null);
+ = new RequestSecurityManagerImpl(request, response, linkSource, locator, source);
- assertEquals(manager.getBaseURL(page), expectedURL);
+ assertEquals(manager.getBaseURL(PAGE_NAME), expectedURL);
verify();
}
-
- private void train_isSecure(MetaDataLocator locator, Page page, boolean secure)
+ private static void train_isSecure(MetaDataLocator locator, String pageName, boolean securePage)
{
- Component component = mockComponent();
- ComponentResources resources = mockInternalComponentResources();
+ expect(locator.findMeta(MetaDataConstants.SECURE_PAGE, pageName, Boolean.class)).andReturn(securePage);
+ }
- train_getRootComponent(page, component);
- train_getComponentResources(component, resources);
- train_findMeta(locator, MetaDataConstants.SECURE_PAGE, resources, Boolean.class, secure);
- }
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/test/InternalBaseTestCase.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/test/InternalBaseTestCase.java?rev=745118&r1=745117&r2=745118&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/test/InternalBaseTestCase.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/test/InternalBaseTestCase.java Tue Feb 17 15:25:11 2009
@@ -409,11 +409,6 @@
return newMock(LinkSource.class);
}
- protected final void train_createPageRenderLink(LinkSource source, Page page, Link link)
- {
- expect(source.createPageRenderLink(page, false)).andReturn(link);
- }
-
protected final void train_isLoaded(InternalComponentResources resources, boolean isLoaded)
{
expect(resources.isLoaded()).andReturn(isLoaded);
@@ -599,11 +594,6 @@
return newMock(RequestSecurityManager.class);
}
- protected final void train_getBaseURL(RequestSecurityManager securityManager, Page page, String baseURL)
- {
- expect(securityManager.getBaseURL(page)).andReturn(baseURL).atLeastOnce();
- }
-
protected final ClientBehaviorSupport mockClientBehaviorSupport()
{
return newMock(ClientBehaviorSupport.class);
@@ -632,4 +622,9 @@
{
return newMock(LocalizationSetter.class);
}
+
+ protected final ComponentModelSource mockComponentModelSource()
+ {
+ return newMock(ComponentModelSource.class);
+ }
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/resources/log4j.properties?rev=745118&r1=745117&r2=745118&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/resources/log4j.properties (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/resources/log4j.properties Tue Feb 17 15:25:11 2009
@@ -1,4 +1,4 @@
-# Copyright 2005, 2006, 2007, 2008 The Apache Software Foundation
+# Copyright 2005, 2006, 2007, 2008, 2009 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.
@@ -25,6 +25,7 @@
log4j.category.tapestry.render=debug
log4j.category.org.apache.tapestry5.internal.services.InternalModule.PageResponseRenderer=debug
+log4j.category.org.apache.tapestry5.internal.services.InternalModule.PageLoader=debug
# log4j.category.org.apache.tapestry5.corelib.components=debug