From 62763d793935f6346f95ca0c79051855422710a7 Mon Sep 17 00:00:00 2001 From: lresende Date: Thu, 17 Jul 2008 21:32:17 +0000 Subject: Renaming gdata binding testcases to be automatically executed by surefire git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@677737 13f79535-47bb-0310-9956-ffa450edef68 --- .../binding/gdata/ConsumerProviderTestCase.java | 128 +++++++++++++++++++ .../gdata/GoogleBloggerServiceTestCase.java | 132 ++++++++++++++++++++ .../Test_GdataBinding_GoogleBloggerService.java | 137 --------------------- .../gdata/Test_GdataBinding_LocalhostServlet.java | 128 ------------------- 4 files changed, 260 insertions(+), 265 deletions(-) create mode 100644 java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/ConsumerProviderTestCase.java create mode 100644 java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleBloggerServiceTestCase.java delete mode 100644 java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/Test_GdataBinding_GoogleBloggerService.java delete mode 100644 java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/Test_GdataBinding_LocalhostServlet.java (limited to 'java/sca') diff --git a/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/ConsumerProviderTestCase.java b/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/ConsumerProviderTestCase.java new file mode 100644 index 0000000000..ea34169297 --- /dev/null +++ b/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/ConsumerProviderTestCase.java @@ -0,0 +1,128 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.gdata; + +import junit.framework.TestCase; +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import com.google.gdata.data.Entry; +import com.google.gdata.data.Feed; +import com.google.gdata.data.PlainTextConstruct; + +public class ConsumerProviderTestCase extends TestCase { + + private SCADomain scaDomainProvider = null; + private SCADomain scaDomainConsumer = null; + private CustomerClient testService = null; + + @Before + public void setUp() throws Exception { + System.out.println("Method Test Start-----------------------------------------------------------------------"); + + // Setup the local GData servlet (Service Binding test) + scaDomainProvider = SCADomain.newInstance("org/apache/tuscany/sca/binding/gdata/Provider.composite"); + System.out.println("[Debug Info] Provider.composite ready..."); + + // Initialize the GData client service (Reference Binding test) + scaDomainConsumer = SCADomain.newInstance("org/apache/tuscany/sca/binding/gdata/Consumer.composite"); + testService = scaDomainConsumer.getService(CustomerClient.class, "CustomerClient"); + } + + @After + public void tearDown() { + scaDomainProvider.close(); + System.out.println("Method Test End------------------------------------------------------------------------"); + System.out.println("\n\n"); + } + + + @Test + public void testClientGetFeed() throws Exception { + Feed feed = testService.clientGetFeed(); + System.out.println(feed.getTitle().getPlainText()); + assertNotNull(feed); + // Given we are testing on the localhost providing feed, we know the + // feed title is "Feedtitle(LocalHostServlet)" + assertEquals("Feedtitle(LocalHostServlet)", feed.getTitle().getPlainText()); + } + + @Test + public void testClientGetEntry() throws Exception { + String entryID = "urn:uuid:customer-0"; + Entry entry = testService.clientGetEntry(entryID); + System.out.println("entryID in testcase: " + entry.getId()); + assertEquals(entryID, entry.getId()); + } + + @Test + public void testClientPost() throws Exception { + Entry newEntry = new Entry(); + newEntry.setTitle(new PlainTextConstruct("NewEntry title")); + newEntry.setContent(new PlainTextConstruct("NewEntry Content")); + Entry postedEntry = testService.clientPost(newEntry); + assertEquals("NewEntry title", postedEntry.getTitle().getPlainText()); + } + + @Test + public void testClientDelete() throws Exception { + + // We first create a new entry, then delete it + + // Post a new entry + Entry newEntry = new Entry(); + newEntry.setTitle(new PlainTextConstruct("NewEntry title")); + newEntry.setContent(new PlainTextConstruct("NewEntry Content")); + Entry confirmedNewEntry = testService.clientPost(newEntry); + + Thread.sleep(300); + + Feed feed00 = testService.clientGetFeed(); + int entryNum00 = feed00.getEntries().size(); // The number of entries + // before deleting + System.out.println("entryNum00:" + entryNum00); + + // Delete this newly created entry + String entryID = confirmedNewEntry.getId(); + Thread.sleep(300); + + testService.clientDelete(entryID); + Feed feed01 = testService.clientGetFeed(); + int entryNum01 = feed01.getEntries().size(); + System.out.println("entryNum01:" + entryNum01); // The number of entries + // after deleting + assertEquals(1, entryNum00 - entryNum01); + } + + + @Test + public void testClientPut() throws Exception { + String newTitleValue = "newTitleValueByPut"; + String entryID = "urn:uuid:customer-0"; + testService.clientPut(entryID, newTitleValue); + Entry updatedEntry = testService.clientGetEntry(entryID); + System.out.println("title: "+ updatedEntry.getTitle().getPlainText()); + assertEquals(newTitleValue, updatedEntry.getTitle().getPlainText()); + } + + + +} diff --git a/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleBloggerServiceTestCase.java b/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleBloggerServiceTestCase.java new file mode 100644 index 0000000000..9871823dcc --- /dev/null +++ b/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleBloggerServiceTestCase.java @@ -0,0 +1,132 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.gdata; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import com.google.gdata.data.Entry; +import com.google.gdata.data.Feed; +import com.google.gdata.data.PlainTextConstruct; + +public class GoogleBloggerServiceTestCase extends TestCase{ + + private SCADomain scaDomainConsumer = null; + private CustomerClient testService = null; + + + public GoogleBloggerServiceTestCase(){ + + } + + @Before + public void setUp() throws Exception { + System.out.println("Method Test Start-----------------------------------------------------------------------"); + + //Initialize the GData client service (Reference Binding test) + scaDomainConsumer = SCADomain.newInstance("org/apache/tuscany/sca/binding/gdata/ConsumerGoogleBlogger.composite"); + testService = scaDomainConsumer.getService(CustomerClient.class, "CustomerClient"); + } + + @After + public void tearDown(){ + System.out.println("Method Test End------------------------------------------------------------------------"); + System.out.println("\n\n"); + } + + @Test + public void testClientGetFeed() throws Exception { + Feed feed = testService.clientGetFeed(); + System.out.println("feed title: " + feed.getTitle().getPlainText()); + assertEquals("gdata binding tuscany test", feed.getTitle().getPlainText()); + } + + + @Test + public void testClientGetEntry() throws Exception { + String entryID = "8308734583601887890"; + Entry blogEntry = testService.clientGetEntry(entryID); + System.out.println("Entry ID: " + blogEntry.getId()); + assertTrue(blogEntry.getId().endsWith(entryID)); + System.out.println("------------------------------------------------------------\n\n"); + } + + + @Test + public void testClientPut() throws Exception { + String entryID = "2889832689497686762"; + String newBlogEntryTitle = "updatedTitleByTestCase2"; + testService.clientPut(entryID, newBlogEntryTitle); //update the title + Thread.sleep(300); + Entry updatedEntry = testService.clientGetEntry(entryID); + assertEquals(newBlogEntryTitle, updatedEntry.getTitle().getPlainText()); + } + + + + @Test + public void testClientPost() throws Exception { + String blogEntryTitle = "titleByBloogerTestcase000"; + Entry newEntry = new Entry(); + newEntry.setTitle(new PlainTextConstruct(blogEntryTitle)); + newEntry.setContent(new PlainTextConstruct("contentByBloggerTestCase000")); + Entry postedEntry = testService.clientPost(newEntry); + assertEquals(blogEntryTitle, postedEntry.getTitle().getPlainText()); + } + + + @Test + public void testClientDelete() throws Exception { + + //This test case might fail + //because Google blogger service has limitation on new posts allowed everyday/every hour? + + System.out.println("testClientDelete"); + //We create a new post, and then delete it + Entry newEntry = new Entry(); + newEntry.setTitle(new PlainTextConstruct("blogEntryShouldNotApear")); + newEntry.setContent(new PlainTextConstruct("contentByBloggerShouldNotAppear")); + Entry postedEntry = testService.clientPost(newEntry); + Thread.sleep(300); + int idStartPosition = postedEntry.getId().lastIndexOf("-"); + String postedEntryID = postedEntry.getId().substring(idStartPosition+1); + System.out.println("postedEntryID: " + postedEntryID ); + + //Before deletion + Entry entry00 = testService.clientGetEntry(postedEntryID); + System.out.println("Before Deleteion: " + entry00.getId()); + + //Delete this entry + testService.clientDelete(postedEntryID); + + //This newly posted entry did not appear in the blogspot website, + //We need a Junit assertion here + //Link: http://haibotuscany.blogspot.com/feeds/posts/default/ + //FIXME: Need an assertion here + //Assert(....); + } + + + +} diff --git a/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/Test_GdataBinding_GoogleBloggerService.java b/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/Test_GdataBinding_GoogleBloggerService.java deleted file mode 100644 index d16b0e304f..0000000000 --- a/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/Test_GdataBinding_GoogleBloggerService.java +++ /dev/null @@ -1,137 +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 static org.junit.Assert.*; - -import java.io.IOException; - -import junit.framework.TestCase; - -import org.apache.tuscany.sca.host.embedded.SCADomain; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -import com.google.gdata.data.Entry; -import com.google.gdata.data.Feed; -import com.google.gdata.data.PlainTextConstruct; - -public class Test_GdataBinding_GoogleBloggerService extends TestCase{ - - private SCADomain scaDomainConsumer = null; - private CustomerClient testService = null; - - - public Test_GdataBinding_GoogleBloggerService(){ - - } - - @Before - public void setUp() throws Exception { - System.out.println("Method Test Start-----------------------------------------------------------------------"); - - //Initialize the GData client service (Reference Binding test) - scaDomainConsumer = SCADomain.newInstance("org/apache/tuscany/sca/binding/gdata/ConsumerGoogleBlogger.composite"); - testService = scaDomainConsumer.getService(CustomerClient.class, "CustomerClient"); - } - - @After - public void tearDown(){ - System.out.println("Method Test End------------------------------------------------------------------------"); - System.out.println("\n\n"); - } - - @Test - public void testClientGetFeed() throws Exception { - Feed feed = testService.clientGetFeed(); - System.out.println("feed title: " + feed.getTitle().getPlainText()); - assertEquals("gdata binding tuscany test", feed.getTitle().getPlainText()); - } - - - @Test - public void testClientGetEntry() throws Exception { - String entryID = "8308734583601887890"; - Entry blogEntry = testService.clientGetEntry(entryID); - System.out.println("Entry ID: " + blogEntry.getId()); - assertTrue(blogEntry.getId().endsWith(entryID)); - System.out.println("------------------------------------------------------------\n\n"); - } - - - @Test - public void testClientPut() throws Exception { - String entryID = "2889832689497686762"; - String newBlogEntryTitle = "updatedTitleByTestCase2"; - testService.clientPut(entryID, newBlogEntryTitle); //update the title - Thread.sleep(300); - Entry updatedEntry = testService.clientGetEntry(entryID); - assertEquals(newBlogEntryTitle, updatedEntry.getTitle().getPlainText()); - } - - - - @Test - public void testClientPost() throws Exception { - String blogEntryTitle = "titleByBloogerTestcase000"; - Entry newEntry = new Entry(); - newEntry.setTitle(new PlainTextConstruct(blogEntryTitle)); - newEntry.setContent(new PlainTextConstruct("contentByBloggerTestCase000")); - Entry postedEntry = testService.clientPost(newEntry); - assertEquals(blogEntryTitle, postedEntry.getTitle().getPlainText()); - } - - - @Test - public void testClientDelete() throws Exception { - - //This test case might fail - //because Google blogger service has limitation on new posts allowed everyday/every hour? - - System.out.println("testClientDelete"); - //We create a new post, and then delete it - Entry newEntry = new Entry(); - newEntry.setTitle(new PlainTextConstruct("blogEntryShouldNotApear")); - newEntry.setContent(new PlainTextConstruct("contentByBloggerShouldNotAppear")); - Entry postedEntry = testService.clientPost(newEntry); - Thread.sleep(300); - int idStartPosition = postedEntry.getId().lastIndexOf("-"); - String postedEntryID = postedEntry.getId().substring(idStartPosition+1); - System.out.println("postedEntryID: " + postedEntryID ); - - //Before deletion - Entry entry00 = testService.clientGetEntry(postedEntryID); - System.out.println("Before Deleteion: " + entry00.getId()); - - //Delete this entry - testService.clientDelete(postedEntryID); - - //This newly posted entry did not appear in the blogspot website, - //We need a Junit assertion here - //Link: http://haibotuscany.blogspot.com/feeds/posts/default/ - //FIXME: Need an assertion here - //Assert(....); - } - - - -} diff --git a/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/Test_GdataBinding_LocalhostServlet.java b/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/Test_GdataBinding_LocalhostServlet.java deleted file mode 100644 index 99af6d6506..0000000000 --- a/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/Test_GdataBinding_LocalhostServlet.java +++ /dev/null @@ -1,128 +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.TestCase; -import org.apache.tuscany.sca.host.embedded.SCADomain; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import com.google.gdata.data.Entry; -import com.google.gdata.data.Feed; -import com.google.gdata.data.PlainTextConstruct; - -public class Test_GdataBinding_LocalhostServlet extends TestCase { - - private SCADomain scaDomainProvider = null; - private SCADomain scaDomainConsumer = null; - private CustomerClient testService = null; - - @Before - public void setUp() throws Exception { - System.out.println("Method Test Start-----------------------------------------------------------------------"); - - // Setup the local GData servlet (Service Binding test) - scaDomainProvider = SCADomain.newInstance("org/apache/tuscany/sca/binding/gdata/Provider.composite"); - System.out.println("[Debug Info] Provider.composite ready..."); - - // Initialize the GData client service (Reference Binding test) - scaDomainConsumer = SCADomain.newInstance("org/apache/tuscany/sca/binding/gdata/Consumer.composite"); - testService = scaDomainConsumer.getService(CustomerClient.class, "CustomerClient"); - } - - @After - public void tearDown() { - scaDomainProvider.close(); - System.out.println("Method Test End------------------------------------------------------------------------"); - System.out.println("\n\n"); - } - - - @Test - public void testClientGetFeed() throws Exception { - Feed feed = testService.clientGetFeed(); - System.out.println(feed.getTitle().getPlainText()); - assertNotNull(feed); - // Given we are testing on the localhost providing feed, we know the - // feed title is "Feedtitle(LocalHostServlet)" - assertEquals("Feedtitle(LocalHostServlet)", feed.getTitle().getPlainText()); - } - - @Test - public void testClientGetEntry() throws Exception { - String entryID = "urn:uuid:customer-0"; - Entry entry = testService.clientGetEntry(entryID); - System.out.println("entryID in testcase: " + entry.getId()); - assertEquals(entryID, entry.getId()); - } - - @Test - public void testClientPost() throws Exception { - Entry newEntry = new Entry(); - newEntry.setTitle(new PlainTextConstruct("NewEntry title")); - newEntry.setContent(new PlainTextConstruct("NewEntry Content")); - Entry postedEntry = testService.clientPost(newEntry); - assertEquals("NewEntry title", postedEntry.getTitle().getPlainText()); - } - - @Test - public void testClientDelete() throws Exception { - - // We first create a new entry, then delete it - - // Post a new entry - Entry newEntry = new Entry(); - newEntry.setTitle(new PlainTextConstruct("NewEntry title")); - newEntry.setContent(new PlainTextConstruct("NewEntry Content")); - Entry confirmedNewEntry = testService.clientPost(newEntry); - - Thread.sleep(300); - - Feed feed00 = testService.clientGetFeed(); - int entryNum00 = feed00.getEntries().size(); // The number of entries - // before deleting - System.out.println("entryNum00:" + entryNum00); - - // Delete this newly created entry - String entryID = confirmedNewEntry.getId(); - Thread.sleep(300); - - testService.clientDelete(entryID); - Feed feed01 = testService.clientGetFeed(); - int entryNum01 = feed01.getEntries().size(); - System.out.println("entryNum01:" + entryNum01); // The number of entries - // after deleting - assertEquals(1, entryNum00 - entryNum01); - } - - - @Test - public void testClientPut() throws Exception { - String newTitleValue = "newTitleValueByPut"; - String entryID = "urn:uuid:customer-0"; - testService.clientPut(entryID, newTitleValue); - Entry updatedEntry = testService.clientGetEntry(entryID); - System.out.println("title: "+ updatedEntry.getTitle().getPlainText()); - assertEquals(newTitleValue, updatedEntry.getTitle().getPlainText()); - } - - - -} -- cgit v1.2.3