diff options
Diffstat (limited to '')
11 files changed, 170 insertions, 193 deletions
diff --git a/branches/sca-java-1.x/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingInvoker.java b/branches/sca-java-1.x/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingInvoker.java index 9575b2ebd0..dd748fec85 100644 --- a/branches/sca-java-1.x/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingInvoker.java +++ b/branches/sca-java-1.x/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingInvoker.java @@ -140,7 +140,7 @@ class GdataBindingInvoker implements Invoker, DataExchangeSemantics { @Override public Message invoke(Message msg) { - System.out.println("[Debug Info]GdataBindingInvoker.PostInvoker --- invoke method reached"); + //System.out.println("[Debug Info]GdataBindingInvoker.PostInvoker --- invoke method reached"); // Post an entry Object[] args = (Object[])msg.getBody(); com.google.gdata.data.Entry feedEntry = null; @@ -149,10 +149,10 @@ class GdataBindingInvoker implements Invoker, DataExchangeSemantics { // Expect an GData entry - System.out.println("[Debug Info]GdataBindingInvoker.PostInvoker --- supportsFeedEntries: " + provider.supportsFeedEntries()); + //System.out.println("[Debug Info]GdataBindingInvoker.PostInvoker --- supportsFeedEntries: " + provider.supportsFeedEntries()); feedEntry = (com.google.gdata.data.Entry)args[0]; - System.out.println("[Debug Info]GdataBindingInvoker.PostInvoker --- feedEntry title: " + feedEntry.getTitle().getPlainText()); + //System.out.println("[Debug Info]GdataBindingInvoker.PostInvoker --- feedEntry title: " + feedEntry.getTitle().getPlainText()); } else { // Expect a key and data item @@ -222,7 +222,7 @@ class GdataBindingInvoker implements Invoker, DataExchangeSemantics { com.google.gdata.data.Entry toUpdateEntry = googleService.getEntry(entryURL, com.google.gdata.data.Entry.class); - System.out.println("EditHtml:" + toUpdateEntry.getEditLink().getHref()); + //System.out.println("EditHtml:" + toUpdateEntry.getEditLink().getHref()); URL editURL = new URL(toUpdateEntry.getEditLink().getHref()); @@ -269,7 +269,7 @@ class GdataBindingInvoker implements Invoker, DataExchangeSemantics { com.google.gdata.data.Entry toUpdateEntry = googleService.getEntry(entryURL, com.google.gdata.data.Entry.class); - System.out.println("EditHtml:" + toUpdateEntry.getEditLink().getHref()); + //System.out.println("EditHtml:" + toUpdateEntry.getEditLink().getHref()); URL editURL = new URL(toUpdateEntry.getEditLink().getHref()); @@ -309,7 +309,7 @@ class GdataBindingInvoker implements Invoker, DataExchangeSemantics { GetMethod getMethod = new GetMethod(uri); getMethod.setRequestHeader("Authorization", authorizationHeader); - System.out.println("[Debug Info] GdataBindingInvoker.GetAllInvoker.invoke---feedURL: " + uri); + //System.out.println("[Debug Info] GdataBindingInvoker.GetAllInvoker.invoke---feedURL: " + uri); try { @@ -354,7 +354,7 @@ class GdataBindingInvoker implements Invoker, DataExchangeSemantics { Object[] args = (Object[])msg.getBody(); Query myQuery = (Query)args[0]; - System.out.println("[Debug Info] GdataBindingInvoker.QueryInvoker.invoke---feedURL: " + uri); + //System.out.println("[Debug Info] GdataBindingInvoker.QueryInvoker.invoke---feedURL: " + uri); try { diff --git a/branches/sca-java-1.x/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingListenerServlet.java b/branches/sca-java-1.x/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingListenerServlet.java index a615b2067e..34d6ca85dc 100644 --- a/branches/sca-java-1.x/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingListenerServlet.java +++ b/branches/sca-java-1.x/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingListenerServlet.java @@ -158,7 +158,7 @@ class GdataBindingListenerServlet extends HttpServlet { qname = new QName(qname.getNamespaceURI(), itemClass.getSimpleName()); itemClassType = new DataTypeImpl<XMLType>("java:complexType", itemClass, new XMLType(qname, null)); - System.out.println("[Debug Info]GdataBindingListenerServlet --- initilized!"); + //System.out.println("[Debug Info]GdataBindingListenerServlet --- initilized!"); } @@ -166,14 +166,13 @@ class GdataBindingListenerServlet extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // No authentication required for a get request - System.out.println("[Debug Info]GdataBindingListenerServlet doGet() --- I am good here 00"); + //System.out.println("[Debug Info]GdataBindingListenerServlet doGet() --- I am good here 00"); // Get the request path String path = URLDecoder.decode(request.getRequestURI().substring(request.getServletPath().length()), "UTF-8"); - System.out.println("[Debug Info]GdataBindingListenerServlet doGet() --- request.getRequestURI(): " + request - .getRequestURI()); - System.out.println("[Debug Info]GdataBindingListenerServlet doGet()--- path: " + path); + //System.out.println("[Debug Info]GdataBindingListenerServlet doGet() --- request.getRequestURI(): " + request.getRequestURI()); + //System.out.println("[Debug Info]GdataBindingListenerServlet doGet()--- path: " + path); // FIXME: Log this get http request, commented out for testing logger.fine("get " + request.getRequestURI()); @@ -218,25 +217,25 @@ class GdataBindingListenerServlet extends HttpServlet { // get HTTP request asking for a feed - System.out.println("[Debug Info]GdataBindingListenerServlet doGet() --- I am good here brach 02"); + //System.out.println("[Debug Info]GdataBindingListenerServlet doGet() --- I am good here brach 02"); // Return a feed containing the entries in the collection com.google.gdata.data.Feed feed = null; if (supportsFeedEntries) { - System.out.println("[Debug Info]GdataBindingListenerServlet doGet() --- supportsFeedEntries: " + supportsFeedEntries); + //System.out.println("[Debug Info]GdataBindingListenerServlet doGet() --- supportsFeedEntries: " + supportsFeedEntries); // The service implementation supports feed entries, invoke its // getFeed operation Message requestMessage = messageFactory.createMessage(); Message responseMessage; if (request.getQueryString() != null) { - System.out.println("getQueryString != null"); + //System.out.println("getQueryString != null"); requestMessage.setBody(new Object[] {request.getQueryString()}); responseMessage = queryInvoker.invoke(requestMessage); } else { - System.out.println("getQueryString == null"); + //System.out.println("getQueryString == null"); responseMessage = getFeedInvoker.invoke(requestMessage); } if (responseMessage.isFault()) { @@ -247,11 +246,11 @@ class GdataBindingListenerServlet extends HttpServlet { feed = (com.google.gdata.data.Feed)responseMessage.getBody(); - System.out.println("feed title: " + feed.getTitle().getPlainText()); + //System.out.println("feed title: " + feed.getTitle().getPlainText()); } else { - System.out.println("GdataBindingListenerServlet doGet(): do not supportsFeedEntries"); + //System.out.println("GdataBindingListenerServlet doGet(): do not supportsFeedEntries"); // The service implementation does not support feed entries, // invoke its getAll operation to get the data item collection, @@ -317,7 +316,7 @@ class GdataBindingListenerServlet extends HttpServlet { out.println(stringWriter.toString()); out.close(); - System.out.println("Feed content in plain text:" + stringWriter.toString()); + //System.out.println("Feed content in plain text:" + stringWriter.toString()); } else { response.sendError(HttpServletResponse.SC_NOT_FOUND); } @@ -342,7 +341,7 @@ class GdataBindingListenerServlet extends HttpServlet { // The service implementation returns a feed entry feedEntry = (com.google.gdata.data.Entry)responseMessage.getBody(); - System.out.println("entry title: " + feedEntry.getTitle().getPlainText()); + //System.out.println("entry title: " + feedEntry.getTitle().getPlainText()); } else { // The service implementation only returns a data item, create @@ -387,7 +386,7 @@ class GdataBindingListenerServlet extends HttpServlet { protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - System.out.println("[Debug Info]GdataBindingListenerServlet doPost() --- reached"); + //System.out.println("[Debug Info]GdataBindingListenerServlet doPost() --- reached"); // Authenticate the user String user = processAuthorizationHeader(request); @@ -399,7 +398,7 @@ class GdataBindingListenerServlet extends HttpServlet { // Get the request path String path = URLDecoder.decode(request.getRequestURI().substring(request.getServletPath().length()), "UTF-8"); - System.out.println("[Debug Info]GdataBindingListenerServlet path --- " + path); + //System.out.println("[Debug Info]GdataBindingListenerServlet path --- " + path); if (path == null || path.length() == 0 || path.equals("/")) { // Create a new Gdata entry @@ -534,7 +533,7 @@ class GdataBindingListenerServlet extends HttpServlet { // Get the request path String path = request.getRequestURI().substring(request.getServletPath().length()); - System.out.println("[Debug Info] localServlet doPut --- path: " + path); + //System.out.println("[Debug Info] localServlet doPut --- path: " + path); if (path != null && path.startsWith("/")) { String id = path.substring(1); @@ -549,7 +548,7 @@ class GdataBindingListenerServlet extends HttpServlet { ParseSource source = new ParseSource(request.getReader()); feedEntry = com.google.gdata.data.Entry.readEntry(source, com.google.gdata.data.Entry.class, null); - System.out.println("[Debug Info] localServlet doPut --- feedEntry title: " + feedEntry.getTitle().getPlainText()); + //System.out.println("[Debug Info] localServlet doPut --- feedEntry title: " + feedEntry.getTitle().getPlainText()); } catch (ParseException pe) { throw new ServletException(pe); } catch (com.google.gdata.util.ParseException e) { @@ -565,7 +564,7 @@ class GdataBindingListenerServlet extends HttpServlet { // Let the component implementation create it if (supportsFeedEntries) { - System.out.println("[Debug Info] localServlet doPut --- supportsFeedEntries: " + supportsFeedEntries); + //System.out.println("[Debug Info] localServlet doPut --- supportsFeedEntries: " + supportsFeedEntries); // The service implementation supports feed entries, pass // the entry to it diff --git a/branches/sca-java-1.x/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataReferenceBindingProvider.java b/branches/sca-java-1.x/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataReferenceBindingProvider.java index 7656754bca..ac8c298d1a 100644 --- a/branches/sca-java-1.x/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataReferenceBindingProvider.java +++ b/branches/sca-java-1.x/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataReferenceBindingProvider.java @@ -88,9 +88,9 @@ class GdataReferenceBindingProvider implements ReferenceBindingProvider { 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); + //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){ diff --git a/branches/sca-java-1.x/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/Consumer.java b/branches/sca-java-1.x/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/Consumer.java index 2517c7233a..7d723a2883 100644 --- a/branches/sca-java-1.x/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/Consumer.java +++ b/branches/sca-java-1.x/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/Consumer.java @@ -36,7 +36,7 @@ public class Consumer { Feed feed = testService.clientGetFeed(); - System.out.println("#Entries(Before post): "+ testService.clientGetFeed().getEntries().size()); + //System.out.println("#Entries(Before post): "+ testService.clientGetFeed().getEntries().size()); /* String entryID = "tag:blogger.com,1999:blog-4520949313432095990.post-973462497533349425"; @@ -49,11 +49,11 @@ public class Consumer { myEntry.setContent(new PlainTextConstruct("contentByConsmer2")); testService.clientPost(myEntry); - System.out.println("#Entries(After post): "+ testService.clientGetFeed().getEntries().size()); + //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()); + //System.out.println("Entry id: " + entry.getId()); } diff --git a/branches/sca-java-1.x/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/ConsumerProviderTestCase.java b/branches/sca-java-1.x/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/ConsumerProviderTestCase.java index 2c15242675..be4cc657f4 100644 --- a/branches/sca-java-1.x/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/ConsumerProviderTestCase.java +++ b/branches/sca-java-1.x/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/ConsumerProviderTestCase.java @@ -19,60 +19,57 @@ package org.apache.tuscany.sca.binding.gdata; -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.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 extends TestCase { - - private SCADomain scaDomainProvider = null; - private SCADomain scaDomainConsumer = null; - private CustomerClient testService = null; +public class ConsumerProviderTestCase { - @Before - @Override - public void setUp() throws Exception { - System.out.println("Method Test Start-----------------------------------------------------------------------"); + 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"); - System.out.println("[Debug Info] Provider.composite ready..."); + //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 - @Override - public void tearDown() { + @AfterClass + public static void tearDown() { + scaDomainConsumer.close(); 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); + //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)" - assertEquals("Feedtitle(LocalHostServlet)", feed.getTitle().getPlainText()); + 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()); - assertEquals(entryID, entry.getId()); + //System.out.println("entryID in testcase: " + entry.getId()); + Assert.assertEquals(entryID, entry.getId()); } @Test @@ -81,7 +78,7 @@ public class ConsumerProviderTestCase extends TestCase { newEntry.setTitle(new PlainTextConstruct("NewEntry title by Post")); newEntry.setContent(new PlainTextConstruct("NewEntry Content by Post")); Entry postedEntry = testService.clientPost(newEntry); - assertEquals("NewEntry title by Post", postedEntry.getTitle().getPlainText()); + Assert.assertEquals("NewEntry title by Post", postedEntry.getTitle().getPlainText()); } @@ -90,12 +87,12 @@ public class ConsumerProviderTestCase extends TestCase { public void testClientPut() throws Exception { String newTitleValue = "newTitleValueByPut"; String entryID = "urn:uuid:customer-0"; - System.out.println("Before clientPut"); + //System.out.println("Before clientPut"); testService.clientPut(entryID, newTitleValue); - System.out.println("After clientPut"); + //System.out.println("After clientPut"); Entry updatedEntry = testService.clientGetEntry(entryID); - System.out.println("title: "+ updatedEntry.getTitle().getPlainText()); - assertEquals(newTitleValue, updatedEntry.getTitle().getPlainText()); + //System.out.println("title: "+ updatedEntry.getTitle().getPlainText()); + Assert.assertEquals(newTitleValue, updatedEntry.getTitle().getPlainText()); } @@ -116,22 +113,22 @@ public class ConsumerProviderTestCase extends TestCase { Feed feed00 = testService.clientGetFeed(); int entryNum00 = feed00.getEntries().size(); // The number of entries // before deleting - System.out.println("entryNum00:" + entryNum00); + //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("confirmed entry ID: " + confirmedNewEntry.getId()); + //System.out.println("confirmed entry title: " + confirmedNewEntry.getTitle().getPlainText()); - System.out.println("Before test clientDelete"); + //System.out.println("Before test clientDelete"); testService.clientDelete(entryID); - System.out.println("After test clientDelete"); + //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 + //System.out.println("entryNum01:" + entryNum01); // The number of entries after deleting //assertEquals(1, entryNum00 - entryNum01); } diff --git a/branches/sca-java-1.x/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/CustomerClientImpl.java b/branches/sca-java-1.x/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/CustomerClientImpl.java index a2b1da894d..7fb7fa9fe2 100644 --- a/branches/sca-java-1.x/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/CustomerClientImpl.java +++ b/branches/sca-java-1.x/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/CustomerClientImpl.java @@ -36,14 +36,14 @@ public class CustomerClientImpl implements CustomerClient { // 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"); + //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()); + //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()); + //System.out.print("Entry" + i + "\t"); + //System.out.println(" id = " + e.getId() + "\t title = " + e.getTitle().getPlainText()); i++; } return feed; @@ -53,11 +53,11 @@ public class CustomerClientImpl implements CustomerClient { // 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 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("\n\n!!! Entry retrieved with id=" + entry.getId() + // + " title=" + // + entry.getTitle().getPlainText()); return entry; } @@ -65,12 +65,11 @@ public class CustomerClientImpl implements CustomerClient { // 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"); + //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()); - System.out.println("\n"); + //System.out.println("!!! New entry posted with id=" + confirmedNewEntry.getId() + // + " title=" + // + confirmedNewEntry.getTitle().getPlainText()); return confirmedNewEntry; } @@ -78,11 +77,10 @@ public class CustomerClientImpl implements CustomerClient { // 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"); + //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"); + //System.out.println("!!! entry with id" + entryID); } @@ -90,16 +88,16 @@ public class CustomerClientImpl implements CustomerClient { // Call Collection.put(entry, updatedTitle) public void clientPut(String entryID, String newTitle) throws Exception { - System.out.println("clientPut"); + //System.out.println("clientPut"); // Put a new entry to the provider - System.out.println(">>> put id=" + entryID + " title=" + newTitle); + //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()); - System.out.println("\n"); + //System.out.println("!!! Updated entry with id=" + entry.getId() + " title=" + entry.getTitle()); + //System.out.println("\n"); } @@ -107,14 +105,14 @@ public class CustomerClientImpl implements CustomerClient { // 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"); + //System.out.println(">>> query the service"); Feed feed = resourceCollection.query(query); - System.out.println("\n\n!!! Query result feed title: " + feed.getTitle().getPlainText()); + //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()); + //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.x/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/CustomerCollectionImpl.java b/branches/sca-java-1.x/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/CustomerCollectionImpl.java index 3c11fb70b9..0772bd67ee 100644 --- a/branches/sca-java-1.x/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/CustomerCollectionImpl.java +++ b/branches/sca-java-1.x/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/CustomerCollectionImpl.java @@ -69,12 +69,12 @@ public class CustomerCollectionImpl implements Collection { // entry.addHtmlLink(""+id, "", "edit"); // entry.addHtmlLink(""+id, "", "alternate"); entries.put(id, entry); - System.out.println(">>> id=" + id); + //System.out.println(">>> id=" + id); } } public Entry post(Entry entry) { - System.out.println(">>> ResourceCollectionImpl.post entry=" + entry.getTitle()); + //System.out.println(">>> ResourceCollectionImpl.post entry=" + entry.getTitle()); String id = "urn:uuid:customer-" + UUID.randomUUID().toString(); entry.setId(id); @@ -93,30 +93,30 @@ public class CustomerCollectionImpl implements Collection { // "alternate"); entries.put(id, entry); - System.out.println(">>> ResourceCollectionImpl.post return id=" + id); + //System.out.println(">>> ResourceCollectionImpl.post return id=" + id); return entry; } public Entry get(String id) { - System.out.println(">>> ResourceCollectionImpl.get id= " + 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()); + //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); + //System.out.println(">>> ResourceCollectionImpl.delete id=" + id); entries.remove(id); } public Feed getFeed() { - System.out.println(">>> ResourceCollectionImpl.get collection"); + //System.out.println(">>> ResourceCollectionImpl.get collection"); Feed feed = new Feed(); feed.setTitle(new PlainTextConstruct("Feedtitle(LocalHostServlet)")); @@ -136,7 +136,7 @@ public class CustomerCollectionImpl implements Collection { //FIXME: need to be modified public Feed query(Query query) { - System.out.println(">>> ResourceCollectionImpl.query collection "); + //System.out.println(">>> ResourceCollectionImpl.query collection "); return getFeed(); } diff --git a/branches/sca-java-1.x/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleBloggerServiceTestCase.java b/branches/sca-java-1.x/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleBloggerServiceTestCase.java index 89f48f08d0..a827677fd0 100644 --- a/branches/sca-java-1.x/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleBloggerServiceTestCase.java +++ b/branches/sca-java-1.x/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleBloggerServiceTestCase.java @@ -42,8 +42,6 @@ public class GoogleBloggerServiceTestCase { @BeforeClass public static 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"); @@ -51,14 +49,13 @@ public class GoogleBloggerServiceTestCase { @AfterClass public static void tearDown(){ - System.out.println("Method Test End------------------------------------------------------------------------"); - System.out.println("\n\n"); + scaDomainConsumer.close(); } @Test public void testClientGetFeed() throws Exception { Feed feed = testService.clientGetFeed(); - System.out.println("feed title: " + feed.getTitle().getPlainText()); + //System.out.println("feed title: " + feed.getTitle().getPlainText()); Assert.assertEquals("gdata binding tuscany test", feed.getTitle().getPlainText()); } @@ -67,9 +64,9 @@ public class GoogleBloggerServiceTestCase { public void testClientGetEntry() throws Exception { String entryID = "8308734583601887890"; Entry blogEntry = testService.clientGetEntry(entryID); - System.out.println("Entry ID: " + blogEntry.getId()); + //System.out.println("Entry ID: " + blogEntry.getId()); Assert.assertTrue(blogEntry.getId().endsWith(entryID)); - System.out.println("------------------------------------------------------------\n\n"); + //System.out.println("------------------------------------------------------------\n\n"); } @@ -102,7 +99,7 @@ public class GoogleBloggerServiceTestCase { //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("blogEntryShouldNotApear")); @@ -111,11 +108,11 @@ public class GoogleBloggerServiceTestCase { Thread.sleep(Constants.SLEEP_INTERVAL); 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); @@ -135,8 +132,8 @@ public class GoogleBloggerServiceTestCase { //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()); } diff --git a/branches/sca-java-1.x/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleCalendarServiceTestCase.java b/branches/sca-java-1.x/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleCalendarServiceTestCase.java index 4451c40faf..e426e22ec9 100644 --- a/branches/sca-java-1.x/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleCalendarServiceTestCase.java +++ b/branches/sca-java-1.x/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleCalendarServiceTestCase.java @@ -21,11 +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.AfterClass; +import org.junit.BeforeClass; import org.junit.Test; import com.google.gdata.client.Query; @@ -34,37 +34,32 @@ import com.google.gdata.data.Entry; import com.google.gdata.data.Feed; import com.google.gdata.data.PlainTextConstruct; -public class GoogleCalendarServiceTestCase extends TestCase{ +public class GoogleCalendarServiceTestCase { - private SCADomain scaDomainConsumer = null; - private CustomerClient testService = null; + private static SCADomain scaDomainConsumer = null; + private static CustomerClient testService = null; public GoogleCalendarServiceTestCase(){ } - @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/ConsumerGoogleCalendar.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("gsoc gosc", feed.getTitle().getPlainText()); + //System.out.println("feed title: " + feed.getTitle().getPlainText()); + Assert.assertEquals("gsoc gosc", feed.getTitle().getPlainText()); } @@ -72,9 +67,9 @@ public class GoogleCalendarServiceTestCase extends TestCase{ public void testClientGetEntry() throws Exception { String entryID = "1c76lcl70jg9r0fm18rcbneea8"; Entry blogEntry = testService.clientGetEntry(entryID); - System.out.println("Entry ID: " + blogEntry.getId()); - assertTrue(blogEntry.getId().endsWith(entryID)); - System.out.println("------------------------------------------------------------\n\n"); + //System.out.println("Entry ID: " + blogEntry.getId()); + Assert.assertTrue(blogEntry.getId().endsWith(entryID)); + //System.out.println("------------------------------------------------------------\n\n"); } @@ -85,7 +80,7 @@ public class GoogleCalendarServiceTestCase 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()); } @@ -97,7 +92,7 @@ public class GoogleCalendarServiceTestCase extends TestCase{ newEntry.setTitle(new PlainTextConstruct(blogEntryTitle)); newEntry.setContent(new PlainTextConstruct("contentByGoogleCalendarTestCase")); Entry postedEntry = testService.clientPost(newEntry); - assertEquals(blogEntryTitle, postedEntry.getTitle().getPlainText()); + Assert.assertEquals(blogEntryTitle, postedEntry.getTitle().getPlainText()); } @@ -107,7 +102,7 @@ public class GoogleCalendarServiceTestCase extends TestCase{ //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("calendarEntryShouldNotApear")); @@ -115,15 +110,15 @@ public class GoogleCalendarServiceTestCase 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); @@ -148,8 +143,8 @@ public class GoogleCalendarServiceTestCase extends TestCase{ 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()); + //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.x/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleContactsServiceTestCase.java b/branches/sca-java-1.x/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleContactsServiceTestCase.java index 7ef9c29fcd..11f39d184b 100644 --- a/branches/sca-java-1.x/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleContactsServiceTestCase.java +++ b/branches/sca-java-1.x/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleContactsServiceTestCase.java @@ -21,11 +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.AfterClass; +import org.junit.BeforeClass; import org.junit.Test; import com.google.gdata.client.Query; @@ -34,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()); + //System.out.println("feed title: " + feed.getTitle().getPlainText()); + Assert.assertEquals("Haibo Zhao's Contacts", feed.getTitle().getPlainText()); } @@ -72,9 +67,9 @@ 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)); + //System.out.println("------------------------------------------------------------\n\n"); } @@ -85,7 +80,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()); } @@ -97,7 +92,7 @@ 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()); } @@ -107,7 +102,7 @@ public class GoogleContactsServiceTestCase extends TestCase { //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")); @@ -115,15 +110,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); @@ -143,8 +138,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()); } diff --git a/branches/sca-java-1.x/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleWebAlbumServiceTestCase.java b/branches/sca-java-1.x/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleWebAlbumServiceTestCase.java index 474d669ff0..6a657d6736 100644 --- a/branches/sca-java-1.x/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleWebAlbumServiceTestCase.java +++ b/branches/sca-java-1.x/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleWebAlbumServiceTestCase.java @@ -21,50 +21,46 @@ 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.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 GoogleWebAlbumServiceTestCase extends TestCase{ +public class GoogleWebAlbumServiceTestCase { - private SCADomain scaDomainConsumer = null; - private CustomerClient testService = null; + private static SCADomain scaDomainConsumer = null; + private static CustomerClient testService = null; public GoogleWebAlbumServiceTestCase(){ } - @Before - @Override - public void setUp() throws Exception { - System.out.println("Method Test Start-----------------------------------------------------------------------"); + @BeforeClass + public static 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"); + @AfterClass + public static 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()); + //System.out.println("feed title: " + feed.getTitle().getPlainText()); + Assert.assertEquals("flowers", feed.getTitle().getPlainText()); } @@ -74,9 +70,9 @@ public class GoogleWebAlbumServiceTestCase extends TestCase{ 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"); + //System.out.println("Entry ID: " + contactEntry.getId()); + Assert.assertTrue(contactEntry.getId().endsWith(entryID)); + //System.out.println("------------------------------------------------------------\n\n"); } @@ -88,8 +84,8 @@ public class GoogleWebAlbumServiceTestCase extends TestCase{ 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()); + //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()); } @@ -102,7 +98,7 @@ public class GoogleWebAlbumServiceTestCase 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()); } |