On Thursday 23 August 2012 14:33:14 Davis, Chad wrote: > > <bean id="MockedService" name="MockedService" > > class="org.easymock.EasyMock" > > factory-method="createStrictMock"> > > > > <constructor-arg value="Interface.for.the.Service"/> > > > > </bean> > > How do you control the correct injections for the various deployments? Do > you automate that with the build? Scripted?
I use these in junit tests. I don't know if this is what you want to do the following is just codesnipplets hoping they are enough to show you how I use easymock with spring. But I guess I missed the part in your original message that you want to do UI testing. The unit test class: import static org.easymock.EasyMock.expect; import static org.easymock.EasyMock.replay; import static org.junit.Assert.assertEquals; //more imports @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = {"applicationContextForThisUnitTest.xml"}) public class Tests extends StrutsSpringJUnit4TestCase<TheActionClassToTest> { @Autowired private interface.for.the.service serviceWeNeed @Before public void setup(){ ObjectFromService ofs = new ObjectFromService expect(serviceWeNeed.methodeCalled).andReturn(ofs); replay(serviceWeNeed); } @Test public void test1() throws IOException, InteractionPackageUpdateExecption { ActionProxy proxy = getActionProxy("/path/to/action.action"); TheActionToTest action = (TheActionToTest) proxy.getAction(); proxy.setExecuteResult(false); try { assertEquals("ExecutionCode", "input", proxy.execute()); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } About using this method in UI test I'm not so sure. In our project I just wrote a second set of services return static data as need. Depending on the maven profile getting used for the build, either the real services or just the dummys get include. Maybe this approache also works for you. Regards, Pascal --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org