From 6f4b0c54784abd0a15c6eba26a9ae6a7f106fcd0 Mon Sep 17 00:00:00 2001
From: sherzinger <sascha.herzinger@uni.lu>
Date: Thu, 8 Nov 2018 11:19:50 +0100
Subject: [PATCH] Migrated Reactome tests to new format (still some issues with
 Cache)

---
 .../reactome/ReactomeTestFunctions.java       |  7 +---
 .../reactome/SpringReactomeTestConfig.java    | 18 +++++++++
 .../resources/test-applicationContext.xml     | 15 -------
 .../src/test/resources/test-dataSource.xml    | 40 -------------------
 .../src/test/resources/test-db.properties     |  3 --
 5 files changed, 19 insertions(+), 64 deletions(-)
 create mode 100644 reactome/src/test/java/lcsb/mapviewer/reactome/SpringReactomeTestConfig.java
 delete mode 100644 reactome/src/test/resources/test-applicationContext.xml
 delete mode 100644 reactome/src/test/resources/test-dataSource.xml
 delete mode 100644 reactome/src/test/resources/test-db.properties

diff --git a/reactome/src/test/java/lcsb/mapviewer/reactome/ReactomeTestFunctions.java b/reactome/src/test/java/lcsb/mapviewer/reactome/ReactomeTestFunctions.java
index aa526b7c56..277d349526 100644
--- a/reactome/src/test/java/lcsb/mapviewer/reactome/ReactomeTestFunctions.java
+++ b/reactome/src/test/java/lcsb/mapviewer/reactome/ReactomeTestFunctions.java
@@ -51,12 +51,7 @@ import lcsb.mapviewer.reactome.utils.ReactomeQueryUtil;
 
 @Transactional
 @Rollback(false)
-@ContextConfiguration(locations = { "/applicationContext-annotation.xml",
-    "/applicationContext-reactome.xml",
-    "/applicationContext-persist.xml",
-    "/test-applicationContext.xml",
-    "/test-dataSource.xml",
-})
+@ContextConfiguration(classes = SpringReactomeTestConfig.class)
 @RunWith(SpringJUnit4ClassRunner.class)
 public abstract class ReactomeTestFunctions {
   private Logger logger = Logger.getLogger(ReactomeTestFunctions.class);
diff --git a/reactome/src/test/java/lcsb/mapviewer/reactome/SpringReactomeTestConfig.java b/reactome/src/test/java/lcsb/mapviewer/reactome/SpringReactomeTestConfig.java
new file mode 100644
index 0000000000..f502938425
--- /dev/null
+++ b/reactome/src/test/java/lcsb/mapviewer/reactome/SpringReactomeTestConfig.java
@@ -0,0 +1,18 @@
+package lcsb.mapviewer.reactome;
+
+import lcsb.mapviewer.persist.SpringPersistConfig;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
+import org.springframework.security.crypto.password.NoOpPasswordEncoder;
+
+@Configuration
+@Import({SpringPersistConfig.class, SpringReactomeConfig.class})
+public class SpringReactomeTestConfig {
+
+  @Bean
+  public NoOpPasswordEncoder passwordEncoder() {
+    return (NoOpPasswordEncoder) NoOpPasswordEncoder.getInstance();
+  }
+
+}
diff --git a/reactome/src/test/resources/test-applicationContext.xml b/reactome/src/test/resources/test-applicationContext.xml
deleted file mode 100644
index 9d15139c8c..0000000000
--- a/reactome/src/test/resources/test-applicationContext.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-<beans xmlns="http://www.springframework.org/schema/beans"
-	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-	xmlns:tx="http://www.springframework.org/schema/tx"
-	xmlns:context="http://www.springframework.org/schema/context"
-	xsi:schemaLocation="http://www.springframework.org/schema/beans
-		http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
-		http://www.springframework.org/schema/tx 
-		http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
-		http://www.springframework.org/schema/context 
-		http://www.springframework.org/schema/context/spring-context-4.0.xsd">
-
-	<!-- Testing Password Encoder used for hashing passwords -->
-	<bean id="PasswordEncoder" class="org.springframework.security.crypto.password.NoOpPasswordEncoder"/>
-
-</beans>
diff --git a/reactome/src/test/resources/test-dataSource.xml b/reactome/src/test/resources/test-dataSource.xml
deleted file mode 100644
index 6374a21fde..0000000000
--- a/reactome/src/test/resources/test-dataSource.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<beans xmlns="http://www.springframework.org/schema/beans"
-	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-	xmlns:tx="http://www.springframework.org/schema/tx"
-	xmlns:context="http://www.springframework.org/schema/context"
-	xsi:schemaLocation="http://www.springframework.org/schema/beans
-		http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
-		http://www.springframework.org/schema/tx 
-		http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
-		http://www.springframework.org/schema/context 
-		http://www.springframework.org/schema/context/spring-context-4.0.xsd">
-
-	<context:property-placeholder
-		ignore-resource-not-found="true"
-		location="classpath:test-db.properties,file:/etc/minerva/test-db.properties" />
-
-
-	<!-- Data Source Declaration -->
-	<bean id="DataSource"
-		class="com.mchange.v2.c3p0.ComboPooledDataSource"
-		destroy-method="close">
-		<property name="driverClass" value="org.postgresql.Driver" />
-		<property name="jdbcUrl" value="${database.uri}" />
-		<property name="user" value="${database.username}" />
-		<property name="password" value="${database.password}" />
-		<property name="maxPoolSize" value="90" />
-		<property name="maxStatements" value="5" />
-		<property name="minPoolSize" value="5" />
-	</bean>
-
-    <bean id="DbInit" class="lcsb.mapviewer.persist.CustomDatabasePopulator">
-        <property name="dataSource"><ref bean="DataSource"/></property>
-    </bean>
-    
-	<bean id="startupScripts" class="org.springframework.jdbc.datasource.init.DataSourceInitializer">
-        <property name="dataSource"><ref bean="DataSource"/></property>
-        <property name="databasePopulator"><ref bean="DbInit"/></property>
-        <property name="enabled" value="true"/>
-    </bean>
-
-</beans>
diff --git a/reactome/src/test/resources/test-db.properties b/reactome/src/test/resources/test-db.properties
deleted file mode 100644
index e1edfb39ac..0000000000
--- a/reactome/src/test/resources/test-db.properties
+++ /dev/null
@@ -1,3 +0,0 @@
-database.uri=jdbc:postgresql://localhost:5432/map_viewer
-database.username=map_viewer
-database.password=123qweasdzxc
\ No newline at end of file
-- 
GitLab