diff --git a/jcasgen-maven-plugin/src/test/java/org/apache/uima/tools/jcasgen/maven/JCasGenMojoTest.java b/jcasgen-maven-plugin/src/test/java/org/apache/uima/tools/jcasgen/maven/JCasGenMojoTest.java index 8f99a76e0..d05925bec 100644 --- a/jcasgen-maven-plugin/src/test/java/org/apache/uima/tools/jcasgen/maven/JCasGenMojoTest.java +++ b/jcasgen-maven-plugin/src/test/java/org/apache/uima/tools/jcasgen/maven/JCasGenMojoTest.java @@ -19,80 +19,58 @@ package org.apache.uima.tools.jcasgen.maven; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import java.io.File; import java.util.ArrayList; -import java.util.List; - -import org.apache.maven.execution.DefaultMavenExecutionRequest; -import org.apache.maven.execution.MavenExecutionRequest; -import org.apache.maven.plugin.testing.AbstractMojoTestCase; -import org.apache.maven.project.MavenProject; -import org.apache.maven.project.ProjectBuilder; -import org.apache.maven.project.ProjectBuildingRequest; -import org.apache.maven.repository.internal.MavenRepositorySystemUtils; + +import org.apache.maven.plugin.testing.MojoRule; import org.codehaus.plexus.util.DirectoryScanner; import org.codehaus.plexus.util.FileUtils; -import org.eclipse.aether.RepositorySystemSession; +import org.junit.Rule; import org.junit.Test; -public class JCasGenMojoTest extends AbstractMojoTestCase { +public class JCasGenMojoTest { + + public @Rule MojoRule rule = new MojoRule(); @Test public void testInvalidFeature() throws Exception { - Exception ee = null; - try { + assertThatExceptionOfType(Exception.class).isThrownBy(() -> { this.test("invalidFeature"); - } catch (Exception e) { - ee = e; - } - assertTrue(ee != null); - assertEquals( - "JCasGen: The feature name 'type', specified in Type 'type.span.Sentence' is reserved. Please choose another name.", - ee.getMessage()); + }).withMessage( + "JCasGen: The feature name 'type', specified in Type 'type.span.Sentence' is reserved. Please choose another name."); } @Test public void testSimple() throws Exception { - this.test("simple", "type.span.Sentence", "type.span.Token", "type.relation.Dependency"); + test("simple", "type.span.Sentence", "type.span.Token", "type.relation.Dependency"); } @Test public void testClasspath() throws Exception { - this.test("classpath", "type.span.Sentence", "type.span.Token", "type.relation.Dependency"); + test("classpath", "type.span.Sentence", "type.span.Token", "type.relation.Dependency"); } @Test public void testWildcard() throws Exception { - this.test("wildcard", "type.span.Sentence", "type.span.Token"); + test("wildcard", "type.span.Sentence", "type.span.Token"); } @Test public void testExclude() throws Exception { - this.test("exclude", "type.span.Sentence"); + test("exclude", "type.span.Sentence"); } - @Test - public void test(String projectName, String... types) throws Exception { + private void test(String projectName, String... types) throws Exception { - File projectSourceDirectory = getTestFile("src/test/resources/" + projectName); - File projectDirectory = getTestFile("target/project-" + projectName + "-test"); + var projectSourceDirectory = new File("src/test/resources/" + projectName); + var projectDirectory = new File("target/project-" + projectName + "-test"); // Stage project to target folder FileUtils.copyDirectoryStructure(projectSourceDirectory, projectDirectory); - File pomFile = new File(projectDirectory, "/pom.xml"); - assertNotNull(pomFile); - assertTrue(pomFile.exists()); - - // create the MavenProject from the pom.xml file - RepositorySystemSession session = MavenRepositorySystemUtils.newSession(); - MavenExecutionRequest executionRequest = new DefaultMavenExecutionRequest(); - ProjectBuildingRequest buildingRequest = executionRequest.getProjectBuildingRequest(); - buildingRequest.setRepositorySession(session); - ProjectBuilder projectBuilder = this.lookup(ProjectBuilder.class); - MavenProject project = projectBuilder.build(pomFile, buildingRequest).getProject(); - assertNotNull(project); + var project = rule.readMavenProject(projectDirectory); // copy resources File source = new File(projectDirectory, "src/main/resources"); @@ -101,11 +79,11 @@ public void test(String projectName, String... types) throws Exception { } // load the Mojo - JCasGenMojo generate = (JCasGenMojo) this.lookupConfiguredMojo(project, "generate"); - assertNotNull(generate); + var generate = (JCasGenMojo) rule.lookupConfiguredMojo(project, "generate"); + assertThat(generate).isNotNull(); // set the MavenProject on the Mojo (AbstractMojoTestCase does not do this by default) - setVariableValueToObject(generate, "project", project); + rule.setVariableValueToObject(generate, "project", project); // execute the Mojo generate.execute(); @@ -114,17 +92,18 @@ public void test(String projectName, String... types) throws Exception { File jCasGenDirectory = new File(project.getBasedir(), "target/generated-sources/jcasgen"); // Record all the files that were generated - DirectoryScanner ds = new DirectoryScanner(); + var ds = new DirectoryScanner(); ds.setBasedir(jCasGenDirectory); ds.setIncludes(new String[] { "**/*.java" }); ds.scan(); - List files = new ArrayList<>(); - for (String scannedFile : ds.getIncludedFiles()) { + + var files = new ArrayList(); + for (var scannedFile : ds.getIncludedFiles()) { files.add(new File(ds.getBasedir(), scannedFile)); } - for (String type : types) { - File wrapperFile = new File(jCasGenDirectory + "/" + type.replace('.', '/') + ".java"); + for (var type : types) { + var wrapperFile = new File(jCasGenDirectory + "/" + type.replace('.', '/') + ".java"); // no _type files in v3 // File typeFile = new File(jCasGenDirectory + "/" + type.replace('.', '/') + "_Type.java"); diff --git a/uimaj-documentation/src/docs/asciidoc/ref/ref.config.adoc b/uimaj-documentation/src/docs/asciidoc/ref/ref.config.adoc index 0ef6edbf4..a47f32dbb 100644 --- a/uimaj-documentation/src/docs/asciidoc/ref/ref.config.adoc +++ b/uimaj-documentation/src/docs/asciidoc/ref/ref.config.adoc @@ -53,6 +53,7 @@ It causes the framework to throw a UIMARuntimeException if an update outside of This table describes the various JVM defined properties; specify these on the Java command line using -Dxxxxxx, where the xxxxxx is one of the properties starting with `uima.` from the table below. +.General properties [cols="1,1,1", frame="all"] |=== @@ -60,42 +61,28 @@ This table describes the various JVM defined properties; specify these on the Ja |**Property Name & Description** |**Since Version** -| - -Use built-in Java Logger as default back-end -| - -`uima.use_jul_as_default_uima_logger` +| Use built-in Java Logger as default back-end +| `uima.use_jul_as_default_uima_logger` See https://issues.apache.org/jira/browse/UIMA-5381[UIMA-5381]. The standard UIMA logger uses an slf4j implementation, which, in turn hooks up to a back end implementation based on what can be found in the class path (see slf4j documentation). If no backend implementation is found, the slf4j default is to use a NOP logger back end which discards all logging. When this flag is specified, the behavior of the UIMA logger is altered to use the built-in-to-Java logging implementation as the back end for the UIMA logger. -| - -3.0.0 - -| +| 3.0.0 -XML: enable doctype declarations -| - -`uima.xml.enable.doctype_decl` (default is false) +| XML: enable doctype declarations +| `uima.xml.enable.doctype_decl` (default is false) See https://issues.apache.org/jira/browse/UIMA-6064[UIMA-6064] Normally, this is turned off to avoid exposure to malicious XML; see https://www.owasp.org/index.php/XML_External_Entity_(XXE)_Processing[ XML External Entity processing vulnerability]. -| - -2.10.4, 3.1.0 - -|**Index protection properties** - -| - -Report Illegal Index-key Feature Updates -| +| 2.10.4, 3.1.0 +|=== -`uima.report_fs_update_corrupts_index` (default is not to report) +.Index protection properties +[cols="1,1,1", frame="all"] +|=== +| Report Illegal Index-key Feature Updates +| `uima.report_fs_update_corrupts_index` (default is not to report) See https://issues.apache.org/jira/browse/UIMA-4135[UIMA-4135]. Updating Features which are used in Set and Sorted indexes as "keys" may corrupt the indexes, if the Feature Structure (FS) has been added to the indexes. @@ -107,49 +94,34 @@ To scan the logs for these reports, search for instances of lines having the str Specifying this property overrides ``uima.disable_auto_protect_indexes``. Users would run with this property defined, and then for high performance, would use the report to manually change their code to avoid the problem or to wrap the updates with a `protectIndexes` kind of protection (see the reference manual, in the CAS or JCas chapters, for examples of user code doing this, and then run with the protection turned off (see below). -| - -2.7.0 - -| +| 2.7.0 -Throw exception on illegal Index-key Feature Updates -| - -`uima.exception_when_fs_update_corrupts_index` (default is false) +| Throw exception on illegal Index-key Feature Updates +| `uima.exception_when_fs_update_corrupts_index` (default is false) See https://issues.apache.org/jira/browse/UIMA-4150[UIMA-4150]. Throws a UIMARuntimeException if an Indexed FS feature used as a key in one or more indexes is updated, outside of an explicit `protectIndexes` block.. \ This is intended for use in automated build and test environments, to provide a strong signal if this kind of mistake gets into the build. If it is not set, then the other properties specify if corruption should be checked for, recovered automatically, and / or reported Specifying this property also forces `uima.report_fs_update_corrupts_index` to true even if it was set to false. -| - -2.7.0 - -| - -Disable the index corruption checking -| +| 2.7.0 -`uima.disable_auto_protect_indexes` +| Disable the index corruption checking +| `uima.disable_auto_protect_indexes` See https://issues.apache.org/jira/browse/UIMA-4135[UIMA-4135]. After you have fixed all reported issues identified with the above report, you may set this property to omit this check, which may slightly improve performance. Note that this property is ignored if the `-Dexception_when_fs_update_corrupts_index` or `-Dreport_fs_update_corrupts_index` -| - -2.7.0 - -|**Measurement / Tracing properties** - -| +| 2.7.0 +|=== -Trace Feature Structure Creation/Updating -| +.Measurement / Tracing properties +[cols="1,1,1", frame="all"] +|=== -`uima.trace_fs_creation_and_updating` +| Trace Feature Structure Creation/Updating +| `uima.trace_fs_creation_and_updating` This causes a trace file to be produced in the current working directory. The file has one line for each Feature Structure that is created, and include information on the cas/cas-view, and the features that are set for the Feature Structure. @@ -157,23 +129,15 @@ There is, additionally, one line for each Feature Structure update. Updates that occur next-to trace information for the same Feature Structure are combined. This can generate a lot of output, and definitely slows down execution. -| - -2.10.1 +| 2.10.1 -| - -Measure index flattening optimization -| - -`uima.measure.flatten_index` +| Measure index flattening optimization +| `uima.measure.flatten_index` See https://issues.apache.org/jira/browse/UIMA-4357[UIMA-4357]. This creates a short report to System.out when Java is shutdown. The report has some statistics about the automatic management of flattened index creation and use. -| - -2.8.0 +| 2.8.0 |=== Some additional global flags intended for helping v3 migration are documented in the V3 user's guide. \ No newline at end of file diff --git a/uimaj-it-pear-with-typesystem/pom.xml b/uimaj-it-pear-with-typesystem/pom.xml index 074cd2dec..1fb5a23df 100644 --- a/uimaj-it-pear-with-typesystem/pom.xml +++ b/uimaj-it-pear-with-typesystem/pom.xml @@ -102,7 +102,6 @@ org.apache.uima PearPackagingMavenPlugin - ${project.version} package-pear @@ -111,8 +110,7 @@ package - - desc/org/apache/uima/it/pear_with_typesystem/TestAnnotator.xml + desc/org/apache/uima/it/pear_with_typesystem/TestAnnotator.xml ${project.artifactId} $main_root/resources