I'm running into trouble with using services declared inside of a Testify TestNG test case with @ForComponents into my pages - when I ask the tester to render a page, the services that were supposed to be injected, are null. Any tips on what I'm doing wrong ?
Here is the sample code: public class StupidPageTest extends AbstractZdTapTest { @ForComponents private UserRepository userRepo; @Override protected void doSetUp() { userRepo = EasyMock.createMock(UserRepository.class); } @Test public void testElementIsOnPage() throws Exception { expect(userRepo.userRegistered((EmailAddress)anyObject())).andStubReturn(Boolean.FALSE); ZdUser testUser = new ZdUser(new EmailAddress("f...@bar.com"));; expect(userRepo.registerUser(isA(UserRegistration.class))).andStubReturn(testUser); replay(userRepo); Document page = tester.renderPage("stupid"); System.out.println("Rendered page: " + page.toString()); } } public abstract class AbstractZdTapTest extends TapestryTest { private static final TapestryTester SHARED_TESTER = new TapestryTester("com.troymaxventures.zadachite", ZdTestAppModule.class,AppModule.class); public AbstractZdTapTest() { super(SHARED_TESTER); } } public abstract class AbstractZdTapTest extends TapestryTest { private static final TapestryTester SHARED_TESTER = new TapestryTester("com.troymaxventures.zadachite", ZdTestAppModule.class); public AbstractZdTapTest() { super(SHARED_TESTER); } } public class ZdTestAppModule { /** * Ensure that there are valid HTTP request/response objects in the test, otherwise the ACEGI integration tends to blow up. */ public static void contributeRequestHandler(OrderedConfiguration<RequestFilter> config, final RequestGlobals requestGlobals) { RequestFilter filter = new RequestFilter() { @Override public boolean service(Request request, Response response, RequestHandler handler) throws IOException { requestGlobals.storeServletRequestResponse(EasyMock.createMock(HttpServletRequest.class), EasyMock.createMock(HttpServletResponse.class)); return handler.service(request, response); } }; config.add("EnsureNonNullHttpRequestAndResponse", filter, "before:*"); } } public class Stupid { @Inject private UserRepository userRepo; void setupRender() throws StorageException { // the userRepo is null here during the test userRepo.getUser(new EmailAddress("f...@bar.com")); } } -- View this message in context: http://old.nabble.com/TestNG---Injecting-Testify-services-into-pages-tp27370621p27370621.html Sent from the Tapestry - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org