svn commit: r1457392 - /struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsJUnit4TestCase.java
Author: grobmeier Date: Sun Mar 17 07:44:54 2013 New Revision: 1457392 URL: http://svn.apache.org/r1457392 Log: WW-4017: Support multiple Action executions and Session values Modified: struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsJUnit4TestCase.java Modified: struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsJUnit4TestCase.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsJUnit4TestCase.java?rev=1457392&r1=1457391&r2=1457392&view=diff == --- struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsJUnit4TestCase.java (original) +++ struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsJUnit4TestCase.java Sun Mar 17 07:44:54 2013 @@ -41,9 +41,11 @@ import org.springframework.mock.web.Mock import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; import java.io.UnsupportedEncodingException; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.Enumeration; import java.util.HashMap; import java.util.Map; import java.util.logging.*; @@ -199,6 +201,23 @@ public abstract class StrutsJUnit4TestCa pageContext = new MockPageContext(servletContext, request, response); } +public void finishExecution() { +HttpSession session = this.request.getSession(); +Enumeration attributeNames = session.getAttributeNames(); + +MockHttpServletRequest nextRequest = new MockHttpServletRequest(); + +while (attributeNames.hasMoreElements()) { +String key = (String) attributeNames.nextElement(); +Object attribute = session.getAttribute(key); +nextRequest.getSession().setAttribute(key, attribute); +} + +this.response = new MockHttpServletResponse(); +this.request = nextRequest; +this.pageContext = new MockPageContext(servletContext, request, response); +} + /** * Sets up the configuration settings, XWork configuration, and * message resources
svn commit: r1457393 - in /struts/struts2/trunk/plugins/junit/src/test: java/org/apache/struts2/session/ resources/
Author: grobmeier Date: Sun Mar 17 07:45:59 2013 New Revision: 1457393 URL: http://svn.apache.org/r1457393 Log: WW-4017: Support multiple Action executions and Session values Added: struts/struts2/trunk/plugins/junit/src/test/java/org/apache/struts2/session/ struts/struts2/trunk/plugins/junit/src/test/java/org/apache/struts2/session/SessionGetAction.java (with props) struts/struts2/trunk/plugins/junit/src/test/java/org/apache/struts2/session/SessionSetAction.java (with props) struts/struts2/trunk/plugins/junit/src/test/java/org/apache/struts2/session/StrutsJUnit4SessionTestCaseTest.java (with props) struts/struts2/trunk/plugins/junit/src/test/resources/struts-session-values-test.xml (with props) struts/struts2/trunk/plugins/junit/src/test/resources/template-session.ftl Added: struts/struts2/trunk/plugins/junit/src/test/java/org/apache/struts2/session/SessionGetAction.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/junit/src/test/java/org/apache/struts2/session/SessionGetAction.java?rev=1457393&view=auto == --- struts/struts2/trunk/plugins/junit/src/test/java/org/apache/struts2/session/SessionGetAction.java (added) +++ struts/struts2/trunk/plugins/junit/src/test/java/org/apache/struts2/session/SessionGetAction.java Sun Mar 17 07:45:59 2013 @@ -0,0 +1,35 @@ +/* + * $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.struts2.session; + +import com.opensymphony.xwork2.ActionSupport; + +/** + * An action which reads a value from the session. + * The value is previously set by SessionSetAction. + */ +public class SessionGetAction extends ActionSupport { +private static final long serialVersionUID = 8366502863472148631L; + +public String execute() { +return ActionSupport.SUCCESS; +} +} Propchange: struts/struts2/trunk/plugins/junit/src/test/java/org/apache/struts2/session/SessionGetAction.java -- svn:eol-style = native Added: struts/struts2/trunk/plugins/junit/src/test/java/org/apache/struts2/session/SessionSetAction.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/junit/src/test/java/org/apache/struts2/session/SessionSetAction.java?rev=1457393&view=auto == --- struts/struts2/trunk/plugins/junit/src/test/java/org/apache/struts2/session/SessionSetAction.java (added) +++ struts/struts2/trunk/plugins/junit/src/test/java/org/apache/struts2/session/SessionSetAction.java Sun Mar 17 07:45:59 2013 @@ -0,0 +1,39 @@ +/* + * $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.struts2.session; + +import com.opensymphony.xwork2.ActionContext; +import com.opensymphony.xwork2.ActionSupport; + +/** + * An action which sets a value into the session + */ +public class SessionSetAction extends ActionSupport { +private static final long serialVersionUID = -3097127804272607687L; + +public String SESSION_KEY = "sessionKey"; +public String SESSION_VALUE = "sessionValue"; + +public String execute() { +ActionContext.getContext().getSession().put(SESSION_KEY, SESSION_VALUE); +return ActionSupport.SUCCESS; +} +} Propchange: struts/struts2/trunk/plugins/junit/src/test/java/org/apache/struts2/ses
svn commit: r1457442 - in /struts/struts2/trunk/xwork-core/src: main/java/com/opensymphony/xwork2/validator/ main/java/com/opensymphony/xwork2/validator/annotations/ test/java/com/opensymphony/xwork2/
Author: lukaszlenart Date: Sun Mar 17 13:25:41 2013 New Revision: 1457442 URL: http://svn.apache.org/r1457442 Log: WW-4002 Improves CustomValidator annotation Added: struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/validator/MyValidator.java Modified: struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/AnnotationValidationConfigurationBuilder.java struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/annotations/CustomValidator.java struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/validator/AnnotationValidationAction.java struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/validator/AnnotationValidationConfigurationBuilderTest.java struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/validator/AnnotationValidationExpAction.java Modified: struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/AnnotationValidationConfigurationBuilder.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/AnnotationValidationConfigurationBuilder.java?rev=1457442&r1=1457441&r2=1457442&view=diff == --- struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/AnnotationValidationConfigurationBuilder.java (original) +++ struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/AnnotationValidationConfigurationBuilder.java Sun Mar 17 13:25:41 2013 @@ -423,6 +423,7 @@ public class AnnotationValidationConfigu .shortCircuit(v.shortCircuit()) .defaultMessage(v.message()) .messageKey(v.key()) +.messageParams(v.messageParams()) .build(); } Modified: struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/annotations/CustomValidator.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/annotations/CustomValidator.java?rev=1457442&r1=1457441&r2=1457442&view=diff == --- struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/annotations/CustomValidator.java (original) +++ struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/annotations/CustomValidator.java Sun Mar 17 13:25:41 2013 @@ -55,6 +55,12 @@ import java.lang.annotation.Target; * i18n key from language specific properties file. * * + * messageParams + * no + * + * Additional params to be used to customize message - will be evaluated against the Value Stack + * + * * fieldName * no * @@ -69,8 +75,8 @@ import java.lang.annotation.Target; * * type * yes - * ValidatorType.FIELD - * Enum value from ValidatorType. Either FIELD or SIMPLE can be used here. + * name of validator + * Simple string which identifies that validator among other * * * @@ -106,6 +112,11 @@ public @interface CustomValidator { String key() default ""; +/** + * Additional params to be used to customize message - will be evaluated against the Value Stack + */ +String[] messageParams() default {}; + public ValidationParameter[] parameters() default {}; boolean shortCircuit() default false; Modified: struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/validator/AnnotationValidationAction.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/validator/AnnotationValidationAction.java?rev=1457442&r1=1457441&r2=1457442&view=diff == --- struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/validator/AnnotationValidationAction.java (original) +++ struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/validator/AnnotationValidationAction.java Sun Mar 17 13:25:41 2013 @@ -3,7 +3,9 @@ package com.opensymphony.xwork2.validato import com.opensymphony.xwork2.ActionSupport; import com.opensymphony.xwork2.validator.annotations.ConditionalVisitorFieldValidator; import com.opensymphony.xwork2.validator.annotations.ConversionErrorFieldValidator; +import com.opensymphony.xwork2.validator.annotations.CustomValidator; import com.opensymphony.xwork2.validator.annotations.RegexFieldValidator; +import com.opensymphony.xwork2.validator.annotations.ValidationParameter; /** * Sets up all available validation annotations @@ -18,6 +20,12 @@ public class AnnotationValidationAction messageParams = {"one", "two", "three"}) @ConversionErrorFieldValidator(fieldName = "bar", key = "conversion.key", message = "Foo conversion error!", shortCircuit = true, repopulateField = true, messageParams
svn commit: r1457552 - in /struts/struts2/trunk/xwork-core/src: main/java/com/opensymphony/xwork2/validator/ main/java/com/opensymphony/xwork2/validator/annotations/ main/java/com/opensymphony/xwork2/
Author: lukaszlenart Date: Sun Mar 17 20:22:18 2013 New Revision: 1457552 URL: http://svn.apache.org/r1457552 Log: WW-4003 Improves DateRangeFieldValidator annotation to match DateRangeFieldValidator class Modified: struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/AnnotationValidationConfigurationBuilder.java struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/annotations/DateRangeFieldValidator.java struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/AbstractRangeValidator.java struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/validator/AnnotationValidationAction.java struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/validator/AnnotationValidationConfigurationBuilderTest.java struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/validator/AnnotationValidationExpAction.java Modified: struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/AnnotationValidationConfigurationBuilder.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/AnnotationValidationConfigurationBuilder.java?rev=1457552&r1=1457551&r2=1457552&view=diff == --- struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/AnnotationValidationConfigurationBuilder.java (original) +++ struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/AnnotationValidationConfigurationBuilder.java Sun Mar 17 20:22:18 2013 @@ -16,6 +16,7 @@ package com.opensymphony.xwork2.validator; import com.opensymphony.xwork2.validator.annotations.*; +import org.apache.commons.lang3.StringUtils; import java.lang.annotation.Annotation; import java.lang.reflect.Method; @@ -559,12 +560,16 @@ public class AnnotationValidationConfigu .build(); } -private Date parseDateString(String value) { +private Date parseDateString(String value, String format) { +SimpleDateFormat d0 = null; +if (StringUtils.isNotEmpty(format)) { +d0 = new SimpleDateFormat(format); +} SimpleDateFormat d1 = (SimpleDateFormat) DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.LONG, Locale.getDefault()); SimpleDateFormat d2 = (SimpleDateFormat)DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM, Locale.getDefault()); SimpleDateFormat d3 = (SimpleDateFormat)DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, Locale.getDefault()); -SimpleDateFormat[] dfs = {d1, d2, d3}; +SimpleDateFormat[] dfs = (d0 != null ? new SimpleDateFormat[]{d0, d1, d2, d3} : new SimpleDateFormat[]{d1, d2, d3}); for (SimpleDateFormat df : dfs) try { Date check = df.parse(value); @@ -574,7 +579,6 @@ public class AnnotationValidationConfigu } catch (ParseException ignore) { } return null; - } private ValidatorConfig processRequiredStringValidatorAnnotation(RequiredStringValidator v, String fieldName, String methodName) { @@ -767,12 +771,19 @@ public class AnnotationValidationConfigu params.put("fieldName", v.fieldName()); } if ( v.min() != null && v.min().length() > 0) { - final Date minDate = parseDateString(v.min()); - params.put("min", String.valueOf(minDate == null ? v.min() : minDate)); + final Date minDate = parseDateString(v.min(), v.dateFormat()); + params.put("min", minDate == null ? v.min() : minDate); } if ( v.max() != null && v.max().length() > 0) { - final Date maxDate = parseDateString(v.max()); - params.put("max", String.valueOf(maxDate == null ? v.max() : maxDate)); + final Date maxDate = parseDateString(v.max(), v.dateFormat()); + params.put("max", maxDate == null ? v.max() : maxDate); +} + +if (StringUtils.isNotEmpty(v.minExpression())) { +params.put("minExpression", v.minExpression()); +} +if (StringUtils.isNotEmpty(v.maxExpression())) { +params.put("maxExpression", v.maxExpression()); } validatorFactory.lookupRegisteredValidatorType(validatorType); @@ -782,6 +793,7 @@ public class AnnotationValidationConfigu .shortCircuit(v.shortCircuit()) .defaultMessage(v.message()) .messageKey(v.key()) +.messageParams(v.messageParams()) .build(); } Modified: struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/annotations/DateRangeFieldValidator.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/annotations
[CONF] Confluence Changes in the last 24 hours
This is a daily summary of all recent changes in Confluence. - Updated Spaces: - Apache Camel (https://cwiki.apache.org/confluence/display/CAMEL) Pages - Camel 2.11.0 Release edited by davsclaus (06:23 AM) https://cwiki.apache.org/confluence/display/CAMEL/Camel+2.11.0+Release Zip File DataFormat edited by njiang (03:26 AM) https://cwiki.apache.org/confluence/display/CAMEL/Zip+File+DataFormat Apache Cloudstack (https://cwiki.apache.org/confluence/display/CLOUDSTACK) Pages - EIP Enhancements edited by murali.reddy (11:16 PM) https://cwiki.apache.org/confluence/display/CLOUDSTACK/EIP+Enhancements Apache CloudStack Weekly News - 18 March 2013 edited by jzb (11:03 PM) https://cwiki.apache.org/confluence/display/CLOUDSTACK/Apache+CloudStack+Weekly+News+-+18+March+2013 Apache CloudStack Weekly News - 25 March 2012 created by jzb (09:58 PM) https://cwiki.apache.org/confluence/display/CLOUDSTACK/Apache+CloudStack+Weekly+News+-+25+March+2012 FS- Dedicate Public IP Addresses per tenant edited by likitha.she...@citrix.com (03:09 AM) https://cwiki.apache.org/confluence/display/CLOUDSTACK/FS-+Dedicate+Public+IP+Addresses+per+tenant Comments https://cwiki.apache.org/confluence/display/CLOUDSTACK/DevCloud (1) OFBiz Project Administration Workspace (https://cwiki.apache.org/confluence/display/OFBADMIN) Pages - Apache OFBiz PMC Members and Committers edited by jacques.le.roux (06:13 AM) https://cwiki.apache.org/confluence/display/OFBADMIN/Apache+OFBiz+PMC+Members+and+Committers OFBiz (Open For Business) Project Open Wiki (https://cwiki.apache.org/confluence/display/OFBIZ) Pages - Apache OFBiz Service Providers edited by jacques.le.roux (06:10 AM) https://cwiki.apache.org/confluence/display/OFBIZ/Apache+OFBiz+Service+Providers Apache OpenOffice Community (https://cwiki.apache.org/confluence/display/OOOUSERS) Pages - 2013 Apr edited by kschenk (03:37 PM) https://cwiki.apache.org/confluence/display/OOOUSERS/2013+Apr 02 - Design Proposal Samer Mansour 2013.03.03 edited by smansour (01:03 AM) https://cwiki.apache.org/confluence/display/OOOUSERS/02+-+Design+Proposal+Samer+Mansour+2013.03.03 Change your notification preferences: https://cwiki.apache.org/confluence/users/viewnotifications.action