Clean up named-vc.
Change-Id: I81c0a5f03721cc22d264cfd8c0e928e56a23366b
diff --git a/Changes b/Changes
index cbacd56..a28f02c 100644
--- a/Changes
+++ b/Changes
@@ -2,6 +2,7 @@
- Added tests for the DNB scenario with custom max match
and context size. (#745)
+- Clean up named-vc.
# version 0.73.1
diff --git a/src/test/java/de/ids_mannheim/korap/web/controller/AdminLoadVCTest.java b/src/test/java/de/ids_mannheim/korap/web/controller/AdminLoadVCTest.java
index 2c359a0..667fc32 100644
--- a/src/test/java/de/ids_mannheim/korap/web/controller/AdminLoadVCTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/controller/AdminLoadVCTest.java
@@ -2,14 +2,18 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
import com.google.common.net.HttpHeaders;
import de.ids_mannheim.korap.cache.VirtualCorpusCache;
import de.ids_mannheim.korap.config.SpringJerseyTest;
+import de.ids_mannheim.korap.dao.QueryDao;
+import de.ids_mannheim.korap.entity.QueryDO;
import de.ids_mannheim.korap.exceptions.KustvaktException;
import jakarta.ws.rs.client.Entity;
import jakarta.ws.rs.core.Form;
@@ -18,6 +22,10 @@
import jakarta.ws.rs.core.Response.Status;
public class AdminLoadVCTest extends SpringJerseyTest {
+
+ @Autowired
+ private QueryDao dao;
+
@Test
public void testLoadCacheVC ()
@@ -31,9 +39,15 @@
MediaType.APPLICATION_FORM_URLENCODED)
.post(Entity.form(f));
assertEquals(Status.OK.getStatusCode(), response.getStatus());
- Thread.sleep(100);
+ Thread.sleep(200);
+
assertTrue(VirtualCorpusCache.contains("named-vc1"));
VirtualCorpusCache.reset();
assertFalse(VirtualCorpusCache.contains("named-vc1"));
+
+ QueryDO vc = dao.retrieveQueryByName("named-vc1", "system");
+ dao.deleteQuery(vc);
+ vc = dao.retrieveQueryByName("named-vc1", "system");
+ assertNull(vc);
}
}
diff --git a/src/test/java/de/ids_mannheim/korap/web/controller/VCReferenceTest.java b/src/test/java/de/ids_mannheim/korap/web/controller/VCReferenceTest.java
index 346b71d..2afb2f7 100644
--- a/src/test/java/de/ids_mannheim/korap/web/controller/VCReferenceTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/controller/VCReferenceTest.java
@@ -9,15 +9,10 @@
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
+
import com.fasterxml.jackson.databind.JsonNode;
import com.google.common.net.HttpHeaders;
-import jakarta.ws.rs.client.Entity;
-import jakarta.ws.rs.core.Form;
-import jakarta.ws.rs.core.MediaType;
-import jakarta.ws.rs.core.Response;
-import jakarta.ws.rs.core.Response.Status;
-
import de.ids_mannheim.korap.authentication.http.HttpAuthorizationHandler;
import de.ids_mannheim.korap.cache.VirtualCorpusCache;
import de.ids_mannheim.korap.config.Attributes;
@@ -29,6 +24,11 @@
import de.ids_mannheim.korap.exceptions.StatusCodes;
import de.ids_mannheim.korap.util.QueryException;
import de.ids_mannheim.korap.utils.JsonUtils;
+import jakarta.ws.rs.client.Entity;
+import jakarta.ws.rs.core.Form;
+import jakarta.ws.rs.core.MediaType;
+import jakarta.ws.rs.core.Response;
+import jakarta.ws.rs.core.Response.Status;
public class VCReferenceTest extends SpringJerseyTest {
@@ -78,6 +78,9 @@
dao.deleteQuery(vc);
vc = dao.retrieveQueryByName("named-vc2", "system");
assertNull(vc);
+
+ VirtualCorpusCache.delete("named-vc1");
+ assertFalse(VirtualCorpusCache.contains("named-vc1"));
}
private int testSearchWithoutRef_VC1 () throws KustvaktException {