diff options
Diffstat (limited to 'branches/sca-java-1.5.1/modules/binding-gdata-runtime/src/test/java/org/apache')
12 files changed, 0 insertions, 1177 deletions
diff --git a/branches/sca-java-1.5.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/Constants.java b/branches/sca-java-1.5.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/Constants.java deleted file mode 100644 index 6b4a6e2509..0000000000 --- a/branches/sca-java-1.5.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/Constants.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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; - -public class Constants { - static long SLEEP_INTERVAL = 400L; -} diff --git a/branches/sca-java-1.5.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/Consumer.java b/branches/sca-java-1.5.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/Consumer.java deleted file mode 100644 index 7d723a2883..0000000000 --- a/branches/sca-java-1.5.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/Consumer.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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 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 { - - //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()); - - - } -} diff --git a/branches/sca-java-1.5.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/ConsumerProviderTestCase.java b/branches/sca-java-1.5.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/ConsumerProviderTestCase.java deleted file mode 100644 index af7027ca90..0000000000 --- a/branches/sca-java-1.5.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/ConsumerProviderTestCase.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * 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.Assert; - -import org.apache.tuscany.sca.host.embedded.SCADomain; -import org.junit.AfterClass; -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 ConsumerProviderTestCase { - - private static SCADomain scaDomainProvider = null; - private static SCADomain scaDomainConsumer = null; - private static CustomerClient testService = null; - - @BeforeClass - public static void setUp() throws Exception { - // Setup the local GData servlet (Service Binding test) - scaDomainProvider = SCADomain.newInstance("org/apache/tuscany/sca/binding/gdata/Provider.composite"); - - // 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"); - } - - @AfterClass - public static void tearDown() { - scaDomainConsumer.close(); - scaDomainProvider.close(); - } - - - @Test - public void testClientGetFeed() throws Exception { - Feed feed = testService.clientGetFeed(); - //System.out.println(feed.getTitle().getPlainText()); - Assert.assertNotNull(feed); - // Given we are testing on the localhost providing feed, we know the - // feed title is "Feedtitle(LocalHostServlet)" - Assert.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()); - Assert.assertEquals(entryID, entry.getId()); - } - - @Test - public void testClientPost() throws Exception { - Entry newEntry = new Entry(); - newEntry.setTitle(new PlainTextConstruct("NewEntry title by Post")); - newEntry.setContent(new PlainTextConstruct("NewEntry Content by Post")); - Entry postedEntry = testService.clientPost(newEntry); - Assert.assertEquals("NewEntry title by Post", postedEntry.getTitle().getPlainText()); - } - - - - @Test - public void testClientPut() throws Exception { - String newTitleValue = "newTitleValueByPut"; - String entryID = "urn:uuid:customer-0"; - //System.out.println("Before clientPut"); - testService.clientPut(entryID, newTitleValue); - //System.out.println("After clientPut"); - Entry updatedEntry = testService.clientGetEntry(entryID); - //System.out.println("title: "+ updatedEntry.getTitle().getPlainText()); - Assert.assertEquals(newTitleValue, updatedEntry.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 to be deleted")); - newEntry.setContent(new PlainTextConstruct("NewEntry Content to be delted")); - Entry confirmedNewEntry = testService.clientPost(newEntry); - - Thread.sleep(Constants.SLEEP_INTERVAL); - - 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); - - //System.out.println("confirmed entry ID: " + confirmedNewEntry.getId()); - //System.out.println("confirmed entry title: " + confirmedNewEntry.getTitle().getPlainText()); - - //System.out.println("Before test clientDelete"); - testService.clientDelete(entryID); - //System.out.println("After test clientDelete"); - - Feed feed01 = testService.clientGetFeed(); - int entryNum01 = feed01.getEntries().size(); - //System.out.println("entryNum01:" + entryNum01); // The number of entries after deleting - - //assertEquals(1, entryNum00 - entryNum01); - } - - -} diff --git a/branches/sca-java-1.5.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/CustomerClient.java b/branches/sca-java-1.5.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/CustomerClient.java deleted file mode 100644 index 7aa0a8961c..0000000000 --- a/branches/sca-java-1.5.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/CustomerClient.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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 com.google.gdata.client.Query; -import com.google.gdata.data.Entry; -import com.google.gdata.data.Feed; - -public interface CustomerClient { - - Feed clientGetFeed() 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; - - Feed clientQuery(Query query) throws Exception; - -} diff --git a/branches/sca-java-1.5.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/CustomerClientImpl.java b/branches/sca-java-1.5.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/CustomerClientImpl.java deleted file mode 100644 index 5dc9c0079f..0000000000 --- a/branches/sca-java-1.5.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/CustomerClientImpl.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * 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 com.google.gdata.client.Query; -import com.google.gdata.data.Feed; -import com.google.gdata.data.Entry; -import com.google.gdata.data.PlainTextConstruct; - -import org.apache.tuscany.sca.binding.gdata.collection.Collection; -import org.apache.tuscany.sca.binding.gdata.collection.NotFoundException; -import org.osoa.sca.annotations.Reference; - -public class CustomerClientImpl implements CustomerClient { - - @Reference - public Collection resourceCollection; - - // 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; - //System.out.print("Entry" + i + "\t"); - //System.out.println(" id = " + e.getId() + "\t title = " + e.getTitle().getPlainText()); - i++; - } - return feed; - } - - - // 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"); - Entry entry = resourceCollection.get(entryID); - //System.out.println("\n\n!!! Entry retrieved with id=" + entry.getId() - // + " title=" - // + entry.getTitle().getPlainText()); - return entry; - } - - - // 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 confirmedNewEntry = resourceCollection.post(newEntry); - //System.out.println("!!! New entry posted with id=" + confirmedNewEntry.getId() - // + " title=" - // + confirmedNewEntry.getTitle().getPlainText()); - return confirmedNewEntry; - } - - - // 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); - } - - - - // Call Collection.put(entry, updatedTitle) - public void clientPut(String entryID, String newTitle) throws Exception { - - //System.out.println("clientPut"); - // Put a new entry to the provider - //System.out.println(">>> put id=" + entryID + " title=" + newTitle); - 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()); - } - - - - // Call Collection.getFeed() - public Feed clientQuery(Query query) throws Exception { - // Get all the entries from the provider, return in a single feed - //System.out.println(">>> query the service"); - Feed feed = resourceCollection.query(query); - //System.out.println("\n\n!!! Query result 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; - //System.out.print("Entry" + i + "\t"); - //System.out.println(" id = " + e.getId() + "\t title = " + e.getTitle().getPlainText()); - i++; - } - return feed; - } - -} diff --git a/branches/sca-java-1.5.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/CustomerCollectionImpl.java b/branches/sca-java-1.5.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/CustomerCollectionImpl.java deleted file mode 100644 index 9c4d118cd6..0000000000 --- a/branches/sca-java-1.5.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/CustomerCollectionImpl.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * 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.util.ArrayList; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -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.Link; -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 Map<String, Entry> entries = new HashMap<String, Entry>(); - - /** - * Default constructor that initializes collection with couple customer - * entries - */ - public CustomerCollectionImpl() { - - for (int i = 0; i < 4; i++) { - // id is supposed to be generated in a random way, but for the - // 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. - Link link = new Link(); - link.setType(Link.Type.ATOM); - link.setRel(Link.Rel.ENTRY_EDIT); - link.setHref("http://localhost:8084/customer" + "/" + id); - entry.getLinks().add(link); - - // entry.addHtmlLink(""+id, "", "edit"); - // entry.addHtmlLink(""+id, "", "alternate"); - entries.put(id, entry); - //System.out.println(">>> id=" + id); - } - } - - public Entry post(Entry entry) { - //System.out.println(">>> ResourceCollectionImpl.post entry=" + entry.getTitle()); - - String id = "urn:uuid:customer-" + UUID.randomUUID().toString(); - entry.setId(id); - - Link link = new Link(); - link.setType(Link.Type.ATOM); - link.setRel(Link.Rel.ENTRY_EDIT); - link.setHref("http://localhost:8084/customer" + "/" + id); - entry.getLinks().add(link); - - //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", - // "alternate"); - - entries.put(id, entry); - //System.out.println(">>> ResourceCollectionImpl.post return id=" + id); - return entry; - } - - public Entry get(String id) { - //System.out.println(">>> ResourceCollectionImpl.get id= " + id); - return entries.get(id); - } - - public void put(String id, Entry entry) { - //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); - } - - - public Feed getFeed() { - //System.out.println(">>> ResourceCollectionImpl.get collection"); - - Feed feed = new Feed(); - 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); - } - feed.setEntries(entryList); - - return feed; - } - - //FIXME: need to be modified - public Feed query(Query query) { - //System.out.println(">>> ResourceCollectionImpl.query collection "); - return getFeed(); - } -} diff --git a/branches/sca-java-1.5.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleBloggerServiceTestCase.java b/branches/sca-java-1.5.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleBloggerServiceTestCase.java deleted file mode 100644 index a827677fd0..0000000000 --- a/branches/sca-java-1.5.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleBloggerServiceTestCase.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * 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.Assert; - -import org.apache.tuscany.sca.host.embedded.SCADomain; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Ignore; -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 GoogleBloggerServiceTestCase { - - private static SCADomain scaDomainConsumer = null; - private static CustomerClient testService = null; - - @BeforeClass - public static void setUp() throws Exception { - //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"); - } - - @AfterClass - public static void tearDown(){ - scaDomainConsumer.close(); - } - - @Test - public void testClientGetFeed() throws Exception { - Feed feed = testService.clientGetFeed(); - //System.out.println("feed title: " + feed.getTitle().getPlainText()); - Assert.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()); - Assert.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(Constants.SLEEP_INTERVAL); - Entry updatedEntry = testService.clientGetEntry(entryID); - Assert.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); - Assert.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(Constants.SLEEP_INTERVAL); - 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); - - //Worked: this newly posted entry did not appear in the blogspot website, - //But we need a Junit assertion here - //Link: http://haibotuscany.blogspot.com/feeds/posts/default/ - //FIXME: Need an assertion here - //Assert(....); - } - - - @Test - public void testClientQuery() throws Exception { - Query myQuery = new Query(new URL("http://haibotuscany.blogspot.com/feeds/posts/default")); - myQuery.setMaxResults(100); - //myQuery.setUpdatedMin(startTime); - myQuery.setUpdatedMax(DateTime.now()); - 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()); - } - - -} diff --git a/branches/sca-java-1.5.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleCalendarServiceTestCase.java b/branches/sca-java-1.5.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleCalendarServiceTestCase.java deleted file mode 100644 index 9c3122e134..0000000000 --- a/branches/sca-java-1.5.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleCalendarServiceTestCase.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * 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.Assert; - -import org.apache.tuscany.sca.host.embedded.SCADomain; -import org.junit.AfterClass; -import org.junit.BeforeClass; -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 GoogleCalendarServiceTestCase { - - private static SCADomain scaDomainConsumer = null; - private static CustomerClient testService = null; - - public GoogleCalendarServiceTestCase() { - - } - - @BeforeClass - public static void setUp() throws Exception { - //Initialize the GData client service (Reference Binding test) - scaDomainConsumer = SCADomain.newInstance("org/apache/tuscany/sca/binding/gdata/ConsumerGoogleCalendar.composite"); - testService = scaDomainConsumer.getService(CustomerClient.class, "CustomerClient"); - } - - @AfterClass - public static void tearDown(){ - scaDomainConsumer.close(); - } - - @Test - public void testClientGetFeed() throws Exception { - Feed feed = testService.clientGetFeed(); - //System.out.println("feed title: " + feed.getTitle().getPlainText()); - Assert.assertEquals("gsoc gosc", feed.getTitle().getPlainText()); - } - - - @Test - public void testClientGetEntry() throws Exception { - String entryID = "1c76lcl70jg9r0fm18rcbneea8"; - Entry blogEntry = testService.clientGetEntry(entryID); - //System.out.println("Entry ID: " + blogEntry.getId()); - Assert.assertTrue(blogEntry.getId().endsWith(entryID)); - //System.out.println("------------------------------------------------------------\n\n"); - } - - - @Test - public void testClientPut() throws Exception { - String entryID = "1c76lcl70jg9r0fm18rcbneea8"; - String newBlogEntryTitle = "updatedTitleByGoogleContactsConsumerTestCase"; - testService.clientPut(entryID, newBlogEntryTitle); //update the title - Thread.sleep(Constants.SLEEP_INTERVAL); - Entry updatedEntry = testService.clientGetEntry(entryID); - Assert.assertEquals(newBlogEntryTitle, updatedEntry.getTitle().getPlainText()); - } - - @Test - public void testClientPost() throws Exception { - String blogEntryTitle = "titleByGoogleCalendarTestcase"; - Entry newEntry = new Entry(); - newEntry.setTitle(new PlainTextConstruct(blogEntryTitle)); - newEntry.setContent(new PlainTextConstruct("contentByGoogleCalendarTestCase")); - Entry postedEntry = testService.clientPost(newEntry); - Assert.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("calendarEntryShouldNotApear")); - newEntry.setContent(new PlainTextConstruct("calendarByBloggerShouldNotAppear")); - Entry postedEntry = testService.clientPost(newEntry); - Thread.sleep(Constants.SLEEP_INTERVAL); - - //System.out.println("ID: " + postedEntry.getId()); - - 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); - - //Worked: this newly posted entry did not appear in the contact list - //But we need a Junit assertion here - //Link: http://haibotuscany.blogspot.com/feeds/posts/default/ - //FIXME: Need an assertion here - //Assert(....); - } - - - @Test - public void testClientQuery() throws Exception { - Query myQuery = new Query(new URL("http://www.google.com/calendar/feeds/haibotuscany@gmail.com/private/full")); - myQuery.setMaxResults(100); - //myQuery.setUpdatedMin(startTime); - myQuery.setUpdatedMax(DateTime.now()); - - //Google Calendar service supports full-text search - String queryString = "event0"; - myQuery.setFullTextQuery(queryString); - - 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()); - } - - -} diff --git a/branches/sca-java-1.5.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleContactsServiceTestCase.java b/branches/sca-java-1.5.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleContactsServiceTestCase.java deleted file mode 100644 index 1f261dfc90..0000000000 --- a/branches/sca-java-1.5.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleContactsServiceTestCase.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - * 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.Assert; - -import org.apache.tuscany.sca.host.embedded.SCADomain; -import org.junit.AfterClass; -import org.junit.BeforeClass; -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 GoogleContactsServiceTestCase { - - private static SCADomain scaDomainConsumer = null; - private static CustomerClient testService = null; - - public GoogleContactsServiceTestCase(){ - - } - - @BeforeClass - public static void setUp() throws Exception { - //Initialize the GData client service (Reference Binding test) - scaDomainConsumer = SCADomain.newInstance("org/apache/tuscany/sca/binding/gdata/ConsumerGoogleContacts.composite"); - testService = scaDomainConsumer.getService(CustomerClient.class, "CustomerClient"); - } - - @AfterClass - public static void tearDown(){ - scaDomainConsumer.close(); - } - - @Test - public void testClientGetFeed() throws Exception { - Feed feed = testService.clientGetFeed(); - System.out.println("feed title: " + feed.getTitle().getPlainText()); - Assert.assertEquals("Haibo Zhao's Contacts", feed.getTitle().getPlainText()); - } - - - @Test - public void testClientGetEntry() throws Exception { - String entryID = "12feeeb38ab87365"; - Entry contactEntry = testService.clientGetEntry(entryID); - //System.out.println("Entry ID: " + contactEntry.getId()); - Assert.assertTrue(contactEntry.getId().endsWith(entryID)); - } - - - @Test - public void testClientPut() throws Exception { - String entryID = "12feeeb38ab87365"; - String newBlogEntryTitle = "updatedTitleByGoogleContactsConsumerTestCase"; - testService.clientPut(entryID, newBlogEntryTitle); //update the title - Thread.sleep(Constants.SLEEP_INTERVAL); - Entry updatedEntry = testService.clientGetEntry(entryID); - Assert.assertEquals(newBlogEntryTitle, updatedEntry.getTitle().getPlainText()); - } - - - - @Test - public void testClientPost() throws Exception { - String blogEntryTitle = "titleByGoogleContactsTestcase"; - Entry newEntry = new Entry(); - newEntry.setTitle(new PlainTextConstruct(blogEntryTitle)); - newEntry.setContent(new PlainTextConstruct("contentByGoogleContactsTestCase")); - Entry postedEntry = testService.clientPost(newEntry); - Assert.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("contactEntryShouldNotApear")); - newEntry.setContent(new PlainTextConstruct("contactByBloggerShouldNotAppear")); - Entry postedEntry = testService.clientPost(newEntry); - Thread.sleep(Constants.SLEEP_INTERVAL); - - //System.out.println("ID: " + postedEntry.getId()); - - int idStartPosition = postedEntry.getId().lastIndexOf("/"); - String postedEntryID = postedEntry.getId().substring(idStartPosition+1); - //System.out.println("postedEntryID: " + postedEntryID ); - - //Before deletion - for (int i = 0; i < 5; i++) { // make 5 attempts because of timing issues - try { - Entry entry00 = testService.clientGetEntry(postedEntryID); - //System.out.println("Before Deletion: " + entry00.getId()); - break; // get was successful - } catch (Exception e) { - if (i < 4) { - System.out.println("Get failed, retrying..."); - } else { - throw e; // final attempt, give up - } - } - } - - //Delete this entry - for (int i = 0; i < 5; i++) { // make 5 attempts because of timing issues - try { - testService.clientDelete(postedEntryID); - break; // delete was successful - } catch (Exception e) { - if (i < 4) { - System.out.println("Delete failed, retrying..."); - } else { - throw e; // final attempt, give up - } - } - } - - //Worked: this newly posted entry did not appear in the contact list - //But we need a Junit assertion here - //Link: http://haibotuscany.blogspot.com/feeds/posts/default/ - //FIXME: Need an assertion here - //Assert(....); - } - - - @Test - public void testClientQuery() throws Exception { - Query myQuery = new Query(new URL("http://www.google.com/m8/feeds/contacts/default/base")); - myQuery.setMaxResults(100); - //myQuery.setUpdatedMin(startTime); - myQuery.setUpdatedMax(DateTime.now()); - 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()); - } - - -} diff --git a/branches/sca-java-1.5.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleWebAlbumServiceTestCase.java b/branches/sca-java-1.5.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleWebAlbumServiceTestCase.java deleted file mode 100644 index 459c2f6933..0000000000 --- a/branches/sca-java-1.5.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleWebAlbumServiceTestCase.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * 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.Assert; - -import org.apache.tuscany.sca.host.embedded.SCADomain; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; - -import com.google.gdata.client.Query; -import com.google.gdata.data.Entry; -import com.google.gdata.data.Feed; - -public class GoogleWebAlbumServiceTestCase { - - private static SCADomain scaDomainConsumer = null; - private static CustomerClient testService = null; - - public GoogleWebAlbumServiceTestCase(){ - - } - - @BeforeClass - public static void setUp() throws Exception { - //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"); - } - - @AfterClass - public static void tearDown(){ - scaDomainConsumer.close(); - } - - @Test - public void testClientGetFeed() throws Exception { - Feed feed = testService.clientGetFeed(); - //System.out.println("feed title: " + feed.getTitle().getPlainText()); - Assert.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()); - Assert.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(Constants.SLEEP_INTERVAL); - Entry updatedEntry = testService.clientGetEntry(entryID); - Assert.assertEquals(newBlogEntryTitle, updatedEntry.getTitle().getPlainText()); - } - - - @Test - @Ignore("Not testing anything") - 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); - } - -} diff --git a/branches/sca-java-1.5.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/Provider.java b/branches/sca-java-1.5.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/Provider.java deleted file mode 100644 index 21bff30256..0000000000 --- a/branches/sca-java-1.5.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/Provider.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 Provider { - - 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(); - } -} diff --git a/branches/sca-java-1.5.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/StartLocalhostServlet.java b/branches/sca-java-1.5.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/StartLocalhostServlet.java deleted file mode 100644 index 2773398426..0000000000 --- a/branches/sca-java-1.5.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/StartLocalhostServlet.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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(); - } -} |