0

I'm using JBosss EAP 7. To avoid long turnaround cycles it would be nice to test WebService consumer directly without starting the Appserver. For this purpose we are working with DeltaSpike and Mockito. Besides this our application is based on an internal Framework, which generates Consumer classes like XyConsumer.

I'm wondering if there is a way to inject resources with @Resource into a class, which is instantiated by DeltaSpike? As far as I understand DeltaSpike is a CDI container, but @Resource injects resources from underlying Web- or EJB-container. In my case I have following scenario:

class TestDAO {
  @Inject
  XyConsumer consumer;
  assertNotNull(consumer.getEntity());
}

class XyConsumer {
  @Resource(name="jndipath")
  resource;
  public Object getEntity(){
    String wsEndpoint = resource.get("endpoint");
    this.callWebService(..., wsEndpoint);
  }
}

Thanks in advance!

  • If I understand you correctly, you use DeltaSpike to test our app without starting server (e.g. DeltaSpike bootstraps Weld SE). If that's the case then you cannot use `@Resource` because that's EJB annotation and you have no EJB container started. – Siliarus Mar 22 '18 at 08:26
  • Actually, come to think of it, you could probably use [weld-junit](https://github.com/weld/weld-junit). Glance at the README files (under either JUnit 4 or 5), it should do what you are after + **allows you to mock `@Resource` injection points**. – Siliarus Mar 22 '18 at 08:28

0 Answers0