0
Hello.
I am working on a Ws Rest with CDI and Jersey. I want to create a test unit with Junit and due to CDI ended up using the CDI-Unit Runner. I found CDI-Unit simpler than Weldjunit4runner.
Now, I need to add the Jersey Test Framework to perform the testing of some features that will be consumed. But I’m not sure how to integrate the Jersey Test Framework into the CDI-Unit.
I have the following exception when running any test:
org.jboss.weld.exceptions.UnproxyableResolutionException: WELD-001437: Normal scoped bean class rest.resource.ContactResourceTest is not proxyable because the type is final or it contains a final method public final javax.ws.rs.client. WebTarget org.glassfish.jersey.test.JerseyTest.target() - unknown javax.enterprise.inject.spi.Bean instance. at org.jboss.weld.util.Proxies.getUnproxyableClassException(Proxies.java:214) at org.jboss.weld.util.Proxies.getUnproxyableTypeException(Proxies.java:178) at org.jboss.weld.util.Proxies.getUnproxyableTypeException(Proxies.java:140) at org.jboss.weld.bean.proxy.ClientProxyProvider.getClientProxy(ClientProxyProvider.java:231) at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:736) at org.jboss.weld.bean.builtin.InstanceImpl.getBeanInstance(InstanceImpl.java:179) at org.jboss.weld.bean.builtin.InstanceImpl.get(InstanceImpl.java:99) at org.jglue.cdiunit.CdiRunner.createTest(CdiRunner.java:156) at org.jglue.cdiunit.CdiRunner.createTest(CdiRunner.java:138) at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:266) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:263) at org.jglue.cdiunit.CdiRunner.methodBlock(CdiRunner.java:164) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68) at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:237) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Is it possible to integrate them? I haven’t even found an example about these two guys working together. By the way, I need CDI for testing because some resource classes have the @Inject annotation for injection services.
@RunWith(CdiRunner.class)
@AdditionalClasses({LoggerProducerUtil.class})
@ActivatedAlternatives(JPATest.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class ContactResourceTest extends JerseyTest {
@Inject
private AuthenticationService service;
private Client client;
@Override
protected Application configure() {
return new ResourceConfig(
ContactResource.class);
}
// @Test omitidos
}