You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by js...@apache.org on 2008/10/09 08:34:01 UTC

svn commit: r703068 [3/7] - in /tuscany/branches/sca-equinox: itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/ itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/ itest/databindings/jaxb-top...

Modified: tuscany/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderEntryEntityTagsTest.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderEntryEntityTagsTest.java?rev=703068&r1=703067&r2=703068&view=diff
==============================================================================
--- tuscany/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderEntryEntityTagsTest.java (original)
+++ tuscany/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderEntryEntityTagsTest.java Wed Oct  8 23:33:54 2008
@@ -22,415 +22,456 @@
 import java.util.Date;
 
 import junit.framework.Assert;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import org.apache.tuscany.sca.binding.atom.collection.Collection;
-import org.apache.tuscany.sca.host.embedded.SCADomain;
 
 import org.apache.abdera.Abdera;
-import org.apache.abdera.i18n.iri.IRI;
 import org.apache.abdera.factory.Factory;
-import org.apache.abdera.model.Base;
+import org.apache.abdera.i18n.iri.IRI;
 import org.apache.abdera.model.Content;
 import org.apache.abdera.model.Entry;
-import org.apache.abdera.model.Feed;
-import org.apache.abdera.model.Document;
-import org.apache.abdera.model.Service;
-import org.apache.abdera.protocol.Response.ResponseType;
+import org.apache.abdera.parser.Parser;
 import org.apache.abdera.protocol.client.AbderaClient;
 import org.apache.abdera.protocol.client.ClientResponse;
 import org.apache.abdera.protocol.client.RequestOptions;
 import org.apache.abdera.protocol.client.util.BaseRequestEntity;
-import org.apache.abdera.util.EntityTag;
-import org.apache.abdera.parser.Parser;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
 
 /**
  * Tests use of server provided entry entity tags for Atom binding in Tuscany.
- * Tests conditional gets (e.g. get if-none-match) or conditional posts (post if-match)
- * using entity tags or last modified header entries. 
- * Uses the SCA provided Provider composite to act as a server.
- * Uses the Abdera provided Client to act as a client.
+ * Tests conditional gets (e.g. get if-none-match) or conditional posts (post
+ * if-match) using entity tags or last modified header entries. Uses the SCA
+ * provided Provider composite to act as a server. Uses the Abdera provided
+ * Client to act as a client.
  */
 public class ProviderEntryEntityTagsTest {
-	public final static String providerURI = "http://localhost:8084/customer";
-	protected static SCADomain scaConsumerDomain;
-	protected static SCADomain scaProviderDomain;
-	protected static CustomerClient testService;
+    public final static String providerURI = "http://localhost:8084/customer";
+    protected static Node providerNode;
     protected static Abdera abdera;
     protected static AbderaClient client;
-    protected static Parser abderaParser;    
+    protected static Parser abderaParser;
     protected static String eTag;
     protected static Date lastModified;
-    protected static final SimpleDateFormat dateFormat = new SimpleDateFormat( "EEE, dd MMM yyyy HH:mm:ss Z" ); // RFC 822 date time
+    protected static final SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z"); // RFC
+                                                                                                              // 822
+                                                                                                              // date
+                                                                                                              // time
+
+    @BeforeClass
+    public static void init() throws Exception {
+        System.out.println(">>>ProviderEntryEntityTagsTest.init");
+        String contribution = ContributionLocationHelper.getContributionLocation(AtomDeleteTestCase.class);
+        providerNode = NodeFactory.newInstance().createNode(
+                                                               "org/apache/tuscany/sca/binding/atom/Provider.composite", new Contribution("provider", contribution));
+        providerNode.start();
+        abdera = new Abdera();
+        client = new AbderaClient(abdera);
+        abderaParser = Abdera.getNewParser();
+    }
+
+    @AfterClass
+    public static void destroy() throws Exception {
+        System.out.println(">>>ProviderEntryEntityTagsTest.destroy");
+        providerNode.stop();
+        providerNode.destroy();
+    }
 
-	@BeforeClass
-	public static void init() throws Exception {
-		System.out.println(">>>ProviderEntryEntityTagsTest.init");
-		scaProviderDomain = SCADomain.newInstance("org/apache/tuscany/sca/binding/atom/Provider.composite");
-		abdera = new Abdera();
-		client = new AbderaClient(abdera);
-		abderaParser = Abdera.getNewParser();
-	}
-
-	@AfterClass
-	public static void destroy() throws Exception {
-		System.out.println(">>>ProviderEntryEntityTagsTest.destroy");
-		scaProviderDomain.close();
-	}
-
-	@Test
-	public void testPrelim() throws Exception {
-		Assert.assertNotNull(scaProviderDomain);
-		Assert.assertNotNull( client );
-	}
-	
     @Test
-	public void testEmptyCachePost() throws Exception {
-		// Pseudo-code
-		// 1) Example HTTP POST request (new entry put, new etag response)
-		// User client post request       
-		//        POST /myblog/entries HTTP/1.1
-		//        Slug: First Post
-		//        
-		//        <?xml version="1.0" ?>
-		//        <entry xmlns="http://www.w3.org/2005/Atom">
-		//          <title>Atom-Powered Robots Run Amok</title>
-		//          <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
-		//          <updated>2007-02-123T17:09:02Z</updated>
-		//          <author><name>Captain Lansing</name></author>
-		//          <content>It's something moving... solid metal</content>
-		//        </entry>
-
-		// Expected Atom server response (note unique ETag)
-		//       HTTP/1.1 201 Created
-		//       Date: Fri, 23 Feb 2007 21:17:11 GMT
-		//       Content-Length: nnn
-		//       Content-Type: application/atom+xml;type=entry
-		//       Location: http://example.org/edit/first-post.atom
-		//       Content-Location: http://example.org/edit/first-post.atom
-		//       ETag: "e180ee84f0671b1"
-		//       Last-Modified: Fri, 25 Jul 2008 14:36:44 -0500
-		// 
-		//        <?xml version="1.0" ?>
-		//        <entry xmlns="http://www.w3.org/2005/Atom">
-		//          <title>Atom-Powered Robots Run Amok</title>
-		//          <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
-		//          <updated>2007-02-123T17:09:02Z</updated>
-		//          <author><name>Captain Lansing</name></author>
-		//          <content>It's something moving... solid metal</content>
-		//        </entry>		
-		
-		// Testing of entry creation
-		Factory factory = abdera.getFactory();
-		String customerName = "Fred Farkle";
-		Entry entry = factory.newEntry();
-		entry.setTitle("customer " + customerName);
-		entry.setUpdated(new Date());
-		entry.addAuthor("Apache Tuscany");
-		// ID created by collection.
+    public void testPrelim() throws Exception {
+        Assert.assertNotNull(providerNode);
+        Assert.assertNotNull(client);
+    }
+
+    @Test
+    public void testEmptyCachePost() throws Exception {
+        // Pseudo-code
+        // 1) Example HTTP POST request (new entry put, new etag response)
+        // User client post request
+        // POST /myblog/entries HTTP/1.1
+        // Slug: First Post
+        //        
+        // <?xml version="1.0" ?>
+        // <entry xmlns="http://www.w3.org/2005/Atom">
+        // <title>Atom-Powered Robots Run Amok</title>
+        // <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
+        // <updated>2007-02-123T17:09:02Z</updated>
+        // <author><name>Captain Lansing</name></author>
+        // <content>It's something moving... solid metal</content>
+        // </entry>
+
+        // Expected Atom server response (note unique ETag)
+        // HTTP/1.1 201 Created
+        // Date: Fri, 23 Feb 2007 21:17:11 GMT
+        // Content-Length: nnn
+        // Content-Type: application/atom+xml;type=entry
+        // Location: http://example.org/edit/first-post.atom
+        // Content-Location: http://example.org/edit/first-post.atom
+        // ETag: "e180ee84f0671b1"
+        // Last-Modified: Fri, 25 Jul 2008 14:36:44 -0500
+        // 
+        // <?xml version="1.0" ?>
+        // <entry xmlns="http://www.w3.org/2005/Atom">
+        // <title>Atom-Powered Robots Run Amok</title>
+        // <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
+        // <updated>2007-02-123T17:09:02Z</updated>
+        // <author><name>Captain Lansing</name></author>
+        // <content>It's something moving... solid metal</content>
+        // </entry>
+
+        // Testing of entry creation
+        Factory factory = abdera.getFactory();
+        String customerName = "Fred Farkle";
+        Entry entry = factory.newEntry();
+        entry.setTitle("customer " + customerName);
+        entry.setUpdated(new Date());
+        entry.addAuthor("Apache Tuscany");
+        // ID created by collection.
         // entry.setId(id); // auto-provided
         // entry.addLink("" + id, "edit"); // auto-provided
         // entry.addLink("" + id, "alternate"); // auto-provided
-		Content content = abdera.getFactory().newContent();
-		content.setContentType(Content.Type.TEXT);
-		content.setValue(customerName);
-		entry.setContentElement(content);
-
-		RequestOptions opts = new RequestOptions();
-		final String contentType = "application/atom+xml; type=entry"; 
-		opts.setContentType(contentType);
-		// AtomTestCaseUtils.printRequestHeaders( "Post request headers", "   ", opts );
-		IRI colUri = new IRI(providerURI).resolve("customer");
-		// res = client.post(colUri.toString() + "?test=foo", entry, opts);
-		ClientResponse res = client.post(colUri.toString(), entry, opts);
-		
-	    // Assert response status code is 201-OK.
-		// Assert response header Content-Type: application/atom+xml; charset=UTF-8
-		// Assert response header Location: http://example.org/edit/first-post.atom
-		// Assert response header Content-Location: http://example.org/edit/first-post.atom
-		// Assert response header ETag: "e180ee84f0671b1"
-		// Assert response header Last-Modified: Fri, 25 Jul 2008 14:36:44 -0500	    
-	    // Assert collection size is 1.
-    	Assert.assertEquals(201, res.getStatus());
-    	Assert.assertEquals(contentType, res.getContentType().toString().trim());
-    	// Assert.assertNotNull( res.getLocation().toString() );
-    	// Assert.assertEquals( "", res.getContentLocation().toString() );
-    	// Save eTag for subsequent tests;
-    	eTag = res.getHeader( "ETag" );
-    	Assert.assertNotNull( eTag );     	
-    	lastModified = res.getLastModified();
-    	Assert.assertNotNull(lastModified);
-	}
-
-	@Test
-	public void testDirtyCachePut() throws Exception {
-		// 2) Conditional PUT request (post with etag. entry provided is stale)
-		// User client PUT request
-		//        PUT /edit/first-post.atom HTTP/1.1
-		// >      If-Match: "e180ee84f0671b1"
-		// 
-		//        <?xml version="1.0" ?>
-		//        <entry xmlns="http://www.w3.org/2005/Atom">
-		//         <title>Atom-Powered Robots Run Amok</title>
-		//         <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
-		//         <updated>2007-02-24T16:34:06Z</updated>
-		//         <author><name>Captain Lansing</name></author>
-		//         <content>Update: it's a hoax!</content>
-		//       </entry>
-		// Testing of entry creation
-		Factory factory = abdera.getFactory();
-		String customerName = "Molly Ringwald";
-		Entry entry = factory.newEntry();
-		entry.setTitle("customer " + customerName);
-		entry.setUpdated( new Date());
-		entry.addAuthor("Apache Tuscany");
-		String id = eTag.substring( 1, eTag.length()-1);
+        Content content = abdera.getFactory().newContent();
+        content.setContentType(Content.Type.TEXT);
+        content.setValue(customerName);
+        entry.setContentElement(content);
+
+        RequestOptions opts = new RequestOptions();
+        final String contentType = "application/atom+xml; type=entry";
+        opts.setContentType(contentType);
+        // AtomTestCaseUtils.printRequestHeaders( "Post request headers", "   ",
+        // opts );
+        IRI colUri = new IRI(providerURI).resolve("customer");
+        // res = client.post(colUri.toString() + "?test=foo", entry, opts);
+        ClientResponse res = client.post(colUri.toString(), entry, opts);
+
+        // Assert response status code is 201-OK.
+        // Assert response header Content-Type: application/atom+xml;
+        // charset=UTF-8
+        // Assert response header Location:
+        // http://example.org/edit/first-post.atom
+        // Assert response header Content-Location:
+        // http://example.org/edit/first-post.atom
+        // Assert response header ETag: "e180ee84f0671b1"
+        // Assert response header Last-Modified: Fri, 25 Jul 2008 14:36:44 -0500
+        // Assert collection size is 1.
+        Assert.assertEquals(201, res.getStatus());
+        Assert.assertEquals(contentType, res.getContentType().toString().trim());
+        // Assert.assertNotNull( res.getLocation().toString() );
+        // Assert.assertEquals( "", res.getContentLocation().toString() );
+        // Save eTag for subsequent tests;
+        eTag = res.getHeader("ETag");
+        Assert.assertNotNull(eTag);
+        lastModified = res.getLastModified();
+        Assert.assertNotNull(lastModified);
+    }
+
+    @Test
+    public void testDirtyCachePut() throws Exception {
+        // 2) Conditional PUT request (post with etag. entry provided is stale)
+        // User client PUT request
+        // PUT /edit/first-post.atom HTTP/1.1
+        // > If-Match: "e180ee84f0671b1"
+        // 
+        // <?xml version="1.0" ?>
+        // <entry xmlns="http://www.w3.org/2005/Atom">
+        // <title>Atom-Powered Robots Run Amok</title>
+        // <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
+        // <updated>2007-02-24T16:34:06Z</updated>
+        // <author><name>Captain Lansing</name></author>
+        // <content>Update: it's a hoax!</content>
+        // </entry>
+        // Testing of entry creation
+        Factory factory = abdera.getFactory();
+        String customerName = "Molly Ringwald";
+        Entry entry = factory.newEntry();
+        entry.setTitle("customer " + customerName);
+        entry.setUpdated(new Date());
+        entry.addAuthor("Apache Tuscany");
+        String id = eTag.substring(1, eTag.length() - 1);
         entry.setId(id); // auto-provided
         // entry.addLink("" + id, "edit"); // auto-provided
         // entry.addLink("" + id, "alternate"); // auto-provided
-		Content content = abdera.getFactory().newContent();
-		content.setContentType(Content.Type.TEXT);
-		content.setValue(customerName);
-		entry.setContentElement(content);
-
-		RequestOptions opts = new RequestOptions();
-		final String contentType = "application/atom+xml; type=entry"; 
-		opts.setContentType(contentType);
-		opts.setHeader( "If-None-Match", eTag);
-		
-		AtomTestCaseUtils.printRequestHeaders( "Put request headers", "   ", opts );
-		IRI colUri = new IRI(providerURI).resolve("customer");
-		// res = client.post(colUri.toString() + "?test=foo", entry, opts);
-	    id = eTag.substring( 1, eTag.length()-1);
-		// Warning. AbderaClient.put(String uri,Base base,RequestOptions options) caches on the client side.
-		// ClientResponse res = client.put(colUri.toString() + id, entry, opts);
-		ClientResponse res = client.put(colUri.toString() + "/" + id, new BaseRequestEntity( entry ), opts);
-		// Expected Atom server response (item was edited by another user)
-		// >      HTTP/1.1 412 Precondition Failed
-		//       Date: Sat, 24 Feb 2007 16:34:11 GMT
-
-	    // If-Match Assert response status code is 412. Precondition failed.
-	    // If-None-Match Assert response status code is 200. OK
-    	Assert.assertEquals(200, res.getStatus());
-    	// Put provides null body and no etags.
-    	res.release();
-	}
-	
-	@Test
-	public void testETagMissGet() throws Exception {
-		// 4) Conditional GET example (get with etag. etag not in cache)
-		// User client GET request
-		//       GET /edit/first-post.atom HTTP/1.1
-		// >      If-None-Match: "e180ee84f0671b1"
-
-		RequestOptions opts = new RequestOptions();
-		final String contentType = "application/atom+xml; type=entry"; 
-		opts.setContentType(contentType);
-		opts.setHeader( "If-None-Match", "123456");
-		opts.setHeader( "Pragma", "no-cache"); // turn off client caching
-		
-		IRI colUri = new IRI(providerURI).resolve("customer");
-		// res = client.post(colUri.toString() + "?test=foo", entry, opts);
-		String id = eTag.substring( 1, eTag.length()-1);
-		// Warning. AbderaClient.put(String uri,Base base,RequestOptions options) caches on the client side.
-		// ClientResponse res = client.put(colUri.toString() + id, entry, opts);
-		ClientResponse res = client.get(colUri.toString() + "/" + id, opts);
-		// Expected Atom server response (item was edited by another user)
-		// >      HTTP/1.1 412 Precondition Failed
-		//       Date: Sat, 24 Feb 2007 16:34:11 GMT
-
-		// Atom server response (item was up to date)
-		// >      HTTP/1.1 200 OK
-		//        Date: Sat, 24 Feb 2007 13:17:11 GMT
-		// >      ETag: "bb4f5e86e92ddb8549604a0df0763581"
-		// >      Last-Modified: Mon, 28 Jul 2008 10:25:37 -0500
-
-	    // Assert response status code is 200 OK.
-		// Assert header Content-Type: application/atom+xml;type=entry
-		// Assert header Location: http://example.org/edit/first-post.atom
-		// Assert header Content-Location: http://example.org/edit/first-post.atom
-		// Assert header ETag: "555555" (etag response != etag request)
-		// Assert header Last-Modified: Fri, 25 Jul 2008 14:36:44 -0500
-    	Assert.assertEquals(200, res.getStatus());
-    	Assert.assertEquals(contentType, res.getContentType().toString().trim());
-    	// Assert.assertNotNull( res.getLocation().toString() );
-    	// Assert.assertEquals( "", res.getContentLocation().toString() );
-    	Assert.assertNotNull( res.getHeader( "ETag" ) );     	
-    	lastModified = res.getLastModified();
-    	Assert.assertNotNull(lastModified);
-		res.release();
-	}
-
-	@Test
-	public void testETagHitGet() throws Exception {
-		// 3) Conditional GET example (get with etag. etag match)
-		// User client GET request
-		//       GET /edit/first-post.atom HTTP/1.1
-		// >      If-None-Match: "e180ee84f0671b1"
-
-		RequestOptions opts = new RequestOptions();
-		final String contentType = "application/atom+xml; type=entry"; 
-		opts.setContentType(contentType);
-		opts.setHeader( "If-None-Match", eTag);
-		opts.setHeader( "Pragma", "no-cache"); // turn off client caching		
-		
-		IRI colUri = new IRI(providerURI).resolve("customer");
-		// res = client.post(colUri.toString() + "?test=foo", entry, opts);
-		String id = eTag.substring( 1, eTag.length()-1);
-		// Warning. AbderaClient.put(String uri,Base base,RequestOptions options) caches on the client side.
-		// ClientResponse res = client.put(colUri.toString() + id, entry, opts);
-		ClientResponse res = client.get(colUri.toString() + "/" + id, opts);
-		// Atom server response (item was up to date)
-		// >      HTTP/1.1 304 Not Modified
-		//       Date: Sat, 24 Feb 2007 13:17:11 GMT
-
-	    // Assert response status code is 304 Not Modified.
-		// Assert header ETag: "e180ee84f0671b1"
-		// Assert header Last-Modified: Fri, 25 Jul 2008 14:36:44 -0500
-    	// Assert.assertEquals(304, res.getStatus());
-		res.release();	    
-	}
-
-
-	@Test
-	public void testUpToDateGet() throws Exception {
-		// 3) Conditional GET example (get with If-Mod. entry is up to date)
-		// User client GET request
-		//       GET /edit/first-post.atom HTTP/1.1
-		// >      If-Modified-Since: Sat, 29 Oct 2025 19:43:31 GMT
-		RequestOptions opts = new RequestOptions();
-		final String contentType = "application/atom+xml; type=entry"; 
-		opts.setContentType(contentType);
-		opts.setHeader( "If-Modified-Since", "Sat, 29 Oct 2025 19:43:31 GMT"); // "EEE, dd MMM yyyy HH:mm:ss Z // RFC 822 Date
-		opts.setHeader( "Pragma", "no-cache"); // turn off client caching
-		
-		IRI colUri = new IRI(providerURI).resolve("customer");
-		// res = client.post(colUri.toString() + "?test=foo", entry, opts);
-		String id = eTag.substring( 1, eTag.length()-1);
-		// Warning. AbderaClient.put(String uri,Base base,RequestOptions options) caches on the client side.
-		// ClientResponse res = client.put(colUri.toString() + id, entry, opts);
-		// Warning. AbderaClient.put(String uri,Base base,RequestOptions options) caches on the client side.
-		// ClientResponse res = client.get(colUri.toString() + "/" + id, opts);
-		ClientResponse res = client.execute( "GET", colUri.toString(), (BaseRequestEntity)null, opts);
-
-		// Atom server response (item was up to date)
-		// >      HTTP/1.1 304 Not Modified
-		//       Date: Sat, 24 Feb 2007 13:17:11 GMT
-
-	    // Assert response status code is 304 Not Modified.
-    	Assert.assertEquals(304, res.getStatus());
-		res.release();	    
-	}
-
-	@Test
-	public void testOutOfDateGet() throws Exception {
-		// 4) Conditional GET example (get with If-Mod. entry is not to date)
-		// User client GET request
-		//       GET /edit/first-post.atom HTTP/1.1
-		// >      If-Modified-Since: Sat, 29 Oct 1844 19:43:31 GMT
-		RequestOptions opts = new RequestOptions();
-		final String contentType = "application/atom+xml; type=entry"; 
-		opts.setContentType(contentType);
-		opts.setHeader( "If-Modified-Since", "Sat, 29 Oct 1844 19:43:31 GMT"); // "EEE, dd MMM yyyy HH:mm:ss Z // RFC 822 Date
-		opts.setHeader( "Pragma", "no-cache"); // turn off client caching
-		
-		IRI colUri = new IRI(providerURI).resolve("customer");
-		// res = client.post(colUri.toString() + "?test=foo", entry, opts);
-		String id = eTag.substring( 1, eTag.length()-1);
-		// Warning. AbderaClient.put(String uri,Base base,RequestOptions options) caches on the client side.
-		// ClientResponse res = client.put(colUri.toString() + id, entry, opts);
-		ClientResponse res = client.get(colUri.toString() + "/" + id, opts);
-
-		// Atom server response (item was up to date)
-		// >      HTTP/1.1 200 OK
-		//        Date: Sat, 24 Feb 2007 13:17:11 GMT
-		// >      ETag: "bb4f5e86e92ddb8549604a0df0763581"
-		// >      Last-Modified: Mon, 28 Jul 2008 10:25:37 -0500
-
-	    // Assert response status code is 200 OK.
-		// Assert header ETag: "e180ee84f0671b1"
-		// Assert header Last-Modified: Greater than If-Mod	    
-    	Assert.assertEquals(200, res.getStatus());
-    	Assert.assertEquals(contentType, res.getContentType().toString().trim());
-    	// Assert.assertNotNull( res.getLocation().toString() );
-    	// Assert.assertEquals( "", res.getContentLocation().toString() );
-    	Assert.assertNotNull( res.getHeader( "ETag" ) );     	
-    	lastModified = res.getLastModified();
-    	Assert.assertNotNull(lastModified);
-		res.release();
-	}
-	
-	@Test
-	public void testUpToDateUnModGet() throws Exception {
-		// 3) Conditional GET example (get with If-Unmod. entry is up to date)
-		// User client GET request
-		//       GET /edit/first-post.atom HTTP/1.1
-		// >      If-Unmodified-Since: Sat, 29 Oct 2025 19:43:31 GMT
-		RequestOptions opts = new RequestOptions();
-		final String contentType = "application/atom+xml; type=entry"; 
-		opts.setContentType(contentType);
-		opts.setHeader( "If-Unmodified-Since", "Sat, 29 Oct 2050 19:43:31 GMT" );
-		opts.setHeader( "Pragma", "no-cache"); // turn off client caching
-		
-		IRI colUri = new IRI(providerURI).resolve("customer");
-		// res = client.post(colUri.toString() + "?test=foo", entry, opts);
-		String id = eTag.substring( 1, eTag.length()-1);
-		// Warning. AbderaClient.put(String uri,Base base,RequestOptions options) caches on the client side.
-		// ClientResponse res = client.put(colUri.toString() + id, entry, opts);
-		ClientResponse res = client.get(colUri.toString() + "/" + id, opts);
-
-		// Atom server response (item was up to date)
-		// >      HTTP/1.1 304 Not Modified
-		//       Date: Sat, 24 Feb 2007 13:17:11 GMT
-
-	    // Assert response status code is 304 Not Modified.
-    	// Assert.assertEquals(304, res.getStatus());
-		// TODO Update when If-Unmodified-Since enabled.
-    	Assert.assertEquals(200, res.getStatus());
-		res.release();	        
-	}
-
-	@Test
-	public void testOutOfDateUnModGet() throws Exception {
-		// 4) Conditional GET example (get with If-Unmod. entry is not to date)
-		// User client GET request
-		//       GET /edit/first-post.atom HTTP/1.1
-		//        Host: example.org
-		// >      If-Unmodified-Since: Sat, 29 Oct 1844 19:43:31 GMT
-		RequestOptions opts = new RequestOptions();
-		final String contentType = "application/atom+xml; type=entry"; 
-		opts.setContentType(contentType);
-		opts.setHeader( "If-Unmodified-Since", "Sat, 29 Oct 1844 19:43:31 GMT" );
-		opts.setHeader( "Pragma", "no-cache"); // turn off client caching
-		
-		IRI colUri = new IRI(providerURI).resolve("customer");
-		// res = client.post(colUri.toString() + "?test=foo", entry, opts);
-		String id = eTag.substring( 1, eTag.length()-1);
-		// Warning. AbderaClient.put(String uri,Base base,RequestOptions options) caches on the client side.
-		// ClientResponse res = client.put(colUri.toString() + id, entry, opts);
-		ClientResponse res = client.get(colUri.toString() + "/" + id, opts);
-
-		// Atom server response (item was up to date)
-		// >      HTTP/1.1 200 OK
-		//        Date: Sat, 24 Feb 2007 13:17:11 GMT
-		// >      ETag: "bb4f5e86e92ddb8549604a0df0763581"
-		// >      Last-Modified: Mon, 28 Jul 2008 10:25:37 -0500
-
-	    // Assert response status code is 200 OK.
-		// Assert header Content-Type: application/atom+xml;type=entry
-		// Assert header Location: http://example.org/edit/first-post.atom
-		// Assert header Content-Location: http://example.org/edit/first-post.atom
-		// Assert header ETag: "e180ee84f0671b1"
-		// Assert header Last-Modified: Less than If-Unmod	    
-    	Assert.assertEquals(200, res.getStatus());
-    	Assert.assertEquals(contentType, res.getContentType().toString().trim());
-    	// Assert.assertNotNull( res.getLocation().toString() );
-    	// Assert.assertEquals( "", res.getContentLocation().toString() );
-    	Assert.assertNotNull( res.getHeader( "ETag" ) );     	
-    	lastModified = res.getLastModified();
-    	Assert.assertNotNull(lastModified);
-		res.release();
-	}
+        Content content = abdera.getFactory().newContent();
+        content.setContentType(Content.Type.TEXT);
+        content.setValue(customerName);
+        entry.setContentElement(content);
+
+        RequestOptions opts = new RequestOptions();
+        final String contentType = "application/atom+xml; type=entry";
+        opts.setContentType(contentType);
+        opts.setHeader("If-None-Match", eTag);
+
+        AtomTestCaseUtils.printRequestHeaders("Put request headers", "   ", opts);
+        IRI colUri = new IRI(providerURI).resolve("customer");
+        // res = client.post(colUri.toString() + "?test=foo", entry, opts);
+        id = eTag.substring(1, eTag.length() - 1);
+        // Warning. AbderaClient.put(String uri,Base base,RequestOptions
+        // options) caches on the client side.
+        // ClientResponse res = client.put(colUri.toString() + id, entry, opts);
+        ClientResponse res = client.put(colUri.toString() + "/" + id, new BaseRequestEntity(entry), opts);
+        // Expected Atom server response (item was edited by another user)
+        // > HTTP/1.1 412 Precondition Failed
+        // Date: Sat, 24 Feb 2007 16:34:11 GMT
+
+        // If-Match Assert response status code is 412. Precondition failed.
+        // If-None-Match Assert response status code is 200. OK
+        Assert.assertEquals(200, res.getStatus());
+        // Put provides null body and no etags.
+        res.release();
+    }
+
+    @Test
+    public void testETagMissGet() throws Exception {
+        // 4) Conditional GET example (get with etag. etag not in cache)
+        // User client GET request
+        // GET /edit/first-post.atom HTTP/1.1
+        // > If-None-Match: "e180ee84f0671b1"
+
+        RequestOptions opts = new RequestOptions();
+        final String contentType = "application/atom+xml; type=entry";
+        opts.setContentType(contentType);
+        opts.setHeader("If-None-Match", "123456");
+        opts.setHeader("Pragma", "no-cache"); // turn off client caching
+
+        IRI colUri = new IRI(providerURI).resolve("customer");
+        // res = client.post(colUri.toString() + "?test=foo", entry, opts);
+        String id = eTag.substring(1, eTag.length() - 1);
+        // Warning. AbderaClient.put(String uri,Base base,RequestOptions
+        // options) caches on the client side.
+        // ClientResponse res = client.put(colUri.toString() + id, entry, opts);
+        ClientResponse res = client.get(colUri.toString() + "/" + id, opts);
+        // Expected Atom server response (item was edited by another user)
+        // > HTTP/1.1 412 Precondition Failed
+        // Date: Sat, 24 Feb 2007 16:34:11 GMT
+
+        // Atom server response (item was up to date)
+        // > HTTP/1.1 200 OK
+        // Date: Sat, 24 Feb 2007 13:17:11 GMT
+        // > ETag: "bb4f5e86e92ddb8549604a0df0763581"
+        // > Last-Modified: Mon, 28 Jul 2008 10:25:37 -0500
+
+        // Assert response status code is 200 OK.
+        // Assert header Content-Type: application/atom+xml;type=entry
+        // Assert header Location: http://example.org/edit/first-post.atom
+        // Assert header Content-Location:
+        // http://example.org/edit/first-post.atom
+        // Assert header ETag: "555555" (etag response != etag request)
+        // Assert header Last-Modified: Fri, 25 Jul 2008 14:36:44 -0500
+        Assert.assertEquals(200, res.getStatus());
+        Assert.assertEquals(contentType, res.getContentType().toString().trim());
+        // Assert.assertNotNull( res.getLocation().toString() );
+        // Assert.assertEquals( "", res.getContentLocation().toString() );
+        Assert.assertNotNull(res.getHeader("ETag"));
+        lastModified = res.getLastModified();
+        Assert.assertNotNull(lastModified);
+        res.release();
+    }
+
+    @Test
+    public void testETagHitGet() throws Exception {
+        // 3) Conditional GET example (get with etag. etag match)
+        // User client GET request
+        // GET /edit/first-post.atom HTTP/1.1
+        // > If-None-Match: "e180ee84f0671b1"
+
+        RequestOptions opts = new RequestOptions();
+        final String contentType = "application/atom+xml; type=entry";
+        opts.setContentType(contentType);
+        opts.setHeader("If-None-Match", eTag);
+        opts.setHeader("Pragma", "no-cache"); // turn off client caching
+
+        IRI colUri = new IRI(providerURI).resolve("customer");
+        // res = client.post(colUri.toString() + "?test=foo", entry, opts);
+        String id = eTag.substring(1, eTag.length() - 1);
+        // Warning. AbderaClient.put(String uri,Base base,RequestOptions
+        // options) caches on the client side.
+        // ClientResponse res = client.put(colUri.toString() + id, entry, opts);
+        ClientResponse res = client.get(colUri.toString() + "/" + id, opts);
+        // Atom server response (item was up to date)
+        // > HTTP/1.1 304 Not Modified
+        // Date: Sat, 24 Feb 2007 13:17:11 GMT
+
+        // Assert response status code is 304 Not Modified.
+        // Assert header ETag: "e180ee84f0671b1"
+        // Assert header Last-Modified: Fri, 25 Jul 2008 14:36:44 -0500
+        // Assert.assertEquals(304, res.getStatus());
+        res.release();
+    }
+
+    @Test
+    public void testUpToDateGet() throws Exception {
+        // 3) Conditional GET example (get with If-Mod. entry is up to date)
+        // User client GET request
+        // GET /edit/first-post.atom HTTP/1.1
+        // > If-Modified-Since: Sat, 29 Oct 2025 19:43:31 GMT
+        RequestOptions opts = new RequestOptions();
+        final String contentType = "application/atom+xml; type=entry";
+        opts.setContentType(contentType);
+        opts.setHeader("If-Modified-Since", "Sat, 29 Oct 2025 19:43:31 GMT"); // "EEE,
+                                                                              // dd
+                                                                              // MMM
+                                                                              // yyyy
+                                                                              // HH
+                                                                              // :
+                                                                              // mm
+                                                                              // :
+                                                                              // ss
+                                                                              // Z
+                                                                              // /
+                                                                              // /
+                                                                              // RFC
+                                                                              // 822
+                                                                              // Date
+        opts.setHeader("Pragma", "no-cache"); // turn off client caching
+
+        IRI colUri = new IRI(providerURI).resolve("customer");
+        // res = client.post(colUri.toString() + "?test=foo", entry, opts);
+        String id = eTag.substring(1, eTag.length() - 1);
+        // Warning. AbderaClient.put(String uri,Base base,RequestOptions
+        // options) caches on the client side.
+        // ClientResponse res = client.put(colUri.toString() + id, entry, opts);
+        // Warning. AbderaClient.put(String uri,Base base,RequestOptions
+        // options) caches on the client side.
+        // ClientResponse res = client.get(colUri.toString() + "/" + id, opts);
+        ClientResponse res = client.execute("GET", colUri.toString(), (BaseRequestEntity)null, opts);
+
+        // Atom server response (item was up to date)
+        // > HTTP/1.1 304 Not Modified
+        // Date: Sat, 24 Feb 2007 13:17:11 GMT
+
+        // Assert response status code is 304 Not Modified.
+        Assert.assertEquals(304, res.getStatus());
+        res.release();
+    }
+
+    @Test
+    public void testOutOfDateGet() throws Exception {
+        // 4) Conditional GET example (get with If-Mod. entry is not to date)
+        // User client GET request
+        // GET /edit/first-post.atom HTTP/1.1
+        // > If-Modified-Since: Sat, 29 Oct 1844 19:43:31 GMT
+        RequestOptions opts = new RequestOptions();
+        final String contentType = "application/atom+xml; type=entry";
+        opts.setContentType(contentType);
+        opts.setHeader("If-Modified-Since", "Sat, 29 Oct 1844 19:43:31 GMT"); // "EEE,
+                                                                              // dd
+                                                                              // MMM
+                                                                              // yyyy
+                                                                              // HH
+                                                                              // :
+                                                                              // mm
+                                                                              // :
+                                                                              // ss
+                                                                              // Z
+                                                                              // /
+                                                                              // /
+                                                                              // RFC
+                                                                              // 822
+                                                                              // Date
+        opts.setHeader("Pragma", "no-cache"); // turn off client caching
+
+        IRI colUri = new IRI(providerURI).resolve("customer");
+        // res = client.post(colUri.toString() + "?test=foo", entry, opts);
+        String id = eTag.substring(1, eTag.length() - 1);
+        // Warning. AbderaClient.put(String uri,Base base,RequestOptions
+        // options) caches on the client side.
+        // ClientResponse res = client.put(colUri.toString() + id, entry, opts);
+        ClientResponse res = client.get(colUri.toString() + "/" + id, opts);
+
+        // Atom server response (item was up to date)
+        // > HTTP/1.1 200 OK
+        // Date: Sat, 24 Feb 2007 13:17:11 GMT
+        // > ETag: "bb4f5e86e92ddb8549604a0df0763581"
+        // > Last-Modified: Mon, 28 Jul 2008 10:25:37 -0500
+
+        // Assert response status code is 200 OK.
+        // Assert header ETag: "e180ee84f0671b1"
+        // Assert header Last-Modified: Greater than If-Mod
+        Assert.assertEquals(200, res.getStatus());
+        Assert.assertEquals(contentType, res.getContentType().toString().trim());
+        // Assert.assertNotNull( res.getLocation().toString() );
+        // Assert.assertEquals( "", res.getContentLocation().toString() );
+        Assert.assertNotNull(res.getHeader("ETag"));
+        lastModified = res.getLastModified();
+        Assert.assertNotNull(lastModified);
+        res.release();
+    }
+
+    @Test
+    public void testUpToDateUnModGet() throws Exception {
+        // 3) Conditional GET example (get with If-Unmod. entry is up to date)
+        // User client GET request
+        // GET /edit/first-post.atom HTTP/1.1
+        // > If-Unmodified-Since: Sat, 29 Oct 2025 19:43:31 GMT
+        RequestOptions opts = new RequestOptions();
+        final String contentType = "application/atom+xml; type=entry";
+        opts.setContentType(contentType);
+        opts.setHeader("If-Unmodified-Since", "Sat, 29 Oct 2050 19:43:31 GMT");
+        opts.setHeader("Pragma", "no-cache"); // turn off client caching
+
+        IRI colUri = new IRI(providerURI).resolve("customer");
+        // res = client.post(colUri.toString() + "?test=foo", entry, opts);
+        String id = eTag.substring(1, eTag.length() - 1);
+        // Warning. AbderaClient.put(String uri,Base base,RequestOptions
+        // options) caches on the client side.
+        // ClientResponse res = client.put(colUri.toString() + id, entry, opts);
+        ClientResponse res = client.get(colUri.toString() + "/" + id, opts);
+
+        // Atom server response (item was up to date)
+        // > HTTP/1.1 304 Not Modified
+        // Date: Sat, 24 Feb 2007 13:17:11 GMT
+
+        // Assert response status code is 304 Not Modified.
+        // Assert.assertEquals(304, res.getStatus());
+        // TODO Update when If-Unmodified-Since enabled.
+        Assert.assertEquals(200, res.getStatus());
+        res.release();
+    }
+
+    @Test
+    public void testOutOfDateUnModGet() throws Exception {
+        // 4) Conditional GET example (get with If-Unmod. entry is not to date)
+        // User client GET request
+        // GET /edit/first-post.atom HTTP/1.1
+        // Host: example.org
+        // > If-Unmodified-Since: Sat, 29 Oct 1844 19:43:31 GMT
+        RequestOptions opts = new RequestOptions();
+        final String contentType = "application/atom+xml; type=entry";
+        opts.setContentType(contentType);
+        opts.setHeader("If-Unmodified-Since", "Sat, 29 Oct 1844 19:43:31 GMT");
+        opts.setHeader("Pragma", "no-cache"); // turn off client caching
+
+        IRI colUri = new IRI(providerURI).resolve("customer");
+        // res = client.post(colUri.toString() + "?test=foo", entry, opts);
+        String id = eTag.substring(1, eTag.length() - 1);
+        // Warning. AbderaClient.put(String uri,Base base,RequestOptions
+        // options) caches on the client side.
+        // ClientResponse res = client.put(colUri.toString() + id, entry, opts);
+        ClientResponse res = client.get(colUri.toString() + "/" + id, opts);
+
+        // Atom server response (item was up to date)
+        // > HTTP/1.1 200 OK
+        // Date: Sat, 24 Feb 2007 13:17:11 GMT
+        // > ETag: "bb4f5e86e92ddb8549604a0df0763581"
+        // > Last-Modified: Mon, 28 Jul 2008 10:25:37 -0500
+
+        // Assert response status code is 200 OK.
+        // Assert header Content-Type: application/atom+xml;type=entry
+        // Assert header Location: http://example.org/edit/first-post.atom
+        // Assert header Content-Location:
+        // http://example.org/edit/first-post.atom
+        // Assert header ETag: "e180ee84f0671b1"
+        // Assert header Last-Modified: Less than If-Unmod
+        Assert.assertEquals(200, res.getStatus());
+        Assert.assertEquals(contentType, res.getContentType().toString().trim());
+        // Assert.assertNotNull( res.getLocation().toString() );
+        // Assert.assertEquals( "", res.getContentLocation().toString() );
+        Assert.assertNotNull(res.getHeader("ETag"));
+        lastModified = res.getLastModified();
+        Assert.assertNotNull(lastModified);
+        res.release();
+    }
 }

Modified: tuscany/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderFeedEntityTagsTest.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderFeedEntityTagsTest.java?rev=703068&r1=703067&r2=703068&view=diff
==============================================================================
--- tuscany/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderFeedEntityTagsTest.java (original)
+++ tuscany/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderFeedEntityTagsTest.java Wed Oct  8 23:33:54 2008
@@ -22,335 +22,344 @@
 import java.util.Date;
 
 import junit.framework.Assert;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import org.apache.tuscany.sca.host.embedded.SCADomain;
 
 import org.apache.abdera.Abdera;
-import org.apache.abdera.i18n.iri.IRI;
 import org.apache.abdera.factory.Factory;
-import org.apache.abdera.model.Base;
+import org.apache.abdera.i18n.iri.IRI;
+import org.apache.abdera.model.Collection;
 import org.apache.abdera.model.Content;
+import org.apache.abdera.model.Document;
 import org.apache.abdera.model.Entry;
 import org.apache.abdera.model.Feed;
-import org.apache.abdera.model.Document;
-import org.apache.abdera.model.Service;
-import org.apache.abdera.model.Collection;
+import org.apache.abdera.parser.Parser;
 import org.apache.abdera.protocol.Response.ResponseType;
 import org.apache.abdera.protocol.client.AbderaClient;
 import org.apache.abdera.protocol.client.ClientResponse;
 import org.apache.abdera.protocol.client.RequestOptions;
-import org.apache.abdera.protocol.client.util.BaseRequestEntity;
-import org.apache.abdera.util.EntityTag;
-import org.apache.abdera.parser.Parser;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
 
 /**
  * Tests use of server provided feed entity tags for Atom binding in Tuscany.
- * Tests conditional gets (e.g. get if-none-match) or conditional posts (post if-match)
- * using entity tags and last modified entries in headers. 
- * Uses the SCA provided Provider composite to act as a server.
- * Uses the Abdera provided Client to act as a client.
+ * Tests conditional gets (e.g. get if-none-match) or conditional posts (post
+ * if-match) using entity tags and last modified entries in headers. Uses the
+ * SCA provided Provider composite to act as a server. Uses the Abdera provided
+ * Client to act as a client.
  */
 public class ProviderFeedEntityTagsTest {
-	public final static String providerURI = "http://localhost:8084/customer";
-	protected static SCADomain scaConsumerDomain;
-	protected static SCADomain scaProviderDomain;
-	protected static CustomerClient testService;
+    public final static String providerURI = "http://localhost:8084/customer";
+    protected static Node providerNode;
     protected static Abdera abdera;
     protected static AbderaClient client;
-    protected static Parser abderaParser;    
+    protected static Parser abderaParser;
     protected static String eTag;
     protected static Date lastModified;
-    protected static final SimpleDateFormat dateFormat = new SimpleDateFormat( "EEE, dd MMM yyyy HH:mm:ss Z" ); // RFC 822 date time
-
-	@BeforeClass
-	public static void init() throws Exception {
-		System.out.println(">>>ProviderFeedEntityTagsTest.init");
-		scaProviderDomain = SCADomain.newInstance("org/apache/tuscany/sca/binding/atom/Provider.composite");
-		abdera = new Abdera();
-		client = new AbderaClient(abdera);
-		abderaParser = Abdera.getNewParser();
-	}
-
-	@AfterClass
-	public static void destroy() throws Exception {
-		System.out.println(">>>ProviderFeedEntityTagsTest.destroy");
-		scaProviderDomain.close();
-	}
-
-	@Test
-	public void testPrelim() throws Exception {
-		Assert.assertNotNull(scaProviderDomain);
-		Assert.assertNotNull( client );
-	}
-			
-	@Test
-    public void testFeedBasics() throws Exception {		
-		System.out.println(">>>ProviderFeedEntityTagsTest.testFeedBasics");
-		// Normal feed request
-		ClientResponse res = client.get(providerURI);
-		Assert.assertNotNull(res);
-		try {
-			// Asser feed provided since no predicates
-			Assert.assertEquals(200, res.getStatus());
-			Assert.assertEquals(ResponseType.SUCCESS, res.getType());
-	    	// AtomTestCaseUtils.printResponseHeaders( "Feed response headers:", "   ", res );
-	    	// System.out.println("Feed response content:");
-	    	// AtomTestCaseUtils.prettyPrint(abdera, res.getDocument());
-
-	    	// Perform other tests on feed.
-			Document<Feed> doc = res.getDocument();
-			Assert.assertNotNull( doc );
-			Feed feed = doc.getRoot();
-			Assert.assertNotNull( feed );
-			printFeed( "Feed values", "   ", feed );
-			// RFC 4287 requires non-null id, title, updated elements
-			Assert.assertNotNull( feed.getId() );
-			Assert.assertNotNull( feed.getTitle() );
-			Assert.assertNotNull( feed.getUpdated() );
-			
-			eTag = res.getHeader("ETag");
-			Assert.assertNotNull( eTag );
-			lastModified = res.getLastModified();
-			Assert.assertNotNull( lastModified );
-		} finally {
-			res.release();
-		}
-	}		
-
-	@Test
-    public void testUnmodifiedGetIfMatch() throws Exception {		
-		System.out.println(">>>ProviderFeedEntityTagsTest.testFeedUnmodifiedGetIfMatch");
-		// Feed request with predicates
-		RequestOptions opts = new RequestOptions();
-		final String contentType = "application/atom+xml"; 
-		opts.setContentType(contentType);
-		opts.setHeader( "If-Match", eTag);
-		
-		ClientResponse res = client.get(providerURI, opts);
-		Assert.assertNotNull(res);
-		try {
-	    	String thisETag = res.getHeader("ETag");
-			Assert.assertNotNull( thisETag );
-			Date thisLastModified = res.getLastModified();
-			Assert.assertNotNull( thisLastModified );
-                        
-			// Should return 200 - Feed provided since it matches etag.
-			Assert.assertEquals(200, res.getStatus());
-			Assert.assertEquals(ResponseType.SUCCESS, res.getType());
-	    	// AtomTestCaseUtils.printResponseHeaders( "Feed response headers:", "   ", res );
-	    	// System.out.println("Feed response content:");
-	    	// AtomTestCaseUtils.prettyPrint(abdera, res.getDocument());
-		} finally {
-			res.release();
-		}
-	}		
-
-	@Test
-    public void testUnmodifiedGetIfNoneMatch() throws Exception {		
-		System.out.println(">>>ProviderFeedEntityTagsTest.testFeedUnmodifiedGetIfNoneMatch");
-		// Feed request with predicates
-		RequestOptions opts = new RequestOptions();
-		final String contentType = "application/atom+xml"; 
-		opts.setContentType(contentType);
-		opts.setHeader( "If-None-Match", eTag);
-		
-		ClientResponse res = client.get(providerURI, opts);
-		Assert.assertNotNull(res);
-		try {
-			// Should return 304 - Feed not provided since it matches ETag.
-			Assert.assertEquals(304, res.getStatus());
-		} finally {
-			res.release();
-		}
-	}		
-
-	@Test
-    public void testUnmodifiedGetIfUnModified() throws Exception {		
-		System.out.println(">>>ProviderFeedEntityTagsTest.testFeedUnmodifiedGetIfUnModified");
-		// Feed request with predicates
-		RequestOptions opts = new RequestOptions();
-		final String contentType = "application/atom+xml"; 
-		opts.setContentType(contentType);
-		opts.setHeader( "If-Unmodified-Since", dateFormat.format( new Date() ));
-		
-		ClientResponse res = client.get(providerURI, opts);
-		Assert.assertNotNull(res);
-		try {
-			// Should return 304 - Feed not provided since feed is modified since.
-			Assert.assertEquals(304, res.getStatus());
-		} finally {
-			res.release();
-		}
-	}		
-
-	@Test
-    public void testUnmodifiedGetIfModified() throws Exception {		
-		System.out.println(">>>ProviderFeedEntityTagsTest.testFeedUnmodifiedGetIfModified");
-		// Feed request with predicates
-		RequestOptions opts = new RequestOptions();
-		final String contentType = "application/atom+xml"; 
-		opts.setContentType(contentType);
-		opts.setHeader( "If-Modified-Since", dateFormat.format( new Date( 0 ) ));
-		
-		ClientResponse res = client.get(providerURI, opts);
-		Assert.assertNotNull(res);
-		try {
-			// Should return 200 - Feed provided since feed is changed.
-			Assert.assertEquals(200, res.getStatus());
-			Assert.assertEquals(ResponseType.SUCCESS, res.getType());
-
-			String thisETag = res.getHeader("ETag");
-			Assert.assertNotNull( thisETag );
-			Date thisLastModified = res.getLastModified();
-			Assert.assertNotNull( thisLastModified );                        
-		} finally {
-			res.release();
-		}
-	}		
-
-	@Test
-    public void testModifiedGetIfNoneMatch() throws Exception {		
-		System.out.println(">>>ProviderFeedEntityTagsTest.testFeedModifiedGetIfNoneMatch");
-		// Post some new content to the feed.
-		Factory factory = abdera.getFactory();
-		String customerName = "Fred Farkle";
-		Entry entry = factory.newEntry();
-		entry.setTitle("customer " + customerName);
-		entry.setUpdated(new Date());
-		entry.addAuthor("Apache Tuscany");
-		Content content = abdera.getFactory().newContent();
-		content.setContentType(Content.Type.TEXT);
-		content.setValue(customerName);
-		entry.setContentElement(content);
-
-		RequestOptions opts = new RequestOptions();
-		String contentType = "application/atom+xml; type=entry"; 
-		opts.setContentType(contentType);
-		IRI colUri = new IRI(providerURI).resolve("customer");
-		ClientResponse res = client.post(colUri.toString(), entry, opts);
-			
-		// Feed request with predicates
-		opts = new RequestOptions();
-		contentType = "application/atom+xml"; 
-		opts.setContentType(contentType);
-		opts.setHeader( "If-None-Match", eTag);
-		
-		res = client.get(providerURI, opts);
-		Assert.assertNotNull(res);
-		try {
-	    	String thisETag = res.getHeader("ETag");
-			Assert.assertNotNull( thisETag );
-			Date thisLastModified = res.getLastModified();
-			Assert.assertNotNull( thisLastModified );
-                        
-			// Should return 200 - value since feed is changed
-			Assert.assertEquals(200, res.getStatus());
-			Assert.assertEquals(ResponseType.SUCCESS, res.getType());
-			
-	    	// AtomTestCaseUtils.printResponseHeaders( "Feed modified if-none-match response headers:", "   ", res );
-	    	// System.out.println("Feed response content:");
-	    	// AtomTestCaseUtils.prettyPrint(abdera, res.getDocument());
-		} finally {
-			res.release();
-		}
-	}		
-
-	@Test
-    public void testModifiedGetIfMatch() throws Exception {		
-		System.out.println(">>>ProviderFeedEntityTagsTest.testFeedModifiedGetIfMatch");
-		// Feed request with predicates
-		RequestOptions opts = new RequestOptions();
-		final String contentType = "application/atom+xml"; 
-		opts.setContentType(contentType);
-		opts.setHeader( "If-Match", eTag);
-		
-		ClientResponse res = client.get(providerURI, opts);
-		Assert.assertNotNull(res);
-		try {
-			// Should return 412 - Precondition failed since feed changed.
-			Assert.assertEquals(412, res.getStatus());
-	    	// AtomTestCaseUtils.printResponseHeaders( "Feed response headers:", "   ", res );
-	    	// System.out.println("Feed response content:");
-	    	// AtomTestCaseUtils.prettyPrint(abdera, res.getDocument());
-		} finally {
-			res.release();
-		}
-	}		
-
-	@Test
-    public void testModifiedGetIfUnModified() throws Exception {		
-		System.out.println(">>>ProviderFeedEntityTagsTest.testFeedUnmodifiedGetIfUnModified");
-		// Feed request with predicates
-		RequestOptions opts = new RequestOptions();
-		final String contentType = "application/atom+xml"; 
-		opts.setContentType(contentType);
-		opts.setHeader( "If-Unmodified-Since", dateFormat.format( new Date() ));
-		
-		ClientResponse res = client.get(providerURI, opts);
-		Assert.assertNotNull(res);
-		try {
-			// Should return 304 - Feed not provided since feed is modified since.			
-			Assert.assertEquals(304, res.getStatus());
-		} finally {
-			res.release();
-		}
-	}		
-
-	@Test
-    public void testModifiedGetIfModified() throws Exception {		
-		System.out.println(">>>ProviderFeedEntityTagsTest.testFeedUnmodifiedGetIfModified");
-		// Feed request with predicates
-		RequestOptions opts = new RequestOptions();
-		final String contentType = "application/atom+xml"; 
-		opts.setContentType(contentType);
-		opts.setHeader( "If-Modified-Since", dateFormat.format( lastModified ));
-		
-		ClientResponse res = client.get(providerURI, opts);
-		Assert.assertNotNull(res);
-		try {
-			// Should return 200 - Feed provided since feed is changed.
-			Assert.assertEquals(200, res.getStatus());
-			Assert.assertEquals(ResponseType.SUCCESS, res.getType());
-
-			String thisETag = res.getHeader("ETag");
-			Assert.assertNotNull( thisETag );
-			Date thisLastModified = res.getLastModified();
-			Assert.assertNotNull( thisLastModified );                        
-		} finally {
-			res.release();
-		}
-	}		
-
-
-	public static void printFeed( String title, String indent, Feed feed ) {
-		if ( feed == null ) {
-			System.out.println( title + " feed is null");
-			return;
-		}
-			
-		System.out.println( title );
-		System.out.println( indent + "id=" + feed.getId() );
-		System.out.println( indent + "title=" + feed.getTitle() );
-		System.out.println( indent + "updated=" + feed.getUpdated() );
-		System.out.println( indent + "author=" + feed.getAuthor() );
-		Collection collection = feed.getCollection();
-		if ( collection == null ) {
-			System.out.println( indent + "collection=null" );
-		} else {
-			System.out.println( indent + "collection=" + collection );
-		}
-		// System.out.println( indent + "collection size=" + feed.getCollection() );
-		// for (Collection collection : workspace.getCollections()) {
-		//    if (collection.getTitle().equals("customers")) {
-		//       String expected = uri + "customers";
-		//       String actual = collection.getResolvedHref().toString();
-		//       assertEquals(expected, actual);
-		//    }
-		// }
+    protected static final SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z"); // RFC
+                                                                                                              // 822
+                                                                                                              // date
+                                                                                                              // time
+
+    @BeforeClass
+    public static void init() throws Exception {
+        System.out.println(">>>ProviderFeedEntityTagsTest.init");
+        String contribution = ContributionLocationHelper.getContributionLocation(AtomDeleteTestCase.class);
+        providerNode = NodeFactory.newInstance().createNode(
+                                                               "org/apache/tuscany/sca/binding/atom/Provider.composite", new Contribution("provider", contribution));
+        providerNode.start();
+        abdera = new Abdera();
+        client = new AbderaClient(abdera);
+        abderaParser = Abdera.getNewParser();
+    }
+
+    @AfterClass
+    public static void destroy() throws Exception {
+        System.out.println(">>>ProviderFeedEntityTagsTest.destroy");
+        providerNode.stop();
+        providerNode.destroy();
+    }
+
+    @Test
+    public void testPrelim() throws Exception {
+        Assert.assertNotNull(providerNode);
+        Assert.assertNotNull(client);
+    }
+
+    @Test
+    public void testFeedBasics() throws Exception {
+        System.out.println(">>>ProviderFeedEntityTagsTest.testFeedBasics");
+        // Normal feed request
+        ClientResponse res = client.get(providerURI);
+        Assert.assertNotNull(res);
+        try {
+            // Asser feed provided since no predicates
+            Assert.assertEquals(200, res.getStatus());
+            Assert.assertEquals(ResponseType.SUCCESS, res.getType());
+            // AtomTestCaseUtils.printResponseHeaders( "Feed response headers:",
+            // "   ", res );
+            // System.out.println("Feed response content:");
+            // AtomTestCaseUtils.prettyPrint(abdera, res.getDocument());
+
+            // Perform other tests on feed.
+            Document<Feed> doc = res.getDocument();
+            Assert.assertNotNull(doc);
+            Feed feed = doc.getRoot();
+            Assert.assertNotNull(feed);
+            printFeed("Feed values", "   ", feed);
+            // RFC 4287 requires non-null id, title, updated elements
+            Assert.assertNotNull(feed.getId());
+            Assert.assertNotNull(feed.getTitle());
+            Assert.assertNotNull(feed.getUpdated());
+
+            eTag = res.getHeader("ETag");
+            Assert.assertNotNull(eTag);
+            lastModified = res.getLastModified();
+            Assert.assertNotNull(lastModified);
+        } finally {
+            res.release();
+        }
+    }
+
+    @Test
+    public void testUnmodifiedGetIfMatch() throws Exception {
+        System.out.println(">>>ProviderFeedEntityTagsTest.testFeedUnmodifiedGetIfMatch");
+        // Feed request with predicates
+        RequestOptions opts = new RequestOptions();
+        final String contentType = "application/atom+xml";
+        opts.setContentType(contentType);
+        opts.setHeader("If-Match", eTag);
+
+        ClientResponse res = client.get(providerURI, opts);
+        Assert.assertNotNull(res);
+        try {
+            String thisETag = res.getHeader("ETag");
+            Assert.assertNotNull(thisETag);
+            Date thisLastModified = res.getLastModified();
+            Assert.assertNotNull(thisLastModified);
+
+            // Should return 200 - Feed provided since it matches etag.
+            Assert.assertEquals(200, res.getStatus());
+            Assert.assertEquals(ResponseType.SUCCESS, res.getType());
+            // AtomTestCaseUtils.printResponseHeaders( "Feed response headers:",
+            // "   ", res );
+            // System.out.println("Feed response content:");
+            // AtomTestCaseUtils.prettyPrint(abdera, res.getDocument());
+        } finally {
+            res.release();
+        }
+    }
+
+    @Test
+    public void testUnmodifiedGetIfNoneMatch() throws Exception {
+        System.out.println(">>>ProviderFeedEntityTagsTest.testFeedUnmodifiedGetIfNoneMatch");
+        // Feed request with predicates
+        RequestOptions opts = new RequestOptions();
+        final String contentType = "application/atom+xml";
+        opts.setContentType(contentType);
+        opts.setHeader("If-None-Match", eTag);
+
+        ClientResponse res = client.get(providerURI, opts);
+        Assert.assertNotNull(res);
+        try {
+            // Should return 304 - Feed not provided since it matches ETag.
+            Assert.assertEquals(304, res.getStatus());
+        } finally {
+            res.release();
+        }
+    }
+
+    @Test
+    public void testUnmodifiedGetIfUnModified() throws Exception {
+        System.out.println(">>>ProviderFeedEntityTagsTest.testFeedUnmodifiedGetIfUnModified");
+        // Feed request with predicates
+        RequestOptions opts = new RequestOptions();
+        final String contentType = "application/atom+xml";
+        opts.setContentType(contentType);
+        opts.setHeader("If-Unmodified-Since", dateFormat.format(new Date()));
+
+        ClientResponse res = client.get(providerURI, opts);
+        Assert.assertNotNull(res);
+        try {
+            // Should return 304 - Feed not provided since feed is modified
+            // since.
+            Assert.assertEquals(304, res.getStatus());
+        } finally {
+            res.release();
+        }
+    }
+
+    @Test
+    public void testUnmodifiedGetIfModified() throws Exception {
+        System.out.println(">>>ProviderFeedEntityTagsTest.testFeedUnmodifiedGetIfModified");
+        // Feed request with predicates
+        RequestOptions opts = new RequestOptions();
+        final String contentType = "application/atom+xml";
+        opts.setContentType(contentType);
+        opts.setHeader("If-Modified-Since", dateFormat.format(new Date(0)));
+
+        ClientResponse res = client.get(providerURI, opts);
+        Assert.assertNotNull(res);
+        try {
+            // Should return 200 - Feed provided since feed is changed.
+            Assert.assertEquals(200, res.getStatus());
+            Assert.assertEquals(ResponseType.SUCCESS, res.getType());
+
+            String thisETag = res.getHeader("ETag");
+            Assert.assertNotNull(thisETag);
+            Date thisLastModified = res.getLastModified();
+            Assert.assertNotNull(thisLastModified);
+        } finally {
+            res.release();
+        }
+    }
+
+    @Test
+    public void testModifiedGetIfNoneMatch() throws Exception {
+        System.out.println(">>>ProviderFeedEntityTagsTest.testFeedModifiedGetIfNoneMatch");
+        // Post some new content to the feed.
+        Factory factory = abdera.getFactory();
+        String customerName = "Fred Farkle";
+        Entry entry = factory.newEntry();
+        entry.setTitle("customer " + customerName);
+        entry.setUpdated(new Date());
+        entry.addAuthor("Apache Tuscany");
+        Content content = abdera.getFactory().newContent();
+        content.setContentType(Content.Type.TEXT);
+        content.setValue(customerName);
+        entry.setContentElement(content);
+
+        RequestOptions opts = new RequestOptions();
+        String contentType = "application/atom+xml; type=entry";
+        opts.setContentType(contentType);
+        IRI colUri = new IRI(providerURI).resolve("customer");
+        ClientResponse res = client.post(colUri.toString(), entry, opts);
+
+        // Feed request with predicates
+        opts = new RequestOptions();
+        contentType = "application/atom+xml";
+        opts.setContentType(contentType);
+        opts.setHeader("If-None-Match", eTag);
+
+        res = client.get(providerURI, opts);
+        Assert.assertNotNull(res);
+        try {
+            String thisETag = res.getHeader("ETag");
+            Assert.assertNotNull(thisETag);
+            Date thisLastModified = res.getLastModified();
+            Assert.assertNotNull(thisLastModified);
+
+            // Should return 200 - value since feed is changed
+            Assert.assertEquals(200, res.getStatus());
+            Assert.assertEquals(ResponseType.SUCCESS, res.getType());
+
+            // AtomTestCaseUtils.printResponseHeaders(
+            // "Feed modified if-none-match response headers:", "   ", res );
+            // System.out.println("Feed response content:");
+            // AtomTestCaseUtils.prettyPrint(abdera, res.getDocument());
+        } finally {
+            res.release();
+        }
+    }
+
+    @Test
+    public void testModifiedGetIfMatch() throws Exception {
+        System.out.println(">>>ProviderFeedEntityTagsTest.testFeedModifiedGetIfMatch");
+        // Feed request with predicates
+        RequestOptions opts = new RequestOptions();
+        final String contentType = "application/atom+xml";
+        opts.setContentType(contentType);
+        opts.setHeader("If-Match", eTag);
+
+        ClientResponse res = client.get(providerURI, opts);
+        Assert.assertNotNull(res);
+        try {
+            // Should return 412 - Precondition failed since feed changed.
+            Assert.assertEquals(412, res.getStatus());
+            // AtomTestCaseUtils.printResponseHeaders( "Feed response headers:",
+            // "   ", res );
+            // System.out.println("Feed response content:");
+            // AtomTestCaseUtils.prettyPrint(abdera, res.getDocument());
+        } finally {
+            res.release();
+        }
+    }
+
+    @Test
+    public void testModifiedGetIfUnModified() throws Exception {
+        System.out.println(">>>ProviderFeedEntityTagsTest.testFeedUnmodifiedGetIfUnModified");
+        // Feed request with predicates
+        RequestOptions opts = new RequestOptions();
+        final String contentType = "application/atom+xml";
+        opts.setContentType(contentType);
+        opts.setHeader("If-Unmodified-Since", dateFormat.format(new Date()));
+
+        ClientResponse res = client.get(providerURI, opts);
+        Assert.assertNotNull(res);
+        try {
+            // Should return 304 - Feed not provided since feed is modified
+            // since.
+            Assert.assertEquals(304, res.getStatus());
+        } finally {
+            res.release();
+        }
+    }
+
+    @Test
+    public void testModifiedGetIfModified() throws Exception {
+        System.out.println(">>>ProviderFeedEntityTagsTest.testFeedUnmodifiedGetIfModified");
+        // Feed request with predicates
+        RequestOptions opts = new RequestOptions();
+        final String contentType = "application/atom+xml";
+        opts.setContentType(contentType);
+        opts.setHeader("If-Modified-Since", dateFormat.format(lastModified));
+
+        ClientResponse res = client.get(providerURI, opts);
+        Assert.assertNotNull(res);
+        try {
+            // Should return 200 - Feed provided since feed is changed.
+            Assert.assertEquals(200, res.getStatus());
+            Assert.assertEquals(ResponseType.SUCCESS, res.getType());
+
+            String thisETag = res.getHeader("ETag");
+            Assert.assertNotNull(thisETag);
+            Date thisLastModified = res.getLastModified();
+            Assert.assertNotNull(thisLastModified);
+        } finally {
+            res.release();
+        }
+    }
+
+    public static void printFeed(String title, String indent, Feed feed) {
+        if (feed == null) {
+            System.out.println(title + " feed is null");
+            return;
+        }
+
+        System.out.println(title);
+        System.out.println(indent + "id=" + feed.getId());
+        System.out.println(indent + "title=" + feed.getTitle());
+        System.out.println(indent + "updated=" + feed.getUpdated());
+        System.out.println(indent + "author=" + feed.getAuthor());
+        Collection collection = feed.getCollection();
+        if (collection == null) {
+            System.out.println(indent + "collection=null");
+        } else {
+            System.out.println(indent + "collection=" + collection);
+        }
+        // System.out.println( indent + "collection size=" +
+        // feed.getCollection() );
+        // for (Collection collection : workspace.getCollections()) {
+        // if (collection.getTitle().equals("customers")) {
+        // String expected = uri + "customers";
+        // String actual = collection.getResolvedHref().toString();
+        // assertEquals(expected, actual);
+        // }
+        // }
 
-	}
+    }
 
 }

Modified: tuscany/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderServiceDocumentTest.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderServiceDocumentTest.java?rev=703068&r1=703067&r2=703068&view=diff
==============================================================================
--- tuscany/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderServiceDocumentTest.java (original)
+++ tuscany/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderServiceDocumentTest.java Wed Oct  8 23:33:54 2008
@@ -18,94 +18,98 @@
  */
 package org.apache.tuscany.sca.binding.atom;
 
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.List;
-
 import junit.framework.Assert;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import org.apache.tuscany.sca.host.embedded.SCADomain;
-import org.apache.tuscany.sca.binding.atom.collection.Collection;
 
 import org.apache.abdera.Abdera;
-import org.apache.abdera.i18n.iri.IRI;
-import org.apache.abdera.factory.Factory;
 import org.apache.abdera.model.Content;
+import org.apache.abdera.model.Document;
 import org.apache.abdera.model.Entry;
 import org.apache.abdera.model.Feed;
-import org.apache.abdera.model.Document;
 import org.apache.abdera.model.Service;
+import org.apache.abdera.parser.Parser;
 import org.apache.abdera.protocol.Response.ResponseType;
 import org.apache.abdera.protocol.client.AbderaClient;
 import org.apache.abdera.protocol.client.ClientResponse;
-import org.apache.abdera.protocol.client.RequestOptions;
-import org.apache.abdera.parser.Parser;
+import org.apache.tuscany.sca.binding.atom.collection.Collection;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
 
 /**
  * Tests use of service documents provided by atom binding based collections.
- * Uses the SCA provided Provider composite to act as a server.
- * Uses the Abdera provided Client to act as a client.
+ * Uses the SCA provided Provider composite to act as a server. Uses the Abdera
+ * provided Client to act as a client.
  */
 public class ProviderServiceDocumentTest {
-	public final static String providerURI = "http://localhost:8084/customer";
-	protected static SCADomain scaProviderDomain;
-    protected static SCADomain scaConsumerDomain;
+    public final static String providerURI = "http://localhost:8084/customer";
+    protected static Node providerNode;
+    protected static Node consumerNode;
     protected static CustomerClient testService;
     protected static Abdera abdera;
     protected static AbderaClient client;
-    protected static Parser abderaParser;    
+    protected static Parser abderaParser;
+
+    @BeforeClass
+    public static void init() throws Exception {
+        String contribution = ContributionLocationHelper.getContributionLocation(AtomDeleteTestCase.class);
+        providerNode = NodeFactory.newInstance().createNode(
+                                                               "org/apache/tuscany/sca/binding/atom/Provider.composite", new Contribution("provider", contribution));
+        consumerNode = NodeFactory.newInstance().createNode(
+                                                               "org/apache/tuscany/sca/binding/atom/Consumer.composite", new Contribution("consumer", contribution));
+        providerNode.start();
+        consumerNode.start();
+        testService = consumerNode.getService(CustomerClient.class, "CustomerClient");
+        abdera = new Abdera();
+        client = new AbderaClient(abdera);
+        abderaParser = Abdera.getNewParser();
+    }
 
-	@BeforeClass
-	public static void init() throws Exception {
-		scaProviderDomain = SCADomain.newInstance("org/apache/tuscany/sca/binding/atom/Provider.composite");
-        scaConsumerDomain = SCADomain.newInstance("org/apache/tuscany/sca/binding/atom/Consumer.composite");
-        testService = scaConsumerDomain.getService(CustomerClient.class, "CustomerClient");
-		abdera = new Abdera();
-		client = new AbderaClient(abdera);
-		abderaParser = Abdera.getNewParser();
-	}
-
-	@AfterClass
-	public static void destroy() throws Exception {
-		scaProviderDomain.close();
-	}
-
-	@Test
-	public void testPrelim() throws Exception {
-		Assert.assertNotNull(scaProviderDomain);
-		Assert.assertNotNull( client );
-	}
-			
-	@Test
-    public void testFeedBasics() throws Exception {		
-		// Normal feed request
-		ClientResponse res = client.get(providerURI);
-		Assert.assertNotNull(res);
-		try {
-			// Assert feed provided since no predicates
-			Assert.assertEquals(200, res.getStatus());
-			Assert.assertEquals(ResponseType.SUCCESS, res.getType());
-	    	// AtomTestCaseUtils.printResponseHeaders( "Feed response headers:", "   ", res );
-	    	// System.out.println("Feed response content:");
-	    	// AtomTestCaseUtils.prettyPrint(abdera, res.getDocument());
-
-	    	// Perform other tests on feed.
-			Document<Feed> doc = res.getDocument();
-			Assert.assertNotNull( doc );
-			Feed feed = doc.getRoot();
-			Assert.assertNotNull( feed );
-			// printFeed( "Feed values", "   ", feed );
-			// RFC 4287 requires non-null id, title, updated elements
-			Assert.assertNotNull( feed.getId() );
-			Assert.assertNotNull( feed.getTitle() );
-			Assert.assertNotNull( feed.getUpdated() );
-		} finally {
-			res.release();
-		}
-	}		
+    @AfterClass
+    public static void destroy() throws Exception {
+        providerNode.stop();
+        providerNode.destroy();
+        consumerNode.stop();
+        consumerNode.destroy();
+    }
+
+    @Test
+    public void testPrelim() throws Exception {
+        Assert.assertNotNull(providerNode);
+        Assert.assertNotNull(client);
+    }
+
+    @Test
+    public void testFeedBasics() throws Exception {
+        // Normal feed request
+        ClientResponse res = client.get(providerURI);
+        Assert.assertNotNull(res);
+        try {
+            // Assert feed provided since no predicates
+            Assert.assertEquals(200, res.getStatus());
+            Assert.assertEquals(ResponseType.SUCCESS, res.getType());
+            // AtomTestCaseUtils.printResponseHeaders( "Feed response headers:",
+            // "   ", res );
+            // System.out.println("Feed response content:");
+            // AtomTestCaseUtils.prettyPrint(abdera, res.getDocument());
+
+            // Perform other tests on feed.
+            Document<Feed> doc = res.getDocument();
+            Assert.assertNotNull(doc);
+            Feed feed = doc.getRoot();
+            Assert.assertNotNull(feed);
+            // printFeed( "Feed values", "   ", feed );
+            // RFC 4287 requires non-null id, title, updated elements
+            Assert.assertNotNull(feed.getId());
+            Assert.assertNotNull(feed.getTitle());
+            Assert.assertNotNull(feed.getUpdated());
+        } finally {
+            res.release();
+        }
+    }
 
     @Test
     public void testServiceDocumentGet() throws Exception {
@@ -119,56 +123,57 @@
         postEntry = postEntry("Count Dracula");
         newEntry = resourceCollection.post(postEntry);
 
-		// Service document
-		ClientResponse res = client.get(providerURI + "/atomsvc");
-		Assert.assertNotNull(res);
-		try {
-			// Asser feed provided since no predicates
-			Assert.assertEquals(200, res.getStatus());
-			Assert.assertEquals(ResponseType.SUCCESS, res.getType());
-
-	    	// Perform other tests on feed.
-	    	// AtomTestCaseUtils.prettyPrint(abdera, res.getDocument());	    	
-			Document<Service> serviceDoc = res.getDocument();
-			Service service = serviceDoc.getRoot();
-			Assert.assertNotNull( service );
-			org.apache.abdera.model.Collection collection =  service.getCollection( "workspace", "customers" );
-			String title = collection.getTitle();
-			Assert.assertEquals("customers", title);
-			String href = collection.getHref().toString();
-			Assert.assertTrue( href.contains( "customer") );
-		} finally {
-			res.release();
-		}
-    }
-
-	public static void printFeed( String title, String indent, Feed feed ) {
-		if ( feed == null ) {
-			System.out.println( title + " feed is null");
-			return;
-		}
-			
-		System.out.println( title );
-		System.out.println( indent + "id=" + feed.getId() );
-		System.out.println( indent + "title=" + feed.getTitle() );
-		System.out.println( indent + "updated=" + feed.getUpdated() );
-		System.out.println( indent + "author=" + feed.getAuthor() );
-		// Collection collection = feed.getCollection();
-		// if ( collection == null ) {
-		// 	System.out.println( indent + "collection=null" );
-		// } else {
-		// 	System.out.println( indent + "collection=" + collection );
-		// }
-		// System.out.println( indent + "collection size=" + feed.getCollection() );
-		// for (Collection collection : workspace.getCollections()) {
-		//    if (collection.getTitle().equals("customers")) {
-		//       String expected = uri + "customers";
-		//       String actual = collection.getResolvedHref().toString();
-		//       assertEquals(expected, actual);
-		//    }
-		// }
+        // Service document
+        ClientResponse res = client.get(providerURI + "/atomsvc");
+        Assert.assertNotNull(res);
+        try {
+            // Asser feed provided since no predicates
+            Assert.assertEquals(200, res.getStatus());
+            Assert.assertEquals(ResponseType.SUCCESS, res.getType());
+
+            // Perform other tests on feed.
+            // AtomTestCaseUtils.prettyPrint(abdera, res.getDocument());
+            Document<Service> serviceDoc = res.getDocument();
+            Service service = serviceDoc.getRoot();
+            Assert.assertNotNull(service);
+            org.apache.abdera.model.Collection collection = service.getCollection("workspace", "customers");
+            String title = collection.getTitle();
+            Assert.assertEquals("customers", title);
+            String href = collection.getHref().toString();
+            Assert.assertTrue(href.contains("customer"));
+        } finally {
+            res.release();
+        }
+    }
+
+    public static void printFeed(String title, String indent, Feed feed) {
+        if (feed == null) {
+            System.out.println(title + " feed is null");
+            return;
+        }
+
+        System.out.println(title);
+        System.out.println(indent + "id=" + feed.getId());
+        System.out.println(indent + "title=" + feed.getTitle());
+        System.out.println(indent + "updated=" + feed.getUpdated());
+        System.out.println(indent + "author=" + feed.getAuthor());
+        // Collection collection = feed.getCollection();
+        // if ( collection == null ) {
+        // System.out.println( indent + "collection=null" );
+        // } else {
+        // System.out.println( indent + "collection=" + collection );
+        // }
+        // System.out.println( indent + "collection size=" +
+        // feed.getCollection() );
+        // for (Collection collection : workspace.getCollections()) {
+        // if (collection.getTitle().equals("customers")) {
+        // String expected = uri + "customers";
+        // String actual = collection.getResolvedHref().toString();
+        // assertEquals(expected, actual);
+        // }
+        // }
 
-	}
+    }
 
     private Entry postEntry(String value) {
         Entry entry = abdera.newEntry();

Modified: tuscany/branches/sca-equinox/modules/binding-ejb-runtime/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-equinox/modules/binding-ejb-runtime/pom.xml?rev=703068&r1=703067&r2=703068&view=diff
==============================================================================
--- tuscany/branches/sca-equinox/modules/binding-ejb-runtime/pom.xml (original)
+++ tuscany/branches/sca-equinox/modules/binding-ejb-runtime/pom.xml Wed Oct  8 23:33:54 2008
@@ -73,7 +73,7 @@
 
         <dependency>
             <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-host-embedded</artifactId>
+            <artifactId>tuscany-node-impl</artifactId>
             <version>1.4-SNAPSHOT</version>
             <scope>test</scope>
         </dependency>

Modified: tuscany/branches/sca-equinox/modules/binding-ejb-runtime/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/EJBReferenceTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-equinox/modules/binding-ejb-runtime/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/EJBReferenceTestCase.java?rev=703068&r1=703067&r2=703068&view=diff
==============================================================================
--- tuscany/branches/sca-equinox/modules/binding-ejb-runtime/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/EJBReferenceTestCase.java (original)
+++ tuscany/branches/sca-equinox/modules/binding-ejb-runtime/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/EJBReferenceTestCase.java Wed Oct  8 23:33:54 2008
@@ -20,7 +20,10 @@
 
 import junit.framework.TestCase;
 
-import org.apache.tuscany.sca.host.embedded.SCADomain;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
 
 import account.Customer;
 
@@ -31,7 +34,7 @@
  */
 public class EJBReferenceTestCase extends TestCase {
     private static final int MOCK_PORT = 8085;
-    private SCADomain scaDomain;
+    private Node node;
 
     @Override
     protected void setUp() throws Exception {
@@ -39,7 +42,9 @@
         System.setProperty("java.naming.provider.url", "ejbd://localhost:" + MOCK_PORT);
         System.setProperty("managed", "false");
 
-        scaDomain = SCADomain.newInstance("account/account.composite");
+        String contribution = ContributionLocationHelper.getContributionLocation(EJBReferenceTestCase.class);
+        node = NodeFactory.newInstance().createNode("account/account.composite", new Contribution("account", contribution));
+        node.start();
 
         // To capture the network traffic for the MockServer, uncomment the next line
         // new Thread(new SocketTracer(MOCK_PORT, OPENEJB_PORT)).start();
@@ -53,11 +58,12 @@
 
     @Override
     protected void tearDown() throws Exception {
-        scaDomain.close();
+        node.stop();
+        node.destroy();
     }
 
     public void testCalculator() throws Exception {
-        Customer customer = scaDomain.getService(Customer.class, "CustomerComponent");
+        Customer customer = node.getService(Customer.class, "CustomerComponent");
         // This is one of the customer numbers in bank application running on Geronimo
         String accountNo = "1234567890";
         Double balance = customer.depositAmount(accountNo, new Double(100));

Modified: tuscany/branches/sca-equinox/modules/binding-gdata-runtime-gsoc/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-equinox/modules/binding-gdata-runtime-gsoc/pom.xml?rev=703068&r1=703067&r2=703068&view=diff
==============================================================================
--- tuscany/branches/sca-equinox/modules/binding-gdata-runtime-gsoc/pom.xml (original)
+++ tuscany/branches/sca-equinox/modules/binding-gdata-runtime-gsoc/pom.xml Wed Oct  8 23:33:54 2008
@@ -135,12 +135,12 @@
 			<scope>test</scope>
 		</dependency>
 
-		<dependency>
-			<groupId>org.apache.tuscany.sca</groupId>
-			<artifactId>tuscany-host-embedded</artifactId>
-			<version>1.4-SNAPSHOT</version>
-			<scope>test</scope>
-		</dependency>
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-node-impl</artifactId>
+            <version>1.4-SNAPSHOT</version>
+            <scope>test</scope>
+        </dependency>
 
 		<dependency>
 			<groupId>junit</groupId>

Modified: tuscany/branches/sca-equinox/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/Consumer.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-equinox/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/Consumer.java?rev=703068&r1=703067&r2=703068&view=diff
==============================================================================
--- tuscany/branches/sca-equinox/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/Consumer.java (original)
+++ tuscany/branches/sca-equinox/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/Consumer.java Wed Oct  8 23:33:54 2008
@@ -19,7 +19,10 @@
 
 package org.apache.tuscany.sca.binding.gdata;
 
-import org.apache.tuscany.sca.host.embedded.SCADomain;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
 
 import com.google.gdata.data.Entry;
 import com.google.gdata.data.Feed;
@@ -30,8 +33,11 @@
     public static void main(String[] args) throws Exception {
 
         //Initialize the GData client service (Reference Binding test)
-        SCADomain scaDomain = SCADomain.newInstance("org/apache/tuscany/sca/binding/gdata/ConsumerGoogleBlogger.composite");
-        CustomerClient testService = scaDomain.getService(CustomerClient.class, "CustomerClient");          
+        String contribution = ContributionLocationHelper.getContributionLocation(Consumer.class);
+        Node node = NodeFactory.newInstance().createNode(
+                                                     "org/apache/tuscany/sca/binding/gdata/ConsumerGoogleBlogger.composite", new Contribution("consumer", contribution));
+        node.start();
+        CustomerClient testService = node.getService(CustomerClient.class, "CustomerClient");          
         
         
         Feed feed = testService.clientGetFeed();