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

svn commit: r702729 - in /tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src: main/java/org/apache/tuscany/sca/binding/gdata/provider/ test/java/org/apache/tuscany/sca/binding/gdata/ test/resources/org/apache/tuscany/sca/binding/gdata/

Author: lresende
Date: Tue Oct  7 23:17:14 2008
New Revision: 702729

URL: http://svn.apache.org/viewvc?rev=702729&view=rev
Log:
TUSCANY-2577 - Applying Haibo's patch to add support for google web albums feeds trough gdata.

Added:
    tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleWebAlbumServiceTestCase.java   (with props)
    tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/resources/org/apache/tuscany/sca/binding/gdata/ConsumerGoogleWebAlbum.composite   (with props)
Modified:
    tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataReferenceBindingProvider.java

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=702729&r1=702728&r2=702729&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 Tue Oct  7 23:17:14 2008
@@ -128,6 +128,11 @@
                 supportsFeedEntries = true;
             }
 
+            String entryURI = this.binding.getURI();
+            if(entryURI.contains("picasaweb.google.com/data/feed/api/")){
+            	entryURI = entryURI.replace("picasaweb.google.com/data/feed/api/", "picasaweb.google.com/data/entry/api/");
+            	binding.setURI(entryURI);
+            }
             return new GdataBindingInvoker.GetInvoker(operation, binding.getURI(), googleService, httpClient, authorizationHeader, this);
 
         } else if (operationName.equals("post")) {
@@ -136,9 +141,21 @@
 
         } else if (operationName.equals("put")) {
 
+            String entryURI = this.binding.getURI();
+            if(entryURI.contains("picasaweb.google.com/data/feed/api/")){
+            	entryURI = entryURI.replace("picasaweb.google.com/data/feed/api/", "picasaweb.google.com/data/entry/api/");
+            	binding.setURI(entryURI);
+            }
             return new GdataBindingInvoker.PutInvoker(operation, binding.getURI(),  googleService, httpClient, authorizationHeader,
                                                       this);
         } else if (operationName.equals("delete")) {
+        	
+        	
+            String entryURI = this.binding.getURI();
+            if(entryURI.contains("picasaweb.google.com/data/feed/api/")){
+            	entryURI = entryURI.replace("picasaweb.google.com/data/feed/api/", "picasaweb.google.com/data/entry/api/");
+            	binding.setURI(entryURI);
+            }
             return new GdataBindingInvoker.DeleteInvoker(operation, binding.getURI(),  googleService, httpClient, authorizationHeader,
                                                          this);
         } else if (operationName.equals("getFeed") || operationName.equals("getAll")) {

Added: tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleWebAlbumServiceTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleWebAlbumServiceTestCase.java?rev=702729&view=auto
==============================================================================
--- tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleWebAlbumServiceTestCase.java (added)
+++ tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleWebAlbumServiceTestCase.java Tue Oct  7 23:17:14 2008
@@ -0,0 +1,120 @@
+/*
+ * 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.net.URL;
+
+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.client.Query;
+import com.google.gdata.data.DateTime;
+import com.google.gdata.data.Entry;
+import com.google.gdata.data.Feed;
+import com.google.gdata.data.PlainTextConstruct;
+
+public class GoogleWebAlbumServiceTestCase extends TestCase{
+
+    private SCADomain scaDomainConsumer = null;
+    private CustomerClient testService = null;    
+    
+    public GoogleWebAlbumServiceTestCase(){
+
+    }
+    
+    @Before
+    @Override
+    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/ConsumerGoogleWebAlbum.composite");
+        testService = scaDomainConsumer.getService(CustomerClient.class, "CustomerClient");  
+    }
+
+    @After
+    @Override
+    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("flowers", feed.getTitle().getPlainText());
+     }
+    
+
+
+    
+    @Test
+    public void testClientGetEntry() throws Exception {
+        String entryID = "photoid/5233468700029715874";
+        Entry contactEntry = testService.clientGetEntry(entryID);
+        System.out.println("Entry ID: " + contactEntry.getId());
+        assertTrue(contactEntry.getId().endsWith(entryID));
+        System.out.println("------------------------------------------------------------\n\n");
+    }
+    
+    
+    @Test
+    public void testClientQuery() throws Exception {
+    	String feedUrlString = "http://picasaweb.google.com/data/feed/api/user/haibotuscany/album/flowers";
+    	URL feedURL = new URL(feedUrlString);   
+    	Query myQuery = new Query(feedURL);
+        myQuery.setMaxResults(100);
+        myQuery.setFullTextQuery("photo");    
+        Feed resultFeed = testService.clientQuery(myQuery);        
+        System.out.println("Query result feed title: " + resultFeed.getTitle().getPlainText());    
+        System.out.println("Query result entry number: "+ resultFeed.getEntries().size());
+        //assertEquals("gdata binding tuscany test", resultFeed.getTitle().getPlainText());
+     }
+    
+    
+    
+    @Test
+    public void testClientPut() throws Exception {  
+        String entryID = "photoid/5233468700029715874";          
+        String newBlogEntryTitle = "updatedTitle:dog";
+        testService.clientPut(entryID, newBlogEntryTitle);      //update the title
+        Thread.sleep(300);            
+        Entry updatedEntry = testService.clientGetEntry(entryID);         
+        assertEquals(newBlogEntryTitle, updatedEntry.getTitle().getPlainText());
+    }
+    
+    
+    @Test
+    public void testClientDelete() throws Exception {
+        
+    	//Tested and it worked, but only once because we can not delete the same entry twice
+    	String entryID = "photoid/5233468698153151618"; 
+    	
+    	//Delete this entry
+    	//To test, change the entryID
+        //testService.clientDelete(entryID);
+    }    
+
+}

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

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

Added: tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/resources/org/apache/tuscany/sca/binding/gdata/ConsumerGoogleWebAlbum.composite
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/resources/org/apache/tuscany/sca/binding/gdata/ConsumerGoogleWebAlbum.composite?rev=702729&view=auto
==============================================================================
--- tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/resources/org/apache/tuscany/sca/binding/gdata/ConsumerGoogleWebAlbum.composite (added)
+++ tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/resources/org/apache/tuscany/sca/binding/gdata/ConsumerGoogleWebAlbum.composite Tue Oct  7 23:17:14 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://picasaweb.google.com/data/feed/api/user/haibotuscany/album/flowers" serviceType="lh2" username="haibotuscany@gmail.com" password="gsocgsocgsoc"/>
+        </reference>
+    </component>
+
+</composite>

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

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

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