summaryrefslogtreecommitdiffstats
path: root/sca-java-1.x/branches/sca-java-1.6.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleWebAlbumServiceTestCase.java
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--sca-java-1.x/branches/sca-java-1.6.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleWebAlbumServiceTestCase.java43
1 files changed, 40 insertions, 3 deletions
diff --git a/sca-java-1.x/branches/sca-java-1.6.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleWebAlbumServiceTestCase.java b/sca-java-1.x/branches/sca-java-1.6.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleWebAlbumServiceTestCase.java
index 459c2f6933..e7a83cb367 100644
--- a/sca-java-1.x/branches/sca-java-1.6.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleWebAlbumServiceTestCase.java
+++ b/sca-java-1.x/branches/sca-java-1.6.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleWebAlbumServiceTestCase.java
@@ -19,6 +19,7 @@
package org.apache.tuscany.sca.binding.gdata;
+import java.net.Socket;
import java.net.URL;
import junit.framework.Assert;
@@ -45,17 +46,25 @@ public class 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");
+ if (internetConnected()) {
+ scaDomainConsumer = SCADomain.newInstance("org/apache/tuscany/sca/binding/gdata/ConsumerGoogleWebAlbum.composite");
+ testService = scaDomainConsumer.getService(CustomerClient.class, "CustomerClient");
+ }
}
@AfterClass
public static void tearDown(){
- scaDomainConsumer.close();
+ if (scaDomainConsumer != null) {
+ scaDomainConsumer.close();
+ }
}
@Test
public void testClientGetFeed() throws Exception {
+ if (testService == null) {
+ // no internet connection
+ return;
+ }
Feed feed = testService.clientGetFeed();
//System.out.println("feed title: " + feed.getTitle().getPlainText());
Assert.assertEquals("flowers", feed.getTitle().getPlainText());
@@ -66,6 +75,10 @@ public class GoogleWebAlbumServiceTestCase {
@Test
public void testClientGetEntry() throws Exception {
+ if (testService == null) {
+ // no internet connection
+ return;
+ }
String entryID = "photoid/5233468700029715874";
Entry contactEntry = testService.clientGetEntry(entryID);
//System.out.println("Entry ID: " + contactEntry.getId());
@@ -76,6 +89,10 @@ public class GoogleWebAlbumServiceTestCase {
@Test
public void testClientQuery() throws Exception {
+ if (testService == null) {
+ // no internet connection
+ return;
+ }
String feedUrlString = "http://picasaweb.google.com/data/feed/api/user/haibotuscany/album/flowers";
URL feedURL = new URL(feedUrlString);
Query myQuery = new Query(feedURL);
@@ -91,6 +108,10 @@ public class GoogleWebAlbumServiceTestCase {
@Test
public void testClientPut() throws Exception {
+ if (testService == null) {
+ // no internet connection
+ return;
+ }
String entryID = "photoid/5233468700029715874";
String newBlogEntryTitle = "updatedTitle:dog";
testService.clientPut(entryID, newBlogEntryTitle); //update the title
@@ -112,4 +133,20 @@ public class GoogleWebAlbumServiceTestCase {
//testService.clientDelete(entryID);
}
+ private static boolean internetConnected() {
+ try {
+ // see whether an internet connection is available
+ Socket testInternet = new Socket("tuscany.apache.org", 80);
+ testInternet.close();
+
+ // internet connection available
+ return true;
+
+ } catch (Exception e) {
+ // no internet connection
+ System.out.println("Unable to run test because no internet connection available");
+ return false;
+ }
+ }
+
}