Solucionado (ver solução)
Solucionado
(ver solução)
2
respostas

Erro ao executar teste no JUnit

O erro:

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@4133f274
    at org.jboss.weld.injection.producer.DefaultLifecycleCallbackInvoker.invokeMethods(DefaultLifecycleCallbackInvoker.java:100)
    at org.jboss.weld.injection.producer.DefaultLifecycleCallbackInvoker.postConstruct(DefaultLifecycleCallbackInvoker.java:81)
    at org.jboss.weld.injection.producer.BasicInjectionTarget.postConstruct(BasicInjectionTarget.java:126)
    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.ContextualInstanceStrategy$DefaultContextualInstanceStrategy.get(ContextualInstanceStrategy.java:101)
    at org.jboss.weld.bean.ContextualInstanceStrategy$ApplicationScopedContextualInstanceStrategy.get(ContextualInstanceStrategy.java:141)
    at org.jboss.weld.bean.ContextualInstance.get(ContextualInstance.java:50)
    at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:99)
    at org.jboss.weld.bean.proxy.ProxyMethodHandler.getInstance(ProxyMethodHandler.java:125)
    at br.com.caelum.vraptor.test.requestflow.VRaptorNavigation$Proxy$_$$_WeldClientProxy.setContainer(Unknown Source)
    at br.com.maxicredito.associado.controller.ControllerIntegration.navigate(ControllerIntegration.java:84)
    at br.com.maxicredito.associado.controller.ControllerIntegration.authenticate(ControllerIntegration.java:61)
    at br.com.maxicredito.associado.controller.PessoaControllerIntegationTest.testSituacao(PessoaControllerIntegationTest.java:17)
    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 org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner$ContainerAwareMethodInvoker.invokeMethod(CdiTestRunner.java:341)
    at org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner$ContainerAwareMethodInvoker.evaluate(CdiTestRunner.java:313)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner.runChild(CdiTestRunner.java:175)
    at org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner.runChild(CdiTestRunner.java:76)
    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.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner$BeforeClassStatement.evaluate(CdiTestRunner.java:367)
    at org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner$AfterClassStatement.evaluate(CdiTestRunner.java:393)
    at br.com.maxicredito.associado.LdapRule$1.evaluate(LdapRule.java:18)
    at org.junit.rules.RunRules.evaluate(RunRules.java:20)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner.run(CdiTestRunner.java:142)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
    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:678)
    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:498)
    at org.jboss.weld.injection.producer.DefaultLifecycleCallbackInvoker.invokeMethods(DefaultLifecycleCallbackInvoker.java:98)
    ... 45 more
Caused by: javax.enterprise.event.ObserverException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at java.lang.Class.newInstance(Class.java:442)
    at org.jboss.weld.security.NewInstanceAction.run(NewInstanceAction.java:33)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.jboss.weld.injection.Exceptions.rethrowException(Exceptions.java:40)
    at org.jboss.weld.injection.Exceptions.rethrowException(Exceptions.java:78)
    at org.jboss.weld.injection.StaticMethodInjectionPoint.invoke(StaticMethodInjectionPoint.java:96)
    at org.jboss.weld.injection.StaticMethodInjectionPoint.invoke(StaticMethodInjectionPoint.java:78)
    at org.jboss.weld.injection.MethodInvocationStrategy$SimpleMethodInvocationStrategy.invoke(MethodInvocationStrategy.java:129)
    at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:309)
    at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:287)
    at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:265)
    at org.jboss.weld.event.ObserverNotifier.notifySyncObservers(ObserverNotifier.java:271)
    at org.jboss.weld.event.ObserverNotifier.notify(ObserverNotifier.java:260)
    at org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:154)
    at org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:136)
    at org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:673)
    at org.jboss.weld.util.ForwardingBeanManager.fireEvent(ForwardingBeanManager.java:101)
    at br.com.caelum.vraptor.ioc.cdi.StereotypesRegistry.configure(StereotypesRegistry.java:54)
    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 org.jboss.weld.injection.StaticMethodInjectionPoint.invoke(StaticMethodInjectionPoint.java:88)
    at org.jboss.weld.injection.StaticMethodInjectionPoint.invoke(StaticMethodInjectionPoint.java:78)
    at org.jboss.weld.injection.MethodInvocationStrategy$SimpleMethodInvocationStrategy.invoke(MethodInvocationStrategy.java:129)
    at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:309)
    at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:287)
    at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:265)
    at org.jboss.weld.event.ObserverNotifier.notifySyncObservers(ObserverNotifier.java:271)
    at org.jboss.weld.event.ObserverNotifier.notify(ObserverNotifier.java:260)
    at org.jboss.weld.event.EventImpl.fire(EventImpl.java:89)
    at br.com.caelum.vraptor.VRaptor.init(VRaptor.java:94)
    at br.com.caelum.vraptor.test.requestflow.VRaptorNavigation.init(VRaptorNavigation.java:48)
    ... 50 more
Caused by: java.lang.AssertionError: Parameters aren't present for show. You must compile your code with -parameters argument.
    at br.eti.clairton.vraptor.crud.controller.ParanamerNameCrudProvider.checkIfNameIsPresent(ParanamerNameCrudProvider.java:80)
    at br.eti.clairton.vraptor.crud.controller.ParanamerNameCrudProvider.parametersFor(ParanamerNameCrudProvider.java:50)
    at br.eti.clairton.vraptor.crud.controller.ParanamerNameCrudProvider$Proxy$_$$_WeldClientProxy.parametersFor(Unknown Source)
    at br.com.caelum.vraptor.http.route.DefaultTypeFinder.getParameterTypes(DefaultTypeFinder.java:57)
    at br.com.caelum.vraptor.http.route.DefaultTypeFinder$Proxy$_$$_WeldClientProxy.getParameterTypes(Unknown Source)
    at br.com.caelum.vraptor.http.route.DefaultRouteBuilder.addParametersInfo(DefaultRouteBuilder.java:196)
    at br.com.caelum.vraptor.http.route.DefaultRouteBuilder.is(DefaultRouteBuilder.java:185)
    at br.com.caelum.vraptor.http.route.PathAnnotationRoutesParser.registerRulesFor(PathAnnotationRoutesParser.java:117)
    at br.com.caelum.vraptor.http.route.PathAnnotationRoutesParser.rulesFor(PathAnnotationRoutesParser.java:91)
    at br.eti.clairton.vraptor.crud.controller.PluralRoutesParser.rulesFor(PluralRoutesParser.java:44)
    at br.eti.clairton.vraptor.crud.controller.PluralRoutesParser$Proxy$_$$_WeldClientProxy.rulesFor(Unknown Source)
    at br.com.caelum.vraptor.ioc.ControllerHandler.handle(ControllerHandler.java:66)
    at sun.reflect.GeneratedMethodAccessor310.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.jboss.weld.injection.StaticMethodInjectionPoint.invoke(StaticMethodInjectionPoint.java:88)
    ... 77 more

O Codiogo:

package br.com.maxicredito.associado.controller;

import static br.com.caelum.vraptor.controller.HttpMethod.PUT;

import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.Test;
import org.junit.runner.RunWith;

import br.com.caelum.vraptor.test.VRaptorTestResult;
import br.com.caelum.vraptor.test.http.Parameters;

@RunWith(CdiTestRunner.class)
public class PessoaControllerIntegationTest  extends ControllerIntegration {

    @Test
    public void testSituacao() {
        authenticate("admin", "123456");
        final VRaptorTestResult result = navigate()
                                            .to("/pessoas/10011", PUT, new Parameters())
                                            .addHeader("Authorization", token())
                                            .addHeader("Content-Type", "application/json")
                                            .setContent("{pessoa:{id:10011,nome:'Abilio',tipo:'PESSOA',situacoes:[1003]}}")
                                            .execute();
        result.wasStatus(200);
    }
}
2 respostas
solução!

Opa, pode ser que o problema seja outro, mas o primeiro aí é que seu eclispe não ta compilando com a opção de manter o nome dos parâmetros. Em preferences, vai em java, compiler e deixa marcado a opção "store information about method parameters"

Resolveu miseravi, muito obrigado