You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by mu...@apache.org on 2009/03/29 00:19:19 UTC
svn commit: r759614 - in /struts/sandbox/trunk/struts2-oval-plugin: ./ src/
src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/
src/main/java/org/apache/struts2/
src/main/java/org/apache/struts2/interceptor/ src/main/java/org/apache/s...
Author: musachy
Date: Sat Mar 28 23:19:17 2009
New Revision: 759614
URL: http://svn.apache.org/viewvc?rev=759614&view=rev
Log:
Initial import of OVal plugin
Added:
struts/sandbox/trunk/struts2-oval-plugin/
struts/sandbox/trunk/struts2-oval-plugin/pom.xml (with props)
struts/sandbox/trunk/struts2-oval-plugin/src/
struts/sandbox/trunk/struts2-oval-plugin/src/main/
struts/sandbox/trunk/struts2-oval-plugin/src/main/java/
struts/sandbox/trunk/struts2-oval-plugin/src/main/java/org/
struts/sandbox/trunk/struts2-oval-plugin/src/main/java/org/apache/
struts/sandbox/trunk/struts2-oval-plugin/src/main/java/org/apache/struts2/
struts/sandbox/trunk/struts2-oval-plugin/src/main/java/org/apache/struts2/interceptor/
struts/sandbox/trunk/struts2-oval-plugin/src/main/java/org/apache/struts2/interceptor/OValValidationInterceptor.java (with props)
struts/sandbox/trunk/struts2-oval-plugin/src/main/java/org/apache/struts2/validation/
struts/sandbox/trunk/struts2-oval-plugin/src/main/java/org/apache/struts2/validation/Profiles.java (with props)
struts/sandbox/trunk/struts2-oval-plugin/src/main/resources/
struts/sandbox/trunk/struts2-oval-plugin/src/main/resources/LICENSE.txt (with props)
struts/sandbox/trunk/struts2-oval-plugin/src/main/resources/NOTICE.txt (with props)
struts/sandbox/trunk/struts2-oval-plugin/src/main/resources/struts-plugin.xml (with props)
struts/sandbox/trunk/struts2-oval-plugin/src/test/
struts/sandbox/trunk/struts2-oval-plugin/src/test/java/
struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/
struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/
struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/
struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/
struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/FieldsWithProfiles.java (with props)
struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/OValValidationInterceptorTest.java (with props)
struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/SimpleField.java (with props)
struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/SimpleFieldI18n.java (with props)
struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/SimpleFieldI18nDefaultKey.java (with props)
struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/SimpleFieldOGNLExpression.java (with props)
struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/SimpleMethod.java (with props)
struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/VoidResult.java (with props)
struts/sandbox/trunk/struts2-oval-plugin/src/test/resources/
struts/sandbox/trunk/struts2-oval-plugin/src/test/resources/org/
struts/sandbox/trunk/struts2-oval-plugin/src/test/resources/org/apache/
struts/sandbox/trunk/struts2-oval-plugin/src/test/resources/org/apache/struts2/
struts/sandbox/trunk/struts2-oval-plugin/src/test/resources/org/apache/struts2/interceptor/
struts/sandbox/trunk/struts2-oval-plugin/src/test/resources/org/apache/struts2/interceptor/SimpleFieldI18n.properties (with props)
struts/sandbox/trunk/struts2-oval-plugin/src/test/resources/oval-test.xml (with props)
Added: struts/sandbox/trunk/struts2-oval-plugin/pom.xml
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-oval-plugin/pom.xml?rev=759614&view=auto
==============================================================================
--- struts/sandbox/trunk/struts2-oval-plugin/pom.xml (added)
+++ struts/sandbox/trunk/struts2-oval-plugin/pom.xml Sat Mar 28 23:19:17 2009
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+/*
+ * $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.
+ */
+-->
+<project xmlns="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/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.struts</groupId>
+ <artifactId>struts2-plugins</artifactId>
+ <version>2.1.7-SNAPSHOT</version>
+ </parent>
+ <groupId>org.apache.struts2</groupId>
+ <artifactId>struts2-oval-plugin</artifactId>
+ <packaging>jar</packaging>
+ <version>1.0-SNAPSHOT</version>
+ <name>Struts 2 OVal Plugin</name>
+ <url>http://maven.apache.org</url>
+ <dependencies>
+ <!-- Core -->
+ <dependency>
+ <groupId>org.apache.struts</groupId>
+ <artifactId>struts2-core</artifactId>
+ <version>2.1.7-SNAPSHOT</version>
+ </dependency>
+
+ <!-- OVal -->
+ <dependency>
+ <groupId>net.sf.oval</groupId>
+ <artifactId>oval</artifactId>
+ <version>1.31</version>
+ </dependency>
+
+ <!-- Testing -->
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ <version>2.0</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
Propchange: struts/sandbox/trunk/struts2-oval-plugin/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/struts2-oval-plugin/pom.xml
------------------------------------------------------------------------------
svn:keywords = Id
Added: struts/sandbox/trunk/struts2-oval-plugin/src/main/java/org/apache/struts2/interceptor/OValValidationInterceptor.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-oval-plugin/src/main/java/org/apache/struts2/interceptor/OValValidationInterceptor.java?rev=759614&view=auto
==============================================================================
--- struts/sandbox/trunk/struts2-oval-plugin/src/main/java/org/apache/struts2/interceptor/OValValidationInterceptor.java (added)
+++ struts/sandbox/trunk/struts2-oval-plugin/src/main/java/org/apache/struts2/interceptor/OValValidationInterceptor.java Sat Mar 28 23:19:17 2009
@@ -0,0 +1,129 @@
+/*
+ * $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.interceptor;
+
+import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;
+import com.opensymphony.xwork2.ActionInvocation;
+import com.opensymphony.xwork2.ActionProxy;
+import com.opensymphony.xwork2.inject.Inject;
+import com.opensymphony.xwork2.validator.ValidatorContext;
+import com.opensymphony.xwork2.validator.DelegatingValidatorContext;
+import com.opensymphony.xwork2.util.logging.Logger;
+import com.opensymphony.xwork2.util.logging.LoggerFactory;
+import com.opensymphony.xwork2.util.ValueStack;
+import com.opensymphony.xwork2.util.reflection.ReflectionProvider;
+import net.sf.oval.Validator;
+import net.sf.oval.ConstraintViolation;
+import net.sf.oval.context.FieldContext;
+import net.sf.oval.context.OValContext;
+
+import java.util.List;
+import java.lang.reflect.Method;
+
+import org.apache.struts2.validation.Profiles;
+import org.apache.commons.lang.xwork.StringUtils;
+
+/*
+ This interceptor provides validation using the OVal validation framework
+ */
+public class OValValidationInterceptor extends MethodFilterInterceptor {
+ private static final Logger LOG = LoggerFactory.getLogger(OValValidationInterceptor.class);
+
+ private ReflectionProvider reflectionProvider;
+
+ @Inject
+ public void setReflectionProvider(ReflectionProvider reflectionProvider) {
+ this.reflectionProvider = reflectionProvider;
+ }
+
+ protected String doIntercept(ActionInvocation invocation) throws Exception {
+ Object action = invocation.getAction();
+ ActionProxy proxy = invocation.getProxy();
+ ValueStack valueStack = invocation.getStack();
+ String methodName = proxy.getMethod();
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Validating [#0/#1] with method [#2]", invocation.getProxy().getNamespace(), invocation.getProxy().getActionName(), methodName);
+ }
+
+ Validator validator = new Validator();
+ //if the method is annotated with a @Profiles annotation, use those profiles
+ Method method = action.getClass().getMethod(methodName, new Class[0]);
+ if (method != null) {
+ Profiles profiles = method.getAnnotation(Profiles.class);
+ if (profiles != null) {
+ String[] profileNames = profiles.value();
+ if (profileNames != null && profileNames.length > 0) {
+ validator.disableAllProfiles();
+ if (LOG.isDebugEnabled())
+ LOG.debug("Enabling profiles [#0]", StringUtils.join(profileNames, ","));
+ for (String profileName : profileNames)
+ validator.enableProfile(profileName);
+ }
+ }
+ }
+
+ //perform validation
+ List<ConstraintViolation> violations = validator.validate(action);
+ if (violations != null) {
+ ValidatorContext validatorContext = new DelegatingValidatorContext(action);
+ for (ConstraintViolation violation : violations) {
+ //translate message
+ String key = violation.getMessage();
+
+ //push the validator into the stack
+ valueStack.push(violation);
+ String message = key;
+ try {
+ message = validatorContext.getText(key);
+ } finally {
+ valueStack.pop();
+ }
+
+ if (isActionError(violation))
+ validatorContext.addActionError(message);
+ else
+ validatorContext.addFieldError(extractFieldName(violation), message);
+ }
+ }
+
+ return invocation.invoke();
+ }
+
+ /**
+ * Get field name, used to add the validation error to fieldErrors
+ */
+ protected String extractFieldName(ConstraintViolation violation) {
+ OValContext context = violation.getContext();
+ if (context instanceof FieldContext) {
+ return ((FieldContext) context).getField().getName();
+ }
+
+ return violation.getCheckName();
+ }
+
+ /**
+ * Decide if a violation should be added to the fieldErrors or actionErrors
+ */
+ protected boolean isActionError(ConstraintViolation violation) {
+ return false;
+ }
+}
Propchange: struts/sandbox/trunk/struts2-oval-plugin/src/main/java/org/apache/struts2/interceptor/OValValidationInterceptor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/struts2-oval-plugin/src/main/java/org/apache/struts2/interceptor/OValValidationInterceptor.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: struts/sandbox/trunk/struts2-oval-plugin/src/main/java/org/apache/struts2/validation/Profiles.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-oval-plugin/src/main/java/org/apache/struts2/validation/Profiles.java?rev=759614&view=auto
==============================================================================
--- struts/sandbox/trunk/struts2-oval-plugin/src/main/java/org/apache/struts2/validation/Profiles.java (added)
+++ struts/sandbox/trunk/struts2-oval-plugin/src/main/java/org/apache/struts2/validation/Profiles.java Sat Mar 28 23:19:17 2009
@@ -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.validation;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+/*
+ Defines a list of profiles to be activated by OVal when calling a method in an action
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+public @interface Profiles {
+ String[] value();
+}
Propchange: struts/sandbox/trunk/struts2-oval-plugin/src/main/java/org/apache/struts2/validation/Profiles.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/struts2-oval-plugin/src/main/java/org/apache/struts2/validation/Profiles.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: struts/sandbox/trunk/struts2-oval-plugin/src/main/resources/LICENSE.txt
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-oval-plugin/src/main/resources/LICENSE.txt?rev=759614&view=auto
==============================================================================
--- struts/sandbox/trunk/struts2-oval-plugin/src/main/resources/LICENSE.txt (added)
+++ struts/sandbox/trunk/struts2-oval-plugin/src/main/resources/LICENSE.txt Sat Mar 28 23:19:17 2009
@@ -0,0 +1,174 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
Propchange: struts/sandbox/trunk/struts2-oval-plugin/src/main/resources/LICENSE.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/struts2-oval-plugin/src/main/resources/LICENSE.txt
------------------------------------------------------------------------------
svn:keywords = Id
Added: struts/sandbox/trunk/struts2-oval-plugin/src/main/resources/NOTICE.txt
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-oval-plugin/src/main/resources/NOTICE.txt?rev=759614&view=auto
==============================================================================
--- struts/sandbox/trunk/struts2-oval-plugin/src/main/resources/NOTICE.txt (added)
+++ struts/sandbox/trunk/struts2-oval-plugin/src/main/resources/NOTICE.txt Sat Mar 28 23:19:17 2009
@@ -0,0 +1,5 @@
+Apache Struts
+Copyright 2000-2007 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
\ No newline at end of file
Propchange: struts/sandbox/trunk/struts2-oval-plugin/src/main/resources/NOTICE.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/struts2-oval-plugin/src/main/resources/NOTICE.txt
------------------------------------------------------------------------------
svn:keywords = Id
Added: struts/sandbox/trunk/struts2-oval-plugin/src/main/resources/struts-plugin.xml
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-oval-plugin/src/main/resources/struts-plugin.xml?rev=759614&view=auto
==============================================================================
--- struts/sandbox/trunk/struts2-oval-plugin/src/main/resources/struts-plugin.xml (added)
+++ struts/sandbox/trunk/struts2-oval-plugin/src/main/resources/struts-plugin.xml Sat Mar 28 23:19:17 2009
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+/*
+ * $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.
+ */
+-->
+<!DOCTYPE struts PUBLIC
+ "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
+ "http://struts.apache.org/dtds/struts-2.0.dtd">
+
+<struts>
+ <package name="oval-default" extends="struts-default">
+ <interceptors>
+ <interceptor name="ovalValidation" class="org.apache.struts2.interceptor.OValValidationInterceptor" />
+
+ <interceptor-stack name="ovalValidationStack">
+ <interceptor-ref name="exception"/>
+ <interceptor-ref name="alias"/>
+ <interceptor-ref name="servletConfig"/>
+ <interceptor-ref name="i18n"/>
+ <interceptor-ref name="prepare"/>
+ <interceptor-ref name="chain"/>
+ <interceptor-ref name="debugging"/>
+ <interceptor-ref name="profiling"/>
+ <interceptor-ref name="scopedModelDriven"/>
+ <interceptor-ref name="modelDriven"/>
+ <interceptor-ref name="fileUpload"/>
+ <interceptor-ref name="checkbox"/>
+ <interceptor-ref name="staticParams"/>
+ <interceptor-ref name="actionMappingParams"/>
+ <interceptor-ref name="params">
+ <param name="excludeParams">dojo\..*,^struts\..*</param>
+ </interceptor-ref>
+ <interceptor-ref name="conversionError"/>
+ <interceptor-ref name="ovalValidation">
+ <param name="excludeMethods">input,back,cancel,browse</param>
+ </interceptor-ref>
+ <interceptor-ref name="workflow">
+ <param name="excludeMethods">input,back,cancel,browse</param>
+ </interceptor-ref>
+ </interceptor-stack>
+ </interceptors>
+ </package>
+</struts>
Propchange: struts/sandbox/trunk/struts2-oval-plugin/src/main/resources/struts-plugin.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/struts2-oval-plugin/src/main/resources/struts-plugin.xml
------------------------------------------------------------------------------
svn:keywords = Id
Added: struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/FieldsWithProfiles.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/FieldsWithProfiles.java?rev=759614&view=auto
==============================================================================
--- struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/FieldsWithProfiles.java (added)
+++ struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/FieldsWithProfiles.java Sat Mar 28 23:19:17 2009
@@ -0,0 +1,70 @@
+/*
+ * $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.interceptor;
+
+import com.opensymphony.xwork2.ActionSupport;
+import net.sf.oval.constraint.NotNull;
+import org.apache.struts2.validation.Profiles;
+
+public class FieldsWithProfiles extends ActionSupport {
+ @NotNull(profiles = "1")
+ private String firstName;
+
+ @NotNull(profiles = "2")
+ private String middleName;
+
+ @NotNull(profiles = "3")
+ private String lastName;
+
+ @Profiles({"1", "3"})
+ public void run1() {
+
+ }
+
+ @Profiles({"2"})
+ public void run2() {
+
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ public String getMiddleName() {
+ return middleName;
+ }
+
+ public void setMiddleName(String middleName) {
+ this.middleName = middleName;
+ }
+}
Propchange: struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/FieldsWithProfiles.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/FieldsWithProfiles.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/OValValidationInterceptorTest.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/OValValidationInterceptorTest.java?rev=759614&view=auto
==============================================================================
--- struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/OValValidationInterceptorTest.java (added)
+++ struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/OValValidationInterceptorTest.java Sat Mar 28 23:19:17 2009
@@ -0,0 +1,152 @@
+/*
+ * $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.interceptor;
+
+import com.opensymphony.xwork2.ActionProxy;
+import com.opensymphony.xwork2.ValidationAware;
+import com.opensymphony.xwork2.XWorkTestCase;
+import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+public class OValValidationInterceptorTest extends XWorkTestCase {
+ public void testSimpleField() throws Exception {
+ ActionProxy baseActionProxy = actionProxyFactory.createActionProxy("oval", "simpleField", null, null);
+ baseActionProxy.execute();
+
+ Map<String, List<String>> fieldErrors = ((ValidationAware) baseActionProxy.getAction()).getFieldErrors();
+ assertNotNull(fieldErrors);
+ assertEquals(1, fieldErrors.size());
+ assertValue(fieldErrors, "name", Arrays.asList("org.apache.struts2.interceptor.SimpleField.name cannot be null"));
+ }
+
+ public void testSimpleFieldNegative() throws Exception {
+ ActionProxy baseActionProxy = actionProxyFactory.createActionProxy("oval", "simpleField", null, null);
+ SimpleField action = (SimpleField) baseActionProxy.getAction();
+ action.setName("123");
+ baseActionProxy.execute();
+
+ Map<String, List<String>> fieldErrors = action.getFieldErrors();
+
+ assertNotNull(fieldErrors);
+ assertEquals(0, fieldErrors.size());
+ }
+
+ public void testSimpleFieldMultipleValidators() throws Exception {
+ ActionProxy baseActionProxy = actionProxyFactory.createActionProxy("oval", "simpleField", null, null);
+ SimpleField action = (SimpleField) baseActionProxy.getAction();
+ action.setName("12345");
+ baseActionProxy.execute();
+
+ Map<String, List<String>> fieldErrors = action.getFieldErrors();
+ assertNotNull(fieldErrors);
+ assertEquals(1, fieldErrors.size());
+ assertNotNull(fieldErrors.get("firstName"));
+ }
+
+ public void testSimpleMethod() throws Exception {
+ ActionProxy baseActionProxy = actionProxyFactory.createActionProxy("oval", "simpleMethod", null, null);
+ SimpleMethod action = (SimpleMethod) baseActionProxy.getAction();
+ baseActionProxy.execute();
+
+ Map<String, List<String>> fieldErrors = action.getFieldErrors();
+ assertNotNull(fieldErrors);
+ assertEquals(1, fieldErrors.size());
+ assertNotNull(fieldErrors.get("firstName"));
+ }
+
+ public void testSimpleFieldOGNLExpression() throws Exception {
+ ActionProxy baseActionProxy = actionProxyFactory.createActionProxy("oval", "simpleFieldOGNL", null, null);
+ SimpleFieldOGNLExpression action = (SimpleFieldOGNLExpression) baseActionProxy.getAction();
+ baseActionProxy.execute();
+
+ Map<String, List<String>> fieldErrors = action.getFieldErrors();
+ assertNotNull(fieldErrors);
+ assertEquals(1, fieldErrors.size());
+ assertNotNull(fieldErrors.get("firstName"));
+ }
+
+ public void testFieldsWithMultipleProfiles() throws Exception {
+ ActionProxy baseActionProxy = actionProxyFactory.createActionProxy("oval", "fieldsWidthProfiles13", null, null);
+ FieldsWithProfiles action = (FieldsWithProfiles) baseActionProxy.getAction();
+ baseActionProxy.execute();
+
+ Map<String, List<String>> fieldErrors = action.getFieldErrors();
+ assertNotNull(fieldErrors);
+ assertEquals(2, fieldErrors.size());
+ assertNotNull(fieldErrors.get("firstName"));
+ assertNotNull(fieldErrors.get("lastName"));
+ }
+
+ public void testSimpleFieldOGNLExpressionNegative() throws Exception {
+ ActionProxy baseActionProxy = actionProxyFactory.createActionProxy("oval", "simpleFieldOGNL", null, null);
+ SimpleFieldOGNLExpression action = (SimpleFieldOGNLExpression) baseActionProxy.getAction();
+ action.setName("Meursault");
+ baseActionProxy.execute();
+
+ Map<String, List<String>> fieldErrors = action.getFieldErrors();
+ assertNotNull(fieldErrors);
+ assertEquals(0, fieldErrors.size());
+ }
+
+ public void testSimpleFieldI18n() throws Exception {
+ ActionProxy baseActionProxy = actionProxyFactory.createActionProxy("oval", "simpleFieldI18n", null, null);
+ SimpleFieldI18n action = (SimpleFieldI18n) baseActionProxy.getAction();
+ baseActionProxy.execute();
+
+ Map<String, List<String>> fieldErrors = action.getFieldErrors();
+
+ assertNotNull(fieldErrors);
+ assertEquals(1, fieldErrors.size());
+ assertValue(fieldErrors, "name", Arrays.asList("name cannot be null"));
+ }
+
+ public void testSimpleFieldI18nDefaultKey() throws Exception {
+ ActionProxy baseActionProxy = actionProxyFactory.createActionProxy("oval", "simpleFieldI18nDefaultKey", null, null);
+ SimpleFieldI18nDefaultKey action = (SimpleFieldI18nDefaultKey) baseActionProxy.getAction();
+ baseActionProxy.execute();
+
+ Map<String, List<String>> fieldErrors = action.getFieldErrors();
+
+ assertNotNull(fieldErrors);
+ assertEquals(1, fieldErrors.size());
+ assertValue(fieldErrors, "name", Arrays.asList("notnull.field"));
+ }
+
+ private void assertValue(Map<String, List<String>> map, String key, List<String> expectedValues) {
+ assertNotNull(map);
+ assertNotNull(key);
+ assertNotNull(expectedValues);
+
+ List<String> values = map.get(key);
+ assertNotNull(values);
+ assertEquals(expectedValues, values);
+ }
+
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ loadConfigurationProviders(new XmlConfigurationProvider("oval-test.xml"));
+ }
+}
Propchange: struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/OValValidationInterceptorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/OValValidationInterceptorTest.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/SimpleField.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/SimpleField.java?rev=759614&view=auto
==============================================================================
--- struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/SimpleField.java (added)
+++ struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/SimpleField.java Sat Mar 28 23:19:17 2009
@@ -0,0 +1,41 @@
+/*
+ * $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.interceptor;
+
+import net.sf.oval.constraint.Length;
+import net.sf.oval.constraint.NotEmpty;
+import net.sf.oval.constraint.NotNull;
+import com.opensymphony.xwork2.ActionSupport;
+
+public class SimpleField extends ActionSupport{
+ @NotNull()
+ @NotEmpty
+ @Length(max = 3)
+ private String name;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
Propchange: struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/SimpleField.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/SimpleField.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/SimpleFieldI18n.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/SimpleFieldI18n.java?rev=759614&view=auto
==============================================================================
--- struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/SimpleFieldI18n.java (added)
+++ struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/SimpleFieldI18n.java Sat Mar 28 23:19:17 2009
@@ -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.interceptor;
+
+import com.opensymphony.xwork2.ActionSupport;
+import net.sf.oval.constraint.NotNull;
+import net.sf.oval.constraint.NotEmpty;
+import net.sf.oval.constraint.Length;
+
+public class SimpleFieldI18n extends ActionSupport {
+ @NotNull(message = "notnull.field")
+ private String name;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
Propchange: struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/SimpleFieldI18n.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/SimpleFieldI18n.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/SimpleFieldI18nDefaultKey.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/SimpleFieldI18nDefaultKey.java?rev=759614&view=auto
==============================================================================
--- struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/SimpleFieldI18nDefaultKey.java (added)
+++ struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/SimpleFieldI18nDefaultKey.java Sat Mar 28 23:19:17 2009
@@ -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.interceptor;
+
+import com.opensymphony.xwork2.ActionSupport;
+import net.sf.oval.constraint.NotNull;
+import net.sf.oval.constraint.NotEmpty;
+import net.sf.oval.constraint.Length;
+
+public class SimpleFieldI18nDefaultKey extends ActionSupport {
+ @NotNull(message = "notnull.field")
+ private String name;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
Propchange: struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/SimpleFieldI18nDefaultKey.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/SimpleFieldI18nDefaultKey.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/SimpleFieldOGNLExpression.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/SimpleFieldOGNLExpression.java?rev=759614&view=auto
==============================================================================
--- struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/SimpleFieldOGNLExpression.java (added)
+++ struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/SimpleFieldOGNLExpression.java Sat Mar 28 23:19:17 2009
@@ -0,0 +1,41 @@
+/*
+ * $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.interceptor;
+
+import net.sf.oval.constraint.NotNull;
+import net.sf.oval.constraint.NotEmpty;
+import net.sf.oval.constraint.Length;
+import net.sf.oval.constraint.Assert;
+import com.opensymphony.xwork2.ActionSupport;
+
+public class SimpleFieldOGNLExpression extends ActionSupport {
+
+ @Assert(expr = "_value == 'Meursault'", lang = "ognl")
+ private String name;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
Propchange: struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/SimpleFieldOGNLExpression.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/SimpleFieldOGNLExpression.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/SimpleMethod.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/SimpleMethod.java?rev=759614&view=auto
==============================================================================
--- struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/SimpleMethod.java (added)
+++ struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/SimpleMethod.java Sat Mar 28 23:19:17 2009
@@ -0,0 +1,41 @@
+/*
+ * $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.interceptor;
+
+import com.opensymphony.xwork2.ActionSupport;
+import net.sf.oval.constraint.Length;
+import net.sf.oval.constraint.NotNull;
+import net.sf.oval.configuration.annotation.IsInvariant;
+
+public class SimpleMethod extends ActionSupport {
+ private String name;
+
+ @IsInvariant
+ @NotNull
+ @Length(max = 4)
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
Propchange: struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/SimpleMethod.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/SimpleMethod.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/VoidResult.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/VoidResult.java?rev=759614&view=auto
==============================================================================
--- struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/VoidResult.java (added)
+++ struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/VoidResult.java Sat Mar 28 23:19:17 2009
@@ -0,0 +1,29 @@
+/*
+ * $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.interceptor;
+
+import com.opensymphony.xwork2.Result;
+import com.opensymphony.xwork2.ActionInvocation;
+
+public class VoidResult implements Result {
+ public void execute(ActionInvocation invocation) throws Exception {
+ }
+}
Propchange: struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/VoidResult.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/struts2-oval-plugin/src/test/java/org/apache/struts2/interceptor/VoidResult.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: struts/sandbox/trunk/struts2-oval-plugin/src/test/resources/org/apache/struts2/interceptor/SimpleFieldI18n.properties
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-oval-plugin/src/test/resources/org/apache/struts2/interceptor/SimpleFieldI18n.properties?rev=759614&view=auto
==============================================================================
--- struts/sandbox/trunk/struts2-oval-plugin/src/test/resources/org/apache/struts2/interceptor/SimpleFieldI18n.properties (added)
+++ struts/sandbox/trunk/struts2-oval-plugin/src/test/resources/org/apache/struts2/interceptor/SimpleFieldI18n.properties Sat Mar 28 23:19:17 2009
@@ -0,0 +1 @@
+notnull.field=${context.field.name} cannot be null
\ No newline at end of file
Propchange: struts/sandbox/trunk/struts2-oval-plugin/src/test/resources/org/apache/struts2/interceptor/SimpleFieldI18n.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/struts2-oval-plugin/src/test/resources/org/apache/struts2/interceptor/SimpleFieldI18n.properties
------------------------------------------------------------------------------
svn:keywords = Id
Added: struts/sandbox/trunk/struts2-oval-plugin/src/test/resources/oval-test.xml
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-oval-plugin/src/test/resources/oval-test.xml?rev=759614&view=auto
==============================================================================
--- struts/sandbox/trunk/struts2-oval-plugin/src/test/resources/oval-test.xml (added)
+++ struts/sandbox/trunk/struts2-oval-plugin/src/test/resources/oval-test.xml Sat Mar 28 23:19:17 2009
@@ -0,0 +1,44 @@
+<!DOCTYPE xwork PUBLIC
+ "-//OpenSymphony Group//XWork 2.0//EN"
+ "http://www.opensymphony.com/xwork/xwork-2.0.dtd"
+ >
+
+<xwork>
+ <package namespace="oval" name="oval-test">
+ <result-types>
+ <result-type name="void" class="org.apache.struts2.interceptor.VoidResult"/>
+ </result-types>
+ <interceptors>
+ <interceptor name="ovalValidation" class="org.apache.struts2.interceptor.OValValidationInterceptor"/>
+ </interceptors>
+
+ <action name="simpleField" class="org.apache.struts2.interceptor.SimpleField">
+ <interceptor-ref name="ovalValidation" />
+ <result type="void"></result>
+ </action>
+ <action name="simpleMethod" class="org.apache.struts2.interceptor.SimpleMethod">
+ <interceptor-ref name="ovalValidation" />
+ <result type="void"></result>
+ </action>
+ <action name="simpleFieldOGNL" class="org.apache.struts2.interceptor.SimpleFieldOGNLExpression">
+ <interceptor-ref name="ovalValidation" />
+ <result type="void"></result>
+ </action>
+ <action name="simpleFieldI18n" class="org.apache.struts2.interceptor.SimpleFieldI18n">
+ <interceptor-ref name="ovalValidation" />
+ <result type="void"></result>
+ </action>
+ <action name="simpleFieldI18nDefaultKey" class="org.apache.struts2.interceptor.SimpleFieldI18nDefaultKey">
+ <interceptor-ref name="ovalValidation" />
+ <result type="void"></result>
+ </action>
+ <action name="fieldsWidthProfiles13" class="org.apache.struts2.interceptor.FieldsWithProfiles" method="run1">
+ <interceptor-ref name="ovalValidation" />
+ <result type="void"></result>
+ </action>
+ <action name="fieldsWidthProfiles2" class="org.apache.struts2.interceptor.FieldsWithProfiles" method="run2">
+ <interceptor-ref name="ovalValidation" />
+ <result type="void"></result>
+ </action>
+ </package>
+</xwork>
Propchange: struts/sandbox/trunk/struts2-oval-plugin/src/test/resources/oval-test.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/struts2-oval-plugin/src/test/resources/oval-test.xml
------------------------------------------------------------------------------
svn:keywords = Id