Changed DB connection (fixed #670)
Change-Id: Ia27404c54e1473662a99b019969f81fd86761740
diff --git a/full/Changes b/full/Changes
index 85fecd4..2b3bae0 100644
--- a/full/Changes
+++ b/full/Changes
@@ -8,6 +8,7 @@
- Fixed missing project.version in info web-service
- Make sure totalResults and other numeric results are numbers (Kupietz)
- Introduce CQP query language in Koral 0.41
+- Changed DB connection (fixed #670)
# version 0.70.1
diff --git a/full/src/main/resources/default-config.xml b/full/src/main/resources/default-config.xml
index 7882650..7cda1cd 100644
--- a/full/src/main/resources/default-config.xml
+++ b/full/src/main/resources/default-config.xml
@@ -112,8 +112,8 @@
<!-- <property name="validateOnMigrate" value="false" /> -->
<!-- <property name="cleanOnValidationError" value="true" /> -->
<property name="locations" value="#{'${jdbc.schemaPath}'.split(',')}"/>
- <!-- <property name="dataSource" ref="dataSource" /> -->
- <property name="dataSource" ref="sqliteDataSource" />
+ <property name="dataSource" ref="dataSource" />
+ <!-- <property name="dataSource" ref="sqliteDataSource" /> -->
<!-- <property name="dataSource" ref="c3p0DataSource" /> -->
<property name="outOfOrder" value="true" />
</bean>
@@ -125,8 +125,8 @@
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
depends-on="flyway">
- <!-- <property name="dataSource" ref="dataSource" /> -->
- <property name="dataSource" ref="sqliteDataSource" />
+ <property name="dataSource" ref="dataSource" />
+ <!-- <property name="dataSource" ref="sqliteDataSource" /> -->
<!-- <property name="dataSource" ref="c3p0DataSource" /> -->
<property name="packagesToScan">
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2PluginTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2PluginTest.java
index 4a469bc..5e33841 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2PluginTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2PluginTest.java
@@ -4,8 +4,18 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
import javax.ws.rs.ProcessingException;
import javax.ws.rs.client.Entity;
@@ -37,6 +47,9 @@
private String username = "plugin-user";
@Autowired
private InstalledPluginDao pluginDao;
+
+ private final AtomicBoolean testFailed = new AtomicBoolean(false);
+
@Test
public void testRegisterPlugin () throws
@@ -220,6 +233,68 @@
node.at("/errors/0/0").asInt());
}
+
+
+ @Test
+ public void testListPluginsConcurrent () throws InterruptedException {
+ ExecutorService executorService = Executors.newFixedThreadPool(3);
+ List<Future<Void>> futures = new ArrayList<>();
+
+ for (int i = 0; i < 3; i++) {
+ futures.add(executorService
+ .submit(new PluginListCallable("Thread " + (i + 1))));
+ }
+
+ executorService.shutdown();
+ executorService.awaitTermination(2, TimeUnit.SECONDS);
+
+ for (Future<Void> future : futures) {
+ try {
+ future.get(); // This will re-throw any exceptions
+ // that occurred in threads
+ }
+ catch (ExecutionException e) {
+ fail("Test failed: " + e.getCause().getMessage());
+ }
+ }
+ }
+
+ class PluginListCallable implements Callable<Void> {
+ private final String name;
+
+ public PluginListCallable (String name) {
+ this.name = name;
+ }
+
+ @Override
+ public Void call () {
+ Form form = getSuperClientForm();
+ try {
+ Response response = target().path(API_VERSION).path("plugins")
+ .request()
+ .header(Attributes.AUTHORIZATION,
+ HttpAuthorizationHandler
+ .createBasicAuthorizationHeaderValue(
+ username, "pass"))
+ .header(HttpHeaders.CONTENT_TYPE,
+ ContentType.APPLICATION_FORM_URLENCODED)
+ .post(Entity.form(form));
+
+ assertEquals(Status.OK.getStatusCode(), response.getStatus());
+
+ String entity = response.readEntity(String.class);
+ JsonNode node = JsonUtils.readTree(entity);
+ assertEquals(2, node.size());
+ }
+ catch (KustvaktException e) {
+ e.printStackTrace();
+ throw new RuntimeException(name, e);
+ }
+ return null;
+ }
+ }
+
+
@Test
public void testListAllPlugins () throws
ProcessingException, KustvaktException {
diff --git a/full/src/test/resources/test-config.xml b/full/src/test/resources/test-config.xml
index 4ef13dc..a49795e 100644
--- a/full/src/test/resources/test-config.xml
+++ b/full/src/test/resources/test-config.xml
@@ -104,8 +104,8 @@
<property name="cleanOnValidationError" value="true" />
<property name="baselineOnMigrate" value="false" />
<property name="locations" value="#{'${jdbc.schemaPath}'.split(',')}"/>
- <property name="dataSource" ref="sqliteDataSource" />
- <!-- <property name="dataSource" ref="dataSource" /> -->
+ <!-- <property name="dataSource" ref="sqliteDataSource" /> -->
+ <property name="dataSource" ref="dataSource" />
<property name="outOfOrder" value="true" />
</bean>
@@ -116,8 +116,8 @@
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
- <!-- <property name="dataSource" ref="dataSource" /> -->
- <property name="dataSource" ref="sqliteDataSource" />
+ <property name="dataSource" ref="dataSource" />
+ <!-- <property name="dataSource" ref="sqliteDataSource" /> -->
<property name="packagesToScan">
<array>
<value>de.ids_mannheim.korap.core.entity</value>
diff --git a/full/src/test/resources/test-jdbc.properties b/full/src/test/resources/test-jdbc.properties
index 48f51f5..958cd53 100644
--- a/full/src/test/resources/test-jdbc.properties
+++ b/full/src/test/resources/test-jdbc.properties
@@ -3,7 +3,8 @@
jdbc.database=sqlite
jdbc.driverClassName=org.sqlite.JDBC
-jdbc.url=jdbc:sqlite::memory:
+#jdbc.url=jdbc:sqlite::memory:
+jdbc.url=jdbc:sqlite::memory:?cache=shared
#jdbc.url=jdbc:sqlite:testDB.sqlite
jdbc.username=pc
jdbc.password=pc