28 Apr 2006

Spring tests Life Cycle

I'm using AbstractTransactionalDataSourceSpringContextTests for test but I never remember the life cycle of those tests so I made an empty one with all methods printing there names:
getConfigLocations
setDataSource
setTransactionManager
onSetUpBeforeTransaction
onSetUpInTransaction
the real test
onTearDownInTransaction
endTransaction
onTearDownAfterTransaction

With log4j.category.com.company.test.LifeCycleSpringTest=DEBUG (my test):
getConfigLocations
16:34:11,662 INFO [LifeCycleSpringTest] Loading config for: classpath*:/**/beans.xml
setDataSource
setTransactionManager
onSetUpBeforeTransaction
16:34:13,880 INFO [LifeCycleSpringTest] Began transaction: transaction manager [org.springframework.orm.hibernate3.HibernateTransactionManager@1a1c42f]; defaultRollback true
onSetUpInTransaction
the real test
onTearDownInTransaction
16:34:13,880 INFO [LifeCycleSpringTest] Rolled back transaction after test execution
endTransaction
onTearDownAfterTransaction

With
log4j.category.com.company.test.LifeCycleSpringTest=DEBUG
log4j.category.org.springframework=DEBUG
log4j.category.org.hibernate=INFO
:
getConfigLocations
16:35:46,379 INFO [CollectionFactory] JDK 1.4+ collections available
16:35:46,394 INFO [CollectionFactory] Commons Collections 3.x available
16:35:46,410 INFO [XmlBeanDefinitionReader] Loading XML bean definitions from file [C:\developpement\workspaces\egrc\SpringUnittest\bin\beans.xml]
16:35:46,597 INFO [ClassPathXmlApplicationContext] Bean factory for application context [org.springframework.context.support.ClassPathXmlApplicationContext;hashCode=14867177]: org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [dataSource,sessionFactory,transactionManager,personDAO]; root of BeanFactory hierarchy
16:35:46,597 INFO [ClassPathXmlApplicationContext] 4 beans defined in application context [org.springframework.context.support.ClassPathXmlApplicationContext;hashCode=14867177]
16:35:46,613 INFO [ClassPathXmlApplicationContext] Unable to locate MessageSource with name 'messageSource': using default [org.springframework.context.support.DelegatingMessageSource@193a66f]
16:35:46,613 INFO [ClassPathXmlApplicationContext] Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster': using default [org.springframework.context.event.SimpleApplicationEventMulticaster@be0e27]
16:35:46,613 INFO [DefaultListableBeanFactory] Pre-instantiating singletons in factory [org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [dataSource,sessionFactory,transactionManager,personDAO]; root of BeanFactory hierarchy]
16:35:46,691 INFO [Environment] Hibernate 3.0.5
16:35:46,707 INFO [Environment] hibernate.properties not found
16:35:46,707 INFO [Environment] using CGLIB reflection optimizer
16:35:46,707 INFO [Environment] using JDK 1.4 java.sql.Timestamp handling
16:35:46,785 INFO [Configuration] configuring from url: file:/C:/developpement/workspaces/egrc/SpringUnittest/bin/hibernate.cfg.xml
16:35:46,863 INFO [Configuration] Mapping resource: com/company/project/Person.hbm.xml
16:35:46,988 INFO [HbmBinder] Mapping class: com.company.project.Person -> Person
16:35:47,019 INFO [Configuration] Configured SessionFactory: sessionFactory
16:35:47,019 INFO [LocalSessionFactoryBean] Building new Hibernate SessionFactory
16:35:47,019 INFO [Configuration] processing extends queue
16:35:47,019 INFO [Configuration] processing collection mappings
16:35:47,019 INFO [Configuration] processing association property references
16:35:47,019 INFO [Configuration] processing foreign key constraints
16:35:47,097 INFO [ConnectionProviderFactory] Initializing connection provider: org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider
16:35:47,738 INFO [SettingsFactory] RDBMS: Oracle, version: Oracle Database 10g Release 10.1.0.2.0 - Production
16:35:47,738 INFO [SettingsFactory] JDBC driver: Oracle JDBC driver, version: 10.1.0.5.0
16:35:47,754 INFO [Dialect] Using dialect: org.hibernate.dialect.Oracle9Dialect
16:35:47,754 INFO [TransactionFactoryFactory] Using default transaction strategy (direct JDBC transactions)
16:35:47,769 INFO [TransactionManagerLookupFactory] No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
16:35:47,769 INFO [SettingsFactory] Automatic flush during beforeCompletion(): disabled
16:35:47,769 INFO [SettingsFactory] Automatic session close at end of transaction: disabled
16:35:47,769 INFO [SettingsFactory] JDBC batch size: 15
16:35:47,769 INFO [SettingsFactory] JDBC batch updates for versioned data: disabled
16:35:47,769 INFO [SettingsFactory] Scrollable result sets: enabled
16:35:47,769 INFO [SettingsFactory] JDBC3 getGeneratedKeys(): disabled
16:35:47,769 INFO [SettingsFactory] Connection release mode: on_close
16:35:47,769 INFO [SettingsFactory] Default schema: BFRA_TEST
16:35:47,769 INFO [SettingsFactory] Default batch fetch size: 1
16:35:47,769 INFO [SettingsFactory] Generate SQL with comments: disabled
16:35:47,769 INFO [SettingsFactory] Order SQL updates by primary key: disabled
16:35:47,769 INFO [SettingsFactory] Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
16:35:47,769 INFO [ASTQueryTranslatorFactory] Using ASTQueryTranslatorFactory
16:35:47,769 INFO [SettingsFactory] Query language substitutions: {}
16:35:47,769 INFO [SettingsFactory] Second-level cache: enabled
16:35:47,769 INFO [SettingsFactory] Query cache: disabled
16:35:47,769 INFO [SettingsFactory] Cache provider: org.hibernate.cache.HashtableCacheProvider
16:35:47,769 INFO [SettingsFactory] Optimize cache for minimal puts: disabled
16:35:47,769 INFO [SettingsFactory] Cache region prefix: hibernate.grc
16:35:47,769 INFO [SettingsFactory] Structured second-level cache entries: disabled
16:35:47,816 INFO [SettingsFactory] Echoing all SQL to stdout
16:35:47,816 INFO [SettingsFactory] Statistics: disabled
16:35:47,816 INFO [SettingsFactory] Deleted entity synthetic identifier rollback: disabled
16:35:47,816 INFO [SettingsFactory] Default entity-mode: pojo
16:35:47,941 INFO [SessionFactoryImpl] building session factory
16:35:48,238 INFO [SessionFactoryObjectFactory] Factory name: sessionFactory
16:35:48,238 INFO [NamingHelper] JNDI InitialContext properties:{}
16:35:48,254 INFO [Dialect] Using dialect: org.hibernate.dialect.Oracle9Dialect
16:35:48,254 INFO [Configuration] processing extends queue
16:35:48,254 INFO [Configuration] processing collection mappings
16:35:48,254 INFO [Configuration] processing association property references
16:35:48,254 INFO [Configuration] processing foreign key constraints
16:35:48,254 INFO [Configuration] processing extends queue
16:35:48,254 INFO [Configuration] processing collection mappings
16:35:48,254 INFO [Configuration] processing association property references
16:35:48,254 INFO [Configuration] processing foreign key constraints
16:35:48,254 INFO [SchemaExport] Running hbm2ddl schema export
16:35:48,254 INFO [SchemaExport] exporting generated schema to database
16:35:48,254 INFO [ConnectionProviderFactory] Initializing connection provider: org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider
16:35:48,363 INFO [SchemaExport] schema export complete
16:35:48,363 INFO [SessionFactoryImpl] Checking 0 named queries
16:35:48,410 INFO [HibernateTransactionManager] Using DataSource [org.apache.commons.dbcp.BasicDataSource@19fe451] of Hibernate SessionFactory for HibernateTransactionManager
setDataSource
setTransactionManager
onSetUpBeforeTransaction
16:35:48,472 INFO [JdbcTransactionObjectSupport] JDBC 3.0 Savepoint class is available
onSetUpInTransaction
the real test
onTearDownInTransaction
endTransaction
onTearDownAfterTransaction

My code:
package com.company.project.test;

import javax.sql.DataSource;

import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests;
import org.springframework.transaction.PlatformTransactionManager;

public class LifeCycleSpringTest extends AbstractTransactionalDataSourceSpringContextTests {

@Override
protected void deleteFromTables(String[] arg0) {
super.deleteFromTables(arg0);
System.out.println("deleteFromTables");
}

@Override
public void setDataSource(DataSource arg0) {
super.setDataSource(arg0);
System.out.println("setDataSource");
}

@Override
protected void endTransaction() {
super.endTransaction();
System.out.println("endTransaction");
}

@Override
protected void onSetUpBeforeTransaction() throws Exception {
super.onSetUpBeforeTransaction();
System.out.println("onSetUpBeforeTransaction");
}

@Override
protected void onSetUpInTransaction() throws Exception {
super.onSetUpInTransaction();
System.out.println("onSetUpInTransaction");
}

@Override
protected void onTearDownAfterTransaction() throws Exception {
super.onTearDownAfterTransaction();
System.out.println("onTearDownAfterTransaction");
}

@Override
protected void onTearDownInTransaction() throws Exception {
super.onTearDownInTransaction();
System.out.println("onTearDownInTransaction");
}

@Override
public void setDefaultRollback(boolean arg0) {
super.setDefaultRollback(arg0);
System.out.println("setDefaultRollback");
}

@Override
public void setTransactionManager(PlatformTransactionManager arg0) {
super.setTransactionManager(arg0);
System.out.println("setTransactionManager");
}

@Override
protected String[] getConfigLocations() {
System.out.println("getConfigLocations");
return new String[] { "classpath*:/**/beans.xml"};
}

public void testLifeCycle() {
System.out.println("the real test");
}
}


Technorati tags:

Citations

18 Apr 2006

Google Calendar is out!

The one that may replace Palm Desktop in my calandar application hear is out! check it out!

Is it better that 30boxes ? Well yes!

Because you can add your friends, french holidays or what ever other calendar you want! It is clearer and quicker...
But import of vCal event does't seems to work ;(

Technorati tags:

Ajaxwrite

Ajax Write application is trying to replace old school microsoft word. Utopia or reality ? We'll see...

Technorati tags: