1 Reply Latest reply: Jul 16, 2010 4:08 AM by 843833 RSS

    Error in juit test case for struts2 action class using StrutsSpringTestCase

    843833
      Hi

      I am getting some error when i am running my Struts2 Action class junit test case using StrutsSpringTestCase class (which is in struts2 junit plugin 2.1.8 version)

      Here is the code....
      package ipl.admin.action.test;
      
      import java.sql.Timestamp;
      import java.util.Date;
      
      import org.apache.struts2.StrutsSpringTestCase;
      
      import ipl.admin.action.RoleMasterNewAction;
      import ipl.admin.beans.RoleMasterNewBeanRemote;
      
      
      
      import com.opensymphony.xwork2.ObjectFactory;
      
      public class RoleMasterNewActionTest extends StrutsSpringTestCase {
      
      
           //XmlBeanFactory bf = new XmlBeanFactory(new ClassPathResource("applicationContext.xml", getClass()));
           RoleMasterNewAction action = new RoleMasterNewAction();
           RoleMasterNewBeanRemote roleMasterBeanNewRemote;
      
           public RoleMasterNewBeanRemote getRoleMasterBeanNewRemote() {
                return roleMasterBeanNewRemote;
           }
      
           public void setRoleMasterBeanNewRemote(
                     RoleMasterNewBeanRemote roleMasterBeanNewRemote) {
                this.roleMasterBeanNewRemote = roleMasterBeanNewRemote;
           }
      
           public void setUp() throws Exception {
                super.setUp();
                ObjectFactory.setObjectFactory(new ObjectFactory());
           }
      
           public void testDoSomeThing() throws Exception {
                
                //System.out.println(bf.getBean("loginIntercepter"));
                assertTrue(action.doSomeThing());
      
           }
      }
      I am getting error for this code. Below is the error details.
      2010-05-03 17:28:14,671 INFO [com.opensymphony.xwork2.config.providers.XmlConfigurationProvider] - Parsing configuration file [struts-default.xml]
      2010-05-03 17:28:14,859 INFO [com.opensymphony.xwork2.config.providers.XmlConfigurationProvider] - Parsing configuration file [struts-plugin.xml]
      2010-05-03 17:28:14,999 INFO [com.opensymphony.xwork2.config.providers.XmlConfigurationProvider] - Parsing configuration file [struts.xml]
      2010-05-03 17:28:15,015 WARN [org.apache.struts2.config.Settings] - Settings: Could not parse struts.locale setting, substituting default VM locale
      2010-05-03 17:28:15,015 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.comm.resources.comman-Lookup
      2010-05-03 17:28:15,015 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.comm.resources.comman-label
      2010-05-03 17:28:15,015 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.comm.resources.comman-headings
      2010-05-03 17:28:15,015 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.comm.resources.comman-messages
      2010-05-03 17:28:15,046 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.comm.resources.comman-setup
      2010-05-03 17:28:15,046 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.comm.resources.common-errors
      2010-05-03 17:28:15,046 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.admin.resources.admin-label
      2010-05-03 17:28:15,046 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.admin.resources.admin-lookup
      2010-05-03 17:28:15,046 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.admin.resources.admin-headings
      2010-05-03 17:28:15,046 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.admin.resources.admin-jndinames
      2010-05-03 17:28:15,046 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.birthCertificate.resources.birth-jndinames
      2010-05-03 17:28:15,046 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.birthCertificate.resources.birth-labels
      2010-05-03 17:28:15,046 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.birthCertificate.resources.birth-headings
      2010-05-03 17:28:15,046 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.admin.resources.admin-alert
      2010-05-03 17:28:15,046 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.comm.resources.form
      2010-05-03 17:28:15,140 INFO [org.apache.struts2.spring.StrutsSpringObjectFactory] - Initializing Struts-Spring integration...
      2010-05-03 17:28:15,171 FATAL [org.apache.struts2.spring.StrutsSpringObjectFactory] - ********** FATAL ERROR STARTING UP STRUTS-SPRING INTEGRATION **********
      Looks like the Spring listener was not configured for your web app!
      Nothing will work until WebApplicationContextUtils returns a valid ApplicationContext.
      You might need to add the following to web.xml:
          <listener>
              <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
          </listener> 
      But already i have the listener configurations in my web.xml .


      Thanks in advance...