Merge branch 'main' into refactoring/339-Drop-CasAnnotationViewerApplet-and-CasTreeViewerApplet
diff --git a/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/AnnotatorContext_implTest.java b/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/AnnotatorContext_implTest.java
index 75d75d9..8326a97 100644
--- a/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/AnnotatorContext_implTest.java
+++ b/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/AnnotatorContext_implTest.java
@@ -19,16 +19,15 @@
package org.apache.uima.analysis_engine.impl;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.within;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.InputStream;
import java.net.URI;
import java.net.URL;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import org.apache.uima.UIMAFramework;
@@ -41,7 +40,6 @@
import org.apache.uima.resource.impl.TestResourceInterface;
import org.apache.uima.test.junit_extension.JUnitExtension;
import org.apache.uima.util.XMLInputSource;
-import org.junit.Assert;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -138,48 +136,35 @@
*/
@Test
public void testGetConfigParameterValueString() throws Exception {
- try {
- // this method should get parameter values from the default "en" group
- String str = (String) mAC1.getConfigParameterValue("StringParam");
- Assert.assertEquals("en", str);
+ // this method should get parameter values from the default "en" group
+ String str = (String) mAC1.getConfigParameterValue("StringParam");
+ assertThat(str).isEqualTo("en");
- String[] strArr = (String[]) mAC1.getConfigParameterValue("StringArrayParam");
- Assert.assertEquals(2, strArr.length);
- Assert.assertEquals("e", strArr[0]);
- Assert.assertEquals("n", strArr[1]);
+ String[] strArr = (String[]) mAC1.getConfigParameterValue("StringArrayParam");
+ assertThat(strArr).containsExactly("e", "n");
- Integer intVal = (Integer) mAC1.getConfigParameterValue("IntegerParam");
- Assert.assertEquals(42, intVal.intValue());
+ Integer intVal = (Integer) mAC1.getConfigParameterValue("IntegerParam");
+ assertThat(intVal).isEqualTo(42);
- Integer[] intArr = (Integer[]) mAC1.getConfigParameterValue("IntegerArrayParam");
- Assert.assertEquals(3, intArr.length);
- Assert.assertEquals(1, intArr[0].intValue());
- Assert.assertEquals(2, intArr[1].intValue());
- Assert.assertEquals(3, intArr[2].intValue());
+ Integer[] intArr = (Integer[]) mAC1.getConfigParameterValue("IntegerArrayParam");
+ assertThat(intArr).containsExactly(1, 2, 3);
- Float floatVal = (Float) mAC1.getConfigParameterValue("FloatParam");
- Assert.assertEquals(null, floatVal);
+ Float floatVal = (Float) mAC1.getConfigParameterValue("FloatParam");
+ assertThat(floatVal).isNull();
- // test override
- String str2 = (String) mAC2.getConfigParameterValue("StringParam");
- Assert.assertEquals("override", str2);
- // other values should not be affected
- Integer intVal2 = (Integer) mAC1.getConfigParameterValue("IntegerParam");
- Assert.assertEquals(42, intVal2.intValue());
+ // test override
+ String str2 = (String) mAC2.getConfigParameterValue("StringParam");
+ assertThat(str2).isEqualTo("override");
+ // other values should not be affected
+ Integer intVal2 = (Integer) mAC1.getConfigParameterValue("IntegerParam");
+ assertThat(intVal2.intValue()).isEqualTo(42);
- // test default fallback
- String str3 = (String) mAC4.getConfigParameterValue("StringParam");
- Assert.assertEquals("test", str3);
+ // test default fallback
+ String str3 = (String) mAC4.getConfigParameterValue("StringParam");
+ assertThat(str3).isEqualTo("test");
- String[] strArr2 = (String[]) mAC4.getConfigParameterValue("StringArrayParam");
- Assert.assertEquals(4, strArr2.length);
- Assert.assertEquals("t", strArr2[0]);
- Assert.assertEquals("e", strArr2[1]);
- Assert.assertEquals("s", strArr2[2]);
- Assert.assertEquals("t", strArr2[3]);
- } catch (Exception e) {
- JUnitExtension.handleException(e);
- }
+ String[] strArr2 = (String[]) mAC4.getConfigParameterValue("StringArrayParam");
+ assertThat(strArr2).containsExactly("t", "e", "s", "t");
}
/*
@@ -187,147 +172,97 @@
*/
@Test
public void testGetConfigParameterValueStringString() throws Exception {
- try {
- // en-US group
- String str = (String) mAC1.getConfigParameterValue("en-US", "StringParam");
- Assert.assertEquals("en", str); // language fallback
+ // en-US group
+ // language fallback
+ assertThat((String) mAC1.getConfigParameterValue("en-US", "StringParam")).isEqualTo("en");
- String[] strArr = (String[]) mAC1.getConfigParameterValue("en-US", "StringArrayParam");
- Assert.assertEquals(5, strArr.length);
- Assert.assertEquals("e", strArr[0]);
- Assert.assertEquals("n", strArr[1]);
- Assert.assertEquals("-", strArr[2]);
- Assert.assertEquals("U", strArr[3]);
- Assert.assertEquals("S", strArr[4]);
+ assertThat((String[]) mAC1.getConfigParameterValue("en-US", "StringArrayParam"))
+ .containsExactly("e", "n", "-", "U", "S");
- Integer intVal = (Integer) mAC1.getConfigParameterValue("en-US", "IntegerParam");
- Assert.assertEquals(1776, intVal.intValue());
+ assertThat(((Integer) mAC1.getConfigParameterValue("en-US", "IntegerParam")).intValue())
+ .isEqualTo(1776);
- Integer[] intArr = (Integer[]) mAC1.getConfigParameterValue("en-US", "IntegerArrayParam");
- Assert.assertEquals(3, intArr.length); // language fallback
- Assert.assertEquals(1, intArr[0].intValue());
- Assert.assertEquals(2, intArr[1].intValue());
- Assert.assertEquals(3, intArr[2].intValue());
+ // language fallback
+ assertThat((Integer[]) mAC1.getConfigParameterValue("en-US", "IntegerArrayParam"))
+ .containsExactly(1, 2, 3);
- Float floatVal = (Float) mAC1.getConfigParameterValue("en-US", "FloatParam");
- Assert.assertEquals(null, floatVal);
+ assertThat((Float) mAC1.getConfigParameterValue("en-US", "FloatParam")).isNull();
- // de group
- String str2 = (String) mAC1.getConfigParameterValue("de", "StringParam");
- Assert.assertEquals("de", str2);
+ // de group
+ assertThat((String) mAC1.getConfigParameterValue("de", "StringParam")).isEqualTo("de");
- String[] strArr2 = (String[]) mAC1.getConfigParameterValue("de", "StringArrayParam");
- Assert.assertEquals(2, strArr2.length);
- Assert.assertEquals("d", strArr2[0]);
- Assert.assertEquals("e", strArr2[1]);
+ assertThat((String[]) mAC1.getConfigParameterValue("de", "StringArrayParam"))
+ .containsExactly("d", "e");
- Integer intVal2 = (Integer) mAC1.getConfigParameterValue("de", "IntegerParam");
- Assert.assertEquals(42, intVal2.intValue()); // default fallback
+ assertThat(((Integer) mAC1.getConfigParameterValue("de", "IntegerParam")).intValue())
+ .isEqualTo(42); // default fallback
- Integer[] intArr2 = (Integer[]) mAC1.getConfigParameterValue("de", "IntegerArrayParam");
- Assert.assertEquals(3, intArr2.length);
- Assert.assertEquals(4, intArr2[0].intValue());
- Assert.assertEquals(5, intArr2[1].intValue());
- Assert.assertEquals(6, intArr2[2].intValue());
+ assertThat((Integer[]) mAC1.getConfigParameterValue("de", "IntegerArrayParam"))
+ .containsExactly(4, 5, 6);
- Float floatVal2 = (Float) mAC1.getConfigParameterValue("de", "FloatParam");
- Assert.assertEquals(null, floatVal2);
+ assertThat((Float) mAC1.getConfigParameterValue("de", "FloatParam")).isNull();
- // zh group
- String str3 = (String) mAC1.getConfigParameterValue("zh", "StringParam");
- Assert.assertEquals("zh", str3);
+ // zh group
+ assertThat((String) mAC1.getConfigParameterValue("zh", "StringParam")).isEqualTo("zh");
- String[] strArr3 = (String[]) mAC1.getConfigParameterValue("zh", "StringArrayParam");
- Assert.assertEquals(2, strArr3.length);
- Assert.assertEquals("z", strArr3[0]);
- Assert.assertEquals("h", strArr3[1]);
+ assertThat((String[]) mAC1.getConfigParameterValue("zh", "StringArrayParam"))
+ .containsExactly("z", "h");
- Integer intVal3 = (Integer) mAC1.getConfigParameterValue("zh", "IntegerParam");
- Assert.assertEquals(42, intVal3.intValue()); // default fallback
+ assertThat(((Integer) mAC1.getConfigParameterValue("zh", "IntegerParam")).intValue())
+ .isEqualTo(42); // default fallback
- Integer[] intArr3 = (Integer[]) mAC1.getConfigParameterValue("zh", "IntegerArrayParam");
- Assert.assertEquals(3, intArr3.length); // default fallback
- Assert.assertEquals(1, intArr3[0].intValue());
- Assert.assertEquals(2, intArr3[1].intValue());
- Assert.assertEquals(3, intArr3[2].intValue());
+ assertThat((Integer[]) mAC1.getConfigParameterValue("zh", "IntegerArrayParam"))
+ .containsExactly(1, 2, 3); // default fallback
- Float floatVal3 = (Float) mAC1.getConfigParameterValue("zh", "FloatParam");
- Assert.assertEquals(3.14, floatVal3, 0.0001);
+ assertThat((Float) mAC1.getConfigParameterValue("zh", "FloatParam")).isCloseTo(3.14f,
+ within(0.0001f));
- // test override
- String str4 = (String) mAC2.getConfigParameterValue("en", "StringParam");
- Assert.assertEquals("override", str4);
- // fallback too
- String str5 = (String) mAC2.getConfigParameterValue("en-GB", "StringParam");
- Assert.assertEquals("override", str5);
- // other groups should not be affected
- String str6 = (String) mAC2.getConfigParameterValue("de", "StringParam");
- Assert.assertEquals("de", str6);
+ // test override
+ assertThat((String) mAC2.getConfigParameterValue("en", "StringParam")).isEqualTo("override");
+ // fallback too
+ assertThat((String) mAC2.getConfigParameterValue("en-GB", "StringParam")).isEqualTo("override");
+ // other groups should not be affected
+ assertThat((String) mAC2.getConfigParameterValue("de", "StringParam")).isEqualTo("de");
- // test empty string array
- String[] strArr4 = (String[]) mAC2.getConfigParameterValue("x-unspecified",
- "StringArrayParam");
- Assert.assertTrue(Arrays.equals(strArr4, new String[0]));
+ // test empty string array
+ assertThat((String[]) mAC2.getConfigParameterValue("x-unspecified", "StringArrayParam"))
+ .isEmpty();
- // test nonexistent group
- String str7 = (String) mAC1.getConfigParameterValue("es", "StringParam");
- Assert.assertEquals("en", str7); // language_fallback for completely nonexistent language
- String str8 = (String) mAC4.getConfigParameterValue("es", "StringParam");
- Assert.assertEquals("test", str8); // default_fallback for nonexistent group
- } catch (Exception e) {
- JUnitExtension.handleException(e);
- }
+ // test nonexistent group
+ // language_fallback for completely nonexistent language
+ assertThat((String) mAC1.getConfigParameterValue("es", "StringParam")).isEqualTo("en");
+ // default_fallback for nonexistent group
+ assertThat((String) mAC4.getConfigParameterValue("es", "StringParam")).isEqualTo("test");
}
@Test
public void testGetConfigurationGroupNames() {
- String[] names = mAC1.getConfigurationGroupNames();
- Assert.assertEquals(5, names.length);
- List<String> l = new ArrayList<>(Arrays.asList(names));
- Assert.assertTrue(l.contains("en"));
- Assert.assertTrue(l.contains("en-US"));
- Assert.assertTrue(l.contains("de"));
- Assert.assertTrue(l.contains("zh"));
- Assert.assertTrue(l.contains("x-unspecified"));
+ assertThat(mAC1.getConfigurationGroupNames()).containsExactlyInAnyOrder("en", "en-US", "de",
+ "zh", "x-unspecified");
// try on something that has no groups
- names = mAC5.getConfigurationGroupNames();
- Assert.assertEquals(0, names.length);
+ assertThat(mAC5.getConfigurationGroupNames()).isEmpty();
}
@Test
public void testGetConfigParameterNames() {
- String[] names = mAC5.getConfigParameterNames();
- Assert.assertEquals(6, names.length);
- Assert.assertEquals("StringParam", names[0]);
- Assert.assertEquals("StringArrayParam", names[1]);
- Assert.assertEquals("IntegerParam", names[2]);
- Assert.assertEquals("IntegerArrayParam", names[3]);
- Assert.assertEquals("FloatParam", names[4]);
- Assert.assertEquals("FloatArrayParam", names[5]);
+ assertThat(mAC5.getConfigParameterNames()).containsExactly("StringParam", "StringArrayParam",
+ "IntegerParam", "IntegerArrayParam", "FloatParam", "FloatArrayParam");
// try on something that has groups
- names = mAC1.getConfigParameterNames();
- Assert.assertEquals(0, names.length);
+ assertThat(mAC1.getConfigParameterNames()).isEmpty();
}
@Test
public void testGetConfigParameterNamesString() {
- String[] names = mAC1.getConfigParameterNames("en");
- Assert.assertEquals(4, names.length);
- List<String> l = new ArrayList<>(Arrays.asList(names));
- Assert.assertTrue(l.contains("StringParam"));
- Assert.assertTrue(l.contains("StringArrayParam"));
- Assert.assertTrue(l.contains("IntegerParam"));
- Assert.assertTrue(l.contains("IntegerArrayParam"));
+ assertThat(mAC1.getConfigParameterNames("en")).containsExactlyInAnyOrder("StringParam",
+ "StringArrayParam", "IntegerParam", "IntegerArrayParam");
// try on nonexistent group
- names = mAC1.getConfigParameterNames("foo");
- Assert.assertEquals(0, names.length);
+ assertThat(mAC1.getConfigParameterNames("foo")).isEmpty();
// try on something that has no groups
- names = mAC4.getConfigParameterNames("en");
- Assert.assertEquals(0, names.length);
+ assertThat(mAC4.getConfigParameterNames("en")).isEmpty();
}
@Test
@@ -335,13 +270,13 @@
try {
// custom object
Object r = mAC3.getResourceObject("TestResourceObject");
- Assert.assertNotNull(r);
- Assert.assertTrue(r instanceof TestResourceInterface);
+ assertThat(r).isNotNull();
+ assertThat(r instanceof TestResourceInterface).isTrue();
// standard data resource
Object r2 = mAC3.getResourceObject("TestFileResource");
- Assert.assertNotNull(r2);
- Assert.assertTrue(r2 instanceof DataResource);
+ assertThat(r2).isNotNull();
+ assertThat(r2 instanceof DataResource).isTrue();
// parameterized resources (should fail)
AnnotatorContextException ex = null;
@@ -350,7 +285,7 @@
} catch (AnnotatorContextException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
ex = null;
try {
@@ -358,11 +293,11 @@
} catch (AnnotatorContextException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
// nonexistent resource (should return null)
Object r3 = mAC3.getResourceObject("Unknown");
- Assert.assertNull(r3);
+ assertThat(r3).isNull();
} catch (Exception e) {
JUnitExtension.handleException(e);
}
@@ -372,12 +307,10 @@
public void testGetResourceURLString() throws Exception {
try {
// standard data resource (should succeed)
- URL url = mAC3.getResourceURL("TestFileResource");
- Assert.assertNotNull(url);
+ assertThat(mAC3.getResourceURL("TestFileResource")).isNotNull();
// custom resource object (should return null)
- URL url2 = mAC3.getResourceURL("TestResourceObject");
- Assert.assertNull(url2);
+ assertThat(mAC3.getResourceURL("TestResourceObject")).isNull();
// parameterized resources (should fail)
AnnotatorContextException ex = null;
@@ -386,7 +319,7 @@
} catch (AnnotatorContextException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
ex = null;
try {
@@ -394,23 +327,19 @@
} catch (AnnotatorContextException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
// nonexistent resource (should return null)
- URL url3 = mAC3.getResourceURL("Unknown");
- Assert.assertNull(url3);
+ assertThat(mAC3.getResourceURL("Unknown")).isNull();
// passthrough to class loader
- URL url5 = mAC3.getResourceURL("org/apache/uima/analysis_engine/impl/testDataFile3.dat");
- Assert.assertNotNull(url5);
+ assertThat(mAC3.getResourceURL("org/apache/uima/analysis_engine/impl/testDataFile3.dat")).isNotNull();
// passthrough to data path
- URL url6 = mAC1.getResourceURL("testDataFile.dat");
- Assert.assertNotNull(url6);
+ assertThat(mAC1.getResourceURL("testDataFile.dat")).isNotNull();
// for directory
- URL url7 = mAC3.getResourceURL("subdir");
- Assert.assertNotNull(url7);
+ assertThat(mAC3.getResourceURL("subdir")).isNotNull();
// spaces as part of extension classpath (spaces should be URL-encoded)
URL url8 = mAC3.getResourceURL("OtherFileResource");
@@ -427,12 +356,10 @@
public void testGetResourceURIString() throws Exception {
try {
// standard data resource (should succeed)
- URI uri = mAC3.getResourceURI("TestFileResource");
- Assert.assertNotNull(uri);
+ assertThat(mAC3.getResourceURI("TestFileResource")).isNotNull();
// custom resource object (should return null)
- URI uri2 = mAC3.getResourceURI("TestResourceObject");
- Assert.assertNull(uri2);
+ assertThat(mAC3.getResourceURI("TestResourceObject")).isNull();
// parameterized resources (should fail)
AnnotatorContextException ex = null;
@@ -441,7 +368,7 @@
} catch (AnnotatorContextException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
ex = null;
try {
@@ -449,23 +376,19 @@
} catch (AnnotatorContextException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
// nonexistent resource (should return null)
- URI uri3 = mAC3.getResourceURI("Unknown");
- Assert.assertNull(uri3);
+ assertThat(mAC3.getResourceURI("Unknown")).isNull();
// passthrough to class loader
- URI uri5 = mAC3.getResourceURI("org/apache/uima/analysis_engine/impl/testDataFile3.dat");
- Assert.assertNotNull(uri5);
+ assertThat(mAC3.getResourceURI("org/apache/uima/analysis_engine/impl/testDataFile3.dat")).isNotNull();
// passthrough to data path
- URI uri6 = mAC1.getResourceURI("testDataFile.dat");
- Assert.assertNotNull(uri6);
+ assertThat(mAC1.getResourceURI("testDataFile.dat")).isNotNull();
// for directory
- URI uri7 = mAC3.getResourceURI("subdir");
- Assert.assertNotNull(uri7);
+ assertThat(mAC3.getResourceURI("subdir")).isNotNull();
// spaces as part of extension classpath (spaces should be decoded)
URI uri8 = mAC3.getResourceURI("OtherFileResource");
@@ -482,12 +405,10 @@
public void testGetResourceFilePathString() throws Exception {
try {
// standard data resource (should succeed)
- String path = mAC3.getResourceFilePath("TestFileResource");
- Assert.assertNotNull(path);
+ assertThat(mAC3.getResourceFilePath("TestFileResource")).isNotNull();
// custom resource object (should return null)
- String path2 = mAC3.getResourceFilePath("TestResourceObject");
- Assert.assertNull(path2);
+ assertThat(mAC3.getResourceFilePath("TestResourceObject")).isNull();
// parameterized resources (should fail)
AnnotatorContextException ex = null;
@@ -496,7 +417,7 @@
} catch (AnnotatorContextException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
ex = null;
try {
@@ -504,24 +425,21 @@
} catch (AnnotatorContextException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
// nonexistent resource (should return null)
- String path3 = mAC3.getResourceFilePath("Unknown");
- Assert.assertNull(path3);
+ assertThat(mAC3.getResourceFilePath("Unknown")).isNull();
// passthrough to class loader
String path5 = mAC3
.getResourceFilePath("org/apache/uima/analysis_engine/impl/testDataFile3.dat");
- Assert.assertNotNull(path5);
+ assertThat(path5).isNotNull();
// passthrough to data path
- String path6 = mAC1.getResourceFilePath("testDataFile.dat");
- Assert.assertNotNull(path6);
+ assertThat(mAC1.getResourceFilePath("testDataFile.dat")).isNotNull();
// for directory
- String path7 = mAC3.getResourceFilePath("subdir");
- Assert.assertNotNull(path7);
+ assertThat(mAC3.getResourceFilePath("subdir")).isNotNull();
// spaces as part of extension classpath (spaces should be decoded)
String path8 = mAC3.getResourceFilePath("OtherFileResource");
@@ -538,12 +456,10 @@
public void testGetResourceAsStreamString() throws Exception {
try {
// standard data resource (should succeed)
- InputStream strm = mAC3.getResourceAsStream("TestFileResource");
- Assert.assertNotNull(strm);
+ assertThat(mAC3.getResourceAsStream("TestFileResource")).isNotNull();
// custom resource object (should return null)
- InputStream strm2 = mAC3.getResourceAsStream("TestResourceObject");
- Assert.assertNull(strm2);
+ assertThat(mAC3.getResourceAsStream("TestResourceObject")).isNull();
// parameterized resources (should fail)
AnnotatorContextException ex = null;
@@ -552,7 +468,7 @@
} catch (AnnotatorContextException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
ex = null;
try {
@@ -560,23 +476,23 @@
} catch (AnnotatorContextException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
// nonexistent resource (should return null)
InputStream strm3 = mAC3.getResourceAsStream("Unknown");
- Assert.assertNull(strm3);
+ assertThat(strm3).isNull();
// passthrough to class loader
InputStream strm4 = mAC3
.getResourceAsStream("org/apache/uima/analysis_engine/impl/testDataFile3.dat");
- Assert.assertNotNull(strm4);
+ assertThat(strm4).isNotNull();
// for directory
InputStream strm5 = mAC3.getResourceAsStream("subdir");
- Assert.assertNotNull(strm5);
+ assertThat(strm5).isNotNull();
// passthrough to data path
InputStream strm6 = mAC1.getResourceAsStream("testDataFile.dat");
- Assert.assertNotNull(strm6);
+ assertThat(strm6).isNotNull();
} catch (Exception e) {
JUnitExtension.handleException(e);
}
@@ -587,21 +503,21 @@
try {
// standard data resource
Object r = mAC3.getResourceObject("TestFileLanguageResource", new String[] { "en" });
- Assert.assertNotNull(r);
- Assert.assertTrue(r instanceof DataResource);
+ assertThat(r).isNotNull();
+ assertThat(r instanceof DataResource).isTrue();
Object r2 = mAC3.getResourceObject("TestFileLanguageResource", new String[] { "de" });
- Assert.assertNotNull(r2);
- Assert.assertTrue(r2 instanceof DataResource);
- Assert.assertFalse(r2.equals(r));
+ assertThat(r2).isNotNull();
+ assertThat(r2 instanceof DataResource).isTrue();
+ assertThat(r2.equals(r)).isFalse();
// custom object
Object r3 = mAC3.getResourceObject("TestLanguageResourceObject", new String[] { "en" });
- Assert.assertNotNull(r3);
- Assert.assertTrue(r3 instanceof TestResourceInterface);
+ assertThat(r3).isNotNull();
+ assertThat(r3 instanceof TestResourceInterface).isTrue();
Object r4 = mAC3.getResourceObject("TestLanguageResourceObject", new String[] { "de" });
- Assert.assertNotNull(r4);
- Assert.assertTrue(r4 instanceof TestResourceInterface);
- Assert.assertFalse(r4.equals(r3));
+ assertThat(r4).isNotNull();
+ assertThat(r4 instanceof TestResourceInterface).isTrue();
+ assertThat(r4.equals(r3)).isFalse();
// parameter values for which no resource exists (should fail)
AnnotatorContextException ex = null;
@@ -610,7 +526,7 @@
} catch (AnnotatorContextException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
ex = null;
try {
@@ -618,7 +534,7 @@
} catch (AnnotatorContextException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
// non-parameterized resources (should fail)
ex = null;
@@ -627,7 +543,7 @@
} catch (AnnotatorContextException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
ex = null;
try {
@@ -635,11 +551,11 @@
} catch (AnnotatorContextException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
// nonexistent resource (should return null)
Object r5 = mAC3.getResourceObject("Unknown", new String[] { "en" });
- Assert.assertNull(r5);
+ assertThat(r5).isNull();
} catch (Exception e) {
JUnitExtension.handleException(e);
}
@@ -651,17 +567,17 @@
// standard data resource
InputStream strm = mAC3.getResourceAsStream("TestFileLanguageResource",
new String[] { "en" });
- Assert.assertNotNull(strm);
+ assertThat(strm).isNotNull();
InputStream strm2 = mAC3.getResourceAsStream("TestFileLanguageResource",
new String[] { "de" });
- Assert.assertNotNull(strm2);
- Assert.assertFalse(strm2.equals(strm));
+ assertThat(strm2).isNotNull();
+ assertThat(strm2.equals(strm)).isFalse();
// custom object (should return null)
InputStream strm3 = mAC3.getResourceAsStream("TestLanguageResourceObject",
new String[] { "en" });
- Assert.assertNull(strm3);
+ assertThat(strm3).isNull();
// parameter values for which no resource exists (should fail)
AnnotatorContextException ex = null;
@@ -670,7 +586,7 @@
} catch (AnnotatorContextException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
ex = null;
try {
@@ -678,7 +594,7 @@
} catch (AnnotatorContextException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
// non-parameterized resources (should fail)
ex = null;
@@ -687,7 +603,7 @@
} catch (AnnotatorContextException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
ex = null;
try {
@@ -695,11 +611,11 @@
} catch (AnnotatorContextException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
// nonexistent resource (should return null)
InputStream strm4 = mAC3.getResourceAsStream("Unknown", new String[] { "en" });
- Assert.assertNull(strm4);
+ assertThat(strm4).isNull();
} catch (Exception e) {
JUnitExtension.handleException(e);
}
@@ -710,15 +626,15 @@
try {
// standard data resource
URL url = mAC3.getResourceURL("TestFileLanguageResource", new String[] { "en" });
- Assert.assertNotNull(url);
+ assertThat(url).isNotNull();
URL url2 = mAC3.getResourceURL("TestFileLanguageResource", new String[] { "de" });
- Assert.assertNotNull(url2);
- Assert.assertFalse(url2.toString().equals(url.toString()));
+ assertThat(url2).isNotNull();
+ assertThat(url2.toString().equals(url.toString())).isFalse();
// custom object (should return null)
URL url3 = mAC3.getResourceURL("TestLanguageResourceObject", new String[] { "en" });
- Assert.assertNull(url3);
+ assertThat(url3).isNull();
// parameter values for which no resource exists (should fail)
AnnotatorContextException ex = null;
@@ -727,7 +643,7 @@
} catch (AnnotatorContextException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
ex = null;
try {
@@ -735,7 +651,7 @@
} catch (AnnotatorContextException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
// non-parameterized resources (should fail)
ex = null;
@@ -744,7 +660,7 @@
} catch (AnnotatorContextException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
ex = null;
try {
@@ -752,11 +668,11 @@
} catch (AnnotatorContextException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
// nonexistent resource (should return null)
URL url4 = mAC3.getResourceURL("Unknown", new String[] { "en" });
- Assert.assertNull(url4);
+ assertThat(url4).isNull();
} catch (Exception e) {
JUnitExtension.handleException(e);
}
@@ -767,15 +683,15 @@
try {
// standard data resource
URI uri = mAC3.getResourceURI("TestFileLanguageResource", new String[] { "en" });
- Assert.assertNotNull(uri);
+ assertThat(uri).isNotNull();
URI uri2 = mAC3.getResourceURI("TestFileLanguageResource", new String[] { "de" });
- Assert.assertNotNull(uri2);
- Assert.assertFalse(uri2.equals(uri));
+ assertThat(uri2).isNotNull();
+ assertThat(uri2.equals(uri)).isFalse();
// custom object (should return null)
URI uri3 = mAC3.getResourceURI("TestLanguageResourceObject", new String[] { "en" });
- Assert.assertNull(uri3);
+ assertThat(uri3).isNull();
// parameter values for which no resource exists (should fail)
AnnotatorContextException ex = null;
@@ -784,7 +700,7 @@
} catch (AnnotatorContextException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
ex = null;
try {
@@ -792,7 +708,7 @@
} catch (AnnotatorContextException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
// non-parameterized resources (should fail)
ex = null;
@@ -801,7 +717,7 @@
} catch (AnnotatorContextException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
ex = null;
try {
@@ -809,11 +725,11 @@
} catch (AnnotatorContextException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
// nonexistent resource (should return null)
URI uri4 = mAC3.getResourceURI("Unknown", new String[] { "en" });
- Assert.assertNull(uri4);
+ assertThat(uri4).isNull();
} catch (Exception e) {
JUnitExtension.handleException(e);
}
@@ -824,15 +740,15 @@
try {
// standard data resource
String path = mAC3.getResourceFilePath("TestFileLanguageResource", new String[] { "en" });
- Assert.assertNotNull(path);
+ assertThat(path).isNotNull();
String path2 = mAC3.getResourceFilePath("TestFileLanguageResource", new String[] { "de" });
- Assert.assertNotNull(path2);
- Assert.assertFalse(path2.equals(path));
+ assertThat(path2).isNotNull();
+ assertThat(path2.equals(path)).isFalse();
// custom object (should return null)
String path3 = mAC3.getResourceFilePath("TestLanguageResourceObject", new String[] { "en" });
- Assert.assertNull(path3);
+ assertThat(path3).isNull();
// parameter values for which no resource exists (should fail)
AnnotatorContextException ex = null;
@@ -841,7 +757,7 @@
} catch (AnnotatorContextException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
ex = null;
try {
@@ -849,7 +765,7 @@
} catch (AnnotatorContextException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
// non-parameterized resources (should fail)
ex = null;
@@ -858,7 +774,7 @@
} catch (AnnotatorContextException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
ex = null;
try {
@@ -866,11 +782,11 @@
} catch (AnnotatorContextException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
// nonexistent resource (should return null)
String path4 = mAC3.getResourceFilePath("Unknown", new String[] { "en" });
- Assert.assertNull(path4);
+ assertThat(path4).isNull();
} catch (Exception e) {
JUnitExtension.handleException(e);
}
@@ -879,8 +795,8 @@
@Test
public void testGetDataPath() throws Exception {
try {
- Assert.assertEquals(TEST_DATAPATH, mAC1.getDataPath());
- Assert.assertEquals(System.getProperty("user.dir"), mAC4.getDataPath());
+ assertThat(mAC1.getDataPath()).isEqualTo(TEST_DATAPATH);
+ assertThat(mAC4.getDataPath()).isEqualTo(System.getProperty("user.dir"));
} catch (Exception e) {
JUnitExtension.handleException(e);
}
diff --git a/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/MultiprocessingAnalysisEngine_implTest.java b/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/MultiprocessingAnalysisEngine_implTest.java
index e47d170..575dd10 100644
--- a/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/MultiprocessingAnalysisEngine_implTest.java
+++ b/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/MultiprocessingAnalysisEngine_implTest.java
@@ -19,6 +19,7 @@
package org.apache.uima.analysis_engine.impl;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
@@ -53,7 +54,6 @@
import org.apache.uima.resource.metadata.impl.TypeSystemDescription_impl;
import org.apache.uima.test.junit_extension.JUnitExtension;
import org.apache.uima.util.XMLInputSource;
-import org.junit.Assert;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -106,7 +106,7 @@
// initialize MultiprocesingTextAnalysisEngine
MultiprocessingAnalysisEngine_impl mtae = new MultiprocessingAnalysisEngine_impl();
boolean result = mtae.initialize(mSimpleDesc, null);
- Assert.assertTrue(result);
+ assertThat(result).isTrue();
// initialize again - should fail
Exception ex = null;
@@ -115,7 +115,7 @@
} catch (UIMA_IllegalStateException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
// initialize a new TAE with parameters
Map<String, Object> map = new HashMap<>();
@@ -123,10 +123,10 @@
map.put(AnalysisEngine.PARAM_TIMEOUT_PERIOD, 60000);
MultiprocessingAnalysisEngine_impl mtae2 = new MultiprocessingAnalysisEngine_impl();
result = mtae2.initialize(mSimpleDesc, map);
- Assert.assertTrue(result);
+ assertThat(result).isTrue();
// check parameter values
- Assert.assertEquals(5, mtae2.getPool().getSize());
- Assert.assertEquals(60000, mtae2.getTimeout());
+ assertThat(mtae2.getPool().getSize()).isEqualTo(5);
+ assertThat(mtae2.getTimeout()).isEqualTo(60000);
} catch (Exception e) {
JUnitExtension.handleException(e);
}
@@ -137,11 +137,11 @@
try {
MultiprocessingAnalysisEngine_impl mtae = new MultiprocessingAnalysisEngine_impl();
boolean result = mtae.initialize(mSimpleDesc, null);
- Assert.assertTrue(result);
+ assertThat(result).isTrue();
AnalysisEngineMetaData md = mtae.getAnalysisEngineMetaData();
- Assert.assertNotNull(md);
- Assert.assertEquals("Simple Test", md.getName());
+ assertThat(md).isNotNull();
+ assertThat(md.getName()).isEqualTo("Simple Test");
} catch (Exception e) {
JUnitExtension.handleException(e);
}
@@ -152,7 +152,7 @@
try {
MultiprocessingAnalysisEngine_impl mtae = new MultiprocessingAnalysisEngine_impl();
boolean result = mtae.initialize(mSimpleDesc, null);
- Assert.assertTrue(result);
+ assertThat(result).isTrue();
CAS cas1 = mtae.newCAS();
// should have the type foo.Bar
@@ -160,22 +160,22 @@
// should be able to get as many as we want and they should all be different
CAS cas2 = mtae.newCAS();
- Assert.assertNotNull(cas2);
- Assert.assertTrue(cas1 != cas2);
+ assertThat(cas2).isNotNull();
+ assertThat(cas1 != cas2).isTrue();
CAS cas3 = mtae.newCAS();
- Assert.assertNotNull(cas3);
- Assert.assertTrue(cas1 != cas3);
- Assert.assertTrue(cas2 != cas3);
+ assertThat(cas3).isNotNull();
+ assertThat(cas1 != cas3).isTrue();
+ assertThat(cas2 != cas3).isTrue();
CAS cas4 = mtae.newCAS();
- Assert.assertNotNull(cas4);
- Assert.assertTrue(cas1 != cas4);
- Assert.assertTrue(cas2 != cas4);
- Assert.assertTrue(cas3 != cas4);
+ assertThat(cas4).isNotNull();
+ assertThat(cas1 != cas4).isTrue();
+ assertThat(cas2 != cas4).isTrue();
+ assertThat(cas3 != cas4).isTrue();
// try aggregate
MultiprocessingAnalysisEngine_impl mtae2 = new MultiprocessingAnalysisEngine_impl();
result = mtae2.initialize(mAggDesc, null);
- Assert.assertTrue(result);
+ assertThat(result).isTrue();
CAS cas5 = mtae2.newCAS();
// should have the type foo.Bar
@@ -488,8 +488,9 @@
tcas.setDocumentText("new test");
mAE.process(tcas);
// System.out.println("Debug finished processing a cas");
- if (doSleeps)
+ if (doSleeps) {
Thread.sleep(0, r.nextInt(1000)); // 0 to 1 microseconds
+ }
tcas.reset();
// process(CAS,ResultSpecification)
@@ -497,11 +498,13 @@
resultSpec.addResultType("NamedEntity", true);
tcas.setDocumentText("testing...");
- if (doSleeps)
+ if (doSleeps) {
Thread.sleep(0, r.nextInt(1000)); // 0 to 1 microseconds
+ }
mAE.process(tcas, resultSpec);
- if (doSleeps)
+ if (doSleeps) {
Thread.sleep(0, r.nextInt(1000)); // 0 to 1 microseconds
+ }
tcas.reset();
// }
} catch (Throwable t) {
diff --git a/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/PearAnalysisEngineWrapperTest.java b/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/PearAnalysisEngineWrapperTest.java
index 0e6d667..300e397 100644
--- a/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/PearAnalysisEngineWrapperTest.java
+++ b/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/PearAnalysisEngineWrapperTest.java
@@ -32,7 +32,6 @@
import org.apache.uima.resource.impl.PearSpecifier_impl;
import org.apache.uima.resource.metadata.impl.NameValuePair_impl;
import org.apache.uima.test.junit_extension.JUnitExtension;
-import org.junit.Assert;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -118,13 +117,13 @@
boolean initialized = this.pearAnalysisEngineWrapper.initialize(pearSpecifier, new HashMap<>());
- Assert.assertTrue("Pear was not initialized", initialized);
+ assertThat(initialized).as("Pear was not initialized").isTrue();
String stringParamValue = (String) this.pearAnalysisEngineWrapper
.getConfigParameterValue(PearAnalysisEngineWrapperTest.PARAMETER_NAME);
- Assert.assertEquals("The value of StringParam has changed",
- PearAnalysisEngineWrapperTest.PARAMETER_VALUE, stringParamValue);
+ assertThat(stringParamValue).as("The value of StringParam has changed")
+ .isEqualTo(PearAnalysisEngineWrapperTest.PARAMETER_VALUE);
}
private PearSpecifier createPearSpecifierWithoutParameters() {
@@ -150,7 +149,7 @@
private PackageBrowser installPearPackage() {
File pearFile = JUnitExtension.getFile("pearTests/analysisEngineWithParameters.pear");
- Assert.assertNotNull("analysisEngine.pear file not found", pearFile);
+ assertThat(pearFile).as("analysisEngine.pear file not found").isNotNull();
return PackageInstaller.installPackage(this.tempInstallDirectory, pearFile, false);
}
diff --git a/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/ResultSpecification_implTest.java b/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/ResultSpecification_implTest.java
index e48e178..f78c937 100644
--- a/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/ResultSpecification_implTest.java
+++ b/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/ResultSpecification_implTest.java
@@ -20,6 +20,7 @@
package org.apache.uima.analysis_engine.impl;
import static org.apache.uima.analysis_engine.impl.AnalysisEngineDescription_implTest.encoding;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertTrue;
import java.io.ByteArrayInputStream;
@@ -40,7 +41,6 @@
import org.apache.uima.resource.metadata.impl.Capability_impl;
import org.apache.uima.test.junit_extension.JUnitExtension;
import org.apache.uima.util.XMLInputSource;
-import org.junit.Assert;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -128,9 +128,9 @@
// sort array before check
Arrays.sort(result);
Arrays.sort(mTypesAndFeatures);
- Assert.assertEquals(mTypesAndFeatures.length, result.length);
+ assertThat(result.length).isEqualTo(mTypesAndFeatures.length);
for (int i = 0; i < result.length; i++) {
- Assert.assertEquals(mTypesAndFeatures[i], result[i]);
+ assertThat(result[i]).isEqualTo(mTypesAndFeatures[i]);
}
// test defaulting - if no language, should be x-unspecified
@@ -179,9 +179,9 @@
// sort array before check
Arrays.sort(result);
Arrays.sort(mTypesAndFeatures);
- Assert.assertEquals(mTypesAndFeatures.length, result.length);
+ assertThat(result.length).isEqualTo(mTypesAndFeatures.length);
for (int i = 0; i < result.length; i++) {
- Assert.assertEquals(mTypesAndFeatures[i], result[i]);
+ assertThat(result[i]).isEqualTo(mTypesAndFeatures[i]);
}
} catch (Exception e) {
JUnitExtension.handleException(e);
@@ -199,14 +199,14 @@
// sort array before check
Arrays.sort(resultEn);
Arrays.sort(mTypesAndFeatures);
- Assert.assertEquals(mTypesAndFeatures.length, resultEn.length);
+ assertThat(resultEn.length).isEqualTo(mTypesAndFeatures.length);
for (int i = 0; i < resultEn.length; i++) {
- Assert.assertEquals(mTypesAndFeatures[i], resultEn[i]);
+ assertThat(resultEn[i]).isEqualTo(mTypesAndFeatures[i]);
}
// check for language ja
TypeOrFeature[] resultJa = rs.getResultTypesAndFeatures("ja");
- Assert.assertEquals(0, resultJa.length);
+ assertThat(resultJa.length).isEqualTo(0);
} catch (Exception e) {
JUnitExtension.handleException(e);
}
@@ -224,9 +224,9 @@
TypeOrFeature[] result = rs.getResultTypesAndFeatures();
Arrays.sort(result);
Arrays.sort(mTypesAndFeatures);
- Assert.assertEquals(mTypesAndFeatures.length, result.length);
+ assertThat(result.length).isEqualTo(mTypesAndFeatures.length);
for (int i = 0; i < result.length; i++) {
- Assert.assertEquals(mTypesAndFeatures[i], result[i]);
+ assertThat(result[i]).isEqualTo(mTypesAndFeatures[i]);
}
} catch (Exception e) {
JUnitExtension.handleException(e);
@@ -247,9 +247,9 @@
TypeOrFeature[] resultEn = rs.getResultTypesAndFeatures("en");
Arrays.sort(resultEn);
- Assert.assertEquals(expectedEnResult.length, resultEn.length);
+ assertThat(resultEn.length).isEqualTo(expectedEnResult.length);
for (int i = 0; i < resultEn.length; i++) {
- Assert.assertEquals(expectedEnResult[i], resultEn[i]);
+ assertThat(resultEn[i]).isEqualTo(expectedEnResult[i]);
}
// check for language de
@@ -258,9 +258,9 @@
TypeOrFeature[] resultDe = rs.getResultTypesAndFeatures("de");
Arrays.sort(resultDe);
- Assert.assertEquals(expectedDeResult.length, resultDe.length);
+ assertThat(resultDe.length).isEqualTo(expectedDeResult.length);
for (int i = 0; i < resultDe.length; i++) {
- Assert.assertEquals(expectedDeResult[i], resultDe[i]);
+ assertThat(resultDe[i]).isEqualTo(expectedDeResult[i]);
}
} catch (Exception e) {
JUnitExtension.handleException(e);
@@ -276,15 +276,15 @@
// check
TypeOrFeature[] result = rs.getResultTypesAndFeatures();
- Assert.assertEquals(2, result.length);
+ assertThat(result.length).isEqualTo(2);
int ftIndex = result[0].getName().equals("FakeType") ? 0 : 1;
int atIndex = ftIndex == 0 ? 1 : 0;
- Assert.assertEquals("FakeType", result[ftIndex].getName());
- Assert.assertEquals(true, result[ftIndex].isType());
- Assert.assertEquals(false, result[ftIndex].isAllAnnotatorFeatures());
- Assert.assertEquals("AnotherType", result[atIndex].getName());
- Assert.assertEquals(true, result[atIndex].isType());
- Assert.assertEquals(true, result[atIndex].isAllAnnotatorFeatures());
+ assertThat(result[ftIndex].getName()).isEqualTo("FakeType");
+ assertThat(result[ftIndex].isType()).isEqualTo(true);
+ assertThat(result[ftIndex].isAllAnnotatorFeatures()).isEqualTo(false);
+ assertThat(result[atIndex].getName()).isEqualTo("AnotherType");
+ assertThat(result[atIndex].isType()).isEqualTo(true);
+ assertThat(result[atIndex].isAllAnnotatorFeatures()).isEqualTo(true);
} catch (Exception e) {
JUnitExtension.handleException(e);
}
@@ -301,28 +301,28 @@
// check for language en
TypeOrFeature[] resultEn = rs.getResultTypesAndFeatures("en");
Arrays.sort(resultEn);
- Assert.assertEquals(2, resultEn.length);
+ assertThat(resultEn.length).isEqualTo(2);
int ftIndex = resultEn[0].getName().equals("FakeType") ? 0 : 1;
int atIndex = ftIndex == 0 ? 1 : 0;
- Assert.assertEquals("AnotherType", resultEn[atIndex].getName());
- Assert.assertEquals(true, resultEn[atIndex].isType());
- Assert.assertEquals(true, resultEn[atIndex].isAllAnnotatorFeatures());
- Assert.assertEquals("FakeType", resultEn[ftIndex].getName());
- Assert.assertEquals(true, resultEn[ftIndex].isType());
- Assert.assertEquals(false, resultEn[ftIndex].isAllAnnotatorFeatures());
+ assertThat(resultEn[atIndex].getName()).isEqualTo("AnotherType");
+ assertThat(resultEn[atIndex].isType()).isEqualTo(true);
+ assertThat(resultEn[atIndex].isAllAnnotatorFeatures()).isEqualTo(true);
+ assertThat(resultEn[ftIndex].getName()).isEqualTo("FakeType");
+ assertThat(resultEn[ftIndex].isType()).isEqualTo(true);
+ assertThat(resultEn[ftIndex].isAllAnnotatorFeatures()).isEqualTo(false);
// check for language ja
TypeOrFeature[] resultJa = rs.getResultTypesAndFeatures("ja");
Arrays.sort(resultJa);
- Assert.assertEquals(2, resultJa.length);
+ assertThat(resultJa.length).isEqualTo(2);
atIndex = resultJa[0].getName().equals("AnotherType") ? 0 : 1;
int ndtIndex = atIndex == 0 ? 1 : 0;
- Assert.assertEquals("AnotherType", resultJa[atIndex].getName());
- Assert.assertEquals(true, resultJa[atIndex].isType());
- Assert.assertEquals(true, resultJa[atIndex].isAllAnnotatorFeatures());
- Assert.assertEquals("NewDefinedType", resultJa[ndtIndex].getName());
- Assert.assertEquals(true, resultJa[ndtIndex].isType());
- Assert.assertEquals(true, resultJa[ndtIndex].isAllAnnotatorFeatures());
+ assertThat(resultJa[atIndex].getName()).isEqualTo("AnotherType");
+ assertThat(resultJa[atIndex].isType()).isEqualTo(true);
+ assertThat(resultJa[atIndex].isAllAnnotatorFeatures()).isEqualTo(true);
+ assertThat(resultJa[ndtIndex].getName()).isEqualTo("NewDefinedType");
+ assertThat(resultJa[ndtIndex].isType()).isEqualTo(true);
+ assertThat(resultJa[ndtIndex].isAllAnnotatorFeatures()).isEqualTo(true);
} catch (Exception e) {
JUnitExtension.handleException(e);
}
@@ -338,13 +338,13 @@
// check
TypeOrFeature[] result = rs.getResultTypesAndFeatures();
Arrays.sort(result);
- Assert.assertEquals(2, result.length);
+ assertThat(result.length).isEqualTo(2);
int atafIndex = result[0].getName().equals("AnotherType:AnotherFeature") ? 0 : 1;
int ftffIndex = atafIndex == 0 ? 1 : 0;
- Assert.assertEquals("AnotherType:AnotherFeature", result[atafIndex].getName());
- Assert.assertEquals(false, result[atafIndex].isType());
- Assert.assertEquals("FakeType:FakeFeature", result[ftffIndex].getName());
- Assert.assertEquals(false, result[ftffIndex].isType());
+ assertThat(result[atafIndex].getName()).isEqualTo("AnotherType:AnotherFeature");
+ assertThat(result[atafIndex].isType()).isEqualTo(false);
+ assertThat(result[ftffIndex].getName()).isEqualTo("FakeType:FakeFeature");
+ assertThat(result[ftffIndex].isType()).isEqualTo(false);
} catch (Exception e) {
JUnitExtension.handleException(e);
}
@@ -359,15 +359,15 @@
// check for language en
TypeOrFeature[] resultEn = rs.getResultTypesAndFeatures("en");
- Assert.assertEquals(1, resultEn.length);
- Assert.assertEquals("AnotherType:AnotherFeature", resultEn[0].getName());
- Assert.assertEquals(false, resultEn[0].isType());
+ assertThat(resultEn.length).isEqualTo(1);
+ assertThat(resultEn[0].getName()).isEqualTo("AnotherType:AnotherFeature");
+ assertThat(resultEn[0].isType()).isEqualTo(false);
// check for language ja
TypeOrFeature[] resultJa = rs.getResultTypesAndFeatures("ja");
- Assert.assertEquals(1, resultJa.length);
- Assert.assertEquals("FakeType:FakeFeature", resultJa[0].getName());
- Assert.assertEquals(false, resultJa[0].isType());
+ assertThat(resultJa.length).isEqualTo(1);
+ assertThat(resultJa[0].getName()).isEqualTo("FakeType:FakeFeature");
+ assertThat(resultJa[0].isType()).isEqualTo(false);
} catch (Exception e) {
JUnitExtension.handleException(e);
}
@@ -379,11 +379,11 @@
ResultSpecification_impl rs = new ResultSpecification_impl();
rs.setResultTypesAndFeatures(mTypesAndFeatures);
- Assert.assertTrue(rs.containsType("FakeType"));
- Assert.assertFalse(rs.containsType("NotThere"));
- Assert.assertTrue(rs.containsType("AnotherType"));
- Assert.assertFalse(rs.containsType("FakeType:FakeFeature"));
- Assert.assertFalse(rs.containsType("AnotherType:AnotherFeature"));
+ assertThat(rs.containsType("FakeType")).isTrue();
+ assertThat(rs.containsType("NotThere")).isFalse();
+ assertThat(rs.containsType("AnotherType")).isTrue();
+ assertThat(rs.containsType("FakeType:FakeFeature")).isFalse();
+ assertThat(rs.containsType("AnotherType:AnotherFeature")).isFalse();
} catch (Exception e) {
JUnitExtension.handleException(e);
}
@@ -395,13 +395,13 @@
ResultSpecification_impl rs = new ResultSpecification_impl();
rs.addCapabilities(capabilities);
- Assert.assertTrue(rs.containsType("FakeType", "en"));
- Assert.assertFalse(rs.containsType("FakeType", "ja"));
- Assert.assertFalse(rs.containsType("NotThere", "en"));
- Assert.assertTrue(rs.containsType("AnotherType", "en-US"));
- Assert.assertTrue(rs.containsType("AnotherType", "x-unspecified"));
- Assert.assertFalse(rs.containsType("FakeType:FakeFeature", "de"));
- Assert.assertFalse(rs.containsType("AnotherType:AnotherFeature", "de"));
+ assertThat(rs.containsType("FakeType", "en")).isTrue();
+ assertThat(rs.containsType("FakeType", "ja")).isFalse();
+ assertThat(rs.containsType("NotThere", "en")).isFalse();
+ assertThat(rs.containsType("AnotherType", "en-US")).isTrue();
+ assertThat(rs.containsType("AnotherType", "x-unspecified")).isTrue();
+ assertThat(rs.containsType("FakeType:FakeFeature", "de")).isFalse();
+ assertThat(rs.containsType("AnotherType:AnotherFeature", "de")).isFalse();
} catch (Exception e) {
JUnitExtension.handleException(e);
}
@@ -413,12 +413,12 @@
ResultSpecification_impl rs = new ResultSpecification_impl();
rs.setResultTypesAndFeatures(mTypesAndFeatures);
- Assert.assertTrue(rs.containsFeature("FakeType:FakeFeature"));
- Assert.assertFalse(rs.containsType("FakeType:FakeFeature2"));
- Assert.assertTrue(rs.containsFeature("AnotherType:AnotherFeature"));
- Assert.assertTrue(rs.containsFeature("AnotherType:YetAnotherFeature"));
- Assert.assertTrue(rs.containsFeature("AnotherType:asdfghjkl"));
- Assert.assertFalse(rs.containsType("NotThere:FakeFeature"));
+ assertThat(rs.containsFeature("FakeType:FakeFeature")).isTrue();
+ assertThat(rs.containsType("FakeType:FakeFeature2")).isFalse();
+ assertThat(rs.containsFeature("AnotherType:AnotherFeature")).isTrue();
+ assertThat(rs.containsFeature("AnotherType:YetAnotherFeature")).isTrue();
+ assertThat(rs.containsFeature("AnotherType:asdfghjkl")).isTrue();
+ assertThat(rs.containsType("NotThere:FakeFeature")).isFalse();
} catch (Exception e) {
JUnitExtension.handleException(e);
}
@@ -430,16 +430,16 @@
ResultSpecification_impl rs = new ResultSpecification_impl();
rs.addCapabilities(capabilities);
- Assert.assertTrue(rs.containsFeature("FakeType:FakeFeature", "ja"));
- Assert.assertTrue(rs.containsFeature("FakeType:FakeFeature", "en"));
- Assert.assertFalse(rs.containsFeature("FakeType:FakeFeature", "de"));
- Assert.assertFalse(rs.containsFeature("FakeType:FakeFeature2", "ja"));
- Assert.assertFalse(rs.containsFeature("FakeType:FakeFeature2", "x-unspecified"));
- Assert.assertTrue(rs.containsFeature("AnotherType:AnotherFeature", "en"));
- Assert.assertTrue(rs.containsFeature("AnotherType:YetAnotherFeature", "de"));
- Assert.assertFalse(rs.containsFeature("AnotherType1:YetAnotherFeature", "de"));
- Assert.assertTrue(rs.containsFeature("AnotherType:asdfghjkl", "ja"));
- Assert.assertFalse(rs.containsFeature("NotThere:FakeFeature", "ja"));
+ assertThat(rs.containsFeature("FakeType:FakeFeature", "ja")).isTrue();
+ assertThat(rs.containsFeature("FakeType:FakeFeature", "en")).isTrue();
+ assertThat(rs.containsFeature("FakeType:FakeFeature", "de")).isFalse();
+ assertThat(rs.containsFeature("FakeType:FakeFeature2", "ja")).isFalse();
+ assertThat(rs.containsFeature("FakeType:FakeFeature2", "x-unspecified")).isFalse();
+ assertThat(rs.containsFeature("AnotherType:AnotherFeature", "en")).isTrue();
+ assertThat(rs.containsFeature("AnotherType:YetAnotherFeature", "de")).isTrue();
+ assertThat(rs.containsFeature("AnotherType1:YetAnotherFeature", "de")).isFalse();
+ assertThat(rs.containsFeature("AnotherType:asdfghjkl", "ja")).isTrue();
+ assertThat(rs.containsFeature("NotThere:FakeFeature", "ja")).isFalse();
} catch (Exception e) {
JUnitExtension.handleException(e);
}
@@ -459,9 +459,9 @@
TypeOrFeature[] result = rs.getResultTypesAndFeatures();
Arrays.sort(result);
Arrays.sort(expectedResult);
- Assert.assertEquals(expectedResult.length, result.length);
+ assertThat(result.length).isEqualTo(expectedResult.length);
for (int i = 0; i < result.length; i++) {
- Assert.assertEquals(expectedResult[i], result[i]);
+ assertThat(result[i]).isEqualTo(expectedResult[i]);
}
} catch (Exception e) {
JUnitExtension.handleException(e);
@@ -488,18 +488,19 @@
rs.compile(tsMgr);
// check
- Assert.assertTrue(rs.containsType("FakeType"));
- Assert.assertFalse(rs.containsType("NotThere"));
- Assert.assertTrue(rs.containsType("AnotherType"));
- Assert.assertFalse(rs.containsType("FakeType:FakeFeature"));
- Assert.assertFalse(rs.containsType("AnotherType:AnotherFeature"));
- Assert.assertTrue(rs.containsFeature("FakeType:FakeFeature"));
- Assert.assertFalse(rs.containsType("FakeType:FakeFeature2"));
- Assert.assertTrue(rs.containsFeature("AnotherType:AnotherFeature"));
- Assert.assertTrue(rs.containsFeature("AnotherType:YetAnotherFeature"));
- Assert.assertTrue(rs.containsFeature("AnotherType:asdfghjkl")); // unknown features are there,
- // if the type says allFeats
- Assert.assertFalse(rs.containsType("NotThere:FakeFeature"));
+ assertThat(rs.containsType("FakeType")).isTrue();
+ assertThat(rs.containsType("NotThere")).isFalse();
+ assertThat(rs.containsType("AnotherType")).isTrue();
+ assertThat(rs.containsType("FakeType:FakeFeature")).isFalse();
+ assertThat(rs.containsType("AnotherType:AnotherFeature")).isFalse();
+ assertThat(rs.containsFeature("FakeType:FakeFeature")).isTrue();
+ assertThat(rs.containsType("FakeType:FakeFeature2")).isFalse();
+ assertThat(rs.containsFeature("AnotherType:AnotherFeature")).isTrue();
+ assertThat(rs.containsFeature("AnotherType:YetAnotherFeature")).isTrue();
+ assertThat(rs.containsFeature("AnotherType:asdfghjkl")).isTrue(); // unknown features are
+ // there,
+ // if the type says allFeats
+ assertThat(rs.containsType("NotThere:FakeFeature")).isFalse();
} catch (Exception e) {
JUnitExtension.handleException(e);
}
@@ -526,24 +527,25 @@
rs.compile(tsMgr);
// check
- Assert.assertFalse(rs.containsType("FakeType"));
- Assert.assertTrue(rs.containsType("FakeType", "en"));
- Assert.assertTrue(rs.containsType("FakeType", "en-us"));
- Assert.assertTrue(rs.containsType("FakeType", "EN_US"));
- Assert.assertFalse(rs.containsType("NotThere"));
- Assert.assertTrue(rs.containsType("AnotherType"));
- Assert.assertFalse(rs.containsType("FakeType:FakeFeature"));
- Assert.assertFalse(rs.containsType("AnotherType:AnotherFeature"));
- Assert.assertFalse(rs.containsFeature("FakeType:FakeFeature"));
- Assert.assertFalse(rs.containsType("FakeType:FakeFeature2"));
- Assert.assertTrue(rs.containsFeature("AnotherType:AnotherFeature"));
- Assert.assertTrue(rs.containsFeature("AnotherType:YetAnotherFeature"));
- Assert.assertTrue(rs.containsFeature("AnotherType:asdfghjkl")); // unknown features are there
- // if type says allfeats
- Assert.assertFalse(rs.containsType("NotThere:FakeFeature"));
- Assert.assertFalse(rs.containsFeature("NotThere:FakeFeature"));
- Assert.assertFalse(rs.containsType("SubType"));
- Assert.assertTrue(rs.containsType("SubType", "en"));
+ assertThat(rs.containsType("FakeType")).isFalse();
+ assertThat(rs.containsType("FakeType", "en")).isTrue();
+ assertThat(rs.containsType("FakeType", "en-us")).isTrue();
+ assertThat(rs.containsType("FakeType", "EN_US")).isTrue();
+ assertThat(rs.containsType("NotThere")).isFalse();
+ assertThat(rs.containsType("AnotherType")).isTrue();
+ assertThat(rs.containsType("FakeType:FakeFeature")).isFalse();
+ assertThat(rs.containsType("AnotherType:AnotherFeature")).isFalse();
+ assertThat(rs.containsFeature("FakeType:FakeFeature")).isFalse();
+ assertThat(rs.containsType("FakeType:FakeFeature2")).isFalse();
+ assertThat(rs.containsFeature("AnotherType:AnotherFeature")).isTrue();
+ assertThat(rs.containsFeature("AnotherType:YetAnotherFeature")).isTrue();
+ assertThat(rs.containsFeature("AnotherType:asdfghjkl")).isTrue(); // unknown features are
+ // there
+ // if type says allfeats
+ assertThat(rs.containsType("NotThere:FakeFeature")).isFalse();
+ assertThat(rs.containsFeature("NotThere:FakeFeature")).isFalse();
+ assertThat(rs.containsType("SubType")).isFalse();
+ assertThat(rs.containsType("SubType", "en")).isTrue();
} catch (Exception e) {
JUnitExtension.handleException(e);
}
@@ -569,7 +571,7 @@
TypeOrFeature[] tofs = newRS.getResultTypesAndFeatures();
Arrays.sort(tofs);
newRS.setResultTypesAndFeatures(tofs);
- Assert.assertEquals(rs, newRS);
+ assertThat(newRS).isEqualTo(rs);
} catch (Exception e) {
JUnitExtension.handleException(e);
}
@@ -588,10 +590,10 @@
Arrays.sort(rsToFs);
Arrays.sort(rsNewToFs);
- Assert.assertEquals(rsToFs.length, rsNewToFs.length);
+ assertThat(rsNewToFs.length).isEqualTo(rsToFs.length);
for (int i = 0; i < rsToFs.length; i++) {
- Assert.assertEquals(rsToFs[i], rsNewToFs[i]);
+ assertThat(rsNewToFs[i]).isEqualTo(rsToFs[i]);
}
} catch (Exception e) {
JUnitExtension.handleException(e);
diff --git a/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/TaeDescription_implTest.java b/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/TaeDescription_implTest.java
index 0e6af3c..8875e1a 100644
--- a/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/TaeDescription_implTest.java
+++ b/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/TaeDescription_implTest.java
@@ -20,6 +20,7 @@
package org.apache.uima.analysis_engine.impl;
import static org.apache.uima.analysis_engine.impl.AnalysisEngineDescription_implTest.encoding;
+import static org.assertj.core.api.Assertions.assertThat;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
@@ -65,7 +66,6 @@
import org.apache.uima.resource.metadata.impl.TypeSystemDescription_impl;
import org.apache.uima.test.junit_extension.JUnitExtension;
import org.apache.uima.util.XMLInputSource;
-import org.junit.Assert;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -253,8 +253,8 @@
AnalysisEngineDescription newAggregateDesc = UIMAFramework.getXMLParser()
.parseAnalysisEngineDescription(new XMLInputSource(is, null));
- Assert.assertEquals(primitiveDesc, newPrimitiveDesc);
- Assert.assertEquals(aggregateDesc, newAggregateDesc);
+ assertThat(newPrimitiveDesc).isEqualTo(primitiveDesc);
+ assertThat(newAggregateDesc).isEqualTo(aggregateDesc);
} catch (Exception e) {
JUnitExtension.handleException(e);
}
@@ -266,12 +266,12 @@
byte[] primitiveDescBytes = SerializationUtils.serialize(primitiveDesc);
AnalysisEngineDescription_impl primitiveDesc2 = (AnalysisEngineDescription_impl) SerializationUtils
.deserialize(primitiveDescBytes);
- Assert.assertEquals(primitiveDesc, primitiveDesc2);
+ assertThat(primitiveDesc2).isEqualTo(primitiveDesc);
byte[] aggregateDescBytes = SerializationUtils.serialize(aggregateDesc);
AnalysisEngineDescription_impl aggregateDesc2 = (AnalysisEngineDescription_impl) SerializationUtils
.deserialize(aggregateDescBytes);
- Assert.assertEquals(aggregateDesc, aggregateDesc2);
+ assertThat(aggregateDesc2).isEqualTo(aggregateDesc);
// make sure XMLization still works
StringWriter writer = new StringWriter();
@@ -280,7 +280,7 @@
writer = new StringWriter();
primitiveDesc2.toXML(writer);
String primitiveDesc2xml = writer.getBuffer().toString();
- Assert.assertEquals(primitiveDesc, primitiveDesc2);
+ assertThat(primitiveDesc2).isEqualTo(primitiveDesc);
writer = new StringWriter();
aggregateDesc.toXML(writer);
@@ -288,7 +288,7 @@
writer = new StringWriter();
aggregateDesc2.toXML(writer);
String aggregateDesc2xml = writer.getBuffer().toString();
- Assert.assertEquals(aggregateDesc, aggregateDesc2);
+ assertThat(aggregateDesc2).isEqualTo(aggregateDesc);
} catch (Exception e) {
JUnitExtension.handleException(e);
}
diff --git a/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/TestAnnotator2.java b/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/TestAnnotator2.java
index a42e56f..059208f 100644
--- a/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/TestAnnotator2.java
+++ b/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/TestAnnotator2.java
@@ -19,6 +19,11 @@
package org.apache.uima.analysis_engine.impl;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
+import static org.assertj.core.api.Assertions.assertThatNoException;
+import static org.junit.jupiter.api.Assertions.fail;
+
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
@@ -33,7 +38,6 @@
import org.apache.uima.UimaContextHolder;
import org.apache.uima.analysis_component.CasAnnotator_ImplBase;
import org.apache.uima.analysis_engine.AnalysisEngineDescription;
-import org.apache.uima.analysis_engine.ResultSpecification;
import org.apache.uima.cas.CAS;
import org.apache.uima.cas.TypeSystem;
import org.apache.uima.impl.UimaContext_ImplBase;
@@ -43,7 +47,6 @@
import org.apache.uima.util.Settings;
import org.apache.uima.util.UimaContextHolderTest;
import org.apache.uima.util.XMLInputSource;
-import org.junit.Assert;
/**
* Annotator class used for testing.
@@ -81,110 +84,81 @@
// testExternalOverride2.settings
String contextName = ((UimaContext_ImplBase) aContext).getQualifiedContextName();
if ("/ExternalOverrides/".equals(contextName)) {
- // Test getting a (0-length) array of strings
String expected = "Context Holder Test";
- String[] actuals = null;
- try {
- actuals = UimaContextHolder.getContext().getSharedSettingArray("test.externalFloatArray");
- } catch (ResourceConfigurationException e) {
- Assert.fail(e.getMessage());
- }
- Assert.assertEquals(0, actuals.length);
+
+ // Test getting a (0-length) array of strings
+ assertThatNoException().isThrownBy(() -> assertThat(
+ UimaContextHolder.getContext().getSharedSettingArray("test.externalFloatArray"))
+ .isEmpty());
// Test assigning an array to a string and vice-versa
// prefix-suffix Prefix-${suffix}
// suffix = should be ignored
- String actual = null;
- try {
- actual = UimaContextHolder.getContext().getSharedSettingValue("context-holder");
- } catch (ResourceConfigurationException e) {
- Assert.fail(e.getMessage());
- }
- Assert.assertEquals(expected, actual);
+ assertThatNoException().isThrownBy(() -> assertThat(
+ UimaContextHolder.getContext().getSharedSettingValue("context-holder"))
+ .isEqualTo(expected));
// Test assigning an array to a string and vice-versa
- try {
- actual = UimaContextHolder.getContext().getSharedSettingValue("test.externalFloatArray");
- Assert.fail("\"bad\" should create an error");
- } catch (ResourceConfigurationException e) {
- System.err.println("Expected exception: " + e.toString());
- }
- try {
- actuals = UimaContextHolder.getContext().getSharedSettingArray("prefix-suffix");
- Assert.fail("\"bad\" should create an error");
- } catch (ResourceConfigurationException e) {
- System.err.println("Expected exception: " + e.toString());
- }
+ assertThatExceptionOfType(ResourceConfigurationException.class)
+ .isThrownBy(() -> UimaContextHolder.getContext()
+ .getSharedSettingValue("test.externalFloatArray"));
+
+ assertThatExceptionOfType(ResourceConfigurationException.class).isThrownBy(
+ () -> UimaContextHolder.getContext().getSharedSettingArray("prefix-suffix"));
// Test a stand-alone settings object
Settings testSettings = UIMAFramework.getResourceSpecifierFactory().createSettings();
String lines = "foo = ${bar} \n" + "bar : [ok \n OK] \n" + "bad = ${missing} \n"
+ "loop1 = one ${loop2} \n" + "loop2 = two ${loop3} \n" + "loop3 = three ${loop1} \n";
- InputStream is;
- try {
- is = new ByteArrayInputStream(lines.getBytes(StandardCharsets.UTF_8));
- testSettings.load(is);
- is.close();
- String val = testSettings.lookUp("foo");
- Assert.assertEquals("[ok,OK]", val);
- try {
- val = testSettings.lookUp("bad");
- Assert.fail("\"bad\" should create an error");
- } catch (ResourceConfigurationException e) {
- System.err.println("Expected exception: " + e.toString());
+
+ assertThatNoException().isThrownBy(() -> {
+ try (InputStream is = new ByteArrayInputStream(lines.getBytes(StandardCharsets.UTF_8))) {
+ testSettings.load(is);
+ String val = testSettings.lookUp("foo");
+ assertThat(val).isEqualTo("[ok,OK]");
+
+ assertThatExceptionOfType(ResourceConfigurationException.class)
+ .as("\"bad\" should create an error")
+ .isThrownBy(() -> testSettings.lookUp("bad"));
+
+ assertThatExceptionOfType(ResourceConfigurationException.class)
+ .as("\"loop2\" should create an error")
+ .isThrownBy(() -> testSettings.lookUp("loop2"));
}
- try {
- val = testSettings.lookUp("loop2");
- Assert.fail("\"loop2\" should create an error");
- } catch (ResourceConfigurationException e) {
- System.err.println("Expected exception: " + e.toString());
- }
- } catch (Exception e) {
- Assert.fail(e.toString());
- }
+ });
// Test POFO access via UimaContextHolder
long threadId = Thread.currentThread().getId();
UimaContextHolderTest testPojoAccess = new UimaContextHolderTest();
- try {
- actual = testPojoAccess.testSettings();
- Assert.assertEquals(expected, actual);
- Assert.assertEquals(threadId, testPojoAccess.threadId);
- } catch (ResourceConfigurationException e) {
- Assert.fail();
- }
+ assertThatNoException()
+ .isThrownBy(() -> assertThat(testPojoAccess.testSettings()).isEqualTo(expected));
+ assertThat(testPojoAccess.threadId).isEqualTo(threadId);
+
// Try from a child thread - should work
testPojoAccess.result = null;
Thread thrd = new Thread(testPojoAccess);
thrd.start();
synchronized (thrd) {
- try {
- thrd.wait();
- Assert.assertEquals(expected, testPojoAccess.result);
- Assert.assertNotSame(threadId, testPojoAccess.threadId);
- } catch (InterruptedException e) {
- Assert.fail();
- }
+ assertThatNoException().isThrownBy(() -> thrd.wait());
+ assertThat(testPojoAccess.result).isEqualTo(expected);
+ assertThat(testPojoAccess.threadId).isNotSameAs(threadId);
}
+
// Try from a process - should fail
String[] args = { System.getProperty("java.home") + "/bin/java", "-cp",
System.getProperty("java.class.path"), UimaContextHolderTest.class.getName() };
ProcessBuilder pb = new ProcessBuilder(args);
try {
Process proc = pb.start();
- int rc = proc.waitFor();
- Assert.assertEquals(0, rc);
+ assertThat(proc.waitFor()).isZero();
} catch (IOException | InterruptedException e) {
- Assert.fail();
+ fail();
}
// Test getting a string value
- try {
- actual = UimaContextHolder.getContext().getSharedSettingValue("context-holder");
- } catch (ResourceConfigurationException e) {
- Assert.fail(e.getMessage());
- }
- Assert.assertEquals(expected, actual);
+ assertThatNoException().isThrownBy(() -> assertThat(
+ UimaContextHolder.getContext().getSharedSettingValue("context-holder"))
+ .isEqualTo(expected));
// Create a nested engine with a different settings
String resDir = "src/test/resources/TextAnalysisEngineImplTest/";
@@ -204,17 +178,14 @@
additionalParams.put(Resource.PARAM_EXTERNAL_OVERRIDE_SETTINGS, extSettings);
UIMAFramework.produceAnalysisEngine(desc, additionalParams);
} catch (Exception e) {
- Assert.fail();
+ fail();
}
- try {
- actual = UimaContextHolder.getContext().getSharedSettingValue("context-holder");
- } catch (ResourceConfigurationException e) {
- Assert.fail(e.getMessage());
- }
- Assert.assertEquals(expected, actual);
-
+ assertThatNoException().isThrownBy(() -> assertThat(
+ UimaContextHolder.getContext().getSharedSettingValue("context-holder"))
+ .isEqualTo(expected));
}
+
// Used to check initialization order by testManyDelegates
allContexts = allContexts + contextName.substring(1);
}
@@ -224,9 +195,6 @@
typeSystemInitCalled = true;
}
- /**
- * @see org.apache.uima.analysis_engine.annotator.TextAnnotator#process(CAS,ResultSpecification)
- */
@Override
public void process(CAS aCAS) {
// set static fields to contain document text, result spec,
diff --git a/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/metadata/SofaMapping_implTest.java b/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/metadata/SofaMapping_implTest.java
index 6de4709..3c39bf2 100644
--- a/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/metadata/SofaMapping_implTest.java
+++ b/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/metadata/SofaMapping_implTest.java
@@ -20,6 +20,7 @@
package org.apache.uima.analysis_engine.impl.metadata;
import static org.apache.uima.analysis_engine.impl.AnalysisEngineDescription_implTest.encoding;
+import static org.assertj.core.api.Assertions.assertThat;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
@@ -27,9 +28,7 @@
import org.apache.uima.UIMAFramework;
import org.apache.uima.analysis_engine.metadata.impl.SofaMapping_impl;
-import org.apache.uima.test.junit_extension.JUnitExtension;
import org.apache.uima.util.XMLInputSource;
-import org.junit.Assert;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -57,27 +56,22 @@
@Test
public void testXmlization() throws Exception {
- try {
- // write to XML
- StringWriter writer = new StringWriter();
- sm1.toXML(writer);
- String sm1Xml = writer.getBuffer().toString();
- writer = new StringWriter();
- sm2.toXML(writer);
- String sm2Xml = writer.getBuffer().toString();
- // parse from XML
- InputStream is = new ByteArrayInputStream(sm1Xml.getBytes(encoding));
- SofaMapping_impl newSm1 = (SofaMapping_impl) UIMAFramework.getXMLParser()
- .parse(new XMLInputSource(is, null));
- is = new ByteArrayInputStream(sm2Xml.getBytes(encoding));
- SofaMapping_impl newSm2 = (SofaMapping_impl) UIMAFramework.getXMLParser()
- .parse(new XMLInputSource(is, null));
+ // write to XML
+ StringWriter writer = new StringWriter();
+ sm1.toXML(writer);
+ String sm1Xml = writer.getBuffer().toString();
+ writer = new StringWriter();
+ sm2.toXML(writer);
+ String sm2Xml = writer.getBuffer().toString();
+ // parse from XML
+ InputStream is = new ByteArrayInputStream(sm1Xml.getBytes(encoding));
+ SofaMapping_impl newSm1 = (SofaMapping_impl) UIMAFramework.getXMLParser()
+ .parse(new XMLInputSource(is, null));
+ is = new ByteArrayInputStream(sm2Xml.getBytes(encoding));
+ SofaMapping_impl newSm2 = (SofaMapping_impl) UIMAFramework.getXMLParser()
+ .parse(new XMLInputSource(is, null));
- Assert.assertEquals(sm1, newSm1);
- Assert.assertEquals(sm2, newSm2);
- } catch (Exception e) {
- JUnitExtension.handleException(e);
- }
+ assertThat(newSm1).isEqualTo(sm1);
+ assertThat(newSm2).isEqualTo(sm2);
}
-
}
diff --git a/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/sequencer/SequencerCapabilityLanguageTest.java b/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/sequencer/SequencerCapabilityLanguageTest.java
index d23f4a4..b73b813 100644
--- a/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/sequencer/SequencerCapabilityLanguageTest.java
+++ b/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/sequencer/SequencerCapabilityLanguageTest.java
@@ -19,6 +19,8 @@
package org.apache.uima.analysis_engine.impl.sequencer;
+import static org.assertj.core.api.Assertions.assertThat;
+
import java.io.File;
import org.apache.uima.UIMAFramework;
@@ -29,7 +31,6 @@
import org.apache.uima.test.junit_extension.FileCompare;
import org.apache.uima.test.junit_extension.JUnitExtension;
import org.apache.uima.util.XMLInputSource;
-import org.junit.Assert;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -80,7 +81,7 @@
}
// check fileoutput
boolean compare = FileCompare.compare(outputReferenceFile, JUnitExtension.getFile(refFile));
- Assert.assertTrue(compare);
+ assertThat(compare).isTrue();
if (compare) {
outputReferenceFile.delete();
}
diff --git a/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/sequencer/SequencerFixedTest.java b/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/sequencer/SequencerFixedTest.java
index 31cc31b..0572ec4 100644
--- a/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/sequencer/SequencerFixedTest.java
+++ b/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/sequencer/SequencerFixedTest.java
@@ -19,6 +19,8 @@
package org.apache.uima.analysis_engine.impl.sequencer;
+import static org.assertj.core.api.Assertions.assertThat;
+
import java.io.File;
import org.apache.uima.UIMAFramework;
@@ -30,7 +32,6 @@
import org.apache.uima.test.junit_extension.FileCompare;
import org.apache.uima.test.junit_extension.JUnitExtension;
import org.apache.uima.util.XMLInputSource;
-import org.junit.Assert;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -80,8 +81,8 @@
resultSpec.addCapabilities(ae.getAnalysisEngineMetaData().getCapabilities());
ae.process(cas, resultSpec);
// check fileoutput
- Assert.assertTrue(FileCompare.compare(outputReferenceFile,
- JUnitExtension.getFile("SequencerTest/SequencerFixedExpected.txt")));
+ assertThat(FileCompare.compare(outputReferenceFile,
+ JUnitExtension.getFile("SequencerTest/SequencerFixedExpected.txt"))).isTrue();
outputReferenceFile.delete();
((CASImpl) cas).traceFSflush();
} catch (Exception ex) {
@@ -125,8 +126,8 @@
resultSpec.addCapabilities(ae.getAnalysisEngineMetaData().getCapabilities());
ae.process(cas, resultSpec);
// check fileoutput
- Assert.assertTrue(FileCompare.compare(outputReferenceFile,
- JUnitExtension.getFile("SequencerTest/SequencerFixedExpected.txt")));
+ assertThat(FileCompare.compare(outputReferenceFile,
+ JUnitExtension.getFile("SequencerTest/SequencerFixedExpected.txt"))).isTrue();
outputReferenceFile.delete();
((CASImpl) cas).traceFSflush();
} catch (Exception ex) {
@@ -170,8 +171,8 @@
resultSpec.addCapabilities(ae.getAnalysisEngineMetaData().getCapabilities());
ae.process(cas, resultSpec);
// check fileoutput
- Assert.assertTrue(FileCompare.compare(outputReferenceFile,
- JUnitExtension.getFile("SequencerTest/SequencerFixedExpected.txt")));
+ assertThat(FileCompare.compare(outputReferenceFile,
+ JUnitExtension.getFile("SequencerTest/SequencerFixedExpected.txt"))).isTrue();
outputReferenceFile.delete();
((CASImpl) cas).traceFSflush();
} catch (Exception ex) {
@@ -215,8 +216,8 @@
resultSpec.addCapabilities(ae.getAnalysisEngineMetaData().getCapabilities());
ae.process(cas, resultSpec);
// check fileoutput
- Assert.assertTrue(FileCompare.compare(outputReferenceFile,
- JUnitExtension.getFile("SequencerTest/SequencerFixedExpected.txt")));
+ assertThat(FileCompare.compare(outputReferenceFile,
+ JUnitExtension.getFile("SequencerTest/SequencerFixedExpected.txt"))).isTrue();
outputReferenceFile.delete();
((CASImpl) cas).traceFSflush();
} catch (Exception ex) {
@@ -260,8 +261,8 @@
resultSpec.addCapabilities(ae.getAnalysisEngineMetaData().getCapabilities());
ae.process(cas, resultSpec);
// check fileoutput
- Assert.assertTrue(FileCompare.compare(outputReferenceFile,
- JUnitExtension.getFile("SequencerTest/SequencerFixedExpected.txt")));
+ assertThat(FileCompare.compare(outputReferenceFile,
+ JUnitExtension.getFile("SequencerTest/SequencerFixedExpected.txt"))).isTrue();
outputReferenceFile.delete();
((CASImpl) cas).traceFSflush();
} catch (Exception ex) {
@@ -305,8 +306,8 @@
resultSpec.addCapabilities(ae.getAnalysisEngineMetaData().getCapabilities());
ae.process(cas, resultSpec);
// check fileoutput
- Assert.assertTrue(FileCompare.compare(outputReferenceFile,
- JUnitExtension.getFile("SequencerTest/SequencerFixedExpected.txt")));
+ assertThat(FileCompare.compare(outputReferenceFile,
+ JUnitExtension.getFile("SequencerTest/SequencerFixedExpected.txt"))).isTrue();
outputReferenceFile.delete();
((CASImpl) cas).traceFSflush();
} catch (Exception ex) {
@@ -350,8 +351,8 @@
resultSpec.addCapabilities(ae.getAnalysisEngineMetaData().getCapabilities());
ae.process(cas, resultSpec);
// check fileoutput
- Assert.assertTrue(FileCompare.compare(outputReferenceFile,
- JUnitExtension.getFile("SequencerTest/SequencerFixedExpected.txt")));
+ assertThat(FileCompare.compare(outputReferenceFile,
+ JUnitExtension.getFile("SequencerTest/SequencerFixedExpected.txt"))).isTrue();
outputReferenceFile.delete();
((CASImpl) cas).traceFSflush();
} catch (Exception ex) {
diff --git a/uimaj-core/src/test/java/org/apache/uima/cas/impl/CasPoolTest.java b/uimaj-core/src/test/java/org/apache/uima/cas/impl/CasPoolTest.java
index 1a1076e..48e26a3 100644
--- a/uimaj-core/src/test/java/org/apache/uima/cas/impl/CasPoolTest.java
+++ b/uimaj-core/src/test/java/org/apache/uima/cas/impl/CasPoolTest.java
@@ -19,6 +19,7 @@
package org.apache.uima.cas.impl;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
@@ -44,7 +45,6 @@
import org.apache.uima.util.InvalidXMLException;
import org.apache.uima.util.XMLInputSource;
import org.apache.uima.util.XMLizable;
-import org.junit.Assert;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -183,9 +183,9 @@
TypeSystem ts = c1.getTypeSystem();
- Assert.assertTrue(ts == c2.getTypeSystem());
- Assert.assertTrue(ts == c1v2.getTypeSystem());
- Assert.assertTrue(ts == c2v2.getTypeSystem());
+ assertThat(ts == c2.getTypeSystem()).isTrue();
+ assertThat(ts == c1v2.getTypeSystem()).isTrue();
+ assertThat(ts == c2v2.getTypeSystem()).isTrue();
casManager.releaseCas(c1v2);
casManager.releaseCas(c2);
diff --git a/uimaj-core/src/test/java/org/apache/uima/cas/impl/FSClassRegistryTest.java b/uimaj-core/src/test/java/org/apache/uima/cas/impl/FSClassRegistryTest.java
index b6be474..0fba3aa 100644
--- a/uimaj-core/src/test/java/org/apache/uima/cas/impl/FSClassRegistryTest.java
+++ b/uimaj-core/src/test/java/org/apache/uima/cas/impl/FSClassRegistryTest.java
@@ -31,11 +31,11 @@
import org.apache.uima.spi.SpiToken;
import org.apache.uima.util.CasCreationUtils;
import org.apache.uima.util.Level;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
public class FSClassRegistryTest {
- @Before
+ @BeforeEach
public void setup() {
System.setProperty(FSClassRegistry.RECORD_JCAS_CLASSLOADERS, "true");
diff --git a/uimaj-core/src/test/java/org/apache/uima/cas/test/TypeOrderTest.java b/uimaj-core/src/test/java/org/apache/uima/cas/test/TypeOrderTest.java
index a118296..b2d2dff 100644
--- a/uimaj-core/src/test/java/org/apache/uima/cas/test/TypeOrderTest.java
+++ b/uimaj-core/src/test/java/org/apache/uima/cas/test/TypeOrderTest.java
@@ -19,13 +19,14 @@
package org.apache.uima.cas.test;
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertTrue;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
-import java.nio.charset.StandardCharsets;
import org.apache.uima.UIMAFramework;
import org.apache.uima.analysis_engine.AnalysisEngine;
@@ -49,7 +50,6 @@
import org.apache.uima.util.InvalidXMLException;
import org.apache.uima.util.XMLInputSource;
import org.apache.uima.util.XMLParser;
-import org.junit.Assert;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -191,11 +191,10 @@
public void testMain() throws Exception {
File refFile = JUnitExtension.getFile("CASTests/CasTypeOrderTestRef.txt");
- Assert.assertNotNull(refFile);
+ assertThat(refFile).isNotNull();
File outputFile = new File(JUnitExtension.getFile("CASTests"), "CasTypeOderTest_testouput.txt");
OutputStreamWriter fileWriter = new OutputStreamWriter(new FileOutputStream(outputFile, false),
- StandardCharsets.UTF_8);
- Assert.assertNotNull(fileWriter);
+ UTF_8);
for (int i = 0; i < 10; i++) {
this.cas.getIndexRepository()
@@ -235,7 +234,7 @@
fileWriter.close();
// System.out.println(refFile.getAbsolutePath());
// System.out.println(outputFile.getAbsolutePath());
- Assert.assertTrue("Comparing ref " + refFile.getAbsolutePath() + " and output "
- + outputFile.getAbsolutePath(), FileCompare.compare(refFile, outputFile));
+ assertThat(FileCompare.compare(refFile, outputFile)).as("Comparing ref "
+ + refFile.getAbsolutePath() + " and output " + outputFile.getAbsolutePath()).isTrue();
}
}
diff --git a/uimaj-core/src/test/java/org/apache/uima/cas_data/impl/CasComparer.java b/uimaj-core/src/test/java/org/apache/uima/cas_data/impl/CasComparer.java
index 9c751ad..24f397c 100644
--- a/uimaj-core/src/test/java/org/apache/uima/cas_data/impl/CasComparer.java
+++ b/uimaj-core/src/test/java/org/apache/uima/cas_data/impl/CasComparer.java
@@ -19,11 +19,13 @@
package org.apache.uima.cas_data.impl;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.fail;
+
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
-import java.util.ConcurrentModificationException;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Set;
@@ -63,7 +65,6 @@
import org.apache.uima.jcas.cas.Sofa;
import org.apache.uima.jcas.cas.StringArray;
import org.apache.uima.jcas.cas.TOP;
-import org.junit.Assert;
/**
* A CAS equality checker for JUnit. SKIPS SOFA FS Comparisons - to make it useful for CasCopier to
@@ -108,7 +109,7 @@
c2Sofas++;
sofaIter.moveToNext();
}
- Assert.assertTrue(c1Sofas == c2Sofas);
+ assertThat(c1Sofas == c2Sofas).isTrue();
}
public static void assertEqualViews(CAS c1, CAS c2) {
@@ -128,7 +129,7 @@
List<TOP> list1 = populate(c1.getIndexRepository().getIndexedFSs(), alreadyCompared);
List<TOP> list2 = populate(c2.getIndexRepository().getIndexedFSs(), alreadyCompared);
- Assert.assertEquals(list1.size(), list2.size());
+ assertThat(list1).hasSameSizeAs(list2);
isSortUse = true; // while sorting; i.e., for next two calls. Affects how visited is used
list1.sort(fsComparator);
@@ -136,12 +137,8 @@
isSortUse = false; // makes the compare1 throw exception if not equal
int i = 0;
- try {
- for (; i < list1.size(); i++) {
- compare1(list1.get(i), list2.get(i), alreadyCompared);
- }
- } catch (ConcurrentModificationException e) {
- Assert.fail();
+ for (; i < list1.size(); i++) {
+ compare1(list1.get(i), list2.get(i), alreadyCompared);
}
}
@@ -188,10 +185,12 @@
if (fs1 == null && fs2 == null) {
return 0;
}
- if (fs1 == null)
+ if (fs1 == null) {
return chkEqual(-1, "fs1 was null and fs2 was not");
- if (fs2 == null)
+ }
+ if (fs2 == null) {
return chkEqual(1, "fs2 was null and fs1 was not");
+ }
}
boolean wasPresent1 = !visited.add(fs1);
@@ -327,31 +326,39 @@
}
// check arrays
} else if (isArray(rangeTypeName)) {
- if (0 != (r = compareArrayFSs(fs1, feat1, fs2, feat2, visited)))
+ if (0 != (r = compareArrayFSs(fs1, feat1, fs2, feat2, visited))) {
return r;
+ }
// check primitive types
} else if (CAS.TYPE_NAME_INTEGER.equals(rangeTypeName)) {
- if (0 != (r = compLong(fs1.getIntValue(feat1), fs2.getIntValue(feat2))))
+ if (0 != (r = compLong(fs1.getIntValue(feat1), fs2.getIntValue(feat2)))) {
return r;
+ }
} else if (CAS.TYPE_NAME_FLOAT.equals(rangeTypeName)) {
- if (0 != (r = compDouble(fs1.getFloatValue(feat1), fs2.getFloatValue(feat2))))
+ if (0 != (r = compDouble(fs1.getFloatValue(feat1), fs2.getFloatValue(feat2)))) {
return r;
+ }
} else if (CAS.TYPE_NAME_BYTE.equals(rangeTypeName)) {
- if (0 != (r = compLong(fs1.getByteValue(feat1), fs2.getByteValue(feat2))))
+ if (0 != (r = compLong(fs1.getByteValue(feat1), fs2.getByteValue(feat2)))) {
return r;
+ }
} else if (CAS.TYPE_NAME_SHORT.equals(rangeTypeName)) {
- if (0 != (r = compLong(fs1.getShortValue(feat1), fs2.getShortValue(feat2))))
+ if (0 != (r = compLong(fs1.getShortValue(feat1), fs2.getShortValue(feat2)))) {
return r;
+ }
} else if (CAS.TYPE_NAME_LONG.equals(rangeTypeName)) {
- if (0 != (r = compLong(fs1.getLongValue(feat1), fs2.getLongValue(feat2))))
+ if (0 != (r = compLong(fs1.getLongValue(feat1), fs2.getLongValue(feat2)))) {
return r;
+ }
} else if (CAS.TYPE_NAME_DOUBLE.equals(rangeTypeName)) {
- if (0 != (r = compDouble(fs1.getDoubleValue(feat1), fs2.getDoubleValue(feat2))))
+ if (0 != (r = compDouble(fs1.getDoubleValue(feat1), fs2.getDoubleValue(feat2)))) {
return r;
+ }
} else if (CAS.TYPE_NAME_BOOLEAN.equals(rangeTypeName)) {
- if (0 != (r = compBoolean(fs1.getBooleanValue(feat1), fs2.getBooleanValue(feat2))))
+ if (0 != (r = compBoolean(fs1.getBooleanValue(feat1), fs2.getBooleanValue(feat2)))) {
return r;
+ }
// check single feature ref
} else {
@@ -366,8 +373,9 @@
for (int j = 0; j < fsCompares.size(); j++) {
int i = fsCompares.get(j);
if (0 != (r = compare1(fs1.getFeatureValue(feats1[i]), fs2.getFeatureValue(feats2[i]),
- visited)))
+ visited))) {
return r;
+ }
}
}
return 0;
@@ -390,7 +398,7 @@
return 0;
}
if (!isSortUse) { // no message for use in sort
- Assert.fail(String.format(format, o));
+ fail(String.format(format, o));
}
return v;
}
@@ -436,12 +444,15 @@
CommonArrayFS arrayFS1 = (CommonArrayFS) arrayFS1fs.getFeatureValue(feat1);
CommonArrayFS arrayFS2 = (CommonArrayFS) arrayFS2fs.getFeatureValue(feat2);
- if (null == arrayFS1 && null == arrayFS2)
+ if (null == arrayFS1 && null == arrayFS2) {
return 0; // are equal
- if (null == arrayFS1)
+ }
+ if (null == arrayFS1) {
return chkEqual(-1, "Array FS1 is null, but Array FS2 is not");
- if (null == arrayFS2)
+ }
+ if (null == arrayFS2) {
return chkEqual(-1, "Array FS2 is null, but Array FS1 is not");
+ }
int r, len;
if (0 != (r = Integer.compare(len = arrayFS1.size(), arrayFS2.size()))) {
@@ -450,61 +461,72 @@
}
// are same size
r = validateSameType(arrayFS1, arrayFS2);
- if (0 != r)
+ if (0 != r) {
return r;
+ }
switch (getArrayType(arrayFS1)) {
case FS:
for (int j = 0; j < len; j++) {
if (0 != (r = compare1((TOP) ((FSArray) arrayFS1).get(j),
- (TOP) ((FSArray) arrayFS2).get(j), visited)))
+ (TOP) ((FSArray) arrayFS2).get(j), visited))) {
return r;
+ }
}
break;
case BOOLEAN:
for (int j = 0; j < len; j++) {
if (0 != (r = compBoolean(((BooleanArrayFS) arrayFS1).get(j),
- ((BooleanArrayFS) arrayFS2).get(j))))
+ ((BooleanArrayFS) arrayFS2).get(j)))) {
return r;
+ }
}
break;
case BYTE:
for (int j = 0; j < len; j++) {
- if (0 != (r = compLong(((ByteArrayFS) arrayFS1).get(j), ((ByteArrayFS) arrayFS2).get(j))))
+ if (0 != (r = compLong(((ByteArrayFS) arrayFS1).get(j),
+ ((ByteArrayFS) arrayFS2).get(j)))) {
return r;
+ }
}
break;
case SHORT:
for (int j = 0; j < len; j++) {
if (0 != (r = compLong(((ShortArrayFS) arrayFS1).get(j),
- ((ShortArrayFS) arrayFS2).get(j))))
+ ((ShortArrayFS) arrayFS2).get(j)))) {
return r;
+ }
}
break;
case INT:
for (int j = 0; j < len; j++) {
- if (0 != (r = compLong(((IntArrayFS) arrayFS1).get(j), ((IntArrayFS) arrayFS2).get(j))))
+ if (0 != (r = compLong(((IntArrayFS) arrayFS1).get(j), ((IntArrayFS) arrayFS2).get(j)))) {
return r;
+ }
}
break;
case LONG:
for (int j = 0; j < len; j++) {
- if (0 != (r = compLong(((LongArrayFS) arrayFS1).get(j), ((LongArrayFS) arrayFS2).get(j))))
+ if (0 != (r = compLong(((LongArrayFS) arrayFS1).get(j),
+ ((LongArrayFS) arrayFS2).get(j)))) {
return r;
+ }
}
break;
case FLOAT:
for (int j = 0; j < len; j++) {
if (0 != (r = compDouble(((FloatArrayFS) arrayFS1).get(j),
- ((FloatArrayFS) arrayFS2).get(j))))
+ ((FloatArrayFS) arrayFS2).get(j)))) {
return r;
+ }
}
break;
case DOUBLE:
for (int j = 0; j < len; j++) {
if (0 != (r = compDouble(((DoubleArrayFS) arrayFS1).get(j),
- ((DoubleArrayFS) arrayFS2).get(j))))
+ ((DoubleArrayFS) arrayFS2).get(j)))) {
return r;
+ }
}
break;
case STRING:
@@ -521,24 +543,33 @@
}
private ARRAY_TYPE getArrayType(CommonArrayFS c) {
- if (c instanceof ArrayFS)
+ if (c instanceof ArrayFS) {
return ARRAY_TYPE.FS;
- if (c instanceof StringArrayFS)
+ }
+ if (c instanceof StringArrayFS) {
return ARRAY_TYPE.STRING;
- if (c instanceof BooleanArrayFS)
+ }
+ if (c instanceof BooleanArrayFS) {
return ARRAY_TYPE.BOOLEAN;
- if (c instanceof ByteArrayFS)
+ }
+ if (c instanceof ByteArrayFS) {
return ARRAY_TYPE.BYTE;
- if (c instanceof ShortArrayFS)
+ }
+ if (c instanceof ShortArrayFS) {
return ARRAY_TYPE.SHORT;
- if (c instanceof IntArrayFS)
+ }
+ if (c instanceof IntArrayFS) {
return ARRAY_TYPE.INT;
- if (c instanceof LongArrayFS)
+ }
+ if (c instanceof LongArrayFS) {
return ARRAY_TYPE.LONG;
- if (c instanceof FloatArrayFS)
+ }
+ if (c instanceof FloatArrayFS) {
return ARRAY_TYPE.FLOAT;
- if (c instanceof DoubleArrayFS)
+ }
+ if (c instanceof DoubleArrayFS) {
return ARRAY_TYPE.DOUBLE;
+ }
return null;
}
diff --git a/uimaj-core/src/test/java/org/apache/uima/cas_data/impl/CasDataToXCasTest.java b/uimaj-core/src/test/java/org/apache/uima/cas_data/impl/CasDataToXCasTest.java
index 58adf54..dce4366 100644
--- a/uimaj-core/src/test/java/org/apache/uima/cas_data/impl/CasDataToXCasTest.java
+++ b/uimaj-core/src/test/java/org/apache/uima/cas_data/impl/CasDataToXCasTest.java
@@ -19,10 +19,11 @@
package org.apache.uima.cas_data.impl;
+import static org.assertj.core.api.Assertions.assertThat;
+
import org.apache.uima.cas_data.CasData;
import org.apache.uima.cas_data.FeatureStructure;
import org.apache.uima.test.junit_extension.JUnitExtension;
-import org.junit.Assert;
import org.junit.jupiter.api.Test;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
@@ -49,7 +50,7 @@
TestContentHandler testContentHandler = new TestContentHandler("Test");
generator.setContentHandler(testContentHandler);
generator.generateXCas(casData);
- Assert.assertTrue(testContentHandler.foundTestElement);
+ assertThat(testContentHandler.foundTestElement).isTrue();
// also try colon and dash conversions
casData = new CasDataImpl();
@@ -64,7 +65,7 @@
testContentHandler = new TestContentHandler("Test:Foo-Bar:What-a-mess");
generator.setContentHandler(testContentHandler);
generator.generateXCas(casData);
- Assert.assertTrue(testContentHandler.foundTestElement);
+ assertThat(testContentHandler.foundTestElement).isTrue();
} catch (Exception e) {
JUnitExtension.handleException(e);
@@ -98,7 +99,7 @@
if (this.testElementName.equals(arg1)) {
foundTestElement = true;
- Assert.assertEquals("myValue", arg3.getValue("myFeature"));
+ assertThat(arg3.getValue("myFeature")).isEqualTo("myValue");
}
}
@@ -121,7 +122,7 @@
@Override
public void endElement(String arg0, String arg1, String arg2) throws SAXException {
if (this.testElementName.equals(arg1)) {
- Assert.assertEquals("this should show up in XML content", buf.toString());
+ assertThat(buf.toString()).isEqualTo("this should show up in XML content");
}
}
}
diff --git a/uimaj-core/src/test/java/org/apache/uima/cas_data/impl/XCasToCasDataSaxHandlerTest.java b/uimaj-core/src/test/java/org/apache/uima/cas_data/impl/XCasToCasDataSaxHandlerTest.java
index 029fad4..7009311 100644
--- a/uimaj-core/src/test/java/org/apache/uima/cas_data/impl/XCasToCasDataSaxHandlerTest.java
+++ b/uimaj-core/src/test/java/org/apache/uima/cas_data/impl/XCasToCasDataSaxHandlerTest.java
@@ -19,6 +19,7 @@
package org.apache.uima.cas_data.impl;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertTrue;
import java.io.File;
@@ -55,7 +56,6 @@
import org.apache.uima.util.Level;
import org.apache.uima.util.XMLInputSource;
import org.apache.uima.util.XMLSerializer;
-import org.junit.Assert;
import org.junit.jupiter.api.Test;
import org.xml.sax.ContentHandler;
import org.xml.sax.InputSource;
@@ -86,9 +86,8 @@
FeatureStructure fs = fsIter.next();
if ("Crawl_colon_URL".equals(fs.getType())) {
// System.out.println("[" + fs.getFeatureValue("value") + "]");
- Assert.assertEquals(
- "http://www.nolimitmedia.com/index.php?act=group&gro=1&gron=Flash&PHPSESSID=5dcc31fb425c4a204b70d9eab92531a5",
- fs.getFeatureValue("value").toString());
+ assertThat(fs.getFeatureValue("value").toString()).isEqualTo(
+ "http://www.nolimitmedia.com/index.php?act=group&gro=1&gron=Flash&PHPSESSID=5dcc31fb425c4a204b70d9eab92531a5");
foundCrawlUrl = true;
}
}
@@ -145,7 +144,7 @@
XCASSerializer xcasSer = new XCASSerializer(aCAS.getTypeSystem());
xcasSer.serialize(aCAS, handler);
- Assert.assertNotNull(casData);
+ assertThat(casData).isNotNull();
assertValidCasData(casData, aCAS.getTypeSystem());
// System.out.println(casData);
@@ -198,19 +197,20 @@
String typeName = fs.getType();
// don't do tests on the "fake" document text FS
- if (XCASSerializer.DEFAULT_DOC_TYPE_NAME.equals(typeName))
+ if (XCASSerializer.DEFAULT_DOC_TYPE_NAME.equals(typeName)) {
continue;
+ }
Type type = typeSystem.getType(typeName);
- Assert.assertNotNull(type);
+ assertThat(type).isNotNull();
if (typeSystem.subsumes(annotType, type)) {
// annotation type - check for presence of begin/end
FeatureValue beginVal = fs.getFeatureValue("begin");
- Assert.assertTrue(beginVal instanceof PrimitiveValue);
- Assert.assertTrue(((PrimitiveValue) beginVal).toInt() >= 0);
+ assertThat(beginVal instanceof PrimitiveValue).isTrue();
+ assertThat(((PrimitiveValue) beginVal).toInt() >= 0).isTrue();
FeatureValue endVal = fs.getFeatureValue("end");
- Assert.assertTrue(endVal instanceof PrimitiveValue);
- Assert.assertTrue(((PrimitiveValue) endVal).toInt() >= 0);
+ assertThat(endVal instanceof PrimitiveValue).isTrue();
+ assertThat(((PrimitiveValue) endVal).toInt() >= 0).isTrue();
}
}
}
@@ -227,8 +227,9 @@
String javaVendor = System.getProperty("java.vendor");
if (javaVendor.startsWith("Sun")) {
String javaVersion = System.getProperty("java.version");
- if (javaVersion.startsWith("1.3") || javaVersion.startsWith("1.4"))
+ if (javaVersion.startsWith("1.3") || javaVersion.startsWith("1.4")) {
return false;
+ }
}
return true;
}
diff --git a/uimaj-core/src/test/java/org/apache/uima/collection/impl/CasConsumerDescription_implTest.java b/uimaj-core/src/test/java/org/apache/uima/collection/impl/CasConsumerDescription_implTest.java
index 6c440bd..13f36cc 100644
--- a/uimaj-core/src/test/java/org/apache/uima/collection/impl/CasConsumerDescription_implTest.java
+++ b/uimaj-core/src/test/java/org/apache/uima/collection/impl/CasConsumerDescription_implTest.java
@@ -20,6 +20,7 @@
package org.apache.uima.collection.impl;
import static org.apache.uima.analysis_engine.impl.AnalysisEngineDescription_implTest.encoding;
+import static org.assertj.core.api.Assertions.assertThat;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
@@ -60,7 +61,6 @@
import org.apache.uima.resource.metadata.impl.TypeSystemDescription_impl;
import org.apache.uima.test.junit_extension.JUnitExtension;
import org.apache.uima.util.XMLInputSource;
-import org.junit.Assert;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -196,7 +196,7 @@
.parse(new XMLInputSource(is, null));
// compare
- Assert.assertEquals(mTestDesc, newDesc);
+ assertThat(newDesc).isEqualTo(mTestDesc);
} catch (Exception e) {
JUnitExtension.handleException(e);
}
@@ -213,7 +213,7 @@
CasConsumerDescription newDesc = (CasConsumerDescription) SerializationUtils
.deserialize(testDescBytes);
- Assert.assertEquals(mTestDesc, newDesc);
+ assertThat(newDesc).isEqualTo(mTestDesc);
} catch (Exception e) {
JUnitExtension.handleException(e);
}
diff --git a/uimaj-core/src/test/java/org/apache/uima/collection/impl/CasInitializerDescription_implTest.java b/uimaj-core/src/test/java/org/apache/uima/collection/impl/CasInitializerDescription_implTest.java
index 9c8b3d7..d5e5b9e 100644
--- a/uimaj-core/src/test/java/org/apache/uima/collection/impl/CasInitializerDescription_implTest.java
+++ b/uimaj-core/src/test/java/org/apache/uima/collection/impl/CasInitializerDescription_implTest.java
@@ -20,6 +20,7 @@
package org.apache.uima.collection.impl;
import static org.apache.uima.analysis_engine.impl.AnalysisEngineDescription_implTest.encoding;
+import static org.assertj.core.api.Assertions.assertThat;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
@@ -60,7 +61,6 @@
import org.apache.uima.resource.metadata.impl.TypeSystemDescription_impl;
import org.apache.uima.test.junit_extension.JUnitExtension;
import org.apache.uima.util.XMLInputSource;
-import org.junit.Assert;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -197,7 +197,7 @@
.parse(new XMLInputSource(is, null));
// compare
- Assert.assertEquals(mTestDesc, newDesc);
+ assertThat(newDesc).isEqualTo(mTestDesc);
} catch (Exception e) {
JUnitExtension.handleException(e);
}
@@ -214,7 +214,7 @@
CasInitializerDescription newDesc = (CasInitializerDescription) SerializationUtils
.deserialize(testDescBytes);
- Assert.assertEquals(mTestDesc, newDesc);
+ assertThat(newDesc).isEqualTo(mTestDesc);
} catch (Exception e) {
JUnitExtension.handleException(e);
}
diff --git a/uimaj-core/src/test/java/org/apache/uima/collection/impl/CollectionReaderDescription_implTest.java b/uimaj-core/src/test/java/org/apache/uima/collection/impl/CollectionReaderDescription_implTest.java
index c0e063b..f93bef0 100644
--- a/uimaj-core/src/test/java/org/apache/uima/collection/impl/CollectionReaderDescription_implTest.java
+++ b/uimaj-core/src/test/java/org/apache/uima/collection/impl/CollectionReaderDescription_implTest.java
@@ -20,6 +20,7 @@
package org.apache.uima.collection.impl;
import static org.apache.uima.analysis_engine.impl.AnalysisEngineDescription_implTest.encoding;
+import static org.assertj.core.api.Assertions.assertThat;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
@@ -60,7 +61,6 @@
import org.apache.uima.resource.metadata.impl.TypeSystemDescription_impl;
import org.apache.uima.test.junit_extension.JUnitExtension;
import org.apache.uima.util.XMLInputSource;
-import org.junit.Assert;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -196,7 +196,7 @@
.getXMLParser().parse(new XMLInputSource(is, null));
// compare
- Assert.assertEquals(mTestDesc, newDesc);
+ assertThat(newDesc).isEqualTo(mTestDesc);
} catch (Exception e) {
JUnitExtension.handleException(e);
}
@@ -213,7 +213,7 @@
CollectionReaderDescription newDesc = (CollectionReaderDescription) SerializationUtils
.deserialize(testDescBytes);
- Assert.assertEquals(mTestDesc, newDesc);
+ assertThat(newDesc).isEqualTo(mTestDesc);
} catch (Exception e) {
JUnitExtension.handleException(e);
}
diff --git a/uimaj-core/src/test/java/org/apache/uima/impl/SomeCustomResource.java b/uimaj-core/src/test/java/org/apache/uima/impl/SomeCustomResource.java
index 3c2eb49..46f6ece 100644
--- a/uimaj-core/src/test/java/org/apache/uima/impl/SomeCustomResource.java
+++ b/uimaj-core/src/test/java/org/apache/uima/impl/SomeCustomResource.java
@@ -18,6 +18,8 @@
*/
package org.apache.uima.impl;
+import static org.assertj.core.api.Assertions.assertThat;
+
import java.util.HashMap;
import java.util.Map;
@@ -26,7 +28,6 @@
import org.apache.uima.resource.ResourceInitializationException;
import org.apache.uima.resource.ResourceSpecifier;
import org.apache.uima.resource.Resource_ImplBase;
-import org.junit.Assert;
public class SomeCustomResource extends Resource_ImplBase {
@@ -41,7 +42,7 @@
@Override
public boolean initialize(ResourceSpecifier aSpecifier, Map aAdditionalParams)
throws ResourceInitializationException {
- Assert.assertTrue(aSpecifier instanceof CustomResourceSpecifier);
+ assertThat(aSpecifier instanceof CustomResourceSpecifier).isTrue();
Parameter[] params = ((CustomResourceSpecifier) aSpecifier).getParameters();
for (int i = 0; i < params.length; i++) {
paramMap.put(params[i].getName(), params[i].getValue());
diff --git a/uimaj-core/src/test/java/org/apache/uima/impl/UimaContext_implTest.java b/uimaj-core/src/test/java/org/apache/uima/impl/UimaContext_implTest.java
index 61a14ea..7c51b9c 100644
--- a/uimaj-core/src/test/java/org/apache/uima/impl/UimaContext_implTest.java
+++ b/uimaj-core/src/test/java/org/apache/uima/impl/UimaContext_implTest.java
@@ -20,6 +20,7 @@
package org.apache.uima.impl;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.within;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
@@ -28,7 +29,6 @@
import java.io.InputStream;
import java.net.URI;
import java.net.URL;
-import java.util.ArrayList;
import java.util.Arrays;
import org.apache.uima.UIMAFramework;
@@ -48,7 +48,6 @@
import org.apache.uima.resource.metadata.impl.XmlizationInfo;
import org.apache.uima.test.junit_extension.JUnitExtension;
import org.apache.uima.util.XMLInputSource;
-import org.junit.Assert;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -135,26 +134,26 @@
public void testGetConfigParameterValueString() throws Exception {
try {
String str = (String) mContext.getConfigParameterValue("StringParam");
- Assert.assertEquals("myString", str);
+ assertThat(str).isEqualTo("myString");
String[] strArr = (String[]) mContext.getConfigParameterValue("StringArrayParam");
- Assert.assertEquals(Arrays.asList(new String[] { "one", "two" }), Arrays.asList(strArr));
+ assertThat(Arrays.asList(strArr)).isEqualTo(Arrays.asList(new String[] { "one", "two" }));
Integer integer = (Integer) mContext.getConfigParameterValue("IntegerParam");
- Assert.assertEquals(Integer.valueOf(42), integer);
+ assertThat(integer).isEqualTo(Integer.valueOf(42));
Integer[] intArr = (Integer[]) mContext.getConfigParameterValue("IntegerArrayParam");
- Assert.assertEquals(Arrays.asList(new Integer[] { 1, 2, 3 }), Arrays.asList(intArr));
+ assertThat(Arrays.asList(intArr)).isEqualTo(Arrays.asList(new Integer[] { 1, 2, 3 }));
Float flt = (Float) mContext.getConfigParameterValue("FloatParam");
- Assert.assertEquals(Float.valueOf(3.14F), flt);
+ assertThat(flt).isEqualTo(Float.valueOf(3.14F));
// default fallback
String str2 = (String) mContext2.getConfigParameterValue("StringParam");
- Assert.assertEquals("en", str2);
+ assertThat(str2).isEqualTo("en");
// get groupless param
String str3 = (String) mContext3.getConfigParameterValue("GrouplessParam1");
- Assert.assertEquals("foo", str3);
+ assertThat(str3).isEqualTo("foo");
// default fallback in presence of groupless params (of different names)
String str4 = (String) mContext3.getConfigParameterValue("StringParam");
- Assert.assertEquals("en", str4);
+ assertThat(str4).isEqualTo("en");
} catch (Exception e) {
JUnitExtension.handleException(e);
}
@@ -168,70 +167,53 @@
try {
// en-US group
String str = (String) mContext2.getConfigParameterValue("en-US", "StringParam");
- Assert.assertEquals("en", str); // language fallback
+ assertThat(str).isEqualTo("en"); // language fallback
String[] strArr = (String[]) mContext2.getConfigParameterValue("en-US", "StringArrayParam");
- Assert.assertEquals(5, strArr.length);
- Assert.assertEquals("e", strArr[0]);
- Assert.assertEquals("n", strArr[1]);
- Assert.assertEquals("-", strArr[2]);
- Assert.assertEquals("U", strArr[3]);
- Assert.assertEquals("S", strArr[4]);
+ assertThat(strArr).containsExactly("e", "n", "-", "U", "S");
Integer intVal = (Integer) mContext2.getConfigParameterValue("en-US", "IntegerParam");
- Assert.assertEquals(1776, intVal.intValue());
+ assertThat(intVal.intValue()).isEqualTo(1776);
+ // language fallback
Integer[] intArr = (Integer[]) mContext2.getConfigParameterValue("en-US",
"IntegerArrayParam");
- Assert.assertEquals(3, intArr.length); // language fallback
- Assert.assertEquals(1, intArr[0].intValue());
- Assert.assertEquals(2, intArr[1].intValue());
- Assert.assertEquals(3, intArr[2].intValue());
+ assertThat(intArr).containsExactly(1, 2, 3);
Float floatVal = (Float) mContext2.getConfigParameterValue("en-US", "FloatParam");
- Assert.assertEquals(null, floatVal);
+ assertThat(floatVal).isEqualTo(null);
// de group
String str2 = (String) mContext2.getConfigParameterValue("de", "StringParam");
- Assert.assertEquals("de", str2);
+ assertThat(str2).isEqualTo("de");
String[] strArr2 = (String[]) mContext2.getConfigParameterValue("de", "StringArrayParam");
- Assert.assertEquals(2, strArr2.length);
- Assert.assertEquals("d", strArr2[0]);
- Assert.assertEquals("e", strArr2[1]);
+ assertThat(strArr2).containsExactly("d", "e");
Integer intVal2 = (Integer) mContext2.getConfigParameterValue("de", "IntegerParam");
- Assert.assertEquals(42, intVal2.intValue()); // default fallback
+ assertThat(intVal2.intValue()).isEqualTo(42); // default fallback
Integer[] intArr2 = (Integer[]) mContext2.getConfigParameterValue("de", "IntegerArrayParam");
- Assert.assertEquals(3, intArr2.length);
- Assert.assertEquals(4, intArr2[0].intValue());
- Assert.assertEquals(5, intArr2[1].intValue());
- Assert.assertEquals(6, intArr2[2].intValue());
+ assertThat(intArr2).containsExactly(4, 5, 6);
Float floatVal2 = (Float) mContext2.getConfigParameterValue("de", "FloatParam");
- Assert.assertEquals(null, floatVal2);
+ assertThat(floatVal2).isEqualTo(null);
// zh group
String str3 = (String) mContext2.getConfigParameterValue("zh", "StringParam");
- Assert.assertEquals("zh", str3);
+ assertThat(str3).isEqualTo("zh");
String[] strArr3 = (String[]) mContext2.getConfigParameterValue("zh", "StringArrayParam");
- Assert.assertEquals(2, strArr3.length);
- Assert.assertEquals("z", strArr3[0]);
- Assert.assertEquals("h", strArr3[1]);
+ assertThat(strArr3).containsExactly("z", "h");
Integer intVal3 = (Integer) mContext2.getConfigParameterValue("zh", "IntegerParam");
- Assert.assertEquals(42, intVal3.intValue()); // default fallback
+ assertThat(intVal3.intValue()).isEqualTo(42); // default fallback
Integer[] intArr3 = (Integer[]) mContext2.getConfigParameterValue("zh", "IntegerArrayParam");
- Assert.assertEquals(3, intArr3.length); // default fallback
- Assert.assertEquals(1, intArr3[0].intValue());
- Assert.assertEquals(2, intArr3[1].intValue());
- Assert.assertEquals(3, intArr3[2].intValue());
+ assertThat(intArr3).containsExactly(1, 2, 3); // default fallback
Float floatVal3 = (Float) mContext2.getConfigParameterValue("zh", "FloatParam");
- Assert.assertEquals(3.14, floatVal3, 0.0001);
+ assertThat(floatVal3).isCloseTo(3.14f, within(0.0001f));
// testing duplicate groups
assertEquals("common-a", mContext4.getConfigParameterValue("a", "CommonParam"));
@@ -250,28 +232,15 @@
@Test
public void testGetConfigurationGroupNames() {
- String[] names = mContext2.getConfigurationGroupNames();
- Assert.assertEquals(5, names.length);
- ArrayList<String> l = new ArrayList<>(Arrays.asList(names));
- Assert.assertTrue(l.contains("en"));
- Assert.assertTrue(l.contains("en-US"));
- Assert.assertTrue(l.contains("de"));
- Assert.assertTrue(l.contains("zh"));
- Assert.assertTrue(l.contains("x-unspecified"));
+ assertThat(mContext2.getConfigurationGroupNames()).containsExactlyInAnyOrder("en", "en-US",
+ "de", "zh", "x-unspecified");
// try on something with both groups and groupless parameters
- names = mContext3.getConfigurationGroupNames();
- Assert.assertEquals(5, names.length);
- l = new ArrayList<>(Arrays.asList(names));
- Assert.assertTrue(l.contains("en"));
- Assert.assertTrue(l.contains("en-US"));
- Assert.assertTrue(l.contains("de"));
- Assert.assertTrue(l.contains("zh"));
- Assert.assertTrue(l.contains("x-unspecified"));
+ assertThat(mContext3.getConfigurationGroupNames()).containsExactlyInAnyOrder("en", "en-US",
+ "de", "zh", "x-unspecified");
// try on something that has no groups
- names = mContext.getConfigurationGroupNames();
- Assert.assertEquals(0, names.length);
+ assertThat(mContext.getConfigurationGroupNames()).isEmpty();
}
@Test
@@ -284,24 +253,16 @@
@Test
public void testGetConfigParameterNames() {
- String[] names = mContext.getConfigParameterNames();
- Assert.assertEquals(6, names.length);
- Assert.assertEquals("StringParam", names[0]);
- Assert.assertEquals("StringArrayParam", names[1]);
- Assert.assertEquals("IntegerParam", names[2]);
- Assert.assertEquals("IntegerArrayParam", names[3]);
- Assert.assertEquals("FloatParam", names[4]);
- Assert.assertEquals("FloatArrayParam", names[5]);
+ assertThat(mContext.getConfigParameterNames()).containsExactly("StringParam",
+ "StringArrayParam", "IntegerParam", "IntegerArrayParam", "FloatParam",
+ "FloatArrayParam");
// try on something that has groups
- names = mContext2.getConfigParameterNames();
- Assert.assertEquals(0, names.length);
+ assertThat(mContext2.getConfigParameterNames()).isEmpty();
// try on something with both groups and groupless parameters
- names = mContext3.getConfigParameterNames();
- Assert.assertEquals(2, names.length);
- Assert.assertEquals("GrouplessParam1", names[0]);
- Assert.assertEquals("GrouplessParam2", names[1]);
+ assertThat(mContext3.getConfigParameterNames()).containsExactly("GrouplessParam1",
+ "GrouplessParam2");
}
@Test
@@ -315,30 +276,18 @@
@Test
public void testGetConfigParameterNamesString() {
- String[] names = mContext2.getConfigParameterNames("en");
- Assert.assertEquals(4, names.length);
- ArrayList<String> l = new ArrayList<>(Arrays.asList(names));
- Assert.assertTrue(l.contains("StringParam"));
- Assert.assertTrue(l.contains("StringArrayParam"));
- Assert.assertTrue(l.contains("IntegerParam"));
- Assert.assertTrue(l.contains("IntegerArrayParam"));
+ assertThat(mContext2.getConfigParameterNames("en")).containsExactlyInAnyOrder("StringParam",
+ "StringArrayParam", "IntegerParam", "IntegerArrayParam");
// try on nonexistent group
- names = mContext2.getConfigParameterNames("foo");
- Assert.assertEquals(0, names.length);
+ assertThat(mContext2.getConfigParameterNames("foo")).isEmpty();
// try on something that has no groups
- names = mContext.getConfigParameterNames("en");
- Assert.assertEquals(0, names.length);
+ assertThat(mContext.getConfigParameterNames("en")).isEmpty();
// try on something with both groups and groupless params
- names = mContext3.getConfigParameterNames("en");
- Assert.assertEquals(4, names.length);
- l = new ArrayList<>(Arrays.asList(names));
- Assert.assertTrue(l.contains("StringParam"));
- Assert.assertTrue(l.contains("StringArrayParam"));
- Assert.assertTrue(l.contains("IntegerParam"));
- Assert.assertTrue(l.contains("IntegerArrayParam"));
+ assertThat(mContext3.getConfigParameterNames("en")).containsExactlyInAnyOrder("StringParam",
+ "StringArrayParam", "IntegerParam", "IntegerArrayParam");
}
@@ -347,13 +296,13 @@
try {
// custom object
Object r = mContext.getResourceObject("TestResourceObject");
- Assert.assertNotNull(r);
- Assert.assertTrue(r instanceof TestResourceInterface);
+ assertThat(r).isNotNull();
+ assertThat(r instanceof TestResourceInterface).isTrue();
// standard data resource
Object r2 = mContext.getResourceObject("TestFileResource");
- Assert.assertNotNull(r2);
- Assert.assertTrue(r2 instanceof DataResource);
+ assertThat(r2).isNotNull();
+ assertThat(r2 instanceof DataResource).isTrue();
// parameterized resources (should fail)
ResourceAccessException ex = null;
@@ -362,7 +311,7 @@
} catch (ResourceAccessException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
ex = null;
try {
@@ -370,11 +319,11 @@
} catch (ResourceAccessException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
// nonexistent resource (should return null)
Object r3 = mContext.getResourceObject("Unknown");
- Assert.assertNull(r3);
+ assertThat(r3).isNull();
} catch (Exception e) {
JUnitExtension.handleException(e);
}
@@ -385,11 +334,11 @@
try {
// standard data resource (should succeed)
URL url = mContext.getResourceURL("TestFileResource");
- Assert.assertNotNull(url);
+ assertThat(url).isNotNull();
// custom resource object (should return null)
URL url2 = mContext.getResourceURL("TestResourceObject");
- Assert.assertNull(url2);
+ assertThat(url2).isNull();
// parameterized resources (should fail)
ResourceAccessException ex = null;
@@ -398,7 +347,7 @@
} catch (ResourceAccessException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
ex = null;
try {
@@ -406,23 +355,23 @@
} catch (ResourceAccessException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
// nonexistent resource (should return null)
URL url3 = mContext.getResourceURL("Unknown");
- Assert.assertNull(url3);
+ assertThat(url3).isNull();
// passthrough to class loader
URL url5 = mContext.getResourceURL("org/apache/uima/analysis_engine/impl/testDataFile3.dat");
- Assert.assertNotNull(url5);
+ assertThat(url5).isNotNull();
// passthrough to data path
URL url6 = mContext.getResourceURL("testDataFile.dat");
- Assert.assertNotNull(url6);
+ assertThat(url6).isNotNull();
// for directory
URL url7 = mContext.getResourceURL("subdir");
- Assert.assertNotNull(url7);
+ assertThat(url7).isNotNull();
// spaces as part of extension classpath (spaces should be URL-encoded)
URL url8 = mContext.getResourceURL("OtherFileResource");
@@ -440,11 +389,11 @@
try {
// standard data resource (should succeed)
URI uri = mContext.getResourceURI("TestFileResource");
- Assert.assertNotNull(uri);
+ assertThat(uri).isNotNull();
// custom resource object (should return null)
URI uri2 = mContext.getResourceURI("TestResourceObject");
- Assert.assertNull(uri2);
+ assertThat(uri2).isNull();
// parameterized resources (should fail)
ResourceAccessException ex = null;
@@ -453,7 +402,7 @@
} catch (ResourceAccessException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
ex = null;
try {
@@ -461,23 +410,23 @@
} catch (ResourceAccessException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
// nonexistent resource (should return null)
URI uri3 = mContext.getResourceURI("Unknown");
- Assert.assertNull(uri3);
+ assertThat(uri3).isNull();
// passthrough to class loader
URI uri5 = mContext.getResourceURI("org/apache/uima/analysis_engine/impl/testDataFile3.dat");
- Assert.assertNotNull(uri5);
+ assertThat(uri5).isNotNull();
// passthrough to data path
URI uri6 = mContext.getResourceURI("testDataFile.dat");
- Assert.assertNotNull(uri6);
+ assertThat(uri6).isNotNull();
// for directory
URI uri7 = mContext.getResourceURI("subdir");
- Assert.assertNotNull(uri7);
+ assertThat(uri7).isNotNull();
// spaces as part of extension classpath (spaces should be decoded, unlike with URL)
URI uri8 = mContext.getResourceURI("OtherFileResource");
@@ -494,11 +443,11 @@
try {
// standard data resource (should succeed)
String path = mContext.getResourceFilePath("TestFileResource");
- Assert.assertNotNull(path);
+ assertThat(path).isNotNull();
// custom resource object (should return null)
String path2 = mContext.getResourceFilePath("TestResourceObject");
- Assert.assertNull(path2);
+ assertThat(path2).isNull();
// parameterized resources (should fail)
ResourceAccessException ex = null;
@@ -507,7 +456,7 @@
} catch (ResourceAccessException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
ex = null;
try {
@@ -515,24 +464,24 @@
} catch (ResourceAccessException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
// nonexistent resource (should return null)
String path3 = mContext.getResourceFilePath("Unknown");
- Assert.assertNull(path3);
+ assertThat(path3).isNull();
// passthrough to class loader
String path5 = mContext
.getResourceFilePath("org/apache/uima/analysis_engine/impl/testDataFile3.dat");
- Assert.assertNotNull(path5);
+ assertThat(path5).isNotNull();
// passthrough to data path
String path6 = mContext.getResourceFilePath("testDataFile.dat");
- Assert.assertNotNull(path6);
+ assertThat(path6).isNotNull();
// for directory
String path7 = mContext.getResourceFilePath("subdir");
- Assert.assertNotNull(path7);
+ assertThat(path7).isNotNull();
// spaces as part of extension classpath (spaces should be decoded, unlike with URL)
String path8 = mContext.getResourceFilePath("OtherFileResource");
@@ -549,11 +498,11 @@
try {
// standard data resource (should succeed)
InputStream strm = mContext.getResourceAsStream("TestFileResource");
- Assert.assertNotNull(strm);
+ assertThat(strm).isNotNull();
// custom resource object (should return null)
InputStream strm2 = mContext.getResourceAsStream("TestResourceObject");
- Assert.assertNull(strm2);
+ assertThat(strm2).isNull();
// parameterized resources (should fail)
ResourceAccessException ex = null;
@@ -562,7 +511,7 @@
} catch (ResourceAccessException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
ex = null;
try {
@@ -570,24 +519,24 @@
} catch (ResourceAccessException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
// nonexistent resource (should return null)
InputStream strm3 = mContext.getResourceAsStream("Unknown");
- Assert.assertNull(strm3);
+ assertThat(strm3).isNull();
// passthrough to class loader
InputStream strm4 = mContext
.getResourceAsStream("org/apache/uima/analysis_engine/impl/testDataFile3.dat");
- Assert.assertNotNull(strm4);
+ assertThat(strm4).isNotNull();
// passthrough to data path
InputStream strm5 = mContext.getResourceAsStream("testDataFile.dat");
- Assert.assertNotNull(strm5);
+ assertThat(strm5).isNotNull();
// for directory
InputStream strm6 = mContext.getResourceAsStream("subdir");
- Assert.assertNotNull(strm6);
+ assertThat(strm6).isNotNull();
// spaces as part of extension classpath
InputStream strm7 = mContext.getResourceAsStream("OtherFileResource");
@@ -602,21 +551,21 @@
try {
// standard data resource
Object r = mContext.getResourceObject("TestFileLanguageResource", new String[] { "en" });
- Assert.assertNotNull(r);
- Assert.assertTrue(r instanceof DataResource);
+ assertThat(r).isNotNull();
+ assertThat(r instanceof DataResource).isTrue();
Object r2 = mContext.getResourceObject("TestFileLanguageResource", new String[] { "de" });
- Assert.assertNotNull(r2);
- Assert.assertTrue(r2 instanceof DataResource);
- Assert.assertFalse(r2.equals(r));
+ assertThat(r2).isNotNull();
+ assertThat(r2 instanceof DataResource).isTrue();
+ assertThat(r).isNotEqualTo(r2);
// custom object
Object r3 = mContext.getResourceObject("TestLanguageResourceObject", new String[] { "en" });
- Assert.assertNotNull(r3);
- Assert.assertTrue(r3 instanceof TestResourceInterface);
+ assertThat(r3).isNotNull();
+ assertThat(r3 instanceof TestResourceInterface).isTrue();
Object r4 = mContext.getResourceObject("TestLanguageResourceObject", new String[] { "de" });
- Assert.assertNotNull(r4);
- Assert.assertTrue(r4 instanceof TestResourceInterface);
- Assert.assertFalse(r4.equals(r3));
+ assertThat(r4).isNotNull();
+ assertThat(r4 instanceof TestResourceInterface).isTrue();
+ assertThat(r3).isNotEqualTo(r4);
// parameter values for which no resource exists (should fail)
ResourceAccessException ex = null;
@@ -625,7 +574,7 @@
} catch (ResourceAccessException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
ex = null;
try {
@@ -633,7 +582,7 @@
} catch (ResourceAccessException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
// non-parameterized resources (should fail)
ex = null;
@@ -642,7 +591,7 @@
} catch (ResourceAccessException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
ex = null;
try {
@@ -650,11 +599,11 @@
} catch (ResourceAccessException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
// nonexistent resource (should return null)
Object r5 = mContext.getResourceObject("Unknown", new String[] { "en" });
- Assert.assertNull(r5);
+ assertThat(r5).isNull();
} catch (Exception e) {
JUnitExtension.handleException(e);
}
@@ -666,17 +615,17 @@
// standard data resource
InputStream strm = mContext.getResourceAsStream("TestFileLanguageResource",
new String[] { "en" });
- Assert.assertNotNull(strm);
+ assertThat(strm).isNotNull();
InputStream strm2 = mContext.getResourceAsStream("TestFileLanguageResource",
new String[] { "de" });
- Assert.assertNotNull(strm2);
- Assert.assertFalse(strm2.equals(strm));
+ assertThat(strm2).isNotNull();
+ assertThat(strm).isNotEqualTo(strm2);
// custom object (should return null)
InputStream strm3 = mContext.getResourceAsStream("TestLanguageResourceObject",
new String[] { "en" });
- Assert.assertNull(strm3);
+ assertThat(strm3).isNull();
// parameter values for which no resource exists (should fail)
ResourceAccessException ex = null;
@@ -685,7 +634,7 @@
} catch (ResourceAccessException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
ex = null;
try {
@@ -693,7 +642,7 @@
} catch (ResourceAccessException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
// non-parameterized resources (should fail)
ex = null;
@@ -702,7 +651,7 @@
} catch (ResourceAccessException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
ex = null;
try {
@@ -710,11 +659,11 @@
} catch (ResourceAccessException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
// nonexistent resource (should return null)
InputStream strm4 = mContext.getResourceAsStream("Unknown", new String[] { "en" });
- Assert.assertNull(strm4);
+ assertThat(strm4).isNull();
} catch (Exception e) {
JUnitExtension.handleException(e);
}
@@ -725,15 +674,15 @@
try {
// standard data resource
URL url = mContext.getResourceURL("TestFileLanguageResource", new String[] { "en" });
- Assert.assertNotNull(url);
+ assertThat(url).isNotNull();
URL url2 = mContext.getResourceURL("TestFileLanguageResource", new String[] { "de" });
- Assert.assertNotNull(url2);
- Assert.assertFalse(url2.toString().equals(url.toString()));
+ assertThat(url2).isNotNull();
+ assertThat(url.toString()).isNotEqualTo(url2.toString());
// custom object (should return null)
URL url3 = mContext.getResourceURL("TestLanguageResourceObject", new String[] { "en" });
- Assert.assertNull(url3);
+ assertThat(url3).isNull();
// parameter values for which no resource exists (should fail)
ResourceAccessException ex = null;
@@ -742,7 +691,7 @@
} catch (ResourceAccessException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
ex = null;
try {
@@ -750,7 +699,7 @@
} catch (ResourceAccessException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
// non-parameterized resources (should fail)
ex = null;
@@ -759,7 +708,7 @@
} catch (ResourceAccessException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
ex = null;
try {
@@ -767,11 +716,11 @@
} catch (ResourceAccessException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
// nonexistent resource (should return null)
URL url4 = mContext.getResourceURL("Unknown", new String[] { "en" });
- Assert.assertNull(url4);
+ assertThat(url4).isNull();
} catch (Exception e) {
JUnitExtension.handleException(e);
}
@@ -782,15 +731,15 @@
try {
// standard data resource
URI uri = mContext.getResourceURI("TestFileLanguageResource", new String[] { "en" });
- Assert.assertNotNull(uri);
+ assertThat(uri).isNotNull();
URI uri2 = mContext.getResourceURI("TestFileLanguageResource", new String[] { "de" });
- Assert.assertNotNull(uri2);
- Assert.assertFalse(uri2.equals(uri));
+ assertThat(uri2).isNotNull();
+ assertThat(uri).isNotEqualTo(uri2);
// custom object (should return null)
URI uri3 = mContext.getResourceURI("TestLanguageResourceObject", new String[] { "en" });
- Assert.assertNull(uri3);
+ assertThat(uri3).isNull();
// parameter values for which no resource exists (should fail)
ResourceAccessException ex = null;
@@ -799,7 +748,7 @@
} catch (ResourceAccessException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
ex = null;
try {
@@ -807,7 +756,7 @@
} catch (ResourceAccessException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
// non-parameterized resources (should fail)
ex = null;
@@ -816,7 +765,7 @@
} catch (ResourceAccessException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
ex = null;
try {
@@ -824,11 +773,11 @@
} catch (ResourceAccessException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
// nonexistent resource (should return null)
URI uri4 = mContext.getResourceURI("Unknown", new String[] { "en" });
- Assert.assertNull(uri4);
+ assertThat(uri4).isNull();
} catch (Exception e) {
JUnitExtension.handleException(e);
}
@@ -839,17 +788,17 @@
try {
// standard data resource
String path = mContext.getResourceFilePath("TestFileLanguageResource", new String[] { "en" });
- Assert.assertNotNull(path);
+ assertThat(path).isNotNull();
String path2 = mContext.getResourceFilePath("TestFileLanguageResource",
new String[] { "de" });
- Assert.assertNotNull(path2);
- Assert.assertFalse(path2.equals(path));
+ assertThat(path2).isNotNull();
+ assertThat(path).isNotEqualTo(path2);
// custom object (should return null)
String path3 = mContext.getResourceFilePath("TestLanguageResourceObject",
new String[] { "en" });
- Assert.assertNull(path3);
+ assertThat(path3).isNull();
// parameter values for which no resource exists (should fail)
ResourceAccessException ex = null;
@@ -858,7 +807,7 @@
} catch (ResourceAccessException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
ex = null;
try {
@@ -866,7 +815,7 @@
} catch (ResourceAccessException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
// non-parameterized resources (should fail)
ex = null;
@@ -875,7 +824,7 @@
} catch (ResourceAccessException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
ex = null;
try {
@@ -883,11 +832,11 @@
} catch (ResourceAccessException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
// nonexistent resource (should return null)
String path4 = mContext.getResourceFilePath("Unknown", new String[] { "en" });
- Assert.assertNull(path4);
+ assertThat(path4).isNull();
} catch (Exception e) {
JUnitExtension.handleException(e);
}
diff --git a/uimaj-core/src/test/java/org/apache/uima/internal/util/AnalysisEnginePoolTest.java b/uimaj-core/src/test/java/org/apache/uima/internal/util/AnalysisEnginePoolTest.java
index a68e018..ca1e317 100644
--- a/uimaj-core/src/test/java/org/apache/uima/internal/util/AnalysisEnginePoolTest.java
+++ b/uimaj-core/src/test/java/org/apache/uima/internal/util/AnalysisEnginePoolTest.java
@@ -19,6 +19,7 @@
package org.apache.uima.internal.util;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
@@ -41,7 +42,6 @@
import org.apache.uima.resource.metadata.impl.ConfigurationParameter_impl;
import org.apache.uima.resource.metadata.impl.NameValuePair_impl;
import org.apache.uima.test.junit_extension.JUnitExtension;
-import org.junit.Assert;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -78,13 +78,14 @@
AnalysisEngine tae = pool.getAnalysisEngine();
AnalysisEngineMetaData md = tae.getAnalysisEngineMetaData();
- Assert.assertNotNull(md);
- Assert.assertEquals("Simple Test", md.getName());
+ assertThat(md).isNotNull();
+ assertThat(md.getName()).isEqualTo("Simple Test");
} catch (Exception e) {
JUnitExtension.handleException(e);
} finally {
- if (pool != null)
+ if (pool != null) {
pool.destroy();
+ }
}
}
@@ -182,7 +183,7 @@
// check pool metadata
pool.getMetaData().setUUID(tae.getMetaData().getUUID());
- Assert.assertEquals(tae.getMetaData(), pool.getMetaData());
+ assertThat(pool.getMetaData()).isEqualTo(tae.getMetaData());
} finally {
pool.releaseAnalysisEngine(tae);
}
diff --git a/uimaj-core/src/test/java/org/apache/uima/internal/util/IntVectorTest.java b/uimaj-core/src/test/java/org/apache/uima/internal/util/IntVectorTest.java
index c203534..040da91 100644
--- a/uimaj-core/src/test/java/org/apache/uima/internal/util/IntVectorTest.java
+++ b/uimaj-core/src/test/java/org/apache/uima/internal/util/IntVectorTest.java
@@ -19,6 +19,7 @@
package org.apache.uima.internal.util;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertTrue;
import java.util.Arrays;
@@ -32,7 +33,6 @@
import org.apache.uima.resource.CasManager;
import org.apache.uima.test.junit_extension.JUnitExtension;
import org.apache.uima.util.XMLInputSource;
-import org.junit.Assert;
import org.junit.jupiter.api.Test;
public class IntVectorTest {
@@ -88,9 +88,9 @@
TypeSystem ts = c1.getTypeSystem();
- Assert.assertTrue(ts == c2.getTypeSystem());
- Assert.assertTrue(ts == c1v2.getTypeSystem());
- Assert.assertTrue(ts == c2v2.getTypeSystem());
+ assertThat(ts == c2.getTypeSystem()).isTrue();
+ assertThat(ts == c1v2.getTypeSystem()).isTrue();
+ assertThat(ts == c2v2.getTypeSystem()).isTrue();
} catch (Exception e) {
JUnitExtension.handleException(e);
diff --git a/uimaj-core/src/test/java/org/apache/uima/internal/util/ResourcePoolTest.java b/uimaj-core/src/test/java/org/apache/uima/internal/util/ResourcePoolTest.java
index c8ad505..c20ed8c 100644
--- a/uimaj-core/src/test/java/org/apache/uima/internal/util/ResourcePoolTest.java
+++ b/uimaj-core/src/test/java/org/apache/uima/internal/util/ResourcePoolTest.java
@@ -19,6 +19,7 @@
package org.apache.uima.internal.util;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import org.apache.uima.UIMAFramework;
@@ -29,7 +30,6 @@
import org.apache.uima.resource.metadata.ResourceMetaData;
import org.apache.uima.test.junit_extension.JUnitExtension;
import org.apache.uima.util.Level;
-import org.junit.Assert;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -67,26 +67,26 @@
@Test
public void testGetResource() throws Exception {
try {
- Assert.assertEquals(3, pool1.getFreeInstances().size());
+ assertThat(pool1.getFreeInstances()).hasSize(3);
// get two resources
Resource foo = pool1.getResource();
- Assert.assertNotNull(foo);
- Assert.assertEquals(2, pool1.getFreeInstances().size());
+ assertThat(foo).isNotNull();
+ assertThat(pool1.getFreeInstances()).hasSize(2);
Resource bar = pool1.getResource();
- Assert.assertNotNull(bar);
- Assert.assertTrue(!foo.equals(bar));
- Assert.assertEquals(1, pool1.getFreeInstances().size());
+ assertThat(bar).isNotNull();
+ assertThat(!foo.equals(bar)).isTrue();
+ assertThat(pool1.getFreeInstances()).hasSize(1);
// get two more resources (should exhaust pool)
Resource a = pool1.getResource();
- Assert.assertNotNull(a);
- Assert.assertEquals(0, pool1.getFreeInstances().size());
+ assertThat(a).isNotNull();
+ assertThat(pool1.getFreeInstances()).hasSize(0);
Resource b = pool1.getResource();
- Assert.assertNull(b);
- Assert.assertEquals(0, pool1.getFreeInstances().size());
+ assertThat(b).isNull();
+ assertThat(pool1.getFreeInstances()).hasSize(0);
} catch (Exception e) {
JUnitExtension.handleException(e);
}
@@ -103,24 +103,24 @@
// returning null
long startTime = System.currentTimeMillis();
Resource foo = pool1.getResource(1000);
- Assert.assertNotNull(foo);
- Assert.assertTrue(System.currentTimeMillis() - startTime < 500);
+ assertThat(foo).isNotNull();
+ assertThat(System.currentTimeMillis() - startTime < 500).isTrue();
startTime = System.currentTimeMillis();
Resource bar = pool1.getResource(1000);
- Assert.assertNotNull(bar);
- Assert.assertTrue(!foo.equals(bar));
- Assert.assertTrue(System.currentTimeMillis() - startTime < 500);
+ assertThat(bar).isNotNull();
+ assertThat(!foo.equals(bar)).isTrue();
+ assertThat(System.currentTimeMillis() - startTime < 500).isTrue();
startTime = System.currentTimeMillis();
Resource a = pool1.getResource(1000);
- Assert.assertNotNull(a);
- Assert.assertTrue(System.currentTimeMillis() - startTime < 500);
+ assertThat(a).isNotNull();
+ assertThat(System.currentTimeMillis() - startTime < 500).isTrue();
startTime = System.currentTimeMillis();
Resource b = pool1.getResource(1000);
- Assert.assertNull(b);
- Assert.assertTrue(System.currentTimeMillis() - startTime >= 1000);
+ assertThat(b).isNull();
+ assertThat(System.currentTimeMillis() - startTime >= 1000).isTrue();
// Start a thread that will release "foo" in .2 second. Demonstrate that
// getResource() will not acquire a resource but getResource(1000) will.
@@ -129,7 +129,7 @@
releaserThread.start();
b = pool1.getResource();
- Assert.assertNull(b);
+ assertThat(b).isNull();
b = pool1.getResource(5000); // wait up to 5 seconds in case machine is sluggish :-(
// observe occasional failures - it appears the test machine gets pre-empted for several
// seconds
@@ -138,7 +138,7 @@
// the checking thread timed out.
// Changing the time the main thread waits for the release from 1 sec to 5 secs to reduce
// spurious failures.
- Assert.assertNotNull(b);
+ assertThat(b).isNotNull();
releaserThread.join();
assertEquals(null, exceptionFromReleaserThread[0]);
} catch (Exception e) {
@@ -150,33 +150,33 @@
public void testReleaseResource() throws Exception {
try {
// acquire all the resources
- Assert.assertEquals(3, pool1.getFreeInstances().size());
+ assertThat(pool1.getFreeInstances()).hasSize(3);
Resource foo = pool1.getResource();
Resource bar = pool1.getResource();
Resource blah = pool1.getResource();
- Assert.assertEquals(0, pool1.getFreeInstances().size());
+ assertThat(pool1.getFreeInstances()).hasSize(0);
// release one
pool1.releaseResource(foo);
- Assert.assertEquals(1, pool1.getFreeInstances().size());
+ assertThat(pool1.getFreeInstances()).hasSize(1);
// try to release "foo" again - should not change the free instances count
// this will log a warning - first we log that this is expected
UIMAFramework.getLogger().log(Level.WARNING,
"Unit test is expecting to log ResourcePool warning.");
pool1.releaseResource(foo);
- Assert.assertEquals(1, pool1.getFreeInstances().size());
+ assertThat(pool1.getFreeInstances()).hasSize(1);
// show that we can then check out a new one
Resource test = pool1.getResource();
- Assert.assertNotNull(test);
- Assert.assertEquals(0, pool1.getFreeInstances().size());
+ assertThat(test).isNotNull();
+ assertThat(pool1.getFreeInstances()).hasSize(0);
// release the others
pool1.releaseResource(test);
pool1.releaseResource(bar);
pool1.releaseResource(blah);
- Assert.assertEquals(3, pool1.getFreeInstances().size());
+ assertThat(pool1.getFreeInstances()).hasSize(3);
} catch (Exception e) {
JUnitExtension.handleException(e);
}
@@ -194,13 +194,13 @@
pool1.releaseResource(b);
// now some stuff should be recorded in the pool
- Assert.assertTrue(!pool1.getFreeInstances().isEmpty());
+ assertThat(!pool1.getFreeInstances().isEmpty()).isTrue();
// destroy the pool
pool1.destroy();
// check that everything is gone
- Assert.assertTrue(pool1.getFreeInstances().isEmpty());
+ assertThat(pool1.getFreeInstances().isEmpty()).isTrue();
} catch (Exception e) {
JUnitExtension.handleException(e);
}
@@ -213,7 +213,7 @@
ResourceMetaData poolMetaData = pool1.getMetaData();
// only UUID should be different
descMetaData.setUUID(poolMetaData.getUUID());
- Assert.assertEquals(descMetaData, poolMetaData);
+ assertThat(poolMetaData).isEqualTo(descMetaData);
} catch (Exception e) {
JUnitExtension.handleException(e);
}
diff --git a/uimaj-core/src/test/java/org/apache/uima/pear/util/ComponentCategoryTest.java b/uimaj-core/src/test/java/org/apache/uima/pear/util/ComponentCategoryTest.java
index 652251c..b615d5d 100644
--- a/uimaj-core/src/test/java/org/apache/uima/pear/util/ComponentCategoryTest.java
+++ b/uimaj-core/src/test/java/org/apache/uima/pear/util/ComponentCategoryTest.java
@@ -19,11 +19,12 @@
package org.apache.uima.pear.util;
+import static org.assertj.core.api.Assertions.assertThat;
+
import java.io.File;
import java.io.FileNotFoundException;
import org.apache.uima.test.junit_extension.JUnitExtension;
-import org.junit.Assert;
import org.junit.jupiter.api.Test;
/**
@@ -55,10 +56,11 @@
@Test
public void testAeDescriptor() throws Exception {
File aeDescFile = JUnitExtension.getFile(TEST_FOLDER + "/" + AE_DESC_NAME);
- if (!aeDescFile.isFile())
+ if (!aeDescFile.isFile()) {
throw new FileNotFoundException("AE descriptor not found");
- Assert.assertTrue(UIMAUtil.ANALYSIS_ENGINE_CTG
- .equals(UIMAUtil.identifyUimaComponentCategory(aeDescFile)));
+ }
+ assertThat(UIMAUtil.identifyUimaComponentCategory(aeDescFile))
+ .isEqualTo(UIMAUtil.ANALYSIS_ENGINE_CTG);
}
/**
@@ -67,10 +69,11 @@
@Test
public void testCcDescriptor() throws Exception {
File ccDescFile = JUnitExtension.getFile(TEST_FOLDER + "/" + CC_DESC_NAME);
- if (!ccDescFile.isFile())
+ if (!ccDescFile.isFile()) {
throw new FileNotFoundException("CC descriptor not found");
- Assert.assertTrue(
- UIMAUtil.CAS_CONSUMER_CTG.equals(UIMAUtil.identifyUimaComponentCategory(ccDescFile)));
+ }
+ assertThat(UIMAUtil.identifyUimaComponentCategory(ccDescFile))
+ .isEqualTo(UIMAUtil.CAS_CONSUMER_CTG);
}
/**
@@ -79,10 +82,11 @@
@Test
public void testCiDescriptor() throws Exception {
File ciDescFile = JUnitExtension.getFile(TEST_FOLDER + "/" + CI_DESC_NAME);
- if (!ciDescFile.isFile())
+ if (!ciDescFile.isFile()) {
throw new FileNotFoundException("CI descriptor not found");
- Assert.assertTrue(UIMAUtil.CAS_INITIALIZER_CTG
- .equals(UIMAUtil.identifyUimaComponentCategory(ciDescFile)));
+ }
+ assertThat(UIMAUtil.identifyUimaComponentCategory(ciDescFile))
+ .isEqualTo(UIMAUtil.CAS_INITIALIZER_CTG);
}
/**
@@ -91,10 +95,11 @@
@Test
public void testCrDescriptor() throws Exception {
File crDescFile = JUnitExtension.getFile(TEST_FOLDER + "/" + CR_DESC_NAME);
- if (!crDescFile.isFile())
+ if (!crDescFile.isFile()) {
throw new FileNotFoundException("CR descriptor not found");
- Assert.assertTrue(UIMAUtil.COLLECTION_READER_CTG
- .equals(UIMAUtil.identifyUimaComponentCategory(crDescFile)));
+ }
+ assertThat(UIMAUtil.identifyUimaComponentCategory(crDescFile))
+ .isEqualTo(UIMAUtil.identifyUimaComponentCategory(crDescFile));
}
/**
@@ -103,9 +108,10 @@
@Test
public void testTsDescriptor() throws Exception {
File tsDescFile = JUnitExtension.getFile(TEST_FOLDER + "/" + TS_DESC_NAME);
- if (!tsDescFile.isFile())
+ if (!tsDescFile.isFile()) {
throw new FileNotFoundException("TS descriptor not found");
- Assert.assertTrue(
- UIMAUtil.TYPE_SYSTEM_CTG.equals(UIMAUtil.identifyUimaComponentCategory(tsDescFile)));
+ }
+ assertThat(UIMAUtil.identifyUimaComponentCategory(tsDescFile))
+ .isEqualTo(UIMAUtil.TYPE_SYSTEM_CTG);
}
}
diff --git a/uimaj-core/src/test/java/org/apache/uima/pear/util/PearEncodingTest.java b/uimaj-core/src/test/java/org/apache/uima/pear/util/PearEncodingTest.java
index d0c69b5..640d733 100644
--- a/uimaj-core/src/test/java/org/apache/uima/pear/util/PearEncodingTest.java
+++ b/uimaj-core/src/test/java/org/apache/uima/pear/util/PearEncodingTest.java
@@ -19,10 +19,11 @@
package org.apache.uima.pear.util;
+import static org.assertj.core.api.Assertions.assertThat;
+
import java.io.File;
import org.apache.uima.test.junit_extension.JUnitExtension;
-import org.junit.Assert;
import org.junit.jupiter.api.Test;
/**
@@ -41,7 +42,7 @@
// normalize encoding
encoding = encoding.toUpperCase();
- Assert.assertTrue(encoding.equals("UTF-8"));
+ assertThat(encoding.equals("UTF-8")).isTrue();
}
@Test
@@ -61,7 +62,7 @@
// normalize encoding
encoding = encoding.toUpperCase();
- Assert.assertTrue(encoding.equals("UTF-8"));
+ assertThat(encoding.equals("UTF-8")).isTrue();
}
@Test
@@ -77,7 +78,7 @@
// normalize encoding
encoding = encoding.toUpperCase();
- Assert.assertTrue(encoding.equals("UTF-16LE"));
+ assertThat(encoding.equals("UTF-16LE")).isTrue();
}
@Test
@@ -97,6 +98,6 @@
// normalize encoding
encoding = encoding.toUpperCase();
- Assert.assertTrue(encoding.equals("UTF-16"));
+ assertThat(encoding.equals("UTF-16")).isTrue();
}
}
diff --git a/uimaj-core/src/test/java/org/apache/uima/pear/util/PearInstallerTest.java b/uimaj-core/src/test/java/org/apache/uima/pear/util/PearInstallerTest.java
index d0f218a..09629b7 100644
--- a/uimaj-core/src/test/java/org/apache/uima/pear/util/PearInstallerTest.java
+++ b/uimaj-core/src/test/java/org/apache/uima/pear/util/PearInstallerTest.java
@@ -19,6 +19,8 @@
package org.apache.uima.pear.util;
+import static org.assertj.core.api.Assertions.assertThat;
+
import java.io.File;
import java.io.FileNotFoundException;
@@ -31,7 +33,6 @@
import org.apache.uima.resource.ResourceSpecifier;
import org.apache.uima.test.junit_extension.JUnitExtension;
import org.apache.uima.util.XMLInputSource;
-import org.junit.Assert;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -56,8 +57,9 @@
File tempFile = File.createTempFile("pear_installer_test_", "tmp");
if (tempFile.delete()) {
File tempDir = tempFile;
- if (tempDir.mkdirs())
+ if (tempDir.mkdirs()) {
this.tempInstallDir = tempDir;
+ }
}
}
@@ -75,30 +77,31 @@
public void testPearInstall() throws Exception {
// check temporary working directory
- if (this.tempInstallDir == null)
+ if (this.tempInstallDir == null) {
throw new FileNotFoundException("temp directory not found");
- // check sample PEAR files
+ // check sample PEAR files
+ }
// get pear file to install
File pearFile = JUnitExtension.getFile("pearTests/DateTime.pear");
- Assert.assertNotNull(pearFile);
+ assertThat(pearFile).isNotNull();
// Install PEAR package
PackageBrowser instPear = PackageInstaller.installPackage(this.tempInstallDir, pearFile, true);
// check pear PackageBrowser object
- Assert.assertNotNull(instPear);
+ assertThat(instPear).isNotNull();
// check PEAR component ID
String componentID = instPear.getInstallationDescriptor().getMainComponentId();
- Assert.assertEquals("uima.example.DateTimeAnnotator", componentID);
+ assertThat(componentID).isEqualTo("uima.example.DateTimeAnnotator");
// check PEAR datapath setting
// pear file contains (uima.datapath = $main_root/my/test/data/path)
File datapath = new File(this.tempInstallDir,
"uima.example.DateTimeAnnotator/my/test/data/path");
File pearDatapath = new File(instPear.getComponentDataPath());
- Assert.assertEquals(datapath, pearDatapath);
+ assertThat(pearDatapath).isEqualTo(datapath);
// Create resouce manager and set PEAR package classpath
ResourceManager rsrcMgr = UIMAFramework.newDefaultResourceManager();
@@ -107,7 +110,7 @@
XMLInputSource in = new XMLInputSource(instPear.getComponentPearDescPath());
ResourceSpecifier specifier = UIMAFramework.getXMLParser().parseResourceSpecifier(in);
AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(specifier, rsrcMgr, null);
- Assert.assertNotNull(ae);
+ assertThat(ae).isNotNull();
// Create a CAS with a sample document text and process the CAS
CAS cas = ae.newCAS();
diff --git a/uimaj-core/src/test/java/org/apache/uima/resource/ConfigurableResource_implTest.java b/uimaj-core/src/test/java/org/apache/uima/resource/ConfigurableResource_implTest.java
index 85f0613..be76991 100644
--- a/uimaj-core/src/test/java/org/apache/uima/resource/ConfigurableResource_implTest.java
+++ b/uimaj-core/src/test/java/org/apache/uima/resource/ConfigurableResource_implTest.java
@@ -40,7 +40,6 @@
import org.apache.uima.resource.metadata.impl.XmlizationInfo;
import org.apache.uima.test.junit_extension.JUnitExtension;
import org.apache.uima.util.XMLInputSource;
-import org.junit.Assert;
import org.junit.jupiter.api.Test;
public class ConfigurableResource_implTest {
@@ -231,7 +230,7 @@
String[] paramsInGrp = grpParamNames[i];
for (int j = 0; j < paramsInGrp.length; j++) {
Object val = testResource2.getConfigParameterValue(groupNames[i], paramsInGrp[j]);
- Assert.assertEquals(val, grpValues[i][j]);
+ assertThat(grpValues[i][j]).isEqualTo(val);
}
}
}
@@ -250,7 +249,7 @@
// test default fallback
String str3 = (String) test.getConfigParameterValue("StringParam");
- Assert.assertEquals("en", str3);
+ assertThat(str3).isEqualTo("en");
// The below was commented out because it has a dependency on the jedii_cpe_impl module
// //XMLInputSource in = new
diff --git a/uimaj-core/src/test/java/org/apache/uima/resource/impl/DataResource_implTest.java b/uimaj-core/src/test/java/org/apache/uima/resource/impl/DataResource_implTest.java
index e83d588..0960beb 100644
--- a/uimaj-core/src/test/java/org/apache/uima/resource/impl/DataResource_implTest.java
+++ b/uimaj-core/src/test/java/org/apache/uima/resource/impl/DataResource_implTest.java
@@ -19,6 +19,8 @@
package org.apache.uima.resource.impl;
+import static org.assertj.core.api.Assertions.assertThat;
+
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStream;
@@ -29,7 +31,6 @@
import org.apache.uima.resource.ResourceInitializationException;
import org.apache.uima.test.junit_extension.JUnitExtension;
-import org.junit.Assert;
import org.junit.jupiter.api.Test;
/**
@@ -54,8 +55,8 @@
dr.initialize(spec, Collections.EMPTY_MAP);
// test
- Assert.assertEquals(new URL(fileUrl), dr.getUrl());
- Assert.assertEquals(new File(localCacheFile), dr.getLocalCache());
+ assertThat(dr.getUrl()).isEqualTo(new URL(fileUrl));
+ assertThat(dr.getLocalCache()).isEqualTo(new File(localCacheFile));
// test failure for nonexistent data
ResourceInitializationException ex = null;
@@ -67,7 +68,7 @@
} catch (ResourceInitializationException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
} catch (Exception e) {
JUnitExtension.handleException(e);
}
@@ -97,7 +98,7 @@
String result = bufRdr.readLine();
inStr.close();
- Assert.assertEquals(testString, result);
+ assertThat(result).isEqualTo(testString);
} catch (Exception e) {
JUnitExtension.handleException(e);
}
diff --git a/uimaj-core/src/test/java/org/apache/uima/resource/impl/FileLanguageResource_implTest.java b/uimaj-core/src/test/java/org/apache/uima/resource/impl/FileLanguageResource_implTest.java
index 3d874c9..663d59e 100644
--- a/uimaj-core/src/test/java/org/apache/uima/resource/impl/FileLanguageResource_implTest.java
+++ b/uimaj-core/src/test/java/org/apache/uima/resource/impl/FileLanguageResource_implTest.java
@@ -19,6 +19,8 @@
package org.apache.uima.resource.impl;
+import static org.assertj.core.api.Assertions.assertThat;
+
import java.io.File;
import java.util.Collections;
@@ -26,7 +28,6 @@
import org.apache.uima.resource.FileLanguageResourceSpecifier;
import org.apache.uima.resource.ResourceInitializationException;
import org.apache.uima.test.junit_extension.JUnitExtension;
-import org.junit.Assert;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -58,12 +59,12 @@
DataResource deResource = mResource.getDataResource(new String[] { "de" });
DataResource enusResource = mResource.getDataResource(new String[] { "en-US" });
- Assert.assertNotNull(enResource);
- Assert.assertNotNull(deResource);
- Assert.assertNotNull(enusResource);
- Assert.assertFalse(enResource.equals(deResource));
- Assert.assertTrue(enResource.equals(enusResource));
- Assert.assertEquals(enResource.hashCode(), enusResource.hashCode());
+ assertThat(enResource).isNotNull();
+ assertThat(deResource).isNotNull();
+ assertThat(enusResource).isNotNull();
+ assertThat(enResource.equals(deResource)).isFalse();
+ assertThat(enResource.equals(enusResource)).isTrue();
+ assertThat(enusResource.hashCode()).isEqualTo(enResource.hashCode());
ResourceInitializationException ex = null;
try {
@@ -71,7 +72,7 @@
} catch (ResourceInitializationException e) {
ex = e;
}
- Assert.assertNotNull(ex);
+ assertThat(ex).isNotNull();
} catch (Exception e) {
JUnitExtension.handleException(e);
}
diff --git a/uimaj-core/src/test/java/org/apache/uima/resource/impl/RelativePathResolver_implTest.java b/uimaj-core/src/test/java/org/apache/uima/resource/impl/RelativePathResolver_implTest.java
index c099fef..f94f33a 100644
--- a/uimaj-core/src/test/java/org/apache/uima/resource/impl/RelativePathResolver_implTest.java
+++ b/uimaj-core/src/test/java/org/apache/uima/resource/impl/RelativePathResolver_implTest.java
@@ -25,10 +25,8 @@
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
-import java.util.Arrays;
import java.util.stream.Stream;
-import org.apache.commons.io.FilenameUtils;
import org.apache.uima.test.junit_extension.JUnitExtension;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
diff --git a/uimaj-core/src/test/java/org/apache/uima/resource/impl/ResourceManager_implTest.java b/uimaj-core/src/test/java/org/apache/uima/resource/impl/ResourceManager_implTest.java
index 2aa2150..f0b6e56 100644
--- a/uimaj-core/src/test/java/org/apache/uima/resource/impl/ResourceManager_implTest.java
+++ b/uimaj-core/src/test/java/org/apache/uima/resource/impl/ResourceManager_implTest.java
@@ -19,6 +19,7 @@
package org.apache.uima.resource.impl;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.junit.Assert.assertTrue;
@@ -39,7 +40,6 @@
import org.apache.uima.resource.metadata.impl.ResourceManagerConfiguration_impl;
import org.apache.uima.test.junit_extension.JUnitExtension;
import org.apache.uima.util.XMLInputSource;
-import org.junit.Assert;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -155,7 +155,7 @@
try {
String path = "c:\\this\\path\\is;for\\windows";
mManager.setDataPath(path);
- Assert.assertEquals(path, mManager.getDataPath());
+ assertThat(mManager.getDataPath()).isEqualTo(path);
} catch (Exception e) {
JUnitExtension.handleException(e);
}
@@ -166,40 +166,38 @@
try {
// test retrieval
DataResource r1 = (DataResource) mManager.getResource(TEST_CONTEXT_NAME + "myDataKey");
- Assert.assertEquals(TEST_DATA_FILE.toURL(), r1.getUrl());
+ assertThat(r1.getUrl()).isEqualTo(TEST_DATA_FILE.toURL());
TestResourceInterface r2 = (TestResourceInterface) mManager
.getResource(TEST_CONTEXT_NAME + "myCustomObjectKey");
- Assert.assertEquals(TEST_STRING, r2.readString());
+ assertThat(r2.readString()).isEqualTo(TEST_STRING);
DataResource en_r = (DataResource) mManager
.getResource(TEST_CONTEXT_NAME + "myLanguageResourceKey", new String[] { "en" });
- Assert.assertTrue(
- en_r.getUrl().toString().endsWith("FileLanguageResource_implTest_data_en.dat"));
+ assertThat(en_r.getUrl().toString()).endsWith("FileLanguageResource_implTest_data_en.dat");
DataResource de_r = (DataResource) mManager
.getResource(TEST_CONTEXT_NAME + "myLanguageResourceKey", new String[] { "de" });
- Assert.assertTrue(
- de_r.getUrl().toString().endsWith("FileLanguageResource_implTest_data_de.dat"));
+ assertThat(de_r.getUrl().toString()).endsWith("FileLanguageResource_implTest_data_de.dat");
// this should get the exact same DataResource object as for the "en" param
DataResource enus_r = (DataResource) mManager
.getResource(TEST_CONTEXT_NAME + "myLanguageResourceKey", new String[] { "en-US" });
- Assert.assertTrue(en_r == enus_r);
+ assertThat(en_r == enus_r).isTrue();
TestResourceInterface en_obj = (TestResourceInterface) mManager.getResource(
TEST_CONTEXT_NAME + "myLanguageResourceObjectKey", new String[] { "en" });
- Assert.assertEquals("English", en_obj.readString());
+ assertThat(en_obj.readString()).isEqualTo("English");
// test spaces in datapath
DataResource r3 = (DataResource) mManager
.getResource(TEST_CONTEXT_NAME + "myResourceWithSpaceInPathKey");
URL expectedBaseUrl = new File(TEST_DATAPATH_WITH_SPACES).toURL();
URL expectedUrl = new URL(expectedBaseUrl, TEST_FILE_IN_DATAPATH);
- Assert.assertEquals(expectedUrl, r3.getUrl());
+ assertThat(r3.getUrl()).isEqualTo(expectedUrl);
URI expectedBaseUri = new File(TEST_DATAPATH_WITH_SPACES).toURI();
URI expectedUri = expectedBaseUri.resolve("Test.dat");
- Assert.assertEquals(expectedUri, r3.getUri());
+ assertThat(r3.getUri()).isEqualTo(expectedUri);
mManager.destroy();
boolean caught = false;
diff --git a/uimaj-core/src/test/java/org/apache/uima/resource/metadata/impl/ConfigurationParameterDeclarations_implTest.java b/uimaj-core/src/test/java/org/apache/uima/resource/metadata/impl/ConfigurationParameterDeclarations_implTest.java
index c366c7c..36e375b 100644
--- a/uimaj-core/src/test/java/org/apache/uima/resource/metadata/impl/ConfigurationParameterDeclarations_implTest.java
+++ b/uimaj-core/src/test/java/org/apache/uima/resource/metadata/impl/ConfigurationParameterDeclarations_implTest.java
@@ -19,6 +19,8 @@
package org.apache.uima.resource.metadata.impl;
+import static org.assertj.core.api.Assertions.assertThat;
+
import java.io.FileInputStream;
import java.io.InputStream;
@@ -27,7 +29,6 @@
import org.apache.uima.UIMAFramework;
import org.apache.uima.test.junit_extension.JUnitExtension;
-import org.junit.Assert;
import org.junit.jupiter.api.Test;
import org.w3c.dom.Document;
@@ -45,7 +46,6 @@
ConfigurationParameterDeclarations_impl obj = new ConfigurationParameterDeclarations_impl();
obj.buildFromXMLElement(doc.getDocumentElement(), UIMAFramework.getXMLParser());
- Assert.assertEquals(1, obj.getConfigurationGroups().length);
+ assertThat(obj.getConfigurationGroups()).hasSize(1);
}
-
}
diff --git a/uimaj-core/src/test/java/org/apache/uima/resource/metadata/impl/MetaDataObject_implTest.java b/uimaj-core/src/test/java/org/apache/uima/resource/metadata/impl/MetaDataObject_implTest.java
index ae38bee..2e7f2d2 100644
--- a/uimaj-core/src/test/java/org/apache/uima/resource/metadata/impl/MetaDataObject_implTest.java
+++ b/uimaj-core/src/test/java/org/apache/uima/resource/metadata/impl/MetaDataObject_implTest.java
@@ -39,7 +39,6 @@
import org.apache.uima.resource.metadata.NameValuePair;
import org.apache.uima.util.XMLParser;
import org.apache.uima.util.XMLizable;
-import org.junit.Assert;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.w3c.dom.Document;
@@ -101,9 +100,9 @@
// HashSet<NameClassPair> orangeAttrs = new HashSet<NameClassPair>(orange.listAttributes());
// HashSet<NameClassPair> bagAttrs = new HashSet<NameClassPair>(fruitBag.listAttributes());
//
- // Assert.assertEquals(TestFruitObject.getAttributeSet(), apple1Attrs);
- // Assert.assertEquals(TestFruitObject.getAttributeSet(), orangeAttrs);
- // Assert.assertEquals(TestFruitBagObject.getAttributeSet(), bagAttrs);
+ // assertThat(apple1Attrs).isEqualTo(TestFruitObject.getAttributeSet());
+ // assertThat(orangeAttrs).isEqualTo(TestFruitObject.getAttributeSet());
+ // assertThat(bagAttrs).isEqualTo(TestFruitBagObject.getAttributeSet());
// } catch (RuntimeException e) {
// JUnitExtension.handleException(e);
// }
@@ -213,10 +212,10 @@
newFruitBag.buildFromXMLElement(fruitBagXmlDoc.getDocumentElement(), xmlp);
// new objects should be equal to the originals
- Assert.assertEquals(apple1, newApple1);
- Assert.assertEquals(apple2, newApple2);
- Assert.assertEquals(orange, newOrange);
- Assert.assertTrue(fruitBag.equals(newFruitBag));
+ assertThat(newApple1).isEqualTo(apple1);
+ assertThat(newApple2).isEqualTo(apple2);
+ assertThat(newOrange).isEqualTo(orange);
+ assertThat(fruitBag.equals(newFruitBag)).isTrue();
// test special cases
@@ -227,17 +226,17 @@
TestFruitBagObject bag = new TestFruitBagObject();
bag.buildFromXMLElement(xmlDoc.getDocumentElement(), xmlp);
TestFruitObject[] fruits = bag.getFruits();
- Assert.assertEquals(2, fruits.length);
- Assert.assertEquals("banana", fruits[0].getName());
- Assert.assertEquals("raspberry", fruits[1].getName());
+ assertThat(fruits.length).isEqualTo(2);
+ assertThat(fruits[0].getName()).isEqualTo("banana");
+ assertThat(fruits[1].getName()).isEqualTo("raspberry");
// property name omitted but can be inferred from type of value
xmlStr = "<fruit><name>banana</name><string>yellow</string></fruit>";
xmlDoc = docBuilder.parse(new ByteArrayInputStream(xmlStr.getBytes()));
TestFruitObject banana = new TestFruitObject();
banana.buildFromXMLElement(xmlDoc.getDocumentElement(), xmlp);
- Assert.assertEquals("yellow", banana.getColor());
- Assert.assertEquals("banana", banana.getName());
+ assertThat(banana.getColor()).isEqualTo("yellow");
+ assertThat(banana.getName()).isEqualTo("banana");
// env var reference
xmlStr = "<fruit><name>raspberry</name><string><envVarRef>test.raspberry.color</envVarRef></string></fruit>";
@@ -245,8 +244,8 @@
xmlDoc = docBuilder.parse(new ByteArrayInputStream(xmlStr.getBytes()));
TestFruitObject raspberry = new TestFruitObject();
raspberry.buildFromXMLElement(xmlDoc.getDocumentElement(), xmlp);
- Assert.assertEquals("red", raspberry.getColor());
- Assert.assertEquals("raspberry", raspberry.getName());
+ assertThat(raspberry.getColor()).isEqualTo("red");
+ assertThat(raspberry.getName()).isEqualTo("raspberry");
}
@Test
diff --git a/uimaj-core/src/test/java/org/apache/uima/resource/service/impl/ResourceServiceAdapter_implTest.java b/uimaj-core/src/test/java/org/apache/uima/resource/service/impl/ResourceServiceAdapter_implTest.java
index ec76220..6a64712 100644
--- a/uimaj-core/src/test/java/org/apache/uima/resource/service/impl/ResourceServiceAdapter_implTest.java
+++ b/uimaj-core/src/test/java/org/apache/uima/resource/service/impl/ResourceServiceAdapter_implTest.java
@@ -19,6 +19,8 @@
package org.apache.uima.resource.service.impl;
+import static org.assertj.core.api.Assertions.assertThat;
+
import java.util.Map;
import org.apache.uima.resource.ResourceSpecifier;
@@ -27,7 +29,6 @@
import org.apache.uima.resource.metadata.impl.ConfigurationParameter_impl;
import org.apache.uima.resource.metadata.impl.ResourceMetaData_impl;
import org.apache.uima.test.junit_extension.JUnitExtension;
-import org.junit.Assert;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -68,8 +69,8 @@
mServiceStub.getMetaDataReturnValue = md;
ResourceMetaData result = mAdapter.getMetaData();
- Assert.assertEquals("callGetMetaData", mServiceStub.lastMethodName);
- Assert.assertEquals(md, result);
+ assertThat(mServiceStub.lastMethodName).isEqualTo("callGetMetaData");
+ assertThat(result).isEqualTo(md);
} catch (Exception e) {
JUnitExtension.handleException(e);
}
diff --git a/uimaj-core/src/test/java/org/apache/uima/resource/service/impl/ResourceService_implTest.java b/uimaj-core/src/test/java/org/apache/uima/resource/service/impl/ResourceService_implTest.java
index f61b309..a0cf593 100644
--- a/uimaj-core/src/test/java/org/apache/uima/resource/service/impl/ResourceService_implTest.java
+++ b/uimaj-core/src/test/java/org/apache/uima/resource/service/impl/ResourceService_implTest.java
@@ -19,13 +19,14 @@
package org.apache.uima.resource.service.impl;
+import static org.assertj.core.api.Assertions.assertThat;
+
import org.apache.uima.analysis_engine.AnalysisEngineDescription;
import org.apache.uima.analysis_engine.impl.AnalysisEngineDescription_impl;
import org.apache.uima.resource.metadata.ConfigurationParameter;
import org.apache.uima.resource.metadata.ResourceMetaData;
import org.apache.uima.resource.metadata.impl.ConfigurationParameter_impl;
import org.apache.uima.test.junit_extension.JUnitExtension;
-import org.junit.Assert;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -61,9 +62,9 @@
public void testGetMetaData() throws Exception {
try {
ResourceMetaData md = service.getMetaData();
- Assert.assertNotNull(md);
- Assert.assertEquals("Test Annotator", md.getName());
- Assert.assertNotNull(md.getUUID());
+ assertThat(md).isNotNull();
+ assertThat(md.getName()).isEqualTo("Test Annotator");
+ assertThat(md.getUUID()).isNotNull();
} catch (Exception e) {
JUnitExtension.handleException(e);
}
diff --git a/uimaj-core/src/test/java/org/apache/uima/util/CasCreationUtilsTest.java b/uimaj-core/src/test/java/org/apache/uima/util/CasCreationUtilsTest.java
index c9a76d5..ef7b1ab 100644
--- a/uimaj-core/src/test/java/org/apache/uima/util/CasCreationUtilsTest.java
+++ b/uimaj-core/src/test/java/org/apache/uima/util/CasCreationUtilsTest.java
@@ -19,6 +19,7 @@
package org.apache.uima.util;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
@@ -57,7 +58,6 @@
import org.apache.uima.resource.metadata.impl.TypePriorityList_impl;
import org.apache.uima.resource.metadata.impl.TypeSystemDescription_impl;
import org.apache.uima.test.junit_extension.JUnitExtension;
-import org.junit.Assert;
import org.junit.jupiter.api.Test;
public class CasCreationUtilsTest {
@@ -91,14 +91,14 @@
TypeSystemDescription ts1desc = UIMAFramework.getXMLParser().parseTypeSystemDescription(
new XMLInputSource(JUnitExtension.getFile("CasCreationUtilsTest/TypeSystem1.xml")));
- Assert.assertEquals(1, ts1desc.getType("Type1").getFeatures().length);
- Assert.assertEquals(1, ts1desc.getType("Type2").getFeatures().length);
- Assert.assertEquals(1, ts1desc.getType("Type3").getFeatures().length);
+ assertThat(ts1desc.getType("Type1").getFeatures()).hasSize(1);
+ assertThat(ts1desc.getType("Type2").getFeatures()).hasSize(1);
+ assertThat(ts1desc.getType("Type3").getFeatures()).hasSize(1);
TypeSystemDescription ts2desc = UIMAFramework.getXMLParser().parseTypeSystemDescription(
new XMLInputSource(JUnitExtension.getFile("CasCreationUtilsTest/TypeSystem2.xml")));
- Assert.assertEquals(1, ts2desc.getType("Type1").getFeatures().length);
- Assert.assertEquals(1, ts2desc.getType("Type2").getFeatures().length);
+ assertThat(ts2desc.getType("Type1").getFeatures()).hasSize(1);
+ assertThat(ts2desc.getType("Type2").getFeatures()).hasSize(1);
ArrayList<TypeSystemDescription> tsList = new ArrayList<>();
tsList.add(ts1desc);
@@ -107,9 +107,9 @@
TypeSystemDescription merged = CasCreationUtils.mergeTypeSystems(tsList,
UIMAFramework.newDefaultResourceManager(), typesWithMergedFeatures);
- Assert.assertEquals(2, merged.getType("Type1").getFeatures().length);
- Assert.assertEquals(2, merged.getType("Type2").getFeatures().length);
- Assert.assertEquals(1, merged.getType("Type3").getFeatures().length);
+ assertThat(merged.getType("Type1").getFeatures()).hasSize(2);
+ assertThat(merged.getType("Type2").getFeatures()).hasSize(2);
+ assertThat(merged.getType("Type3").getFeatures()).hasSize(1);
assertEquals(2, typesWithMergedFeatures.size());
assertTrue(typesWithMergedFeatures.containsKey("Type1"));
@@ -287,47 +287,47 @@
UIMAFramework.newDefaultResourceManager(), mergedTypes);
// test results of merge
- Assert.assertEquals(8, typeSys.getTypes().length);
+ assertThat(typeSys.getTypes()).hasSize(8);
TypeDescription type0 = typeSys.getType("NamedEntity");
- Assert.assertNotNull(type0);
- Assert.assertEquals("uima.tcas.Annotation", type0.getSupertypeName());
- Assert.assertEquals(1, type0.getFeatures().length);
+ assertThat(type0).isNotNull();
+ assertThat(type0.getSupertypeName()).isEqualTo("uima.tcas.Annotation");
+ assertThat(type0.getFeatures()).hasSize(1);
TypeDescription type1 = typeSys.getType("Person");
- Assert.assertNotNull(type1);
- Assert.assertEquals("NamedEntity", type1.getSupertypeName());
- Assert.assertEquals(1, type1.getFeatures().length);
+ assertThat(type1).isNotNull();
+ assertThat(type1.getSupertypeName()).isEqualTo("NamedEntity");
+ assertThat(type1.getFeatures()).hasSize(1);
TypeDescription type2 = typeSys.getType("Place");
- Assert.assertNotNull(type2);
- Assert.assertEquals("NamedEntity", type2.getSupertypeName());
- Assert.assertEquals(3, type2.getFeatures().length);
+ assertThat(type2).isNotNull();
+ assertThat(type2.getSupertypeName()).isEqualTo("NamedEntity");
+ assertThat(type2.getFeatures()).hasSize(3);
TypeDescription type3 = typeSys.getType("Org");
- Assert.assertNotNull(type3);
- Assert.assertEquals("uima.tcas.Annotation", type3.getSupertypeName());
- Assert.assertEquals(0, type3.getFeatures().length);
+ assertThat(type3).isNotNull();
+ assertThat(type3.getSupertypeName()).isEqualTo("uima.tcas.Annotation");
+ assertThat(type3.getFeatures()).isEmpty();
TypeDescription type4 = typeSys.getType("DocumentStructure");
- Assert.assertNotNull(type4);
- Assert.assertEquals("uima.tcas.Annotation", type4.getSupertypeName());
- Assert.assertEquals(0, type4.getFeatures().length);
+ assertThat(type4).isNotNull();
+ assertThat(type4.getSupertypeName()).isEqualTo("uima.tcas.Annotation");
+ assertThat(type4.getFeatures()).isEmpty();
TypeDescription type5 = typeSys.getType("Paragraph");
- Assert.assertNotNull(type5);
- Assert.assertEquals("DocumentStructure", type5.getSupertypeName());
- Assert.assertEquals(0, type5.getFeatures().length);
+ assertThat(type5).isNotNull();
+ assertThat(type5.getSupertypeName()).isEqualTo("DocumentStructure");
+ assertThat(type5.getFeatures()).isEmpty();
TypeDescription type6 = typeSys.getType("Sentence");
- Assert.assertNotNull(type6);
- Assert.assertEquals("DocumentStructure", type6.getSupertypeName());
- Assert.assertEquals(0, type6.getFeatures().length);
+ assertThat(type6).isNotNull();
+ assertThat(type6.getSupertypeName()).isEqualTo("DocumentStructure");
+ assertThat(type6.getFeatures()).isEmpty();
TypeDescription type7 = typeSys.getType("test.flowController.Test");
- Assert.assertNotNull(type7);
- Assert.assertEquals("uima.tcas.Annotation", type7.getSupertypeName());
- Assert.assertEquals(1, type7.getFeatures().length);
+ assertThat(type7).isNotNull();
+ assertThat(type7.getSupertypeName()).isEqualTo("uima.tcas.Annotation");
+ assertThat(type7.getFeatures()).hasSize(1);
// Place has merged features, Person has different supertype
assertEquals(2, mergedTypes.size());
@@ -352,16 +352,16 @@
TypePriorities pri = CasCreationUtils.mergeDelegateAnalysisEngineTypePriorities(desc);
// test results of merge
- Assert.assertNotNull(pri);
+ assertThat(pri).isNotNull();
TypePriorityList[] priLists = pri.getPriorityLists();
- Assert.assertEquals(3, priLists.length);
+ assertThat(priLists).hasSize(3);
String[] list0 = priLists[0].getTypes();
String[] list1 = priLists[1].getTypes();
String[] list2 = priLists[2].getTypes();
// order of the three lists is not defined
- Assert.assertTrue((list0.length == 2 && list1.length == 2 && list2.length == 3)
+ assertThat((list0.length == 2 && list1.length == 2 && list2.length == 3)
|| (list0.length == 2 && list1.length == 3 && list2.length == 2)
- || (list0.length == 3 && list1.length == 2 && list2.length == 2));
+ || (list0.length == 3 && list1.length == 2 && list2.length == 2)).isTrue();
} catch (Exception e) {
JUnitExtension.handleException(e);
@@ -380,18 +380,18 @@
// test results of merge
FsIndexDescription[] indexes = indexColl.getFsIndexes();
- Assert.assertEquals(3, indexes.length);
+ assertThat(indexes).hasSize(3);
// order of indexes is not defined
String label0 = indexes[0].getLabel();
String label1 = indexes[1].getLabel();
String label2 = indexes[2].getLabel();
- Assert.assertTrue(label0.equals("DocStructIndex") || label1.equals("DocStructIndex")
- || label2.equals("DocStructIndex"));
- Assert.assertTrue(label0.equals("PlaceIndex") || label1.equals("PlaceIndex")
- || label2.equals("PlaceIndex"));
- Assert.assertTrue(
+ assertThat(label0.equals("DocStructIndex") || label1.equals("DocStructIndex")
+ || label2.equals("DocStructIndex")).isTrue();
+ assertThat(label0.equals("PlaceIndex") || label1.equals("PlaceIndex")
+ || label2.equals("PlaceIndex")).isTrue();
+ assertThat(
label0.equals("FlowControllerTestIndex") || label1.equals("FlowControllerTestIndex")
- || label2.equals("FlowControllerTestIndex"));
+ || label2.equals("FlowControllerTestIndex")).isTrue();
} catch (Exception e) {
JUnitExtension.handleException(e);
}
@@ -587,47 +587,47 @@
// test results of merge
// Type System
- Assert.assertEquals(8, typeSys.getTypes().length);
+ assertThat(typeSys.getTypes()).hasSize(8);
TypeDescription type0 = typeSys.getType("NamedEntity");
- Assert.assertNotNull(type0);
- Assert.assertEquals("uima.tcas.Annotation", type0.getSupertypeName());
- Assert.assertEquals(1, type0.getFeatures().length);
+ assertThat(type0).isNotNull();
+ assertThat(type0.getSupertypeName()).isEqualTo("uima.tcas.Annotation");
+ assertThat(type0.getFeatures()).hasSize(1);
TypeDescription type1 = typeSys.getType("Person");
- Assert.assertNotNull(type1);
- Assert.assertEquals("NamedEntity", type1.getSupertypeName());
- Assert.assertEquals(1, type1.getFeatures().length);
+ assertThat(type1).isNotNull();
+ assertThat(type1.getSupertypeName()).isEqualTo("NamedEntity");
+ assertThat(type1.getFeatures()).hasSize(1);
TypeDescription type2 = typeSys.getType("Place");
- Assert.assertNotNull(type2);
- Assert.assertEquals("NamedEntity", type2.getSupertypeName());
- Assert.assertEquals(3, type2.getFeatures().length);
+ assertThat(type2).isNotNull();
+ assertThat(type2.getSupertypeName()).isEqualTo("NamedEntity");
+ assertThat(type2.getFeatures()).hasSize(3);
TypeDescription type3 = typeSys.getType("Org");
- Assert.assertNotNull(type3);
- Assert.assertEquals("uima.tcas.Annotation", type3.getSupertypeName());
- Assert.assertEquals(0, type3.getFeatures().length);
+ assertThat(type3).isNotNull();
+ assertThat(type3.getSupertypeName()).isEqualTo("uima.tcas.Annotation");
+ assertThat(type3.getFeatures()).isEmpty();
TypeDescription type4 = typeSys.getType("DocumentStructure");
- Assert.assertNotNull(type4);
- Assert.assertEquals("uima.tcas.Annotation", type4.getSupertypeName());
- Assert.assertEquals(0, type4.getFeatures().length);
+ assertThat(type4).isNotNull();
+ assertThat(type4.getSupertypeName()).isEqualTo("uima.tcas.Annotation");
+ assertThat(type4.getFeatures()).isEmpty();
TypeDescription type5 = typeSys.getType("Paragraph");
- Assert.assertNotNull(type5);
- Assert.assertEquals("DocumentStructure", type5.getSupertypeName());
- Assert.assertEquals(0, type5.getFeatures().length);
+ assertThat(type5).isNotNull();
+ assertThat(type5.getSupertypeName()).isEqualTo("DocumentStructure");
+ assertThat(type5.getFeatures()).isEmpty();
TypeDescription type6 = typeSys.getType("Sentence");
- Assert.assertNotNull(type6);
- Assert.assertEquals("DocumentStructure", type6.getSupertypeName());
- Assert.assertEquals(0, type6.getFeatures().length);
+ assertThat(type6).isNotNull();
+ assertThat(type6.getSupertypeName()).isEqualTo("DocumentStructure");
+ assertThat(type6.getFeatures()).isEmpty();
TypeDescription type7 = typeSys.getType("test.flowController.Test");
- Assert.assertNotNull(type7);
- Assert.assertEquals("uima.tcas.Annotation", type7.getSupertypeName());
- Assert.assertEquals(1, type7.getFeatures().length);
+ assertThat(type7).isNotNull();
+ assertThat(type7.getSupertypeName()).isEqualTo("uima.tcas.Annotation");
+ assertThat(type7.getFeatures()).hasSize(1);
// Place has merged features, Person has different supertype
assertEquals(2, mergedTypes.size());
@@ -635,31 +635,31 @@
assertTrue(mergedTypes.containsKey("Person"));
// Type Priorities
- Assert.assertNotNull(pri);
+ assertThat(pri).isNotNull();
TypePriorityList[] priLists = pri.getPriorityLists();
- Assert.assertEquals(3, priLists.length);
+ assertThat(priLists).hasSize(3);
String[] list0 = priLists[0].getTypes();
String[] list1 = priLists[1].getTypes();
String[] list2 = priLists[2].getTypes();
// order of the three lists is not defined
- Assert.assertTrue((list0.length == 2 && list1.length == 2 && list2.length == 3)
+ assertThat((list0.length == 2 && list1.length == 2 && list2.length == 3)
|| (list0.length == 2 && list1.length == 3 && list2.length == 2)
- || (list0.length == 3 && list1.length == 2 && list2.length == 2));
+ || (list0.length == 3 && list1.length == 2 && list2.length == 2)).isTrue();
// Indexes
FsIndexDescription[] indexes = indexColl.getFsIndexes();
- Assert.assertEquals(3, indexes.length);
+ assertThat(indexes).hasSize(3);
// order of indexes is not defined
String label0 = indexes[0].getLabel();
String label1 = indexes[1].getLabel();
String label2 = indexes[2].getLabel();
- Assert.assertTrue(label0.equals("DocStructIndex") || label1.equals("DocStructIndex")
- || label2.equals("DocStructIndex"));
- Assert.assertTrue(label0.equals("PlaceIndex") || label1.equals("PlaceIndex")
- || label2.equals("PlaceIndex"));
- Assert.assertTrue(
+ assertThat(label0.equals("DocStructIndex") || label1.equals("DocStructIndex")
+ || label2.equals("DocStructIndex")).isTrue();
+ assertThat(label0.equals("PlaceIndex") || label1.equals("PlaceIndex")
+ || label2.equals("PlaceIndex")).isTrue();
+ assertThat(
label0.equals("FlowControllerTestIndex") || label1.equals("FlowControllerTestIndex")
- || label2.equals("FlowControllerTestIndex"));
+ || label2.equals("FlowControllerTestIndex")).isTrue();
// Now test case where aggregate contains a remote, and we want to do the
// merge of the non-remote delegates and report the failure. (This example
diff --git a/uimaj-core/src/test/java/org/apache/uima/util/CasIOUtilsTest.java b/uimaj-core/src/test/java/org/apache/uima/util/CasIOUtilsTest.java
index d386b1c..d08695c 100644
--- a/uimaj-core/src/test/java/org/apache/uima/util/CasIOUtilsTest.java
+++ b/uimaj-core/src/test/java/org/apache/uima/util/CasIOUtilsTest.java
@@ -21,6 +21,7 @@
import static java.util.Arrays.asList;
import static org.apache.uima.cas.SerialFormat.COMPRESSED_FILTERED_TSI;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.fail;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -50,7 +51,6 @@
import org.apache.uima.resource.metadata.TypeSystemDescription;
import org.apache.uima.resource.metadata.impl.TypePriorities_impl;
import org.apache.uima.test.junit_extension.JUnitExtension;
-import org.junit.Assert;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -216,16 +216,15 @@
SerialFormat loadedFormat = CasIOUtils.load(casInputStream, null, casToUse,
leniently ? CasLoadMode.LENIENT : CasLoadMode.DEFAULT);
casInputStream.close();
- Assert.assertEquals(format, loadedFormat);
+ assertThat(loadedFormat).isEqualTo(format);
assertCorrectlyLoaded(casToUse, leniently);
}
private static void assertCorrectlyLoaded(CAS cas, boolean leniently) throws Exception {
// Check if all the annotations are there (mind the file contains FSes that are NOT
// annotations!)
- Assert.assertEquals(
- leniently ? SIMPLE_CAS_DEFAULT_INDEX_SIZE_LENIENT : SIMPLE_CAS_DEFAULT_INDEX_SIZE,
- cas.getAnnotationIndex().size());
+ assertThat(cas.getAnnotationIndex()).hasSize(
+ leniently ? SIMPLE_CAS_DEFAULT_INDEX_SIZE_LENIENT : SIMPLE_CAS_DEFAULT_INDEX_SIZE);
// Count ALL FSes now, including the ones that are not annotations!
List<String> expectedTypes = new ArrayList<>(asList("org.apache.uima.testTypeSystem.Entity",
@@ -253,10 +252,10 @@
}
Collections.sort(fsTypes);
- Assert.assertEquals(
- leniently ? SIMPLE_CAS_ALL_INDEXED_SIZE_LENIENT : SIMPLE_CAS_ALL_INDEXED_SIZE, fsCount);
+ assertThat(fsCount).isEqualTo(
+ leniently ? SIMPLE_CAS_ALL_INDEXED_SIZE_LENIENT : SIMPLE_CAS_ALL_INDEXED_SIZE);
- Assert.assertEquals(expectedTypes, fsTypes);
+ assertThat(fsTypes).isEqualTo(expectedTypes);
}
@Test
@@ -273,13 +272,13 @@
try {
CasIOUtils.load(casInputStream, cas);
} catch (Exception e) {
- Assert.assertTrue(e instanceof CASRuntimeException);
- Assert.assertTrue(((CASRuntimeException) e).getMessageKey()
- .equals("UNRECOGNIZED_SERIALIZED_CAS_FORMAT"));
+ assertThat(e instanceof CASRuntimeException).isTrue();
+ assertThat(((CASRuntimeException) e).getMessageKey()
+ .equals("UNRECOGNIZED_SERIALIZED_CAS_FORMAT")).isTrue();
casInputStream.close();
return;
}
- Assert.fail("An exception should have been thrown for wrong input.");
+ fail("An exception should have been thrown for wrong input.");
}
@Test
@@ -288,10 +287,10 @@
try {
CasIOUtils.save(cas, new FileOutputStream(casFile), SerialFormat.UNKNOWN);
} catch (Exception e) {
- // Assert.assertTrue(e instanceof IllegalArgumentException);
+ // assertThat(e instanceof IllegalArgumentException).isTrue();
return;
}
- Assert.fail("An exception should have been thrown for wrong format.");
+ fail("An exception should have been thrown for wrong format.");
}
@Test
diff --git a/uimaj-core/src/test/java/org/apache/uima/util/LevelTest.java b/uimaj-core/src/test/java/org/apache/uima/util/LevelTest.java
index d43e971..18b9ea8 100644
--- a/uimaj-core/src/test/java/org/apache/uima/util/LevelTest.java
+++ b/uimaj-core/src/test/java/org/apache/uima/util/LevelTest.java
@@ -19,7 +19,8 @@
package org.apache.uima.util;
-import org.junit.Assert;
+import static org.assertj.core.api.Assertions.assertThat;
+
import org.junit.jupiter.api.Test;
/**
@@ -32,34 +33,34 @@
Level level = Level.OFF;
// check if level is on
- Assert.assertFalse(level.isOn());
+ assertThat(level.isOn()).isFalse();
// check if level is equal to "OFF"
- Assert.assertTrue(level.equals(Level.OFF));
+ assertThat(level.equals(Level.OFF)).isTrue();
// check if level is not equal to "FINE"
- Assert.assertFalse(level.equals(Level.FINE));
+ assertThat(level.equals(Level.FINE)).isFalse();
// check if level text is "OFF"
- Assert.assertEquals(level.toString(), "OFF");
+ assertThat("OFF").isEqualTo(level.toString());
// check if level value is Integer.MAX_VALUE
- Assert.assertEquals(level.toInteger(), Integer.MAX_VALUE);
+ assertThat(Integer.MAX_VALUE).isEqualTo(level.toInteger());
// check if level is greater or equal to ALL
- Assert.assertFalse(level.isGreaterOrEqual(Level.ALL));
+ assertThat(level.isGreaterOrEqual(Level.ALL)).isFalse();
// check if level is greater or equal to FINEST
- Assert.assertFalse(level.isGreaterOrEqual(Level.FINEST));
+ assertThat(level.isGreaterOrEqual(Level.FINEST)).isFalse();
// check if level is greater or equal to FINER
- Assert.assertFalse(level.isGreaterOrEqual(Level.FINER));
+ assertThat(level.isGreaterOrEqual(Level.FINER)).isFalse();
// check if level is greater or equal to FINE
- Assert.assertFalse(level.isGreaterOrEqual(Level.FINE));
+ assertThat(level.isGreaterOrEqual(Level.FINE)).isFalse();
// check if level is greater or equal to CONFIG
- Assert.assertFalse(level.isGreaterOrEqual(Level.CONFIG));
+ assertThat(level.isGreaterOrEqual(Level.CONFIG)).isFalse();
// check if level is greater or equal to INFO
- Assert.assertFalse(level.isGreaterOrEqual(Level.INFO));
+ assertThat(level.isGreaterOrEqual(Level.INFO)).isFalse();
// check if level is greater or equal to WARNING
- Assert.assertFalse(level.isGreaterOrEqual(Level.WARNING));
+ assertThat(level.isGreaterOrEqual(Level.WARNING)).isFalse();
// check if level is greater or equal to SEVERE
- Assert.assertFalse(level.isGreaterOrEqual(Level.SEVERE));
+ assertThat(level.isGreaterOrEqual(Level.SEVERE)).isFalse();
// check if level is greater or equal to OFF
- Assert.assertTrue(level.isGreaterOrEqual(Level.OFF));
+ assertThat(level.isGreaterOrEqual(Level.OFF)).isTrue();
}
@@ -68,34 +69,34 @@
Level level = Level.ALL;
// check if level is on
- Assert.assertTrue(level.isOn());
+ assertThat(level.isOn()).isTrue();
// check if level is equal to "ALL"
- Assert.assertTrue(level.equals(Level.ALL));
+ assertThat(level.equals(Level.ALL)).isTrue();
// check if level is not equal to "CONFIG"
- Assert.assertFalse(level.equals(Level.CONFIG));
+ assertThat(level.equals(Level.CONFIG)).isFalse();
// check if level text is "ALL"
- Assert.assertEquals(level.toString(), "ALL");
+ assertThat("ALL").isEqualTo(level.toString());
// check if level value is Integer.MIN_VALUE
- Assert.assertEquals(level.toInteger(), Integer.MIN_VALUE);
+ assertThat(Integer.MIN_VALUE).isEqualTo(level.toInteger());
// check if level is greater or equal to ALL
- Assert.assertTrue(level.isGreaterOrEqual(Level.ALL));
+ assertThat(level.isGreaterOrEqual(Level.ALL)).isTrue();
// check if level is greater or equal to FINEST
- Assert.assertTrue(level.isGreaterOrEqual(Level.FINEST));
+ assertThat(level.isGreaterOrEqual(Level.FINEST)).isTrue();
// check if level is greater or equal to FINER
- Assert.assertTrue(level.isGreaterOrEqual(Level.FINER));
+ assertThat(level.isGreaterOrEqual(Level.FINER)).isTrue();
// check if level is greater or equal to FINE
- Assert.assertTrue(level.isGreaterOrEqual(Level.FINE));
+ assertThat(level.isGreaterOrEqual(Level.FINE)).isTrue();
// check if level is greater or equal to CONFIG
- Assert.assertTrue(level.isGreaterOrEqual(Level.CONFIG));
+ assertThat(level.isGreaterOrEqual(Level.CONFIG)).isTrue();
// check if level is greater or equal to INFO
- Assert.assertTrue(level.isGreaterOrEqual(Level.INFO));
+ assertThat(level.isGreaterOrEqual(Level.INFO)).isTrue();
// check if level is greater or equal to WARNING
- Assert.assertTrue(level.isGreaterOrEqual(Level.WARNING));
+ assertThat(level.isGreaterOrEqual(Level.WARNING)).isTrue();
// check if level is greater or equal to SEVERE
- Assert.assertTrue(level.isGreaterOrEqual(Level.SEVERE));
+ assertThat(level.isGreaterOrEqual(Level.SEVERE)).isTrue();
// check if level is greater or equal to OFF
- Assert.assertTrue(level.isGreaterOrEqual(Level.OFF));
+ assertThat(level.isGreaterOrEqual(Level.OFF)).isTrue();
}
@Test
@@ -103,34 +104,34 @@
Level level = Level.FINEST;
// check if level is on
- Assert.assertTrue(level.isOn());
+ assertThat(level.isOn()).isTrue();
// check if level is equal to "FINEST"
- Assert.assertTrue(level.equals(Level.FINEST));
+ assertThat(level.equals(Level.FINEST)).isTrue();
// check if level is not equal to "WARNING"
- Assert.assertFalse(level.equals(Level.WARNING));
+ assertThat(level.equals(Level.WARNING)).isFalse();
// check if level text is "FINEST"
- Assert.assertEquals(level.toString(), "FINEST");
+ assertThat("FINEST").isEqualTo(level.toString());
// check if level value is 10000
- Assert.assertEquals(level.toInteger(), 10000);
+ assertThat(10000).isEqualTo(level.toInteger());
// check if level is greater or equal to ALL
- Assert.assertFalse(level.isGreaterOrEqual(Level.ALL));
+ assertThat(level.isGreaterOrEqual(Level.ALL)).isFalse();
// check if level is greater or equal to FINEST
- Assert.assertTrue(level.isGreaterOrEqual(Level.FINEST));
+ assertThat(level.isGreaterOrEqual(Level.FINEST)).isTrue();
// check if level is greater or equal to FINER
- Assert.assertTrue(level.isGreaterOrEqual(Level.FINER));
+ assertThat(level.isGreaterOrEqual(Level.FINER)).isTrue();
// check if level is greater or equal to FINE
- Assert.assertTrue(level.isGreaterOrEqual(Level.FINE));
+ assertThat(level.isGreaterOrEqual(Level.FINE)).isTrue();
// check if level is greater or equal to CONFIG
- Assert.assertTrue(level.isGreaterOrEqual(Level.CONFIG));
+ assertThat(level.isGreaterOrEqual(Level.CONFIG)).isTrue();
// check if level is greater or equal to INFO
- Assert.assertTrue(level.isGreaterOrEqual(Level.INFO));
+ assertThat(level.isGreaterOrEqual(Level.INFO)).isTrue();
// check if level is greater or equal to WARNING
- Assert.assertTrue(level.isGreaterOrEqual(Level.WARNING));
+ assertThat(level.isGreaterOrEqual(Level.WARNING)).isTrue();
// check if level is greater or equal to SEVERE
- Assert.assertTrue(level.isGreaterOrEqual(Level.SEVERE));
+ assertThat(level.isGreaterOrEqual(Level.SEVERE)).isTrue();
// check if level is greater or equal to OFF
- Assert.assertTrue(level.isGreaterOrEqual(Level.OFF));
+ assertThat(level.isGreaterOrEqual(Level.OFF)).isTrue();
}
@@ -139,34 +140,34 @@
Level level = Level.FINER;
// check if level is on
- Assert.assertTrue(level.isOn());
+ assertThat(level.isOn()).isTrue();
// check if level is equal to "FINER"
- Assert.assertTrue(level.equals(Level.FINER));
+ assertThat(level.equals(Level.FINER)).isTrue();
// check if level is not equal to "WARNING"
- Assert.assertFalse(level.equals(Level.WARNING));
+ assertThat(level.equals(Level.WARNING)).isFalse();
// check if level text is "FINER"
- Assert.assertEquals(level.toString(), "FINER");
+ assertThat("FINER").isEqualTo(level.toString());
// check if level value is 20000
- Assert.assertEquals(level.toInteger(), 20000);
+ assertThat(20000).isEqualTo(level.toInteger());
// check if level is greater or equal to ALL
- Assert.assertFalse(level.isGreaterOrEqual(Level.ALL));
+ assertThat(level.isGreaterOrEqual(Level.ALL)).isFalse();
// check if level is greater or equal to FINEST
- Assert.assertFalse(level.isGreaterOrEqual(Level.FINEST));
+ assertThat(level.isGreaterOrEqual(Level.FINEST)).isFalse();
// check if level is greater or equal to FINER
- Assert.assertTrue(level.isGreaterOrEqual(Level.FINER));
+ assertThat(level.isGreaterOrEqual(Level.FINER)).isTrue();
// check if level is greater or equal to FINE
- Assert.assertTrue(level.isGreaterOrEqual(Level.FINE));
+ assertThat(level.isGreaterOrEqual(Level.FINE)).isTrue();
// check if level is greater or equal to CONFIG
- Assert.assertTrue(level.isGreaterOrEqual(Level.CONFIG));
+ assertThat(level.isGreaterOrEqual(Level.CONFIG)).isTrue();
// check if level is greater or equal to INFO
- Assert.assertTrue(level.isGreaterOrEqual(Level.INFO));
+ assertThat(level.isGreaterOrEqual(Level.INFO)).isTrue();
// check if level is greater or equal to WARNING
- Assert.assertTrue(level.isGreaterOrEqual(Level.WARNING));
+ assertThat(level.isGreaterOrEqual(Level.WARNING)).isTrue();
// check if level is greater or equal to SEVERE
- Assert.assertTrue(level.isGreaterOrEqual(Level.SEVERE));
+ assertThat(level.isGreaterOrEqual(Level.SEVERE)).isTrue();
// check if level is greater or equal to OFF
- Assert.assertTrue(level.isGreaterOrEqual(Level.OFF));
+ assertThat(level.isGreaterOrEqual(Level.OFF)).isTrue();
}
@@ -175,34 +176,34 @@
Level level = Level.FINE;
// check if level is on
- Assert.assertTrue(level.isOn());
+ assertThat(level.isOn()).isTrue();
// check if level is equal to "FINE"
- Assert.assertTrue(level.equals(Level.FINE));
+ assertThat(level.equals(Level.FINE)).isTrue();
// check if level is not equal to "WARNING"
- Assert.assertFalse(level.equals(Level.WARNING));
+ assertThat(level.equals(Level.WARNING)).isFalse();
// check if level text is "FINE"
- Assert.assertEquals(level.toString(), "FINE");
+ assertThat("FINE").isEqualTo(level.toString());
// check if level value is 30000
- Assert.assertEquals(level.toInteger(), 30000);
+ assertThat(30000).isEqualTo(level.toInteger());
// check if level is greater or equal to ALL
- Assert.assertFalse(level.isGreaterOrEqual(Level.ALL));
+ assertThat(level.isGreaterOrEqual(Level.ALL)).isFalse();
// check if level is greater or equal to FINEST
- Assert.assertFalse(level.isGreaterOrEqual(Level.FINEST));
+ assertThat(level.isGreaterOrEqual(Level.FINEST)).isFalse();
// check if level is greater or equal to FINER
- Assert.assertFalse(level.isGreaterOrEqual(Level.FINER));
+ assertThat(level.isGreaterOrEqual(Level.FINER)).isFalse();
// check if level is greater or equal to FINE
- Assert.assertTrue(level.isGreaterOrEqual(Level.FINE));
+ assertThat(level.isGreaterOrEqual(Level.FINE)).isTrue();
// check if level is greater or equal to CONFIG
- Assert.assertTrue(level.isGreaterOrEqual(Level.CONFIG));
+ assertThat(level.isGreaterOrEqual(Level.CONFIG)).isTrue();
// check if level is greater or equal to INFO
- Assert.assertTrue(level.isGreaterOrEqual(Level.INFO));
+ assertThat(level.isGreaterOrEqual(Level.INFO)).isTrue();
// check if level is greater or equal to WARNING
- Assert.assertTrue(level.isGreaterOrEqual(Level.WARNING));
+ assertThat(level.isGreaterOrEqual(Level.WARNING)).isTrue();
// check if level is greater or equal to SEVERE
- Assert.assertTrue(level.isGreaterOrEqual(Level.SEVERE));
+ assertThat(level.isGreaterOrEqual(Level.SEVERE)).isTrue();
// check if level is greater or equal to OFF
- Assert.assertTrue(level.isGreaterOrEqual(Level.OFF));
+ assertThat(level.isGreaterOrEqual(Level.OFF)).isTrue();
}
@@ -211,34 +212,34 @@
Level level = Level.CONFIG;
// check if level is on
- Assert.assertTrue(level.isOn());
+ assertThat(level.isOn()).isTrue();
// check if level is equal to "CONFIG"
- Assert.assertTrue(level.equals(Level.CONFIG));
+ assertThat(level.equals(Level.CONFIG)).isTrue();
// check if level is not equal to "WARNING"
- Assert.assertFalse(level.equals(Level.WARNING));
+ assertThat(level.equals(Level.WARNING)).isFalse();
// check if level text is "CONFIG"
- Assert.assertEquals(level.toString(), "CONFIG");
+ assertThat("CONFIG").isEqualTo(level.toString());
// check if level value is 40000
- Assert.assertEquals(level.toInteger(), 40000);
+ assertThat(40000).isEqualTo(level.toInteger());
// check if level is greater or equal to ALL
- Assert.assertFalse(level.isGreaterOrEqual(Level.ALL));
+ assertThat(level.isGreaterOrEqual(Level.ALL)).isFalse();
// check if level is greater or equal to FINEST
- Assert.assertFalse(level.isGreaterOrEqual(Level.FINEST));
+ assertThat(level.isGreaterOrEqual(Level.FINEST)).isFalse();
// check if level is greater or equal to FINER
- Assert.assertFalse(level.isGreaterOrEqual(Level.FINER));
+ assertThat(level.isGreaterOrEqual(Level.FINER)).isFalse();
// check if level is greater or equal to FINE
- Assert.assertFalse(level.isGreaterOrEqual(Level.FINE));
+ assertThat(level.isGreaterOrEqual(Level.FINE)).isFalse();
// check if level is greater or equal to CONFIG
- Assert.assertTrue(level.isGreaterOrEqual(Level.CONFIG));
+ assertThat(level.isGreaterOrEqual(Level.CONFIG)).isTrue();
// check if level is greater or equal to INFO
- Assert.assertTrue(level.isGreaterOrEqual(Level.INFO));
+ assertThat(level.isGreaterOrEqual(Level.INFO)).isTrue();
// check if level is greater or equal to WARNING
- Assert.assertTrue(level.isGreaterOrEqual(Level.WARNING));
+ assertThat(level.isGreaterOrEqual(Level.WARNING)).isTrue();
// check if level is greater or equal to SEVERE
- Assert.assertTrue(level.isGreaterOrEqual(Level.SEVERE));
+ assertThat(level.isGreaterOrEqual(Level.SEVERE)).isTrue();
// check if level is greater or equal to OFF
- Assert.assertTrue(level.isGreaterOrEqual(Level.OFF));
+ assertThat(level.isGreaterOrEqual(Level.OFF)).isTrue();
}
@@ -247,34 +248,34 @@
Level level = Level.INFO;
// check if level is on
- Assert.assertTrue(level.isOn());
+ assertThat(level.isOn()).isTrue();
// check if level is equal to "INFO"
- Assert.assertTrue(level.equals(Level.INFO));
+ assertThat(level.equals(Level.INFO)).isTrue();
// check if level is not equal to "WARNING"
- Assert.assertFalse(level.equals(Level.WARNING));
+ assertThat(level.equals(Level.WARNING)).isFalse();
// check if level text is "INFO"
- Assert.assertEquals(level.toString(), "INFO");
+ assertThat("INFO").isEqualTo(level.toString());
// check if level value is 50000
- Assert.assertEquals(level.toInteger(), 50000);
+ assertThat(50000).isEqualTo(level.toInteger());
// check if level is greater or equal to ALL
- Assert.assertFalse(level.isGreaterOrEqual(Level.ALL));
+ assertThat(level.isGreaterOrEqual(Level.ALL)).isFalse();
// check if level is greater or equal to FINEST
- Assert.assertFalse(level.isGreaterOrEqual(Level.FINEST));
+ assertThat(level.isGreaterOrEqual(Level.FINEST)).isFalse();
// check if level is greater or equal to FINER
- Assert.assertFalse(level.isGreaterOrEqual(Level.FINER));
+ assertThat(level.isGreaterOrEqual(Level.FINER)).isFalse();
// check if level is greater or equal to FINE
- Assert.assertFalse(level.isGreaterOrEqual(Level.FINE));
+ assertThat(level.isGreaterOrEqual(Level.FINE)).isFalse();
// check if level is greater or equal to CONFIG
- Assert.assertFalse(level.isGreaterOrEqual(Level.CONFIG));
+ assertThat(level.isGreaterOrEqual(Level.CONFIG)).isFalse();
// check if level is greater or equal to INFO
- Assert.assertTrue(level.isGreaterOrEqual(Level.INFO));
+ assertThat(level.isGreaterOrEqual(Level.INFO)).isTrue();
// check if level is greater or equal to WARNING
- Assert.assertTrue(level.isGreaterOrEqual(Level.WARNING));
+ assertThat(level.isGreaterOrEqual(Level.WARNING)).isTrue();
// check if level is greater or equal to SEVERE
- Assert.assertTrue(level.isGreaterOrEqual(Level.SEVERE));
+ assertThat(level.isGreaterOrEqual(Level.SEVERE)).isTrue();
// check if level is greater or equal to OFF
- Assert.assertTrue(level.isGreaterOrEqual(Level.OFF));
+ assertThat(level.isGreaterOrEqual(Level.OFF)).isTrue();
}
@Test
@@ -282,34 +283,34 @@
Level level = Level.WARNING;
// check if level is on
- Assert.assertTrue(level.isOn());
+ assertThat(level.isOn()).isTrue();
// check if level is equal to "WARNING"
- Assert.assertTrue(level.equals(Level.WARNING));
+ assertThat(level.equals(Level.WARNING)).isTrue();
// check if level is not equal to "OFF"
- Assert.assertFalse(level.equals(Level.OFF));
+ assertThat(level.equals(Level.OFF)).isFalse();
// check if level text is "WARNING"
- Assert.assertEquals(level.toString(), "WARNING");
+ assertThat("WARNING").isEqualTo(level.toString());
// check if level value is 60000
- Assert.assertEquals(level.toInteger(), 60000);
+ assertThat(60000).isEqualTo(level.toInteger());
// check if level is greater or equal to ALL
- Assert.assertFalse(level.isGreaterOrEqual(Level.ALL));
+ assertThat(level.isGreaterOrEqual(Level.ALL)).isFalse();
// check if level is greater or equal to FINEST
- Assert.assertFalse(level.isGreaterOrEqual(Level.FINEST));
+ assertThat(level.isGreaterOrEqual(Level.FINEST)).isFalse();
// check if level is greater or equal to FINER
- Assert.assertFalse(level.isGreaterOrEqual(Level.FINER));
+ assertThat(level.isGreaterOrEqual(Level.FINER)).isFalse();
// check if level is greater or equal to FINE
- Assert.assertFalse(level.isGreaterOrEqual(Level.FINE));
+ assertThat(level.isGreaterOrEqual(Level.FINE)).isFalse();
// check if level is greater or equal to CONFIG
- Assert.assertFalse(level.isGreaterOrEqual(Level.CONFIG));
+ assertThat(level.isGreaterOrEqual(Level.CONFIG)).isFalse();
// check if level is greater or equal to INFO
- Assert.assertFalse(level.isGreaterOrEqual(Level.INFO));
+ assertThat(level.isGreaterOrEqual(Level.INFO)).isFalse();
// check if level is greater or equal to WARNING
- Assert.assertTrue(level.isGreaterOrEqual(Level.WARNING));
+ assertThat(level.isGreaterOrEqual(Level.WARNING)).isTrue();
// check if level is greater or equal to SEVERE
- Assert.assertTrue(level.isGreaterOrEqual(Level.SEVERE));
+ assertThat(level.isGreaterOrEqual(Level.SEVERE)).isTrue();
// check if level is greater or equal to OFF
- Assert.assertTrue(level.isGreaterOrEqual(Level.OFF));
+ assertThat(level.isGreaterOrEqual(Level.OFF)).isTrue();
}
@@ -318,34 +319,34 @@
Level level = Level.SEVERE;
// check if level is on
- Assert.assertTrue(level.isOn());
+ assertThat(level.isOn()).isTrue();
// check if level is equal to "SEVERE"
- Assert.assertTrue(level.equals(Level.SEVERE));
+ assertThat(level.equals(Level.SEVERE)).isTrue();
// check if level is not equal to "OFF"
- Assert.assertFalse(level.equals(Level.OFF));
+ assertThat(level.equals(Level.OFF)).isFalse();
// check if level text is "SEVERE"
- Assert.assertEquals(level.toString(), "SEVERE");
+ assertThat("SEVERE").isEqualTo(level.toString());
// check if level value is 70000
- Assert.assertEquals(level.toInteger(), 70000);
+ assertThat(70000).isEqualTo(level.toInteger());
// check if level is greater or equal to ALL
- Assert.assertFalse(level.isGreaterOrEqual(Level.ALL));
+ assertThat(level.isGreaterOrEqual(Level.ALL)).isFalse();
// check if level is greater or equal to FINEST
- Assert.assertFalse(level.isGreaterOrEqual(Level.FINEST));
+ assertThat(level.isGreaterOrEqual(Level.FINEST)).isFalse();
// check if level is greater or equal to FINER
- Assert.assertFalse(level.isGreaterOrEqual(Level.FINER));
+ assertThat(level.isGreaterOrEqual(Level.FINER)).isFalse();
// check if level is greater or equal to FINE
- Assert.assertFalse(level.isGreaterOrEqual(Level.FINE));
+ assertThat(level.isGreaterOrEqual(Level.FINE)).isFalse();
// check if level is greater or equal to CONFIG
- Assert.assertFalse(level.isGreaterOrEqual(Level.CONFIG));
+ assertThat(level.isGreaterOrEqual(Level.CONFIG)).isFalse();
// check if level is greater or equal to INFO
- Assert.assertFalse(level.isGreaterOrEqual(Level.INFO));
+ assertThat(level.isGreaterOrEqual(Level.INFO)).isFalse();
// check if level is greater or equal to WARNING
- Assert.assertFalse(level.isGreaterOrEqual(Level.WARNING));
+ assertThat(level.isGreaterOrEqual(Level.WARNING)).isFalse();
// check if level is greater or equal to SEVERE
- Assert.assertTrue(level.isGreaterOrEqual(Level.SEVERE));
+ assertThat(level.isGreaterOrEqual(Level.SEVERE)).isTrue();
// check if level is greater or equal to OFF
- Assert.assertTrue(level.isGreaterOrEqual(Level.OFF));
+ assertThat(level.isGreaterOrEqual(Level.OFF)).isTrue();
}
@@ -355,11 +356,11 @@
Integer myInt = 70000;
// check if level is equal to "SEVERE"
- Assert.assertTrue(level.equals(Level.SEVERE));
+ assertThat(level.equals(Level.SEVERE)).isTrue();
// check with another class than Level
- Assert.assertFalse(level.equals(myInt));
+ assertThat(level.equals(myInt)).isFalse();
// check with null value
- Assert.assertFalse(level.equals(null));
+ assertThat(level.equals(null)).isFalse();
}
@Test
@@ -367,13 +368,13 @@
Level level = Level.INFO;
// check if level "ALL" is greater or equal to "INFO"
- Assert.assertFalse(level.isGreaterOrEqual(Level.ALL));
+ assertThat(level.isGreaterOrEqual(Level.ALL)).isFalse();
// check if level "SEVERE" is greater or equal to "INFO"
- Assert.assertTrue(level.isGreaterOrEqual(Level.SEVERE));
+ assertThat(level.isGreaterOrEqual(Level.SEVERE)).isTrue();
// check with null value
- Assert.assertFalse(level.isGreaterOrEqual(null));
+ assertThat(level.isGreaterOrEqual(null)).isFalse();
}
}
diff --git a/uimaj-core/src/test/java/org/apache/uima/util/impl/JSR47Logger_implTest.java b/uimaj-core/src/test/java/org/apache/uima/util/impl/JSR47Logger_implTest.java
index 3bd53cc..e82a72c 100644
--- a/uimaj-core/src/test/java/org/apache/uima/util/impl/JSR47Logger_implTest.java
+++ b/uimaj-core/src/test/java/org/apache/uima/util/impl/JSR47Logger_implTest.java
@@ -18,11 +18,12 @@
*/
package org.apache.uima.util.impl;
+import static org.assertj.core.api.Assertions.assertThat;
+
import java.util.HashMap;
import java.util.logging.Logger;
import org.apache.uima.util.Level;
-import org.junit.Assert;
import org.junit.jupiter.api.Test;
/**
@@ -57,10 +58,10 @@
classLogger.setLevel(null); // causes it to inherit from above
// check base configuration
- Assert.assertNotNull(uimaLogger);
- Assert.assertNotNull(classLogger);
- Assert.assertTrue(uimaLogger.isLoggable(Level.INFO));
- Assert.assertTrue(classLogger.isLoggable(Level.INFO));
+ assertThat(uimaLogger).isNotNull();
+ assertThat(classLogger).isNotNull();
+ assertThat(uimaLogger.isLoggable(Level.INFO)).isTrue();
+ assertThat(classLogger.isLoggable(Level.INFO)).isTrue();
} finally {
java.util.logging.Logger.getLogger("").setLevel(java.util.logging.Level.INFO);
@@ -85,83 +86,83 @@
classLogger.setLevel(null); // causes it to inherit from above
// check message logging for root logger based on default log level
- Assert.assertEquals(defaultLogLevel.isGreaterOrEqual(Level.ALL),
- uimaLogger.isLoggable(Level.ALL));
- Assert.assertEquals(defaultLogLevel.isGreaterOrEqual(Level.FINEST),
- uimaLogger.isLoggable(Level.FINEST));
- Assert.assertEquals(defaultLogLevel.isGreaterOrEqual(Level.FINER),
- uimaLogger.isLoggable(Level.FINER));
- Assert.assertEquals(defaultLogLevel.isGreaterOrEqual(Level.FINE),
- uimaLogger.isLoggable(Level.FINE));
- Assert.assertEquals(defaultLogLevel.isGreaterOrEqual(Level.CONFIG),
- uimaLogger.isLoggable(Level.CONFIG));
- Assert.assertEquals(defaultLogLevel.isGreaterOrEqual(Level.INFO),
- uimaLogger.isLoggable(Level.INFO));
- Assert.assertEquals(defaultLogLevel.isGreaterOrEqual(Level.WARNING),
- uimaLogger.isLoggable(Level.WARNING));
- Assert.assertEquals(defaultLogLevel.isGreaterOrEqual(Level.SEVERE),
- uimaLogger.isLoggable(Level.SEVERE));
- Assert.assertEquals(defaultLogLevel.isGreaterOrEqual(Level.OFF),
- uimaLogger.isLoggable(Level.OFF));
+ assertThat(uimaLogger.isLoggable(Level.ALL))
+ .isEqualTo(defaultLogLevel.isGreaterOrEqual(Level.ALL));
+ assertThat(uimaLogger.isLoggable(Level.FINEST))
+ .isEqualTo(defaultLogLevel.isGreaterOrEqual(Level.FINEST));
+ assertThat(uimaLogger.isLoggable(Level.FINER))
+ .isEqualTo(defaultLogLevel.isGreaterOrEqual(Level.FINER));
+ assertThat(uimaLogger.isLoggable(Level.FINE))
+ .isEqualTo(defaultLogLevel.isGreaterOrEqual(Level.FINE));
+ assertThat(uimaLogger.isLoggable(Level.CONFIG))
+ .isEqualTo(defaultLogLevel.isGreaterOrEqual(Level.CONFIG));
+ assertThat(uimaLogger.isLoggable(Level.INFO))
+ .isEqualTo(defaultLogLevel.isGreaterOrEqual(Level.INFO));
+ assertThat(uimaLogger.isLoggable(Level.WARNING))
+ .isEqualTo(defaultLogLevel.isGreaterOrEqual(Level.WARNING));
+ assertThat(uimaLogger.isLoggable(Level.SEVERE))
+ .isEqualTo(defaultLogLevel.isGreaterOrEqual(Level.SEVERE));
+ assertThat(uimaLogger.isLoggable(Level.OFF))
+ .isEqualTo(defaultLogLevel.isGreaterOrEqual(Level.OFF));
// check message logging for class logger based on default log level
- Assert.assertEquals(defaultLogLevel.isGreaterOrEqual(Level.ALL),
- classLogger.isLoggable(Level.ALL));
- Assert.assertEquals(defaultLogLevel.isGreaterOrEqual(Level.FINEST),
- classLogger.isLoggable(Level.FINEST));
- Assert.assertEquals(defaultLogLevel.isGreaterOrEqual(Level.FINER),
- classLogger.isLoggable(Level.FINER));
- Assert.assertEquals(defaultLogLevel.isGreaterOrEqual(Level.FINE),
- classLogger.isLoggable(Level.FINE));
- Assert.assertEquals(defaultLogLevel.isGreaterOrEqual(Level.CONFIG),
- classLogger.isLoggable(Level.CONFIG));
- Assert.assertEquals(defaultLogLevel.isGreaterOrEqual(Level.INFO),
- classLogger.isLoggable(Level.INFO));
- Assert.assertEquals(defaultLogLevel.isGreaterOrEqual(Level.WARNING),
- classLogger.isLoggable(Level.WARNING));
- Assert.assertEquals(defaultLogLevel.isGreaterOrEqual(Level.SEVERE),
- classLogger.isLoggable(Level.SEVERE));
- Assert.assertEquals(defaultLogLevel.isGreaterOrEqual(Level.OFF),
- classLogger.isLoggable(Level.OFF));
+ assertThat(classLogger.isLoggable(Level.ALL))
+ .isEqualTo(defaultLogLevel.isGreaterOrEqual(Level.ALL));
+ assertThat(classLogger.isLoggable(Level.FINEST))
+ .isEqualTo(defaultLogLevel.isGreaterOrEqual(Level.FINEST));
+ assertThat(classLogger.isLoggable(Level.FINER))
+ .isEqualTo(defaultLogLevel.isGreaterOrEqual(Level.FINER));
+ assertThat(classLogger.isLoggable(Level.FINE))
+ .isEqualTo(defaultLogLevel.isGreaterOrEqual(Level.FINE));
+ assertThat(classLogger.isLoggable(Level.CONFIG))
+ .isEqualTo(defaultLogLevel.isGreaterOrEqual(Level.CONFIG));
+ assertThat(classLogger.isLoggable(Level.INFO))
+ .isEqualTo(defaultLogLevel.isGreaterOrEqual(Level.INFO));
+ assertThat(classLogger.isLoggable(Level.WARNING))
+ .isEqualTo(defaultLogLevel.isGreaterOrEqual(Level.WARNING));
+ assertThat(classLogger.isLoggable(Level.SEVERE))
+ .isEqualTo(defaultLogLevel.isGreaterOrEqual(Level.SEVERE));
+ assertThat(classLogger.isLoggable(Level.OFF))
+ .isEqualTo(defaultLogLevel.isGreaterOrEqual(Level.OFF));
// reset class logger level to OFF
// Logger.getLogger(this.getClass().getName()).setLevel(java.util.logging.Level.OFF);
classLogger.setLevel(Level.OFF);
- Assert.assertFalse(classLogger.isLoggable(Level.ALL));
- Assert.assertFalse(classLogger.isLoggable(Level.FINEST));
- Assert.assertFalse(classLogger.isLoggable(Level.FINER));
- Assert.assertFalse(classLogger.isLoggable(Level.FINE));
- Assert.assertFalse(classLogger.isLoggable(Level.CONFIG));
- Assert.assertFalse(classLogger.isLoggable(Level.INFO));
- Assert.assertFalse(classLogger.isLoggable(Level.WARNING));
- Assert.assertFalse(classLogger.isLoggable(Level.SEVERE));
- Assert.assertFalse(classLogger.isLoggable(Level.OFF));
+ assertThat(classLogger.isLoggable(Level.ALL)).isFalse();
+ assertThat(classLogger.isLoggable(Level.FINEST)).isFalse();
+ assertThat(classLogger.isLoggable(Level.FINER)).isFalse();
+ assertThat(classLogger.isLoggable(Level.FINE)).isFalse();
+ assertThat(classLogger.isLoggable(Level.CONFIG)).isFalse();
+ assertThat(classLogger.isLoggable(Level.INFO)).isFalse();
+ assertThat(classLogger.isLoggable(Level.WARNING)).isFalse();
+ assertThat(classLogger.isLoggable(Level.SEVERE)).isFalse();
+ assertThat(classLogger.isLoggable(Level.OFF)).isFalse();
// reset class logger level to ALL
// Logger.getLogger(this.getClass().getName()).setLevel(java.util.logging.Level.ALL);
classLogger.setLevel(Level.ALL);
- Assert.assertTrue(classLogger.isLoggable(Level.ALL));
- Assert.assertTrue(classLogger.isLoggable(Level.FINEST));
- Assert.assertTrue(classLogger.isLoggable(Level.FINER));
- Assert.assertTrue(classLogger.isLoggable(Level.FINE));
- Assert.assertTrue(classLogger.isLoggable(Level.CONFIG));
- Assert.assertTrue(classLogger.isLoggable(Level.INFO));
- Assert.assertTrue(classLogger.isLoggable(Level.WARNING));
- Assert.assertTrue(classLogger.isLoggable(Level.SEVERE));
- Assert.assertTrue(classLogger.isLoggable(Level.OFF));
+ assertThat(classLogger.isLoggable(Level.ALL)).isTrue();
+ assertThat(classLogger.isLoggable(Level.FINEST)).isTrue();
+ assertThat(classLogger.isLoggable(Level.FINER)).isTrue();
+ assertThat(classLogger.isLoggable(Level.FINE)).isTrue();
+ assertThat(classLogger.isLoggable(Level.CONFIG)).isTrue();
+ assertThat(classLogger.isLoggable(Level.INFO)).isTrue();
+ assertThat(classLogger.isLoggable(Level.WARNING)).isTrue();
+ assertThat(classLogger.isLoggable(Level.SEVERE)).isTrue();
+ assertThat(classLogger.isLoggable(Level.OFF)).isTrue();
// reset class logger level to WARNING
// Logger.getLogger(this.getClass().getName()).setLevel(java.util.logging.Level.WARNING);
classLogger.setLevel(Level.WARNING);
- Assert.assertFalse(classLogger.isLoggable(Level.ALL));
- Assert.assertFalse(classLogger.isLoggable(Level.FINEST));
- Assert.assertFalse(classLogger.isLoggable(Level.FINER));
- Assert.assertFalse(classLogger.isLoggable(Level.FINE));
- Assert.assertFalse(classLogger.isLoggable(Level.CONFIG));
- Assert.assertFalse(classLogger.isLoggable(Level.INFO));
- Assert.assertTrue(classLogger.isLoggable(Level.WARNING));
- Assert.assertTrue(classLogger.isLoggable(Level.SEVERE));
- Assert.assertTrue(classLogger.isLoggable(Level.OFF));
+ assertThat(classLogger.isLoggable(Level.ALL)).isFalse();
+ assertThat(classLogger.isLoggable(Level.FINEST)).isFalse();
+ assertThat(classLogger.isLoggable(Level.FINER)).isFalse();
+ assertThat(classLogger.isLoggable(Level.FINE)).isFalse();
+ assertThat(classLogger.isLoggable(Level.CONFIG)).isFalse();
+ assertThat(classLogger.isLoggable(Level.INFO)).isFalse();
+ assertThat(classLogger.isLoggable(Level.WARNING)).isTrue();
+ assertThat(classLogger.isLoggable(Level.SEVERE)).isTrue();
+ assertThat(classLogger.isLoggable(Level.OFF)).isTrue();
} finally {
// reset log level to default log level
diff --git a/uimaj-core/src/test/java/org/apache/uima/util/impl/Logger_implTest.java b/uimaj-core/src/test/java/org/apache/uima/util/impl/Logger_implTest.java
index d42adf2..8c77f26 100644
--- a/uimaj-core/src/test/java/org/apache/uima/util/impl/Logger_implTest.java
+++ b/uimaj-core/src/test/java/org/apache/uima/util/impl/Logger_implTest.java
@@ -19,8 +19,9 @@
package org.apache.uima.util.impl;
+import static org.assertj.core.api.Assertions.assertThat;
+
import org.apache.uima.util.Level;
-import org.junit.Assert;
import org.junit.jupiter.api.Test;
/**
@@ -38,15 +39,15 @@
rootLogger.setLevel(Level.INFO);
// check default configuration
- Assert.assertNotNull(rootLogger);
- Assert.assertNotNull(classLogger);
- Assert.assertTrue(rootLogger.isLoggable(Level.INFO));
- Assert.assertTrue(classLogger.isLoggable(Level.INFO));
+ assertThat(rootLogger).isNotNull();
+ assertThat(classLogger).isNotNull();
+ assertThat(rootLogger.isLoggable(Level.INFO)).isTrue();
+ assertThat(classLogger.isLoggable(Level.INFO)).isTrue();
// check getInstance() calls
- Assert.assertNotSame(classLogger, rootLogger);
- Assert.assertEquals(rootLogger, rootLogger1);
- Assert.assertNotSame(classLogger, classLogger1);
+ assertThat(classLogger).isNotSameAs(rootLogger);
+ assertThat(rootLogger1).isEqualTo(rootLogger);
+ assertThat(classLogger).isNotSameAs(classLogger1);
}
@Test
@@ -60,62 +61,62 @@
rootLogger.setLevel(Level.INFO);
// check message leveling root logger
- Assert.assertFalse(rootLogger.isLoggable(Level.ALL));
- Assert.assertFalse(rootLogger.isLoggable(Level.FINEST));
- Assert.assertFalse(rootLogger.isLoggable(Level.FINER));
- Assert.assertFalse(rootLogger.isLoggable(Level.FINE));
- Assert.assertFalse(rootLogger.isLoggable(Level.CONFIG));
- Assert.assertTrue(rootLogger.isLoggable(Level.INFO));
- Assert.assertTrue(rootLogger.isLoggable(Level.WARNING));
- Assert.assertTrue(rootLogger.isLoggable(Level.SEVERE));
- Assert.assertTrue(rootLogger.isLoggable(Level.OFF));
+ assertThat(rootLogger.isLoggable(Level.ALL)).isFalse();
+ assertThat(rootLogger.isLoggable(Level.FINEST)).isFalse();
+ assertThat(rootLogger.isLoggable(Level.FINER)).isFalse();
+ assertThat(rootLogger.isLoggable(Level.FINE)).isFalse();
+ assertThat(rootLogger.isLoggable(Level.CONFIG)).isFalse();
+ assertThat(rootLogger.isLoggable(Level.INFO)).isTrue();
+ assertThat(rootLogger.isLoggable(Level.WARNING)).isTrue();
+ assertThat(rootLogger.isLoggable(Level.SEVERE)).isTrue();
+ assertThat(rootLogger.isLoggable(Level.OFF)).isTrue();
// check message leveling class logger
- Assert.assertFalse(rootLogger.isLoggable(Level.ALL));
- Assert.assertFalse(rootLogger.isLoggable(Level.FINEST));
- Assert.assertFalse(rootLogger.isLoggable(Level.FINER));
- Assert.assertFalse(rootLogger.isLoggable(Level.FINE));
- Assert.assertFalse(rootLogger.isLoggable(Level.CONFIG));
- Assert.assertTrue(rootLogger.isLoggable(Level.INFO));
- Assert.assertTrue(rootLogger.isLoggable(Level.WARNING));
- Assert.assertTrue(rootLogger.isLoggable(Level.SEVERE));
- Assert.assertTrue(rootLogger.isLoggable(Level.OFF));
+ assertThat(rootLogger.isLoggable(Level.ALL)).isFalse();
+ assertThat(rootLogger.isLoggable(Level.FINEST)).isFalse();
+ assertThat(rootLogger.isLoggable(Level.FINER)).isFalse();
+ assertThat(rootLogger.isLoggable(Level.FINE)).isFalse();
+ assertThat(rootLogger.isLoggable(Level.CONFIG)).isFalse();
+ assertThat(rootLogger.isLoggable(Level.INFO)).isTrue();
+ assertThat(rootLogger.isLoggable(Level.WARNING)).isTrue();
+ assertThat(rootLogger.isLoggable(Level.SEVERE)).isTrue();
+ assertThat(rootLogger.isLoggable(Level.OFF)).isTrue();
// reset class logger level to OFF
classLogger.setLevel(Level.OFF);
- Assert.assertFalse(classLogger.isLoggable(Level.ALL));
- Assert.assertFalse(classLogger.isLoggable(Level.FINEST));
- Assert.assertFalse(classLogger.isLoggable(Level.FINER));
- Assert.assertFalse(classLogger.isLoggable(Level.FINE));
- Assert.assertFalse(classLogger.isLoggable(Level.CONFIG));
- Assert.assertFalse(classLogger.isLoggable(Level.INFO));
- Assert.assertFalse(classLogger.isLoggable(Level.WARNING));
- Assert.assertFalse(classLogger.isLoggable(Level.SEVERE));
- Assert.assertTrue(classLogger.isLoggable(Level.OFF));
+ assertThat(classLogger.isLoggable(Level.ALL)).isFalse();
+ assertThat(classLogger.isLoggable(Level.FINEST)).isFalse();
+ assertThat(classLogger.isLoggable(Level.FINER)).isFalse();
+ assertThat(classLogger.isLoggable(Level.FINE)).isFalse();
+ assertThat(classLogger.isLoggable(Level.CONFIG)).isFalse();
+ assertThat(classLogger.isLoggable(Level.INFO)).isFalse();
+ assertThat(classLogger.isLoggable(Level.WARNING)).isFalse();
+ assertThat(classLogger.isLoggable(Level.SEVERE)).isFalse();
+ assertThat(classLogger.isLoggable(Level.OFF)).isTrue();
// reset class logger level to ALL
classLogger.setLevel(Level.ALL);
- Assert.assertTrue(classLogger.isLoggable(Level.ALL));
- Assert.assertTrue(classLogger.isLoggable(Level.FINEST));
- Assert.assertTrue(classLogger.isLoggable(Level.FINER));
- Assert.assertTrue(classLogger.isLoggable(Level.FINE));
- Assert.assertTrue(classLogger.isLoggable(Level.CONFIG));
- Assert.assertTrue(classLogger.isLoggable(Level.INFO));
- Assert.assertTrue(classLogger.isLoggable(Level.WARNING));
- Assert.assertTrue(classLogger.isLoggable(Level.SEVERE));
- Assert.assertTrue(classLogger.isLoggable(Level.OFF));
+ assertThat(classLogger.isLoggable(Level.ALL)).isTrue();
+ assertThat(classLogger.isLoggable(Level.FINEST)).isTrue();
+ assertThat(classLogger.isLoggable(Level.FINER)).isTrue();
+ assertThat(classLogger.isLoggable(Level.FINE)).isTrue();
+ assertThat(classLogger.isLoggable(Level.CONFIG)).isTrue();
+ assertThat(classLogger.isLoggable(Level.INFO)).isTrue();
+ assertThat(classLogger.isLoggable(Level.WARNING)).isTrue();
+ assertThat(classLogger.isLoggable(Level.SEVERE)).isTrue();
+ assertThat(classLogger.isLoggable(Level.OFF)).isTrue();
// reset class logger level to WARNING
classLogger.setLevel(Level.WARNING);
- Assert.assertFalse(classLogger.isLoggable(Level.ALL));
- Assert.assertFalse(classLogger.isLoggable(Level.FINEST));
- Assert.assertFalse(classLogger.isLoggable(Level.FINER));
- Assert.assertFalse(classLogger.isLoggable(Level.FINE));
- Assert.assertFalse(classLogger.isLoggable(Level.CONFIG));
- Assert.assertFalse(classLogger.isLoggable(Level.INFO));
- Assert.assertTrue(classLogger.isLoggable(Level.WARNING));
- Assert.assertTrue(classLogger.isLoggable(Level.SEVERE));
- Assert.assertTrue(classLogger.isLoggable(Level.OFF));
+ assertThat(classLogger.isLoggable(Level.ALL)).isFalse();
+ assertThat(classLogger.isLoggable(Level.FINEST)).isFalse();
+ assertThat(classLogger.isLoggable(Level.FINER)).isFalse();
+ assertThat(classLogger.isLoggable(Level.FINE)).isFalse();
+ assertThat(classLogger.isLoggable(Level.CONFIG)).isFalse();
+ assertThat(classLogger.isLoggable(Level.INFO)).isFalse();
+ assertThat(classLogger.isLoggable(Level.WARNING)).isTrue();
+ assertThat(classLogger.isLoggable(Level.SEVERE)).isTrue();
+ assertThat(classLogger.isLoggable(Level.OFF)).isTrue();
} finally {
rootLogger.setLevel(Level.INFO);
classLogger.setLevel(Level.INFO);
diff --git a/uimaj-core/src/test/java/org/apache/uima/util/impl/LoggingTest.java b/uimaj-core/src/test/java/org/apache/uima/util/impl/LoggingTest.java
index 8e9298a..29ce156 100644
--- a/uimaj-core/src/test/java/org/apache/uima/util/impl/LoggingTest.java
+++ b/uimaj-core/src/test/java/org/apache/uima/util/impl/LoggingTest.java
@@ -19,11 +19,12 @@
package org.apache.uima.util.impl;
+import static org.assertj.core.api.Assertions.assertThat;
+
import org.apache.uima.UIMAFramework;
import org.apache.uima.test.junit_extension.JUnitExtension;
import org.apache.uima.util.Level;
import org.apache.uima.util.Logger;
-import org.junit.Assert;
import org.junit.jupiter.api.Test;
/**
@@ -36,13 +37,13 @@
try {
// get default logger
Logger logger = UIMAFramework.getLogger();
- Assert.assertNotNull(logger);
+ assertThat(logger).isNotNull();
// create another logger
Logger logger1 = UIMAFramework.getLogger();
// both loggers must reference the same instance
- Assert.assertEquals(logger, logger1);
+ assertThat(logger1).isEqualTo(logger);
// test base logging functions
logger.log(Level.SEVERE, "Log test messege with Level SEVERE");
@@ -60,7 +61,7 @@
try {
// get class logger
Logger logger = UIMAFramework.getLogger(this.getClass());
- Assert.assertNotNull(logger);
+ assertThat(logger).isNotNull();
// create another class logger
Logger logger1 = UIMAFramework.getLogger(this.getClass());
@@ -69,10 +70,10 @@
Logger defaultLogger = UIMAFramework.getLogger();
// both loggers must reference the same instance
- Assert.assertEquals(logger, logger1);
+ assertThat(logger1).isEqualTo(logger);
// should not be the same
- Assert.assertNotSame(defaultLogger, logger1);
+ assertThat(logger1).isNotSameAs(defaultLogger);
// test base logging functions
logger.log(Level.SEVERE, "Log test messege with Level SEVERE");
@@ -96,25 +97,25 @@
// set level to WARNING
uimaLogger.setLevel(Level.WARNING);
- Assert.assertTrue(uimaLogger.isLoggable(Level.WARNING));
- Assert.assertTrue(uimaLogger.isLoggable(Level.SEVERE));
- Assert.assertFalse(uimaLogger.isLoggable(Level.INFO));
- Assert.assertTrue(logger.isLoggable(Level.WARNING));
- Assert.assertTrue(logger.isLoggable(Level.SEVERE));
- Assert.assertFalse(logger.isLoggable(Level.INFO));
+ assertThat(uimaLogger.isLoggable(Level.WARNING)).isTrue();
+ assertThat(uimaLogger.isLoggable(Level.SEVERE)).isTrue();
+ assertThat(uimaLogger.isLoggable(Level.INFO)).isFalse();
+ assertThat(logger.isLoggable(Level.WARNING)).isTrue();
+ assertThat(logger.isLoggable(Level.SEVERE)).isTrue();
+ assertThat(logger.isLoggable(Level.INFO)).isFalse();
// set level to FINE
uimaLogger.setLevel(Level.FINE);
- Assert.assertTrue(uimaLogger.isLoggable(Level.WARNING));
- Assert.assertTrue(uimaLogger.isLoggable(Level.SEVERE));
- Assert.assertTrue(uimaLogger.isLoggable(Level.INFO));
- Assert.assertFalse(uimaLogger.isLoggable(Level.FINER));
- Assert.assertFalse(uimaLogger.isLoggable(Level.ALL));
- Assert.assertTrue(logger.isLoggable(Level.WARNING));
- Assert.assertTrue(logger.isLoggable(Level.SEVERE));
- Assert.assertTrue(logger.isLoggable(Level.INFO));
- Assert.assertFalse(logger.isLoggable(Level.FINER));
- Assert.assertFalse(logger.isLoggable(Level.ALL));
+ assertThat(uimaLogger.isLoggable(Level.WARNING)).isTrue();
+ assertThat(uimaLogger.isLoggable(Level.SEVERE)).isTrue();
+ assertThat(uimaLogger.isLoggable(Level.INFO)).isTrue();
+ assertThat(uimaLogger.isLoggable(Level.FINER)).isFalse();
+ assertThat(uimaLogger.isLoggable(Level.ALL)).isFalse();
+ assertThat(logger.isLoggable(Level.WARNING)).isTrue();
+ assertThat(logger.isLoggable(Level.SEVERE)).isTrue();
+ assertThat(logger.isLoggable(Level.INFO)).isTrue();
+ assertThat(logger.isLoggable(Level.FINER)).isFalse();
+ assertThat(logger.isLoggable(Level.ALL)).isFalse();
} catch (Exception ex) {
JUnitExtension.handleException(ex);
} finally {
diff --git a/uimaj-core/src/test/java/org/apache/uima/util/impl/ProcessTrace_implTest.java b/uimaj-core/src/test/java/org/apache/uima/util/impl/ProcessTrace_implTest.java
index 49bda67..8d38892 100644
--- a/uimaj-core/src/test/java/org/apache/uima/util/impl/ProcessTrace_implTest.java
+++ b/uimaj-core/src/test/java/org/apache/uima/util/impl/ProcessTrace_implTest.java
@@ -19,11 +19,12 @@
package org.apache.uima.util.impl;
+import static org.assertj.core.api.Assertions.assertThat;
+
import java.util.List;
import org.apache.uima.util.ProcessTrace;
import org.apache.uima.util.ProcessTraceEvent;
-import org.junit.Assert;
import org.junit.jupiter.api.Test;
public class ProcessTrace_implTest {
@@ -34,76 +35,76 @@
public void testStartAndEndEvent() {
ProcessTrace pt = new ProcessTrace_impl();
// should be nothing on event list
- Assert.assertTrue(pt.getEvents().isEmpty());
+ assertThat(pt.getEvents().isEmpty()).isTrue();
// start two events
pt.startEvent("c1", "t1", "testing");
pt.startEvent("c1", "t2", "testing");
// should be nothing on event list until both are closed
- Assert.assertTrue(pt.getEvents().isEmpty());
+ assertThat(pt.getEvents().isEmpty()).isTrue();
pt.endEvent("c1", "t2", "success");
- Assert.assertTrue(pt.getEvents().isEmpty());
+ assertThat(pt.getEvents().isEmpty()).isTrue();
pt.endEvent("c1", "t1", "success");
- Assert.assertEquals(1, pt.getEvents().size());
+ assertThat(pt.getEvents()).hasSize(1);
// start two more events
pt.startEvent("c2", "t1", "testing");
pt.startEvent("c2", "t2", "testing");
// close one and start another
pt.endEvent("c2", "t2", "testing");
- Assert.assertEquals(1, pt.getEvents().size());
+ assertThat(pt.getEvents()).hasSize(1);
pt.startEvent("c2", "t3", "testing");
pt.endEvent("c2", "t3", "testing");
- Assert.assertEquals(1, pt.getEvents().size());
+ assertThat(pt.getEvents()).hasSize(1);
// start another event and then end the original event
pt.startEvent("c2", "t4", "testing");
pt.endEvent("c2", "t1", "success");
- Assert.assertEquals(2, pt.getEvents().size());
+ assertThat(pt.getEvents()).hasSize(2);
// verify contents of the ProcessTrace
List<ProcessTraceEvent> evts = pt.getEvents();
ProcessTraceEvent evt0 = evts.get(0);
- Assert.assertEquals("c1", evt0.getComponentName());
- Assert.assertEquals("t1", evt0.getType());
- Assert.assertEquals("testing", evt0.getDescription());
- Assert.assertEquals("success", evt0.getResultMessage());
+ assertThat(evt0.getComponentName()).isEqualTo("c1");
+ assertThat(evt0.getType()).isEqualTo("t1");
+ assertThat(evt0.getDescription()).isEqualTo("testing");
+ assertThat(evt0.getResultMessage()).isEqualTo("success");
List<ProcessTraceEvent> subEvts = evt0.getSubEvents();
ProcessTraceEvent subEvt0 = subEvts.get(0);
- Assert.assertEquals("c1", subEvt0.getComponentName());
- Assert.assertEquals("t2", subEvt0.getType());
- Assert.assertEquals("testing", subEvt0.getDescription());
- Assert.assertEquals("success", subEvt0.getResultMessage());
- Assert.assertTrue(subEvt0.getSubEvents().isEmpty());
+ assertThat(subEvt0.getComponentName()).isEqualTo("c1");
+ assertThat(subEvt0.getType()).isEqualTo("t2");
+ assertThat(subEvt0.getDescription()).isEqualTo("testing");
+ assertThat(subEvt0.getResultMessage()).isEqualTo("success");
+ assertThat(subEvt0.getSubEvents().isEmpty()).isTrue();
ProcessTraceEvent evt1 = evts.get(1);
- Assert.assertEquals("c2", evt1.getComponentName());
- Assert.assertEquals("t1", evt1.getType());
- Assert.assertEquals("testing", evt1.getDescription());
- Assert.assertEquals("success", evt1.getResultMessage());
- Assert.assertEquals(3, evt1.getSubEvents().size());
+ assertThat(evt1.getComponentName()).isEqualTo("c2");
+ assertThat(evt1.getType()).isEqualTo("t1");
+ assertThat(evt1.getDescription()).isEqualTo("testing");
+ assertThat(evt1.getResultMessage()).isEqualTo("success");
+ assertThat(evt1.getSubEvents()).hasSize(3);
}
@Test
public void testAddEvent() {
ProcessTrace_impl pt = new ProcessTrace_impl();
// should be nothing on event list
- Assert.assertTrue(pt.getEvents().isEmpty());
+ assertThat(pt.getEvents().isEmpty()).isTrue();
// add event
pt.addEvent("c1", "t1", "testing", 0, "success");
// should be one thing on list
- Assert.assertEquals(1, pt.getEvents().size());
+ assertThat(pt.getEvents()).hasSize(1);
// start an event
pt.startEvent("c2", "t1", "testing");
// add event
pt.addEvent("c2", "t2", "testing", 0, "success");
// should still be one thing on list
- Assert.assertEquals(1, pt.getEvents().size());
+ assertThat(pt.getEvents()).hasSize(1);
// end event that we started
pt.endEvent("c2", "t1", "success");
// should be 2 events on list
- Assert.assertEquals(2, pt.getEvents().size());
+ assertThat(pt.getEvents()).hasSize(2);
// 2nd event should have a sub-event
ProcessTraceEvent evt = pt.getEvents().get(1);
- Assert.assertEquals(1, evt.getSubEvents().size());
+ assertThat(evt.getSubEvents()).hasSize(1);
}
/*
@@ -127,27 +128,27 @@
// get top-level events for component c1
List<ProcessTraceEvent> c1evts = pt.getEventsByComponentName("c1", false);
- Assert.assertEquals(1, c1evts.size());
+ assertThat(c1evts).hasSize(1);
ProcessTraceEvent evt = c1evts.get(0);
- Assert.assertEquals(evt.getType(), "t1");
+ assertThat("t1").isEqualTo(evt.getType());
// get all events for component c1
c1evts = pt.getEventsByComponentName("c1", true);
- Assert.assertEquals(2, c1evts.size());
+ assertThat(c1evts).hasSize(2);
evt = c1evts.get(1);
- Assert.assertEquals(evt.getType(), "t2");
+ assertThat("t2").isEqualTo(evt.getType());
// get top-level events for component c2
List<ProcessTraceEvent> c2evts = pt.getEventsByComponentName("c2", false);
- Assert.assertEquals(1, c2evts.size());
+ assertThat(c2evts).hasSize(1);
evt = c2evts.get(0);
- Assert.assertEquals(evt.getType(), "t1");
+ assertThat("t1").isEqualTo(evt.getType());
// get all events for component c2
c2evts = pt.getEventsByComponentName("c2", true);
- Assert.assertEquals(4, c2evts.size());
+ assertThat(c2evts).hasSize(4);
evt = c2evts.get(3);
- Assert.assertEquals(evt.getType(), "t4");
+ assertThat("t4").isEqualTo(evt.getType());
}
/*
@@ -171,17 +172,17 @@
// get top-level events of type t1
List<ProcessTraceEvent> t1evts = pt.getEventsByType("t1", false);
- Assert.assertEquals(2, t1evts.size());
+ assertThat(t1evts).hasSize(2);
ProcessTraceEvent evt = t1evts.get(0);
- Assert.assertEquals(evt.getComponentName(), "c1");
+ assertThat("c1").isEqualTo(evt.getComponentName());
evt = t1evts.get(1);
- Assert.assertEquals(evt.getComponentName(), "c2");
+ assertThat("c2").isEqualTo(evt.getComponentName());
// get all events for type t1
t1evts = pt.getEventsByType("t1", true);
- Assert.assertEquals(3, t1evts.size());
+ assertThat(t1evts).hasSize(3);
evt = t1evts.get(2);
- Assert.assertEquals(evt.getComponentName(), "c3");
+ assertThat("c3").isEqualTo(evt.getComponentName());
}
/*
@@ -204,11 +205,11 @@
pt.endEvent("c2", "t1", "success");
ProcessTraceEvent evt = pt.getEvent("c2", "t2");
- Assert.assertEquals("c2", evt.getComponentName());
- Assert.assertEquals("t2", evt.getType());
+ assertThat(evt.getComponentName()).isEqualTo("c2");
+ assertThat(evt.getType()).isEqualTo("t2");
evt = pt.getEvent("c3", "t2");
- Assert.assertNull(evt);
+ assertThat(evt).isNull();
}
@Test
@@ -230,8 +231,8 @@
ProcessTraceEvent c1evt = pt1.getEvents().get(0);
ProcessTraceEvent c2evt = pt1.getEvents().get(1);
ProcessTraceEvent c2subEvt = c2evt.getSubEvents().get(0);
- Assert.assertEquals(1250, c1evt.getDuration());
- Assert.assertEquals(1000, c2subEvt.getDuration());
+ assertThat(c1evt.getDuration()).isEqualTo(1250);
+ assertThat(c2subEvt.getDuration()).isEqualTo(1000);
}
}
diff --git a/uimaj-core/src/test/java/org/apache/uima/util/impl/XMLParser_implTest.java b/uimaj-core/src/test/java/org/apache/uima/util/impl/XMLParser_implTest.java
index 6ebaa4e..d381fb5 100644
--- a/uimaj-core/src/test/java/org/apache/uima/util/impl/XMLParser_implTest.java
+++ b/uimaj-core/src/test/java/org/apache/uima/util/impl/XMLParser_implTest.java
@@ -41,7 +41,6 @@
import org.apache.uima.util.InvalidXMLException;
import org.apache.uima.util.XMLInputSource;
import org.apache.uima.util.XMLParser;
-import org.junit.Assert;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -85,10 +84,10 @@
.parse(new XMLInputSource(withImports));
AnalysisEngineDescription desc2 = (AnalysisEngineDescription) mXmlParser
.parse(new XMLInputSource(manuallyExpanded));
- Assert.assertNotNull(desc1);
- Assert.assertNotNull(desc2);
- Assert.assertEquals(desc1.getDelegateAnalysisEngineSpecifiers(),
- desc2.getDelegateAnalysisEngineSpecifiers());
+ assertThat(desc1).isNotNull();
+ assertThat(desc2).isNotNull();
+ assertThat(desc2.getDelegateAnalysisEngineSpecifiers())
+ .isEqualTo(desc1.getDelegateAnalysisEngineSpecifiers());
} catch (Exception e) {
JUnitExtension.handleException(e);
} finally {
@@ -106,14 +105,13 @@
AnalysisEngineDescription taeDesc = UIMAFramework.getXMLParser()
.parseAnalysisEngineDescription(new XMLInputSource(envVarRefTest),
new XMLParser.ParsingOptions(true, true));
- Assert.assertEquals("foo-bar", taeDesc.getMetaData().getName());
+ assertThat(taeDesc.getMetaData().getName()).isEqualTo("foo-bar");
// parse with env var ref expansion disabled
taeDesc = UIMAFramework.getXMLParser().parseAnalysisEngineDescription(
new XMLInputSource(envVarRefTest), new XMLParser.ParsingOptions(false));
- Assert.assertEquals(
- "<envVarRef>uima.test.var1</envVarRef>-<envVarRef>uima.test.var2</envVarRef>",
- taeDesc.getMetaData().getName());
+ assertThat(taeDesc.getMetaData().getName()).isEqualTo(
+ "<envVarRef>uima.test.var1</envVarRef>-<envVarRef>uima.test.var2</envVarRef>");
} catch (Exception e) {
JUnitExtension.handleException(e);