Hello
I have a project with the following profile:
- Eclipse Moon
- Java 6
- JSF 2.2 / Primefaces 5.3
- JBoss 7
- Demoiselle 2.4.2.
The application already works, the problem is in the execution of JUnit 4.12 test cases . The test case shown below corresponds to invoking a managed bean method annotated with @ViewController
, that is, testing a backing bean of a page XHTML :
@RunWith(DemoiselleRunner.class)
public class CaixaAberturaTests {
@Inject
CaixaOperacaoEditMB caixaOperacao;
@Test
public void shouldConfirmarAberturaParaUsuarioLogado() {
// Arrange
caixaOperacao.setSaldoInicial(new BigDecimal(100.00));
// Act
String destino = caixaOperacao.confirmarAbertura();
// Assert
assertNotNull(destino);
}
}
When executed, the exception is thrown in the Arrange session line, which is nothing more than assigning a value to a property. The code for such a method is as follows:
public void setSaldoInicial(BigDecimal value) {
saldoInicial = value;
}
However, the method never gets executed, it is intercepted before, and in this process the exception is thrown, as stack :
java.lang.NullPointerException
at br.gov.frameworkdemoiselle.internal.context.FacesViewContextImpl.getSession(FacesViewContextImpl.java:143)
at br.gov.frameworkdemoiselle.internal.context.FacesViewContextImpl.getStore(FacesViewContextImpl.java:88)
at br.gov.frameworkdemoiselle.internal.context.AbstractCustomContext.get(AbstractCustomContext.java:92)
at br.gov.frameworkdemoiselle.internal.context.AbstractCustomContext.get(AbstractCustomContext.java:79)
at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:73)
at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:79)
at br.ufpr.restaurante.view.CaixaOperacaoEditMB$Proxy$_$$_WeldClientProxy.setSaldoInicial(CaixaOperacaoEditMB$Proxy$_$$_WeldClientProxy.java)
at br.ufpr.restaurante.view.tests.CaixaAberturaTests.shouldConfirmarAberturaParaUsuarioLogado(CaixaAberturaTests.java:38)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
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.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at br.gov.frameworkdemoiselle.junit.DemoiselleRunner.runChild(DemoiselleRunner.java:60)
at br.gov.frameworkdemoiselle.junit.DemoiselleRunner.runChild(DemoiselleRunner.java:49)
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.junit.runners.ParentRunner.run(ParentRunner.java:363)
at br.gov.frameworkdemoiselle.junit.DemoiselleRunner.run(DemoiselleRunner.java:73)
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)
I would like some tips to solve the case.
Thank you in advance!