Modified: 
tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataReferenceBindingProvider.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataReferenceBindingProvider.java?rev=677508&r1=677507&r2=677508&view=diff
==============================================================================
--- 
tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataReferenceBindingProvider.java
 (original)
+++ 
tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataReferenceBindingProvider.java
 Wed Jul 16 23:21:15 2008
@@ -42,6 +42,9 @@
 import org.apache.tuscany.sca.runtime.RuntimeComponent;
 import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
 
+import com.google.gdata.client.GoogleService;
+import com.google.gdata.util.AuthenticationException;
+
 /**
  * Implementation of the Atom binding provider.
  * 
@@ -52,6 +55,7 @@
     private RuntimeComponentReference reference;
     private GdataBinding binding;
     private String authorizationHeader;
+    private GoogleService googleService;
     private HttpClient httpClient;
     private Mediator mediator;
     private DataType<?> itemClassType;
@@ -65,11 +69,12 @@
      * @param reference
      * @param binding
      * @param mediator
+     * @throws AuthenticationException 
      */
     GdataReferenceBindingProvider(RuntimeComponent component,
                                   RuntimeComponentReference reference,
                                   GdataBinding binding,
-                                  Mediator mediator) {
+                                  Mediator mediator) throws 
AuthenticationException {
         this.reference = reference;
         this.binding = binding;
         this.mediator = mediator;
@@ -77,6 +82,23 @@
         // Prepare authorization header
         String authorization = "admin" + ":" + "admin";
         authorizationHeader = "Basic " + new 
String(Base64.encodeBase64(authorization.getBytes()));
+        
+        
+        // Prepare gdata header
+        String serviceType = binding.getServiceType();
+        String usernane = binding.getUsername();
+        String password = binding.getPassword();
+        
+        System.out.println("[Debug Info] binding.getServiceType()" + 
serviceType);
+        System.out.println("[Debug Info] binding.getName()" +usernane);
+        System.out.println("[Debug Info] binding.getPassword()" + password);   
 
+        
+        googleService = new GoogleService(serviceType, "");
+        if(binding.getUsername().equals("admin") == false && 
binding.getPassword().equals("admin")==false){
+            
googleService.setUserCredentials(binding.getUsername(),binding.getPassword());  
   
+        }
+         
+
 
         // Create an HTTP client
         HttpConnectionManager connectionManager = new 
MultiThreadedHttpConnectionManager();
@@ -102,57 +124,53 @@
             qname = new QName(qname.getNamespaceURI(), 
itemClass.getSimpleName());
             itemClassType = new DataTypeImpl<XMLType>("java:complexType", 
itemClass, new XMLType(qname, null));
 
-            // To-change
-            // org.apache.abdera.model.Entry --> com.google.gdata.data.Entry;
-
             if (itemClassType.getPhysical() == 
com.google.gdata.data.Entry.class) {
                 supportsFeedEntries = true;
             }
 
-            // 
//System.out.println("GdataReferenceBindingProvider.createInvoker---operation=get");
-            return new GdataBindingInvoker.GetInvoker(operation, 
binding.getURI(), httpClient, authorizationHeader,
-                                                      this);
+            return new GdataBindingInvoker.GetInvoker(operation, 
binding.getURI(), googleService, httpClient, authorizationHeader, this);
 
         } else if (operationName.equals("post")) {
 
-            // //System.out.println("GdataReferenceBindingProvider 
CreateInvoker
-            // --- post");
-            return new GdataBindingInvoker.PostInvoker(operation, 
binding.getURI(), httpClient, authorizationHeader,
-                                                       this);
+            return new GdataBindingInvoker.PostInvoker(operation, 
binding.getURI(), googleService, httpClient, authorizationHeader, this);
 
         } else if (operationName.equals("put")) {
 
-            return new GdataBindingInvoker.PutInvoker(operation, 
binding.getURI(), httpClient, authorizationHeader,
+            return new GdataBindingInvoker.PutInvoker(operation, 
binding.getURI(),  googleService, httpClient, authorizationHeader,
                                                       this);
         } else if (operationName.equals("delete")) {
-            return new GdataBindingInvoker.DeleteInvoker(operation, 
binding.getURI(), httpClient, authorizationHeader,
+            return new GdataBindingInvoker.DeleteInvoker(operation, 
binding.getURI(),  googleService, httpClient, authorizationHeader,
                                                          this);
         } else if (operationName.equals("getFeed") || 
operationName.equals("getAll")) {
 
             // //System.out.println("GdataReferenceBindingProvider
             // CreateInvoker: getFeed or getAll");
 
-            return new GdataBindingInvoker.GetAllInvoker(operation, 
binding.getURI(), httpClient, authorizationHeader,
+            return new GdataBindingInvoker.GetAllInvoker(operation, 
binding.getURI(),  googleService, httpClient, authorizationHeader,
                                                          this);
 
         } else if (operationName.equals("postMedia")) {
-            return new GdataBindingInvoker.PostMediaInvoker(operation, 
binding.getURI(), httpClient,
+            return new GdataBindingInvoker.PostMediaInvoker(operation, 
binding.getURI(),  googleService, httpClient,
                                                             
authorizationHeader, this);
         } else if (operationName.equals("putMedia")) {
-            return new GdataBindingInvoker.PutMediaInvoker(operation, 
binding.getURI(), httpClient,
+            return new GdataBindingInvoker.PutMediaInvoker(operation, 
binding.getURI(),  googleService, httpClient,
                                                            
authorizationHeader, this);
         } else if (operationName.equals("query")) {
-            return new GdataBindingInvoker.QueryInvoker(operation, 
binding.getURI(), httpClient, authorizationHeader,
+            return new GdataBindingInvoker.QueryInvoker(operation, 
binding.getURI(),  googleService, httpClient, authorizationHeader,
                                                         this);
         }
 
-        return new GdataBindingInvoker(operation, binding.getURI(), 
httpClient, authorizationHeader, this);
+        return new GdataBindingInvoker(operation, binding.getURI(),  
googleService, httpClient, authorizationHeader, this);
     }
 
+    
+    
     public InterfaceContract getBindingInterfaceContract() {
         return reference.getInterfaceContract();
     }
 
+    
+    
     public void start() {
 
         // Configure the HTTP client credentials

Modified: 
tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/Consumer.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/Consumer.java?rev=677508&r1=677507&r2=677508&view=diff
==============================================================================
--- 
tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/Consumer.java
 (original)
+++ 
tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/Consumer.java
 Wed Jul 16 23:21:15 2008
@@ -21,21 +21,40 @@
 
 import org.apache.tuscany.sca.host.embedded.SCADomain;
 
+import com.google.gdata.data.Entry;
+import com.google.gdata.data.Feed;
+import com.google.gdata.data.PlainTextConstruct;
+
 public class Consumer {
 
     public static void main(String[] args) throws Exception {
 
-        SCADomain scaDomain = 
SCADomain.newInstance("org/apache/tuscany/sca/binding/gdata/Consumer.composite");
-
-        CustomerClient testService = 
scaDomain.getService(CustomerClient.class, "CustomerClient");
-
-        //testService.testCustomerCollection();
-
-        testService.testGetFeed(); // Tested, worked
-        testService.testGetEntry(); // Tested, worked
-        testService.testPost(); // Tested, worked
-        testService.testGetFeed(); // Tested, worked
+        //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");          
+        
+        
+        Feed feed = testService.clientGetFeed();
+        
+        System.out.println("#Entries(Before post): "+ 
testService.clientGetFeed().getEntries().size());
+        
+        /*
+        String entryID = 
"tag:blogger.com,1999:blog-4520949313432095990.post-973462497533349425";
+        Entry entry = testService.clientGetEntry(entryID);
+        System.out.println("Entry id: " + entry.getId());
+        */
+        
+        Entry myEntry = new Entry();
+        myEntry.setTitle(new PlainTextConstruct("titleByConsumer2"));
+        myEntry.setContent(new PlainTextConstruct("contentByConsmer2"));
+        testService.clientPost(myEntry);
+        
+        System.out.println("#Entries(After post): "+ 
testService.clientGetFeed().getEntries().size());
+        
+        String entryID = 
"tag:blogger.com,1999:blog-4520949313432095990.post-973462497533349425";
+        Entry entry = testService.clientGetEntry(entryID);
+        System.out.println("Entry id: " + entry.getId());
 
-        scaDomain.close();
+       
     }
 }

Modified: 
tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/CustomerClient.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/CustomerClient.java?rev=677508&r1=677507&r2=677508&view=diff
==============================================================================
--- 
tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/CustomerClient.java
 (original)
+++ 
tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/CustomerClient.java
 Wed Jul 16 23:21:15 2008
@@ -19,16 +19,21 @@
 
 package org.apache.tuscany.sca.binding.gdata;
 
-public interface CustomerClient {
-
-    // void testCustomerCollection() throws Exception;
+import com.google.gdata.data.Entry;
+import com.google.gdata.data.Feed;
 
-    void testGetFeed() throws Exception;
-
-    void testGetEntry() throws Exception;
+public interface CustomerClient {
 
-    void testPost() throws Exception;
+    Feed clientGetFeed() throws Exception;
 
-    // void testCustomerGetEntry() throws Exception;
+    Entry clientGetEntry(String entryID) throws Exception;
+    
+    Entry clientPost(Entry entry) throws Exception;
+    
+    void clientDelete(String entryID) throws Exception;
+    
+    void clientPut(String entryID, String newTitle) throws Exception;
+    
+    //void testQuery() throws Exception;
 
 }

Modified: 
tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/CustomerClientImpl.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/CustomerClientImpl.java?rev=677508&r1=677507&r2=677508&view=diff
==============================================================================
--- 
tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/CustomerClientImpl.java
 (original)
+++ 
tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/CustomerClientImpl.java
 Wed Jul 16 23:21:15 2008
@@ -19,27 +19,25 @@
 
 package org.apache.tuscany.sca.binding.gdata;
 
-import org.apache.abdera.Abdera;
-import org.apache.tuscany.sca.binding.gdata.collection.Collection;
-import org.osoa.sca.annotations.Reference;
-
-import com.google.gdata.data.DateTime;
+import com.google.gdata.data.Feed;
 import com.google.gdata.data.Entry;
 import com.google.gdata.data.PlainTextConstruct;
 
-public class CustomerClientImpl implements CustomerClient {
+import org.apache.tuscany.sca.binding.gdata.collection.Collection;
+import org.apache.tuscany.sca.binding.gdata.collection.NotFoundException;
+import org.osoa.sca.annotations.Reference;
 
-    protected final Abdera abdera = new Abdera();
+public class CustomerClientImpl implements CustomerClient {
 
     @Reference
     public Collection resourceCollection;
 
-    // Test Collection.getFeed()
-    public void testGetFeed() throws Exception {
-        // Get all the entries from the provider
-        System.out.println("\n\n+++++++++++ get the feed from the provider 
service +++++++++++");
-        com.google.gdata.data.Feed feed = resourceCollection.getFeed();
-        System.out.println("\n\n\n!!!Fetched feed title:  " + 
feed.getTitle().getPlainText());
+    // Call Collection.getFeed()
+    public Feed clientGetFeed() throws Exception {
+        // Get all the entries from the provider, return in a single feed
+        System.out.println(">>> get the feed from the provider service");
+        Feed feed = resourceCollection.getFeed();
+        System.out.println("\n\n!!! Fetched feed title:  " + 
feed.getTitle().getPlainText());
         int i = 0;
         for (Object o : feed.getEntries()) {
             com.google.gdata.data.Entry e = (com.google.gdata.data.Entry)o;
@@ -47,109 +45,65 @@
             System.out.println(" id = " + e.getId() + "\t title = " + 
e.getTitle().getPlainText());
             i++;
         }
-        
System.out.println("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
-        System.out.println("\n\n\n");
+        return feed;
     }
-
-    // Test Collection.get(entryID)
-    public void testGetEntry() throws Exception {
-
+        
+    
+    // Call Collection.get(entryID)
+    public Entry clientGetEntry(String entryID) throws Exception {
         // Get an existing entry based on its id
-        System.out.println("+++++++++++ get an existing entry from the 
provider service +++++++++++");
-        System.out.println(">>> get an entry based on its id");
-        Entry entry = resourceCollection.get("urn:uuid:customer-0");
-        System.out.println("\n\n\n!!! Entry retrieved with id=" + entry.getId()
+        System.out.println(">>> get an existing entry from the provider 
service");
+        Entry entry = resourceCollection.get(entryID);
+        System.out.println("\n\n!!! Entry retrieved with id=" + entry.getId()
             + " title="
             + entry.getTitle().getPlainText());
-        
System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
-        System.out.println("\n\n\n");
-
+        return entry;
     }
 
-    // Test Collection.post(newEntry)
-    public void testPost() throws Exception {
-
+       
+    // Call Collection.post(newEntry)
+    public Entry clientPost(Entry newEntry) throws Exception {
         // Put a new entry to the provider
-        System.out.println("+++++++++++ post a new entry to the provider 
service +++++++++++");
-        Entry newEntry = new Entry();
-        newEntry.setTitle(new PlainTextConstruct("NewEntry title"));
-        newEntry.setContent(new PlainTextConstruct("NewEntry Content"));
-        System.out.println(">>> post a new entry:  title=" + 
newEntry.getTitle().getPlainText());
+        System.out.println(">>> post a new entry to the provider service");
         Entry confirmedNewEntry = resourceCollection.post(newEntry);
         System.out.println("!!! New entry posted with id=" + 
confirmedNewEntry.getId()
             + " title="
-            + confirmedNewEntry.getTitle());
+            + confirmedNewEntry.getTitle().getPlainText());        
         System.out.println("\n");
+        return confirmedNewEntry;
     }
 
-    /*
-     * public void testCustomerCollection() throws Exception { //Put a new 
entry
-     * to the provider System.out.println("\n\n+++++++++++ post a new entry to
-     * the provider service +++++++++++"); Entry newEntry =
-     * newEntry("newtitle"); newEntry.addAuthor("newAuthor");
-     * System.out.println(">>> post a new entry: title=" + newEntry.getTitle() 
+ "
-     * author=" + newEntry.getAuthor().getName()); newEntry =
-     * resourceCollection.post(newEntry); System.out.println("!!! New entry
-     * posted with id=" + newEntry.getId() + " title=" + newEntry.getTitle());
-     * System.out.println("\n"); //Put a new entry to the provider
-     * System.out.println("+++++++++++ post a new entry to the provider service
-     * +++++++++++"); newEntry = newEntry("newtitleTemp");
-     * newEntry.addAuthor("newAuthorTemp"); System.out.println(">>> post a new
-     * entry: title=" + newEntry.getTitle() + " author=" +
-     * newEntry.getAuthor().getName()); newEntry =
-     * resourceCollection.post(newEntry); System.out.println("!!! New entry
-     * posted with id=" + newEntry.getId() + " title=" + newEntry.getTitle());
-     * System.out.println("\n"); //Get an existing entry based on its id
-     * System.out.println("+++++++++++ get an existing entry from the provider
-     * service +++++++++++"); System.out.println(">>> get an entry based on its
-     * id"); Entry entry = resourceCollection.get(newEntry.getId().toString());
-     * System.out.println("!!! Entry retrieved with id=" + entry.getId() + "
-     * title=" + entry.getTitle()); System.out.println("\n"); //Update an
-     * existing entry based on its id System.out.println("+++++++++++ update an
-     * existing entry in the provider service +++++++++++");
-     * System.out.println(">>> put id=" + entry.getId() + "
-     * title=updatedTitle"); resourceCollection.put(entry.getId().toString(),
-     * updateEntry(entry, "updatedTitle")); System.out.println("!!! Updated
-     * entry with id=" + entry.getId() + " title=" + entry.getTitle());
-     * System.out.println("\n"); System.out.println("+++++++++++ delete an
-     * existing entry from the provider service +++++++++++");
-     * System.out.println(">>> delete id=" + entry.getId());
-     * resourceCollection.delete(entry.getId().toString());
-     * System.out.println("!!! entry deleted"); //Get all the entries from the
-     * provider System.out.println("\n\n+++++++++++ get all the entries from 
the
-     * provider service +++++++++++"); Feed feed = 
resourceCollection.getFeed();
-     * int i=0; for (Object o : feed.getEntries()) { Entry e = (Entry)o;
-     * System.out.print("Entry" + i + "\t"); System.out.println(" id = " +
-     * e.getId() + "\t title = " + e.getTitle()+ "\t author = " +
-     * e.getAuthor().getName()); i++; } }
-     */
-
-    private Entry newEntry(String value) {
-        /*
-         * Entry entry = this.abdera.newEntry(); entry.setTitle(value); Content
-         * content = this.abdera.getFactory().newContent();
-         * content.setContentType(Content.Type.TEXT); content.setValue(value);
-         * entry.setContentElement(content);
-         */
-
-        Entry entry = new Entry();
-        entry.setTitle(new PlainTextConstruct(value));
-        entry.setContent(new PlainTextConstruct(value));
-        entry.setUpdated(DateTime.now());
-        // entry.addHtmlLink("http://www.google.com";, "languageType", "title");
-        return entry;
+    
+    // Call Collection.delete(newEntry)
+    public void clientDelete(String entryID) throws Exception {
+        // Put a new entry to the provider
+        System.out.println(">>> delete an existing entry from the provider 
service");
+        System.out.println(">>> delete id=" + "urn:uuid:customer-1");
+        resourceCollection.delete(entryID);
+        System.out.println("!!! entry with id" + entryID);
+        System.out.println("\n");
     }
+    
+    
+    
+    // Call Collection.put(entry, updatedTitle)
+    public void clientPut(String entryID, String newTitle) throws Exception {
 
-    private Entry updateEntry(Entry entry, String value) {
-        /*
-         * entry.setTitle(value); Content content =
-         * this.abdera.getFactory().newContent();
-         * content.setContentType(Content.Type.TEXT); content.setValue(value);
-         * entry.setContentElement(content);
-         */
-        entry.setTitle(new PlainTextConstruct("Entry title: " + value));
-        entry.setContent(new PlainTextConstruct(value));
-        return entry;
+        System.out.println("clientPut");
+        // Put a new entry to the provider
+        System.out.println(">>> put id=" + entryID + " title=updatedTitle");
+        Entry entry = resourceCollection.get(entryID);
+        
+        //change the title of this entry
+        entry.setTitle(new PlainTextConstruct(newTitle));
+        resourceCollection.put(entryID, entry);
+        System.out.println("!!! Updated entry with id=" + entry.getId() + " 
title=" + entry.getTitle());
+        System.out.println("\n");
     }
 
+    
+    // Call Collection.query(entry, updatedTitle)
+    public void clientQuery() throws Exception {
+    }   
+   
 }

Modified: 
tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/CustomerCollectionImpl.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/CustomerCollectionImpl.java?rev=677508&r1=677507&r2=677508&view=diff
==============================================================================
--- 
tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/CustomerCollectionImpl.java
 (original)
+++ 
tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/CustomerCollectionImpl.java
 Wed Jul 16 23:21:15 2008
@@ -24,18 +24,18 @@
 import java.util.Map;
 import java.util.UUID;
 
-import org.apache.tuscany.sca.binding.gdata.collection.Collection;
-import org.osoa.sca.annotations.Scope;
-
 import com.google.gdata.data.DateTime;
 import com.google.gdata.data.Entry;
 import com.google.gdata.data.Feed;
 import com.google.gdata.data.PlainTextConstruct;
 
+import org.apache.tuscany.sca.binding.gdata.collection.Collection;
+import org.osoa.sca.annotations.Scope;
+
 @Scope("COMPOSITE")
 public class CustomerCollectionImpl implements Collection {
 
-    // private final Abdera abdera = new Abdera();
+
     private Map<String, Entry> entries = new HashMap<String, Entry>();
 
     /**
@@ -46,33 +46,21 @@
 
         for (int i = 0; i < 4; i++) {
             // id is supposed to be generated in a random way, but for the
-            // purpose of testing
-            // I just make them as static ids
+            // purpose of testing, we just make them as static ids
+            
             // String id = "urn:uuid:customer-" + UUID.randomUUID().toString();
 
             String id = "urn:uuid:customer-" + String.valueOf(i);
-
             Entry entry = new Entry();
             entry.setId(id);
             entry.setTitle(new PlainTextConstruct("EntryTitle_" + i));
             entry.setContent(new PlainTextConstruct("content_" + i));
             entry.setUpdated(DateTime.now());
-
             // FIXME: The following three lines of code need to be fixed to add
-            // HTML links.
-
+            // HTML links.            
             // entry.addHtmlLink(""+id, "application/atom+xml", "title");
             // entry.addHtmlLink(""+id, "", "edit");
             // entry.addHtmlLink(""+id, "", "alternate");
-
-            /*
-             * Entry entry = abdera.getFactory().newEntry(); entry.setId(id);
-             * entry.setTitle("title_" + String.valueOf(i));
-             * entry.addAuthor("author_" + String.valueOf(i)); 
entry.addLink("" +
-             * id, "edit"); entry.addLink("" + id, "alternate");
-             * entry.setUpdated(new Date());
-             */
-
             entries.put(id, entry);
             System.out.println(">>> id=" + id);
         }
@@ -83,10 +71,8 @@
 
         String id = "urn:uuid:customer-" + UUID.randomUUID().toString();
         entry.setId(id);
-        /*
-         * entry.addLink("" + id, "edit"); entry.addLink("" + id, "alternate");
-         * entry.setUpdated(new Date());
-         */
+
+        //entry.addLink("" + id, "edit"); entry.addLink("" + id, "alternate");
         entry.setUpdated(DateTime.now());
         // entry.addHtmlLink("http://www.google.com";, "languageType", "edit");
         // entry.addHtmlLink("http://www.google.com";, "languageType",
@@ -103,39 +89,28 @@
     }
 
     public void put(String id, Entry entry) {
-        System.out.println(">>> ResourceCollectionImpl.put id=" + id + " 
entry=" + entry.getTitle());
-
-        // entry.setUpdated(new Date());
+        System.out.println(">>> ResourceCollectionImpl.put id=" + id + " 
entry=" + entry.getTitle().getPlainText());
         entry.setUpdated(DateTime.now());
-
         entries.put(id, entry);
     }
+    
 
     public void delete(String id) {
         System.out.println(">>> ResourceCollectionImpl.delete id=" + id);
         entries.remove(id);
     }
 
-    @SuppressWarnings("unchecked")
+    
     public Feed getFeed() {
         System.out.println(">>> ResourceCollectionImpl.get collection");
-
-        /*
-         * Feed feed = this.abdera.getFactory().newFeed();
-         * feed.setTitle("customers"); feed.setSubtitle("This is a sample
-         * feed"); feed.setUpdated(new Date()); feed.addLink("");
-         * feed.addLink("", "self");
-         */
-
+        
         Feed feed = new Feed();
-        feed.setTitle(new PlainTextConstruct("Feedtitle"));
+        feed.setTitle(new PlainTextConstruct("Feedtitle(LocalHostServlet)"));
         feed.setSubtitle(new PlainTextConstruct("Subtitle: This is a sample 
feed"));
         feed.setUpdated(DateTime.now());
-
         // FIXME: The following two lines of code need to be fixed
         // feed.addHtmlLink("", "", "");
         // feed.addHtmlLink("", "languageType", "self");
-
         ArrayList<Entry> entryList = new ArrayList<Entry>();
         for (Entry entry : entries.values()) {
             entryList.add(entry);
@@ -145,6 +120,7 @@
         return feed;
     }
 
+    
     public Feed query(String queryString) {
         System.out.println(">>> ResourceCollectionImpl.query collection " + 
queryString);
         return getFeed();

Added: 
tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/StartLocalhostServlet.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/StartLocalhostServlet.java?rev=677508&view=auto
==============================================================================
--- 
tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/StartLocalhostServlet.java
 (added)
+++ 
tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/StartLocalhostServlet.java
 Wed Jul 16 23:21:15 2008
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.binding.gdata;
+
+import java.io.IOException;
+
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+
+public class StartLocalhostServlet {
+
+    public static void main(String[] args) {
+
+        SCADomain scaDomain = 
SCADomain.newInstance("org/apache/tuscany/sca/binding/gdata/Provider.composite");
+        System.out.println("Provider.composite ready...");
+
+        try {
+            System.in.read();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+
+        scaDomain.close();
+    }
+}

Propchange: 
tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/StartLocalhostServlet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/StartLocalhostServlet.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: 
tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/Test_GdataBinding_GoogleBloggerService.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/Test_GdataBinding_GoogleBloggerService.java?rev=677508&view=auto
==============================================================================
--- 
tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/Test_GdataBinding_GoogleBloggerService.java
 (added)
+++ 
tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/Test_GdataBinding_GoogleBloggerService.java
 Wed Jul 16 23:21:15 2008
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.binding.gdata;
+
+import static org.junit.Assert.*;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.google.gdata.data.Entry;
+import com.google.gdata.data.Feed;
+import com.google.gdata.data.PlainTextConstruct;
+
+public class Test_GdataBinding_GoogleBloggerService extends TestCase{
+
+    private SCADomain scaDomainConsumer = null;
+    private CustomerClient testService = null;
+    
+    
+    public Test_GdataBinding_GoogleBloggerService(){
+
+    }
+    
+    @Before
+    public void setUp() throws Exception {
+        System.out.println("Method Test 
Start-----------------------------------------------------------------------");
+        
+        //Initialize the GData client service (Reference Binding test)
+        scaDomainConsumer = 
SCADomain.newInstance("org/apache/tuscany/sca/binding/gdata/ConsumerGoogleBlogger.composite");
+        testService = scaDomainConsumer.getService(CustomerClient.class, 
"CustomerClient");  
+    }
+
+    @After
+    public void tearDown(){
+        System.out.println("Method Test 
End------------------------------------------------------------------------");
+        System.out.println("\n\n");
+    }        
+    
+    @Test
+    public void testClientGetFeed() throws Exception {
+        Feed feed = testService.clientGetFeed();
+        System.out.println("feed title: " + feed.getTitle().getPlainText());   
     
+        assertEquals("gdata binding tuscany test", 
feed.getTitle().getPlainText());
+     }
+    
+    
+    @Test
+    public void testClientGetEntry() throws Exception {
+        String entryID = "8308734583601887890";
+        Entry blogEntry = testService.clientGetEntry(entryID);
+        System.out.println("Entry ID: " + blogEntry.getId());
+        assertTrue(blogEntry.getId().endsWith(entryID));
+        
System.out.println("------------------------------------------------------------\n\n");
+    }
+    
+    
+    @Test
+    public void testClientPut() throws Exception {  
+        String entryID = "2889832689497686762";          
+        String newBlogEntryTitle = "updatedTitleByTestCase2";
+        testService.clientPut(entryID, newBlogEntryTitle);      //update the 
title
+        Thread.sleep(300);            
+        Entry updatedEntry = testService.clientGetEntry(entryID);         
+        assertEquals(newBlogEntryTitle, 
updatedEntry.getTitle().getPlainText());
+    }
+    
+    
+
+    @Test
+    public void testClientPost() throws Exception {
+        String blogEntryTitle = "titleByBloogerTestcase000";
+        Entry newEntry = new Entry();
+        newEntry.setTitle(new PlainTextConstruct(blogEntryTitle));
+        newEntry.setContent(new 
PlainTextConstruct("contentByBloggerTestCase000"));
+        Entry postedEntry = testService.clientPost(newEntry);        
+        assertEquals(blogEntryTitle, postedEntry.getTitle().getPlainText());
+    }
+
+    
+    @Test
+    public void testClientDelete() throws Exception {
+        
+        //This test case might fail
+        //because Google blogger service has limitation on new posts allowed 
everyday/every hour?
+        
+        System.out.println("testClientDelete");
+        //We create a new post, and then delete it
+        Entry newEntry = new Entry();
+        newEntry.setTitle(new PlainTextConstruct("blogEntryShouldNotApear"));
+        newEntry.setContent(new 
PlainTextConstruct("contentByBloggerShouldNotAppear"));
+        Entry postedEntry = testService.clientPost(newEntry);
+        Thread.sleep(300);        
+        int idStartPosition = postedEntry.getId().lastIndexOf("-");
+        String postedEntryID = 
postedEntry.getId().substring(idStartPosition+1);        
+        System.out.println("postedEntryID: " + postedEntryID );
+        
+        //Before deletion
+        Entry entry00 = testService.clientGetEntry(postedEntryID);
+        System.out.println("Before Deleteion: " + entry00.getId());
+        
+        //Delete this entry
+        testService.clientDelete(postedEntryID);
+
+        //This newly posted entry did not appear in the blogspot website,
+        //We need a Junit assertion here
+        //Link:  http://haibotuscany.blogspot.com/feeds/posts/default/
+        //FIXME: Need an assertion here
+        //Assert(....);
+    }
+    
+
+
+}

Propchange: 
tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/Test_GdataBinding_GoogleBloggerService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/Test_GdataBinding_GoogleBloggerService.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: 
tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/Test_GdataBinding_LocalhostServlet.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/Test_GdataBinding_LocalhostServlet.java?rev=677508&view=auto
==============================================================================
--- 
tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/Test_GdataBinding_LocalhostServlet.java
 (added)
+++ 
tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/Test_GdataBinding_LocalhostServlet.java
 Wed Jul 16 23:21:15 2008
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.binding.gdata;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import com.google.gdata.data.Entry;
+import com.google.gdata.data.Feed;
+import com.google.gdata.data.PlainTextConstruct;
+
+public class Test_GdataBinding_LocalhostServlet extends TestCase {
+
+    private SCADomain scaDomainProvider = null;
+    private SCADomain scaDomainConsumer = null;
+    private CustomerClient testService = null;
+
+    @Before
+    public void setUp() throws Exception {
+        System.out.println("Method Test 
Start-----------------------------------------------------------------------");
+
+        // Setup the local GData servlet (Service Binding test)
+        scaDomainProvider = 
SCADomain.newInstance("org/apache/tuscany/sca/binding/gdata/Provider.composite");
+        System.out.println("[Debug Info] Provider.composite ready...");
+
+        // Initialize the GData client service (Reference Binding test)
+        scaDomainConsumer = 
SCADomain.newInstance("org/apache/tuscany/sca/binding/gdata/Consumer.composite");
+        testService = scaDomainConsumer.getService(CustomerClient.class, 
"CustomerClient");
+    }
+
+    @After
+    public void tearDown() {
+        scaDomainProvider.close();
+        System.out.println("Method Test 
End------------------------------------------------------------------------");
+        System.out.println("\n\n");
+    }
+    
+        
+    @Test
+    public void testClientGetFeed() throws Exception {
+        Feed feed = testService.clientGetFeed();
+        System.out.println(feed.getTitle().getPlainText());
+        assertNotNull(feed);
+        // Given we are testing on the localhost providing feed, we know the
+        // feed title is "Feedtitle(LocalHostServlet)"
+        assertEquals("Feedtitle(LocalHostServlet)", 
feed.getTitle().getPlainText());
+    }
+
+    @Test
+    public void testClientGetEntry() throws Exception {
+        String entryID = "urn:uuid:customer-0";
+        Entry entry = testService.clientGetEntry(entryID);
+        System.out.println("entryID in testcase: " + entry.getId());
+        assertEquals(entryID, entry.getId());
+    }
+
+    @Test
+    public void testClientPost() throws Exception {
+        Entry newEntry = new Entry();
+        newEntry.setTitle(new PlainTextConstruct("NewEntry title"));
+        newEntry.setContent(new PlainTextConstruct("NewEntry Content"));       
 
+        Entry postedEntry = testService.clientPost(newEntry);        
+        assertEquals("NewEntry title", postedEntry.getTitle().getPlainText());
+    }
+    
+    @Test
+    public void testClientDelete() throws Exception {
+
+        // We first create a new entry, then delete it
+
+        // Post a new entry
+        Entry newEntry = new Entry();
+        newEntry.setTitle(new PlainTextConstruct("NewEntry title"));
+        newEntry.setContent(new PlainTextConstruct("NewEntry Content"));
+        Entry confirmedNewEntry = testService.clientPost(newEntry);
+
+        Thread.sleep(300);
+        
+        Feed feed00 = testService.clientGetFeed();
+        int entryNum00 = feed00.getEntries().size(); // The number of entries
+                                                        // before deleting
+        System.out.println("entryNum00:" + entryNum00);
+
+        // Delete this newly created entry
+        String entryID = confirmedNewEntry.getId();
+        Thread.sleep(300);
+        
+        testService.clientDelete(entryID);
+        Feed feed01 = testService.clientGetFeed();
+        int entryNum01 = feed01.getEntries().size();
+        System.out.println("entryNum01:" + entryNum01); // The number of 
entries
+                                                        // after deleting
+        assertEquals(1, entryNum00 - entryNum01);
+    }
+    
+
+    @Test
+    public void testClientPut() throws Exception {
+        String newTitleValue = "newTitleValueByPut";
+        String entryID = "urn:uuid:customer-0";
+        testService.clientPut(entryID, newTitleValue);
+        Entry updatedEntry = testService.clientGetEntry(entryID);
+        System.out.println("title: "+ updatedEntry.getTitle().getPlainText());
+        assertEquals(newTitleValue, updatedEntry.getTitle().getPlainText());
+    }
+
+  
+
+}

Propchange: 
tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/Test_GdataBinding_LocalhostServlet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/Test_GdataBinding_LocalhostServlet.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: 
tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/resources/org/apache/tuscany/sca/binding/gdata/Consumer.composite
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/resources/org/apache/tuscany/sca/binding/gdata/Consumer.composite?rev=677508&r1=677507&r2=677508&view=diff
==============================================================================
--- 
tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/resources/org/apache/tuscany/sca/binding/gdata/Consumer.composite
 (original)
+++ 
tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/resources/org/apache/tuscany/sca/binding/gdata/Consumer.composite
 Wed Jul 16 23:21:15 2008
@@ -25,7 +25,7 @@
     <component name="CustomerClient">
         <implementation.java 
class="org.apache.tuscany.sca.binding.gdata.CustomerClientImpl"/>
         <reference name="resourceCollection">
-               <tuscany:binding.gdata uri="http://localhost:8084/customer"/>
+               <tuscany:binding.gdata uri="http://localhost:8084/customer"; 
serviceType="localServiceBinding" username="admin" password="admin"/>
         </reference>
     </component>
 

Added: 
tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/resources/org/apache/tuscany/sca/binding/gdata/ConsumerGoogleBlogger.composite
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/resources/org/apache/tuscany/sca/binding/gdata/ConsumerGoogleBlogger.composite?rev=677508&view=auto
==============================================================================
--- 
tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/resources/org/apache/tuscany/sca/binding/gdata/ConsumerGoogleBlogger.composite
 (added)
+++ 
tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/resources/org/apache/tuscany/sca/binding/gdata/ConsumerGoogleBlogger.composite
 Wed Jul 16 23:21:15 2008
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0";
+           xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0";
+          targetNamespace="http://customer";
+          name="Consumer">
+    
+    <component name="CustomerClient">
+        <implementation.java 
class="org.apache.tuscany.sca.binding.gdata.CustomerClientImpl"/>
+        <reference name="resourceCollection">
+               <tuscany:binding.gdata 
uri="http://haibotuscany.blogspot.com/feeds/posts/default"; 
serviceType="blogger" username="[EMAIL PROTECTED]" password="gsocgsocgsoc"/>
+        </reference>
+    </component>
+
+</composite>

Propchange: 
tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/resources/org/apache/tuscany/sca/binding/gdata/ConsumerGoogleBlogger.composite
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/resources/org/apache/tuscany/sca/binding/gdata/ConsumerGoogleBlogger.composite
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: 
tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/resources/org/apache/tuscany/sca/binding/gdata/ConsumerGoogleBlogger.composite
------------------------------------------------------------------------------
    svn:mime-type = text/xml


Reply via email to