Paul, things are working again , thanks for your help. Where I was running into trouble was that looking at the debugger, the field shows up as null up until the point the field is accessed for the first time (at which point the whole lookup of the injected field seems to occur). So, in the debugger the field was showing as null, and then the page render was failing for other reasons (e.g. for a while, incorrectly set up mocks, at other times, I was missing the .tml in the right package), but it was harder to see as the stacktrace only shows up in the rendered page (on which I was asserting). The next thing I'm trying to work out is use Testify for unit-like testing. The idea was that I could possibly instantiate the page class myself (e.g. w/o having to ask the tester to render the page), inject the dependencies (using tester.injectInto(pageInstance) ) that are needed for a particular method and then just invoke the method. I do see the SimpleObjectsForComponentStore.put(..) being called in the set up phase before the test case executes. However, using this approach, when I call tester.injectInto(page) the SimpleObjectsForComponentStore.get(..) is never called and as a result the test fails w/ a message that "No service implement the interface...". Can this be made to work in some way using Testify ?
testStupidPageUnitTest(com.troymaxventures.zadachite.pagetests.StupidPageTest) Time elapsed: 136.47 sec <<< FAILURE! java.lang.RuntimeException: No service implements the interface com.troymaxventures.zadachite.services.UserRepository. at org.apache.tapestry5.ioc.internal.RegistryImpl.getService(RegistryImpl.java:575) at org.apache.tapestry5.ioc.internal.RegistryWrapper.getService(RegistryWrapper.java:58) at org.apache.tapestry5.test.PageTester.getService(PageTester.java:154) at com.formos.tapestry.testify.core.TapestryTester$FieldInjector.process(TapestryTester.java:125) at com.formos.tapestry.testify.core.TapestryTester.processField(TapestryTester.java:106) at com.formos.tapestry.testify.core.TapestryTester.processFieldsAnnotatedWith(TapestryTester.java:96) at com.formos.tapestry.testify.core.TapestryTester.injectInto(TapestryTester.java:74) at com.troymaxventures.zadachite.pagetests.StupidPageTest.testStupidPageUnitTest(StupidPageTest.java:54) Here's the test case: public class StupidPageTest extends AbstractZdTapTest { @ForComponents UserRepository userRepo; @Override protected void doSetUp() { userRepo = EasyMock.createNiceMock(UserRepository.class); System.out.println("The doSetUp() is called by TestNG"); } @Test public void testElementIsOnPage() throws Exception { ZdUser testUser = new ZdUser(new EmailAddress("f...@bar.com")); expect(userRepo.getUser(isA(EmailAddress.class))).andStubReturn(testUser); replay(userRepo); Document page = tester.renderPage("stupid"); System.out.println("Page is : " + page.toString()); Assert.assertTrue(page.toString().contains("I should be empty")); } @Test public void testStupidPageUnitTest() throws Exception { ZdUser testUser = new ZdUser(new EmailAddress("f...@bar.com")); expect(userRepo.getUser(isA(EmailAddress.class))).andStubReturn(testUser); replay(userRepo); Stupid s = new Stupid(); tester.injectInto(s); s.setupRender(); } } -- View this message in context: http://old.nabble.com/TestNG---Injecting-Testify-services-into-pages-tp27370621p27391903.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