Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
tags editadas
Link
Maniero
  • 484,4mil
  • 94
  • 1,3mil
  • 2,2mil
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Tweeted twitter.com/#!/StackOverflowPT/status/570504234132774913
adicionou 376 caracteres ao conteúdo
Fonte Link

O teste basicamente faz acesso ao banco de dados para ler os dados de uma tabela, e fazer inserção em outra. Esqueci de dizer mas estou utilizando JPA e Hibernate na aplicação na parte de acesso a dados. E no caso dos testes estou utilizando também DbUnit e o banco HSQLDB em memória. Durante os testes faço uso do CDI para injetar (@Inject) o EntityManager e um DAO.

Obrigado.

Obrigado.

O teste basicamente faz acesso ao banco de dados para ler os dados de uma tabela, e fazer inserção em outra. Esqueci de dizer mas estou utilizando JPA e Hibernate na aplicação na parte de acesso a dados. E no caso dos testes estou utilizando também DbUnit e o banco HSQLDB em memória. Durante os testes faço uso do CDI para injetar (@Inject) o EntityManager e um DAO.

Obrigado.

Formatação
Fonte Link
Victor Stafusa
  • 64,9mil
  • 9
  • 120
  • 189

Demoiselle JUnit - Nullpointer ExceptionNullPointerException

Ao executar um teste de unidade com: br.gov.frameworkdemoiselle.junit.DemoiselleRunner

Estábr.gov.frameworkdemoiselle.junit.DemoiselleRunner, está acontecendo o seguinte erro no final da execução do teste:

java.lang.NullPointerException

at br.gov.frameworkdemoiselle.internal.bootstrap.SeBootstrap.removeContexts(SeBootstrap.java:70)
at br.gov.frameworkdemoiselle.internal.bootstrap.SeBootstrap$Proxy$_$$_WeldClientProxy.removeContexts(SeBootstrap$Proxy$_$$_WeldClientProxy.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:267)
at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52)
at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:137)
at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:263)
at org.jboss.weld.introspector.jlr.WeldMethodImpl.invokeOnInstance(WeldMethodImpl.java:164)
at org.jboss.weld.introspector.ForwardingWeldMethod.invokeOnInstance(ForwardingWeldMethod.java:51)
at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:154)
at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:245)
at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:233)
at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:213)
at org.jboss.weld.event.ObserverNotifier.notifyObserver(ObserverNotifier.java:117)
at org.jboss.weld.event.ObserverNotifier.notifyObservers(ObserverNotifier.java:85)
at org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:75)
at org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:70)
at org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:580)
at br.gov.frameworkdemoiselle.junit.DemoiselleRunner.shutdown(DemoiselleRunner.java:88)
at br.gov.frameworkdemoiselle.junit.DemoiselleRunner.runChild(DemoiselleRunner.java:63)
at br.gov.frameworkdemoiselle.junit.DemoiselleRunner.runChild(DemoiselleRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
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)
java.lang.NullPointerException
    at br.gov.frameworkdemoiselle.internal.bootstrap.SeBootstrap.removeContexts(SeBootstrap.java:70)
    at br.gov.frameworkdemoiselle.internal.bootstrap.SeBootstrap$Proxy$_$$_WeldClientProxy.removeContexts(SeBootstrap$Proxy$_$$_WeldClientProxy.java)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:267)
    at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52)
    at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:137)
    at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:263)
    at org.jboss.weld.introspector.jlr.WeldMethodImpl.invokeOnInstance(WeldMethodImpl.java:164)
    at org.jboss.weld.introspector.ForwardingWeldMethod.invokeOnInstance(ForwardingWeldMethod.java:51)
    at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:154)
    at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:245)
    at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:233)
    at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:213)
    at org.jboss.weld.event.ObserverNotifier.notifyObserver(ObserverNotifier.java:117)
    at org.jboss.weld.event.ObserverNotifier.notifyObservers(ObserverNotifier.java:85)
    at org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:75)
    at org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:70)
    at org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:580)
    at br.gov.frameworkdemoiselle.junit.DemoiselleRunner.shutdown(DemoiselleRunner.java:88)
    at br.gov.frameworkdemoiselle.junit.DemoiselleRunner.runChild(DemoiselleRunner.java:63)
    at br.gov.frameworkdemoiselle.junit.DemoiselleRunner.runChild(DemoiselleRunner.java:49)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
    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)

Trata-se de um módulo da aplicação que roda como um serviço. Ou seja, não roda em nenhum servidor de aplicação. O objetivo de rodar os testes com o DemoiselleRunnerDemoiselleRunner é para habilitar o CDI.

        <dependency>
            <groupId>br.gov.frameworkdemoiselle.component</groupId>
            <artifactId>demoiselle-junit</artifactId>
            <version>2.3.1</version>
        </dependency>

        <dependency>
            <groupId>br.gov.frameworkdemoiselle</groupId>
            <artifactId>demoiselle-core</artifactId>
            <version>2.4.1</version>
        </dependency>

        <dependency>
            <groupId>br.gov.frameworkdemoiselle</groupId>
            <artifactId>demoiselle-jpa</artifactId>
            <version>2.4.1</version>
        </dependency>
        <dependency>
            <groupId>br.gov.frameworkdemoiselle.component</groupId>
            <artifactId>demoiselle-junit</artifactId>
            <version>2.3.1</version>
        </dependency>

        <dependency>
            <groupId>br.gov.frameworkdemoiselle</groupId>
            <artifactId>demoiselle-core</artifactId>
            <version>2.4.1</version>
        </dependency>

        <dependency>
            <groupId>br.gov.frameworkdemoiselle</groupId>
            <artifactId>demoiselle-jpa</artifactId>
            <version>2.4.1</version>
        </dependency>

Demoiselle JUnit - Nullpointer Exception

Ao executar um teste de unidade com: br.gov.frameworkdemoiselle.junit.DemoiselleRunner

Está acontecendo o seguinte erro no final da execução do teste:

java.lang.NullPointerException

at br.gov.frameworkdemoiselle.internal.bootstrap.SeBootstrap.removeContexts(SeBootstrap.java:70)
at br.gov.frameworkdemoiselle.internal.bootstrap.SeBootstrap$Proxy$_$$_WeldClientProxy.removeContexts(SeBootstrap$Proxy$_$$_WeldClientProxy.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:267)
at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52)
at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:137)
at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:263)
at org.jboss.weld.introspector.jlr.WeldMethodImpl.invokeOnInstance(WeldMethodImpl.java:164)
at org.jboss.weld.introspector.ForwardingWeldMethod.invokeOnInstance(ForwardingWeldMethod.java:51)
at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:154)
at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:245)
at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:233)
at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:213)
at org.jboss.weld.event.ObserverNotifier.notifyObserver(ObserverNotifier.java:117)
at org.jboss.weld.event.ObserverNotifier.notifyObservers(ObserverNotifier.java:85)
at org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:75)
at org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:70)
at org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:580)
at br.gov.frameworkdemoiselle.junit.DemoiselleRunner.shutdown(DemoiselleRunner.java:88)
at br.gov.frameworkdemoiselle.junit.DemoiselleRunner.runChild(DemoiselleRunner.java:63)
at br.gov.frameworkdemoiselle.junit.DemoiselleRunner.runChild(DemoiselleRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
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)

Trata-se de um módulo da aplicação que roda como um serviço. Ou seja, não roda em nenhum servidor de aplicação. O objetivo de rodar os testes com o DemoiselleRunner é para habilitar o CDI.

        <dependency>
            <groupId>br.gov.frameworkdemoiselle.component</groupId>
            <artifactId>demoiselle-junit</artifactId>
            <version>2.3.1</version>
        </dependency>

        <dependency>
            <groupId>br.gov.frameworkdemoiselle</groupId>
            <artifactId>demoiselle-core</artifactId>
            <version>2.4.1</version>
        </dependency>

        <dependency>
            <groupId>br.gov.frameworkdemoiselle</groupId>
            <artifactId>demoiselle-jpa</artifactId>
            <version>2.4.1</version>
        </dependency>

Demoiselle JUnit - NullPointerException

Ao executar um teste de unidade com br.gov.frameworkdemoiselle.junit.DemoiselleRunner, está acontecendo o seguinte erro no final da execução do teste:

java.lang.NullPointerException
    at br.gov.frameworkdemoiselle.internal.bootstrap.SeBootstrap.removeContexts(SeBootstrap.java:70)
    at br.gov.frameworkdemoiselle.internal.bootstrap.SeBootstrap$Proxy$_$$_WeldClientProxy.removeContexts(SeBootstrap$Proxy$_$$_WeldClientProxy.java)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:267)
    at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52)
    at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:137)
    at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:263)
    at org.jboss.weld.introspector.jlr.WeldMethodImpl.invokeOnInstance(WeldMethodImpl.java:164)
    at org.jboss.weld.introspector.ForwardingWeldMethod.invokeOnInstance(ForwardingWeldMethod.java:51)
    at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:154)
    at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:245)
    at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:233)
    at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:213)
    at org.jboss.weld.event.ObserverNotifier.notifyObserver(ObserverNotifier.java:117)
    at org.jboss.weld.event.ObserverNotifier.notifyObservers(ObserverNotifier.java:85)
    at org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:75)
    at org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:70)
    at org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:580)
    at br.gov.frameworkdemoiselle.junit.DemoiselleRunner.shutdown(DemoiselleRunner.java:88)
    at br.gov.frameworkdemoiselle.junit.DemoiselleRunner.runChild(DemoiselleRunner.java:63)
    at br.gov.frameworkdemoiselle.junit.DemoiselleRunner.runChild(DemoiselleRunner.java:49)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
    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)

Trata-se de um módulo da aplicação que roda como um serviço. Ou seja, não roda em nenhum servidor de aplicação. O objetivo de rodar os testes com o DemoiselleRunner é para habilitar o CDI.

        <dependency>
            <groupId>br.gov.frameworkdemoiselle.component</groupId>
            <artifactId>demoiselle-junit</artifactId>
            <version>2.3.1</version>
        </dependency>

        <dependency>
            <groupId>br.gov.frameworkdemoiselle</groupId>
            <artifactId>demoiselle-core</artifactId>
            <version>2.4.1</version>
        </dependency>

        <dependency>
            <groupId>br.gov.frameworkdemoiselle</groupId>
            <artifactId>demoiselle-jpa</artifactId>
            <version>2.4.1</version>
        </dependency>
Fonte Link
Carregando