tests and bean loader hot fix
diff --git a/src/test/java/de/ids_mannheim/korap/config/BeanConfigTest.java b/src/test/java/de/ids_mannheim/korap/config/BeanConfigTest.java
index 266b784..5ddb6dd 100644
--- a/src/test/java/de/ids_mannheim/korap/config/BeanConfigTest.java
+++ b/src/test/java/de/ids_mannheim/korap/config/BeanConfigTest.java
@@ -2,6 +2,7 @@
 
 import de.ids_mannheim.korap.exceptions.KustvaktException;
 import net.jcip.annotations.NotThreadSafe;
+import org.apache.log4j.Logger;
 import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.BeforeClass;
@@ -28,13 +29,16 @@
 @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
 public abstract class BeanConfigTest {
 
+
+    private static Logger jlog = Logger.getLogger(BeanConfigTest.class);
+
     @Autowired
     private ApplicationContext context;
 
 
     public void init () throws Exception {
         assertNotNull("Application context must not be null!", this.context);
-        System.out.println("running one-time before init for class "
+        jlog.debug("running one-time before init for class "
                 + this.getClass().getSimpleName() + " ...");
         initMethod();
         BeansFactory.setKustvaktContext(helper().getContext());
diff --git a/src/test/java/de/ids_mannheim/korap/config/LoaderTest.java b/src/test/java/de/ids_mannheim/korap/config/LoaderTest.java
index ce4de02..192c561 100644
--- a/src/test/java/de/ids_mannheim/korap/config/LoaderTest.java
+++ b/src/test/java/de/ids_mannheim/korap/config/LoaderTest.java
@@ -61,12 +61,12 @@
         while (!set.isEmpty()) {
             out_loop: for (BootableBeanInterface iface : new ArrayList<>(list)) {
                 try {
-                    System.out.println("Running boot instructions from class "
-                            + iface.getClass().getSimpleName());
                     for (Class cl : iface.getDependencies()) {
                         if (set.contains(cl))
                             continue out_loop;
                     }
+                    System.out.println("Running boot instructions from class "
+                            + iface.getClass().getSimpleName());
                     set.remove(iface.getClass());
                     list.remove(iface);
                     iface.load(helper().getContext());
diff --git a/src/test/java/de/ids_mannheim/korap/handlers/UserDaoTest.java b/src/test/java/de/ids_mannheim/korap/handlers/UserDaoTest.java
index d3bdc84..32e53d1 100644
--- a/src/test/java/de/ids_mannheim/korap/handlers/UserDaoTest.java
+++ b/src/test/java/de/ids_mannheim/korap/handlers/UserDaoTest.java
@@ -10,6 +10,7 @@
 import de.ids_mannheim.korap.user.UserDetails;
 import de.ids_mannheim.korap.user.UserSettings;
 import de.ids_mannheim.korap.user.Userdata;
+import org.junit.Ignore;
 import org.junit.Test;
 
 import static org.junit.Assert.assertEquals;
@@ -46,26 +47,32 @@
     }
 
 
-    //    @Test
+    @Test
+    @Ignore
     public void testUserdetailsGetNonExistent () throws KustvaktException {
         helper().setupSimpleAccount("userdbtest", "userdbTest");
         User user = helper().getContext().getUserDBHandler()
                 .getAccount("userdbtest");
-        UserDataDbIface dao = BeansFactory.getTypeFactory().getTypedBean(
-                helper().getContext().getUserDataDaos(), UserDetails.class);
+        UserDataDbIface dao = BeansFactory.getTypeFactory()
+                .getTypeInterfaceBean(
+                        helper().getContext().getUserDataProviders(),
+                        UserDetails.class);
         Userdata data = dao.get(user);
         assertNull(data);
         helper().dropUser("userdbtest");
     }
 
 
-    //    @Test
+    @Test
+    @Ignore
     public void testUserSettingsGetNonExistent () throws KustvaktException {
         helper().setupSimpleAccount("userdbtest", "userdbTest");
         User user = helper().getContext().getUserDBHandler()
                 .getAccount("userdbtest");
-        UserDataDbIface dao = BeansFactory.getTypeFactory().getTypedBean(
-                helper().getContext().getUserDataDaos(), UserSettings.class);
+        UserDataDbIface dao = BeansFactory.getTypeFactory()
+                .getTypeInterfaceBean(
+                        helper().getContext().getUserDataProviders(),
+                        UserSettings.class);
         Userdata data = dao.get(user);
         assertNull(data);
         helper().dropUser("userdbtest");
@@ -74,7 +81,8 @@
 
 
     // username cannot currently be changed
-    //    @Test
+    @Test
+    @Ignore
     public void updateUsername () throws KustvaktException {
         User user1 = helper().getContext().getUserDBHandler()
                 .getAccount(TestHelper.getUserCredentials()[0]);
diff --git a/src/test/java/de/ids_mannheim/korap/resource/rewrite/CollectionRewriteTest.java b/src/test/java/de/ids_mannheim/korap/resource/rewrite/CollectionRewriteTest.java
index 227be22..90e37eb 100644
--- a/src/test/java/de/ids_mannheim/korap/resource/rewrite/CollectionRewriteTest.java
+++ b/src/test/java/de/ids_mannheim/korap/resource/rewrite/CollectionRewriteTest.java
@@ -46,7 +46,8 @@
 
 
     @Test
-    public void testCollectionNodeRemoveCorpusIdNoErrors () {
+    public void testCollectionNodeRemoveCorpusIdNoErrors ()
+            throws KustvaktException {
         RewriteHandler handler = new RewriteHandler();
         handler.insertBeans(helper().getContext());
         handler.add(CollectionConstraint.class);
@@ -68,7 +69,8 @@
 
 
     @Test
-    public void testCollectionNodeRemoveAllCorpusIdNoErrors () {
+    public void testCollectionNodeRemoveAllCorpusIdNoErrors ()
+            throws KustvaktException {
         RewriteHandler handler = new RewriteHandler();
         handler.insertBeans(helper().getContext());
         handler.add(CollectionConstraint.class);
@@ -88,7 +90,8 @@
 
 
     @Test
-    public void testCollectionNodeRemoveGroupedCorpusIdNoErrors () {
+    public void testCollectionNodeRemoveGroupedCorpusIdNoErrors ()
+            throws KustvaktException {
         RewriteHandler handler = new RewriteHandler();
         handler.insertBeans(helper().getContext());
         handler.add(CollectionConstraint.class);
@@ -111,7 +114,8 @@
 
     //fixme: will probably fail when one doc groups are being refactored
     @Test
-    public void testCollectionCleanEmptyDocGroupNoErrors () {
+    public void testCollectionCleanEmptyDocGroupNoErrors ()
+            throws KustvaktException {
         RewriteHandler handler = new RewriteHandler();
         handler.insertBeans(helper().getContext());
         handler.add(CollectionConstraint.class);
@@ -139,7 +143,8 @@
 
 
     @Test
-    public void testCollectionCleanMoveOneDocFromGroupUpNoErrors () {
+    public void testCollectionCleanMoveOneDocFromGroupUpNoErrors ()
+            throws KustvaktException {
         RewriteHandler handler = new RewriteHandler();
         handler.insertBeans(helper().getContext());
         handler.add(CollectionConstraint.class);
@@ -160,7 +165,8 @@
 
 
     @Test
-    public void testCollectionCleanEmptyGroupAndMoveOneFromGroupUpNoErrors () {
+    public void testCollectionCleanEmptyGroupAndMoveOneFromGroupUpNoErrors ()
+            throws KustvaktException {
         RewriteHandler handler = new RewriteHandler();
         handler.insertBeans(helper().getContext());
         handler.add(CollectionConstraint.class);
@@ -181,7 +187,8 @@
 
 
     @Test
-    public void testCollectionRemoveAndMoveOneFromGroupUpNoErrors () {
+    public void testCollectionRemoveAndMoveOneFromGroupUpNoErrors ()
+            throws KustvaktException {
         RewriteHandler handler = new RewriteHandler();
         handler.insertBeans(helper().getContext());
         handler.add(CollectionConstraint.class);
@@ -251,7 +258,7 @@
 
 
     @Test
-    public void testRemoveCorpusFromDifferentGroups () {
+    public void testRemoveCorpusFromDifferentGroups () throws KustvaktException {
         RewriteHandler handler = new RewriteHandler();
         handler.insertBeans(helper().getContext());
         handler.add(CollectionConstraint.class);
@@ -276,7 +283,8 @@
 
 
     @Test
-    public void testRemoveOneCorpusAndMoveDocFromTwoGroups () {
+    public void testRemoveOneCorpusAndMoveDocFromTwoGroups ()
+            throws KustvaktException {
         RewriteHandler handler = new RewriteHandler();
         handler.insertBeans(helper().getContext());
         handler.add(CollectionConstraint.class);
diff --git a/src/test/java/de/ids_mannheim/korap/resource/rewrite/FoundryRewriteTest.java b/src/test/java/de/ids_mannheim/korap/resource/rewrite/FoundryRewriteTest.java
index 8c0f1f0..b667796 100644
--- a/src/test/java/de/ids_mannheim/korap/resource/rewrite/FoundryRewriteTest.java
+++ b/src/test/java/de/ids_mannheim/korap/resource/rewrite/FoundryRewriteTest.java
@@ -53,7 +53,8 @@
 
 
     @Test
-    public void testDefaultFoundryInjectLemmaThrowsNoError () {
+    public void testDefaultFoundryInjectLemmaThrowsNoError ()
+            throws KustvaktException {
 
         KustvaktConfiguration c = helper().getBean(
                 ContextHolder.KUSTVAKT_CONFIG);
@@ -77,7 +78,7 @@
 
 
     @Test
-    public void testDefaultFoundryInjectPOSNoErrors () {
+    public void testDefaultFoundryInjectPOSNoErrors () throws KustvaktException {
 
         KustvaktConfiguration c = helper().getBean(
                 ContextHolder.KUSTVAKT_CONFIG);
@@ -115,8 +116,10 @@
         String result = handler.processQuery(s.toJSON(), user);
         JsonNode node = JsonUtils.readTree(result);
 
-        UserDataDbIface dao = BeansFactory.getTypeFactory().getTypedBean(
-                helper().getContext().getUserDataDaos(), UserSettings.class);
+        UserDataDbIface dao = BeansFactory.getTypeFactory()
+                .getTypeInterfaceBean(
+                        helper().getContext().getUserDataProviders(),
+                        UserSettings.class);
         UserSettings settings = (UserSettings) dao.get(user);
         assertTrue(settings.isValid());
         String pos = (String) settings.get(Attributes.DEFAULT_POS_FOUNDRY);
@@ -145,8 +148,10 @@
         String result = handler.processQuery(s.toJSON(), user);
         JsonNode node = JsonUtils.readTree(result);
 
-        UserDataDbIface dao = BeansFactory.getTypeFactory().getTypedBean(
-                helper().getContext().getUserDataDaos(), UserSettings.class);
+        UserDataDbIface dao = BeansFactory.getTypeFactory()
+                .getTypeInterfaceBean(
+                        helper().getContext().getUserDataProviders(),
+                        UserSettings.class);
         UserSettings settings = (UserSettings) dao.get(user);
         assertTrue(settings.isValid());
         String lemma = (String) settings.get(Attributes.DEFAULT_LEMMA_FOUNDRY);
@@ -161,7 +166,8 @@
 
 
     @Test
-    public void testFoundryInjectJoinedQueryNoErrors () {
+    public void testFoundryInjectJoinedQueryNoErrors ()
+            throws KustvaktException {
         KustvaktConfiguration c = helper().getBean(
                 ContextHolder.KUSTVAKT_CONFIG);
 
@@ -183,7 +189,8 @@
 
 
     @Test
-    public void testFoundryInjectGroupedQueryNoErrors () {
+    public void testFoundryInjectGroupedQueryNoErrors ()
+            throws KustvaktException {
         QuerySerializer s = new QuerySerializer();
         RewriteHandler handler = new RewriteHandler();
         handler.insertBeans(helper().getContext());
diff --git a/src/test/java/de/ids_mannheim/korap/resource/rewrite/IdRewriteTest.java b/src/test/java/de/ids_mannheim/korap/resource/rewrite/IdRewriteTest.java
index 69e8ea7..b112b61 100644
--- a/src/test/java/de/ids_mannheim/korap/resource/rewrite/IdRewriteTest.java
+++ b/src/test/java/de/ids_mannheim/korap/resource/rewrite/IdRewriteTest.java
@@ -16,7 +16,7 @@
 public class IdRewriteTest extends BeanConfigTest {
 
     @Test
-    public void insertTokenId () {
+    public void insertTokenId () throws KustvaktException {
         RewriteHandler handler = new RewriteHandler();
         handler.insertBeans(helper().getContext());
         assertTrue(handler.add(IdWriter.class));
@@ -34,7 +34,7 @@
 
 
     @Test
-    public void testIdWriterTest () {
+    public void testIdWriterTest () throws KustvaktException {
         RewriteHandler handler = new RewriteHandler();
         handler.insertBeans(helper().getContext());
         assertTrue(handler.add(IdWriter.class));
diff --git a/src/test/java/de/ids_mannheim/korap/resource/rewrite/RewriteHandlerTest.java b/src/test/java/de/ids_mannheim/korap/resource/rewrite/RewriteHandlerTest.java
index 3cb528d..9458b0c 100644
--- a/src/test/java/de/ids_mannheim/korap/resource/rewrite/RewriteHandlerTest.java
+++ b/src/test/java/de/ids_mannheim/korap/resource/rewrite/RewriteHandlerTest.java
@@ -33,7 +33,7 @@
 
     // throws exception cause of missing configuration
     @Test(expected = RuntimeException.class)
-    public void testRewriteConfigThrowsException () {
+    public void testRewriteConfigThrowsException () throws KustvaktException {
         RewriteHandler handler = new RewriteHandler();
         QuerySerializer s = new QuerySerializer();
         s.setQuery("[(base=laufen | base=gehen) & tt/pos=VVFIN]", "poliqarp");
@@ -43,7 +43,7 @@
 
 
     @Test
-    public void testRewriteNoBeanInject () {
+    public void testRewriteNoBeanInject () throws KustvaktException {
         RewriteHandler handler = new RewriteHandler(helper().getContext()
                 .getConfiguration());
         QuerySerializer s = new QuerySerializer();
@@ -55,7 +55,7 @@
 
 
     @Test
-    public void testRewriteBeanInject () {
+    public void testRewriteBeanInject () throws KustvaktException {
         RewriteHandler handler = new RewriteHandler();
         handler.insertBeans(helper().getContext());
         QuerySerializer s = new QuerySerializer();
@@ -74,7 +74,7 @@
 
 
     @Test
-    public void testRewriteUserSpecific () {
+    public void testRewriteUserSpecific () throws KustvaktException {
         RewriteHandler handler = new RewriteHandler();
         handler.insertBeans(helper().getContext());
         QuerySerializer s = new QuerySerializer();
@@ -96,7 +96,8 @@
     public void initMethod () throws KustvaktException {
         helper().setupAccount();
         UserDataDbIface settingsdao = BeansFactory.getTypeFactory()
-                .getTypedBean(helper().getContext().getUserDataDaos(),
+                .getTypeInterfaceBean(
+                        helper().getContext().getUserDataProviders(),
                         UserSettings.class);
         assertNotNull(settingsdao);
         UserSettings s = (UserSettings) settingsdao.get(helper().getUser());
diff --git a/src/test/java/de/ids_mannheim/korap/suites/DaoTestSuite.java b/src/test/java/de/ids_mannheim/korap/suites/DaoTestSuite.java
deleted file mode 100644
index fdd328d..0000000
--- a/src/test/java/de/ids_mannheim/korap/suites/DaoTestSuite.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package de.ids_mannheim.korap.suites;
-
-import de.ids_mannheim.korap.handlers.ResourceDaoTest;
-import de.ids_mannheim.korap.handlers.UserDaoTest;
-import de.ids_mannheim.korap.security.PolicyDaoTest;
-import de.ids_mannheim.korap.user.UserdataTest;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-/**
- * @author hanl
- * @date 26/02/2016
- */
-
-@Deprecated
-@RunWith(Suite.class)
-@Suite.SuiteClasses({ PolicyDaoTest.class, UserdataTest.class,
-        UserDaoTest.class, ResourceDaoTest.class })
-public class DaoTestSuite {}
diff --git a/src/test/java/de/ids_mannheim/korap/suites/LoaderTestSuite.java b/src/test/java/de/ids_mannheim/korap/suites/LoaderTestSuite.java
deleted file mode 100644
index 9f3a05e..0000000
--- a/src/test/java/de/ids_mannheim/korap/suites/LoaderTestSuite.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package de.ids_mannheim.korap.suites;
-
-/**
- * @author hanl
- * @date 09/03/2016
- */
-
-import de.ids_mannheim.korap.config.CollectionLoaderTest;
-import de.ids_mannheim.korap.config.PolicyLoaderTest;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({ PolicyLoaderTest.class, CollectionLoaderTest.class })
-public class LoaderTestSuite {}
diff --git a/src/test/java/de/ids_mannheim/korap/suites/SecurityEntityTestSuite.java b/src/test/java/de/ids_mannheim/korap/suites/SecurityEntityTestSuite.java
deleted file mode 100644
index c3cceda..0000000
--- a/src/test/java/de/ids_mannheim/korap/suites/SecurityEntityTestSuite.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package de.ids_mannheim.korap.suites;
-
-import de.ids_mannheim.korap.security.PermissionBufferTest;
-import de.ids_mannheim.korap.security.PolicyBuilderTest;
-import de.ids_mannheim.korap.security.SecurityPolicyTest;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-/**
- * @author hanl
- * @date 09/03/2016
- */
-// test object serialization and I/O buffers
-@RunWith(Suite.class)
-@Suite.SuiteClasses({ PermissionBufferTest.class, PolicyBuilderTest.class,
-        SecurityPolicyTest.class })
-public class SecurityEntityTestSuite {}
diff --git a/src/test/java/de/ids_mannheim/korap/suites/SecurityTestSuite.java b/src/test/java/de/ids_mannheim/korap/suites/SecurityTestSuite.java
deleted file mode 100644
index 45116b5..0000000
--- a/src/test/java/de/ids_mannheim/korap/suites/SecurityTestSuite.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package de.ids_mannheim.korap.suites;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-/**
- * @author hanl
- * @date 09/03/2016
- */
-@RunWith(Suite.class)
-@Suite.SuiteClasses({})
-public class SecurityTestSuite {}
diff --git a/src/test/java/de/ids_mannheim/korap/suites/ServiceTestSuite.java b/src/test/java/de/ids_mannheim/korap/suites/ServiceTestSuite.java
deleted file mode 100644
index e83e232..0000000
--- a/src/test/java/de/ids_mannheim/korap/suites/ServiceTestSuite.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package de.ids_mannheim.korap.suites;
-
-/**
- * @author hanl
- * @date 09/03/2016
- */
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({})
-public class ServiceTestSuite {
-
-}
diff --git a/src/test/java/de/ids_mannheim/korap/user/UserdataTest.java b/src/test/java/de/ids_mannheim/korap/user/UserdataTest.java
index 9295cf3..d7a3bf4 100644
--- a/src/test/java/de/ids_mannheim/korap/user/UserdataTest.java
+++ b/src/test/java/de/ids_mannheim/korap/user/UserdataTest.java
@@ -92,13 +92,16 @@
 
     @Test
     public void testUserdatafactory () throws KustvaktException {
-        UserDataDbIface dao = BeansFactory.getTypeFactory().getTypedBean(
-                helper().getContext().getUserDataDaos(), UserDetails.class);
+        UserDataDbIface dao = BeansFactory.getTypeFactory()
+                .getTypeInterfaceBean(
+                        helper().getContext().getUserDataProviders(),
+                        UserDetails.class);
         assertNotNull(dao);
         assertEquals(UserDetailsDao.class, dao.getClass());
 
-        dao = BeansFactory.getTypeFactory().getTypedBean(
-                helper().getContext().getUserDataDaos(), UserSettings.class);
+        dao = BeansFactory.getTypeFactory().getTypeInterfaceBean(
+                helper().getContext().getUserDataProviders(),
+                UserSettings.class);
         assertNotNull(dao);
         assertEquals(UserSettingsDao.class, dao.getClass());
 
@@ -107,8 +110,8 @@
 
     @Test(expected = RuntimeException.class)
     public void testUserdatafactoryError () throws KustvaktException {
-        BeansFactory.getTypeFactory().getTypedBean(
-                helper().getContext().getUserDataDaos(), new Userdata(1) {
+        BeansFactory.getTypeFactory().getTypeInterfaceBean(
+                helper().getContext().getUserDataProviders(), new Userdata(1) {
                     @Override
                     public String[] requiredFields () {
                         return new String[0];
diff --git a/src/test/resources/default-config.xml b/src/test/resources/default-config.xml
index f669953..3ad0aeb 100644
--- a/src/test/resources/default-config.xml
+++ b/src/test/resources/default-config.xml
@@ -21,8 +21,6 @@
                             http://www.springframework.org/schema/util
                             http://www.springframework.org/schema/util/spring-util-4.0.xsd">
 
-    <cache:annotation-driven/>
-
     <bean id="props"
           class="org.springframework.beans.factory.config.PropertiesFactoryBean">
         <property name="ignoreResourceNotFound" value="true"/>
@@ -67,7 +65,7 @@
           class="org.springframework.jdbc.datasource.SingleConnectionDataSource"
           lazy-init="false">
         <property name="driverClassName" value="org.sqlite.JDBC"/>
-        <property name="url" value="jdbc:sqlite:tmp_new.sqlite"/>
+        <property name="url" value="jdbc:sqlite::memory:"/>
         <!--<property name="initialSize" value="1" />-->
         <!--<property name="maxTotal" value="1" />-->
         <!--<property name="maxIdle" value="1" />-->
@@ -116,17 +114,16 @@
         <constructor-arg ref="kustvakt_db"/>
     </bean>
 
-    <!--<bean id="collectionProvider"-->
-    <!--class="de.ids_mannheim.korap.handlers.CollectionDao">-->
-    <!--<constructor-arg ref="kustvakt_db"/>-->
-    <!--</bean>-->
-
-    <!--fixme: change name according to convention -->
-    <bean id="resourceProvider"
+    <bean id="resource_provider"
           class="de.ids_mannheim.korap.handlers.ResourceDao">
         <constructor-arg ref="kustvakt_db"/>
     </bean>
 
+    <bean id="document_provider"
+          class="de.ids_mannheim.korap.handlers.DocumentDao">
+        <constructor-arg ref="kustvakt_db"/>
+    </bean>
+
     <bean id="kustvakt_policies"
           class="de.ids_mannheim.korap.security.ac.PolicyDao">
         <constructor-arg ref="kustvakt_db"/>
@@ -184,7 +181,7 @@
                 ref="kustvakt_db"/>
     </bean>
     <bean id="userdata_settings"
-          class="de.ids_mannheim.korap.handlers.UserDetailsDao">
+          class="de.ids_mannheim.korap.handlers.UserSettingsDao">
         <constructor-arg
                 type="de.ids_mannheim.korap.interfaces.db.PersistenceClient"
                 ref="kustvakt_db"/>
@@ -196,6 +193,12 @@
         <ref bean="userdata_settings"/>
     </util:list>
 
+    <util:list id="kustvakt_resources"
+               value-type="de.ids_mannheim.korap.interfaces.db.ResourceOperationIface">
+        <ref bean="document_provider"/>
+        <ref bean="resource_provider"/>
+    </util:list>
+
 
     <!-- specify type for constructor argument -->
     <bean id="kustvakt_authenticationmanager"