Author: tommaso
Date: Wed Jul 18 22:18:28 2012
New Revision: 1363151

URL: http://svn.apache.org/viewvc?rev=1363151&view=rev
Log:
[CLEREZZA-695] - removing stack traces from tests

Modified:
    
incubator/clerezza/trunk/uima/uima.utils/src/test/java/org/apache/clerezza/uima/utils/AEProviderTest.java
    
incubator/clerezza/trunk/uima/uima.utils/src/test/java/org/apache/clerezza/uima/utils/ClerezzaTypeSystemTest.java
    
incubator/clerezza/trunk/uima/uima.utils/src/test/java/org/apache/clerezza/uima/utils/ExternalServicesFacadeTest.java
    
incubator/clerezza/trunk/uima/uima.utils/src/test/java/org/apache/clerezza/uima/utils/UIMAExecutorTest.java
    
incubator/clerezza/trunk/uima/uima.utils/src/test/java/org/apache/clerezza/uima/utils/UIMAUtilsTest.java

Modified: 
incubator/clerezza/trunk/uima/uima.utils/src/test/java/org/apache/clerezza/uima/utils/AEProviderTest.java
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/uima/uima.utils/src/test/java/org/apache/clerezza/uima/utils/AEProviderTest.java?rev=1363151&r1=1363150&r2=1363151&view=diff
==============================================================================
--- 
incubator/clerezza/trunk/uima/uima.utils/src/test/java/org/apache/clerezza/uima/utils/AEProviderTest.java
 (original)
+++ 
incubator/clerezza/trunk/uima/uima.utils/src/test/java/org/apache/clerezza/uima/utils/AEProviderTest.java
 Wed Jul 18 22:18:28 2012
@@ -27,7 +27,6 @@ import static org.junit.Assert.fail;
 
 /**
  * Testcase for {@link AEProvider}
- * 
  */
 public class AEProviderTest {
 
@@ -39,23 +38,15 @@ public class AEProviderTest {
   }
 
   @Test
-  public void testGetDefaultAENotNull() {
-    try {
-      AnalysisEngine ae = this.aeProvider.getDefaultAE();
-      assertTrue(ae != null);
-    } catch (Throwable e) {
-      fail(e.getLocalizedMessage());
-    }
+  public void testGetDefaultAENotNull() throws Exception {
+    AnalysisEngine ae = this.aeProvider.getDefaultAE();
+    assertTrue(ae != null);
   }
 
   @Test
-  public void testGetAEWithPathNotNull() {
-    try {
-      AnalysisEngine ae = this.aeProvider.getAE("/META-INF/ExtServicesAE.xml");
-      assertTrue(ae != null);
-    } catch (Throwable e) {
-      fail(e.getLocalizedMessage());
-    }
+  public void testGetAEWithPathNotNull() throws Exception {
+    AnalysisEngine ae = this.aeProvider.getAE("/META-INF/ExtServicesAE.xml");
+    assertTrue(ae != null);
   }
 
   @Test

Modified: 
incubator/clerezza/trunk/uima/uima.utils/src/test/java/org/apache/clerezza/uima/utils/ClerezzaTypeSystemTest.java
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/uima/uima.utils/src/test/java/org/apache/clerezza/uima/utils/ClerezzaTypeSystemTest.java?rev=1363151&r1=1363150&r2=1363151&view=diff
==============================================================================
--- 
incubator/clerezza/trunk/uima/uima.utils/src/test/java/org/apache/clerezza/uima/utils/ClerezzaTypeSystemTest.java
 (original)
+++ 
incubator/clerezza/trunk/uima/uima.utils/src/test/java/org/apache/clerezza/uima/utils/ClerezzaTypeSystemTest.java
 Wed Jul 18 22:18:28 2012
@@ -40,41 +40,33 @@ import static org.junit.Assert.*;
 public class ClerezzaTypeSystemTest {
 
   @Test
-  public void parsingTest() {
-    try {
-      TypeSystemDescription tsd = 
UIMAFramework.getXMLParser().parseTypeSystemDescription(
-              new 
XMLInputSource(getClass().getResource("/ClerezzaTestTypeSystemDescriptor.xml")));
-      assertNotNull(tsd);
-      
assertNotNull(tsd.getType("org.apache.clerezza.uima.utils.ts.WikipediaEntity"));
-      
assertNotNull(tsd.getType("org.apache.clerezza.uima.utils.ts.WikipediaEntityAnnotation"));
-    } catch (Exception e) {
-      fail(e.getLocalizedMessage());
-    }
+  public void parsingTest() throws Exception {
+    TypeSystemDescription tsd = 
UIMAFramework.getXMLParser().parseTypeSystemDescription(
+            new 
XMLInputSource(getClass().getResource("/ClerezzaTestTypeSystemDescriptor.xml")));
+    assertNotNull(tsd);
+    
assertNotNull(tsd.getType("org.apache.clerezza.uima.utils.ts.WikipediaEntity"));
+    
assertNotNull(tsd.getType("org.apache.clerezza.uima.utils.ts.WikipediaEntityAnnotation"));
   }
 
   @Test
-  public void dummyTypeSystemWithAnnotatorTest() {
-    try {
-      CAS cas = 
AnnotatorTester.performTest("src/test/resources/SampleWikipediaAEDescriptor.xml",
-              "this is useless", null);
-      assertNotNull(cas);
-      /* check annotations */
-      AnnotationIndex<Annotation> annotationIndex = 
cas.getJCas().getAnnotationIndex(
-              WikipediaEntityAnnotation.type);
-      assertNotNull(annotationIndex);
-      assertTrue(annotationIndex.size() == 1);
-      /* check entities */
-      Type type = 
cas.getTypeSystem().getType("org.apache.clerezza.uima.utils.ts.WikipediaEntity");
-      FSIterator<FeatureStructure> entities = 
cas.getJCas().getIndexRepository()
-              .getAllIndexedFS(type);
-      assertTrue(entities.hasNext());
-      while (entities.hasNext()) {
-        FSList references = (FSList) entities.next().getFeatureValue(
-                type.getFeatureByBaseName("references"));
-        assertNotNull(references.getNthElement(0));
-      }
-    } catch (Exception e) {
-      fail(e.getLocalizedMessage());
+  public void dummyTypeSystemWithAnnotatorTest() throws Exception {
+    CAS cas = 
AnnotatorTester.performTest("src/test/resources/SampleWikipediaAEDescriptor.xml",
+            "this is useless", null);
+    assertNotNull(cas);
+    /* check annotations */
+    AnnotationIndex<Annotation> annotationIndex = 
cas.getJCas().getAnnotationIndex(
+            WikipediaEntityAnnotation.type);
+    assertNotNull(annotationIndex);
+    assertTrue(annotationIndex.size() == 1);
+    /* check entities */
+    Type type = 
cas.getTypeSystem().getType("org.apache.clerezza.uima.utils.ts.WikipediaEntity");
+    FSIterator<FeatureStructure> entities = cas.getJCas().getIndexRepository()
+            .getAllIndexedFS(type);
+    assertTrue(entities.hasNext());
+    while (entities.hasNext()) {
+      FSList references = (FSList) entities.next().getFeatureValue(
+              type.getFeatureByBaseName("references"));
+      assertNotNull(references.getNthElement(0));
     }
   }
 }

Modified: 
incubator/clerezza/trunk/uima/uima.utils/src/test/java/org/apache/clerezza/uima/utils/ExternalServicesFacadeTest.java
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/uima/uima.utils/src/test/java/org/apache/clerezza/uima/utils/ExternalServicesFacadeTest.java?rev=1363151&r1=1363150&r2=1363151&view=diff
==============================================================================
--- 
incubator/clerezza/trunk/uima/uima.utils/src/test/java/org/apache/clerezza/uima/utils/ExternalServicesFacadeTest.java
 (original)
+++ 
incubator/clerezza/trunk/uima/uima.utils/src/test/java/org/apache/clerezza/uima/utils/ExternalServicesFacadeTest.java
 Wed Jul 18 22:18:28 2012
@@ -34,113 +34,86 @@ import static org.junit.Assert.*;
  */
 public class ExternalServicesFacadeTest {
 
-    private static final String AN_ENGLISH_TEXT = "this is a document supposed 
to be recognized as written in the language of Queen Elizabeth";
+  private static final String AN_ENGLISH_TEXT = "this is a document supposed 
to be recognized as written in the language of Queen Elizabeth";
 
-    private static final String CLEREZZA_RELATED_TEXT = "Clerezza is fully 
based on OSGi. OSGi is a very lightweight approach to offer the modularization 
and dynamism missing in standard Java. By using OSGi services it can also 
interoperate with Spring-DS or Peaberry applications";
+  private static final String CLEREZZA_RELATED_TEXT = "Clerezza is fully based 
on OSGi. OSGi is a very lightweight approach to offer the modularization and 
dynamism missing in standard Java. By using OSGi services it can also 
interoperate with Spring-DS or Peaberry applications";
 
-    private static final String ANOTHER_ENGLISH_TEXT ="President Obama vows to 
\"make BP pay\" for the Gulf oil spill, and says the US must end its fossil 
fuel \"addiction\".";
-
-    @Test
-    public void getLanguageTest() {
-        try {
-            ExternalServicesFacade externalServicesFacade = new 
ExternalServicesFacade();
-            Map<String, Object> parameterSettings = new HashMap<String, 
Object>();
-            parameterSettings.put("apikey", 
"04490000a72fe7ec5cb3497f14e77f338c86f2fe");
-            externalServicesFacade.setParameterSetting(parameterSettings);
-            FeatureStructure languageFS = 
externalServicesFacade.getLanguage(AN_ENGLISH_TEXT);
-            String language = 
languageFS.getStringValue(languageFS.getType().getFeatureByBaseName("language"));
-            assertEquals(language, "english");
-        } catch (Exception e) {
-            e.printStackTrace();
-            fail(e.getLocalizedMessage());
-        }
-
-    }
-
-
-    @Test
-    public void getTagsTest() {
-        try {
-            ExternalServicesFacade externalServicesFacade = new 
ExternalServicesFacade();
-            Map<String, Object> parameterSettings = new HashMap<String, 
Object>();
-            parameterSettings.put("apikey", 
"04490000a72fe7ec5cb3497f14e77f338c86f2fe");
-            externalServicesFacade.setParameterSetting(parameterSettings);
-            List<FeatureStructure> tags = 
externalServicesFacade.getTags(AN_ENGLISH_TEXT);
-            assertTrue(tags != null);
-            assertTrue(!tags.isEmpty());
-            assertTrue(tags.size() == 1);
-            FeatureStructure keyword = tags.get(0);
-            Type type = keyword.getType();
-            String tagText = 
keyword.getStringValue(type.getFeatureByBaseName("text"));
-            assertTrue(tagText!=null && tagText.equals("document"));
-        } catch (Exception e) {
-            e.printStackTrace();
-            fail(e.getLocalizedMessage());
-        }
+  private static final String ANOTHER_ENGLISH_TEXT = "President Obama vows to 
\"make BP pay\" for the Gulf oil spill, and says the US must end its fossil 
fuel \"addiction\".";
 
+  @Test
+  public void getLanguageTest() throws Exception {
+    ExternalServicesFacade externalServicesFacade = new 
ExternalServicesFacade();
+    Map<String, Object> parameterSettings = new HashMap<String, Object>();
+    parameterSettings.put("apikey", 
"04490000a72fe7ec5cb3497f14e77f338c86f2fe");
+    externalServicesFacade.setParameterSetting(parameterSettings);
+    FeatureStructure languageFS = 
externalServicesFacade.getLanguage(AN_ENGLISH_TEXT);
+    String language = 
languageFS.getStringValue(languageFS.getType().getFeatureByBaseName("language"));
+    assertEquals(language, "english");
+
+  }
+
+
+  @Test
+  public void getTagsTest() throws Exception {
+    ExternalServicesFacade externalServicesFacade = new 
ExternalServicesFacade();
+    Map<String, Object> parameterSettings = new HashMap<String, Object>();
+    parameterSettings.put("apikey", 
"04490000a72fe7ec5cb3497f14e77f338c86f2fe");
+    externalServicesFacade.setParameterSetting(parameterSettings);
+    List<FeatureStructure> tags = 
externalServicesFacade.getTags(AN_ENGLISH_TEXT);
+    assertTrue(tags != null);
+    assertTrue(!tags.isEmpty());
+    assertTrue(tags.size() == 1);
+    FeatureStructure keyword = tags.get(0);
+    Type type = keyword.getType();
+    String tagText = keyword.getStringValue(type.getFeatureByBaseName("text"));
+    assertTrue(tagText != null && tagText.equals("document"));
+
+  }
+
+  @Test
+  public void getNamedEntitiesTest() throws Exception {
+    ExternalServicesFacade externalServicesFacade = new 
ExternalServicesFacade();
+    String licenseId = "g6h9zamsdtwhb93nc247ecrs";
+    Map<String, Object> parameterSettings = new HashMap<String, Object>();
+    parameterSettings.put("licenseID", licenseId);
+    externalServicesFacade.setParameterSetting(parameterSettings);
+    List<FeatureStructure> entities = 
externalServicesFacade.getNamedEntities(ANOTHER_ENGLISH_TEXT);
+    assertTrue(entities != null);
+    assertTrue(!entities.isEmpty());
+    for (FeatureStructure fs : entities) {
+      Annotation annotation = (Annotation) fs;
+      assertTrue(annotation.getType() != null && 
annotation.getType().getName() != null);
+      assertTrue(annotation.getBegin() > 0);
+      assertTrue(annotation.getEnd() > 0);
+      assertTrue(annotation.getCoveredText() != null);
     }
+  }
 
-    @Test
-    public void getNamedEntitiesTest() {
-        try {
-            ExternalServicesFacade externalServicesFacade = new 
ExternalServicesFacade();
-            String licenseId = "g6h9zamsdtwhb93nc247ecrs";
-            Map<String, Object> parameterSettings = new HashMap<String, 
Object>();
-            parameterSettings.put("licenseID", licenseId);
-            externalServicesFacade.setParameterSetting(parameterSettings);
-            List<FeatureStructure> entities = 
externalServicesFacade.getNamedEntities(ANOTHER_ENGLISH_TEXT);
-            assertTrue(entities != null);
-            assertTrue(!entities.isEmpty());
-            for (FeatureStructure fs : entities) {
-              Annotation annotation = (Annotation) fs;
-              assertTrue(annotation.getType()!=null && 
annotation.getType().getName()!=null);
-              assertTrue(annotation.getBegin()>0);
-              assertTrue(annotation.getEnd()>0);
-              assertTrue(annotation.getCoveredText()!=null);
-            }
-        }
-        catch (Exception e) {
-            e.printStackTrace();
-            fail(e.getLocalizedMessage());
-        }
-    }
-
-    @Test
-    public void getCategoryTest() {
-       try {
-            ExternalServicesFacade externalServicesFacade = new 
ExternalServicesFacade();
-            Map<String, Object> parameterSettings = new HashMap<String, 
Object>();
-            parameterSettings.put("apikey", 
"04490000a72fe7ec5cb3497f14e77f338c86f2fe");
-            externalServicesFacade.setParameterSetting(parameterSettings);
-            FeatureStructure categoryFS = 
externalServicesFacade.getCategory(CLEREZZA_RELATED_TEXT);
-            String category = 
categoryFS.getStringValue(categoryFS.getType().getFeatureByBaseName("text"));
-            assertEquals(category, "computer_internet");
-        } catch (Exception e) {
-            e.printStackTrace();
-            fail(e.getLocalizedMessage());
-        }
-    }
-
-    @Test
-    public void getConceptsTest() {
-        try {
-            ExternalServicesFacade externalServicesFacade = new 
ExternalServicesFacade();
-            Map<String, Object> parameterSettings = new HashMap<String, 
Object>();
-            parameterSettings.put("apikey", 
"04490000a72fe7ec5cb3497f14e77f338c86f2fe");
-            externalServicesFacade.setParameterSetting(parameterSettings);
-            List<FeatureStructure> concepts = 
externalServicesFacade.getConcepts(ANOTHER_ENGLISH_TEXT);
-            assertTrue(concepts != null);
-            assertTrue("Concepts list is empty",!concepts.isEmpty());
-            assertTrue("Concepts list size is 
"+concepts.size(),concepts.size() == 8);
-            FeatureStructure concept = concepts.get(0);
-            Type type = concept.getType();
-            String conceptText = 
concept.getStringValue(type.getFeatureByBaseName("text"));
-            assertTrue("First concept was"+conceptText+" instead of 
Petroleum",conceptText!=null && conceptText.equals("Petroleum"));
-        } catch (Exception e) {
-            e.printStackTrace();
-            fail(e.getLocalizedMessage());
-        }
-
-    }
+  @Test
+  public void getCategoryTest() throws Exception {
+    ExternalServicesFacade externalServicesFacade = new 
ExternalServicesFacade();
+    Map<String, Object> parameterSettings = new HashMap<String, Object>();
+    parameterSettings.put("apikey", 
"04490000a72fe7ec5cb3497f14e77f338c86f2fe");
+    externalServicesFacade.setParameterSetting(parameterSettings);
+    FeatureStructure categoryFS = 
externalServicesFacade.getCategory(CLEREZZA_RELATED_TEXT);
+    String category = 
categoryFS.getStringValue(categoryFS.getType().getFeatureByBaseName("text"));
+    assertEquals(category, "computer_internet");
+  }
+
+  @Test
+  public void getConceptsTest() throws Exception {
+    ExternalServicesFacade externalServicesFacade = new 
ExternalServicesFacade();
+    Map<String, Object> parameterSettings = new HashMap<String, Object>();
+    parameterSettings.put("apikey", 
"04490000a72fe7ec5cb3497f14e77f338c86f2fe");
+    externalServicesFacade.setParameterSetting(parameterSettings);
+    List<FeatureStructure> concepts = 
externalServicesFacade.getConcepts(ANOTHER_ENGLISH_TEXT);
+    assertTrue(concepts != null);
+    assertTrue("Concepts list is empty", !concepts.isEmpty());
+    assertTrue("Concepts list size is " + concepts.size(), concepts.size() == 
8);
+    FeatureStructure concept = concepts.get(0);
+    Type type = concept.getType();
+    String conceptText = 
concept.getStringValue(type.getFeatureByBaseName("text"));
+    assertTrue("First concept was" + conceptText + " instead of Petroleum", 
conceptText != null && conceptText.equals("Petroleum"));
+  }
 
 }

Modified: 
incubator/clerezza/trunk/uima/uima.utils/src/test/java/org/apache/clerezza/uima/utils/UIMAExecutorTest.java
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/uima/uima.utils/src/test/java/org/apache/clerezza/uima/utils/UIMAExecutorTest.java?rev=1363151&r1=1363150&r2=1363151&view=diff
==============================================================================
--- 
incubator/clerezza/trunk/uima/uima.utils/src/test/java/org/apache/clerezza/uima/utils/UIMAExecutorTest.java
 (original)
+++ 
incubator/clerezza/trunk/uima/uima.utils/src/test/java/org/apache/clerezza/uima/utils/UIMAExecutorTest.java
 Wed Jul 18 22:18:28 2012
@@ -21,7 +21,6 @@ package org.apache.clerezza.uima.utils;
 import org.junit.Test;
 
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
 /**
  * Testcase for {@link UIMAExecutor}
@@ -29,23 +28,15 @@ import static org.junit.Assert.fail;
 public class UIMAExecutorTest {
 
   @Test
-  public void testDefaultConstructor() {
-    try {
-      UIMAExecutor uimaExecutor = 
UIMAExecutorFactory.getInstance().createUIMAExecutor();
-      assertTrue(uimaExecutor != null);
-    } catch (Throwable e) {
-      fail(e.getLocalizedMessage());
-    }
+  public void testDefaultConstructor() throws Exception {
+    UIMAExecutor uimaExecutor = 
UIMAExecutorFactory.getInstance().createUIMAExecutor();
+    assertTrue(uimaExecutor != null);
   }
 
   @Test
-  public void testPathConstructor() {
-    try {
-      UIMAExecutor uimaExecutor = 
UIMAExecutorFactory.getInstance().createUIMAExecutor("/META-INF/ExtServicesAE.xml");
-      assertTrue(uimaExecutor != null);
-    } catch (Throwable e) {
-      fail(e.getLocalizedMessage());
-    }
+  public void testPathConstructor() throws Exception {
+    UIMAExecutor uimaExecutor = 
UIMAExecutorFactory.getInstance().createUIMAExecutor("/META-INF/ExtServicesAE.xml");
+    assertTrue(uimaExecutor != null);
   }
 
 }

Modified: 
incubator/clerezza/trunk/uima/uima.utils/src/test/java/org/apache/clerezza/uima/utils/UIMAUtilsTest.java
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/uima/uima.utils/src/test/java/org/apache/clerezza/uima/utils/UIMAUtilsTest.java?rev=1363151&r1=1363150&r2=1363151&view=diff
==============================================================================
--- 
incubator/clerezza/trunk/uima/uima.utils/src/test/java/org/apache/clerezza/uima/utils/UIMAUtilsTest.java
 (original)
+++ 
incubator/clerezza/trunk/uima/uima.utils/src/test/java/org/apache/clerezza/uima/utils/UIMAUtilsTest.java
 Wed Jul 18 22:18:28 2012
@@ -50,71 +50,54 @@ public class UIMAUtilsTest {
   private static final String DOCUMENT_TEXT = "the server will return a \"A 
concept with the same label and language already exists!\", so there are 
actually 2 issues:";
 
   @Test
-  public void testGetAllFSOfAnnotationType() {
-    try {
-      JCas cas = getCAS().getJCas();
-      cas.setDocumentText(DOCUMENT_TEXT);
-
-      FeatureStructure firstFeatureStructure = new TOP(cas);
-      cas.addFsToIndexes(firstFeatureStructure);
-      FeatureStructure secondFeatureStructure = new TOP(cas);
-      cas.addFsToIndexes(secondFeatureStructure);
-
-      List<FeatureStructure> featureStructures = 
UIMAUtils.getAllFSofType(TOP.type, cas);
-
-      assertTrue(featureStructures != null);
-      assertTrue(!featureStructures.isEmpty());
-      assertTrue(featureStructures.size() == 3); // two simple FSs and the 
DocumentAnnotation, both extend TOP
-    } catch (Exception e) {
-      e.printStackTrace();
-      fail(e.toString());
-    }
-
+  public void testGetAllFSOfAnnotationType() throws Exception {
+    JCas cas = getCAS().getJCas();
+    cas.setDocumentText(DOCUMENT_TEXT);
+
+    FeatureStructure firstFeatureStructure = new TOP(cas);
+    cas.addFsToIndexes(firstFeatureStructure);
+    FeatureStructure secondFeatureStructure = new TOP(cas);
+    cas.addFsToIndexes(secondFeatureStructure);
+
+    List<FeatureStructure> featureStructures = 
UIMAUtils.getAllFSofType(TOP.type, cas);
+
+    assertTrue(featureStructures != null);
+    assertTrue(!featureStructures.isEmpty());
+    assertTrue(featureStructures.size() == 3); // two simple FSs and the 
DocumentAnnotation, both extend TOP
   }
 
   @Test
-  public void testGetAllAnnotationsOfCustomType() {
-    try {
-      JCas cas = getCAS().getJCas();
-      cas.setDocumentText(DOCUMENT_TEXT);
-
-      Annotation simpleAnnotation = new Annotation(cas);
-      simpleAnnotation.setBegin(10);
-      simpleAnnotation.setEnd(24);
-      simpleAnnotation.addToIndexes();
-
-      Annotation secondSimpleAnnotation = new Annotation(cas);
-      secondSimpleAnnotation.setBegin(32);
-      secondSimpleAnnotation.setEnd(44);
-      secondSimpleAnnotation.addToIndexes();
-
-      List<Annotation> foundAnnotations = 
UIMAUtils.getAllAnnotationsOfType(DocumentAnnotation.type, cas);
-
-      assertTrue(foundAnnotations != null);
-      assertTrue(!foundAnnotations.isEmpty());
-      assertTrue(foundAnnotations.size() == 1);
-    } catch (Exception e) {
-      e.printStackTrace();
-      fail(e.toString());
-    }
-
+  public void testGetAllAnnotationsOfCustomType() throws Exception {
+    JCas cas = getCAS().getJCas();
+    cas.setDocumentText(DOCUMENT_TEXT);
+
+    Annotation simpleAnnotation = new Annotation(cas);
+    simpleAnnotation.setBegin(10);
+    simpleAnnotation.setEnd(24);
+    simpleAnnotation.addToIndexes();
+
+    Annotation secondSimpleAnnotation = new Annotation(cas);
+    secondSimpleAnnotation.setBegin(32);
+    secondSimpleAnnotation.setEnd(44);
+    secondSimpleAnnotation.addToIndexes();
+
+    List<Annotation> foundAnnotations = 
UIMAUtils.getAllAnnotationsOfType(DocumentAnnotation.type, cas);
+
+    assertTrue(foundAnnotations != null);
+    assertTrue(!foundAnnotations.isEmpty());
+    assertTrue(foundAnnotations.size() == 1);
   }
 
   @Test
-  public void testGetSingletonFS() {
-    try {
-      JCas cas = getCAS().getJCas();
-      cas.setDocumentText(DOCUMENT_TEXT);
-      FeatureStructure documentAnnotation = 
UIMAUtils.getSingletonFeatureStructure(DocumentAnnotation.type, cas);
-      assertTrue(documentAnnotation != null);
-    } catch (Exception e) {
-      e.printStackTrace();
-      fail(e.toString());
-    }
+  public void testGetSingletonFS() throws Exception {
+    JCas cas = getCAS().getJCas();
+    cas.setDocumentText(DOCUMENT_TEXT);
+    FeatureStructure documentAnnotation = 
UIMAUtils.getSingletonFeatureStructure(DocumentAnnotation.type, cas);
+    assertTrue(documentAnnotation != null);
   }
 
   @Test
-  public void testFailingGetSingletonFS() {
+  public void testFailingGetSingletonFS() throws Exception {
     try {
       JCas cas = getCAS().getJCas();
       cas.setDocumentText(DOCUMENT_TEXT);
@@ -136,9 +119,7 @@ public class UIMAUtilsTest {
   }
 
   @Test
-  public void testEnhanceNode() {
-
-    try {
+  public void testEnhanceNode() throws Exception {
       JCas cas = getCAS().getJCas();
       cas.setDocumentText(DOCUMENT_TEXT);
 
@@ -156,12 +137,6 @@ public class UIMAUtilsTest {
       GraphNode node = new GraphNode(new UriRef(cas.toString()), mGraph);
 
       UIMAUtils.enhanceNode(node, 
UIMAUtils.getAllAnnotationsOfType(Annotation.type, cas));
-
-
-    } catch (Exception e) {
-      fail(e.getLocalizedMessage());
-    }
-
   }
 
 


Reply via email to