aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/io/trygvis/esper/testing/Config.java10
-rw-r--r--src/main/java/io/trygvis/esper/testing/web/JerseyApplication.java3
-rw-r--r--src/main/java/io/trygvis/esper/testing/web/MissingShiroJdbcRealm.java9
-rw-r--r--src/main/java/io/trygvis/esper/testing/web/WebConfig.java17
4 files changed, 35 insertions, 4 deletions
diff --git a/src/main/java/io/trygvis/esper/testing/Config.java b/src/main/java/io/trygvis/esper/testing/Config.java
index 13ef1cd..5beb9bb 100644
--- a/src/main/java/io/trygvis/esper/testing/Config.java
+++ b/src/main/java/io/trygvis/esper/testing/Config.java
@@ -48,6 +48,8 @@ public class Config {
public final String databaseUsername;
public final String databasePassword;
+ private BoneCPDataSource dataSource;
+
public Config(GitoriousConfig gitorious, long nexusUpdateInterval, long jenkinsUpdateInterval, String databaseUrl,
String databaseUsername, String databasePassword) {
this.gitorious = gitorious;
@@ -89,12 +91,16 @@ public class Config {
}
public BoneCPDataSource createBoneCp() throws SQLException {
- return new BoneCPDataSource(new BoneCPConfig(){{
+ if (dataSource != null) {
+ return dataSource;
+ }
+
+ return dataSource = new BoneCPDataSource(new BoneCPConfig() {{
setJdbcUrl(databaseUrl);
setUsername(databaseUsername);
setPassword(databasePassword);
setDefaultAutoCommit(false);
- setCloseConnectionWatch(true);
+ setCloseConnectionWatch(false);
setMaxConnectionsPerPartition(10);
}});
}
diff --git a/src/main/java/io/trygvis/esper/testing/web/JerseyApplication.java b/src/main/java/io/trygvis/esper/testing/web/JerseyApplication.java
index 8d071a9..6937804 100644
--- a/src/main/java/io/trygvis/esper/testing/web/JerseyApplication.java
+++ b/src/main/java/io/trygvis/esper/testing/web/JerseyApplication.java
@@ -10,8 +10,7 @@ public class JerseyApplication extends Application {
private final DatabaseAccess da;
public JerseyApplication() throws Exception {
- Config config = Config.loadFromDisk();
- this.da = new DatabaseAccess(config.createBoneCp());
+ this.da = new DatabaseAccess(WebConfig.config.createBoneCp());
}
@Override
diff --git a/src/main/java/io/trygvis/esper/testing/web/MissingShiroJdbcRealm.java b/src/main/java/io/trygvis/esper/testing/web/MissingShiroJdbcRealm.java
new file mode 100644
index 0000000..0aacf7f
--- /dev/null
+++ b/src/main/java/io/trygvis/esper/testing/web/MissingShiroJdbcRealm.java
@@ -0,0 +1,9 @@
+package io.trygvis.esper.testing.web;
+
+import org.apache.shiro.realm.jdbc.*;
+
+public class MissingShiroJdbcRealm extends JdbcRealm {
+ public MissingShiroJdbcRealm() throws Exception {
+ setDataSource(WebConfig.config.createBoneCp());
+ }
+}
diff --git a/src/main/java/io/trygvis/esper/testing/web/WebConfig.java b/src/main/java/io/trygvis/esper/testing/web/WebConfig.java
new file mode 100644
index 0000000..02fb4ff
--- /dev/null
+++ b/src/main/java/io/trygvis/esper/testing/web/WebConfig.java
@@ -0,0 +1,17 @@
+package io.trygvis.esper.testing.web;
+
+import io.trygvis.esper.testing.*;
+
+import java.io.*;
+
+public class WebConfig {
+ public static final Config config;
+
+ static {
+ try {
+ config = Config.loadFromDisk();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}