You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rz...@apache.org on 2021/02/12 12:30:42 UTC
[tomee] branch tomee-7.0.x updated: TOMEE-2125: Datasource Config:
MaxWait,
TimeBetweenEvictionRunsMillis and MinEvictableIdleTimeMillis are ignored
This is an automated email from the ASF dual-hosted git repository.
rzo1 pushed a commit to branch tomee-7.0.x
in repository https://gitbox.apache.org/repos/asf/tomee.git
The following commit(s) were added to refs/heads/tomee-7.0.x by this push:
new f0e2ccf TOMEE-2125: Datasource Config: MaxWait, TimeBetweenEvictionRunsMillis and MinEvictableIdleTimeMillis are ignored
f0e2ccf is described below
commit f0e2ccf1d49c500218a6c562297d327613810675
Author: Richard Zowalla <13...@users.noreply.github.com>
AuthorDate: Fri Feb 12 12:57:23 2021 +0100
TOMEE-2125: Datasource Config: MaxWait, TimeBetweenEvictionRunsMillis and MinEvictableIdleTimeMillis are ignored
(cherry picked from commit 495978a3edbaf433d4087988c6cbdb1793172b8c)
---
.../openejb/resource/jdbc/DataSourceFactory.java | 2 +-
.../jdbc/TomcatDataSourceConfigurationTest.java | 83 ++++++++++++++++++++++
2 files changed, 84 insertions(+), 1 deletion(-)
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/DataSourceFactory.java b/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/DataSourceFactory.java
index e0db5e3..e103145 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/DataSourceFactory.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/DataSourceFactory.java
@@ -412,7 +412,7 @@ public class DataSourceFactory {
properties.remove(key);
// If someone is using the legacy property, use it
- if (properties.contains(oldKey)) {
+ if (properties.containsKey(oldKey)) {
return;
}
properties.remove(oldKey);
diff --git a/tomee/tomee-jdbc/src/test/java/org/apache/tomee/jdbc/TomcatDataSourceConfigurationTest.java b/tomee/tomee-jdbc/src/test/java/org/apache/tomee/jdbc/TomcatDataSourceConfigurationTest.java
new file mode 100644
index 0000000..f2f8892
--- /dev/null
+++ b/tomee/tomee-jdbc/src/test/java/org/apache/tomee/jdbc/TomcatDataSourceConfigurationTest.java
@@ -0,0 +1,83 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.tomee.jdbc;
+
+import org.apache.openejb.jee.EjbJar;
+import org.apache.openejb.junit.ApplicationComposer;
+import org.apache.openejb.resource.jdbc.managed.local.ManagedDataSource;
+import org.apache.openejb.testing.Configuration;
+import org.apache.openejb.testing.Module;
+import org.apache.openejb.testng.PropertiesBuilder;
+import org.apache.tomcat.jdbc.pool.PoolConfiguration;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.annotation.Resource;
+import javax.sql.DataSource;
+import java.util.Properties;
+
+import static org.junit.Assert.*;
+
+@RunWith(ApplicationComposer.class)
+public class TomcatDataSourceConfigurationTest {
+ @Resource(name = "test")
+ private DataSource ds;
+
+ @Module
+ public EjbJar mandatory() {
+ return new EjbJar();
+ }
+
+ @Configuration
+ public Properties props() {
+ final String prefix = getClass().getSimpleName();
+ return new PropertiesBuilder()
+ .p("openejb.jdbc.datasource-creator", TomEEDataSourceCreator.class.getName())
+ .p(prefix, "new://Resource?type=DataSource&name=test")
+ .p(prefix + ".JdbcDriver", "org.hsqldb.jdbcDriver")
+ .p(prefix + ".JdbcUrl", "jdbc:hsqldb:mem:tomeeDSConfigTest")
+ .p(prefix + ".InitialSize", "15")
+ .p(prefix + ".JtaManaged", "true")
+ .p(prefix + ".MaxWait", "5000")
+ .p(prefix + ".MinEvictableIdleTimeMillis", "7200000")
+ .p(prefix + ".TimeBetweenEvictionRuns", "7300000")
+ .build();
+ }
+
+ /*
+ * TOMEE-2125
+ */
+ @Test
+ public void testPoolConfiguration() {
+ assertNotNull(ds);
+ final TomEEDataSourceCreator.TomEEDataSource tds = TomEEDataSourceCreator.TomEEDataSource.class.cast(ManagedDataSource.class.cast(ds).getDelegate());
+
+ assertNotNull(tds);
+
+ PoolConfiguration poolConfig = tds.getPool().getPoolProperties();
+ assertNotNull(poolConfig);
+ assertEquals("test", poolConfig.getName());
+ assertEquals("jdbc:hsqldb:mem:tomeeDSConfigTest", poolConfig.getUrl());
+ assertEquals("org.hsqldb.jdbcDriver", poolConfig.getDriverClassName());
+ assertEquals("test", poolConfig.getName());
+ assertEquals(5000, poolConfig.getMaxWait());
+ assertEquals(7200000, poolConfig.getMinEvictableIdleTimeMillis());
+ assertEquals(7300000, poolConfig.getTimeBetweenEvictionRunsMillis());
+ }
+
+
+}