I believe you can write a mock implementation of the Person bean and have a copy of applicationcontext.xml for your unit test that points to that mock implementation. What you'd need to do is provide an application context variable to the constructor of your action; in your production code, that app context will refer to your current applicationcontext.xml, and in your unit test, that context will refer to the mock applicationcontext.xml and will thus redirect the bean call.
Additionally, if you need to set the session object to use the action, you can use a mock session object that implements HttpSession for your unit tests, and provide a setter for the session field in the action. Hope this helps, Session > I think you have to ask the Spring forums. > > Antonio > > 2007/9/17, isharatbabu <[EMAIL PROTECTED]>: >> >> >> Hello all, >> >> I have created a java bean called person. i am accessing that java bean >> from applicationcontext.xml where bean scope is set as session. >> >> applicationcontext.xml >> >> >> <beans xmlns="http://www.springframework.org/schema/beans" >> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >> xmlns:aop="http://www.springframework.org/schema/aop" >> xsi:schemaLocation="http://www.springframework.org/schema/beans >> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd >> http://www.springframework.org/schema/aop >> http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"> >> >> <bean id="person1" class="org.apache.struts2.showcase.person.Person1" >> /> >> >> <!-- a simple session-scoped bean --> <bean id="person" >> class="org.apache.struts2.showcase.person.Person " scope="session"> >> <property name="person1" ref="person1" /> </bean> >> >> </beans> >> >> >> i am able to acess the "person" bean, set the bean values in session >> and remove them successfully. i got the object of the Person in my >> Action class as simply writing : >> >> Person person; >> >> >> i want to do the same in Junit test cases, without creating the new >> instance of the person.which i was able to do in actions. >> >> I want to know how to access the applicationcontext.xml attributes in >> Junit test cases with out application server running. >> >> Please respond soon. I have deadline for the project. thanks in >> anticipation. >> >> >> -- View this message in context: >> http://www.nabble.com/Struts-2-Unit-test-for-Session.-tf4465519.html#a1 >> 2732508 Sent from the Struts - User mailing list archive at Nabble.com. >> >> >> --------------------------------------------------------------------- To >> unsubscribe, e-mail: [EMAIL PROTECTED] For additional >> commands, e-mail: [EMAIL PROTECTED] >> >> > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]