Hi Mats,
> I then have a subclass with the JUnit 4 test:
>
> public class GamesLauncherTest extends AbstractPageTest {
>
> @ForComponents @Mock
> private XyzManager xyzManager;
>
> @Mock
> private XyzConfig xyzConfig;
>
>
> What I get is runtime exceptions, such as this:
>
> Caused by: java.lang.RuntimeException: Service id 'xyzConfig' is
> not defined by any module. Defined services: AccessDecisionManager,
> ... VirtualAssetStreamer.
Something is trying to look up a service with id "xyzConfig" - using that
id. I assume you have something like this in your page:
@Inject
@Service("xyzConfig")
private XyzConfig config;
If that's true then it might simply be that you haven't got a
@ForComponents annotation on your xyzConfig mock. Also, if you name the
service (using the @Service annotation) then you need to name it in the
@ForComponents too:
public class GamesLauncherTest extends AbstractPageTest {
@ForComponents @Mock
private XyzManager xyzManager;
@ForComponents("xyzConfig") @Mock
private XyzConfig xyzConfig;
> We define our services in spring XML files, and @Inject them into our
> pages, and this worries me quite a bit, since I can't see any examples
> where Spring XML wiring has been mocked.
If you are faking/mocking the services then there's no problem. However,
Testify and Tapestry's PageTester don't work with the tapestry-spring
integration so you can't rely on the real spring services for (for
example) integration tests.
- Paul
---
This e-mail may contain confidential and/or privileged information. If you are
not the intended recipient (or have received this e-mail in error) please
notify the sender immediately and delete this e-mail. Any unauthorized copying,
disclosure or distribution of the material in this e-mail is strictly forbidden.
Please refer to http://www.db.com/en/content/eu_disclosures.htm for additional
EU corporate and regulatory disclosures.