From 3dc88e069a6e909529a9a6eb5540c1bb64b149f3 Mon Sep 17 00:00:00 2001
From: Keith Donald <kdonald@vmware.com>
Date: Wed, 16 Dec 2009 16:44:43 +0000
Subject: [PATCH] polish

---
 pom.xml                                       |  8 ++++-
 .../petclinic/AbstractClinicTests-context.xml | 33 ++++++++++++-------
 .../jpa/applicationContext-jpaCommon.xml      | 32 +++++++++++-------
 3 files changed, 49 insertions(+), 24 deletions(-)

diff --git a/pom.xml b/pom.xml
index 5883e8e..71f127b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -26,7 +26,7 @@
 			<groupId>javax.persistence</groupId>
 			<artifactId>com.springsource.javax.persistence</artifactId>
 			<version>1.0.0</version>
-		</dependency>
+		</dependency>	
 		<dependency>
 			<groupId>javax.servlet</groupId>
 			<artifactId>com.springsource.javax.servlet</artifactId>
@@ -146,6 +146,12 @@
 			<version>${spring.version}</version>
             <scope>test</scope>
 		</dependency>
+		<dependency>
+ 		   <groupId>javax.transaction</groupId>
+ 		   <artifactId>com.springsource.javax.transaction</artifactId>
+		    <version>1.1.0</version>
+		    <scope>test</scope>
+		</dependency>		
 	</dependencies>
 	<repositories>
 		<repository>
diff --git a/src/test/resources/org/springframework/samples/petclinic/AbstractClinicTests-context.xml b/src/test/resources/org/springframework/samples/petclinic/AbstractClinicTests-context.xml
index 3f79cbc..af4c40b 100644
--- a/src/test/resources/org/springframework/samples/petclinic/AbstractClinicTests-context.xml
+++ b/src/test/resources/org/springframework/samples/petclinic/AbstractClinicTests-context.xml
@@ -1,22 +1,31 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-	xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"
-	xmlns:tx="http://www.springframework.org/schema/tx"
-	xsi:schemaLocation="
-		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
-		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
-		http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
+		xmlns:p="http://www.springframework.org/schema/p"
+		xmlns:context="http://www.springframework.org/schema/context" 
+		xmlns:jdbc="http://www.springframework.org/schema/jdbc"
+		xmlns:tx="http://www.springframework.org/schema/tx"
+		xsi:schemaLocation="
+			http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+			http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
+			http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
+			http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
 
-	<context:property-placeholder location="classpath:/jdbc.properties"/>
+	<context:property-placeholder location="classpath:jdbc.properties"/>
 
 	<context:annotation-config/>
 
 	<tx:annotation-driven/>
 
-	<bean id="dataSource" class="org.springframework.samples.petclinic.config.DbcpDataSourceFactory"
-			p:driverClassName="${jdbc.driverClassName}" p:url="${jdbc.url}" 
-			p:username="${jdbc.username}" p:password="${jdbc.password}" p:populate="${jdbc.populate}"
-			p:schemaLocation="${jdbc.schemaLocation}" p:dataLocation="${jdbc.dataLocation}"
-			p:dropLocation="${jdbc.dropLocation}"/>
+	<!-- DataSource configuration for Apache Commons DBCP. -->
+	<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"
+			p:driverClassName="${jdbc.driverClassName}" p:url="${jdbc.url}"
+			p:username="${jdbc.username}" p:password="${jdbc.password}"/>
+	
+	<!-- Database initializer. If any of the script fails, the initialization stops. -->
+	<!-- As an alternative, for embedded databases see <jdbc:embedded-database/>. -->
+	<jdbc:initialize-database data-source="dataSource">
+		<jdbc:script location="${jdbc.initLocation}"/>
+		<jdbc:script location="${jdbc.dataLocation}"/>
+	</jdbc:initialize-database>
 	
 </beans>
diff --git a/src/test/resources/org/springframework/samples/petclinic/jpa/applicationContext-jpaCommon.xml b/src/test/resources/org/springframework/samples/petclinic/jpa/applicationContext-jpaCommon.xml
index b873dfc..33a2eb1 100644
--- a/src/test/resources/org/springframework/samples/petclinic/jpa/applicationContext-jpaCommon.xml
+++ b/src/test/resources/org/springframework/samples/petclinic/jpa/applicationContext-jpaCommon.xml
@@ -1,21 +1,30 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-	xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"
-	xmlns:tx="http://www.springframework.org/schema/tx"
-	xsi:schemaLocation="
-		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
-		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
-		http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
+		xmlns:p="http://www.springframework.org/schema/p"
+		xmlns:context="http://www.springframework.org/schema/context" 
+		xmlns:jdbc="http://www.springframework.org/schema/jdbc"
+		xmlns:tx="http://www.springframework.org/schema/tx"
+		xsi:schemaLocation="
+			http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+			http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
+			http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
+			http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
 
 	<context:property-placeholder location="classpath:/jdbc.properties" />
 
 	<tx:annotation-driven />
 
-	<bean id="dataSource" class="org.springframework.samples.petclinic.config.DbcpDataSourceFactory"
-			p:driverClassName="${jdbc.driverClassName}" p:url="${jdbc.url}" 
-			p:username="${jdbc.username}" p:password="${jdbc.password}" p:populate="${jdbc.populate}"
-			p:schemaLocation="${jdbc.schemaLocation}" p:dataLocation="${jdbc.dataLocation}"
-			p:dropLocation="${jdbc.dropLocation}"/>
+	<!-- DataSource configuration for Apache Commons DBCP. -->
+	<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"
+			p:driverClassName="${jdbc.driverClassName}" p:url="${jdbc.url}"
+			p:username="${jdbc.username}" p:password="${jdbc.password}"/>
+	
+	<!-- Database initializer. If any of the script fails, the initialization stops. -->
+	<!-- As an alternative, for embedded databases see <jdbc:embedded-database/>. -->
+	<jdbc:initialize-database data-source="dataSource">
+		<jdbc:script location="${jdbc.initLocation}"/>
+		<jdbc:script location="${jdbc.dataLocation}"/>
+	</jdbc:initialize-database>
 	
 	<!-- Note: the specific "jpaAdapter" bean sits in adapter context file -->
 	<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
@@ -23,6 +32,7 @@
 		<property name="loadTimeWeaver">
 			<bean class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver" />
 		</property>
+		<property name="persistenceXmlLocation" value="classpath:META-INF/jpa-persistence.xml"/>		
 	</bean>
 
 	<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"
-- 
GitLab