You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by st...@apache.org on 2019/01/06 22:45:05 UTC

[openjpa] 02/02: OPENJPA-2753 add a profile for Oracle as Docker image

This is an automated email from the ASF dual-hosted git repository.

struberg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openjpa.git

commit bb6bad070217721424e51edf1b4e5725e3a8e489
Author: Mark Struberg <st...@apache.org>
AuthorDate: Sun Jan 6 23:43:41 2019 +0100

    OPENJPA-2753 add a profile for Oracle as Docker image
    
    -Ptest-oracle-docker
    as new profile to start Oracle 11_XE
---
 .../org/apache/openjpa/jdbc/sql/DBDictionary.java  |   6 +-
 .../openjpa/conf/OpenJPAConfigurationImpl.java     |   8 +-
 .../lib/jdbc/DelegatingDatabaseMetaData.java       |   6 +-
 pom.xml                                            | 106 ++++++++++++++++++++-
 src/test/sql/oracle-docker/init.sql                |  28 ++++++
 5 files changed, 143 insertions(+), 11 deletions(-)

diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
index 888e35a..3f02899 100644
--- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
+++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
@@ -550,9 +550,9 @@ public class DBDictionary
                 supportsGetGeneratedKeys =  (isJDBC3) ? metaData.supportsGetGeneratedKeys() : false;
             }
             if (log.isInfoEnabled()) {
-            	log.info(_loc.get("dict-info", new Object[] {
-            		metaData.getDatabaseProductName(), getMajorVersion(), getMinorVersion(),
-            		metaData.getDriverName(), metaData.getDriverVersion()}));
+                log.info(_loc.get("dict-info", new Object[] {
+                        metaData.getDatabaseProductName(), getMajorVersion(), getMinorVersion(),
+                        metaData.getDriverName(), metaData.getDriverVersion()}));
             }
         }
         connected = true;
diff --git a/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfigurationImpl.java b/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfigurationImpl.java
index d3b6765..17d9b84 100644
--- a/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfigurationImpl.java
+++ b/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfigurationImpl.java
@@ -1849,12 +1849,12 @@ public class OpenJPAConfigurationImpl
 
     @Override
     public boolean isInitializeEagerly() {
-    	return eagerInitialization.get();
+        return eagerInitialization.get();
     }
 
     @Override
     public void setInitializeEagerly(boolean retry) {
-    	eagerInitialization.set(retry);
+        eagerInitialization.set(retry);
     }
 
     @Override
@@ -1960,8 +1960,8 @@ public class OpenJPAConfigurationImpl
         getAuditorInstance();
         cacheMarshallerPlugins.initialize();
         if (isInitializeEagerly()) {
-        	getConnectionFactory();
-        	getConnectionFactory2();
+            getConnectionFactory();
+            getConnectionFactory2();
         }
     }
 
diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingDatabaseMetaData.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingDatabaseMetaData.java
index 17b0621..181344e 100644
--- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingDatabaseMetaData.java
+++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingDatabaseMetaData.java
@@ -1004,12 +1004,12 @@ public class DelegatingDatabaseMetaData implements DatabaseMetaData {
 
     @Override
     public boolean generatedKeyAlwaysReturned() throws SQLException {
-    	throw new UnsupportedOperationException();
+        return _metaData.generatedKeyAlwaysReturned();
     }
 
     @Override
     public ResultSet getPseudoColumns(String catalog, String schemaPattern,
-    	String tableNamepattern, String columnNamePattern) throws SQLException {
-    	throw new UnsupportedOperationException();
+            String tableNamepattern, String columnNamePattern) throws SQLException {
+        return _metaData.getPseudoColumns(catalog, schemaPattern, tableNamepattern, columnNamePattern);
     }
 }
diff --git a/pom.xml b/pom.xml
index c80e4a0..6f29b68 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1368,6 +1368,110 @@
             </repositories>
         </profile>
 
+        <!--
+            Profile for testing with Oracle DB against a Docker image
+
+            Attention: This might requiere a manual download of the Oracle JDBC driver.
+            This driver (ojdbc6.jar) can be downloaded at the Oracle homepage.
+
+            Then determine which version you got
+            $> unzip -p ojdbc6.jar META-INF/MANIFEST.MF
+            This will contain something like
+            "Implementation-Version: 11.2.0.4.0"
+            Use this version to install the JDBC driver into your local Maven repository
+            with
+            $> mvn install:file ...
+
+            By default we use a ojdbc6 version hosted at Atlassian.
+            For this to work we also need to add a repository section.
+            We only use it for the ojdbc driver though.
+        -->
+        <profile>
+            <id>test-oracle-docker</id>
+            <activation>
+                <property>
+                    <name>test-oracle-docker</name>
+                </property>
+            </activation>
+            <properties>
+                <!-- by default we use the Atlassian 3rd Party repo, which contains the dependency -->
+                <oracle.maven.repo>https://packages.atlassian.com/maven-3rdparty/</oracle.maven.repo>
+
+                <oracle.groupid>com.oracle</oracle.groupid>
+                <oracle.artifactid>ojdbc6</oracle.artifactid>
+                <oracle.version>11.2.0.4.0-atlassian-hosted</oracle.version>
+
+                <oracle.server.version>16.04</oracle.server.version>
+                <docker.external.oracle.port>1521</docker.external.oracle.port>
+
+                <connection.driver.name>oracle.jdbc.driver.OracleDriver</connection.driver.name>
+                <openjpa.oracle.database>openjpatst</openjpa.oracle.database>
+                <openjpa.oracle.username>openjpatst</openjpa.oracle.username>
+                <openjpa.oracle.password>openjpatst</openjpa.oracle.password>
+                <openjpa.oracle.SID>xe</openjpa.oracle.SID>
+                <openjpa.oracle.url>jdbc:oracle:thin:@localhost:${docker.external.oracle.port}:${openjpa.oracle.SID}</openjpa.oracle.url>
+
+                <connection.url>${openjpa.oracle.url}</connection.url>
+                <connection.username>${openjpa.oracle.username}</connection.username>
+                <connection.password>${openjpa.oracle.password}</connection.password>
+                <jdbc.DBDictionary />
+            </properties>
+            <dependencies>
+                <dependency>
+                    <groupId>${oracle.groupid}</groupId>
+                    <artifactId>${oracle.artifactid}</artifactId>
+                    <version>${oracle.version}</version>
+                    <scope>test</scope>
+                </dependency>
+            </dependencies>
+
+            <repositories>
+                <repository>
+                    <id>oracle.repository</id>
+                    <name>Oracle Repository</name>
+                    <url>${oracle.maven.repo}</url>
+                    <layout>default</layout>
+                    <snapshots>
+                        <enabled>false</enabled>
+                    </snapshots>
+                    <releases>
+                        <enabled>true</enabled>
+                    </releases>
+                </repository>
+            </repositories>
+
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>io.fabric8</groupId>
+                        <artifactId>docker-maven-plugin</artifactId>
+                        <configuration>
+                            <images>
+                                <image>
+                                    <name>wnameless/oracle-xe-11g:${oracle.server.version}</name>
+                                    <run>
+<!--
+                                        <env>
+                                            <ORACLE_DISABLE_ASYNCH_IO>true</ORACLE_DISABLE_ASYNCH_IO>
+                                        </env>
+-->
+                                        <volumes>
+                                            <bind>
+                                                <volume>${project.basedir}/src/test/sql/oracle-docker:/docker-entrypoint-initdb.d/</volume>
+                                            </bind>
+                                        </volumes>
+                                        <ports>
+                                            <port>${docker.external.oracle.port}:1521</port>
+                                        </ports>
+                                    </run>
+                                </image>
+                            </images>
+                        </configuration>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+
         <!-- Profile for testing with Oracle DB -->
         <profile>
             <!--
@@ -1751,7 +1855,7 @@
                 <plugin>
                     <groupId>io.fabric8</groupId>
                     <artifactId>docker-maven-plugin</artifactId>
-                    <version>0.27.2</version>
+                    <version>0.28.0</version>
                 </plugin>
                 <plugin>
                     <groupId>org.apache.maven.plugins</groupId>
diff --git a/src/test/sql/oracle-docker/init.sql b/src/test/sql/oracle-docker/init.sql
new file mode 100644
index 0000000..8886510
--- /dev/null
+++ b/src/test/sql/oracle-docker/init.sql
@@ -0,0 +1,28 @@
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements.  See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership.  The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License.  You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing,
+-- software distributed under the License is distributed on an
+-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+-- KIND, either express or implied.  See the License for the
+-- specific language governing permissions and limitations
+-- under the License.
+
+-- ***********************************************************
+-- Init script for creating a work user schema for running
+-- tests against our oracle Docker image.
+-- See the 'test-oracle-docker' Maven Profile
+-- ***********************************************************
+
+
+CREATE USER openjpatst IDENTIFIED BY openjpatst;
+GRANT CONNECT, RESOURCE, DBA TO openjpatst;
+GRANT CREATE SESSION GRANT ANY PRIVILEGE TO openjpatst;
+GRANT UNLIMITED TABLESPACE TO  openjpatst;
\ No newline at end of file