summaryrefslogtreecommitdiffstats
path: root/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderServiceDocumentTest.java
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2008-10-09 06:33:54 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2008-10-09 06:33:54 +0000
commitefe3363a815a777ecd283928900404dea84a7e1f (patch)
tree42522fd01e6af981f8ff94663d911d56744154d5 /branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderServiceDocumentTest.java
parentaacabe1650e380595a8d701123394d791656d17d (diff)
Work in progress. Fixed implementation of NodeImpl, now working without dependencies on implementations from other bundles (except RuntimeAssemblyFactory, which will need to be cleaned up too). Started to remove dependencies on host-embedded and port code to NodeFactory and Node, as an interim step to bring them up, before porting them to the OSGi-enabled node launcher.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@703068 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r--branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderServiceDocumentTest.java241
1 files changed, 123 insertions, 118 deletions
diff --git a/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderServiceDocumentTest.java b/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderServiceDocumentTest.java
index 816be8b6e5..93cbf29766 100644
--- a/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderServiceDocumentTest.java
+++ b/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderServiceDocumentTest.java
@@ -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;
-
- @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();
- }
- }
+ 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();
+ }
+
+ @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 @@ public class ProviderServiceDocumentTest {
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();
- }
+ // 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);
- // }
- // }
-
- }
+ 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();