8 Replies Latest reply on Oct 1, 2012 8:35 AM by tiagowanke

    @ShouldMatchDataSet before persist

    tiagowanke

      Hi,

       

      I have a test that persist a entity:

       

         

          @Test
          @ShouldMatchDataSet("anexo/dataset-salvar-anexo-expected.yml")
          public void salvar() throws BusinessException {
      
      
              Anexo anexo = TestUtils.criarAnexo();
              anexo.setIdAnexo(null);
              anexoCRUD.salvar(anexo);
              System.out.println("teste");
          }
      
      

       

      For some reason the @ShouldMatchDataSet it being executed before my anexoCRUD.salvar(anexo), than i get a Assertion error.

      Inside my anexoCRUD i have a em.persist(anexo).

      The only difference i see between this test from the others that i have (working) is that entity Anexo have a @Lob field.

        • 1. Re: @ShouldMatchDataSet before persist
          bmajsak

          Hi Tiago,

           

          that's quite interesting behaviour I must say. ShouldMatchDataSet comparision is always fired after the test (so after the transaction itself is either commited or rolled back). Could you please share assertion error message?

          • 2. Re: @ShouldMatchDataSet before persist
            tiagowanke

            Hey Bartosz Majsak,

             

            Tnks for answering.

             

            java.lang.AssertionError: Test failed in 1 cases.

            value (table=anexo, row=0, col=nome) expected:<arquivo[]> but was:<arquivo[                                                                                                                                                                                                 ]>

             

             

                      at org.jboss.arquillian.persistence.test.AssertionErrorCollector.report(AssertionErrorCollector.java:56)

                      at org.jboss.arquillian.persistence.lifecycle.ErrorCollectorHandler.collectErrors(ErrorCollectorHandler.java:47)

                      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.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)

                      at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

                      at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)

                      at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)

                      at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)

                      at org.jboss.arquillian.persistence.lifecycle.PersistenceTestTrigger.afterTest(PersistenceTestTrigger.java:100)

                      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.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)

                      at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)

                      at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)

                      at org.jboss.arquillian.testenricher.cdi.CreationalContextDestroyer.destory(CreationalContextDestroyer.java:44)

                      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.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)

                      at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

                      at org.jboss.arquillian.test.impl.TestContextHandler.createTestContext(TestContextHandler.java:89)

                      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.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)

                      at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

                      at org.jboss.arquillian.test.impl.TestContextHandler.createClassContext(TestContextHandler.java:75)

                      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.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)

                      at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

                      at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:60)

                      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.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)

                      at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

                      at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)

                      at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)

                      at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.after(EventTestRunnerAdaptor.java:103)

                      at org.jboss.arquillian.junit.Arquillian$5$1.evaluate(Arquillian.java:245)

                      at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:314)

                      at org.jboss.arquillian.junit.Arquillian.access$100(Arquillian.java:46)

                      at org.jboss.arquillian.junit.Arquillian$5.evaluate(Arquillian.java:240)

                      at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)

                      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)

                      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)

                      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)

                      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)

                      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)

                      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)

                      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)

                      at org.jboss.arquillian.junit.Arquillian$2.evaluate(Arquillian.java:185)

                      at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:314)

                      at org.jboss.arquillian.junit.Arquillian.access$100(Arquillian.java:46)

                      at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:199)

                      at org.junit.runners.ParentRunner.run(ParentRunner.java:300)

                      at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:147)

                      at org.junit.runner.JUnitCore.run(JUnitCore.java:157)

                      at org.junit.runner.JUnitCore.run(JUnitCore.java:136)

                      at org.jboss.arquillian.junit.container.JUnitTestRunner.execute(JUnitTestRunner.java:65)

                      at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.executeTest(ServletTestRunner.java:160)

                      at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.execute(ServletTestRunner.java:126)

                      at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.doGet(ServletTestRunner.java:90)

                      at javax.servlet.http.HttpServlet.service(HttpServlet.java:734)

                      at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

                      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)

                      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)

                      at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:67)

                      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)

                      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)

                      at org.jboss.solder.servlet.exception.CatchExceptionFilter.doFilter(CatchExceptionFilter.java:65)

                      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)

                      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)

                      at org.jboss.solder.servlet.event.ServletEventBridgeFilter.doFilter(ServletEventBridgeFilter.java:74)

                      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)

                      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)

                      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)

                      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)

                      at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:139)

                      at org.jboss.as.web.NamingValve.invoke(NamingValve.java:57)

                      at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:49)

                      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:154)

                      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

                      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

                      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362)

                      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)

                      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:667)

                      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:952)

                      at java.lang.Thread.run(Unknown Source)

             

            • 3. Re: @ShouldMatchDataSet before persist
              bmajsak

              Looks like a bug to me. Thx for reporting. Would you be so kind and open JIRA issue https://issues.jboss.org/browse/ARQ for it, provide some details about the environment (such as database and container) so I can start working on that? Please assign to me and pick "Extension - Persistence" as component.

               

              Many thanks!

              • 4. Re: @ShouldMatchDataSet before persist
                bmajsak

                I think your problem is not really with @ShouldMatchDataSet mechanics. It works as properly, but the problem is most likely how Hibernate is mapping @Lob fields for PostgreSQL.

                I tried to reproduce your problem and I'm able to persist the object, but comparison (using @ShouldMatchDataSet) is failing due to this very problem [I'm getting number from the db instead of text].

                 

                However if I try custom Hibernate mapping, as pointed out here I'm getting green bar.

                 

                Could you please try this approach and let me know if it helps you as well?

                • 5. Re: @ShouldMatchDataSet before persist
                  bmajsak

                  Hey,

                   

                  any update on this one?

                  • 6. Re: @ShouldMatchDataSet before persist
                    tiagowanke

                    Working now.

                    Tnks.

                    • 7. Re: @ShouldMatchDataSet before persist
                      bmajsak

                      Cool, so I can close the issue, right?

                      • 8. Re: @ShouldMatchDataSet before persist
                        tiagowanke

                        Yes.