I'm writing my first SeamTest class. I like the idea of TDD, but I'm kinda 
frustrated with getting my first test working perfectly. I'm struggling with 
this problem for 2 days now. I also combed the forum/google for an answer.

META-INF/persistence.xml, hibernate.cfg.xml

  | <persistence>
  |     <persistence-unit name="cast">
  |     <properties>
  |     <property name="hibernate.ejb.cfgfile"
  |     value="/hibernate.cfg.xml"/>
  |     </properties>
  | </persistence-unit>
  | </persistence>
  | 

  | <hibernate-configuration>
  | <session-factory>
  | 
  | <!-- Hibernate settings -->
  | <property name="hibernate.connection.driver_class"  
>oracle.jdbc.driver.OracleDriver   </property>
  | <property name="hibernate.connection.url" 
>jdbc:oracle:thin:@localhost:1521:ORCL </property>
  | <property name="hibernate.connection.username" >scarduser</property>
  | <property name="hibernate.connection.password"> scarduser</property>
  | <property name="hibernate.dialect" 
>org.hibernate.dialect.Oracle9Dialect</property>
  | 
  | <!-- JDBC connection pool -->
  | <property name="connection.pool_size" >15</property>
  | 
  | <property name="hibernate.hbm2ddl.auto">update</property>
  | 
  | <!-- Enable Hibernate's automatic session context management -->
  | <property name="current_session_context_class">thread</property>
  | 
  | <property name="format_sql">true</property>
  | <property name="use_sql_comments">false</property>
  | <property name="generate_statistics">false</property>
  | <!-- SQL logging configuration -->
  | <!-- NOTE: to show sql, use DEBUG log level for org.hibernate.SQL category 
-->
  | <!--
  | <property name="show_sql">true</property>
  | -->
  | 
  | <!-- Query configuration -->
  | <property name="hibernate.query.substitutions">true 1, false 0</property>
  | <property name="hibernate.max_fetch_depth">2</property>
  | 
  | <!-- Batch configuration -->
  | <property name="hibernate.default_batch_fetch_size">8</property>
  | <property name="hibernate.jdbc.batch_size">20</property>
  | 
  | <mapping class="com.ibm.dw.open18.Course"/>
  | <mapping class="com.cmsc.sonycard.model.Catalog"/> 
  | </session-factory>
  | </hibernate-configuration> 
  | 

My seamtest class - CatalogTest


  | package com.cmsc.sonycard.model;
  | 
  | /** Imports omitted ***/
  | public class CatalogTest extends SeamTest {
  |     private Catalog catalog;
  | 
  | /* START SECTION A
  |     private EntityManagerFactory emf;
  | 
  |     public EntityManagerFactory getEntityManagerFactory() {
  |             return emf;
  |     }
  | 
  |     @Configuration(beforeTestClass = true)
  |     public void init() {
  |             emf = Persistence
  |                             .createEntityManagerFactory("cast");
  |     }
  | 
  |     @Configuration(afterTestClass = true)
  |     public void destroy() {
  |                     emf.close();
  | 
  |     }
  | END SECTION A */
  | 
  |     @Test
  |     public void testPersist() {
  |             EntityManagerFactory emf =
  |                  Persistence.createEntityManagerFactory("cast");
  |             EntityManager em = emf.createEntityManager();
  |             catalog = new Catalog();
  |             catalog.setName("Blah Blah");
  |             catalog.setActive("Y");
  |         em.getTransaction().begin();
  |         em.persist(catalog);
  |         em.getTransaction().commit();
  | 
  |         em.close();
  |     }
  | 
  | }
  | 
  | 
  | 


My tests run fine with the above code as is. The problem is when I uncomment 
"Section A" and run my test again -
 my testPersist() still runs successfully but I get these errors.

   [testng] 10:50:38,202 WARN  [DriverManagerConnectionProvider] problem 
closing pooled connection
   [testng] java.sql.SQLException: Io exception: Socket closed
   [testng]     at 
oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
   [testng]     at 
oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
   [testng]     at 
oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:333)
   [testng]     at 
oracle.jdbc.driver.OracleConnection.close(OracleConnection.java:1442)
   [testng]     at 
org.hibernate.connection.DriverManagerConnectionProvider.close(DriverManagerConnectionProvider.java:152)
   [testng]     at 
org.hibernate.connection.DriverManagerConnectionProvider.finalize(DriverManagerConnectionProvider.java:142)
   [testng]     at java.lang.ref.Finalizer.invokeFinalizeMethod(Native Method)
   [testng]     at java.lang.ref.Finalizer.runFinalizer(Finalizer.java:83)
   [testng]     at java.lang.ref.Finalizer.access$100(Finalizer.java:14)
   [testng]     at 
java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:160)
   [testng] 10:50:38,202 INFO  [TableMetadata] columns: [phone, type, street, 
postal_code, id, county, longitude, country, uri, description, state, latitude, 
na
me, city]
   [testng] 10:50:38,202 INFO  [DriverManagerConnectionProvider] cleaning up 
connection pool: jdbc:oracle:thin:@localhost:1521:ORCL
   [testng] 10:50:38,202 WARN  [DriverManagerConnectionProvider] problem 
closing pooled connection
   [testng] java.sql.SQLException: Io exception: Socket closed
   [testng]     at 
oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
   [testng]     at 
oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
   [testng]     at 
oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:333)
   [testng]     at 
oracle.jdbc.driver.OracleConnection.close(OracleConnection.java:1442)
   [testng]     at 
org.hibernate.connection.DriverManagerConnectionProvider.close(DriverManagerConnectionProvider.java:152)
   [testng]     at 
org.hibernate.connection.DriverManagerConnectionProvider.finalize(DriverManagerConnectionProvider.java:142)
   [testng]     at java.lang.ref.Finalizer.invokeFinalizeMethod(Native Method)
   [testng]     at java.lang.ref.Finalizer.runFinalizer(Finalizer.java:83)
   [testng]     at java.lang.ref.Finalizer.access$100(Finalizer.java:14)
   [testng]     at 
java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:160)
   [testng] 10:50:38,202 INFO  [TableMetadata] foreign keys: []
   [testng] 10:50:38,202 INFO  [TableMetadata] indexes: [sys_c005286]
   [testng] 10:50:38,202 INFO  [SchemaUpdate] schema update complete
   [testng] Creating C:\source\cast\build\testout\CatalogTest.html
   [testng] PASSED: testPersist
   [testng] FAILED: org.jboss.seam.mock.SeamTest.end()
   [testng] java.lang.NullPointerException
   [testng]     at 
org.jboss.seam.contexts.WebApplicationContext.get(WebApplicationContext.java:48)
   [testng]     at org.jboss.seam.Component.forName(Component.java:1579)
   [testng]     at org.jboss.seam.Component.getInstance(Component.java:1627)
   [testng]     at org.jboss.seam.Component.getInstance(Component.java:1622)
   [testng]     at org.jboss.seam.Component.getInstance(Component.java:1599)
   [testng]     at org.jboss.seam.Component.getInstance(Component.java:1594)
   [testng]     at 
org.jboss.seam.core.ConversationEntries.instance(ConversationEntries.java:91)
   [testng]     at 
org.jboss.seam.contexts.Lifecycle.endSession(Lifecycle.java:284)
   [testng]     at org.jboss.seam.mock.SeamTest.end(SeamTest.java:676)
   [testng]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)



I tried putting the same code block into the registration example and I get 
similar errors. Am I missing something in the testng configuration.

Sorry for the long post. Thanks for any help, will keep trying, got some free 
time to play today.

Franco



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

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

Reply via email to