Assembled lite version.
Change-Id: I48e60fffd9219a97923e7c388f4f97bcda416d3f
diff --git a/core/pom.xml b/core/pom.xml
new file mode 100644
index 0000000..26765dd
--- /dev/null
+++ b/core/pom.xml
@@ -0,0 +1,449 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>de.ids_mannheim.korap</groupId>
+ <artifactId>Kustvakt-core</artifactId>
+ <version>0.59.8</version>
+
+ <properties>
+ <java.version>1.7</java.version>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <spring-framework.version>4.3.7.RELEASE</spring-framework.version>
+ <jersey.version>1.19.4</jersey.version>
+ </properties>
+ <build>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ <includes>
+ <include>**/*.info</include>
+ <include>**/*.xml</include>
+ <include>**/*.conf</include>
+ <include>**/*.kustvakt</include>
+ <include>**/*.properties</include>
+ <include>**/*.sql</include>
+ </includes>
+ </resource>
+ </resources>
+ <testResources>
+ <testResource>
+ <directory>src/test/resources</directory>
+ <filtering>true</filtering>
+ <includes>
+ <include>**/*.prop</include>
+ <include>**/*.xml</include>
+ <include>**/*.conf</include>
+ <include>**/*.info</include>
+ <include>**/*.properties</include>
+ </includes>
+ </testResource>
+ <testResource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ <includes>
+ <include>**/*.info</include>
+ <include>**/*.properties</include>
+ </includes>
+ </testResource>
+ </testResources>
+ <plugins>
+ <!-- Formatter plugin for Eclipse based coding conventions http://maven-java-formatter-plugin.googlecode.com/svn/site/0.4/usage.html -->
+ <plugin>
+ <groupId>com.googlecode.maven-java-formatter-plugin</groupId>
+ <artifactId>maven-java-formatter-plugin</artifactId>
+ <version>0.4</version>
+ <configuration>
+ <configFile>${project.basedir}/Format.xml</configFile>
+ <overrideConfigCompilerVersion>true</overrideConfigCompilerVersion>
+ <compilerSource>1.7</compilerSource>
+ <compilerCompliance>1.7</compilerCompliance>
+ <compilerTargetPlatform>1.7</compilerTargetPlatform>
+ </configuration>
+ <!-- <executions> <execution> <goals> <goal>format</goal> </goals> </execution>
+ </executions> -->
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.3</version>
+ <configuration>
+ <compilerVersion>${java.version}</compilerVersion>
+ <source>${java.version}</source>
+ <target>${java.version}</target>
+ </configuration>
+ </plugin>
+
+ <!-- build tests jar, so extensions can use fastjerseytest class to build
+ rest tests -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.1</version>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.19.1</version>
+
+ <configuration>
+ <reuseForks>false</reuseForks>
+ <forkCount>2</forkCount>
+ <threadCount>10</threadCount>
+ <argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine>
+
+ <excludes>
+ <exclude>**/*APITest.java</exclude>
+ <exclude>de/ids_mannheim/korap/suites/*.java</exclude>
+ <exclude>**/KustvaktServerTest.java</exclude>
+ <exclude>**/ResourceServiceTest.java</exclude>
+ <exclude>**/ResourceInfoServiceTest.java</exclude>
+ <exclude>**/PolicyServiceTest.java</exclude>
+ </excludes>
+ <includes>
+ <include>de/ids_mannheim/korap/**/*.java</include>
+ </includes>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-shade-plugin</artifactId>
+ <version>2.1</version>
+ <executions>
+ <!-- option 1 -->
+ <execution>
+ <id>full</id>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <finalName>Kustvakt-${project.version}}-core</finalName>
+ <transformers>
+ <transformer
+ implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
+ <mainClass> de.ids_mannheim.korap.web.KustvaktServer </mainClass>
+ </transformer>
+ <transformer
+ implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/spring.handlers </resource>
+ </transformer>
+ <transformer
+ implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/spring.schemas </resource>
+ </transformer>
+ </transformers>
+ <!-- Additional configuration. apparently there is a securityException -->
+ <filters>
+ <filter>
+ <artifact>*:*</artifact>
+ <excludes>
+ <exclude>META-INF/*.SF</exclude>
+ <exclude>META-INF/*.DSA </exclude>
+ <exclude>META-INF/*.RSA </exclude>
+ </excludes>
+ </filter>
+ </filters>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-bundle</artifactId>
+ <version>${jersey.version}</version>
+ </dependency>
+ <!--EM: added -->
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-server</artifactId>
+ <version>${jersey.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.sun.jersey.contribs</groupId>
+ <artifactId>jersey-spring</artifactId>
+ <version>${jersey.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-web</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-aop</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <!-- EM:done -->
+ <dependency>
+ <groupId>com.sun.jersey.jersey-test-framework</groupId>
+ <artifactId>jersey-test-framework-core</artifactId>
+ <version>${jersey.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.jersey.jersey-test-framework</groupId>
+ <artifactId>jersey-test-framework-grizzly</artifactId>
+ <version>${jersey.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <!-- <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId>
+ <version>1.7.5</version> </dependency> -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>1.7.5</version>
+ </dependency>
+ <!-- <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId>
+ <version>1.2.17</version> </dependency> <dependency> <groupId>log4j</groupId>
+ <artifactId>apache-log4j-extras</artifactId> <version>1.2.17</version> </dependency> -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.12</version>
+ </dependency>
+ <dependency>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
+ <version>1.16.6</version>
+ </dependency>
+ <dependency>
+ <groupId>joda-time</groupId>
+ <artifactId>joda-time</artifactId>
+ <version>2.2</version>
+ </dependency>
+ <dependency>
+ <groupId>de.ids_mannheim.korap</groupId>
+ <artifactId>Koral</artifactId>
+ <version>0.27</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-servlet</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.xerial</groupId>
+ <artifactId>sqlite-jdbc</artifactId>
+ <version>3.8.10.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <version>5.1.6</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-dbcp2</artifactId>
+ <version>2.1.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-validator</groupId>
+ <artifactId>commons-validator</artifactId>
+ <version>1.4.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.mindrot</groupId>
+ <artifactId>jbcrypt</artifactId>
+ <version>0.3m</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.nimbusds</groupId>
+ <artifactId>nimbus-jose-jwt</artifactId>
+ <version>2.10.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>de.ids_mannheim.korap</groupId>
+ <artifactId>Krill</artifactId>
+ <version>0.55.9</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.xerial</groupId>
+ <artifactId>sqlite-jdbc</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.reflections</groupId>
+ <artifactId>reflections</artifactId>
+ <version>0.9.9-RC1</version>
+ </dependency>
+
+
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-core</artifactId>
+ <version>${spring-framework.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-web</artifactId>
+ <version>${spring-framework.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-asm</artifactId>
+ <version>3.1.4.RELEASE</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-orm</artifactId>
+ <version>${spring-framework.version}</version>
+ </dependency>
+ <!-- EM: done -->
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <version>${spring-framework.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context-support</artifactId>
+ <version>${spring-framework.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <version>${spring-framework.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <!-- apparently this order prevents the spring schemas from being overriden
+ in META-INF/spring.schemas, thus must stay like this -->
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-aop</artifactId>
+ <version>${spring-framework.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-aspects</artifactId>
+ <version>${spring-framework.version}</version>
+ </dependency>
+
+ <!-- copied from extension -->
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-jdbc</artifactId>
+ <version>${spring-framework.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-tx</artifactId>
+ <version>${spring-framework.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.flywaydb</groupId>
+ <artifactId>flyway-core</artifactId>
+ <version>4.0</version>
+ </dependency>
+
+ <!-- <dependency> <groupId>net.sf.ehcache</groupId> <artifactId>ehcache-core</artifactId>
+ <version>2.6.5</version> </dependency> -->
+
+ <dependency>
+ <groupId>org.apache.oltu.oauth2</groupId>
+ <artifactId>org.apache.oltu.oauth2.authzserver</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+
+ <!-- end copy -->
+
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ <version>3.2.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-server</artifactId>
+ <version>8.1.8.v20121106</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-servlet</artifactId>
+ <version>8.1.8.v20121106</version>
+ </dependency>
+ <dependency>
+ <groupId>asm</groupId>
+ <artifactId>asm</artifactId>
+ <version>3.3.1</version>
+ </dependency>
+ <dependency>
+ <groupId>com.novell.ldap</groupId>
+ <artifactId>jldap</artifactId>
+ <version>4.3</version>
+ </dependency>
+ <!-- https://mvnrepository.com/artifact/com.unboundid/unboundid-ldapsdk -->
+ <dependency>
+ <groupId>com.unboundid</groupId>
+ <artifactId>unboundid-ldapsdk</artifactId>
+ <version>3.2.1</version>
+ </dependency>
+
+ <!-- not part of public release <dependency> <groupId>KorAP-graphDB</groupId>
+ <artifactId>KorAP-graphDB</artifactId> <version>1.0-SNAPSHOT</version> <exclusions>
+ <exclusion> <groupId>org.antlr</groupId> <artifactId>antlr4-runtime</artifactId>
+ </exclusion> <exclusion> <groupId>org.glassfish.jersey.core</groupId> <artifactId>jersey-client</artifactId>
+ </exclusion> <exclusion> <groupId>org.glassfish.jersey.containers</groupId>
+ <artifactId>jersey-container-grizzly2-http</artifactId> </exclusion> <exclusion>
+ <groupId>org.glassfish.jersey.core</groupId> <artifactId>jersey-common</artifactId>
+ </exclusion> <exclusion> <groupId>org.glassfish.jersey.core</groupId> <artifactId>jersey-server</artifactId>
+ </exclusion> </exclusions> </dependency> -->
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.3.3</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>2.4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-ehcache</artifactId>
+ <version>5.1.8.Final</version>
+ </dependency>
+ </dependencies>
+
+
+</project>
\ No newline at end of file
diff --git a/core/src/main/java/de/ids_mannheim/korap/config/KustvaktConfiguration.java b/core/src/main/java/de/ids_mannheim/korap/config/KustvaktConfiguration.java
index 6c100ab..ae25ae1 100644
--- a/core/src/main/java/de/ids_mannheim/korap/config/KustvaktConfiguration.java
+++ b/core/src/main/java/de/ids_mannheim/korap/config/KustvaktConfiguration.java
@@ -1,25 +1,27 @@
package de.ids_mannheim.korap.config;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.regex.Pattern;
+
+import org.apache.log4j.PropertyConfigurator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import de.ids_mannheim.korap.exceptions.KustvaktException;
import de.ids_mannheim.korap.interfaces.EncryptionIface;
import de.ids_mannheim.korap.utils.TimeUtils;
import lombok.Getter;
-import org.apache.log4j.PropertyConfigurator;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.*;
-import java.util.regex.Pattern;
/**
* if configuration class is extended, loadSubTypes method should be
@@ -92,7 +94,10 @@
private String ldapConfig;
-
+ public KustvaktConfiguration (Properties properties) throws IOException {
+ load(properties);
+ }
+
/**
* loading of the properties and mapping to parameter variables
*
@@ -228,9 +233,9 @@
* @param props
* @throws IOException
*/
- public void setProperties (Properties props) throws IOException {
- this.load(props);
- }
+// public void setProperties (Properties props) throws IOException {
+// this.load(props);
+// }
/**
diff --git a/core/src/main/java/de/ids_mannheim/korap/exceptions/DatabaseException.java b/core/src/main/java/de/ids_mannheim/korap/exceptions/DatabaseException.java
index 702bf4b..26190cc 100644
--- a/core/src/main/java/de/ids_mannheim/korap/exceptions/DatabaseException.java
+++ b/core/src/main/java/de/ids_mannheim/korap/exceptions/DatabaseException.java
@@ -11,14 +11,18 @@
public class DatabaseException extends KustvaktException {
private DatabaseException (Object userid, Integer status, String message,
- String args) {
- super(String.valueOf(userid), status, message, args);
+ String args, Exception e) {
+ super(String.valueOf(userid), status, message, args, e);
}
-
public DatabaseException (Object userid, String target, Integer status, String message,
+ String ... args) {
+ this(null, userid, target, status, message);
+ }
+
+ public DatabaseException (Exception e, Object userid, String target, Integer status, String message,
String ... args) {
- this(userid, status, message, Arrays.asList(args).toString());
+ this(userid, status, message, Arrays.asList(args).toString(), e);
AuditRecord record = new AuditRecord(AuditRecord.CATEGORY.DATABASE);
record.setUserid(String.valueOf(userid));
record.setStatus(status);
@@ -29,7 +33,7 @@
public DatabaseException (KustvaktException e, Integer status, String ... args) {
- this(e.getUserid(), e.getStatusCode(), e.getMessage(), e.getEntity());
+ this(e.getUserid(), e.getStatusCode(), e.getMessage(), e.getEntity(), e);
AuditRecord record = AuditRecord.dbRecord(e.getUserid(), status, args);
record.setField_1(e.string());
this.records.addAll(e.getRecords());
diff --git a/core/src/main/java/de/ids_mannheim/korap/exceptions/KustvaktException.java b/core/src/main/java/de/ids_mannheim/korap/exceptions/KustvaktException.java
index bdbe010..696d34f 100644
--- a/core/src/main/java/de/ids_mannheim/korap/exceptions/KustvaktException.java
+++ b/core/src/main/java/de/ids_mannheim/korap/exceptions/KustvaktException.java
@@ -38,10 +38,14 @@
this.userid = String.valueOf(userid);
}
+ public KustvaktException (Object userid, int status, String message,
+ String entity) {
+ this(userid, status, message, entity, null);
+ }
public KustvaktException (Object userid, int status, String message,
- String entity) {
- super(message);
+ String entity, Exception e) {
+ super(message, e);
this.statusCode = status;
this.entity = entity;
this.userid = String.valueOf(userid);
diff --git a/core/src/main/java/de/ids_mannheim/korap/exceptions/WrappedException.java b/core/src/main/java/de/ids_mannheim/korap/exceptions/WrappedException.java
index 3e067a7..534419a 100644
--- a/core/src/main/java/de/ids_mannheim/korap/exceptions/WrappedException.java
+++ b/core/src/main/java/de/ids_mannheim/korap/exceptions/WrappedException.java
@@ -13,13 +13,13 @@
public class WrappedException extends KustvaktException {
private WrappedException (Object userid, Integer status, String message,
- String args) {
- super(String.valueOf(userid), status, message, args);
+ String args, Exception rootCause) {
+ super(String.valueOf(userid), status, message, args, rootCause);
}
public WrappedException (Object userid, Integer status, String ... args) {
- this(userid, status, "", Arrays.asList(args).toString());
+ this(userid, status, "", Arrays.asList(args).toString(), null);
AuditRecord record = AuditRecord.serviceRecord(userid, status, args);
this.records.add(record);
}
@@ -27,7 +27,7 @@
public WrappedException (KustvaktException e, Integer status,
String ... args) {
- this(e.getUserid(), e.getStatusCode(), e.getMessage(), e.getEntity());
+ this(e.getUserid(), e.getStatusCode(), e.getMessage(), e.getEntity(), e);
AuditRecord record = AuditRecord.serviceRecord(e.getUserid(), status,
args);
record.setField_1(e.string());
diff --git a/core/src/main/java/de/ids_mannheim/korap/resource/rewrite/RewriteHandler.java b/core/src/main/java/de/ids_mannheim/korap/resource/rewrite/RewriteHandler.java
index 7a3308f..89f9bdd 100644
--- a/core/src/main/java/de/ids_mannheim/korap/resource/rewrite/RewriteHandler.java
+++ b/core/src/main/java/de/ids_mannheim/korap/resource/rewrite/RewriteHandler.java
@@ -49,11 +49,12 @@
this.query_processors = new HashSet<>();
this.failed_task_registration = new HashSet<>();
this.beans = null;
+ this.add(FoundryInject.class);
}
public void defaultRewriteConstraints () {
- this.add(FoundryInject.class);
+// this.add(FoundryInject.class);
//this.add(PublicCollection.class);
this.add(CollectionRewrite.class);
this.add(IdWriter.class);
diff --git a/core/src/main/java/de/ids_mannheim/korap/web/KustvaktBaseServer.java b/core/src/main/java/de/ids_mannheim/korap/web/KustvaktBaseServer.java
index 4ef0d7a..92be0ef 100644
--- a/core/src/main/java/de/ids_mannheim/korap/web/KustvaktBaseServer.java
+++ b/core/src/main/java/de/ids_mannheim/korap/web/KustvaktBaseServer.java
@@ -30,25 +30,6 @@
}
- public static void main (String[] args) throws Exception {
- KustvaktBaseServer server = new KustvaktBaseServer() {
- @Override
- protected void setup () {}
- };
- kargs = server.readAttributes(args);
-
- if (kargs.config != null)
- BeansFactory.loadFileContext(kargs.config);
- else
- BeansFactory.loadClasspathContext();
-
- kargs.setRootPackages(new String[] { "de.ids_mannheim.korap.web.service.light" });
- rootPackages = "de.ids_mannheim.korap.web.service.light";
-
- server.start();
- }
-
-
protected KustvaktArgs readAttributes (String[] args) {
KustvaktArgs kargs = new KustvaktArgs();
for (int i = 0; i < args.length; i++) {
@@ -94,7 +75,7 @@
ServletContextHandler contextHandler = new ServletContextHandler(
ServletContextHandler.NO_SESSIONS);
contextHandler.setContextPath("/");
- contextHandler.setInitParameter("contextConfigLocation", "classpath:default-config.xml");
+ contextHandler.setInitParameter("contextConfigLocation", "classpath:"+kargs.getConfig());
ServletContextListener listener = new ContextLoaderListener();
contextHandler.addEventListener(listener);
diff --git a/core/src/main/java/de/ids_mannheim/korap/web/SearchKrill.java b/core/src/main/java/de/ids_mannheim/korap/web/SearchKrill.java
index eca0a23..3e7095c 100644
--- a/core/src/main/java/de/ids_mannheim/korap/web/SearchKrill.java
+++ b/core/src/main/java/de/ids_mannheim/korap/web/SearchKrill.java
@@ -5,6 +5,7 @@
import java.io.IOException;
import java.nio.file.Paths;
import java.util.List;
+import java.util.Properties;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -36,7 +37,7 @@
String i = "/Users/hanl/Projects/prep_corpus";
String klinux10 = "/vol/work/hanl/indices";
private KrillIndex index;
-
+
/**
* Constructor
*/
diff --git a/core/src/main/java/de/ids_mannheim/korap/web/filter/AdminFilter.java b/core/src/main/java/de/ids_mannheim/korap/web/filter/AdminFilter.java
index bfd12f9..377efaa 100644
--- a/core/src/main/java/de/ids_mannheim/korap/web/filter/AdminFilter.java
+++ b/core/src/main/java/de/ids_mannheim/korap/web/filter/AdminFilter.java
@@ -5,6 +5,8 @@
import javax.ws.rs.ext.Provider;
+import org.springframework.beans.factory.annotation.Autowired;
+
import com.sun.jersey.spi.container.ContainerRequest;
import com.sun.jersey.spi.container.ContainerRequestFilter;
import com.sun.jersey.spi.container.ContainerResponseFilter;
@@ -28,8 +30,8 @@
@Provider
public class AdminFilter implements ContainerRequestFilter, ResourceFilter {
- private static AuthenticationManagerIface authManager = BeansFactory.getKustvaktContext()
- .getAuthenticationManager();
+ @Autowired
+ private AuthenticationManagerIface authManager;
@Override
public ContainerRequest filter(ContainerRequest cr) {
diff --git a/core/src/test/java/de/ids_mannheim/korap/config/AppTestConfigBase.java b/core/src/test/java/de/ids_mannheim/korap/config/AppTestConfigBase.java
new file mode 100644
index 0000000..76db69e
--- /dev/null
+++ b/core/src/test/java/de/ids_mannheim/korap/config/AppTestConfigBase.java
@@ -0,0 +1,39 @@
+package de.ids_mannheim.korap.config;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class AppTestConfigBase {
+
+ private static String mainConfigurationFile = "kustvakt-test.conf";
+
+ @Bean(name = ContextHolder.KUSTVAKT_CONFIG)
+ public KustvaktConfiguration getConfig () {
+
+ KustvaktConfiguration c = null;
+
+ InputStream s = ConfigLoader.loadConfigStream(mainConfigurationFile);
+
+ if (s != null){
+ Properties p = new Properties();
+ try {
+ p.load(s);
+ c = new KustvaktConfiguration(p);
+ }
+ catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ else {
+ System.out.println("No properties found!");
+ System.exit(-1);
+ }
+ return c;
+ }
+
+}
diff --git a/core/src/test/java/de/ids_mannheim/korap/config/BeanConfigBaseTest.java b/core/src/test/java/de/ids_mannheim/korap/config/BeanConfigBaseTest.java
new file mode 100644
index 0000000..d7be3d1
--- /dev/null
+++ b/core/src/test/java/de/ids_mannheim/korap/config/BeanConfigBaseTest.java
@@ -0,0 +1,100 @@
+package de.ids_mannheim.korap.config;
+
+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;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import de.ids_mannheim.korap.exceptions.KustvaktException;
+import net.jcip.annotations.NotThreadSafe;
+
+/**
+ * @author hanl
+ * @date 09/03/2016
+ */
+@NotThreadSafe
+@RunWith(BeanConfigBaseTest.SpringExtendedSetupListener.class)
+@ContextConfiguration(classes = AppTestConfigBase.class)
+@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
+public abstract class BeanConfigBaseTest {
+
+ private static Logger jlog = Logger.getLogger(BeanConfigBaseTest.class);
+// @Autowired
+ protected ApplicationContext context;
+
+ @Before
+ public void init () throws Exception {
+ 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() + " ...");
+ BeansFactory.setKustvaktContext(getContext());
+ assertNotNull(BeansFactory.getKustvaktContext());
+ initMethod();
+ }
+
+
+ protected abstract ContextHolder getContext ();
+
+
+ public void close () {
+ BeansFactory.closeApplication();
+ }
+
+ public abstract void initMethod () throws KustvaktException;
+
+
+// protected TestHelper helper () {
+// try {
+// return TestHelper.newInstance(this.context);
+// }
+// catch (Exception e) {
+// return null;
+// }
+// }
+
+
+ public static class SpringExtendedSetupListener extends
+ SpringJUnit4ClassRunner {
+
+ private BeanConfigBaseTest instanceSetupListener;
+
+
+ public SpringExtendedSetupListener (Class<?> clazz)
+ throws InitializationError {
+ super(clazz);
+ }
+
+
+ @Override
+ protected Object createTest () throws Exception {
+ 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 BeanConfigBaseTest && instanceSetupListener == null) {
+ instanceSetupListener = (BeanConfigBaseTest) test;
+ instanceSetupListener.init();
+ }
+ return test;
+ }
+
+
+ @Override
+ public void run (RunNotifier notifier) {
+ super.run(notifier);
+ if (instanceSetupListener != null)
+ instanceSetupListener.close();
+ }
+
+
+ }
+}
diff --git a/core/src/test/java/de/ids_mannheim/korap/web/service/FastJerseyBaseTest.java b/core/src/test/java/de/ids_mannheim/korap/web/service/FastJerseyBaseTest.java
new file mode 100644
index 0000000..625be6a
--- /dev/null
+++ b/core/src/test/java/de/ids_mannheim/korap/web/service/FastJerseyBaseTest.java
@@ -0,0 +1,150 @@
+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.BeanConfigBaseTest;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.springframework.web.context.ContextLoaderListener;
+
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.UriBuilder;
+import java.io.IOException;
+import java.net.BindException;
+import java.net.URI;
+
+/**
+ * @author hanl
+ * @date 29/07/2015
+ */
+public abstract class FastJerseyBaseTest extends BeanConfigBaseTest {
+
+ private final static String API_VERSION = "v0.1";
+
+ private static DefaultResourceConfig resourceConfig =
+ new DefaultResourceConfig();
+
+ private static TestContainerFactory testContainerFactory;
+
+ protected static TestContainer testContainer;
+
+ protected static Client client;
+
+ protected static int PORT = 8089; // FB, was: 9000;
+ protected static int PORT_IT = 1;
+ protected static String containerURI = "http://localhost/";
+
+
+ public static void addClass (Class<?> resourceClass) {
+ resourceConfig.getClasses().add(resourceClass);
+ }
+
+ 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();
+ }
+
+
+ protected static void initServer (int port, String[] classPackages) {
+ 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();
+ }
+
+ testContainer = tcf.create(
+ UriBuilder.fromUri(containerURI).port(port).build(), ad);
+ client = testContainer.getClient();
+ if (client == null) {
+ client = Client.create(ad.getClientConfig());
+ }
+ }
+
+
+
+
+
+ @After
+ public 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());
+ }
+
+
+
+}
diff --git a/full/pom.xml b/full/pom.xml
new file mode 100644
index 0000000..8efeb30
--- /dev/null
+++ b/full/pom.xml
@@ -0,0 +1,196 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>de.ids_mannheim.korap</groupId>
+ <artifactId>Kustvakt-full</artifactId>
+ <version>0.1</version>
+ <properties>
+ <java.version>1.7</java.version>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <spring-framework.version>4.3.7.RELEASE</spring-framework.version>
+ <jersey.version>1.19.4</jersey.version>
+ </properties>
+ <build>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ <includes>
+ <include>**/*.info</include>
+ <include>**/*.xml</include>
+ <include>**/*.conf</include>
+ <include>**/*.kustvakt</include>
+ <include>**/*.properties</include>
+ <include>**/*.sql</include>
+ </includes>
+ </resource>
+ </resources>
+ <testResources>
+ <testResource>
+ <directory>src/test/resources</directory>
+ <filtering>true</filtering>
+ <includes>
+ <include>**/*.prop</include>
+ <include>**/*.xml</include>
+ <include>**/*.conf</include>
+ <include>**/*.info</include>
+ <include>**/*.properties</include>
+ </includes>
+ </testResource>
+ <testResource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ <includes>
+ <include>**/*.info</include>
+ <include>**/*.properties</include>
+ </includes>
+ </testResource>
+ </testResources>
+ <plugins>
+ <!-- Formatter plugin for Eclipse based coding conventions http://maven-java-formatter-plugin.googlecode.com/svn/site/0.4/usage.html -->
+ <plugin>
+ <groupId>com.googlecode.maven-java-formatter-plugin</groupId>
+ <artifactId>maven-java-formatter-plugin</artifactId>
+ <version>0.4</version>
+ <configuration>
+ <configFile>${project.basedir}/Format.xml</configFile>
+ <overrideConfigCompilerVersion>true</overrideConfigCompilerVersion>
+ <compilerSource>${java.version}</compilerSource>
+ <compilerCompliance>${java.version}</compilerCompliance>
+ <compilerTargetPlatform>${java.version}</compilerTargetPlatform>
+ </configuration>
+ <!-- <executions> <execution> <goals> <goal>format</goal> </goals> </execution>
+ </executions> -->
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.3</version>
+ <configuration>
+ <compilerVersion>${java.version}</compilerVersion>
+ <source>${java.version}</source>
+ <target>${java.version}</target>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.19.1</version>
+ <configuration>
+ <reuseForks>false</reuseForks>
+ <forkCount>2</forkCount>
+ <threadCount>10</threadCount>
+
+ <excludes>
+ <exclude>**/*APITest.java</exclude>
+ <exclude>de/ids_mannheim/korap/suites/*.java</exclude>
+ <exclude>**/KustvaktServerTest.java</exclude>
+ <exclude>**/ResourceServiceTest.java</exclude>
+ <exclude>**/ResourceInfoServiceTest.java</exclude>
+ <exclude>**/PolicyServiceTest.java</exclude>
+ </excludes>
+ <includes>
+ <include>de/ids_mannheim/korap/**/*.java</include>
+ </includes>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-shade-plugin</artifactId>
+ <version>2.1</version>
+ <executions>
+ <!-- option 1 -->
+ <execution>
+ <id>full</id>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <finalName>Kustvakt-${project.version}-full</finalName>
+ <transformers>
+ <transformer
+ implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
+ <mainClass>
+ de.ids_mannheim.korap.server.KustvaktServer
+ </mainClass>
+ </transformer>
+ <transformer
+ implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/spring.handlers
+ </resource>
+ </transformer>
+ <transformer
+ implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/spring.schemas
+ </resource>
+ </transformer>
+ </transformers>
+ <!-- Additional configuration. apparently there is a securityException -->
+ <filters>
+ <filter>
+ <artifact>*:*</artifact>
+ <excludes>
+ <exclude>META-INF/*.SF</exclude>
+ <exclude>META-INF/*.DSA
+ </exclude>
+ <exclude>META-INF/*.RSA
+ </exclude>
+ </excludes>
+ </filter>
+ </filters>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>de.ids_mannheim.korap</groupId>
+ <artifactId>Kustvakt-core</artifactId>
+ <version>0.59.8</version>
+ </dependency>
+ <dependency>
+ <groupId>de.ids_mannheim.korap</groupId>
+ <artifactId>Kustvakt-core</artifactId>
+ <version>0.59.8</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- Hibernate -->
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-entitymanager</artifactId>
+ <version>5.1.8.Final</version>
+ </dependency>
+
+
+ <!-- Jersey -->
+ <dependency>
+ <groupId>com.sun.jersey.jersey-test-framework</groupId>
+ <artifactId>jersey-test-framework-core</artifactId>
+ <version>${jersey.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.jersey.jersey-test-framework</groupId>
+ <artifactId>jersey-test-framework-grizzly</artifactId>
+ <version>${jersey.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- Spring -->
+<!-- <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <version>${spring-framework.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ -->
+
+ </dependencies>
+</project>
\ No newline at end of file
diff --git a/full/src/main/java/de/ids_mannheim/korap/filter/AuthFilter.java b/full/src/main/java/de/ids_mannheim/korap/filter/AuthFilter.java
index 0807d23..79d5511 100644
--- a/full/src/main/java/de/ids_mannheim/korap/filter/AuthFilter.java
+++ b/full/src/main/java/de/ids_mannheim/korap/filter/AuthFilter.java
@@ -1,4 +1,4 @@
-package de.ids_mannheim.korap.web.filter;
+package de.ids_mannheim.korap.filter;
import com.sun.jersey.spi.container.ContainerRequest;
import com.sun.jersey.spi.container.ContainerRequestFilter;
diff --git a/full/src/main/java/de/ids_mannheim/korap/handlers/EntityDao.java b/full/src/main/java/de/ids_mannheim/korap/handlers/EntityDao.java
index ac16556..19e091c 100644
--- a/full/src/main/java/de/ids_mannheim/korap/handlers/EntityDao.java
+++ b/full/src/main/java/de/ids_mannheim/korap/handlers/EntityDao.java
@@ -265,12 +265,12 @@
catch (DuplicateKeyException e) {
jlog.error("Could not create user account with username: {}",
user.getUsername());
- throw new DatabaseException(user.getUsername(), "korap_users",
+ throw new DatabaseException(e, user.getUsername(), "korap_users",
StatusCodes.ENTRY_EXISTS, "Username exists.",
user.getUsername());
}
catch (DataAccessException e) {
- throw new DatabaseException(user.getUsername(), "korap_users",
+ throw new DatabaseException(e, user.getUsername(), "korap_users",
StatusCodes.ENTRY_EXISTS, "Username exists.",
user.getUsername());
}
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 86e9da9..a43d6f0 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,4 +1,4 @@
-package de.ids_mannheim.korap.web;
+package de.ids_mannheim.korap.server;
import java.util.ArrayList;
import java.util.List;
@@ -8,6 +8,7 @@
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;
/**
@@ -26,9 +27,10 @@
if (kargs.getConfig() != null)
BeansFactory.loadFileContext(kargs.getConfig());
- else
+ else{
+ kargs.setConfig("default-config.xml");
BeansFactory.loadClasspathContext("default-config.xml");
-
+ }
kargs.setRootPackages(new String[] { "de.ids_mannheim.korap.web.utils",
"de.ids_mannheim.korap.web.service.full" });
rootPackages = "de.ids_mannheim.korap.web.utils;"
diff --git a/full/src/main/java/de/ids_mannheim/korap/web/service/full/AdminService.java b/full/src/main/java/de/ids_mannheim/korap/web/service/full/AdminService.java
index d3694b8..67be146 100644
--- a/full/src/main/java/de/ids_mannheim/korap/web/service/full/AdminService.java
+++ b/full/src/main/java/de/ids_mannheim/korap/web/service/full/AdminService.java
@@ -32,10 +32,10 @@
import de.ids_mannheim.korap.resources.ResourceFactory;
import de.ids_mannheim.korap.security.PolicyCondition;
import de.ids_mannheim.korap.security.ac.PolicyBuilder;
+import de.ids_mannheim.korap.server.KustvaktServer;
import de.ids_mannheim.korap.user.User;
import de.ids_mannheim.korap.utils.JsonUtils;
import de.ids_mannheim.korap.utils.TimeUtils;
-import de.ids_mannheim.korap.web.KustvaktServer;
import de.ids_mannheim.korap.web.filter.AdminFilter;
import de.ids_mannheim.korap.web.filter.PiwikFilter;
import de.ids_mannheim.korap.web.utils.KustvaktResponseHandler;
diff --git a/full/src/main/java/de/ids_mannheim/korap/web/service/full/AnnotationService.java b/full/src/main/java/de/ids_mannheim/korap/web/service/full/AnnotationService.java
index 102ed8b..5055e56 100644
--- a/full/src/main/java/de/ids_mannheim/korap/web/service/full/AnnotationService.java
+++ b/full/src/main/java/de/ids_mannheim/korap/web/service/full/AnnotationService.java
@@ -27,8 +27,8 @@
import de.ids_mannheim.korap.entity.AnnotationPair;
import de.ids_mannheim.korap.exceptions.KustvaktException;
import de.ids_mannheim.korap.exceptions.StatusCodes;
+import de.ids_mannheim.korap.filter.AuthFilter;
import de.ids_mannheim.korap.utils.JsonUtils;
-import de.ids_mannheim.korap.web.filter.AuthFilter;
import de.ids_mannheim.korap.web.filter.DemoUserFilter;
import de.ids_mannheim.korap.web.filter.PiwikFilter;
import de.ids_mannheim.korap.web.utils.KustvaktResponseHandler;
diff --git a/full/src/main/java/de/ids_mannheim/korap/web/service/full/AuthService.java b/full/src/main/java/de/ids_mannheim/korap/web/service/full/AuthService.java
index 2802ceb..96f345c 100644
--- a/full/src/main/java/de/ids_mannheim/korap/web/service/full/AuthService.java
+++ b/full/src/main/java/de/ids_mannheim/korap/web/service/full/AuthService.java
@@ -7,13 +7,14 @@
import de.ids_mannheim.korap.config.BeansFactory;
import de.ids_mannheim.korap.exceptions.KustvaktException;
import de.ids_mannheim.korap.exceptions.StatusCodes;
+import de.ids_mannheim.korap.filter.AuthFilter;
import de.ids_mannheim.korap.interfaces.AuthenticationManagerIface;
import de.ids_mannheim.korap.security.auth.BasicHttpAuth;
+import de.ids_mannheim.korap.server.KustvaktServer;
import de.ids_mannheim.korap.user.*;
import de.ids_mannheim.korap.utils.JsonUtils;
import de.ids_mannheim.korap.utils.KustvaktLogger;
import de.ids_mannheim.korap.utils.ServiceInfo;
-import de.ids_mannheim.korap.web.KustvaktServer;
import de.ids_mannheim.korap.web.filter.*;
import de.ids_mannheim.korap.web.utils.KustvaktResponseHandler;
diff --git a/full/src/main/java/de/ids_mannheim/korap/web/service/full/DocumentService.java b/full/src/main/java/de/ids_mannheim/korap/web/service/full/DocumentService.java
index 83dee9c..df23da8 100644
--- a/full/src/main/java/de/ids_mannheim/korap/web/service/full/DocumentService.java
+++ b/full/src/main/java/de/ids_mannheim/korap/web/service/full/DocumentService.java
@@ -5,9 +5,9 @@
import de.ids_mannheim.korap.exceptions.KustvaktException;
import de.ids_mannheim.korap.handlers.DocumentDao;
import de.ids_mannheim.korap.resources.Document;
+import de.ids_mannheim.korap.server.KustvaktServer;
import de.ids_mannheim.korap.utils.JsonUtils;
import de.ids_mannheim.korap.utils.KustvaktLogger;
-import de.ids_mannheim.korap.web.KustvaktServer;
import de.ids_mannheim.korap.web.filter.AdminFilter;
import de.ids_mannheim.korap.web.utils.KustvaktResponseHandler;
import org.slf4j.Logger;
diff --git a/full/src/main/java/de/ids_mannheim/korap/web/service/full/KustvaktService.java b/full/src/main/java/de/ids_mannheim/korap/web/service/full/KustvaktService.java
index c4db1b8..7c7b647 100644
--- a/full/src/main/java/de/ids_mannheim/korap/web/service/full/KustvaktService.java
+++ b/full/src/main/java/de/ids_mannheim/korap/web/service/full/KustvaktService.java
@@ -1,8 +1,9 @@
package de.ids_mannheim.korap.web.service.full;
+import de.ids_mannheim.korap.server.KustvaktServer;
import de.ids_mannheim.korap.utils.JsonUtils;
import de.ids_mannheim.korap.utils.ServiceInfo;
-import de.ids_mannheim.korap.web.KustvaktServer;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/full/src/main/java/de/ids_mannheim/korap/web/service/full/OAuthService.java b/full/src/main/java/de/ids_mannheim/korap/web/service/full/OAuthService.java
index 67a11ef..778ac27 100644
--- a/full/src/main/java/de/ids_mannheim/korap/web/service/full/OAuthService.java
+++ b/full/src/main/java/de/ids_mannheim/korap/web/service/full/OAuthService.java
@@ -5,14 +5,14 @@
import de.ids_mannheim.korap.config.*;
import de.ids_mannheim.korap.exceptions.KustvaktException;
import de.ids_mannheim.korap.exceptions.StatusCodes;
+import de.ids_mannheim.korap.filter.AuthFilter;
import de.ids_mannheim.korap.handlers.OAuth2Handler;
import de.ids_mannheim.korap.interfaces.AuthenticationManagerIface;
import de.ids_mannheim.korap.interfaces.EncryptionIface;
+import de.ids_mannheim.korap.server.KustvaktServer;
import de.ids_mannheim.korap.user.*;
import de.ids_mannheim.korap.utils.JsonUtils;
import de.ids_mannheim.korap.utils.StringUtils;
-import de.ids_mannheim.korap.web.KustvaktServer;
-import de.ids_mannheim.korap.web.filter.AuthFilter;
import de.ids_mannheim.korap.web.filter.BlockingFilter;
import de.ids_mannheim.korap.web.filter.DemoUserFilter;
import de.ids_mannheim.korap.web.filter.PiwikFilter;
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 3358eb4..617385e 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
@@ -40,6 +40,7 @@
import de.ids_mannheim.korap.config.KustvaktConfiguration.BACKENDS;
import de.ids_mannheim.korap.exceptions.KustvaktException;
import de.ids_mannheim.korap.exceptions.StatusCodes;
+import de.ids_mannheim.korap.filter.AuthFilter;
import de.ids_mannheim.korap.interfaces.AuthenticationManagerIface;
import de.ids_mannheim.korap.query.serialize.MetaQueryBuilder;
import de.ids_mannheim.korap.query.serialize.QuerySerializer;
@@ -60,7 +61,6 @@
import de.ids_mannheim.korap.utils.StringUtils;
import de.ids_mannheim.korap.web.ClientsHandler;
import de.ids_mannheim.korap.web.SearchKrill;
-import de.ids_mannheim.korap.web.filter.AuthFilter;
import de.ids_mannheim.korap.web.filter.DemoUserFilter;
import de.ids_mannheim.korap.web.filter.PiwikFilter;
import de.ids_mannheim.korap.web.utils.KustvaktResponseHandler;
diff --git a/full/src/main/java/de/ids_mannheim/korap/web/service/full/UserService.java b/full/src/main/java/de/ids_mannheim/korap/web/service/full/UserService.java
index b36ff99..f18d72f 100644
--- a/full/src/main/java/de/ids_mannheim/korap/web/service/full/UserService.java
+++ b/full/src/main/java/de/ids_mannheim/korap/web/service/full/UserService.java
@@ -10,13 +10,13 @@
import de.ids_mannheim.korap.config.URIParam;
import de.ids_mannheim.korap.exceptions.KustvaktException;
import de.ids_mannheim.korap.exceptions.StatusCodes;
+import de.ids_mannheim.korap.filter.AuthFilter;
import de.ids_mannheim.korap.interfaces.AuthenticationManagerIface;
+import de.ids_mannheim.korap.server.KustvaktServer;
import de.ids_mannheim.korap.user.*;
import de.ids_mannheim.korap.utils.JsonUtils;
import de.ids_mannheim.korap.utils.StringUtils;
import de.ids_mannheim.korap.utils.TimeUtils;
-import de.ids_mannheim.korap.web.KustvaktServer;
-import de.ids_mannheim.korap.web.filter.AuthFilter;
import de.ids_mannheim.korap.web.filter.BlockingFilter;
import de.ids_mannheim.korap.web.filter.DemoUserFilter;
import de.ids_mannheim.korap.web.filter.PiwikFilter;
diff --git a/full/src/main/resources/default-config.xml b/full/src/main/resources/default-config.xml
index 94a9c53..33e19a7 100644
--- a/full/src/main/resources/default-config.xml
+++ b/full/src/main/resources/default-config.xml
@@ -59,7 +59,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" -->
@@ -284,4 +284,10 @@
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
+
+ <!-- Krill -->
+ <bean id="search_krill"
+ class="de.ids_mannheim.korap.web.SearchKrill">
+ <constructor-arg value="${krill.indexDir}"/>
+ </bean>
</beans>
\ No newline at end of file
diff --git a/full/src/main/resources/kustvakt.conf b/full/src/main/resources/kustvakt.conf
index 3ef0604..8d04c92 100644
--- a/full/src/main/resources/kustvakt.conf
+++ b/full/src/main/resources/kustvakt.conf
@@ -1,5 +1,5 @@
## index dir
-krill.indexDir= src/test/resources/sample-index
+krill.indexDir= ../sample-index
krill.index.commit.count = 134217000
krill.index.commit.log = log/krill.commit.log
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" -->
diff --git a/lite/pom.xml b/lite/pom.xml
new file mode 100644
index 0000000..157e178
--- /dev/null
+++ b/lite/pom.xml
@@ -0,0 +1,190 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>de.ids_mannheim.korap</groupId>
+ <artifactId>Kustvakt-lite</artifactId>
+ <version>0.1</version>
+ <properties>
+ <java.version>1.7</java.version>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <spring-framework.version>4.3.7.RELEASE</spring-framework.version>
+ <jersey.version>1.19.4</jersey.version>
+ </properties>
+
+ <build>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ <includes>
+ <include>**/*.info</include>
+ <include>**/*.xml</include>
+ <include>**/*.conf</include>
+ <include>**/*.kustvakt</include>
+ <include>**/*.properties</include>
+ <include>**/*.sql</include>
+ </includes>
+ </resource>
+ </resources>
+ <testResources>
+ <testResource>
+ <directory>src/test/resources</directory>
+ <filtering>true</filtering>
+ <includes>
+ <include>**/*.prop</include>
+ <include>**/*.xml</include>
+ <include>**/*.conf</include>
+ <include>**/*.info</include>
+ <include>**/*.properties</include>
+ </includes>
+ </testResource>
+ <testResource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ <includes>
+ <include>**/*.info</include>
+ <include>**/*.properties</include>
+ </includes>
+ </testResource>
+ </testResources>
+ <plugins>
+ <!-- Formatter plugin for Eclipse based coding conventions http://maven-java-formatter-plugin.googlecode.com/svn/site/0.4/usage.html -->
+ <plugin>
+ <groupId>com.googlecode.maven-java-formatter-plugin</groupId>
+ <artifactId>maven-java-formatter-plugin</artifactId>
+ <version>0.4</version>
+ <configuration>
+ <configFile>${project.basedir}/Format.xml</configFile>
+ <overrideConfigCompilerVersion>true</overrideConfigCompilerVersion>
+ <compilerSource>${java.version}</compilerSource>
+ <compilerCompliance>${java.version}</compilerCompliance>
+ <compilerTargetPlatform>${java.version}</compilerTargetPlatform>
+ </configuration>
+ <!-- <executions> <execution> <goals> <goal>format</goal> </goals> </execution>
+ </executions> -->
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.3</version>
+ <configuration>
+ <compilerVersion>${java.version}</compilerVersion>
+ <source>${java.version}</source>
+ <target>${java.version}</target>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.19.1</version>
+ <configuration>
+ <reuseForks>false</reuseForks>
+ <forkCount>2</forkCount>
+ <threadCount>10</threadCount>
+
+ <excludes>
+ <exclude>**/*APITest.java</exclude>
+ <exclude>de/ids_mannheim/korap/suites/*.java</exclude>
+ <exclude>**/KustvaktServerTest.java</exclude>
+ <exclude>**/ResourceServiceTest.java</exclude>
+ <exclude>**/ResourceInfoServiceTest.java</exclude>
+ <exclude>**/PolicyServiceTest.java</exclude>
+ </excludes>
+ <includes>
+ <include>de/ids_mannheim/korap/**/*.java</include>
+ </includes>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-shade-plugin</artifactId>
+ <version>2.1</version>
+ <executions>
+ <!-- option 1 -->
+ <execution>
+ <id>light</id>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <finalName>
+ Kustvakt-${project.version}-lite
+ </finalName>
+ <transformers>
+ <transformer
+ implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
+ <mainClass>
+ de.ids_mannheim.korap.server.KustvaktLiteServer
+ </mainClass>
+ </transformer>
+ <transformer
+ implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/spring.handlers
+ </resource>
+ </transformer>
+ <transformer
+ implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/spring.schemas
+ </resource>
+ </transformer>
+ </transformers>
+ <!-- Additional configuration. -->
+ <!-- apparently there is a securityexception -->
+ <filters>
+ <filter>
+ <artifact>*:*</artifact>
+ <excludes>
+ <exclude>META-INF/*.SF</exclude>
+ <exclude>META-INF/*.DSA
+ </exclude>
+ <exclude>META-INF/*.RSA
+ </exclude>
+ </excludes>
+ </filter>
+ </filters>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+
+ <dependencies>
+ <dependency>
+ <groupId>de.ids_mannheim.korap</groupId>
+ <artifactId>Kustvakt-core</artifactId>
+ <version>0.59.8</version>
+ </dependency>
+ <dependency>
+ <groupId>de.ids_mannheim.korap</groupId>
+ <artifactId>Kustvakt-core</artifactId>
+ <version>0.59.8</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- Spring -->
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <version>${spring-framework.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <!-- Jersey test framework -->
+ <dependency>
+ <groupId>com.sun.jersey.jersey-test-framework</groupId>
+ <artifactId>jersey-test-framework-core</artifactId>
+ <version>${jersey.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.jersey.jersey-test-framework</groupId>
+ <artifactId>jersey-test-framework-grizzly</artifactId>
+ <version>${jersey.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
diff --git a/lite/src/main/java/de/ids_mannheim/korap/server/KustvaktLiteServer.java b/lite/src/main/java/de/ids_mannheim/korap/server/KustvaktLiteServer.java
new file mode 100644
index 0000000..338c43f
--- /dev/null
+++ b/lite/src/main/java/de/ids_mannheim/korap/server/KustvaktLiteServer.java
@@ -0,0 +1,31 @@
+package de.ids_mannheim.korap.server;
+
+import de.ids_mannheim.korap.config.BeansFactory;
+import de.ids_mannheim.korap.web.KustvaktBaseServer;
+
+public class KustvaktLiteServer extends KustvaktBaseServer{
+
+
+ public static void main (String[] args) throws Exception {
+ KustvaktLiteServer server = new KustvaktLiteServer();
+ kargs = server.readAttributes(args);
+
+ if (kargs.getConfig() != null)
+ BeansFactory.loadFileContext(kargs.getConfig());
+ else{
+ kargs.setConfig("light-config.xml");
+ BeansFactory.loadClasspathContext();
+ }
+ kargs.setRootPackages(new String[] { "de.ids_mannheim.korap.web.service.light" });
+ rootPackages = "de.ids_mannheim.korap.web.service.light";
+
+ server.start();
+ }
+
+ @Override
+ protected void setup () {
+ // TODO Auto-generated method stub
+
+ }
+
+}
diff --git a/lite/src/main/java/de/ids_mannheim/korap/web/service/light/LightService.java b/lite/src/main/java/de/ids_mannheim/korap/web/service/light/LightService.java
index 3d1e900..476b6bf 100644
--- a/lite/src/main/java/de/ids_mannheim/korap/web/service/light/LightService.java
+++ b/lite/src/main/java/de/ids_mannheim/korap/web/service/light/LightService.java
@@ -1,14 +1,33 @@
package de.ids_mannheim.korap.web.service.light;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriBuilder;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+
import com.sun.jersey.core.util.MultivaluedMapImpl;
-import de.ids_mannheim.korap.config.BeansFactory;
+
import de.ids_mannheim.korap.config.KustvaktConfiguration;
import de.ids_mannheim.korap.config.QueryBuilderUtil;
import de.ids_mannheim.korap.exceptions.KustvaktException;
import de.ids_mannheim.korap.exceptions.StatusCodes;
import de.ids_mannheim.korap.query.serialize.MetaQueryBuilder;
import de.ids_mannheim.korap.query.serialize.QuerySerializer;
-import de.ids_mannheim.korap.resource.rewrite.FoundryInject;
import de.ids_mannheim.korap.resource.rewrite.RewriteHandler;
import de.ids_mannheim.korap.utils.KoralCollectionQueryBuilder;
import de.ids_mannheim.korap.utils.KustvaktLogger;
@@ -16,45 +35,33 @@
import de.ids_mannheim.korap.web.SearchKrill;
import de.ids_mannheim.korap.web.TRACE;
import de.ids_mannheim.korap.web.utils.KustvaktResponseHandler;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.ws.rs.*;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.SecurityContext;
-import javax.ws.rs.core.UriBuilder;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-import java.util.Set;
/**
* @author hanl
* @date 29/01/2014
+ *
+ * @author margaretha
+ * @date 21/09/2017
*/
-@Path("v0.1" + "/")
+@Controller
+@Path("/")
@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
public class LightService {
private static Logger jlog = LoggerFactory.getLogger(LightService.class);
+ @Autowired
private SearchKrill searchKrill;
private ClientsHandler graphDBhandler;
+ @Autowired
private RewriteHandler processor;
+ @Autowired
private KustvaktConfiguration config;
public LightService () {
- this.config = BeansFactory.getKustvaktContext().getConfiguration();
- this.searchKrill = new SearchKrill(config.getIndexDir());
UriBuilder builder = UriBuilder.fromUri("http://10.0.10.13").port(9997);
this.graphDBhandler = new ClientsHandler(builder.build());
- this.processor = new RewriteHandler();
- this.processor.add(FoundryInject.class);
-// this.processor.insertBeans(BeansFactory.getKustvaktContext());
}
diff --git a/lite/src/main/resources/kustvakt-lite.conf b/lite/src/main/resources/kustvakt-lite.conf
new file mode 100644
index 0000000..87b1c8e
--- /dev/null
+++ b/lite/src/main/resources/kustvakt-lite.conf
@@ -0,0 +1,17 @@
+# index dir
+krill.indexDir= ../sample-index
+
+krill.index.commit.count = 134217000
+krill.index.commit.log = log/krill.commit.log
+krill.index.commit.auto = 500
+krill.index.relations.max = 100
+
+kustvakt.default.pos = tt
+kustvakt.default.lemma = tt
+kustvakt.default.token = opennlp
+kustvakt.default.dep = mate
+kustvakt.default.const = mate
+
+# server
+server.port=8089
+server.host=localhost
diff --git a/lite/src/main/resources/light-config.xml b/lite/src/main/resources/light-config.xml
index 5ac341a..3ff2ef1 100644
--- a/lite/src/main/resources/light-config.xml
+++ b/lite/src/main/resources/light-config.xml
@@ -1,25 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
+ xmlns:context="http://www.springframework.org/schema/context"
xmlns="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
- http://www.springframework.org/schema/util
- http://www.springframework.org/schema/util/spring-util-4.0.xsd">
+ http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
+ http://www.springframework.org/schema/context
+ http://www.springframework.org/schema/context/spring-context-4.0.xsd
+ http://www.springframework.org/schema/util
+ http://www.springframework.org/schema/util/spring-util-4.0.xsd">
- <!--<util:properties id="props" location="classpath:kustvakt.conf"/>-->
+ <context:component-scan base-package="de.ids_mannheim.korap" />
+ <context:annotation-config />
- <bean id="props"
+ <bean id="properties"
class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="ignoreResourceNotFound" value="true"/>
<property name="locations">
<array>
- <value>classpath:kustvakt.conf</value>
- <value>file:./kustvakt.conf</value>
+ <value>classpath:kustvakt-lite.conf</value>
+ <value>file:./kustvakt-lite.conf</value>
</array>
</property>
</bean>
+
+ <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
+ <property name="properties">
+ <ref bean="properties"/>
+ </property>
+ </bean>
<bean id="kustvakt_auditing"
class="de.ids_mannheim.korap.interfaces.defaults.DefaultAuditing">
@@ -27,10 +37,16 @@
<bean id="kustvakt_config"
class="de.ids_mannheim.korap.config.KustvaktConfiguration">
- <property name="properties" ref="props"/>
+ <constructor-arg index="0" name="properties" ref="properties"/>
</bean>
<bean name="kustvakt_encryption"
class="de.ids_mannheim.korap.interfaces.defaults.DefaultEncryption">
</bean>
+
+ <bean id="search_krill"
+ class="de.ids_mannheim.korap.web.SearchKrill">
+ <constructor-arg value="${krill.indexDir}"/>
+ </bean>
+
</beans>
\ No newline at end of file
diff --git a/lite/src/main/resources/log4j.properties b/lite/src/main/resources/log4j.properties
new file mode 100644
index 0000000..5d769fb
--- /dev/null
+++ b/lite/src/main/resources/log4j.properties
@@ -0,0 +1,35 @@
+
+# Root logger option
+#log4j.threshold=ALL
+log4j.rootLogger=error, stdout, debugLog
+log4j.logger.log=ERROR, errorLog
+
+# Direct log messages to stdout
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd, HH:mm:ss} %C{6} - %M%n %-5p: %m%n
+
+log4j.appender.errorLog=org.apache.log4j.RollingFileAppender
+log4j.appender.errorLog.layout=org.apache.log4j.PatternLayout
+log4j.appender.errorLog.layout.ConversionPattern=%d{MMM dd, yyyy HH:mm:ss} %C{6} - %M %n %-5p: %m%n
+log4j.appender.errorLog.File=./logs/errors.log
+
+log4j.appender.policyLog=org.apache.log4j.RollingFileAppender
+log4j.appender.policyLog.layout=org.apache.log4j.PatternLayout
+log4j.appender.policyLog.layout.ConversionPattern=%d{MMM dd, yyyy HH:mm:ss} %C{6} - %M %n %-5p: %m%n
+log4j.appender.policyLog.File=./logs/policies.log
+
+log4j.appender.authLog=org.apache.log4j.RollingFileAppender
+log4j.appender.authLog.layout=org.apache.log4j.PatternLayout
+log4j.appender.authLog.layout.ConversionPattern=%d{MMM dd, yyyy HH:mm:ss} %C{6} - %M %n %-5p: %m%n
+log4j.appender.authLog.File=./logs/auth.log
+
+log4j.appender.debugLog=org.apache.log4j.RollingFileAppender
+log4j.appender.debugLog.layout=org.apache.log4j.PatternLayout
+log4j.appender.debugLog.layout.ConversionPattern=%d{MMM dd, yyyy HH:mm:ss} %C{6} - %M %n %-5p: %m%n
+log4j.appender.debugLog.File=./logs/logging.log
+
+
+log4j.logger.de.ids_mannheim.korap.security.ac = ERROR, policyLog
+log4j.logger.de.ids_mannheim.korap.security.auth = ERROR, authLog
\ No newline at end of file
diff --git a/lite/src/test/java/de/ids_mannheim/korap/web/service/FastJerseyLightTest.java b/lite/src/test/java/de/ids_mannheim/korap/web/service/FastJerseyLightTest.java
new file mode 100644
index 0000000..8d87265
--- /dev/null
+++ b/lite/src/test/java/de/ids_mannheim/korap/web/service/FastJerseyLightTest.java
@@ -0,0 +1,37 @@
+package de.ids_mannheim.korap.web.service;
+
+import org.junit.Before;
+
+import de.ids_mannheim.korap.config.ContextHolder;
+
+public abstract class FastJerseyLightTest extends FastJerseyBaseTest {
+
+ private static String[] classPackages =
+ new String[] { "de.ids_mannheim.korap.web.service.light" };
+
+
+ public static void startServer () {
+ try {
+ if (testContainer != null) {
+ testContainer.start();
+ }
+ }
+ catch (Exception e) {
+ initServer(PORT + PORT_IT++, classPackages);
+ startServer();
+ }
+ }
+
+ @Before
+ public static void startServerBeforeFirstTestRun () {
+ if (testContainer == null) {
+ initServer(PORT, classPackages);
+ startServer();
+ }
+ }
+
+ @Override
+ protected ContextHolder getContext () {
+ return new ContextHolder(this.context) {};
+ }
+}
diff --git a/lite/src/test/java/de/ids_mannheim/korap/web/service/LightServiceTest.java b/lite/src/test/java/de/ids_mannheim/korap/web/service/LightServiceTest.java
index afdf435..17c7df6 100644
--- a/lite/src/test/java/de/ids_mannheim/korap/web/service/LightServiceTest.java
+++ b/lite/src/test/java/de/ids_mannheim/korap/web/service/LightServiceTest.java
@@ -1,19 +1,20 @@
-package de.ids_mannheim.korap.web.service.full;
+package de.ids_mannheim.korap.web.service;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.sun.jersey.api.client.ClientResponse;
-import de.ids_mannheim.korap.exceptions.KustvaktException;
-import de.ids_mannheim.korap.query.serialize.QuerySerializer;
-import de.ids_mannheim.korap.utils.JsonUtils;
-import de.ids_mannheim.korap.web.service.FastJerseyTest;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+
import org.apache.lucene.LucenePackage;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.sun.jersey.api.client.ClientResponse;
+
+import de.ids_mannheim.korap.exceptions.KustvaktException;
+import de.ids_mannheim.korap.query.serialize.QuerySerializer;
+import de.ids_mannheim.korap.utils.JsonUtils;
/**
* EM: FIX ME: Database restructure
@@ -21,13 +22,7 @@
* Created by hanl on 29.04.16.
*/
@Ignore
-public class LightServiceTest extends FastJerseyTest {
-
- @BeforeClass
- public static void configure () throws Exception {
- FastJerseyTest.setPackages("de.ids_mannheim.korap.web.service.light");
- }
-
+public class LightServiceTest extends FastJerseyLightTest {
@Override
public void initMethod () throws KustvaktException {}
diff --git a/pom.xml b/pom.xml
index bcf54fd..4628b48 100644
--- a/pom.xml
+++ b/pom.xml
@@ -17,8 +17,8 @@
<spring-framework.version>4.3.7.RELEASE</spring-framework.version>
<jersey.version>1.19.4</jersey.version>
</properties>
- <profiles>
- <!-- mvn -Plight builds additionally the light server version with reduced functionality! -->
+ <!-- <profiles>
+ mvn -Plight builds additionally the light server version with reduced functionality!
<profile>
<id>light</id>
<build>
@@ -27,7 +27,7 @@
<artifactId>maven-shade-plugin</artifactId>
<version>2.1</version>
<executions>
- <!-- option 1 -->
+ option 1
<execution>
<id>light</id>
<phase>package</phase>
@@ -56,8 +56,8 @@
</resource>
</transformer>
</transformers>
- <!-- Additional configuration. -->
- <!-- apparently there is a securityexception -->
+ Additional configuration.
+ apparently there is a securityexception
<filters>
<filter>
<artifact>*:*</artifact>
@@ -78,7 +78,8 @@
</build>
</profile>
</profiles>
- <build>
+ -->
+ <build>
<resources>
<resource>
<directory>src/main/resources</directory>