Skip to content
Snippets Groups Projects
Commit 98f22e6b authored by Thorsten Vitt's avatar Thorsten Vitt
Browse files

Unified integration tests

parent 058ffd06
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
......@@ -21,12 +22,13 @@ public abstract class AbstractIntegrationTest {
* @throws MalformedURLException
* @throws IOException
*/
protected URLConnection createRequest(final String request) throws MalformedURLException,
protected HttpURLConnection createRequest(final String request)
throws MalformedURLException,
IOException {
final URL url = new URL(System.getProperty("service.url") + request);
final URLConnection connection = url.openConnection();
connection.setConnectTimeout(360000);
return connection;
return (HttpURLConnection) connection;
}
/**
......
package info.textgrid.services.aggregator;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import junit.framework.Assert;
import org.junit.Test;
public class PdfIT extends AbstractIntegrationTest {
@Test
public void testGet() throws MalformedURLException, IOException {
final HttpURLConnection connection = createRequest("/pdf/textgrid:jfss.0");
connection.connect();
Assert.assertEquals(200, connection.getResponseCode());
Assert.assertEquals("application/pdf", connection.getContentType());
Assert.assertTrue("Response should be non-null",
readContents(connection) > 0);
}
}
package info.textgrid.services.aggregator;
import info.textgrid.services.aggregator.pdf.PDF;
import java.net.URI;
import javax.ws.rs.core.Response;
import junit.framework.Assert;
public class TestPDF {
// @Test FIXME
public void testGet() {
final PDF pdf = new PDF(TextGridRepProvider.getInstance());
final Response response = pdf.get(URI.create("textgrid:jfss.0"), null);
Assert.assertEquals(200, response.getStatus());
}
}
......@@ -3,7 +3,7 @@
import info.textgrid.services.aggregator.AbstractIntegrationTest;
import java.io.IOException;
import java.net.URLConnection;
import java.net.HttpURLConnection;
import junit.framework.Assert;
......@@ -14,11 +14,11 @@ public class HtmlIT extends AbstractIntegrationTest {
@Test
public void testGet() throws IOException {
final URLConnection connection = createRequest("/html/textgrid:jfst.0");
final HttpURLConnection connection = createRequest("/html/textgrid:jfst.0");
connection.connect();
Assert.assertEquals(200, connection.getResponseCode());
Assert.assertEquals("text/html", connection.getContentType());
final long realLength = readContents(connection);
Assert.assertTrue("Content length > 0", realLength > 0);
Assert.assertTrue("Content length > 0", readContents(connection) > 0);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment