struts git commit: WW-4600 Adds additional check if session was invalidated

2016-02-03 Thread lukaszlenart
Repository: struts
Updated Branches:
  refs/heads/support-2-3 c44566bd2 -> 85373951b


WW-4600 Adds additional check if session was invalidated


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/85373951
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/85373951
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/85373951

Branch: refs/heads/support-2-3
Commit: 85373951b7dfe55a92a76c87ee8faf50233bf07c
Parents: c44566b
Author: Lukasz Lenart 
Authored: Wed Feb 3 09:28:21 2016 +0100
Committer: Lukasz Lenart 
Committed: Wed Feb 3 09:33:50 2016 +0100

--
 .../interceptor/MessageStoreInterceptor.java|  43 +++
 .../MessageStoreInterceptorTest.java| 116 ++-
 2 files changed, 135 insertions(+), 24 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/struts/blob/85373951/core/src/main/java/org/apache/struts2/interceptor/MessageStoreInterceptor.java
--
diff --git 
a/core/src/main/java/org/apache/struts2/interceptor/MessageStoreInterceptor.java
 
b/core/src/main/java/org/apache/struts2/interceptor/MessageStoreInterceptor.java
index f34cee0..97e1693 100644
--- 
a/core/src/main/java/org/apache/struts2/interceptor/MessageStoreInterceptor.java
+++ 
b/core/src/main/java/org/apache/struts2/interceptor/MessageStoreInterceptor.java
@@ -272,41 +272,42 @@ public class MessageStoreInterceptor extends 
AbstractInterceptor {
  */
 protected void after(ActionInvocation invocation, String result) throws 
Exception {
 
+boolean isCommitted = ServletActionContext.getResponse().isCommitted();
+if (isCommitted) {
+LOG.trace("Response was already committed, cannot store 
messages!");
+return;
+}
+
+boolean isInvalidated = 
ServletActionContext.getRequest().getSession(false) == null;
+if (isInvalidated) {
+LOG.trace("Session was invalidated or never created, cannot store 
messages!");
+return;
+}
+
+Map session = 
invocation.getInvocationContext().getSession();
+if (session == null) {
+LOG.trace("Could not store action [#0] error/messages into 
session, because session hasn't been opened yet.", invocation.getAction());
+return;
+}
+
 String reqOperationMode = getRequestOperationMode(invocation);
 boolean isRedirect = invocation.getResult() instanceof 
ServletRedirectResult;
-boolean isCommitted = ServletActionContext.getResponse().isCommitted();
 
 if (STORE_MODE.equalsIgnoreCase(reqOperationMode) ||
 STORE_MODE.equalsIgnoreCase(operationMode) ||
 (AUTOMATIC_MODE.equalsIgnoreCase(operationMode) && 
isRedirect)) {
 
 Object action = invocation.getAction();
-if (action instanceof ValidationAware && !isCommitted) {
-// store error / messages into session
-Map session = 
invocation.getInvocationContext().getSession();
-
-if (session == null) {
-if (LOG.isDebugEnabled()) {
-LOG.debug("Could not store action ["+action+"] 
error/messages into session, because session hasn't been opened yet.");
-}
-return;
-}
-
-if (LOG.isDebugEnabled()) {
-LOG.debug("store action ["+action+"] error/messages into 
session ");
-}
+if (action instanceof ValidationAware) {
+LOG.debug("Storing action [#0] error/messages into session ", 
action);
 
 ValidationAware validationAwareAction = (ValidationAware) 
action;
 session.put(actionErrorsSessionKey, 
validationAwareAction.getActionErrors());
 session.put(actionMessagesSessionKey, 
validationAwareAction.getActionMessages());
 session.put(fieldErrorsSessionKey, 
validationAwareAction.getFieldErrors());
 
-} else if(LOG.isDebugEnabled()) {
-if (isCommitted) {
-LOG.debug("Response was already committed, cannot store 
messages!");
-} else {
-LOG.debug("Action [" + action + "] is not ValidationAware, 
no message / error that are storeable");
-}
+} else {
+LOG.debug("Action [#0] is not ValidationAware, no message / 
error that are storeable", action);
 }
 }
 }

http://git-wip-us.apache.org/repos/asf/struts/blob/85373951/core/src/test/java/org/apache/struts2/interceptor/MessageStoreInterceptorTest.java

struts git commit: WW-4596 Fixes SMI with ActionConfigMatcher

2016-02-03 Thread lukaszlenart
Repository: struts
Updated Branches:
  refs/heads/master d8b6602e6 -> 23a0c9eb6


WW-4596 Fixes SMI with ActionConfigMatcher


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/23a0c9eb
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/23a0c9eb
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/23a0c9eb

Branch: refs/heads/master
Commit: 23a0c9eb643c41f800dc43159672dd31a6159472
Parents: d8b6602
Author: Lukasz Lenart 
Authored: Wed Feb 3 09:48:30 2016 +0100
Committer: Lukasz Lenart 
Committed: Wed Feb 3 09:48:30 2016 +0100

--
 .../xwork2/config/impl/ActionConfigMatcher.java |  1 +
 .../xwork2/config/impl/ActionConfigMatcherTest.java | 16 +++-
 2 files changed, 16 insertions(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/struts/blob/23a0c9eb/core/src/main/java/com/opensymphony/xwork2/config/impl/ActionConfigMatcher.java
--
diff --git 
a/core/src/main/java/com/opensymphony/xwork2/config/impl/ActionConfigMatcher.java
 
b/core/src/main/java/com/opensymphony/xwork2/config/impl/ActionConfigMatcher.java
index 3105437..2a2f0ed 100644
--- 
a/core/src/main/java/com/opensymphony/xwork2/config/impl/ActionConfigMatcher.java
+++ 
b/core/src/main/java/com/opensymphony/xwork2/config/impl/ActionConfigMatcher.java
@@ -115,6 +115,7 @@ public class ActionConfigMatcher extends 
AbstractMatcher implement
 .methodName(methodName)
 .addParams(params)
 .addResultConfigs(results)
+.addAllowedMethod(orig.getAllowedMethods())
 .addInterceptors(orig.getInterceptors())
 .addExceptionMappings(exs)
 .location(orig.getLocation())

http://git-wip-us.apache.org/repos/asf/struts/blob/23a0c9eb/core/src/test/java/com/opensymphony/xwork2/config/impl/ActionConfigMatcherTest.java
--
diff --git 
a/core/src/test/java/com/opensymphony/xwork2/config/impl/ActionConfigMatcherTest.java
 
b/core/src/test/java/com/opensymphony/xwork2/config/impl/ActionConfigMatcherTest.java
index a425157..6eb9f27 100644
--- 
a/core/src/test/java/com/opensymphony/xwork2/config/impl/ActionConfigMatcherTest.java
+++ 
b/core/src/test/java/com/opensymphony/xwork2/config/impl/ActionConfigMatcherTest.java
@@ -103,6 +103,14 @@ public class ActionConfigMatcherTest extends XWorkTestCase 
{
 "doclass_class".equals(m.getMethodName()));
 }
 
+public void testAllowedMethods() {
+ActionConfig m = matcher.match("addEvent!start");
+assertTrue(m.getAllowedMethods().contains("start"));
+
+m = matcher.match("addEvent!cancel");
+assertTrue(m.getAllowedMethods().contains("cancel"));
+}
+
 public void testLooseMatch() {
 configMap.put("*!*", configMap.get("bar/*/**"));
 ActionConfigMatcher matcher = new ActionConfigMatcher(new 
WildcardHelper(), configMap, true);
@@ -157,7 +165,13 @@ public class ActionConfigMatcherTest extends XWorkTestCase 
{
 .build();
 
 map.put("bar/*/**", config);
-
+
+config = new ActionConfig.Builder("package", "eventAdd!*", "bar")
+.methodName("{1}")
+.build();
+
+map.put("addEvent!*", config);
+
 map.put("noWildcard", new ActionConfig.Builder("", "", "").build());
 
 return map;



struts git commit: WW-4600 Adds additional check if session was invalidated

2016-02-03 Thread lukaszlenart
Repository: struts
Updated Branches:
  refs/heads/master 94691e0af -> d8b6602e6


WW-4600 Adds additional check if session was invalidated

Conflicts:

core/src/main/java/org/apache/struts2/interceptor/MessageStoreInterceptor.java


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/d8b6602e
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/d8b6602e
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/d8b6602e

Branch: refs/heads/master
Commit: d8b6602e6fd5d4943217ea98dac6be69db9a615d
Parents: 94691e0
Author: Lukasz Lenart 
Authored: Wed Feb 3 09:28:21 2016 +0100
Committer: Lukasz Lenart 
Committed: Wed Feb 3 09:37:19 2016 +0100

--
 .../interceptor/MessageStoreInterceptor.java|  39 ---
 .../MessageStoreInterceptorTest.java| 116 ++-
 2 files changed, 135 insertions(+), 20 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/struts/blob/d8b6602e/core/src/main/java/org/apache/struts2/interceptor/MessageStoreInterceptor.java
--
diff --git 
a/core/src/main/java/org/apache/struts2/interceptor/MessageStoreInterceptor.java
 
b/core/src/main/java/org/apache/struts2/interceptor/MessageStoreInterceptor.java
index 8ff2522..848c5bf 100644
--- 
a/core/src/main/java/org/apache/struts2/interceptor/MessageStoreInterceptor.java
+++ 
b/core/src/main/java/org/apache/struts2/interceptor/MessageStoreInterceptor.java
@@ -60,7 +60,7 @@ import java.util.Map;
  * 
  *
  * 
- * In the 'AUTOMATIC' mode, the interceptor will always retrieve the stored 
action's message / errors 
+ * In the 'AUTOMATIC' mode, the interceptor will always retrieve the stored 
action's message / errors
  * and field errors and put them back into the {@link ValidationAware} action, 
and after Action execution, 
  * if the {@link com.opensymphony.xwork2.Result} is an instance of {@link 
ServletRedirectResult}, the action's message / errors
  * and field errors into automatically be stored in the HTTP session..
@@ -269,25 +269,34 @@ public class MessageStoreInterceptor extends 
AbstractInterceptor {
  */
 protected void after(ActionInvocation invocation, String result) throws 
Exception {
 
+boolean isCommitted = ServletActionContext.getResponse().isCommitted();
+if (isCommitted) {
+LOG.trace("Response was already committed, cannot store 
messages!");
+return;
+}
+
+boolean isInvalidated = 
ServletActionContext.getRequest().getSession(false) == null;
+if (isInvalidated) {
+LOG.trace("Session was invalidated or never created, cannot store 
messages!");
+return;
+}
+
+Map session = 
invocation.getInvocationContext().getSession();
+if (session == null) {
+LOG.trace("Could not store action [{}] error/messages into 
session, because session hasn't been opened yet.", invocation.getAction());
+return;
+}
+
 String reqOperationMode = getRequestOperationMode(invocation);
 boolean isRedirect = invocation.getResult() instanceof 
ServletRedirectResult;
-boolean isCommitted = ServletActionContext.getResponse().isCommitted();
 
 if (STORE_MODE.equalsIgnoreCase(reqOperationMode) ||
 STORE_MODE.equalsIgnoreCase(operationMode) ||
 (AUTOMATIC_MODE.equalsIgnoreCase(operationMode) && 
isRedirect)) {
 
 Object action = invocation.getAction();
-if (action instanceof ValidationAware && !isCommitted) {
-// store error / messages into session
-Map session = 
invocation.getInvocationContext().getSession();
-
-if (session == null) {
-LOG.debug("Could not store action [{}] error/messages into 
session, because session hasn't been opened yet.", action);
-return;
-}
-
-LOG.debug("Store action [{}] error/messages into session.", 
action);
+if (action instanceof ValidationAware) {
+LOG.debug("Storing action [{}] error/messages into session ", 
action);
 
 ValidationAware validationAwareAction = (ValidationAware) 
action;
 session.put(actionErrorsSessionKey, 
validationAwareAction.getActionErrors());
@@ -295,11 +304,7 @@ public class MessageStoreInterceptor extends 
AbstractInterceptor {
 session.put(fieldErrorsSessionKey, 
validationAwareAction.getFieldErrors());
 
 } else {
-if (isCommitted) {
-LOG.debug("Response was already committed, cannot store 
messages!");
-} else {
- 

struts git commit: WW-4596 Adds support to defined allowed methods with *

2016-02-03 Thread lukaszlenart
Repository: struts
Updated Branches:
  refs/heads/master 23a0c9eb6 -> 954a29efc


WW-4596 Adds support to defined allowed methods with *


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/954a29ef
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/954a29ef
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/954a29ef

Branch: refs/heads/master
Commit: 954a29efcee7221bd00268857a98f833de4b5d60
Parents: 23a0c9e
Author: Lukasz Lenart 
Authored: Wed Feb 3 10:38:13 2016 +0100
Committer: Lukasz Lenart 
Committed: Wed Feb 3 10:38:13 2016 +0100

--
 .../xwork2/config/entities/AllowedMethods.java   |  3 +++
 .../xwork2/config/entities/AllowedMethodsTest.java   | 15 +++
 2 files changed, 18 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/struts/blob/954a29ef/core/src/main/java/com/opensymphony/xwork2/config/entities/AllowedMethods.java
--
diff --git 
a/core/src/main/java/com/opensymphony/xwork2/config/entities/AllowedMethods.java
 
b/core/src/main/java/com/opensymphony/xwork2/config/entities/AllowedMethods.java
index e8796b1..976117d 100644
--- 
a/core/src/main/java/com/opensymphony/xwork2/config/entities/AllowedMethods.java
+++ 
b/core/src/main/java/com/opensymphony/xwork2/config/entities/AllowedMethods.java
@@ -32,6 +32,9 @@ public class AllowedMethods {
 } else if (method.startsWith("regex:")) {
 String pattern = method.substring(method.indexOf(":") + 1);
 allowedMethods.add(new PatternAllowedMethod(pattern, method));
+} else if (method.contains("*") && !method.startsWith("regex:")) {
+String pattern = method.replaceAll("\\*", "(.*)");
+allowedMethods.add(new PatternAllowedMethod(pattern, method));
 } else {
 allowedMethods.add(new LiteralAllowedMethod(ret.toString()));
 }

http://git-wip-us.apache.org/repos/asf/struts/blob/954a29ef/core/src/test/java/com/opensymphony/xwork2/config/entities/AllowedMethodsTest.java
--
diff --git 
a/core/src/test/java/com/opensymphony/xwork2/config/entities/AllowedMethodsTest.java
 
b/core/src/test/java/com/opensymphony/xwork2/config/entities/AllowedMethodsTest.java
index 78f3094..607a9dc 100644
--- 
a/core/src/test/java/com/opensymphony/xwork2/config/entities/AllowedMethodsTest.java
+++ 
b/core/src/test/java/com/opensymphony/xwork2/config/entities/AllowedMethodsTest.java
@@ -37,6 +37,21 @@ public class AllowedMethodsTest extends TestCase {
 assertFalse(allowedMethods.isAllowed("someOtherMethod"));
 }
 
+public void testWidlcardWithStarMethods() throws Exception {
+// given
+String method = "cancel*";
+Set literals = new HashSet<>();
+literals.add(method);
+
+// when
+AllowedMethods allowedMethods = AllowedMethods.build(literals);
+
+// then
+assertEquals(1, allowedMethods.list().size());
+assertTrue(allowedMethods.isAllowed("cancelAction"));
+assertFalse(allowedMethods.isAllowed("startEvent"));
+}
+
 public void testRegexMethods() throws Exception {
 // given
 String method = "regex:my([a-zA-Z].*)";



[10/13] struts git commit: turned comments into LOG.trace()

2016-02-03 Thread cnenning
turned comments into LOG.trace()


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/8651545a
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/8651545a
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/8651545a

Branch: refs/heads/master
Commit: 8651545aaa34dad22c16969f5697cb5b1055f591
Parents: 9230270
Author: cnenning 
Authored: Mon Feb 1 09:44:22 2016 +0100
Committer: cnenning 
Committed: Mon Feb 1 09:44:22 2016 +0100

--
 .../main/java/org/apache/struts2/views/tiles/TilesResult.java| 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/struts/blob/8651545a/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java
--
diff --git 
a/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java 
b/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java
index 4656f91..ecbdcee 100644
--- 
a/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java
+++ 
b/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java
@@ -115,7 +115,7 @@ public class TilesResult extends ServletDispatcherResult {
 String actionName = invocation.getInvocationContext().getName();
 
 if (StringUtils.isEmpty(location)) {
-// location not set -> action must have one @TilesDefinition
+LOG.trace("location not set -> action must have one 
@TilesDefinition");
 tilesDefinition = annotationProcessor.findAnnotation(action, null);
 String tileName = StringUtils.isNotEmpty(tilesDefinition.name()) ? 
tilesDefinition.name() : actionName;
 location = tileName;
@@ -142,7 +142,7 @@ public class TilesResult extends ServletDispatcherResult {
 }
 if (!definitionValid) {
 if (tilesDefinition == null) {
-// tilesDefinition not found yet, search in action
+LOG.trace("tilesDefinition not found yet, searching in 
action");
 tilesDefinition = annotationProcessor.findAnnotation(action, 
location);
 }
 if (tilesDefinition != null) {



[07/13] struts git commit: renamed test class to stick to naming convention

2016-02-03 Thread cnenning
renamed test class to stick to naming convention

Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/9ca6eb98
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/9ca6eb98
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/9ca6eb98

Branch: refs/heads/master
Commit: 9ca6eb9813ae65a6dd245071825fb9abf63a2a94
Parents: b1588dd
Author: cnenning 
Authored: Mon Jan 25 14:36:07 2016 +0100
Committer: cnenning 
Committed: Mon Jan 25 14:36:07 2016 +0100

--
 .../StrutsTilesAnnotationProcessorTest.java | 148 +++
 .../TestStrutsTilesAnnotationProcessor.java | 148 ---
 2 files changed, 148 insertions(+), 148 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/struts/blob/9ca6eb98/plugins/tiles/src/test/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessorTest.java
--
diff --git 
a/plugins/tiles/src/test/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessorTest.java
 
b/plugins/tiles/src/test/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessorTest.java
new file mode 100644
index 000..acaacce
--- /dev/null
+++ 
b/plugins/tiles/src/test/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessorTest.java
@@ -0,0 +1,148 @@
+package org.apache.struts2.tiles;
+
+import java.util.List;
+import java.util.Set;
+
+import org.apache.struts2.tiles.annotation.TilesDefinition;
+import org.apache.tiles.Attribute;
+import org.apache.tiles.Definition;
+import org.apache.tiles.Expression;
+import org.junit.Test;
+
+import org.junit.Assert;
+
+public class StrutsTilesAnnotationProcessorTest {
+
+@Test
+public void findAnnotationSingleAction() {
+StrutsTilesAnnotationProcessor annotationProcessor = new 
StrutsTilesAnnotationProcessor();
+TilesDefinition tilesDefinition = 
annotationProcessor.findAnnotation(new TilesTestActionSingleAnnotation(), null);
+Assert.assertNotNull(tilesDefinition);
+Assert.assertEquals("definition-name", tilesDefinition.name());
+}
+
+@Test
+public void findAnnotationMultipleActionNameNull() {
+StrutsTilesAnnotationProcessor annotationProcessor = new 
StrutsTilesAnnotationProcessor();
+TilesDefinition tilesDefinition = 
annotationProcessor.findAnnotation(new TilesTestActionMultipleAnnotations(), 
null);
+Assert.assertNotNull(tilesDefinition);
+Assert.assertEquals("def1", tilesDefinition.name());
+}
+
+@Test
+public void findAnnotationMultipleActionNameGiven() {
+StrutsTilesAnnotationProcessor annotationProcessor = new 
StrutsTilesAnnotationProcessor();
+TilesDefinition tilesDefinition = 
annotationProcessor.findAnnotation(new TilesTestActionMultipleAnnotations(), 
"def2");
+Assert.assertNotNull(tilesDefinition);
+Assert.assertEquals("def2", tilesDefinition.name());
+}
+
+@Test
+public void findAnnotationMultipleActionNotFound() {
+StrutsTilesAnnotationProcessor annotationProcessor = new 
StrutsTilesAnnotationProcessor();
+TilesDefinition tilesDefinition = 
annotationProcessor.findAnnotation(new TilesTestActionMultipleAnnotations(), 
"def3");
+Assert.assertNull(tilesDefinition);
+}
+
+@Test
+public void buildDefiniton() {
+StrutsTilesAnnotationProcessor annotationProcessor = new 
StrutsTilesAnnotationProcessor();
+TilesDefinition tilesDefinition = 
annotationProcessor.findAnnotation(new TilesTestActionSingleAnnotation(), null);
+
+Definition definition = 
annotationProcessor.buildTilesDefinition("tileName", tilesDefinition);
+
+Assert.assertNotNull(definition);
+Assert.assertEquals("tileName", definition.getName());
+Assert.assertEquals("preparer", definition.getPreparer());
+Assert.assertEquals("base-definition", definition.getExtends());
+Attribute templateAttribute = definition.getTemplateAttribute();
+Assert.assertEquals("template", templateAttribute.getValue());
+Assert.assertEquals("type", templateAttribute.getRenderer());
+Assert.assertEquals("role", templateAttribute.getRole());
+Expression definitionExpressionObject = 
templateAttribute.getExpressionObject();
+Assert.assertEquals("templ*", 
definitionExpressionObject.getExpression());
+Assert.assertNull(definitionExpressionObject.getLanguage());
+
+Attribute putAttribute = definition.getAttribute("put-attr");
+Assert.assertNotNull(putAttribute);
+Assert.assertEquals("attr-val", putAttribute.getValue());
+Assert.assertEquals("attr-type", putAttribute.getRenderer());
+Assert.assertEquals("attr-role", putAttribute.getRole());
+Expression 

[12/13] struts git commit: WW-4594 Merges #85 which adds annotations to configure tiles

2016-02-03 Thread cnenning
WW-4594 Merges #85 which adds annotations to configure tiles


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/15688132
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/15688132
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/15688132

Branch: refs/heads/master
Commit: 15688132eff8a5f718ac24794822133fb3fe2d35
Parents: 94691e0 f5ef143
Author: cnenning 
Authored: Wed Feb 3 10:51:15 2016 +0100
Committer: cnenning 
Committed: Wed Feb 3 10:51:15 2016 +0100

--
 .../showcase/tiles/TilesAnnotationsAction.java  |  40 +
 apps/showcase/src/main/webapp/WEB-INF/tiles.xml |  10 +-
 .../src/main/webapp/WEB-INF/tiles/body.jsp  |   3 +
 .../webapp/WEB-INF/tiles/layout-annotations.jsp |  14 ++
 .../tiles/StrutsTilesAnnotationProcessor.java   | 177 +++
 .../tiles/annotation/TilesAddAttribute.java |  30 
 .../tiles/annotation/TilesAddListAttribute.java |  28 +++
 .../tiles/annotation/TilesDefinition.java   |  66 +++
 .../tiles/annotation/TilesDefinitions.java  |  36 
 .../tiles/annotation/TilesPutAttribute.java |  32 
 .../tiles/annotation/TilesPutListAttribute.java |  32 
 .../apache/struts2/views/tiles/TilesResult.java |  69 ++--
 .../StrutsTilesAnnotationProcessorTest.java | 147 +++
 .../TilesTestActionMultipleAnnotations.java |  12 ++
 .../tiles/TilesTestActionSingleAnnotation.java  |  49 +
 ...TilesTestActionSingleAnnotationAllEmpty.java |  28 +++
 16 files changed, 760 insertions(+), 13 deletions(-)
--




[06/13] struts git commit: fixed line endings

2016-02-03 Thread cnenning
fixed line endings


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/b1588ddc
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/b1588ddc
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/b1588ddc

Branch: refs/heads/master
Commit: b1588ddc84d876a676bab66ad80ec34637e98536
Parents: a53deac
Author: cnenning 
Authored: Mon Jan 25 13:50:45 2016 +0100
Committer: cnenning 
Committed: Mon Jan 25 13:50:45 2016 +0100

--
 apps/showcase/src/main/webapp/WEB-INF/tiles.xml | 108 +++---
 .../src/main/webapp/WEB-INF/tiles/body.jsp  |  52 +--
 .../apache/struts2/views/tiles/TilesResult.java | 326 +--
 3 files changed, 243 insertions(+), 243 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/struts/blob/b1588ddc/apps/showcase/src/main/webapp/WEB-INF/tiles.xml
--
diff --git a/apps/showcase/src/main/webapp/WEB-INF/tiles.xml 
b/apps/showcase/src/main/webapp/WEB-INF/tiles.xml
index d644502..a74de1b 100644
--- a/apps/showcase/src/main/webapp/WEB-INF/tiles.xml
+++ b/apps/showcase/src/main/webapp/WEB-INF/tiles.xml
@@ -1,54 +1,54 @@
-
-
-
-http://tiles.apache.org/dtds/tiles-config_3_0.dtd;>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+http://tiles.apache.org/dtds/tiles-config_3_0.dtd;>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

http://git-wip-us.apache.org/repos/asf/struts/blob/b1588ddc/apps/showcase/src/main/webapp/WEB-INF/tiles/body.jsp
--
diff --git a/apps/showcase/src/main/webapp/WEB-INF/tiles/body.jsp 
b/apps/showcase/src/main/webapp/WEB-INF/tiles/body.jsp
index ca9d10d..855a896 100644
--- a/apps/showcase/src/main/webapp/WEB-INF/tiles/body.jsp
+++ b/apps/showcase/src/main/webapp/WEB-INF/tiles/body.jsp
@@ -1,27 +1,27 @@
-<%@taglib prefix="s" uri="/struts-tags" %>
-
-   
-   
-   
-   This example illustrates the Struts/Tiles 
Plugin.
-
-   Tiles 2 is an effort to extract the Tiles 
library from Struts. It is currently housed
-   in the Sandbox area of the Apache 
Struts Subversion repository.
-
-   Features
-   
-   
-   View FreeMarker Example
-   
-   
-   View Example with a FreeMarker Layout
-   
-   
-   View Example with tiles configuration by 
annotating action
-   
-   
-
-   
-   
-   
+<%@taglib prefix="s" uri="/struts-tags" %>
+
+   
+   
+   
+   This example illustrates the Struts/Tiles 
Plugin.
+
+   Tiles 2 is an effort to extract the Tiles 
library from Struts. It is currently housed
+   in the Sandbox area of the Apache 
Struts Subversion repository.
+
+   Features
+   
+   
+   View FreeMarker Example
+   
+   
+   View Example with a FreeMarker Layout
+   
+   
+   View Example with tiles configuration by 
annotating action
+   
+   
+
+   
+   
+   
 
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/struts/blob/b1588ddc/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java
--
diff --git 
a/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java 
b/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java
index da00765..4656f91 100644
--- 

[11/13] struts git commit: removed outcommented line

2016-02-03 Thread cnenning
removed outcommented line


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/f5ef1438
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/f5ef1438
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/f5ef1438

Branch: refs/heads/master
Commit: f5ef1438aaf4d9841dd5180a470dbe52edd8693e
Parents: 8651545
Author: cnenning 
Authored: Mon Feb 1 09:45:34 2016 +0100
Committer: cnenning 
Committed: Mon Feb 1 09:45:34 2016 +0100

--
 .../apache/struts2/tiles/StrutsTilesAnnotationProcessorTest.java| 1 -
 1 file changed, 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/struts/blob/f5ef1438/plugins/tiles/src/test/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessorTest.java
--
diff --git 
a/plugins/tiles/src/test/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessorTest.java
 
b/plugins/tiles/src/test/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessorTest.java
index acaacce..c71d100 100644
--- 
a/plugins/tiles/src/test/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessorTest.java
+++ 
b/plugins/tiles/src/test/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessorTest.java
@@ -109,7 +109,6 @@ public class StrutsTilesAnnotationProcessorTest {
 Assert.assertNull(definition.getExtends());
 Attribute templateAttribute = definition.getTemplateAttribute();
 Assert.assertNull(templateAttribute.getValue());
-//Assert.assertNull(templateAttribute.getRenderer());
 Assert.assertNull(templateAttribute.getRole());
 Assert.assertNull(templateAttribute.getExpressionObject());
 



[09/13] struts git commit: added missing license header

2016-02-03 Thread cnenning
added missing license header


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/92302703
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/92302703
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/92302703

Branch: refs/heads/master
Commit: 92302703f2430ee6077fa93f0eabd6dbfc497d9a
Parents: edf7c09
Author: cnenning 
Authored: Mon Feb 1 09:37:25 2016 +0100
Committer: cnenning 
Committed: Mon Feb 1 09:37:25 2016 +0100

--
 .../showcase/tiles/TilesAnnotationsAction.java| 18 ++
 1 file changed, 18 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/struts/blob/92302703/apps/showcase/src/main/java/org/apache/struts2/showcase/tiles/TilesAnnotationsAction.java
--
diff --git 
a/apps/showcase/src/main/java/org/apache/struts2/showcase/tiles/TilesAnnotationsAction.java
 
b/apps/showcase/src/main/java/org/apache/struts2/showcase/tiles/TilesAnnotationsAction.java
index b5c62f0..2b789c2 100644
--- 
a/apps/showcase/src/main/java/org/apache/struts2/showcase/tiles/TilesAnnotationsAction.java
+++ 
b/apps/showcase/src/main/java/org/apache/struts2/showcase/tiles/TilesAnnotationsAction.java
@@ -1,3 +1,21 @@
+/*
+ * 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.struts2.showcase.tiles;
 
 import org.apache.struts2.convention.annotation.Namespace;



[08/13] struts git commit: formatted annotations more nicely

2016-02-03 Thread cnenning
formatted annotations more nicely


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/edf7c099
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/edf7c099
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/edf7c099

Branch: refs/heads/master
Commit: edf7c099e3ed6ee17008a738ef8801c854139fd1
Parents: 9ca6eb9
Author: cnenning 
Authored: Mon Feb 1 09:36:23 2016 +0100
Committer: cnenning 
Committed: Mon Feb 1 09:36:23 2016 +0100

--
 .../apache/struts2/showcase/tiles/TilesAnnotationsAction.java   | 5 +++--
 .../org/apache/struts2/tiles/annotation/TilesDefinition.java| 3 ++-
 2 files changed, 5 insertions(+), 3 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/struts/blob/edf7c099/apps/showcase/src/main/java/org/apache/struts2/showcase/tiles/TilesAnnotationsAction.java
--
diff --git 
a/apps/showcase/src/main/java/org/apache/struts2/showcase/tiles/TilesAnnotationsAction.java
 
b/apps/showcase/src/main/java/org/apache/struts2/showcase/tiles/TilesAnnotationsAction.java
index 997db11..b5c62f0 100644
--- 
a/apps/showcase/src/main/java/org/apache/struts2/showcase/tiles/TilesAnnotationsAction.java
+++ 
b/apps/showcase/src/main/java/org/apache/struts2/showcase/tiles/TilesAnnotationsAction.java
@@ -12,8 +12,9 @@ import com.opensymphony.xwork2.ActionSupport;
 @ParentPackage("tiles")
 @Result(name = "success", type="tiles")
 @TilesDefinition(extend = "showcase.annotations", putAttributes = {
-@TilesPutAttribute(name = "header", value = 
"/WEB-INF/tiles/header.jsp"),
-@TilesPutAttribute(name = "body", value = "/WEB-INF/tiles/body.ftl"), 
})
+@TilesPutAttribute(name = "header", value = "/WEB-INF/tiles/header.jsp"),
+@TilesPutAttribute(name = "body", value = "/WEB-INF/tiles/body.ftl")
+})
 public class TilesAnnotationsAction extends ActionSupport {
 
 private static final long serialVersionUID = 2900509995064928866L;

http://git-wip-us.apache.org/repos/asf/struts/blob/edf7c099/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesDefinition.java
--
diff --git 
a/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesDefinition.java
 
b/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesDefinition.java
index 1618b63..3aa144c 100644
--- 
a/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesDefinition.java
+++ 
b/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesDefinition.java
@@ -42,7 +42,8 @@ import java.lang.annotation.Target;
  *  @Result(name = "success", type="tiles")
  *  @TilesDefinition(extend = "layout", putAttributes = {
  *  @TilesPutAttribute(name = "header", value = 
"/WEB-INF/tiles/header.jsp"),
- *  @TilesPutAttribute(name = "body", value = 
"/WEB-INF/tiles/body.ftl"), })
+ *  @TilesPutAttribute(name = "body", value = 
"/WEB-INF/tiles/body.ftl")
+ *  })
  *  public class FooAction extends ActionSupport {
  *  
  * 



[01/13] struts git commit: fixed tiles showcase by setting dtd to 3.0

2016-02-03 Thread cnenning
Repository: struts
Updated Branches:
  refs/heads/master 954a29efc -> 6d2a57355


fixed tiles showcase by setting dtd to 3.0

Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/d9f4054b
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/d9f4054b
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/d9f4054b

Branch: refs/heads/master
Commit: d9f4054b1367cd7ab6e3f22b9cc677f62def4e83
Parents: 249d2f8
Author: cnenning 
Authored: Fri Jan 22 14:59:48 2016 +0100
Committer: cnenning 
Committed: Fri Jan 22 14:59:48 2016 +0100

--
 apps/showcase/src/main/webapp/WEB-INF/tiles.xml | 96 ++--
 1 file changed, 48 insertions(+), 48 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/struts/blob/d9f4054b/apps/showcase/src/main/webapp/WEB-INF/tiles.xml
--
diff --git a/apps/showcase/src/main/webapp/WEB-INF/tiles.xml 
b/apps/showcase/src/main/webapp/WEB-INF/tiles.xml
index 7c7057f..027f9a4 100644
--- a/apps/showcase/src/main/webapp/WEB-INF/tiles.xml
+++ b/apps/showcase/src/main/webapp/WEB-INF/tiles.xml
@@ -1,48 +1,48 @@
-
-
-
-http://tiles.apache.org/dtds/tiles-config_2_0.dtd;>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+http://tiles.apache.org/dtds/tiles-config_3_0.dtd;>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+



[05/13] struts git commit: updated javadoc

2016-02-03 Thread cnenning
updated javadoc

Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/a53deac7
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/a53deac7
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/a53deac7

Branch: refs/heads/master
Commit: a53deac7ce8732053edd43dddac329448055aef0
Parents: d76357f
Author: cnenning 
Authored: Mon Jan 25 13:39:47 2016 +0100
Committer: cnenning 
Committed: Mon Jan 25 13:39:47 2016 +0100

--
 .../tiles/annotation/TilesDefinition.java   | 20 
 1 file changed, 20 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/struts/blob/a53deac7/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesDefinition.java
--
diff --git 
a/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesDefinition.java
 
b/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesDefinition.java
index a71bbc3..1618b63 100644
--- 
a/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesDefinition.java
+++ 
b/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesDefinition.java
@@ -27,6 +27,26 @@ import java.lang.annotation.Target;
 /**
  * Represents a definition element in 
tiles.xml.
  *
+ * 
+ *  With a sample layout in tiles.xml like this:
+ *  
+ *  definition name="layout" template="/WEB-INF/tiles/layout.jsp"
+ *  put-attribute name="header" value=".header"/
+ *  put-attribute name="body" value=".body"/
+ *  /definition
+ *  
+ * 
+ * 
+ *  You can annotate an action like that:
+ *  
+ *  @Result(name = "success", type="tiles")
+ *  @TilesDefinition(extend = "layout", putAttributes = {
+ *  @TilesPutAttribute(name = "header", value = 
"/WEB-INF/tiles/header.jsp"),
+ *  @TilesPutAttribute(name = "body", value = 
"/WEB-INF/tiles/body.ftl"), })
+ *  public class FooAction extends ActionSupport {
+ *  
+ * 
+ *
  */
 @Retention(value = RetentionPolicy.RUNTIME)
 @Target(value = { ElementType.TYPE })



[02/13] struts git commit: Added tiles annotations, see WW-4594.

2016-02-03 Thread cnenning
Added tiles annotations, see WW-4594.

Added tiles annotations, created StrutsTilesAnnotationProcessor to
create Definitons from them and using it in TilesResult.

Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/9ac326aa
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/9ac326aa
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/9ac326aa

Branch: refs/heads/master
Commit: 9ac326aa2458fe43140c1b13b61c87752d282e3d
Parents: d9f4054
Author: cnenning 
Authored: Fri Jan 22 15:27:09 2016 +0100
Committer: cnenning 
Committed: Fri Jan 22 15:27:09 2016 +0100

--
 .../tiles/StrutsTilesAnnotationProcessor.java   | 176 
 .../tiles/annotation/TilesAddAttribute.java |  30 ++
 .../tiles/annotation/TilesAddListAttribute.java |  28 ++
 .../tiles/annotation/TilesDefinition.java   |  45 +++
 .../tiles/annotation/TilesDefinitions.java  |  36 +++
 .../tiles/annotation/TilesPutAttribute.java |  32 +++
 .../tiles/annotation/TilesPutListAttribute.java |  32 +++
 .../apache/struts2/views/tiles/TilesResult.java | 279 +++
 8 files changed, 542 insertions(+), 116 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/struts/blob/9ac326aa/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessor.java
--
diff --git 
a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessor.java
 
b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessor.java
new file mode 100644
index 000..2ae3ba4
--- /dev/null
+++ 
b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessor.java
@@ -0,0 +1,176 @@
+/*
+ * 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.struts2.tiles;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.struts2.tiles.annotation.TilesAddAttribute;
+import org.apache.struts2.tiles.annotation.TilesAddListAttribute;
+import org.apache.struts2.tiles.annotation.TilesDefinition;
+import org.apache.struts2.tiles.annotation.TilesDefinitions;
+import org.apache.struts2.tiles.annotation.TilesPutAttribute;
+import org.apache.struts2.tiles.annotation.TilesPutListAttribute;
+import org.apache.tiles.Attribute;
+import org.apache.tiles.Definition;
+import org.apache.tiles.Expression;
+import org.apache.tiles.ListAttribute;
+
+/**
+ * Processes tiles annotations to create {@link Definition}s and
+ * {@link Attribute}s in a way as close to tiles.xml as possible.
+ *
+ */
+public class StrutsTilesAnnotationProcessor {
+
+/**
+ * Search strategy is as follows:
+ * 
+ *   Check if action has Annotation {@link TilesDefinition}
+ *   If not, check if action has Annotation {@link 
TilesDefinitions}
+ *   If given tileName is not null and present in {@link 
TilesDefinitions}, return it
+ *   Return first element of {@link TilesDefinitions}
+ *   Return null
+ * 
+ *
+ * @param action
+ *Annotated action.
+ * @param tileName
+ *Tilename to search for. May be null in some circumstances.
+ * @return {@link TilesDefinition}
+ */
+public TilesDefinition findAnnotation(Object action, String tileName) {
+Class clazz = action.getClass();
+TilesDefinition tilesDefinition = 
clazz.getAnnotation(TilesDefinition.class);
+TilesDefinitions tilesDefinitions = 
clazz.getAnnotation(TilesDefinitions.class);
+
+if (tilesDefinition == null && tilesDefinitions != null) {
+if (!StringUtils.isEmpty(tileName)) {
+for (TilesDefinition i : tilesDefinitions.value()) {
+if (i.name() != null && i.name().equals(tileName)) {
+tilesDefinition = i;
+break;
+}
+}
+}
+if (tilesDefinitions.value().length > 0) {
+tilesDefinition = 

[04/13] struts git commit: added tests for StrutsTilesAnnotationProcessor

2016-02-03 Thread cnenning
added tests for StrutsTilesAnnotationProcessor

Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/d76357fd
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/d76357fd
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/d76357fd

Branch: refs/heads/master
Commit: d76357fd829a3ea8ddca21d625c49b606cca88d5
Parents: e50c37c
Author: cnenning 
Authored: Mon Jan 25 11:23:10 2016 +0100
Committer: cnenning 
Committed: Mon Jan 25 11:23:10 2016 +0100

--
 .../tiles/StrutsTilesAnnotationProcessor.java   |   7 +-
 .../TestStrutsTilesAnnotationProcessor.java | 148 +++
 .../TilesTestActionMultipleAnnotations.java |  12 ++
 .../tiles/TilesTestActionSingleAnnotation.java  |  49 ++
 ...TilesTestActionSingleAnnotationAllEmpty.java |  28 
 5 files changed, 241 insertions(+), 3 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/struts/blob/d76357fd/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessor.java
--
diff --git 
a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessor.java
 
b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessor.java
index 2ae3ba4..fa5f735 100644
--- 
a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessor.java
+++ 
b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessor.java
@@ -66,9 +66,10 @@ public class StrutsTilesAnnotationProcessor {
 break;
 }
 }
-}
-if (tilesDefinitions.value().length > 0) {
-tilesDefinition = tilesDefinitions.value()[0];
+} else {
+if (tilesDefinitions.value().length > 0) {
+tilesDefinition = tilesDefinitions.value()[0];
+}
 }
 }
 

http://git-wip-us.apache.org/repos/asf/struts/blob/d76357fd/plugins/tiles/src/test/java/org/apache/struts2/tiles/TestStrutsTilesAnnotationProcessor.java
--
diff --git 
a/plugins/tiles/src/test/java/org/apache/struts2/tiles/TestStrutsTilesAnnotationProcessor.java
 
b/plugins/tiles/src/test/java/org/apache/struts2/tiles/TestStrutsTilesAnnotationProcessor.java
new file mode 100644
index 000..db808cd
--- /dev/null
+++ 
b/plugins/tiles/src/test/java/org/apache/struts2/tiles/TestStrutsTilesAnnotationProcessor.java
@@ -0,0 +1,148 @@
+package org.apache.struts2.tiles;
+
+import java.util.List;
+import java.util.Set;
+
+import org.apache.struts2.tiles.annotation.TilesDefinition;
+import org.apache.tiles.Attribute;
+import org.apache.tiles.Definition;
+import org.apache.tiles.Expression;
+import org.junit.Test;
+
+import org.junit.Assert;
+
+public class TestStrutsTilesAnnotationProcessor {
+
+@Test
+public void findAnnotationSingleAction() {
+StrutsTilesAnnotationProcessor annotationProcessor = new 
StrutsTilesAnnotationProcessor();
+TilesDefinition tilesDefinition = 
annotationProcessor.findAnnotation(new TilesTestActionSingleAnnotation(), null);
+Assert.assertNotNull(tilesDefinition);
+Assert.assertEquals("definition-name", tilesDefinition.name());
+}
+
+@Test
+public void findAnnotationMultipleActionNameNull() {
+StrutsTilesAnnotationProcessor annotationProcessor = new 
StrutsTilesAnnotationProcessor();
+TilesDefinition tilesDefinition = 
annotationProcessor.findAnnotation(new TilesTestActionMultipleAnnotations(), 
null);
+Assert.assertNotNull(tilesDefinition);
+Assert.assertEquals("def1", tilesDefinition.name());
+}
+
+@Test
+public void findAnnotationMultipleActionNameGiven() {
+StrutsTilesAnnotationProcessor annotationProcessor = new 
StrutsTilesAnnotationProcessor();
+TilesDefinition tilesDefinition = 
annotationProcessor.findAnnotation(new TilesTestActionMultipleAnnotations(), 
"def2");
+Assert.assertNotNull(tilesDefinition);
+Assert.assertEquals("def2", tilesDefinition.name());
+}
+
+@Test
+public void findAnnotationMultipleActionNotFound() {
+StrutsTilesAnnotationProcessor annotationProcessor = new 
StrutsTilesAnnotationProcessor();
+TilesDefinition tilesDefinition = 
annotationProcessor.findAnnotation(new TilesTestActionMultipleAnnotations(), 
"def3");
+Assert.assertNull(tilesDefinition);
+}
+
+@Test
+public void buildDefiniton() {
+StrutsTilesAnnotationProcessor annotationProcessor = new 
StrutsTilesAnnotationProcessor();
+TilesDefinition tilesDefinition = 
annotationProcessor.findAnnotation(new 

[03/13] struts git commit: added sample for tiles annotations

2016-02-03 Thread cnenning
added sample for tiles annotations

Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/e50c37c5
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/e50c37c5
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/e50c37c5

Branch: refs/heads/master
Commit: e50c37c5ba5781900edf53f9ec71b8649471d448
Parents: 9ac326a
Author: cnenning 
Authored: Fri Jan 22 15:27:50 2016 +0100
Committer: cnenning 
Committed: Fri Jan 22 15:27:50 2016 +0100

--
 .../showcase/tiles/TilesAnnotationsAction.java  | 21 +
 apps/showcase/src/main/webapp/WEB-INF/tiles.xml |  6 +++
 .../src/main/webapp/WEB-INF/tiles/body.jsp  | 49 +++-
 .../webapp/WEB-INF/tiles/layout-annotations.jsp | 14 ++
 4 files changed, 67 insertions(+), 23 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/struts/blob/e50c37c5/apps/showcase/src/main/java/org/apache/struts2/showcase/tiles/TilesAnnotationsAction.java
--
diff --git 
a/apps/showcase/src/main/java/org/apache/struts2/showcase/tiles/TilesAnnotationsAction.java
 
b/apps/showcase/src/main/java/org/apache/struts2/showcase/tiles/TilesAnnotationsAction.java
new file mode 100644
index 000..997db11
--- /dev/null
+++ 
b/apps/showcase/src/main/java/org/apache/struts2/showcase/tiles/TilesAnnotationsAction.java
@@ -0,0 +1,21 @@
+package org.apache.struts2.showcase.tiles;
+
+import org.apache.struts2.convention.annotation.Namespace;
+import org.apache.struts2.convention.annotation.ParentPackage;
+import org.apache.struts2.convention.annotation.Result;
+import org.apache.struts2.tiles.annotation.TilesDefinition;
+import org.apache.struts2.tiles.annotation.TilesPutAttribute;
+
+import com.opensymphony.xwork2.ActionSupport;
+
+@Namespace("/tiles")
+@ParentPackage("tiles")
+@Result(name = "success", type="tiles")
+@TilesDefinition(extend = "showcase.annotations", putAttributes = {
+@TilesPutAttribute(name = "header", value = 
"/WEB-INF/tiles/header.jsp"),
+@TilesPutAttribute(name = "body", value = "/WEB-INF/tiles/body.ftl"), 
})
+public class TilesAnnotationsAction extends ActionSupport {
+
+private static final long serialVersionUID = 2900509995064928866L;
+
+}

http://git-wip-us.apache.org/repos/asf/struts/blob/e50c37c5/apps/showcase/src/main/webapp/WEB-INF/tiles.xml
--
diff --git a/apps/showcase/src/main/webapp/WEB-INF/tiles.xml 
b/apps/showcase/src/main/webapp/WEB-INF/tiles.xml
index 027f9a4..d644502 100644
--- a/apps/showcase/src/main/webapp/WEB-INF/tiles.xml
+++ b/apps/showcase/src/main/webapp/WEB-INF/tiles.xml
@@ -45,4 +45,10 @@
 
 
 
+
+
+
+
+
+
 

http://git-wip-us.apache.org/repos/asf/struts/blob/e50c37c5/apps/showcase/src/main/webapp/WEB-INF/tiles/body.jsp
--
diff --git a/apps/showcase/src/main/webapp/WEB-INF/tiles/body.jsp 
b/apps/showcase/src/main/webapp/WEB-INF/tiles/body.jsp
index e2e3512..ca9d10d 100644
--- a/apps/showcase/src/main/webapp/WEB-INF/tiles/body.jsp
+++ b/apps/showcase/src/main/webapp/WEB-INF/tiles/body.jsp
@@ -1,24 +1,27 @@
-<%@taglib prefix="s" uri="/struts-tags" %>
-
-   
-   
-   
-   This example illustrates the Struts/Tiles 
Plugin.
-
-   Tiles 2 is an effort to extract the Tiles 
library from Struts. It is currently housed
-   in the Sandbox area of the Apache 
Struts Subversion repository.
-
-   Features
-   
-   
-   View FreeMarker Example
-   
-   
-   View Example with a FreeMarker Layout
-   
-   
-
-   
-   
-   
+<%@taglib prefix="s" uri="/struts-tags" %>
+
+   
+   
+   
+   This example illustrates the Struts/Tiles 
Plugin.
+
+   Tiles 2 is an effort to extract the Tiles 
library from Struts. It is currently housed
+   in the Sandbox area of the Apache 
Struts Subversion repository.
+
+   Features
+   
+   
+   View FreeMarker Example
+   
+   

[09/10] struts git commit: removed outcommented line

2016-02-03 Thread cnenning
removed outcommented line


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/8a9e0172
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/8a9e0172
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/8a9e0172

Branch: refs/heads/support-2-3
Commit: 8a9e01727ce51a0a8291a45a593ec40428de
Parents: 5b2b244
Author: cnenning 
Authored: Mon Feb 1 09:45:34 2016 +0100
Committer: cnenning 
Committed: Wed Feb 3 13:34:47 2016 +0100

--
 .../apache/struts2/tiles/StrutsTilesAnnotationProcessorTest.java| 1 -
 1 file changed, 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/struts/blob/8a9e0172/plugins/tiles/src/test/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessorTest.java
--
diff --git 
a/plugins/tiles/src/test/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessorTest.java
 
b/plugins/tiles/src/test/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessorTest.java
index acaacce..c71d100 100644
--- 
a/plugins/tiles/src/test/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessorTest.java
+++ 
b/plugins/tiles/src/test/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessorTest.java
@@ -109,7 +109,6 @@ public class StrutsTilesAnnotationProcessorTest {
 Assert.assertNull(definition.getExtends());
 Attribute templateAttribute = definition.getTemplateAttribute();
 Assert.assertNull(templateAttribute.getValue());
-//Assert.assertNull(templateAttribute.getRenderer());
 Assert.assertNull(templateAttribute.getRole());
 Assert.assertNull(templateAttribute.getExpressionObject());
 



[2/2] struts-examples git commit: Adds new app to show how to use MessageStore

2016-02-03 Thread lukaszlenart
Adds new app to show how to use MessageStore


Project: http://git-wip-us.apache.org/repos/asf/struts-examples/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts-examples/commit/74c60c11
Tree: http://git-wip-us.apache.org/repos/asf/struts-examples/tree/74c60c11
Diff: http://git-wip-us.apache.org/repos/asf/struts-examples/diff/74c60c11

Branch: refs/heads/master
Commit: 74c60c11f207e69e8ef03bd1f9e9224e0f823b0b
Parents: 496a01b
Author: Lukasz Lenart 
Authored: Thu Feb 4 08:18:02 2016 +0100
Committer: Lukasz Lenart 
Committed: Thu Feb 4 08:18:02 2016 +0100

--
 message-store/pom.xml   | 50 
 .../org/apache/struts/example/HelloWorld1.java  | 33 +
 .../org/apache/struts/example/HelloWorld2.java  | 32 +
 message-store/src/main/resources/example.xml| 37 +++
 message-store/src/main/resources/log4j2.xml | 16 +++
 message-store/src/main/resources/struts.xml | 25 ++
 .../main/webapp/WEB-INF/example/HelloWorld2.jsp | 13 +
 message-store/src/main/webapp/WEB-INF/web.xml   | 23 +
 message-store/src/main/webapp/index.html| 10 
 9 files changed, 239 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/struts-examples/blob/74c60c11/message-store/pom.xml
--
diff --git a/message-store/pom.xml b/message-store/pom.xml
new file mode 100644
index 000..f90d3c0
--- /dev/null
+++ b/message-store/pom.xml
@@ -0,0 +1,50 @@
+
+http://maven.apache.org/POM/4.0.0; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance;
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd;>
+  4.0.0
+  
+struts-examples
+org.apache.struts
+1.0.0
+  
+
+  message-store
+  1.0-SNAPSHOT
+  war
+  message-store
+
+  
+
+  javax.servlet
+  servlet-api
+  2.4
+  provided
+
+
+
+  javax.servlet
+  jsp-api
+  2.0
+  provided
+
+  
+
+  
+
+  
+org.mortbay.jetty
+jetty-maven-plugin
+8.1.16.v20140903
+
+  CTRL+C
+  8999
+  10
+  
${basedir}/src/main/webapp/
+  
+${basedir}/src/main/webapp/WEB-INF/web.xml
+  
+
+  
+
+  
+

http://git-wip-us.apache.org/repos/asf/struts-examples/blob/74c60c11/message-store/src/main/java/org/apache/struts/example/HelloWorld1.java
--
diff --git 
a/message-store/src/main/java/org/apache/struts/example/HelloWorld1.java 
b/message-store/src/main/java/org/apache/struts/example/HelloWorld1.java
new file mode 100644
index 000..ddd9b09
--- /dev/null
+++ b/message-store/src/main/java/org/apache/struts/example/HelloWorld1.java
@@ -0,0 +1,33 @@
+/*
+ * $Id$
+ *
+ * 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.struts.example;
+
+import com.opensymphony.xwork2.ActionSupport;
+
+public class HelloWorld1 extends ActionSupport {
+
+public String execute() throws Exception {
+addActionError("Hello from HelloWorld1!");
+return SUCCESS;
+}
+
+}

http://git-wip-us.apache.org/repos/asf/struts-examples/blob/74c60c11/message-store/src/main/java/org/apache/struts/example/HelloWorld2.java
--
diff --git 
a/message-store/src/main/java/org/apache/struts/example/HelloWorld2.java 
b/message-store/src/main/java/org/apache/struts/example/HelloWorld2.java
new file mode 100644
index 000..5e92dd3
--- /dev/null
+++ b/message-store/src/main/java/org/apache/struts/example/HelloWorld2.java
@@ -0,0 +1,32 @@
+/*
+ * $Id$
+ *
+ * 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 

[1/2] struts-examples git commit: Defines new example app

2016-02-03 Thread lukaszlenart
Repository: struts-examples
Updated Branches:
  refs/heads/master ce0b5d249 -> 74c60c11f


Defines new example app


Project: http://git-wip-us.apache.org/repos/asf/struts-examples/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts-examples/commit/496a01b7
Tree: http://git-wip-us.apache.org/repos/asf/struts-examples/tree/496a01b7
Diff: http://git-wip-us.apache.org/repos/asf/struts-examples/diff/496a01b7

Branch: refs/heads/master
Commit: 496a01b746f13bcdbfb2a9209b4822420efc0708
Parents: ce0b5d2
Author: Lukasz Lenart 
Authored: Thu Feb 4 08:17:12 2016 +0100
Committer: Lukasz Lenart 
Committed: Thu Feb 4 08:17:12 2016 +0100

--
 pom.xml | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/struts-examples/blob/496a01b7/pom.xml
--
diff --git a/pom.xml b/pom.xml
index e04ccda..75ada42 100644
--- a/pom.xml
+++ b/pom.xml
@@ -74,7 +74,8 @@
 using-tags
 unit-testing
 wildcard-method-selection
-
+message-store
+  
 
 
 
@@ -115,4 +116,4 @@
 
 
 
-
+
\ No newline at end of file



[2/7] struts git commit: Defines listener to store messages

2016-02-03 Thread lukaszlenart
Defines listener to store messages


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/a9b2c3cb
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/a9b2c3cb
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/a9b2c3cb

Branch: refs/heads/master
Commit: a9b2c3cb4d43f0816141ae5d0ed7f49f6d1874d5
Parents: 6bb526d
Author: Lukasz Lenart 
Authored: Thu Feb 4 08:04:44 2016 +0100
Committer: Lukasz Lenart 
Committed: Thu Feb 4 08:04:44 2016 +0100

--
 .../MessageStorePreResultListener.java  | 95 
 1 file changed, 95 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/struts/blob/a9b2c3cb/core/src/main/java/org/apache/struts2/interceptor/MessageStorePreResultListener.java
--
diff --git 
a/core/src/main/java/org/apache/struts2/interceptor/MessageStorePreResultListener.java
 
b/core/src/main/java/org/apache/struts2/interceptor/MessageStorePreResultListener.java
new file mode 100644
index 000..0f45b1a
--- /dev/null
+++ 
b/core/src/main/java/org/apache/struts2/interceptor/MessageStorePreResultListener.java
@@ -0,0 +1,95 @@
+/*
+ * 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.struts2.interceptor;
+
+import com.opensymphony.xwork2.ActionInvocation;
+import com.opensymphony.xwork2.interceptor.PreResultListener;
+import com.opensymphony.xwork2.interceptor.ValidationAware;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.struts2.ServletActionContext;
+import org.apache.struts2.result.ServletRedirectResult;
+
+import java.util.Map;
+
+/**
+ * This listener is used by {@link MessageStoreInterceptor} to store messages 
in HttpSession
+ * just before result will be executed. It must be done that way as after 
result will be executed
+ * HttpSession cannot be modified (response was already sent to browser).
+ */
+class MessageStorePreResultListener implements PreResultListener {
+
+private static final Logger LOG = 
LogManager.getLogger(MessageStorePreResultListener.class);
+
+private MessageStoreInterceptor interceptor;
+
+public MessageStorePreResultListener(MessageStoreInterceptor interceptor) {
+this.interceptor = interceptor;
+}
+
+@Override
+public void beforeResult(ActionInvocation invocation, String resultCode) {
+
+boolean isCommitted = ServletActionContext.getResponse().isCommitted();
+if (isCommitted) {
+LOG.trace("Response was already committed, cannot store 
messages!");
+return;
+}
+
+boolean isInvalidated = 
ServletActionContext.getRequest().getSession(false) == null;
+if (isInvalidated) {
+LOG.trace("Session was invalidated or never created, cannot store 
messages!");
+return;
+}
+
+Map session = 
invocation.getInvocationContext().getSession();
+if (session == null) {
+LOG.trace("Could not store action [{}] error/messages into 
session, because session hasn't been opened yet.", invocation.getAction());
+return;
+}
+
+String reqOperationMode = 
interceptor.getRequestOperationMode(invocation);
+
+boolean isRedirect = false;
+try {
+isRedirect = invocation.getResult() instanceof 
ServletRedirectResult;
+} catch (Exception e) {
+LOG.warn("Cannot read result!", e);
+}
+
+if 
(MessageStoreInterceptor.STORE_MODE.equalsIgnoreCase(reqOperationMode) ||
+
MessageStoreInterceptor.STORE_MODE.equalsIgnoreCase(interceptor.getOperationModel())
 ||
+
(MessageStoreInterceptor.AUTOMATIC_MODE.equalsIgnoreCase(interceptor.getOperationModel())
 && isRedirect)) {
+
+Object action = invocation.getAction();
+if (action instanceof ValidationAware) {
+LOG.debug("Storing action [{}] error/messages into session ", 

[6/7] struts git commit: Updates tests to reflect invocation change logic

2016-02-03 Thread lukaszlenart
Updates tests to reflect invocation change logic


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/41cf08c7
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/41cf08c7
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/41cf08c7

Branch: refs/heads/master
Commit: 41cf08c772d36fabecb9517cad614d525bb8f01e
Parents: f755e01
Author: Lukasz Lenart 
Authored: Thu Feb 4 08:06:08 2016 +0100
Committer: Lukasz Lenart 
Committed: Thu Feb 4 08:06:08 2016 +0100

--
 .../java/com/opensymphony/xwork2/DefaultActionInvocationTest.java | 3 +++
 .../src/test/java/org/apache/struts2/views/jsp/ActionTagTest.java | 3 ++-
 2 files changed, 5 insertions(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/struts/blob/41cf08c7/core/src/test/java/com/opensymphony/xwork2/DefaultActionInvocationTest.java
--
diff --git 
a/core/src/test/java/com/opensymphony/xwork2/DefaultActionInvocationTest.java 
b/core/src/test/java/com/opensymphony/xwork2/DefaultActionInvocationTest.java
index 042c1dc..7b7b3fe 100644
--- 
a/core/src/test/java/com/opensymphony/xwork2/DefaultActionInvocationTest.java
+++ 
b/core/src/test/java/com/opensymphony/xwork2/DefaultActionInvocationTest.java
@@ -1,6 +1,8 @@
 package com.opensymphony.xwork2;
 
+import com.opensymphony.xwork2.config.entities.ActionConfig;
 import com.opensymphony.xwork2.config.entities.InterceptorMapping;
+import com.opensymphony.xwork2.config.entities.ResultConfig;
 import com.opensymphony.xwork2.mock.MockActionProxy;
 import com.opensymphony.xwork2.mock.MockContainer;
 import com.opensymphony.xwork2.mock.MockInterceptor;
@@ -304,6 +306,7 @@ class DefaultActionInvocationTester extends 
DefaultActionInvocation {
 interceptors = interceptorMappings.iterator();
 MockActionProxy actionProxy = new MockActionProxy();
 actionProxy.setMethod("execute");
+actionProxy.setConfig(new ActionConfig.Builder("foo", "bar", 
"clazz").addResultConfig(new ResultConfig.Builder("buzz", 
"fizz").build()).build());
 proxy = actionProxy;
 action = new ActionSupport();
 }

http://git-wip-us.apache.org/repos/asf/struts/blob/41cf08c7/core/src/test/java/org/apache/struts2/views/jsp/ActionTagTest.java
--
diff --git a/core/src/test/java/org/apache/struts2/views/jsp/ActionTagTest.java 
b/core/src/test/java/org/apache/struts2/views/jsp/ActionTagTest.java
index 42d9a71..2b1cd82 100644
--- a/core/src/test/java/org/apache/struts2/views/jsp/ActionTagTest.java
+++ b/core/src/test/java/org/apache/struts2/views/jsp/ActionTagTest.java
@@ -179,7 +179,8 @@ public class ActionTagTest extends AbstractTagTest {
 
 
assertTrue(stack.getContext().containsKey(ServletActionContext.PAGE_CONTEXT));
 
assertTrue(stack.getContext().get(ServletActionContext.PAGE_CONTEXT)instanceof 
PageContext);
-assertNull(result); // result is never executed, hence never set into 
invocation
+assertNotNull(result);
+assertFalse(result.isExecuted());
 }
 
  public void testExecuteButResetReturnSameInvocation() throws Exception {



[5/7] struts git commit: Updates test to cover usage of new listener

2016-02-03 Thread lukaszlenart
Updates test to cover usage of new listener


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/f755e01c
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/f755e01c
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/f755e01c

Branch: refs/heads/master
Commit: f755e01c182e48cab00244ba16f3f6eafa746880
Parents: 8071052
Author: Lukasz Lenart 
Authored: Thu Feb 4 08:05:46 2016 +0100
Committer: Lukasz Lenart 
Committed: Thu Feb 4 08:05:46 2016 +0100

--
 .../MessageStoreInterceptorTest.java| 234 +--
 1 file changed, 7 insertions(+), 227 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/struts/blob/f755e01c/core/src/test/java/org/apache/struts2/interceptor/MessageStoreInterceptorTest.java
--
diff --git 
a/core/src/test/java/org/apache/struts2/interceptor/MessageStoreInterceptorTest.java
 
b/core/src/test/java/org/apache/struts2/interceptor/MessageStoreInterceptorTest.java
index 77b9da1..9fc8396 100644
--- 
a/core/src/test/java/org/apache/struts2/interceptor/MessageStoreInterceptorTest.java
+++ 
b/core/src/test/java/org/apache/struts2/interceptor/MessageStoreInterceptorTest.java
@@ -28,6 +28,7 @@ import java.util.List;
 import java.util.Map;
 
 import com.opensymphony.xwork2.ActionProxy;
+import com.opensymphony.xwork2.interceptor.PreResultListener;
 import org.apache.struts2.ServletActionContext;
 import org.apache.struts2.StrutsInternalTestCase;
 import org.apache.struts2.result.ServletActionRedirectResult;
@@ -63,84 +64,6 @@ public class MessageStoreInterceptorTest extends 
StrutsInternalTestCase {
 ServletActionContext.setResponse(response);
 }
 
-public void testStoreMessage() throws Exception {
-MessageStoreInterceptor interceptor = new MessageStoreInterceptor();
-interceptor.setAllowRequestParameterSwitch(true);
-interceptor.setOperationMode(MessageStoreInterceptor.STORE_MODE);
-
-
-Map paramMap = new LinkedHashMap();
-Map sessionMap = new LinkedHashMap();
-
-ActionSupport action = new ActionSupport();
-action.addActionError("some action error 1");
-action.addActionError("some action error 2");
-action.addActionMessage("some action message 1");
-action.addActionMessage("some action message 2");
-action.addFieldError("field1", "some field error 1");
-action.addFieldError("field2", "some field error 2");
-
-ActionContext actionContext = new ActionContext(new HashMap());
-actionContext.put(ActionContext.PARAMETERS, paramMap);
-actionContext.put(ActionContext.SESSION, sessionMap);
-
-HttpSession mockedSession = 
EasyMock.createControl().createMock(HttpSession.class);
-HttpServletRequest mockedRequest = 
EasyMock.createControl().createMock(HttpServletRequest.class);
-mockedRequest.getSession(false);
-EasyMock.expectLastCall().andReturn(mockedSession);
-EasyMock.expectLastCall().once();
-ServletActionContext.setRequest(mockedRequest);
-
-EasyMock.replay(mockedRequest);
-
-// Mock (ActionInvocation)
-ActionInvocation mockActionInvocation = 
EasyMock.createControl().createMock(ActionInvocation.class);
-mockActionInvocation.getInvocationContext();
-EasyMock.expectLastCall().andReturn(actionContext);
-EasyMock.expectLastCall().anyTimes();
-
-mockActionInvocation.invoke();
-EasyMock.expectLastCall().andReturn(Action.SUCCESS);
-
-mockActionInvocation.getAction();
-EasyMock.expectLastCall().andReturn(action);
-
-mockActionInvocation.getResult();
-EasyMock.expectLastCall().andReturn(new ServletActionRedirectResult());
-
-EasyMock.replay(mockActionInvocation);
-
-interceptor.init();
-interceptor.intercept(mockActionInvocation);
-interceptor.destroy();
-
-assertEquals(sessionMap.size(), 3);
-
assertTrue(sessionMap.containsKey(MessageStoreInterceptor.actionErrorsSessionKey));
-
assertTrue(sessionMap.containsKey(MessageStoreInterceptor.actionMessagesSessionKey));
-
assertTrue(sessionMap.containsKey(MessageStoreInterceptor.fieldErrorsSessionKey));
-
-List actionErrors = (List) 
sessionMap.get(MessageStoreInterceptor.actionErrorsSessionKey);
-List actionMessages = (List) 
sessionMap.get(MessageStoreInterceptor.actionMessagesSessionKey);
-Map fieldErrors = (Map) 
sessionMap.get(MessageStoreInterceptor.fieldErrorsSessionKey);
-
-assertEquals(actionErrors.size(), 2);
-assertEquals(actionMessages.size(), 2);
-assertEquals(fieldErrors.size(), 2);
-
-

[4/7] struts git commit: Uses the new listener

2016-02-03 Thread lukaszlenart
Uses the new listener


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/8071052f
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/8071052f
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/8071052f

Branch: refs/heads/master
Commit: 8071052f86c5196bf771eb6ede442b9823753703
Parents: 0754027
Author: Lukasz Lenart 
Authored: Thu Feb 4 08:05:21 2016 +0100
Committer: Lukasz Lenart 
Committed: Thu Feb 4 08:05:21 2016 +0100

--
 .../interceptor/MessageStoreInterceptor.java| 61 +++-
 1 file changed, 8 insertions(+), 53 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/struts/blob/8071052f/core/src/main/java/org/apache/struts2/interceptor/MessageStoreInterceptor.java
--
diff --git 
a/core/src/main/java/org/apache/struts2/interceptor/MessageStoreInterceptor.java
 
b/core/src/main/java/org/apache/struts2/interceptor/MessageStoreInterceptor.java
index 848c5bf..4b7220e 100644
--- 
a/core/src/main/java/org/apache/struts2/interceptor/MessageStoreInterceptor.java
+++ 
b/core/src/main/java/org/apache/struts2/interceptor/MessageStoreInterceptor.java
@@ -28,7 +28,6 @@ import 
com.opensymphony.xwork2.interceptor.AbstractInterceptor;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 
-import org.apache.struts2.ServletActionContext;
 import org.apache.struts2.result.ServletRedirectResult;
 
 import java.util.ArrayList;
@@ -176,6 +175,7 @@ public class MessageStoreInterceptor extends 
AbstractInterceptor {
 public void setAllowRequestParameterSwitch(boolean 
allowRequestParameterSwitch) {
 this.allowRequestParameterSwitch = allowRequestParameterSwitch;
 }
+
 public boolean getAllowRequestParameterSwitch() {
 return this.allowRequestParameterSwitch;
 }
@@ -183,6 +183,7 @@ public class MessageStoreInterceptor extends 
AbstractInterceptor {
 public void setRequestParameterSwitch(String requestParameterSwitch) {
 this.requestParameterSwitch = requestParameterSwitch;
 }
+
 public String getRequestParameterSwitch() {
 return this.requestParameterSwitch;
 }
@@ -190,16 +191,20 @@ public class MessageStoreInterceptor extends 
AbstractInterceptor {
 public void setOperationMode(String operationMode) {
 this.operationMode = operationMode;
 }
+
 public String getOperationModel() {
 return this.operationMode;
 }
 
 public String intercept(ActionInvocation invocation) throws Exception {
-LOG.debug("entering MessageStoreInterceptor ...");
+LOG.trace("entering MessageStoreInterceptor ...");
 
 before(invocation);
+
+LOG.trace("Registering listener to store messages before result will 
be executed");
+invocation.addPreResultListener(new 
MessageStorePreResultListener(this));
+
 String result = invocation.invoke();
-after(invocation, result);
 
 LOG.debug("exit executing MessageStoreInterceptor");
 
@@ -260,56 +265,6 @@ public class MessageStoreInterceptor extends 
AbstractInterceptor {
 }
 
 /**
- * Handle the storing of field errors / action messages / field errors, 
which is
- * done after action invocation, and the operationMode is in 
'STORE'.
- *
- * @param invocation the action invocation
- * @param result the result
- * @throws Exception in case of any error
- */
-protected void after(ActionInvocation invocation, String result) throws 
Exception {
-
-boolean isCommitted = ServletActionContext.getResponse().isCommitted();
-if (isCommitted) {
-LOG.trace("Response was already committed, cannot store 
messages!");
-return;
-}
-
-boolean isInvalidated = 
ServletActionContext.getRequest().getSession(false) == null;
-if (isInvalidated) {
-LOG.trace("Session was invalidated or never created, cannot store 
messages!");
-return;
-}
-
-Map session = 
invocation.getInvocationContext().getSession();
-if (session == null) {
-LOG.trace("Could not store action [{}] error/messages into 
session, because session hasn't been opened yet.", invocation.getAction());
-return;
-}
-
-String reqOperationMode = getRequestOperationMode(invocation);
-boolean isRedirect = invocation.getResult() instanceof 
ServletRedirectResult;
-
-if (STORE_MODE.equalsIgnoreCase(reqOperationMode) ||
-STORE_MODE.equalsIgnoreCase(operationMode) ||
-(AUTOMATIC_MODE.equalsIgnoreCase(operationMode) && 
isRedirect)) {
-
-Object action = invocation.getAction();
-  

[1/7] struts git commit: Creates result before executing it to allow listeners to operate on it

2016-02-03 Thread lukaszlenart
Repository: struts
Updated Branches:
  refs/heads/master 6d2a57355 -> 857195c1b


Creates result before executing it to allow listeners to operate on it


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/6bb526d8
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/6bb526d8
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/6bb526d8

Branch: refs/heads/master
Commit: 6bb526d8ecae0156b9c19bbf86a151501b642f09
Parents: 954a29e
Author: Lukasz Lenart 
Authored: Wed Feb 3 21:01:48 2016 +0100
Committer: Lukasz Lenart 
Committed: Wed Feb 3 21:01:48 2016 +0100

--
 .../java/com/opensymphony/xwork2/DefaultActionInvocation.java | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/struts/blob/6bb526d8/core/src/main/java/com/opensymphony/xwork2/DefaultActionInvocation.java
--
diff --git 
a/core/src/main/java/com/opensymphony/xwork2/DefaultActionInvocation.java 
b/core/src/main/java/com/opensymphony/xwork2/DefaultActionInvocation.java
index d6385c6..a8dcf56 100644
--- a/core/src/main/java/com/opensymphony/xwork2/DefaultActionInvocation.java
+++ b/core/src/main/java/com/opensymphony/xwork2/DefaultActionInvocation.java
@@ -183,6 +183,7 @@ public class DefaultActionInvocation implements 
ActionInvocation {
 }
 
 public Result createResult() throws Exception {
+LOG.trace("Creating result related to resultCode [{}]", resultCode);
 
 if (explicitResult != null) {
 Result ret = explicitResult;
@@ -247,7 +248,11 @@ public class DefaultActionInvocation implements 
ActionInvocation {
 // this is needed because the result will be executed, then 
control will return to the Interceptor, which will
 // return above and flow through again
 if (!executed) {
+result = createResult();
+
 if (preResultListeners != null) {
+LOG.trace("Executing PreResultListeners for result [{}]", 
result);
+
 for (Object preResultListener : preResultListeners) {
 PreResultListener listener = (PreResultListener) 
preResultListener;
 
@@ -354,8 +359,6 @@ public class DefaultActionInvocation implements 
ActionInvocation {
  * @throws ConfigurationException If not result can be found with the 
returned code
  */
 private void executeResult() throws Exception {
-result = createResult();
-
 String timerKey = "executeResult: " + getResultCode();
 try {
 UtilTimerStack.push(timerKey);



[7/7] struts git commit: WW-4605 Refactors MessageStoreInterceptor to use listener

2016-02-03 Thread lukaszlenart
WW-4605 Refactors MessageStoreInterceptor to use listener


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/857195c1
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/857195c1
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/857195c1

Branch: refs/heads/master
Commit: 857195c1b1fef638bcdb7fbb8f212a7b384ecbaf
Parents: 6d2a573 41cf08c
Author: Lukasz Lenart 
Authored: Thu Feb 4 08:20:02 2016 +0100
Committer: Lukasz Lenart 
Committed: Thu Feb 4 08:20:02 2016 +0100

--
 .../xwork2/DefaultActionInvocation.java |   7 +-
 .../interceptor/MessageStoreInterceptor.java|  61 +
 .../MessageStorePreResultListener.java  |  95 +++
 .../xwork2/DefaultActionInvocationTest.java |   3 +
 .../MessageStoreInterceptorTest.java| 234 +
 .../MessageStorePreResultListenerTest.java  | 252 +++
 .../apache/struts2/views/jsp/ActionTagTest.java |   3 +-
 7 files changed, 372 insertions(+), 283 deletions(-)
--




[3/7] struts git commit: Adds test based on MessageStoreInterceptor

2016-02-03 Thread lukaszlenart
Adds test based on MessageStoreInterceptor


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/0754027a
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/0754027a
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/0754027a

Branch: refs/heads/master
Commit: 0754027a5a72357ac6ee2ef829c4d8080ad8dad4
Parents: a9b2c3c
Author: Lukasz Lenart 
Authored: Thu Feb 4 08:05:00 2016 +0100
Committer: Lukasz Lenart 
Committed: Thu Feb 4 08:05:00 2016 +0100

--
 .../MessageStorePreResultListenerTest.java  | 252 +++
 1 file changed, 252 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/struts/blob/0754027a/core/src/test/java/org/apache/struts2/interceptor/MessageStorePreResultListenerTest.java
--
diff --git 
a/core/src/test/java/org/apache/struts2/interceptor/MessageStorePreResultListenerTest.java
 
b/core/src/test/java/org/apache/struts2/interceptor/MessageStorePreResultListenerTest.java
new file mode 100644
index 000..4e46b3a
--- /dev/null
+++ 
b/core/src/test/java/org/apache/struts2/interceptor/MessageStorePreResultListenerTest.java
@@ -0,0 +1,252 @@
+package org.apache.struts2.interceptor;
+
+import com.opensymphony.xwork2.Action;
+import com.opensymphony.xwork2.ActionContext;
+import com.opensymphony.xwork2.ActionInvocation;
+import com.opensymphony.xwork2.ActionSupport;
+import org.apache.struts2.ServletActionContext;
+import org.apache.struts2.StrutsInternalTestCase;
+import org.apache.struts2.result.ServletActionRedirectResult;
+import org.easymock.EasyMock;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+public class MessageStorePreResultListenerTest extends StrutsInternalTestCase {
+
+public void testSessionWasInvalidated() throws Exception {
+// given
+ActionContext actionContext = new ActionContext(new HashMap());
+actionContext.put(ActionContext.PARAMETERS, new LinkedHashMap());
+
+ActionInvocation mockActionInvocation = 
EasyMock.createControl().createMock(ActionInvocation.class);
+
+mockActionInvocation.getInvocationContext();
+EasyMock.expectLastCall().andReturn(actionContext);
+EasyMock.expectLastCall().anyTimes();
+
+EasyMock.replay(mockActionInvocation);
+
+HttpServletRequest mockedRequest = 
EasyMock.createControl().createMock(HttpServletRequest.class);
+mockedRequest.getSession(false);
+EasyMock.expectLastCall().andReturn(null);
+EasyMock.expectLastCall().once();
+ServletActionContext.setRequest(mockedRequest);
+
+EasyMock.replay(mockedRequest);
+
+HttpServletResponse mockedResponse = 
EasyMock.createControl().createMock(HttpServletResponse.class);
+mockedResponse.isCommitted();
+EasyMock.expectLastCall().andReturn(false);
+EasyMock.expectLastCall().once();
+ServletActionContext.setResponse(mockedResponse);
+
+EasyMock.replay(mockedResponse);
+
+// when
+MessageStoreInterceptor msi = new MessageStoreInterceptor();
+MessageStorePreResultListener listener = new 
MessageStorePreResultListener(msi);
+listener.beforeResult(mockActionInvocation, Action.SUCCESS);
+
+// then
+EasyMock.verify(mockActionInvocation);
+EasyMock.verify(mockedRequest);
+EasyMock.verify(mockedResponse);
+}
+
+public void testResponseWasComitted() throws Exception {
+// given
+ActionContext actionContext = new ActionContext(new HashMap());
+actionContext.put(ActionContext.PARAMETERS, new LinkedHashMap());
+
+ActionInvocation mockActionInvocation = 
EasyMock.createControl().createMock(ActionInvocation.class);
+
+mockActionInvocation.getInvocationContext();
+EasyMock.expectLastCall().andReturn(actionContext);
+EasyMock.expectLastCall().anyTimes();
+
+EasyMock.replay(mockActionInvocation);
+
+HttpServletResponse mockedResponse = 
EasyMock.createControl().createMock(HttpServletResponse.class);
+mockedResponse.isCommitted();
+EasyMock.expectLastCall().andReturn(true);
+EasyMock.expectLastCall().once();
+ServletActionContext.setResponse(mockedResponse);
+
+EasyMock.replay(mockedResponse);
+
+// when
+MessageStoreInterceptor msi = new MessageStoreInterceptor();
+MessageStorePreResultListener listener = new 
MessageStorePreResultListener(msi);
+listener.beforeResult(mockActionInvocation, Action.SUCCESS);
+
+

[10/10] struts git commit: WW-4606 made @TilesDefinition work with tiles 2

2016-02-03 Thread cnenning
WW-4606 made @TilesDefinition work with tiles 2


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/87979d28
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/87979d28
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/87979d28

Branch: refs/heads/support-2-3
Commit: 87979d282126bfe37ba6993b538310e1ae124e1c
Parents: 8a9e017
Author: cnenning 
Authored: Wed Feb 3 14:18:54 2016 +0100
Committer: cnenning 
Committed: Wed Feb 3 14:18:54 2016 +0100

--
 apps/showcase/src/main/resources/struts-tiles.xml   | 5 +
 .../main/java/org/apache/struts2/views/tiles/TilesResult.java   | 4 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/struts/blob/87979d28/apps/showcase/src/main/resources/struts-tiles.xml
--
diff --git a/apps/showcase/src/main/resources/struts-tiles.xml 
b/apps/showcase/src/main/resources/struts-tiles.xml
index 9fbe025..3d30911 100644
--- a/apps/showcase/src/main/resources/struts-tiles.xml
+++ b/apps/showcase/src/main/resources/struts-tiles.xml
@@ -20,6 +20,11 @@
 showcase.freemarkerLayout
 
 
+
+
+
+
+
 
 /WEB-INF/tiles/layout.jsp
 /tiles/layout.jsp

http://git-wip-us.apache.org/repos/asf/struts/blob/87979d28/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java
--
diff --git 
a/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java 
b/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java
index c1dbfb9..e2a7dc7 100644
--- 
a/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java
+++ 
b/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java
@@ -130,7 +130,7 @@ public class TilesResult extends ServletDispatcherResult {
 boolean definitionValid = false;
 try {
 LOG.debug("checking if tiles definition exists '{}'", location);
-definitionValid = container.isValidDefinition(location, request);
+definitionValid = container.isValidDefinition(location, request, 
response);
 } catch (TilesException e) {
 LOG.warn("got TilesException while checking if definiton exists, 
ignoring it", e);
 }
@@ -143,7 +143,7 @@ public class TilesResult extends ServletDispatcherResult {
 Definition definition = 
annotationProcessor.buildTilesDefinition(location, tilesDefinition);
 if (container instanceof MutableTilesContainer) {
 LOG.debug("registering tiles definition with name '{}'", 
definition.getName());
-((MutableTilesContainer)container).register(definition, 
request);
+((MutableTilesContainer)container).register(definition, 
request, response);
 } else {
 LOG.error("cannot register tiles definition as tiles 
container is not mutable!");
 }



[01/10] struts git commit: WW-4606 cherry-picked @TilesDefinition and related classes

2016-02-03 Thread cnenning
Repository: struts
Updated Branches:
  refs/heads/support-2-3 85373951b -> 87979d282


WW-4606 cherry-picked @TilesDefinition and related classes


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/a6345e79
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/a6345e79
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/a6345e79

Branch: refs/heads/support-2-3
Commit: a6345e79c9d0ea0d5137a890af2df1f44e647908
Parents: 8537395
Author: cnenning 
Authored: Fri Jan 22 15:27:09 2016 +0100
Committer: cnenning 
Committed: Wed Feb 3 13:15:44 2016 +0100

--
 .../tiles/StrutsTilesAnnotationProcessor.java   | 176 +++
 .../tiles/annotation/TilesAddAttribute.java |  30 
 .../tiles/annotation/TilesAddListAttribute.java |  28 +++
 .../tiles/annotation/TilesDefinition.java   |  45 +
 .../tiles/annotation/TilesDefinitions.java  |  36 
 .../tiles/annotation/TilesPutAttribute.java |  32 
 .../tiles/annotation/TilesPutListAttribute.java |  32 
 .../apache/struts2/views/tiles/TilesResult.java |  72 ++--
 8 files changed, 438 insertions(+), 13 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/struts/blob/a6345e79/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessor.java
--
diff --git 
a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessor.java
 
b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessor.java
new file mode 100644
index 000..2ae3ba4
--- /dev/null
+++ 
b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessor.java
@@ -0,0 +1,176 @@
+/*
+ * 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.struts2.tiles;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.struts2.tiles.annotation.TilesAddAttribute;
+import org.apache.struts2.tiles.annotation.TilesAddListAttribute;
+import org.apache.struts2.tiles.annotation.TilesDefinition;
+import org.apache.struts2.tiles.annotation.TilesDefinitions;
+import org.apache.struts2.tiles.annotation.TilesPutAttribute;
+import org.apache.struts2.tiles.annotation.TilesPutListAttribute;
+import org.apache.tiles.Attribute;
+import org.apache.tiles.Definition;
+import org.apache.tiles.Expression;
+import org.apache.tiles.ListAttribute;
+
+/**
+ * Processes tiles annotations to create {@link Definition}s and
+ * {@link Attribute}s in a way as close to tiles.xml as possible.
+ *
+ */
+public class StrutsTilesAnnotationProcessor {
+
+/**
+ * Search strategy is as follows:
+ * 
+ *   Check if action has Annotation {@link TilesDefinition}
+ *   If not, check if action has Annotation {@link 
TilesDefinitions}
+ *   If given tileName is not null and present in {@link 
TilesDefinitions}, return it
+ *   Return first element of {@link TilesDefinitions}
+ *   Return null
+ * 
+ *
+ * @param action
+ *Annotated action.
+ * @param tileName
+ *Tilename to search for. May be null in some circumstances.
+ * @return {@link TilesDefinition}
+ */
+public TilesDefinition findAnnotation(Object action, String tileName) {
+Class clazz = action.getClass();
+TilesDefinition tilesDefinition = 
clazz.getAnnotation(TilesDefinition.class);
+TilesDefinitions tilesDefinitions = 
clazz.getAnnotation(TilesDefinitions.class);
+
+if (tilesDefinition == null && tilesDefinitions != null) {
+if (!StringUtils.isEmpty(tileName)) {
+for (TilesDefinition i : tilesDefinitions.value()) {
+if (i.name() != null && i.name().equals(tileName)) {
+tilesDefinition = i;
+break;
+}
+}
+}
+if (tilesDefinitions.value().length > 0) {
+tilesDefinition = 

[05/10] struts git commit: WW-4606 fixed javadoc

2016-02-03 Thread cnenning
WW-4606 fixed javadoc


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/469b25f8
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/469b25f8
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/469b25f8

Branch: refs/heads/support-2-3
Commit: 469b25f8e10c2b275e1c158e2ee97d753f324ecc
Parents: 2726068
Author: cnenning 
Authored: Mon Jan 25 13:50:45 2016 +0100
Committer: cnenning 
Committed: Wed Feb 3 13:33:22 2016 +0100

--
 .../main/java/org/apache/struts2/views/tiles/TilesResult.java  | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/struts/blob/469b25f8/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java
--
diff --git 
a/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java 
b/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java
index 1cea77b..c1dbfb9 100644
--- 
a/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java
+++ 
b/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java
@@ -40,6 +40,7 @@ import com.opensymphony.xwork2.ActionInvocation;
 import com.opensymphony.xwork2.util.logging.Logger;
 import com.opensymphony.xwork2.util.logging.LoggerFactory;
 
+
 /**
  * 
  * Renders a view using struts-tiles.
@@ -50,7 +51,8 @@ import com.opensymphony.xwork2.util.logging.LoggerFactory;
  *
  * listener
  *  
listener-classorg.apache.struts2.tiles.StrutsTilesListener/listener-class
- * /listener * 
+ * /listener
+ * 
  *
  * 
  * In struts.xml, use type="tiles" on your result.
@@ -72,13 +74,13 @@ import com.opensymphony.xwork2.util.logging.LoggerFactory;
  * /result-types
  * 
  *
+ *
  * 
  * You have to configure tiles itself. Therefore you can add 
tiles.xml either 
  * to resources or WEB-INF. You may also use annotations like {@link 
TilesDefinition}.
  *
  * 
  *
- *
  */
 public class TilesResult extends ServletDispatcherResult {
 



[06/10] struts git commit: renamed test class to stick to naming convention

2016-02-03 Thread cnenning
renamed test class to stick to naming convention

Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/1bbcd4bf
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/1bbcd4bf
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/1bbcd4bf

Branch: refs/heads/support-2-3
Commit: 1bbcd4bf70077384ee80d9fe39331def4fa40f82
Parents: 469b25f
Author: cnenning 
Authored: Mon Jan 25 14:36:07 2016 +0100
Committer: cnenning 
Committed: Wed Feb 3 13:33:48 2016 +0100

--
 .../StrutsTilesAnnotationProcessorTest.java | 148 +++
 .../TestStrutsTilesAnnotationProcessor.java | 148 ---
 2 files changed, 148 insertions(+), 148 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/struts/blob/1bbcd4bf/plugins/tiles/src/test/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessorTest.java
--
diff --git 
a/plugins/tiles/src/test/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessorTest.java
 
b/plugins/tiles/src/test/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessorTest.java
new file mode 100644
index 000..acaacce
--- /dev/null
+++ 
b/plugins/tiles/src/test/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessorTest.java
@@ -0,0 +1,148 @@
+package org.apache.struts2.tiles;
+
+import java.util.List;
+import java.util.Set;
+
+import org.apache.struts2.tiles.annotation.TilesDefinition;
+import org.apache.tiles.Attribute;
+import org.apache.tiles.Definition;
+import org.apache.tiles.Expression;
+import org.junit.Test;
+
+import org.junit.Assert;
+
+public class StrutsTilesAnnotationProcessorTest {
+
+@Test
+public void findAnnotationSingleAction() {
+StrutsTilesAnnotationProcessor annotationProcessor = new 
StrutsTilesAnnotationProcessor();
+TilesDefinition tilesDefinition = 
annotationProcessor.findAnnotation(new TilesTestActionSingleAnnotation(), null);
+Assert.assertNotNull(tilesDefinition);
+Assert.assertEquals("definition-name", tilesDefinition.name());
+}
+
+@Test
+public void findAnnotationMultipleActionNameNull() {
+StrutsTilesAnnotationProcessor annotationProcessor = new 
StrutsTilesAnnotationProcessor();
+TilesDefinition tilesDefinition = 
annotationProcessor.findAnnotation(new TilesTestActionMultipleAnnotations(), 
null);
+Assert.assertNotNull(tilesDefinition);
+Assert.assertEquals("def1", tilesDefinition.name());
+}
+
+@Test
+public void findAnnotationMultipleActionNameGiven() {
+StrutsTilesAnnotationProcessor annotationProcessor = new 
StrutsTilesAnnotationProcessor();
+TilesDefinition tilesDefinition = 
annotationProcessor.findAnnotation(new TilesTestActionMultipleAnnotations(), 
"def2");
+Assert.assertNotNull(tilesDefinition);
+Assert.assertEquals("def2", tilesDefinition.name());
+}
+
+@Test
+public void findAnnotationMultipleActionNotFound() {
+StrutsTilesAnnotationProcessor annotationProcessor = new 
StrutsTilesAnnotationProcessor();
+TilesDefinition tilesDefinition = 
annotationProcessor.findAnnotation(new TilesTestActionMultipleAnnotations(), 
"def3");
+Assert.assertNull(tilesDefinition);
+}
+
+@Test
+public void buildDefiniton() {
+StrutsTilesAnnotationProcessor annotationProcessor = new 
StrutsTilesAnnotationProcessor();
+TilesDefinition tilesDefinition = 
annotationProcessor.findAnnotation(new TilesTestActionSingleAnnotation(), null);
+
+Definition definition = 
annotationProcessor.buildTilesDefinition("tileName", tilesDefinition);
+
+Assert.assertNotNull(definition);
+Assert.assertEquals("tileName", definition.getName());
+Assert.assertEquals("preparer", definition.getPreparer());
+Assert.assertEquals("base-definition", definition.getExtends());
+Attribute templateAttribute = definition.getTemplateAttribute();
+Assert.assertEquals("template", templateAttribute.getValue());
+Assert.assertEquals("type", templateAttribute.getRenderer());
+Assert.assertEquals("role", templateAttribute.getRole());
+Expression definitionExpressionObject = 
templateAttribute.getExpressionObject();
+Assert.assertEquals("templ*", 
definitionExpressionObject.getExpression());
+Assert.assertNull(definitionExpressionObject.getLanguage());
+
+Attribute putAttribute = definition.getAttribute("put-attr");
+Assert.assertNotNull(putAttribute);
+Assert.assertEquals("attr-val", putAttribute.getValue());
+Assert.assertEquals("attr-type", putAttribute.getRenderer());
+Assert.assertEquals("attr-role", putAttribute.getRole());
+

[07/10] struts git commit: formatted annotations more nicely

2016-02-03 Thread cnenning
formatted annotations more nicely


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/473403ca
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/473403ca
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/473403ca

Branch: refs/heads/support-2-3
Commit: 473403ca1702730efd62771b7341790cfb342910
Parents: 1bbcd4b
Author: cnenning 
Authored: Mon Feb 1 09:36:23 2016 +0100
Committer: cnenning 
Committed: Wed Feb 3 13:34:09 2016 +0100

--
 .../apache/struts2/showcase/tiles/TilesAnnotationsAction.java   | 5 +++--
 .../org/apache/struts2/tiles/annotation/TilesDefinition.java| 3 ++-
 2 files changed, 5 insertions(+), 3 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/struts/blob/473403ca/apps/showcase/src/main/java/org/apache/struts2/showcase/tiles/TilesAnnotationsAction.java
--
diff --git 
a/apps/showcase/src/main/java/org/apache/struts2/showcase/tiles/TilesAnnotationsAction.java
 
b/apps/showcase/src/main/java/org/apache/struts2/showcase/tiles/TilesAnnotationsAction.java
index 997db11..b5c62f0 100644
--- 
a/apps/showcase/src/main/java/org/apache/struts2/showcase/tiles/TilesAnnotationsAction.java
+++ 
b/apps/showcase/src/main/java/org/apache/struts2/showcase/tiles/TilesAnnotationsAction.java
@@ -12,8 +12,9 @@ import com.opensymphony.xwork2.ActionSupport;
 @ParentPackage("tiles")
 @Result(name = "success", type="tiles")
 @TilesDefinition(extend = "showcase.annotations", putAttributes = {
-@TilesPutAttribute(name = "header", value = 
"/WEB-INF/tiles/header.jsp"),
-@TilesPutAttribute(name = "body", value = "/WEB-INF/tiles/body.ftl"), 
})
+@TilesPutAttribute(name = "header", value = "/WEB-INF/tiles/header.jsp"),
+@TilesPutAttribute(name = "body", value = "/WEB-INF/tiles/body.ftl")
+})
 public class TilesAnnotationsAction extends ActionSupport {
 
 private static final long serialVersionUID = 2900509995064928866L;

http://git-wip-us.apache.org/repos/asf/struts/blob/473403ca/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesDefinition.java
--
diff --git 
a/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesDefinition.java
 
b/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesDefinition.java
index 1618b63..3aa144c 100644
--- 
a/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesDefinition.java
+++ 
b/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesDefinition.java
@@ -42,7 +42,8 @@ import java.lang.annotation.Target;
  *  @Result(name = "success", type="tiles")
  *  @TilesDefinition(extend = "layout", putAttributes = {
  *  @TilesPutAttribute(name = "header", value = 
"/WEB-INF/tiles/header.jsp"),
- *  @TilesPutAttribute(name = "body", value = 
"/WEB-INF/tiles/body.ftl"), })
+ *  @TilesPutAttribute(name = "body", value = 
"/WEB-INF/tiles/body.ftl")
+ *  })
  *  public class FooAction extends ActionSupport {
  *  
  * 



[04/10] struts git commit: updated javadoc

2016-02-03 Thread cnenning
updated javadoc

Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/27260685
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/27260685
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/27260685

Branch: refs/heads/support-2-3
Commit: 27260685e1c878787e24ae6ac6a9a5f28ba6f2a8
Parents: bd5e64e
Author: cnenning 
Authored: Mon Jan 25 13:39:47 2016 +0100
Committer: cnenning 
Committed: Wed Feb 3 13:23:01 2016 +0100

--
 .../tiles/annotation/TilesDefinition.java   | 20 
 1 file changed, 20 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/struts/blob/27260685/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesDefinition.java
--
diff --git 
a/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesDefinition.java
 
b/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesDefinition.java
index a71bbc3..1618b63 100644
--- 
a/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesDefinition.java
+++ 
b/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesDefinition.java
@@ -27,6 +27,26 @@ import java.lang.annotation.Target;
 /**
  * Represents a definition element in 
tiles.xml.
  *
+ * 
+ *  With a sample layout in tiles.xml like this:
+ *  
+ *  definition name="layout" template="/WEB-INF/tiles/layout.jsp"
+ *  put-attribute name="header" value=".header"/
+ *  put-attribute name="body" value=".body"/
+ *  /definition
+ *  
+ * 
+ * 
+ *  You can annotate an action like that:
+ *  
+ *  @Result(name = "success", type="tiles")
+ *  @TilesDefinition(extend = "layout", putAttributes = {
+ *  @TilesPutAttribute(name = "header", value = 
"/WEB-INF/tiles/header.jsp"),
+ *  @TilesPutAttribute(name = "body", value = 
"/WEB-INF/tiles/body.ftl"), })
+ *  public class FooAction extends ActionSupport {
+ *  
+ * 
+ *
  */
 @Retention(value = RetentionPolicy.RUNTIME)
 @Target(value = { ElementType.TYPE })



[02/10] struts git commit: WW-4606 added @TilesDefinition sample to showcase app

2016-02-03 Thread cnenning
WW-4606 added @TilesDefinition sample to showcase app


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/9a8f36de
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/9a8f36de
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/9a8f36de

Branch: refs/heads/support-2-3
Commit: 9a8f36dee2e28d95a08864dd69727d093b12ced3
Parents: a6345e7
Author: cnenning 
Authored: Fri Jan 22 15:27:50 2016 +0100
Committer: cnenning 
Committed: Wed Feb 3 13:21:59 2016 +0100

--
 .../showcase/tiles/TilesAnnotationsAction.java  | 21 
 apps/showcase/src/main/webapp/WEB-INF/tiles.xml |  6 ++
 .../src/main/webapp/WEB-INF/tiles/body.jsp  |  3 +++
 .../webapp/WEB-INF/tiles/layout-annotations.jsp | 14 +
 4 files changed, 44 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/struts/blob/9a8f36de/apps/showcase/src/main/java/org/apache/struts2/showcase/tiles/TilesAnnotationsAction.java
--
diff --git 
a/apps/showcase/src/main/java/org/apache/struts2/showcase/tiles/TilesAnnotationsAction.java
 
b/apps/showcase/src/main/java/org/apache/struts2/showcase/tiles/TilesAnnotationsAction.java
new file mode 100644
index 000..997db11
--- /dev/null
+++ 
b/apps/showcase/src/main/java/org/apache/struts2/showcase/tiles/TilesAnnotationsAction.java
@@ -0,0 +1,21 @@
+package org.apache.struts2.showcase.tiles;
+
+import org.apache.struts2.convention.annotation.Namespace;
+import org.apache.struts2.convention.annotation.ParentPackage;
+import org.apache.struts2.convention.annotation.Result;
+import org.apache.struts2.tiles.annotation.TilesDefinition;
+import org.apache.struts2.tiles.annotation.TilesPutAttribute;
+
+import com.opensymphony.xwork2.ActionSupport;
+
+@Namespace("/tiles")
+@ParentPackage("tiles")
+@Result(name = "success", type="tiles")
+@TilesDefinition(extend = "showcase.annotations", putAttributes = {
+@TilesPutAttribute(name = "header", value = 
"/WEB-INF/tiles/header.jsp"),
+@TilesPutAttribute(name = "body", value = "/WEB-INF/tiles/body.ftl"), 
})
+public class TilesAnnotationsAction extends ActionSupport {
+
+private static final long serialVersionUID = 2900509995064928866L;
+
+}

http://git-wip-us.apache.org/repos/asf/struts/blob/9a8f36de/apps/showcase/src/main/webapp/WEB-INF/tiles.xml
--
diff --git a/apps/showcase/src/main/webapp/WEB-INF/tiles.xml 
b/apps/showcase/src/main/webapp/WEB-INF/tiles.xml
index 7c7057f..0a1b1be 100644
--- a/apps/showcase/src/main/webapp/WEB-INF/tiles.xml
+++ b/apps/showcase/src/main/webapp/WEB-INF/tiles.xml
@@ -45,4 +45,10 @@
 
 
 
+
+
+
+
+
+
 

http://git-wip-us.apache.org/repos/asf/struts/blob/9a8f36de/apps/showcase/src/main/webapp/WEB-INF/tiles/body.jsp
--
diff --git a/apps/showcase/src/main/webapp/WEB-INF/tiles/body.jsp 
b/apps/showcase/src/main/webapp/WEB-INF/tiles/body.jsp
index 095762f..0a5ffe8 100644
--- a/apps/showcase/src/main/webapp/WEB-INF/tiles/body.jsp
+++ b/apps/showcase/src/main/webapp/WEB-INF/tiles/body.jsp
@@ -16,6 +16,9 @@

View Example with a FreeMarker Layout

+   
+   View Example with tiles configuration by 
annotating action
+   

 


http://git-wip-us.apache.org/repos/asf/struts/blob/9a8f36de/apps/showcase/src/main/webapp/WEB-INF/tiles/layout-annotations.jsp
--
diff --git a/apps/showcase/src/main/webapp/WEB-INF/tiles/layout-annotations.jsp 
b/apps/showcase/src/main/webapp/WEB-INF/tiles/layout-annotations.jsp
new file mode 100644
index 000..5609cb1
--- /dev/null
+++ b/apps/showcase/src/main/webapp/WEB-INF/tiles/layout-annotations.jsp
@@ -0,0 +1,14 @@
+<%@ taglib uri="http://tiles.apache.org/tags-tiles; prefix="tiles" %>
+<%@ taglib prefix="s" uri="/struts-tags" %>
+
+<%-- Show usage; Used in Header --%>
+
+
+Struts2 Showcase - 
+
+
+
+Notice that this is a layout made in JSP
+It is configured with annotations!
+
+



[08/10] struts git commit: added missing license header

2016-02-03 Thread cnenning
added missing license header


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/5b2b244a
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/5b2b244a
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/5b2b244a

Branch: refs/heads/support-2-3
Commit: 5b2b244a662e8a4d51f364419c2c358ecc88ed6b
Parents: 473403c
Author: cnenning 
Authored: Mon Feb 1 09:37:25 2016 +0100
Committer: cnenning 
Committed: Wed Feb 3 13:34:32 2016 +0100

--
 .../showcase/tiles/TilesAnnotationsAction.java| 18 ++
 1 file changed, 18 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/struts/blob/5b2b244a/apps/showcase/src/main/java/org/apache/struts2/showcase/tiles/TilesAnnotationsAction.java
--
diff --git 
a/apps/showcase/src/main/java/org/apache/struts2/showcase/tiles/TilesAnnotationsAction.java
 
b/apps/showcase/src/main/java/org/apache/struts2/showcase/tiles/TilesAnnotationsAction.java
index b5c62f0..2b789c2 100644
--- 
a/apps/showcase/src/main/java/org/apache/struts2/showcase/tiles/TilesAnnotationsAction.java
+++ 
b/apps/showcase/src/main/java/org/apache/struts2/showcase/tiles/TilesAnnotationsAction.java
@@ -1,3 +1,21 @@
+/*
+ * 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.struts2.showcase.tiles;
 
 import org.apache.struts2.convention.annotation.Namespace;



[03/10] struts git commit: added tests for StrutsTilesAnnotationProcessor

2016-02-03 Thread cnenning
added tests for StrutsTilesAnnotationProcessor

Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/bd5e64e5
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/bd5e64e5
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/bd5e64e5

Branch: refs/heads/support-2-3
Commit: bd5e64e5980115a37dcdbed29ff6d15ddad06da7
Parents: 9a8f36d
Author: cnenning 
Authored: Mon Jan 25 11:23:10 2016 +0100
Committer: cnenning 
Committed: Wed Feb 3 13:22:35 2016 +0100

--
 .../tiles/StrutsTilesAnnotationProcessor.java   |   7 +-
 .../TestStrutsTilesAnnotationProcessor.java | 148 +++
 .../TilesTestActionMultipleAnnotations.java |  12 ++
 .../tiles/TilesTestActionSingleAnnotation.java  |  49 ++
 ...TilesTestActionSingleAnnotationAllEmpty.java |  28 
 5 files changed, 241 insertions(+), 3 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/struts/blob/bd5e64e5/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessor.java
--
diff --git 
a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessor.java
 
b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessor.java
index 2ae3ba4..fa5f735 100644
--- 
a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessor.java
+++ 
b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessor.java
@@ -66,9 +66,10 @@ public class StrutsTilesAnnotationProcessor {
 break;
 }
 }
-}
-if (tilesDefinitions.value().length > 0) {
-tilesDefinition = tilesDefinitions.value()[0];
+} else {
+if (tilesDefinitions.value().length > 0) {
+tilesDefinition = tilesDefinitions.value()[0];
+}
 }
 }
 

http://git-wip-us.apache.org/repos/asf/struts/blob/bd5e64e5/plugins/tiles/src/test/java/org/apache/struts2/tiles/TestStrutsTilesAnnotationProcessor.java
--
diff --git 
a/plugins/tiles/src/test/java/org/apache/struts2/tiles/TestStrutsTilesAnnotationProcessor.java
 
b/plugins/tiles/src/test/java/org/apache/struts2/tiles/TestStrutsTilesAnnotationProcessor.java
new file mode 100644
index 000..db808cd
--- /dev/null
+++ 
b/plugins/tiles/src/test/java/org/apache/struts2/tiles/TestStrutsTilesAnnotationProcessor.java
@@ -0,0 +1,148 @@
+package org.apache.struts2.tiles;
+
+import java.util.List;
+import java.util.Set;
+
+import org.apache.struts2.tiles.annotation.TilesDefinition;
+import org.apache.tiles.Attribute;
+import org.apache.tiles.Definition;
+import org.apache.tiles.Expression;
+import org.junit.Test;
+
+import org.junit.Assert;
+
+public class TestStrutsTilesAnnotationProcessor {
+
+@Test
+public void findAnnotationSingleAction() {
+StrutsTilesAnnotationProcessor annotationProcessor = new 
StrutsTilesAnnotationProcessor();
+TilesDefinition tilesDefinition = 
annotationProcessor.findAnnotation(new TilesTestActionSingleAnnotation(), null);
+Assert.assertNotNull(tilesDefinition);
+Assert.assertEquals("definition-name", tilesDefinition.name());
+}
+
+@Test
+public void findAnnotationMultipleActionNameNull() {
+StrutsTilesAnnotationProcessor annotationProcessor = new 
StrutsTilesAnnotationProcessor();
+TilesDefinition tilesDefinition = 
annotationProcessor.findAnnotation(new TilesTestActionMultipleAnnotations(), 
null);
+Assert.assertNotNull(tilesDefinition);
+Assert.assertEquals("def1", tilesDefinition.name());
+}
+
+@Test
+public void findAnnotationMultipleActionNameGiven() {
+StrutsTilesAnnotationProcessor annotationProcessor = new 
StrutsTilesAnnotationProcessor();
+TilesDefinition tilesDefinition = 
annotationProcessor.findAnnotation(new TilesTestActionMultipleAnnotations(), 
"def2");
+Assert.assertNotNull(tilesDefinition);
+Assert.assertEquals("def2", tilesDefinition.name());
+}
+
+@Test
+public void findAnnotationMultipleActionNotFound() {
+StrutsTilesAnnotationProcessor annotationProcessor = new 
StrutsTilesAnnotationProcessor();
+TilesDefinition tilesDefinition = 
annotationProcessor.findAnnotation(new TilesTestActionMultipleAnnotations(), 
"def3");
+Assert.assertNull(tilesDefinition);
+}
+
+@Test
+public void buildDefiniton() {
+StrutsTilesAnnotationProcessor annotationProcessor = new 
StrutsTilesAnnotationProcessor();
+TilesDefinition tilesDefinition = 
annotationProcessor.findAnnotation(new