On Oct 21, 2006, at 5:21 PM, Stephen Duncan wrote:
Your patch didn't come through to the list. Make sure to send it with
a '.txt' extension.
Ooops, I always get tripped by this :)
Ugo
Index: .
===================================================================
--- . (revision 466094)
+++ . (working copy)
@@ -42,12 +42,14 @@
import org.apache.abdera.parser.Parser;
import org.apache.abdera.parser.ParserOptions;
import org.apache.abdera.protocol.client.Client;
+import org.apache.abdera.protocol.client.ClientResponse;
import org.apache.abdera.protocol.client.CommonsClient;
import org.apache.abdera.protocol.client.RequestOptions;
-import org.apache.abdera.protocol.client.ClientResponse;
import org.apache.abdera.test.client.JettyTest;
import org.apache.abdera.util.MimeTypeHelper;
import org.apache.abdera.util.iri.IRI;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
* Test to make sure that we can operate as a simple APP client
@@ -55,6 +57,8 @@
@SuppressWarnings("serial")
public class AppTest extends JettyTest {
+ Log logger = LogFactory.getLog(AppTest.class);
+
private static Abdera abdera = new Abdera();
private static Factory getFactory() {
@@ -336,6 +340,7 @@
RequestOptions options = client.getDefaultRequestOptions();
options.setHeader("Connection", "close");
// do the introspection step
+ logger.info("Do the introspection step");
ClientResponse response =
client.get("http://localhost:8080/service",options);
assertEquals(response.getStatus(),200);
Document<Service> service_doc = response.getDocument();
@@ -347,6 +352,7 @@
assertNotNull(c.getTitle());
assertNotNull(c.getHref());
}
+ response.release();
String col_uri = getBase() + "/collections/entries";
@@ -351,6 +357,7 @@
String col_uri = getBase() + "/collections/entries";
// post a new entry
+ logger.info("Post the new entry");
response = client.post(col_uri, entry, options);
assertEquals(201, response.getStatus());
assertNotNull(response.getLocation());
@@ -357,8 +364,10 @@
assertNotNull(response.getContentLocation());
String self_uri = response.getLocation().toString();
+ response.release();
// get the collection to see if our entry is there
+ logger.info("Get the collection to see if our entry is there");
response = client.get(col_uri, options);
assertEquals(200, response.getStatus());
Document<Feed> feed_doc = response.getDocument();
@@ -363,8 +372,10 @@
assertEquals(200, response.getStatus());
Document<Feed> feed_doc = response.getDocument();
assertEquals(feed_doc.getRoot().getEntries().size(), 1);
+ response.release();
// get the entry to see if we can get it
+ logger.info("Get the entry to see if we can get it");
response = client.get(self_uri, options);
assertEquals(200, response.getStatus());
Document<Entry> entry_doc = response.getDocument();
@@ -377,12 +388,16 @@
Document<Entry> doc = response.getDocument();
entry = (Entry) doc.getRoot().clone();
entry.setTitle("New title");
+ response.release();
// submit the changed entry back to the server
+ logger.info("Submit the changed entry back to the server");
response = client.put(edit_uri, entry, options);
assertEquals(204, response.getStatus());
-
+ response.release();
+
// check to see if the entry was modified properly
+ logger.info("Check to see if the entry was modified properly");
response = client.get(self_uri, options);
assertEquals(200, response.getStatus());
entry_doc = response.getDocument();
@@ -387,14 +402,19 @@
assertEquals(200, response.getStatus());
entry_doc = response.getDocument();
assertEquals(entry_doc.getRoot().getTitle(), "New title");
+ response.release();
// delete the entry
+ logger.info("Delete the entry");
response = client.delete(edit_uri, options);
assertEquals(204, response.getStatus());
+ response.release();
// is it gone?
+ logger.info("Get the deleted entry");
response = client.get(self_uri, options);
assertEquals(404, response.getStatus());
+ response.release();
// YAY! We're a working APP client
@@ -401,6 +421,7 @@
// Now let's try to do a media post
// Post the media resource
+ logger.info("Post the media resource");
options = client.getDefaultRequestOptions();
options.setContentType("text/plain");
options.setHeader("Connection", "close");
@@ -410,8 +431,10 @@
assertNotNull(response.getContentLocation());
self_uri = response.getLocation().toString();
+ response.release();
// was an entry created?
+ logger.info("Test if entry was created");
options = client.getDefaultRequestOptions();
options.setHeader("Connection", "close");
response = client.get(self_uri, options);
@@ -428,8 +451,10 @@
doc = response.getDocument();
entry = (Entry) doc.getRoot().clone();
entry.setTitle("New title");
+ response.release();
// submit the changes
+ logger.info("Submit the changes");
options = client.getDefaultRequestOptions();
options.setContentType("application/atom+xml");
options.setHeader("Connection", "close");
@@ -435,8 +460,10 @@
options.setHeader("Connection", "close");
response = client.put(edit_uri, entry, options);
assertEquals(204, response.getStatus());
-
+ response.release();
+
// get the media resource
+ logger.info("Get the media resource");
response = client.get(media);
assertEquals(200, response.getStatus());
String mediavalue = read(response.getInputStream());
@@ -441,8 +468,10 @@
assertEquals(200, response.getStatus());
String mediavalue = read(response.getInputStream());
assertEquals(mediavalue,"test");
+ response.release();
// edit the media resource
+ logger.info("Edit the media resource");
options = client.getDefaultRequestOptions();
options.setHeader("Connection", "close");
options.setContentType("text/plain");
@@ -448,8 +477,10 @@
options.setContentType("text/plain");
response = client.put(edit_media, new
ByteArrayInputStream("TEST".getBytes()), options);
assertEquals(204, response.getStatus());
+ response.release();
// was the resource changed?
+ logger.info("Was the resource changed?");
response = client.get(media, options);
assertEquals(200, response.getStatus());
mediavalue = read(response.getInputStream());
@@ -454,19 +485,26 @@
assertEquals(200, response.getStatus());
mediavalue = read(response.getInputStream());
assertEquals(mediavalue,"TEST");
+ response.release();
// delete the entry
+ logger.info("Delete the entry");
response = client.delete(edit_uri, options);
assertEquals(204, response.getStatus());
+ response.release();
// is the entry gone?
+ logger.info("Is the entry gone?");
response = client.get(self_uri, options);
assertEquals(404, response.getStatus());
+ response.release();
// is the media resource gone?
+ logger.info("Is the media resource gone?");
options.setNoCache(true); // need to force revalidation to check
response = client.get(media, options);
assertEquals(404, response.getStatus());
+ response.release();
// YAY! We can handle media link entries