aspose file tools*
The moose likes Spring and the fly likes Spring Configuration file using Data Source for JUnit Test Cases........... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Spring
Reply locked New topic
Author

Spring Configuration file using Data Source for JUnit Test Cases...........

Kishore Nallamothu
Greenhorn

Joined: Aug 28, 2006
Posts: 9
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">


<beans>
<!--
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName">
<value>oracle.jdbc.driver.OracleDriver</value>
</property>
<property name="url">
<value>jdbcracle:thin:@192.168.44.111:1521:SCHEMA</value>
</property>
<property name="username">
<value>username</value>
</property>
<property name="password">
<value>password</value>
</property>
</bean>

--><!-- JunitJdbc.properties -->
<!-- <bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="JunitJdbc.properties" />
</bean> -->

<!-- Local DataSource that works in any environment -->
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"
value="oracle.jdbc.driver.OracleDriver" />
<property name="url"
value="jdbcracle:thin:@192.168.44.66:1521:SCHEMA" />
<property name="username" value="username" />
<property name="password" value="password" />
<property name="maxIdle" value="5" />
<property name="maxActive" value="90" />
<property name="minIdle" value="5" />

</bean>

<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">



<property name="mappingLocations">
<!-- Common HBM's i.e not specific to module -->
<list>
<value>classpath*:com/pkg1/hbm/*.hbm.xml</value>
<value>classpath*:com/pkg2/hbm/*.hbm.xml</value>
<value>classpath*:com/pkg3/hbm/*.hbm.xml</value>
<value>classpath*:com/pkg4/hbm/*.hbm.xml</value>
<value>classpath*:com/pkg5/hbm/*.hbm.xml</value>
<value>classpath*:com/pkg6/hbm/*.hbm.xml</value>
</list>
</property>

<property name="mappingResources">
<!-- Local HBM's i.e specific module hbms -->
<list>
<value>pkgtest/abc.hbm.xml</value>
<value>pkgtest/asd.hbm.xml</value>
<value>pkgtest/ert.hbm.xml</value>
<value>pkgtest/sdas.hbm.xml</value>


</list>

</property>

<property name="hibernateProperties">
<props>
<prop key="connection.provider_class">
org.hibernate.connection.DatasourceConnectionProvider
</prop>
<prop key="jdbc.use_streams_for_binary">true</prop>
<prop key="jdbc.batch_size">0</prop>
<prop key="hibernate.dialect">
org.hibernate.dialect.Oracle10gDialect
</prop>
<prop key="hibernate.query.substitutions">
true 1, false 0
</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.max_fetch_depth">2</prop>
<prop key="hibernate.cache.use_second_level_cache">
false
</prop>
<prop key="hibernate.cache.use_minimal_puts">
false
</prop>
<!-- Todd Albee: setting use_query_cache conflicts with SwarmCache -->
<prop key="hibernate.cache.use_query_cache">false</prop>
<prop key="hibenrate.cache.use_structured_entries">
true
</prop>
<prop key="hibernate.connection.release_mode">
auto
</prop>

<!-- for backward compatibility of hql queries -->
<prop key="hibernate.query.factory_class">
org.hibernate.hql.classic.ClassicQueryTranslatorFactory
</prop>

<!-- we get UserTransaction not bound to JNDI error -->


<prop key="hibernate.generate_statistics">true</prop>

</props>
</property>

<property name="dataSource">
<ref bean="dataSource" />

</property>

<property name="eventListeners">
<map>
<entry key="merge">
<bean
class="org.springframework.orm.hibernate3.support.IdTransferringMergeEventListener" />
</entry>
</map>
</property>
</bean>



<!-- Added for transaction starts here -->


<bean id="baseTransactionService"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"
abstract="true">
<property name="transactionManager" ref="transactionManager" />
<property name="transactionAttributes">
<props>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>


<!-- Added for transaction ends here -->






<!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>





<!-- Service, DAO layer configuration starts here -->
<bean id="myService" class="MyServiceImpl">
<property name="myDAO" ref="myDAO" />
</bean>

<bean id="myDAO" class="MyDAOImpl">
<property name="sessionFactory" ref="sessionFactory" />
</bean>

<!-- Service,DAO layer configuration ends here -->


</beans>
Vyas Sanzgiri
Ranch Hand

Joined: Jun 16, 2007
Posts: 686

What is the question?


===Vyas Sanzgiri===
My Blog
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60053
    
  65

If you have a question, please be sure to state it clearly and with all required details. Please read this for more information.

This topic is closed to give the poster another chance to post a new topic with necessary details.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Spring Configuration file using Data Source for JUnit Test Cases...........
 
Similar Threads
Spring transaction
Dirty Checking not occuring.
Hiberante transaction in Spring
java.sql.SQLException: No suitable driver
Connectin leak