I have a small application using Seam 1.2.1.GA and Hibernate. It's running okay 
in the server, but now I'm trying to add integration testing and TestNG is 
throwing an error:

   [testng] 12:13:31,437 ERROR [AbstractKernelController] Error installing to 
Start: name=persistence.units:jar=test.jar,unitName=myDatabase state=Create
   [testng] java.lang.AssertionError
   [testng] at 
org.hibernate.cfg.AnnotationBinder.getElementsToProcess(AnnotationBinder.java:766)
   [testng] at 
org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:621)
   [testng] at 
org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:452)
   [testng] at 
org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:268)
   [testng] at 
org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1039)
   [testng] at 
org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1233)
   [testng] at 
org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:154)
   [testng] at 
org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:869)
   [testng] at 
org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:407)
   [testng] at 
org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:126)
   [testng] at 
org.jboss.ejb3.entity.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:264)
   [testng] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   [testng] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   [testng] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   [testng] at java.lang.reflect.Method.invoke(Unknown Source)
... and so on...

Here's my persistence.xml:



  |    <persistence-unit name="myDatabase">
  |       <provider>org.hibernate.ejb.HibernatePersistence</provider>
  |       <jta-data-source>java:/myDatasource</jta-data-source>
  |       <properties>
  |          <property name="hibernate.dialect" 
  | value="org.hibernate.dialect.MySQLDialect"/>
  |          <property name="hibernate.hbm2ddl.auto" value="none"/>
  |          <property name="hibernate.show_sql" value="false"/>
  |          <!-- These are the default for JBoss EJB3, but not for HEM: -->
  |          <property name="hibernate.cache.provider_class" 
  | value="org.hibernate.cache.HashtableCacheProvider"/>
  |          <property name="hibernate.transaction.manager_lookup_class" 
  | value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
  | <property name="jboss.entity.manager.factory.jndi.name" 
  |           value="java:/EntityManagerFactories/myData"/>
  |       </properties>
  |    </persistence-unit>
  | 

And jboss-beans.xml:


  |    <bean name="myDatasourceBootstrap" 
  | class="org.jboss.resource.adapter.jdbc.local.LocalTxDataSource">
  |       <property name="driverClass">com.mysql.jdbc.Driver</property>
  | ... other properties elided ....
  |    </bean>
  | 
  |    <bean name="myDatasource" class="java.lang.Object">
  |       <constructor factoryMethod="getDatasource">
  |          <factory bean="myDatasourceBootstrap"/>
  |       </constructor>
  |    </bean>
  | 

My test code (derived closely from the booking example):



  | public class LoginTest extends SeamTest {
  |    
  |    @Test
  |    public void testLogin() throws Exception {
  |       
  |       new FacesRequest() {
  | 
  |          @Override
  |          protected void updateModelValues() throws Exception {
  |             setValue("#{identity.username}", "xxxxx");
  |             setValue("#{identity.password}", "YYYYY");
  |          }
  | 
  |          @Override
  |          protected void invokeApplication() throws Exception {
  |             System.out.println("invokeApplication");
  |             assert getValue("#{identity.username}").equals("xxxxx");
  |             invokeMethod("#{identity.login}");
  |          }
  | 
  |          @Override
  |          protected void renderResponse() throws Exception {
  |             assert getValue("#{identity.loggedIn}").equals(true);          
  |          }
  |       }.run();
  |       
  |    }
  |    
  |    public static void main(String[] args) throws Exception {
  |       new LoginTest().testLogin();
  |    }
  | 
  | }
  | 

And testng.xml:


  | <suite name="Login Testing" verbose="2" parallel="false">
  | 
  |    <test name="Login">
  |      <classes>
  |        <class name="my.tests.LoginTest"/>
  |      </classes>
  |    </test>
  | 
  | 
  | </suite>
  | 

This is very close to the test structure in the booking example, except for 
using Hibernate and MySQL instead of hsqldb. But apparently I'm leaving 
something out.

Any help would be appreciated.

Steven Gollery

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4054881#4054881

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4054881
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to