You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltaspike.apache.org by gp...@apache.org on 2014/04/12 18:56:44 UTC
git commit: DELTASPIKE-560 navigation parameter interceptor
Repository: deltaspike
Updated Branches:
refs/heads/master 9c45305c6 -> b05724e9a
DELTASPIKE-560 navigation parameter interceptor
Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/b05724e9
Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/b05724e9
Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/b05724e9
Branch: refs/heads/master
Commit: b05724e9a2ef54943b3e24e2d118d6e7c97994f3
Parents: 9c45305
Author: gpetracek <gp...@apache.org>
Authored: Sat Apr 12 18:32:35 2014 +0200
Committer: gpetracek <gp...@apache.org>
Committed: Sat Apr 12 18:47:46 2014 +0200
----------------------------------------------------------------------
.../view/navigation/NavigationParameter.java | 5 +-
.../navigation/NavigationParameterStrategy.java | 28 ++++++++
.../DefaultNavigationParameterStrategy.java | 66 +++++++++++++++++
.../NavigationParameterInterceptor.java | 44 ++++++++++++
.../NavigationParameterListInterceptor.java | 44 ++++++++++++
.../impl/src/main/resources/META-INF/beans.xml | 4 ++
.../uc001/NoNavigationParameterWarFileTest.java | 63 +++++++++++++++++
.../navigation/parameter/uc001/PageBean001.java | 1 -
.../navigation/parameter/uc002/PageBean002.java | 2 -
.../StaticNavigationParameterWarFileTest.java | 74 ++++++++++++++++++++
.../DynamicNavigationParameterWarFileTest.java | 72 +++++++++++++++++++
.../navigation/parameter/uc004/PageBean004.java | 8 +--
.../test/jsf/impl/util/ArchiveUtils.java | 16 +++++
13 files changed, 418 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/b05724e9/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/view/navigation/NavigationParameter.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/view/navigation/NavigationParameter.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/view/navigation/NavigationParameter.java
index 5d803dd..9b84ddf 100644
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/view/navigation/NavigationParameter.java
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/view/navigation/NavigationParameter.java
@@ -22,6 +22,7 @@ import org.apache.deltaspike.core.api.config.view.metadata.Aggregated;
import org.apache.deltaspike.core.api.config.view.metadata.ViewMetaData;
import javax.enterprise.util.Nonbinding;
+import javax.interceptor.InterceptorBinding;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
@@ -40,7 +41,7 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@ViewMetaData
@Aggregated(true)
-//TODO @InterceptorBinding
+@InterceptorBinding
public @interface NavigationParameter
{
/**
@@ -67,7 +68,7 @@ public @interface NavigationParameter
*/
@ViewMetaData
@Aggregated(true)
- //TODO @InterceptorBinding
+ @InterceptorBinding
public static @interface List
{
/**
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/b05724e9/deltaspike/modules/jsf/api/src/main/java/org/apache/deltaspike/jsf/spi/config/view/navigation/NavigationParameterStrategy.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/api/src/main/java/org/apache/deltaspike/jsf/spi/config/view/navigation/NavigationParameterStrategy.java b/deltaspike/modules/jsf/api/src/main/java/org/apache/deltaspike/jsf/spi/config/view/navigation/NavigationParameterStrategy.java
new file mode 100644
index 0000000..62c50ad
--- /dev/null
+++ b/deltaspike/modules/jsf/api/src/main/java/org/apache/deltaspike/jsf/spi/config/view/navigation/NavigationParameterStrategy.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.deltaspike.jsf.spi.config.view.navigation;
+
+import org.apache.deltaspike.core.spi.InterceptorStrategy;
+
+/**
+ * Allows to provide a custom {@link InterceptorStrategy}
+ */
+public interface NavigationParameterStrategy extends InterceptorStrategy
+{
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/b05724e9/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/config/view/navigation/DefaultNavigationParameterStrategy.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/config/view/navigation/DefaultNavigationParameterStrategy.java b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/config/view/navigation/DefaultNavigationParameterStrategy.java
new file mode 100644
index 0000000..089cd35
--- /dev/null
+++ b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/config/view/navigation/DefaultNavigationParameterStrategy.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.deltaspike.jsf.impl.config.view.navigation;
+
+import org.apache.deltaspike.core.api.config.view.navigation.NavigationParameter;
+import org.apache.deltaspike.core.api.config.view.navigation.NavigationParameterContext;
+import org.apache.deltaspike.jsf.spi.config.view.navigation.NavigationParameterStrategy;
+
+import javax.enterprise.context.Dependent;
+import javax.inject.Inject;
+import javax.interceptor.InvocationContext;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+@Dependent
+public class DefaultNavigationParameterStrategy implements NavigationParameterStrategy
+{
+ private static final long serialVersionUID = 198321901578229292L;
+
+ @Inject
+ private NavigationParameterContext navigationParameterContext;
+
+ @Override
+ public Object execute(InvocationContext ic) throws Exception
+ {
+ List<NavigationParameter> parameterList = new ArrayList<NavigationParameter>();
+
+ NavigationParameter navigationParameter = ic.getMethod().getAnnotation(NavigationParameter.class);
+
+ if (navigationParameter != null)
+ {
+ parameterList.add(navigationParameter);
+ }
+
+ NavigationParameter.List navigationParameterList = ic.getMethod().getAnnotation(NavigationParameter.List.class);
+
+ if (navigationParameterList != null)
+ {
+ Collections.addAll(parameterList, navigationParameterList.value());
+ }
+
+ for (NavigationParameter currentParameter : parameterList)
+ {
+ this.navigationParameterContext.addPageParameter(currentParameter.key(), currentParameter.value());
+ }
+
+ return ic.proceed();
+ }
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/b05724e9/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/config/view/navigation/NavigationParameterInterceptor.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/config/view/navigation/NavigationParameterInterceptor.java b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/config/view/navigation/NavigationParameterInterceptor.java
new file mode 100644
index 0000000..27fc4d9
--- /dev/null
+++ b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/config/view/navigation/NavigationParameterInterceptor.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.deltaspike.jsf.impl.config.view.navigation;
+
+import org.apache.deltaspike.core.api.config.view.navigation.NavigationParameter;
+import org.apache.deltaspike.jsf.spi.config.view.navigation.NavigationParameterStrategy;
+
+import javax.inject.Inject;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptor;
+import javax.interceptor.InvocationContext;
+import java.io.Serializable;
+
+@NavigationParameter(key = "", value = "")
+@Interceptor
+public class NavigationParameterInterceptor implements Serializable
+{
+ private static final long serialVersionUID = 1762625956958428994L;
+
+ @Inject
+ private NavigationParameterStrategy navigationParameterStrategy;
+
+ @AroundInvoke
+ public Object addParameter(InvocationContext invocationContext) throws Exception
+ {
+ return this.navigationParameterStrategy.execute(invocationContext);
+ }
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/b05724e9/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/config/view/navigation/NavigationParameterListInterceptor.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/config/view/navigation/NavigationParameterListInterceptor.java b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/config/view/navigation/NavigationParameterListInterceptor.java
new file mode 100644
index 0000000..8cedd46
--- /dev/null
+++ b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/config/view/navigation/NavigationParameterListInterceptor.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.deltaspike.jsf.impl.config.view.navigation;
+
+import org.apache.deltaspike.core.api.config.view.navigation.NavigationParameter;
+import org.apache.deltaspike.jsf.spi.config.view.navigation.NavigationParameterStrategy;
+
+import javax.inject.Inject;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptor;
+import javax.interceptor.InvocationContext;
+import java.io.Serializable;
+
+@NavigationParameter.List( { } )
+@Interceptor
+public class NavigationParameterListInterceptor implements Serializable
+{
+ private static final long serialVersionUID = 2762625956958428994L;
+
+ @Inject
+ private NavigationParameterStrategy navigationParameterStrategy;
+
+ @AroundInvoke
+ public Object addParameterList(InvocationContext invocationContext) throws Exception
+ {
+ return this.navigationParameterStrategy.execute(invocationContext);
+ }
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/b05724e9/deltaspike/modules/jsf/impl/src/main/resources/META-INF/beans.xml
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/main/resources/META-INF/beans.xml b/deltaspike/modules/jsf/impl/src/main/resources/META-INF/beans.xml
index 4070730..5d9be56 100644
--- a/deltaspike/modules/jsf/impl/src/main/resources/META-INF/beans.xml
+++ b/deltaspike/modules/jsf/impl/src/main/resources/META-INF/beans.xml
@@ -20,4 +20,8 @@
<beans xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
+ <interceptors>
+ <class>org.apache.deltaspike.jsf.impl.config.view.navigation.NavigationParameterInterceptor</class>
+ <class>org.apache.deltaspike.jsf.impl.config.view.navigation.NavigationParameterListInterceptor</class>
+ </interceptors>
</beans>
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/b05724e9/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/navigation/parameter/uc001/NoNavigationParameterWarFileTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/navigation/parameter/uc001/NoNavigationParameterWarFileTest.java b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/navigation/parameter/uc001/NoNavigationParameterWarFileTest.java
new file mode 100644
index 0000000..472d6bd
--- /dev/null
+++ b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/navigation/parameter/uc001/NoNavigationParameterWarFileTest.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.deltaspike.test.jsf.impl.config.view.navigation.parameter.uc001;
+
+import junit.framework.Assert;
+import org.apache.deltaspike.core.api.config.view.navigation.NavigationParameterContext;
+import org.apache.deltaspike.test.jsf.impl.util.ArchiveUtils;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.inject.Inject;
+
+
+@RunWith(Arquillian.class)
+public class NoNavigationParameterWarFileTest
+{
+ @Deployment
+ public static WebArchive deploy()
+ {
+ String simpleName = NoNavigationParameterWarFileTest.class.getSimpleName();
+ String archiveName = simpleName.substring(0, 1).toLowerCase() + simpleName.substring(1);
+
+ return ShrinkWrap.create(WebArchive.class, archiveName + ".war")
+ .addPackage(NoNavigationParameterWarFileTest.class.getPackage())
+ .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreAndJsfArchive())
+ .addAsLibraries(ArchiveUtils.getDeltaSpikeSecurityArchive())
+ .addAsWebInfResource(ArchiveUtils.getBeansXml(), "beans.xml");
+ }
+
+ @Inject
+ private PageBean001 pageBean;
+
+ @Inject
+ private NavigationParameterContext navigationParameterContext;
+
+ @Test
+ public void noParameters()
+ {
+ Assert.assertTrue(this.navigationParameterContext.getPageParameters().isEmpty());
+ this.pageBean.actionMethod();
+ Assert.assertTrue(this.navigationParameterContext.getPageParameters().isEmpty());
+ }
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/b05724e9/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/navigation/parameter/uc001/PageBean001.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/navigation/parameter/uc001/PageBean001.java b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/navigation/parameter/uc001/PageBean001.java
index 75f4eec..c1f0369 100644
--- a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/navigation/parameter/uc001/PageBean001.java
+++ b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/navigation/parameter/uc001/PageBean001.java
@@ -25,7 +25,6 @@ import javax.enterprise.inject.Model;
@Model
public class PageBean001
{
- //TODO add test
//no params
public Class<? extends ViewConfig> actionMethod()
{
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/b05724e9/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/navigation/parameter/uc002/PageBean002.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/navigation/parameter/uc002/PageBean002.java b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/navigation/parameter/uc002/PageBean002.java
index 1827097..3417178 100644
--- a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/navigation/parameter/uc002/PageBean002.java
+++ b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/navigation/parameter/uc002/PageBean002.java
@@ -23,8 +23,6 @@ import org.apache.deltaspike.core.api.config.view.navigation.NavigationParameter
import javax.enterprise.inject.Model;
-//TODO add tests
-
@Model
public class PageBean002
{
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/b05724e9/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/navigation/parameter/uc002/StaticNavigationParameterWarFileTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/navigation/parameter/uc002/StaticNavigationParameterWarFileTest.java b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/navigation/parameter/uc002/StaticNavigationParameterWarFileTest.java
new file mode 100644
index 0000000..7b4d15c
--- /dev/null
+++ b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/navigation/parameter/uc002/StaticNavigationParameterWarFileTest.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.deltaspike.test.jsf.impl.config.view.navigation.parameter.uc002;
+
+import junit.framework.Assert;
+import org.apache.deltaspike.core.api.config.view.navigation.NavigationParameterContext;
+import org.apache.deltaspike.test.jsf.impl.util.ArchiveUtils;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.inject.Inject;
+
+
+@RunWith(Arquillian.class)
+public class StaticNavigationParameterWarFileTest
+{
+ @Deployment
+ public static WebArchive deploy()
+ {
+ String simpleName = StaticNavigationParameterWarFileTest.class.getSimpleName();
+ String archiveName = simpleName.substring(0, 1).toLowerCase() + simpleName.substring(1);
+
+ return ShrinkWrap.create(WebArchive.class, archiveName + ".war")
+ .addPackage(StaticNavigationParameterWarFileTest.class.getPackage())
+ .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreAndJsfArchive())
+ .addAsLibraries(ArchiveUtils.getDeltaSpikeSecurityArchive())
+ .addAsWebInfResource(ArchiveUtils.getBeansXml(), "beans.xml");
+ }
+
+ @Inject
+ private PageBean002 pageBean;
+
+ @Inject
+ private NavigationParameterContext navigationParameterContext;
+
+ @Test
+ public void oneParameters()
+ {
+ Assert.assertTrue(this.navigationParameterContext.getPageParameters().isEmpty());
+ this.pageBean.actionMethod1();
+ Assert.assertEquals(1, this.navigationParameterContext.getPageParameters().size());
+ Assert.assertEquals("staticMarker", this.navigationParameterContext.getPageParameters().get("param1"));
+ }
+
+ @Test
+ public void multipleParameters()
+ {
+ Assert.assertTrue(this.navigationParameterContext.getPageParameters().isEmpty());
+ this.pageBean.actionMethod2();
+ Assert.assertEquals(2, this.navigationParameterContext.getPageParameters().size());
+ Assert.assertEquals("staticMarker1", this.navigationParameterContext.getPageParameters().get("param1"));
+ Assert.assertEquals("staticMarker2", this.navigationParameterContext.getPageParameters().get("param2"));
+ }
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/b05724e9/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/navigation/parameter/uc004/DynamicNavigationParameterWarFileTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/navigation/parameter/uc004/DynamicNavigationParameterWarFileTest.java b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/navigation/parameter/uc004/DynamicNavigationParameterWarFileTest.java
new file mode 100644
index 0000000..6afff6c
--- /dev/null
+++ b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/navigation/parameter/uc004/DynamicNavigationParameterWarFileTest.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.deltaspike.test.jsf.impl.config.view.navigation.parameter.uc004;
+
+import junit.framework.Assert;
+import org.apache.deltaspike.core.api.config.view.navigation.NavigationParameterContext;
+import org.apache.deltaspike.test.jsf.impl.util.ArchiveUtils;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.inject.Inject;
+
+
+@RunWith(Arquillian.class)
+public class DynamicNavigationParameterWarFileTest
+{
+ @Deployment
+ public static WebArchive deploy()
+ {
+ String simpleName = DynamicNavigationParameterWarFileTest.class.getSimpleName();
+ String archiveName = simpleName.substring(0, 1).toLowerCase() + simpleName.substring(1);
+
+ return ShrinkWrap.create(WebArchive.class, archiveName + ".war")
+ .addPackage(DynamicNavigationParameterWarFileTest.class.getPackage())
+ .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreAndJsfArchive())
+ .addAsLibraries(ArchiveUtils.getDeltaSpikeSecurityArchive())
+ .addAsWebInfResource(ArchiveUtils.getBeansXml(), "beans.xml");
+ }
+
+ @Inject
+ private PageBean004 pageBean;
+
+ @Inject
+ private NavigationParameterContext navigationParameterContext;
+
+ @Test
+ public void dynamicParameters()
+ {
+ Assert.assertTrue(this.navigationParameterContext.getPageParameters().isEmpty());
+
+ this.pageBean.actionMethod();
+ Assert.assertTrue(this.navigationParameterContext.getPageParameters().isEmpty());
+
+ this.pageBean.actionMethod();
+ Assert.assertEquals(1, this.navigationParameterContext.getPageParameters().size());
+ Assert.assertEquals("0", this.navigationParameterContext.getPageParameters().get("cv"));
+
+ this.pageBean.actionMethod();
+ Assert.assertEquals(1, this.navigationParameterContext.getPageParameters().size());
+ Assert.assertEquals("1", this.navigationParameterContext.getPageParameters().get("cv"));
+ }
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/b05724e9/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/navigation/parameter/uc004/PageBean004.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/navigation/parameter/uc004/PageBean004.java b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/navigation/parameter/uc004/PageBean004.java
index e8b4d42..e3d1729 100644
--- a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/navigation/parameter/uc004/PageBean004.java
+++ b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/navigation/parameter/uc004/PageBean004.java
@@ -30,20 +30,20 @@ import java.io.Serializable;
@SessionScoped
public class PageBean004 implements Serializable
{
- private int currentValue = -100;
+ private static final long serialVersionUID = -436742087379474804L;
+
+ private int currentValue = -2;
@Inject
private NavigationParameterContext navigationParameterContext;
- //TODO add test
-
public Class<? extends ViewConfig> actionMethod()
{
currentValue++;
if (currentValue >= 0)
{
- this.navigationParameterContext.addPageParameter("cv", this.currentValue++);
+ this.navigationParameterContext.addPageParameter("cv", this.currentValue);
}
return SimplePageConfig.class;
}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/b05724e9/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/util/ArchiveUtils.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/util/ArchiveUtils.java b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/util/ArchiveUtils.java
index 2232ff8..3c08ea7 100644
--- a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/util/ArchiveUtils.java
+++ b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/util/ArchiveUtils.java
@@ -21,6 +21,8 @@ package org.apache.deltaspike.test.jsf.impl.util;
import org.apache.deltaspike.test.category.WebProfileCategory;
import org.apache.deltaspike.test.utils.ShrinkWrapArchiveUtil;
import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.Asset;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import java.util.ArrayList;
@@ -75,4 +77,18 @@ public class ArchiveUtils
"META-INF/beans.xml",
new String[]{"org.apache.deltaspike.security"}, excludedFiles);
}
+
+ public static Asset getBeansXml()
+ {
+ Asset beansXml = new StringAsset(
+ "<beans>" +
+ "<interceptors>" +
+ "<class>org.apache.deltaspike.jsf.impl.config.view.navigation.NavigationParameterInterceptor</class>" +
+ "<class>org.apache.deltaspike.jsf.impl.config.view.navigation.NavigationParameterListInterceptor</class>" +
+ "</interceptors>" +
+ "</beans>"
+ );
+
+ return beansXml;
+ }
}