Author: pkluegl
Date: Wed Nov 6 10:20:52 2019
New Revision: 1869455
URL: http://svn.apache.org/viewvc?rev=1869455&view=rev
Log:
UIMA-6131: avoid usage of Error
Modified:
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/engine/RutaTestUtils.java
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/seed/TextSeeder.java
uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/OutOfWindowTest.java
Modified:
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/engine/RutaTestUtils.java
URL:
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/engine/RutaTestUtils.java?rev=1869455&r1=1869454&r2=1869455&view=diff
==============================================================================
---
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/engine/RutaTestUtils.java
(original)
+++
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/engine/RutaTestUtils.java
Wed Nov 6 10:20:52 2019
@@ -306,7 +306,7 @@ public class RutaTestUtils {
Type t = getTestType(cas, typeId);
Collection<AnnotationFS> select = CasUtil.select(cas, t);
if (select.size() != expectedCnt) {
- throw new AssertionError("size of expected annotations (" + expectedCnt
+ throw new RuntimeException("size of expected annotations (" + expectedCnt
+ ") does not match with actual size (" + select.size() + ").");
}
if (expecteds.length > 0) {
@@ -314,7 +314,7 @@ public class RutaTestUtils {
for (String expected : expecteds) {
String actual = iterator.next().getCoveredText();
if (!actual.equals(expected)) {
- throw new AssertionError(
+ throw new RuntimeException(
"expected text (" + expected + ") does not match with actual
(" + actual + ").");
}
}
Modified:
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/seed/TextSeeder.java
URL:
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/seed/TextSeeder.java?rev=1869455&r1=1869454&r2=1869455&view=diff
==============================================================================
---
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/seed/TextSeeder.java
(original)
+++
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/seed/TextSeeder.java
Wed Nov 6 10:20:52 2019
@@ -33,6 +33,7 @@ public class TextSeeder implements RutaA
public static final String seedType = "org.apache.uima.ruta.type.TokenSeed";
+ @Override
public Type seed(String text, CAS cas) {
Type result = null;
JCas jCas = null;
@@ -55,7 +56,8 @@ public class TextSeeder implements RutaA
try {
a = sourceLexer.yylex();
- } catch (Exception e) {
+ } catch (Throwable e) {
+ // ignore problems
}
while (a != null) {
cas.addFsToIndexes(a);
Modified:
uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/OutOfWindowTest.java
URL:
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/OutOfWindowTest.java?rev=1869455&r1=1869454&r2=1869455&view=diff
==============================================================================
---
uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/OutOfWindowTest.java
(original)
+++
uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/OutOfWindowTest.java
Wed Nov 6 10:20:52 2019
@@ -41,18 +41,18 @@ public class OutOfWindowTest {
cas.release();
}
-
+
@Test
public void testFeatureMatch() {
String document = "First Sentence. Second Sentence.";
String script = "";
script += "(# PERIOD){-> T1};";
script += "T1 #{-> T1};";
-
+
script += "CW.ct==\"First\"{-> GATHER(Struct, \"next\" = 3)} #
CW.ct==\"Second\";";
script += "T1->{Struct.next{REGEXP(\"Sec.*\") -> T2};};";
script += "T1<-{Struct.next{PARTOF(CW) -> T3};};";
-
+
Map<String, String> complexTypes = new TreeMap<String, String>();
String typeName = "org.apache.uima.Struct";
complexTypes.put(typeName, "uima.tcas.Annotation");
@@ -62,33 +62,32 @@ public class OutOfWindowTest {
features.put(typeName, list);
String fn1 = "next";
list.add(new TestFeature(fn1, "", "uima.tcas.Annotation"));
-
+
CAS cas = null;
try {
cas = RutaTestUtils.getCAS(document, complexTypes, features);
Ruta.apply(cas, script);
} catch (Exception e) {
- throw new AssertionError("No exception is expected when applying the
rules.", e);
+ throw new RuntimeException("No exception is expected when applying the
rules.", e);
}
-
-
+
RutaTestUtils.assertAnnotationsEquals(cas, 2, 1, "Second");
RutaTestUtils.assertAnnotationsEquals(cas, 3, 1, "Second");
cas.release();
}
-
+
@Test
public void testSequentialAfterOutOfWindowFeatureMatch() {
String document = "First Sentence. Second one.";
String script = "";
script += "(# PERIOD){-> T1};";
script += "T1 #{-> T1};";
-
+
script += "CW.ct==\"First\"{-> GATHER(Struct, \"next\" = 3)} #
CW.ct==\"Second\";";
script += "T1->{Struct.next{REGEXP(\"Sec.*\")} ANY{-> T2};};";
script += "T1<-{Struct.next{PARTOF(CW)} ANY{-> T3};};";
-
+
Map<String, String> complexTypes = new TreeMap<String, String>();
String typeName = "org.apache.uima.Struct";
complexTypes.put(typeName, "uima.tcas.Annotation");
@@ -98,20 +97,19 @@ public class OutOfWindowTest {
features.put(typeName, list);
String fn1 = "next";
list.add(new TestFeature(fn1, "", "uima.tcas.Annotation"));
-
+
CAS cas = null;
try {
cas = RutaTestUtils.getCAS(document, complexTypes, features);
Ruta.apply(cas, script);
} catch (Exception e) {
- throw new AssertionError("No exception is expected when applying the
rules.", e);
+ throw new RuntimeException("No exception is expected when applying the
rules.", e);
}
-
-
+
RutaTestUtils.assertAnnotationsEquals(cas, 2, 0);
RutaTestUtils.assertAnnotationsEquals(cas, 3, 0);
cas.release();
}
-
+
}