Split assets test from service test
Change-Id: I87276d3827bcd680950f4909b37b78f3514f31d4
diff --git a/plugin/src/test/java/de/ids_mannheim/korap/plkexport/AssetTest.java b/plugin/src/test/java/de/ids_mannheim/korap/plkexport/AssetTest.java
new file mode 100644
index 0000000..a03e508
--- /dev/null
+++ b/plugin/src/test/java/de/ids_mannheim/korap/plkexport/AssetTest.java
@@ -0,0 +1,92 @@
+package de.ids_mannheim.korap.plkexport;
+
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.fail;
+
+import org.glassfish.jersey.server.ResourceConfig;
+import org.glassfish.jersey.test.JerseyTest;
+
+import java.util.Properties;
+
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.core.Application;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedHashMap;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+
+public class AssetTest extends JerseyTest {
+
+ @Override
+ protected Application configure () {
+ return new ResourceConfig(IdsExportService.class);
+ }
+
+ @Test
+ public void testFormHtml () {
+ Response responsehtml = target("/export").request()
+ .get();
+ assertEquals("HTTP Code",
+ Status.OK.getStatusCode(), responsehtml.getStatus());
+ String str = responsehtml.readEntity(String.class);
+ assertTrue("HTTP Body", str.contains("<title>Export</title>"));
+ assertTrue("Assets", str.contains("<script src=\"https://korap.ids-mannheim.de/js"));
+ assertTrue("Assets", str.contains("<link href=\"https://korap.ids-mannheim.de/css"));
+ assertFalse("Errors", str.contains("dynCall("));
+ }
+
+ @Test
+ public void testFormHtmlAssets () {
+ Properties properties = ExWSConf.properties(null);
+ String hostTemp = properties.getProperty("asset.host");
+ String pathTemp = properties.getProperty("asset.path");
+ properties.setProperty("asset.host", "ids-mannheim.example");
+ properties.setProperty("asset.path", "/instance/test");
+
+ Response responsehtml = target("/export").request()
+ .get();
+ assertEquals("HTTP Code",
+ Status.OK.getStatusCode(), responsehtml.getStatus());
+ String str = responsehtml.readEntity(String.class);
+ assertTrue("HTTP Body", str.contains("<title>Export</title>"));
+ assertTrue("Assets", str.contains("<script src=\"https://ids-mannheim.example/instance/test/js"));
+ assertTrue("Assets", str.contains("<link href=\"https://ids-mannheim.example/instance/test/css"));
+ assertFalse("Errors", str.contains("dynCall("));
+
+ properties.setProperty("asset.host", hostTemp);
+ properties.setProperty("asset.path", pathTemp != null ? pathTemp : "");
+ }
+
+ @Test
+ public void testFormHtmlExporters () {
+ Response responsehtml = target("/export").request()
+ .get();
+ assertEquals("HTTP Code",
+ Status.OK.getStatusCode(), responsehtml.getStatus());
+ String str = responsehtml.readEntity(String.class);
+ assertTrue("HTTP Body", str.contains("<title>Export</title>"));
+ assertTrue("RTF", str.contains("id=\"formatrtf\""));
+ assertTrue("RTF-Label", str.contains("for=\"formatrtf\""));
+ assertTrue("JSON", str.contains("id=\"formatjson\""));
+ assertTrue("JSON-Label", str.contains("for=\"formatjson\""));
+ assertTrue("CSV", str.contains("id=\"formatcsv\""));
+ assertTrue("CSV-Label", str.contains("for=\"formatcsv\""));
+ assertFalse("DOC", str.contains("id=\"formatdoc\""));
+ }
+
+
+ @Test
+ public void testJS () {
+ Response responsejs = target("/export.js").request()
+ .get();
+ assertEquals("HTTP Code",
+ Status.OK.getStatusCode(), responsejs.getStatus());
+ String str = responsejs.readEntity(String.class);
+
+ assertTrue("HTTP Body", str.contains("pluginit"));
+ }
+};
diff --git a/plugin/src/test/java/de/ids_mannheim/korap/plkexport/CsvExportTest.java b/plugin/src/test/java/de/ids_mannheim/korap/plkexport/CsvExporterTest.java
similarity index 98%
rename from plugin/src/test/java/de/ids_mannheim/korap/plkexport/CsvExportTest.java
rename to plugin/src/test/java/de/ids_mannheim/korap/plkexport/CsvExporterTest.java
index 076451d..528c63f 100644
--- a/plugin/src/test/java/de/ids_mannheim/korap/plkexport/CsvExportTest.java
+++ b/plugin/src/test/java/de/ids_mannheim/korap/plkexport/CsvExporterTest.java
@@ -11,7 +11,7 @@
import javax.ws.rs.core.Response;
-public class CsvExportTest {
+public class CsvExporterTest {
@Test
public void testInit () throws IOException {
diff --git a/plugin/src/test/java/de/ids_mannheim/korap/plkexport/IdsExportServiceTest.java b/plugin/src/test/java/de/ids_mannheim/korap/plkexport/IdsExportServiceTest.java
index 8ead0e0..e3654a9 100644
--- a/plugin/src/test/java/de/ids_mannheim/korap/plkexport/IdsExportServiceTest.java
+++ b/plugin/src/test/java/de/ids_mannheim/korap/plkexport/IdsExportServiceTest.java
@@ -1,5 +1,6 @@
package de.ids_mannheim.korap.plkexport;
+import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertFalse;
@@ -37,7 +38,6 @@
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
-import org.junit.Test;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -57,6 +57,7 @@
private static MockServerClient mockClient;
private ObjectMapper mapper = new ObjectMapper();
+ // Cell split for RTF info table
private static final String CELLSPLIT = "\\cell\\cf0\\fs18\\b0\\f1 ";
@BeforeClass
@@ -149,70 +150,6 @@
Status.BAD_REQUEST.getStatusCode(), responsejson.getStatus());
}
-
- @Test
- public void testFormHtml () {
- Response responsehtml = target("/export").request()
- .get();
- assertEquals("HTTP Code",
- Status.OK.getStatusCode(), responsehtml.getStatus());
- String str = responsehtml.readEntity(String.class);
- assertTrue("HTTP Body", str.contains("<title>Export</title>"));
- assertTrue("Assets", str.contains("<script src=\"https://korap.ids-mannheim.de/js"));
- assertTrue("Assets", str.contains("<link href=\"https://korap.ids-mannheim.de/css"));
- assertFalse("Errors", str.contains("dynCall("));
- }
-
- @Test
- public void testFormHtmlAssets () {
- Properties properties = ExWSConf.properties(null);
- String hostTemp = properties.getProperty("asset.host");
- String pathTemp = properties.getProperty("asset.path");
- properties.setProperty("asset.host", "ids-mannheim.example");
- properties.setProperty("asset.path", "/instance/test");
-
- Response responsehtml = target("/export").request()
- .get();
- assertEquals("HTTP Code",
- Status.OK.getStatusCode(), responsehtml.getStatus());
- String str = responsehtml.readEntity(String.class);
- assertTrue("HTTP Body", str.contains("<title>Export</title>"));
- assertTrue("Assets", str.contains("<script src=\"https://ids-mannheim.example/instance/test/js"));
- assertTrue("Assets", str.contains("<link href=\"https://ids-mannheim.example/instance/test/css"));
- assertFalse("Errors", str.contains("dynCall("));
-
- properties.setProperty("asset.host", hostTemp);
- properties.setProperty("asset.path", pathTemp != null ? pathTemp : "");
- }
-
- @Test
- public void testFormHtmlExporters () {
- Response responsehtml = target("/export").request()
- .get();
- assertEquals("HTTP Code",
- Status.OK.getStatusCode(), responsehtml.getStatus());
- String str = responsehtml.readEntity(String.class);
- assertTrue("HTTP Body", str.contains("<title>Export</title>"));
- assertTrue("RTF", str.contains("id=\"formatrtf\""));
- assertTrue("RTF-Label", str.contains("for=\"formatrtf\""));
- assertTrue("JSON", str.contains("id=\"formatjson\""));
- assertTrue("JSON-Label", str.contains("for=\"formatjson\""));
- assertTrue("CSV", str.contains("id=\"formatcsv\""));
- assertTrue("CSV-Label", str.contains("for=\"formatcsv\""));
- assertFalse("DOC", str.contains("id=\"formatdoc\""));
- }
-
-
- @Test
- public void testJS () {
- Response responsejs = target("/export.js").request()
- .get();
- assertEquals("HTTP Code",
- Status.OK.getStatusCode(), responsejs.getStatus());
- String str = responsejs.readEntity(String.class);
-
- assertTrue("HTTP Body", str.contains("pluginit"));
- }
@Test
public void testExportWsJsonEmpty () {
diff --git a/plugin/src/test/java/de/ids_mannheim/korap/plkexport/JsonExportTest.java b/plugin/src/test/java/de/ids_mannheim/korap/plkexport/JsonExporterTest.java
similarity index 98%
rename from plugin/src/test/java/de/ids_mannheim/korap/plkexport/JsonExportTest.java
rename to plugin/src/test/java/de/ids_mannheim/korap/plkexport/JsonExporterTest.java
index 4f5e284..4bea7db 100644
--- a/plugin/src/test/java/de/ids_mannheim/korap/plkexport/JsonExportTest.java
+++ b/plugin/src/test/java/de/ids_mannheim/korap/plkexport/JsonExporterTest.java
@@ -14,7 +14,7 @@
import javax.ws.rs.core.Response;
-public class JsonExportTest {
+public class JsonExporterTest {
@Test
public void testInit () throws IOException {
diff --git a/plugin/src/test/java/de/ids_mannheim/korap/plkexport/RtfExportTest.java b/plugin/src/test/java/de/ids_mannheim/korap/plkexport/RtfExporterTest.java
similarity index 98%
rename from plugin/src/test/java/de/ids_mannheim/korap/plkexport/RtfExportTest.java
rename to plugin/src/test/java/de/ids_mannheim/korap/plkexport/RtfExporterTest.java
index 33eb787..a146845 100644
--- a/plugin/src/test/java/de/ids_mannheim/korap/plkexport/RtfExportTest.java
+++ b/plugin/src/test/java/de/ids_mannheim/korap/plkexport/RtfExporterTest.java
@@ -11,7 +11,7 @@
import javax.ws.rs.core.Response;
-public class RtfExportTest {
+public class RtfExporterTest {
@Test
public void testInit () throws IOException {