0 Replies Latest reply on Apr 4, 2008 12:33 PM by jwi.jwi.informationsdesign.de

    SeamTest without commit

    jwi.jwi.informationsdesign.de

      After generating a project with seam-gen, a test runs with no exceptions and completes, but there are no database entries... it looks like there is no commit.
      Also, in the logged hibernate-SQL-statements there are no inserts/updates to be found.


      Any ideas ?


      here are the relevant files...


      ds.xml (for jboss-deployment)



      <?xml version="1.0" encoding="UTF-8"?>
      
      <!DOCTYPE datasources
          PUBLIC "-//JBoss//DTD JBOSS JCA Config 1.5//EN"
          "http://www.jboss.org/j2ee/dtd/jboss-ds_1_5.dtd">
          
      <datasources>
         
         <local-tx-datasource>
            <jndi-name>vcDatasource</jndi-name>
                  <connection-url>jdbc:oracle:thin:@someserver:1521:reposdb</connection-url>
            <driver-class>oracle.jdbc.OracleDriver</driver-class>
            <user-name>vctest</user-name>
            <password>pw</password>
         </local-tx-datasource>
          
      </datasources>
      




      persistence.xml


      <?xml version="1.0" encoding="UTF-8"?>
      <!-- Persistence deployment descriptor for tests -->
      <persistence xmlns="http://java.sun.com/xml/ns/persistence" 
                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                   xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" 
                   version="1.0">
                   
         <persistence-unit name="vc_seamtest">
            <provider>org.hibernate.ejb.HibernatePersistence</provider>
            <jta-data-source>java:/vcDatasource</jta-data-source>
            <properties>
               <property name="hibernate.hbm2ddl.auto" value="update"/>
               <property name="hibernate.show_sql" value="true"/>
               <property name="hibernate.cache.use_second_level_cache" value="false"/>
               <property name="jboss.entity.manager.factory.jndi.name" value="java:/vc_seamtestEntityManagerFactory"/>
            </properties>
         </persistence-unit>
          
      </persistence>
      




      components.xml


      <?xml version="1.0" encoding="UTF-8"?>
      <components xmlns="http://jboss.com/products/seam/components"
                  xmlns:core="http://jboss.com/products/seam/core"
                  xmlns:persistence="http://jboss.com/products/seam/persistence"
                  xmlns:drools="http://jboss.com/products/seam/drools"
                  xmlns:bpm="http://jboss.com/products/seam/bpm"
                  xmlns:security="http://jboss.com/products/seam/security"
                  xmlns:mail="http://jboss.com/products/seam/mail"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation=
                      "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.0.xsd 
                       http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.0.xsd 
                       http://jboss.com/products/seam/drools http://jboss.com/products/seam/drools-2.0.xsd
                       http://jboss.com/products/seam/bpm http://jboss.com/products/seam/bpm-2.0.xsd
                       http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.0.xsd
                       http://jboss.com/products/seam/mail http://jboss.com/products/seam/mail-2.0.xsd
                       http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.0.xsd">
      
         <core:init debug="@debug@" jndi-pattern="@jndiPattern@"/>
           
         <core:manager concurrent-request-timeout="500" 
                       conversation-timeout="120000" 
                       conversation-id-parameter="cid"/>
          
         <persistence:managed-persistence-context name="entityManager"
                                           auto-create="true"
                            persistence-unit-jndi-name="java:/vc_seamtestEntityManagerFactory"/>                          
      
         <drools:rule-base name="securityRules">
             <drools:rule-files>
                 <value>/security.drl</value>
             </drools:rule-files>
         </drools:rule-base>
      
         <security:identity security-rules="#{securityRules}" authenticate-method="#{authenticator.authenticate}" remember-me="true"/>
         
         <event type="org.jboss.seam.security.notLoggedIn">
             <action execute="#{redirect.captureCurrentView}"/>
         </event>
         <event type="org.jboss.seam.security.loginSuccessful">
             <action execute="#{redirect.returnToCapturedView}"/>
         </event>
         
         <mail:mail-session host="localhost" port="2525" username="test" password="test" />
              
         <!-- For use with jBPM pageflow or process management -->
         <!--  
         <bpm:jbpm>
            <bpm:process-definitions></bpm:process-definitions>
            <bpm:pageflow-definitions></bpm:pageflow-definitions>
         </bpm:jbpm>
         -->
            
      </components>
      




      Test.java



              @Test
              public void testImport_CJK() throws Exception
              {
      
                      new FacesRequest()
                      {
                              protected void invokeApplication()
                              {
                                      EntityManager em = (EntityManager) getValue("#{entityManager}");
                                      try
                                      {
                                              GesellschaftManager gm = new GesellschaftManager(em, engine, journalDataFactory);
                                              ImportManager im = new ImportManager(em, gm);
                                              im.importCJK();
                                      }
                                      catch (Throwable e)
                                      {
                                              e.printStackTrace();
                                              fail("exception occured");
                                      }
                              }
      
      
                      }.run();