Author: nash
Date: Sun Oct 10 09:19:14 2010
New Revision: 1006260

URL: http://svn.apache.org/viewvc?rev=1006260&view=rev
Log:
TUSCANY-3707: If no internet connection, avoid running tests that need the 
internet

Modified:
    
tuscany/sca-java-1.x/branches/sca-java-1.6.1/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/aggregator/AggregatorTestCase.java
    
tuscany/sca-java-1.x/branches/sca-java-1.6.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleBloggerServiceTestCase.java
    
tuscany/sca-java-1.x/branches/sca-java-1.6.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleCalendarServiceTestCase.java
    
tuscany/sca-java-1.x/branches/sca-java-1.6.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleContactsServiceTestCase.java
    
tuscany/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
    
tuscany/sca-java-1.x/branches/sca-java-1.6.1/samples/feed-aggregator/src/test/java/feed/FeedAggregatorTestCase.java

Modified: 
tuscany/sca-java-1.x/branches/sca-java-1.6.1/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/aggregator/AggregatorTestCase.java
URL: 
http://svn.apache.org/viewvc/tuscany/sca-java-1.x/branches/sca-java-1.6.1/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/aggregator/AggregatorTestCase.java?rev=1006260&r1=1006259&r2=1006260&view=diff
==============================================================================
--- 
tuscany/sca-java-1.x/branches/sca-java-1.6.1/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/aggregator/AggregatorTestCase.java
 (original)
+++ 
tuscany/sca-java-1.x/branches/sca-java-1.6.1/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/aggregator/AggregatorTestCase.java
 Sun Oct 10 09:19:14 2010
@@ -56,6 +56,11 @@ public class AggregatorTestCase {
     
     @Test
     public void testAggregator() throws Exception {
+        // this test needs an internet connection
+        if (!internetConnected()) {
+            return;
+        }
+
         Entry<String, Item>[] entries = aggregatorService.getAll();
         
         Assert.assertNotNull(entries);
@@ -65,4 +70,20 @@ public class AggregatorTestCase {
             System.out.println(">>> Entry[" + pos + "] - " + 
entries[pos].getData().getTitle());
         }
     }
+
+    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;
+        }
+    }
 }

Modified: 
tuscany/sca-java-1.x/branches/sca-java-1.6.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleBloggerServiceTestCase.java
URL: 
http://svn.apache.org/viewvc/tuscany/sca-java-1.x/branches/sca-java-1.6.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleBloggerServiceTestCase.java?rev=1006260&r1=1006259&r2=1006260&view=diff
==============================================================================
--- 
tuscany/sca-java-1.x/branches/sca-java-1.6.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleBloggerServiceTestCase.java
 (original)
+++ 
tuscany/sca-java-1.x/branches/sca-java-1.6.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleBloggerServiceTestCase.java
 Sun Oct 10 09:19:14 2010
@@ -19,6 +19,7 @@
 
 package org.apache.tuscany.sca.binding.gdata;
 
+import java.net.Socket;
 import java.net.URL;
 
 import junit.framework.Assert;
@@ -43,17 +44,25 @@ public class GoogleBloggerServiceTestCas
     @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");  
+        if (internetConnected()) {
+            scaDomainConsumer = 
SCADomain.newInstance("org/apache/tuscany/sca/binding/gdata/ConsumerGoogleBlogger.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("gdata binding tuscany test", 
feed.getTitle().getPlainText());
@@ -62,6 +71,10 @@ public class GoogleBloggerServiceTestCas
     
     @Test
     public void testClientGetEntry() throws Exception {
+        if (testService == null) {
+            // no internet connection
+            return;
+        }
         String entryID = "8308734583601887890";
         Entry blogEntry = testService.clientGetEntry(entryID);
         //System.out.println("Entry ID: " + blogEntry.getId());
@@ -72,6 +85,10 @@ public class GoogleBloggerServiceTestCas
     
     @Test
     public void testClientPut() throws Exception {  
+        if (testService == null) {
+            // no internet connection
+            return;
+        }
         String entryID = "2889832689497686762";          
         String newBlogEntryTitle = "updatedTitleByTestCase2";
         testService.clientPut(entryID, newBlogEntryTitle);      //update the 
title
@@ -84,6 +101,10 @@ public class GoogleBloggerServiceTestCas
 
     @Test
     public void testClientPost() throws Exception {
+        if (testService == null) {
+            // no internet connection
+            return;
+        }
         String blogEntryTitle = "titleByBloogerTestcase000";
         Entry newEntry = new Entry();
         newEntry.setTitle(new PlainTextConstruct(blogEntryTitle));
@@ -95,6 +116,10 @@ public class GoogleBloggerServiceTestCas
     
     @Test
     public void testClientDelete() throws Exception {
+        if (testService == null) {
+            // no internet connection
+            return;
+        }
         
         //This test case might fail
         //because Google blogger service has limitation on new posts allowed 
everyday/every hour?
@@ -127,6 +152,10 @@ public class GoogleBloggerServiceTestCas
     
     @Test
     public void testClientQuery() throws Exception {
+        if (testService == null) {
+            // no internet connection
+            return;
+        }
         Query myQuery = new Query(new 
URL("http://haibotuscany.blogspot.com/feeds/posts/default";));
         myQuery.setMaxResults(100);
         //myQuery.setUpdatedMin(startTime);
@@ -137,5 +166,20 @@ public class GoogleBloggerServiceTestCas
         //assertEquals("gdata binding tuscany test", 
resultFeed.getTitle().getPlainText());
      }
 
+    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;
+        }
+    }
 
 }

Modified: 
tuscany/sca-java-1.x/branches/sca-java-1.6.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleCalendarServiceTestCase.java
URL: 
http://svn.apache.org/viewvc/tuscany/sca-java-1.x/branches/sca-java-1.6.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleCalendarServiceTestCase.java?rev=1006260&r1=1006259&r2=1006260&view=diff
==============================================================================
--- 
tuscany/sca-java-1.x/branches/sca-java-1.6.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleCalendarServiceTestCase.java
 (original)
+++ 
tuscany/sca-java-1.x/branches/sca-java-1.6.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleCalendarServiceTestCase.java
 Sun Oct 10 09:19:14 2010
@@ -19,6 +19,7 @@
 
 package org.apache.tuscany.sca.binding.gdata;
 
+import java.net.Socket;
 import java.net.URL;
 
 import junit.framework.Assert;
@@ -46,17 +47,25 @@ public class GoogleCalendarServiceTestCa
     @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");  
+        if (internetConnected()) {
+            scaDomainConsumer = 
SCADomain.newInstance("org/apache/tuscany/sca/binding/gdata/ConsumerGoogleCalendar.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("gsoc gosc", feed.getTitle().getPlainText());
@@ -65,6 +74,10 @@ public class GoogleCalendarServiceTestCa
     
     @Test
     public void testClientGetEntry() throws Exception {
+        if (testService == null) {
+            // no internet connection
+            return;
+        }
         String entryID = "1c76lcl70jg9r0fm18rcbneea8";
         Entry blogEntry = testService.clientGetEntry(entryID);
         //System.out.println("Entry ID: " + blogEntry.getId());
@@ -75,6 +88,10 @@ public class GoogleCalendarServiceTestCa
     
     @Test
     public void testClientPut() throws Exception {  
+        if (testService == null) {
+            // no internet connection
+            return;
+        }
         String entryID = "1c76lcl70jg9r0fm18rcbneea8";          
         String newBlogEntryTitle = 
"updatedTitleByGoogleContactsConsumerTestCase";
         testService.clientPut(entryID, newBlogEntryTitle);      //update the 
title
@@ -85,6 +102,10 @@ public class GoogleCalendarServiceTestCa
     
     @Test
     public void testClientPost() throws Exception {
+        if (testService == null) {
+            // no internet connection
+            return;
+        }
         String blogEntryTitle = "titleByGoogleCalendarTestcase";
         Entry newEntry = new Entry();
         newEntry.setTitle(new PlainTextConstruct(blogEntryTitle));
@@ -95,6 +116,10 @@ public class GoogleCalendarServiceTestCa
 
     @Test
     public void testClientDelete() throws Exception {
+        if (testService == null) {
+            // no internet connection
+            return;
+        }
         
         //This test case might fail
         //because Google blogger service has limitation on new posts allowed 
everyday/every hour?
@@ -130,6 +155,10 @@ public class GoogleCalendarServiceTestCa
     
     @Test
     public void testClientQuery() throws Exception {
+        if (testService == null) {
+            // no internet connection
+            return;
+        }
         Query myQuery = new Query(new 
URL("http://www.google.com/calendar/feeds/[email protected]/private/full";));
         myQuery.setMaxResults(100);
         //myQuery.setUpdatedMin(startTime);
@@ -145,5 +174,20 @@ public class GoogleCalendarServiceTestCa
         //assertEquals("gdata binding tuscany test", 
resultFeed.getTitle().getPlainText());
      }
 
+    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;
+        }
+    }
 
 }

Modified: 
tuscany/sca-java-1.x/branches/sca-java-1.6.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleContactsServiceTestCase.java
URL: 
http://svn.apache.org/viewvc/tuscany/sca-java-1.x/branches/sca-java-1.6.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleContactsServiceTestCase.java?rev=1006260&r1=1006259&r2=1006260&view=diff
==============================================================================
--- 
tuscany/sca-java-1.x/branches/sca-java-1.6.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleContactsServiceTestCase.java
 (original)
+++ 
tuscany/sca-java-1.x/branches/sca-java-1.6.1/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleContactsServiceTestCase.java
 Sun Oct 10 09:19:14 2010
@@ -19,6 +19,7 @@
 
 package org.apache.tuscany.sca.binding.gdata;
 
+import java.net.Socket;
 import java.net.URL;
 
 import junit.framework.Assert;
@@ -46,17 +47,25 @@ public class GoogleContactsServiceTestCa
     @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");  
+        if (internetConnected()) {
+            scaDomainConsumer = 
SCADomain.newInstance("org/apache/tuscany/sca/binding/gdata/ConsumerGoogleContacts.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("Haibo Zhao's Contacts", 
feed.getTitle().getPlainText());
@@ -65,6 +74,10 @@ public class GoogleContactsServiceTestCa
     
     @Test
     public void testClientGetEntry() throws Exception {
+        if (testService == null) {
+            // no internet connection
+            return;
+        }
         String entryID = "12feeeb38ab87365";
         Entry contactEntry = testService.clientGetEntry(entryID);
         //System.out.println("Entry ID: " + contactEntry.getId());
@@ -74,6 +87,10 @@ public class GoogleContactsServiceTestCa
     
     @Test
     public void testClientPut() throws Exception {  
+        if (testService == null) {
+            // no internet connection
+            return;
+        }
         String entryID = "12feeeb38ab87365";          
         String newBlogEntryTitle = 
"updatedTitleByGoogleContactsConsumerTestCase";
         testService.clientPut(entryID, newBlogEntryTitle);      //update the 
title
@@ -86,6 +103,10 @@ public class GoogleContactsServiceTestCa
 
     @Test
     public void testClientPost() throws Exception {
+        if (testService == null) {
+            // no internet connection
+            return;
+        }
         String blogEntryTitle = "titleByGoogleContactsTestcase";
         Entry newEntry = new Entry();
         newEntry.setTitle(new PlainTextConstruct(blogEntryTitle));
@@ -97,6 +118,10 @@ public class GoogleContactsServiceTestCa
     
     @Test
     public void testClientDelete() throws Exception {
+        if (testService == null) {
+            // no internet connection
+            return;
+        }
         
         //This test case might fail
         //because Google blogger service has limitation on new posts allowed 
everyday/every hour?
@@ -154,6 +179,10 @@ public class GoogleContactsServiceTestCa
     
     @Test
     public void testClientQuery() throws Exception {
+        if (testService == null) {
+            // no internet connection
+            return;
+        }
         Query myQuery = new Query(new 
URL("http://www.google.com/m8/feeds/contacts/default/base";));
         myQuery.setMaxResults(100);
         //myQuery.setUpdatedMin(startTime);
@@ -164,5 +193,20 @@ public class GoogleContactsServiceTestCa
         //assertEquals("gdata binding tuscany test", 
resultFeed.getTitle().getPlainText());
      }
 
+    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;
+        }
+    }
 
 }

Modified: 
tuscany/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
URL: 
http://svn.apache.org/viewvc/tuscany/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?rev=1006260&r1=1006259&r2=1006260&view=diff
==============================================================================
--- 
tuscany/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
 (original)
+++ 
tuscany/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
 Sun Oct 10 09:19:14 2010
@@ -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 GoogleWebAlbumServiceTestCa
     @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 GoogleWebAlbumServiceTestCa
     
     @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 GoogleWebAlbumServiceTestCa
     
     @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 GoogleWebAlbumServiceTestCa
     
     @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 GoogleWebAlbumServiceTestCa
         //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;
+        }
+    }
+
 }

Modified: 
tuscany/sca-java-1.x/branches/sca-java-1.6.1/samples/feed-aggregator/src/test/java/feed/FeedAggregatorTestCase.java
URL: 
http://svn.apache.org/viewvc/tuscany/sca-java-1.x/branches/sca-java-1.6.1/samples/feed-aggregator/src/test/java/feed/FeedAggregatorTestCase.java?rev=1006260&r1=1006259&r2=1006260&view=diff
==============================================================================
--- 
tuscany/sca-java-1.x/branches/sca-java-1.6.1/samples/feed-aggregator/src/test/java/feed/FeedAggregatorTestCase.java
 (original)
+++ 
tuscany/sca-java-1.x/branches/sca-java-1.6.1/samples/feed-aggregator/src/test/java/feed/FeedAggregatorTestCase.java
 Sun Oct 10 09:19:14 2010
@@ -20,6 +20,7 @@ package feed;
 
 import java.io.IOException;
 import java.io.Reader;
+import java.net.Socket;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -67,6 +68,10 @@ public class FeedAggregatorTestCase {
 
     @BeforeClass
     public static void init() throws Exception {
+        if (!internetConnected()) {
+            // no internet connection
+            return;
+        }
         try {
             System.out.println(">>>FeedAggregatorTest.init");
             scaProviderDomain = 
SCADomain.newInstance("FeedAggregator.composite");
@@ -82,17 +87,27 @@ public class FeedAggregatorTestCase {
     @AfterClass
     public static void destroy() throws Exception {
         System.out.println(">>>FeedAggregatorTest.destroy");
-        scaProviderDomain.close();
+        if (scaProviderDomain != null) {
+            scaProviderDomain.close();
+        }
     }
 
     @Test
     public void testPrelim() throws Exception {
+        if (scaProviderDomain == null) {
+            // no internet connection
+            return;
+        }
         Assert.assertNotNull(scaProviderDomain);
         Assert.assertNotNull(client);
     }
 
     @Test
     public void testFeedBasics() throws Exception {
+        if (scaProviderDomain == null) {
+            // no internet connection
+            return;
+        }
         System.out.println(">>>FeedAggregatorTest.testFeedBasics");
         RequestOptions opts = new RequestOptions();
         // Normal feed request
@@ -143,6 +158,10 @@ public class FeedAggregatorTestCase {
 
     @Test
     public void testUnmodifiedGetIfModified() throws Exception {
+        if (scaProviderDomain == null) {
+            // no internet connection
+            return;
+        }
         
System.out.println(">>>FeedAggregatorTest.testFeedUnmodifiedGetIfModified");
         // Feed request with predicates
         RequestOptions opts = new RequestOptions();
@@ -180,6 +199,10 @@ public class FeedAggregatorTestCase {
 
     @Test
     public void testUnmodifiedGetIfUnModified() throws Exception {
+        if (scaProviderDomain == null) {
+            // no internet connection
+            return;
+        }
         
System.out.println(">>>FeedAggregatorTest.testFeedUnmodifiedGetIfUnModified");
         // Feed request with predicates
         RequestOptions opts = new RequestOptions();
@@ -355,4 +378,20 @@ public class FeedAggregatorTestCase {
         // System.out.println( "getUpdatedMedian entry max median=" + median );
         return median;
     }
+
+    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;
+        }
+    }
 }


Reply via email to