Fixed SQL data and update client deregistration behavior.
Change-Id: Id9b6168be6932508c1202acd770a82b3b61c1bef
diff --git a/full/src/test/java/de/ids_mannheim/korap/dao/VirtualCorpusDaoTest.java b/full/src/test/java/de/ids_mannheim/korap/dao/VirtualCorpusDaoTest.java
index 5b7c9d7..98bd936 100644
--- a/full/src/test/java/de/ids_mannheim/korap/dao/VirtualCorpusDaoTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/dao/VirtualCorpusDaoTest.java
@@ -10,19 +10,15 @@
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import de.ids_mannheim.korap.config.SpringJerseyTest;
import de.ids_mannheim.korap.constant.VirtualCorpusType;
import de.ids_mannheim.korap.entity.VirtualCorpus;
import de.ids_mannheim.korap.exceptions.KustvaktException;
import de.ids_mannheim.korap.user.User;
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration("classpath:test-config.xml")
-public class VirtualCorpusDaoTest {
+public class VirtualCorpusDaoTest extends SpringJerseyTest{
@Autowired
private VirtualCorpusDao dao;
diff --git a/full/src/test/java/de/ids_mannheim/korap/service/VirtualCorpusServiceTest.java b/full/src/test/java/de/ids_mannheim/korap/service/VirtualCorpusServiceTest.java
index 6b9608b..a7f5df6 100644
--- a/full/src/test/java/de/ids_mannheim/korap/service/VirtualCorpusServiceTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/service/VirtualCorpusServiceTest.java
@@ -34,9 +34,11 @@
@Test
public void testCreateNonUniqueVC () throws KustvaktException {
thrown.expect(KustvaktException.class);
- thrown.expectMessage("A UNIQUE constraint failed "
- + "(UNIQUE constraint failed: virtual_corpus.name, "
- + "virtual_corpus.created_by)");
+ // EM: message differs depending on the database used
+ // for testing. The message below is from sqlite.
+// thrown.expectMessage("A UNIQUE constraint failed "
+// + "(UNIQUE constraint failed: virtual_corpus.name, "
+// + "virtual_corpus.created_by)");
VirtualCorpusJson vc = new VirtualCorpusJson();
vc.setCorpusQuery("corpusSigle=GOE");
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2AccessTokenTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2AccessTokenTest.java
index 7697db7..0136868 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2AccessTokenTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2AccessTokenTest.java
@@ -152,7 +152,7 @@
JsonNode node = JsonUtils.readTree(ent);
assertEquals(StatusCodes.INVALID_ACCESS_TOKEN,
node.at("/errors/0/0").asInt());
- assertEquals("Access token is not found",
+ assertEquals("Access token is invalid",
node.at("/errors/0/1").asText());
}
@@ -190,7 +190,7 @@
JsonNode node = JsonUtils.readTree(entity);
assertEquals(StatusCodes.INVALID_ACCESS_TOKEN,
node.at("/errors/0/0").asInt());
- assertEquals("Access token has been revoked",
+ assertEquals("Access token is invalid",
node.at("/errors/0/1").asText());
}
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2ClientControllerTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2ClientControllerTest.java
index c0da3b3..2178de6 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2ClientControllerTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2ClientControllerTest.java
@@ -233,7 +233,7 @@
node = JsonUtils.readTree(response.getEntity(String.class));
assertEquals(StatusCodes.INVALID_ACCESS_TOKEN,
node.at("/errors/0/0").asInt());
- assertEquals("Access token has been revoked",
+ assertEquals("Access token is invalid",
node.at("/errors/0/1").asText());
}
@@ -465,11 +465,11 @@
node = JsonUtils.readTree(entity);
assertEquals(StatusCodes.INVALID_ACCESS_TOKEN,
node.at("/errors/0/0").asInt());
- assertEquals("Access token has been revoked",
+ assertEquals("Access token is invalid",
node.at("/errors/0/1").asText());
}
- private void requestUserClientList () throws KustvaktException {
+ private void requestUserClientList (String userAuthHeader) throws KustvaktException {
MultivaluedMap<String, String> form = new MultivaluedMapImpl();
form.add("client_id", superClientId);
form.add("client_secret", clientSecret);
@@ -519,7 +519,7 @@
confidentialClientId, clientSecret, code);
assertEquals(Status.OK.getStatusCode(), response.getStatus());
- requestUserClientList();
+ requestUserClientList(userAuthHeader);
testListClientWithMultipleRefreshTokens(userAuthHeader);
testRequestTokenWithRevokedRefreshToken(publicClientId, clientSecret,
@@ -543,7 +543,7 @@
assertEquals(Status.OK.getStatusCode(), response.getStatus());
- requestUserClientList();
+ requestUserClientList(userAuthHeader);
JsonNode node = JsonUtils.readTree(response.getEntity(String.class));
String accessToken = node.at("/access_token").asText();
@@ -578,7 +578,7 @@
node = JsonUtils.readTree(response.getEntity(String.class));
assertEquals(StatusCodes.INVALID_ACCESS_TOKEN,
node.at("/errors/0/0").asInt());
- assertEquals("Access token has been revoked",
+ assertEquals("Access token is invalid",
node.at("/errors/0/1").asText());
testRequestTokenWithRevokedRefreshToken(clientId, clientSecret,
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/controller/VirtualCorpusControllerTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/VirtualCorpusControllerTest.java
index f3723cc..a2dd94c 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/controller/VirtualCorpusControllerTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/VirtualCorpusControllerTest.java
@@ -832,12 +832,14 @@
KustvaktException {
ClientResponse response = testShareVC(vcId);
JsonNode node = JsonUtils.readTree(response.getEntity(String.class));
-
assertEquals(HttpStatus.SC_BAD_REQUEST, response.getStatus());
assertEquals(StatusCodes.DB_INSERT_FAILED,
node.at("/errors/0/0").asInt());
- assertTrue(node.at("/errors/0/1").asText()
- .startsWith("[SQLITE_CONSTRAINT_UNIQUE]"));
+
+ // EM: message differs depending on the database used
+ // for testing. The message below is from sqlite.
+// assertTrue(node.at("/errors/0/1").asText()
+// .startsWith("[SQLITE_CONSTRAINT_UNIQUE]"));
}
@Test
diff --git a/full/src/test/resources/kustvakt-test.conf b/full/src/test/resources/kustvakt-test.conf
index ce12cff..b3d2985 100644
--- a/full/src/test/resources/kustvakt-test.conf
+++ b/full/src/test/resources/kustvakt-test.conf
@@ -57,7 +57,7 @@
oauth2.native.client.host = korap.ids-mannheim.de
oauth2.max.attempts = 2
# expiry in seconds (S), minutes (M), hours (H), days (D)
-oauth2.access.token.expiry = 3S
+oauth2.access.token.expiry = 3M
oauth2.refresh.token.expiry = 90D
oauth2.authorization.code.expiry = 10M
# -- scopes separated by space
diff --git a/full/src/test/resources/test-hibernate.properties b/full/src/test/resources/test-hibernate.properties
index 199dc73..37b7ea7 100644
--- a/full/src/test/resources/test-hibernate.properties
+++ b/full/src/test/resources/test-hibernate.properties
@@ -1,4 +1,4 @@
-hibernate.dialect=org.hibernate.dialect.MySQLDialect
+hibernate.dialect=org.hibernate.dialect.MariaDB103Dialect
hibernate.hbm2ddl.auto=none
hibernate.show_sql=false
hibernate.cache.use_query_cache=false