Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Taal2014-07-02 21:45:46 +0000
committerMartin Taal2014-07-02 21:45:46 +0000
commitbc198403bc4e5b721e451aa32cc94899a7625798 (patch)
tree03b922aedca0e3bd79acc1ffb8eb042f0e5e1a1f
parent81bd1f748278af708d70d4c7a45808745ffded47 (diff)
downloadorg.eclipse.emf.texo-bc198403bc4e5b721e451aa32cc94899a7625798.tar.gz
org.eclipse.emf.texo-bc198403bc4e5b721e451aa32cc94899a7625798.tar.xz
org.eclipse.emf.texo-bc198403bc4e5b721e451aa32cc94899a7625798.zip
Change tests to run on Luna
-rw-r--r--tests/org.eclipse.emf.texo.server.test/META-INF/MANIFEST.MF18
-rw-r--r--tests/org.eclipse.emf.texo.server.test/src/org/eclipse/emf/texo/server/test/ws/BaseWSWebTest.java59
-rw-r--r--tests/org.eclipse.emf.texo.server.test/src/org/eclipse/emf/texo/server/test/ws/WSMainTest.java18
-rw-r--r--tests/org.eclipse.emf.texo.xml.test/META-INF/MANIFEST.MF2
4 files changed, 45 insertions, 52 deletions
diff --git a/tests/org.eclipse.emf.texo.server.test/META-INF/MANIFEST.MF b/tests/org.eclipse.emf.texo.server.test/META-INF/MANIFEST.MF
index 9f17c324..9348e57f 100644
--- a/tests/org.eclipse.emf.texo.server.test/META-INF/MANIFEST.MF
+++ b/tests/org.eclipse.emf.texo.server.test/META-INF/MANIFEST.MF
@@ -20,16 +20,16 @@ Require-Bundle: org.eclipse.emf.texo.xml;bundle-version="[0.1.0,1.1.0)",
org.eclipse.persistence.antlr;bundle-version="[3.0.0,4.0.0)",
org.hsqldb;bundle-version="[2.0.0,3.0.0)",
javax.persistence;bundle-version="[2.0.0,3.0.0)",
- org.eclipse.jetty.server;bundle-version="[7.0.0,9.0.0)",
- org.eclipse.jetty.util;bundle-version="[7.0.0,9.0.0)",
- org.eclipse.jetty.servlet;bundle-version="[7.0.0,9.0.0)",
+ org.eclipse.jetty.server;bundle-version="[7.0.0,10.0.0)",
+ org.eclipse.jetty.util;bundle-version="[7.0.0,10.0.0)",
+ org.eclipse.jetty.servlet;bundle-version="[7.0.0,10.0.0)",
javax.servlet;bundle-version="[3.0.0,4.0.0)",
- org.eclipse.jetty.client;bundle-version="[8.1.0,9.0.0)",
- org.eclipse.jetty.http;bundle-version="[8.0.0,9.0.0)",
- org.eclipse.jetty.io;bundle-version="[8.0.0,9.0.0)",
- org.eclipse.jetty.security;bundle-version="[8.0.0,9.0.0)",
- org.eclipse.jetty.server;bundle-version="[8.0.0,9.0.0)",
- org.eclipse.jetty.continuation;bundle-version="[8.0.0,9.0.0)",
+ org.eclipse.jetty.client;bundle-version="[8.1.0,10.0.0)",
+ org.eclipse.jetty.http;bundle-version="[8.0.0,10.0.0)",
+ org.eclipse.jetty.io;bundle-version="[8.0.0,10.0.0)",
+ org.eclipse.jetty.security;bundle-version="[8.0.0,10.0.0)",
+ org.eclipse.jetty.server;bundle-version="[8.0.0,10.0.0)",
+ org.eclipse.jetty.continuation;bundle-version="[8.0.0,10.0.0)",
org.json;bundle-version="[1.0.0,2.1.0)",
org.eclipse.emf.texo.json;bundle-version="[0.1.0,1.1.0)",
org.eclipse.emf.texo.test.emfmodel;bundle-version="[0.1.0,1.1.0)",
diff --git a/tests/org.eclipse.emf.texo.server.test/src/org/eclipse/emf/texo/server/test/ws/BaseWSWebTest.java b/tests/org.eclipse.emf.texo.server.test/src/org/eclipse/emf/texo/server/test/ws/BaseWSWebTest.java
index c860235c..91280aed 100644
--- a/tests/org.eclipse.emf.texo.server.test/src/org/eclipse/emf/texo/server/test/ws/BaseWSWebTest.java
+++ b/tests/org.eclipse.emf.texo.server.test/src/org/eclipse/emf/texo/server/test/ws/BaseWSWebTest.java
@@ -34,10 +34,11 @@ import org.eclipse.emf.texo.utils.ModelUtils;
import org.eclipse.emf.texo.xml.ModelXMLLoader;
import org.eclipse.emf.texo.xml.ModelXMLSaver;
import org.eclipse.emf.texo.xml.XMLWebServiceObjectResolver;
-import org.eclipse.jetty.client.ContentExchange;
import org.eclipse.jetty.client.HttpClient;
-import org.eclipse.jetty.http.HttpMethods;
-import org.eclipse.jetty.io.ByteArrayBuffer;
+import org.eclipse.jetty.client.api.ContentResponse;
+import org.eclipse.jetty.client.api.Request;
+import org.eclipse.jetty.client.util.BytesContentProvider;
+import org.eclipse.jetty.http.HttpMethod;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
@@ -65,7 +66,6 @@ public abstract class BaseWSWebTest extends BaseTest {
stopClient();
}
httpClient = new HttpClient();
- httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
httpClient.start();
}
@@ -93,27 +93,20 @@ public abstract class BaseWSWebTest extends BaseTest {
doServerTearDown();
}
- protected ContentExchange doRequest(String wsPartOfUrl, String method, String content) throws Exception {
+ protected ContentResponse doRequest(String wsPartOfUrl, HttpMethod method, String content) throws Exception {
if (httpClient == null) {
startClient();
}
- ContentExchange contentExchange = new ContentExchange();
- contentExchange.setURL(getURL() + "/" + encodeWsPart(wsPartOfUrl)); //$NON-NLS-1$
- contentExchange.setMethod(method);
-
- System.err.println(">>>>>>>>>>>>>>>>>>>>>");
- System.err.println(getURL() + "/" + wsPartOfUrl);
- System.err.println(method);
- System.err.println("<<<<<<<<<<<<<<<<<<<<<");
+ final Request request = httpClient.newRequest(getURL() + "/" + encodeWsPart(wsPartOfUrl)); //$NON-NLS-1$
+ request.method(method);
if (content != null) {
- contentExchange.setRequestContent(new ByteArrayBuffer(content.getBytes(CHARACTER_ENCODING)));
+ request.content(new BytesContentProvider(content.getBytes(CHARACTER_ENCODING)), "text/plain");
}
- httpClient.send(contentExchange);
- contentExchange.waitForDone();
- return contentExchange;
+ final ContentResponse response = request.send();
+ return response;
}
private String encodeWsPart(String wsPart) throws Exception {
@@ -133,32 +126,32 @@ public abstract class BaseWSWebTest extends BaseTest {
protected void doDeleteRequest(String wsPart, int expectedResponse) {
try {
- final ContentExchange contentExchange = doRequest(wsPart, HttpMethods.DELETE, null);
+ final ContentResponse response = doRequest(wsPart, HttpMethod.DELETE, null);
System.err.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>");
- System.err.println(contentExchange.getResponseContent());
- Assert.assertEquals(expectedResponse, contentExchange.getResponseStatus());
+ System.err.println(response.getContent());
+ Assert.assertEquals(expectedResponse, response.getStatus());
} catch (final Exception e) {
throw new IllegalStateException(e);
}
}
protected String doContentRequest(String wsPart, String content, int expectedResponse, String expectedContent,
- String method) {
+ HttpMethod method) {
try {
- final ContentExchange contentExchange = doRequest(wsPart, method, content);
+ final ContentResponse contentResponse = doRequest(wsPart, method, content);
System.err.println(content);
- dumpError(expectedResponse, contentExchange);
+ dumpError(expectedResponse, contentResponse);
- Assert.assertEquals(expectedResponse, contentExchange.getResponseStatus());
+ Assert.assertEquals(expectedResponse, contentResponse.getStatus());
if (expectedResponse == 500) {
// no content available anyway
return ""; //$NON-NLS-1$
}
- final String retContent = contentExchange.getResponseContent();
+ final String retContent = contentResponse.getContentAsString();
System.err.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>");
System.err.println(retContent);
@@ -229,14 +222,14 @@ public abstract class BaseWSWebTest extends BaseTest {
protected String doGetRequest(String wsPart, String testContent, int responseCode) {
try {
- final ContentExchange contentExchange = doRequest(wsPart, HttpMethods.GET, null);
- dumpError(responseCode, contentExchange);
- final String content = contentExchange.getResponseContent();
+ final ContentResponse contentResponse = doRequest(wsPart, HttpMethod.GET, null);
+ dumpError(responseCode, contentResponse);
+ final String content = contentResponse.getContentAsString();
System.err.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>");
System.err.println(content);
- Assert.assertEquals(responseCode, contentExchange.getResponseStatus());
+ Assert.assertEquals(responseCode, contentResponse.getStatus());
if (testContent != null && content.indexOf(testContent) == -1) {
System.err.println(content);
Assert.fail();
@@ -247,10 +240,10 @@ public abstract class BaseWSWebTest extends BaseTest {
}
}
- private void dumpError(int expectedResponseCode, ContentExchange contentExchange) throws Exception {
- if (expectedResponseCode != contentExchange.getResponseStatus()
- && contentExchange.getResponseStatus() == HttpServletResponse.SC_INTERNAL_SERVER_ERROR) {
- final String content = contentExchange.getResponseContent();
+ private void dumpError(int expectedResponseCode, ContentResponse response) throws Exception {
+ if (expectedResponseCode != response.getStatus()
+ && response.getStatus() == HttpServletResponse.SC_INTERNAL_SERVER_ERROR) {
+ final String content = response.getContentAsString();
if (content.contains("response:error")) { //$NON-NLS-1$
final ErrorType errorType = (ErrorType) deserialize(content).get(0);
System.err.println(errorType.getMessage());
diff --git a/tests/org.eclipse.emf.texo.server.test/src/org/eclipse/emf/texo/server/test/ws/WSMainTest.java b/tests/org.eclipse.emf.texo.server.test/src/org/eclipse/emf/texo/server/test/ws/WSMainTest.java
index 1008322d..c4d37a29 100644
--- a/tests/org.eclipse.emf.texo.server.test/src/org/eclipse/emf/texo/server/test/ws/WSMainTest.java
+++ b/tests/org.eclipse.emf.texo.server.test/src/org/eclipse/emf/texo/server/test/ws/WSMainTest.java
@@ -43,7 +43,7 @@ import org.eclipse.emf.texo.test.model.samples.library.Writer;
import org.eclipse.emf.texo.test.model.samples.librarymodelclasses.model.LibraryModelFactory;
import org.eclipse.emf.texo.test.model.samples.librarymodelclasses.model.LibraryModelPackage;
import org.eclipse.emf.texo.utils.ModelUtils;
-import org.eclipse.jetty.http.HttpMethods;
+import org.eclipse.jetty.http.HttpMethod;
import org.junit.Assert;
import org.junit.Test;
@@ -192,7 +192,7 @@ public class WSMainTest extends BaseWSWebTest {
libResult.getWriters().remove(w);
libResult.setName("updated"); //$NON-NLS-1$
content = serialize(libResult);
- doContentRequest(getObjectUrlPart(libResult), content, HttpServletResponse.SC_OK, null, HttpMethods.PUT);
+ doContentRequest(getObjectUrlPart(libResult), content, HttpServletResponse.SC_OK, null, HttpMethod.PUT);
checkExists(w, false);
for (Book bk : w.getBooks()) {
checkExists(bk, false);
@@ -220,7 +220,7 @@ public class WSMainTest extends BaseWSWebTest {
w.setName("name" + i); //$NON-NLS-1$
final String content = serialize(w);
final String resultStr = doContentRequest(LibraryModelPackage.INSTANCE.getWriterEClass().getName(), content,
- HttpServletResponse.SC_OK, null, HttpMethods.POST);
+ HttpServletResponse.SC_OK, null, HttpMethod.POST);
final ResultType result = (ResultType) deserialize(resultStr).get(0);
Assert.assertEquals(1, result.getInserted().size());
Assert.assertEquals(0, result.getUpdated().size());
@@ -274,7 +274,7 @@ public class WSMainTest extends BaseWSWebTest {
w.setName("name" + i); //$NON-NLS-1$
final String content = serialize(w);
doContentRequest(ModelUtils.getQualifiedNameFromEClass(LibraryModelPackage.INSTANCE.getWriterEClass()), content,
- HttpServletResponse.SC_OK, null, HttpMethods.POST);
+ HttpServletResponse.SC_OK, null, HttpMethod.POST);
}
// get all the writers which start with a 2, in total there are 11 (the ones 20-29 and 2)
@@ -329,7 +329,7 @@ public class WSMainTest extends BaseWSWebTest {
final String content = serialize(queryType);
final String resultStr = doContentRequest("?" + ServiceConstants.PARAM_RETRIEVAL + "=true", content,
- HttpServletResponse.SC_OK, null, HttpMethods.POST);
+ HttpServletResponse.SC_OK, null, HttpMethod.POST);
final ResponseType result = (ResponseType) deserialize(resultStr).get(0);
Assert.assertEquals(11, result.getTotalRows());
Assert.assertEquals(11, result.getData().size());
@@ -353,7 +353,7 @@ public class WSMainTest extends BaseWSWebTest {
final String content = serialize(queryType);
final String resultStr = doContentRequest("?" + ServiceConstants.PARAM_RETRIEVAL + "=true", content,
- HttpServletResponse.SC_OK, null, HttpMethods.POST);
+ HttpServletResponse.SC_OK, null, HttpMethod.POST);
final ResponseType result = (ResponseType) deserialize(resultStr).get(0);
Assert.assertEquals(11, result.getTotalRows());
Assert.assertEquals(11, result.getData().size());
@@ -409,7 +409,7 @@ public class WSMainTest extends BaseWSWebTest {
final String content = serialize(createTestDataInstance());
final String resultStr = doContentRequest(
ModelUtils.getQualifiedNameFromEClass(LibraryModelPackage.INSTANCE.getWriterEClass()), content,
- HttpServletResponse.SC_OK, null, HttpMethods.POST);
+ HttpServletResponse.SC_OK, null, HttpMethod.POST);
final ResultType result = (ResultType) deserialize(resultStr).get(0);
lib = (Library) result.getInserted().get(0);
Assert.assertTrue(lib.getDb_Id() != null);
@@ -434,7 +434,7 @@ public class WSMainTest extends BaseWSWebTest {
final String content = serialize(w);
final String resultStr = doContentRequest(
ModelUtils.getQualifiedNameFromEClass(LibraryModelPackage.INSTANCE.getWriterEClass()), content,
- HttpServletResponse.SC_OK, null, HttpMethods.POST);
+ HttpServletResponse.SC_OK, null, HttpMethod.POST);
final ResultType resultType = (ResultType) deserialize(resultStr).get(0);
final Writer wResult = (Writer) resultType.getUpdated().get(0);
Assert.assertNotSame(w, wResult);
@@ -461,7 +461,7 @@ public class WSMainTest extends BaseWSWebTest {
final String content = serialize(w);
final String resultStr = doContentRequest(
ModelUtils.getQualifiedNameFromEClass(LibraryModelPackage.INSTANCE.getWriterEClass()), content,
- HttpServletResponse.SC_OK, null, HttpMethods.POST);
+ HttpServletResponse.SC_OK, null, HttpMethod.POST);
final ResultType resultType = (ResultType) deserialize(resultStr).get(0);
final Writer wResult = (Writer) resultType.getUpdated().get(0);
Assert.assertNotSame(w, wResult);
diff --git a/tests/org.eclipse.emf.texo.xml.test/META-INF/MANIFEST.MF b/tests/org.eclipse.emf.texo.xml.test/META-INF/MANIFEST.MF
index e89bc6b0..bb4fe76a 100644
--- a/tests/org.eclipse.emf.texo.xml.test/META-INF/MANIFEST.MF
+++ b/tests/org.eclipse.emf.texo.xml.test/META-INF/MANIFEST.MF
@@ -14,5 +14,5 @@ Require-Bundle: org.eclipse.emf.texo.xml;bundle-version="[0.1.0,1.1.0)",
org.eclipse.emf.ecore.xmi;bundle-version="[2.5.0,3.0.0)",
org.eclipse.emf.texo.datagenerator;bundle-version="[0.1.0,1.1.0)",
org.junit;bundle-version="[4.0.0,5.1.0)",
- com.google.guava;bundle-version="[10.0.0,12.0.0)"
+ com.google.guava;bundle-version="[10.0.0,16.0.0)"
Export-Package: org.eclipse.emf.texo.xml.test;version="0.1.0"

Back to the top