diff options
author | nash <nash@13f79535-47bb-0310-9956-ffa450edef68> | 2010-10-26 12:50:12 +0000 |
---|---|---|
committer | nash <nash@13f79535-47bb-0310-9956-ffa450edef68> | 2010-10-26 12:50:12 +0000 |
commit | 58743897517841a3427d43f76660bd3231e0fcfb (patch) | |
tree | 1cb647bece39ed650fae9386d0f06ab4b7f8f4c6 /sca-java-1.x/trunk/samples/feed-aggregator | |
parent | d9ebf13190d93ec63502518987fb963213560859 (diff) |
Merge r1006260 TUSCANY-3707: If no internet connection, avoid running tests that need the internet
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1027521 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-1.x/trunk/samples/feed-aggregator')
-rw-r--r-- | sca-java-1.x/trunk/samples/feed-aggregator/src/test/java/feed/FeedAggregatorTestCase.java | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/sca-java-1.x/trunk/samples/feed-aggregator/src/test/java/feed/FeedAggregatorTestCase.java b/sca-java-1.x/trunk/samples/feed-aggregator/src/test/java/feed/FeedAggregatorTestCase.java index 7eb52d95f1..8196ef5410 100644 --- a/sca-java-1.x/trunk/samples/feed-aggregator/src/test/java/feed/FeedAggregatorTestCase.java +++ b/sca-java-1.x/trunk/samples/feed-aggregator/src/test/java/feed/FeedAggregatorTestCase.java @@ -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; + } + } } |