I have tapestry-spring in my pom.xml and TapestrySpringFilter in my web.xml,
but neither of those helps me with testing. The following test:

    @Test
    public void testListUsers() {
        String appPackage = "org.appfuse.web";
        String appName = "App";
        PageTester tester = new PageTester(appPackage, appName,
"src/main/webapp");
        Document doc = tester.renderPage("UserList");
        assertNotNull(doc.getElementById("userList"));
    }

Results in the following error:

Caused by: java.lang.RuntimeException: Error obtaining injected value for
field org.appfuse.web.pages.UserList.userManager: No service implements the
interface org.appfuse.service.UserManager.
        at
org.apache.tapestry5.internal.transform.InjectWorker.transform(InjectWorker.java:68)
        at
$ComponentClassTransformWorker_11e45efc856.transform($ComponentClassTransformWorker_11e45efc856.java)
        at
$ComponentClassTransformWorker_11e45efc84c.transform($ComponentClassTransformWorker_11e45efc84c.java)
        at
org.apache.tapestry5.internal.services.ComponentClassTransformerImpl.transformComponentClass(ComponentClassTransformerImpl.java:170)
        ... 53 more

I was able to get it working by creating a
src/test/**/services/SpringObjectProvider and
src/test/**/services/TestModule. Is that the easiest way to populate @Inject
dependencies from Spring when testing?

If so, is it possible to get beans (or the ApplicationContext) in a test
from the SpringObjectProvider? 

Also, I'd be interested in seeing an example where EasyMock or jMock is used
to create the objects and set expectations.

Thanks,

Matt


Olle Hallin wrote:
> 
> Is there a problem using tapestry-spring.jar?
> 
> Olle
> 
> 2008/12/17 mraible <m...@raibledesigns.com>
> 
>>
>> Is the following still the best way to inject Spring beans into a page
>> when
>> testing?
>>
>> http://wiki.apache.org/tapestry/Tapestry5SpringIntegrationAlternative1
>>
>> With Tapestry 4, I could populate a Map with with the bean name and a
>> real
>> (or mock) implementation and instantiate the page, then call methods
>> accordingly. Is this possible with Tapestry 5 w/o creating a lot of
>> infrastructure code (which the above seems to require)?
>>
>> Thanks,
>>
>> Matt
>> --
>> View this message in context:
>> http://www.nabble.com/-T5--Testing-Pages-with-injected-Spring-beans-tp21057429p21057429.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
>>
>>
> 
> 
> -- 
> Olle Hallin
> Senior Java Developer and Architect
> olle.hal...@crisp.se
> www.crisp.se
> 
> 

-- 
View this message in context: 
http://www.nabble.com/-T5--Testing-Pages-with-injected-Spring-beans-tp21057429p21058304.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

Reply via email to