diff options
Diffstat (limited to 'branches/sca-java-1.5.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleContactsServiceTestCase.java')
-rw-r--r-- | branches/sca-java-1.5.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleContactsServiceTestCase.java | 52 |
1 files changed, 22 insertions, 30 deletions
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 index e63692153f..1eff8a1316 100644 --- 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 @@ -21,12 +21,11 @@ package org.apache.tuscany.sca.binding.gdata; import java.net.URL; -import junit.framework.TestCase; +import junit.framework.Assert; import org.apache.tuscany.sca.host.embedded.SCADomain; -import org.junit.After; -import org.junit.Before; -import org.junit.Ignore; +import org.junit.AfterClass; +import org.junit.BeforeClass; import org.junit.Test; import com.google.gdata.client.Query; @@ -35,37 +34,32 @@ import com.google.gdata.data.Entry; import com.google.gdata.data.Feed; import com.google.gdata.data.PlainTextConstruct; -public class GoogleContactsServiceTestCase extends TestCase { +public class GoogleContactsServiceTestCase { - private SCADomain scaDomainConsumer = null; - private CustomerClient testService = null; + private static SCADomain scaDomainConsumer = null; + private static CustomerClient testService = null; public GoogleContactsServiceTestCase(){ } - @Before - @Override - public void setUp() throws Exception { - System.out.println("Method Test Start-----------------------------------------------------------------------"); - + @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"); } - @After - @Override - public void tearDown(){ - System.out.println("Method Test End------------------------------------------------------------------------"); - System.out.println("\n\n"); + @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()); - assertEquals("Haibo Zhao's Contacts", feed.getTitle().getPlainText()); + Assert.assertEquals("Haibo Zhao's Contacts", feed.getTitle().getPlainText()); } @@ -73,9 +67,8 @@ public class GoogleContactsServiceTestCase extends TestCase { public void testClientGetEntry() throws Exception { String entryID = "12feeeb38ab87365"; Entry contactEntry = testService.clientGetEntry(entryID); - System.out.println("Entry ID: " + contactEntry.getId()); - assertTrue(contactEntry.getId().endsWith(entryID)); - System.out.println("------------------------------------------------------------\n\n"); + //System.out.println("Entry ID: " + contactEntry.getId()); + Assert.assertTrue(contactEntry.getId().endsWith(entryID)); } @@ -86,7 +79,7 @@ public class GoogleContactsServiceTestCase extends TestCase { testService.clientPut(entryID, newBlogEntryTitle); //update the title Thread.sleep(Constants.SLEEP_INTERVAL); Entry updatedEntry = testService.clientGetEntry(entryID); - assertEquals(newBlogEntryTitle, updatedEntry.getTitle().getPlainText()); + Assert.assertEquals(newBlogEntryTitle, updatedEntry.getTitle().getPlainText()); } @@ -98,18 +91,17 @@ public class GoogleContactsServiceTestCase extends TestCase { newEntry.setTitle(new PlainTextConstruct(blogEntryTitle)); newEntry.setContent(new PlainTextConstruct("contentByGoogleContactsTestCase")); Entry postedEntry = testService.clientPost(newEntry); - assertEquals(blogEntryTitle, postedEntry.getTitle().getPlainText()); + Assert.assertEquals(blogEntryTitle, postedEntry.getTitle().getPlainText()); } - //@Ignore("TUSCANY-3164") @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"); + //System.out.println("testClientDelete"); //We create a new post, and then delete it Entry newEntry = new Entry(); newEntry.setTitle(new PlainTextConstruct("contactEntryShouldNotApear")); @@ -117,15 +109,15 @@ public class GoogleContactsServiceTestCase extends TestCase { Entry postedEntry = testService.clientPost(newEntry); Thread.sleep(Constants.SLEEP_INTERVAL); - System.out.println("ID: " + postedEntry.getId()); + //System.out.println("ID: " + postedEntry.getId()); int idStartPosition = postedEntry.getId().lastIndexOf("/"); String postedEntryID = postedEntry.getId().substring(idStartPosition+1); - System.out.println("postedEntryID: " + postedEntryID ); + //System.out.println("postedEntryID: " + postedEntryID ); //Before deletion Entry entry00 = testService.clientGetEntry(postedEntryID); - System.out.println("Before Deleteion: " + entry00.getId()); + //System.out.println("Before Deleteion: " + entry00.getId()); //Delete this entry testService.clientDelete(postedEntryID); @@ -145,8 +137,8 @@ public class GoogleContactsServiceTestCase extends TestCase { //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()); + //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()); } |