You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by to...@apache.org on 2011/04/19 14:56:26 UTC

svn commit: r1095073 - /uima/sandbox/trunk/AlchemyAPIAnnotator/src/test/java/org/apache/uima/alchemy/annotator/URLMicroformatsAnnotatorTest.java

Author: tommaso
Date: Tue Apr 19 12:56:25 2011
New Revision: 1095073

URL: http://svn.apache.org/viewvc?rev=1095073&view=rev
Log:
[UIMA-2129] - added check if URL is reachable to avoid failures due to connectivity

Modified:
    uima/sandbox/trunk/AlchemyAPIAnnotator/src/test/java/org/apache/uima/alchemy/annotator/URLMicroformatsAnnotatorTest.java

Modified: uima/sandbox/trunk/AlchemyAPIAnnotator/src/test/java/org/apache/uima/alchemy/annotator/URLMicroformatsAnnotatorTest.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/AlchemyAPIAnnotator/src/test/java/org/apache/uima/alchemy/annotator/URLMicroformatsAnnotatorTest.java?rev=1095073&r1=1095072&r2=1095073&view=diff
==============================================================================
--- uima/sandbox/trunk/AlchemyAPIAnnotator/src/test/java/org/apache/uima/alchemy/annotator/URLMicroformatsAnnotatorTest.java (original)
+++ uima/sandbox/trunk/AlchemyAPIAnnotator/src/test/java/org/apache/uima/alchemy/annotator/URLMicroformatsAnnotatorTest.java Tue Apr 19 12:56:25 2011
@@ -24,6 +24,7 @@ import org.apache.uima.alchemy.utils.Tes
 import org.apache.uima.jcas.JCas;
 import org.junit.Test;
 
+import java.net.URI;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -39,18 +40,28 @@ public class URLMicroformatsAnnotatorTes
   @Test
   public void annotatorIntegrationTest() {
     try {
-      Map<String,Object> parameterSettings = new HashMap<String, Object>();
-      parameterSettings.put("apikey","04490000a72fe7ec5cb3497f14e77f338c86f2fe");
-      JCas resultingCAS = TestUtils.executeAE(TestUtils.getAE(XML_PATH,parameterSettings), URL);
-      List<MicroformatFS> microformats = (List<MicroformatFS>) TestUtils.getAllFSofType(MicroformatFS.type, resultingCAS);
-      assertTrue(microformats!=null);
-      assertTrue(microformats.size()==7);
+      if (isURLreachable()) {
+        Map<String,Object> parameterSettings = new HashMap<String, Object>();
+        parameterSettings.put("apikey","04490000a72fe7ec5cb3497f14e77f338c86f2fe");
+        JCas resultingCAS = TestUtils.executeAE(TestUtils.getAE(XML_PATH,parameterSettings), URL);
+        List<MicroformatFS> microformats = (List<MicroformatFS>) TestUtils.getAllFSofType(MicroformatFS.type, resultingCAS);
+        assertTrue(microformats!=null);
+        assertTrue(microformats.size()==7);
+      }
     } catch (Exception e) {
       e.printStackTrace();
       fail(e.toString());
     }
   }
 
+  private boolean isURLreachable() {
+    try {
+      return new URI(URL).toURL().getContent() != null;
+    } catch (Exception e) {
+      return false;
+    }
+  }
+
   @SuppressWarnings("unchecked")
   @Test
   public void mockedAnnotatorTest() {