2 Replies Latest reply on Jun 18, 2009 11:31 PM by wujekleon

    Changing Test DataSource

    jyelloz

      Hello.  I've been working to set up test cases for an existing Seam data model.  I'm using Seam 2.0.1 and the latest of the Java 1.5 jdks.  I set up Eclipse for TestNG and when I run tests, I get the following:

      FAILED CONFIGURATION: @BeforeClass init
      org.jboss.deployers.client.spi.IncompleteDeploymentException: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS):
      
      *** CONTEXTS IN ERROR: Name -> Error
      
      persistence.units:unitName=FakePersistenceUnitName -> java.lang.AssertionError
      
      
           at org.jboss.deployers.plugins.deployers.DeployersImpl.checkComplete(DeployersImpl.java:576)
           at org.jboss.deployers.plugins.main.MainDeployerImpl.checkComplete(MainDeployerImpl.java:559)
           at org.jboss.embedded.DeploymentGroup.process(DeploymentGroup.java:128)
           at org.jboss.embedded.Bootstrap.deployResourceBases(Bootstrap.java:289)
           at org.jboss.seam.mock.EmbeddedBootstrap.startAndDeployResources(EmbeddedBootstrap.java:15)
           at org.jboss.seam.mock.BaseSeamTest.startJbossEmbeddedIfNecessary(BaseSeamTest.java:1041)
           at org.jboss.seam.mock.BaseSeamTest.startSeam(BaseSeamTest.java:935)
           at org.jboss.seam.mock.BaseSeamTest.init(BaseSeamTest.java:923)
           at org.jboss.seam.mock.SeamTest.init(SeamTest.java:42)
      ... Removed 22 stack frames


      I'm guessing that the data model is somehow incompatible with Hypersonic SQL because I don't get this problem when I deploy the project onto JBoss Application Server with a MySQL InnoDB data source.  If I comment out the persistence-unit in persistence-test.xml I don't get this error and basic tests such as assert 2 == 2; will pass.
      Does anybody know if I am right about this?  If I am, does anybody know if/how I can switch the TestNG/jboss embedded environment to use a MySQL data source?  I've tried various things that seemed appropriate for this outcome but have not had any success.

        • 1. Re: Changing Test DataSource
          thejavafreak

          Show us your persistence.xml here

          • 2. Re: Changing Test DataSource

            Hello


            I am facing a similar problem I am using Seam 2.1.1GA. I want to use a different database for testing. I have tried various locations and configurations, but didn't succeed.


            Steps that i have taken:




            1. I have created a Seam project useing JBoss Seam tools (EAR with Test project)




            1. I hava generated a entities useing Seam Generate Entities




            1. I have taken a glance in Seam tutorail and it said:




            By default, a generated project will use the java:/DefaultDS (a built in HSQL datasource in Embedded JBoss) for testing. If you want to use another datasource place the foo-ds.xml into bootstrap/deploy directory.

            So I have moved to bootstrap/deploy following file:


            test-src/META-INF/forms-test-ds.xml


            <datasources>
               
               <local-tx-datasource>
                  <jndi-name>formsDatasourceTest</jndi-name>
                  <connection-url>jdbc:mysql://localhost:3306/formsTest</connection-url>
                  <driver-class>com.mysql.jdbc.Driver</driver-class>
                  <user-name>formsTest</user-name>
                  <password></password>
               </local-tx-datasource>
                
            </datasources>



            While Application datasource files in project-ear/rsources/ has following content


            <datasources>
               
               <local-tx-datasource>
                  <jndi-name>formsDatasource</jndi-name>
                  <connection-url>jdbc:mysql://localhost:3306/forms</connection-url>
                  <driver-class>com.mysql.jdbc.Driver</driver-class>
                  <user-name>forms</user-name>
                  <password>forms</password>
               </local-tx-datasource>
                
            </datasources>
            


            as result i have recieved following stack trace


            org.jboss.deployment.DeploymentException: Error during install jboss.jca:service=ManagedConnectionFactory,name=formsDatasourceTest
                 at org.jboss.deployment.DeploymentException.rethrowAsDeploymentException(DeploymentException.java:52)
                 at org.jboss.system.ServiceController.install(ServiceController.java:277)



            persitance.xml in project-ejb/ehbModule/META-INF has following content:


             <persistence-unit name="forms">
                  <provider>org.hibernate.ejb.HibernatePersistence</provider>
                  <jta-data-source>java:/formsDatasource</jta-data-source>
                  <properties>
                     <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
                     <property name="hibernate.hbm2ddl.auto" value="validate"/>
                     <property name="hibernate.show_sql" value="true"/>
                     <property name="hibernate.format_sql" value="true"/>
                     <property name="jboss.entity.manager.factory.jndi.name" value="java:/formsEntityManagerFactory"/>
                  </properties>
               </persistence-unit>



            I would be very gratefull for your help.



            best regrads



            Mathew