BrynCooke/cdi-unit — Issue #4: CdiRunner and @Named annotation
Author: uvula
Created: 2011-11-25 10:11:42+00:00
State: open

Hi,
I have another question. I'm beginning to use CDI with Java SE.
I have made a small test project (eclipse+maven+cdirunner).
I never read the CDI spec and I don't want to start a discussion
about Qualifier here.
I only tried to use the @Named annotation which I have seen
in other examples in the internet.

I have a:
- Interface Node
- Class RealNode
- A factory creating RealNodes named "rnode"
- Class JunitNode for testing
- A factory creating JunitNodes named "junit".

A Main call:
@Inject
@Named("jnode")
//@Named("rnode")
private Node node;

If I use the @Named in Main, I can toggle which factory is used.

In the JUnit test, I used the injection:
@Inject
@Named("jnode")
private Node node;

And it doesn't work, because I think the @Named "tag" is not considered.
Or must I used the CdiRunner in another way?

If I can attach a zip file, I will upload it, or send it be email to my last contact with you.

Uwe / Germany