formatter plugin
diff --git a/src/test/java/de/ids_mannheim/korap/web/service/FastJerseyTest.java b/src/test/java/de/ids_mannheim/korap/web/service/FastJerseyTest.java
index 83e1438..db7a860 100644
--- a/src/test/java/de/ids_mannheim/korap/web/service/FastJerseyTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/service/FastJerseyTest.java
@@ -37,49 +37,57 @@
private static Client client;
private static String[] classPackages = null;
- public static void addClass(Class<?> resourceClass) {
+
+ public static void addClass (Class<?> resourceClass) {
resourceConfig.getClasses().add(resourceClass);
}
- public static void setPackages(String... pack) {
+
+ public static void setPackages (String ... pack) {
classPackages = pack;
}
- public static void addSingleton(Object resourceSingleton) {
+
+ public static void addSingleton (Object resourceSingleton) {
resourceConfig.getSingletons().add(resourceSingleton);
}
- public String getAPIVersion() {
+
+ public String getAPIVersion () {
return API_VERSION;
}
- public static <T> void addProviderForContext(Class<T> contextClass,
+
+ public static <T> void addProviderForContext (Class<T> contextClass,
T contextObject) {
- addSingleton(
- new SingletonTypeInjectableProvider<Context, T>(contextClass,
- contextObject) {
- });
+ addSingleton(new SingletonTypeInjectableProvider<Context, T>(
+ contextClass, contextObject) {});
}
- public static void addRequestFilter(Object filter) {
+
+ public static void addRequestFilter (Object filter) {
resourceConfig.getContainerRequestFilters().add(filter);
}
- public static void addResponseFilter(Object filter) {
+
+ public static void addResponseFilter (Object filter) {
resourceConfig.getContainerResponseFilters().add(filter);
}
- public static void setTestContainerFactory(
+
+ public static void setTestContainerFactory (
TestContainerFactory newTestContainerFactory) {
testContainerFactory = newTestContainerFactory;
}
+
@BeforeClass
- public static void cleanStaticVariables() {
+ public static void cleanStaticVariables () {
resourceConfig = new DefaultResourceConfig();
}
- public static void initServer() {
+
+ public static void initServer () {
AppDescriptor ad;
if (classPackages == null)
ad = new LowLevelAppDescriptor.Builder(resourceConfig).build();
@@ -94,42 +102,47 @@
tcf = new GrizzlyWebTestContainerFactory();
}
- testContainer = tcf
- .create(UriBuilder.fromUri("http://localhost/").port(9998)
- .build(), ad);
+ testContainer = tcf.create(UriBuilder.fromUri("http://localhost/")
+ .port(9998).build(), ad);
client = testContainer.getClient();
if (client == null) {
client = Client.create(ad.getClientConfig());
}
}
- public static void startServer() {
+
+ public static void startServer () {
if (testContainer != null) {
testContainer.start();
}
}
+
@AfterClass
- public static void stopServer() {
+ public static void stopServer () {
testContainer.stop();
testContainer = null;
client = null;
}
- public Client client() {
+
+ public Client client () {
return client;
}
- public URI getBaseUri() {
+
+ public URI getBaseUri () {
return testContainer.getBaseUri();
}
- public WebResource resource() {
+
+ public WebResource resource () {
return client.resource(getBaseUri());
}
+
@Before
- public void startServerBeforeFirstTestRun() {
+ public void startServerBeforeFirstTestRun () {
if (testContainer == null) {
initServer();
startServer();
diff --git a/src/test/java/de/ids_mannheim/korap/web/service/OAuth2HandlerTest.java b/src/test/java/de/ids_mannheim/korap/web/service/OAuth2HandlerTest.java
index ce7851d..0a55637 100644
--- a/src/test/java/de/ids_mannheim/korap/web/service/OAuth2HandlerTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/service/OAuth2HandlerTest.java
@@ -24,13 +24,14 @@
private static final String SCOPES = "search preferences queries account";
+
@BeforeClass
- public static void setup() throws Exception {
+ public static void setup () throws Exception {
// BeanConfiguration.loadClasspathContext("default-config.xml");
// handler = new OAuth2Handler(
// BeanConfiguration.getKustvaktContext().getPersistenceClient());
// crypto = BeanConfiguration.getKustvaktContext().getEncryption();
-// info = new ClientInfo(crypto.createID(), crypto.createToken());
+ // info = new ClientInfo(crypto.createID(), crypto.createToken());
// info.setConfidential(true);
// //todo: support for subdomains?!
// info.setUrl("http://localhost:8080/api/v0.1");
@@ -44,6 +45,7 @@
// crypto = helper.getBean(ContextHolder.KUSTVAKT_ENCRYPTION);
}
+
// @AfterClass
// public static void drop() throws KustvaktException {
// assert handler != null;
@@ -53,28 +55,29 @@
// }
@Test
- public void testStoreAuthorizationCodeThrowsNoException()
+ public void testStoreAuthorizationCodeThrowsNoException ()
throws KustvaktException {
String auth_code = helper().getContext().getEncryption().createToken();
- AuthCodeInfo codeInfo = new AuthCodeInfo(info.getClient_id(),
- auth_code);
+ AuthCodeInfo codeInfo = new AuthCodeInfo(info.getClient_id(), auth_code);
codeInfo.setScopes(SCOPES);
- OAuth2Handler handler = new OAuth2Handler(helper().getContext().getPersistenceClient());
+ OAuth2Handler handler = new OAuth2Handler(helper().getContext()
+ .getPersistenceClient());
handler.authorize(codeInfo, helper().getUser());
codeInfo = handler.getAuthorization(auth_code);
Assert.assertNotNull("client is null!", codeInfo);
}
+
@Test
- public void testAuthorizationCodeRemoveThrowsNoException()
+ public void testAuthorizationCodeRemoveThrowsNoException ()
throws KustvaktException {
String auth_code = helper().getContext().getEncryption().createToken();
- AuthCodeInfo codeInfo = new AuthCodeInfo(info.getClient_id(),
- auth_code);
+ AuthCodeInfo codeInfo = new AuthCodeInfo(info.getClient_id(), auth_code);
codeInfo.setScopes(SCOPES);
- OAuth2Handler handler = new OAuth2Handler(helper().getContext().getPersistenceClient());
+ OAuth2Handler handler = new OAuth2Handler(helper().getContext()
+ .getPersistenceClient());
handler.authorize(codeInfo, helper().getUser());
String t = helper().getContext().getEncryption().createToken();
String refresh = helper().getContext().getEncryption().createToken();
@@ -87,43 +90,49 @@
Assert.assertNull("clearing authorization failed", c2);
}
+
@Test
- public void testTokenEndpointRedirect() {
+ public void testTokenEndpointRedirect () {
}
+
@Test
- public void testStoreAccessCodeViaAuthCodeThrowsNoException() {
+ public void testStoreAccessCodeViaAuthCodeThrowsNoException () {
String auth_code = helper().getContext().getEncryption().createToken();
- AuthCodeInfo codeInfo = new AuthCodeInfo(info.getClient_id(),
- auth_code);
+ AuthCodeInfo codeInfo = new AuthCodeInfo(info.getClient_id(), auth_code);
codeInfo.setScopes(SCOPES);
}
+
@Test
- public void testDeleteAccessCodesByUserDeleteCascade() {
+ public void testDeleteAccessCodesByUserDeleteCascade () {
}
+
@Test
- public void testAccessTokenbyUserDeleteCascade() {
+ public void testAccessTokenbyUserDeleteCascade () {
}
+
@Test
- public void testRefreshToken() {
+ public void testRefreshToken () {
}
+
// fixme: exception thrown?!
@Test
- public void testAccessTokenExpired() {
+ public void testAccessTokenExpired () {
}
+
@Override
- public void initMethod() throws KustvaktException {
+ public void initMethod () throws KustvaktException {
helper().setupAccount();
EncryptionIface crypto = helper().getContext().getEncryption();
diff --git a/src/test/java/de/ids_mannheim/korap/web/service/full/AuthServiceTest.java b/src/test/java/de/ids_mannheim/korap/web/service/full/AuthServiceTest.java
index 9a3f782..b394d68 100644
--- a/src/test/java/de/ids_mannheim/korap/web/service/full/AuthServiceTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/service/full/AuthServiceTest.java
@@ -14,7 +14,7 @@
public class AuthServiceTest extends FastJerseyTest {
@BeforeClass
- public static void configure() throws Exception {
+ public static void configure () throws Exception {
FastJerseyTest.setPackages("de.ids_mannheim.korap.web.service",
"de.ids_mannheim.korap.web.filter",
"de.ids_mannheim.korap.web.utils");
@@ -22,28 +22,32 @@
@Override
- public void initMethod() throws KustvaktException {
+ public void initMethod () throws KustvaktException {
helper().setupAccount();
}
+
@Test
- public void testBasicHttp() {
+ public void testBasicHttp () {
User user = helper().getUser();
}
+
@Test
- public void testBasicLogout(){
+ public void testBasicLogout () {
}
+
@Test
- public void testSessionTokenLogin() {
+ public void testSessionTokenLogin () {
}
+
@Test
- public void testSessionTokenLogout() {
+ public void testSessionTokenLogout () {
}
diff --git a/src/test/java/de/ids_mannheim/korap/web/service/full/FilterTest.java b/src/test/java/de/ids_mannheim/korap/web/service/full/FilterTest.java
index ac05e24..5392eec 100644
--- a/src/test/java/de/ids_mannheim/korap/web/service/full/FilterTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/service/full/FilterTest.java
@@ -17,40 +17,49 @@
public class FilterTest extends FastJerseyTest {
@BeforeClass
- public static void setup() throws Exception {
+ 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().path(getAPIVersion()).path("user/info")
- .header(Attributes.AUTHORIZATION, BasicHttpAuth
- .encode(TestHelper.getUserCredentials()[0],
+ public void testTestUserAuth () {
+ ClientResponse resp = resource()
+ .path(getAPIVersion())
+ .path("user/info")
+ .header(Attributes.AUTHORIZATION,
+ BasicHttpAuth.encode(
+ TestHelper.getUserCredentials()[0],
TestHelper.getUserCredentials()[1]))
.get(ClientResponse.class);
assert resp.getStatus() == Response.SC_OK;
}
+
@Test
- public void testDemoAuth() {
- ClientResponse resp = resource().path(getAPIVersion()).path("user/info")
- .get(ClientResponse.class);
+ public void testDemoAuth () {
+ ClientResponse resp = resource().path(getAPIVersion())
+ .path("user/info").get(ClientResponse.class);
assert resp.getStatus() == Response.SC_OK;
}
+
@Test
- public void testUnauthorizedAuth() {
- ClientResponse resp = resource().path(getAPIVersion()).path("user/info")
+ public void testUnauthorizedAuth () {
+ ClientResponse resp = resource()
+ .path(getAPIVersion())
+ .path("user/info")
.header(Attributes.AUTHORIZATION,
BasicHttpAuth.encode("kustvakt", "kustvakt2015"))
.get(ClientResponse.class);
assert resp.getStatus() == Response.SC_UNAUTHORIZED;
}
+
@Override
- public void initMethod() throws KustvaktException {
+ public void initMethod () throws KustvaktException {
helper().setupAccount();
}
}
diff --git a/src/test/java/de/ids_mannheim/korap/web/service/full/KustvaktCoreRestTest.java b/src/test/java/de/ids_mannheim/korap/web/service/full/KustvaktCoreRestTest.java
index f227ba3..ec25c17 100644
--- a/src/test/java/de/ids_mannheim/korap/web/service/full/KustvaktCoreRestTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/service/full/KustvaktCoreRestTest.java
@@ -20,22 +20,24 @@
public class KustvaktCoreRestTest extends FastJerseyTest {
@BeforeClass
- public static void configure() {
+ public static void configure () {
FastJerseyTest.setPackages("de.ids_mannheim.korap.web.service.light",
"de.ids_mannheim.korap.web.filter",
"de.ids_mannheim.korap.web.utils");
}
+
// @Test
- public void testFieldsInSearch() {
+ public void testFieldsInSearch () {
ClientResponse response = resource().path(getAPIVersion())
.path("search").queryParam("q", "[base=Wort]")
.queryParam("ql", "poliqarp").get(ClientResponse.class);
assert ClientResponse.Status.OK.getStatusCode() == response.getStatus();
}
+
@Test
- public void testQuery() {
+ public void testQuery () {
ClientResponse response = resource().path(getAPIVersion())
.path("search").queryParam("q", "[base=Wort]")
.queryParam("ql", "poliqarp").get(ClientResponse.class);
@@ -44,8 +46,9 @@
assert ClientResponse.Status.OK.getStatusCode() == response.getStatus();
}
+
@Test
- public void testQueryRaw() {
+ public void testQueryRaw () {
QuerySerializer s = new QuerySerializer();
s.setQuery("[base=Wort]", "poliqarp");
@@ -56,29 +59,34 @@
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(getAPIVersion())
- .get(ClientResponse.class);
+ public void testGetMatchInfoThrowsNoException () {
+ ClientResponse response = resource().path(getAPIVersion()).get(
+ ClientResponse.class);
}
+
// @Test
- public void testGetStatsThrowsNoException() {
+ public void testGetStatsThrowsNoException () {
CollectionQueryProcessor pr = new CollectionQueryProcessor();
pr.process("corpusID=WPD & textClass=Sport");
Map map = new LinkedHashMap();
map.put("collection", pr.getRequestMap());
- ClientResponse response = resource().path(getAPIVersion()).path("stats")
+ ClientResponse response = resource().path(getAPIVersion())
+ .path("stats")
.post(ClientResponse.class, JsonUtils.toJSON(map));
assert ClientResponse.Status.OK.getStatusCode() == response.getStatus();
}
+
@Test
@Ignore
- public void testGetStats2ThrowsNoException() {
- ClientResponse response = resource().path(getAPIVersion()).path("stats")
+ public void testGetStats2ThrowsNoException () {
+ ClientResponse response = resource().path(getAPIVersion())
+ .path("stats")
.post(ClientResponse.class, "creationDate in 1787");
String ent = response.getEntity(String.class);
assert ClientResponse.Status.OK.getStatusCode() == response.getStatus();
@@ -87,8 +95,9 @@
// System.out.println("STATS ENTITY " + ent);
}
+
// @Test
- public void testBuildQueryThrowsNoException() {
+ public void testBuildQueryThrowsNoException () {
ClientResponse response = resource().path(getAPIVersion())
.path("search").queryParam("q", "[base=Haus & surface=Hauses]")
.queryParam("ql", "poliqarp").queryParam("cutOff", "true")
@@ -96,8 +105,9 @@
assert ClientResponse.Status.OK.getStatusCode() == response.getStatus();
}
+
// @Test
- public void testQueryByNameThrowsNoException() {
+ public void testQueryByNameThrowsNoException () {
ClientResponse response = resource().path(getAPIVersion())
.path("corpus").path("WPD").path("search")
.queryParam("q", "[base=Haus & surface=Hauses]")
@@ -106,8 +116,9 @@
System.out.println("RESPONSE " + response.getEntity(String.class));
}
+
@Override
- public void initMethod() throws KustvaktException {
+ public void initMethod () throws KustvaktException {
helper().setupAccount();
}
}
diff --git a/src/test/java/de/ids_mannheim/korap/web/service/full/OAuth2EndpointTest.java b/src/test/java/de/ids_mannheim/korap/web/service/full/OAuth2EndpointTest.java
index 9870cea..60b7267 100644
--- a/src/test/java/de/ids_mannheim/korap/web/service/full/OAuth2EndpointTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/service/full/OAuth2EndpointTest.java
@@ -20,25 +20,28 @@
public class OAuth2EndpointTest extends FastJerseyTest {
@BeforeClass
- public static void configure() throws Exception {
+ public static void configure () throws Exception {
FastJerseyTest.setPackages("de.ids_mannheim.korap.web.service",
"de.ids_mannheim.korap.web.filter",
"de.ids_mannheim.korap.web.utils");
}
+
@Test
- public void init() {
+ public void init () {
}
+
@Override
- public void initMethod() throws KustvaktException {
+ public void initMethod () throws KustvaktException {
helper().setupAccount();
}
+
@Test
@Ignore
- public void testAuthorizeClient() {
+ public void testAuthorizeClient () {
ClientResponse response = resource().path("v0.1").path("oauth2")
.path("register")
.queryParam("redirect_url", "korap.ids-mannheim.de/redirect")
@@ -47,9 +50,10 @@
assert response.getStatus() == ClientResponse.Status.OK.getStatusCode();
}
+
@Test
@Ignore
- public void testRevokeClient() {
+ public void testRevokeClient () {
ClientResponse response = resource().path("v0.1").path("oauth2")
.path("register")
.queryParam("redirect_url", "korap.ids-mannheim.de/redirect")
@@ -60,9 +64,10 @@
}
+
@Test
@Ignore
- public void authenticate() {
+ public void authenticate () {
String[] cred = TestHelper.getUserCredentials();
String enc = BasicHttpAuth.encode(cred[0], cred[1]);
ClientResponse response = resource().path("v0.1").path("oauth2")
diff --git a/src/test/java/de/ids_mannheim/korap/web/service/full/ResourceRemoteApiTest.java b/src/test/java/de/ids_mannheim/korap/web/service/full/ResourceRemoteApiTest.java
index bcf5f9a..95d7470 100644
--- a/src/test/java/de/ids_mannheim/korap/web/service/full/ResourceRemoteApiTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/service/full/ResourceRemoteApiTest.java
@@ -11,7 +11,7 @@
@Test
- public void testResourceGetFromDemo() {
+ public void testResourceGetFromDemo () {
}
}
diff --git a/src/test/java/de/ids_mannheim/korap/web/service/full/ResourceServiceTest.java b/src/test/java/de/ids_mannheim/korap/web/service/full/ResourceServiceTest.java
index f3cf778..d9e761c 100644
--- a/src/test/java/de/ids_mannheim/korap/web/service/full/ResourceServiceTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/service/full/ResourceServiceTest.java
@@ -23,17 +23,19 @@
public class ResourceServiceTest extends FastJerseyTest {
@BeforeClass
- public static void configure() throws Exception {
+ 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
- @Ignore
- public void testSearchSimple() {
- ClientResponse response = resource().path(getAPIVersion())
- .path("search").queryParam("q", "[orth=das]")
+ public void testSearchSimple () {
+ ClientResponse response = resource()
+ .path(getAPIVersion())
+ .path("search")
+ .queryParam("q", "[orth=das]")
.queryParam("ql", "poliqarp")
// .queryParam("cq", "corpusID=GOE")
.header(Attributes.AUTHORIZATION,
@@ -43,15 +45,17 @@
response.getStatus());
JsonNode node = JsonUtils.readTree(response.getEntity(String.class));
- Assert.assertNotNull(node);
+ assertNotNull(node);
assertNotEquals(0, node.path("matches").size());
}
+
@Test
- @Ignore
- public void testCollectionGet() {
- ClientResponse response = resource().path(getAPIVersion())
- .path("collection").header(Attributes.AUTHORIZATION,
+ public void testCollectionGet () {
+ ClientResponse response = resource()
+ .path(getAPIVersion())
+ .path("collection")
+ .header(Attributes.AUTHORIZATION,
BasicHttpAuth.encode("kustvakt", "kustvakt2015"))
.get(ClientResponse.class);
assertEquals(ClientResponse.Status.OK.getStatusCode(),
@@ -61,49 +65,58 @@
assertNotEquals(0, node.size());
}
+
@Test
- @Ignore
- public void testStats() {
- ClientResponse response = resource().path(getAPIVersion())
- .path("collection").header(Attributes.AUTHORIZATION,
+ public void testStats () {
+ ClientResponse response = resource()
+ .path(getAPIVersion())
+ .path("collection")
+ .header(Attributes.AUTHORIZATION,
BasicHttpAuth.encode("kustvakt", "kustvakt2015"))
.get(ClientResponse.class);
assertEquals(ClientResponse.Status.OK.getStatusCode(),
response.getStatus());
JsonNode node = JsonUtils.readTree(response.getEntity(String.class));
- Assert.assertNotNull(node);
+ assertNotNull(node);
+ assertNotEquals(0, node.size());
- System.out.println("-------------------------------");
- System.out.println("NODE COLLECTIONS" + node);
String id = node.path(0).path("id").asText();
- System.out.println("ID IS " + id);
- System.out.println("FROM NODE " + node);
- response = resource().path(getAPIVersion()).path("collection").path(id)
- .path("stats").header(Attributes.AUTHORIZATION,
+ response = resource()
+ .path(getAPIVersion())
+ .path("collection")
+ .path(id)
+ .path("stats")
+ .header(Attributes.AUTHORIZATION,
BasicHttpAuth.encode("kustvakt", "kustvakt2015"))
.get(ClientResponse.class);
assertEquals(ClientResponse.Status.OK.getStatusCode(),
response.getStatus());
node = JsonUtils.readTree(response.getEntity(String.class));
- Assert.assertNotNull(node);
+ assertNotNull(node);
int docs = node.path("documents").asInt();
- System.out.println("-------------------------------");
- System.out.println("NODE " + node);
assertNotEquals(0, docs);
Assert.assertTrue(docs < 15);
}
+
@Test
- public void testResourceStore() {
+ public void testResourceStore () {
}
+
+ @Test
+ public void testResourceDelete () {
+
+ }
+
+
@Test
@Ignore
- public void testSerializationQueryInCollection() {
+ public void testSerializationQueryInCollection () {
ClientResponse response = resource().path(getAPIVersion())
.path("corpus/WPD/search").queryParam("q", "[base=Haus]")
.queryParam("ql", "poliqarp").queryParam("context", "base/s:s")
@@ -113,8 +126,9 @@
System.out.println("Entity 1 " + ent);
}
+
@Test
- public void testSerializationQueryPublic() {
+ public void testSerializationQueryPublic () {
ClientResponse response = resource().path(getAPIVersion())
.path("search").queryParam("q", "[base=Haus]")
.queryParam("ql", "poliqarp").queryParam("context", "sentence")
@@ -125,8 +139,9 @@
System.out.println(node);
}
+
@Test
- public void testQuery() {
+ public void testQuery () {
ClientResponse response = resource().path(getAPIVersion())
.path("search").queryParam("q", "[base=Haus]")
.queryParam("ql", "poliqarp").queryParam("context", "sentence")
@@ -138,24 +153,33 @@
assertNotEquals("${project.version}", "/meta/version");
}
+
@Test
@Ignore
- public void testSerializationMeta() {
+ public void testSerializationMeta () {
ClientResponse response = resource().path(getAPIVersion())
.path("search").queryParam("context", "sentence")
.queryParam("q", "[pos=ADJA]").queryParam("ql", "poliqarp")
.get(ClientResponse.class);
}
+
@Test
@Ignore
- public void testSerializationCollection() {
+ public void testSerializationCollection () {
ClientResponse response = resource().path(getAPIVersion()).path("")
.get(ClientResponse.class);
}
+
+ @Test
+ public void testMatchInfo () {
+
+ }
+
+
@Override
- public void initMethod() throws KustvaktException {
+ public void initMethod () throws KustvaktException {
helper().runBootInterfaces();
}
}