diff --git a/pom.xml b/pom.xml index 38626f7bbea23163653063c98678fbff84bc807e..2870e0374c283cecc3d129bb8d7386c2898cc242 100644 --- a/pom.xml +++ b/pom.xml @@ -65,11 +65,11 @@ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <targetJdk>1.7</targetJdk> <org.springframework.version>3.2.13.RELEASE</org.springframework.version> - <org.hibernate.version>4.3.8.Final</org.hibernate.version> + <org.hibernate.version>4.3.9.Final</org.hibernate.version> <com.sun.jersey.version>1.17.1</com.sun.jersey.version> <jackson.version>1.9.2</jackson.version> <org.mysql.version>5.1.34</org.mysql.version> - <org.postgresql.version>9.4-1200-jdbc41</org.postgresql.version> + <org.postgresql.version>9.4-1201-jdbc41</org.postgresql.version> <org.infinispan.version>6.0.2.Final</org.infinispan.version> <lucene.version>4.8.0</lucene.version> <version.selenium>2.43.1</version.selenium> @@ -1260,6 +1260,15 @@ <forkMode>always</forkMode> <systemProperties> <profile>${test.env}</profile> + <test.env.db.name>${test.env.db.name}</test.env.db.name> + <test.env.db.user>${test.env.db.user}</test.env.db.user> + <test.env.db.pass>${test.env.db.pass}</test.env.db.pass> + <test.env.db.host.port>${test.env.db.host.port}</test.env.db.host.port> + <test.env.db.postgresql.user>${test.env.db.postgresql.user}</test.env.db.postgresql.user> + <test.env.db.postgresql.pass>${test.env.db.postgresql.pass}</test.env.db.postgresql.pass> + <test.env.db.postgresql.host.port>${test.env.db.postgresql.host.port}</test.env.db.postgresql.host.port> + <test.env.instance.id>${test.env.instance.id}</test.env.instance.id> + <test.env.jmx.rmi.port.0>${test.env.jmx.rmi.port.0}</test.env.jmx.rmi.port.0> <arquillian.launch>tomcat-7-managed</arquillian.launch> </systemProperties> <testNGArtifactName>none:none</testNGArtifactName> diff --git a/src/main/java/org/olat/core/commons/persistence/_spring/databaseCorecontext.xml b/src/main/java/org/olat/core/commons/persistence/_spring/databaseCorecontext.xml index b2034b75d43d27b033732c17a12a2d06cf5e809e..35b93b4403f556de317dbfba929c0d92b3bad65c 100644 --- a/src/main/java/org/olat/core/commons/persistence/_spring/databaseCorecontext.xml +++ b/src/main/java/org/olat/core/commons/persistence/_spring/databaseCorecontext.xml @@ -197,8 +197,6 @@ <constructor-arg> <props> <prop key="hibernate.connection.provider_class">com.zaxxer.hikari.hibernate.HikariConnectionProvider</prop> - <!-- Min pool size --> - <prop key="hibernate.hikari.minimumPoolSize">${db.hibernate.hikari.minsize}</prop> <!-- Max pool size , mysql-default value is 100, If you need to support more connections, you should set a larger value for this variable in mysql config --> <prop key="hibernate.hikari.maximumPoolSize">${db.hibernate.hikari.maxsize}</prop> <prop key="hibernate.hikari.minimumIdle">4</prop> diff --git a/src/test/java/org/olat/test/ArquillianDeployments.java b/src/test/java/org/olat/test/ArquillianDeployments.java index 848217c67d2ad545914ea6e20d461d5b09a1ef7f..11a247dd9a6a4f447c4e6ed0468d08b081727c04 100644 --- a/src/test/java/org/olat/test/ArquillianDeployments.java +++ b/src/test/java/org/olat/test/ArquillianDeployments.java @@ -21,11 +21,21 @@ package org.olat.test; import java.io.File; import java.io.FileFilter; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.StringWriter; +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; import org.jboss.shrinkwrap.api.ArchivePath; import org.jboss.shrinkwrap.api.Filter; import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.Asset; +import org.jboss.shrinkwrap.api.asset.StringAsset; import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.springframework.util.PropertyPlaceholderHelper; public class ArquillianDeployments { @@ -52,14 +62,42 @@ public class ArquillianDeployments { addResourceRecursive(new File(MAIN_JAVA), null, new JavaResourcesFilter(), archive); addResourceRecursive(new File(MAIN_RSRC), null, new AllFileFilter(), archive); addWebResourceRecursive(new File(WEBAPP), "static", new StaticFileFilter(), archive); - + addOlatLocalProperties(archive); + archive.setWebXML(new File(WEBINF_TOMCAT, "web.xml")); + return archive; + } + + public static WebArchive addOlatLocalProperties(WebArchive archive) { String profile = System.getProperty("profile"); if(profile == null || profile.isEmpty()) { profile = "mysql"; } - archive.addAsResource(new File("src/test/profile/" + profile, "olat.local.properties"), "olat.local.properties"); - archive.setWebXML(new File(WEBINF_TOMCAT, "web.xml")); - return archive; + + File barebonePropertiesFile = new File("src/test/profile/" + profile, "olat.local.properties"); + PropertyPlaceholderHelper helper = new PropertyPlaceholderHelper("${", "}", ":", true); + + Asset propertiesAsset = null; + try(InputStream inStream = new FileInputStream(barebonePropertiesFile)) { + + Properties properties = new Properties(); + properties.load(inStream); + + List<String> propNames = new ArrayList<>(properties.stringPropertyNames()); + Properties updatedProperties = new Properties(); + for(String name:propNames) { + String value = properties.getProperty(name); + String replacedValue = helper.replacePlaceholders(value, new PropertyPlaceholderResolver(properties)); + updatedProperties.setProperty(name, replacedValue); + } + + StringWriter writer = new StringWriter(); + updatedProperties.store(writer, "Replaced for Arquillian deployements"); + propertiesAsset = new StringAsset(writer.toString()); + } catch (IOException e) { + e.printStackTrace(); + } + + return archive.addAsResource(propertiesAsset, "olat.local.properties"); } public static WebArchive addLibraries(WebArchive archive) { @@ -202,4 +240,31 @@ public class ArquillianDeployments { return !exclude; } } + + private static class PropertyPlaceholderResolver implements PropertyPlaceholderHelper.PlaceholderResolver { + + private final Properties properties; + + public PropertyPlaceholderResolver(Properties properties) { + this.properties = properties; + } + + public String resolvePlaceholder(String placeholderName) { + try { + String propVal = System.getProperty(placeholderName); + if (propVal == null) { + // Fall back to searching the system environment. + propVal = System.getenv(placeholderName); + if(propVal == null) { + propVal = properties.getProperty(placeholderName); + } + } + return propVal; + } + catch (Throwable ex) { + System.err.println("Could not resolve placeholder '" + placeholderName + "' in as system property: " + ex); + return null; + } + } + } }