svn commit: r1153904 - in /struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2: StrutsJUnit4TestCase.java StrutsSpringJUnit4TestCase.java StrutsSpringTestCase.java StrutsTestCase.java
Author: mcucchiara Date: Thu Aug 4 15:12:44 2011 New Revision: 1153904 URL: http://svn.apache.org/viewvc?rev=1153904&view=rev Log: WW-3667 - StrutsJUnit4TestCase does not provide the executeAction method Added: struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsSpringJUnit4TestCase.java (with props) Modified: struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsJUnit4TestCase.java (contents, props changed) struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsSpringTestCase.java (props changed) struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsTestCase.java (contents, props changed) 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=1153904&r1=1153903&r2=1153904&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 Thu Aug 4 15:12:44 2011 @@ -1,16 +1,49 @@ +/* + * $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; -import com.opensymphony.xwork2.XWorkJUnit4TestCase; +import com.opensymphony.xwork2.*; +import com.opensymphony.xwork2.config.Configuration; import com.opensymphony.xwork2.interceptor.annotations.After; import com.opensymphony.xwork2.interceptor.annotations.Before; import com.opensymphony.xwork2.util.logging.LoggerFactory; import com.opensymphony.xwork2.util.logging.jdk.JdkLoggerFactory; import org.apache.struts2.dispatcher.Dispatcher; +import org.apache.struts2.dispatcher.mapper.ActionMapper; +import org.apache.struts2.dispatcher.mapper.ActionMapping; import org.apache.struts2.util.StrutsTestCaseHelper; +import org.springframework.core.io.DefaultResourceLoader; +import org.springframework.mock.web.MockHttpServletRequest; +import org.springframework.mock.web.MockHttpServletResponse; +import org.springframework.mock.web.MockPageContext; import org.springframework.mock.web.MockServletContext; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.UnsupportedEncodingException; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.HashMap; import java.util.Map; import java.util.logging.ConsoleHandler; import java.util.logging.Formatter; @@ -18,8 +51,17 @@ import java.util.logging.Level; import java.util.logging.LogRecord; import java.util.logging.Logger; +import static org.junit.Assert.assertNotNull; + + +public class StrutsJUnit4TestCase extends XWorkJUnit4TestCase { +protected MockHttpServletResponse response; +protected MockHttpServletRequest request; +protected MockPageContext pageContext; +protected MockServletContext servletContext; +protected Map dispatcherInitParams; -public class StrutsJUnit4TestCase extends XWorkJUnit4TestCase { +protected DefaultResourceLoader resourceLoader = new DefaultResourceLoader(); static { ConsoleHandler handler = new ConsoleHandler(); @@ -51,6 +93,115 @@ public class StrutsJUnit4TestCase extend } /** + * gets an object from the stack after an action is executed + */ +protected Object findValueAfterExecute(String key) { +return ServletActionContext.getValueStack(request).findValue(key); +} + +/** + * gets an object from the stack after an action is executed + * @return The executed action + */ +@SuppressWarnings("unchecked") +protected T getAction() { +return (T) findValueAfterExecute("action"); +} + +protected boolean containsErrors() { +T action = this.getAction(); +if(action instanceof ValidationAware) { +return ((ValidationAware) action).hasActionErrors(); +} +throw new UnsupportedOperationException("Current action does not
svn commit: r1153918 - in /struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2: StrutsJUnit4TestCase.java StrutsSpringJUnit4TestCase.java
Author: mcucchiara Date: Thu Aug 4 16:12:15 2011 New Revision: 1153918 URL: http://svn.apache.org/viewvc?rev=1153918&view=rev Log: Made StrutsJunit4 classes abstract Modified: struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsJUnit4TestCase.java struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsSpringJUnit4TestCase.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=1153918&r1=1153917&r2=1153918&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 Thu Aug 4 16:12:15 2011 @@ -54,7 +54,7 @@ import java.util.logging.Logger; import static org.junit.Assert.assertNotNull; -public class StrutsJUnit4TestCase extends XWorkJUnit4TestCase { +public abstract class StrutsJUnit4TestCase extends XWorkJUnit4TestCase { protected MockHttpServletResponse response; protected MockHttpServletRequest request; protected MockPageContext pageContext; Modified: struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsSpringJUnit4TestCase.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsSpringJUnit4TestCase.java?rev=1153918&r1=1153917&r2=1153918&view=diff == --- struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsSpringJUnit4TestCase.java (original) +++ struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsSpringJUnit4TestCase.java Thu Aug 4 16:12:15 2011 @@ -31,7 +31,7 @@ import org.springframework.web.context.W * Date: 04/08/11 * Time: 16.50 */ -public class StrutsSpringJUnit4TestCase extends StrutsJUnit4TestCase implements ApplicationContextAware { +public abstract class StrutsSpringJUnit4TestCase extends StrutsJUnit4TestCase implements ApplicationContextAware { protected ApplicationContext applicationContext; @Override
[CONF] Confluence Changes in the last 24 hours
This is a daily summary of all recent changes in Confluence. - Updated Spaces: - Apache ActiveMQ (https://cwiki.apache.org/confluence/display/ACTIVEMQ) Pages - How do transactions work edited by dejanb (06:48 AM) https://cwiki.apache.org/confluence/display/ACTIVEMQ/How+do+transactions+work Apache Archiva (https://cwiki.apache.org/confluence/display/ARCHIVA) Pages - Archiva Roadmap edited by olamy (03:30 PM) https://cwiki.apache.org/confluence/display/ARCHIVA/Archiva+Roadmap Apache Buildr (https://cwiki.apache.org/confluence/display/BUILDR) Pages - Buildr in the Wild edited by ctiwald (09:08 AM) https://cwiki.apache.org/confluence/display/BUILDR/Buildr+in+the+Wild How to depend on a war-packaged project created by vacc...@pobox.com (02:24 AM) https://cwiki.apache.org/confluence/display/BUILDR/How+to+depend+on+a+war-packaged+project Comments https://cwiki.apache.org/confluence/display/BUILDR/How+to+reuse+another+project%27s+test+classes (1) Apache Camel (https://cwiki.apache.org/confluence/display/CAMEL) Pages - Dynamic Router edited by janstey (02:17 PM) https://cwiki.apache.org/confluence/display/CAMEL/Dynamic+Router Bean Binding edited by davsclaus (10:01 AM) https://cwiki.apache.org/confluence/display/CAMEL/Bean+Binding AdviceWith edited by davsclaus (05:54 AM) https://cwiki.apache.org/confluence/display/CAMEL/AdviceWith Apache Deft (https://cwiki.apache.org/confluence/display/DEFT) Pages - Coding Standards edited by jmeehan (01:20 PM) https://cwiki.apache.org/confluence/display/DEFT/Coding+Standards Contribute edited by jmeehan (01:18 PM) https://cwiki.apache.org/confluence/display/DEFT/Contribute Apache Directory client API (https://cwiki.apache.org/confluence/display/DIRAPI) Pages - Navigation edited by elecharny (06:32 AM) https://cwiki.apache.org/confluence/display/DIRAPI/Navigation Downloads edited by elecharny (06:31 AM) https://cwiki.apache.org/confluence/display/DIRAPI/Downloads Apache Directory Website (https://cwiki.apache.org/confluence/display/DIRxSITE) Pages - Navigation edited by elecharny (06:30 AM) https://cwiki.apache.org/confluence/display/DIRxSITE/Navigation Apache Flume (https://cwiki.apache.org/confluence/display/FLUME) Pages - How to Contribute edited by jmhsieh (07:11 PM) https://cwiki.apache.org/confluence/display/FLUME/How+to+Contribute Index edited by jmhsieh (07:11 PM) https://cwiki.apache.org/confluence/display/FLUME/Index Flume Plugins edited by jmhsieh (06:43 PM) https://cwiki.apache.org/confluence/display/FLUME/Flume+Plugins Flume Config Language created by jmhsieh (10:52 AM) https://cwiki.apache.org/confluence/display/FLUME/Flume+Config+Language Feature Status edited by jmhsieh (10:19 AM) https://cwiki.apache.org/confluence/display/FLUME/Feature+Status End to End mode Design created by jmhsieh (10:12 AM) https://cwiki.apache.org/confluence/display/FLUME/End+to+End+mode+Design Flume Node Design created by jmhsieh (09:49 AM) https://cwiki.apache.org/confluence/display/FLUME/Flume+Node+Design Flume Master Design created by jmhsieh (09:23 AM) https://cwiki.apache.org/confluence/display/FLUME/Flume+Master+Design Flume Internals edited by jmhsieh (09:16 AM) https://cwiki.apache.org/confluence/display/FLUME/Flume+Internals Apache Hive (https://cwiki.apache.org/confluence/display/Hive) Pages - Transitivity on predicate pushdown created by charleschen (02:03 PM) https://cwiki.apache.org/confluence/display/Hive/Transitivity+on+predicate+pushdown Apache Mahout (https://cwiki.apache.org/confluence/display/MAHOUT) Pages - Parallel Frequent Pattern Mining edited by lance.nors...@gmail.com (05:37 AM) https://cwiki.apache.org/confluence/display/MAHOUT/Parallel+Frequent+Pattern+Mining Apache MyFaces (https://cwiki.apache.org/confluence/display/MYFACES) Pages - Working with tables created by lu4242 (10:45 PM) https://cwiki.apache.org/confluence/display/MYFACES/Working+with+tables Get row data from an ActionListener created by lu4242 (10:40 PM) https://cwiki.apache.org/confluence/display/MYFACES/Get+row+data+from+an+ActionListener