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 35c6314317..51cfa8d04f 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 @@ private Properties updateDBCPProperties(Properties props) { } // 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 0000000000..d6ba5f4cc5 --- /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 1f77be4f4e..6a16db356f 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 void setUp() { // 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 void testGetCurrentLocalTime() { 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 6bdeabbf38..ff4dd7ce01 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> -