You could try altering your StartupListenerTest to load
applicationContext.xml. This should work. If it doesn't, you're probably
altering the wrong file.

On Wed, May 5, 2010 at 12:44 AM, Tony Luo <xiuxiu.luo.x...@gmail.com> wrote:

> Hi Matt,
>
> I noticed that StartupListenerTest doesn' load applicationContext.xml.
> But even I put the configuration in applicationContext-dao.xml, the
> StartupListenerTest also failed to get the manager bean.
>
> <bean id="personManager"
> class="org.appfuse.service.impl.GenericManagerImpl">
>   <constructor-arg>
>       <bean class="org.appfuse.dao.hibernate.GenericDaoHibernate"
> autowire="byType">
>           <constructor-arg
> value="org.appfuse.tutorial.model.Person"/>
>       </bean>
>   </constructor-arg>
> </bean>
>
> 2010/5/5 Matt Raible <m...@raibledesigns.com>:
> > public class StartupListenerTest extends TestCase {
> >     private MockServletContext sc = null;
> >     private ServletContextListener listener = null;
> >     private ContextLoaderListener springListener = null;
> >
> >     protected void setUp() throws Exception {
> >         super.setUp();
> >         sc = new MockServletContext("");
> >         sc.addInitParameter(Constants.CSS_THEME, "simplicity");
> >
> >         // initialize Spring
> >         sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM,
> >                 "classpath:/applicationContext-dao.xml, " +
> >                 "classpath:/applicationContext-service.xml, " +
> >                 "classpath:/applicationContext-resources.xml");
> >
> >         springListener = new ContextLoaderListener();
> >         springListener.contextInitialized(new ServletContextEvent(sc));
> >         listener = new StartupListener();
> >     }
> >
> >     protected void tearDown() throws Exception {
> >         super.tearDown();
> >         springListener = null;
> >         listener = null;
> >         sc = null;
> >     }
> >
> >     public void testContextInitialized() {
> >         listener.contextInitialized(new ServletContextEvent(sc));
> >
> >         assertTrue(sc.getAttribute(Constants.CONFIG) != null);
> >         Map config = (Map) sc.getAttribute(Constants.CONFIG);
> >         assertEquals(config.get(Constants.CSS_THEME), "simplicity");
> >
> >         assertTrue(sc.getAttribute(WebApplicationContext
> >                 .ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE) != null);
> >         assertTrue(sc.getAttribute(Constants.AVAILABLE_ROLES) != null);
> >     }
> > }
> >
> >
> > On Wed, May 5, 2010 at 12:36 AM, Tony Luo <xiuxiu.luo.x...@gmail.com>
> wrote:
> >>
> >> Hi All,
> >>
> >> I need to put a list of object in memory when application start.
> >> The object is quite simple so I generate the service by Generic
> >> Manager and configured it in applicationContext.xml
> >>
> >> <bean id="personManager"
> >> class="org.appfuse.service.impl.GenericManagerImpl">
> >>    <constructor-arg>
> >>        <bean class="org.appfuse.dao.hibernate.GenericDaoHibernate"
> >> autowire="byType">
> >>            <constructor-arg
> >> value="org.appfuse.tutorial.model.Person"/>
> >>        </bean>
> >>    </constructor-arg>
> >> </bean>
> >>
> >> The cod in StartupListener is like the following code
> >>
> >> GenericManager<Person,Long> mgr = (GenericManager<Person,Long>)
> >> ctx.getBean("personManager");
> >>
> >> Unfortunately, It failed in the testing and the log says can't find
> >> this bean when do StartupListenerTest. What shall I do now?
> >>
> >> Regards
> >> Tony Luo
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscr...@appfuse.dev.java.net
> >> For additional commands, e-mail: users-h...@appfuse.dev.java.net
> >>
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@appfuse.dev.java.net
> For additional commands, e-mail: users-h...@appfuse.dev.java.net
>
>

Reply via email to