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

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


The following commit(s) were added to refs/heads/master by this push:
     new 34634d90f [OPENJPA-2938] maxIdle property is properly set; tests are 
improved (#132)
34634d90f is described below

commit 34634d90fd40dabb1ced5a7c9c6fa432ef7433bb
Author: Maxim Solodovnik <[email protected]>
AuthorDate: Fri Jul 4 12:28:23 2025 +0700

    [OPENJPA-2938] maxIdle property is properly set; tests are improved (#132)
    
    * [OPENJPA-2938] maxIdle property is properly set; tests are improved
---
 .../openjpa/jdbc/schema/DBCPDriverDataSource.java  |  6 ++--
 .../openjpa/conf/TestConnectionProperties.java     | 37 ++++++++++++++++++++++
 .../persistence/simple/TestJava8TimeTypes.java     |  3 +-
 .../src/main/resources/META-INF/persistence.xml    | 11 -------
 4 files changed, 43 insertions(+), 14 deletions(-)

diff --git 
a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DBCPDriverDataSource.java
 
b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DBCPDriverDataSource.java
index 35c631431..51cfa8d04 100644
--- 
a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DBCPDriverDataSource.java
+++ 
b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DBCPDriverDataSource.java
@@ -187,12 +187,14 @@ extends SimpleDriverDataSource implements Configurable, 
Closeable {
         }
 
         // set some default properties for DBCP
-        if (hasKey(dbcpProps, "maxActive") == null) {
+        String maxActiveKey = hasKey(dbcpProps, "maxActive");
+        if (maxActiveKey == null) {
             dbcpProps.setProperty("maxActive", "10");
+            maxActiveKey = "maxActive";
         }
         if (hasKey(dbcpProps, "maxIdle") == null) {
             // by default we set maxIdle to the same value as maxActive.
-            dbcpProps.setProperty("maxIdle", 
dbcpProps.getProperty("maxActive"));
+            dbcpProps.setProperty("maxIdle", 
dbcpProps.getProperty(maxActiveKey));
         }
         if (hasKey(dbcpProps, "minIdle") == null) {
             dbcpProps.setProperty("minIdle", "0");
diff --git 
a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/conf/TestConnectionProperties.java
 
b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/conf/TestConnectionProperties.java
new file mode 100644
index 000000000..d6ba5f4cc
--- /dev/null
+++ 
b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/conf/TestConnectionProperties.java
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ */
+package org.apache.openjpa.conf;
+
+import org.apache.openjpa.persistence.OpenJPAEntityManager;
+import org.apache.openjpa.persistence.test.SingleEMFTestCase;
+
+public class TestConnectionProperties extends SingleEMFTestCase {
+    @Override
+    public void setUp() throws Exception {
+        super.setUp(new Object[] { "openjpa.ConnectionProperties",
+            "autoReconnect=true,MaxActive=10,MaxWait=6000,TestOnBorrow=true"
+        });
+        emf.createEntityManager().close();
+    }
+
+    public void testEmWithProps() {
+        OpenJPAEntityManager em = emf.createEntityManager();
+        em.close();
+    }
+}
diff --git 
a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/simple/TestJava8TimeTypes.java
 
b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/simple/TestJava8TimeTypes.java
index 1f77be4f4..6a16db356 100644
--- 
a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/simple/TestJava8TimeTypes.java
+++ 
b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/simple/TestJava8TimeTypes.java
@@ -65,7 +65,7 @@ public class TestJava8TimeTypes extends SingleEMFTestCase {
         // it still can fail in case will be started exactly at midnight
         entity2.setId(2);
         entity2.setOldDateField(new Date());
-        entity2.setLocalTimeField(LocalTime.now().minusNanos(1));
+        entity2.setLocalTimeField(LocalTime.now().minusSeconds(1)); // 
hopefully test will pass in 1 sec
         entity2.setLocalDateField(LocalDate.parse(VAL_LOCAL_DATE));
         entity2.setLocalDateTimeField(LocalDateTime.parse(VAL_LOCAL_DATETIME));
         
entity2.setOffsetTimeField(entity2.getLocalTimeField().atOffset(ZoneOffset.ofHours(-9)));
@@ -260,6 +260,7 @@ public class TestJava8TimeTypes extends SingleEMFTestCase {
         final TypedQuery<Java8TimeTypes> qry
                 = em.createQuery("select j from Java8TimeTypes AS j where 
j.localTimeField < LOCAL TIME", Java8TimeTypes.class);
         final List<Java8TimeTypes> times = qry.getResultList();
+System.err.println(times);
         assertNotNull(times);
         assertFalse(times.isEmpty());
         em.close();
diff --git 
a/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionRefresh/src/main/resources/META-INF/persistence.xml
 
b/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionRefresh/src/main/resources/META-INF/persistence.xml
index 6bdeabbf3..ff4dd7ce0 100644
--- 
a/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionRefresh/src/main/resources/META-INF/persistence.xml
+++ 
b/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionRefresh/src/main/resources/META-INF/persistence.xml
@@ -20,16 +20,5 @@
     <!-- simply all annotated persistent entities will be part of this unit-->
     <persistence-unit name="TestUnit">
         <class>org.apache.openjpa.tools.maven.testentity.TestEntity</class>
-<!-- TODO REMOVE
-        <properties>
-            <property name="openjpa.ConnectionDriverName" 
value="org.hsqldb.jdbcDriver" />
-            <property name="openjpa.ConnectionURL" 
value="jdbc:hsqldb:file:openjpa-hsqldb" />
-            <property name="openjpa.ConnectionUserName" value="SA" />
-            <property name="openjpa.ConnectionPassword" value="" />
-        </properties>
--->
-
     </persistence-unit>
-
 </persistence>
-

Reply via email to