Renamed AuthFilter and moved it to /full.
Change-Id: I5d27d09c9c978a0a2cc2ead8c830438712ee4c16
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 77cb072..c7123b8 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,7 +5,6 @@
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;
@@ -121,6 +120,11 @@
if (licensePattern!=null && availability != null){
Matcher m = licensePattern.matcher(availability);
if (!m.matches()){
+ jlog.debug("availability: "+availability);
+ if (availability.isEmpty()){
+ km.addError(StatusCodes.MISSING_ATTRIBUTE,
+ "Availability for "+ id +"is empty.", id);
+ }
km = new Match();
km.addError(StatusCodes.ACCESS_DENIED,
"Retrieving match info with ID "+id+" is not allowed.", id);
@@ -151,9 +155,15 @@
layers, includeSpans, includeHighlights,
sentenceExpansion);
String availability = km.getAvailability();
+
if (licensePattern !=null && availability != null){
+ if (availability.isEmpty()){
+ km.addError(StatusCodes.MISSING_ATTRIBUTE,
+ "Availability for "+ id +"is empty.", id);
+ }
Matcher m = licensePattern.matcher(availability);
if (!m.matches()){
+ jlog.debug("pattern: "+ licensePattern.toString() + ", availability: "+availability);
km = new Match();
km.addError(StatusCodes.ACCESS_DENIED,
"Retrieving match info with ID "+id+" is not allowed.", id);
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
index 345ec96..0c45d7b 100644
--- 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
@@ -2,7 +2,6 @@
import java.net.URI;
-import javax.ws.rs.core.Context;
import javax.ws.rs.core.UriBuilder;
import org.junit.After;
@@ -12,7 +11,6 @@
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;
@@ -46,13 +44,13 @@
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 static void addClass (Class<?> resourceClass) {
+// resourceConfig.getClasses().add(resourceClass);
+// }
+//
+// public static void addSingleton (Object resourceSingleton) {
+// resourceConfig.getSingletons().add(resourceSingleton);
+// }
public String getAPIVersion () {
@@ -60,21 +58,21 @@
}
- public static <T> void addProviderForContext (Class<T> contextClass,
- T contextObject) {
- addSingleton(new SingletonTypeInjectableProvider<Context, T>(
- contextClass, contextObject) {});
- }
+// 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 addRequestFilter (Object filter) {
+// resourceConfig.getContainerRequestFilters().add(filter);
+// }
+//
+//
+// public static void addResponseFilter (Object filter) {
+// resourceConfig.getContainerResponseFilters().add(filter);
+// }
public static void setTestContainerFactory (
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 19e091c..3d75697 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
@@ -36,7 +36,7 @@
* of database or other persistence mechanism. By mapping application calls to the persistence layer, the DAO provides
* some specific data operations without exposing details of the database.
*/
-
+@Deprecated
/**
* @author hanl
* @date 13/01/2014
diff --git a/full/src/main/java/de/ids_mannheim/korap/security/auth/KustvaktAuthenticationManager.java b/full/src/main/java/de/ids_mannheim/korap/security/auth/KustvaktAuthenticationManager.java
index f5258c1..31d5f46 100644
--- a/full/src/main/java/de/ids_mannheim/korap/security/auth/KustvaktAuthenticationManager.java
+++ b/full/src/main/java/de/ids_mannheim/korap/security/auth/KustvaktAuthenticationManager.java
@@ -160,7 +160,7 @@
}
}
- /**
+ /** EM: fix type is not flexible
* @param type
* @param attributes
* contains username and password to authenticate the user.
diff --git a/full/src/main/java/de/ids_mannheim/korap/web/controller/AnnotationController.java b/full/src/main/java/de/ids_mannheim/korap/web/controller/AnnotationController.java
index dbeb447..46ffcd4 100644
--- a/full/src/main/java/de/ids_mannheim/korap/web/controller/AnnotationController.java
+++ b/full/src/main/java/de/ids_mannheim/korap/web/controller/AnnotationController.java
@@ -21,9 +21,9 @@
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.service.AnnotationService;
import de.ids_mannheim.korap.utils.JsonUtils;
+import de.ids_mannheim.korap.web.filter.AuthenticationFilter;
import de.ids_mannheim.korap.web.filter.DemoUserFilter;
import de.ids_mannheim.korap.web.filter.PiwikFilter;
import de.ids_mannheim.korap.web.utils.KustvaktResponseHandler;
@@ -36,7 +36,7 @@
*/
@Controller
@Path("annotation/")
-@ResourceFilters({ AuthFilter.class, DemoUserFilter.class, PiwikFilter.class })
+@ResourceFilters({ AuthenticationFilter.class, DemoUserFilter.class, PiwikFilter.class })
@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
public class AnnotationController {
diff --git a/full/src/main/java/de/ids_mannheim/korap/web/controller/AuthenticationController.java b/full/src/main/java/de/ids_mannheim/korap/web/controller/AuthenticationController.java
index 75a772e..43b17cc 100644
--- a/full/src/main/java/de/ids_mannheim/korap/web/controller/AuthenticationController.java
+++ b/full/src/main/java/de/ids_mannheim/korap/web/controller/AuthenticationController.java
@@ -31,7 +31,6 @@
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.user.TokenContext;
@@ -39,6 +38,7 @@
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.filter.AuthenticationFilter;
import de.ids_mannheim.korap.web.filter.BlockingFilter;
import de.ids_mannheim.korap.web.filter.DemoUserFilter;
import de.ids_mannheim.korap.web.filter.PiwikFilter;
@@ -100,7 +100,7 @@
// fixme: moved to user
@GET
@Path("status")
- @ResourceFilters({ AuthFilter.class, DemoUserFilter.class,
+ @ResourceFilters({ AuthenticationFilter.class, DemoUserFilter.class,
BlockingFilter.class })
public Response getStatus (@Context SecurityContext context,
@HeaderParam(ContainerRequest.USER_AGENT) String agent,
@@ -326,7 +326,7 @@
//fixme: moved from userservice
@GET
@Path("logout")
- @ResourceFilters({ AuthFilter.class, DemoUserFilter.class,
+ @ResourceFilters({ AuthenticationFilter.class, DemoUserFilter.class,
PiwikFilter.class })
public Response logout (@Context SecurityContext ctx,
@Context Locale locale) {
diff --git a/full/src/main/java/de/ids_mannheim/korap/web/controller/OAuthController.java b/full/src/main/java/de/ids_mannheim/korap/web/controller/OAuthController.java
index 2bc03d7..33163fd 100644
--- a/full/src/main/java/de/ids_mannheim/korap/web/controller/OAuthController.java
+++ b/full/src/main/java/de/ids_mannheim/korap/web/controller/OAuthController.java
@@ -5,7 +5,6 @@
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;
@@ -13,6 +12,7 @@
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.filter.AuthenticationFilter;
import de.ids_mannheim.korap.web.filter.BlockingFilter;
import de.ids_mannheim.korap.web.filter.DemoUserFilter;
import de.ids_mannheim.korap.web.filter.PiwikFilter;
@@ -77,7 +77,7 @@
@POST
@Path("unregister")
- @ResourceFilters({ AuthFilter.class, BlockingFilter.class })
+ @ResourceFilters({ AuthenticationFilter.class, BlockingFilter.class })
public Response unregisterClient (@Context SecurityContext context,
@HeaderParam("Host") String host,
@QueryParam("client_secret") String secret,
@@ -98,7 +98,7 @@
@POST
@Path("register")
- @ResourceFilters({ AuthFilter.class, BlockingFilter.class })
+ @ResourceFilters({ AuthenticationFilter.class, BlockingFilter.class })
public Response registerClient (@Context SecurityContext context,
@HeaderParam("Host") String host,
@QueryParam("redirect_url") String rurl) {
@@ -125,7 +125,7 @@
@GET
@Path("info")
- @ResourceFilters({ AuthFilter.class, DemoUserFilter.class, PiwikFilter.class })
+ @ResourceFilters({ AuthenticationFilter.class, DemoUserFilter.class, PiwikFilter.class })
public Response getStatus (@Context SecurityContext context,
@QueryParam("scope") String scopes) {
TokenContext ctx = (TokenContext) context.getUserPrincipal();
@@ -150,7 +150,7 @@
@GET
@Path("authorizations")
- @ResourceFilters({ AuthFilter.class, BlockingFilter.class })
+ @ResourceFilters({ AuthenticationFilter.class, BlockingFilter.class })
public Response getAuthorizations (@Context SecurityContext context,
@HeaderParam(ContainerRequest.USER_AGENT) String agent,
@HeaderParam(ContainerRequest.HOST) String host) {
diff --git a/full/src/main/java/de/ids_mannheim/korap/web/controller/SearchController.java b/full/src/main/java/de/ids_mannheim/korap/web/controller/SearchController.java
index 3c4f33d..4579947 100644
--- a/full/src/main/java/de/ids_mannheim/korap/web/controller/SearchController.java
+++ b/full/src/main/java/de/ids_mannheim/korap/web/controller/SearchController.java
@@ -43,7 +43,6 @@
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;
@@ -64,6 +63,7 @@
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.AuthenticationFilter;
import de.ids_mannheim.korap.web.filter.DemoUserFilter;
import de.ids_mannheim.korap.web.filter.PiwikFilter;
import de.ids_mannheim.korap.web.utils.KustvaktResponseHandler;
@@ -79,7 +79,7 @@
@Controller
@Path("/")
@RequestMapping("/")
-@ResourceFilters({ AuthFilter.class, DemoUserFilter.class, PiwikFilter.class })
+@ResourceFilters({ AuthenticationFilter.class, DemoUserFilter.class, PiwikFilter.class })
@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
public class SearchController {
diff --git a/full/src/main/java/de/ids_mannheim/korap/web/controller/UserController.java b/full/src/main/java/de/ids_mannheim/korap/web/controller/UserController.java
index b181178..34b1875 100644
--- a/full/src/main/java/de/ids_mannheim/korap/web/controller/UserController.java
+++ b/full/src/main/java/de/ids_mannheim/korap/web/controller/UserController.java
@@ -41,7 +41,6 @@
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.user.KorAPUser;
import de.ids_mannheim.korap.user.TokenContext;
@@ -53,6 +52,7 @@
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.filter.AuthenticationFilter;
import de.ids_mannheim.korap.web.filter.BlockingFilter;
import de.ids_mannheim.korap.web.filter.DemoUserFilter;
import de.ids_mannheim.korap.web.filter.PiwikFilter;
@@ -137,7 +137,7 @@
@POST
@Path("update")
@Consumes(MediaType.APPLICATION_JSON)
- @ResourceFilters({ AuthFilter.class, PiwikFilter.class,
+ @ResourceFilters({ AuthenticationFilter.class, PiwikFilter.class,
BlockingFilter.class })
public Response updateAccount (@Context SecurityContext ctx, String json) {
TokenContext context = (TokenContext) ctx.getUserPrincipal();
@@ -261,7 +261,7 @@
// todo: refactor and make something out of if --> needs to give some sort of feedback!
@GET
@Path("info")
- @ResourceFilters({ AuthFilter.class, PiwikFilter.class,
+ @ResourceFilters({ AuthenticationFilter.class, PiwikFilter.class,
BlockingFilter.class })
public Response getStatus (@Context SecurityContext context,
@QueryParam("scopes") String scopes) {
@@ -292,7 +292,7 @@
@GET
@Path("settings")
- @ResourceFilters({ AuthFilter.class, DemoUserFilter.class,
+ @ResourceFilters({ AuthenticationFilter.class, DemoUserFilter.class,
PiwikFilter.class, BlockingFilter.class })
public Response getUserSettings (@Context SecurityContext context,
@Context Locale locale) {
@@ -315,7 +315,7 @@
@POST
@Path("settings")
@Consumes({ MediaType.APPLICATION_JSON })
- @ResourceFilters({ AuthFilter.class, PiwikFilter.class,
+ @ResourceFilters({ AuthenticationFilter.class, PiwikFilter.class,
BlockingFilter.class })
public Response updateSettings (@Context SecurityContext context,
@Context Locale locale, Map settings) {
@@ -352,7 +352,7 @@
@GET
@Path("details")
- @ResourceFilters({ AuthFilter.class, DemoUserFilter.class,
+ @ResourceFilters({ AuthenticationFilter.class, DemoUserFilter.class,
PiwikFilter.class, BlockingFilter.class })
public Response getDetails (@Context SecurityContext context,
@Context Locale locale, @QueryParam("pointer") String pointer) {
@@ -378,7 +378,7 @@
@POST
@Path("details")
@Consumes({ MediaType.APPLICATION_JSON })
- @ResourceFilters({ AuthFilter.class, PiwikFilter.class,
+ @ResourceFilters({ AuthenticationFilter.class, PiwikFilter.class,
BlockingFilter.class })
public Response updateDetails (@Context SecurityContext context,
@Context Locale locale, Map details) {
@@ -411,7 +411,7 @@
@POST
@Path("queries")
@Consumes(MediaType.APPLICATION_JSON)
- @ResourceFilters({ AuthFilter.class, PiwikFilter.class,
+ @ResourceFilters({ AuthenticationFilter.class, PiwikFilter.class,
BlockingFilter.class })
public Response updateQueries (@Context SecurityContext context,
String json) {
@@ -469,7 +469,7 @@
@DELETE
- @ResourceFilters({ AuthFilter.class, PiwikFilter.class,
+ @ResourceFilters({ AuthenticationFilter.class, PiwikFilter.class,
BlockingFilter.class })
public Response deleteUser (@Context SecurityContext context) {
TokenContext ctx = (TokenContext) context.getUserPrincipal();
@@ -488,7 +488,7 @@
@GET
@Path("queries")
- @ResourceFilters({ AuthFilter.class, DemoUserFilter.class,
+ @ResourceFilters({ AuthenticationFilter.class, DemoUserFilter.class,
PiwikFilter.class, BlockingFilter.class })
public Response getQueries (@Context SecurityContext context,
@Context Locale locale) {
diff --git a/full/src/main/java/de/ids_mannheim/korap/web/controller/VirtualCorpusController.java b/full/src/main/java/de/ids_mannheim/korap/web/controller/VirtualCorpusController.java
index aafaa10..50eb392 100644
--- a/full/src/main/java/de/ids_mannheim/korap/web/controller/VirtualCorpusController.java
+++ b/full/src/main/java/de/ids_mannheim/korap/web/controller/VirtualCorpusController.java
@@ -17,13 +17,13 @@
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.service.VirtualCorpusService;
import de.ids_mannheim.korap.user.TokenContext;
import de.ids_mannheim.korap.user.User;
import de.ids_mannheim.korap.utils.JsonUtils;
import de.ids_mannheim.korap.utils.ParameterChecker;
+import de.ids_mannheim.korap.web.filter.AuthenticationFilter;
import de.ids_mannheim.korap.web.filter.DemoUserFilter;
import de.ids_mannheim.korap.web.filter.PiwikFilter;
import de.ids_mannheim.korap.web.input.VirtualCorpusFromJson;
@@ -32,7 +32,7 @@
@Controller
@Path("vc")
@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
-@ResourceFilters({ AuthFilter.class, DemoUserFilter.class, PiwikFilter.class })
+@ResourceFilters({ AuthenticationFilter.class, DemoUserFilter.class, PiwikFilter.class })
public class VirtualCorpusController {
private static Logger jlog =
diff --git a/full/src/main/java/de/ids_mannheim/korap/filter/AuthFilter.java b/full/src/main/java/de/ids_mannheim/korap/web/filter/AuthenticationFilter.java
similarity index 94%
rename from full/src/main/java/de/ids_mannheim/korap/filter/AuthFilter.java
rename to full/src/main/java/de/ids_mannheim/korap/web/filter/AuthenticationFilter.java
index 146879d..5f92c1b 100644
--- a/full/src/main/java/de/ids_mannheim/korap/filter/AuthFilter.java
+++ b/full/src/main/java/de/ids_mannheim/korap/web/filter/AuthenticationFilter.java
@@ -1,4 +1,4 @@
-package de.ids_mannheim.korap.filter;
+package de.ids_mannheim.korap.web.filter;
import com.sun.jersey.spi.container.ContainerRequest;
import com.sun.jersey.spi.container.ContainerRequestFilter;
@@ -22,7 +22,7 @@
*/
@Component
@Provider
-public class AuthFilter implements ContainerRequestFilter, ResourceFilter {
+public class AuthenticationFilter implements ContainerRequestFilter, ResourceFilter {
@Autowired
private AuthenticationManagerIface userController;
diff --git a/full/src/main/resources/log4j.properties b/full/src/main/resources/log4j.properties
index 2b8d2a1..35aad91 100644
--- a/full/src/main/resources/log4j.properties
+++ b/full/src/main/resources/log4j.properties
@@ -4,6 +4,9 @@
log4j.rootLogger=ERROR, stdout, debugLog
log4j.logger.log=ERROR, errorLog
+log4j.logger.de.ids_mannheim.korap.service.VirtualCorpusService = error, debugLog
+log4j.logger.de.ids_mannheim.korap.web.SearchKrill = debug, debugLog, stdout
+
# Direct log messages to stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
diff --git a/full/src/test/java/de/ids_mannheim/korap/config/SpringJerseyTest.java b/full/src/test/java/de/ids_mannheim/korap/config/SpringJerseyTest.java
new file mode 100644
index 0000000..930e454
--- /dev/null
+++ b/full/src/test/java/de/ids_mannheim/korap/config/SpringJerseyTest.java
@@ -0,0 +1,48 @@
+package de.ids_mannheim.korap.config;
+
+import java.util.concurrent.ThreadLocalRandom;
+
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.web.context.ContextLoaderListener;
+
+import com.sun.jersey.spi.spring.container.servlet.SpringServlet;
+import com.sun.jersey.test.framework.AppDescriptor;
+import com.sun.jersey.test.framework.JerseyTest;
+import com.sun.jersey.test.framework.WebAppDescriptor;
+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.web.GrizzlyWebTestContainerFactory;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration("classpath:test-config.xml")
+public abstract class SpringJerseyTest extends JerseyTest {
+
+ 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" };
+
+
+ @Override
+ protected TestContainerFactory getTestContainerFactory ()
+ throws TestContainerException {
+ return new GrizzlyWebTestContainerFactory();
+ }
+
+ @Override
+ protected AppDescriptor configure () {
+ return new WebAppDescriptor.Builder(classPackages)
+ .servletClass(SpringServlet.class)
+ .contextListenerClass(ContextLoaderListener.class)
+ .contextParam("contextConfigLocation",
+ "classpath:test-config.xml")
+ .build();
+ }
+
+ @Override
+ protected int getPort (int defaultPort) {
+ return ThreadLocalRandom.current().nextInt(5000, 8000 + 1);
+ }
+}
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/service/full/VirtualCorpusServiceTest.java b/full/src/test/java/de/ids_mannheim/korap/web/service/full/VirtualCorpusServiceTest.java
index ab33aa1..f3dfdf1 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/service/full/VirtualCorpusServiceTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/service/full/VirtualCorpusServiceTest.java
@@ -1,59 +1,26 @@
package de.ids_mannheim.korap.web.service.full;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import org.eclipse.jetty.http.HttpHeaders;
import org.junit.Ignore;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import org.springframework.web.context.ContextLoaderListener;
import com.fasterxml.jackson.databind.JsonNode;
import com.sun.jersey.api.client.ClientResponse;
-import com.sun.jersey.spi.spring.container.servlet.SpringServlet;
-import com.sun.jersey.test.framework.AppDescriptor;
-import com.sun.jersey.test.framework.JerseyTest;
-import com.sun.jersey.test.framework.WebAppDescriptor;
-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.web.GrizzlyWebTestContainerFactory;
import de.ids_mannheim.korap.config.Attributes;
+import de.ids_mannheim.korap.config.SpringJerseyTest;
import de.ids_mannheim.korap.exceptions.KustvaktException;
import de.ids_mannheim.korap.exceptions.StatusCodes;
import de.ids_mannheim.korap.security.auth.BasicHttpAuth;
import de.ids_mannheim.korap.utils.JsonUtils;
-@Ignore
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration("classpath:test-config.xml")
-public class VirtualCorpusServiceTest extends JerseyTest {
-
- 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" };
-
-
- @Override
- protected TestContainerFactory getTestContainerFactory ()
- throws TestContainerException {
- return new GrizzlyWebTestContainerFactory();
- }
-
- @Override
- protected AppDescriptor configure () {
- return new WebAppDescriptor.Builder(classPackages)
- .servletClass(SpringServlet.class)
- .contextListenerClass(ContextLoaderListener.class)
- .contextParam("contextConfigLocation",
- "classpath:test-config.xml")
- .build();
- }
+public class VirtualCorpusServiceTest extends SpringJerseyTest{
@Test
+ @Ignore
public void testStoreVC () throws KustvaktException {
String json =
"{\"name\": \"new vc\",\"type\": \"PRIVATE\",\"createdBy\": "
@@ -93,7 +60,7 @@
ClientResponse response = resource().path("vc").path("store")
.entity(json).post(ClientResponse.class);
String entity = response.getEntity(String.class);
- // System.out.println(entity);
+ System.out.println(entity);
JsonNode node = JsonUtils.readTree(entity);
assertEquals(StatusCodes.DESERIALIZATION_FAILED,
@@ -101,7 +68,6 @@
assertTrue(node.at("/errors/0/1").asText().startsWith(
"Cannot deserialize value of type `de.ids_mannheim.korap.constant."
+ "VirtualCorpusType` from String \"PRIVAT\": value not one of "
- + "declared Enum instance names: [PROJECT, PRIVATE, PREDEFINED, "
- + "PUBLISHED]"));
+ + "declared Enum instance names"));
}
}