Updated RewriteHandler and tests using BeanConfigTest.
Change-Id: I8e8e2756ccfe4e995b3dcaffd3eb2852ecc88353
diff --git a/core/Changes b/core/Changes
index 210c625..ee3b3cb 100644
--- a/core/Changes
+++ b/core/Changes
@@ -1,6 +1,8 @@
# version 0.61.5
-17/11/2018
+17/12/2018
- Added search timeout in meta query (margaretha)
+18/12/2018
+ - Updated RewriteHandler (margaretha)
version 0.61.4
14/11/2018
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 59101c1..130bc2d 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
@@ -150,10 +150,10 @@
}
- public <T extends ContextHolder> void insertBeans (T beans) {
- this.beans = beans;
- this.config = beans.getConfiguration();
- }
+// public <T extends ContextHolder> void insertBeans (T beans) {
+// this.beans = beans;
+// this.config = beans.getConfiguration();
+// }
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 f3505ce..65be493 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
@@ -83,9 +83,9 @@
}
if (index != null){
String result = new Krill(json).apply(index).toJsonString();
-// if (DEBUG){
+ if (DEBUG){
jlog.debug(result);
-// }
+ }
return result;
}
Result kr = new Result();
diff --git a/full/Changes b/full/Changes
index c9be960..3532fcd 100644
--- a/full/Changes
+++ b/full/Changes
@@ -1,6 +1,8 @@
# version 0.61.5
-17/11/2018
+17/12/2018
- Added a search timeout test (margaretha)
+18/12/2018
+ - Updated tests using BeanConfigTest to use SpringJerseyTest (margaretha)
# version 0.61.4
14/11/2018
diff --git a/full/src/main/resources/log4j2.properties b/full/src/main/resources/log4j2.properties
index 1acd50c..c4762c2 100644
--- a/full/src/main/resources/log4j2.properties
+++ b/full/src/main/resources/log4j2.properties
@@ -11,6 +11,6 @@
appender.mainFile.layout.pattern= %d{yyyy-MM-dd, HH:mm:ss} %C{6} - %M%n %-5p: %m%n
rootLogger.level = warn
-rootLogger.appenderRefs = mainFile
+rootLogger.appenderRefs = console,mainFile
rootLogger.appenderRef.file.ref = MAINLOG
-rootLogger.additivity=false
\ No newline at end of file
+rootLogger.additivity=true
\ No newline at end of file
diff --git a/full/src/test/java/de/ids_mannheim/korap/config/NamedVCLoaderTest.java b/full/src/test/java/de/ids_mannheim/korap/cache/NamedVCLoaderTest.java
similarity index 91%
rename from full/src/test/java/de/ids_mannheim/korap/config/NamedVCLoaderTest.java
rename to full/src/test/java/de/ids_mannheim/korap/cache/NamedVCLoaderTest.java
index 3fef08f..7e3736a 100644
--- a/full/src/test/java/de/ids_mannheim/korap/config/NamedVCLoaderTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/cache/NamedVCLoaderTest.java
@@ -1,4 +1,4 @@
-package de.ids_mannheim.korap.config;
+package de.ids_mannheim.korap.cache;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -10,6 +10,8 @@
import de.ids_mannheim.korap.KrillCollection;
import de.ids_mannheim.korap.collection.CachedVCData;
+import de.ids_mannheim.korap.config.NamedVCLoader;
+import de.ids_mannheim.korap.config.SpringJerseyTest;
import de.ids_mannheim.korap.dao.VirtualCorpusDao;
import de.ids_mannheim.korap.entity.VirtualCorpus;
import de.ids_mannheim.korap.exceptions.KustvaktException;
diff --git a/full/src/test/java/de/ids_mannheim/korap/config/BeanConfigBaseTest.java b/full/src/test/java/de/ids_mannheim/korap/config/BeanConfigBaseTest.java
deleted file mode 100644
index b69cecf..0000000
--- a/full/src/test/java/de/ids_mannheim/korap/config/BeanConfigBaseTest.java
+++ /dev/null
@@ -1,84 +0,0 @@
-package de.ids_mannheim.korap.config;
-
-import static org.junit.Assert.assertNotNull;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-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.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
- */
-@Deprecated
-@NotThreadSafe
-@RunWith(BeanConfigBaseTest.SpringExtendedSetupListener.class)
-@ContextConfiguration("classpath:test-config.xml")
-@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
-public abstract class BeanConfigBaseTest {
-
- private static Logger jlog = LogManager.getLogger(BeanConfigBaseTest.class);
- @Autowired
- protected ApplicationContext context;
-
- public void init () throws Exception {
- 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 abstract void initMethod () throws KustvaktException;
-
- public void close () {
- BeansFactory.closeApplication();
- }
-
- 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/full/src/test/java/de/ids_mannheim/korap/config/TestBeans.java b/full/src/test/java/de/ids_mannheim/korap/config/TestBeans.java
deleted file mode 100644
index 7994ef5..0000000
--- a/full/src/test/java/de/ids_mannheim/korap/config/TestBeans.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package de.ids_mannheim.korap.config;
-
-import java.util.List;
-
-import de.ids_mannheim.korap.authentication.AuthenticationManager;
-import de.ids_mannheim.korap.interfaces.EncryptionIface;
-import de.ids_mannheim.korap.interfaces.EntityHandlerIface;
-import de.ids_mannheim.korap.interfaces.db.AuditingIface;
-import de.ids_mannheim.korap.interfaces.db.UserDataDbIface;
-
-/**
- * @author hanl
- * @date 20/02/2016
- */
-public interface TestBeans {
-
-// public KustvaktConfiguration getConfig();
-
- public EntityHandlerIface getUserDao();
-
- public AuditingIface getAuditingDao();
-
- public List<UserDataDbIface> getUserdataDaos();
-
- public EncryptionIface getCrypto();
-
- public AuthenticationManager getAuthManager();
-
-}
diff --git a/full/src/test/java/de/ids_mannheim/korap/misc/ClassLoaderTest.java b/full/src/test/java/de/ids_mannheim/korap/misc/ClassLoaderTest.java
index cae64f1..9523bf6 100644
--- a/full/src/test/java/de/ids_mannheim/korap/misc/ClassLoaderTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/misc/ClassLoaderTest.java
@@ -4,11 +4,11 @@
import static org.junit.Assert.assertTrue;
import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
-import de.ids_mannheim.korap.config.BeanConfigTest;
import de.ids_mannheim.korap.config.ContextHolder;
import de.ids_mannheim.korap.config.DefaultHandler;
-import de.ids_mannheim.korap.exceptions.KustvaktException;
+import de.ids_mannheim.korap.config.SpringJerseyTest;
import de.ids_mannheim.korap.handlers.JDBCAuditing;
import de.ids_mannheim.korap.interfaces.db.AuditingIface;
@@ -16,8 +16,11 @@
* @author hanl
* @date 27/07/2015
*/
-public class ClassLoaderTest extends BeanConfigTest {
+public class ClassLoaderTest extends SpringJerseyTest {
+ @Autowired
+ AuditingIface audit;
+
@Test
public void testDefaultCreationThrowsNoException () {
DefaultHandler pl = new DefaultHandler();
@@ -26,25 +29,9 @@
assertTrue(o instanceof AuditingIface);
}
-
-// @Test
-// @Deprecated
-// public void testDefaultCreation2ThrowsNoException () {
-// AuthenticationManagerIface iface = helper().getContext()
-// .getAuthenticationManager();
-// assertNotNull(iface);
-// assertTrue(iface instanceof KustvaktAuthenticationManager);
-// }
-
-
@Test
public void testDefaultInterfaceMatchThrowsNoException () {
- AuditingIface iface = helper().getContext().getAuditingProvider();
- assertNotNull(iface);
- assertTrue(iface instanceof JDBCAuditing);
+ assertNotNull(audit);
+ assertTrue(audit instanceof JDBCAuditing);
}
-
-
- @Override
- public void initMethod () throws KustvaktException {}
}
diff --git a/full/src/test/java/de/ids_mannheim/korap/misc/ConfigTest.java b/full/src/test/java/de/ids_mannheim/korap/misc/ConfigTest.java
index 734f78c..bd56477 100644
--- a/full/src/test/java/de/ids_mannheim/korap/misc/ConfigTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/misc/ConfigTest.java
@@ -6,27 +6,25 @@
import java.io.IOException;
import java.io.InputStream;
-import java.net.URISyntaxException;
-import java.util.Map;
import java.util.Properties;
-import org.junit.Ignore;
import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
-import de.ids_mannheim.korap.config.BeanConfigTest;
import de.ids_mannheim.korap.config.ConfigLoader;
-import de.ids_mannheim.korap.exceptions.KustvaktException;
-import de.ids_mannheim.korap.interfaces.EncryptionIface;
+import de.ids_mannheim.korap.config.KustvaktConfiguration;
+import de.ids_mannheim.korap.config.SpringJerseyTest;
import de.ids_mannheim.korap.utils.ServiceInfo;
import de.ids_mannheim.korap.utils.TimeUtils;
-/** EM: To do: fix tests
+/**
* @author hanl
* @date 02/09/2015
*/
-@Ignore
-public class ConfigTest extends BeanConfigTest {
+public class ConfigTest extends SpringJerseyTest {
+ @Autowired
+ KustvaktConfiguration config;
@Test
public void testConfigLoader () {
@@ -52,32 +50,11 @@
@Test
public void testProperties () {
- assertEquals("token layer does not match", "opennlp", helper()
- .getContext().getConfiguration().getDefault_token());
+ assertEquals("token layer does not match", "opennlp", config.getDefault_token());
assertEquals("token expiration does not match",
- TimeUtils.convertTimeToSeconds("1D"), helper().getContext()
- .getConfiguration().getLongTokenTTL());
+ TimeUtils.convertTimeToSeconds("1D"), config.getLongTokenTTL());
}
- @Test(expected = KustvaktException.class)
- @Ignore
- public void testBeanOverrideInjection () throws Exception {
- helper().getContext()
- .getConfiguration()
- .setPropertiesAsStream(
- ConfigTest.class.getClassLoader().getResourceAsStream(
- "kustvakt.conf"));
- }
-
- @Test
- public void testBootConfigDependencyOrder () {
- // todo:
-
- }
-
- @Override
- public void initMethod () throws KustvaktException {
-
- }
+
}
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 188c36a..4fc673b 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,44 +1,38 @@
package de.ids_mannheim.korap.misc;
+
import java.util.Date;
import org.joda.time.LocalDate;
-import org.junit.Ignore;
import org.junit.Test;
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 de.ids_mannheim.korap.interfaces.db.AuditingIface;
+import de.ids_mannheim.korap.interfaces.defaults.DefaultAuditing;
/**
* @author hanl
* @date 27/07/2015
*/
-//todo: test audit commit in thread and that no concurrency issue arrises
-public class FileAuditingTest extends BeanConfigTest {
-
- @Override
- public void initMethod () throws KustvaktException {
-
- }
-
+// todo: test audit commit in thread and that no concurrency issue
+// arrises
+public class FileAuditingTest {
@Test
public void testAdd () {
+ AuditingIface auditor = new DefaultAuditing();
for (int i = 0; i < 20; i++) {
AuditRecord record = AuditRecord.serviceRecord("MichaelHanl",
StatusCodes.ILLEGAL_ARGUMENT, String.valueOf(i),
"string value");
- helper().getContext().getAuditingProvider().audit(record);
+ auditor.audit(record);
}
}
-
- @Ignore
- @Test (expected = UnsupportedOperationException.class)
+ @Test(expected = UnsupportedOperationException.class)
public void testRetrieval () {
- helper().getContext().getAuditingProvider()
- .retrieveRecords(new LocalDate(new Date().getTime()), 10);
+ AuditingIface auditor = new DefaultAuditing();
+ auditor.retrieveRecords(new LocalDate(new Date().getTime()), 10);
}
}
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 52b331a..ab5039e 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
@@ -3,12 +3,14 @@
import java.io.IOException;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import javax.annotation.PostConstruct;
+
import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
import de.ids_mannheim.korap.KrillCollection;
-import de.ids_mannheim.korap.config.BeanConfigTest;
+import de.ids_mannheim.korap.config.KustvaktConfiguration;
+import de.ids_mannheim.korap.config.SpringJerseyTest;
import de.ids_mannheim.korap.exceptions.KustvaktException;
import de.ids_mannheim.korap.query.serialize.CollectionQueryProcessor;
import de.ids_mannheim.korap.utils.JsonUtils;
@@ -19,27 +21,26 @@
* @author hanl
* @date 14/01/2016
*/
-public class LocalQueryTest extends BeanConfigTest {
+public class LocalQueryTest extends SpringJerseyTest {
private static String index;
- private static String qstring;
+ @Autowired
+ KustvaktConfiguration config;
- @BeforeClass
- public static void setup () throws Exception {
- qstring = "creationDate since 1786 & creationDate until 1788";
- // qstring = "creationDate since 1765 & creationDate until 1768";
- // qstring = "textType = Aphorismus";
- // qstring = "title ~ \"Werther\"";
+ @PostConstruct
+ public void setup () throws Exception {
+ index = config.getIndexDir();
}
- @AfterClass
- public static void drop () {}
-
-
@Test
public void testQuery () throws KustvaktException {
+ String qstring = "creationDate since 1786 & creationDate until 1788";
+ // qstring = "creationDate since 1765 & creationDate until 1768";
+ // qstring = "textType = Aphorismus";
+ // qstring = "title ~ \"Werther\"";
+
SearchKrill krill = new SearchKrill(index);
KoralCollectionQueryBuilder coll = new KoralCollectionQueryBuilder();
coll.with(qstring);
@@ -73,14 +74,4 @@
assertNotNull(docs);
}
-
- @Test
- public void testQueryHash () {}
-
-
- @Override
- public void initMethod () throws KustvaktException {
-// helper().runBootInterfaces();
- index = helper().getContext().getConfiguration().getIndexDir();
- }
}
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 28bab56..e055529 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
@@ -4,10 +4,12 @@
import static org.junit.Assert.assertNotNull;
import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
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.SpringJerseyTest;
import de.ids_mannheim.korap.config.TestVariables;
import de.ids_mannheim.korap.exceptions.KustvaktException;
import de.ids_mannheim.korap.query.serialize.QuerySerializer;
@@ -20,19 +22,15 @@
* @author hanl
* @date 03/09/2015
*/
-public class CollectionRewriteTest extends BeanConfigTest {
+public class CollectionRewriteTest extends SpringJerseyTest {
- @Override
- public void initMethod () throws KustvaktException {
-// helper().runBootInterfaces();
- }
-
-
+ @Autowired
+ public KustvaktConfiguration config;
+
@Test
public void testCollectionNodeRemoveCorpusIdNoErrors ()
throws KustvaktException {
- RewriteHandler handler = new RewriteHandler();
- handler.insertBeans(helper().getContext());
+ RewriteHandler handler = new RewriteHandler(config);
handler.add(CollectionConstraint.class);
QuerySerializer s = new QuerySerializer();
s.setQuery(TestVariables.SIMPLE_ADD_QUERY, "poliqarp");
@@ -54,8 +52,7 @@
@Test
public void testCollectionNodeRemoveAllCorpusIdNoErrors ()
throws KustvaktException {
- RewriteHandler handler = new RewriteHandler();
- handler.insertBeans(helper().getContext());
+ RewriteHandler handler = new RewriteHandler(config);
handler.add(CollectionConstraint.class);
QuerySerializer s = new QuerySerializer();
s.setQuery(TestVariables.SIMPLE_ADD_QUERY, "poliqarp");
@@ -75,8 +72,7 @@
@Test
public void testCollectionNodeRemoveGroupedCorpusIdNoErrors ()
throws KustvaktException {
- RewriteHandler handler = new RewriteHandler();
- handler.insertBeans(helper().getContext());
+ RewriteHandler handler = new RewriteHandler(config);
handler.add(CollectionConstraint.class);
QuerySerializer s = new QuerySerializer();
s.setQuery(TestVariables.SIMPLE_ADD_QUERY, "poliqarp");
@@ -99,8 +95,7 @@
@Test
public void testCollectionCleanEmptyDocGroupNoErrors ()
throws KustvaktException {
- RewriteHandler handler = new RewriteHandler();
- handler.insertBeans(helper().getContext());
+ RewriteHandler handler = new RewriteHandler(config);
handler.add(CollectionConstraint.class);
handler.add(CollectionCleanRewrite.class);
QuerySerializer s = new QuerySerializer();
@@ -128,8 +123,7 @@
@Test
public void testCollectionCleanMoveOneDocFromGroupUpNoErrors ()
throws KustvaktException {
- RewriteHandler handler = new RewriteHandler();
- handler.insertBeans(helper().getContext());
+ RewriteHandler handler = new RewriteHandler(config);
handler.add(CollectionConstraint.class);
handler.add(CollectionCleanRewrite.class);
QuerySerializer s = new QuerySerializer();
@@ -150,8 +144,7 @@
@Test
public void testCollectionCleanEmptyGroupAndMoveOneFromGroupUpNoErrors ()
throws KustvaktException {
- RewriteHandler handler = new RewriteHandler();
- handler.insertBeans(helper().getContext());
+ RewriteHandler handler = new RewriteHandler(config);
handler.add(CollectionConstraint.class);
handler.add(CollectionCleanRewrite.class);
QuerySerializer s = new QuerySerializer();
@@ -172,8 +165,7 @@
@Test
public void testCollectionRemoveAndMoveOneFromGroupUpNoErrors ()
throws KustvaktException {
- RewriteHandler handler = new RewriteHandler();
- handler.insertBeans(helper().getContext());
+ RewriteHandler handler = new RewriteHandler(config);
handler.add(CollectionConstraint.class);
handler.add(CollectionCleanRewrite.class);
QuerySerializer s = new QuerySerializer();
@@ -196,8 +188,7 @@
@Test
public void testPublicCollectionRewriteEmptyAdd () throws KustvaktException {
- RewriteHandler handler = new RewriteHandler();
- handler.insertBeans(helper().getContext());
+ RewriteHandler handler = new RewriteHandler(config);
handler.add(CollectionRewrite.class);
QuerySerializer s = new QuerySerializer();
@@ -221,8 +212,7 @@
@Test
public void testPublicCollectionRewriteNonEmptyAdd ()
throws KustvaktException {
- RewriteHandler handler = new RewriteHandler();
- handler.insertBeans(helper().getContext());
+ RewriteHandler handler = new RewriteHandler(config);
handler.add(CollectionRewrite.class);
QuerySerializer s = new QuerySerializer();
@@ -251,8 +241,7 @@
@Test
public void testRemoveCorpusFromDifferentGroups () throws KustvaktException {
- RewriteHandler handler = new RewriteHandler();
- handler.insertBeans(helper().getContext());
+ RewriteHandler handler = new RewriteHandler(config);
handler.add(CollectionConstraint.class);
QuerySerializer s = new QuerySerializer();
s.setQuery(TestVariables.SIMPLE_ADD_QUERY, "poliqarp");
@@ -277,8 +266,7 @@
@Test
public void testRemoveOneCorpusAndMoveDocFromTwoGroups ()
throws KustvaktException {
- RewriteHandler handler = new RewriteHandler();
- handler.insertBeans(helper().getContext());
+ RewriteHandler handler = new RewriteHandler(config);
handler.add(CollectionConstraint.class);
// todo: use this collection query also to test clean up filter! after reduction of corpusSigle (wiss | freizeit)!
handler.add(CollectionCleanRewrite.class);
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 98828da..f159049 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
@@ -5,22 +5,17 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-import org.junit.Ignore;
import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
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;
import de.ids_mannheim.korap.config.KustvaktConfiguration;
+import de.ids_mannheim.korap.config.SpringJerseyTest;
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.resource.LayerMapper;
-import de.ids_mannheim.korap.user.User;
-import de.ids_mannheim.korap.user.UserSettings;
+import de.ids_mannheim.korap.user.KorAPUser;
import de.ids_mannheim.korap.utils.JsonUtils;
/**
@@ -28,7 +23,7 @@
* @date 18/06/2015
*/
//todo: check position and information of rewrites!
-public class FoundryRewriteTest extends BeanConfigTest {
+public class FoundryRewriteTest extends SpringJerseyTest {
private static String simple_add_query = "[pos=ADJA]";
private static String simple_rewrite_query = "[base=Haus]";
@@ -36,16 +31,11 @@
private static String complex_rewrite_query2 = "[orth=laufe/i & base!=Lauf]";
private static String complex_rewrite_query3 = "[(base=laufen | base=gehen) & tt/pos=VVFIN]";
- private static KustvaktConfiguration config;
-
-
- @Override
- public void initMethod () throws KustvaktException {
- config = helper().getContext().getConfiguration();
-// helper().setupAccount();
- }
-
-
+ @Autowired
+ public KustvaktConfiguration config;
+ @Autowired
+ public RewriteHandler handler;
+
@Test
public void testDefaultLayerMapperThrowsNoException () {
LayerMapper m = new LayerMapper(config);
@@ -58,25 +48,17 @@
}
- @Ignore
- @Deprecated
@Test
public void testDefaultFoundryInjectLemmaThrowsNoError ()
throws KustvaktException {
- KustvaktConfiguration c = helper().getBean(
- ContextHolder.KUSTVAKT_CONFIG);
-
- RewriteHandler processor = new RewriteHandler();
- processor.insertBeans(helper().getContext());
- processor.add(FoundryInject.class);
QuerySerializer s = new QuerySerializer();
s.setQuery("[base=Haus]", "poliqarp");
- String result = processor.processQuery(s.toJSON(), null);
+ String result = handler.processQuery(s.toJSON(), new KorAPUser());
JsonNode node = JsonUtils.readTree(result);
assertNotNull(node);
assertFalse(node.at("/query/wrap/foundry").isMissingNode());
- assertEquals(c.getDefault_lemma(), node.at("/query/wrap/foundry")
+ assertEquals(config.getDefault_lemma(), node.at("/query/wrap/foundry")
.asText());
assertEquals("lemma", node.at("/query/wrap/layer").asText());
assertFalse(node.at("/query/wrap/rewrites").isMissingNode());
@@ -88,20 +70,14 @@
@Test
public void testDefaultFoundryInjectPOSNoErrors () throws KustvaktException {
- KustvaktConfiguration c = helper().getBean(
- ContextHolder.KUSTVAKT_CONFIG);
-
QuerySerializer s = new QuerySerializer();
- RewriteHandler handler = new RewriteHandler();
- handler.insertBeans(helper().getContext());
s.setQuery("[pos=ADJA]", "poliqarp");
- assertTrue(handler.add(FoundryInject.class));
- String result = handler.processQuery(s.toJSON(), null);
+ String result = handler.processQuery(s.toJSON(), new KorAPUser());
JsonNode node = JsonUtils.readTree(result);
assertNotNull(node);
assertFalse(node.at("/query/wrap/foundry").isMissingNode());
- assertEquals(c.getDefault_pos(), node.at("/query/wrap/foundry")
+ assertEquals(config.getDefault_pos(), node.at("/query/wrap/foundry")
.asText());
assertEquals("pos", node.at("/query/wrap/layer").asText());
assertFalse(node.at("/query/wrap/rewrites").isMissingNode());
@@ -111,82 +87,77 @@
}
// EM: Fix me usersetting
- @Test
- @Ignore
- public void testRewriteFoundryInjectPOSThrowsNoError ()
- throws KustvaktException {
- User user = helper().getUser();
-
- RewriteHandler handler = new RewriteHandler();
- handler.insertBeans(helper().getContext());
- handler.add(FoundryInject.class);
- QuerySerializer s = new QuerySerializer();
- s.setQuery("[pos=ADJA]", "poliqarp");
- String result = handler.processQuery(s.toJSON(), user);
- JsonNode node = JsonUtils.readTree(result);
-
- UserDataDbIface dao = BeansFactory.getTypeFactory()
- .getTypeInterfaceBean(
- helper().getContext().getUserDataProviders(),
- UserSettings.class);
- UserSettings settings = (UserSettings) dao.get(user);
- assertTrue(settings.isValid());
- String pos = (String) settings.get(Attributes.DEFAULT_POS_FOUNDRY);
-
- assertNotNull(node);
- assertEquals("pos", node.at("/query/wrap/layer").asText());
- assertEquals(pos, node.at("/query/wrap/foundry").asText());
- assertFalse(node.at("/query/wrap/rewrites").isMissingNode());
- assertEquals("koral:rewrite", node.at("/query/wrap/rewrites/0/@type")
- .asText());
- }
+// @Test
+// @Ignore
+// public void testRewriteFoundryInjectPOSThrowsNoError ()
+// throws KustvaktException {
+// User user = helper().getUser();
+//
+// RewriteHandler handler = new RewriteHandler();
+// handler.insertBeans(helper().getContext());
+// handler.add(FoundryInject.class);
+// QuerySerializer s = new QuerySerializer();
+// s.setQuery("[pos=ADJA]", "poliqarp");
+// String result = handler.processQuery(s.toJSON(), user);
+// JsonNode node = JsonUtils.readTree(result);
+//
+// UserDataDbIface dao = BeansFactory.getTypeFactory()
+// .getTypeInterfaceBean(
+// helper().getContext().getUserDataProviders(),
+// UserSettings.class);
+// UserSettings settings = (UserSettings) dao.get(user);
+// assertTrue(settings.isValid());
+// String pos = (String) settings.get(Attributes.DEFAULT_POS_FOUNDRY);
+//
+// assertNotNull(node);
+// assertEquals("pos", node.at("/query/wrap/layer").asText());
+// assertEquals(pos, node.at("/query/wrap/foundry").asText());
+// assertFalse(node.at("/query/wrap/rewrites").isMissingNode());
+// assertEquals("koral:rewrite", node.at("/query/wrap/rewrites/0/@type")
+// .asText());
+// }
// EM: Fix me usersetting
- @Test
- @Ignore
- public void testRewriteFoundryInjectLemmaThrowsNoError ()
- throws KustvaktException {
- KustvaktConfiguration c = helper().getBean(
- ContextHolder.KUSTVAKT_CONFIG);
- User user = helper().getUser();
-
- RewriteHandler handler = new RewriteHandler();
- handler.insertBeans(helper().getContext());
- handler.add(FoundryInject.class);
- QuerySerializer s = new QuerySerializer();
- s.setQuery("[base=Haus]", "poliqarp");
- String result = handler.processQuery(s.toJSON(), user);
- JsonNode node = JsonUtils.readTree(result);
-
- UserDataDbIface dao = BeansFactory.getTypeFactory()
- .getTypeInterfaceBean(
- helper().getContext().getUserDataProviders(),
- UserSettings.class);
- UserSettings settings = (UserSettings) dao.get(user);
- assertTrue(settings.isValid());
- String lemma = (String) settings.get(Attributes.DEFAULT_LEMMA_FOUNDRY);
-
- assertNotNull(node);
- assertEquals("lemma", node.at("/query/wrap/layer").asText());
- assertEquals(lemma, node.at("/query/wrap/foundry").asText());
- assertFalse(node.at("/query/wrap/rewrites").isMissingNode());
- assertEquals("koral:rewrite", node.at("/query/wrap/rewrites/0/@type")
- .asText());
- }
+// @Test
+// @Ignore
+// public void testRewriteFoundryInjectLemmaThrowsNoError ()
+// throws KustvaktException {
+// KustvaktConfiguration c = helper().getBean(
+// ContextHolder.KUSTVAKT_CONFIG);
+// User user = helper().getUser();
+//
+// RewriteHandler handler = new RewriteHandler();
+// handler.insertBeans(helper().getContext());
+// handler.add(FoundryInject.class);
+// QuerySerializer s = new QuerySerializer();
+// s.setQuery("[base=Haus]", "poliqarp");
+// String result = handler.processQuery(s.toJSON(), user);
+// JsonNode node = JsonUtils.readTree(result);
+//
+// UserDataDbIface dao = BeansFactory.getTypeFactory()
+// .getTypeInterfaceBean(
+// helper().getContext().getUserDataProviders(),
+// UserSettings.class);
+// UserSettings settings = (UserSettings) dao.get(user);
+// assertTrue(settings.isValid());
+// String lemma = (String) settings.get(Attributes.DEFAULT_LEMMA_FOUNDRY);
+//
+// assertNotNull(node);
+// assertEquals("lemma", node.at("/query/wrap/layer").asText());
+// assertEquals(lemma, node.at("/query/wrap/foundry").asText());
+// assertFalse(node.at("/query/wrap/rewrites").isMissingNode());
+// assertEquals("koral:rewrite", node.at("/query/wrap/rewrites/0/@type")
+// .asText());
+// }
@Test
public void testFoundryInjectJoinedQueryNoErrors ()
throws KustvaktException {
- KustvaktConfiguration c = helper().getBean(
- ContextHolder.KUSTVAKT_CONFIG);
QuerySerializer s = new QuerySerializer();
- RewriteHandler handler = new RewriteHandler();
- handler.insertBeans(helper().getContext());
s.setQuery("[orth=laufe/i & base!=Lauf]", "poliqarp");
- assertTrue(handler.add(FoundryInject.class));
- String result = handler.processQuery(s.toJSON(), null);
+ String result = handler.processQuery(s.toJSON(), new KorAPUser());
JsonNode node = JsonUtils.readTree(result);
assertNotNull(node);
@@ -202,11 +173,8 @@
public void testFoundryInjectGroupedQueryNoErrors ()
throws KustvaktException {
QuerySerializer s = new QuerySerializer();
- RewriteHandler handler = new RewriteHandler();
- handler.insertBeans(helper().getContext());
s.setQuery("[(base=laufen | tt/pos=VVFIN)]", "poliqarp");
- assertTrue(handler.add(FoundryInject.class));
- String result = handler.processQuery(s.toJSON(), null);
+ String result = handler.processQuery(s.toJSON(), new KorAPUser());
JsonNode node = JsonUtils.readTree(result);
// System.out.println("NODDE "+ node);
assertNotNull(node);
@@ -220,29 +188,18 @@
}
@Test
- @Ignore
- public void testFoundyBaseRewrite() throws KustvaktException {
+ public void testFoundryBaseRewrite() throws KustvaktException {
QuerySerializer s = new QuerySerializer();
- RewriteHandler handler = new RewriteHandler();
- handler.insertBeans(helper().getContext());
s.setQuery("[orth=laufen]", "poliqarp");
- assertTrue(handler.add(FoundryInject.class));
- String result = handler.processQuery(s.toJSON(), null);
+ String result = handler.processQuery(s.toJSON(), new KorAPUser());
JsonNode node = JsonUtils.readTree(result);
-// System.out.println("NODDE "+ node);
- assertNotNull(node);
- assertEquals("koral:termGroup", node.at("/query/wrap/@type").asText());
- assertFalse(node.at("/query/wrap/operands/0/operands/0/foundry")
+ System.out.println("NODE "+ node);
+// assertNotNull(node);
+ assertEquals("koral:term", node.at("/query/wrap/@type").asText());
+ assertFalse(node.at("/query/wrap/foundry")
.isMissingNode());
- assertFalse(node.at("/query/wrap/operands/0/operands/0/rewrites")
+ assertFalse(node.at("/query/wrap/rewrites")
.isMissingNode());
- assertFalse(node.at("/query/wrap/operands/0/operands/1/foundry")
- .isMissingNode());
- assertFalse(node.at("/query/wrap/operands/0/operands/1/rewrites")
- .isMissingNode());
-
- assertFalse(node.at("/query/wrap/operands/1/foundry").isMissingNode());
- assertTrue(node.at("/query/wrap/operands/1/rewrites").isMissingNode());
}
}
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 65ae668..ed8f4a3 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
@@ -5,31 +5,36 @@
import static org.junit.Assert.assertTrue;
import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
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.SpringJerseyTest;
import de.ids_mannheim.korap.exceptions.KustvaktException;
import de.ids_mannheim.korap.query.serialize.QuerySerializer;
+import de.ids_mannheim.korap.user.KorAPUser;
import de.ids_mannheim.korap.utils.JsonUtils;
/**
* @author hanl
* @date 21/10/2015
*/
-public class IdRewriteTest extends BeanConfigTest {
+public class IdRewriteTest extends SpringJerseyTest {
+ @Autowired
+ private KustvaktConfiguration config;
+
@Test
public void insertTokenId () throws KustvaktException {
- RewriteHandler handler = new RewriteHandler();
- handler.insertBeans(helper().getContext());
+ RewriteHandler handler = new RewriteHandler(config);
assertTrue(handler.add(IdWriter.class));
String query = "[surface=Wort]";
QuerySerializer s = new QuerySerializer();
s.setQuery(query, "poliqarp");
- String value = handler.processQuery(s.toJSON(), null);
+ String value = handler.processQuery(s.toJSON(), new KorAPUser());
JsonNode result = JsonUtils.readTree(value);
assertNotNull(result);
@@ -39,13 +44,12 @@
@Test
public void testIdWriterTest () throws KustvaktException {
- RewriteHandler handler = new RewriteHandler();
- handler.insertBeans(helper().getContext());
+ RewriteHandler handler = new RewriteHandler(config);
assertTrue(handler.add(IdWriter.class));
QuerySerializer s = new QuerySerializer();
s.setQuery("[base=Haus]", "poliqarp");
- String result = handler.processQuery(s.toJSON(), null);
+ String result = handler.processQuery(s.toJSON(), new KorAPUser());
JsonNode node = JsonUtils.readTree(result);
assertNotNull(node);
assertFalse(node.at("/query/wrap").isMissingNode());
@@ -53,8 +57,4 @@
}
- @Override
- public void initMethod () throws KustvaktException {
-
- }
}
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 32deec8..2fe92d8 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
@@ -3,8 +3,9 @@
import static org.junit.Assert.assertEquals;
import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
-import de.ids_mannheim.korap.config.BeanConfigTest;
+import de.ids_mannheim.korap.config.SpringJerseyTest;
import de.ids_mannheim.korap.config.TestVariables;
import de.ids_mannheim.korap.exceptions.KustvaktException;
import de.ids_mannheim.korap.rewrite.CollectionRewrite;
@@ -14,17 +15,13 @@
* @author hanl
* @date 12/11/2015
*/
-public class ResultRewriteTest extends BeanConfigTest {
+public class ResultRewriteTest extends SpringJerseyTest {
- @Override
- public void initMethod () throws KustvaktException {
-
- }
-
+ @Autowired
+ public RewriteHandler ha;
+
@Test
public void testPostRewriteNothingToDo () throws KustvaktException {
- RewriteHandler ha = new RewriteHandler();
- ha.insertBeans(helper().getContext());
assertEquals("Handler could not be added to rewrite handler instance!",
true, ha.add(CollectionRewrite.class));
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 67f74bd..30ecd1f 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,22 +1,18 @@
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 org.springframework.beans.factory.annotation.Autowired;
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.KustvaktConfiguration;
+import de.ids_mannheim.korap.config.SpringJerseyTest;
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.user.UserSettings;
import de.ids_mannheim.korap.utils.JsonUtils;
/** EM: to do: Fix tests
@@ -25,12 +21,14 @@
* @author hanl
* @date 21/10/2015
*/
-public class RewriteHandlerTest extends BeanConfigTest {
+public class RewriteHandlerTest extends SpringJerseyTest {
+ @Autowired
+ private KustvaktConfiguration config;
+
@Test
public void testRewriteTaskAdd () {
- RewriteHandler handler = new RewriteHandler();
- handler.insertBeans(helper().getContext());
+ RewriteHandler handler = new RewriteHandler(config);
assertTrue(handler.add(FoundryInject.class));
assertTrue(handler.add(CollectionCleanRewrite.class));
assertTrue(handler.add(IdWriter.class));
@@ -50,8 +48,7 @@
@Test
public void testRewriteNoBeanInject () throws KustvaktException {
- RewriteHandler handler = new RewriteHandler(helper().getContext()
- .getConfiguration());
+ RewriteHandler handler = new RewriteHandler(config);
QuerySerializer s = new QuerySerializer();
s.setQuery("[(base=laufen | base=gehen) & tt/pos=VVFIN]", "poliqarp");
assertTrue(handler.add(FoundryInject.class));
@@ -61,8 +58,7 @@
@Test
public void testRewriteBeanInject () throws KustvaktException {
- RewriteHandler handler = new RewriteHandler();
- handler.insertBeans(helper().getContext());
+ RewriteHandler handler = new RewriteHandler(config);
QuerySerializer s = new QuerySerializer();
s.setQuery("[base=laufen | tt/pos=VVFIN]", "poliqarp");
assertTrue(handler.add(FoundryInject.class));
@@ -76,26 +72,25 @@
}
// EM: Fix me usersetting
- @Test
- @Ignore
- public void testRewriteUserSpecific () throws KustvaktException {
- RewriteHandler handler = new RewriteHandler();
- handler.insertBeans(helper().getContext());
- QuerySerializer s = new QuerySerializer();
- s.setQuery("[base=laufen|tt/pos=VFIN]", "poliqarp");
- assertTrue(handler.add(FoundryInject.class));
- String res = handler.processQuery(s.toJSON(), helper().getUser());
- JsonNode node = JsonUtils.readTree(res);
- assertNotNull(node);
- assertEquals("tt_test",
- node.at("/query/wrap/operands/0/foundry").asText());
- assertNotEquals("tt_test",
- node.at("/query/wrap/operands/1/foundry").asText());
- }
+// @Test
+// @Ignore
+// public void testRewriteUserSpecific () throws KustvaktException {
+// RewriteHandler handler = new RewriteHandler(config);
+// QuerySerializer s = new QuerySerializer();
+// s.setQuery("[base=laufen|tt/pos=VFIN]", "poliqarp");
+// assertTrue(handler.add(FoundryInject.class));
+// String res = handler.processQuery(s.toJSON(), helper().getUser());
+// JsonNode node = JsonUtils.readTree(res);
+// assertNotNull(node);
+// assertEquals("tt_test",
+// node.at("/query/wrap/operands/0/foundry").asText());
+// assertNotEquals("tt_test",
+// node.at("/query/wrap/operands/1/foundry").asText());
+// }
// EM: Fix me usersetting
- @Override
- public void initMethod () throws KustvaktException {
+// @Override
+// public void initMethod () throws KustvaktException {
// helper().setupAccount();
// UserDataDbIface settingsdao = BeansFactory.getTypeFactory()
// .getTypeInterfaceBean(
@@ -105,7 +100,7 @@
// UserSettings s = (UserSettings) settingsdao.get(helper().getUser());
// s.setField(Attributes.DEFAULT_LEMMA_FOUNDRY, "tt_test");
// settingsdao.update(s);
- }
+// }
diff --git a/full/src/test/java/de/ids_mannheim/korap/user/UserFactoryTest.java b/full/src/test/java/de/ids_mannheim/korap/user/UserFactoryTest.java
deleted file mode 100644
index 51d03cb..0000000
--- a/full/src/test/java/de/ids_mannheim/korap/user/UserFactoryTest.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package de.ids_mannheim.korap.user;
-
-/**
- * @author hanl
- * @date 04/02/2016
- */
-public class UserFactoryTest {}
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/ApiVersionTest.java b/full/src/test/java/de/ids_mannheim/korap/web/ApiVersionTest.java
index 92400e6..87d62ad 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/ApiVersionTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/ApiVersionTest.java
@@ -14,6 +14,10 @@
import de.ids_mannheim.korap.config.SpringJerseyTest;
import de.ids_mannheim.korap.exceptions.KustvaktException;
+/**
+ * @author margaretha
+ *
+ */
public class ApiVersionTest extends SpringJerseyTest {
@Test
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/JettyServerTest.java b/full/src/test/java/de/ids_mannheim/korap/web/JettyServerTest.java
index ce898c2..b4c5b09 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/JettyServerTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/JettyServerTest.java
@@ -13,6 +13,10 @@
import org.junit.BeforeClass;
import org.junit.Test;
+/**
+ * @author margaretha
+ *
+ */
public class JettyServerTest {
@BeforeClass
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/controller/KustvaktCoreRestTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/KustvaktCoreRestTest.java
deleted file mode 100644
index 4d63221..0000000
--- a/full/src/test/java/de/ids_mannheim/korap/web/controller/KustvaktCoreRestTest.java
+++ /dev/null
@@ -1,85 +0,0 @@
-package de.ids_mannheim.korap.web.controller;
-
-import org.junit.Ignore;
-import org.junit.Test;
-
-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.web.FastJerseyTest;
-
-/**
- * @author hanl
- * @date 26/06/2015
- */
-public class KustvaktCoreRestTest extends FastJerseyTest {
-
- @Override
- public void initMethod () throws KustvaktException {
-// helper().setupAccount();
-// helper().runBootInterfaces();
- }
-
- // @Test
- public void testFieldsInSearch () {
- ClientResponse response = resource().path(API_VERSION)
- .path("search").queryParam("q", "[base=Wort]")
- .queryParam("ql", "poliqarp").get(ClientResponse.class);
- assert ClientResponse.Status.OK.getStatusCode() == response.getStatus();
- }
-
-
- @Test
- public void testQuery () {
- ClientResponse response = resource().path(API_VERSION)
- .path("search").queryParam("q", "[base=Wort]")
- .queryParam("ql", "poliqarp").get(ClientResponse.class);
- // System.out.println("_______________________________________________");
-// System.out.println(response.getEntity(String.class));
- assert ClientResponse.Status.OK.getStatusCode() == response.getStatus();
- }
-
-
- @Test
- public void testQueryRaw () {
- QuerySerializer s = new QuerySerializer();
- s.setQuery("[base=Wort]", "poliqarp");
-
- ClientResponse response = resource().path(API_VERSION)
- .path("search").post(ClientResponse.class, s.toJSON());
- // System.out.println("_______________________________________________ RAW");
- // System.out.println(response.getEntity(String.class));
- assert ClientResponse.Status.OK.getStatusCode() == response.getStatus();
- }
-
-
- // in case no index is there, this will throw an error
- @Test
- @Ignore
- public void testGetMatchInfoThrowsNoException () {
- ClientResponse response = resource().path(API_VERSION).get(
- ClientResponse.class);
- }
-
- // @Test
- public void testBuildQueryThrowsNoException () {
- ClientResponse response = resource().path(API_VERSION)
- .path("search").queryParam("q", "[base=Haus & surface=Hauses]")
- .queryParam("ql", "poliqarp").queryParam("cutOff", "true")
- .queryParam("page", "1").method("TRACE", ClientResponse.class);
- assert ClientResponse.Status.OK.getStatusCode() == response.getStatus();
- }
-
-
- // @Test
- public void testQueryByNameThrowsNoException () {
- ClientResponse response = resource().path(API_VERSION)
- .path("corpus").path("WPD").path("search")
- .queryParam("q", "[base=Haus & surface=Hauses]")
- .queryParam("ql", "poliqarp").queryParam("cutOff", "true")
- .queryParam("page", "1").get(ClientResponse.class);
-// System.out.println("RESPONSE " + response.getEntity(String.class));
- }
-
-}