TAP5-2070 new test integration app for activation context check
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/7e058593 Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/7e058593 Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/7e058593 Branch: refs/heads/master Commit: 7e058593bf074416bd8af97a66a1dc770021e8bd Parents: 83fcdca Author: Massimo Lusetti <mluse...@apache.org> Authored: Mon Aug 5 19:43:46 2013 +0200 Committer: Massimo Lusetti <mluse...@apache.org> Committed: Mon Aug 5 19:48:15 2013 +0200 ---------------------------------------------------------------------- .../src/test/activationctx/WEB-INF/web.xml | 19 +++++ .../ActivationContextintegrationTests.java | 88 ++++++++++++++++++++ .../activationctx/components/Layout.java | 19 +++++ .../integration/activationctx/pages/Index.java | 30 +++++++ .../activationctx/pages/NoContext.java | 23 +++++ .../activationctx/pages/OneContext.java | 25 ++++++ .../activationctx/pages/TwoContext.java | 26 ++++++ .../activationctx/services/AppModule.java | 30 +++++++ .../activationctx/components/Layout.tml | 21 +++++ .../integration/activationctx/pages/Index.tml | 39 +++++++++ .../activationctx/pages/NoContext.tml | 7 ++ .../activationctx/pages/OneContext.tml | 7 ++ .../activationctx/pages/TwoContext.tml | 7 ++ 13 files changed, 341 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/7e058593/tapestry-core/src/test/activationctx/WEB-INF/web.xml ---------------------------------------------------------------------- diff --git a/tapestry-core/src/test/activationctx/WEB-INF/web.xml b/tapestry-core/src/test/activationctx/WEB-INF/web.xml new file mode 100644 index 0000000..d42a684 --- /dev/null +++ b/tapestry-core/src/test/activationctx/WEB-INF/web.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE web-app + PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" + "http://java.sun.com/dtd/web-app_2_3.dtd"> +<web-app> + <display-name>Activation Context Test App</display-name> + <context-param> + <param-name>tapestry.app-package</param-name> + <param-value>org.apache.tapestry5.integration.activationctx</param-value> + </context-param> + <filter> + <filter-name>app</filter-name> + <filter-class>org.apache.tapestry5.TapestryFilter</filter-class> + </filter> + <filter-mapping> + <filter-name>app</filter-name> + <url-pattern>/*</url-pattern> + </filter-mapping> +</web-app> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/7e058593/tapestry-core/src/test/java/org/apache/tapestry5/integration/activationctx/ActivationContextintegrationTests.java ---------------------------------------------------------------------- diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/activationctx/ActivationContextintegrationTests.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/activationctx/ActivationContextintegrationTests.java new file mode 100644 index 0000000..da6be55 --- /dev/null +++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/activationctx/ActivationContextintegrationTests.java @@ -0,0 +1,88 @@ +// Copyright 2013 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.activationctx; + +import org.apache.tapestry5.integration.TapestryCoreTestCase; +import org.testng.annotations.Test; + +/** + * To test TAP5-2070 + */ +public class ActivationContextintegrationTests extends TapestryCoreTestCase +{ + @Test + public void no_context_correct() + { + openLinks("No context correct"); + + assertTextPresent("You are able to see me only without activation context"); + } + + @Test + public void no_context_error() + { + openLinks("No context error"); + + assertTextPresent("HTTP ERROR 404"); + } + + @Test + public void one_context_without() + { + openLinks("One context without"); + + assertTextPresent("HTTP ERROR 404"); + } + + @Test + public void one_context_with_one() + { + openLinks("One context correct"); + + assertTextPresent("You are able to see me only with one parameter in the activation context"); + } + + @Test + public void one_context_with_two() + { + openLinks("One context error"); + + assertTextPresent("HTTP ERROR 404"); + } + + @Test + public void two_context_without() + { + openLinks("Two context without"); + + assertTextPresent("HTTP ERROR 404"); + } + + @Test + public void two_context_with_one() + { + openLinks("Two context error"); + + assertTextPresent("HTTP ERROR 404"); + } + + @Test + public void two_context_with_two() + { + openLinks("Two context correct"); + + assertTextPresent("You are able to see me only with two parameters in the activation context"); + } +} http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/7e058593/tapestry-core/src/test/java/org/apache/tapestry5/integration/activationctx/components/Layout.java ---------------------------------------------------------------------- diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/activationctx/components/Layout.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/activationctx/components/Layout.java new file mode 100644 index 0000000..1caa518 --- /dev/null +++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/activationctx/components/Layout.java @@ -0,0 +1,19 @@ +// Copyright 2013 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.activationctx.components; + +public class Layout +{ +} http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/7e058593/tapestry-core/src/test/java/org/apache/tapestry5/integration/activationctx/pages/Index.java ---------------------------------------------------------------------- diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/activationctx/pages/Index.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/activationctx/pages/Index.java new file mode 100644 index 0000000..39dc050 --- /dev/null +++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/activationctx/pages/Index.java @@ -0,0 +1,30 @@ +// Copyright 2013 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.activationctx.pages; + +/** + * TAP5-2070 Integration test index page + */ +public class Index +{ + + public String[] getTwoValues() + { + return new String[] { + "One", + "Two" + }; + } +} http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/7e058593/tapestry-core/src/test/java/org/apache/tapestry5/integration/activationctx/pages/NoContext.java ---------------------------------------------------------------------- diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/activationctx/pages/NoContext.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/activationctx/pages/NoContext.java new file mode 100644 index 0000000..9492f74 --- /dev/null +++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/activationctx/pages/NoContext.java @@ -0,0 +1,23 @@ +// Copyright 2013 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.activationctx.pages; + +import org.apache.tapestry5.annotations.UnknownActivationContextCheck; + +@UnknownActivationContextCheck +public class NoContext +{ + +} http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/7e058593/tapestry-core/src/test/java/org/apache/tapestry5/integration/activationctx/pages/OneContext.java ---------------------------------------------------------------------- diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/activationctx/pages/OneContext.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/activationctx/pages/OneContext.java new file mode 100644 index 0000000..e49070a --- /dev/null +++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/activationctx/pages/OneContext.java @@ -0,0 +1,25 @@ +// Copyright 2013 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.activationctx.pages; + +import org.apache.tapestry5.annotations.PageActivationContext; +import org.apache.tapestry5.annotations.UnknownActivationContextCheck; + +@UnknownActivationContextCheck +public class OneContext +{ + @PageActivationContext + private String activationContext; +} http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/7e058593/tapestry-core/src/test/java/org/apache/tapestry5/integration/activationctx/pages/TwoContext.java ---------------------------------------------------------------------- diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/activationctx/pages/TwoContext.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/activationctx/pages/TwoContext.java new file mode 100644 index 0000000..74f73a8 --- /dev/null +++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/activationctx/pages/TwoContext.java @@ -0,0 +1,26 @@ +// Copyright 2013 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.activationctx.pages; + +import org.apache.tapestry5.annotations.UnknownActivationContextCheck; + +@UnknownActivationContextCheck +public class TwoContext +{ + void onActivate(String one, String two) + { + // Do some nifty stuff... + } +} http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/7e058593/tapestry-core/src/test/java/org/apache/tapestry5/integration/activationctx/services/AppModule.java ---------------------------------------------------------------------- diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/activationctx/services/AppModule.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/activationctx/services/AppModule.java new file mode 100644 index 0000000..4d4541a --- /dev/null +++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/activationctx/services/AppModule.java @@ -0,0 +1,30 @@ +// Copyright 2013 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.activationctx.services; + +import org.apache.tapestry5.SymbolConstants; +import org.apache.tapestry5.ioc.MappedConfiguration; + +/** + * + */ +public class AppModule +{ + public static void contributeApplicationDefaults(MappedConfiguration<String, String> configuration) + { + configuration.add(SymbolConstants.SUPPORTED_LOCALES, "en"); + configuration.add(SymbolConstants.PRODUCTION_MODE, "false"); + } +} http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/7e058593/tapestry-core/src/test/resources/org/apache/tapestry5/integration/activationctx/components/Layout.tml ---------------------------------------------------------------------- diff --git a/tapestry-core/src/test/resources/org/apache/tapestry5/integration/activationctx/components/Layout.tml b/tapestry-core/src/test/resources/org/apache/tapestry5/integration/activationctx/components/Layout.tml new file mode 100644 index 0000000..0084db4 --- /dev/null +++ b/tapestry-core/src/test/resources/org/apache/tapestry5/integration/activationctx/components/Layout.tml @@ -0,0 +1,21 @@ +<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd" xmlns:p="tapestry:parameter"> + <head> + <title>LinkTrans: ${componentresources.pagename}</title> + </head> + <body> + <h1>${componentresources.pagename}</h1> + + <t:body/> + + <hr/> + + <ul> + <li> + <t:pagelink page="index">back to index</t:pagelink> + </li> + <li> + <t:pagelink page="${componentResources.pageName}">refresh</t:pagelink> + </li> + </ul> + </body> +</html> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/7e058593/tapestry-core/src/test/resources/org/apache/tapestry5/integration/activationctx/pages/Index.tml ---------------------------------------------------------------------- diff --git a/tapestry-core/src/test/resources/org/apache/tapestry5/integration/activationctx/pages/Index.tml b/tapestry-core/src/test/resources/org/apache/tapestry5/integration/activationctx/pages/Index.tml new file mode 100644 index 0000000..d6fc3f7 --- /dev/null +++ b/tapestry-core/src/test/resources/org/apache/tapestry5/integration/activationctx/pages/Index.tml @@ -0,0 +1,39 @@ +<t:layout xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd" xmlns:p="tapestry:parameter"> + + <ul> + <li> + <t:pagelink page="nocontext">No context correct</t:pagelink> + </li> + + <li> + <t:pagelink page="nocontext" context="literal:one">No context error</t:pagelink> + </li> + + + <li> + <t:pagelink page="onecontext">One context without</t:pagelink> + </li> + + <li> + <t:pagelink page="onecontext" context="literal:one">One context correct</t:pagelink> + </li> + + <li> + <t:pagelink page="onecontext" context="twoValues">One context error</t:pagelink> + </li> + + + <li> + <t:pagelink page="twocontext">Two context without</t:pagelink> + </li> + + <li> + <t:pagelink page="twocontext" context="literal:one">Two context error</t:pagelink> + </li> + + <li> + <t:pagelink page="twocontext" context="twoValues">Two context correct</t:pagelink> + </li> + </ul> + +</t:layout> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/7e058593/tapestry-core/src/test/resources/org/apache/tapestry5/integration/activationctx/pages/NoContext.tml ---------------------------------------------------------------------- diff --git a/tapestry-core/src/test/resources/org/apache/tapestry5/integration/activationctx/pages/NoContext.tml b/tapestry-core/src/test/resources/org/apache/tapestry5/integration/activationctx/pages/NoContext.tml new file mode 100644 index 0000000..2a8852d --- /dev/null +++ b/tapestry-core/src/test/resources/org/apache/tapestry5/integration/activationctx/pages/NoContext.tml @@ -0,0 +1,7 @@ +<t:layout xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd" xmlns:p="tapestry:parameter"> + + <p> + You are able to see me only without activation context + </p> + +</t:layout> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/7e058593/tapestry-core/src/test/resources/org/apache/tapestry5/integration/activationctx/pages/OneContext.tml ---------------------------------------------------------------------- diff --git a/tapestry-core/src/test/resources/org/apache/tapestry5/integration/activationctx/pages/OneContext.tml b/tapestry-core/src/test/resources/org/apache/tapestry5/integration/activationctx/pages/OneContext.tml new file mode 100644 index 0000000..a1ce81a --- /dev/null +++ b/tapestry-core/src/test/resources/org/apache/tapestry5/integration/activationctx/pages/OneContext.tml @@ -0,0 +1,7 @@ +<t:layout xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd" xmlns:p="tapestry:parameter"> + + <p> + You are able to see me only with one parameter in the activation context + </p> + +</t:layout> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/7e058593/tapestry-core/src/test/resources/org/apache/tapestry5/integration/activationctx/pages/TwoContext.tml ---------------------------------------------------------------------- diff --git a/tapestry-core/src/test/resources/org/apache/tapestry5/integration/activationctx/pages/TwoContext.tml b/tapestry-core/src/test/resources/org/apache/tapestry5/integration/activationctx/pages/TwoContext.tml new file mode 100644 index 0000000..cf24c2a --- /dev/null +++ b/tapestry-core/src/test/resources/org/apache/tapestry5/integration/activationctx/pages/TwoContext.tml @@ -0,0 +1,7 @@ +<t:layout xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd" xmlns:p="tapestry:parameter"> + + <p> + You are able to see me only with two parameters in the activation context + </p> + +</t:layout> \ No newline at end of file