svn commit: r1301531 - /struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsTestCase.java
Author: lukaszlenart Date: Fri Mar 16 14:06:25 2012 New Revision: 1301531 URL: http://svn.apache.org/viewvc?rev=1301531&view=rev Log: WW-3774 - initialize portlet mocks only in case if portlet dependencies are available Modified: struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsTestCase.java Modified: struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsTestCase.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsTestCase.java?rev=1301531&r1=1301530&r2=1301531&view=diff == --- struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsTestCase.java (original) +++ struts/struts2/trunk/plugins/junit/src/main/java/org/apache/struts2/StrutsTestCase.java Fri Mar 16 14:06:25 2012 @@ -26,6 +26,7 @@ import com.opensymphony.xwork2.ActionPro import com.opensymphony.xwork2.ActionProxyFactory; import com.opensymphony.xwork2.XWorkTestCase; import com.opensymphony.xwork2.config.Configuration; +import com.opensymphony.xwork2.util.ClassLoaderUtil; import com.opensymphony.xwork2.util.logging.LoggerFactory; import com.opensymphony.xwork2.util.logging.jdk.JdkLoggerFactory; import org.apache.struts2.dispatcher.Dispatcher; @@ -37,7 +38,6 @@ import org.springframework.mock.web.Mock import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.mock.web.MockPageContext; import org.springframework.mock.web.MockServletContext; -import org.springframework.mock.web.portlet.MockPortletContext; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; @@ -94,6 +94,8 @@ public abstract class StrutsTestCase ext LoggerFactory.setLoggerFactory(new JdkLoggerFactory()); } +private static final com.opensymphony.xwork2.util.logging.Logger LOG = LoggerFactory.getLogger(StrutsTestCase.class); + /** * gets an object from the stack after an action is executed */ @@ -158,7 +160,17 @@ public abstract class StrutsTestCase ext } private void initMockPortletContext(ActionContext actionContext) { -actionContext.put(StrutsStatics.STRUTS_PORTLET_CONTEXT, new MockPortletContext()); +try { +ClassLoaderUtil.loadClass("javax.portlet.PortletContext", getClass()); +Class mockClazz = ClassLoaderUtil.loadClass("org.springframework.mock.web.portlet.MockPortletContext", getClass()); +actionContext.put(StrutsStatics.STRUTS_PORTLET_CONTEXT, mockClazz.newInstance()); +} catch (ClassNotFoundException e) { +LOG.debug("Cannot initialize portlet Mocks (javax.portlet.PortletContext class not found), you're missing dependencies (please add them) or not a portlet environment (so you can ignore this)!"); +} catch (InstantiationException e) { +LOG.warn("Cannot initialize portlet mocks!", e); +} catch (IllegalAccessException e) { +LOG.warn("Cannot initialize portlet mocks!", e); +} } /**
[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.10.0 Release edited by bvahdat (01:36 PM) https://cwiki.apache.org/confluence/display/CAMEL/Camel+2.10.0+Release Apache CXF (https://cwiki.apache.org/confluence/display/CXF) Pages - Release Management edited by dkulp (09:18 AM) https://cwiki.apache.org/confluence/display/CXF/Release+Management Apache DeltaSpike (https://cwiki.apache.org/confluence/display/DeltaSpike) Pages - Message Module Drafts edited by gpetracek (12:25 PM) https://cwiki.apache.org/confluence/display/DeltaSpike/Message+Module+Drafts Apache Directory SandBox (https://cwiki.apache.org/confluence/display/DIRxSBOX) Pages - TxnLogManager class edited by elecharny (08:41 AM) https://cwiki.apache.org/confluence/display/DIRxSBOX/TxnLogManager+class LogFlushManager created by elecharny (03:22 AM) https://cwiki.apache.org/confluence/display/DIRxSBOX/LogFlushManager Apache Directory Server v2.0 (https://cwiki.apache.org/confluence/display/DIRxSRVx20) Pages - ADS 2.0 configuration edited by elecharny (10:17 AM) https://cwiki.apache.org/confluence/display/DIRxSRVx20/ADS+2.0+configuration Apache Felix (https://cwiki.apache.org/confluence/display/FELIX) Pages - Apache Felix File Install edited by gnodet (06:07 AM) https://cwiki.apache.org/confluence/display/FELIX/Apache+Felix+File+Install Apache Flume (https://cwiki.apache.org/confluence/display/FLUME) Pages - Getting Started edited by ers81239 (04:43 PM) https://cwiki.apache.org/confluence/display/FLUME/Getting+Started Apache Giraph (Incubating) (https://cwiki.apache.org/confluence/display/GIRAPH) Pages - How to Contribute edited by aching (03:18 AM) https://cwiki.apache.org/confluence/display/GIRAPH/How+to+Contribute OODT (https://cwiki.apache.org/confluence/display/OODT) Pages - OODT Push-Pull User Guide edited by good...@oodt.apache.org (04:27 PM) https://cwiki.apache.org/confluence/display/OODT/OODT+Push-Pull+User+Guide Apache OpenOffice Community (https://cwiki.apache.org/confluence/display/OOOUSERS) Pages - Logo Proposals edited by drewjensen (11:56 PM) https://cwiki.apache.org/confluence/display/OOOUSERS/Logo+Proposals AOO 3.4 Release Notes edited by orw (10:38 AM) https://cwiki.apache.org/confluence/display/OOOUSERS/AOO+3.4+Release+Notes Apache Openmeetings (https://cwiki.apache.org/confluence/display/OPENMEETINGS) Pages - Documents for Presentations and PR created by seba.wag...@gmail.com (12:45 PM) https://cwiki.apache.org/confluence/display/OPENMEETINGS/Documents+for+Presentations+and+PR Apache Pig (https://cwiki.apache.org/confluence/display/PIG) Pages - PigTutorial edited by thinkerfee...@yahoo.com (06:22 PM) https://cwiki.apache.org/confluence/display/PIG/PigTutorial HowToContribute edited by traviscrawf...@gmail.com (06:04 PM) https://cwiki.apache.org/confluence/display/PIG/HowToContribute Better documented version of script1-local.pig created by thinkerfee...@yahoo.com (05:36 PM) https://cwiki.apache.org/confluence/display/PIG/2012/03/16/Better+documented+version+of+script1-local.pig GSoc2012 edited by daijy (01:15 AM) https://cwiki.apache.org/confluence/display/PIG/GSoc2012 Apache Qpid (https://cwiki.apache.org/confluence/display/qpid) Pages - Java Broker Unified Configuration edited by robbie (01:58 PM) https://cwiki.apache.org/confluence/display/qpid/Java+Broker+Unified+Configuration Client Failover Behaviour edited by alex.rufous (11:37 AM) https://cwiki.apache.org/confluence/display/qpid/Client+Failover+Behaviour Apache Shiro (https://cwiki.apache.org/confluence/display/SHIRO) Pages - Commercial Support edited by lhazlewood (08:52 PM) https://cwiki.apache.org/confluence/display/SHIRO/Commercial+Support Apache Tapestry (https://cwiki.apache.org/confluence