atom feed1 message in net.java.dev.appfuse.commits[appfuse-commits] svn commit: r3238 -...
FromSent OnAttachments
mrai...@dev.java.netMay 5, 2009 9:26 pm 
Subject:[appfuse-commits] svn commit: r3238 - trunk: . archetypes/appfuse-basic-struts/src archetypes/appfuse-modular-struts/src web/struts web/struts/src/main/java/org/appf...
From:mrai...@dev.java.net (mrai@dev.java.net)
Date:May 5, 2009 9:26:41 pm
List:net.java.dev.appfuse.commits

Author: mraible Date: 2009-05-06 04:27:20+0000 New Revision: 3238

Modified: trunk/archetypes/appfuse-basic-struts/src/pom.xml trunk/archetypes/appfuse-modular-struts/src/pom.xml trunk/pom.xml trunk/web/struts/pom.xml trunk/web/struts/src/main/java/org/appfuse/webapp/action/DateConverter.java trunk/web/struts/src/main/java/org/appfuse/webapp/action/PasswordHintAction.java trunk/web/struts/src/main/java/org/appfuse/webapp/action/SignupAction.java trunk/web/struts/src/main/java/org/appfuse/webapp/action/UserAction.java trunk/web/struts/src/main/resources/struts.xml trunk/web/struts/src/main/webapp/WEB-INF/web.xml trunk/web/struts/src/test/java/org/appfuse/webapp/action/BaseActionTestCase.java

Log: APF-1130: Upgraded to Struts 2.1. Works for web/struts, but not for
archetypes/appfuse-basic-struts.

Modified: trunk/archetypes/appfuse-basic-struts/src/pom.xml Url:
https://appfuse.dev.java.net/source/browse/appfuse/trunk/archetypes/appfuse-basic-struts/src/pom.xml?view=diff&rev=3238&p1=trunk/archetypes/appfuse-basic-struts/src/pom.xml&p2=trunk/archetypes/appfuse-basic-struts/src/pom.xml&r1=3237&r2=3238 ============================================================================== --- trunk/archetypes/appfuse-basic-struts/src/pom.xml (original) +++ trunk/archetypes/appfuse-basic-struts/src/pom.xml 2009-05-06 04:27:20+0000 @@ -712,7 +712,7 @@ <commons.io.version>1.3.2</commons.io.version> <displaytag.version>1.2</displaytag.version> <spring.version>2.5.6</spring.version> - <struts.version>2.0.11.1</struts.version> + <struts.version>2.1.6</struts.version>

<!-- Testing dependency versions --> <cargo.version>1.0</cargo.version>

Modified: trunk/archetypes/appfuse-modular-struts/src/pom.xml Url:
https://appfuse.dev.java.net/source/browse/appfuse/trunk/archetypes/appfuse-modular-struts/src/pom.xml?view=diff&rev=3238&p1=trunk/archetypes/appfuse-modular-struts/src/pom.xml&p2=trunk/archetypes/appfuse-modular-struts/src/pom.xml&r1=3237&r2=3238 ============================================================================== --- trunk/archetypes/appfuse-modular-struts/src/pom.xml (original) +++ trunk/archetypes/appfuse-modular-struts/src/pom.xml 2009-05-06 04:27:20+0000 @@ -322,7 +322,7 @@ <commons.io.version>1.3.2</commons.io.version> <displaytag.version>1.2</displaytag.version> <spring.version>2.5.6</spring.version> - <struts.version>2.0.11.1</struts.version> + <struts.version>2.1.6</struts.version>

<!-- Testing dependency versions --> <cargo.version>1.0</cargo.version>

Modified: trunk/pom.xml Url:
https://appfuse.dev.java.net/source/browse/appfuse/trunk/pom.xml?view=diff&rev=3238&p1=trunk/pom.xml&p2=trunk/pom.xml&r1=3237&r2=3238 ============================================================================== --- trunk/pom.xml (original) +++ trunk/pom.xml 2009-05-06 04:27:20+0000 @@ -485,7 +485,7 @@ <spring.version>2.5.6</spring.version> <spring.security.version>2.0.4</spring.security.version> <springmodules.validation.version>0.8</springmodules.validation.version> - <struts.version>2.0.11.1</struts.version> + <struts.version>2.1.6</struts.version> <struts.menu.version>2.4.3</struts.menu.version> <tapestry.version>5.0.14</tapestry.version> <urlrewrite.version>3.1.0</urlrewrite.version>

Modified: trunk/web/struts/pom.xml Url:
https://appfuse.dev.java.net/source/browse/appfuse/trunk/web/struts/pom.xml?view=diff&rev=3238&p1=trunk/web/struts/pom.xml&p2=trunk/web/struts/pom.xml&r1=3237&r2=3238 ============================================================================== --- trunk/web/struts/pom.xml (original) +++ trunk/web/struts/pom.xml 2009-05-06 04:27:20+0000 @@ -210,7 +210,7 @@ </dependency> <dependency> <groupId>org.apache.struts</groupId> - <artifactId>struts2-codebehind-plugin</artifactId> + <artifactId>struts2-convention-plugin</artifactId> <version>${struts.version}</version> </dependency> <dependency>

Modified:
trunk/web/struts/src/main/java/org/appfuse/webapp/action/DateConverter.java Url:
https://appfuse.dev.java.net/source/browse/appfuse/trunk/web/struts/src/main/java/org/appfuse/webapp/action/DateConverter.java?view=diff&rev=3238&p1=trunk/web/struts/src/main/java/org/appfuse/webapp/action/DateConverter.java&p2=trunk/web/struts/src/main/java/org/appfuse/webapp/action/DateConverter.java&r1=3237&r2=3238 ============================================================================== --- trunk/web/struts/src/main/java/org/appfuse/webapp/action/DateConverter.java
(original) +++ trunk/web/struts/src/main/java/org/appfuse/webapp/action/DateConverter.java
2009-05-06 04:27:20+0000 @@ -6,7 +6,7 @@

import org.apache.struts2.util.StrutsTypeConverter; import org.appfuse.util.DateUtil; -import com.opensymphony.xwork2.util.TypeConversionException; +import com.opensymphony.xwork2.conversion.TypeConversionException;

public class DateConverter extends StrutsTypeConverter {

@@ -26,4 +26,4 @@ public String convertToString(Map ctx, Object data) { return DateUtil.convertDateToString((Date) data); } -} \ No newline at end of file +}

Modified:
trunk/web/struts/src/main/java/org/appfuse/webapp/action/PasswordHintAction.java Url:
https://appfuse.dev.java.net/source/browse/appfuse/trunk/web/struts/src/main/java/org/appfuse/webapp/action/PasswordHintAction.java?view=diff&rev=3238&p1=trunk/web/struts/src/main/java/org/appfuse/webapp/action/PasswordHintAction.java&p2=trunk/web/struts/src/main/java/org/appfuse/webapp/action/PasswordHintAction.java&r1=3237&r2=3238 ============================================================================== ---
trunk/web/struts/src/main/java/org/appfuse/webapp/action/PasswordHintAction.java
(original) +++
trunk/web/struts/src/main/java/org/appfuse/webapp/action/PasswordHintAction.java
2009-05-06 04:27:20+0000 @@ -30,7 +30,7 @@ * @return success if username works, input if not */ public String execute() { - List<String> args = new ArrayList<String>(); + List<Object> args = new ArrayList<Object>();

// ensure that the username has been sent if (username == null) {

Modified:
trunk/web/struts/src/main/java/org/appfuse/webapp/action/SignupAction.java Url:
https://appfuse.dev.java.net/source/browse/appfuse/trunk/web/struts/src/main/java/org/appfuse/webapp/action/SignupAction.java?view=diff&rev=3238&p1=trunk/web/struts/src/main/java/org/appfuse/webapp/action/SignupAction.java&p2=trunk/web/struts/src/main/java/org/appfuse/webapp/action/SignupAction.java&r1=3237&r2=3238 ============================================================================== --- trunk/web/struts/src/main/java/org/appfuse/webapp/action/SignupAction.java
(original) +++ trunk/web/struts/src/main/java/org/appfuse/webapp/action/SignupAction.java
2009-05-06 04:27:20+0000 @@ -1,19 +1,19 @@ package org.appfuse.webapp.action;

-import org.springframework.security.AccessDeniedException; -import org.springframework.security.context.SecurityContextHolder; -import
org.springframework.security.providers.UsernamePasswordAuthenticationToken; +import java.util.ArrayList; +import java.util.List; +import javax.servlet.http.HttpServletResponse; + import org.apache.struts2.ServletActionContext; import org.appfuse.Constants; import org.appfuse.model.User; import org.appfuse.service.UserExistsException; import org.appfuse.webapp.util.RequestUtil; import org.springframework.mail.MailException; - -import javax.servlet.http.HttpServletResponse; -import java.util.ArrayList; -import java.util.List; +import org.springframework.security.AccessDeniedException; +import org.springframework.security.context.SecurityContextHolder; +import
org.springframework.security.providers.UsernamePasswordAuthenticationToken;

/** * Action to allow new users to sign up. @@ -81,7 +81,7 @@ return null; } catch (UserExistsException e) { log.warn(e.getMessage()); - List<String> args = new ArrayList<String>(); + List<Object> args = new ArrayList<Object>(); args.add(user.getUsername()); args.add(user.getEmail()); addActionError(getText("errors.existing.user", args));

Modified:
trunk/web/struts/src/main/java/org/appfuse/webapp/action/UserAction.java Url:
https://appfuse.dev.java.net/source/browse/appfuse/trunk/web/struts/src/main/java/org/appfuse/webapp/action/UserAction.java?view=diff&rev=3238&p1=trunk/web/struts/src/main/java/org/appfuse/webapp/action/UserAction.java&p2=trunk/web/struts/src/main/java/org/appfuse/webapp/action/UserAction.java&r1=3237&r2=3238 ============================================================================== --- trunk/web/struts/src/main/java/org/appfuse/webapp/action/UserAction.java
(original) +++ trunk/web/struts/src/main/java/org/appfuse/webapp/action/UserAction.java
2009-05-06 04:27:20+0000 @@ -69,7 +69,7 @@ */ public String delete() { userManager.removeUser(user.getId().toString()); - List<String> args = new ArrayList<String>(); + List<Object> args = new ArrayList<Object>(); args.add(user.getFullName()); saveMessage(getText("user.deleted", args));

@@ -181,7 +181,7 @@ getResponse().sendError(HttpServletResponse.SC_FORBIDDEN); return null; } catch (UserExistsException e) { - List<String> args = new ArrayList<String>(); + List<Object> args = new ArrayList<Object>(); args.add(user.getUsername()); args.add(user.getEmail()); addActionError(getText("errors.existing.user", args)); @@ -199,7 +199,7 @@ return "mainMenu"; } else { // add success messages - List<String> args = new ArrayList<String>(); + List<Object> args = new ArrayList<Object>(); args.add(user.getFullName()); if (isNew) { saveMessage(getText("user.added", args));

Modified: trunk/web/struts/src/main/resources/struts.xml Url:
https://appfuse.dev.java.net/source/browse/appfuse/trunk/web/struts/src/main/resources/struts.xml?view=diff&rev=3238&p1=trunk/web/struts/src/main/resources/struts.xml&p2=trunk/web/struts/src/main/resources/struts.xml&r1=3237&r2=3238 ============================================================================== --- trunk/web/struts/src/main/resources/struts.xml (original) +++ trunk/web/struts/src/main/resources/struts.xml 2009-05-06 04:27:20+0000 @@ -13,6 +13,7 @@ <constant name="struts.ui.theme" value="css_xhtml"/> <constant name="struts.codebehind.pathPrefix" value="/WEB-INF/pages/"/> <constant name="struts.enable.SlashesInActionNames" value="true"/> + <constant name="struts.convention.action.disableScanning" value="true"/>

<!-- Configuration for the default package. --> <package name="default" extends="struts-default"> @@ -23,17 +24,17 @@ <interceptor-stack name="defaultStack"> <interceptor-ref name="exception"/> <interceptor-ref name="alias"/> - <interceptor-ref name="servlet-config"/> + <interceptor-ref name="servletConfig"/> <interceptor-ref name="prepare"/> <interceptor-ref name="i18n"/> <interceptor-ref name="chain"/> <interceptor-ref name="debugging"/> <interceptor-ref name="profiling"/> - <interceptor-ref name="scoped-model-driven"/> - <interceptor-ref name="model-driven"/> + <interceptor-ref name="scopedModelDriven"/> + <interceptor-ref name="modelDriven"/> <interceptor-ref name="fileUpload"/> <interceptor-ref name="checkbox"/> - <interceptor-ref name="static-params"/> + <interceptor-ref name="staticParams"/> <interceptor-ref name="params"> <param name="excludeParams">dojo\..*</param> </interceptor-ref> @@ -56,7 +57,7 @@ </interceptors>

<global-results> - <result name="mainMenu" type="redirect-action">mainMenu</result> + <result name="mainMenu" type="redirectAction">mainMenu</result> <result
name="dataAccessFailure">/WEB-INF/pages/dataAccessFailure.jsp</result> </global-results>

@@ -76,7 +77,7 @@

<action name="saveSignup" class="signupAction" method="save"> <result name="input">/WEB-INF/pages/signup.jsp</result> - <result name="success" type="redirect-action">/mainMenu</result> + <result name="success" type="redirectAction">/mainMenu</result> </action>

<action name="editUser" class="userAction" method="edit"> @@ -91,16 +92,16 @@ </action>

<action name="saveUser" class="userAction" method="save"> - <result name="cancel" type="redirect-action">admin/users</result> + <result name="cancel" type="redirectAction">admin/users</result> <result name="input">/WEB-INF/pages/userForm.jsp</result> - <result name="success" type="redirect-action">admin/users</result> + <result name="success" type="redirectAction">admin/users</result> </action>

<action name="uploadFile"
class="org.appfuse.webapp.action.FileUploadAction"> <interceptor-ref name="fileUploadStack"/> <result name="input">/WEB-INF/pages/uploadForm.jsp</result> <result name="success">/WEB-INF/pages/uploadDisplay.jsp</result> - <result name="cancel" type="redirect-action">mainMenu</result> + <result name="cancel" type="redirectAction">mainMenu</result> </action>

<action name="passwordHint" class="passwordHintAction">

Modified: trunk/web/struts/src/main/webapp/WEB-INF/web.xml Url:
https://appfuse.dev.java.net/source/browse/appfuse/trunk/web/struts/src/main/webapp/WEB-INF/web.xml?view=diff&rev=3238&p1=trunk/web/struts/src/main/webapp/WEB-INF/web.xml&p2=trunk/web/struts/src/main/webapp/WEB-INF/web.xml&r1=3237&r2=3238 ============================================================================== --- trunk/web/struts/src/main/webapp/WEB-INF/web.xml (original) +++ trunk/web/struts/src/main/webapp/WEB-INF/web.xml 2009-05-06 04:27:20+0000 @@ -1,7 +1,7 @@ <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> - + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> + <display-name>appfuse</display-name> <distributable/>

@@ -99,12 +99,20 @@ </init-param> </filter> <filter> - <filter-name>struts-cleanup</filter-name> -
<filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class> + <filter-name>struts-prepare</filter-name> +
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter</filter-class> + <init-param> + <param-name>actionPackages</param-name> + <param-value>org.appfuse.webapp.action</param-value> + </init-param> </filter> <filter> <filter-name>struts</filter-name> -
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class> +
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter</filter-class> + <init-param> + <param-name>actionPackages</param-name> + <param-value>org.appfuse.webapp.action</param-value> + </init-param> </filter>

<filter-mapping> @@ -114,9 +122,9 @@ <filter-mapping> <filter-name>securityFilter</filter-name> <url-pattern>/*</url-pattern> - </filter-mapping> + </filter-mapping> <!-- Commented out for 2 reasons: 1) it's a pain when developing JSPs, and - 2) it causes the Signup webtest to fail
--> +2) it causes the Signup webtest to fail --> <!--filter-mapping> <filter-name>cacheFilter</filter-name> <url-pattern>*.jsp</url-pattern> @@ -158,10 +166,8 @@ <dispatcher>FORWARD</dispatcher> </filter-mapping> <filter-mapping> - <filter-name>struts-cleanup</filter-name> + <filter-name>struts-prepare</filter-name> <url-pattern>/*</url-pattern> - <dispatcher>REQUEST</dispatcher> - <dispatcher>FORWARD</dispatcher> </filter-mapping> <filter-mapping> <filter-name>sitemesh</filter-name> @@ -179,8 +185,6 @@ <filter-mapping> <filter-name>struts</filter-name> <url-pattern>/*</url-pattern> - <dispatcher>REQUEST</dispatcher> - <dispatcher>FORWARD</dispatcher> </filter-mapping>

<listener> @@ -210,7 +214,7 @@ <param-value>true</param-value> </init-param> </servlet> - + <servlet> <servlet-name>xfire</servlet-name> <servlet-class>org.codehaus.xfire.spring.XFireSpringServlet</servlet-class> @@ -220,7 +224,7 @@ <servlet-name>dwr-invoker</servlet-name> <url-pattern>/dwr/*</url-pattern> </servlet-mapping> - + <servlet-mapping> <servlet-name>xfire</servlet-name> <url-pattern>/services/*</url-pattern>

Modified:
trunk/web/struts/src/test/java/org/appfuse/webapp/action/BaseActionTestCase.java Url:
https://appfuse.dev.java.net/source/browse/appfuse/trunk/web/struts/src/test/java/org/appfuse/webapp/action/BaseActionTestCase.java?view=diff&rev=3238&p1=trunk/web/struts/src/test/java/org/appfuse/webapp/action/BaseActionTestCase.java&p2=trunk/web/struts/src/test/java/org/appfuse/webapp/action/BaseActionTestCase.java&r1=3237&r2=3238 ============================================================================== ---
trunk/web/struts/src/test/java/org/appfuse/webapp/action/BaseActionTestCase.java
(original) +++
trunk/web/struts/src/test/java/org/appfuse/webapp/action/BaseActionTestCase.java
2009-05-06 04:27:20+0000 @@ -1,7 +1,15 @@ package org.appfuse.webapp.action;

+import java.util.HashMap; + import com.opensymphony.xwork2.ActionContext; +import com.opensymphony.xwork2.config.Configuration; +import com.opensymphony.xwork2.config.ConfigurationManager; +import com.opensymphony.xwork2.config.providers.XWorkConfigurationProvider; +import com.opensymphony.xwork2.inject.Container; import com.opensymphony.xwork2.util.LocalizedTextUtil; +import com.opensymphony.xwork2.util.ValueStack; +import com.opensymphony.xwork2.util.ValueStackFactory; import org.apache.commons.logging.Log; import org.apache.struts2.ServletActionContext; import org.appfuse.Constants; @@ -9,10 +17,9 @@ import org.springframework.mock.web.MockHttpServletRequest; import
org.springframework.test.AbstractTransactionalDataSourceSpringContextTests;

-import java.util.HashMap; - /** * Base class for running Struts 2 Action tests. + * * @author mraible */ public abstract class BaseActionTestCase extends
AbstractTransactionalDataSourceSpringContextTests { @@ -21,22 +28,33 @@

protected String[] getConfigLocations() { super.setAutowireMode(AUTOWIRE_BY_NAME); - return new String[] { + return new String[]{ "classpath:/applicationContext-resources.xml", "classpath:/applicationContext-dao.xml", "classpath:/applicationContext-service.xml", "classpath*:/applicationContext.xml", // for modular archetypes "/WEB-INF/applicationContext*.xml" - }; + }; }

@Override protected void onSetUpBeforeTransaction() throws Exception { smtpPort = smtpPort + (int) (Math.random() * 100); - - LocalizedTextUtil.addDefaultResourceBundle(Constants.BUNDLE_KEY); - ActionContext.getContext().setSession(new HashMap()); - + + LocalizedTextUtil.addDefaultResourceBundle(Constants.BUNDLE_KEY); + + // Initialize ActionContext + ConfigurationManager configurationManager = new ConfigurationManager(); + configurationManager.addContainerProvider(new
XWorkConfigurationProvider()); + Configuration config = configurationManager.getConfiguration(); + Container container = config.getContainer(); + + ValueStack stack =
container.getInstance(ValueStackFactory.class).createValueStack(); + stack.getContext().put(ActionContext.CONTAINER, container); + ActionContext.setContext(new ActionContext(stack.getContext())); + + ActionContext.getContext().setSession(new HashMap<String, Object>()); + // change the port on the mailSender so it doesn't conflict with an // existing SMTP server on localhost JavaMailSenderImpl mailSender = (JavaMailSenderImpl)
applicationContext.getBean("mailSender"); @@ -53,6 +71,6 @@

@Override protected void onTearDownAfterTransaction() throws Exception { - ActionContext.getContext().setSession(null); + ActionContext.getContext().setSession(null); } }