import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
-
import javax.xml.bind.Unmarshaller;
+
+import org.apache.commons.httpclient.methods.DeleteMethod;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.PutMethod;
+import org.apache.commons.httpclient.methods.StringRequestEntity;
+
import org.collectionspace.services.client.TestServiceClient;
-import org.jboss.resteasy.client.ClientRequest;
import org.jboss.resteasy.client.ClientResponse;
-
import org.jboss.resteasy.plugins.providers.multipart.InputPart;
import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
protected final String WRONG_XML_SCHEMA_DATA =
XML_DECLARATION +
"<wrong_schema>wrong schema contents</wrong_schema>";
-
+ // A MIME media type character set designation for the entity bodies
+ // of PUT and POST requests. Set this to null to avoid adding a character
+ // set attribute to the MIME type in the "Content-Type:" HTTP header.
+ final String NULL_CHARSET = null;
// ---------------------------------------------------------------
// CRUD tests : CREATE tests
*
* @return An error message.
*/
- protected String invalidStatusCodeMessage(ServiceRequestType requestType, int statusCode) {
- return "Status code '" + statusCode + "' in response is NOT within the expected set: " +
- requestType.validStatusCodesAsString();
+ protected String invalidStatusCodeMessage(
+ ServiceRequestType requestType, int statusCode) {
+ return "Status code '" + statusCode +
+ "' in response is NOT within the expected set: " +
+ requestType.validStatusCodesAsString();
}
/**
protected int submitRequest(String method, String url) {
int statusCode = 0;
try{
- ClientRequest request = new ClientRequest(url);
+ TestServiceClient client = new TestServiceClient();
if(method.equals(javax.ws.rs.HttpMethod.DELETE)){
- ClientResponse res = request.delete();
- statusCode = res.getStatus();
+ DeleteMethod deleteMethod = new DeleteMethod(url);
+ statusCode = client.getHttpClient().executeMethod(deleteMethod);
}else if(method.equals(javax.ws.rs.HttpMethod.GET)){
- ClientResponse res = request.get();
- statusCode = res.getStatus();
+ GetMethod getMethod = new GetMethod(url);
+ statusCode = client.getHttpClient().executeMethod(getMethod);
}else{
// Do nothing - leave status code at default value.
}
String mediaType, String entityStr) {
int statusCode = 0;
try{
- ClientRequest request = new ClientRequest(url);
- request.body(mediaType, entityStr);
+ TestServiceClient client = new TestServiceClient();
if(method.equals(javax.ws.rs.HttpMethod.POST)){
- ClientResponse res = request.post(java.lang.String.class);
- statusCode = res.getStatus();
+ StringRequestEntity entityBody =
+ new StringRequestEntity(mediaType, entityStr, NULL_CHARSET);
+ PostMethod postMethod = new PostMethod(url);
+ postMethod.setRequestEntity(entityBody);
+ statusCode = client.getHttpClient().executeMethod(postMethod);
}else if(method.equals(javax.ws.rs.HttpMethod.PUT)){
- ClientResponse res = request.put(java.lang.String.class);
- statusCode = res.getStatus();
+ StringRequestEntity entityBody =
+ new StringRequestEntity(mediaType, entityStr, NULL_CHARSET);
+ PutMethod putMethod = new PutMethod(url);
+ putMethod.setRequestEntity(entityBody);
+ statusCode = client.getHttpClient().executeMethod(putMethod);
}else{
// Do nothing - leave status code at default value.
}