Skip to content

@Tested/@Injectable does not support custom annotations when also using standard DI annotations #124

@henryken

Description

@henryken

Hi,

When upgrading from v1.9 to v1.14, the @Injectable is not working for non-javax annotated field.
This issue seems have been found few months ago (http://stackoverflow.com/questions/26683962/why-is-there-a-npe-on-injectable-class)

In the code below, the "clock" can be injected properly.
However, trialReadyTemplate and trialReadyTimer are not injected.

I'm using TestNG and Java 8.
The current workaround is to use reflection at the beginning of the test method.

@Service
public class TrialServerServiceImpl implements TrialServerService {

    @Resource
    private Clock clock;

    @Produce(uri = "direct:trial-ready")
    private ProducerTemplate trialReadyTemplate;

    @Metric(name = "trial.ready")
    private Timer trialReadyTimer;
}



public class TrialServerServiceImplTest {

    @Tested
    private TrialServerServiceImpl trialServerService;

    @Injectable
    private Clock clock;

    @Injectable
    private ProducerTemplate trialReadyTemplate;

    @Injectable
    private Timer trialReadyTimer;
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions