[dna-commits] DNA SVN: r1251 - in trunk: extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa and 1 other directory.

dna-commits at lists.jboss.org dna-commits at lists.jboss.org
Tue Sep 22 13:02:29 EDT 2009


Author: rhauch
Date: 2009-09-22 13:02:29 -0400 (Tue, 22 Sep 2009)
New Revision: 1251

Added:
   trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/JdbcConnectionTest.java
Modified:
   trunk/pom.xml
Log:
DNA-525 Configure connection information for QA databases

Successfully configured the connection information for MySQL 5.x, MS SQL Server 2008, IBM DB2 v 9.x, and PostgreSQL 8.3.  However, still working on the Oracle 10g/11g and Sybase connections.  Also, have not run any of the tests using these databases, so we may have problems.

Added: trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/JdbcConnectionTest.java
===================================================================
--- trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/JdbcConnectionTest.java	                        (rev 0)
+++ trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/JdbcConnectionTest.java	2009-09-22 17:02:29 UTC (rev 1251)
@@ -0,0 +1,122 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of 
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ * 
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.connector.store.jpa;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+import java.util.UUID;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import org.hibernate.ejb.Ejb3Configuration;
+import org.jboss.dna.connector.store.jpa.model.basic.BasicModel;
+import org.jboss.dna.connector.store.jpa.model.basic.NodeId;
+import org.jboss.dna.connector.store.jpa.model.basic.PropertiesEntity;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Simple unit test that simply verifies the database connection.
+ */
+public class JdbcConnectionTest {
+
+    private EntityManagerFactory factory;
+    private EntityManager manager;
+    private BasicModel model;
+
+    @Before
+    public void beforeEach() throws Exception {
+        model = new BasicModel();
+    }
+
+    @After
+    public void afterEach() throws Exception {
+        try {
+            if (manager != null) manager.close();
+        } finally {
+            manager = null;
+            if (factory != null) {
+                try {
+                    factory.close();
+                } finally {
+                    factory = null;
+                }
+            }
+        }
+    }
+
+    protected EntityManager startEntityManager() {
+        if (manager == null) {
+            // Set the connection properties using the environment defined in the POM files ...
+            JpaSource source = TestEnvironment.configureJpaSource("Test Repository", this);
+
+            // Connect to the database ...
+            Ejb3Configuration configurator = new Ejb3Configuration();
+            model.configure(configurator);
+            configurator.setProperty("hibernate.dialect", source.getDialect());
+            configurator.setProperty("hibernate.connection.driver_class", source.getDriverClassName());
+            configurator.setProperty("hibernate.connection.username", source.getUsername());
+            configurator.setProperty("hibernate.connection.password", source.getPassword());
+            configurator.setProperty("hibernate.connection.url", source.getUrl());
+            configurator.setProperty("hibernate.show_sql", "false");
+            configurator.setProperty("hibernate.format_sql", "true");
+            configurator.setProperty("hibernate.use_sql_comments", "true");
+            configurator.setProperty("hibernate.hbm2ddl.auto", "create");
+            factory = configurator.buildEntityManagerFactory();
+            manager = factory.createEntityManager();
+        }
+        return manager;
+    }
+
+    @Test
+    public void shouldConnectToDatabaseAndPersistBasicProperty() {
+        startEntityManager();
+
+        Long workspaceId = 10L;
+        NodeId nodeId = new NodeId(workspaceId, UUID.randomUUID().toString());
+        PropertiesEntity prop = new PropertiesEntity();
+        prop.setCompressed(true);
+        prop.setData("Hello, World".getBytes());
+        prop.setId(nodeId);
+        manager.getTransaction().begin();
+        try {
+            // Save a properties entity (with compressed data) ...
+            manager.persist(prop);
+            manager.getTransaction().commit();
+        } catch (RuntimeException t) {
+            manager.getTransaction().rollback();
+            throw t;
+        }
+        // Look up the object ...
+        manager.getTransaction().begin();
+        try {
+            PropertiesEntity prop2 = manager.find(PropertiesEntity.class, nodeId);
+            assertThat(prop2.isCompressed(), is(prop.isCompressed()));
+            assertThat(prop2.getId(), is(prop.getId()));
+            assertThat(prop2.getData(), is(prop.getData()));
+        } finally {
+            manager.getTransaction().rollback();
+        }
+    }
+}


Property changes on: trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/JdbcConnectionTest.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml	2009-09-22 16:05:53 UTC (rev 1250)
+++ trunk/pom.xml	2009-09-22 17:02:29 UTC (rev 1251)
@@ -428,7 +428,7 @@
       </profile>
 
       <!-- The PostgreSQL test environment, local to the developer -->
-      <profile>
+      <!--profile>
           <id>postgresql_local</id>
 		      <activation>
 		        <property>
@@ -450,7 +450,7 @@
             <jpaSource.username>postgres</jpaSource.username>
             <jpaSource.password>data</jpaSource.password>
           </properties>
-      </profile>
+      </profile-->
 
       <!--
           ###################################################################
@@ -477,10 +477,10 @@
           </dependencies>
           <properties>
             <jpaSource.dialect>org.hibernate.dialect.MySQL5InnoDBDialect</jpaSource.dialect>
-            <jpaSource.driverClassName>com.mysql.jdbc.driverClassName</jpaSource.driverClassName>
-            <jpaSource.url>jdbc:mysql://vmg08.mw.lab.eng.bos.redhat.com/hibbrtru</jpaSource.url>
-            <jpaSource.username>username</jpaSource.username>
-            <jpaSource.password>password</jpaSource.password>
+            <jpaSource.driverClassName>com.mysql.jdbc.Driver</jpaSource.driverClassName>
+            <jpaSource.url>jdbc:mysql://vmg02.mw.lab.eng.bos.redhat.com/jbossdna</jpaSource.url>
+            <jpaSource.username>jbossdna</jpaSource.username>
+            <jpaSource.password>jbossdna</jpaSource.password>
           </properties>
       </profile>
 
@@ -497,16 +497,15 @@
             <dependency>
               <groupId>postgresql</groupId>
               <artifactId>postgresql</artifactId>
-              <version>8.2-504</version>
-              <classifier>jdbc3</classifier>
+              <version>8.4-701.jdbc3</version>
             </dependency>
           </dependencies>
           <properties>
             <jpaSource.dialect>org.hibernate.dialect.PostgreSQLDialect</jpaSource.dialect>
             <jpaSource.driverClassName>org.postgresql.Driver</jpaSource.driverClassName>
-            <jpaSource.url>jdbc:postgresql://dev01.qa.atl.jboss.com:5432:hibbrtru</jpaSource.url>
-            <jpaSource.username>username</jpaSource.username>
-            <jpaSource.password>password</jpaSource.password>
+            <jpaSource.url>jdbc:postgresql://vmg03.mw.lab.eng.bos.redhat.com:5432:jbossdna</jpaSource.url>
+            <jpaSource.username>jbossdna</jpaSource.username>
+            <jpaSource.password>jbossdna</jpaSource.password>
           </properties>
       </profile>
 
@@ -516,36 +515,6 @@
           ###################################################################
       -->
 
-      <!-- The DB2 8.x test environment (using 9x drivers)-->
-      <profile>
-          <id>db2v8</id>
-		      <activation>
-		        <property>
-		          <name>database</name>
-		          <value>db2v8</value>
-		        </property>
-		      </activation>
-          <dependencies>
-            <dependency>
-              <groupId>com.ibm</groupId>
-              <artifactId>db2jcc</artifactId>
-              <version>3.1.57</version>
-            </dependency>
-            <dependency>
-              <groupId>com.ibm</groupId>
-              <artifactId>db2jcc_license_cu</artifactId>
-              <version>3.1.57</version>
-            </dependency>
-          </dependencies>
-          <properties>
-            <jpaSource.dialect>org.hibernate.dialect.DB2Dialect</jpaSource.dialect>
-            <jpaSource.driverClassName>com.ibm.db2.jcc.DB2Driver</jpaSource.driverClassName>
-            <jpaSource.url>jdbc:db2://dev32.qa.atl.jboss.com:50000/jbossqa</jpaSource.url>
-            <jpaSource.username>username</jpaSource.username>
-            <jpaSource.password>password</jpaSource.password>
-          </properties>
-      </profile>
-
       <!-- The DB2 9.x test environment (using 9x drivers)-->
       <profile>
           <id>db2v9</id>
@@ -559,49 +528,23 @@
             <dependency>
               <groupId>com.ibm</groupId>
               <artifactId>db2jcc</artifactId>
-              <version>3.1.57</version>
+              <version>3.8.47</version>
             </dependency>
             <dependency>
               <groupId>com.ibm</groupId>
               <artifactId>db2jcc_license_cu</artifactId>
-              <version>3.1.57</version>
+              <version>3.8.47</version>
             </dependency>
           </dependencies>
           <properties>
             <jpaSource.dialect>org.hibernate.dialect.DB2Dialect</jpaSource.dialect>
             <jpaSource.driverClassName>com.ibm.db2.jcc.DB2Driver</jpaSource.driverClassName>
-            <jpaSource.url>jdbc:db2://dev67.qa.atl.jboss.com:50000/jbossqa</jpaSource.url>
-            <jpaSource.username>username</jpaSource.username>
-            <jpaSource.password>password</jpaSource.password>
+            <jpaSource.url>jdbc:db2://vmg06.mw.lab.eng.bos.redhat.com:50000/jbossqa</jpaSource.url>
+            <jpaSource.username>jbossdna</jpaSource.username>
+            <jpaSource.password>jbossdna</jpaSource.password>
           </properties>
       </profile>
 
-      <!-- The Oracle9i test environment -->
-      <profile>
-          <id>oracle9i</id>
-		      <activation>
-		        <property>
-		          <name>database</name>
-		          <value>oracle9i</value>
-		        </property>
-		      </activation>
-          <dependencies>
-            <dependency>
-              <groupId>com.oracle</groupId>
-              <artifactId>ojdbc14</artifactId>
-              <!-- use the 10g drivers which are surprisingly largely bug free -->
-              <version>10.0.2.0</version>
-            </dependency>
-          </dependencies>
-          <properties>
-            <jpaSource.dialect>org.hibernate.dialect.Oracle9iDialect</jpaSource.dialect>
-            <jpaSource.driverClassName>oracle.jdbc.driverClassName.OracleDriver</jpaSource.driverClassName>
-            <jpaSource.url>jdbc:oracle:thin:@dev20.qa.atl.jboss.com:1521:qa</jpaSource.url>
-            <jpaSource.username>username</jpaSource.username>
-            <jpaSource.password>password</jpaSource.password>
-          </properties>
-      </profile>
-
       <!-- The Oracle10g test environment -->
       <profile>
           <id>oracle10g</id>
@@ -621,10 +564,10 @@
           </dependencies>
           <properties>
             <jpaSource.dialect>org.hibernate.dialect.Oracle10gDialect</jpaSource.dialect>
-            <jpaSource.driverClassName>oracle.jdbc.driverClassName.OracleDriver</jpaSource.driverClassName>
-            <jpaSource.url>jdbc:oracle:thin:@dev01.qa.atl.jboss.com:1521:qadb01</jpaSource.url>
-            <jpaSource.username>username</jpaSource.username>
-            <jpaSource.password>password</jpaSource.password>
+            <jpaSource.driverClassName>oracle.jdbc.driver.OracleDriver</jpaSource.driverClassName>
+            <jpaSource.url>jdbc:oracle:thin:@vmg05.mw.lab.eng.bos.redhat.com:1521:qa09</jpaSource.url>
+            <jpaSource.username>jbossdna</jpaSource.username>
+            <jpaSource.password>jbossdna</jpaSource.password>
           </properties>
       </profile>
 
@@ -646,10 +589,10 @@
           </dependencies>
           <properties>
             <jpaSource.dialect>org.hibernate.dialect.Oracle10gDialect</jpaSource.dialect>
-            <jpaSource.driverClassName>oracle.jdbc.driverClassName.OracleDriver</jpaSource.driverClassName>
-            <jpaSource.url>jdbc:oracle:thin:@ENGLXDBS11.mm.atl2.redhat.com:1521:orcl</jpaSource.url>
-            <jpaSource.username>integtest</jpaSource.username>
-            <jpaSource.password>teiid</jpaSource.password>
+            <jpaSource.driverClassName>oracle.jdbc.driver.OracleDriver</jpaSource.driverClassName>
+            <jpaSource.url>jdbc:oracle:thin:@vmg05.mw.lab.eng.bos.redhat.com:1521:qa09</jpaSource.url>
+            <jpaSource.username>jbossdna</jpaSource.username>
+            <jpaSource.password>jbossdna</jpaSource.password>
           </properties>
       </profile>
 
@@ -670,36 +613,37 @@
             </dependency>
           </dependencies>
           <properties>
-            <jpaSource.dialect>org.hibernate.dialect.SybaseASE15Dialect</jpaSource.dialect>
+            <jpaSource.dialect>org.hibernate.dialect.SybaseDialect</jpaSource.dialect>
             <jpaSource.driverClassName>com.sybase.jdbc3.jdbc.SybDriver</jpaSource.driverClassName>
-            <jpaSource.url>jdbc:sybase:Tds:dev77.qa.atl2.redhat.com:5000/hibbrtru</jpaSource.url>
-            <jpaSource.username>username</jpaSource.username>
-            <jpaSource.password>password</jpaSource.password>
+            <jpaSource.url>jdbc:sybase:Tds:vmg07.mw.lab.eng.bos.redhat.com:5000/jbossdna</jpaSource.url>
+            <jpaSource.username>jbossdna</jpaSource.username>
+            <jpaSource.password>jbossdna</jpaSource.password>
           </properties>
       </profile>
 
-      <!-- The SQLServer2005 (MS JDBC) test environment -->
+      <!-- The SQLServer2008 (MS JDBC) test environment -->
       <profile>
-          <id>mssql2005</id>
+          <id>mssql2008</id>
 		      <activation>
 		        <property>
 		          <name>database</name>
-		          <value>mssql2005</value>
+		          <value>mssql2008</value>
 		        </property>
 		      </activation>
           <dependencies>
             <dependency>
               <groupId>com.microsoft.sqlserver</groupId>
               <artifactId>msjdbc</artifactId>
-              <version>1.1</version>
+              <version>2.0.1008.2</version>
+              <classifier>4</classifier><!-- Must use the JDBC-4 driver on JDK6 -->
             </dependency>
           </dependencies>
           <properties>
             <jpaSource.dialect>org.hibernate.dialect.SQLServerDialect</jpaSource.dialect>
             <jpaSource.driverClassName>com.microsoft.sqlserver.jdbc.SQLServerDriver</jpaSource.driverClassName>
-            <jpaSource.url>jdbc:sqlserver://dev30.qa.atl.jboss.com:3918</jpaSource.url>
-            <jpaSource.username>username</jpaSource.username>
-            <jpaSource.password>password</jpaSource.password>
+            <jpaSource.url>jdbc:sqlserver://vmg04.mw.lab.eng.bos.redhat.com</jpaSource.url>
+            <jpaSource.username>jbossdna</jpaSource.username>
+            <jpaSource.password>jbossdna</jpaSource.password>
           </properties>
       </profile>
 



More information about the dna-commits mailing list