Removed deprecated loader codes and tests.
Change-Id: I38bdc4babe6a379cf761c2ea6e0a05b01a218482
diff --git a/core/src/main/java/de/ids_mannheim/korap/web/service/BootableBeanInterface.java b/core/src/main/java/de/ids_mannheim/korap/web/service/BootableBeanInterface.java
deleted file mode 100644
index 56915c3..0000000
--- a/core/src/main/java/de/ids_mannheim/korap/web/service/BootableBeanInterface.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package de.ids_mannheim.korap.web.service;
-
-import de.ids_mannheim.korap.config.ContextHolder;
-import de.ids_mannheim.korap.exceptions.KustvaktException;
-
-/**
- * @author hanl
- * @date 12/01/2016
- */
-@Deprecated
-public interface BootableBeanInterface {
-
- void load (ContextHolder beans) throws KustvaktException;
-
-
- Class<? extends BootableBeanInterface>[] getDependencies ();
-
-}
diff --git a/core/src/main/java/de/ids_mannheim/korap/web/service/BootupInterface.java b/core/src/main/java/de/ids_mannheim/korap/web/service/BootupInterface.java
deleted file mode 100644
index 86b62d9..0000000
--- a/core/src/main/java/de/ids_mannheim/korap/web/service/BootupInterface.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package de.ids_mannheim.korap.web.service;
-
-import de.ids_mannheim.korap.exceptions.KustvaktException;
-
-/**
- * @author hanl
- * @date 12/01/2016
- */
-@Deprecated
-public interface BootupInterface {
-
- void load () throws KustvaktException;
-
-
- Class<? extends BootupInterface>[] getDependencies ();
-
-}
diff --git a/core/src/main/java/de/ids_mannheim/korap/web/service/CollectionLoader.java b/core/src/main/java/de/ids_mannheim/korap/web/service/CollectionLoader.java
deleted file mode 100644
index 5485896..0000000
--- a/core/src/main/java/de/ids_mannheim/korap/web/service/CollectionLoader.java
+++ /dev/null
@@ -1,129 +0,0 @@
-package de.ids_mannheim.korap.web.service;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStreamReader;
-
-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.exceptions.StatusCodes;
-import de.ids_mannheim.korap.resources.KustvaktResource;
-import de.ids_mannheim.korap.resources.Permissions.Permission;
-import de.ids_mannheim.korap.resources.VirtualCollection;
-import de.ids_mannheim.korap.security.ac.PolicyBuilder;
-import de.ids_mannheim.korap.security.ac.ResourceFinder;
-import de.ids_mannheim.korap.security.ac.SecurityManager;
-import de.ids_mannheim.korap.user.User;
-import de.ids_mannheim.korap.utils.JsonUtils;
-import de.ids_mannheim.korap.utils.KoralCollectionQueryBuilder;
-
-/**
- * @author hanl, margaretha
- * @date 12/01/2016
- * @lastupdate 19/04/2017
- */
-@Deprecated
-public class CollectionLoader implements BootableBeanInterface {
-
- @Override
- @Deprecated
- public void load (ContextHolder beans) throws KustvaktException {
- SecurityManager.overrideProviders(beans);
- ResourceFinder.overrideProviders(beans);
-
- User user = User.UserFactory
- .toUser(KustvaktConfiguration.KUSTVAKT_USER);
-
- KustvaktConfiguration config = beans.getConfiguration();
- PolicyBuilder builder = new PolicyBuilder(user);
- String result = null;
- BufferedReader br;
- try {
- File f = new File(config.getPolicyConfig());
- br = new BufferedReader(
- new InputStreamReader(new FileInputStream(f)));
- }
- catch (FileNotFoundException e) {
- throw new KustvaktException("Policy config file: "
- + config.getPolicyConfig() + " does not exists!",
- e.getCause(), 101);
- }
- String policy = null, collectionQuery = null;
- String[] policyData = null;
- String type, id, name, description, condition;
- String[] permissions;
- try {
- while ((policy = br.readLine()) != null) {
- if (policy.startsWith("#") || policy.isEmpty())
- continue;
- policyData = policy.split("\t");
- type = policyData[0];
- id = policyData[1];
- name = policyData[2];
- description = policyData[3];
- condition = policyData[4];
- permissions = policyData[5].split(",");
- if (policyData.length > 6)
- collectionQuery = policyData[6];
-
- Permission[] permissionArr = new Permission[permissions.length];
- for (int i = 0; i < permissions.length; i++) {
- if (permissions[i].equals("read")) {
- permissionArr[i] = Permission.READ;
- }
- }
-
- KustvaktResource resource = createResource(type, id, name,
- description, collectionQuery);
- if (resource != null) {
- builder = new PolicyBuilder(user);
- builder.addCondition(condition);
- builder.setResources(resource);
- builder.setPermissions(permissionArr);
- result = builder.create();
- if (JsonUtils.readTree(result).size() > 0)
- throw new KustvaktException(StatusCodes.REQUEST_INVALID,
- "creating collections caused errors", result);
- }
- }
- br.close();
- }
- catch (IOException e) {
- throw new KustvaktException("Failed creating virtual collections.",
- e.getCause(), 100);
- }
- }
-
-
- private KustvaktResource createResource (String type, String id,
- String name, String description, String docQuery) {
- KoralCollectionQueryBuilder builder;
- KustvaktResource resource = null;
- if (type.equals("virtualcollection")) {
- resource = new VirtualCollection(id);
- if (!name.isEmpty()) {
- resource.setName(name);
- }
- if (!description.isEmpty()) {
- resource.setDescription(description);
- }
- if (docQuery != null && !docQuery.isEmpty()) {
- builder = new KoralCollectionQueryBuilder();
- builder.with(docQuery);
- resource.setFields(builder.toJSON());
- }
- }
-
- return resource;
- }
-
-
- @Override
- public Class<? extends BootableBeanInterface>[] getDependencies () {
- return new Class[] { UserLoader.class };
- }
-}
diff --git a/core/src/main/java/de/ids_mannheim/korap/web/service/PolicyLoader.java b/core/src/main/java/de/ids_mannheim/korap/web/service/PolicyLoader.java
deleted file mode 100644
index 91f7205..0000000
--- a/core/src/main/java/de/ids_mannheim/korap/web/service/PolicyLoader.java
+++ /dev/null
@@ -1,125 +0,0 @@
-package de.ids_mannheim.korap.web.service;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStreamReader;
-
-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.resources.Corpus;
-import de.ids_mannheim.korap.resources.Foundry;
-import de.ids_mannheim.korap.resources.KustvaktResource;
-import de.ids_mannheim.korap.resources.Layer;
-import de.ids_mannheim.korap.resources.VirtualCollection;
-import de.ids_mannheim.korap.resources.Permissions.Permission;
-import de.ids_mannheim.korap.security.ac.PolicyBuilder;
-import de.ids_mannheim.korap.security.ac.ResourceFinder;
-import de.ids_mannheim.korap.security.ac.SecurityManager;
-import de.ids_mannheim.korap.user.User;
-import de.ids_mannheim.korap.utils.KoralCollectionQueryBuilder;
-
-/**
- * @author hanl
- * @date 15/01/2016
- */
-@Deprecated
-public class PolicyLoader implements BootableBeanInterface {
-
- @Override
- public void load(ContextHolder beans) throws KustvaktException {
- SecurityManager.overrideProviders(beans);
- ResourceFinder.overrideProviders(beans);
-
- User user = User.UserFactory.toUser(KustvaktConfiguration.KUSTVAKT_USER);
- KustvaktConfiguration config = beans.getConfiguration();
- PolicyBuilder builder = new PolicyBuilder(user);
- BufferedReader br;
- try {
- File f = new File(config.getPolicyConfig());
- br = new BufferedReader(new InputStreamReader(new FileInputStream(f)));
- } catch (FileNotFoundException e) {
- throw new KustvaktException("Policy config file: " + config.getPolicyConfig() + " does not exists!",
- e.getCause(), 101);
- }
- String policy = null;
- String[] policyData = null;
- String type, id, name, description, condition;
- String[] permissions;
- try {
- while ((policy = br.readLine()) != null) {
- if (policy.startsWith("#") || policy.isEmpty()){
- continue;
- }
-
- policyData = policy.split("\t");
- type = policyData[0];
- id = policyData[1];
- name = policyData[2];
- description = policyData[3];
- condition = policyData[4];
- permissions = policyData[5].split(",");
-
- String collectionQuery = null;
- if (policyData.length > 6)
- collectionQuery = policyData[6];
-
- Permission[] permissionArr = new Permission[permissions.length];
- for (int i = 0; i < permissions.length; i++) {
- if (permissions[i].equals("read")) {
- permissionArr[i] = Permission.READ;
- }
- }
- KustvaktResource resource = createResource(type, id, name, description, collectionQuery);
- if (resource != null) {
- builder.addCondition(condition);
- builder.setResources(resource);
- builder.setPermissions(permissionArr);
- builder.create();
- }
- }
- br.close();
- } catch (IOException e) {
- throw new KustvaktException("Failed creating policies.", e.getCause(), 100);
- }
- }
-
- private KustvaktResource createResource(String type, String id, String name, String description, String docQuery) {
-
- KustvaktResource resource = null;
- if (type.equals("corpus")) {
- resource = new Corpus(id);
- } else if (type.equals("foundry")) {
- resource = new Foundry(id);
- } else if (type.equals("layer")) {
- resource = new Layer(id);
- } else if (type.equals("virtualcollection")) {
- KoralCollectionQueryBuilder builder;
- resource = new VirtualCollection(id);
- if (docQuery != null && !docQuery.isEmpty()) {
- builder = new KoralCollectionQueryBuilder();
- builder.with(docQuery);
- resource.setFields(builder.toJSON());
- }
- } else {
- return resource;
- }
-
- if (!name.isEmpty()) {
- resource.setName(name);
- }
- if (!description.isEmpty()) {
- resource.setDescription(description);
- }
-
- return resource;
- }
-
- @Override
- public Class<? extends BootableBeanInterface>[] getDependencies() {
- return new Class[] { UserLoader.class };
- }
-}
diff --git a/core/src/main/java/de/ids_mannheim/korap/web/service/UserLoader.java b/core/src/main/java/de/ids_mannheim/korap/web/service/UserLoader.java
deleted file mode 100644
index cab1e1b..0000000
--- a/core/src/main/java/de/ids_mannheim/korap/web/service/UserLoader.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package de.ids_mannheim.korap.web.service;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import de.ids_mannheim.korap.config.Attributes;
-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.AuthenticationManagerIface;
-
-/**
- * @author hanl
- * @date 12/01/2016
- */
-@Deprecated
-public class UserLoader implements BootableBeanInterface {
-
- @Override
- public void load (ContextHolder beans) throws KustvaktException {
- AuthenticationManagerIface manager = beans.getAuthenticationManager();
- manager.createUserAccount(KustvaktConfiguration.KUSTVAKT_USER, false);
-
- // EM: Fix me
- // EM: Hack for LDAP User
- //
- Map<String, Object> ldapUser = new HashMap<>();
- ldapUser.put(Attributes.ID, 101);
- ldapUser.put(Attributes.USERNAME, "LDAPDefaultUser");
- ldapUser.put(Attributes.PASSWORD, "unnecessary123");
- ldapUser.put(Attributes.EMAIL, "korap@ids-mannheim.de");
- ldapUser.put(Attributes.COUNTRY, "unnecessary");
- ldapUser.put(Attributes.ADDRESS, "unnecessary");
- ldapUser.put(Attributes.FIRSTNAME, "unnecessary");
- ldapUser.put(Attributes.LASTNAME, "unnecessary");
- ldapUser.put(Attributes.INSTITUTION, "IDS");
- ldapUser.put(Attributes.IS_ADMIN, "false");
-
- manager.createUserAccount(ldapUser, false);
- }
-
-
- @Override
- public Class<? extends BootableBeanInterface>[] getDependencies () {
- return new Class[0];
- }
-}
diff --git a/full/src/main/java/de/ids_mannheim/korap/server/KustvaktServer.java b/full/src/main/java/de/ids_mannheim/korap/server/KustvaktServer.java
index a43d6f0..4b3a6d6 100644
--- a/full/src/main/java/de/ids_mannheim/korap/server/KustvaktServer.java
+++ b/full/src/main/java/de/ids_mannheim/korap/server/KustvaktServer.java
@@ -1,15 +1,7 @@
package de.ids_mannheim.korap.server;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
import de.ids_mannheim.korap.config.BeansFactory;
-import de.ids_mannheim.korap.config.ContextHolder;
-import de.ids_mannheim.korap.config.KustvaktClassLoader;
-import de.ids_mannheim.korap.exceptions.KustvaktException;
import de.ids_mannheim.korap.web.KustvaktBaseServer;
-import de.ids_mannheim.korap.web.service.BootableBeanInterface;
/**
* pu
@@ -40,14 +32,14 @@
@Override
protected void setup () {
- Set<Class<? extends BootableBeanInterface>> set = KustvaktClassLoader
- .loadSubTypes(BootableBeanInterface.class);
-
- ContextHolder context = BeansFactory.getKustvaktContext();
- if (context == null)
- throw new RuntimeException("Beans could not be loaded!");
-
- List<BootableBeanInterface> list = new ArrayList<>(set.size());
+// Set<Class<? extends BootableBeanInterface>> set = KustvaktClassLoader
+// .loadSubTypes(BootableBeanInterface.class);
+//
+// ContextHolder context = BeansFactory.getKustvaktContext();
+// if (context == null)
+// throw new RuntimeException("Beans could not be loaded!");
+//
+// List<BootableBeanInterface> list = new ArrayList<>(set.size());
// for (Class cl : set) {
// BootableBeanInterface iface;
//
@@ -62,29 +54,29 @@
// continue;
// }
// }
- System.out.println("Found boot loading interfaces: " + list);
-
- while (!list.isEmpty()) {
- loop: for (BootableBeanInterface iface : new ArrayList<>(list)) {
- try {
- for (Class dep : iface.getDependencies()) {
- if (set.contains(dep))
- continue loop;
- }
- iface.load(context);
- list.remove(iface);
- set.remove(iface.getClass());
- System.out.println("Done with interface "
- + iface.getClass().getSimpleName());
- }
- catch (KustvaktException e) {
- // don't do anything!
- System.out.println("An error occurred in class "
- + iface.getClass().getSimpleName() + "!\n");
- e.printStackTrace();
- System.exit(-1);
- }
- }
- }
+// System.out.println("Found boot loading interfaces: " + list);
+//
+// while (!list.isEmpty()) {
+// loop: for (BootableBeanInterface iface : new ArrayList<>(list)) {
+// try {
+// for (Class dep : iface.getDependencies()) {
+// if (set.contains(dep))
+// continue loop;
+// }
+// iface.load(context);
+// list.remove(iface);
+// set.remove(iface.getClass());
+// System.out.println("Done with interface "
+// + iface.getClass().getSimpleName());
+// }
+// catch (KustvaktException e) {
+// // don't do anything!
+// System.out.println("An error occurred in class "
+// + iface.getClass().getSimpleName() + "!\n");
+// e.printStackTrace();
+// System.exit(-1);
+// }
+// }
+// }
}
}
diff --git a/full/src/main/java/de/ids_mannheim/korap/web/service/full/SearchService.java b/full/src/main/java/de/ids_mannheim/korap/web/service/full/SearchService.java
index ab33369..8dde18a 100644
--- a/full/src/main/java/de/ids_mannheim/korap/web/service/full/SearchService.java
+++ b/full/src/main/java/de/ids_mannheim/korap/web/service/full/SearchService.java
@@ -611,90 +611,6 @@
}
-
- /**
- * String search, String ql, List<String> parents, String cli,
- * String cri,
- * int cls, int crs, int num, int page, boolean cutoff) param
- * context will
- * be like this: context: "3-t,2-c"
- * <p/>
- * id does not have to be an integer. name is also possible, in
- * which case a
- * type reference is required
- *
- * @param securityContext
- * @param locale
- * @return
- */
- // todo: remove raw
-// @GET
-// @Path("/{type}/{id}/search")
- @Deprecated //EM
- public Response searchbyName (@Context SecurityContext securityContext,
- @Context Locale locale, @QueryParam("q") String query,
- @QueryParam("ql") String ql, @QueryParam("v") String v,
- @QueryParam("context") String ctx,
- @QueryParam("cutoff") Boolean cutoff,
- @QueryParam("count") Integer pageLength,
- @QueryParam("offset") Integer pageIndex,
- @QueryParam("page") Integer pageInteger, @PathParam("id") String id,
- @PathParam("type") String type, @QueryParam("cq") String cq,
- @QueryParam("raw") Boolean raw,
- @QueryParam("engine") String engine) {
- // ref is a virtual collection id!
- TokenContext context = (TokenContext) securityContext
- .getUserPrincipal();
- KustvaktConfiguration.BACKENDS eng = this.config.chooseBackend(engine);
- type = StringUtils.normalize(type);
- id = StringUtils.decodeHTML(id);
- raw = raw == null ? false : raw;
-
- try {
- User user = controller.getUser(context.getUsername());
- MetaQueryBuilder meta;
-
- if (!raw) {
- meta = createMetaQuery(pageIndex, pageInteger, ctx, pageLength,
- cutoff);
-
- QuerySerializer s = new QuerySerializer();
- s.setQuery(query, ql, v);
-
- // add collection query
- KoralCollectionQueryBuilder builder = new KoralCollectionQueryBuilder();
- builder.setBaseQuery(s.toJSON());
- //query = createQuery(user, type, id, builder);
- builder.with(Attributes.CORPUS_SIGLE, "=", id);
- builder.toJSON();
-
- }
- else {
- meta = new MetaQueryBuilder();
- }
-
- try {
- // rewrite process
- query = this.processor.processQuery(query, user);
- }
- catch (KustvaktException e) {
- jlog.error("Failed in rewriting query: " + query, e);
- throw KustvaktResponseHandler.throwit(500, e.getMessage(),
- null);
- }
-
- String result = doSearch(eng, query, pageLength, meta);
- jlog.debug("The result set: {}", result);
- return Response.ok(result).build();
- }
- catch (KustvaktException e) {
- jlog.error("Exception encountered: {}", e.string());
- throw KustvaktResponseHandler.throwit(e);
- }
-
- }
-
-
@Deprecated
private String createQuery (User user, String type, String id,
KoralCollectionQueryBuilder builder) {
diff --git a/full/src/test/java/de/ids_mannheim/korap/config/CollectionLoaderTest.java b/full/src/test/java/de/ids_mannheim/korap/config/CollectionLoaderTest.java
deleted file mode 100644
index 82af51b..0000000
--- a/full/src/test/java/de/ids_mannheim/korap/config/CollectionLoaderTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package de.ids_mannheim.korap.config;
-
-import de.ids_mannheim.korap.exceptions.KustvaktException;
-import de.ids_mannheim.korap.handlers.ResourceDao;
-import de.ids_mannheim.korap.web.service.CollectionLoader;
-import de.ids_mannheim.korap.web.service.UserLoader;
-import org.junit.Assert;
-import org.junit.Ignore;
-import org.junit.Test;
-
-/**
- * @author hanl
- * @date 11/02/2016
- */
-@Deprecated
-@Ignore
-public class CollectionLoaderTest extends BeanConfigTest {
-
- @Test
- public void testCollectionLoader () {
- ResourceDao dao = new ResourceDao(helper().getContext()
- .getPersistenceClient());
-
- boolean error = false;
- UserLoader u = new UserLoader();
- CollectionLoader l = new CollectionLoader();
- try {
- u.load(helper().getContext());
- l.load(helper().getContext());
- }
- catch (KustvaktException e) {
- error = true;
- }
- Assert.assertFalse(error);
- Assert.assertNotEquals("Is not supposed to be zero", 0, dao.size());
- }
-
-
- @Override
- public void initMethod () throws KustvaktException {
-
- }
-}
diff --git a/full/src/test/java/de/ids_mannheim/korap/config/ConfigTest.java b/full/src/test/java/de/ids_mannheim/korap/config/ConfigTest.java
index eabb0a3..991165b 100644
--- a/full/src/test/java/de/ids_mannheim/korap/config/ConfigTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/config/ConfigTest.java
@@ -1,20 +1,26 @@
package de.ids_mannheim.korap.config;
+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 java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.NoSuchAlgorithmException;
+import java.util.Map;
+import java.util.Properties;
+
+import org.codehaus.plexus.util.IOUtil;
+import org.junit.Ignore;
+import org.junit.Test;
+
import de.ids_mannheim.korap.exceptions.KustvaktException;
import de.ids_mannheim.korap.interfaces.EncryptionIface;
import de.ids_mannheim.korap.utils.ServiceInfo;
import de.ids_mannheim.korap.utils.TimeUtils;
-import de.ids_mannheim.korap.web.service.BootableBeanInterface;
-import org.codehaus.plexus.util.IOUtil;
-import org.junit.Assert;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import java.io.*;
-import java.security.NoSuchAlgorithmException;
-import java.util.*;
-
-import static org.junit.Assert.*;
/**
* @author hanl
@@ -81,45 +87,6 @@
"kustvakt.conf"));
}
-
- @Test
- public void testBootConfigRun () throws KustvaktException {
-// helper().runBootInterfaces();
- helper().setupAccount();
- assertNotNull(helper().getUser());
-
- Set<Class<? extends BootableBeanInterface>> set = KustvaktClassLoader
- .loadSubTypes(BootableBeanInterface.class);
-
- int check = set.size();
- List<String> tracker = new ArrayList<>();
- List<BootableBeanInterface> list = new ArrayList<>(set.size());
- for (Class cl : set) {
- BootableBeanInterface iface;
- try {
- iface = (BootableBeanInterface) cl.newInstance();
- list.add(iface);
- }
- catch (InstantiationException | IllegalAccessException e) {
- // do nothing
- }
- }
-
- while (!set.isEmpty()) {
- out_loop: for (BootableBeanInterface iface : new ArrayList<>(list)) {
- for (Class cl : iface.getDependencies()) {
- if (set.contains(cl))
- continue out_loop;
- }
- tracker.add(iface.getClass().getSimpleName());
- set.remove(iface.getClass());
- list.remove(iface);
- }
- }
- assertEquals(check, tracker.size());
- }
-
- // todo:
@Test
@Ignore
public void testKustvaktValueValidation() {
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
deleted file mode 100644
index 9be6496..0000000
--- a/full/src/test/java/de/ids_mannheim/korap/config/LoaderTest.java
+++ /dev/null
@@ -1,92 +0,0 @@
-package de.ids_mannheim.korap.config;
-
-import de.ids_mannheim.korap.exceptions.KustvaktException;
-import de.ids_mannheim.korap.web.service.BootableBeanInterface;
-import de.ids_mannheim.korap.web.service.CollectionLoader;
-import de.ids_mannheim.korap.web.service.PolicyLoader;
-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;
-import java.util.List;
-import java.util.Set;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-
-/**
- * @author hanl
- * @date 12/02/2016
- */
-public class LoaderTest extends BeanConfigTest {
-
- @Test
- @Ignore
- public void testConfigOrder () {
- System.out.println("done ...");
-
- List s = new ArrayList<>();
- s.add("new");
- s.add("new2");
- }
-
-
- @Override
- public void initMethod () throws KustvaktException {}
-
-
- @Test
- @Ignore
- @Deprecated
- public void runBootInterfaces () {
- Set<Class<? extends BootableBeanInterface>> set = new HashSet<>();
- set.add(CollectionLoader.class);
- set.add(PolicyLoader.class);
- set.add(UserLoader.class);
-
- List<BootableBeanInterface> list = new ArrayList<>(set.size());
- for (Class cl : set) {
- BootableBeanInterface iface;
- try {
- iface = (BootableBeanInterface) cl.newInstance();
- list.add(iface);
- }
- catch (InstantiationException | IllegalAccessException e) {
- // do nothing
- }
- }
- assertEquals(set.size(), list.size());
- List tracer = new ArrayList();
- System.out.println("Found boot loading interfaces: " + list);
- while (!set.isEmpty()) {
- out_loop: for (BootableBeanInterface iface : new ArrayList<>(list)) {
- try {
- 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());
- tracer.add(iface.getClass());
- }
- catch (KustvaktException e) {
- // don't do anything!
- System.out.println("An error occurred in class "
- + iface.getClass().getSimpleName() + "!\n" + e);
- throw new RuntimeException(
- "Boot loading interface failed ...");
- }
- }
- }
- assertEquals(0, tracer.indexOf(UserLoader.class));
- assertNotEquals(0, tracer.indexOf(CollectionLoader.class));
- assertNotEquals(0, tracer.indexOf(PolicyLoader.class));
- }
-
-}
diff --git a/full/src/test/java/de/ids_mannheim/korap/config/PolicyLoaderTest.java b/full/src/test/java/de/ids_mannheim/korap/config/PolicyLoaderTest.java
deleted file mode 100644
index f9a1a09..0000000
--- a/full/src/test/java/de/ids_mannheim/korap/config/PolicyLoaderTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package de.ids_mannheim.korap.config;
-
-import de.ids_mannheim.korap.exceptions.KustvaktException;
-import de.ids_mannheim.korap.security.ac.PolicyDao;
-import de.ids_mannheim.korap.web.service.CollectionLoader;
-import de.ids_mannheim.korap.web.service.PolicyLoader;
-import de.ids_mannheim.korap.web.service.UserLoader;
-import org.junit.Test;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-
-import org.junit.Ignore;
-
-/**
- * @author hanl
- * @date 11/02/2016
- */
-@Deprecated
-@Ignore
-public class PolicyLoaderTest extends BeanConfigTest {
-
- @Test
- @Ignore
- public void testPolicyLoader () {
- boolean error = false;
- UserLoader u = new UserLoader();
- CollectionLoader c = new CollectionLoader();
- PolicyLoader l = new PolicyLoader();
- try {
- u.load(helper().getContext());
- c.load(helper().getContext());
- l.load(helper().getContext());
- }
- catch (KustvaktException e) {
- e.printStackTrace();
- error = true;
- }
- assertFalse(error);
- PolicyDao dao = new PolicyDao(helper().getContext()
- .getPersistenceClient());
- assertNotEquals("Is not supposed to be zero", 0, dao.size());
- }
-
-
- @Override
- public void initMethod () throws KustvaktException {
-
- }
-}
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 69501ff..a490dfe 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
@@ -7,18 +7,14 @@
import java.io.File;
import java.io.IOException;
-import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.security.NoSuchAlgorithmException;
import java.sql.ResultSet;
import java.sql.SQLException;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
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;
@@ -27,43 +23,21 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
-import org.springframework.context.annotation.Bean;
import org.springframework.jdbc.core.RowCallbackHandler;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.jdbc.datasource.SingleConnectionDataSource;
import de.ids_mannheim.korap.exceptions.EmptyResultException;
import de.ids_mannheim.korap.exceptions.KustvaktException;
-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.JDBCClient;
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.resources.KustvaktResource;
-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;
import de.ids_mannheim.korap.user.User;
import de.ids_mannheim.korap.utils.TimeUtils;
-import de.ids_mannheim.korap.web.service.BootableBeanInterface;
-import de.ids_mannheim.korap.web.service.CollectionLoader;
/**
* creates a test user that can be used to access protected functions
@@ -248,52 +222,6 @@
return new HashMap<>(data);
}
-
- @Deprecated
- public TestHelper runBootInterfaces () {
- Set<Class<? extends BootableBeanInterface>> set = KustvaktClassLoader
- .loadSubTypes(BootableBeanInterface.class);
-
- List<BootableBeanInterface> list = new ArrayList<>(set.size());
- for (Class cl : set) {
- BootableBeanInterface iface;
- try {
- iface = (BootableBeanInterface) cl.newInstance();
- if (!(iface instanceof CollectionLoader)){
- list.add(iface);
- }
- }
- catch (InstantiationException | IllegalAccessException e) {
- // do nothing
- }
- }
- jlog.debug("Found boot loading interfaces: " + list);
- while (!list.isEmpty()) {
- out_loop: for (BootableBeanInterface iface : new ArrayList<>(list)) {
- try {
- jlog.debug("Running boot instructions from class "
- + iface.getClass().getSimpleName());
- for (Class cl : iface.getDependencies()) {
- if (set.contains(cl))
- continue out_loop;
- }
- set.remove(iface.getClass());
- list.remove(iface);
- iface.load(beansHolder);
- }
- catch (KustvaktException e) {
- // don't do anything!
- System.out.println("An error occurred in class "
- + iface.getClass().getSimpleName() + "!\n" + e);
- throw new RuntimeException(
- "Boot loading interface failed ...");
- }
- }
- }
- return this;
- }
-
-
public int setupResource (KustvaktResource resource)
throws KustvaktException {
ResourceDao dao = new ResourceDao(
diff --git a/full/src/test/java/de/ids_mannheim/korap/config/UserLoaderTest.java b/full/src/test/java/de/ids_mannheim/korap/config/UserLoaderTest.java
deleted file mode 100644
index 96a3e87..0000000
--- a/full/src/test/java/de/ids_mannheim/korap/config/UserLoaderTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package de.ids_mannheim.korap.config;
-
-import de.ids_mannheim.korap.exceptions.KustvaktException;
-import de.ids_mannheim.korap.handlers.EntityDao;
-import de.ids_mannheim.korap.web.service.UserLoader;
-import org.junit.Assert;
-import org.junit.Ignore;
-import org.junit.Test;
-
-/**
- * @author hanl
- * @date 11/02/2016
- */
-@Ignore
-public class UserLoaderTest extends BeanConfigTest {
-
- @Test
- public void testUserLoader () {
- EntityDao dao = new EntityDao(helper().getContext()
- .getPersistenceClient());
-
- boolean error = false;
- UserLoader l = new UserLoader();
- try {
- l.load(helper().getContext());
- }
- catch (KustvaktException e) {
- e.printStackTrace();
- error = true;
- }
- Assert.assertFalse(error);
- Assert.assertNotEquals("Is not supposed to be zero", 0, dao.size());
- }
-
-
- @Override
- public void initMethod () throws KustvaktException {
-
- }
-}
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 82a9ebb..1362f33 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
@@ -462,6 +462,8 @@
s.setQuery("[orth=der]", "poliqarp");
s.setCollection("corpusSigle=GOE");
+ s.setQuery("Wasser", "poliqarp");
+ System.out.println(s.toJSON());
ClientResponse response = resource()
.path("search").post(ClientResponse.class, s.toJSON());
assertEquals(ClientResponse.Status.OK.getStatusCode(),