Assembled lite version.
Change-Id: I48e60fffd9219a97923e7c388f4f97bcda416d3f
diff --git a/full/src/test/java/de/ids_mannheim/korap/config/AppTestConfig.java b/full/src/test/java/de/ids_mannheim/korap/config/AppTestConfig.java
new file mode 100644
index 0000000..e39c5e0
--- /dev/null
+++ b/full/src/test/java/de/ids_mannheim/korap/config/AppTestConfig.java
@@ -0,0 +1,140 @@
+package de.ids_mannheim.korap.config;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import de.ids_mannheim.korap.handlers.AdminDao;
+import de.ids_mannheim.korap.handlers.DocumentDao;
+import de.ids_mannheim.korap.handlers.EntityDao;
+import de.ids_mannheim.korap.handlers.JDBCAuditing;
+import de.ids_mannheim.korap.handlers.ResourceDao;
+import de.ids_mannheim.korap.handlers.UserDetailsDao;
+import de.ids_mannheim.korap.handlers.UserSettingsDao;
+import de.ids_mannheim.korap.interfaces.AuthenticationIface;
+import de.ids_mannheim.korap.interfaces.AuthenticationManagerIface;
+import de.ids_mannheim.korap.interfaces.EncryptionIface;
+import de.ids_mannheim.korap.interfaces.db.AdminHandlerIface;
+import de.ids_mannheim.korap.interfaces.db.AuditingIface;
+import de.ids_mannheim.korap.interfaces.db.EntityHandlerIface;
+import de.ids_mannheim.korap.interfaces.db.PersistenceClient;
+import de.ids_mannheim.korap.interfaces.db.PolicyHandlerIface;
+import de.ids_mannheim.korap.interfaces.db.ResourceOperationIface;
+import de.ids_mannheim.korap.interfaces.db.UserDataDbIface;
+import de.ids_mannheim.korap.interfaces.defaults.KustvaktEncryption;
+import de.ids_mannheim.korap.security.ac.PolicyDao;
+import de.ids_mannheim.korap.security.auth.APIAuthentication;
+import de.ids_mannheim.korap.security.auth.BasicHttpAuth;
+import de.ids_mannheim.korap.security.auth.KustvaktAuthenticationManager;
+import de.ids_mannheim.korap.security.auth.OpenIDconnectAuthentication;
+import de.ids_mannheim.korap.security.auth.SessionAuthentication;
+@Configuration
+public class AppTestConfig extends AppTestConfigBase implements TestBeans {
+
+ protected PersistenceClient dataSource;
+
+ public AppTestConfig () throws InterruptedException, IOException {
+ this.dataSource = TestHelper.sqlite_db(true);
+ //this.dataSource = TestHelper.mysql_db();
+ }
+
+
+ @Bean(name = "kustvakt_db")
+ public PersistenceClient getDataSource () {
+ return this.dataSource;
+ }
+
+
+ @Bean(name = ContextHolder.KUSTVAKT_POLICIES)
+ @Override
+ public PolicyHandlerIface getPolicyDao () {
+ return new PolicyDao(this.dataSource);
+ }
+
+
+ @Bean(name = ContextHolder.KUSTVAKT_USERDB)
+ @Override
+ public EntityHandlerIface getUserDao () {
+ return new EntityDao(this.dataSource);
+ }
+
+
+ @Bean(name = ContextHolder.KUSTVAKT_ADMINDB)
+ @Override
+ public AdminHandlerIface getAdminDao () {
+ return new AdminDao(this.dataSource);
+ }
+
+
+
+ @Bean(name = ContextHolder.KUSTVAKT_AUDITING)
+ @Override
+ public AuditingIface getAuditingDao () {
+ return new JDBCAuditing(this.dataSource);
+ }
+
+
+ @Bean(name = ContextHolder.KUSTVAKT_RESOURCES)
+ @Override
+ public List<ResourceOperationIface> getResourceDaos () {
+ List<ResourceOperationIface> res = new ArrayList<>();
+ res.add(getDocumentDao());
+ res.add(getResourceDao());
+ return res;
+ }
+
+ @Bean(name = "document_dao")
+ public DocumentDao getDocumentDao () {
+ return new DocumentDao(getDataSource());
+ }
+
+
+ @Bean(name = "resource_dao")
+ public ResourceDao getResourceDao () {
+ return new ResourceDao(getDataSource());
+ }
+
+
+
+ @Bean(name = ContextHolder.KUSTVAKT_USERDATA)
+ @Override
+ public List<UserDataDbIface> getUserdataDaos () {
+ List<UserDataDbIface> ud = new ArrayList<>();
+ ud.add(new UserSettingsDao(getDataSource()));
+ ud.add(new UserDetailsDao(getDataSource()));
+ return ud;
+ }
+
+
+ @Bean(name = ContextHolder.KUSTVAKT_ENCRYPTION)
+ @Override
+ public EncryptionIface getCrypto () {
+ return new KustvaktEncryption(getConfig());
+ }
+
+
+ @Bean(name = ContextHolder.KUSTVAKT_AUTHENTICATION_MANAGER)
+ @Override
+ public AuthenticationManagerIface getAuthManager () {
+ AuthenticationManagerIface manager = new KustvaktAuthenticationManager(
+ getUserDao(), getAdminDao(), getCrypto(), getConfig(),
+ getAuditingDao(), getUserdataDaos());
+ Set<AuthenticationIface> pro = new HashSet<>();
+ pro.add(new BasicHttpAuth());
+ pro.add(new APIAuthentication(getConfig()));
+ pro.add(new SessionAuthentication(getConfig(), getCrypto()));
+ pro.add(new OpenIDconnectAuthentication(getConfig(), getDataSource()));
+ manager.setProviders(pro);
+ return manager;
+ }
+
+}
+
+
diff --git a/full/src/test/java/de/ids_mannheim/korap/config/BeanConfigTest.java b/full/src/test/java/de/ids_mannheim/korap/config/BeanConfigTest.java
index 79042d5..8f941bb 100644
--- a/full/src/test/java/de/ids_mannheim/korap/config/BeanConfigTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/config/BeanConfigTest.java
@@ -3,6 +3,7 @@
import static org.junit.Assert.assertNotNull;
import org.apache.log4j.Logger;
+import org.junit.Before;
import org.junit.runner.RunWith;
import org.junit.runner.notification.RunNotifier;
import org.junit.runners.model.InitializationError;
@@ -22,8 +23,8 @@
*/
@NotThreadSafe
@RunWith(BeanConfigTest.SpringExtendedSetupListener.class)
-@ContextConfiguration(classes = TestHelper.AppTestConfig.class)
-@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
+@ContextConfiguration(classes = AppTestConfig.class)
+@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
public abstract class BeanConfigTest {
private static Logger jlog = Logger.getLogger(BeanConfigTest.class);
@@ -31,8 +32,9 @@
private ApplicationContext context;
+ @Before
public void init () throws Exception {
-// context = new ClassPathXmlApplicationContext("test-default-config.xml");
+ context = new ClassPathXmlApplicationContext("test-default-config.xml");
assertNotNull("Application context must not be null!", this.context);
jlog.debug("running one-time before init for class "
+ this.getClass().getSimpleName() + " ...");
@@ -62,7 +64,7 @@
public static class SpringExtendedSetupListener extends
SpringJUnit4ClassRunner {
- private BeanConfigTest instanceSetupListener;
+ private BeanConfigBaseTest instanceSetupListener;
public SpringExtendedSetupListener (Class<?> clazz)
@@ -76,8 +78,8 @@
Object test = super.createTest();
// Note that JUnit4 will call this createTest() multiple times for each
// test method, so we need to ensure to call "beforeClassSetup" only once.
- if (test instanceof BeanConfigTest && instanceSetupListener == null) {
- instanceSetupListener = (BeanConfigTest) test;
+ if (test instanceof BeanConfigBaseTest && instanceSetupListener == null) {
+ instanceSetupListener = (BeanConfigBaseTest) test;
instanceSetupListener.init();
}
return test;
diff --git a/full/src/test/java/de/ids_mannheim/korap/config/LoaderTest.java b/full/src/test/java/de/ids_mannheim/korap/config/LoaderTest.java
index 009a4c0..9be6496 100644
--- a/full/src/test/java/de/ids_mannheim/korap/config/LoaderTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/config/LoaderTest.java
@@ -7,6 +7,7 @@
import de.ids_mannheim.korap.web.service.UserLoader;
import org.junit.Ignore;
import org.junit.Test;
+import org.springframework.test.annotation.DirtiesContext;
import java.util.ArrayList;
import java.util.HashSet;
diff --git a/full/src/test/java/de/ids_mannheim/korap/config/TestBeans.java b/full/src/test/java/de/ids_mannheim/korap/config/TestBeans.java
index 8c96bc4..85a0f4a 100644
--- a/full/src/test/java/de/ids_mannheim/korap/config/TestBeans.java
+++ b/full/src/test/java/de/ids_mannheim/korap/config/TestBeans.java
@@ -12,31 +12,26 @@
* @author hanl
* @date 20/02/2016
*/
-public abstract class TestBeans {
+public interface TestBeans {
- protected PersistenceClient dataSource;
+ public PolicyHandlerIface getPolicyDao();
- public abstract PolicyHandlerIface getPolicyDao();
+// public KustvaktConfiguration getConfig();
- public abstract KustvaktConfiguration getConfig();
-
- public abstract EntityHandlerIface getUserDao();
+ public EntityHandlerIface getUserDao();
- public abstract AdminHandlerIface getAdminDao();
+ public AdminHandlerIface getAdminDao();
- public abstract AuditingIface getAuditingDao();
+ public AuditingIface getAuditingDao();
- public abstract List<ResourceOperationIface> getResourceDaos();
+ public List<ResourceOperationIface> getResourceDaos();
- public abstract List<UserDataDbIface> getUserdataDaos();
+ public List<UserDataDbIface> getUserdataDaos();
- public abstract EncryptionIface getCrypto();
+ public EncryptionIface getCrypto();
- public abstract AuthenticationManagerIface getAuthManager();
+ public AuthenticationManagerIface getAuthManager();
- @Bean(name = "kustvakt_db")
- public PersistenceClient getDataSource() {
- return this.dataSource;
- }
+
}
diff --git a/full/src/test/java/de/ids_mannheim/korap/config/TestHelper.java b/full/src/test/java/de/ids_mannheim/korap/config/TestHelper.java
index 8c71eae..69501ff 100644
--- a/full/src/test/java/de/ids_mannheim/korap/config/TestHelper.java
+++ b/full/src/test/java/de/ids_mannheim/korap/config/TestHelper.java
@@ -18,6 +18,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import java.util.Set;
import org.apache.commons.dbcp2.BasicDataSource;
@@ -136,9 +137,10 @@
manager.createUserAccount(m, false);
}
catch (KustvaktException e) {
- // do nothing
+ throw new RuntimeException(e);
+ /*// do nothing
jlog.error("Error: {}", e.string());
- assertNotNull("Test user could not be set up", null);
+ assertNotNull("Test user could not be set up", null);*/
}
assertNotEquals(0, dao.size());
return this;
@@ -350,7 +352,7 @@
}
- private static PersistenceClient sqlite_db (boolean memory)
+ protected static PersistenceClient sqlite_db (boolean memory)
throws InterruptedException {
SingleConnectionDataSource dataSource = new SingleConnectionDataSource();
dataSource.setDriverClassName("org.sqlite.JDBC");
@@ -425,97 +427,4 @@
return client;
}
- public static class AppTestConfig extends TestBeans {
-
- public AppTestConfig () throws InterruptedException, IOException {
- this.dataSource = TestHelper.sqlite_db(true);
- //this.dataSource = TestHelper.mysql_db();
- }
-
-
- @Bean(name = ContextHolder.KUSTVAKT_POLICIES)
- @Override
- public PolicyHandlerIface getPolicyDao () {
- return new PolicyDao(this.dataSource);
- }
-
-
- @Bean(name = ContextHolder.KUSTVAKT_USERDB)
- @Override
- public EntityHandlerIface getUserDao () {
- return new EntityDao(this.dataSource);
- }
-
- @Bean(name = ContextHolder.KUSTVAKT_ADMINDB)
- @Override
- public AdminHandlerIface getAdminDao () {
- return new AdminDao(this.dataSource);
- }
-
- @Bean(name = ContextHolder.KUSTVAKT_CONFIG)
- @Override
- public KustvaktConfiguration getConfig () {
- KustvaktConfiguration c = new KustvaktConfiguration();
- InputStream s = ConfigLoader.loadConfigStream(mainConfigurationFile);
- if (s != null)
- c.setPropertiesAsStream(s);
- else {
- System.out.println("No properties found!");
- System.exit(-1);
- }
- return c;
- }
-
-
- @Bean(name = ContextHolder.KUSTVAKT_AUDITING)
- @Override
- public AuditingIface getAuditingDao () {
- return new JDBCAuditing(this.dataSource);
- }
-
-
- @Bean(name = ContextHolder.KUSTVAKT_RESOURCES)
- @Override
- public List<ResourceOperationIface> getResourceDaos () {
- List<ResourceOperationIface> res = new ArrayList<>();
- res.add(new ResourceDao(getDataSource()));
- res.add(new DocumentDao(getDataSource()));
- return res;
- }
-
-
- @Bean(name = ContextHolder.KUSTVAKT_USERDATA)
- @Override
- public List<UserDataDbIface> getUserdataDaos () {
- List<UserDataDbIface> ud = new ArrayList<>();
- ud.add(new UserSettingsDao(getDataSource()));
- ud.add(new UserDetailsDao(getDataSource()));
- return ud;
- }
-
-
- @Bean(name = ContextHolder.KUSTVAKT_ENCRYPTION)
- @Override
- public EncryptionIface getCrypto () {
- return new KustvaktEncryption(getConfig());
- }
-
-
- @Bean(name = ContextHolder.KUSTVAKT_AUTHENTICATION_MANAGER)
- @Override
- public AuthenticationManagerIface getAuthManager () {
- AuthenticationManagerIface manager = new KustvaktAuthenticationManager(
- getUserDao(), getAdminDao(), getCrypto(), getConfig(), getAuditingDao(),
- getUserdataDaos());
- Set<AuthenticationIface> pro = new HashSet<>();
- pro.add(new BasicHttpAuth());
- pro.add(new APIAuthentication(getConfig()));
- pro.add(new SessionAuthentication(getConfig(), getCrypto()));
- pro.add(new OpenIDconnectAuthentication(getConfig(), getDataSource()));
- manager.setProviders(pro);
- return manager;
- }
-
}
-
-}
diff --git a/full/src/test/java/de/ids_mannheim/korap/handlers/DocumentDaoTest.java b/full/src/test/java/de/ids_mannheim/korap/handlers/DocumentDaoTest.java
index 8061071..4b5561b 100644
--- a/full/src/test/java/de/ids_mannheim/korap/handlers/DocumentDaoTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/handlers/DocumentDaoTest.java
@@ -1,11 +1,13 @@
package de.ids_mannheim.korap.handlers;
import de.ids_mannheim.korap.config.BeanConfigTest;
+import de.ids_mannheim.korap.config.BeanConfigBaseTest;
import de.ids_mannheim.korap.exceptions.KustvaktException;
import de.ids_mannheim.korap.resources.Document;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
@@ -17,7 +19,8 @@
*/
public class DocumentDaoTest extends BeanConfigTest {
- private static DocumentDao dao;
+ @Autowired
+ private DocumentDao dao;
@After
diff --git a/full/src/test/java/de/ids_mannheim/korap/handlers/ResourceDaoTest.java b/full/src/test/java/de/ids_mannheim/korap/handlers/ResourceDaoTest.java
index f21e305..e5f652f 100644
--- a/full/src/test/java/de/ids_mannheim/korap/handlers/ResourceDaoTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/handlers/ResourceDaoTest.java
@@ -14,8 +14,9 @@
import org.junit.Test;
import de.ids_mannheim.korap.config.Attributes;
-import de.ids_mannheim.korap.config.BeanConfigTest;
+import de.ids_mannheim.korap.config.BeanConfigBaseTest;
import de.ids_mannheim.korap.config.KustvaktClassLoader;
+import de.ids_mannheim.korap.config.BeanConfigTest;
import de.ids_mannheim.korap.config.TestHelper;
import de.ids_mannheim.korap.exceptions.KustvaktException;
import de.ids_mannheim.korap.resources.KustvaktResource;
diff --git a/full/src/test/java/de/ids_mannheim/korap/handlers/UserDaoTest.java b/full/src/test/java/de/ids_mannheim/korap/handlers/UserDaoTest.java
index 855383f..10c01c3 100644
--- a/full/src/test/java/de/ids_mannheim/korap/handlers/UserDaoTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/handlers/UserDaoTest.java
@@ -1,8 +1,14 @@
package de.ids_mannheim.korap.handlers;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import org.junit.Ignore;
+import org.junit.Test;
+
import de.ids_mannheim.korap.config.Attributes;
-import de.ids_mannheim.korap.config.BeanConfigTest;
import de.ids_mannheim.korap.config.BeansFactory;
+import de.ids_mannheim.korap.config.BeanConfigTest;
import de.ids_mannheim.korap.config.TestHelper;
import de.ids_mannheim.korap.exceptions.KustvaktException;
import de.ids_mannheim.korap.interfaces.db.EntityHandlerIface;
@@ -11,11 +17,6 @@
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;
-import static org.junit.Assert.assertNull;
;
diff --git a/full/src/test/java/de/ids_mannheim/korap/misc/DemoUserTest.java b/full/src/test/java/de/ids_mannheim/korap/misc/DemoUserTest.java
index ca0f29f..2b5cdcb 100644
--- a/full/src/test/java/de/ids_mannheim/korap/misc/DemoUserTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/misc/DemoUserTest.java
@@ -19,14 +19,6 @@
}
- @BeforeClass
- public static void setup () throws Exception {
- FastJerseyTest.setPackages("de.ids_mannheim.korap.web.service.full",
- "de.ids_mannheim.korap.web.filter",
- "de.ids_mannheim.korap.web.utils");
- }
-
-
@Test
public void testDemoCollectionGet () {
// ClientResponse response = resource().path(getVersion())
diff --git a/full/src/test/java/de/ids_mannheim/korap/misc/FileAuditingTest.java b/full/src/test/java/de/ids_mannheim/korap/misc/FileAuditingTest.java
index 06993b0..188c36a 100644
--- a/full/src/test/java/de/ids_mannheim/korap/misc/FileAuditingTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/misc/FileAuditingTest.java
@@ -1,13 +1,14 @@
package de.ids_mannheim.korap.misc;
-import de.ids_mannheim.korap.auditing.AuditRecord;
-import de.ids_mannheim.korap.config.BeanConfigTest;
-import de.ids_mannheim.korap.exceptions.KustvaktException;
-import de.ids_mannheim.korap.exceptions.StatusCodes;
+import java.util.Date;
+
import org.joda.time.LocalDate;
import org.junit.Ignore;
import org.junit.Test;
-import java.util.Date;
+import de.ids_mannheim.korap.auditing.AuditRecord;
+import de.ids_mannheim.korap.config.BeanConfigTest;
+import de.ids_mannheim.korap.exceptions.KustvaktException;
+import de.ids_mannheim.korap.exceptions.StatusCodes;
/**
* @author hanl
diff --git a/full/src/test/java/de/ids_mannheim/korap/misc/LocalQueryTest.java b/full/src/test/java/de/ids_mannheim/korap/misc/LocalQueryTest.java
index 45c2324..e5020f9 100644
--- a/full/src/test/java/de/ids_mannheim/korap/misc/LocalQueryTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/misc/LocalQueryTest.java
@@ -1,16 +1,17 @@
package de.ids_mannheim.korap.misc;
-import de.ids_mannheim.korap.KrillCollection;
-import de.ids_mannheim.korap.config.BeanConfigTest;
-import de.ids_mannheim.korap.exceptions.KustvaktException;
-import de.ids_mannheim.korap.query.serialize.CollectionQueryProcessor;
-import de.ids_mannheim.korap.utils.KoralCollectionQueryBuilder;
-import de.ids_mannheim.korap.utils.JsonUtils;
-import de.ids_mannheim.korap.web.SearchKrill;
+import java.io.IOException;
+
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
-import java.io.IOException;
+import de.ids_mannheim.korap.KrillCollection;
+import de.ids_mannheim.korap.config.BeanConfigTest;
+import de.ids_mannheim.korap.exceptions.KustvaktException;
+import de.ids_mannheim.korap.query.serialize.CollectionQueryProcessor;
+import de.ids_mannheim.korap.utils.JsonUtils;
+import de.ids_mannheim.korap.utils.KoralCollectionQueryBuilder;
+import de.ids_mannheim.korap.web.SearchKrill;
/**
* @author hanl
diff --git a/full/src/test/java/de/ids_mannheim/korap/misc/PublicAPITest.java b/full/src/test/java/de/ids_mannheim/korap/misc/PublicAPITest.java
index bc2f3eb..784d755 100644
--- a/full/src/test/java/de/ids_mannheim/korap/misc/PublicAPITest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/misc/PublicAPITest.java
@@ -10,14 +10,6 @@
public class PublicAPITest extends FastJerseyTest {
- @BeforeClass
- public static void setup () {
- FastJerseyTest.setPackages("de.ids_mannheim.korap.web.service.light",
- "de.ids_mannheim.korap.web.filter",
- "de.ids_mannheim.korap.web.utils");
- }
-
-
@Override
public void initMethod () throws KustvaktException {}
diff --git a/full/src/test/java/de/ids_mannheim/korap/resource/rewrite/CollectionRewriteTest.java b/full/src/test/java/de/ids_mannheim/korap/resource/rewrite/CollectionRewriteTest.java
index fe35d64..2e03b21 100644
--- a/full/src/test/java/de/ids_mannheim/korap/resource/rewrite/CollectionRewriteTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/resource/rewrite/CollectionRewriteTest.java
@@ -1,6 +1,15 @@
package de.ids_mannheim.korap.resource.rewrite;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.junit.Test;
+
import com.fasterxml.jackson.databind.JsonNode;
+
import de.ids_mannheim.korap.config.BeanConfigTest;
import de.ids_mannheim.korap.config.KustvaktConfiguration;
import de.ids_mannheim.korap.config.TestVariables;
@@ -8,13 +17,6 @@
import de.ids_mannheim.korap.query.serialize.QuerySerializer;
import de.ids_mannheim.korap.user.User;
import de.ids_mannheim.korap.utils.JsonUtils;
-import org.junit.Test;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
/**
* @author hanl
diff --git a/full/src/test/java/de/ids_mannheim/korap/resource/rewrite/FoundryRewriteTest.java b/full/src/test/java/de/ids_mannheim/korap/resource/rewrite/FoundryRewriteTest.java
index 7dcb215..9594ba5 100644
--- a/full/src/test/java/de/ids_mannheim/korap/resource/rewrite/FoundryRewriteTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/resource/rewrite/FoundryRewriteTest.java
@@ -1,6 +1,16 @@
package de.ids_mannheim.korap.resource.rewrite;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Ignore;
+import org.junit.Test;
+
import com.fasterxml.jackson.databind.JsonNode;
+
+import de.ids_mannheim.korap.config.Attributes;
import de.ids_mannheim.korap.config.BeanConfigTest;
import de.ids_mannheim.korap.config.BeansFactory;
import de.ids_mannheim.korap.config.ContextHolder;
@@ -9,14 +19,9 @@
import de.ids_mannheim.korap.interfaces.db.UserDataDbIface;
import de.ids_mannheim.korap.query.serialize.QuerySerializer;
import de.ids_mannheim.korap.resource.LayerMapper;
-import de.ids_mannheim.korap.config.Attributes;
import de.ids_mannheim.korap.user.User;
import de.ids_mannheim.korap.user.UserSettings;
import de.ids_mannheim.korap.utils.JsonUtils;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
/**
* @author hanl
diff --git a/full/src/test/java/de/ids_mannheim/korap/resource/rewrite/IdRewriteTest.java b/full/src/test/java/de/ids_mannheim/korap/resource/rewrite/IdRewriteTest.java
index b112b61..65ae668 100644
--- a/full/src/test/java/de/ids_mannheim/korap/resource/rewrite/IdRewriteTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/resource/rewrite/IdRewriteTest.java
@@ -1,13 +1,17 @@
package de.ids_mannheim.korap.resource.rewrite;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
import com.fasterxml.jackson.databind.JsonNode;
+
import de.ids_mannheim.korap.config.BeanConfigTest;
import de.ids_mannheim.korap.exceptions.KustvaktException;
import de.ids_mannheim.korap.query.serialize.QuerySerializer;
import de.ids_mannheim.korap.utils.JsonUtils;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
/**
* @author hanl
diff --git a/full/src/test/java/de/ids_mannheim/korap/resource/rewrite/ResultRewriteTest.java b/full/src/test/java/de/ids_mannheim/korap/resource/rewrite/ResultRewriteTest.java
index 479927c..7ec8b91 100644
--- a/full/src/test/java/de/ids_mannheim/korap/resource/rewrite/ResultRewriteTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/resource/rewrite/ResultRewriteTest.java
@@ -1,6 +1,15 @@
package de.ids_mannheim.korap.resource.rewrite;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import org.junit.Before;
+import org.junit.Test;
+
import com.fasterxml.jackson.databind.JsonNode;
+
import de.ids_mannheim.korap.config.BeanConfigTest;
import de.ids_mannheim.korap.config.TestVariables;
import de.ids_mannheim.korap.exceptions.KustvaktException;
@@ -8,10 +17,6 @@
import de.ids_mannheim.korap.resources.Document;
import de.ids_mannheim.korap.utils.JsonUtils;
import net.sf.ehcache.CacheManager;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
/**
* @author hanl
diff --git a/full/src/test/java/de/ids_mannheim/korap/resource/rewrite/RewriteBenchmarkTest.java b/full/src/test/java/de/ids_mannheim/korap/resource/rewrite/RewriteBenchmarkTest.java
index 68077d6..c3d65c4 100644
--- a/full/src/test/java/de/ids_mannheim/korap/resource/rewrite/RewriteBenchmarkTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/resource/rewrite/RewriteBenchmarkTest.java
@@ -1,6 +1,16 @@
package de.ids_mannheim.korap.resource.rewrite;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import org.joda.time.DateTime;
+import org.junit.Test;
+import org.springframework.test.annotation.DirtiesContext;
+
import com.fasterxml.jackson.databind.JsonNode;
+
import de.ids_mannheim.korap.config.BeanConfigTest;
import de.ids_mannheim.korap.config.TestVariables;
import de.ids_mannheim.korap.exceptions.KustvaktException;
@@ -8,10 +18,6 @@
import de.ids_mannheim.korap.resources.Document;
import de.ids_mannheim.korap.utils.JsonUtils;
import de.ids_mannheim.korap.utils.TimeUtils;
-import org.joda.time.DateTime;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
/**
* Created by hanl on 30.05.16.
diff --git a/full/src/test/java/de/ids_mannheim/korap/resource/rewrite/RewriteHandlerTest.java b/full/src/test/java/de/ids_mannheim/korap/resource/rewrite/RewriteHandlerTest.java
index 8c33d35..0054f7c 100644
--- a/full/src/test/java/de/ids_mannheim/korap/resource/rewrite/RewriteHandlerTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/resource/rewrite/RewriteHandlerTest.java
@@ -1,19 +1,23 @@
package de.ids_mannheim.korap.resource.rewrite;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Ignore;
+import org.junit.Test;
+
import com.fasterxml.jackson.databind.JsonNode;
+
+import de.ids_mannheim.korap.config.Attributes;
import de.ids_mannheim.korap.config.BeanConfigTest;
import de.ids_mannheim.korap.config.BeansFactory;
import de.ids_mannheim.korap.exceptions.KustvaktException;
import de.ids_mannheim.korap.interfaces.db.UserDataDbIface;
import de.ids_mannheim.korap.query.serialize.QuerySerializer;
-import de.ids_mannheim.korap.config.Attributes;
import de.ids_mannheim.korap.user.UserSettings;
import de.ids_mannheim.korap.utils.JsonUtils;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-import org.junit.Ignore;
/**
* @author hanl
diff --git a/full/src/test/java/de/ids_mannheim/korap/security/PolicyBuilderTest.java b/full/src/test/java/de/ids_mannheim/korap/security/PolicyBuilderTest.java
index eb0c3d8..f7bf66d 100644
--- a/full/src/test/java/de/ids_mannheim/korap/security/PolicyBuilderTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/security/PolicyBuilderTest.java
@@ -1,9 +1,11 @@
package de.ids_mannheim.korap.security;
+import org.junit.Test;
+import org.springframework.test.annotation.DirtiesContext;
+
import de.ids_mannheim.korap.config.BeanConfigTest;
import de.ids_mannheim.korap.exceptions.KustvaktException;
import de.ids_mannheim.korap.security.ac.PolicyBuilder;
-import org.junit.Test;
/**
* @author hanl
diff --git a/full/src/test/java/de/ids_mannheim/korap/security/PolicyDaoTest.java b/full/src/test/java/de/ids_mannheim/korap/security/PolicyDaoTest.java
index 98895ae..6f7136b 100644
--- a/full/src/test/java/de/ids_mannheim/korap/security/PolicyDaoTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/security/PolicyDaoTest.java
@@ -1,5 +1,18 @@
package de.ids_mannheim.korap.security;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.junit.Ignore;
+import org.junit.Test;
+
+import de.ids_mannheim.korap.config.Attributes;
import de.ids_mannheim.korap.config.BeanConfigTest;
import de.ids_mannheim.korap.exceptions.KustvaktException;
import de.ids_mannheim.korap.interfaces.db.PolicyHandlerIface;
@@ -8,18 +21,8 @@
import de.ids_mannheim.korap.resources.Permissions;
import de.ids_mannheim.korap.resources.VirtualCollection;
import de.ids_mannheim.korap.security.ac.PolicyBuilder;
-import de.ids_mannheim.korap.config.Attributes;
import de.ids_mannheim.korap.user.User;
import edu.emory.mathcs.backport.java.util.Arrays;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import static org.junit.Assert.*;
/** EM: needs reimplementation
*
diff --git a/full/src/test/java/de/ids_mannheim/korap/security/ResourceFinderTest.java b/full/src/test/java/de/ids_mannheim/korap/security/ResourceFinderTest.java
index a96378d..47f7c33 100644
--- a/full/src/test/java/de/ids_mannheim/korap/security/ResourceFinderTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/security/ResourceFinderTest.java
@@ -1,20 +1,20 @@
package de.ids_mannheim.korap.security;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+
+import java.util.Set;
+
+import org.junit.Ignore;
+import org.junit.Test;
+
import de.ids_mannheim.korap.config.BeanConfigTest;
import de.ids_mannheim.korap.exceptions.KustvaktException;
import de.ids_mannheim.korap.resources.Corpus;
import de.ids_mannheim.korap.resources.VirtualCollection;
import de.ids_mannheim.korap.security.ac.ResourceFinder;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import java.util.Set;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-
/**
* @author hanl
* @date 06/02/2016
diff --git a/full/src/test/java/de/ids_mannheim/korap/security/ResourcesTest.java b/full/src/test/java/de/ids_mannheim/korap/security/ResourcesTest.java
index dd90bb0..890beb7 100644
--- a/full/src/test/java/de/ids_mannheim/korap/security/ResourcesTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/security/ResourcesTest.java
@@ -1,30 +1,34 @@
package de.ids_mannheim.korap.security;
-import de.ids_mannheim.korap.config.BeanConfigTest;
-import de.ids_mannheim.korap.config.ContextHolder;
-import de.ids_mannheim.korap.config.KustvaktConfiguration;
-import de.ids_mannheim.korap.exceptions.KustvaktException;
-import de.ids_mannheim.korap.interfaces.db.EntityHandlerIface;
-import de.ids_mannheim.korap.resources.*;
-import de.ids_mannheim.korap.security.ac.ResourceFinder;
-import de.ids_mannheim.korap.security.ac.ResourceHandler;
-import de.ids_mannheim.korap.security.ac.SecurityManager;
-import de.ids_mannheim.korap.user.User;
-import de.ids_mannheim.korap.utils.TimeUtils;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.Set;
import org.hamcrest.core.StringStartsWith;
import org.joda.time.DateTime;
-import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import java.util.Set;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
+import de.ids_mannheim.korap.config.BeanConfigTest;
+import de.ids_mannheim.korap.config.ContextHolder;
+import de.ids_mannheim.korap.config.KustvaktConfiguration;
+import de.ids_mannheim.korap.exceptions.KustvaktException;
+import de.ids_mannheim.korap.interfaces.db.EntityHandlerIface;
+import de.ids_mannheim.korap.resources.Corpus;
+import de.ids_mannheim.korap.resources.Foundry;
+import de.ids_mannheim.korap.resources.KustvaktResource;
+import de.ids_mannheim.korap.resources.Permissions;
+import de.ids_mannheim.korap.resources.ResourceFactory;
+import de.ids_mannheim.korap.resources.VirtualCollection;
+import de.ids_mannheim.korap.security.ac.ResourceFinder;
+import de.ids_mannheim.korap.security.ac.ResourceHandler;
+import de.ids_mannheim.korap.security.ac.SecurityManager;
+import de.ids_mannheim.korap.user.User;
+import de.ids_mannheim.korap.utils.TimeUtils;
/**
* @author hanl, margaretha
diff --git a/full/src/test/java/de/ids_mannheim/korap/security/SecurityPolicyTest.java b/full/src/test/java/de/ids_mannheim/korap/security/SecurityPolicyTest.java
index cd3a32b..f9a3057 100644
--- a/full/src/test/java/de/ids_mannheim/korap/security/SecurityPolicyTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/security/SecurityPolicyTest.java
@@ -1,17 +1,21 @@
package de.ids_mannheim.korap.security;
-import de.ids_mannheim.korap.config.BeanConfigTest;
-import de.ids_mannheim.korap.exceptions.KustvaktException;
-import de.ids_mannheim.korap.interfaces.db.PolicyHandlerIface;
-import de.ids_mannheim.korap.resources.Corpus;
-import de.ids_mannheim.korap.resources.Permissions;
-import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import static org.junit.Assert.*;
+import org.junit.Test;
+
+import de.ids_mannheim.korap.config.BeanConfigTest;
+import de.ids_mannheim.korap.exceptions.KustvaktException;
+import de.ids_mannheim.korap.interfaces.db.PolicyHandlerIface;
+import de.ids_mannheim.korap.resources.Corpus;
+import de.ids_mannheim.korap.resources.Permissions;
/**
* @author hanl
diff --git a/full/src/test/java/de/ids_mannheim/korap/security/auth/KustvaktAuthenticationManagerTest.java b/full/src/test/java/de/ids_mannheim/korap/security/auth/KustvaktAuthenticationManagerTest.java
index f5a2085..0e8d5fc 100644
--- a/full/src/test/java/de/ids_mannheim/korap/security/auth/KustvaktAuthenticationManagerTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/security/auth/KustvaktAuthenticationManagerTest.java
@@ -1,5 +1,12 @@
package de.ids_mannheim.korap.security.auth;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.After;
+import org.junit.Ignore;
+import org.junit.Test;
+
import de.ids_mannheim.korap.config.Attributes;
import de.ids_mannheim.korap.config.BeanConfigTest;
import de.ids_mannheim.korap.config.KustvaktBaseDaoInterface;
@@ -7,13 +14,11 @@
import de.ids_mannheim.korap.exceptions.KustvaktException;
import de.ids_mannheim.korap.interfaces.AuthenticationManagerIface;
import de.ids_mannheim.korap.interfaces.db.EntityHandlerIface;
-import de.ids_mannheim.korap.user.*;
-import org.junit.After;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
+import de.ids_mannheim.korap.user.KorAPUser;
+import de.ids_mannheim.korap.user.User;
+import de.ids_mannheim.korap.user.UserDetails;
+import de.ids_mannheim.korap.user.UserSettings;
+import de.ids_mannheim.korap.user.Userdata;
/**
* @author hanl
diff --git a/full/src/test/java/de/ids_mannheim/korap/user/UserdataTest.java b/full/src/test/java/de/ids_mannheim/korap/user/UserdataTest.java
index 5137ed6..a20685a 100644
--- a/full/src/test/java/de/ids_mannheim/korap/user/UserdataTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/user/UserdataTest.java
@@ -1,25 +1,29 @@
package de.ids_mannheim.korap.user;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import de.ids_mannheim.korap.config.Attributes;
-import de.ids_mannheim.korap.config.BeanConfigTest;
-import de.ids_mannheim.korap.config.BeansFactory;
-import de.ids_mannheim.korap.exceptions.KustvaktException;
-import de.ids_mannheim.korap.exceptions.DatabaseException;
-import de.ids_mannheim.korap.handlers.UserDetailsDao;
-import de.ids_mannheim.korap.handlers.UserSettingsDao;
-import de.ids_mannheim.korap.interfaces.db.UserDataDbIface;
-import de.ids_mannheim.korap.user.User.CorpusAccess;
-import de.ids_mannheim.korap.utils.JsonUtils;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import java.util.HashMap;
import java.util.Map;
-import static org.junit.Assert.*;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+
+import de.ids_mannheim.korap.config.Attributes;
+import de.ids_mannheim.korap.config.BeanConfigTest;
+import de.ids_mannheim.korap.config.BeansFactory;
+import de.ids_mannheim.korap.exceptions.KustvaktException;
+import de.ids_mannheim.korap.handlers.UserDetailsDao;
+import de.ids_mannheim.korap.handlers.UserSettingsDao;
+import de.ids_mannheim.korap.interfaces.db.UserDataDbIface;
+import de.ids_mannheim.korap.utils.JsonUtils;
/**
* @author hanl
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/service/FastJerseyTest.java b/full/src/test/java/de/ids_mannheim/korap/web/service/FastJerseyTest.java
index 932ffb1..0ccd639 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/service/FastJerseyTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/service/FastJerseyTest.java
@@ -1,130 +1,38 @@
package de.ids_mannheim.korap.web.service;
-import com.sun.jersey.api.client.Client;
-import com.sun.jersey.api.client.WebResource;
-import com.sun.jersey.api.core.DefaultResourceConfig;
-import com.sun.jersey.spi.inject.SingletonTypeInjectableProvider;
-import com.sun.jersey.spi.spring.container.servlet.SpringServlet;
-import com.sun.jersey.test.framework.AppDescriptor;
-import com.sun.jersey.test.framework.LowLevelAppDescriptor;
-import com.sun.jersey.test.framework.WebAppDescriptor;
-import com.sun.jersey.test.framework.spi.container.TestContainer;
-import com.sun.jersey.test.framework.spi.container.TestContainerException;
-import com.sun.jersey.test.framework.spi.container.TestContainerFactory;
-import com.sun.jersey.test.framework.spi.container.grizzly.GrizzlyTestContainerFactory;
-import com.sun.jersey.test.framework.spi.container.grizzly.web.GrizzlyWebTestContainerFactory;
-import de.ids_mannheim.korap.config.BeanConfigTest;
-import org.junit.AfterClass;
import org.junit.Before;
-import org.junit.BeforeClass;
-import org.springframework.web.context.ContextLoaderListener;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationContext;
+import org.springframework.test.context.ContextConfiguration;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.UriBuilder;
-import java.io.IOException;
-import java.net.BindException;
-import java.net.URI;
+import de.ids_mannheim.korap.config.AppTestConfig;
+import de.ids_mannheim.korap.config.ContextHolder;
+import de.ids_mannheim.korap.config.TestHelper;
-/**
- * @author hanl
- * @date 29/07/2015
- */
-public abstract class FastJerseyTest extends BeanConfigTest {
+@ContextConfiguration(classes = AppTestConfig.class)
+public abstract class FastJerseyTest extends FastJerseyBaseTest {
- private final static String API_VERSION = "v0.1";
-
- private static DefaultResourceConfig resourceConfig =
- new DefaultResourceConfig();
-
- private static TestContainerFactory testContainerFactory;
-
- private static TestContainer testContainer;
-
- protected static Client client;
- private static String[] classPackages = null;
-
- private static int PORT = 8089; // FB, was: 9000;
- private static int PORT_IT = 1;
- protected static String containerURI = "http://localhost/";
+ private static String[] classPackages = new String[]{
+ "de.ids_mannheim.korap.web.service.full",
+ "de.ids_mannheim.korap.web.filter",
+ "de.ids_mannheim.korap.web.utils"};
- public static void addClass (Class<?> resourceClass) {
- resourceConfig.getClasses().add(resourceClass);
- }
-
-
- public static void setPackages (String ... pack) {
- classPackages = pack;
- }
-
-
- public static void addSingleton (Object resourceSingleton) {
- resourceConfig.getSingletons().add(resourceSingleton);
- }
-
-
- public String getAPIVersion () {
- return API_VERSION;
- }
-
-
- public static <T> void addProviderForContext (Class<T> contextClass,
- T contextObject) {
- addSingleton(new SingletonTypeInjectableProvider<Context, T>(
- contextClass, contextObject) {});
- }
-
-
- public static void addRequestFilter (Object filter) {
- resourceConfig.getContainerRequestFilters().add(filter);
- }
-
-
- public static void addResponseFilter (Object filter) {
- resourceConfig.getContainerResponseFilters().add(filter);
- }
-
-
- public static void setTestContainerFactory (
- TestContainerFactory newTestContainerFactory) {
- testContainerFactory = newTestContainerFactory;
- }
-
-
- @BeforeClass
- public static void cleanStaticVariables () {
- resourceConfig = new DefaultResourceConfig();
- }
-
-
- public static void initServer (int port) {
- AppDescriptor ad;
- if (classPackages == null)
- ad = new LowLevelAppDescriptor.Builder(resourceConfig).build();
- else
- ad = new WebAppDescriptor.Builder(classPackages)
- .servletClass(SpringServlet.class)
- .contextListenerClass(ContextLoaderListener.class)
- .contextParam("contextConfigLocation", "classpath:test-default-config.xml")
- .build();
-
- TestContainerFactory tcf = testContainerFactory;
- if (tcf == null) {
- if (classPackages == null)
- tcf = new GrizzlyTestContainerFactory();
- else
- tcf = new GrizzlyWebTestContainerFactory();
+ protected TestHelper helper () {
+ try {
+ return TestHelper.newInstance(this.context);
}
-
- testContainer = tcf.create(
- UriBuilder.fromUri(containerURI).port(port).build(), ad);
- client = testContainer.getClient();
- if (client == null) {
- client = Client.create(ad.getClientConfig());
+ catch (Exception e) {
+ return null;
}
}
-
-
+
+
+ @Override
+ protected ContextHolder getContext () {
+ return helper().getContext();
+ }
+
public static void startServer () {
try {
if (testContainer != null) {
@@ -132,39 +40,15 @@
}
}
catch (Exception e) {
- initServer(PORT + PORT_IT++);
+ initServer(PORT + PORT_IT++, classPackages);
startServer();
}
}
-
-
- @AfterClass
- public static void stopServer () {
- testContainer.stop();
- testContainer = null;
- client = null;
- }
-
-
- public Client client () {
- return client;
- }
-
-
- public URI getBaseUri () {
- return testContainer.getBaseUri();
- }
-
-
- public WebResource resource () {
- return client.resource(getBaseUri());
- }
-
-
+
@Before
public void startServerBeforeFirstTestRun () {
if (testContainer == null) {
- initServer(PORT);
+ initServer(PORT,classPackages);
startServer();
}
}
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/service/OAuth2HandlerTest.java b/full/src/test/java/de/ids_mannheim/korap/web/service/OAuth2HandlerTest.java
index 4bdb337..f0fecd3 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/service/OAuth2HandlerTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/service/OAuth2HandlerTest.java
@@ -1,5 +1,11 @@
package de.ids_mannheim.korap.web.service;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
import de.ids_mannheim.korap.config.AuthCodeInfo;
import de.ids_mannheim.korap.config.BeanConfigTest;
import de.ids_mannheim.korap.config.ClientInfo;
@@ -9,11 +15,6 @@
import de.ids_mannheim.korap.interfaces.EncryptionIface;
import de.ids_mannheim.korap.interfaces.db.PersistenceClient;
import de.ids_mannheim.korap.user.TokenContext;
-import org.junit.Test;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
/**
* @author hanl
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/service/SearchKrillTest.java b/full/src/test/java/de/ids_mannheim/korap/web/service/SearchKrillTest.java
index 867d8e6..4e06330 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/service/SearchKrillTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/service/SearchKrillTest.java
@@ -1,6 +1,13 @@
package de.ids_mannheim.korap.web.service;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Test;
+
import com.fasterxml.jackson.databind.JsonNode;
+
import de.ids_mannheim.korap.KrillIndex;
import de.ids_mannheim.korap.config.BeanConfigTest;
import de.ids_mannheim.korap.config.KustvaktConfiguration;
@@ -9,14 +16,6 @@
import de.ids_mannheim.korap.utils.JsonUtils;
import de.ids_mannheim.korap.web.SearchKrill;
-import org.junit.Assert;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-
/**
* Created by hanl on 02.06.16.
*/
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/service/full/AuthServiceTest.java b/full/src/test/java/de/ids_mannheim/korap/web/service/full/AuthServiceTest.java
index 7cb49a3..b7bdee0 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/service/full/AuthServiceTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/service/full/AuthServiceTest.java
@@ -27,9 +27,6 @@
@BeforeClass
public static void configure () throws Exception {
- FastJerseyTest.setPackages("de.ids_mannheim.korap.web.service.full",
- "de.ids_mannheim.korap.web.filter",
- "de.ids_mannheim.korap.web.utils");
credentials = new String[2];
credentials[0] = (String) TestHelper.getUserCredentials().get(Attributes.USERNAME);
credentials[1] = (String) TestHelper.getUserCredentials().get(Attributes.PASSWORD);
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/service/full/FilterTest.java b/full/src/test/java/de/ids_mannheim/korap/web/service/full/FilterTest.java
index 746a62c..fd568c4 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/service/full/FilterTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/service/full/FilterTest.java
@@ -20,14 +20,6 @@
*/
public class FilterTest extends FastJerseyTest {
- @BeforeClass
- public static void setup () throws Exception {
- FastJerseyTest.setPackages("de.ids_mannheim.korap.web.service.full",
- "de.ids_mannheim.korap.web.filter",
- "de.ids_mannheim.korap.web.utils");
- }
-
-
@Test
public void testTestUserAuth () {
ClientResponse resp = resource()
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/service/full/KustvaktCoreRestTest.java b/full/src/test/java/de/ids_mannheim/korap/web/service/full/KustvaktCoreRestTest.java
index 9113353..05f7062 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/service/full/KustvaktCoreRestTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/service/full/KustvaktCoreRestTest.java
@@ -22,16 +22,6 @@
// helper().runBootInterfaces();
}
- @BeforeClass
- public static void configure () {
-
-// FastJerseyTest.setPackages("de.ids_mannheim.korap.web.service.light", // version hanl
- FastJerseyTest.setPackages("de.ids_mannheim.korap.web.service.full", // volle Version FB
- "de.ids_mannheim.korap.web.filter",
- "de.ids_mannheim.korap.web.utils");
- }
-
-
// @Test
public void testFieldsInSearch () {
ClientResponse response = resource()
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/service/full/MatchInfoServiceTest.java b/full/src/test/java/de/ids_mannheim/korap/web/service/full/MatchInfoServiceTest.java
index 73dbc4a..374f9fc 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/service/full/MatchInfoServiceTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/service/full/MatchInfoServiceTest.java
@@ -19,14 +19,6 @@
public class MatchInfoServiceTest extends FastJerseyTest {
- @BeforeClass
- public static void configure () throws Exception {
- FastJerseyTest.setPackages("de.ids_mannheim.korap.web.service.full",
- "de.ids_mannheim.korap.web.filter",
- "de.ids_mannheim.korap.web.utils");
- }
-
-
@Test
public void testGetMatchInfoPublicCorpus () {
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/service/full/OAuth2EndpointTest.java b/full/src/test/java/de/ids_mannheim/korap/web/service/full/OAuth2EndpointTest.java
index ff1a23b..0b2ae91 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/service/full/OAuth2EndpointTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/service/full/OAuth2EndpointTest.java
@@ -24,13 +24,6 @@
// todo: in combination with other tests, causes failures!
public class OAuth2EndpointTest extends FastJerseyTest {
- @BeforeClass
- public static void configure () throws Exception {
- FastJerseyTest.setPackages("de.ids_mannheim.korap.web.service.full",
- "de.ids_mannheim.korap.web.filter",
- "de.ids_mannheim.korap.web.utils");
- }
-
@Override
public void initMethod () throws KustvaktException {
helper().setupAccount();
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/service/full/PolicyServiceTest.java b/full/src/test/java/de/ids_mannheim/korap/web/service/full/PolicyServiceTest.java
index f063aca..b9364df 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/service/full/PolicyServiceTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/service/full/PolicyServiceTest.java
@@ -38,14 +38,6 @@
private User user = UserFactory.getDemoUser();
- @BeforeClass
- public static void configure () throws Exception {
- FastJerseyTest.setPackages("de.ids_mannheim.korap.web.service.full",
- "de.ids_mannheim.korap.web.filter",
- "de.ids_mannheim.korap.web.utils");
- }
-
-
@Test
public void testCreatePolicyForVirtualCollection ()
throws IOException, KustvaktException {
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/service/full/QuerySerializationServiceTest.java b/full/src/test/java/de/ids_mannheim/korap/web/service/full/QuerySerializationServiceTest.java
index e33eb9e..eed1024 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/service/full/QuerySerializationServiceTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/service/full/QuerySerializationServiceTest.java
@@ -36,14 +36,6 @@
}
- @BeforeClass
- public static void configure () throws Exception {
- FastJerseyTest.setPackages("de.ids_mannheim.korap.web.service.full",
- "de.ids_mannheim.korap.web.filter",
- "de.ids_mannheim.korap.web.utils");
- }
-
-
@Test
public void testQuerySerializationFilteredPublic () {
ClientResponse response = resource()
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/service/full/ResourceInfoServiceTest.java b/full/src/test/java/de/ids_mannheim/korap/web/service/full/ResourceInfoServiceTest.java
index e0cfe1a..2ef3fd1 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/service/full/ResourceInfoServiceTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/service/full/ResourceInfoServiceTest.java
@@ -30,15 +30,6 @@
// helper().runBootInterfaces();
}
-
- @BeforeClass
- public static void configure () throws Exception {
- FastJerseyTest.setPackages("de.ids_mannheim.korap.web.service.full",
- "de.ids_mannheim.korap.web.filter",
- "de.ids_mannheim.korap.web.utils");
- }
-
-
@Test
public void testGetPublicVirtualCollectionInfo () {
ClientResponse response = resource().path(getAPIVersion())
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/service/full/ResourceServiceTest.java b/full/src/test/java/de/ids_mannheim/korap/web/service/full/ResourceServiceTest.java
index 5dd9bab..0ccc272 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/service/full/ResourceServiceTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/service/full/ResourceServiceTest.java
@@ -35,13 +35,6 @@
@Deprecated
public class ResourceServiceTest extends FastJerseyTest {
- @BeforeClass
- public static void configure () throws Exception {
- FastJerseyTest.setPackages("de.ids_mannheim.korap.web.service.full",
- "de.ids_mannheim.korap.web.filter",
- "de.ids_mannheim.korap.web.utils");
- }
-
// create a simple test collection for user kustvakt, otherwise test fails
@Test
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/service/full/SearchServiceTest.java b/full/src/test/java/de/ids_mannheim/korap/web/service/full/SearchServiceTest.java
index 909a250..82a9ebb 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/service/full/SearchServiceTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/service/full/SearchServiceTest.java
@@ -44,13 +44,6 @@
}
- @BeforeClass
- public static void configure () throws Exception {
- FastJerseyTest.setPackages("de.ids_mannheim.korap.web.service.full",
- "de.ids_mannheim.korap.web.filter",
- "de.ids_mannheim.korap.web.utils");
- }
-
@Test
public void testSearchQueryPublicCorpora () {
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/service/full/SearchWithAvailabilityTest.java b/full/src/test/java/de/ids_mannheim/korap/web/service/full/SearchWithAvailabilityTest.java
index 69ed333..3398e14 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/service/full/SearchWithAvailabilityTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/service/full/SearchWithAvailabilityTest.java
@@ -23,14 +23,6 @@
// helper().runBootInterfaces();
}
-
- @BeforeClass
- public static void configure () throws Exception {
- FastJerseyTest.setPackages("de.ids_mannheim.korap.web.service.full",
- "de.ids_mannheim.korap.web.filter",
- "de.ids_mannheim.korap.web.utils");
- }
-
private void checkAndFree (String json) {
JsonNode node = JsonUtils.readTree(json);
assertEquals("availability",
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/service/full/StatisticsServiceTest.java b/full/src/test/java/de/ids_mannheim/korap/web/service/full/StatisticsServiceTest.java
index 335f564..9f72b78 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/service/full/StatisticsServiceTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/service/full/StatisticsServiceTest.java
@@ -29,13 +29,6 @@
}
- @BeforeClass
- public static void configure () {
-// FastJerseyTest.setPackages("de.ids_mannheim.korap.web.service.light",
- FastJerseyTest.setPackages("de.ids_mannheim.korap.web.service.full",
- "de.ids_mannheim.korap.web.utils");
- }
-
@Test
public void testGetStatisticsNoResource ()
throws JsonProcessingException, IOException {
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/service/full/UserServiceTest.java b/full/src/test/java/de/ids_mannheim/korap/web/service/full/UserServiceTest.java
index f85ca36..4891c0b 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/service/full/UserServiceTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/service/full/UserServiceTest.java
@@ -54,8 +54,6 @@
@BeforeClass
public static void setup() throws Exception {
- FastJerseyTest.setPackages("de.ids_mannheim.korap.web.service.full", "de.ids_mannheim.korap.web.filter",
- "de.ids_mannheim.korap.web.utils");
credentials = new String[2];
credentials[0] = (String) TestHelper.getUserCredentials().get(Attributes.USERNAME);
credentials[1] = (String) TestHelper.getUserCredentials().get(Attributes.PASSWORD);
diff --git a/full/src/test/resources/kustvakt-test.conf b/full/src/test/resources/kustvakt-test.conf
index 50afe37..6659491 100644
--- a/full/src/test/resources/kustvakt-test.conf
+++ b/full/src/test/resources/kustvakt-test.conf
@@ -1,5 +1,5 @@
## index dir
-krill.indexDir = src/test/resources/sample-index
+krill.indexDir = /home/elma/git/Kustvakt-new/sample-index
krill.index.commit.count = 134217000
krill.index.commit.log = log/krill.commit.log
diff --git a/full/src/test/resources/test-default-config.xml b/full/src/test/resources/test-default-config.xml
index abd03af..34ad45e 100644
--- a/full/src/test/resources/test-default-config.xml
+++ b/full/src/test/resources/test-default-config.xml
@@ -52,7 +52,7 @@
<!-- props are injected from default-config.xml -->
<bean id="kustvakt_config" class="de.ids_mannheim.korap.config.KustvaktConfiguration">
- <property name="properties" ref="props" />
+ <constructor-arg name="properties" ref="props" />
</bean>
<!--class="org.apache.commons.dbcp2.BasicDataSource" -->