maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stephane-3 <mittiprove...@yahoo.se>
Subject DAO injection in integration tests with a few database server specific methods
Date Fri, 23 Nov 2012 06:15:34 GMT
Hi,

I have a Spring Hibernate project with a DAO coded against a MySql database.
Most of the DAO methods would run on HSQLDB and on Oracle, except for some
that contain database server specific syntax.

I already use some Maven profiles to filter the database server data source
specific properties.

Now I wonder which way to go so as to have a few DAO methods specific to
each database server.

I would like to keep most of the DAO methods in a common location, and only
have the database server specific DAO methods in anpther one.

So for example, for the Oracle database server:

Should the Oracle specific DAO methods sit in a different Java package ?

Should there be a different resource xml file to have the beans for the
integration tests injection of these specific DAO methods ?

Here is my setup as of today:

The abstract test class:

@ContextConfiguration(locations = { "classpath:spring-hibernate.xml",
"classpath:spring-hibernate-dao.xml", "classpath:spring-data-source.xml",
"classpath:log4j.xml" })
public abstract class AbstractDaoTest extends
AbstractTransactionalJUnit4SpringContextTests {
}

A Maven profile for the Oracle database server:

    <profile>
      <id>oracle-test</id>
      <properties>
        <test.source.dir>src/integration/java</test.source.dir>
      </properties>
      <build>
        <filters>
         
<filter>src/integration/filters/data-source.oracle.properties</filter>
        </filters>
        <resources>
          <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
          </resource>
          <resource>
            <directory>src/integration/resources</directory>
            <filtering>true</filtering>
          </resource>
        </resources>
      </build>
    </profile>

The spring-hibernate-dao.xml file content:

<beans>

	<bean id="addressDao"
		class="com.thalasoft.learnintouch.core.dao.hibernate.AddressHibernateDao">
		<property name="sessionFactory" ref="sessionFactory" />
	</bean>

	<bean id="adminDao"
		class="com.thalasoft.learnintouch.core.dao.hibernate.AdminHibernateDao">
		<property name="sessionFactory" ref="sessionFactory" />
	</bean>

etc...
</beans>





--
View this message in context: http://maven.40175.n5.nabble.com/DAO-injection-in-integration-tests-with-a-few-database-server-specific-methods-tp5732576.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Mime
View raw message