Galera, bom dia!
Estou tentando utilizar o seguinte plugin do VRaptor para a realização de testes de integração (VRaptor-Test).
Mas ainda não entendi muito bem como devo usá-lo. Gostaria de realizar testes iguais aos que estão sendo apresentados na documentação dele, ou seja, chamar alguma URI e ter como retorno um objeto onde eu possa validar os campos que foram devolvidos pelos includes do meu Controller. Esses testes devem chamar também os DAO’s e devolver as respectivas respostas.
O que é preciso fazer para realizar testes de integração com esse plugin?
Preciso subir algum servidor para conseguir executá-lo?
Os testes podem ser executados pelo Eclipse?
Como faria para rodá-los pelo Maven?
Eu tentei rodar um teste, tanto pelo Eclipse quanto pelo Maven, e obtive a seguinte Exception:
org.jboss.weld.exceptions.WeldException: WELD-000049: Unable to invoke public void br.com.caelum.vraptor.test.requestflow.VRaptorNavigation.init() throws javax.servlet.ServletException on br.com.caelum.vraptor.test.requestflow.VRaptorNavigation@3d9c13b5
at org.jboss.weld.injection.producer.DefaultLifecycleCallbackInvoker.invokeMethods(DefaultLifecycleCallbackInvoker.java:91)
at org.jboss.weld.injection.producer.DefaultLifecycleCallbackInvoker.postConstruct(DefaultLifecycleCallbackInvoker.java:72)
at org.jboss.weld.injection.producer.BasicInjectionTarget.postConstruct(BasicInjectionTarget.java:95)
at org.jboss.weld.injection.producer.BeanInjectionTarget.postConstruct(BeanInjectionTarget.java:63)
at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:162)
at org.jboss.weld.context.AbstractContext.get(AbstractContext.java:96)
at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:98)
at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:78)
at br.com.caelum.vraptor.test.requestflow.VRaptorNavigation$Proxy$_$$_WeldClientProxy.setContainer(Unknown Source)
at br.com.caelum.vraptor.test.VRaptorIntegration.navigate(VRaptorIntegration.java:32)
at br.com.gkarian.imovelcerto.guest.imovel.listorder.ImovelTest.index(ImovelTest.java:15)
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:483)
at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
at org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)
at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:87)
at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
at org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:88)
at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: java.lang.reflect.InvocationTargetException
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:483)
at org.jboss.weld.injection.producer.DefaultLifecycleCallbackInvoker.invokeMethods(DefaultLifecycleCallbackInvoker.java:89)
... 32 more
Caused by: javax.servlet.ServletException: VRaptor only runs under Java EE 7 environment or Servlet Containers that supports Servlets 3 with CDI 1.1 jars.
at br.com.caelum.vraptor.VRaptor.validateJavaEE7Environment(VRaptor.java:170)
at br.com.caelum.vraptor.VRaptor.init(VRaptor.java:90)
at br.com.caelum.vraptor.test.requestflow.VRaptorNavigation.init(VRaptorNavigation.java:52)
... 37 more