You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by re...@apache.org on 2022/03/02 14:41:24 UTC
[uima-uimafit] 01/01: [UIMA-6424] Upgrade uimaFIT to JUnit 5
This is an automated email from the ASF dual-hosted git repository.
rec pushed a commit to branch reactoring/UIMA-6424-Upgrade-uimaFIT-to-JUnit-5
in repository https://gitbox.apache.org/repos/asf/uima-uimafit.git
commit 21a9c18e2e5e49b6de2f9a8680e3a7ec7fb8e963
Author: Richard Eckart de Castilho <re...@apache.org>
AuthorDate: Wed Mar 2 15:41:18 2022 +0100
[UIMA-6424] Upgrade uimaFIT to JUnit 5
- Migrating from JUnit 4 to JUnit 5
- Auto-formatting
- Add Eclipse formatter settings to repo
---
.gitignore | 1 +
installEclipseSettings.sh | 42 ++
.../main/eclipse}/org.eclipse.jdt.core.prefs | 31 +-
src/main/eclipse/org.eclipse.jdt.ui.prefs | 121 +++++
.../apache/uima/fit/testing/assertj/CasAssert.java | 18 +-
.../fit/testing/assertj/CasAssert_ImplBase.java | 83 ++--
.../uima/fit/testing/assertj/JCasAssert.java | 18 +-
.../fit/testing/assertj/ValidationCheckAssert.java | 3 +-
uimafit-benchmark/pom.xml | 7 +
.../java/org/apache/uima/fit/benchmark/Batch.java | 4 +-
.../org/apache/uima/fit/benchmark/Benchmark.java | 75 ++-
.../apache/uima/fit/benchmark/BenchmarkGroup.java | 17 +-
.../fit/benchmark/CachingRandomJCasProvider.java | 1 +
.../uima/fit/benchmark/CasInitializationUtils.java | 61 ++-
.../org/apache/uima/fit/benchmark/Measurement.java | 80 ++-
.../uima/fit/benchmark/RunnableWithExceptions.java | 2 +-
.../apache/uima/fit/benchmark/FSUtilBenchmark.java | 31 +-
.../uima/fit/benchmark/JCasFactoryBenchmark.java | 40 +-
.../apache/uima/fit/benchmark/SelectBenchmark.java | 453 +++++++++--------
uimafit-core/.settings/org.eclipse.jdt.core.prefs | 31 +-
uimafit-core/.settings/org.eclipse.jdt.ui.prefs | 121 ++++-
uimafit-core/pom.xml | 8 +-
.../uima/fit/component/CasAnnotator_ImplBase.java | 4 +-
.../uima/fit/component/CasConsumer_ImplBase.java | 4 +-
.../apache/uima/fit/component/CasDumpWriter.java | 13 +-
.../fit/component/CasFlowController_ImplBase.java | 4 +-
.../uima/fit/component/CasMultiplier_ImplBase.java | 4 +-
.../uima/fit/component/ExternalResourceAware.java | 5 +-
.../uima/fit/component/JCasAnnotator_ImplBase.java | 4 +-
.../uima/fit/component/JCasConsumer_ImplBase.java | 4 +-
.../fit/component/JCasFlowController_ImplBase.java | 4 +-
.../fit/component/JCasMultiplier_ImplBase.java | 4 +-
.../initialize/ExternalResourceInitializer.java | 24 +-
.../fit/component/initialize/package-info.java | 1 -
.../apache/uima/fit/component/package-info.java | 1 -
.../org/apache/uima/fit/descriptor/FsIndex.java | 4 +-
.../uima/fit/descriptor/LanguageCapability.java | 6 +-
.../uima/fit/descriptor/MimeTypeCapability.java | 6 +-
.../uima/fit/descriptor/ResourceMetaData.java | 8 +-
.../apache/uima/fit/descriptor/SofaCapability.java | 26 +-
.../apache/uima/fit/descriptor/TypeCapability.java | 12 +-
.../apache/uima/fit/descriptor/package-info.java | 1 -
.../uima/fit/factory/AnalysisEngineFactory.java | 33 +-
.../apache/uima/fit/factory/CapabilityFactory.java | 15 +-
.../org/apache/uima/fit/factory/CasFactory.java | 6 +-
.../uima/fit/factory/CollectionReaderFactory.java | 85 ++--
.../fit/factory/ConfigurationParameterFactory.java | 6 +-
.../uima/fit/factory/ExternalResourceFactory.java | 155 +++---
.../org/apache/uima/fit/factory/JCasFactory.java | 18 +-
.../factory/ResourceCreationSpecifierFactory.java | 3 +-
.../uima/fit/factory/ResourceMetaDataFactory.java | 36 +-
.../uima/fit/factory/SofaMappingFactory.java | 3 +-
.../initializable/InitializableFactory.java | 8 +-
.../org/apache/uima/fit/factory/package-info.java | 23 +-
.../apache/uima/fit/internal/ClassLoaderUtils.java | 3 +-
.../apache/uima/fit/internal/DescriptionUtils.java | 8 +-
.../ExtendedExternalResourceDescription_impl.java | 6 +-
.../apache/uima/fit/internal/LegacySupport.java | 4 +-
.../uima/fit/internal/LegacySupportPlugin.java | 36 +-
.../org/apache/uima/fit/internal/MetaDataType.java | 4 +-
.../apache/uima/fit/internal/ReflectionUtil.java | 24 +-
.../org/apache/uima/fit/internal/ResourceList.java | 6 +-
.../uima/fit/internal/ResourceManagerFactory.java | 12 +-
.../propertyeditors/GetAsTextStringEditor.java | 4 +-
.../propertyeditors/PropertyEditorUtil.java | 3 +-
.../org/apache/uima/fit/pipeline/JCasIterable.java | 10 +-
.../org/apache/uima/fit/pipeline/JCasIterator.java | 45 +-
.../apache/uima/fit/pipeline/SimplePipeline.java | 67 +--
.../org/apache/uima/fit/pipeline/package-info.java | 1 -
.../uima/fit/testing/factory/TokenBuilder.java | 12 +-
.../java/org/apache/uima/fit/util/CasIOUtil.java | 4 +-
.../java/org/apache/uima/fit/util/CasUtil.java | 204 ++++----
.../apache/uima/fit/util/FSCollectionFactory.java | 43 +-
.../main/java/org/apache/uima/fit/util/FSUtil.java | 237 ++++-----
.../java/org/apache/uima/fit/util/JCasUtil.java | 81 ++--
.../java/org/apache/uima/fit/util/LocaleUtil.java | 6 +-
.../org/apache/uima/fit/util/package-info.java | 29 +-
.../uima/fit/validation/ValidationCheck.java | 20 +-
.../fit/validation/ValidationCheckException.java | 4 +-
.../validation/ValidationCheckFailedException.java | 4 +-
.../org/apache/uima/fit/validation/Validator.java | 39 +-
.../src/test/java/DefaultPackageAETest.java | 9 +-
.../org/apache/uima/fit/ComponentTestBase.java | 10 +-
.../uima/fit/component/CasDumpWriterTest.java | 11 +-
.../uima/fit/component/CasMultiplierTest.java | 84 ++--
.../JCasCollectionReader_ImplBaseTest.java | 8 +-
.../fit/component/ViewCreatorAnnotatorTest.java | 73 ++-
.../fit/component/ViewTextCopierAnnotatorTest.java | 45 +-
.../ConfigurationParameterInitializerTest.java | 405 ++++++++--------
.../apache/uima/fit/data/CreateSampleXCASFile.java | 11 +-
.../uima/fit/descriptor/TypeCapabilityTest.java | 12 +-
.../uima/fit/factory/AggregateBuilderTest.java | 104 ++--
.../uima/fit/factory/AggregateWithReaderTest.java | 2 +-
.../AnalysisEngineFactoryExternalResourceTest.java | 262 +++++-----
.../fit/factory/AnalysisEngineFactoryTest.java | 357 +++++++-------
.../uima/fit/factory/AnnotationFactoryTest.java | 4 +-
...ollectionReaderFactoryExternalResourceTest.java | 12 +-
.../fit/factory/CollectionReaderFactoryTest.java | 60 +--
.../factory/ConfigurationParameterFactoryTest.java | 51 +-
...ameterFactory_ParameterValueConversionTest.java | 2 +-
.../factory/ExternalResourceConfiguratorTest.java | 6 +-
.../fit/factory/ExternalResourceFactoryTest.java | 232 ++++-----
.../FlowControllerFactoryExternalResourceTest.java | 10 +-
.../fit/factory/FlowControllerFactoryTest.java | 15 +-
.../uima/fit/factory/FsIndexFactoryTest.java | 10 +-
.../apache/uima/fit/factory/JCasBuilderTest.java | 21 +-
.../apache/uima/fit/factory/JCasFactoryTest.java | 4 +-
.../ResourceCreationSpecifierFactoryTest.java | 37 +-
.../fit/factory/ResourceManagerFactoryTest.java | 13 +-
.../fit/factory/ResourceMetaDataFactoryTest.java | 4 +-
.../uima/fit/factory/SofaMappingFactoryTest.java | 4 +-
.../fit/factory/TypePrioritiesFactoryTest.java | 20 +-
.../factory/TypeSystemDescriptionFactoryTest.java | 4 +-
.../uima/fit/factory/UimaContextFactoryTest.java | 14 +-
.../initializable/InitializableFactoryTest.java | 30 +-
.../uima/fit/factory/testAes/ParameterizedAE.java | 14 +-
.../testAes/ReversableTestFlowController.java | 4 +-
.../testAes/SerializationTestAnnotator.java | 2 +-
.../fit/factory/testCrs/SingleFileXReader.java | 7 +-
.../fit/factory/testCrs/SingleFileXReaderTest.java | 47 +-
.../fit/factory/testRes/TestExternalResource.java | 6 +-
.../factory/testRes/TestSharedResourceObject.java | 6 +-
.../apache/uima/fit/pipeline/JCasIterableTest.java | 94 ++--
.../uima/fit/pipeline/SimplePipelineTest.java | 43 +-
.../uima/fit/testing/factory/TokenBuilderTest.java | 36 +-
.../uima/fit/util/AnnotationPredicateTestData.java | 150 +++---
.../java/org/apache/uima/fit/util/CasUtilTest.java | 153 +++---
.../apache/uima/fit/util/ContainmentIndexTest.java | 8 +-
.../apache/uima/fit/util/DisableLoggingTest.java | 6 +-
.../uima/fit/util/FSCollectionFactoryTest.java | 93 ++--
.../java/org/apache/uima/fit/util/FSUtilTest.java | 71 ++-
.../org/apache/uima/fit/util/HideOutputTest.java | 6 +-
.../org/apache/uima/fit/util/JCasIterableTest.java | 2 +-
.../org/apache/uima/fit/util/JCasUtilTest.java | 535 ++++++++++-----------
.../org/apache/uima/fit/util/JCasUtilv3Test.java | 172 +++----
.../org/apache/uima/fit/util/LocaleUtilTest.java | 9 +-
.../org/apache/uima/fit/util/SelectionAssert.java | 51 +-
.../apache/uima/fit/util/SimplePipelineTest.java | 22 +-
.../fit/validation/CasValidatorBuilderTest.java | 12 +-
.../checks/EndSameAsBeginCheckForTesting.java | 2 +-
uimafit-cpe/.settings/org.eclipse.jdt.core.prefs | 136 +++++-
uimafit-cpe/.settings/org.eclipse.jdt.ui.prefs | 120 ++++-
uimafit-cpe/pom.xml | 5 +
.../org/apache/uima/fit/cpe/CasMultiplierTest.java | 71 ++-
.../fit/cpe/CpePipelineFailureHandlingTest.java | 9 +-
.../org/apache/uima/fit/cpe/CpePipelineTest.java | 12 +-
.../uima/fit/cpe/ExternalResourceFactoryTest.java | 64 ++-
.../.settings/org.eclipse.jdt.core.prefs | 139 +++++-
.../.settings/org.eclipse.jdt.ui.prefs | 120 ++++-
uimafit-examples/pom.xml | 11 +-
.../fit/examples/experiment/pos/GoldTagger.java | 2 +-
.../fit/examples/experiment/pos/RunExperiment.java | 25 +-
.../fit/examples/experiment/pos/XmiWriter.java | 3 +-
.../fit/examples/experiment/pos/package-info.java | 1 -
.../getstarted/GetStartedQuickDescriptor.java | 4 +-
.../uima/fit/examples/getstarted/package-info.java | 1 -
.../examples/resource/ExternalResourceExample.java | 4 +-
.../resource/ExternalResourceExample3.java | 4 +-
.../uima/fit/examples/resource/package-info.java | 1 -
.../fit/examples/tutorial/ex1/package-info.java | 1 -
.../examples/tutorial/ex2/RoomNumberAnnotator.java | 6 +-
.../fit/examples/tutorial/ex2/package-info.java | 1 -
.../tutorial/ex6/UimaAcronymAnnotator.java | 7 +-
.../fit/examples/tutorial/ex6/package-info.java | 1 -
.../fit/examples/tutorial/ExamplesTestBase.java | 7 +-
.../tutorial/ex1/RoomNumberAnnotator1Test.java | 10 +-
.../tutorial/ex1/RoomNumberAnnotator2Test.java | 10 +-
.../fit/examples/tutorial/ex6/Example6Test.java | 9 +-
.../org/apache/uima/fit/examples/xmi/XmiTest.java | 19 +-
uimafit-junit/pom.xml | 8 +-
.../apache/uima/fit/testing/junit/ManagedCas.java | 98 ++--
.../apache/uima/fit/testing/junit/ManagedJCas.java | 98 ++--
.../.settings/org.eclipse.jdt.core.prefs | 139 +++++-
.../.settings/org.eclipse.jdt.ui.prefs | 120 ++++-
uimafit-maven-plugin/pom.xml | 11 +
.../org/apache/uima/fit/maven/EnhanceMojo.java | 59 +--
.../apache/uima/fit/maven/util/ComponentType.java | 1 +
.../java/org/apache/uima/fit/maven/util/Util.java | 53 +-
.../javadoc/ComponentDescriptionExtractorTest.java | 4 +-
.../maven/javadoc/JavadocTextExtractorTest.java | 8 +-
uimafit-parent/pom.xml | 83 ++--
.../.settings/org.eclipse.jdt.core.prefs | 139 +++++-
uimafit-spring/.settings/org.eclipse.jdt.ui.prefs | 120 ++++-
uimafit-spring/pom.xml | 26 +-
.../fit/spring/SpringContextResourceManager.java | 4 +-
.../spring/factory/CasConsumerFactory_impl.java | 4 +-
.../spring/util/ResourceInitializationUtil.java | 3 +-
.../spring/SpringContextResourceManagerTest.java | 8 +-
.../uima/fit/spring/UimaFactoryInjectionTest.java | 13 +-
189 files changed, 4559 insertions(+), 3434 deletions(-)
diff --git a/.gitignore b/.gitignore
index d4318d8..ed5ad65 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,3 +4,4 @@
target/
api-change-report/
issuesFixed
+.idea
diff --git a/installEclipseSettings.sh b/installEclipseSettings.sh
new file mode 100755
index 0000000..5e932e6
--- /dev/null
+++ b/installEclipseSettings.sh
@@ -0,0 +1,42 @@
+#/bin/sh
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Formatter settings
+JDT_CORE_PREFS="src/main/eclipse/org.eclipse.jdt.core.prefs"
+
+# Save actions
+JDT_UI_PREFS="src/main/eclipse/org.eclipse.jdt.ui.prefs"
+
+function installPrefs {
+ mkdir -p $1/.settings/
+ cp -v $JDT_CORE_PREFS $1/.settings/
+ cp -v $JDT_UI_PREFS $1/.settings/
+}
+
+installPrefs .
+installPrefs uimafit-doc
+installPrefs uimafit-docbook
+installPrefs uimafit-parent
+installPrefs uimafit-assertj
+installPrefs uimafit-benchmark
+installPrefs uimafit-core
+installPrefs uimafit-cpe
+installPrefs uimafit-examples
+installPrefs uimafit-junit
+installPrefs uimafit-maven-plugin
+installPrefs uimafit-spring
diff --git a/uimafit-core/.settings/org.eclipse.jdt.core.prefs b/src/main/eclipse/org.eclipse.jdt.core.prefs
similarity index 96%
copy from uimafit-core/.settings/org.eclipse.jdt.core.prefs
copy to src/main/eclipse/org.eclipse.jdt.core.prefs
index 4ff91b1..9ed6a9e 100644
--- a/uimafit-core/.settings/org.eclipse.jdt.core.prefs
+++ b/src/main/eclipse/org.eclipse.jdt.core.prefs
@@ -7,7 +7,7 @@ org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
-org.eclipse.jdt.core.compiler.processAnnotations=disabled
+org.eclipse.jdt.core.compiler.processAnnotations=enabled
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false
@@ -16,14 +16,21 @@ org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns=false
org.eclipse.jdt.core.formatter.align_with_spaces=false
org.eclipse.jdt.core.formatter.alignment_for_additive_operator=16
+org.eclipse.jdt.core.formatter.alignment_for_annotations_on_enum_constant=49
+org.eclipse.jdt.core.formatter.alignment_for_annotations_on_field=49
+org.eclipse.jdt.core.formatter.alignment_for_annotations_on_local_variable=49
+org.eclipse.jdt.core.formatter.alignment_for_annotations_on_method=49
+org.eclipse.jdt.core.formatter.alignment_for_annotations_on_package=49
+org.eclipse.jdt.core.formatter.alignment_for_annotations_on_parameter=49
+org.eclipse.jdt.core.formatter.alignment_for_annotations_on_type=49
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_assertion_message=0
org.eclipse.jdt.core.formatter.alignment_for_assignment=0
-org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator=16
org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
org.eclipse.jdt.core.formatter.alignment_for_compact_loops=16
@@ -52,6 +59,7 @@ org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_record_declarati
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_type_annotations=0
org.eclipse.jdt.core.formatter.alignment_for_type_arguments=0
org.eclipse.jdt.core.formatter.alignment_for_type_parameters=0
org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16
@@ -59,7 +67,7 @@ org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
org.eclipse.jdt.core.formatter.blank_lines_after_last_class_body_declaration=0
org.eclipse.jdt.core.formatter.blank_lines_after_package=1
org.eclipse.jdt.core.formatter.blank_lines_before_abstract_method=1
-org.eclipse.jdt.core.formatter.blank_lines_before_field=1
+org.eclipse.jdt.core.formatter.blank_lines_before_field=0
org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
@@ -110,7 +118,7 @@ org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off
org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on
org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
-org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=false
+org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
@@ -128,7 +136,7 @@ org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert
-org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
@@ -139,13 +147,6 @@ org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_ini
org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
-org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert
-org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert
-org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert
-org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
-org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
-org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
-org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_after_additive_operator=insert
org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_case=insert
@@ -153,7 +154,6 @@ org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_default=insert
org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
@@ -227,7 +227,6 @@ org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_case=insert
org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_default=insert
org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
-org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator=insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
@@ -382,11 +381,11 @@ org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
org.eclipse.jdt.core.formatter.tabulation.char=space
org.eclipse.jdt.core.formatter.tabulation.size=2
org.eclipse.jdt.core.formatter.text_block_indentation=0
-org.eclipse.jdt.core.formatter.use_on_off_tags=false
+org.eclipse.jdt.core.formatter.use_on_off_tags=true
org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
org.eclipse.jdt.core.formatter.wrap_before_additive_operator=true
+org.eclipse.jdt.core.formatter.wrap_before_assertion_message_operator=true
org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false
-org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator=true
org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true
org.eclipse.jdt.core.formatter.wrap_before_logical_operator=true
diff --git a/src/main/eclipse/org.eclipse.jdt.ui.prefs b/src/main/eclipse/org.eclipse.jdt.ui.prefs
new file mode 100644
index 0000000..10948b0
--- /dev/null
+++ b/src/main/eclipse/org.eclipse.jdt.ui.prefs
@@ -0,0 +1,121 @@
+eclipse.preferences.version=1
+editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
+formatter_profile=_Apache UIMA Code Conventions
+formatter_settings_version=21
+sp_cleanup.add_all=false
+sp_cleanup.add_default_serial_version_id=true
+sp_cleanup.add_generated_serial_version_id=false
+sp_cleanup.add_missing_annotations=true
+sp_cleanup.add_missing_deprecated_annotations=true
+sp_cleanup.add_missing_methods=false
+sp_cleanup.add_missing_nls_tags=false
+sp_cleanup.add_missing_override_annotations=true
+sp_cleanup.add_missing_override_annotations_interface_methods=true
+sp_cleanup.add_serial_version_id=false
+sp_cleanup.always_use_blocks=true
+sp_cleanup.always_use_parentheses_in_expressions=false
+sp_cleanup.always_use_this_for_non_static_field_access=false
+sp_cleanup.always_use_this_for_non_static_method_access=false
+sp_cleanup.arrays_fill=false
+sp_cleanup.bitwise_conditional_expression=false
+sp_cleanup.boolean_literal=false
+sp_cleanup.break_loop=false
+sp_cleanup.collection_cloning=false
+sp_cleanup.comparing_on_criteria=false
+sp_cleanup.comparison_statement=false
+sp_cleanup.controlflow_merge=false
+sp_cleanup.convert_functional_interfaces=false
+sp_cleanup.convert_to_enhanced_for_loop=false
+sp_cleanup.convert_to_enhanced_for_loop_if_loop_var_used=false
+sp_cleanup.convert_to_switch_expressions=false
+sp_cleanup.correct_indentation=false
+sp_cleanup.double_negation=false
+sp_cleanup.else_if=false
+sp_cleanup.embedded_if=false
+sp_cleanup.evaluate_nullable=false
+sp_cleanup.extract_increment=false
+sp_cleanup.format_source_code=true
+sp_cleanup.format_source_code_changes_only=false
+sp_cleanup.hash=false
+sp_cleanup.if_condition=false
+sp_cleanup.insert_inferred_type_arguments=false
+sp_cleanup.instanceof=false
+sp_cleanup.invert_equals=false
+sp_cleanup.join=false
+sp_cleanup.lazy_logical_operator=false
+sp_cleanup.make_local_variable_final=false
+sp_cleanup.make_parameters_final=false
+sp_cleanup.make_private_fields_final=true
+sp_cleanup.make_type_abstract_if_missing_method=false
+sp_cleanup.make_variable_declarations_final=false
+sp_cleanup.map_cloning=false
+sp_cleanup.merge_conditional_blocks=false
+sp_cleanup.multi_catch=false
+sp_cleanup.never_use_blocks=false
+sp_cleanup.never_use_parentheses_in_expressions=true
+sp_cleanup.no_string_creation=false
+sp_cleanup.no_super=true
+sp_cleanup.number_suffix=false
+sp_cleanup.objects_equals=false
+sp_cleanup.on_save_use_additional_actions=true
+sp_cleanup.organize_imports=true
+sp_cleanup.overridden_assignment=false
+sp_cleanup.plain_replacement=false
+sp_cleanup.precompile_regex=false
+sp_cleanup.primitive_comparison=false
+sp_cleanup.primitive_parsing=false
+sp_cleanup.primitive_serialization=false
+sp_cleanup.pull_up_assignment=false
+sp_cleanup.push_down_negation=false
+sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
+sp_cleanup.reduce_indentation=false
+sp_cleanup.redundant_falling_through_block_end=false
+sp_cleanup.remove_private_constructors=true
+sp_cleanup.remove_redundant_modifiers=true
+sp_cleanup.remove_redundant_semicolons=false
+sp_cleanup.remove_redundant_type_arguments=false
+sp_cleanup.remove_trailing_whitespaces=false
+sp_cleanup.remove_trailing_whitespaces_all=true
+sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
+sp_cleanup.remove_unnecessary_array_creation=false
+sp_cleanup.remove_unnecessary_casts=false
+sp_cleanup.remove_unnecessary_nls_tags=false
+sp_cleanup.remove_unused_imports=true
+sp_cleanup.remove_unused_local_variables=false
+sp_cleanup.remove_unused_private_fields=true
+sp_cleanup.remove_unused_private_members=false
+sp_cleanup.remove_unused_private_methods=true
+sp_cleanup.remove_unused_private_types=true
+sp_cleanup.simplify_lambda_expression_and_method_ref=false
+sp_cleanup.single_used_field=false
+sp_cleanup.sort_members=false
+sp_cleanup.sort_members_all=false
+sp_cleanup.standard_comparison=false
+sp_cleanup.static_inner_class=false
+sp_cleanup.strictly_equal_or_different=false
+sp_cleanup.stringbuilder=false
+sp_cleanup.substring=false
+sp_cleanup.switch=false
+sp_cleanup.ternary_operator=false
+sp_cleanup.try_with_resource=false
+sp_cleanup.unlooped_while=false
+sp_cleanup.unreachable_block=false
+sp_cleanup.use_anonymous_class_creation=false
+sp_cleanup.use_autoboxing=false
+sp_cleanup.use_blocks=true
+sp_cleanup.use_blocks_only_for_return_and_throw=false
+sp_cleanup.use_directly_map_method=false
+sp_cleanup.use_lambda=false
+sp_cleanup.use_parentheses_in_expressions=false
+sp_cleanup.use_this_for_non_static_field_access=false
+sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
+sp_cleanup.use_this_for_non_static_method_access=false
+sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
+sp_cleanup.use_unboxing=false
+sp_cleanup.use_var=false
+sp_cleanup.useless_continue=false
+sp_cleanup.useless_return=false
diff --git a/uimafit-assertj/src/main/java/org/apache/uima/fit/testing/assertj/CasAssert.java b/uimafit-assertj/src/main/java/org/apache/uima/fit/testing/assertj/CasAssert.java
index 8b320ff..b9adc06 100644
--- a/uimafit-assertj/src/main/java/org/apache/uima/fit/testing/assertj/CasAssert.java
+++ b/uimafit-assertj/src/main/java/org/apache/uima/fit/testing/assertj/CasAssert.java
@@ -23,16 +23,12 @@ import org.apache.uima.cas.CAS;
/**
* Asserts related to the {@link CAS}.
*/
-public class CasAssert
- extends CasAssert_ImplBase<CasAssert, CAS>
-{
- public CasAssert(CAS actual)
- {
- super(actual, CasAssert.class);
- }
+public class CasAssert extends CasAssert_ImplBase<CasAssert, CAS> {
+ public CasAssert(CAS actual) {
+ super(actual, CasAssert.class);
+ }
- public static CasAssert assertThat(CAS actual)
- {
- return new CasAssert(actual);
- }
+ public static CasAssert assertThat(CAS actual) {
+ return new CasAssert(actual);
+ }
}
\ No newline at end of file
diff --git a/uimafit-assertj/src/main/java/org/apache/uima/fit/testing/assertj/CasAssert_ImplBase.java b/uimafit-assertj/src/main/java/org/apache/uima/fit/testing/assertj/CasAssert_ImplBase.java
index 3a22e1f..a931105 100644
--- a/uimafit-assertj/src/main/java/org/apache/uima/fit/testing/assertj/CasAssert_ImplBase.java
+++ b/uimafit-assertj/src/main/java/org/apache/uima/fit/testing/assertj/CasAssert_ImplBase.java
@@ -34,57 +34,50 @@ import org.assertj.core.api.Fail;
* Asserts related to the {@link CAS}.
*/
public class CasAssert_ImplBase<SELF extends CasAssert_ImplBase<SELF, ACTUAL>, ACTUAL>
- extends AbstractAssert<SELF, ACTUAL>
-{
- public CasAssert_ImplBase(ACTUAL aActual, Class<?> aSelfType)
- {
- super(aActual, aSelfType);
+ extends AbstractAssert<SELF, ACTUAL> {
+ public CasAssert_ImplBase(ACTUAL aActual, Class<?> aSelfType) {
+ super(aActual, aSelfType);
+ }
+
+ protected ValidationSummary validate(Validator aValidator) throws ValidationException {
+ if (actual instanceof CAS) {
+ return aValidator.check((CAS) actual);
}
-
- protected ValidationSummary validate(Validator aValidator) throws ValidationException
- {
- if (actual instanceof CAS) {
- return aValidator.check((CAS) actual);
- }
- if (actual instanceof JCas) {
- return aValidator.check((JCas) actual);
- }
-
- throw new IllegalArgumentException(
- "Unsupported CAS implementation [" + actual.getClass().getName() + "]");
+ if (actual instanceof JCas) {
+ return aValidator.check((JCas) actual);
}
- /**
- * Checks that CAS is valid using the auto-detected validation checks.
- */
- public SELF isValid()
- {
- return isValidUsing(new Validator.Builder().build());
- }
-
- /**
- * Checks that CAS is valid using the given validator.
- */
- public SELF isValidUsing(Validator aValidator)
- {
- isNotNull();
+ throw new IllegalArgumentException(
+ "Unsupported CAS implementation [" + actual.getClass().getName() + "]");
+ }
- try {
- ValidationSummary summary = validate(aValidator);
+ /**
+ * Checks that CAS is valid using the auto-detected validation checks.
+ */
+ public SELF isValid() {
+ return isValidUsing(new Validator.Builder().build());
+ }
- String messageBuffer = summary.getResults().stream()
- .filter(r -> r.getSeverity().isEquallyOrMoreSevereThan(ERROR))
- .map(r -> format("[%s] %s", r.getSource(), r.getMessage()))
- .collect(joining("\n"));
+ /**
+ * Checks that CAS is valid using the given validator.
+ */
+ public SELF isValidUsing(Validator aValidator) {
+ isNotNull();
- if (messageBuffer.length() > 0) {
- Fail.fail(messageBuffer);
- }
- }
- catch (ValidationException e) {
- Fail.fail("Unable to validate CAS", e);
- }
+ try {
+ ValidationSummary summary = validate(aValidator);
- return myself;
+ String messageBuffer = summary.getResults().stream()
+ .filter(r -> r.getSeverity().isEquallyOrMoreSevereThan(ERROR))
+ .map(r -> format("[%s] %s", r.getSource(), r.getMessage())).collect(joining("\n"));
+
+ if (messageBuffer.length() > 0) {
+ Fail.fail(messageBuffer);
+ }
+ } catch (ValidationException e) {
+ Fail.fail("Unable to validate CAS", e);
}
+
+ return myself;
+ }
}
\ No newline at end of file
diff --git a/uimafit-assertj/src/main/java/org/apache/uima/fit/testing/assertj/JCasAssert.java b/uimafit-assertj/src/main/java/org/apache/uima/fit/testing/assertj/JCasAssert.java
index de1b60c..86ad5df 100644
--- a/uimafit-assertj/src/main/java/org/apache/uima/fit/testing/assertj/JCasAssert.java
+++ b/uimafit-assertj/src/main/java/org/apache/uima/fit/testing/assertj/JCasAssert.java
@@ -23,16 +23,12 @@ import org.apache.uima.jcas.JCas;
/**
* Asserts related to the {@link JCas}.
*/
-public class JCasAssert
- extends CasAssert_ImplBase<JCasAssert, JCas>
-{
- public JCasAssert(JCas actual)
- {
- super(actual, JCasAssert.class);
- }
+public class JCasAssert extends CasAssert_ImplBase<JCasAssert, JCas> {
+ public JCasAssert(JCas actual) {
+ super(actual, JCasAssert.class);
+ }
- public static JCasAssert assertThat(JCas actual)
- {
- return new JCasAssert(actual);
- }
+ public static JCasAssert assertThat(JCas actual) {
+ return new JCasAssert(actual);
+ }
}
\ No newline at end of file
diff --git a/uimafit-assertj/src/main/java/org/apache/uima/fit/testing/assertj/ValidationCheckAssert.java b/uimafit-assertj/src/main/java/org/apache/uima/fit/testing/assertj/ValidationCheckAssert.java
index 8ef8e8b..e01f357 100644
--- a/uimafit-assertj/src/main/java/org/apache/uima/fit/testing/assertj/ValidationCheckAssert.java
+++ b/uimafit-assertj/src/main/java/org/apache/uima/fit/testing/assertj/ValidationCheckAssert.java
@@ -29,8 +29,7 @@ import org.assertj.core.api.AbstractAssert;
/**
* Asserts related to {@link ValidationCheck} implementations.
*/
-public class ValidationCheckAssert
- extends AbstractAssert<ValidationCheckAssert, ValidationCheck> {
+public class ValidationCheckAssert extends AbstractAssert<ValidationCheckAssert, ValidationCheck> {
public ValidationCheckAssert(ValidationCheck actual) {
super(actual, ValidationCheckAssert.class);
}
diff --git a/uimafit-benchmark/pom.xml b/uimafit-benchmark/pom.xml
index 2b754dc..6a6ca4b 100644
--- a/uimafit-benchmark/pom.xml
+++ b/uimafit-benchmark/pom.xml
@@ -43,6 +43,7 @@
<groupId>org.apache.uima</groupId>
<artifactId>uimaj-core</artifactId>
</dependency>
+
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
@@ -52,6 +53,12 @@
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
+
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
diff --git a/uimafit-benchmark/src/main/java/org/apache/uima/fit/benchmark/Batch.java b/uimafit-benchmark/src/main/java/org/apache/uima/fit/benchmark/Batch.java
index 51d2427..06f2202 100644
--- a/uimafit-benchmark/src/main/java/org/apache/uima/fit/benchmark/Batch.java
+++ b/uimafit-benchmark/src/main/java/org/apache/uima/fit/benchmark/Batch.java
@@ -42,11 +42,11 @@ public class Batch {
public List<Measurement> getMeasurements() {
return measurements;
}
-
+
public void setTimeLimitExceeded(boolean aTimeLimitExceeded) {
timeLimitExceeded = aTimeLimitExceeded;
}
-
+
public boolean isTimeLimitExceeded() {
return timeLimitExceeded;
}
diff --git a/uimafit-benchmark/src/main/java/org/apache/uima/fit/benchmark/Benchmark.java b/uimafit-benchmark/src/main/java/org/apache/uima/fit/benchmark/Benchmark.java
index df49c62..cff66b1 100644
--- a/uimafit-benchmark/src/main/java/org/apache/uima/fit/benchmark/Benchmark.java
+++ b/uimafit-benchmark/src/main/java/org/apache/uima/fit/benchmark/Benchmark.java
@@ -53,7 +53,7 @@ public class Benchmark {
private LongSupplier timer = () -> System.currentTimeMillis();
private DoubleFunction<Double> toMs = n -> n;
private long timeLimitMs = 5 * 1000;
-
+
private boolean ignore = false;
private List<Batch> batches = new ArrayList<>();
@@ -72,28 +72,26 @@ public class Benchmark {
this(aName);
applyTemplate(aTemplate);
}
-
+
public Benchmark ignore(boolean aIgnore) {
ignore = aIgnore;
return this;
}
-
+
public boolean isIgnored() {
return ignore;
}
- public Benchmark limit(long aLimit)
- {
+ public Benchmark limit(long aLimit) {
timeLimitMs = aLimit;
return this;
}
-
+
public long getTimeLimitMs() {
return timeLimitMs;
}
- public void applyTemplate(Benchmark aTemplate)
- {
+ public void applyTemplate(Benchmark aTemplate) {
initializer = aTemplate.initializer;
baseRepeat = aTemplate.baseRepeat;
@@ -150,14 +148,14 @@ public class Benchmark {
Batch batch = new Batch(aMagnitude);
initializer.accept(aMagnitude);
-
+
long initTime = System.currentTimeMillis();
for (int i = 0; i < baseRepeat; i++) {
long startTime = timer.getAsLong();
try {
subject.run();
batch.addMeasurement(new Measurement(i, timer.getAsLong() - startTime));
-
+
if (System.currentTimeMillis() > initTime + getTimeLimitMs()) {
batch.setTimeLimitExceeded(true);
break;
@@ -172,13 +170,12 @@ public class Benchmark {
public void run() {
stats = null;
-
+
if (verbose) {
System.out.printf("%n%s%n", StringUtils.repeat("=", name.length()));
System.out.printf("%s%n", name);
System.out.printf("%s%n", StringUtils.repeat("=", name.length()));
- }
- else {
+ } else {
System.out.printf("%s: ", name);
}
@@ -192,7 +189,7 @@ public class Benchmark {
}
Batch results = runBatch(magnitude);
if (!ignore) {
- batches.add(results);
+ batches.add(results);
}
magnitude = magnitudeIncrement.apply(magnitude);
n++;
@@ -223,42 +220,34 @@ public class Benchmark {
}
public Measurement getSlowestMeasurement() {
- return getBatches().stream()
- .flatMap(b -> b.getMeasurements().stream())
- .max(comparing(Measurement::getDuration))
- .get();
+ return getBatches().stream().flatMap(b -> b.getMeasurements().stream())
+ .max(comparing(Measurement::getDuration)).get();
}
-
- public DescriptiveStatistics getStats()
- {
+
+ public DescriptiveStatistics getStats() {
if (stats == null) {
stats = new DescriptiveStatistics();
- getBatches().stream()
- .flatMap(b -> b.getMeasurements().stream())
- .mapToLong(Measurement::getDuration)
- .forEach(stats::addValue);
+ getBatches().stream().flatMap(b -> b.getMeasurements().stream())
+ .mapToLong(Measurement::getDuration).forEach(stats::addValue);
}
return stats;
}
-
- public double toMs(double duration)
- {
+
+ public double toMs(double duration) {
return toMs.apply(duration);
}
-
- public String batchToString(Batch aBatch)
- {
+
+ public String batchToString(Batch aBatch) {
DescriptiveStatistics batchStats = new DescriptiveStatistics();
-
+
StringBuilder sb = new StringBuilder();
- sb.append("[").append(String.format("%7d/%7d | ", aBatch.getMagnitude(),
- aBatch.getMeasurements().size()));
+ sb.append("[").append(
+ String.format("%7d/%7d | ", aBatch.getMagnitude(), aBatch.getMeasurements().size()));
int failures = 0;
for (Measurement m : aBatch.getMeasurements()) {
if (m.failed()) {
failures++;
- }
- else {
+ } else {
batchStats.addValue(m.getDuration());
}
}
@@ -276,8 +265,8 @@ public class Benchmark {
/** Get CPU time in nanoseconds. */
public static long cpuTime() {
- ThreadMXBean bean = ManagementFactory.getThreadMXBean( );
- if(bean.isCurrentThreadCpuTimeSupported( )) {
+ ThreadMXBean bean = ManagementFactory.getThreadMXBean();
+ if (bean.isCurrentThreadCpuTimeSupported()) {
return bean.getCurrentThreadCpuTime();
}
throw new UnsupportedOperationException(CPU_TIME_NOT_SUPPORTED_MSG);
@@ -285,8 +274,8 @@ public class Benchmark {
/** Get user time in nanoseconds. */
public static long userTime() {
- ThreadMXBean bean = ManagementFactory.getThreadMXBean( );
- if(bean.isCurrentThreadCpuTimeSupported( )) {
+ ThreadMXBean bean = ManagementFactory.getThreadMXBean();
+ if (bean.isCurrentThreadCpuTimeSupported()) {
return bean.getCurrentThreadUserTime();
}
throw new UnsupportedOperationException(CPU_TIME_NOT_SUPPORTED_MSG);
@@ -294,9 +283,9 @@ public class Benchmark {
/** Get static system time in nanoseconds. */
public static long system() {
- ThreadMXBean bean = ManagementFactory.getThreadMXBean( );
- if(bean.isCurrentThreadCpuTimeSupported( )) {
- return bean.getCurrentThreadCpuTime( ) - bean.getCurrentThreadUserTime( );
+ ThreadMXBean bean = ManagementFactory.getThreadMXBean();
+ if (bean.isCurrentThreadCpuTimeSupported()) {
+ return bean.getCurrentThreadCpuTime() - bean.getCurrentThreadUserTime();
}
throw new UnsupportedOperationException(CPU_TIME_NOT_SUPPORTED_MSG);
}
diff --git a/uimafit-benchmark/src/main/java/org/apache/uima/fit/benchmark/BenchmarkGroup.java b/uimafit-benchmark/src/main/java/org/apache/uima/fit/benchmark/BenchmarkGroup.java
index a6f0e05..ac999ee 100644
--- a/uimafit-benchmark/src/main/java/org/apache/uima/fit/benchmark/BenchmarkGroup.java
+++ b/uimafit-benchmark/src/main/java/org/apache/uima/fit/benchmark/BenchmarkGroup.java
@@ -61,15 +61,14 @@ public class BenchmarkGroup {
}
System.out.printf("%n%nSorted by execution time:%n");
- benchmarks.stream()
- .filter(b -> !b.isIgnored())
- .sorted(comparing(Benchmark::getAverageDuration))
- .forEach(benchmark -> {
- System.out.printf("AVG: %.3fms (%10s total) -- %s%n",
- benchmark.toMs(benchmark.getAverageDuration()),
- formatDurationWords(round(benchmark.toMs(benchmark.getCumulativeDuration())), true, true),
- benchmark.getName());
- });
+ benchmarks.stream().filter(b -> !b.isIgnored()).sorted(comparing(Benchmark::getAverageDuration))
+ .forEach(benchmark -> {
+ System.out.printf("AVG: %.3fms (%10s total) -- %s%n",
+ benchmark.toMs(benchmark.getAverageDuration()),
+ formatDurationWords(round(benchmark.toMs(benchmark.getCumulativeDuration())),
+ true, true),
+ benchmark.getName());
+ });
System.out.printf(">>>>>>>>>>>>>>>>>>%n%n");
}
diff --git a/uimafit-benchmark/src/main/java/org/apache/uima/fit/benchmark/CachingRandomJCasProvider.java b/uimafit-benchmark/src/main/java/org/apache/uima/fit/benchmark/CachingRandomJCasProvider.java
index 5edea66..46066bd 100644
--- a/uimafit-benchmark/src/main/java/org/apache/uima/fit/benchmark/CachingRandomJCasProvider.java
+++ b/uimafit-benchmark/src/main/java/org/apache/uima/fit/benchmark/CachingRandomJCasProvider.java
@@ -22,6 +22,7 @@ import static org.apache.uima.fit.benchmark.CasInitializationUtils.initRandomCas
import java.util.HashMap;
import java.util.Map;
+
import org.apache.uima.cas.CASException;
import org.apache.uima.fit.factory.JCasFactory;
import org.apache.uima.jcas.JCas;
diff --git a/uimafit-benchmark/src/main/java/org/apache/uima/fit/benchmark/CasInitializationUtils.java b/uimafit-benchmark/src/main/java/org/apache/uima/fit/benchmark/CasInitializationUtils.java
index ed595bf..6a176d4 100644
--- a/uimafit-benchmark/src/main/java/org/apache/uima/fit/benchmark/CasInitializationUtils.java
+++ b/uimafit-benchmark/src/main/java/org/apache/uima/fit/benchmark/CasInitializationUtils.java
@@ -28,42 +28,39 @@ import org.apache.uima.cas.Type;
import org.apache.uima.fit.type.Sentence;
import org.apache.uima.fit.type.Token;
-public final class CasInitializationUtils
-{
- private CasInitializationUtils()
- {
- // No instances
- }
+public final class CasInitializationUtils {
+ private CasInitializationUtils() {
+ // No instances
+ }
- public static void initRandomCas(CAS cas, int typeCount, int annotationCount, int maxAnnotationLength,
- int approxDocLength, long seed) {
- cas.reset();
- Random rnd = new Random(seed);
- List<Type> types = new ArrayList<Type>();
- types.add(cas.getTypeSystem().getType(Token.class.getName()));
- types.add(cas.getTypeSystem().getType(Sentence.class.getName()));
+ public static void initRandomCas(CAS cas, int typeCount, int annotationCount,
+ int maxAnnotationLength, int approxDocLength, long seed) {
+ cas.reset();
+ Random rnd = new Random(seed);
+ List<Type> types = new ArrayList<Type>();
+ types.add(cas.getTypeSystem().getType(Token.class.getName()));
+ types.add(cas.getTypeSystem().getType(Sentence.class.getName()));
- // Shuffle the types
- for (int n = 0; n < typeCount; n++) {
- Type t = types.remove(rnd.nextInt(types.size()));
- types.add(t);
- }
+ // Shuffle the types
+ for (int n = 0; n < typeCount; n++) {
+ Type t = types.remove(rnd.nextInt(types.size()));
+ types.add(t);
+ }
- // Randomly generate annotations
- for (int n = 0; n < annotationCount; n++) {
- for (Type t : types) {
- int begin = rnd.nextInt(approxDocLength);
- int end = begin + rnd.nextInt(maxAnnotationLength);
- cas.addFsToIndexes(cas.createAnnotation(t, begin, end));
- }
- }
+ // Randomly generate annotations
+ for (int n = 0; n < annotationCount; n++) {
+ for (Type t : types) {
+ int begin = rnd.nextInt(approxDocLength);
+ int end = begin + rnd.nextInt(maxAnnotationLength);
+ cas.addFsToIndexes(cas.createAnnotation(t, begin, end));
+ }
+ }
- try {
- cas.getJCas();
- }
- catch (CASException e) {
- throw new RuntimeException(e);
- }
+ try {
+ cas.getJCas();
+ } catch (CASException e) {
+ throw new RuntimeException(e);
}
+ }
}
diff --git a/uimafit-benchmark/src/main/java/org/apache/uima/fit/benchmark/Measurement.java b/uimafit-benchmark/src/main/java/org/apache/uima/fit/benchmark/Measurement.java
index ace262e..fdedd82 100644
--- a/uimafit-benchmark/src/main/java/org/apache/uima/fit/benchmark/Measurement.java
+++ b/uimafit-benchmark/src/main/java/org/apache/uima/fit/benchmark/Measurement.java
@@ -19,46 +19,44 @@
package org.apache.uima.fit.benchmark;
public class Measurement {
- private final int run;
- private final long duration;
- private final Exception exception;
-
- public Measurement(int aRun, long aDuration) {
- run = aRun;
- duration = aDuration;
- exception = null;
- }
-
- public Measurement(int aRun, long aDuration, Exception aException) {
- exception = aException;
- run = aRun;
- duration = aDuration;
- }
+ private final int run;
+ private final long duration;
+ private final Exception exception;
- public int getRun() {
- return run;
- }
-
- public long getDuration() {
- return duration;
- }
-
- public Exception getException() {
- return exception;
- }
-
- public boolean failed() {
- return exception != null;
- }
-
- @Override
- public String toString()
- {
- if (failed()) {
- return "[" + run + ": FAIL]";
- }
- else {
- return "[" + run + ": " + duration + "]";
- }
+ public Measurement(int aRun, long aDuration) {
+ run = aRun;
+ duration = aDuration;
+ exception = null;
+ }
+
+ public Measurement(int aRun, long aDuration, Exception aException) {
+ exception = aException;
+ run = aRun;
+ duration = aDuration;
+ }
+
+ public int getRun() {
+ return run;
+ }
+
+ public long getDuration() {
+ return duration;
+ }
+
+ public Exception getException() {
+ return exception;
+ }
+
+ public boolean failed() {
+ return exception != null;
+ }
+
+ @Override
+ public String toString() {
+ if (failed()) {
+ return "[" + run + ": FAIL]";
+ } else {
+ return "[" + run + ": " + duration + "]";
}
- }
\ No newline at end of file
+ }
+}
\ No newline at end of file
diff --git a/uimafit-benchmark/src/main/java/org/apache/uima/fit/benchmark/RunnableWithExceptions.java b/uimafit-benchmark/src/main/java/org/apache/uima/fit/benchmark/RunnableWithExceptions.java
index cbd62e0..e60dd20 100644
--- a/uimafit-benchmark/src/main/java/org/apache/uima/fit/benchmark/RunnableWithExceptions.java
+++ b/uimafit-benchmark/src/main/java/org/apache/uima/fit/benchmark/RunnableWithExceptions.java
@@ -19,5 +19,5 @@
package org.apache.uima.fit.benchmark;
public interface RunnableWithExceptions {
- void run() throws Exception;
+ void run() throws Exception;
}
diff --git a/uimafit-benchmark/src/test/java/org/apache/uima/fit/benchmark/FSUtilBenchmark.java b/uimafit-benchmark/src/test/java/org/apache/uima/fit/benchmark/FSUtilBenchmark.java
index 4162160..816cd2f 100644
--- a/uimafit-benchmark/src/test/java/org/apache/uima/fit/benchmark/FSUtilBenchmark.java
+++ b/uimafit-benchmark/src/test/java/org/apache/uima/fit/benchmark/FSUtilBenchmark.java
@@ -23,32 +23,27 @@ import static org.apache.uima.fit.util.FSUtil.setFeature;
import org.apache.uima.fit.factory.JCasFactory;
import org.apache.uima.fit.type.Token;
import org.apache.uima.jcas.JCas;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
public class FSUtilBenchmark {
- private static JCas jcas;
- private static Token fs;
+ private static JCas jcas;
+ private static Token fs;
- @BeforeClass
+ @BeforeAll
public static void setupOnce() throws Exception {
- jcas = JCasFactory.createText("test");
- fs = new Token(jcas, 0, 1);
- fs.addToIndexes();
+ jcas = JCasFactory.createText("test");
+ fs = new Token(jcas, 0, 1);
+ fs.addToIndexes();
}
- @Test
+ @Test
public void benchmarkSetFeature() {
- Benchmark template = new Benchmark("TEMPLATE")
- .timer(System::nanoTime, t -> t / 1000)
- .repeat(1_000_000);
+ Benchmark template = new Benchmark("TEMPLATE").timer(System::nanoTime, t -> t / 1000)
+ .repeat(1_000_000);
- new Benchmark("set feature string JCas", template)
- .measure(() -> fs.setPos("NN"))
- .run();
+ new Benchmark("set feature string JCas", template).measure(() -> fs.setPos("NN")).run();
- new Benchmark("set feature string", template)
- .measure(() -> setFeature(fs, "pos", "NN"))
- .run();
+ new Benchmark("set feature string", template).measure(() -> setFeature(fs, "pos", "NN")).run();
}
}
diff --git a/uimafit-benchmark/src/test/java/org/apache/uima/fit/benchmark/JCasFactoryBenchmark.java b/uimafit-benchmark/src/test/java/org/apache/uima/fit/benchmark/JCasFactoryBenchmark.java
index 938c7d1..6cc70b6 100644
--- a/uimafit-benchmark/src/test/java/org/apache/uima/fit/benchmark/JCasFactoryBenchmark.java
+++ b/uimafit-benchmark/src/test/java/org/apache/uima/fit/benchmark/JCasFactoryBenchmark.java
@@ -22,37 +22,31 @@ import static org.apache.uima.fit.factory.TypeSystemDescriptionFactory.createTyp
import org.apache.uima.resource.metadata.TypeSystemDescription;
import org.apache.uima.util.CasCreationUtils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class JCasFactoryBenchmark
-{
+public class JCasFactoryBenchmark {
@Test
public void benchmarkCreateTypeSystemDescription() throws Exception {
- Benchmark template = new Benchmark("TEMPLATE")
- .repeat(1000);
-
+ Benchmark template = new Benchmark("TEMPLATE").repeat(1000);
+
new Benchmark("createTypeSystemDescription", template)
- .measure(() -> createTypeSystemDescription())
- .run();
+ .measure(() -> createTypeSystemDescription()).run();
}
-
+
@Test
public void benchmarkCreateJCas() throws Exception {
- Benchmark template = new Benchmark("TEMPLATE")
- .repeat(1000);
-
+ Benchmark template = new Benchmark("TEMPLATE").repeat(1000);
+
TypeSystemDescription tsd = createTypeSystemDescription();
-
- new Benchmark("create CAS", template)
- .measure(() -> CasCreationUtils.createCas(tsd, null, null))
- .run();
-
- new Benchmark("create JCas (fresh TSD)", template)
- .measure(() -> CasCreationUtils.createCas(createTypeSystemDescription(), null, null).getJCas())
- .run();
-
+
+ new Benchmark("create CAS", template).measure(() -> CasCreationUtils.createCas(tsd, null, null))
+ .run();
+
+ new Benchmark("create JCas (fresh TSD)", template).measure(
+ () -> CasCreationUtils.createCas(createTypeSystemDescription(), null, null).getJCas())
+ .run();
+
new Benchmark("create JCas (re-use TSD)", template)
- .measure(() -> CasCreationUtils.createCas(tsd, null, null).getJCas())
- .run();
+ .measure(() -> CasCreationUtils.createCas(tsd, null, null).getJCas()).run();
}
}
diff --git a/uimafit-benchmark/src/test/java/org/apache/uima/fit/benchmark/SelectBenchmark.java b/uimafit-benchmark/src/test/java/org/apache/uima/fit/benchmark/SelectBenchmark.java
index 4e23194..a1b7f26 100644
--- a/uimafit-benchmark/src/test/java/org/apache/uima/fit/benchmark/SelectBenchmark.java
+++ b/uimafit-benchmark/src/test/java/org/apache/uima/fit/benchmark/SelectBenchmark.java
@@ -34,243 +34,282 @@ import org.apache.uima.fit.type.Token;
import org.apache.uima.fit.util.CasUtil;
import org.apache.uima.fit.util.JCasUtil;
import org.apache.uima.jcas.cas.TOP;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
public class SelectBenchmark {
private static final String TYPE_NAME_TOKEN = "org.apache.uima.fit.type.Token";
private static final String TYPE_NAME_SENTENCE = "org.apache.uima.fit.type.Sentence";
-
+
private Benchmark templateForFastOperations;
private Benchmark templateForNormalOperations;
private Benchmark warmupTask;
private CachingRandomJCasProvider casProvider;
-
- @Before
+
+ @BeforeEach
public void setup() {
casProvider = new CachingRandomJCasProvider();
- warmupTask = new Benchmark("WARM-UP")
- .initialize(casProvider::prepare)
- .repeat(100)
- .magnitude(10)
- .magnitudeIncrement(count -> count * 10)
- .incrementTimes(5)
- .ignore(true)
- .measure(() -> casProvider.get().select().forEach(t -> {}));
- templateForFastOperations = new Benchmark("FAST TEMPLATE")
- .initialize(casProvider::prepare)
- .timer(Benchmark::userTime, t -> t / 1_000_000)
- .repeat(1_000)
- .magnitude(10)
- .magnitudeIncrement(count -> count * 10)
- .incrementTimes(5);
- templateForNormalOperations = new Benchmark("NORMAL TEMPLATE")
- .initialize(casProvider::prepare)
- .timer(Benchmark::userTime, t -> t / 1_000_000)
- .repeat(10_000)
- .magnitude(10)
- .magnitudeIncrement(count -> count * 10)
- .incrementTimes(4);
+ warmupTask = new Benchmark("WARM-UP").initialize(casProvider::prepare).repeat(100).magnitude(10)
+ .magnitudeIncrement(count -> count * 10).incrementTimes(5).ignore(true)
+ .measure(() -> casProvider.get().select().forEach(t -> {
+ }));
+ templateForFastOperations = new Benchmark("FAST TEMPLATE").initialize(casProvider::prepare)
+ .timer(Benchmark::userTime, t -> t / 1_000_000).repeat(1_000).magnitude(10)
+ .magnitudeIncrement(count -> count * 10).incrementTimes(5);
+ templateForNormalOperations = new Benchmark("NORMAL TEMPLATE").initialize(casProvider::prepare)
+ .timer(Benchmark::userTime, t -> t / 1_000_000).repeat(10_000).magnitude(10)
+ .magnitudeIncrement(count -> count * 10).incrementTimes(4);
}
-
@Test
public void benchmarkSelect() {
- new BenchmarkGroup("select", templateForFastOperations)
- .addIgnoringTemplate(warmupTask)
- .add(new Benchmark("JCasUtil.selectAll(JCAS).forEach(x -> {})")
- .measure(() -> JCasUtil.selectAll(casProvider.get()).forEach(x -> {})))
- .add(new Benchmark("JCAS.select().forEach(x -> {})")
- .measure(() -> casProvider.get().select().forEach(x -> {})))
- .add(new Benchmark("JCasUtil.select(JCAS, TOP.class).forEach(x -> {})")
- .measure(() -> JCasUtil.select(casProvider.get(), TOP.class).forEach(x -> {})))
- .add(new Benchmark("JCAS.select(TOP.class).forEach(x -> {})")
- .measure(() -> casProvider.get().select(TOP.class).forEach(x -> {})))
- .add(new Benchmark("JCasUtil.select(JCAS, Token.class).forEach(x -> {})")
- .measure(() -> JCasUtil.select(casProvider.get(), Token.class).forEach(x -> {})))
- .add(new Benchmark("JCAS.select(Token.class).forEach(x -> {})")
- .measure(() -> casProvider.get().select(Token.class).forEach(x -> {})))
- .add(new Benchmark("JCAS.getAnnotationIndex(Token.class).select().forEach(x -> {})")
- .measure(() -> casProvider.get().getAnnotationIndex(Token.class).select().forEach(x -> {})))
- .runAll();
+ new BenchmarkGroup("select", templateForFastOperations).addIgnoringTemplate(warmupTask)
+ .add(new Benchmark("JCasUtil.selectAll(JCAS).forEach(x -> {})")
+ .measure(() -> JCasUtil.selectAll(casProvider.get()).forEach(x -> {
+ })))
+ .add(new Benchmark("JCAS.select().forEach(x -> {})")
+ .measure(() -> casProvider.get().select().forEach(x -> {
+ })))
+ .add(new Benchmark("JCasUtil.select(JCAS, TOP.class).forEach(x -> {})")
+ .measure(() -> JCasUtil.select(casProvider.get(), TOP.class).forEach(x -> {
+ })))
+ .add(new Benchmark("JCAS.select(TOP.class).forEach(x -> {})")
+ .measure(() -> casProvider.get().select(TOP.class).forEach(x -> {
+ })))
+ .add(new Benchmark("JCasUtil.select(JCAS, Token.class).forEach(x -> {})")
+ .measure(() -> JCasUtil.select(casProvider.get(), Token.class).forEach(x -> {
+ })))
+ .add(new Benchmark("JCAS.select(Token.class).forEach(x -> {})")
+ .measure(() -> casProvider.get().select(Token.class).forEach(x -> {
+ })))
+ .add(new Benchmark("JCAS.getAnnotationIndex(Token.class).select().forEach(x -> {})")
+ .measure(() -> casProvider.get().getAnnotationIndex(Token.class).select()
+ .forEach(x -> {
+ })))
+ .runAll();
}
@Test
public void benchmarkSelectOverlapping() {
new BenchmarkGroup("select overlapping", templateForNormalOperations)
- .addIgnoringTemplate(warmupTask)
- .add(new Benchmark("selectOverlapping(JCAS, Token.class, s).forEach(t -> {})")
- .measure(() -> {
- select(casProvider.get(), Sentence.class).forEach(s ->
- selectOverlapping(Token.class, s).forEach(t -> {}));
- }))
- .add(new Benchmark("CAS.select(Token.class).filter(t -> overlapping(t, s)).forEach(t -> {})")
- .measure(() -> {
- select(casProvider.get(), Sentence.class).forEach(s ->
- casProvider.get().select(Token.class)
- .filter(t -> overlapping(t, s))
- .forEach(t -> {}));
- }))
- .add(new Benchmark("JCAS.getAnnotationIndex(Token.class).stream().filter(t -> overlapping(t, s)).forEach(t -> {})")
- .measure(() -> {
- select(casProvider.get(), Sentence.class).forEach(s ->
- casProvider.get().getAnnotationIndex(Token.class).stream()
- .filter(t -> overlapping(t, s))
- .forEach(t -> {}));
- }))
- .runAll();
+ .addIgnoringTemplate(warmupTask)
+ .add(new Benchmark("selectOverlapping(JCAS, Token.class, s).forEach(t -> {})")
+ .measure(() -> {
+ select(casProvider.get(), Sentence.class)
+ .forEach(s -> selectOverlapping(Token.class, s).forEach(t -> {
+ }));
+ }))
+ .add(new Benchmark(
+ "CAS.select(Token.class).filter(t -> overlapping(t, s)).forEach(t -> {})")
+ .measure(() -> {
+ select(casProvider.get(), Sentence.class)
+ .forEach(s -> casProvider.get().select(Token.class)
+ .filter(t -> overlapping(t, s)).forEach(t -> {
+ }));
+ }))
+ .add(new Benchmark(
+ "JCAS.getAnnotationIndex(Token.class).stream().filter(t -> overlapping(t, s)).forEach(t -> {})")
+ .measure(() -> {
+ select(casProvider.get(), Sentence.class).forEach(s -> casProvider
+ .get().getAnnotationIndex(Token.class).stream()
+ .filter(t -> overlapping(t, s)).forEach(t -> {
+ }));
+ }))
+ .runAll();
}
-
+
@Test
public void benchmarkSelectCoveredBy() {
new BenchmarkGroup("select covered by", templateForNormalOperations)
- .addIgnoringTemplate(warmupTask)
- .add(new Benchmark("selectCovered(Token.class, s).forEach(t -> {})")
- .measure(() -> {
- select(casProvider.get(), Sentence.class).forEach(s ->
- selectCovered(Token.class, s).forEach(t -> {}));
- }))
- .add(new Benchmark("JCAS.select(Token.class).coveredBy(s).forEach(t -> {})")
- .measure(() -> {
- select(casProvider.get(), Sentence.class).forEach(s ->
- casProvider.get().select(Token.class).coveredBy(s).forEach(t -> {}));
- }))
- .add(new Benchmark("JCAS.getAnnotationIndex(Token.class).select().coveredBy(s).forEach(t -> {})")
- .measure(() -> {
- select(casProvider.get(), Sentence.class).forEach(s ->
- casProvider.get().getAnnotationIndex(Token.class).select().coveredBy(s).forEach(t -> {}));
- }))
- .add(new Benchmark("JCAS.select(Token.class).filter(t -> coveredBy(t, s)).forEach(t -> {})")
- .measure(() -> {
- select(casProvider.get(), Sentence.class).forEach(s ->
- casProvider.get().select(Token.class)
- .filter(t -> coveredBy(t, s))
- .forEach(t -> {}));
- }))
- .add(new Benchmark("JCAS.getAnnotationIndex(Token.class).stream().filter(t -> coveredBy(t, s)).forEach(t -> {})")
- .measure(() -> {
- select(casProvider.get(), Sentence.class).forEach(s ->
- casProvider.get().getAnnotationIndex(Token.class).stream()
- .filter(t -> coveredBy(t, s))
- .forEach(t -> {}));
- }))
- .add(new Benchmark("JCAS.select(Token.class).coveredBy(s.getBegin(), s.getEnd()).forEach(t -> {})")
- .measure(() -> {
- select(casProvider.get(), Sentence.class).forEach(s ->
- casProvider.get().select(Token.class).coveredBy(s.getBegin(), s.getEnd()).forEach(t -> {}));
- }))
- .add(new Benchmark("JCAS.getAnnotationIndex(Token.class).select().coveredBy(s.getBegin(), s.getEnd()).forEach(t -> {})")
- .measure(() -> {
- select(casProvider.get(), Sentence.class).forEach(s ->
- casProvider.get().getAnnotationIndex(Token.class).select().coveredBy(s.getBegin(), s.getEnd()).forEach(t -> {}));
- }))
- .add(new Benchmark("selectCovered(JCAS, Token.class, s.getBegin(), s.getEnd()).forEach(t -> {})")
- .measure(() -> {
- select(casProvider.get(), Sentence.class).forEach(s ->
- selectCovered(casProvider.get(), Token.class, s.getBegin(), s.getEnd()).forEach(t -> {}));
- }))
- .runAll();
+ .addIgnoringTemplate(warmupTask)
+ .add(new Benchmark("selectCovered(Token.class, s).forEach(t -> {})").measure(() -> {
+ select(casProvider.get(), Sentence.class)
+ .forEach(s -> selectCovered(Token.class, s).forEach(t -> {
+ }));
+ })).add(new Benchmark("JCAS.select(Token.class).coveredBy(s).forEach(t -> {})")
+ .measure(() -> {
+ select(casProvider.get(), Sentence.class).forEach(
+ s -> casProvider.get().select(Token.class).coveredBy(s).forEach(t -> {
+ }));
+ }))
+ .add(new Benchmark(
+ "JCAS.getAnnotationIndex(Token.class).select().coveredBy(s).forEach(t -> {})")
+ .measure(() -> {
+ select(casProvider.get(), Sentence.class).forEach(
+ s -> casProvider.get().getAnnotationIndex(Token.class)
+ .select().coveredBy(s).forEach(t -> {
+ }));
+ }))
+ .add(new Benchmark(
+ "JCAS.select(Token.class).filter(t -> coveredBy(t, s)).forEach(t -> {})")
+ .measure(() -> {
+ select(casProvider.get(), Sentence.class)
+ .forEach(s -> casProvider.get().select(Token.class)
+ .filter(t -> coveredBy(t, s)).forEach(t -> {
+ }));
+ }))
+ .add(new Benchmark(
+ "JCAS.getAnnotationIndex(Token.class).stream().filter(t -> coveredBy(t, s)).forEach(t -> {})")
+ .measure(() -> {
+ select(casProvider.get(), Sentence.class).forEach(
+ s -> casProvider.get().getAnnotationIndex(Token.class)
+ .stream().filter(t -> coveredBy(t, s)).forEach(t -> {
+ }));
+ }))
+ .add(new Benchmark(
+ "JCAS.select(Token.class).coveredBy(s.getBegin(), s.getEnd()).forEach(t -> {})")
+ .measure(() -> {
+ select(casProvider.get(), Sentence.class)
+ .forEach(s -> casProvider.get().select(Token.class)
+ .coveredBy(s.getBegin(), s.getEnd()).forEach(t -> {
+ }));
+ }))
+ .add(new Benchmark(
+ "JCAS.getAnnotationIndex(Token.class).select().coveredBy(s.getBegin(), s.getEnd()).forEach(t -> {})")
+ .measure(() -> {
+ select(casProvider.get(), Sentence.class).forEach(s -> casProvider
+ .get().getAnnotationIndex(Token.class).select()
+ .coveredBy(s.getBegin(), s.getEnd()).forEach(t -> {
+ }));
+ }))
+ .add(new Benchmark(
+ "selectCovered(JCAS, Token.class, s.getBegin(), s.getEnd()).forEach(t -> {})")
+ .measure(() -> {
+ select(casProvider.get(), Sentence.class)
+ .forEach(s -> selectCovered(casProvider.get(), Token.class,
+ s.getBegin(), s.getEnd()).forEach(t -> {
+ }));
+ }))
+ .runAll();
}
-
+
@Test
public void benchmarkSelectCovering() {
new BenchmarkGroup("select covering", templateForNormalOperations)
- .addIgnoringTemplate(warmupTask)
- .add(new Benchmark("JCasUtil.selectCovering(Token.class, s).forEach(t -> {})")
- .measure(() -> {
- select(casProvider.get(), Sentence.class).forEach(s ->
- JCasUtil.selectCovering(Token.class, s).forEach(t -> {}));
- }))
- .add(new Benchmark("CasUtil.selectCovering(tokenType, s).forEach(t -> {})")
- .measure(() -> {
- CAS cas = casProvider.get().getCas();
- select(cas, getType(cas, TYPE_NAME_SENTENCE)).forEach(s ->
- CasUtil.selectCovering(getType(cas, TYPE_NAME_TOKEN), s).forEach(t -> {}));
- }))
- .add(new Benchmark("JCAS.select(Token.class).covering(s).forEach(t -> {})")
- .measure(() -> {
- select(casProvider.get(), Sentence.class).forEach(s ->
- casProvider.get().select(Token.class).covering(s).forEach(t -> {}));
- }))
- .add(new Benchmark("CAS.getAnnotationIndex(getType(cas, TYPE_NAME_TOKEN)).select().covering(s).forEach(t -> {})")
- .measure(() -> {
- CAS cas = casProvider.get().getCas();
- select(cas, getType(cas, TYPE_NAME_SENTENCE)).forEach(s ->
- casProvider.get().getAnnotationIndex(getType(cas, TYPE_NAME_TOKEN)).select().covering(s).forEach(t -> {}));
- }))
- .add(new Benchmark("JCAS.getAnnotationIndex(Token.class).select().covering(s).forEach(t -> {})")
- .measure(() -> {
- select(casProvider.get(), Sentence.class).forEach(s ->
- casProvider.get().getAnnotationIndex(Token.class).select().covering(s).forEach(t -> {}));
- }))
- .add(new Benchmark("JCAS.select(Token.class).filter(t -> covering(t, s)).forEach(t -> {})")
- .measure(() -> {
- select(casProvider.get(), Sentence.class).forEach(s ->
- casProvider.get().select(Token.class)
- .filter(t -> covering(t, s))
- .forEach(t -> {}));
- }))
- .add(new Benchmark("CAS.getAnnotationIndex(getType(cas, TYPE_NAME_TOKEN)).stream().filter(t -> covering(t, s)).forEach(t -> {})")
- .measure(() -> {
- CAS cas = casProvider.get().getCas();
- select(cas, getType(cas, TYPE_NAME_SENTENCE)).forEach(s ->
- casProvider.get().getAnnotationIndex(getType(cas, TYPE_NAME_TOKEN)).stream()
- .filter(t -> covering(t, s))
- .forEach(t -> {}));
- }))
- .add(new Benchmark("JCAS.getAnnotationIndex(Token.class).stream().filter(t -> covering(t, s)).forEach(t -> {})")
- .measure(() -> {
- select(casProvider.get(), Sentence.class).forEach(s ->
- casProvider.get().getAnnotationIndex(Token.class).stream()
- .filter(t -> covering(t, s))
- .forEach(t -> {}));
- }))
- .runAll();
+ .addIgnoringTemplate(warmupTask)
+ .add(new Benchmark("JCasUtil.selectCovering(Token.class, s).forEach(t -> {})")
+ .measure(() -> {
+ select(casProvider.get(), Sentence.class)
+ .forEach(s -> JCasUtil.selectCovering(Token.class, s).forEach(t -> {
+ }));
+ }))
+ .add(new Benchmark("CasUtil.selectCovering(tokenType, s).forEach(t -> {})")
+ .measure(() -> {
+ CAS cas = casProvider.get().getCas();
+ select(cas, getType(cas, TYPE_NAME_SENTENCE)).forEach(s -> CasUtil
+ .selectCovering(getType(cas, TYPE_NAME_TOKEN), s).forEach(t -> {
+ }));
+ }))
+ .add(new Benchmark("JCAS.select(Token.class).covering(s).forEach(t -> {})")
+ .measure(() -> {
+ select(casProvider.get(), Sentence.class).forEach(
+ s -> casProvider.get().select(Token.class).covering(s).forEach(t -> {
+ }));
+ }))
+ .add(new Benchmark(
+ "CAS.getAnnotationIndex(getType(cas, TYPE_NAME_TOKEN)).select().covering(s).forEach(t -> {})")
+ .measure(() -> {
+ CAS cas = casProvider.get().getCas();
+ select(cas, getType(cas, TYPE_NAME_SENTENCE)).forEach(s -> casProvider
+ .get().getAnnotationIndex(getType(cas, TYPE_NAME_TOKEN))
+ .select().covering(s).forEach(t -> {
+ }));
+ }))
+ .add(new Benchmark(
+ "JCAS.getAnnotationIndex(Token.class).select().covering(s).forEach(t -> {})")
+ .measure(() -> {
+ select(casProvider.get(), Sentence.class).forEach(
+ s -> casProvider.get().getAnnotationIndex(Token.class)
+ .select().covering(s).forEach(t -> {
+ }));
+ }))
+ .add(new Benchmark(
+ "JCAS.select(Token.class).filter(t -> covering(t, s)).forEach(t -> {})")
+ .measure(() -> {
+ select(casProvider.get(), Sentence.class)
+ .forEach(s -> casProvider.get().select(Token.class)
+ .filter(t -> covering(t, s)).forEach(t -> {
+ }));
+ }))
+ .add(new Benchmark(
+ "CAS.getAnnotationIndex(getType(cas, TYPE_NAME_TOKEN)).stream().filter(t -> covering(t, s)).forEach(t -> {})")
+ .measure(() -> {
+ CAS cas = casProvider.get().getCas();
+ select(cas, getType(cas, TYPE_NAME_SENTENCE)).forEach(s -> casProvider
+ .get().getAnnotationIndex(getType(cas, TYPE_NAME_TOKEN))
+ .stream().filter(t -> covering(t, s)).forEach(t -> {
+ }));
+ }))
+ .add(new Benchmark(
+ "JCAS.getAnnotationIndex(Token.class).stream().filter(t -> covering(t, s)).forEach(t -> {})")
+ .measure(() -> {
+ select(casProvider.get(), Sentence.class).forEach(
+ s -> casProvider.get().getAnnotationIndex(Token.class)
+ .stream().filter(t -> covering(t, s)).forEach(t -> {
+ }));
+ }))
+ .runAll();
}
-
+
@Test
public void benchmarkSelectAt() {
- new BenchmarkGroup("select at", templateForNormalOperations)
- .addIgnoringTemplate(warmupTask)
- .add(new Benchmark("JCasUtil.selectAt(CAS, Token.class, s.getBegin(), s.getEnd()).forEach(t -> {})")
- .measure(() -> {
- select(casProvider.get(), Sentence.class).forEach(s ->
- JCasUtil.selectAt(casProvider.get(), Token.class, s.getBegin(), s.getEnd()).forEach(t -> {}));
- }))
- .add(new Benchmark("JCAS.select(Token.class).at(s.getBegin(), s.getEnd()).forEach(t -> {})")
- .measure(() -> {
- select(casProvider.get(), Sentence.class).forEach(s ->
- casProvider.get().select(Token.class).at(s.getBegin(), s.getEnd()).forEach(t -> {}));
- }))
- .add(new Benchmark("JCAS.select(Token.class).at(s).forEach(t -> {})")
- .measure(() -> {
- select(casProvider.get(), Sentence.class).forEach(s ->
- casProvider.get().select(Token.class).at(s).forEach(t -> {}));
- }))
- .add(new Benchmark("JCAS.select(Token.class).filter(t -> colocated(t, s)).forEach(t -> {})")
- .measure(() -> {
- select(casProvider.get(), Sentence.class).forEach(s ->
- casProvider.get().select(Token.class)
- .filter(t -> colocated(t, s))
- .forEach(t -> {}));
- }))
- .add(new Benchmark("JCAS.getAnnotationIndex(Token.class).stream().filter(t -> colocated(t, s)).forEach(t -> {})")
- .measure(() -> {
- select(casProvider.get(), Sentence.class).forEach(s ->
- casProvider.get().getAnnotationIndex(Token.class).stream()
- .filter(t -> colocated(t, s))
- .forEach(t -> {}));
- }))
- .add(new Benchmark("JCAS.getAnnotationIndex(Token.class).select().at(s).forEach(t -> {})")
- .measure(() -> {
- select(casProvider.get(), Sentence.class).forEach(s ->
- casProvider.get().getAnnotationIndex(Token.class).select().at(s).forEach(t -> {}));
- }))
- .add(new Benchmark("JCAS.getAnnotationIndex(Token.class).select().at(s.getBegin(), s.getEnd()).forEach(t -> {})")
- .measure(() -> {
- select(casProvider.get(), Sentence.class).forEach(s ->
- casProvider.get().getAnnotationIndex(Token.class).select().at(s.getBegin(), s.getEnd()).forEach(t -> {}));
+ new BenchmarkGroup("select at", templateForNormalOperations).addIgnoringTemplate(warmupTask)
+ .add(new Benchmark(
+ "JCasUtil.selectAt(CAS, Token.class, s.getBegin(), s.getEnd()).forEach(t -> {})")
+ .measure(() -> {
+ select(casProvider.get(), Sentence.class)
+ .forEach(
+ s -> JCasUtil
+ .selectAt(casProvider.get(), Token.class,
+ s.getBegin(), s.getEnd())
+ .forEach(t -> {
+ }));
+ }))
+ .add(new Benchmark(
+ "JCAS.select(Token.class).at(s.getBegin(), s.getEnd()).forEach(t -> {})")
+ .measure(() -> {
+ select(casProvider.get(), Sentence.class)
+ .forEach(s -> casProvider.get().select(Token.class)
+ .at(s.getBegin(), s.getEnd()).forEach(t -> {
+ }));
+ }))
+ .add(new Benchmark("JCAS.select(Token.class).at(s).forEach(t -> {})").measure(() -> {
+ select(casProvider.get(), Sentence.class)
+ .forEach(s -> casProvider.get().select(Token.class).at(s).forEach(t -> {
+ }));
}))
- .runAll();
+ .add(new Benchmark(
+ "JCAS.select(Token.class).filter(t -> colocated(t, s)).forEach(t -> {})")
+ .measure(() -> {
+ select(casProvider.get(), Sentence.class)
+ .forEach(s -> casProvider.get().select(Token.class)
+ .filter(t -> colocated(t, s)).forEach(t -> {
+ }));
+ }))
+ .add(new Benchmark(
+ "JCAS.getAnnotationIndex(Token.class).stream().filter(t -> colocated(t, s)).forEach(t -> {})")
+ .measure(() -> {
+ select(casProvider.get(), Sentence.class).forEach(
+ s -> casProvider.get().getAnnotationIndex(Token.class)
+ .stream().filter(t -> colocated(t, s)).forEach(t -> {
+ }));
+ }))
+ .add(new Benchmark(
+ "JCAS.getAnnotationIndex(Token.class).select().at(s).forEach(t -> {})")
+ .measure(() -> {
+ select(casProvider.get(), Sentence.class).forEach(
+ s -> casProvider.get().getAnnotationIndex(Token.class)
+ .select().at(s).forEach(t -> {
+ }));
+ }))
+ .add(new Benchmark(
+ "JCAS.getAnnotationIndex(Token.class).select().at(s.getBegin(), s.getEnd()).forEach(t -> {})")
+ .measure(() -> {
+ select(casProvider.get(), Sentence.class).forEach(
+ s -> casProvider.get().getAnnotationIndex(Token.class)
+ .select().at(s.getBegin(), s.getEnd()).forEach(t -> {
+ }));
+ }))
+ .runAll();
}
}
diff --git a/uimafit-core/.settings/org.eclipse.jdt.core.prefs b/uimafit-core/.settings/org.eclipse.jdt.core.prefs
index 4ff91b1..9ed6a9e 100644
--- a/uimafit-core/.settings/org.eclipse.jdt.core.prefs
+++ b/uimafit-core/.settings/org.eclipse.jdt.core.prefs
@@ -7,7 +7,7 @@ org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
-org.eclipse.jdt.core.compiler.processAnnotations=disabled
+org.eclipse.jdt.core.compiler.processAnnotations=enabled
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false
@@ -16,14 +16,21 @@ org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns=false
org.eclipse.jdt.core.formatter.align_with_spaces=false
org.eclipse.jdt.core.formatter.alignment_for_additive_operator=16
+org.eclipse.jdt.core.formatter.alignment_for_annotations_on_enum_constant=49
+org.eclipse.jdt.core.formatter.alignment_for_annotations_on_field=49
+org.eclipse.jdt.core.formatter.alignment_for_annotations_on_local_variable=49
+org.eclipse.jdt.core.formatter.alignment_for_annotations_on_method=49
+org.eclipse.jdt.core.formatter.alignment_for_annotations_on_package=49
+org.eclipse.jdt.core.formatter.alignment_for_annotations_on_parameter=49
+org.eclipse.jdt.core.formatter.alignment_for_annotations_on_type=49
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_assertion_message=0
org.eclipse.jdt.core.formatter.alignment_for_assignment=0
-org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator=16
org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
org.eclipse.jdt.core.formatter.alignment_for_compact_loops=16
@@ -52,6 +59,7 @@ org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_record_declarati
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_type_annotations=0
org.eclipse.jdt.core.formatter.alignment_for_type_arguments=0
org.eclipse.jdt.core.formatter.alignment_for_type_parameters=0
org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16
@@ -59,7 +67,7 @@ org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
org.eclipse.jdt.core.formatter.blank_lines_after_last_class_body_declaration=0
org.eclipse.jdt.core.formatter.blank_lines_after_package=1
org.eclipse.jdt.core.formatter.blank_lines_before_abstract_method=1
-org.eclipse.jdt.core.formatter.blank_lines_before_field=1
+org.eclipse.jdt.core.formatter.blank_lines_before_field=0
org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
@@ -110,7 +118,7 @@ org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off
org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on
org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
-org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=false
+org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
@@ -128,7 +136,7 @@ org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert
-org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
@@ -139,13 +147,6 @@ org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_ini
org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
-org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert
-org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert
-org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert
-org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
-org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
-org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
-org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_after_additive_operator=insert
org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_case=insert
@@ -153,7 +154,6 @@ org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_default=insert
org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
@@ -227,7 +227,6 @@ org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_case=insert
org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_default=insert
org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
-org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator=insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
@@ -382,11 +381,11 @@ org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
org.eclipse.jdt.core.formatter.tabulation.char=space
org.eclipse.jdt.core.formatter.tabulation.size=2
org.eclipse.jdt.core.formatter.text_block_indentation=0
-org.eclipse.jdt.core.formatter.use_on_off_tags=false
+org.eclipse.jdt.core.formatter.use_on_off_tags=true
org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
org.eclipse.jdt.core.formatter.wrap_before_additive_operator=true
+org.eclipse.jdt.core.formatter.wrap_before_assertion_message_operator=true
org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false
-org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator=true
org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true
org.eclipse.jdt.core.formatter.wrap_before_logical_operator=true
diff --git a/uimafit-core/.settings/org.eclipse.jdt.ui.prefs b/uimafit-core/.settings/org.eclipse.jdt.ui.prefs
index eb8a428..10948b0 100644
--- a/uimafit-core/.settings/org.eclipse.jdt.ui.prefs
+++ b/uimafit-core/.settings/org.eclipse.jdt.ui.prefs
@@ -1,4 +1,121 @@
eclipse.preferences.version=1
+editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
formatter_profile=_Apache UIMA Code Conventions
-formatter_settings_version=19
-org.eclipse.jdt.ui.text.custom_code_templates=
+formatter_settings_version=21
+sp_cleanup.add_all=false
+sp_cleanup.add_default_serial_version_id=true
+sp_cleanup.add_generated_serial_version_id=false
+sp_cleanup.add_missing_annotations=true
+sp_cleanup.add_missing_deprecated_annotations=true
+sp_cleanup.add_missing_methods=false
+sp_cleanup.add_missing_nls_tags=false
+sp_cleanup.add_missing_override_annotations=true
+sp_cleanup.add_missing_override_annotations_interface_methods=true
+sp_cleanup.add_serial_version_id=false
+sp_cleanup.always_use_blocks=true
+sp_cleanup.always_use_parentheses_in_expressions=false
+sp_cleanup.always_use_this_for_non_static_field_access=false
+sp_cleanup.always_use_this_for_non_static_method_access=false
+sp_cleanup.arrays_fill=false
+sp_cleanup.bitwise_conditional_expression=false
+sp_cleanup.boolean_literal=false
+sp_cleanup.break_loop=false
+sp_cleanup.collection_cloning=false
+sp_cleanup.comparing_on_criteria=false
+sp_cleanup.comparison_statement=false
+sp_cleanup.controlflow_merge=false
+sp_cleanup.convert_functional_interfaces=false
+sp_cleanup.convert_to_enhanced_for_loop=false
+sp_cleanup.convert_to_enhanced_for_loop_if_loop_var_used=false
+sp_cleanup.convert_to_switch_expressions=false
+sp_cleanup.correct_indentation=false
+sp_cleanup.double_negation=false
+sp_cleanup.else_if=false
+sp_cleanup.embedded_if=false
+sp_cleanup.evaluate_nullable=false
+sp_cleanup.extract_increment=false
+sp_cleanup.format_source_code=true
+sp_cleanup.format_source_code_changes_only=false
+sp_cleanup.hash=false
+sp_cleanup.if_condition=false
+sp_cleanup.insert_inferred_type_arguments=false
+sp_cleanup.instanceof=false
+sp_cleanup.invert_equals=false
+sp_cleanup.join=false
+sp_cleanup.lazy_logical_operator=false
+sp_cleanup.make_local_variable_final=false
+sp_cleanup.make_parameters_final=false
+sp_cleanup.make_private_fields_final=true
+sp_cleanup.make_type_abstract_if_missing_method=false
+sp_cleanup.make_variable_declarations_final=false
+sp_cleanup.map_cloning=false
+sp_cleanup.merge_conditional_blocks=false
+sp_cleanup.multi_catch=false
+sp_cleanup.never_use_blocks=false
+sp_cleanup.never_use_parentheses_in_expressions=true
+sp_cleanup.no_string_creation=false
+sp_cleanup.no_super=true
+sp_cleanup.number_suffix=false
+sp_cleanup.objects_equals=false
+sp_cleanup.on_save_use_additional_actions=true
+sp_cleanup.organize_imports=true
+sp_cleanup.overridden_assignment=false
+sp_cleanup.plain_replacement=false
+sp_cleanup.precompile_regex=false
+sp_cleanup.primitive_comparison=false
+sp_cleanup.primitive_parsing=false
+sp_cleanup.primitive_serialization=false
+sp_cleanup.pull_up_assignment=false
+sp_cleanup.push_down_negation=false
+sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
+sp_cleanup.reduce_indentation=false
+sp_cleanup.redundant_falling_through_block_end=false
+sp_cleanup.remove_private_constructors=true
+sp_cleanup.remove_redundant_modifiers=true
+sp_cleanup.remove_redundant_semicolons=false
+sp_cleanup.remove_redundant_type_arguments=false
+sp_cleanup.remove_trailing_whitespaces=false
+sp_cleanup.remove_trailing_whitespaces_all=true
+sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
+sp_cleanup.remove_unnecessary_array_creation=false
+sp_cleanup.remove_unnecessary_casts=false
+sp_cleanup.remove_unnecessary_nls_tags=false
+sp_cleanup.remove_unused_imports=true
+sp_cleanup.remove_unused_local_variables=false
+sp_cleanup.remove_unused_private_fields=true
+sp_cleanup.remove_unused_private_members=false
+sp_cleanup.remove_unused_private_methods=true
+sp_cleanup.remove_unused_private_types=true
+sp_cleanup.simplify_lambda_expression_and_method_ref=false
+sp_cleanup.single_used_field=false
+sp_cleanup.sort_members=false
+sp_cleanup.sort_members_all=false
+sp_cleanup.standard_comparison=false
+sp_cleanup.static_inner_class=false
+sp_cleanup.strictly_equal_or_different=false
+sp_cleanup.stringbuilder=false
+sp_cleanup.substring=false
+sp_cleanup.switch=false
+sp_cleanup.ternary_operator=false
+sp_cleanup.try_with_resource=false
+sp_cleanup.unlooped_while=false
+sp_cleanup.unreachable_block=false
+sp_cleanup.use_anonymous_class_creation=false
+sp_cleanup.use_autoboxing=false
+sp_cleanup.use_blocks=true
+sp_cleanup.use_blocks_only_for_return_and_throw=false
+sp_cleanup.use_directly_map_method=false
+sp_cleanup.use_lambda=false
+sp_cleanup.use_parentheses_in_expressions=false
+sp_cleanup.use_this_for_non_static_field_access=false
+sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
+sp_cleanup.use_this_for_non_static_method_access=false
+sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
+sp_cleanup.use_unboxing=false
+sp_cleanup.use_var=false
+sp_cleanup.useless_continue=false
+sp_cleanup.useless_return=false
diff --git a/uimafit-core/pom.xml b/uimafit-core/pom.xml
index 1f34788..a3e2daa 100644
--- a/uimafit-core/pom.xml
+++ b/uimafit-core/pom.xml
@@ -61,6 +61,12 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
+
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
@@ -74,7 +80,7 @@
</dependency>
<dependency>
<groupId>org.xmlunit</groupId>
- <artifactId>xmlunit-assertj</artifactId>
+ <artifactId>xmlunit-assertj3</artifactId>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/component/CasAnnotator_ImplBase.java b/uimafit-core/src/main/java/org/apache/uima/fit/component/CasAnnotator_ImplBase.java
index e7c2ef9..587c5ef 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/component/CasAnnotator_ImplBase.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/component/CasAnnotator_ImplBase.java
@@ -28,8 +28,8 @@ import org.apache.uima.resource.ResourceInitializationException;
* Base class for CAS annotators which initializes itself based on annotations.
*
*/
-public abstract class CasAnnotator_ImplBase extends
- org.apache.uima.analysis_component.CasAnnotator_ImplBase {
+public abstract class CasAnnotator_ImplBase
+ extends org.apache.uima.analysis_component.CasAnnotator_ImplBase {
@Override
public void initialize(final UimaContext context) throws ResourceInitializationException {
super.initialize(context);
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/component/CasConsumer_ImplBase.java b/uimafit-core/src/main/java/org/apache/uima/fit/component/CasConsumer_ImplBase.java
index 9d599ca..2ae04f2 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/component/CasConsumer_ImplBase.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/component/CasConsumer_ImplBase.java
@@ -31,8 +31,8 @@ import org.apache.uima.resource.ResourceInitializationException;
*
*/
@OperationalProperties(multipleDeploymentAllowed = false)
-public abstract class CasConsumer_ImplBase extends
- org.apache.uima.analysis_component.CasAnnotator_ImplBase {
+public abstract class CasConsumer_ImplBase
+ extends org.apache.uima.analysis_component.CasAnnotator_ImplBase {
@Override
public void initialize(final UimaContext context) throws ResourceInitializationException {
super.initialize(context);
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/component/CasDumpWriter.java b/uimafit-core/src/main/java/org/apache/uima/fit/component/CasDumpWriter.java
index c3cc562..3c5feb9 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/component/CasDumpWriter.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/component/CasDumpWriter.java
@@ -111,7 +111,7 @@ public class CasDumpWriter extends CasConsumer_ImplBase {
@ConfigurationParameter(name = PARAM_SORT, mandatory = true, defaultValue = "false")
private boolean sort;
-
+
private InExPattern[] cookedTypePatterns;
private PrintWriter out;
@@ -211,18 +211,18 @@ public class CasDumpWriter extends CasConsumer_ImplBase {
if (name != 0) {
return name;
}
-
+
// Last resort: try the address.
if (aO1 instanceof FeatureStructureImpl && aO2 instanceof FeatureStructureImpl) {
return ((FeatureStructureImpl) aO1).getAddress()
- ((FeatureStructureImpl) aO2).getAddress();
}
-
+
// Fall back to name.
return name;
}
});
-
+
annotationIterator = sortedFS.iterator();
}
@@ -239,7 +239,7 @@ public class CasDumpWriter extends CasConsumer_ImplBase {
processFeatureStructure(annotation);
}
}
-
+
private void processFeatureStructure(FeatureStructure aFS) {
String meta = aFS.toString();
for (String line : meta.split("\n")) {
@@ -257,7 +257,8 @@ public class CasDumpWriter extends CasConsumer_ImplBase {
}
private void processView(CAS aCAS) {
- out.println("-------- View " + aCAS.getViewName() + " begin ----------------------------------");
+ out.println(
+ "-------- View " + aCAS.getViewName() + " begin ----------------------------------");
out.println();
processDocumentMetadata(aCAS);
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/component/CasFlowController_ImplBase.java b/uimafit-core/src/main/java/org/apache/uima/fit/component/CasFlowController_ImplBase.java
index feca365..5cb9921 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/component/CasFlowController_ImplBase.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/component/CasFlowController_ImplBase.java
@@ -26,8 +26,8 @@ import org.apache.uima.resource.ResourceInitializationException;
/**
*/
-public abstract class CasFlowController_ImplBase extends
- org.apache.uima.flow.CasFlowController_ImplBase {
+public abstract class CasFlowController_ImplBase
+ extends org.apache.uima.flow.CasFlowController_ImplBase {
@Override
public void initialize(final FlowControllerContext context)
throws ResourceInitializationException {
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/component/CasMultiplier_ImplBase.java b/uimafit-core/src/main/java/org/apache/uima/fit/component/CasMultiplier_ImplBase.java
index 3497d5f..53a38cb 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/component/CasMultiplier_ImplBase.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/component/CasMultiplier_ImplBase.java
@@ -29,8 +29,8 @@ import org.apache.uima.resource.ResourceInitializationException;
*
*/
@OperationalProperties(outputsNewCases = true)
-public abstract class CasMultiplier_ImplBase extends
- org.apache.uima.analysis_component.CasMultiplier_ImplBase {
+public abstract class CasMultiplier_ImplBase
+ extends org.apache.uima.analysis_component.CasMultiplier_ImplBase {
@Override
public void initialize(final UimaContext context) throws ResourceInitializationException {
super.initialize(context);
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/component/ExternalResourceAware.java b/uimafit-core/src/main/java/org/apache/uima/fit/component/ExternalResourceAware.java
index f5edff0..235915a 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/component/ExternalResourceAware.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/component/ExternalResourceAware.java
@@ -29,8 +29,9 @@ import org.apache.uima.resource.ResourceInitializationException;
public interface ExternalResourceAware {
/**
* Get the name of the resource. This is set by the different variations of
- * {@link ExternalResourceFactory#bindResourceOnce} which internally call {@code ExternalResourceFactory.bindNestedResources(...)}
- * to set the parameter {@link ExternalResourceFactory#PARAM_RESOURCE_NAME PARAM_RESOURCE_NAME}.<br>
+ * {@link ExternalResourceFactory#bindResourceOnce} which internally call
+ * {@code ExternalResourceFactory.bindNestedResources(...)} to set the parameter
+ * {@link ExternalResourceFactory#PARAM_RESOURCE_NAME PARAM_RESOURCE_NAME}.<br>
* <b>It is mandatory that any resource implementing this interface declares the configuration
* parameter {@link ExternalResourceFactory#PARAM_RESOURCE_NAME PARAM_RESOURCE_NAME}.</b>
*
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/component/JCasAnnotator_ImplBase.java b/uimafit-core/src/main/java/org/apache/uima/fit/component/JCasAnnotator_ImplBase.java
index 5483899..f47911e 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/component/JCasAnnotator_ImplBase.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/component/JCasAnnotator_ImplBase.java
@@ -27,8 +27,8 @@ import org.apache.uima.resource.ResourceInitializationException;
* Base class for JCas annotators which initializes itself based on annotations.
*
*/
-public abstract class JCasAnnotator_ImplBase extends
- org.apache.uima.analysis_component.JCasAnnotator_ImplBase {
+public abstract class JCasAnnotator_ImplBase
+ extends org.apache.uima.analysis_component.JCasAnnotator_ImplBase {
@Override
public void initialize(final UimaContext context) throws ResourceInitializationException {
super.initialize(context);
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/component/JCasConsumer_ImplBase.java b/uimafit-core/src/main/java/org/apache/uima/fit/component/JCasConsumer_ImplBase.java
index 2ca2a98..9bd52cb 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/component/JCasConsumer_ImplBase.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/component/JCasConsumer_ImplBase.java
@@ -31,8 +31,8 @@ import org.apache.uima.resource.ResourceInitializationException;
*
*/
@OperationalProperties(multipleDeploymentAllowed = false)
-public abstract class JCasConsumer_ImplBase extends
- org.apache.uima.analysis_component.JCasAnnotator_ImplBase {
+public abstract class JCasConsumer_ImplBase
+ extends org.apache.uima.analysis_component.JCasAnnotator_ImplBase {
@Override
public void initialize(final UimaContext context) throws ResourceInitializationException {
super.initialize(context);
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/component/JCasFlowController_ImplBase.java b/uimafit-core/src/main/java/org/apache/uima/fit/component/JCasFlowController_ImplBase.java
index dcdb34c..5b8b32d 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/component/JCasFlowController_ImplBase.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/component/JCasFlowController_ImplBase.java
@@ -26,8 +26,8 @@ import org.apache.uima.resource.ResourceInitializationException;
/**
*/
-public abstract class JCasFlowController_ImplBase extends
- org.apache.uima.flow.JCasFlowController_ImplBase {
+public abstract class JCasFlowController_ImplBase
+ extends org.apache.uima.flow.JCasFlowController_ImplBase {
@Override
public void initialize(final FlowControllerContext context)
throws ResourceInitializationException {
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/component/JCasMultiplier_ImplBase.java b/uimafit-core/src/main/java/org/apache/uima/fit/component/JCasMultiplier_ImplBase.java
index 52df95d..2072661 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/component/JCasMultiplier_ImplBase.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/component/JCasMultiplier_ImplBase.java
@@ -29,8 +29,8 @@ import org.apache.uima.resource.ResourceInitializationException;
*
*/
@OperationalProperties(outputsNewCases = true)
-public abstract class JCasMultiplier_ImplBase extends
- org.apache.uima.analysis_component.JCasMultiplier_ImplBase {
+public abstract class JCasMultiplier_ImplBase
+ extends org.apache.uima.analysis_component.JCasMultiplier_ImplBase {
@Override
public void initialize(final UimaContext context) throws ResourceInitializationException {
super.initialize(context);
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/component/initialize/ExternalResourceInitializer.java b/uimafit-core/src/main/java/org/apache/uima/fit/component/initialize/ExternalResourceInitializer.java
index ba0e4f0..32c31b2 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/component/initialize/ExternalResourceInitializer.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/component/initialize/ExternalResourceInitializer.java
@@ -56,6 +56,7 @@ public final class ExternalResourceInitializer {
/**
* Configure a component from the given context.
+ *
* @param object
* the component.
* @param context
@@ -101,7 +102,7 @@ public final class ExternalResourceInitializer {
if (!ReflectionUtil.isAnnotationPresent(field, ExternalResource.class)) {
continue;
}
-
+
ExternalResource era = ReflectionUtil.getAnnotation(field, ExternalResource.class);
// Get the resource key. If it is a nested resource, also get the prefix.
@@ -124,20 +125,20 @@ public final class ExternalResourceInitializer {
// Sanity checks
if (value == null && era.mandatory()) {
- throw new ResourceInitializationException(new IllegalStateException("Mandatory resource ["
- + key + "] is not set on [" + baseCls + "]"));
+ throw new ResourceInitializationException(new IllegalStateException(
+ "Mandatory resource [" + key + "] is not set on [" + baseCls + "]"));
}
// Now record the setting and optionally apply it to the given
// instance.
if (value != null) {
field.setAccessible(true);
-
+
try {
if (value instanceof ResourceList) {
// Value is a multi-valued resource
ResourceList resList = (ResourceList) value;
-
+
// We cannot do this in ResourceList because the resource doesn't have access to
// the UIMA context we use here. Resources are initialize with their own contexts
// by the UIMA framework!
@@ -151,20 +152,19 @@ public final class ExternalResourceInitializer {
SimpleTypeConverter converter = new SimpleTypeConverter();
value = converter.convertIfNecessary(elements, field.getType());
}
-
+
try {
field.set(object, value);
} catch (IllegalAccessException e) {
throw new ResourceInitializationException(e);
}
- }
- finally {
+ } finally {
field.setAccessible(false);
}
}
}
}
-
+
private static Object getResourceObject(UimaContext aContext, String aKey)
throws ResourceInitializationException {
Object value;
@@ -222,10 +222,10 @@ public final class ExternalResourceInitializer {
// have to rely on the UIMA implementation details and access the internal resource
// map via reflection. If the resource manager is not derived from the default
// UIMA resource manager, then we cannot really do anything here.
- throw new IllegalStateException("Unsupported resource manager implementation ["
- + resMgr.getClass() + "]");
+ throw new IllegalStateException(
+ "Unsupported resource manager implementation [" + resMgr.getClass() + "]");
}
-
+
return resMgr.getExternalResources();
}
}
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/component/initialize/package-info.java b/uimafit-core/src/main/java/org/apache/uima/fit/component/initialize/package-info.java
index 180ed31..2b5da94 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/component/initialize/package-info.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/component/initialize/package-info.java
@@ -20,4 +20,3 @@
* Reflection-based context and dependency injection.
*/
package org.apache.uima.fit.component.initialize;
-
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/component/package-info.java b/uimafit-core/src/main/java/org/apache/uima/fit/component/package-info.java
index 1da74dd..0faa29f 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/component/package-info.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/component/package-info.java
@@ -20,4 +20,3 @@
* uimaFIT-enhanced base classes for UIMA components and some simple components.
*/
package org.apache.uima.fit.component;
-
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/descriptor/FsIndex.java b/uimafit-core/src/main/java/org/apache/uima/fit/descriptor/FsIndex.java
index 35a8c13..558c8b0 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/descriptor/FsIndex.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/descriptor/FsIndex.java
@@ -59,7 +59,7 @@ public @interface FsIndex {
/**
* The type of the index as name. As an alternative, the index can be defined using a class with
- * {@link #type()}. One method or the other must be used to set the index type.
+ * {@link #type()}. One method or the other must be used to set the index type.
*
* @see FsIndexDescription#getTypeName()
*
@@ -69,7 +69,7 @@ public @interface FsIndex {
/**
* The type of the index as class. As an alternative, the index can be defined using a type name
- * with {@link #typeName()}. One method or the other must be used to set the index type.
+ * with {@link #typeName()}. One method or the other must be used to set the index type.
*
* @see FsIndexDescription#getTypeName()
*
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/descriptor/LanguageCapability.java b/uimafit-core/src/main/java/org/apache/uima/fit/descriptor/LanguageCapability.java
index 96eef02..96c70b2 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/descriptor/LanguageCapability.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/descriptor/LanguageCapability.java
@@ -26,9 +26,11 @@ import java.lang.annotation.Target;
/**
* Provides information on the languages supported by a component.
*
- * <pre><code>
+ * <pre>
+ * <code>
* {@literal @}LanguageCapability({ "en", "de" })
- * </code></pre>
+ * </code>
+ * </pre>
*/
@Retention(RetentionPolicy.RUNTIME)
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/descriptor/MimeTypeCapability.java b/uimafit-core/src/main/java/org/apache/uima/fit/descriptor/MimeTypeCapability.java
index f613105..0d50fd4 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/descriptor/MimeTypeCapability.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/descriptor/MimeTypeCapability.java
@@ -26,9 +26,11 @@ import java.lang.annotation.Target;
/**
* Provides information on the MIME types supported by a component.
*
- * <pre><code>
+ * <pre>
+ * <code>
* {@literal @}MimeTypeCapability({ "application/xml", "text/html" })
- * </code></pre>
+ * </code>
+ * </pre>
*/
@Retention(RetentionPolicy.RUNTIME)
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/descriptor/ResourceMetaData.java b/uimafit-core/src/main/java/org/apache/uima/fit/descriptor/ResourceMetaData.java
index 96a3a5a..5dfb92c 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/descriptor/ResourceMetaData.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/descriptor/ResourceMetaData.java
@@ -31,7 +31,7 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface ResourceMetaData {
-
+
/**
* Gets the name of this Resource.
*
@@ -40,7 +40,7 @@ public @interface ResourceMetaData {
* @return the name of this Resource
*/
String name() default "";
-
+
/**
* Gets the copyright notice for this Resource.
*
@@ -58,7 +58,7 @@ public @interface ResourceMetaData {
* @return the description of this Resource
*/
String description() default "";
-
+
/**
* Gets the vendor of this Resource.
*
@@ -67,7 +67,7 @@ public @interface ResourceMetaData {
* @return the vendor of this Resource, as a String
*/
String vendor() default "";
-
+
/**
* Gets the version number of this Resource.
*
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/descriptor/SofaCapability.java b/uimafit-core/src/main/java/org/apache/uima/fit/descriptor/SofaCapability.java
index da905e2..2bc1e36 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/descriptor/SofaCapability.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/descriptor/SofaCapability.java
@@ -25,13 +25,19 @@ import java.lang.annotation.Target;
/**
*
- * <pre><code>
+ * <pre>
+ * <code>
* {@literal @}SofaCapability(inputSofas = { GOLD_VIEW, SYSTEM_VIEW })
- * </code></pre>
+ * </code>
+ * </pre>
+ *
* or
- * <pre><code>
+ *
+ * <pre>
+ * <code>
* {@literal @}SofaCapability(inputSofas = CAS.NAME_DEFAULT_SOFA, outputSofas = GOLD_VIEW)
- * </code></pre>
+ * </code>
+ * </pre>
*
* Adding this annotation to your analysis engine description makes your component "sofa aware." The
* base CAS delivered to "sofa aware" components has no explicit view associated with it. The logic
@@ -39,17 +45,21 @@ import java.lang.annotation.Target;
* as needed. You should therefore be aware that if you need to work with the "_InitialView" view,
* then you must explicitly request it with a call like:
*
- * <pre><code>
+ * <pre>
+ * <code>
* JCas initialView = jCas.getView(CAS.NAME_DEFAULT_SOFA);
- * </code></pre>
+ * </code>
+ * </pre>
*
* This is because the base CAS that it passed into the process method to "sofa aware" components is
* not the same as the "_InitialView". See how the following member variable is used to understand
* why/how:
*
- * <pre><code>
+ * <pre>
+ * <code>
* org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.mSofaAware
- * </code></pre>
+ * </code>
+ * </pre>
*/
@Retention(RetentionPolicy.RUNTIME)
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/descriptor/TypeCapability.java b/uimafit-core/src/main/java/org/apache/uima/fit/descriptor/TypeCapability.java
index f197316..187e4b6 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/descriptor/TypeCapability.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/descriptor/TypeCapability.java
@@ -26,19 +26,23 @@ import java.lang.annotation.Target;
/**
* A typical use of this annotation might look something like:
*
- * <pre><code>
+ * <pre>
+ * <code>
* {@literal @}TypeCapability(
* inputs="org.apache.uima.fit.type.Token",
* outputs="org.apache.uima.fit.type.Token:pos")
- * </code></pre>
+ * </code>
+ * </pre>
*
* or
*
- * <pre><code>
+ * <pre>
+ * <code>
* {@literal @}TypeCapability(
* inputs={"org.apache.uima.fit.type.Token","org.apache.uima.fit.type.Sentence"},
* outputs={"org.apache.uima.fit.type.Token:pos", "org.apache.uima.tutorial.RoomNumber"})
- * </code></pre>
+ * </code>
+ * </pre>
*
*/
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/descriptor/package-info.java b/uimafit-core/src/main/java/org/apache/uima/fit/descriptor/package-info.java
index 02bb883..dec8e44 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/descriptor/package-info.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/descriptor/package-info.java
@@ -20,4 +20,3 @@
* uimaFIT annotations used for dependency injection.
*/
package org.apache.uima.fit.descriptor;
-
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/factory/AnalysisEngineFactory.java b/uimafit-core/src/main/java/org/apache/uima/fit/factory/AnalysisEngineFactory.java
index 97db415..de0fe5a 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/factory/AnalysisEngineFactory.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/factory/AnalysisEngineFactory.java
@@ -848,7 +848,7 @@ public final class AnalysisEngineFactory {
public static AnalysisEngineDescription createEngineDescription(PearSpecifier pearSpecifier,
Object... configurationData) throws InvalidXMLException, IOException {
ConfigurationParameterFactory.ensureParametersComeInPairs(configurationData);
-
+
if (configurationData != null) {
for (int i = 0; i < configurationData.length / 2; i++) {
String name = (String) configurationData[i * 2];
@@ -856,19 +856,20 @@ public final class AnalysisEngineFactory {
ConfigurationParameterFactory.setParameter(pearSpecifier, name, value);
}
}
-
+
AnalysisEngineDescription desc = new AnalysisEngineDescription_impl();
desc.setFrameworkImplementation(Constants.JAVA_FRAMEWORK_NAME);
desc.setPrimitive(false);
desc.getDelegateAnalysisEngineSpecifiersWithImports().put(pearSpecifier.getPearPath(),
pearSpecifier);
-
+
FixedFlow fixedFlow = new FixedFlow_impl();
fixedFlow.setFixedFlow(new String[] { pearSpecifier.getPearPath() });
desc.getAnalysisEngineMetaData().setFlowConstraints(fixedFlow);
-
+
return desc;
}
+
/**
* Get an {@link AnalysisEngineDescription} from an XML descriptor file and a set of configuration
* parameters.
@@ -1503,7 +1504,7 @@ public final class AnalysisEngineFactory {
return createEngineDescription(asList(analysisEngineDescriptions), asList(names), null, null,
null);
}
-
+
// Intentionally package-private! We need this in the AggregateBuilder and we would like to test
// it, but it shouldn't really be part of the public API.
static String generateDelegateKey(AnalysisEngineDescription aAed, int aIndex) {
@@ -1512,44 +1513,42 @@ public final class AnalysisEngineFactory {
if (sanitizedName != null) {
return sanitizedName + "-" + aIndex;
}
- }
+ }
if (aAed.isPrimitive()) {
return aAed.getImplementationName() + "-" + aIndex;
}
-
+
return "aggregate-" + aIndex;
}
-
+
static String sanitizeDelegateKey(String name) {
if (name == null) {
return null;
}
-
+
String trimmedName = name.trim();
if (trimmedName.isEmpty()) {
return null;
}
-
+
StringBuilder buf = new StringBuilder();
for (int i = 0; i < trimmedName.length(); i++) {
char c = trimmedName.charAt(i);
if (isWhitespace(c) || c == '_') {
- if (buf.length() > 0 && buf.charAt(buf.length()-1) != '_') {
+ if (buf.length() > 0 && buf.charAt(buf.length() - 1) != '_') {
buf.append('_');
}
- }
- else if (!isJavaIdentifierPart(c)) {
+ } else if (!isJavaIdentifierPart(c)) {
return null;
- }
- else {
+ } else {
buf.append(c);
}
}
-
+
return buf.toString();
}
-
+
/**
* Create and configure an aggregate {@link AnalysisEngine} from several component descriptions.
*
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/factory/CapabilityFactory.java b/uimafit-core/src/main/java/org/apache/uima/fit/factory/CapabilityFactory.java
index d17bb40..fa41072 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/factory/CapabilityFactory.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/factory/CapabilityFactory.java
@@ -43,7 +43,8 @@ public final class CapabilityFactory {
* Creates a single capability consisting of the information in the {@link SofaCapability} and
* {@link TypeCapability} annotations for the class.
*
- * @param componentClass a class with capability annotations
+ * @param componentClass
+ * a class with capability annotations
* @return capabilities extracted from the class
*/
public static Capability createCapability(Class<?> componentClass) {
@@ -55,7 +56,7 @@ public final class CapabilityFactory {
MimeTypeCapability.class);
boolean languageCapabilityPresent = ReflectionUtil.isAnnotationPresent(componentClass,
LanguageCapability.class);
-
+
// Skip if no capability annotations are present at all
if (!sofaCapabilityPresent && !typeCapabilityPresent && !mimeTypeCapabilityPresent
&& !languageCapabilityPresent) {
@@ -73,7 +74,7 @@ public final class CapabilityFactory {
}
capability.setLanguagesSupported(languages);
}
-
+
if (mimeTypeCapabilityPresent) {
MimeTypeCapability annotation = ReflectionUtil.getAnnotation(componentClass,
MimeTypeCapability.class);
@@ -83,9 +84,10 @@ public final class CapabilityFactory {
}
capability.setMimeTypesSupported(mimeTypes);
}
-
+
if (sofaCapabilityPresent) {
- SofaCapability annotation = ReflectionUtil.getAnnotation(componentClass, SofaCapability.class);
+ SofaCapability annotation = ReflectionUtil.getAnnotation(componentClass,
+ SofaCapability.class);
String[] inputSofas = annotation.inputSofas();
if (inputSofas.length == 1 && inputSofas[0].equals(SofaCapability.NO_DEFAULT_VALUE)) {
inputSofas = new String[0];
@@ -100,7 +102,8 @@ public final class CapabilityFactory {
}
if (typeCapabilityPresent) {
- TypeCapability annotation = ReflectionUtil.getAnnotation(componentClass, TypeCapability.class);
+ TypeCapability annotation = ReflectionUtil.getAnnotation(componentClass,
+ TypeCapability.class);
String[] inputTypesOrFeatureNames = annotation.inputs();
capability.setInputs(createTypesOrFeatures(inputTypesOrFeatureNames));
String[] outputTypesOrFeatureNames = annotation.outputs();
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/factory/CasFactory.java b/uimafit-core/src/main/java/org/apache/uima/fit/factory/CasFactory.java
index 77a1d26..578bb59 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/factory/CasFactory.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/factory/CasFactory.java
@@ -69,7 +69,7 @@ public final class CasFactory {
*
* @param aText
* the document text to be set in the new CAS.
- * @param aLanguage
+ * @param aLanguage
* the document language to be set in the new CAS.
* @return a new CAS
* @throws ResourceInitializationException
@@ -86,7 +86,7 @@ public final class CasFactory {
}
return cas;
}
-
+
/**
* Creates a new {@link CAS}. The type system is detected automatically using
* {@link TypeSystemDescriptionFactory#createTypeSystemDescription()}. Type priorities are
@@ -106,7 +106,7 @@ public final class CasFactory {
}
/**
- * Creates a new {@link CAS} from type system descriptor files found by name. No auto-detection
+ * Creates a new {@link CAS} from type system descriptor files found by name. No auto-detection
* for type priorities, or indexes is performed.
*
* @param typeSystemDescriptorNames
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/factory/CollectionReaderFactory.java b/uimafit-core/src/main/java/org/apache/uima/fit/factory/CollectionReaderFactory.java
index 850463c..cccdb57 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/factory/CollectionReaderFactory.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/factory/CollectionReaderFactory.java
@@ -163,9 +163,9 @@ public final class CollectionReaderFactory {
* Any additional configuration parameters to be set. These should be supplied as (name,
* value) pairs, so there should always be an even number of parameters.
* @return The AnalysisEngine created from the XML descriptor and the configuration parameters.
- * @throws ResourceInitializationException
+ * @throws ResourceInitializationException
* if the descriptor could not be created or if the component could not be instantiated
- * @throws InvalidXMLException
+ * @throws InvalidXMLException
* if the descriptor could not be created
* @throws IOException
* if the descriptor could not be read
@@ -191,9 +191,9 @@ public final class CollectionReaderFactory {
* value) pairs, so there should always be an even number of parameters.
* @return The AnalysisEngine created from the XML descriptor and the configuration parameters.
* @deprecated use {@link #createReader(String, Object...)}
- * @throws ResourceInitializationException
+ * @throws ResourceInitializationException
* if the descriptor could not be created or if the component could not be instantiated
- * @throws InvalidXMLException
+ * @throws InvalidXMLException
* if the descriptor could not be created
* @throws IOException
* if the descriptor could not be read
@@ -220,9 +220,8 @@ public final class CollectionReaderFactory {
* @throws ResourceInitializationException
* if the component could not be initialized
*/
- public static CollectionReader createReader(
- Class<? extends CollectionReader> readerClass, Object... configurationData)
- throws ResourceInitializationException {
+ public static CollectionReader createReader(Class<? extends CollectionReader> readerClass,
+ Object... configurationData) throws ResourceInitializationException {
TypeSystemDescription tsd = createTypeSystemDescription();
return createReader(readerClass, tsd, (TypePriorities) null, configurationData);
}
@@ -266,9 +265,9 @@ public final class CollectionReaderFactory {
* @throws ResourceInitializationException
* if the component could not be initialized
*/
- public static CollectionReader createReader(
- Class<? extends CollectionReader> readerClass, TypeSystemDescription typeSystem,
- Object... configurationData) throws ResourceInitializationException {
+ public static CollectionReader createReader(Class<? extends CollectionReader> readerClass,
+ TypeSystemDescription typeSystem, Object... configurationData)
+ throws ResourceInitializationException {
return createReader(readerClass, typeSystem, (TypePriorities) null, configurationData);
}
@@ -311,15 +310,15 @@ public final class CollectionReaderFactory {
* value) pairs, so there should always be an even number of parameters.
* @return The CollectionReader created and initialized with the type system and configuration
* parameters.
- * @deprecated use {@link #createReaderDescription(Class, TypeSystemDescription, String[], Object...)}
+ * @deprecated use
+ * {@link #createReaderDescription(Class, TypeSystemDescription, String[], Object...)}
* @throws ResourceInitializationException
* if the component could not be initialized
*/
@Deprecated
- public static CollectionReader createReader(
- Class<? extends CollectionReader> readerClass, TypeSystemDescription typeSystem,
- String[] prioritizedTypeNames, Object... configurationData)
- throws ResourceInitializationException {
+ public static CollectionReader createReader(Class<? extends CollectionReader> readerClass,
+ TypeSystemDescription typeSystem, String[] prioritizedTypeNames,
+ Object... configurationData) throws ResourceInitializationException {
TypePriorities typePriorities = createTypePriorities(prioritizedTypeNames);
return createReader(readerClass, typeSystem, typePriorities, configurationData);
}
@@ -339,10 +338,11 @@ public final class CollectionReaderFactory {
* value) pairs, so there should always be an even number of parameters.
* @return The CollectionReader created and initialized with the type system and configuration
* parameters.
- * @deprecated use {@link #createReaderDescription(Class, TypeSystemDescription, String[], Object...)}
+ * @deprecated use
+ * {@link #createReaderDescription(Class, TypeSystemDescription, String[], Object...)}
* @throws ResourceInitializationException
* if the component could not be initialized
- *
+ *
* @deprecated use {@link #createReader(Class, TypeSystemDescription, String[], Object...)}
*/
@Deprecated
@@ -369,15 +369,14 @@ public final class CollectionReaderFactory {
* @throws ResourceInitializationException
* if the component could not be initialized
*/
- public static CollectionReader createReader(
- Class<? extends CollectionReader> readerClass, TypeSystemDescription typeSystem,
- TypePriorities typePriorities, Object... configurationData)
- throws ResourceInitializationException {
- CollectionReaderDescription desc = createReaderDescription(readerClass, typeSystem, typePriorities,
- configurationData);
+ public static CollectionReader createReader(Class<? extends CollectionReader> readerClass,
+ TypeSystemDescription typeSystem, TypePriorities typePriorities,
+ Object... configurationData) throws ResourceInitializationException {
+ CollectionReaderDescription desc = createReaderDescription(readerClass, typeSystem,
+ typePriorities, configurationData);
return createReader(desc);
}
-
+
/**
* @param readerClass
* The class of the CollectionReader to be created.
@@ -392,7 +391,7 @@ public final class CollectionReaderFactory {
* parameters.
* @throws ResourceInitializationException
* if the component could not be initialized
- *
+ *
* @deprecated use {@link #createReader(Class, TypeSystemDescription, TypePriorities, Object...)}
*/
@Deprecated
@@ -438,7 +437,7 @@ public final class CollectionReaderFactory {
* parameters.
* @throws ResourceInitializationException
* if the component could not be initialized
- *
+ *
* @deprecated use {@link #createReader(CollectionReaderDescription, Object...)}
*/
@Deprecated
@@ -488,7 +487,7 @@ public final class CollectionReaderFactory {
* configuration parameters
* @throws ResourceInitializationException
* if the descriptor could not be set up
- *
+ *
* @deprecated use {@link #createReaderDescription(Class, Object...)}
*/
@Deprecated
@@ -518,7 +517,8 @@ public final class CollectionReaderFactory {
public static CollectionReaderDescription createReaderDescription(
Class<? extends CollectionReader> readerClass, TypeSystemDescription typeSystem,
Object... configurationData) throws ResourceInitializationException {
- return createReaderDescription(readerClass, typeSystem, (TypePriorities) null, configurationData);
+ return createReaderDescription(readerClass, typeSystem, (TypePriorities) null,
+ configurationData);
}
/**
@@ -536,7 +536,7 @@ public final class CollectionReaderFactory {
* configuration parameters
* @throws ResourceInitializationException
* if the descriptor could not be set up
- *
+ *
* @deprecated use {@link #createReaderDescription(Class, TypeSystemDescription, Object...)}
*/
@Deprecated
@@ -583,15 +583,17 @@ public final class CollectionReaderFactory {
* configuration parameters
* @throws ResourceInitializationException
* if the descriptor could not be set up
- *
- * @deprecated use {@link #createReaderDescription(Class, TypeSystemDescription, String[], Object...)}
+ *
+ * @deprecated use
+ * {@link #createReaderDescription(Class, TypeSystemDescription, String[], Object...)}
*/
@Deprecated
public static CollectionReaderDescription createDescription(
Class<? extends CollectionReader> readerClass, TypeSystemDescription typeSystem,
String[] prioritizedTypeNames, Object... configurationData)
throws ResourceInitializationException {
- return createReaderDescription(readerClass, typeSystem, prioritizedTypeNames, configurationData);
+ return createReaderDescription(readerClass, typeSystem, prioritizedTypeNames,
+ configurationData);
}
/**
@@ -614,8 +616,8 @@ public final class CollectionReaderFactory {
Class<? extends CollectionReader> readerClass, TypeSystemDescription typeSystem,
TypePriorities typePriorities, Object... configurationData)
throws ResourceInitializationException {
- return createReaderDescription(readerClass, typeSystem, typePriorities, (FsIndexCollection) null,
- (Capability[]) null, configurationData);
+ return createReaderDescription(readerClass, typeSystem, typePriorities,
+ (FsIndexCollection) null, (Capability[]) null, configurationData);
}
/**
@@ -632,8 +634,9 @@ public final class CollectionReaderFactory {
* configuration parameters
* @throws ResourceInitializationException
* if the descriptor could not be set up
- *
- * @deprecated use {@link #createReaderDescription(Class, TypeSystemDescription, TypePriorities, Object...)}
+ *
+ * @deprecated use
+ * {@link #createReaderDescription(Class, TypeSystemDescription, TypePriorities, Object...)}
*/
@Deprecated
public static CollectionReaderDescription createDescription(
@@ -700,7 +703,8 @@ public final class CollectionReaderFactory {
* @throws ResourceInitializationException
* if the descriptor could not be set up
*
- * @deprecated use {@link #createReaderDescription(Class, TypeSystemDescription, TypePriorities, FsIndexCollection, Capability[], Object...)}
+ * @deprecated use
+ * {@link #createReaderDescription(Class, TypeSystemDescription, TypePriorities, FsIndexCollection, Capability[], Object...)}
*/
@Deprecated
public static CollectionReaderDescription createDescription(
@@ -710,7 +714,7 @@ public final class CollectionReaderFactory {
return createReaderDescription(readerClass, typeSystem, typePriorities, indexes, capabilities,
configurationData);
}
-
+
/**
*
* @param readerClass
@@ -760,7 +764,8 @@ public final class CollectionReaderFactory {
* configuration parameters
* @throws ResourceInitializationException
* if the descriptor could not be set up
- * @deprecated use {@link #createReaderDescription(Class, TypeSystemDescription, TypePriorities, FsIndexCollection, Capability[], ConfigurationParameter[], Object[])}
+ * @deprecated use
+ * {@link #createReaderDescription(Class, TypeSystemDescription, TypePriorities, FsIndexCollection, Capability[], ConfigurationParameter[], Object[])}
*/
@Deprecated
public static CollectionReaderDescription createDescription(
@@ -856,7 +861,7 @@ public final class CollectionReaderFactory {
return desc;
}
-
+
/**
* The factory method for creating CollectionReaderDescription objects for a given class,
* TypeSystemDescription, TypePriorities, capabilities, and configuration data
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/factory/ConfigurationParameterFactory.java b/uimafit-core/src/main/java/org/apache/uima/fit/factory/ConfigurationParameterFactory.java
index 1a3aca2..4418897 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/factory/ConfigurationParameterFactory.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/factory/ConfigurationParameterFactory.java
@@ -288,9 +288,9 @@ public final class ConfigurationParameterFactory {
static Object convertParameterValue(ConfigurationParameter param, Object aValue) {
Object value = aValue;
if (aValue == null) {
- return null;
+ return null;
}
-
+
if (value.getClass().isArray() && value.getClass().getComponentType().isPrimitive()) {
if ("boolean".equals(value.getClass().getComponentType().getName())) {
return ArrayUtils.toObject((boolean[]) value);
@@ -307,7 +307,7 @@ public final class ConfigurationParameterFactory {
if ("float".equals(value.getClass().getComponentType().getName())) {
return ArrayUtils.toObject((float[]) value);
}
-
+
if ("double".equals(value.getClass().getComponentType().getName())) {
return ArrayUtils.toObject((double[]) value);
}
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/factory/ExternalResourceFactory.java b/uimafit-core/src/main/java/org/apache/uima/fit/factory/ExternalResourceFactory.java
index fa98531..cfdee71 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/factory/ExternalResourceFactory.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/factory/ExternalResourceFactory.java
@@ -159,8 +159,8 @@ public final class ExternalResourceFactory {
ResourceCreationSpecifierFactory.setConfigurationParameters(meta,
reflectedConfigurationData.configurationParameters,
reflectedConfigurationData.configurationValues);
- ResourceCreationSpecifierFactory.setConfigurationParameters(meta,
- cfg.configurationParameters, cfg.configurationValues);
+ ResourceCreationSpecifierFactory.setConfigurationParameters(meta, cfg.configurationParameters,
+ cfg.configurationValues);
ConfigurableDataResourceSpecifier_impl spec1 = new ConfigurableDataResourceSpecifier_impl();
spec1.setUrl("");
@@ -170,7 +170,8 @@ public final class ExternalResourceFactory {
List<Parameter> params = new ArrayList<Parameter>();
if (aParams != null) {
for (int i = 0; i < aParams.length / 2; i++) {
- if (ExternalResourceFactory.getResourceParameterType(aParams[i * 2 + 1]) != ResourceValueType.NO_RESOURCE) {
+ if (ExternalResourceFactory
+ .getResourceParameterType(aParams[i * 2 + 1]) != ResourceValueType.NO_RESOURCE) {
continue;
}
@@ -199,6 +200,7 @@ public final class ExternalResourceFactory {
/**
* Create an external resource description for a {@link SharedResourceObject}.
+ *
* @param aUrl
* the URL from which the resource is initialized.
* @param aInterface
@@ -210,14 +212,15 @@ public final class ExternalResourceFactory {
* @see ConfigurableDataResourceSpecifier
* @see SharedResourceObject
*/
- public static ExternalResourceDescription createSharedResourceDescription(
- String aUrl, Class<? extends SharedResourceObject> aInterface, Object... aParams) {
- return createNamedResourceDescriptionUsingUrl(uniqueResourceKey(aInterface.getName()), aInterface,
- aUrl, aParams);
+ public static ExternalResourceDescription createSharedResourceDescription(String aUrl,
+ Class<? extends SharedResourceObject> aInterface, Object... aParams) {
+ return createNamedResourceDescriptionUsingUrl(uniqueResourceKey(aInterface.getName()),
+ aInterface, aUrl, aParams);
}
/**
* Create an external resource description for a {@link SharedResourceObject}.
+ *
* @param aUrl
* the URL from which the resource is initialized.
* @param aInterface
@@ -229,14 +232,15 @@ public final class ExternalResourceFactory {
* @see ConfigurableDataResourceSpecifier
* @see SharedResourceObject
*/
- public static ExternalResourceDescription createSharedResourceDescription(
- URL aUrl, Class<? extends SharedResourceObject> aInterface, Object... aParams) {
- return createNamedResourceDescriptionUsingUrl(uniqueResourceKey(aInterface.getName()), aInterface,
- aUrl.toString(), aParams);
+ public static ExternalResourceDescription createSharedResourceDescription(URL aUrl,
+ Class<? extends SharedResourceObject> aInterface, Object... aParams) {
+ return createNamedResourceDescriptionUsingUrl(uniqueResourceKey(aInterface.getName()),
+ aInterface, aUrl.toString(), aParams);
}
/**
* Create an external resource description for a {@link SharedResourceObject}.
+ *
* @param aFile
* the file from which the resource is initialized.
* @param aInterface
@@ -248,8 +252,8 @@ public final class ExternalResourceFactory {
* @see ConfigurableDataResourceSpecifier
* @see SharedResourceObject
*/
- public static ExternalResourceDescription createSharedResourceDescription(
- File aFile, Class<? extends SharedResourceObject> aInterface, Object... aParams) {
+ public static ExternalResourceDescription createSharedResourceDescription(File aFile,
+ Class<? extends SharedResourceObject> aInterface, Object... aParams) {
try {
return createSharedResourceDescription(aFile.toURI().toURL(), aInterface, aParams);
} catch (MalformedURLException e) {
@@ -274,8 +278,9 @@ public final class ExternalResourceFactory {
* @see ConfigurableDataResourceSpecifier
* @see SharedResourceObject
*/
- public static ExternalResourceDescription createNamedResourceDescriptionUsingUrl(final String aName,
- Class<? extends SharedResourceObject> aInterface, String aUrl, Object... aParams) {
+ public static ExternalResourceDescription createNamedResourceDescriptionUsingUrl(
+ final String aName, Class<? extends SharedResourceObject> aInterface, String aUrl,
+ Object... aParams) {
// Extract ExternalResourceDescriptions from configurationData
List<ExternalResourceBinding> bindings = new ArrayList<ExternalResourceBinding>();
List<ExternalResourceDescription> descs = new ArrayList<ExternalResourceDescription>();
@@ -319,8 +324,8 @@ public final class ExternalResourceFactory {
* @return the description.
* @see FileResourceSpecifier
*/
- public static ExternalResourceDescription createNamedFileResourceDescription(
- final String aName, String aUrl) {
+ public static ExternalResourceDescription createNamedFileResourceDescription(final String aName,
+ String aUrl) {
ExternalResourceDescription extRes = new ExternalResourceDescription_impl();
extRes.setName(aName);
FileResourceSpecifier frs = new FileResourceSpecifier_impl();
@@ -385,13 +390,11 @@ public final class ExternalResourceFactory {
// Get the type of class/interface a resource has to implement to bind to the annotated field.
// If no API is set, get it from the annotated field type.
Class<? extends Resource> api = era.api();
-
+
// If no API is specified, look at the annotated field
if (api == Resource.class) {
- if (
- Resource.class.isAssignableFrom(field.getType()) ||
- SharedResourceObject.class.isAssignableFrom(field.getType())
- ) {
+ if (Resource.class.isAssignableFrom(field.getType())
+ || SharedResourceObject.class.isAssignableFrom(field.getType())) {
// If no API is set, check if the field type is already a resource type
api = (Class<? extends Resource>) field.getType();
} else {
@@ -440,8 +443,8 @@ public final class ExternalResourceFactory {
* @throws ResourceInitializationException
* if the external resource dependencies could not be created
*/
- public static ExternalResourceDependency[] createResourceDependencies(
- Class<?> cls) throws ResourceInitializationException {
+ public static ExternalResourceDependency[] createResourceDependencies(Class<?> cls)
+ throws ResourceInitializationException {
Map<String, ExternalResourceDependency> depMap = new HashMap<String, ExternalResourceDependency>();
ExternalResourceFactory.createResourceDependencies(cls, cls, depMap);
Collection<ExternalResourceDependency> deps = depMap.values();
@@ -463,8 +466,8 @@ public final class ExternalResourceFactory {
ExternalResourceDependency dep = createResourceDependency(field);
if (dependencies.containsKey(dep.getKey())) {
- throw new ResourceInitializationException(new IllegalStateException("Key [" + dep.getKey()
- + "] may only be used on a single field."));
+ throw new ResourceInitializationException(new IllegalStateException(
+ "Key [" + dep.getKey() + "] may only be used on a single field."));
}
dependencies.put(dep.getKey(), dep);
@@ -556,7 +559,7 @@ public final class ExternalResourceFactory {
throws InvalidXMLException {
bindResourceUsingUrl(aDesc, aKey, aUrl);
}
-
+
/**
* Scan the given resource specifier for external resource dependencies and whenever a dependency
* is encountered that has the specified key, the resource will be bound.
@@ -624,8 +627,8 @@ public final class ExternalResourceFactory {
* @see CustomResourceSpecifier
*/
public static void bindResource(ResourceSpecifier aDesc, Class<?> aApi,
- Class<? extends Resource> aRes, String... aParams) throws InvalidXMLException,
- ClassNotFoundException {
+ Class<? extends Resource> aRes, String... aParams)
+ throws InvalidXMLException, ClassNotFoundException {
// Appending a disambiguation suffix it possible to have multiple instances of the same
// resource with different settings to different keys.
ExternalResourceDescription extRes = createNamedResourceDescription(
@@ -857,10 +860,8 @@ public final class ExternalResourceFactory {
// If not, create one
if (!found) {
- setResourceDependencies(
- aDesc,
- ArrayUtils.add(deps,
- createResourceDependency(aKey, aApi, false, null)));
+ setResourceDependencies(aDesc,
+ ArrayUtils.add(deps, createResourceDependency(aKey, aApi, false, null)));
}
}
@@ -890,8 +891,7 @@ public final class ExternalResourceFactory {
* @throws IllegalArgumentException
* if the sub-class passed is not supported.
*/
- private static ExternalResourceDependency[] getResourceDependencies(
- ResourceSpecifier aDesc) {
+ private static ExternalResourceDependency[] getResourceDependencies(ResourceSpecifier aDesc) {
if (aDesc instanceof CollectionReaderDescription) {
return ((CollectionReaderDescription) aDesc).getExternalResourceDependencies();
} else if (aDesc instanceof AnalysisEngineDescription) {
@@ -928,8 +928,8 @@ public final class ExternalResourceFactory {
if (deps == null) {
deps = new ExternalResourceDependency[] {};
}
- aDesc.setExternalResourceDependencies(ArrayUtils.add(deps,
- createResourceDependency(aKey, aImpl, false, null)));
+ aDesc.setExternalResourceDependencies(
+ ArrayUtils.add(deps, createResourceDependency(aKey, aImpl, false, null)));
}
bindResourceUsingUrl(aDesc, aKey, aImpl, aUrl, aParams);
}
@@ -999,8 +999,8 @@ public final class ExternalResourceFactory {
/**
* Create a binding for the given external resource in the given resource manager. This method
- * also scans the given external resource for any nested external resources and creates
- * bindings for them as well.
+ * also scans the given external resource for any nested external resources and creates bindings
+ * for them as well.
*
* @param aResMgrCfg
* the resource manager to create the binding in.
@@ -1008,18 +1008,19 @@ public final class ExternalResourceFactory {
* what key to bind to.
* @param aRes
* the resource that should be bound.
- * @deprecated Use {@link #bindResourceOnce(ResourceManagerConfiguration, String, ExternalResourceDescription)}
+ * @deprecated Use
+ * {@link #bindResourceOnce(ResourceManagerConfiguration, String, ExternalResourceDescription)}
*/
@Deprecated
public static void bindResource(ResourceManagerConfiguration aResMgrCfg, String aBindTo,
ExternalResourceDescription aRes) {
bindResourceOnce(aResMgrCfg, aBindTo, aRes);
}
-
+
/**
* Create a binding for the given external resource in the given resource manager. This method
- * also scans the given external resource for any nested external resources and creates
- * bindings for them as well.
+ * also scans the given external resource for any nested external resources and creates bindings
+ * for them as well.
* <p>
* <b>NOTE:</b>If you use this method on resource manager configurations of aggregate analysis
* engine descriptions because it will <b>not have any effects on the delegate analysis
@@ -1057,10 +1058,10 @@ public final class ExternalResourceFactory {
bindNestedResources(aRes, bindings, resources);
// Commit everything to the resource manager configuration
- aResMgrCfg.setExternalResourceBindings(bindings.values().toArray(
- new ExternalResourceBinding[bindings.size()]));
- aResMgrCfg.setExternalResources(resources.values().toArray(
- new ExternalResourceDescription[resources.size()]));
+ aResMgrCfg.setExternalResourceBindings(
+ bindings.values().toArray(new ExternalResourceBinding[bindings.size()]));
+ aResMgrCfg.setExternalResources(
+ resources.values().toArray(new ExternalResourceDescription[resources.size()]));
}
/**
@@ -1072,14 +1073,15 @@ public final class ExternalResourceFactory {
* what key to bind to.
* @param aNestedRes
* the resource that should be bound.
- * @deprecated Use {@link #bindResourceOnce(ExternalResourceDescription, String, ExternalResourceDescription)}
+ * @deprecated Use
+ * {@link #bindResourceOnce(ExternalResourceDescription, String, ExternalResourceDescription)}
*/
@Deprecated
public static void bindResource(ExternalResourceDescription aRes, String aBindTo,
ExternalResourceDescription aNestedRes) {
bindResourceOnce(aRes, aBindTo, aNestedRes);
}
-
+
/**
* Create a binding for the given external resource in the given resource. This method also scans
* the given external resource for any nested external resources and creates bindings for them as
@@ -1271,8 +1273,7 @@ public final class ExternalResourceFactory {
ExternalResourceBinding extResBind = createResourceBinding(aBindTo, aRes);
aResMgrCfg.addExternalResourceBinding(extResBind);
}
-
-
+
/**
* Create a binding for the given external resource in resource manager configuration of the given
* resource creation specified. If no resource manager configuration exists yet, it is created.
@@ -1293,7 +1294,8 @@ public final class ExternalResourceFactory {
* @param aRes
* the resource that should be bound.
*/
- public static void bindResourceOnceWithoutNested(ResourceCreationSpecifier aDesc, String aBindTo, String aRes) {
+ public static void bindResourceOnceWithoutNested(ResourceCreationSpecifier aDesc, String aBindTo,
+ String aRes) {
ResourceManagerConfiguration resMgrCfg = aDesc.getResourceManagerConfiguration();
if (resMgrCfg == null) {
resMgrCfg = new ResourceManagerConfiguration_impl();
@@ -1346,19 +1348,17 @@ public final class ExternalResourceFactory {
if (value == null) {
continue;
}
-
+
// Store External Resource parameters separately
ResourceValueType type = getResourceParameterType(value);
if (type == ResourceValueType.PRIMITIVE) {
ExternalResourceDescription description = (ExternalResourceDescription) value;
extRes.put(key, description);
- }
- else if (type.isMultiValued()) {
+ } else if (type.isMultiValued()) {
Collection<ExternalResourceDescription> resList;
if (type == ResourceValueType.ARRAY) {
resList = asList((ExternalResourceDescription[]) value);
- }
- else {
+ } else {
resList = (Collection<ExternalResourceDescription>) value;
}
@@ -1372,7 +1372,7 @@ public final class ExternalResourceFactory {
params.add(res);
n++;
}
-
+
// Record the list and attach the list elements to the list
extRes.put(key, createResourceDescription(ResourceList.class, params.toArray()));
}
@@ -1380,24 +1380,23 @@ public final class ExternalResourceFactory {
return extRes;
}
-
+
/**
- * Determine which kind of external resource the given value is. This is only meant for
- * uimaFIT internal use. This method is required by the ConfigurationParameterFactory, so it is
- * package private instead of private.
+ * Determine which kind of external resource the given value is. This is only meant for uimaFIT
+ * internal use. This method is required by the ConfigurationParameterFactory, so it is package
+ * private instead of private.
*/
static ResourceValueType getResourceParameterType(Object aValue) {
if (aValue == null) {
return ResourceValueType.NO_RESOURCE;
}
-
+
boolean isResourcePrimitive = aValue instanceof ExternalResourceDescription;
- boolean isResourceArray = aValue.getClass().isArray()
- && ExternalResourceDescription.class.isAssignableFrom(aValue.getClass()
- .getComponentType());
- boolean isResourceCollection = (Collection.class.isAssignableFrom(aValue
- .getClass()) && !((Collection) aValue).isEmpty() && ((Collection) aValue)
- .iterator().next() instanceof ExternalResourceDescription);
+ boolean isResourceArray = aValue.getClass().isArray() && ExternalResourceDescription.class
+ .isAssignableFrom(aValue.getClass().getComponentType());
+ boolean isResourceCollection = (Collection.class.isAssignableFrom(aValue.getClass())
+ && !((Collection) aValue).isEmpty()
+ && ((Collection) aValue).iterator().next() instanceof ExternalResourceDescription);
if (isResourcePrimitive) {
return ResourceValueType.PRIMITIVE;
} else if (isResourceArray) {
@@ -1408,7 +1407,7 @@ public final class ExternalResourceFactory {
return ResourceValueType.NO_RESOURCE;
}
}
-
+
/**
* Create an instance of a UIMA shared/external resource class.
*
@@ -1423,8 +1422,8 @@ public final class ExternalResourceFactory {
* @throws ResourceInitializationException
* if there was a problem instantiating the resource.
*/
- public static <R extends Resource> R createResource(Class<R> resourceClass,
- Object... params) throws ResourceInitializationException {
+ public static <R extends Resource> R createResource(Class<R> resourceClass, Object... params)
+ throws ResourceInitializationException {
return createResource(resourceClass, null, params);
}
@@ -1450,18 +1449,14 @@ public final class ExternalResourceFactory {
ExternalResourceDescription res = createResourceDescription(resourceClass, params);
return (R) produceResource(resourceClass, res.getResourceSpecifier(), resMgr, emptyMap());
}
-
+
/**
* Types of external resource values.
*/
static enum ResourceValueType {
- NO_RESOURCE,
- PRIMITIVE,
- ARRAY,
- COLLECTION;
-
- public boolean isMultiValued()
- {
+ NO_RESOURCE, PRIMITIVE, ARRAY, COLLECTION;
+
+ public boolean isMultiValued() {
return this == COLLECTION || this == ARRAY;
}
}
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/factory/JCasFactory.java b/uimafit-core/src/main/java/org/apache/uima/fit/factory/JCasFactory.java
index 57d1285..b39564e 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/factory/JCasFactory.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/factory/JCasFactory.java
@@ -44,7 +44,7 @@ public final class JCasFactory {
* @return a new JCas
* @throws ResourceInitializationException
* if the CAS could not be initialized
- * @throws CASException
+ * @throws CASException
* if the JCas could not be initialized
*/
public static JCas createText(String aText) throws ResourceInitializationException, CASException {
@@ -59,19 +59,19 @@ public final class JCasFactory {
*
* @param aText
* the document text to be set in the new JCas.
- * @param aLanguage
+ * @param aLanguage
* the document language to be set in the new JCas.
* @return a new JCas
* @throws ResourceInitializationException
* if the CAS could not be initialized
- * @throws CASException
+ * @throws CASException
* if the JCas could not be initialized
*/
public static JCas createText(String aText, String aLanguage)
throws ResourceInitializationException, CASException {
return CasFactory.createText(aText, aLanguage).getJCas();
}
-
+
/**
* Creates a new {@link JCas}. The type system is detected automatically using
* {@link TypeSystemDescriptionFactory#createTypeSystemDescription()}. Type priorities are
@@ -81,7 +81,7 @@ public final class JCasFactory {
* @return a new JCas
* @throws ResourceInitializationException
* if the CAS could not be initialized
- * @throws CASException
+ * @throws CASException
* if the JCas could not be initialized
*/
public static JCas createJCas() throws ResourceInitializationException, CASException {
@@ -98,7 +98,7 @@ public final class JCasFactory {
* @return a new JCas
* @throws ResourceInitializationException
* if the CAS could not be initialized
- * @throws CASException
+ * @throws CASException
* if the JCas could not be initialized
*/
public static JCas createJCas(String... typeSystemDescriptorNames)
@@ -115,7 +115,7 @@ public final class JCasFactory {
* @return a new JCas
* @throws ResourceInitializationException
* if the CAS could not be initialized
- * @throws CASException
+ * @throws CASException
* if the JCas could not be initialized
*/
public static JCas createJCasFromPath(String... typeSystemDescriptorPaths)
@@ -132,7 +132,7 @@ public final class JCasFactory {
* @return a new JCas
* @throws ResourceInitializationException
* if the CAS could not be initialized
- * @throws CASException
+ * @throws CASException
* if the JCas could not be initialized
*/
public static JCas createJCas(TypeSystemDescription typeSystemDescription)
@@ -150,7 +150,7 @@ public final class JCasFactory {
* @return a new JCas
* @throws ResourceInitializationException
* if the CAS could not be initialized
- * @throws CASException
+ * @throws CASException
* if the JCas could not be initialized
* @throws IOException
* if there is a problem reading the file
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/factory/ResourceCreationSpecifierFactory.java b/uimafit-core/src/main/java/org/apache/uima/fit/factory/ResourceCreationSpecifierFactory.java
index 8bcc481..c55a6a4 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/factory/ResourceCreationSpecifierFactory.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/factory/ResourceCreationSpecifierFactory.java
@@ -126,7 +126,8 @@ public final class ResourceCreationSpecifierFactory {
ConfigurationParameterFactory.ensureParametersComeInPairs(configurationData);
- ConfigurationParameter[] configurationParameters = new ConfigurationParameter[configurationData.length / 2];
+ ConfigurationParameter[] configurationParameters = new ConfigurationParameter[configurationData.length
+ / 2];
Object[] configurationValues = new Object[configurationData.length / 2];
for (int i = 0; i < configurationValues.length; i++) {
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/factory/ResourceMetaDataFactory.java b/uimafit-core/src/main/java/org/apache/uima/fit/factory/ResourceMetaDataFactory.java
index 15e05b9..2f95a99 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/factory/ResourceMetaDataFactory.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/factory/ResourceMetaDataFactory.java
@@ -41,7 +41,8 @@ public final class ResourceMetaDataFactory {
* the class that may carry the {@link org.apache.uima.fit.descriptor.ResourceMetaData}
* annotation
*/
- public static void configureResourceMetaData(ResourceMetaData aMetaData, Class<?> aComponentClass) {
+ public static void configureResourceMetaData(ResourceMetaData aMetaData,
+ Class<?> aComponentClass) {
org.apache.uima.fit.descriptor.ResourceMetaData componentAnno = ReflectionUtil
.getInheritableAnnotation(org.apache.uima.fit.descriptor.ResourceMetaData.class,
aComponentClass);
@@ -64,12 +65,12 @@ public final class ResourceMetaDataFactory {
aMetaData.setVersion(emptyAsNull(componentAnno.version()));
}
}
-
+
/**
* Used when the version of a component is unknown.
*/
private static final String DEFAULT_VERSION = "unknown";
-
+
/**
* Used when the description of a component is unknown.
*/
@@ -82,8 +83,7 @@ public final class ResourceMetaDataFactory {
* the class to analyze
* @return the default copyright
*/
- public static String getDefaultCopyright(Class<?> aComponentClass)
- {
+ public static String getDefaultCopyright(Class<?> aComponentClass) {
// rec 2013-01-27: Basically just here for completeness - no idea where to one could obtain
// a copyright information for the class. Possibly from some LICENSE file in the JAR which
// contains the class.
@@ -97,8 +97,7 @@ public final class ResourceMetaDataFactory {
* the class to analyze
* @return the default version
*/
- public static String getDefaultVersion(Class<?> aComponentClass)
- {
+ public static String getDefaultVersion(Class<?> aComponentClass) {
// TODO This method could try to obtain a version from the package of the component
// aComponentClass.getPackage().getImplementationVersion()
return DEFAULT_VERSION;
@@ -111,31 +110,28 @@ public final class ResourceMetaDataFactory {
* the class to analyze
* @return the default description
*/
- public static String getDefaultDescription(Class<?> aComponentClass)
- {
+ public static String getDefaultDescription(Class<?> aComponentClass) {
return DEFAULT_DESCRIPTION;
}
-
+
/**
* Get the default vendor of a component class.
*
* @param aComponentClass
* the class to analyze
- * @return the package name of the component, if the component is in a package, otherwise
+ * @return the package name of the component, if the component is in a package, otherwise
* {@code null}.
*/
- public static String getDefaultVendor(Class<?> aComponentClass)
- {
+ public static String getDefaultVendor(Class<?> aComponentClass) {
// TODO This method could try to obtain a vendor from the package of the component
// aComponentClass.getPackage().getImplementationVendor()
if (aComponentClass.getPackage() != null) {
return aComponentClass.getPackage().getName();
- }
- else {
+ } else {
return null;
}
}
-
+
/**
* Get the default name of a component class.
*
@@ -143,16 +139,14 @@ public final class ResourceMetaDataFactory {
* the class to analyze
* @return the fully qualified name of the class.
*/
- public static String getDefaultName(Class<?> aComponentClass)
- {
+ public static String getDefaultName(Class<?> aComponentClass) {
return aComponentClass.getName();
}
-
+
private static String emptyAsNull(String aString) {
if (aString == null || aString.length() == 0) {
return null;
- }
- else {
+ } else {
return aString;
}
}
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/factory/SofaMappingFactory.java b/uimafit-core/src/main/java/org/apache/uima/fit/factory/SofaMappingFactory.java
index 9252d9b..597a6c1 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/factory/SofaMappingFactory.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/factory/SofaMappingFactory.java
@@ -36,7 +36,8 @@ public final class SofaMappingFactory {
* <p>
* WARNING: in version 0.9.12 the ordering of the parameters was changed! The order used to be
* aggregateSofaName, componentKey, componentSofaName. This was changed because it seemed an
- * unnatural ordering.</p>
+ * unnatural ordering.
+ * </p>
*
* @param componentKey
* the key/name used by the aggregate analysis engine for the component whose view is
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/factory/initializable/InitializableFactory.java b/uimafit-core/src/main/java/org/apache/uima/fit/factory/initializable/InitializableFactory.java
index 535782d..46a2f30 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/factory/initializable/InitializableFactory.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/factory/initializable/InitializableFactory.java
@@ -56,8 +56,8 @@ public final class InitializableFactory {
ClassLoader cl = ClassLoaderUtils.findClassloader(context);
cls = Class.forName(className, true, cl).asSubclass(superClass);
} catch (Exception e) {
- throw new ResourceInitializationException(new IllegalStateException("classname = "
- + className + " superClass = " + superClass.getName(), e));
+ throw new ResourceInitializationException(new IllegalStateException(
+ "classname = " + className + " superClass = " + superClass.getName(), e));
}
return create(context, cls);
}
@@ -79,8 +79,8 @@ public final class InitializableFactory {
ClassLoader cl = ClassLoaderUtils.findClassloader();
return Class.forName(className, true, cl).asSubclass(superClass);
} catch (Exception e) {
- throw new ResourceInitializationException(new IllegalStateException("classname = "
- + className + " superClass = " + superClass.getName(), e));
+ throw new ResourceInitializationException(new IllegalStateException(
+ "classname = " + className + " superClass = " + superClass.getName(), e));
}
}
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/factory/package-info.java b/uimafit-core/src/main/java/org/apache/uima/fit/factory/package-info.java
index 2eb3845..04fc8c9 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/factory/package-info.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/factory/package-info.java
@@ -24,9 +24,9 @@
* It is recommended to avoid instantiating components with uimaFIT outside of a running pipeline,
* unless necessary and unless you are aware of the consequences.
*
- * When run within a pipeline, such as {@link org.apache.uima.fit.pipeline.SimplePipeline} or
- * within a Collection Processing Engine, the pipeline logic takes care of invoking the life-cycle
- * methods on a component, such as:
+ * When run within a pipeline, such as {@link org.apache.uima.fit.pipeline.SimplePipeline} or within
+ * a Collection Processing Engine, the pipeline logic takes care of invoking the life-cycle methods
+ * on a component, such as:
*
* <ul>
* <li>initialize</li>
@@ -37,17 +37,18 @@
*
* When components are created manually, it is the responsability of the caller to explicitly invoke
* the life-cycle methods. The only method that uimaFIT may call is <em>initialize</em> to provide
- * an {@link org.apache.uima.UimaContext} with the desired parametrization of the component.
+ * an {@link org.apache.uima.UimaContext} with the desired parametrization of the component.
*
* Not letting UIMA/uimaFIT manage the life-cycle of a component can, thus, have some unexpected
* effects. For example, a {@link org.apache.uima.collection.CollectionReader} cannot be reused
- * after it has been passed to a {@link org.apache.uima.fit.pipeline.SimplePipeline#runPipeline(org.apache.uima.collection.CollectionReader, org.apache.uima.analysis_engine.AnalysisEngine...)}.
+ * after it has been passed to a
+ * {@link org.apache.uima.fit.pipeline.SimplePipeline#runPipeline(org.apache.uima.collection.CollectionReader, org.apache.uima.analysis_engine.AnalysisEngine...)}.
* The pipeline reads all files from the reader instance, and when it is complete, the reader does
- * not have any more data to produce. Passing the reader to subsequent {@code runPipeline} methods will not
- * produce any results. When a {@link org.apache.uima.collection.CollectionReaderDescription}
- * is passed instead, the reader is created, initalized, and destroyed inside the
- * {@code runPipeline} method. The description can be passed to multiple {@code runPipeline} calls
- * and each time, it will behave the same way, producing all its data.
+ * not have any more data to produce. Passing the reader to subsequent {@code runPipeline} methods
+ * will not produce any results. When a
+ * {@link org.apache.uima.collection.CollectionReaderDescription} is passed instead, the reader is
+ * created, initalized, and destroyed inside the {@code runPipeline} method. The description can be
+ * passed to multiple {@code runPipeline} calls and each time, it will behave the same way,
+ * producing all its data.
*/
package org.apache.uima.fit.factory;
-
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/internal/ClassLoaderUtils.java b/uimafit-core/src/main/java/org/apache/uima/fit/internal/ClassLoaderUtils.java
index f498264..11efc13 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/internal/ClassLoaderUtils.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/internal/ClassLoaderUtils.java
@@ -38,7 +38,8 @@ public final class ClassLoaderUtils {
* <li>The {@link UimaContext} in the {@link UimaContextHolder} of the current thread(if any)</li>
* <li>The current thread-context classloader (if any)</li>
* <li>The classloader through which uimaFIT (i.e. this class) was loaded.</li>
- * <li>For backwards compatibility then delegates to {@link ClassUtils#getDefaultClassLoader()}</li>
+ * <li>For backwards compatibility then delegates to
+ * {@link ClassUtils#getDefaultClassLoader()}</li>
* </ol>
*
* @return a classloader or {@code null} if no suitable classloader could be found.
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/internal/DescriptionUtils.java b/uimafit-core/src/main/java/org/apache/uima/fit/internal/DescriptionUtils.java
index 7076c62..9fa7b4b 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/internal/DescriptionUtils.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/internal/DescriptionUtils.java
@@ -83,12 +83,12 @@ public final class DescriptionUtils {
aeDelegate.getAnalysisEngineMetaData().setTypeSystem(null);
aeDelegate.getAnalysisEngineMetaData().setTypePriorities(null);
aeDelegate.getAnalysisEngineMetaData().setFsIndexCollection(null);
-
+
if (firstDelegate == null) {
firstDelegate = aeDelegate;
}
}
-
+
// Type systems cannot be set on aggregates, so set it on the first delegate instead
firstDelegate.getAnalysisEngineMetaData().setTypeSystem(meta.getTypeSystem());
// The rest can be set on the aggregate
@@ -113,7 +113,7 @@ public final class DescriptionUtils {
aDesc.setResourceManagerConfiguration(resMgrCfg);
}
- resMgrCfg.setExternalResources(resources.values().toArray(
- new ExternalResourceDescription[resources.size()]));
+ resMgrCfg.setExternalResources(
+ resources.values().toArray(new ExternalResourceDescription[resources.size()]));
}
}
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/internal/ExtendedExternalResourceDescription_impl.java b/uimafit-core/src/main/java/org/apache/uima/fit/internal/ExtendedExternalResourceDescription_impl.java
index 063252a..9ef74fb 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/internal/ExtendedExternalResourceDescription_impl.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/internal/ExtendedExternalResourceDescription_impl.java
@@ -46,7 +46,8 @@ public class ExtendedExternalResourceDescription_impl extends ExternalResourceDe
}
/**
- * @param aExternalResourceBindings the external resource bindings
+ * @param aExternalResourceBindings
+ * the external resource bindings
*/
public void setExternalResourceBindings(
Collection<ExternalResourceBinding> aExternalResourceBindings) {
@@ -64,7 +65,8 @@ public class ExtendedExternalResourceDescription_impl extends ExternalResourceDe
}
/**
- * @param aExternalResourceDescriptions the external resource descriptions
+ * @param aExternalResourceDescriptions
+ * the external resource descriptions
*/
public void setExternalResources(
Collection<ExternalResourceDescription> aExternalResourceDescriptions) {
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/internal/LegacySupport.java b/uimafit-core/src/main/java/org/apache/uima/fit/internal/LegacySupport.java
index e17b5bb..442ac29 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/internal/LegacySupport.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/internal/LegacySupport.java
@@ -77,9 +77,9 @@ public final class LegacySupport {
};
}
}
-
+
/**
- * Get legacy support instance. Never returns {@code null}. If no legacy support plug-in is
+ * Get legacy support instance. Never returns {@code null}. If no legacy support plug-in is
* available, a dummy plug-in is returned.
*
* @return the legacy support plugin.
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/internal/LegacySupportPlugin.java b/uimafit-core/src/main/java/org/apache/uima/fit/internal/LegacySupportPlugin.java
index 4e701e4..51cf6fc 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/internal/LegacySupportPlugin.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/internal/LegacySupportPlugin.java
@@ -36,7 +36,8 @@ public interface LegacySupportPlugin {
* the modern annotation type.
* @return {@code true} if a legacy version of the annotation is present.
*/
- boolean isAnnotationPresent(AccessibleObject aObject, Class<? extends Annotation> aAnnotationClass);
+ boolean isAnnotationPresent(AccessibleObject aObject,
+ Class<? extends Annotation> aAnnotationClass);
/**
* Checks if a legacy version of the given modern annotation is present.
@@ -84,22 +85,23 @@ public interface LegacySupportPlugin {
*/
<L extends Annotation, M extends Annotation> M getAnnotation(Class<?> aObject,
Class<M> aAnnotationClass);
-//
-// /**
-// * Get the default value of a property of the annotation. This is used for example to get the
-// * default name of a configuration parameter.
-// *
-// * @param aObject
-// * an object that has a legacy annotation.
-// * @param aAnnotationClass
-// * the modern annotation type.
-// * @param aProperty
-// * a property of the annotation, e.g. {@code "name"} (see
-// * {@link ConfigurationParameter#name()})
-// * @return
-// */
-// <M extends Annotation> Object getDefaultValue(AccessibleObject aObject, Class<M> aAnnotationClass,
-// String aProperty);
+ //
+ // /**
+ // * Get the default value of a property of the annotation. This is used for example to get the
+ // * default name of a configuration parameter.
+ // *
+ // * @param aObject
+ // * an object that has a legacy annotation.
+ // * @param aAnnotationClass
+ // * the modern annotation type.
+ // * @param aProperty
+ // * a property of the annotation, e.g. {@code "name"} (see
+ // * {@link ConfigurationParameter#name()})
+ // * @return
+ // */
+ // <M extends Annotation> Object getDefaultValue(AccessibleObject aObject, Class<M>
+ // aAnnotationClass,
+ // String aProperty);
/**
* Get all currently accessible descriptor locations for the given type.
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/internal/MetaDataType.java b/uimafit-core/src/main/java/org/apache/uima/fit/internal/MetaDataType.java
index aec2974..38101ea 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/internal/MetaDataType.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/internal/MetaDataType.java
@@ -22,7 +22,5 @@ package org.apache.uima.fit.internal;
* INTERNAL API - Kinds of meta data uimaFIT uses.
*/
public enum MetaDataType {
- TYPE_SYSTEM,
- FS_INDEX,
- TYPE_PRIORITIES;
+ TYPE_SYSTEM, FS_INDEX, TYPE_PRIORITIES;
}
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/internal/ReflectionUtil.java b/uimafit-core/src/main/java/org/apache/uima/fit/internal/ReflectionUtil.java
index 966ea8c..c38c2af 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/internal/ReflectionUtil.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/internal/ReflectionUtil.java
@@ -25,7 +25,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-
/**
* INTERNAL API - Utility methods to access Java annotations.
*/
@@ -89,7 +88,8 @@ public final class ReflectionUtil {
* @param aName
* the field name
* @return the fields for the class of the object
- * @throws NoSuchFieldException if there is no such field
+ * @throws NoSuchFieldException
+ * if there is no such field
*/
public static Field getField(final Class<?> aClass, final String aName)
throws NoSuchFieldException {
@@ -146,14 +146,13 @@ public final class ReflectionUtil {
if (aObject.getAnnotation(aAnnotationClass) != null) {
return true;
}
-
+
// If not present, check if an equivalent legacy annotation is present
return LegacySupport.getInstance().isAnnotationPresent(aObject, aAnnotationClass);
}
-
+
/**
- * Equivalent to {@link Class#isAnnotationPresent(Class)} but handles uimaFIT legacy
- * annotations.
+ * Equivalent to {@link Class#isAnnotationPresent(Class)} but handles uimaFIT legacy annotations.
*
* @param aObject
* the object to analyze
@@ -168,11 +167,11 @@ public final class ReflectionUtil {
if (aObject.getAnnotation(aAnnotationClass) != null) {
return true;
}
-
+
// If not present, check if an equivalent legacy annotation is present
return LegacySupport.getInstance().isAnnotationPresent(aObject, aAnnotationClass);
}
-
+
/**
* Equivalent to {@link AccessibleObject#getAnnotation(Class)} but handles uimaFIT legacy
* annotations.
@@ -186,8 +185,7 @@ public final class ReflectionUtil {
* @return the annotation
*/
public static <T extends Annotation> T getAnnotation(AccessibleObject aObject,
- Class<T> aAnnotationClass)
- {
+ Class<T> aAnnotationClass) {
T annotation = aObject.getAnnotation(aAnnotationClass);
if (annotation == null) {
annotation = LegacySupport.getInstance().getAnnotation(aObject, aAnnotationClass);
@@ -196,8 +194,7 @@ public final class ReflectionUtil {
}
/**
- * Equivalent to {@link Class#getAnnotation(Class)} but handles uimaFIT legacy
- * annotations.
+ * Equivalent to {@link Class#getAnnotation(Class)} but handles uimaFIT legacy annotations.
*
* @param <T>
* the annotation type
@@ -208,8 +205,7 @@ public final class ReflectionUtil {
* @return the annotation
*/
public static <T extends Annotation> T getAnnotation(Class<?> aObject,
- Class<T> aAnnotationClass)
- {
+ Class<T> aAnnotationClass) {
T annotation = aObject.getAnnotation(aAnnotationClass);
if (annotation == null) {
annotation = LegacySupport.getInstance().getAnnotation(aObject, aAnnotationClass);
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/internal/ResourceList.java b/uimafit-core/src/main/java/org/apache/uima/fit/internal/ResourceList.java
index cbe624c..fe47960 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/internal/ResourceList.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/internal/ResourceList.java
@@ -24,11 +24,11 @@ import org.apache.uima.fit.descriptor.ExternalResource;
/**
* INTERNAL API - Helper resource used when an {@link ExternalResource} annotation is used on an
- * array or collection field.
+ * array or collection field.
*/
public class ResourceList extends Resource_ImplBase {
public static final String ELEMENT_KEY = "ELEMENT";
-
+
public static final String PARAM_SIZE = "size";
@ConfigurationParameter(name = PARAM_SIZE, mandatory = true)
private int size;
@@ -36,7 +36,7 @@ public class ResourceList extends Resource_ImplBase {
public ResourceList() {
// Nothing to do
}
-
+
public int getSize() {
return size;
}
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/internal/ResourceManagerFactory.java b/uimafit-core/src/main/java/org/apache/uima/fit/internal/ResourceManagerFactory.java
index 7372b9d..d83475e 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/internal/ResourceManagerFactory.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/internal/ResourceManagerFactory.java
@@ -36,7 +36,7 @@ import org.slf4j.LoggerFactory;
*/
public class ResourceManagerFactory {
private static final Logger LOG = LoggerFactory.getLogger(ResourceManagerFactory.class);
-
+
private static ResourceManagerCreator resourceManagerCreator = new DefaultResourceManagerCreator();
private ResourceManagerFactory() {
@@ -99,12 +99,12 @@ public class ResourceManagerFactory {
short maj = UimaVersion.getMajorVersion();
short min = UimaVersion.getMinorVersion();
short rev = UimaVersion.getBuildRevision();
- boolean uimaCoreIgnoresContextClassloader =
- (maj == 2 && (min < 10 || (min == 10 && rev < 3))) || // version < 2.10.3
- (maj == 3 && ((min == 0 && rev < 1))); // version < 3.0.1
+ boolean uimaCoreIgnoresContextClassloader = (maj == 2 && (min < 10 || (min == 10 && rev < 3)))
+ || // version < 2.10.3
+ (maj == 3 && ((min == 0 && rev < 1))); // version < 3.0.1
if (uimaCoreIgnoresContextClassloader) {
- LOG.trace("Detected UIMA version " + maj + "." + min + "." + rev +
- " which ignores the thread context classloader, setting it explicitly");
+ LOG.trace("Detected UIMA version " + maj + "." + min + "." + rev
+ + " which ignores the thread context classloader, setting it explicitly");
resMgr.setExtensionClassLoader(ClassLoaderUtils.findClassloader(), true);
}
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/internal/propertyeditors/GetAsTextStringEditor.java b/uimafit-core/src/main/java/org/apache/uima/fit/internal/propertyeditors/GetAsTextStringEditor.java
index 256a45c..c250e5b 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/internal/propertyeditors/GetAsTextStringEditor.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/internal/propertyeditors/GetAsTextStringEditor.java
@@ -63,8 +63,8 @@ public class GetAsTextStringEditor extends PropertyEditorSupport {
} else if (Enum.class.isAssignableFrom(value.getClass())) {
super.setValue(String.valueOf(value));
} else {
- throw new IllegalArgumentException("Unable to convert " + value.getClass()
- + " to String. No PropertyEditor found.");
+ throw new IllegalArgumentException(
+ "Unable to convert " + value.getClass() + " to String. No PropertyEditor found.");
}
}
}
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/internal/propertyeditors/PropertyEditorUtil.java b/uimafit-core/src/main/java/org/apache/uima/fit/internal/propertyeditors/PropertyEditorUtil.java
index 88a07f5..5fc5837 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/internal/propertyeditors/PropertyEditorUtil.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/internal/propertyeditors/PropertyEditorUtil.java
@@ -38,7 +38,8 @@ public final class PropertyEditorUtil {
/**
* Register the property editors provided by uimaFIT in the given property editor registry.
*
- * @param aRegistry a property editor registry
+ * @param aRegistry
+ * a property editor registry
*/
public static void registerUimaFITEditors(PropertyEditorRegistry aRegistry) {
aRegistry.registerCustomEditor(Charset.class, new CharsetEditor());
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/pipeline/JCasIterable.java b/uimafit-core/src/main/java/org/apache/uima/fit/pipeline/JCasIterable.java
index a7f0001..c265aaa 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/pipeline/JCasIterable.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/pipeline/JCasIterable.java
@@ -42,14 +42,14 @@ import org.apache.uima.resource.ResourceManager;
public class JCasIterable implements Iterable<JCas> {
private final ResourceManager resMgr;
-
+
private final CollectionReaderDescription reader;
private final AnalysisEngineDescription[] engines;
/**
- * Iterate over the documents loaded by the collection reader, running the analysis engines on each
- * one before yielding them. When created with this constructor, analysis engines by default
+ * Iterate over the documents loaded by the collection reader, running the analysis engines on
+ * each one before yielding them. When created with this constructor, analysis engines by default
* receive a collectionProcessComplete call when all documents have been read from the reader and
* all components get destroyed.
*
@@ -64,8 +64,8 @@ public class JCasIterable implements Iterable<JCas> {
}
/**
- * Iterate over the documents loaded by the collection reader, running the analysis engines on each
- * one before yielding them. When created with this constructor, analysis engines by default
+ * Iterate over the documents loaded by the collection reader, running the analysis engines on
+ * each one before yielding them. When created with this constructor, analysis engines by default
* receive a collectionProcessComplete call when all documents have been read from the reader and
* all components get destroyed.
*
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/pipeline/JCasIterator.java b/uimafit-core/src/main/java/org/apache/uima/fit/pipeline/JCasIterator.java
index 52e76c4..e3bc410 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/pipeline/JCasIterator.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/pipeline/JCasIterator.java
@@ -61,18 +61,18 @@ public class JCasIterator implements Iterator<JCas> {
private final JCas jCas;
private final ResourceManager resMgr;
-
+
private boolean selfComplete = false;
private boolean selfDestroy = false;
-
+
private boolean destroyed = false;
-
+
private boolean resourceManagerCreatedInternally = false;
/**
- * Iterate over the documents loaded by the given reader, running the analysis engines on each
- * one before yielding them. By default, components <b>DO get</b> life-cycle events, such as
+ * Iterate over the documents loaded by the given reader, running the analysis engines on each one
+ * before yielding them. By default, components <b>DO get</b> life-cycle events, such as
* collectionProcessComplete or destroy when this constructor is used.
*
* @param aReader
@@ -89,10 +89,10 @@ public class JCasIterator implements Iterator<JCas> {
throws CASException, ResourceInitializationException {
this(null, aReader, aEngines);
}
-
+
/**
- * Iterate over the documents loaded by the given reader, running the analysis engines on each
- * one before yielding them. By default, components <b>DO get</b> life-cycle events, such as
+ * Iterate over the documents loaded by the given reader, running the analysis engines on each one
+ * before yielding them. By default, components <b>DO get</b> life-cycle events, such as
* collectionProcessComplete or destroy when this constructor is used.
*
* @param aResMgr
@@ -114,25 +114,24 @@ public class JCasIterator implements Iterator<JCas> {
throws CASException, ResourceInitializationException {
selfComplete = true;
selfDestroy = true;
-
+
if (aResMgr == null) {
resMgr = newResourceManager();
resourceManagerCreatedInternally = true;
- }
- else {
+ } else {
resMgr = aResMgr;
resourceManagerCreatedInternally = false;
}
-
+
collectionReader = produceCollectionReader(aReader, resMgr, null);
analysisEngines = new AnalysisEngine[] {
produceAnalysisEngine(createEngineDescription(aEngines), resMgr, null) };
-
+
jCas = createCas(resMgr, collectionReader, analysisEngines);
collectionReader.typeSystemInit(jCas.getTypeSystem());
}
-
+
/**
* Iterate over the documents loaded by the CollectionReader, running the AnalysisEngine on each
* one before yielding them. By default, components <b>do NOT get</b> life-cycle events, such as
@@ -168,11 +167,11 @@ public class JCasIterator implements Iterator<JCas> {
* if the JCas could not be initialized
*/
public JCasIterator(final CollectionReader aReader,
- final TypeSystemDescription aTypeSystemDescription) throws CASException,
- ResourceInitializationException {
+ final TypeSystemDescription aTypeSystemDescription)
+ throws CASException, ResourceInitializationException {
this(aReader, createEngine(NoOpAnnotator.class, aTypeSystemDescription));
}
-
+
/**
* Iterate over the documents loaded by the CollectionReader, running the AnalysisEngine on each
* one before yielding them. By default, components <b>do NOT get</b> life-cycle events, such as
@@ -198,12 +197,11 @@ public class JCasIterator implements Iterator<JCas> {
if (aResMgr == null) {
resMgr = newResourceManager();
resourceManagerCreatedInternally = true;
- }
- else {
+ } else {
resMgr = aResMgr;
resourceManagerCreatedInternally = false;
}
-
+
collectionReader = aReader;
analysisEngines = aEngines;
@@ -212,8 +210,7 @@ public class JCasIterator implements Iterator<JCas> {
}
private JCas createCas(final ResourceManager aResMgr, final CollectionReader aReader,
- final AnalysisEngine... aEngines) throws CASException, ResourceInitializationException
- {
+ final AnalysisEngine... aEngines) throws CASException, ResourceInitializationException {
Collection<MetaDataObject> metaData = new ArrayList<MetaDataObject>();
metaData.add(aReader.getProcessingResourceMetaData());
for (AnalysisEngine ae : aEngines) {
@@ -222,13 +219,13 @@ public class JCasIterator implements Iterator<JCas> {
return CasCreationUtils.createCas(metaData, null, aResMgr).getJCas();
}
-
+
@Override
public boolean hasNext() {
if (destroyed) {
return false;
}
-
+
boolean error = true;
try {
boolean hasOneMore = collectionReader.hasNext();
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/pipeline/SimplePipeline.java b/uimafit-core/src/main/java/org/apache/uima/fit/pipeline/SimplePipeline.java
index 6591428..5c818db 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/pipeline/SimplePipeline.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/pipeline/SimplePipeline.java
@@ -22,6 +22,7 @@ import static java.util.Arrays.asList;
import static org.apache.uima.fit.factory.AnalysisEngineFactory.createEngine;
import static org.apache.uima.fit.factory.AnalysisEngineFactory.createEngineDescription;
import static org.apache.uima.fit.util.LifeCycleUtil.collectionProcessComplete;
+
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@@ -79,11 +80,11 @@ public final class SimplePipeline {
* and call the other runPipeline method.
* @throws IOException
* if there is an I/O problem in the reader
- * @throws ResourceInitializationException
+ * @throws ResourceInitializationException
* if there is a problem initializing or running the pipeline.
- * @throws CollectionException
+ * @throws CollectionException
* if there is a problem initializing or running the pipeline.
- * @throws AnalysisEngineProcessException
+ * @throws AnalysisEngineProcessException
* if there is a problem initializing or running the pipeline.
*/
public static void runPipeline(final CollectionReader reader,
@@ -93,12 +94,12 @@ public final class SimplePipeline {
try {
// Create AAE
final AnalysisEngineDescription aaeDesc = createEngineDescription(descs);
-
+
// Instantiate AAE
aae = createEngine(aaeDesc);
-
+
// Create CAS from merged metadata
- final CAS cas = CasCreationUtils.createCas(asList(reader.getMetaData(), aae.getMetaData()),
+ final CAS cas = CasCreationUtils.createCas(asList(reader.getMetaData(), aae.getMetaData()),
null, reader.getResourceManager());
reader.typeSystemInit(cas.getTypeSystem());
@@ -128,21 +129,25 @@ public final class SimplePipeline {
* External resources can be shared between the reader and the analysis engines.
* </p>
* <p>
- * This method is suitable for the batch-processing of sets of documents where the overheaded
- * of instantiating the pipeline components does not significantly impact the overall runtime
- * of the pipeline. If you need to avoid this overhead, e.g. because you wish to run a pipeline
- * on individual documents, then you should not use this method. Instead, create a CAS using
- * {@link JCasFactory}, create a reader instance using {@link CollectionReaderFactory#createReader},
- * create an engine instance using {@link AnalysisEngineFactory#createEngine} and then use
- * a loop to process the data, resetting the CAS after each step.
+ * This method is suitable for the batch-processing of sets of documents where the overheaded of
+ * instantiating the pipeline components does not significantly impact the overall runtime of the
+ * pipeline. If you need to avoid this overhead, e.g. because you wish to run a pipeline on
+ * individual documents, then you should not use this method. Instead, create a CAS using
+ * {@link JCasFactory}, create a reader instance using
+ * {@link CollectionReaderFactory#createReader}, create an engine instance using
+ * {@link AnalysisEngineFactory#createEngine} and then use a loop to process the data, resetting
+ * the CAS after each step.
* </p>
- * <pre><code>
+ *
+ * <pre>
+ * <code>
* while (reader.hasNext()) {
* reader.getNext(cas);
* engine.process(cas);
* cas.reset();
* }
- * </code></pre>
+ * </code>
+ * </pre>
*
* @param readerDesc
* The CollectionReader that loads the documents into the CAS.
@@ -152,11 +157,11 @@ public final class SimplePipeline {
* and call the other runPipeline method.
* @throws IOException
* if there is an I/O problem in the reader
- * @throws ResourceInitializationException
+ * @throws ResourceInitializationException
* if there is a problem initializing or running the pipeline.
- * @throws CollectionException
+ * @throws CollectionException
* if there is a problem initializing or running the pipeline.
- * @throws AnalysisEngineProcessException
+ * @throws AnalysisEngineProcessException
* if there is a problem initializing or running the pipeline.
*/
public static void runPipeline(final CollectionReaderDescription readerDesc,
@@ -167,16 +172,16 @@ public final class SimplePipeline {
ResourceManager resMgr = null;
try {
resMgr = ResourceManagerFactory.newResourceManager();
-
+
// Create the components
reader = UIMAFramework.produceCollectionReader(readerDesc, resMgr, null);
-
+
// Create AAE
final AnalysisEngineDescription aaeDesc = createEngineDescription(descs);
-
+
// Instantiate AAE
aae = UIMAFramework.produceAnalysisEngine(aaeDesc, resMgr, null);
-
+
// Create CAS from merged metadata
final CAS cas = CasCreationUtils.createCas(asList(reader.getMetaData(), aae.getMetaData()),
null, resMgr);
@@ -222,11 +227,11 @@ public final class SimplePipeline {
* a sequence of analysis engines
* @throws IOException
* if there is an I/O problem in the reader
- * @throws CollectionException
+ * @throws CollectionException
* if there is a problem initializing or running the pipeline.
- * @throws ResourceInitializationException
+ * @throws ResourceInitializationException
* if there is a problem initializing or running the pipeline.
- * @throws AnalysisEngineProcessException
+ * @throws AnalysisEngineProcessException
* if there is a problem initializing or running the pipeline.
*/
public static void runPipeline(final CollectionReader reader, final AnalysisEngine... engines)
@@ -234,7 +239,7 @@ public final class SimplePipeline {
CollectionException {
runPipeline(reader.getResourceManager(), reader, engines);
}
-
+
/**
* <p>
* Provides a simple way to run a pipeline for a given collection reader and sequence of analysis
@@ -258,11 +263,11 @@ public final class SimplePipeline {
* a sequence of analysis engines
* @throws IOException
* if there is an I/O problem in the reader
- * @throws ResourceInitializationException
+ * @throws ResourceInitializationException
* if there is a problem initializing or running the pipeline.
- * @throws CollectionException
+ * @throws CollectionException
* if there is a problem initializing or running the pipeline.
- * @throws AnalysisEngineProcessException
+ * @throws AnalysisEngineProcessException
* if there is a problem initializing or running the pipeline.
*/
public static void runPipeline(final ResourceManager aResMgr, final CollectionReader reader,
@@ -310,10 +315,10 @@ public final class SimplePipeline {
try {
// Create aggregate AE
final AnalysisEngineDescription aaeDesc = createEngineDescription(aDescs);
-
+
// Instantiate
aae = createEngine(aaeDesc);
-
+
// Process
aae.process(aCas);
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/pipeline/package-info.java b/uimafit-core/src/main/java/org/apache/uima/fit/pipeline/package-info.java
index 4c520e4..fe4ffb1 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/pipeline/package-info.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/pipeline/package-info.java
@@ -20,4 +20,3 @@
* Executing UIMA pipelines.
*/
package org.apache.uima.fit.pipeline;
-
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/testing/factory/TokenBuilder.java b/uimafit-core/src/main/java/org/apache/uima/fit/testing/factory/TokenBuilder.java
index 9f83fcc..9bbba84 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/testing/factory/TokenBuilder.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/testing/factory/TokenBuilder.java
@@ -77,8 +77,9 @@ public class TokenBuilder<TOKEN_TYPE extends Annotation, SENTENCE_TYPE extends A
* the feature name for the stem for your token type. This assumes that there is a single
* string feature for which to put your stem. null is an ok value.
*/
- public TokenBuilder(final Class<TOKEN_TYPE> aTokenClass, final Class<SENTENCE_TYPE> aSentenceClass,
- String aPosFeatureName, String aStemFeatureName) {
+ public TokenBuilder(final Class<TOKEN_TYPE> aTokenClass,
+ final Class<SENTENCE_TYPE> aSentenceClass, String aPosFeatureName,
+ String aStemFeatureName) {
tokenClass = aTokenClass;
sentenceClass = aSentenceClass;
setPosFeatureName(aPosFeatureName);
@@ -92,7 +93,8 @@ public class TokenBuilder<TOKEN_TYPE extends Annotation, SENTENCE_TYPE extends A
* @param <T>
* the type system token type (e.g. org.apache.uima.fit.examples.type.Token)
* @param <S>
- * the type system sentence type (e.g. {@code org.apache.uima.fit.examples.type.Sentence})
+ * the type system sentence type (e.g.
+ * {@code org.apache.uima.fit.examples.type.Sentence})
* @param aTokenClass
* the class of your token type from your type system (e.g.
* {@code org.apache.uima.fit.type.Token})
@@ -247,8 +249,8 @@ public class TokenBuilder<TOKEN_TYPE extends Annotation, SENTENCE_TYPE extends A
while (!aText.startsWith(tokenString, offset)) {
offset++;
if (offset > aText.length()) {
- throw new IllegalArgumentException(String.format("unable to find string %s",
- tokenString));
+ throw new IllegalArgumentException(
+ String.format("unable to find string %s", tokenString));
}
}
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/util/CasIOUtil.java b/uimafit-core/src/main/java/org/apache/uima/fit/util/CasIOUtil.java
index 40299a4..e14475b 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/util/CasIOUtil.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/util/CasIOUtil.java
@@ -198,7 +198,7 @@ public class CasIOUtil {
public static void readJCas(JCas aJCas, File aFile) throws IOException {
CasIOUtil.readCas(aJCas.getCas(), aFile);
}
-
+
/**
*
* @param aJCas
@@ -213,7 +213,7 @@ public class CasIOUtil {
public static void readXmi(JCas aJCas, File aFile) throws IOException {
CasIOUtil.readXmi(aJCas.getCas(), aFile);
}
-
+
/**
*
* @param aJCas
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/util/CasUtil.java b/uimafit-core/src/main/java/org/apache/uima/fit/util/CasUtil.java
index 4194b11..696636b 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/util/CasUtil.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/util/CasUtil.java
@@ -61,7 +61,7 @@ public final class CasUtil {
private CasUtil() {
// No instances
}
-
+
/**
* Get an iterator over the given feature structures type.
*
@@ -124,11 +124,9 @@ public final class CasUtil {
String typeName = aTypename;
if (typeName.startsWith(UIMA_BUILTIN_JCAS_PREFIX)) {
typeName = "uima." + typeName.substring(UIMA_BUILTIN_JCAS_PREFIX.length());
- }
- else if (FeatureStructure.class.getName().equals(aTypename)) {
+ } else if (FeatureStructure.class.getName().equals(aTypename)) {
typeName = CAS.TYPE_NAME_TOP;
- }
- else if (AnnotationFS.class.getName().equals(aTypename)) {
+ } else if (AnnotationFS.class.getName().equals(aTypename)) {
typeName = CAS.TYPE_NAME_ANNOTATION;
}
final Type type = aCas.getTypeSystem().getType(typeName);
@@ -138,8 +136,8 @@ public final class CasUtil {
while (i.hasNext()) {
sb.append(i.next().getName()).append('\n');
}
- throw new IllegalArgumentException("Undeclared type [" + aTypename + "]. Available types: "
- + sb);
+ throw new IllegalArgumentException(
+ "Undeclared type [" + aTypename + "]. Available types: " + sb);
}
return type;
}
@@ -262,7 +260,7 @@ public final class CasUtil {
requireAnnotationType(cas, type);
return cas.getAnnotationIndex(type).select().asList();
}
-
+
/**
* Get all annotations of the given type at the specified offsets.
*
@@ -276,9 +274,10 @@ public final class CasUtil {
* the end offset.
* @return the annotations at the specified offsets.
*/
- public static List<AnnotationFS> selectAt(final CAS aCas, final Type aType, int aBegin, int aEnd) {
+ public static List<AnnotationFS> selectAt(final CAS aCas, final Type aType, int aBegin,
+ int aEnd) {
List<AnnotationFS> list = new ArrayList<AnnotationFS>();
-
+
// withSnapshotIterators() not needed here since we copy the FSes to a list anyway
FSIterator<AnnotationFS> it = aCas.getAnnotationIndex(aType).iterator();
@@ -291,7 +290,7 @@ public final class CasUtil {
while (it.isValid() && (it.get()).getEnd() > aEnd) {
it.moveToNext();
}
-
+
while (it.isValid()) {
AnnotationFS a = it.get();
// If the offsets do not match the specified offets, we're done
@@ -301,7 +300,7 @@ public final class CasUtil {
it.moveToNext();
list.add(a);
}
-
+
return list;
}
@@ -318,22 +317,23 @@ public final class CasUtil {
* the end offset.
* @return the single annotation at the specified offsets.
*/
- public static AnnotationFS selectSingleAt(final CAS aCas, final Type aType, int aBegin, int aEnd) {
+ public static AnnotationFS selectSingleAt(final CAS aCas, final Type aType, int aBegin,
+ int aEnd) {
List<AnnotationFS> list = selectAt(aCas, aType, aBegin, aEnd);
if (list.isEmpty()) {
throw new IllegalArgumentException("CAS does not contain any [" + aType.getName() + "] at ["
+ aBegin + "," + aEnd + "]");
}
-
+
if (list.size() > 1) {
- throw new IllegalArgumentException("CAS contains more than one [" + aType.getName()
- + "] at [" + aBegin + "," + aEnd + "]");
+ throw new IllegalArgumentException("CAS contains more than one [" + aType.getName() + "] at ["
+ + aBegin + "," + aEnd + "]");
}
return list.get(0);
}
-
+
/**
* Get a list of annotations of the given annotation type located between two annotations. Does
* not use subiterators and does not respect type priorities. Zero-width annotations what lie on
@@ -393,7 +393,7 @@ public final class CasUtil {
int end = right.getBegin();
List<AnnotationFS> list = new ArrayList<AnnotationFS>();
-
+
// withSnapshotIterators() not needed here since we copy the FSes to a list anyway
FSIterator<AnnotationFS> it = cas.getAnnotationIndex(type).iterator();
@@ -461,14 +461,14 @@ public final class CasUtil {
* Get a list of annotations of the given annotation type constraint by a certain annotation.
* Iterates over all annotations of the given type to find the covered annotations. Does not use
* subiterators and does not respect type prioritites. Was adapted from {@link Subiterator}. Uses
- * the same approach except that type priorities are ignored.
+ * the same approach except that type priorities are ignored.
* <p>
* The covering annotation is never returned itself, even if it is of the queried-for type or a
* subtype of that type.
* <p>
* The method only returns properly covered annotations, that is annotations where the begin/end
- * offsets are equal to the 'covering' annotation or where both the begin/end are included in
- * the span of the 'covering' annotation. Partially overlapping annotations are not returned.
+ * offsets are equal to the 'covering' annotation or where both the begin/end are included in the
+ * span of the 'covering' annotation. Partially overlapping annotations are not returned.
*
* @param type
* a UIMA type.
@@ -492,8 +492,8 @@ public final class CasUtil {
* subtype of that type.
* <p>
* The method only returns properly covered annotations, that is annotations where the begin/end
- * offsets are equal to the 'covering' annotation or where both the begin/end are included in
- * the span of the 'covering' annotation. Partially overlapping annotations are not returned.
+ * offsets are equal to the 'covering' annotation or where both the begin/end are included in the
+ * span of the 'covering' annotation. Partially overlapping annotations are not returned.
*
* @param cas
* a CAS.
@@ -505,12 +505,13 @@ public final class CasUtil {
* @see Subiterator
* @see <a href="package-summary.html#SortOrder">Order of selected feature structures</a>
*/
- public static List<AnnotationFS> selectCovered(CAS cas, Type type, AnnotationFS coveringAnnotation) {
+ public static List<AnnotationFS> selectCovered(CAS cas, Type type,
+ AnnotationFS coveringAnnotation) {
int begin = coveringAnnotation.getBegin();
int end = coveringAnnotation.getEnd();
List<AnnotationFS> list = new ArrayList<AnnotationFS>();
-
+
// withSnapshotIterators() not needed here since we copy the FSes to a list anyway
FSIterator<AnnotationFS> it = cas.getAnnotationIndex(type).iterator();
@@ -582,12 +583,13 @@ public final class CasUtil {
* <p>
* <b>Note:</b> this is significantly slower than using
* {@link #selectCovered(CAS, Type, AnnotationFS)}. It is possible to use
- * {@code selectCovered(cas, type, new Annotation(jCas, int, int))}, but that will allocate memory
- * in the jCas for the new annotation. If you do that repeatedly many times, memory may fill up.
+ * {@code selectCovered(cas, type, new Annotation(jCas, int, int))}, but that will allocate
+ * memory in the jCas for the new annotation. If you do that repeatedly many times, memory may
+ * fill up.
* <p>
* The method only returns properly covered annotations, that is annotations where the begin/end
- * offsets are equal to the given begin/end or where both the begin/end are included in
- * the span of the given span. Partially overlapping annotations are not returned.
+ * offsets are equal to the given begin/end or where both the begin/end are included in the span
+ * of the given span. Partially overlapping annotations are not returned.
*
* @param cas
* a CAS.
@@ -604,8 +606,8 @@ public final class CasUtil {
public static List<AnnotationFS> selectCovered(CAS cas, Type type, int begin, int end) {
List<AnnotationFS> list = new ArrayList<AnnotationFS>();
-
- // withSnapshotIterators() not needed here since we copy the FSes to a list anyway
+
+ // withSnapshotIterators() not needed here since we copy the FSes to a list anyway
FSIterator<AnnotationFS> it = cas.getAnnotationIndex(type).iterator();
// Skip annotations whose start is before the start parameter.
@@ -648,6 +650,7 @@ public final class CasUtil {
* <p>
* <b>Note:</b> this is <b>REALLY SLOW!</b> You don't want to use this. Instead, consider using
* {@link #indexCovering(CAS, Type, Type)} or a {@link ContainmentIndex}.
+ *
* @param type
* a UIMA type.
* @param coveredAnnotation
@@ -684,11 +687,12 @@ public final class CasUtil {
* @return a return value.
* @see <a href="package-summary.html#SortOrder">Order of selected feature structures</a>
*/
- public static List<AnnotationFS> selectCovering(CAS cas, Type type, AnnotationFS coveredAnnotation) {
+ public static List<AnnotationFS> selectCovering(CAS cas, Type type,
+ AnnotationFS coveredAnnotation) {
return selectCovering(cas, type, coveredAnnotation.getBegin(), coveredAnnotation.getEnd());
}
-
+
/**
* Get a list of annotations of the given annotation type constraint by a certain annotation.
* Iterates over all annotations to find the covering annotations.
@@ -715,11 +719,11 @@ public final class CasUtil {
public static List<AnnotationFS> selectCovering(CAS cas, Type type, int begin, int end) {
List<AnnotationFS> list = new ArrayList<AnnotationFS>();
-
- // withSnapshotIterators() not needed here since we copy the FSes to a list anyway
+
+ // withSnapshotIterators() not needed here since we copy the FSes to a list anyway
FSIterator<AnnotationFS> iter = type == null ? cas.getAnnotationIndex().iterator()
: cas.getAnnotationIndex(type).iterator();
-
+
while (iter.hasNext()) {
AnnotationFS a = iter.next();
if ((a.getBegin() <= begin) && (a.getEnd() >= end)) {
@@ -739,8 +743,8 @@ public final class CasUtil {
* is properly contained within the span of the 'covering' annotation. Partially overlapping
* annotations are not returned.
* <p>
- * When querying for the annotations covering a given annotation, the given annotation itself
- * is never returned, even if it is of the queried type.
+ * When querying for the annotations covering a given annotation, the given annotation itself is
+ * never returned, even if it is of the queried type.
*
* @param cas
* a CAS.
@@ -783,15 +787,16 @@ public final class CasUtil {
* Create an index for quickly lookup up the annotations covered by a particular annotation. This
* is preferable to using {@link #selectCovered(CAS, Type, int, int)} because the overhead of
* scanning the CAS occurs only when the index is build. Subsequent lookups to the index are fast.
- * The order of entries in the map is not defined. However, lists of covered annotations in
- * the map are guaranteed to be in the same order as in the UIMA default annotation index.
+ * The order of entries in the map is not defined. However, lists of covered annotations in the
+ * map are guaranteed to be in the same order as in the UIMA default annotation index.
* <p>
* The method only returns properly covered annotations, that is annotations where the begin/end
- * offsets are equal to the 'covering' annotation or where both the begin/end are included in
- * the span of the 'covering' annotation. Partially overlapping annotations are not returned.
+ * offsets are equal to the 'covering' annotation or where both the begin/end are included in the
+ * span of the 'covering' annotation. Partially overlapping annotations are not returned.
* <p>
- * When querying for the annotations covered by a given annotation, the given annotation itself
- * is never returned, even if it is of the queried type. *
+ * When querying for the annotations covered by a given annotation, the given annotation itself is
+ * never returned, even if it is of the queried type. *
+ *
* @param cas
* a CAS.
* @param type
@@ -816,24 +821,24 @@ public final class CasUtil {
}
}
};
-
+
// Get the covering and covered annotations
Collection<AnnotationFS> collType = select(cas, type);
Collection<AnnotationFS> collCoveredType = select(cas, coveredType);
-
+
// Convert them into array for faster access
AnnotationFS[] typeArray = collType.toArray(new AnnotationFS[collType.size()]);
AnnotationFS[] coveredTypeArray = collCoveredType
.toArray(new AnnotationFS[collCoveredType.size()]);
-
+
// Keeps currently "open" annotations in a sorted order
Deque<AnnotationFS> memory = new ArrayDeque<>();
- //Deque<AnnotationFS> memory2 = new ArrayDeque<>();
-
+ // Deque<AnnotationFS> memory2 = new ArrayDeque<>();
+
// Array cursors
int o = 0;
int i = 0;
-
+
while ((o < typeArray.length || !memory.isEmpty()) && i < coveredTypeArray.length) {
// Always make sure the memory contains at least one covering annotation to compare against
if (memory.isEmpty()) {
@@ -841,15 +846,15 @@ public final class CasUtil {
o++;
}
AnnotationFS bottom = memory.peek();
-
+
// Fast-forward over annotations which cannot be covered by the bottom element because they
// start earlier.
AnnotationFS iFS = coveredTypeArray[i];
- while (i < coveredTypeArray.length-1 && iFS.getBegin() < bottom.getBegin()) {
+ while (i < coveredTypeArray.length - 1 && iFS.getBegin() < bottom.getBegin()) {
i++;
iFS = coveredTypeArray[i];
}
-
+
// Cache begin/end of current covered annotation for faster access
int iFSbegin = iFS.getBegin();
int iFSend = iFS.getEnd();
@@ -863,7 +868,7 @@ public final class CasUtil {
memory.push(typeArray[o]);
o++;
}
-
+
// Record covered annotations
for (AnnotationFS covering : memory) {
if (covering.getBegin() <= iFSbegin && iFS.getEnd() <= covering.getEnd()) {
@@ -877,13 +882,12 @@ public final class CasUtil {
}
}
}
-
+
i++;
- }
- else {
+ } else {
i++;
}
-
+
// Purge covering annotations from memory that cannot match anymore given the currently
// exampled covered annotation
// Alternative implementation: re-uses memory
@@ -900,41 +904,40 @@ public final class CasUtil {
}
/**
- * Get a list of annotations of the given annotation type overlapping the given annotation. Does
+ * Get a list of annotations of the given annotation type overlapping the given annotation. Does
* not use subiterators and does not respect type prioritites.
*
* @param aType
* a UIMA type.
- * @param aBoundaryAnnotation
+ * @param aBoundaryAnnotation
* the covering annotation.
* @return a list of overlapping annotations.
* @see <a href="package-summary.html#SortOrder">Order of selected feature structures</a>
- */
- public static List<AnnotationFS> selectOverlapping(Type aType,
- AnnotationFS aBoundaryAnnotation) {
+ */
+ public static List<AnnotationFS> selectOverlapping(Type aType, AnnotationFS aBoundaryAnnotation) {
return selectOverlapping(aBoundaryAnnotation.getCAS(), aType, aBoundaryAnnotation.getBegin(),
aBoundaryAnnotation.getEnd());
- }
-
+ }
+
/**
- * Get a list of annotations of the given annotation type overlapping the given annotation. Does
+ * Get a list of annotations of the given annotation type overlapping the given annotation. Does
* not use subiterators and does not respect type prioritites.
*
* @param aCas
* a CAS.
* @param aType
* a UIMA type.
- * @param aBoundaryAnnotation
+ * @param aBoundaryAnnotation
* the covering annotation.
* @return a list of overlapping annotations.
* @see <a href="package-summary.html#SortOrder">Order of selected feature structures</a>
- */
+ */
public static List<AnnotationFS> selectOverlapping(CAS aCas, Type aType,
AnnotationFS aBoundaryAnnotation) {
return selectOverlapping(aCas, aType, aBoundaryAnnotation.getBegin(),
aBoundaryAnnotation.getEnd());
- }
-
+ }
+
/**
* Get a list of annotations of the given annotation type overlapping the given span. Does not use
* subiterators and does not respect type prioritites.
@@ -949,11 +952,11 @@ public final class CasUtil {
* end offset.
* @return a list of overlapping annotations.
* @see <a href="package-summary.html#SortOrder">Order of selected feature structures</a>
- */
+ */
public static List<AnnotationFS> selectOverlapping(CAS aCas, Type aType, int aSelBegin,
int aSelEnd) {
requireAnnotationType(aCas, aType);
-
+
List<AnnotationFS> annotations = new ArrayList<>();
for (AnnotationFS t : aCas.getAnnotationIndex(aType)) {
int begin = t.getBegin();
@@ -963,18 +966,18 @@ public final class CasUtil {
if (aSelBegin != begin && begin >= aSelEnd) {
break;
}
-
+
// not yet there
if (aSelBegin != begin && end <= aSelBegin) {
continue;
}
-
+
annotations.add(t);
}
return annotations;
}
-
+
/**
* This method exists simply as a convenience method for unit testing. It is not very efficient
* and should not, in general be used outside the context of unit testing.
@@ -992,7 +995,7 @@ public final class CasUtil {
public static AnnotationFS selectByIndex(CAS cas, Type type, int index) {
requireAnnotationType(cas, type);
- // withSnapshotIterators() not needed here since we return only one result
+ // withSnapshotIterators() not needed here since we return only one result
FSIterator<AnnotationFS> i = cas.getAnnotationIndex(type).iterator();
int n = index;
i.moveToFirst();
@@ -1038,7 +1041,7 @@ public final class CasUtil {
return result;
}
-
+
/**
* Get the single instance of the specified type from the CAS.
*
@@ -1145,11 +1148,11 @@ public final class CasUtil {
// The moveTo operation also does not yield an iterator being invalid because it points
// *before the first* index entry, at max it points *to the first* index entry, so this
// case also does not need to be handled.
-
+
// No need to do additional seeks here (as done in selectCovered) because the current method
// does not have to worry about type priorities - it never returns annotations that have
// the same offset as the reference annotation.
-
+
// make sure we're past the end of the reference annotation
while (itr.isValid() && itr.get().getBegin() < aAnchor.getEnd()) {
itr.moveToNext();
@@ -1166,11 +1169,10 @@ public final class CasUtil {
}
} else if (cas.getTypeSystem().subsumes(aAnchor.getType(), type)) {
return aAnchor;
- }
- else {
+ } else {
throw new IllegalArgumentException(
"Relative position cannot be 0 if the type of the anchor annotator does not subsume "
- + "the selected type.");
+ + "the selected type.");
}
}
@@ -1195,10 +1197,10 @@ public final class CasUtil {
List<AnnotationFS> precedingAnnotations = new ArrayList<AnnotationFS>();
// Seek annotation in index
- // withSnapshotIterators() not needed here since we copy the FSes to a list anyway
+ // withSnapshotIterators() not needed here since we copy the FSes to a list anyway
FSIterator<AnnotationFS> itr = cas.getAnnotationIndex(type).iterator();
itr.moveTo(anchor);
-
+
// If the insertion point is beyond the index, move back to the last.
if (!itr.isValid()) {
itr.moveToLast();
@@ -1206,7 +1208,7 @@ public final class CasUtil {
return precedingAnnotations;
}
}
-
+
int anchorBegin = anchor.getBegin();
// Zero-width annotations are in the index *after* the wider annotations starting at the same
@@ -1220,7 +1222,7 @@ public final class CasUtil {
break;
}
}
-
+
// make sure we're past the beginning of the reference annotation
while (itr.isValid() && itr.get().getEnd() > anchorBegin) {
itr.moveToPrevious();
@@ -1232,11 +1234,8 @@ public final class CasUtil {
int curEnd = cur.getEnd();
- if (
- (curEnd <= anchorBegin
- || (cur.getBegin() == curEnd && curEnd == anchorBegin))
- && cur != anchor
- ) {
+ if ((curEnd <= anchorBegin || (cur.getBegin() == curEnd && curEnd == anchorBegin))
+ && cur != anchor) {
precedingAnnotations.add(cur);
i++;
}
@@ -1266,10 +1265,10 @@ public final class CasUtil {
requireAnnotationType(cas, type);
// Seek annotation in index
- // withSnapshotIterators() not needed here since we copy the FSes to a list anyway
+ // withSnapshotIterators() not needed here since we copy the FSes to a list anyway
FSIterator<AnnotationFS> itr = cas.getAnnotationIndex(type).iterator();
itr.moveTo(anchor);
-
+
int anchorBegin = anchor.getBegin();
int anchorEnd = anchor.getEnd();
@@ -1292,19 +1291,17 @@ public final class CasUtil {
while (itr.isValid() && itr.getNvc().getBegin() == anchorBegin) {
itr.moveToPrevious();
}
-
+
if (!itr.isValid()) {
itr.moveToFirst();
- }
- else {
+ } else {
itr.moveToNext();
}
- }
- else {
+ } else {
itr.moveToFirst();
}
}
-
+
// make sure we're past the end of the reference annotation
while (itr.isValid() && itr.get().getBegin() < anchorEnd) {
itr.moveToNext();
@@ -1316,10 +1313,10 @@ public final class CasUtil {
AnnotationFS cur = itr.get();
if (cur != anchor && cur.getBegin() >= anchorEnd) {
followingAnnotations.add(cur);
- i ++;
+ i++;
}
}
-
+
return followingAnnotations;
}
@@ -1337,7 +1334,7 @@ public final class CasUtil {
public static <T extends TOP> boolean exists(CAS aCas, Type aType) {
return CasUtil.iterator(aCas, aType).hasNext();
}
-
+
/**
* Convenience method to get the specified view or a default view if the requested view does not
* exist. The default can also be {@code null}.
@@ -1422,8 +1419,7 @@ public final class CasUtil {
return text;
}
- public static boolean isAnnotationType(CAS aCas, Type aType)
- {
+ public static boolean isAnnotationType(CAS aCas, Type aType) {
return aCas.getTypeSystem().subsumes(aCas.getAnnotationType(), aType);
}
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/util/FSCollectionFactory.java b/uimafit-core/src/main/java/org/apache/uima/fit/util/FSCollectionFactory.java
index 40e39a6..b2e9a12 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/util/FSCollectionFactory.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/util/FSCollectionFactory.java
@@ -123,7 +123,7 @@ public abstract class FSCollectionFactory {
*
* @param <T>
* the feature structure type
- * @param aIndex
+ * @param aIndex
* the index to convert.
* @return the wrapped index.
* @see <a href="package-summary.html#SortOrder">Order of selected feature structures</a>
@@ -611,18 +611,18 @@ public abstract class FSCollectionFactory {
public static <T extends TOP> FSList<T> createFSList(CAS aCas, T... aValues) {
return createFSList(aCas, asList(aValues));
}
-
+
public static <T extends TOP> FSList<T> createFSList(CAS aCas, Collection<T> aValues) {
if (aValues == null) {
return null;
}
-
+
TypeSystem ts = aCas.getTypeSystem();
if (aValues.size() == 0) {
return aCas.emptyFSList();
}
-
+
Type nonEmptyType = ts.getType(CAS.TYPE_NAME_NON_EMPTY_FS_LIST);
Feature headFeature = nonEmptyType.getFeatureByBaseName(CAS.FEATURE_BASE_NAME_HEAD);
Feature tailFeature = nonEmptyType.getFeatureByBaseName(CAS.FEATURE_BASE_NAME_TAIL);
@@ -644,7 +644,6 @@ public abstract class FSCollectionFactory {
return (FSList<T>) list;
}
-
public static FloatList createFloatList(JCas aJCas, float... aValues) {
return createFloatList(aJCas.getCas(), aValues);
}
@@ -653,7 +652,7 @@ public abstract class FSCollectionFactory {
if (aValues == null) {
return null;
}
-
+
TypeSystem ts = aCas.getTypeSystem();
Type emptyType = ts.getType(CAS.TYPE_NAME_EMPTY_FLOAT_LIST);
@@ -661,7 +660,7 @@ public abstract class FSCollectionFactory {
if (aValues.length == 0) {
return aCas.createFS(emptyType);
}
-
+
Type nonEmptyType = ts.getType(CAS.TYPE_NAME_NON_EMPTY_FLOAT_LIST);
Feature headFeature = nonEmptyType.getFeatureByBaseName(CAS.FEATURE_BASE_NAME_HEAD);
Feature tailFeature = nonEmptyType.getFeatureByBaseName(CAS.FEATURE_BASE_NAME_TAIL);
@@ -684,11 +683,12 @@ public abstract class FSCollectionFactory {
return (T) list;
}
- public static <T extends FeatureStructure> T createFloatList(CAS aCas, Collection<Float> aValues) {
+ public static <T extends FeatureStructure> T createFloatList(CAS aCas,
+ Collection<Float> aValues) {
if (aValues == null) {
return null;
}
-
+
TypeSystem ts = aCas.getTypeSystem();
Type emptyType = ts.getType(CAS.TYPE_NAME_EMPTY_FLOAT_LIST);
@@ -696,7 +696,7 @@ public abstract class FSCollectionFactory {
if (aValues.size() == 0) {
return aCas.createFS(emptyType);
}
-
+
Type nonEmptyType = ts.getType(CAS.TYPE_NAME_NON_EMPTY_FLOAT_LIST);
Feature headFeature = nonEmptyType.getFeatureByBaseName(CAS.FEATURE_BASE_NAME_HEAD);
Feature tailFeature = nonEmptyType.getFeatureByBaseName(CAS.FEATURE_BASE_NAME_TAIL);
@@ -730,7 +730,7 @@ public abstract class FSCollectionFactory {
if (aValues == null) {
return null;
}
-
+
TypeSystem ts = aCas.getTypeSystem();
Type emptyType = ts.getType(CAS.TYPE_NAME_EMPTY_INTEGER_LIST);
@@ -738,7 +738,7 @@ public abstract class FSCollectionFactory {
if (aValues.length == 0) {
return aCas.createFS(emptyType);
}
-
+
Type nonEmptyType = ts.getType(CAS.TYPE_NAME_NON_EMPTY_INTEGER_LIST);
Feature headFeature = nonEmptyType.getFeatureByBaseName(CAS.FEATURE_BASE_NAME_HEAD);
Feature tailFeature = nonEmptyType.getFeatureByBaseName(CAS.FEATURE_BASE_NAME_TAIL);
@@ -761,11 +761,12 @@ public abstract class FSCollectionFactory {
return (T) list;
}
- public static <T extends FeatureStructure> T createIntegerList(CAS aCas, Collection<Integer> aValues) {
+ public static <T extends FeatureStructure> T createIntegerList(CAS aCas,
+ Collection<Integer> aValues) {
if (aValues == null) {
return null;
}
-
+
TypeSystem ts = aCas.getTypeSystem();
Type emptyType = ts.getType(CAS.TYPE_NAME_EMPTY_INTEGER_LIST);
@@ -773,7 +774,7 @@ public abstract class FSCollectionFactory {
if (aValues.size() == 0) {
return aCas.createFS(emptyType);
}
-
+
Type nonEmptyType = ts.getType(CAS.TYPE_NAME_NON_EMPTY_INTEGER_LIST);
Feature headFeature = nonEmptyType.getFeatureByBaseName(CAS.FEATURE_BASE_NAME_HEAD);
Feature tailFeature = nonEmptyType.getFeatureByBaseName(CAS.FEATURE_BASE_NAME_TAIL);
@@ -806,12 +807,13 @@ public abstract class FSCollectionFactory {
public static <T extends FeatureStructure> T createStringList(CAS aCas, String... aValues) {
return createStringList(aCas, asList(aValues));
}
-
- public static <T extends FeatureStructure> T createStringList(CAS aCas, Collection<String> aValues) {
+
+ public static <T extends FeatureStructure> T createStringList(CAS aCas,
+ Collection<String> aValues) {
if (aValues == null) {
return null;
}
-
+
TypeSystem ts = aCas.getTypeSystem();
Type emptyType = ts.getType(CAS.TYPE_NAME_EMPTY_STRING_LIST);
@@ -819,7 +821,7 @@ public abstract class FSCollectionFactory {
if (aValues.size() == 0) {
return aCas.createFS(emptyType);
}
-
+
Type nonEmptyType = ts.getType(CAS.TYPE_NAME_NON_EMPTY_STRING_LIST);
Feature headFeature = nonEmptyType.getFeatureByBaseName(CAS.FEATURE_BASE_NAME_HEAD);
Feature tailFeature = nonEmptyType.getFeatureByBaseName(CAS.FEATURE_BASE_NAME_TAIL);
@@ -883,7 +885,8 @@ public abstract class FSCollectionFactory {
}
}
- private static class AnnotationIndexAdapter<T extends AnnotationFS> extends AbstractCollection<T> {
+ private static class AnnotationIndexAdapter<T extends AnnotationFS>
+ extends AbstractCollection<T> {
private final AnnotationIndex<T> index;
public AnnotationIndexAdapter(AnnotationIndex<T> aIndex) {
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/util/FSUtil.java b/uimafit-core/src/main/java/org/apache/uima/fit/util/FSUtil.java
index 180b5ca..1ab625b 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/util/FSUtil.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/util/FSUtil.java
@@ -58,32 +58,30 @@ import org.apache.uima.cas.TypeSystem;
import org.apache.uima.jcas.cas.TOP;
public class FSUtil {
- private static Feature getMandatoryFeature(FeatureStructure aFS, String aFeature)
- {
+ private static Feature getMandatoryFeature(FeatureStructure aFS, String aFeature) {
Feature feat = aFS.getType().getFeatureByBaseName(aFeature);
-
+
if (feat == null) {
- throw new IllegalArgumentException("Type [" + aFS.getType() + "] has no feature with name ["
- + aFeature + "]");
+ throw new IllegalArgumentException(
+ "Type [" + aFS.getType() + "] has no feature with name [" + aFeature + "]");
}
-
+
return feat;
}
-
- private static void requireSingleValue(Feature aFeature, Object aArray)
- {
+
+ private static void requireSingleValue(Feature aFeature, Object aArray) {
if (aArray == null) {
- throw new IllegalArgumentException("Cannot set [" + aFeature.getName() + "] to a null value.");
+ throw new IllegalArgumentException(
+ "Cannot set [" + aFeature.getName() + "] to a null value.");
}
-
+
if (Array.getLength(aArray) != 1) {
throw new IllegalArgumentException("Feature [" + aFeature.getName()
+ "] requires a single value but got " + asList(aArray));
}
}
-
- private static boolean isListType(TypeSystem aTS, Type aType)
- {
+
+ private static boolean isListType(TypeSystem aTS, Type aType) {
return aTS.subsumes(aTS.getType(CAS.TYPE_NAME_LIST_BASE), aType);
}
@@ -105,7 +103,7 @@ public class FSUtil {
if (feat == null) {
return false;
}
-
+
return feat.getRange().isArray() || isListType(aTypeSystem, feat.getRange());
}
@@ -114,11 +112,9 @@ public class FSUtil {
if (feat.getRange().isPrimitive()) {
requireSingleValue(feat, aValue);
aFS.setBooleanValue(feat, aValue[0]);
- }
- else if (aValue == null) {
+ } else if (aValue == null) {
aFS.setFeatureValue(feat, null);
- }
- else {
+ } else {
aFS.setFeatureValue(feat, createBooleanArrayFS(aFS.getCAS(), aValue));
}
}
@@ -128,11 +124,9 @@ public class FSUtil {
if (feat.getRange().isPrimitive()) {
requireSingleValue(feat, aValue);
aFS.setByteValue(feat, aValue[0]);
- }
- else if (aValue == null) {
+ } else if (aValue == null) {
aFS.setFeatureValue(feat, null);
- }
- else {
+ } else {
aFS.setFeatureValue(feat, createByteArrayFS(aFS.getCAS(), aValue));
}
}
@@ -142,11 +136,9 @@ public class FSUtil {
if (feat.getRange().isPrimitive()) {
requireSingleValue(feat, aValue);
aFS.setDoubleValue(feat, aValue[0]);
- }
- else if (aValue == null) {
+ } else if (aValue == null) {
aFS.setFeatureValue(feat, null);
- }
- else {
+ } else {
aFS.setFeatureValue(feat, createDoubleArrayFS(aFS.getCAS(), aValue));
}
}
@@ -156,14 +148,11 @@ public class FSUtil {
if (feat.getRange().isPrimitive()) {
requireSingleValue(feat, aValue);
aFS.setFloatValue(feat, aValue[0]);
- }
- else if (aValue == null) {
+ } else if (aValue == null) {
aFS.setFeatureValue(feat, null);
- }
- else if (feat.getRange().isArray()) {
+ } else if (feat.getRange().isArray()) {
aFS.setFeatureValue(feat, createFloatArrayFS(aFS.getCAS(), aValue));
- }
- else {
+ } else {
aFS.setFeatureValue(feat, createFloatList(aFS.getCAS(), aValue));
}
}
@@ -173,14 +162,11 @@ public class FSUtil {
if (feat.getRange().isPrimitive()) {
requireSingleValue(feat, aValue);
aFS.setIntValue(feat, aValue[0]);
- }
- else if (aValue == null) {
+ } else if (aValue == null) {
aFS.setFeatureValue(feat, null);
- }
- else if (feat.getRange().isArray()) {
+ } else if (feat.getRange().isArray()) {
aFS.setFeatureValue(feat, createIntArrayFS(aFS.getCAS(), aValue));
- }
- else {
+ } else {
aFS.setFeatureValue(feat, createIntegerList(aFS.getCAS(), aValue));
}
}
@@ -190,11 +176,9 @@ public class FSUtil {
if (feat.getRange().isPrimitive()) {
requireSingleValue(feat, aValue);
aFS.setLongValue(feat, aValue[0]);
- }
- else if (aValue == null) {
+ } else if (aValue == null) {
aFS.setFeatureValue(feat, null);
- }
- else {
+ } else {
aFS.setFeatureValue(feat, createLongArrayFS(aFS.getCAS(), aValue));
}
}
@@ -204,11 +188,9 @@ public class FSUtil {
if (feat.getRange().isPrimitive()) {
requireSingleValue(feat, aValue);
aFS.setShortValue(feat, aValue[0]);
- }
- else if (aValue == null) {
+ } else if (aValue == null) {
aFS.setFeatureValue(feat, null);
- }
- else {
+ } else {
aFS.setFeatureValue(feat, createShortArrayFS(aFS.getCAS(), aValue));
}
}
@@ -218,14 +200,11 @@ public class FSUtil {
if (feat.getRange().isPrimitive()) {
requireSingleValue(feat, aValue);
aFS.setStringValue(feat, aValue[0]);
- }
- else if (aValue == null) {
+ } else if (aValue == null) {
aFS.setFeatureValue(feat, null);
- }
- else if (feat.getRange().isArray()) {
+ } else if (feat.getRange().isArray()) {
aFS.setFeatureValue(feat, createStringArrayFS(aFS.getCAS(), aValue));
- }
- else {
+ } else {
aFS.setFeatureValue(feat, createStringList(aFS.getCAS(), aValue));
}
}
@@ -234,28 +213,24 @@ public class FSUtil {
Feature feat = getMandatoryFeature(aFS, aFeature);
if (feat.getRange().isArray()) {
aFS.setFeatureValue(feat, createArrayFS(aFS.getCAS(), aValue));
- }
- else if (aValue == null) {
+ } else if (aValue == null) {
aFS.setFeatureValue(feat, null);
- }
- else if (isListType(aFS.getCAS().getTypeSystem(), feat.getRange())) {
+ } else if (isListType(aFS.getCAS().getTypeSystem(), feat.getRange())) {
TOP[] values = new TOP[aValue.length];
System.arraycopy(aValue, 0, values, 0, aValue.length);
aFS.setFeatureValue(feat, createFSList(aFS.getCAS(), values));
- }
- else {
+ } else {
requireSingleValue(feat, aValue);
aFS.setFeatureValue(feat, aValue[0]);
}
}
-
+
@SuppressWarnings({ "unchecked", "rawtypes" })
public static void setFeature(FeatureStructure aFS, String aFeature, Collection aValue) {
Feature feat = getMandatoryFeature(aFS, aFeature);
if (aValue == null) {
aFS.setFeatureValue(feat, null);
- }
- else if (feat.getRange().isArray()) {
+ } else if (feat.getRange().isArray()) {
switch (feat.getRange().getName()) {
case CAS.TYPE_NAME_BOOLEAN_ARRAY:
aFS.setFeatureValue(feat, createBooleanArrayFS(aFS.getCAS(), aValue));
@@ -285,8 +260,7 @@ public class FSUtil {
aFS.setFeatureValue(feat, createArrayFS(aFS.getCAS(), aValue));
break;
}
- }
- else {
+ } else {
switch (feat.getRange().getName()) {
case CAS.TYPE_NAME_FLOAT_LIST:
aFS.setFeatureValue(feat, createFloatList(aFS.getCAS(), aValue));
@@ -297,23 +271,21 @@ public class FSUtil {
case CAS.TYPE_NAME_STRING_LIST:
aFS.setFeatureValue(feat, createStringList(aFS.getCAS(), aValue));
break;
- default:
+ default:
aFS.setFeatureValue(feat, createFSList(aFS.getCAS(), aValue));
break;
}
}
}
- public static <T> T getFeature(FeatureStructure aFS, String aFeature, Class<T> aClazz)
- {
+ public static <T> T getFeature(FeatureStructure aFS, String aFeature, Class<T> aClazz) {
Feature feat = getMandatoryFeature(aFS, aFeature);
return getFeature(aFS, feat, aClazz);
}
-
+
@SuppressWarnings({ "unchecked", "rawtypes" })
- public static <T> T getFeature(FeatureStructure aFS, Feature aFeature, Class<T> aClazz)
- {
+ public static <T> T getFeature(FeatureStructure aFS, Feature aFeature, Class<T> aClazz) {
if (aFeature.getRange().isPrimitive()) {
switch (aFeature.getRange().getName()) {
case CAS.TYPE_NAME_BOOLEAN:
@@ -333,69 +305,61 @@ public class FSUtil {
case CAS.TYPE_NAME_STRING:
return aClazz.cast(aFS.getStringValue(aFeature));
default:
- throw new IllegalArgumentException("Unable to coerce value of feature [" + aFeature.getName()
- + "] with type [" + aFeature.getRange().getName() + "] into [" + aClazz.getName() + "]");
+ throw new IllegalArgumentException(
+ "Unable to coerce value of feature [" + aFeature.getName() + "] with type ["
+ + aFeature.getRange().getName() + "] into [" + aClazz.getName() + "]");
}
}
-
+
FeatureStructure value = aFS.getFeatureValue(aFeature);
-
+
// "null" case
if (value == null) {
return null;
}
-
+
// Here we store the values before we coerce them into the final target type
// "target" is actually an array
Object target;
int length;
-
+
// Handle case where feature is an array
if (value instanceof CommonArrayFS) {
// Shortcut if the user explicitly requests an array type
if (!Object.class.equals(aClazz) && aClazz.isAssignableFrom(value.getClass())) {
return (T) value;
}
-
+
CommonArrayFS source = (CommonArrayFS) value;
length = source.size();
if (value instanceof BooleanArrayFS) {
target = new boolean[length];
((BooleanArrayFS) source).copyToArray(0, (boolean[]) target, 0, length);
- }
- else if (value instanceof ByteArrayFS) {
+ } else if (value instanceof ByteArrayFS) {
target = new byte[length];
((ByteArrayFS) source).copyToArray(0, (byte[]) target, 0, length);
- }
- else if (value instanceof DoubleArrayFS) {
+ } else if (value instanceof DoubleArrayFS) {
target = new double[length];
((DoubleArrayFS) source).copyToArray(0, (double[]) target, 0, length);
- }
- else if (value instanceof FloatArrayFS) {
+ } else if (value instanceof FloatArrayFS) {
target = new float[length];
((FloatArrayFS) source).copyToArray(0, (float[]) target, 0, length);
- }
- else if (value instanceof IntArrayFS) {
+ } else if (value instanceof IntArrayFS) {
target = new int[length];
((IntArrayFS) source).copyToArray(0, (int[]) target, 0, length);
- }
- else if (value instanceof LongArrayFS) {
+ } else if (value instanceof LongArrayFS) {
target = new long[length];
((LongArrayFS) source).copyToArray(0, (long[]) target, 0, length);
- }
- else if (value instanceof ShortArrayFS) {
+ } else if (value instanceof ShortArrayFS) {
target = new short[length];
((ShortArrayFS) source).copyToArray(0, (short[]) target, 0, length);
- }
- else if (value instanceof StringArrayFS) {
+ } else if (value instanceof StringArrayFS) {
target = new String[length];
((StringArrayFS) source).copyToArray(0, (String[]) target, 0, length);
- }
- else {
+ } else {
if (aClazz.isArray()) {
target = Array.newInstance(aClazz.getComponentType(), length);
- }
- else {
+ } else {
target = new FeatureStructure[length];
}
((ArrayFS) source).copyToArray(0, (FeatureStructure[]) target, 0, length);
@@ -407,7 +371,7 @@ public class FSUtil {
if (!Object.class.equals(aClazz) && aClazz.isAssignableFrom(value.getClass())) {
return (T) value;
}
-
+
// Get length of list
length = 0;
{
@@ -426,10 +390,10 @@ public class FSUtil {
FeatureStructure cur = value;
// We assume to by facing a non-empty element if it has a "head" feature
while (cur.getType().getFeatureByBaseName(CAS.FEATURE_BASE_NAME_HEAD) != null) {
- floatTarget[i] = cur.getFloatValue(cur.getType().getFeatureByBaseName(
- CAS.FEATURE_BASE_NAME_HEAD));
- cur = cur.getFeatureValue(cur.getType()
- .getFeatureByBaseName(CAS.FEATURE_BASE_NAME_TAIL));
+ floatTarget[i] = cur
+ .getFloatValue(cur.getType().getFeatureByBaseName(CAS.FEATURE_BASE_NAME_HEAD));
+ cur = cur.getFeatureValue(
+ cur.getType().getFeatureByBaseName(CAS.FEATURE_BASE_NAME_TAIL));
}
target = floatTarget;
break;
@@ -440,10 +404,10 @@ public class FSUtil {
FeatureStructure cur = value;
// We assume to by facing a non-empty element if it has a "head" feature
while (cur.getType().getFeatureByBaseName(CAS.FEATURE_BASE_NAME_HEAD) != null) {
- intTarget[i] = cur.getIntValue(cur.getType().getFeatureByBaseName(
- CAS.FEATURE_BASE_NAME_HEAD));
- cur = cur.getFeatureValue(cur.getType()
- .getFeatureByBaseName(CAS.FEATURE_BASE_NAME_TAIL));
+ intTarget[i] = cur
+ .getIntValue(cur.getType().getFeatureByBaseName(CAS.FEATURE_BASE_NAME_HEAD));
+ cur = cur.getFeatureValue(
+ cur.getType().getFeatureByBaseName(CAS.FEATURE_BASE_NAME_TAIL));
}
target = intTarget;
break;
@@ -454,10 +418,10 @@ public class FSUtil {
FeatureStructure cur = value;
// We assume to by facing a non-empty element if it has a "head" feature
while (cur.getType().getFeatureByBaseName(CAS.FEATURE_BASE_NAME_HEAD) != null) {
- stringTarget[i] = cur.getStringValue(cur.getType().getFeatureByBaseName(
- CAS.FEATURE_BASE_NAME_HEAD));
- cur = cur.getFeatureValue(cur.getType()
- .getFeatureByBaseName(CAS.FEATURE_BASE_NAME_TAIL));
+ stringTarget[i] = cur
+ .getStringValue(cur.getType().getFeatureByBaseName(CAS.FEATURE_BASE_NAME_HEAD));
+ cur = cur.getFeatureValue(
+ cur.getType().getFeatureByBaseName(CAS.FEATURE_BASE_NAME_TAIL));
}
target = stringTarget;
break;
@@ -472,64 +436,60 @@ public class FSUtil {
FeatureStructure cur = value;
// We assume to by facing a non-empty element if it has a "head" feature
while (cur.getType().getFeatureByBaseName(CAS.FEATURE_BASE_NAME_HEAD) != null) {
- Array.set(target, i,
- cur.getFeatureValue(cur.getType().getFeatureByBaseName(
- CAS.FEATURE_BASE_NAME_HEAD)));
+ Array.set(target, i, cur.getFeatureValue(
+ cur.getType().getFeatureByBaseName(CAS.FEATURE_BASE_NAME_HEAD)));
i++;
- cur = cur.getFeatureValue(cur.getType()
- .getFeatureByBaseName(CAS.FEATURE_BASE_NAME_TAIL));
+ cur = cur.getFeatureValue(
+ cur.getType().getFeatureByBaseName(CAS.FEATURE_BASE_NAME_TAIL));
}
break;
}
}
- }
- else if (aClazz.isAssignableFrom(value.getClass())) {
+ } else if (aClazz.isAssignableFrom(value.getClass())) {
return (T) value;
- }
- else if (aFS.getCAS().getTypeSystem()
- .subsumes(CasUtil.getType(aFS.getCAS(), aClazz), aFeature.getRange())) {
+ } else if (aFS.getCAS().getTypeSystem().subsumes(CasUtil.getType(aFS.getCAS(), aClazz),
+ aFeature.getRange())) {
return (T) value;
- }
- else {
- throw new IllegalArgumentException("Unable to coerce value of feature [" + aFeature.getName()
- + "] with type [" + aFeature.getRange().getName() + "] into [" + aClazz.getName() + "]");
+ } else {
+ throw new IllegalArgumentException(
+ "Unable to coerce value of feature [" + aFeature.getName() + "] with type ["
+ + aFeature.getRange().getName() + "] into [" + aClazz.getName() + "]");
}
// Handle case where return value is an array
if (aClazz.isArray()) {
return aClazz.cast(target);
}
-
+
// Handle case where return value is Object
Class targetClass = aClazz;
if (Object.class.equals(aClazz)) {
targetClass = List.class;
}
-
+
// Handle case where return value is a collection
if (Collection.class.isAssignableFrom(targetClass)) {
Collection targetCollection;
-
+
if (targetClass.isInterface()) {
// If the target is an interface, try using a default implementation;
if (List.class.isAssignableFrom(targetClass)) {
targetCollection = new ArrayList(length);
- }
- else if (Set.class.isAssignableFrom(targetClass)) {
+ } else if (Set.class.isAssignableFrom(targetClass)) {
targetCollection = new HashSet(length);
+ } else {
+ throw new IllegalArgumentException("Unable to coerce value of feature ["
+ + aFeature.getName() + "] with type [" + aFeature.getRange().getName()
+ + "] into [" + targetClass.getName() + "]");
}
- else {
- throw new IllegalArgumentException("Unable to coerce value of feature [" + aFeature.getName()
- + "] with type [" + aFeature.getRange().getName() + "] into [" + targetClass.getName() + "]");
- }
- }
- else {
+ } else {
// Try to instantiate using 0-args constructor
try {
targetCollection = (Collection) targetClass.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
- throw new IllegalArgumentException("Unable to coerce value of feature [" + aFeature.getName()
- + "] with type [" + aFeature.getRange().getName() + "] into [" + targetClass.getName() + "]", e);
+ throw new IllegalArgumentException("Unable to coerce value of feature ["
+ + aFeature.getName() + "] with type [" + aFeature.getRange().getName()
+ + "] into [" + targetClass.getName() + "]", e);
}
}
for (int i = 0; i < length; i++) {
@@ -537,8 +497,9 @@ public class FSUtil {
}
return (T) targetClass.cast(targetCollection);
}
-
- throw new IllegalArgumentException("Unable to coerce value of feature [" + aFeature.getName()
- + "] with type [" + aFeature.getRange().getName() + "] into [" + targetClass.getName() + "]");
+
+ throw new IllegalArgumentException(
+ "Unable to coerce value of feature [" + aFeature.getName() + "] with type ["
+ + aFeature.getRange().getName() + "] into [" + targetClass.getName() + "]");
}
}
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/util/JCasUtil.java b/uimafit-core/src/main/java/org/apache/uima/fit/util/JCasUtil.java
index 2c1cf32..78de254 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/util/JCasUtil.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/util/JCasUtil.java
@@ -109,11 +109,11 @@ public final class JCasUtil {
* @see <a href="package-summary.html#SortOrder">Order of selected feature structures</a>
*/
@SuppressWarnings("unchecked")
- public static <T extends AnnotationFS> Iterator<T> iterator(AnnotationFS container,
- Class<T> type, boolean ambiguous, boolean strict) {
+ public static <T extends AnnotationFS> Iterator<T> iterator(AnnotationFS container, Class<T> type,
+ boolean ambiguous, boolean strict) {
CAS cas = container.getCAS();
- return ((AnnotationIndex<T>) cas.getAnnotationIndex(CasUtil.getType(cas, type))).subiterator(
- container, ambiguous, strict);
+ return ((AnnotationIndex<T>) cas.getAnnotationIndex(CasUtil.getType(cas, type)))
+ .subiterator(container, ambiguous, strict);
}
/**
@@ -210,7 +210,7 @@ public final class JCasUtil {
int aBegin, int aEnd) {
return cast(CasUtil.selectAt(jCas.getCas(), getType(jCas, type), aBegin, aEnd));
}
-
+
/**
* Get a single annotations of the given type at the specified offsets.
*
@@ -264,8 +264,8 @@ public final class JCasUtil {
* @see Subiterator
* @see <a href="package-summary.html#SortOrder">Order of selected feature structures</a>
*/
- public static <T extends Annotation> List<T> selectBetween(final Class<T> type,
- AnnotationFS ann1, AnnotationFS ann2) {
+ public static <T extends Annotation> List<T> selectBetween(final Class<T> type, AnnotationFS ann1,
+ AnnotationFS ann2) {
return cast(CasUtil.selectBetween(CasUtil.getType(ann1.getCAS(), type), ann1, ann2));
}
@@ -305,8 +305,8 @@ public final class JCasUtil {
* subtype of that type.
* <p>
* The method only returns properly covered annotations, that is annotations where the begin/end
- * offsets are equal to the 'covering' annotation or where both the begin/end are included in
- * the span of the 'covering' annotation. Partially overlapping annotations are not returned.
+ * offsets are equal to the 'covering' annotation or where both the begin/end are included in the
+ * span of the 'covering' annotation. Partially overlapping annotations are not returned.
*
* @param <T>
* the JCas type.
@@ -333,8 +333,8 @@ public final class JCasUtil {
* subtype of that type.
* <p>
* The method only returns properly covered annotations, that is annotations where the begin/end
- * offsets are equal to the 'covering' annotation or where both the begin/end are included in
- * the span of the 'covering' annotation. Partially overlapping annotations are not returned.
+ * offsets are equal to the 'covering' annotation or where both the begin/end are included in the
+ * span of the 'covering' annotation. Partially overlapping annotations are not returned.
*
* @param <T>
* the JCas type.
@@ -360,12 +360,13 @@ public final class JCasUtil {
* <p>
* <b>Note:</b> this is significantly slower than using
* {@link #selectCovered(JCas, Class, AnnotationFS)}. It is possible to use
- * {@code selectCovered(jCas, cls, new Annotation(jCas, int, int))}, but that will allocate memory
- * in the jCas for the new annotation. If you do that repeatedly many times, memory may fill up.
+ * {@code selectCovered(jCas, cls, new Annotation(jCas, int, int))}, but that will allocate
+ * memory in the jCas for the new annotation. If you do that repeatedly many times, memory may
+ * fill up.
* <p>
* The method only returns properly covered annotations, that is annotations where the begin/end
- * offsets are equal to the given begin/end or where both the begin/end are included in
- * the span of the given span. Partially overlapping annotations are not returned.
+ * offsets are equal to the given begin/end or where both the begin/end are included in the span
+ * of the given span. Partially overlapping annotations are not returned.
*
* @param <T>
* the JCas type.
@@ -485,8 +486,8 @@ public final class JCasUtil {
* is properly contained within the span of the 'covering' annotation. Partially overlapping
* annotations are not returned.
* <p>
- * When querying for the annotations covering a given annotation, the given annotation itself
- * is never returned, even if it is of the queried type.
+ * When querying for the annotations covering a given annotation, the given annotation itself is
+ * never returned, even if it is of the queried type.
*
* @param <T>
* the covered JCAs type.
@@ -503,23 +504,23 @@ public final class JCasUtil {
*/
public static <T extends Annotation, S extends Annotation> Map<T, List<S>> indexCovering(
JCas jCas, Class<? extends T> type, Class<? extends S> coveringType) {
- return cast(CasUtil.indexCovering(jCas.getCas(), getType(jCas, type),
- getType(jCas, coveringType)));
+ return cast(
+ CasUtil.indexCovering(jCas.getCas(), getType(jCas, type), getType(jCas, coveringType)));
}
/**
* Create an index for quickly lookup up the annotations covered by a particular annotation. This
* is preferable to using {@link #selectCovered(JCas, Class, int, int)} because the overhead of
* scanning the CAS occurs only when the index is build. Subsequent lookups to the index are fast.
- * The order of entries in the map is not defined. However, lists of covered annotations in
- * the map are guaranteed to be in the same order as in the UIMA default annotation index.
+ * The order of entries in the map is not defined. However, lists of covered annotations in the
+ * map are guaranteed to be in the same order as in the UIMA default annotation index.
* <p>
* The method only returns properly covered annotations, that is annotations where the begin/end
- * offsets are equal to the 'covering' annotation or where both the begin/end are included in
- * the span of the 'covering' annotation. Partially overlapping annotations are not returned.
+ * offsets are equal to the 'covering' annotation or where both the begin/end are included in the
+ * span of the 'covering' annotation. Partially overlapping annotations are not returned.
* <p>
- * When querying for the annotations covered by a given annotation, the given annotation itself
- * is never returned, even if it is of the queried type.
+ * When querying for the annotations covered by a given annotation, the given annotation itself is
+ * never returned, even if it is of the queried type.
*
* @param <T>
* the covering JCas type.
@@ -534,48 +535,48 @@ public final class JCasUtil {
* @return the index.
* @see <a href="package-summary.html#SortOrder">Order of selected feature structures</a>
*/
- public static <T extends Annotation, S extends Annotation> Map<T, List<S>> indexCovered(
- JCas jCas, Class<? extends T> type, Class<? extends S> coveredType) {
- return cast(CasUtil
- .indexCovered(jCas.getCas(), getType(jCas, type), getType(jCas, coveredType)));
+ public static <T extends Annotation, S extends Annotation> Map<T, List<S>> indexCovered(JCas jCas,
+ Class<? extends T> type, Class<? extends S> coveredType) {
+ return cast(
+ CasUtil.indexCovered(jCas.getCas(), getType(jCas, type), getType(jCas, coveredType)));
}
/**
- * Get a list of annotations of the given annotation type overlapping the given annotation. Does
+ * Get a list of annotations of the given annotation type overlapping the given annotation. Does
* not use subiterators and does not respect type prioritites.
*
* @param aType
* a UIMA type.
- * @param aBoundaryAnnotation
+ * @param aBoundaryAnnotation
* the covering annotation.
* @return a list of overlapping annotations.
* @see <a href="package-summary.html#SortOrder">Order of selected feature structures</a>
- */
+ */
public static <T extends Annotation> List<T> selectOverlapping(Class<T> aType,
AnnotationFS aBoundaryAnnotation) {
return cast(CasUtil.selectOverlapping(getType(aBoundaryAnnotation.getJCas(), aType),
aBoundaryAnnotation));
}
-
+
/**
- * Get a list of annotations of the given annotation type overlapping the given annotation. Does
+ * Get a list of annotations of the given annotation type overlapping the given annotation. Does
* not use subiterators and does not respect type prioritites.
*
* @param aJCas
* a CAS.
* @param aType
* a UIMA type.
- * @param aBoundaryAnnotation
+ * @param aBoundaryAnnotation
* the covering annotation.
* @return a list of overlapping annotations.
* @see <a href="package-summary.html#SortOrder">Order of selected feature structures</a>
- */
+ */
public static <T extends Annotation> List<T> selectOverlapping(JCas aJCas, Class<T> aType,
AnnotationFS aBoundaryAnnotation) {
return cast(
CasUtil.selectOverlapping(aJCas.getCas(), getType(aJCas, aType), aBoundaryAnnotation));
}
-
+
/**
* Get a list of annotations of the given annotation type overlapping the given span. Does not use
* subiterators and does not respect type prioritites.
@@ -590,12 +591,12 @@ public final class JCasUtil {
* end offset.
* @return a list of overlapping annotations.
* @see <a href="package-summary.html#SortOrder">Order of selected feature structures</a>
- */
+ */
public static <T extends Annotation> List<T> selectOverlapping(JCas aJCas, Class<T> aType,
- int aBegin, int aEnd) {
+ int aBegin, int aEnd) {
return cast(CasUtil.selectOverlapping(aJCas.getCas(), getType(aJCas, aType), aBegin, aEnd));
}
-
+
/**
* Check if the given annotation contains any annotation of the given type.
*
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/util/LocaleUtil.java b/uimafit-core/src/main/java/org/apache/uima/fit/util/LocaleUtil.java
index b2360a4..e4eb639 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/util/LocaleUtil.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/util/LocaleUtil.java
@@ -57,7 +57,8 @@ public final class LocaleUtil {
* passed into the multi-parameter constructors of Locale. The passed in string should not contain
* more than two hyphens as the Locale constructor with the most params is three.
*
- * @param localeString the locale string
+ * @param localeString
+ * the locale string
* @return the parsed locale
*/
public static Locale createLocale(String localeString) {
@@ -78,7 +79,8 @@ public final class LocaleUtil {
* passes through to getLocaleConstant. If this returns null, then this method passes through to
* createLocale.
*
- * @param localeString the locale string
+ * @param localeString
+ * the locale string
* @return the parsed locale
*/
public static Locale getLocale(String localeString) {
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/util/package-info.java b/uimafit-core/src/main/java/org/apache/uima/fit/util/package-info.java
index f35697e..636fa6b 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/util/package-info.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/util/package-info.java
@@ -17,33 +17,36 @@
* under the License.
*/
/**
- * Utility classes like {@link org.apache.uima.fit.util.CasUtil} and {@link org.apache.uima.fit.util.JCasUtil}.
+ * Utility classes like {@link org.apache.uima.fit.util.CasUtil} and
+ * {@link org.apache.uima.fit.util.JCasUtil}.
*
* <H2><a id="SortOrder">Sort order</a></H2>
*
- * The various <em>select</em> methods in {@link org.apache.uima.fit.util.CasUtil} and
+ * The various <em>select</em> methods in {@link org.apache.uima.fit.util.CasUtil} and
* {@link org.apache.uima.fit.util.JCasUtil} rely on the UIMA feature structure indexes. Their
* behaviour differs depending on the type of feature structure being selected and where they are
* selected from:
*
* <H2>Selecting from a {@link org.apache.uima.cas.CAS}/{@link org.apache.uima.jcas.JCas}</H2>
* <ol>
- * <li><b>Annotations</b> - if the type being selected is {@link org.apache.uima.jcas.tcas.Annotation}
- * or a sub-type thereof, the built-in annotation index is used. This index has the keys
- * <em>begin</em> (Ascending), <em>end</em> (Descending) and <em>TYPE_PRIORITY</em>. There are no
- * built-in type priorities, so this last sort item does not play a role in the index unless
- * type priorities are specified. uimaFIT uses {@link org.apache.uima.cas.CAS#getAnnotationIndex(org.apache.uima.cas.Type)}
- * to access annotation feature structures.</li>
- * <li><b>Other feature structures</b> - if feature structures are selected that are not
+ * <li><b>Annotations</b> - if the type being selected is
+ * {@link org.apache.uima.jcas.tcas.Annotation} or a sub-type thereof, the built-in annotation index
+ * is used. This index has the keys <em>begin</em> (Ascending), <em>end</em> (Descending) and
+ * <em>TYPE_PRIORITY</em>. There are no built-in type priorities, so this last sort item does not
+ * play a role in the index unless type priorities are specified. uimaFIT uses
+ * {@link org.apache.uima.cas.CAS#getAnnotationIndex(org.apache.uima.cas.Type)} to access annotation
+ * feature structures.</li>
+ * <li><b>Other feature structures</b> - if feature structures are selected that are not
* {@link org.apache.uima.jcas.tcas.Annotation annotations}, the order should be considered
- * undefined. uimaFIT uses {@link org.apache.uima.cas.FSIndexRepository#getAllIndexedFS(org.apache.uima.cas.Type)}
- * to access these feature structures.</li>
+ * undefined. uimaFIT uses
+ * {@link org.apache.uima.cas.FSIndexRepository#getAllIndexedFS(org.apache.uima.cas.Type)} to access
+ * these feature structures.</li>
* </ol>
*
- * <H2>Selecting from a {@link org.apache.uima.cas.ArrayFS ArrayFS/FSArray}/{@link org.apache.uima.jcas.cas.FSList}</H2>
+ * <H2>Selecting from a {@link org.apache.uima.cas.ArrayFS
+ * ArrayFS/FSArray}/{@link org.apache.uima.jcas.cas.FSList}</H2>
*
* When selecting from a feature structure list or array, the order is determined by the order of
* the annotations inside the list/array.
*/
package org.apache.uima.fit.util;
-
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/validation/ValidationCheck.java b/uimafit-core/src/main/java/org/apache/uima/fit/validation/ValidationCheck.java
index 26ac388..f0e4f74 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/validation/ValidationCheck.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/validation/ValidationCheck.java
@@ -23,26 +23,28 @@ package org.apache.uima.fit.validation;
* mechanism.
*/
public interface ValidationCheck {
-
+
/**
* Fail the check with the given message.
*
- * @param aMessage the failure message.
- * @throws ValidationCheckFailedException an exception carrying the failure message.
+ * @param aMessage
+ * the failure message.
+ * @throws ValidationCheckFailedException
+ * an exception carrying the failure message.
*/
- default void fail(String aMessage) throws ValidationCheckFailedException
- {
+ default void fail(String aMessage) throws ValidationCheckFailedException {
throw new ValidationCheckFailedException(aMessage);
}
/**
* Skip the check with the given reason.
*
- * @param aMessage the skip reason.
- * @throws ValidationCheckSkippedException an exception carrying the failure message.
+ * @param aMessage
+ * the skip reason.
+ * @throws ValidationCheckSkippedException
+ * an exception carrying the failure message.
*/
- default void skip(String aMessage) throws ValidationCheckSkippedException
- {
+ default void skip(String aMessage) throws ValidationCheckSkippedException {
throw new ValidationCheckSkippedException(aMessage);
}
}
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/validation/ValidationCheckException.java b/uimafit-core/src/main/java/org/apache/uima/fit/validation/ValidationCheckException.java
index c9b6b9b..66598de 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/validation/ValidationCheckException.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/validation/ValidationCheckException.java
@@ -19,8 +19,8 @@
package org.apache.uima.fit.validation;
/**
- * Exception by a particular validation check. These exceptions should not abort the validation
- * but rather be rendered as results for the particular check.
+ * Exception by a particular validation check. These exceptions should not abort the validation but
+ * rather be rendered as results for the particular check.
*/
public abstract class ValidationCheckException extends ValidationException {
private static final long serialVersionUID = -5685006985598972648L;
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/validation/ValidationCheckFailedException.java b/uimafit-core/src/main/java/org/apache/uima/fit/validation/ValidationCheckFailedException.java
index 0c7a7cd..91f0930 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/validation/ValidationCheckFailedException.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/validation/ValidationCheckFailedException.java
@@ -28,8 +28,8 @@ public class ValidationCheckFailedException extends ValidationCheckException {
super();
}
- public ValidationCheckFailedException(String aMessage, Throwable aCause, boolean aEnableSuppression,
- boolean aWritableStackTrace) {
+ public ValidationCheckFailedException(String aMessage, Throwable aCause,
+ boolean aEnableSuppression, boolean aWritableStackTrace) {
super(aMessage, aCause, aEnableSuppression, aWritableStackTrace);
}
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/validation/Validator.java b/uimafit-core/src/main/java/org/apache/uima/fit/validation/Validator.java
index ca69888..d8ccf30 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/validation/Validator.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/validation/Validator.java
@@ -64,7 +64,7 @@ public class Validator {
return summary;
}
-
+
public ValidationSummary check(CAS cas) throws ValidationException {
ValidationSummary summary = new ValidationSummary();
@@ -91,7 +91,7 @@ public class Validator {
return summary;
}
-
+
public Collection<ValidationCheck> getChecks() {
return checks;
}
@@ -145,10 +145,7 @@ public class Validator {
* names of check classes to be excluded.
*/
public Validator.Builder excludingByName(String... className) {
- stream(className)
- .map(Pattern::quote)
- .map(Pattern::compile)
- .forEach(excludePatterns::add);
+ stream(className).map(Pattern::quote).map(Pattern::compile).forEach(excludePatterns::add);
return this;
}
@@ -161,9 +158,7 @@ public class Validator {
* regular expressions matching check class names to be excluded.
*/
public Validator.Builder excludingByPattern(String... patterns) {
- stream(patterns)
- .map(Pattern::compile)
- .forEach(excludePatterns::add);
+ stream(patterns).map(Pattern::compile).forEach(excludePatterns::add);
return this;
}
@@ -180,7 +175,7 @@ public class Validator {
stream(types).forEach(excludeTypes::add);
return this;
}
-
+
/**
* Retain only checks with the given names. Subtypes of the given classes are not retained.
* <p>
@@ -190,10 +185,7 @@ public class Validator {
* names of check classes to be included.
*/
public Validator.Builder includingByName(String... className) {
- stream(className)
- .map(Pattern::quote)
- .map(Pattern::compile)
- .forEach(includePatterns::add);
+ stream(className).map(Pattern::quote).map(Pattern::compile).forEach(includePatterns::add);
return this;
}
@@ -206,9 +198,7 @@ public class Validator {
* regular expressions matching check class names to be included.
*/
public Validator.Builder includingByPattern(String... patterns) {
- stream(patterns)
- .map(Pattern::compile)
- .forEach(includePatterns::add);
+ stream(patterns).map(Pattern::compile).forEach(includePatterns::add);
return this;
}
@@ -227,8 +217,7 @@ public class Validator {
}
private Validator.Builder autoDetectChecks() {
- stream(load(ValidationCheck.class).spliterator(), false)
- .forEachOrdered(checks::add);
+ stream(load(ValidationCheck.class).spliterator(), false).forEachOrdered(checks::add);
return this;
}
@@ -236,25 +225,25 @@ public class Validator {
if (!skipAutoDetection) {
autoDetectChecks();
}
-
+
if (!includePatterns.isEmpty()) {
checks.removeIf(check -> includePatterns.stream()
.noneMatch(p -> p.matcher(check.getClass().getName()).matches()));
}
-
+
if (!includeTypes.isEmpty()) {
checks.removeIf(check -> includeTypes.stream()
.noneMatch(t -> t.isAssignableFrom(check.getClass())));
}
-
+
if (!excludePatterns.isEmpty()) {
checks.removeIf(check -> excludePatterns.stream()
.anyMatch(p -> p.matcher(check.getClass().getName()).matches()));
}
-
+
if (!excludeTypes.isEmpty()) {
- checks.removeIf(check -> excludeTypes.stream()
- .anyMatch(t -> t.isAssignableFrom(check.getClass())));
+ checks.removeIf(
+ check -> excludeTypes.stream().anyMatch(t -> t.isAssignableFrom(check.getClass())));
}
return new Validator(checks);
diff --git a/uimafit-core/src/test/java/DefaultPackageAETest.java b/uimafit-core/src/test/java/DefaultPackageAETest.java
index bf51bab..9485f4a 100644
--- a/uimafit-core/src/test/java/DefaultPackageAETest.java
+++ b/uimafit-core/src/test/java/DefaultPackageAETest.java
@@ -24,7 +24,7 @@ import org.apache.uima.fit.component.JCasAnnotator_ImplBase;
import org.apache.uima.fit.factory.AnalysisEngineFactory;
import org.apache.uima.fit.pipeline.SimplePipeline;
import org.apache.uima.jcas.JCas;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*/
@@ -33,13 +33,12 @@ public class DefaultPackageAETest extends ComponentTestBase {
@Test
public void testPackageLessAE() throws Exception {
- AnalysisEngineDescription aed = AnalysisEngineFactory.createEngineDescription(
- DefaultPackageAE.class, (Object[]) null);
+ AnalysisEngineDescription aed = AnalysisEngineFactory
+ .createEngineDescription(DefaultPackageAE.class, (Object[]) null);
jCas.setDocumentText("some text");
SimplePipeline.runPipeline(jCas, aed);
- aed = AnalysisEngineFactory
- .createEngineDescription(DefaultPackageAE2.class, (Object[]) null);
+ aed = AnalysisEngineFactory.createEngineDescription(DefaultPackageAE2.class, (Object[]) null);
jCas.reset();
jCas.setDocumentText("some text");
SimplePipeline.runPipeline(jCas, aed);
diff --git a/uimafit-core/src/test/java/org/apache/uima/fit/ComponentTestBase.java b/uimafit-core/src/test/java/org/apache/uima/fit/ComponentTestBase.java
index 8529914..40c0bbc 100644
--- a/uimafit-core/src/test/java/org/apache/uima/fit/ComponentTestBase.java
+++ b/uimafit-core/src/test/java/org/apache/uima/fit/ComponentTestBase.java
@@ -27,7 +27,7 @@ import org.apache.uima.jcas.JCas;
import org.apache.uima.resource.metadata.TypePriorities;
import org.apache.uima.resource.metadata.TypeSystemDescription;
import org.apache.uima.util.CasCreationUtils;
-import org.junit.Before;
+import org.junit.jupiter.api.BeforeEach;
/**
*
@@ -47,9 +47,9 @@ public class ComponentTestBase {
try {
TYPE_SYSTEM_DESCRIPTION.set(TypeSystemDescriptionFactory.createTypeSystemDescription());
- TypePriorities tp = TypePrioritiesFactory.createTypePriorities(new String[] {
- "org.apache.uima.fit.type.Sentence", "org.apache.uima.fit.type.AnalyzedText",
- "org.apache.uima.fit.type.Token" });
+ TypePriorities tp = TypePrioritiesFactory
+ .createTypePriorities(new String[] { "org.apache.uima.fit.type.Sentence",
+ "org.apache.uima.fit.type.AnalyzedText", "org.apache.uima.fit.type.Token" });
TYPE_PRIORITIES.set(tp);
JCas jCas = CasCreationUtils.createCas(TYPE_SYSTEM_DESCRIPTION.get(), tp, null).getJCas();
@@ -77,7 +77,7 @@ public class ComponentTestBase {
* (~100ms on my laptop). Instead, we will have one JCas per thread sitting around that we will
* reset everytime a new test is called.
*/
- @Before
+ @BeforeEach
public void setUp() {
jCas = JCAS.get();
jCas.reset();
diff --git a/uimafit-core/src/test/java/org/apache/uima/fit/component/CasDumpWriterTest.java b/uimafit-core/src/test/java/org/apache/uima/fit/component/CasDumpWriterTest.java
index ef232fe..6a967dc 100644
--- a/uimafit-core/src/test/java/org/apache/uima/fit/component/CasDumpWriterTest.java
+++ b/uimafit-core/src/test/java/org/apache/uima/fit/component/CasDumpWriterTest.java
@@ -19,18 +19,17 @@
package org.apache.uima.fit.component;
import static org.apache.commons.io.FileUtils.readFileToString;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
import org.apache.uima.analysis_engine.AnalysisEngine;
-import org.apache.uima.fit.component.CasDumpWriter;
import org.apache.uima.fit.factory.AnalysisEngineFactory;
import org.apache.uima.fit.util.CasIOUtil;
import org.apache.uima.jcas.JCas;
import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.junit.rules.TemporaryFolder;
public class CasDumpWriterTest {
@@ -49,8 +48,8 @@ public class CasDumpWriterTest {
writer.process(jcas);
assertTrue(outputFile.exists());
- String reference = readFileToString(
- new File("src/test/resources/data/reference/test.xmi.dump"), "UTF-8").trim();
+ String reference = readFileToString(new File("src/test/resources/data/reference/test.xmi.dump"),
+ "UTF-8").trim();
String actual = readFileToString(outputFile, "UTF-8").trim();
actual = actual.replaceAll("\r\n", "\n");
diff --git a/uimafit-core/src/test/java/org/apache/uima/fit/component/CasMultiplierTest.java b/uimafit-core/src/test/java/org/apache/uima/fit/component/CasMultiplierTest.java
index bbd6be8..f489914 100644
--- a/uimafit-core/src/test/java/org/apache/uima/fit/component/CasMultiplierTest.java
+++ b/uimafit-core/src/test/java/org/apache/uima/fit/component/CasMultiplierTest.java
@@ -22,7 +22,7 @@ import static org.apache.uima.fit.factory.AnalysisEngineFactory.createEngineDesc
import static org.apache.uima.fit.factory.CollectionReaderFactory.createReaderDescription;
import static org.apache.uima.fit.pipeline.SimplePipeline.iteratePipeline;
import static org.apache.uima.fit.pipeline.SimplePipeline.runPipeline;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.IOException;
@@ -36,32 +36,32 @@ import org.apache.uima.collection.CollectionReaderDescription;
import org.apache.uima.jcas.JCas;
import org.apache.uima.resource.ResourceInitializationException;
import org.apache.uima.util.Progress;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
public class CasMultiplierTest {
@Test
public void testRunPipeline() throws Exception {
CollectionReaderDescription reader = createReaderDescription(Reader.class);
-
+
AnalysisEngineDescription incrementor = createEngineDescription(TextIncrementor.class);
-
+
AnalysisEngineDescription consumer = createEngineDescription(Consumer.class);
-
+
runPipeline(reader, incrementor, incrementor, incrementor, consumer);
-
+
assertEquals(13, Consumer.textResult);
}
- @Ignore("UIMA-3470 not fixed yet")
+ @Disabled("UIMA-3470 not fixed yet")
@Test
public void testIteratePipelineOnText() throws Exception {
CollectionReaderDescription reader = createReaderDescription(Reader.class);
-
+
AnalysisEngineDescription incrementor = createEngineDescription(TextIncrementor.class);
-
+
AnalysisEngineDescription consumer = createEngineDescription(Consumer.class);
-
+
int expectedResult = 4;
for (JCas jcas : iteratePipeline(reader, incrementor, incrementor, incrementor, consumer)) {
assertEquals(expectedResult, Consumer.textResult);
@@ -73,11 +73,11 @@ public class CasMultiplierTest {
@Test
public void testIteratePipelineOnFeature() throws Exception {
CollectionReaderDescription reader = createReaderDescription(Reader.class);
-
+
AnalysisEngineDescription incrementor = createEngineDescription(FeatureIncrementor.class);
-
+
AnalysisEngineDescription consumer = createEngineDescription(Consumer.class);
-
+
int expectedResult = 4;
for (JCas jcas : iteratePipeline(reader, incrementor, incrementor, incrementor, consumer)) {
assertEquals(expectedResult, Consumer.featureResult);
@@ -86,16 +86,15 @@ public class CasMultiplierTest {
}
}
- public static class Reader extends CasCollectionReader_ImplBase
- {
+ public static class Reader extends CasCollectionReader_ImplBase {
private int generated = 0;
-
+
@Override
public void getNext(CAS aCAS) throws IOException, CollectionException {
generated++;
aCAS.setDocumentText(Integer.toString(generated));
aCAS.setDocumentLanguage(Integer.toString(generated));
-// System.out.printf("%nGenerated: %s%n", aCAS.getDocumentText());
+ // System.out.printf("%nGenerated: %s%n", aCAS.getDocumentText());
}
@Override
@@ -108,18 +107,17 @@ public class CasMultiplierTest {
return null;
}
}
-
+
/**
* Takes in a CAS, interprets its text as an integer, adds one to it, and creates a new CAS with
* the new value as text.
*/
- public static class TextIncrementor extends CasMultiplier_ImplBase
- {
+ public static class TextIncrementor extends CasMultiplier_ImplBase {
private boolean inputReceived = false;
private boolean outputCreated = false;
-
+
private int value = -1;
-
+
@Override
public boolean hasNext() throws AnalysisEngineProcessException {
return inputReceived && !outputCreated;
@@ -129,13 +127,13 @@ public class CasMultiplierTest {
public AbstractCas next() throws AnalysisEngineProcessException {
outputCreated = true;
inputReceived = false;
-
+
CAS output = getEmptyCAS();
- output.setDocumentText(Integer.toString(value+1));
+ output.setDocumentText(Integer.toString(value + 1));
value = -1;
-
-// System.out.printf(" Out : %s%n", output.getDocumentText());
-
+
+ // System.out.printf(" Out : %s%n", output.getDocumentText());
+
return output;
}
@@ -143,12 +141,12 @@ public class CasMultiplierTest {
public void process(CAS aCAS) throws AnalysisEngineProcessException {
outputCreated = false;
inputReceived = true;
-
+
value = Integer.valueOf(aCAS.getDocumentText());
-
-// System.out.printf(" In : %s%n", aCAS.getDocumentText());
+
+ // System.out.printf(" In : %s%n", aCAS.getDocumentText());
}
- }
+ }
/**
* Takes in a CAS, interprets its text as an integer, adds one to it, and creates a new CAS with
@@ -171,36 +169,34 @@ public class CasMultiplierTest {
@Override
public void process(CAS aCAS) throws AnalysisEngineProcessException {
int n = Integer.parseInt(aCAS.getDocumentLanguage());
-// System.out.printf(" In : %s%n", aCAS.getDocumentLanguage());
+ // System.out.printf(" In : %s%n", aCAS.getDocumentLanguage());
n++;
aCAS.setDocumentLanguage(Integer.toString(n));
-// System.out.printf(" Out : %s%n", aCAS.getDocumentLanguage());
+ // System.out.printf(" Out : %s%n", aCAS.getDocumentLanguage());
}
}
-
- public static class Consumer extends CasAnnotator_ImplBase
- {
+
+ public static class Consumer extends CasAnnotator_ImplBase {
public static int textResult = -1;
public static int featureResult = -1;
-
+
@Override
public void initialize(UimaContext aContext) throws ResourceInitializationException {
super.initialize(aContext);
textResult = -1;
featureResult = -1;
}
-
+
@Override
public void process(CAS aCAS) throws AnalysisEngineProcessException {
-// System.out.printf("Text result : %s%n", aCAS.getDocumentText());
+ // System.out.printf("Text result : %s%n", aCAS.getDocumentText());
textResult = Integer.valueOf(aCAS.getDocumentText());
-
-// System.out.printf("Feature result : %s%n", aCAS.getDocumentLanguage());
+
+ // System.out.printf("Feature result : %s%n", aCAS.getDocumentLanguage());
try {
featureResult = Integer.valueOf(aCAS.getDocumentLanguage());
- }
- catch (NumberFormatException e) {
+ } catch (NumberFormatException e) {
featureResult = -2;
}
}
diff --git a/uimafit-core/src/test/java/org/apache/uima/fit/component/JCasCollectionReader_ImplBaseTest.java b/uimafit-core/src/test/java/org/apache/uima/fit/component/JCasCollectionReader_ImplBaseTest.java
index 7e2a9cc..a961922 100644
--- a/uimafit-core/src/test/java/org/apache/uima/fit/component/JCasCollectionReader_ImplBaseTest.java
+++ b/uimafit-core/src/test/java/org/apache/uima/fit/component/JCasCollectionReader_ImplBaseTest.java
@@ -19,7 +19,7 @@
package org.apache.uima.fit.component;
import static org.apache.uima.fit.factory.CollectionReaderFactory.createReader;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.File;
import java.io.IOException;
@@ -33,7 +33,7 @@ import org.apache.uima.jcas.JCas;
import org.apache.uima.util.CasCreationUtils;
import org.apache.uima.util.Progress;
import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.junit.rules.TemporaryFolder;
/**
@@ -56,8 +56,8 @@ public class JCasCollectionReader_ImplBaseTest {
File file = folder.newFile("test.txt");
FileUtils.write(file, "Aaa Bbbb Cc Dddd eeee ff .", "UTF-8");
- CollectionReader reader = createReader(SingleTextReader.class,
- SingleTextReader.PARAM_FILE, file.getPath());
+ CollectionReader reader = createReader(SingleTextReader.class, SingleTextReader.PARAM_FILE,
+ file.getPath());
CAS cas = CasCreationUtils.createCas(reader.getProcessingResourceMetaData());
reader.getNext(cas);
diff --git a/uimafit-core/src/test/java/org/apache/uima/fit/component/ViewCreatorAnnotatorTest.java b/uimafit-core/src/test/java/org/apache/uima/fit/component/ViewCreatorAnnotatorTest.java
index 78e171d..58ac594 100644
--- a/uimafit-core/src/test/java/org/apache/uima/fit/component/ViewCreatorAnnotatorTest.java
+++ b/uimafit-core/src/test/java/org/apache/uima/fit/component/ViewCreatorAnnotatorTest.java
@@ -20,8 +20,8 @@ package org.apache.uima.fit.component;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.catchThrowable;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import org.apache.uima.analysis_engine.AnalysisEngine;
import org.apache.uima.analysis_engine.AnalysisEngineDescription;
@@ -37,7 +37,7 @@ import org.apache.uima.fit.type.Token;
import org.apache.uima.fit.util.JCasUtil;
import org.apache.uima.jcas.JCas;
import org.apache.uima.resource.ResourceInitializationException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* I initially thought that the behavior of mapping the default view to another yet-to-be-created
@@ -49,8 +49,8 @@ import org.junit.Test;
public class ViewCreatorAnnotatorTest extends ComponentTestBase {
@Test
- public void testViewCreatorAnnotator() throws ResourceInitializationException,
- AnalysisEngineProcessException, CASException {
+ public void testViewCreatorAnnotator()
+ throws ResourceInitializationException, AnalysisEngineProcessException, CASException {
AnalysisEngine viewCreator = AnalysisEngineFactory.createEngine(ViewCreatorAnnotator.class,
typeSystemDescription, ViewCreatorAnnotator.PARAM_VIEW_NAME, "myView");
viewCreator.process(jCas);
@@ -71,8 +71,7 @@ public class ViewCreatorAnnotatorTest extends ComponentTestBase {
engine.process(jCas);
assertEquals("some", JCasUtil.selectByIndex(jCas, Token.class, 0).getCoveredText());
- engine = AnalysisEngineFactory.createEngine(SofaUnawareAnnotator.class,
- typeSystemDescription);
+ engine = AnalysisEngineFactory.createEngine(SofaUnawareAnnotator.class, typeSystemDescription);
jCas.reset();
engine.process(jCas);
assertEquals("some", JCasUtil.selectByIndex(jCas, Token.class, 0).getCoveredText());
@@ -86,55 +85,51 @@ public class ViewCreatorAnnotatorTest extends ComponentTestBase {
@SuppressWarnings("javadoc")
@Test
public void testOtherViewAware() throws Exception {
- AnalysisEngineDescription description = AnalysisEngineFactory.createEngineDescription(
- SofaAwareAnnotator.class, typeSystemDescription);
+ AnalysisEngineDescription description = AnalysisEngineFactory
+ .createEngineDescription(SofaAwareAnnotator.class, typeSystemDescription);
AnalysisEngine engine = AnalysisEngineFactory.createEngine(description, "myView");
-
+
Throwable thrown = catchThrowable(() -> {
// Avoid exception being logged to the console
HideOutput hider = null;
try {
hider = new HideOutput();
engine.process(jCas);
- }
- finally {
+ } finally {
if (hider != null) {
hider.restoreOutput();
}
}
});
-
- assertThat(thrown)
- .as("Exception thrown when view does not exist")
- .hasRootCauseInstanceOf(CASRuntimeException.class)
- .hasStackTraceContaining("No sofaFS with name myView found");
+
+ assertThat(thrown).as("Exception thrown when view does not exist")
+ .hasRootCauseInstanceOf(CASRuntimeException.class)
+ .hasStackTraceContaining("No sofaFS with name myView found");
}
@Test
- public void testOtherViewUnaware() throws ResourceInitializationException,
- AnalysisEngineProcessException {
- AnalysisEngineDescription description = AnalysisEngineFactory.createEngineDescription(
- SofaUnawareAnnotator.class, typeSystemDescription);
+ public void testOtherViewUnaware()
+ throws ResourceInitializationException, AnalysisEngineProcessException {
+ AnalysisEngineDescription description = AnalysisEngineFactory
+ .createEngineDescription(SofaUnawareAnnotator.class, typeSystemDescription);
AnalysisEngine engine = AnalysisEngineFactory.createEngine(description, "myView");
-
+
Throwable thrown = catchThrowable(() -> {
// Avoid exception being logged to the console
HideOutput hider = null;
try {
hider = new HideOutput();
engine.process(jCas);
- }
- finally {
+ } finally {
if (hider != null) {
hider.restoreOutput();
}
}
});
-
- assertThat(thrown)
- .as("Exception thrown when view does not exist")
- .hasRootCauseInstanceOf(CASRuntimeException.class)
- .hasStackTraceContaining("No sofaFS with name myView found");
+
+ assertThat(thrown).as("Exception thrown when view does not exist")
+ .hasRootCauseInstanceOf(CASRuntimeException.class)
+ .hasStackTraceContaining("No sofaFS with name myView found");
}
@@ -145,15 +140,15 @@ public class ViewCreatorAnnotatorTest extends ComponentTestBase {
@SuppressWarnings("javadoc")
@Test
public void testSofaInitializer() throws Exception {
- AnalysisEngineDescription description = AnalysisEngineFactory.createEngineDescription(
- SofaAwareAnnotator.class, typeSystemDescription);
+ AnalysisEngineDescription description = AnalysisEngineFactory
+ .createEngineDescription(SofaAwareAnnotator.class, typeSystemDescription);
AnalysisEngine engine = AnalysisEngineFactory.createEngine(description, "myView");
AnalysisEngine viewCreator = AnalysisEngineFactory.createEngine(ViewCreatorAnnotator.class,
typeSystemDescription, ViewCreatorAnnotator.PARAM_VIEW_NAME, "myView");
viewCreator.process(jCas);
engine.process(jCas);
- assertEquals("some", JCasUtil.selectByIndex(jCas.getView("myView"), Token.class, 0)
- .getCoveredText());
+ assertEquals("some",
+ JCasUtil.selectByIndex(jCas.getView("myView"), Token.class, 0).getCoveredText());
// here I run again with viewCreator running twice to make sure it
// does the right thing when the view
@@ -162,8 +157,8 @@ public class ViewCreatorAnnotatorTest extends ComponentTestBase {
viewCreator.process(jCas);
viewCreator.process(jCas);
engine.process(jCas);
- assertEquals("some", JCasUtil.selectByIndex(jCas.getView("myView"), Token.class, 0)
- .getCoveredText());
+ assertEquals("some",
+ JCasUtil.selectByIndex(jCas.getView("myView"), Token.class, 0).getCoveredText());
description = AnalysisEngineFactory.createEngineDescription(SofaUnawareAnnotator.class,
typeSystemDescription);
@@ -171,15 +166,15 @@ public class ViewCreatorAnnotatorTest extends ComponentTestBase {
jCas.reset();
viewCreator.process(jCas);
engine.process(jCas);
- assertEquals("some", JCasUtil.selectByIndex(jCas.getView("myView"), Token.class, 0)
- .getCoveredText());
+ assertEquals("some",
+ JCasUtil.selectByIndex(jCas.getView("myView"), Token.class, 0).getCoveredText());
jCas.reset();
viewCreator.process(jCas);
viewCreator.process(jCas);
engine.process(jCas);
- assertEquals("some", JCasUtil.selectByIndex(jCas.getView("myView"), Token.class, 0)
- .getCoveredText());
+ assertEquals("some",
+ JCasUtil.selectByIndex(jCas.getView("myView"), Token.class, 0).getCoveredText());
}
@SofaCapability(inputSofas = CAS.NAME_DEFAULT_SOFA)
diff --git a/uimafit-core/src/test/java/org/apache/uima/fit/component/ViewTextCopierAnnotatorTest.java b/uimafit-core/src/test/java/org/apache/uima/fit/component/ViewTextCopierAnnotatorTest.java
index e487565..45582dd 100644
--- a/uimafit-core/src/test/java/org/apache/uima/fit/component/ViewTextCopierAnnotatorTest.java
+++ b/uimafit-core/src/test/java/org/apache/uima/fit/component/ViewTextCopierAnnotatorTest.java
@@ -20,9 +20,9 @@ package org.apache.uima.fit.component;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.catchThrowable;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import org.apache.uima.analysis_engine.AnalysisEngine;
import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
@@ -34,7 +34,7 @@ import org.apache.uima.fit.factory.AnalysisEngineFactory;
import org.apache.uima.fit.testing.util.HideOutput;
import org.apache.uima.jcas.JCas;
import org.apache.uima.resource.ResourceInitializationException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
@@ -42,18 +42,18 @@ import org.junit.Test;
public class ViewTextCopierAnnotatorTest extends ComponentTestBase {
@Test
- public void testViewTextCopier() throws ResourceInitializationException,
- AnalysisEngineProcessException, CASException {
+ public void testViewTextCopier()
+ throws ResourceInitializationException, AnalysisEngineProcessException, CASException {
String text = "sample text";
String sourceViewName = "SourceView";
String destinationViewName = "DestinationView";
jCas.setDocumentText(text);
- AnalysisEngine viewCreator = AnalysisEngineFactory.createEngine(
- ViewTextCopierAnnotator.class, typeSystemDescription,
- ViewTextCopierAnnotator.PARAM_SOURCE_VIEW_NAME, CAS.NAME_DEFAULT_SOFA,
- ViewTextCopierAnnotator.PARAM_DESTINATION_VIEW_NAME, destinationViewName);
+ AnalysisEngine viewCreator = AnalysisEngineFactory.createEngine(ViewTextCopierAnnotator.class,
+ typeSystemDescription, ViewTextCopierAnnotator.PARAM_SOURCE_VIEW_NAME,
+ CAS.NAME_DEFAULT_SOFA, ViewTextCopierAnnotator.PARAM_DESTINATION_VIEW_NAME,
+ destinationViewName);
viewCreator.process(jCas);
JCas destinationView = jCas.getView(destinationViewName);
assertNotNull(destinationView);
@@ -81,34 +81,31 @@ public class ViewTextCopierAnnotatorTest extends ComponentTestBase {
}
@Test
- public void testExceptions() throws ResourceInitializationException,
- AnalysisEngineProcessException {
+ public void testExceptions()
+ throws ResourceInitializationException, AnalysisEngineProcessException {
String sourceViewName = "SourceView";
String destinationViewName = "DestinationView";
- AnalysisEngine viewCreator = AnalysisEngineFactory.createEngine(
- ViewTextCopierAnnotator.class, typeSystemDescription,
- ViewTextCopierAnnotator.PARAM_SOURCE_VIEW_NAME, sourceViewName,
+ AnalysisEngine viewCreator = AnalysisEngineFactory.createEngine(ViewTextCopierAnnotator.class,
+ typeSystemDescription, ViewTextCopierAnnotator.PARAM_SOURCE_VIEW_NAME, sourceViewName,
ViewTextCopierAnnotator.PARAM_DESTINATION_VIEW_NAME, destinationViewName);
-
+
Throwable thrown = catchThrowable(() -> {
// Avoid exception being logged to the console
HideOutput hider = null;
try {
hider = new HideOutput();
- viewCreator.process(jCas);
- }
- finally {
+ viewCreator.process(jCas);
+ } finally {
if (hider != null) {
hider.restoreOutput();
}
}
});
-
- assertThat(thrown)
- .as("Exception thrown when source view does not exist")
- .hasRootCauseInstanceOf(CASRuntimeException.class)
- .hasStackTraceContaining("No sofaFS with name SourceView found");
+
+ assertThat(thrown).as("Exception thrown when source view does not exist")
+ .hasRootCauseInstanceOf(CASRuntimeException.class)
+ .hasStackTraceContaining("No sofaFS with name SourceView found");
}
}
diff --git a/uimafit-core/src/test/java/org/apache/uima/fit/component/initialize/ConfigurationParameterInitializerTest.java b/uimafit-core/src/test/java/org/apache/uima/fit/component/initialize/ConfigurationParameterInitializerTest.java
index fc7d86d..bdabe1f 100644
--- a/uimafit-core/src/test/java/org/apache/uima/fit/component/initialize/ConfigurationParameterInitializerTest.java
+++ b/uimafit-core/src/test/java/org/apache/uima/fit/component/initialize/ConfigurationParameterInitializerTest.java
@@ -26,12 +26,13 @@ import static java.util.regex.Pattern.compile;
import static org.apache.commons.collections4.SetUtils.unmodifiableSet;
import static org.apache.uima.fit.component.initialize.ConfigurationParameterInitializer.initialize;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.awt.Point;
import java.io.File;
@@ -63,159 +64,163 @@ import org.apache.uima.fit.factory.testAes.ParameterizedAE.EnumValue;
import org.apache.uima.jcas.JCas;
import org.apache.uima.resource.ResourceInitializationException;
import org.apache.uima.resource.metadata.impl.ConfigurationParameterSettings_impl;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.xml.sax.SAXException;
public class ConfigurationParameterInitializerTest extends ComponentTestBase {
public static class PrimitiveTypesInjection {
private @ConfigurationParameter int intValue;
+
private @ConfigurationParameter boolean booleanValue;
+
private @ConfigurationParameter String stringValue;
+
private @ConfigurationParameter float floatValue;
+
private @ConfigurationParameter double doubleValue;
}
-
+
@Test
public void thatPrimitiveTypesCanBeInjected() throws Exception {
PrimitiveTypesInjection target = new PrimitiveTypesInjection();
-
- initialize(target,
- "intValue", 1,
- "booleanValue", true,
- "stringValue", "test",
- "floatValue", 1.234f,
- "doubleValue", 1.234d);
-
+
+ initialize(target, "intValue", 1, "booleanValue", true, "stringValue", "test", "floatValue",
+ 1.234f, "doubleValue", 1.234d);
+
assertThat(target.intValue).isEqualTo(1);
assertThat(target.booleanValue).isEqualTo(true);
assertThat(target.stringValue).isEqualTo("test");
assertThat(target.floatValue).isEqualTo(1.234f);
assertThat(target.doubleValue).isEqualTo(1.234d);
}
-
+
public static class PrimitiveArraysInjection {
private @ConfigurationParameter int[] intValues;
+
private @ConfigurationParameter boolean[] booleanValues;
+
private @ConfigurationParameter String[] stringValues;
+
private @ConfigurationParameter float[] floatValues;
+
private @ConfigurationParameter double[] doubleValues;
}
-
+
@Test
public void thatPrimitiveArraysCanBeInjected() throws Exception {
PrimitiveArraysInjection target = new PrimitiveArraysInjection();
-
- initialize(target,
- "intValues", new int[] {1, 2, 3},
- "booleanValues", new boolean[] {true, false, true},
- "stringValues", new String[] { "test1", "test2", "test3" },
- "floatValues", new float[] { 1.234f, 2.468f, 3.456f },
- "doubleValues", new double[] { 1.234d, 2.468d, 3.456d });
-
- assertThat(target.intValues).containsExactly(1,2,3);
+
+ initialize(target, "intValues", new int[] { 1, 2, 3 }, "booleanValues",
+ new boolean[] { true, false, true }, "stringValues",
+ new String[] { "test1", "test2", "test3" }, "floatValues",
+ new float[] { 1.234f, 2.468f, 3.456f }, "doubleValues",
+ new double[] { 1.234d, 2.468d, 3.456d });
+
+ assertThat(target.intValues).containsExactly(1, 2, 3);
assertThat(target.booleanValues).containsExactly(true, false, true);
assertThat(target.stringValues).containsExactly("test1", "test2", "test3");
assertThat(target.floatValues).containsExactly(1.234f, 2.468f, 3.456f);
assertThat(target.doubleValues).containsExactly(1.234d, 2.468d, 3.456d);
}
-
+
@Test
public void thatPrimitiveArraysCanBeInjectedAsLists() throws Exception {
PrimitiveArraysInjection target = new PrimitiveArraysInjection();
-
- initialize(target,
- "intValues", asList(1, 2, 3),
- "booleanValues", asList(true, false, true),
- "stringValues", asList("test1", "test2", "test3"),
- "floatValues", asList(1.234f, 2.468f, 3.456f),
- "doubleValues", asList(1.234d, 2.468d, 3.456d));
-
- assertThat(target.intValues).containsExactly(1,2,3);
+
+ initialize(target, "intValues", asList(1, 2, 3), "booleanValues", asList(true, false, true),
+ "stringValues", asList("test1", "test2", "test3"), "floatValues",
+ asList(1.234f, 2.468f, 3.456f), "doubleValues", asList(1.234d, 2.468d, 3.456d));
+
+ assertThat(target.intValues).containsExactly(1, 2, 3);
assertThat(target.booleanValues).containsExactly(true, false, true);
assertThat(target.stringValues).containsExactly("test1", "test2", "test3");
assertThat(target.floatValues).containsExactly(1.234f, 2.468f, 3.456f);
assertThat(target.doubleValues).containsExactly(1.234d, 2.468d, 3.456d);
}
-
+
@Test
public void thatPrimitiveArraysCanBeInjectedAsValues() throws Exception {
PrimitiveArraysInjection target = new PrimitiveArraysInjection();
-
- initialize(target,
- "intValues", 1,
- "booleanValues", true,
- "stringValues", "test",
- "floatValues", 1.234f,
- "doubleValues", 1.234d);
-
+
+ initialize(target, "intValues", 1, "booleanValues", true, "stringValues", "test", "floatValues",
+ 1.234f, "doubleValues", 1.234d);
+
assertThat(target.intValues).containsExactly(1);
assertThat(target.booleanValues).containsExactly(true);
assertThat(target.stringValues).containsExactly("test");
assertThat(target.floatValues).containsExactly(1.234f);
assertThat(target.doubleValues).containsExactly(1.234d);
}
-
+
public static class FileInjection {
private @ConfigurationParameter File file;
+
private @ConfigurationParameter File fileFromString;
+
private @ConfigurationParameter File[] fileArray;
+
private @ConfigurationParameter File[] fileArrayFromString;
+
private @ConfigurationParameter List<File> fileList;
+
private @ConfigurationParameter List<File> fileFromStringList;
+
private @ConfigurationParameter Set<File> fileSet;
}
-
+
@Test
public void thatFileObjectCanBeInjected() throws Exception {
FileInjection target = new FileInjection();
-
- initialize(target,
- "file", new File("test"),
- "fileFromString", "test",
- "fileArray", new File[] {new File("test1"), new File("test2") },
- "fileArrayFromString", new String[] {"test1", "test2"},
- "fileList", asList(new File("test1"), new File("test2")),
- "fileSet", unmodifiableSet(new File("test1"), new File("test2")),
- "fileFromStringList", asList("test1", "test2"));
-
+
+ initialize(target, "file", new File("test"), "fileFromString", "test", "fileArray",
+ new File[] { new File("test1"), new File("test2") }, "fileArrayFromString",
+ new String[] { "test1", "test2" }, "fileList",
+ asList(new File("test1"), new File("test2")), "fileSet",
+ unmodifiableSet(new File("test1"), new File("test2")), "fileFromStringList",
+ asList("test1", "test2"));
+
assertThat(target.file).hasName("test");
assertThat(target.fileFromString).hasName("test");
assertThat(target.fileArray).extracting(File::getName).containsExactly("test1", "test2");
assertThat(target.fileArrayFromString).extracting(File::getName).containsExactly("test1",
"test2");
assertThat(target.fileList).extracting(File::getName).containsExactly("test1", "test2");
- assertThat(target.fileFromStringList).extracting(File::getName).containsExactly(
- "test1", "test2");
- assertThat(target.fileSet).extracting(File::getName).containsExactlyInAnyOrder(
- "test1", "test2");
+ assertThat(target.fileFromStringList).extracting(File::getName).containsExactly("test1",
+ "test2");
+ assertThat(target.fileSet).extracting(File::getName).containsExactlyInAnyOrder("test1",
+ "test2");
}
-
+
public static class ClassInjection {
private @ConfigurationParameter Class<?> clazz;
+
private @ConfigurationParameter Class<?> clazzFromString;
+
private @ConfigurationParameter Class<?>[] clazzArray;
+
private @ConfigurationParameter Class<?>[] clazzArrayFromString;
+
private @ConfigurationParameter List<Class<?>> clazzList;
+
private @ConfigurationParameter List<Class<?>> clazzListFromString;
+
private @ConfigurationParameter Set<Class<?>> clazzSet;
}
-
+
@Test
public void thatClassObjectCanBeInjected() throws Exception {
ClassInjection target = new ClassInjection();
-
- initialize(target,
- "clazz", Integer.class,
- "clazzFromString", Integer.class.getName(),
+
+ initialize(target, "clazz", Integer.class, "clazzFromString", Integer.class.getName(),
"clazzArray", new Class<?>[] { Integer.class, Boolean.class, Float.class },
- "clazzArrayFromString", new String[] { Integer.class.getName(), Boolean.class.getName(),
- Float.class.getName() },
- "clazzList", asList(Integer.class, Boolean.class, Float.class),
- "clazzListFromString", asList(Integer.class.getName(), Boolean.class.getName(),
- Float.class.getName()),
+ "clazzArrayFromString",
+ new String[] { Integer.class.getName(), Boolean.class.getName(),
+ Float.class.getName() },
+ "clazzList", asList(Integer.class, Boolean.class, Float.class), "clazzListFromString",
+ asList(Integer.class.getName(), Boolean.class.getName(), Float.class.getName()),
"clazzSet", unmodifiableSet(Integer.class, Boolean.class, Float.class));
-
+
assertThat(target.clazz).isEqualTo(Integer.class);
assertThat(target.clazzFromString).isEqualTo(Integer.class);
assertThat(target.clazzArray).containsExactly(Integer.class, Boolean.class, Float.class);
@@ -227,108 +232,116 @@ public class ConfigurationParameterInitializerTest extends ComponentTestBase {
assertThat(target.clazzSet).containsExactlyInAnyOrder(Integer.class, Boolean.class,
Float.class);
}
-
+
public static class URIInjection {
private @ConfigurationParameter URI uri;
+
private @ConfigurationParameter URI uriFromString;
+
private @ConfigurationParameter URI[] uriArray;
+
private @ConfigurationParameter URI[] uriArrayFromString;
+
private @ConfigurationParameter List<URI> uriList;
+
private @ConfigurationParameter List<URI> uriListFromString;
+
private @ConfigurationParameter Set<URI> uriSet;
}
-
+
@Test
public void thatURICanBeInjected() throws Exception {
URIInjection target = new URIInjection();
-
- initialize(target,
- "uri", URI.create("file:test"),
- "uriFromString", "file:test",
- "uriArray", new URI[] { URI.create("file:test1"), URI.create("file:test2"),
- URI.create("file:test3") },
+
+ initialize(target, "uri", URI.create("file:test"), "uriFromString", "file:test", "uriArray",
+ new URI[] { URI.create("file:test1"), URI.create("file:test2"),
+ URI.create("file:test3") },
"uriArrayFromString", new String[] { "file:test1", "file:test2", "file:test3" },
- "uriList", asList(URI.create("file:test1"), URI.create("file:test2"),
- URI.create("file:test3")),
- "uriListFromString", asList("file:test1", "file:test2", "file:test3"),
- "uriSet", unmodifiableSet(URI.create("file:test1"), URI.create("file:test2"),
+ "uriList",
+ asList(URI.create("file:test1"), URI.create("file:test2"), URI.create("file:test3")),
+ "uriListFromString", asList("file:test1", "file:test2", "file:test3"), "uriSet",
+ unmodifiableSet(URI.create("file:test1"), URI.create("file:test2"),
URI.create("file:test3")));
-
+
assertThat(target.uri).isEqualTo(URI.create("file:test"));
assertThat(target.uriFromString).isEqualTo(URI.create("file:test"));
- assertThat(target.uriArray).containsExactly(URI.create("file:test1"), URI.create("file:test2"),
+ assertThat(target.uriArray).containsExactly(URI.create("file:test1"), URI.create("file:test2"),
URI.create("file:test3"));
- assertThat(target.uriArrayFromString).containsExactly(URI.create("file:test1"),
+ assertThat(target.uriArrayFromString).containsExactly(URI.create("file:test1"),
URI.create("file:test2"), URI.create("file:test3"));
- assertThat(target.uriList).containsExactly(URI.create("file:test1"), URI.create("file:test2"),
+ assertThat(target.uriList).containsExactly(URI.create("file:test1"), URI.create("file:test2"),
URI.create("file:test3"));
- assertThat(target.uriListFromString).containsExactly(URI.create("file:test1"),
+ assertThat(target.uriListFromString).containsExactly(URI.create("file:test1"),
URI.create("file:test2"), URI.create("file:test3"));
- assertThat(target.uriSet).containsExactlyInAnyOrder(URI.create("file:test1"),
+ assertThat(target.uriSet).containsExactlyInAnyOrder(URI.create("file:test1"),
URI.create("file:test2"), URI.create("file:test3"));
}
-
+
public static class URLInjection {
private @ConfigurationParameter URL URL;
+
private @ConfigurationParameter URL URLFromString;
+
private @ConfigurationParameter URL[] URLArray;
+
private @ConfigurationParameter URL[] URLArrayFromString;
+
private @ConfigurationParameter List<URL> URLList;
+
private @ConfigurationParameter List<URL> URLListFromString;
+
private @ConfigurationParameter Set<URL> URLSet;
}
-
+
@Test
public void thatURLCanBeInjected() throws Exception {
URLInjection target = new URLInjection();
-
- initialize(target,
- "URL", new URL("file:test"),
- "URLFromString", "file:test",
- "URLArray", new URL[] { new URL("file:test1"), new URL("file:test2"),
- new URL("file:test3") },
+
+ initialize(target, "URL", new URL("file:test"), "URLFromString", "file:test", "URLArray",
+ new URL[] { new URL("file:test1"), new URL("file:test2"), new URL("file:test3") },
"URLArrayFromString", new String[] { "file:test1", "file:test2", "file:test3" },
- "URLList", asList(new URL("file:test1"), new URL("file:test2"),
- new URL("file:test3")),
- "URLListFromString", asList("file:test1", "file:test2", "file:test3"),
- "URLSet", unmodifiableSet(new URL("file:test1"), new URL("file:test2"),
- new URL("file:test3")));
-
+ "URLList", asList(new URL("file:test1"), new URL("file:test2"), new URL("file:test3")),
+ "URLListFromString", asList("file:test1", "file:test2", "file:test3"), "URLSet",
+ unmodifiableSet(new URL("file:test1"), new URL("file:test2"), new URL("file:test3")));
+
assertThat(target.URL).isEqualTo(new URL("file:test"));
assertThat(target.URLFromString).isEqualTo(new URL("file:test"));
- assertThat(target.URLArray).containsExactly(new URL("file:test1"), new URL("file:test2"),
+ assertThat(target.URLArray).containsExactly(new URL("file:test1"), new URL("file:test2"),
new URL("file:test3"));
- assertThat(target.URLArrayFromString).containsExactly(new URL("file:test1"),
+ assertThat(target.URLArrayFromString).containsExactly(new URL("file:test1"),
new URL("file:test2"), new URL("file:test3"));
- assertThat(target.URLList).containsExactly(new URL("file:test1"), new URL("file:test2"),
+ assertThat(target.URLList).containsExactly(new URL("file:test1"), new URL("file:test2"),
new URL("file:test3"));
- assertThat(target.URLListFromString).containsExactly(new URL("file:test1"),
+ assertThat(target.URLListFromString).containsExactly(new URL("file:test1"),
new URL("file:test2"), new URL("file:test3"));
- assertThat(target.URLSet).containsExactlyInAnyOrder(new URL("file:test1"),
+ assertThat(target.URLSet).containsExactlyInAnyOrder(new URL("file:test1"),
new URL("file:test2"), new URL("file:test3"));
}
-
+
public static class PatternInjection {
private @ConfigurationParameter Pattern pattern;
+
private @ConfigurationParameter Pattern patternFromString;
+
private @ConfigurationParameter Pattern[] patternArray;
+
private @ConfigurationParameter Pattern[] patternArrayFromString;
+
private @ConfigurationParameter List<Pattern> patternList;
+
private @ConfigurationParameter List<Pattern> patternListFromString;
}
-
+
@Test
public void thatPatternCanBeInjected() throws Exception {
PatternInjection target = new PatternInjection();
-
- initialize(target,
- "pattern", compile("^test$"),
- "patternFromString", "^test$",
- "patternArray", new Pattern[] { compile("test1"), compile("test2"), compile("test3") },
- "patternArrayFromString", new String[] { "test1", "test2", "test3" },
- "patternList", asList(compile("test1"), compile("test2"), compile("test3")),
- "patternListFromString", asList("test1", "test2", "test3"));
-
+
+ initialize(target, "pattern", compile("^test$"), "patternFromString", "^test$", "patternArray",
+ new Pattern[] { compile("test1"), compile("test2"), compile("test3") },
+ "patternArrayFromString", new String[] { "test1", "test2", "test3" }, "patternList",
+ asList(compile("test1"), compile("test2"), compile("test3")), "patternListFromString",
+ asList("test1", "test2", "test3"));
+
assertThat(target.pattern).matches(p -> p.matcher("test").matches());
assertThat(target.patternFromString).matches(p -> p.matcher("test").matches());
assertThat(target.patternArray).hasSize(3);
@@ -347,39 +360,44 @@ public class ConfigurationParameterInitializerTest extends ComponentTestBase {
assertThat(target.patternListFromString.get(0)).matches(p -> p.matcher("test1").matches());
assertThat(target.patternListFromString.get(1)).matches(p -> p.matcher("test2").matches());
assertThat(target.patternListFromString.get(2)).matches(p -> p.matcher("test3").matches());
- }
+ }
public static class CharsetInjection {
private @ConfigurationParameter Charset charset;
+
private @ConfigurationParameter String charsetAsString;
+
private @ConfigurationParameter Charset charsetFromString;
+
private @ConfigurationParameter Charset[] charsetArray;
+
private @ConfigurationParameter String[] charsetsAsStringArray;
+
private @ConfigurationParameter Charset[] charsetArrayFromString;
+
private @ConfigurationParameter List<Charset> charsetList;
+
private @ConfigurationParameter List<String> charsetAsStringList;
+
private @ConfigurationParameter List<Charset> charsetListFromString;
+
private @ConfigurationParameter Set<Charset> charsetSet;
}
-
+
@Test
public void thatCharsetCanBeInjected() throws Exception {
CharsetInjection target = new CharsetInjection();
-
- initialize(target,
- "charset", UTF_8,
- "charsetAsString", UTF_8,
- "charsetFromString", UTF_8.toString(),
- "charsetArray", new Charset[] { UTF_8, UTF_16, US_ASCII },
+
+ initialize(target, "charset", UTF_8, "charsetAsString", UTF_8, "charsetFromString",
+ UTF_8.toString(), "charsetArray", new Charset[] { UTF_8, UTF_16, US_ASCII },
"charsetsAsStringArray", new Charset[] { UTF_8, UTF_16, US_ASCII },
- "charsetArrayFromString", new String[] { UTF_8.toString(), UTF_16.toString(),
- US_ASCII.toString() },
- "charsetList", asList(UTF_8, UTF_16, US_ASCII),
- "charsetAsStringList", asList(UTF_8, UTF_16, US_ASCII),
- "charsetListFromString", asList(UTF_8.toString(), UTF_16.toString(),
- US_ASCII.toString()),
- "charsetSet", unmodifiableSet(UTF_8, UTF_16, US_ASCII));
-
+ "charsetArrayFromString",
+ new String[] { UTF_8.toString(), UTF_16.toString(), US_ASCII.toString() },
+ "charsetList", asList(UTF_8, UTF_16, US_ASCII), "charsetAsStringList",
+ asList(UTF_8, UTF_16, US_ASCII), "charsetListFromString",
+ asList(UTF_8.toString(), UTF_16.toString(), US_ASCII.toString()), "charsetSet",
+ unmodifiableSet(UTF_8, UTF_16, US_ASCII));
+
assertThat(target.charset).isEqualTo(UTF_8);
assertThat(target.charsetAsString).isEqualTo(UTF_8.toString());
assertThat(target.charsetFromString).isEqualTo(UTF_8);
@@ -394,47 +412,43 @@ public class ConfigurationParameterInitializerTest extends ComponentTestBase {
assertThat(target.charsetSet).containsExactlyInAnyOrder(UTF_8, UTF_16, US_ASCII);
}
-
private static class CustomClassWithStringConstructor {
private String value;
-
+
public CustomClassWithStringConstructor(String aValue) {
value = aValue;
}
-
+
public String getValue() {
return value;
}
}
-
+
public static class CustomClassWithStringConstructorInjection {
private @ConfigurationParameter CustomClassWithStringConstructor customFromString;
+
private @ConfigurationParameter CustomClassWithStringConstructor[] customArrayFromString;
+
private @ConfigurationParameter List<CustomClassWithStringConstructor> customListFromString;
}
-
+
@Test
public void thatCustomClassWithStringConstructorObjectCanBeInjected() throws Exception {
- CustomClassWithStringConstructorInjection target =
- new CustomClassWithStringConstructorInjection();
-
- initialize(target,
- "customFromString", "test",
- "customArrayFromString", new String[] { "test1", "test2", "test3" },
- "customListFromString", asList("test1", "test2", "test3"));
-
- assertThat(target.customFromString)
- .extracting(CustomClassWithStringConstructor::getValue)
+ CustomClassWithStringConstructorInjection target = new CustomClassWithStringConstructorInjection();
+
+ initialize(target, "customFromString", "test", "customArrayFromString",
+ new String[] { "test1", "test2", "test3" }, "customListFromString",
+ asList("test1", "test2", "test3"));
+
+ assertThat(target.customFromString).extracting(CustomClassWithStringConstructor::getValue)
.isEqualTo("test");
- assertThat(target.customArrayFromString)
- .extracting(CustomClassWithStringConstructor::getValue)
+ assertThat(target.customArrayFromString).extracting(CustomClassWithStringConstructor::getValue)
.containsExactly("test1", "test2", "test3");
- assertThat(target.customListFromString)
- .extracting(CustomClassWithStringConstructor::getValue)
+ assertThat(target.customListFromString).extracting(CustomClassWithStringConstructor::getValue)
.containsExactly("test1", "test2", "test3");
}
-
+
// --- Legacy unit tests below ---
@Test
@@ -451,8 +465,8 @@ public class ConfigurationParameterInitializerTest extends ComponentTestBase {
typeSystemDescription, ParameterizedAE.PARAM_FLOAT_3, 1.234f,
ParameterizedAE.PARAM_FLOAT_6, new Float[] { 1.234f, 0.001f }, "file2", "foo/bar",
"files9", new File[] { new File("test/data/file"), new File("test/data/file2") },
- ParameterizedAE.PARAM_STRING_9, "singleelementarray",
- "files10", new File("test/data/file"), "booleans8", true);
+ ParameterizedAE.PARAM_STRING_9, "singleelementarray", "files10",
+ new File("test/data/file"), "booleans8", true);
ParameterizedAE component = new ParameterizedAE();
component.initialize(engine.getUimaContext());
@@ -545,27 +559,27 @@ public class ConfigurationParameterInitializerTest extends ComponentTestBase {
assertEquals(new File("test/data/file"), component.getFiles9().get(0));
assertEquals(new File("test/data/file2"), component.getFiles9().get(1));
assertEquals(new File("test/data/file"), component.getFiles10().get(0));
-
+
assertNull(component.getRegex1());
assertTrue(component.getRegex2().matcher("This is uimaFIT calling!").matches());
engine = AnalysisEngineFactory.createEngine(ParameterizedAE.class, typeSystemDescription,
- ParameterizedAE.PARAM_FLOAT_3, 1.234f, ParameterizedAE.PARAM_FLOAT_6, new Float[] {
- 1.234f, 0.001f }, ParameterizedAE.PARAM_STRING_1, "lime",
+ ParameterizedAE.PARAM_FLOAT_3, 1.234f, ParameterizedAE.PARAM_FLOAT_6,
+ new Float[] { 1.234f, 0.001f }, ParameterizedAE.PARAM_STRING_1, "lime",
ParameterizedAE.PARAM_STRING_2, new String[] { "banana", "strawberry" },
- ParameterizedAE.PARAM_STRING_3, "cherry", ParameterizedAE.PARAM_STRING_4, new String[] {
- "raspberry", "blueberry", "blackberry" }, ParameterizedAE.PARAM_STRING_5,
+ ParameterizedAE.PARAM_STRING_3, "cherry", ParameterizedAE.PARAM_STRING_4,
+ new String[] { "raspberry", "blueberry", "blackberry" }, ParameterizedAE.PARAM_STRING_5,
new String[] { "a" }, ParameterizedAE.PARAM_BOOLEAN_1, true,
- ParameterizedAE.PARAM_BOOLEAN_2, true, ParameterizedAE.PARAM_BOOLEAN_3, new boolean[] {
- true, true, false }, ParameterizedAE.PARAM_BOOLEAN_4, new Boolean[] { true, false,
- false }, ParameterizedAE.PARAM_BOOLEAN_5, new Boolean[] { true },
- ParameterizedAE.PARAM_INT_1, 0, ParameterizedAE.PARAM_INT_2, 24,
+ ParameterizedAE.PARAM_BOOLEAN_2, true, ParameterizedAE.PARAM_BOOLEAN_3,
+ new boolean[] { true, true, false }, ParameterizedAE.PARAM_BOOLEAN_4,
+ new Boolean[] { true, false, false }, ParameterizedAE.PARAM_BOOLEAN_5,
+ new Boolean[] { true }, ParameterizedAE.PARAM_INT_1, 0, ParameterizedAE.PARAM_INT_2, 24,
ParameterizedAE.PARAM_INT_3, new int[] { 5 }, "file1", "foo1/bar1", "file1b",
- "foo1b/bar1b", "file2", "foo2/bar2", "files3", new String[] {
- "C:\\Documents and Settings\\Philip\\My Documents\\", "/usr/local/bin" }, "files4",
- new String[0], "files5", new String[] { "foos/bars" }, "files6", new String[] {
- "C:\\Documents and Settings\\Philip\\My Documents\\", "/usr/local/bin" }, "files7",
- new String[0], "files8", new String[] { "foos/bars" }, "files9",
+ "foo1b/bar1b", "file2", "foo2/bar2", "files3",
+ new String[] { "C:\\Documents and Settings\\Philip\\My Documents\\", "/usr/local/bin" },
+ "files4", new String[0], "files5", new String[] { "foos/bars" }, "files6",
+ new String[] { "C:\\Documents and Settings\\Philip\\My Documents\\", "/usr/local/bin" },
+ "files7", new String[0], "files8", new String[] { "foos/bars" }, "files9",
Arrays.asList(new File("test/data/file"), new File("test/data/file2")));
component = new ParameterizedAE();
component.initialize(engine.getUimaContext());
@@ -596,8 +610,8 @@ public class ConfigurationParameterInitializerTest extends ComponentTestBase {
assertEquals(0, component.getFiles4().length);
assertArrayEquals(new File[] { new File("foos/bars") }, component.getFiles5());
assertEquals(2, component.getFiles6().size());
- assertEquals(new File("C:\\Documents and Settings\\Philip\\My Documents\\"), component
- .getFiles6().get(0));
+ assertEquals(new File("C:\\Documents and Settings\\Philip\\My Documents\\"),
+ component.getFiles6().get(0));
assertEquals(new File("/usr/local/bin"), component.getFiles6().get(1));
assertEquals(0, component.getFiles7().size());
assertEquals(1, component.getFiles8().size());
@@ -607,8 +621,8 @@ public class ConfigurationParameterInitializerTest extends ComponentTestBase {
assertEquals(new File("test/data/file2"), component.getFiles9().get(1));
engine = AnalysisEngineFactory.createEngine(ParameterizedAE.class, typeSystemDescription,
- ParameterizedAE.PARAM_FLOAT_3, 1.234f, ParameterizedAE.PARAM_FLOAT_6, new Float[] {
- 1.234f, 0.001f }, ParameterizedAE.PARAM_BOOLEAN_1, true,
+ ParameterizedAE.PARAM_FLOAT_3, 1.234f, ParameterizedAE.PARAM_FLOAT_6,
+ new Float[] { 1.234f, 0.001f }, ParameterizedAE.PARAM_BOOLEAN_1, true,
ParameterizedAE.PARAM_BOOLEAN_3, new boolean[3], ParameterizedAE.PARAM_FLOAT_5,
new float[] { 1.2f, 3.4f }, "file2", "foo2/bar2");
component = new ParameterizedAE();
@@ -622,8 +636,8 @@ public class ConfigurationParameterInitializerTest extends ComponentTestBase {
rie = null;
try {
engine = AnalysisEngineFactory.createEngine(ParameterizedAE.class, typeSystemDescription,
- ParameterizedAE.PARAM_FLOAT_3, 1.234f, ParameterizedAE.PARAM_FLOAT_6, new Float[] {
- 1.234f, 0.001f }, ParameterizedAE.PARAM_STRING_1, true);
+ ParameterizedAE.PARAM_FLOAT_3, 1.234f, ParameterizedAE.PARAM_FLOAT_6,
+ new Float[] { 1.234f, 0.001f }, ParameterizedAE.PARAM_STRING_1, true);
} catch (ResourceInitializationException e) {
rie = e;
}
@@ -678,12 +692,13 @@ public class ConfigurationParameterInitializerTest extends ComponentTestBase {
* If a parameter value is set to null, that is as good as if it was not set at all. If it is
* mandatory, an exception has to be thrown.
*/
- @Test(expected = ResourceInitializationException.class)
+ @Test
public void testMandatoryParameterSetToNull() throws Exception {
- AnalysisEngine aed = AnalysisEngineFactory.createEngine(DefaultValueAE2.class,
+ AnalysisEngine aed = AnalysisEngineFactory.createEngine(DefaultValueAE2.class,
DefaultValueAE2.PARAM_COLOR, null);
DefaultValueAE2 ae = new DefaultValueAE2();
- ae.initialize(aed.getUimaContext());
+ assertThatExceptionOfType(ResourceInitializationException.class)
+ .isThrownBy(() -> ae.initialize(aed.getUimaContext()));
}
/**
@@ -712,12 +727,13 @@ public class ConfigurationParameterInitializerTest extends ComponentTestBase {
/**
* Test that a parameter not supported by UIMA produces an error.
*/
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testNonUimaCompatibleParameterValue() throws Exception {
AnalysisEngine aed = AnalysisEngineFactory.createEngine(DefaultValueAE2.class, null,
DefaultValueAE2.PARAM_COLOR, new Point(1, 2));
DefaultValueAE2 ae = new DefaultValueAE2();
- ae.initialize(aed.getUimaContext());
+ assertThatExceptionOfType(IllegalArgumentException.class)
+ .isThrownBy(() -> ae.initialize(aed.getUimaContext()));
}
/**
@@ -726,8 +742,8 @@ public class ConfigurationParameterInitializerTest extends ComponentTestBase {
*/
@Test
public void testUnsetOptionalParameter() throws Exception {
- AnalysisEngineDescription aed = AnalysisEngineFactory.createEngineDescription(
- DefaultValueAE1.class, (Object[]) null);
+ AnalysisEngineDescription aed = AnalysisEngineFactory
+ .createEngineDescription(DefaultValueAE1.class, (Object[]) null);
// Remove the settings from the descriptor, but leave the declarations.
// The settings are already filled with default values by createPrimitiveDescription,
// but here we want to simulate loading a descriptor without settings from a file.
@@ -743,6 +759,7 @@ public class ConfigurationParameterInitializerTest extends ComponentTestBase {
public static class DefaultValueAE1 extends JCasAnnotator_ImplBase {
public static final String PARAM_COLOR = "color";
+
@ConfigurationParameter(defaultValue = "green", mandatory = false)
private String color;
@@ -759,6 +776,7 @@ public class ConfigurationParameterInitializerTest extends ComponentTestBase {
public static class DefaultValueAE2 extends JCasAnnotator_ImplBase {
public static final String PARAM_COLOR = "color";
+
@ConfigurationParameter(mandatory = true)
private String color;
@@ -775,6 +793,7 @@ public class ConfigurationParameterInitializerTest extends ComponentTestBase {
public static class DefaultValueAE3 extends JCasAnnotator_ImplBase {
public static final String PARAM_COLOR = "color";
+
@ConfigurationParameter(defaultValue = "GREEN", mandatory = false)
private Color color;
@@ -860,8 +879,8 @@ public class ConfigurationParameterInitializerTest extends ComponentTestBase {
assertEquals(new Locale("es"), ae.locale3);
assertEquals(new Locale("en", "CA"), ae.locale4);
- aed = AnalysisEngineFactory.createEngine(DefaultLocaleValueAE.class, "L1", "", "L2", "",
- "L3", null);
+ aed = AnalysisEngineFactory.createEngine(DefaultLocaleValueAE.class, "L1", "", "L2", "", "L3",
+ null);
ae = new DefaultLocaleValueAE();
ae.initialize(aed.getUimaContext());
assertEquals(Locale.getDefault(), ae.locale1);
@@ -878,10 +897,10 @@ public class ConfigurationParameterInitializerTest extends ComponentTestBase {
* Descriptor Editor to do this.) This point is moot anyways because I am checking in the
* generated descriptor files and there is no reason to run this main method in the future.
*/
- public static void main(String[] args) throws ResourceInitializationException,
- FileNotFoundException, SAXException, IOException {
- AnalysisEngineDescription aed = AnalysisEngineFactory.createEngineDescription(
- DefaultValueAE1.class, (Object[]) null);
+ public static void main(String[] args)
+ throws ResourceInitializationException, FileNotFoundException, SAXException, IOException {
+ AnalysisEngineDescription aed = AnalysisEngineFactory
+ .createEngineDescription(DefaultValueAE1.class, (Object[]) null);
aed.toXML(new FileOutputStream("src/test/resources/data/descriptor/DefaultValueAE1.xml"));
aed = AnalysisEngineFactory.createEngineDescription(DefaultValueAE2.class, (Object[]) null);
aed.toXML(new FileOutputStream("src/test/resources/data/descriptor/DefaultValueAE2.xml"));
diff --git a/uimafit-core/src/test/java/org/apache/uima/fit/data/CreateSampleXCASFile.java b/uimafit-core/src/test/java/org/apache/uima/fit/data/CreateSampleXCASFile.java
index 5240ede..5330bf1 100644
--- a/uimafit-core/src/test/java/org/apache/uima/fit/data/CreateSampleXCASFile.java
+++ b/uimafit-core/src/test/java/org/apache/uima/fit/data/CreateSampleXCASFile.java
@@ -42,13 +42,10 @@ public class CreateSampleXCASFile {
JCas jCas = JCasFactory.createJCas();
// quote from http://www.gutenberg.org/files/20417/20417-h/20417-h.htm
String text = "... the more knowledge advances the more it becomes possible to condense it into little books.";
- tokenBuilder
- .buildTokens(
- jCas,
- text,
- "... the more knowledge advances the more it becomes possible to condense it into little books . ",
- ". T M K A T M I B P T C I I L B .",
- "... the more knowledge advance the more it become possible to condense it into little book . ");
+ tokenBuilder.buildTokens(jCas, text,
+ "... the more knowledge advances the more it becomes possible to condense it into little books . ",
+ ". T M K A T M I B P T C I I L B .",
+ "... the more knowledge advance the more it become possible to condense it into little book . ");
FileOutputStream out = new FileOutputStream("src/test/resources/data/docs/test.xcas");
XCASSerializer ser = new XCASSerializer(jCas.getTypeSystem());
diff --git a/uimafit-core/src/test/java/org/apache/uima/fit/descriptor/TypeCapabilityTest.java b/uimafit-core/src/test/java/org/apache/uima/fit/descriptor/TypeCapabilityTest.java
index 7f52e8f..3e4063c 100644
--- a/uimafit-core/src/test/java/org/apache/uima/fit/descriptor/TypeCapabilityTest.java
+++ b/uimafit-core/src/test/java/org/apache/uima/fit/descriptor/TypeCapabilityTest.java
@@ -18,9 +18,9 @@
*/
package org.apache.uima.fit.descriptor;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import org.apache.uima.analysis_engine.AnalysisEngineDescription;
import org.apache.uima.analysis_engine.TypeOrFeature;
@@ -29,7 +29,7 @@ import org.apache.uima.fit.factory.AnalysisEngineFactory;
import org.apache.uima.fit.factory.testAes.Annotator4;
import org.apache.uima.resource.ResourceInitializationException;
import org.apache.uima.resource.metadata.Capability;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*/
@@ -38,8 +38,8 @@ public class TypeCapabilityTest extends ComponentTestBase {
@Test
public void testTC() throws ResourceInitializationException {
- AnalysisEngineDescription aed = AnalysisEngineFactory.createEngineDescription(
- Annotator4.class, typeSystemDescription);
+ AnalysisEngineDescription aed = AnalysisEngineFactory.createEngineDescription(Annotator4.class,
+ typeSystemDescription);
Capability[] capabilities = aed.getAnalysisEngineMetaData().getCapabilities();
assertEquals(1, capabilities.length);
Capability capability = capabilities[0];
diff --git a/uimafit-core/src/test/java/org/apache/uima/fit/factory/AggregateBuilderTest.java b/uimafit-core/src/test/java/org/apache/uima/fit/factory/AggregateBuilderTest.java
index 73f44aa..189ae9b 100644
--- a/uimafit-core/src/test/java/org/apache/uima/fit/factory/AggregateBuilderTest.java
+++ b/uimafit-core/src/test/java/org/apache/uima/fit/factory/AggregateBuilderTest.java
@@ -19,7 +19,9 @@
package org.apache.uima.fit.factory;
import static org.apache.uima.fit.factory.AnalysisEngineFactory.createEngine;
-import static org.junit.Assert.assertEquals;
+import static org.apache.uima.fit.factory.AnalysisEngineFactory.createEngineDescription;
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.File;
import java.io.IOException;
@@ -42,7 +44,7 @@ import org.apache.uima.fit.util.CasIOUtil;
import org.apache.uima.fit.util.TypeSystemUtil;
import org.apache.uima.flow.FlowControllerDescription;
import org.apache.uima.resource.ResourceInitializationException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*/
@@ -53,25 +55,28 @@ public class AggregateBuilderTest extends ComponentTestBase {
tokenBuilder.buildTokens(jCas, "Anyone up for a game of Foosball?");
AggregateBuilder builder = new AggregateBuilder();
- builder.add(AnalysisEngineFactory.createEngineDescription(Annotator1.class,
- typeSystemDescription), ViewNames.PARENTHESES_VIEW, "A");
- builder.add(AnalysisEngineFactory.createEngineDescription(Annotator2.class,
- typeSystemDescription), ViewNames.SORTED_VIEW, "B", ViewNames.SORTED_PARENTHESES_VIEW,
- "C", ViewNames.PARENTHESES_VIEW, "A");
- builder.add(AnalysisEngineFactory.createEngineDescription(Annotator3.class,
- typeSystemDescription), ViewNames.INITIAL_VIEW, "B");
+ builder.add(
+ AnalysisEngineFactory.createEngineDescription(Annotator1.class, typeSystemDescription),
+ ViewNames.PARENTHESES_VIEW, "A");
+ builder.add(
+ AnalysisEngineFactory.createEngineDescription(Annotator2.class, typeSystemDescription),
+ ViewNames.SORTED_VIEW, "B", ViewNames.SORTED_PARENTHESES_VIEW, "C",
+ ViewNames.PARENTHESES_VIEW, "A");
+ builder.add(
+ AnalysisEngineFactory.createEngineDescription(Annotator3.class, typeSystemDescription),
+ ViewNames.INITIAL_VIEW, "B");
AnalysisEngine aggregateEngine = builder.createAggregate();
aggregateEngine.process(jCas);
assertEquals("Anyone up for a game of Foosball?", jCas.getDocumentText());
- assertEquals("Any(o)n(e) (u)p f(o)r (a) g(a)m(e) (o)f F(oo)sb(a)ll?", jCas.getView("A")
- .getDocumentText());
+ assertEquals("Any(o)n(e) (u)p f(o)r (a) g(a)m(e) (o)f F(oo)sb(a)ll?",
+ jCas.getView("A").getDocumentText());
assertEquals("?AFaaabeeffgllmnnoooooprsuy", jCas.getView("B").getDocumentText());
- assertEquals("(((((((((())))))))))?AFaaabeeffgllmnnoooooprsuy", jCas.getView("C")
- .getDocumentText());
- assertEquals("yusrpooooonnmllgffeebaaaFA?", jCas.getView(ViewNames.REVERSE_VIEW)
- .getDocumentText());
+ assertEquals("(((((((((())))))))))?AFaaabeeffgllmnnoooooprsuy",
+ jCas.getView("C").getDocumentText());
+ assertEquals("yusrpooooonnmllgffeebaaaFA?",
+ jCas.getView(ViewNames.REVERSE_VIEW).getDocumentText());
CasIOUtil.readJCas(jCas, new File("src/test/resources/data/docs/test.xmi"));
AnalysisEngine ae1 = AnalysisEngineFactory.createEngine(NoOpAnnotator.class,
@@ -82,8 +87,9 @@ public class AggregateBuilderTest extends ComponentTestBase {
AnalysisEngineDescription aggregateDescription = builder.createAggregateDescription();
builder = new AggregateBuilder();
builder.add(aggregateDescription);
- builder.add(AnalysisEngineFactory.createEngineDescription(Annotator1.class,
- typeSystemDescription), ViewNames.PARENTHESES_VIEW, "PARENS");
+ builder.add(
+ AnalysisEngineFactory.createEngineDescription(Annotator1.class, typeSystemDescription),
+ ViewNames.PARENTHESES_VIEW, "PARENS");
aggregateEngine = builder.createAggregate();
jCas.reset();
@@ -93,15 +99,15 @@ public class AggregateBuilderTest extends ComponentTestBase {
aggregateEngine.process(jCas);
assertEquals("Anyone up for a game of Foosball?", jCas.getDocumentText());
- assertEquals("Any(o)n(e) (u)p f(o)r (a) g(a)m(e) (o)f F(oo)sb(a)ll?", jCas.getView("A")
- .getDocumentText());
+ assertEquals("Any(o)n(e) (u)p f(o)r (a) g(a)m(e) (o)f F(oo)sb(a)ll?",
+ jCas.getView("A").getDocumentText());
assertEquals("?AFaaabeeffgllmnnoooooprsuy", jCas.getView("B").getDocumentText());
- assertEquals("(((((((((())))))))))?AFaaabeeffgllmnnoooooprsuy", jCas.getView("C")
- .getDocumentText());
- assertEquals("yusrpooooonnmllgffeebaaaFA?", jCas.getView(ViewNames.REVERSE_VIEW)
- .getDocumentText());
- assertEquals("Any(o)n(e) (u)p f(o)r (a) g(a)m(e) (o)f F(oo)sb(a)ll?", jCas.getView("PARENS")
- .getDocumentText());
+ assertEquals("(((((((((())))))))))?AFaaabeeffgllmnnoooooprsuy",
+ jCas.getView("C").getDocumentText());
+ assertEquals("yusrpooooonnmllgffeebaaaFA?",
+ jCas.getView(ViewNames.REVERSE_VIEW).getDocumentText());
+ assertEquals("Any(o)n(e) (u)p f(o)r (a) g(a)m(e) (o)f F(oo)sb(a)ll?",
+ jCas.getView("PARENS").getDocumentText());
}
@@ -110,12 +116,12 @@ public class AggregateBuilderTest extends ComponentTestBase {
tokenBuilder.buildTokens(jCas, "'Verb' is a noun!?");
AggregateBuilder builder = new AggregateBuilder();
- String componentName1 = builder.add(AnalysisEngineFactory.createEngineDescription(
- Annotator1.class, typeSystemDescription));
- String componentName2 = builder.add(AnalysisEngineFactory.createEngineDescription(
- Annotator1.class, typeSystemDescription));
- String componentName3 = builder.add(AnalysisEngineFactory.createEngineDescription(
- Annotator1.class, typeSystemDescription));
+ String componentName1 = builder.add(
+ AnalysisEngineFactory.createEngineDescription(Annotator1.class, typeSystemDescription));
+ String componentName2 = builder.add(
+ AnalysisEngineFactory.createEngineDescription(Annotator1.class, typeSystemDescription));
+ String componentName3 = builder.add(
+ AnalysisEngineFactory.createEngineDescription(Annotator1.class, typeSystemDescription));
assertEquals("org.apache.uima.fit.factory.testAes.Annotator1-0", componentName1);
assertEquals("org.apache.uima.fit.factory.testAes.Annotator1-1", componentName2);
@@ -137,26 +143,30 @@ public class AggregateBuilderTest extends ComponentTestBase {
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testOddNumberOfViewNames() throws ResourceInitializationException {
AggregateBuilder builder = new AggregateBuilder();
- builder.add(AnalysisEngineFactory.createEngineDescription(Annotator1.class,
- typeSystemDescription), ViewNames.PARENTHESES_VIEW);
+ assertThatExceptionOfType(IllegalArgumentException.class) //
+ .isThrownBy(() -> builder.add(
+ createEngineDescription(Annotator1.class, typeSystemDescription),
+ ViewNames.PARENTHESES_VIEW));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testDuplicateComponentNames() throws ResourceInitializationException {
AggregateBuilder builder = new AggregateBuilder();
- builder.add("name", AnalysisEngineFactory.createEngineDescription(Annotator1.class,
- typeSystemDescription));
- builder.add("name", AnalysisEngineFactory.createEngineDescription(Annotator1.class,
- typeSystemDescription));
+ builder.add("name", createEngineDescription(Annotator1.class, typeSystemDescription));
+
+ assertThatExceptionOfType(IllegalArgumentException.class) //
+ .isThrownBy(() -> builder.add("name",
+ createEngineDescription(Annotator1.class, typeSystemDescription)));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testBadSofaMapping() {
AggregateBuilder builder = new AggregateBuilder();
- builder.addSofaMapping("name", ViewNames.PARENTHESES_VIEW, "A");
+ assertThatExceptionOfType(IllegalArgumentException.class) //
+ .isThrownBy(() -> builder.addSofaMapping("name", ViewNames.PARENTHESES_VIEW, "A"));
}
@Test
@@ -164,12 +174,12 @@ public class AggregateBuilderTest extends ComponentTestBase {
tokenBuilder.buildTokens(jCas, "An honest man can never surrender an honest doubt.");
AggregateBuilder builder = new AggregateBuilder();
- builder.add(AnalysisEngineFactory.createEngineDescription(FlowAE1.class,
- typeSystemDescription));
- builder.add(AnalysisEngineFactory.createEngineDescription(FlowAE2.class,
- typeSystemDescription));
- builder.add(AnalysisEngineFactory.createEngineDescription(FlowAE3.class,
- typeSystemDescription));
+ builder.add(
+ AnalysisEngineFactory.createEngineDescription(FlowAE1.class, typeSystemDescription));
+ builder.add(
+ AnalysisEngineFactory.createEngineDescription(FlowAE2.class, typeSystemDescription));
+ builder.add(
+ AnalysisEngineFactory.createEngineDescription(FlowAE3.class, typeSystemDescription));
FlowControllerDescription fcd = FlowControllerFactory
.createFlowControllerDescription(ReversableTestFlowController.class);
diff --git a/uimafit-core/src/test/java/org/apache/uima/fit/factory/AggregateWithReaderTest.java b/uimafit-core/src/test/java/org/apache/uima/fit/factory/AggregateWithReaderTest.java
index f6afd77..c4d2918 100644
--- a/uimafit-core/src/test/java/org/apache/uima/fit/factory/AggregateWithReaderTest.java
+++ b/uimafit-core/src/test/java/org/apache/uima/fit/factory/AggregateWithReaderTest.java
@@ -34,7 +34,7 @@ import org.apache.uima.collection.CollectionException;
import org.apache.uima.collection.CollectionReaderDescription;
import org.apache.uima.collection.CollectionReader_ImplBase;
import org.apache.uima.util.Progress;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*/
diff --git a/uimafit-core/src/test/java/org/apache/uima/fit/factory/AnalysisEngineFactoryExternalResourceTest.java b/uimafit-core/src/test/java/org/apache/uima/fit/factory/AnalysisEngineFactoryExternalResourceTest.java
index 2adc920..edcab72 100644
--- a/uimafit-core/src/test/java/org/apache/uima/fit/factory/AnalysisEngineFactoryExternalResourceTest.java
+++ b/uimafit-core/src/test/java/org/apache/uima/fit/factory/AnalysisEngineFactoryExternalResourceTest.java
@@ -24,7 +24,7 @@ import static org.apache.uima.fit.factory.AnalysisEngineFactory.createEngineDesc
import static org.apache.uima.fit.factory.ExternalResourceFactory.bindResourceOnce;
import static org.apache.uima.fit.factory.ExternalResourceFactory.createResourceDescription;
import static org.apache.uima.fit.factory.ExternalResourceFactory.createSharedResourceDescription;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -44,10 +44,7 @@ import org.apache.uima.fit.factory.testRes.TestSharedResourceObject;
import org.apache.uima.resource.ExternalResourceDescription;
import org.apache.uima.util.InvalidXMLException;
import org.apache.uima.util.XMLInputSource;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestName;
+import org.junit.jupiter.api.Test;
import org.xml.sax.SAXException;
/**
@@ -59,10 +56,9 @@ public class AnalysisEngineFactoryExternalResourceTest {
@Test
public void resource_testInjection() throws Exception {
AnalysisEngineDescription aeDesc = saveLoad(createEngineDescription(
- TestAnalysisEngineWithResource.class,
- TestAnalysisEngineWithResource.PARAM_RESOURCE,
- createResourceDescription(TestExternalResource.class,
- TestExternalResource.PARAM_VALUE, TestExternalResource.EXPECTED_VALUE)));
+ TestAnalysisEngineWithResource.class, TestAnalysisEngineWithResource.PARAM_RESOURCE,
+ createResourceDescription(TestExternalResource.class, TestExternalResource.PARAM_VALUE,
+ TestExternalResource.EXPECTED_VALUE)));
AnalysisEngine ae = createEngine(aeDesc);
ae.process(ae.newCAS());
@@ -73,20 +69,19 @@ public class AnalysisEngineFactoryExternalResourceTest {
*/
@Test
public void resource_testSharedInjection() throws Exception {
- ExternalResourceDescription resDesc = createResourceDescription(
- TestExternalResource.class, TestExternalResource.PARAM_VALUE,
- TestExternalResource.EXPECTED_VALUE);
+ ExternalResourceDescription resDesc = createResourceDescription(TestExternalResource.class,
+ TestExternalResource.PARAM_VALUE, TestExternalResource.EXPECTED_VALUE);
- AnalysisEngineDescription aeDesc1 = saveLoad(createEngineDescription(
- TestAnalysisEngineWithResource.class, TestAnalysisEngineWithResource.PARAM_RESOURCE,
- resDesc));
+ AnalysisEngineDescription aeDesc1 = saveLoad(
+ createEngineDescription(TestAnalysisEngineWithResource.class,
+ TestAnalysisEngineWithResource.PARAM_RESOURCE, resDesc));
- AnalysisEngineDescription aeDesc2 = saveLoad(createEngineDescription(
- TestAnalysisEngineWithResource.class, TestAnalysisEngineWithResource.PARAM_RESOURCE,
- resDesc));
+ AnalysisEngineDescription aeDesc2 = saveLoad(
+ createEngineDescription(TestAnalysisEngineWithResource.class,
+ TestAnalysisEngineWithResource.PARAM_RESOURCE, resDesc));
-// dumpResourceConfiguration(aeDesc1);
-// dumpResourceConfiguration(aeDesc2);
+ // dumpResourceConfiguration(aeDesc1);
+ // dumpResourceConfiguration(aeDesc2);
AnalysisEngine ae1 = createEngine(aeDesc1);
AnalysisEngine ae2 = createEngine(aeDesc2);
@@ -103,15 +98,12 @@ public class AnalysisEngineFactoryExternalResourceTest {
@Test
public void resource_testSimpleNesting() throws Exception {
AnalysisEngineDescription aeDesc = saveLoad(createEngineDescription(
- TestAnalysisEngineWithResource.class,
- TestAnalysisEngineWithResource.PARAM_RESOURCE,
- createResourceDescription(
- TestExternalResource2.class,
- TestExternalResource.PARAM_VALUE,
- TestExternalResource.EXPECTED_VALUE,
- TestExternalResource2.PARAM_RESOURCE,
+ TestAnalysisEngineWithResource.class, TestAnalysisEngineWithResource.PARAM_RESOURCE,
+ createResourceDescription(TestExternalResource2.class, TestExternalResource.PARAM_VALUE,
+ TestExternalResource.EXPECTED_VALUE, TestExternalResource2.PARAM_RESOURCE,
createResourceDescription(TestExternalResource.class,
- TestExternalResource.PARAM_VALUE, TestExternalResource.EXPECTED_VALUE))));
+ TestExternalResource.PARAM_VALUE,
+ TestExternalResource.EXPECTED_VALUE))));
AnalysisEngine ae = createEngine(aeDesc);
ae.process(ae.newCAS());
@@ -122,26 +114,24 @@ public class AnalysisEngineFactoryExternalResourceTest {
*/
@Test
public void resource_testSharedSimpleNesting() throws Exception {
- ExternalResourceDescription resDesc = createResourceDescription(
- TestExternalResource2.class,
- TestExternalResource.PARAM_VALUE,
- TestExternalResource.EXPECTED_VALUE,
+ ExternalResourceDescription resDesc = createResourceDescription(TestExternalResource2.class,
+ TestExternalResource.PARAM_VALUE, TestExternalResource.EXPECTED_VALUE,
TestExternalResource2.PARAM_RESOURCE,
- createResourceDescription(TestExternalResource.class,
- TestExternalResource.PARAM_VALUE, TestExternalResource.EXPECTED_VALUE));
+ createResourceDescription(TestExternalResource.class, TestExternalResource.PARAM_VALUE,
+ TestExternalResource.EXPECTED_VALUE));
- AnalysisEngineDescription aeDesc1 = saveLoad(createEngineDescription(
- TestAnalysisEngineWithResource.class, TestAnalysisEngineWithResource.PARAM_RESOURCE,
- resDesc));
+ AnalysisEngineDescription aeDesc1 = saveLoad(
+ createEngineDescription(TestAnalysisEngineWithResource.class,
+ TestAnalysisEngineWithResource.PARAM_RESOURCE, resDesc));
-// dumpResourceConfiguration(aeDesc1);
+ // dumpResourceConfiguration(aeDesc1);
- AnalysisEngineDescription aeDesc2 = saveLoad(createEngineDescription(
- TestAnalysisEngineWithResource.class, TestAnalysisEngineWithResource.PARAM_RESOURCE,
- resDesc));
+ AnalysisEngineDescription aeDesc2 = saveLoad(
+ createEngineDescription(TestAnalysisEngineWithResource.class,
+ TestAnalysisEngineWithResource.PARAM_RESOURCE, resDesc));
-// dumpResourceConfiguration(aeDesc1);
-// dumpResourceConfiguration(aeDesc2);
+ // dumpResourceConfiguration(aeDesc1);
+ // dumpResourceConfiguration(aeDesc2);
AnalysisEngine ae1 = createEngine(aeDesc1);
AnalysisEngine ae2 = createEngine(aeDesc2);
@@ -157,22 +147,20 @@ public class AnalysisEngineFactoryExternalResourceTest {
*/
@Test
public void resource_testDeeperNesting() throws Exception {
- ExternalResourceDescription resDesc2 = createResourceDescription(
- TestExternalResource.class, TestExternalResource.PARAM_VALUE,
- TestExternalResource.EXPECTED_VALUE);
-
- ExternalResourceDescription resDesc = createResourceDescription(
- TestExternalResource2.class, TestExternalResource2.PARAM_RESOURCE, resDesc2,
+ ExternalResourceDescription resDesc2 = createResourceDescription(TestExternalResource.class,
TestExternalResource.PARAM_VALUE, TestExternalResource.EXPECTED_VALUE);
+ ExternalResourceDescription resDesc = createResourceDescription(TestExternalResource2.class,
+ TestExternalResource2.PARAM_RESOURCE, resDesc2, TestExternalResource.PARAM_VALUE,
+ TestExternalResource.EXPECTED_VALUE);
+
AnalysisEngineDescription aeDesc = saveLoad(createEngineDescription(
- TestAnalysisEngineWithResource.class,
- TestAnalysisEngineWithResource.PARAM_RESOURCE,
- createResourceDescription(TestExternalResource2.class,
- TestExternalResource.PARAM_VALUE, TestExternalResource.EXPECTED_VALUE,
- TestExternalResource2.PARAM_RESOURCE, resDesc)));
+ TestAnalysisEngineWithResource.class, TestAnalysisEngineWithResource.PARAM_RESOURCE,
+ createResourceDescription(TestExternalResource2.class, TestExternalResource.PARAM_VALUE,
+ TestExternalResource.EXPECTED_VALUE, TestExternalResource2.PARAM_RESOURCE,
+ resDesc)));
-// dumpResourceConfiguration(aeDesc);
+ // dumpResourceConfiguration(aeDesc);
AnalysisEngine ae = createEngine(aeDesc);
ae.process(ae.newCAS());
@@ -183,16 +171,15 @@ public class AnalysisEngineFactoryExternalResourceTest {
*/
@Test
public void resource_testSelfInjection() throws Exception {
- ExternalResourceDescription resDesc = createResourceDescription(
- TestExternalResource2.class, TestExternalResource.PARAM_VALUE,
- TestExternalResource.EXPECTED_VALUE);
+ ExternalResourceDescription resDesc = createResourceDescription(TestExternalResource2.class,
+ TestExternalResource.PARAM_VALUE, TestExternalResource.EXPECTED_VALUE);
bindResourceOnce(resDesc, TestExternalResource2.PARAM_RESOURCE, resDesc);
- AnalysisEngineDescription aeDesc = saveLoad(createEngineDescription(
- TestAnalysisEngineWithResource.class, TestAnalysisEngineWithResource.PARAM_RESOURCE,
- resDesc));
+ AnalysisEngineDescription aeDesc = saveLoad(
+ createEngineDescription(TestAnalysisEngineWithResource.class,
+ TestAnalysisEngineWithResource.PARAM_RESOURCE, resDesc));
-// dumpResourceConfiguration(aeDesc);
+ // dumpResourceConfiguration(aeDesc);
AnalysisEngine ae = createEngine(aeDesc);
ae.process(ae.newCAS());
@@ -203,21 +190,20 @@ public class AnalysisEngineFactoryExternalResourceTest {
*/
@Test
public void resource_testDoubleSelfInjection() throws Exception {
- ExternalResourceDescription resDesc = createResourceDescription(
- TestExternalResource2.class, TestExternalResource.PARAM_VALUE,
- TestExternalResource.EXPECTED_VALUE);
+ ExternalResourceDescription resDesc = createResourceDescription(TestExternalResource2.class,
+ TestExternalResource.PARAM_VALUE, TestExternalResource.EXPECTED_VALUE);
bindResourceOnce(resDesc, TestExternalResource2.PARAM_RESOURCE, resDesc);
- AnalysisEngineDescription aeDesc1 = saveLoad(createEngineDescription(
- TestAnalysisEngineWithResource.class, TestAnalysisEngineWithResource.PARAM_RESOURCE,
- resDesc));
+ AnalysisEngineDescription aeDesc1 = saveLoad(
+ createEngineDescription(TestAnalysisEngineWithResource.class,
+ TestAnalysisEngineWithResource.PARAM_RESOURCE, resDesc));
- AnalysisEngineDescription aeDesc2 = saveLoad(createEngineDescription(
- TestAnalysisEngineWithResource.class, TestAnalysisEngineWithResource.PARAM_RESOURCE,
- resDesc));
+ AnalysisEngineDescription aeDesc2 = saveLoad(
+ createEngineDescription(TestAnalysisEngineWithResource.class,
+ TestAnalysisEngineWithResource.PARAM_RESOURCE, resDesc));
-// dumpResourceConfiguration(aeDesc1);
-// dumpResourceConfiguration(aeDesc2);
+ // dumpResourceConfiguration(aeDesc1);
+ // dumpResourceConfiguration(aeDesc2);
AnalysisEngine ae1 = createEngine(aeDesc1);
AnalysisEngine ae2 = createEngine(aeDesc2);
@@ -233,11 +219,12 @@ public class AnalysisEngineFactoryExternalResourceTest {
*/
@Test
public void sharedObject_testInjection() throws Exception {
- AnalysisEngineDescription aeDesc = saveLoad(createEngineDescription(
- TestAnalysisEngineWithSharedResourceObject.class,
- TestAnalysisEngineWithSharedResourceObject.PARAM_RESOURCE,
- createSharedResourceDescription("http://dumm.my", TestSharedResourceObject.class,
- TestSharedResourceObject.PARAM_VALUE, TestSharedResourceObject.EXPECTED_VALUE)));
+ AnalysisEngineDescription aeDesc = saveLoad(
+ createEngineDescription(TestAnalysisEngineWithSharedResourceObject.class,
+ TestAnalysisEngineWithSharedResourceObject.PARAM_RESOURCE,
+ createSharedResourceDescription("http://dumm.my",
+ TestSharedResourceObject.class, TestSharedResourceObject.PARAM_VALUE,
+ TestSharedResourceObject.EXPECTED_VALUE)));
AnalysisEngine ae = createEngine(aeDesc);
ae.process(ae.newCAS());
@@ -248,20 +235,20 @@ public class AnalysisEngineFactoryExternalResourceTest {
*/
@Test
public void sharedObject_testSharedInjection() throws Exception {
- ExternalResourceDescription resDesc = createSharedResourceDescription(
- "http://dumm.my", TestSharedResourceObject.class, TestSharedResourceObject.PARAM_VALUE,
+ ExternalResourceDescription resDesc = createSharedResourceDescription("http://dumm.my",
+ TestSharedResourceObject.class, TestSharedResourceObject.PARAM_VALUE,
TestSharedResourceObject.EXPECTED_VALUE);
- AnalysisEngineDescription aeDesc1 = saveLoad(createEngineDescription(
- TestAnalysisEngineWithSharedResourceObject.class,
- TestAnalysisEngineWithSharedResourceObject.PARAM_RESOURCE, resDesc));
+ AnalysisEngineDescription aeDesc1 = saveLoad(
+ createEngineDescription(TestAnalysisEngineWithSharedResourceObject.class,
+ TestAnalysisEngineWithSharedResourceObject.PARAM_RESOURCE, resDesc));
- AnalysisEngineDescription aeDesc2 = saveLoad(createEngineDescription(
- TestAnalysisEngineWithSharedResourceObject.class,
- TestAnalysisEngineWithSharedResourceObject.PARAM_RESOURCE, resDesc));
+ AnalysisEngineDescription aeDesc2 = saveLoad(
+ createEngineDescription(TestAnalysisEngineWithSharedResourceObject.class,
+ TestAnalysisEngineWithSharedResourceObject.PARAM_RESOURCE, resDesc));
-// dumpResourceConfiguration(aeDesc1);
-// dumpResourceConfiguration(aeDesc2);
+ // dumpResourceConfiguration(aeDesc1);
+ // dumpResourceConfiguration(aeDesc2);
AnalysisEngine ae1 = createEngine(aeDesc1);
AnalysisEngine ae2 = createEngine(aeDesc2);
@@ -280,11 +267,8 @@ public class AnalysisEngineFactoryExternalResourceTest {
AnalysisEngineDescription aeDesc = saveLoad(createEngineDescription(
TestAnalysisEngineWithSharedResourceObject.class,
TestAnalysisEngineWithSharedResourceObject.PARAM_RESOURCE,
- createSharedResourceDescription(
- "http://dumm.my",
- TestSharedResourceObject2.class,
- TestSharedResourceObject2.PARAM_VALUE,
- TestSharedResourceObject2.EXPECTED_VALUE,
+ createSharedResourceDescription("http://dumm.my", TestSharedResourceObject2.class,
+ TestSharedResourceObject2.PARAM_VALUE, TestSharedResourceObject2.EXPECTED_VALUE,
TestSharedResourceObject2.PARAM_RESOURCE,
createSharedResourceDescription("http://dumm.my",
TestSharedResourceObject.class, TestSharedResourceObject.PARAM_VALUE,
@@ -299,17 +283,17 @@ public class AnalysisEngineFactoryExternalResourceTest {
*/
@Test
public void sharedObject_testSimpleNestingViaBind() throws Exception {
- ExternalResourceDescription res2 = createSharedResourceDescription(
- "http://dumm.my", TestSharedResourceObject.class,
- TestSharedResourceObject.PARAM_VALUE, TestSharedResourceObject.EXPECTED_VALUE);
+ ExternalResourceDescription res2 = createSharedResourceDescription("http://dumm.my",
+ TestSharedResourceObject.class, TestSharedResourceObject.PARAM_VALUE,
+ TestSharedResourceObject.EXPECTED_VALUE);
- ExternalResourceDescription res1 = createSharedResourceDescription(
- "http://dumm.my", TestSharedResourceObject2.class,
- TestSharedResourceObject2.PARAM_VALUE, TestSharedResourceObject2.EXPECTED_VALUE);
+ ExternalResourceDescription res1 = createSharedResourceDescription("http://dumm.my",
+ TestSharedResourceObject2.class, TestSharedResourceObject2.PARAM_VALUE,
+ TestSharedResourceObject2.EXPECTED_VALUE);
bindResourceOnce(res1, TestSharedResourceObject2.PARAM_RESOURCE, res2);
-
- AnalysisEngineDescription aeDesc =createEngineDescription(
+
+ AnalysisEngineDescription aeDesc = createEngineDescription(
TestAnalysisEngineWithSharedResourceObject.class,
TestAnalysisEngineWithSharedResourceObject.PARAM_RESOURCE, res1);
@@ -318,22 +302,22 @@ public class AnalysisEngineFactoryExternalResourceTest {
AnalysisEngine ae = createEngine(aeDesc);
ae.process(ae.newCAS());
}
-
+
/**
* Test self-injection
*/
@Test
public void sharedObject_testSelfInjection() throws Exception {
- ExternalResourceDescription resDesc = createSharedResourceDescription(
- "http://dumm.my", TestSharedResourceObject2.class,
- TestSharedResourceObject.PARAM_VALUE, TestSharedResourceObject.EXPECTED_VALUE);
+ ExternalResourceDescription resDesc = createSharedResourceDescription("http://dumm.my",
+ TestSharedResourceObject2.class, TestSharedResourceObject.PARAM_VALUE,
+ TestSharedResourceObject.EXPECTED_VALUE);
bindResourceOnce(resDesc, TestSharedResourceObject2.PARAM_RESOURCE, resDesc);
- AnalysisEngineDescription aeDesc = saveLoad(createEngineDescription(
- TestAnalysisEngineWithSharedResourceObject.class,
- TestAnalysisEngineWithSharedResourceObject.PARAM_RESOURCE, resDesc));
+ AnalysisEngineDescription aeDesc = saveLoad(
+ createEngineDescription(TestAnalysisEngineWithSharedResourceObject.class,
+ TestAnalysisEngineWithSharedResourceObject.PARAM_RESOURCE, resDesc));
-// dumpResourceConfiguration(aeDesc);
+ // dumpResourceConfiguration(aeDesc);
AnalysisEngine ae = createEngine(aeDesc);
ae.process(ae.newCAS());
@@ -347,7 +331,7 @@ public class AnalysisEngineFactoryExternalResourceTest {
@Override
public void afterResourcesInitialized() {
-// System.out.println(getClass().getSimpleName() + ".afterResourcesInitialized()");
+ // System.out.println(getClass().getSimpleName() + ".afterResourcesInitialized()");
// Ensure the External Resource is bound
assertNotNull(resource);
if (this != resource) {
@@ -357,8 +341,8 @@ public class AnalysisEngineFactoryExternalResourceTest {
}
}
- public static class TestSharedResourceObject2 extends TestSharedResourceObject implements
- ExternalResourceAware {
+ public static class TestSharedResourceObject2 extends TestSharedResourceObject
+ implements ExternalResourceAware {
public final static String PARAM_RESOURCE = "resource2";
@ExternalResource(key = PARAM_RESOURCE)
@@ -369,7 +353,7 @@ public class AnalysisEngineFactoryExternalResourceTest {
@Override
public void afterResourcesInitialized() {
-// System.out.println(getClass().getSimpleName() + ".afterResourcesInitialized()");
+ // System.out.println(getClass().getSimpleName() + ".afterResourcesInitialized()");
// Ensure the External Resource is bound
assertNotNull(resource);
if (this != resource) {
@@ -393,7 +377,7 @@ public class AnalysisEngineFactoryExternalResourceTest {
@Override
public void process(CAS aCAS) throws AnalysisEngineProcessException {
-// System.out.println(getClass().getSimpleName() + ".process()");
+ // System.out.println(getClass().getSimpleName() + ".process()");
assertNotNull(resource);
resource.assertConfiguredOk();
}
@@ -408,44 +392,36 @@ public class AnalysisEngineFactoryExternalResourceTest {
@Override
public void process(CAS aCAS) throws AnalysisEngineProcessException {
-// System.out.println(getClass().getSimpleName() + ".process()");
+ // System.out.println(getClass().getSimpleName() + ".process()");
assertNotNull(resource);
resource.assertConfiguredOk();
}
}
- AnalysisEngineDescription saveLoad(AnalysisEngineDescription aDesc) throws InvalidXMLException,
- SAXException, IOException {
+ AnalysisEngineDescription saveLoad(AnalysisEngineDescription aDesc)
+ throws InvalidXMLException, SAXException, IOException {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
aDesc.toXML(bos);
return UIMAFramework.getXMLParser().parseAnalysisEngineDescription(
new XMLInputSource(new ByteArrayInputStream(bos.toByteArray()), null));
}
-// private void dumpResourceConfiguration(ResourceCreationSpecifier aSpec) {
-// System.out.println("-- begin resource configuration");
-// for (ExternalResourceBinding b : aSpec.getResourceManagerConfiguration()
-// .getExternalResourceBindings()) {
-// System.out.printf("Binding : %s -> %s %n", b.getKey(), b.getResourceName());
-// }
-//
-// for (ExternalResourceDescription r : aSpec.getResourceManagerConfiguration()
-// .getExternalResources()) {
-// if (r.getImplementationName() != null) {
-// System.out.printf("Resource: %s -> %s %n", r.getName(), r.getImplementationName());
-// } else {
-// System.out.printf("Resource: %s -> %s %n", r.getName(),
-// ((CustomResourceSpecifier) r.getResourceSpecifier()).getResourceClassName());
-// }
-// }
-// System.out.println("-- end resource configuration");
-// }
-
- @Rule
- public TestName name = new TestName();
-
- @Before
- public void printSeparator() {
- System.out.println("\n=== " + name.getMethodName() + " =====================");
- }
+ // private void dumpResourceConfiguration(ResourceCreationSpecifier aSpec) {
+ // System.out.println("-- begin resource configuration");
+ // for (ExternalResourceBinding b : aSpec.getResourceManagerConfiguration()
+ // .getExternalResourceBindings()) {
+ // System.out.printf("Binding : %s -> %s %n", b.getKey(), b.getResourceName());
+ // }
+ //
+ // for (ExternalResourceDescription r : aSpec.getResourceManagerConfiguration()
+ // .getExternalResources()) {
+ // if (r.getImplementationName() != null) {
+ // System.out.printf("Resource: %s -> %s %n", r.getName(), r.getImplementationName());
+ // } else {
+ // System.out.printf("Resource: %s -> %s %n", r.getName(),
+ // ((CustomResourceSpecifier) r.getResourceSpecifier()).getResourceClassName());
+ // }
+ // }
+ // System.out.println("-- end resource configuration");
+ // }
}
diff --git a/uimafit-core/src/test/java/org/apache/uima/fit/factory/AnalysisEngineFactoryTest.java b/uimafit-core/src/test/java/org/apache/uima/fit/factory/AnalysisEngineFactoryTest.java
index 795ecde..26a3c04 100644
--- a/uimafit-core/src/test/java/org/apache/uima/fit/factory/AnalysisEngineFactoryTest.java
+++ b/uimafit-core/src/test/java/org/apache/uima/fit/factory/AnalysisEngineFactoryTest.java
@@ -27,12 +27,13 @@ import static org.apache.uima.fit.factory.AnalysisEngineFactory.generateDelegate
import static org.apache.uima.fit.factory.AnalysisEngineFactory.sanitizeDelegateKey;
import static org.apache.uima.fit.factory.TypeSystemDescriptionFactory.createTypeSystemDescription;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
import java.io.FileOutputStream;
@@ -87,15 +88,15 @@ import org.apache.uima.resource.metadata.TypePriorities;
import org.apache.uima.resource.metadata.TypePriorityList;
import org.apache.uima.resource.metadata.TypeSystemDescription;
import org.apache.uima.util.XMLInputSource;
-import org.junit.Test;
-import org.xmlunit.assertj.XmlAssert;
+import org.junit.jupiter.api.Test;
+import org.xmlunit.assertj3.XmlAssert;
public class AnalysisEngineFactoryTest extends ComponentTestBase {
@Test
public void testViewAE() throws Exception {
- AnalysisEngineDescription aed = AnalysisEngineFactory.createEngineDescription(
- Annotator4.class, typeSystemDescription);
+ AnalysisEngineDescription aed = AnalysisEngineFactory.createEngineDescription(Annotator4.class,
+ typeSystemDescription);
AnalysisEngine ae = AnalysisEngineFactory.createEngine(aed, "A");
JCas aView = jCas.createView("A");
@@ -129,19 +130,18 @@ public class AnalysisEngineFactoryTest extends ComponentTestBase {
jCas = engine.newJCas();
tokenBuilder.buildTokens(jCas, "word");
- FSIterator<Annotation> tokensInSentence = jCas.getAnnotationIndex().subiterator(
- JCasUtil.selectByIndex(jCas, Sentence.class, 0));
+ FSIterator<Annotation> tokensInSentence = jCas.getAnnotationIndex()
+ .subiterator(JCasUtil.selectByIndex(jCas, Sentence.class, 0));
assertFalse(tokensInSentence.hasNext());
prioritizedTypeNames = new String[] { "org.apache.uima.fit.type.Sentence",
"org.apache.uima.fit.type.Token" };
- engine = AnalysisEngineFactory.createEngine(
- org.apache.uima.fit.component.NoOpAnnotator.class, typeSystemDescription,
- prioritizedTypeNames, (Object[]) null);
+ engine = AnalysisEngineFactory.createEngine(org.apache.uima.fit.component.NoOpAnnotator.class,
+ typeSystemDescription, prioritizedTypeNames, (Object[]) null);
jCas = engine.newJCas();
tokenBuilder.buildTokens(jCas, "word");
- tokensInSentence = jCas.getAnnotationIndex().subiterator(
- JCasUtil.selectByIndex(jCas, Sentence.class, 0));
+ tokensInSentence = jCas.getAnnotationIndex()
+ .subiterator(JCasUtil.selectByIndex(jCas, Sentence.class, 0));
assertTrue(tokensInSentence.hasNext());
}
@@ -169,13 +169,13 @@ public class AnalysisEngineFactoryTest extends ComponentTestBase {
aggregateEngine.process(jCas);
assertEquals("Anyone up for a game of Foosball?", jCas.getDocumentText());
- assertEquals("Any(o)n(e) (u)p f(o)r (a) g(a)m(e) (o)f F(oo)sb(a)ll?", jCas.getView("A")
- .getDocumentText());
+ assertEquals("Any(o)n(e) (u)p f(o)r (a) g(a)m(e) (o)f F(oo)sb(a)ll?",
+ jCas.getView("A").getDocumentText());
assertEquals("?AFaaabeeffgllmnnoooooprsuy", jCas.getView("B").getDocumentText());
- assertEquals("(((((((((())))))))))?AFaaabeeffgllmnnoooooprsuy", jCas.getView("C")
- .getDocumentText());
- assertEquals("yusrpooooonnmllgffeebaaaFA?", jCas.getView(ViewNames.REVERSE_VIEW)
- .getDocumentText());
+ assertEquals("(((((((((())))))))))?AFaaabeeffgllmnnoooooprsuy",
+ jCas.getView("C").getDocumentText());
+ assertEquals("yusrpooooonnmllgffeebaaaFA?",
+ jCas.getView(ViewNames.REVERSE_VIEW).getDocumentText());
}
@@ -206,13 +206,13 @@ public class AnalysisEngineFactoryTest extends ComponentTestBase {
aggregateEngine.process(jCas);
assertEquals("Anyone up for a game of Foosball?", jCas.getDocumentText());
- assertEquals("Any(o)n(e) (u)p f(o)r (a) g(a)m(e) (o)f F(oo)sb(a)ll?", jCas.getView("A")
- .getDocumentText());
+ assertEquals("Any(o)n(e) (u)p f(o)r (a) g(a)m(e) (o)f F(oo)sb(a)ll?",
+ jCas.getView("A").getDocumentText());
assertEquals("?AFaaabeeffgllmnnoooooprsuy", jCas.getView("B").getDocumentText());
- assertEquals("(((((((((())))))))))?AFaaabeeffgllmnnoooooprsuy", jCas.getView("C")
- .getDocumentText());
- assertEquals("yusrpooooonnmllgffeebaaaFA?", jCas.getView(ViewNames.REVERSE_VIEW)
- .getDocumentText());
+ assertEquals("(((((((((())))))))))?AFaaabeeffgllmnnoooooprsuy",
+ jCas.getView("C").getDocumentText());
+ assertEquals("yusrpooooonnmllgffeebaaaFA?",
+ jCas.getView(ViewNames.REVERSE_VIEW).getDocumentText());
CasIOUtil.readJCas(jCas, new File("src/test/resources/data/docs/test.xmi"));
AnalysisEngine ae1 = AnalysisEngineFactory.createEngine(NoOpAnnotator.class,
@@ -224,8 +224,8 @@ public class AnalysisEngineFactoryTest extends ComponentTestBase {
@Test
public void testReflectPrimitiveDescription() throws ResourceInitializationException {
- AnalysisEngineDescription aed = AnalysisEngineFactory.createEngineDescription(
- Annotator2.class, typeSystemDescription, typePriorities);
+ AnalysisEngineDescription aed = AnalysisEngineFactory.createEngineDescription(Annotator2.class,
+ typeSystemDescription, typePriorities);
Capability[] capabilities = aed.getAnalysisEngineMetaData().getCapabilities();
assertEquals(1, capabilities.length);
String[] inputSofas = capabilities[0].getInputSofas();
@@ -289,11 +289,12 @@ public class AnalysisEngineFactoryTest extends ComponentTestBase {
testConfigurationParameter(aed, ParameterizedAE.PARAM_FLOAT_6,
ConfigurationParameter.TYPE_FLOAT, true, true, null);
testConfigurationParameter(aed, ParameterizedAE.PARAM_FLOAT_7,
- ConfigurationParameter.TYPE_FLOAT, true, true, new Float[] { 1.1111f, 2.2222f, 3.333f });
+ ConfigurationParameter.TYPE_FLOAT, true, true,
+ new Float[] { 1.1111f, 2.2222f, 3.333f });
- AnalysisEngine ae = AnalysisEngineFactory
- .createEngine(aed, ParameterizedAE.PARAM_FLOAT_3, 3.1415f,
- ParameterizedAE.PARAM_FLOAT_6, new Float[] { 2.71828183f }, "file2", "foo/bar");
+ AnalysisEngine ae = AnalysisEngineFactory.createEngine(aed, ParameterizedAE.PARAM_FLOAT_3,
+ 3.1415f, ParameterizedAE.PARAM_FLOAT_6, new Float[] { 2.71828183f }, "file2",
+ "foo/bar");
Object paramValue = ae.getAnalysisEngineMetaData().getConfigurationParameterSettings()
.getParameterValue(ParameterizedAE.PARAM_FLOAT_3);
assertEquals(paramValue, 3.1415f);
@@ -308,13 +309,11 @@ public class AnalysisEngineFactoryTest extends ComponentTestBase {
ConfigurationParameterDeclarations cpd = aed.getMetaData()
.getConfigurationParameterDeclarations();
ConfigurationParameter cp = cpd.getConfigurationParameter(null, parameterName);
- assertNotNull("Parameter [" + parameterName + "] does not exist!", cp);
- assertEquals("Parameter [" + parameterName + "] has wrong name", parameterName, cp.getName());
- assertEquals("Parameter [" + parameterName + "] has wrong type", parameterType, cp.getType());
- assertEquals("Parameter [" + parameterName + "] has wrong mandatory flag", mandatory,
- cp.isMandatory());
- assertEquals("Parameter [" + parameterName + "] has wrong multi-value flag", multiValued,
- cp.isMultiValued());
+ assertThat(cp).as("Parameter [%s] exists", parameterName).isNotNull();
+ assertThat(cp.getName()).isEqualTo(parameterName);
+ assertThat(cp.getType()).isEqualTo(parameterType);
+ assertThat(cp.isMandatory()).isEqualTo(mandatory);
+ assertThat(cp.isMultiValued()).isEqualTo(multiValued);
ConfigurationParameterSettings cps = aed.getMetaData().getConfigurationParameterSettings();
Object actualValue = cps.getParameterValue(parameterName);
if (parameterValue == null) {
@@ -338,8 +337,8 @@ public class AnalysisEngineFactoryTest extends ComponentTestBase {
@Test
public void testPrimitiveDescription() throws ResourceInitializationException {
- AnalysisEngineDescription aed = AnalysisEngineFactory.createEngineDescription(
- NoOpAnnotator.class, typeSystemDescription);
+ AnalysisEngineDescription aed = AnalysisEngineFactory
+ .createEngineDescription(NoOpAnnotator.class, typeSystemDescription);
assertNotNull(aed);
// assertEquals("org.apache.uima.fit.type.TypeSystem",
// aed.getAnalysisEngineMetaData().getTypeSystem().getImports()[0].getName());
@@ -351,102 +350,112 @@ public class AnalysisEngineFactoryTest extends ComponentTestBase {
*/
@Test
public void testComponentAnnotationOnAncestor() throws Exception {
- AnalysisEngineDescription desc1 = AnalysisEngineFactory.createEngineDescription(
- PristineAnnotatorClass.class, (Object[]) null);
- assertTrue(
- "Multiple deployment should be allowed on " + desc1.getAnnotatorImplementationName(),
- desc1.getAnalysisEngineMetaData().getOperationalProperties()
- .isMultipleDeploymentAllowed());
-
- AnalysisEngineDescription desc2 = AnalysisEngineFactory.createEngineDescription(
- UnannotatedAnnotatorClass.class, (Object[]) null);
- assertFalse(
- "Multiple deployment should be prohibited on " + desc2.getAnnotatorImplementationName(),
- desc2.getAnalysisEngineMetaData().getOperationalProperties()
- .isMultipleDeploymentAllowed());
-
- AnalysisEngineDescription desc3 = AnalysisEngineFactory.createEngineDescription(
- AnnotatedAnnotatorClass.class, (Object[]) null);
- assertTrue(
- "Multiple deployment should be allowed on " + desc3.getAnnotatorImplementationName(),
- desc3.getAnalysisEngineMetaData().getOperationalProperties()
- .isMultipleDeploymentAllowed());
+ AnalysisEngineDescription desc1 = AnalysisEngineFactory
+ .createEngineDescription(PristineAnnotatorClass.class, (Object[]) null);
+ assertThat(desc1.getAnalysisEngineMetaData().getOperationalProperties()
+ .isMultipleDeploymentAllowed())
+ .as("Multiple deployment should be allowed on %s",
+ desc1.getAnnotatorImplementationName())
+ .isTrue();
+
+ AnalysisEngineDescription desc2 = AnalysisEngineFactory
+ .createEngineDescription(UnannotatedAnnotatorClass.class, (Object[]) null);
+ assertThat(desc2.getAnalysisEngineMetaData().getOperationalProperties()
+ .isMultipleDeploymentAllowed())
+ .as("Multiple deployment should be prohibited on %s",
+ desc2.getAnnotatorImplementationName())
+ .isFalse();
+
+ AnalysisEngineDescription desc3 = AnalysisEngineFactory
+ .createEngineDescription(AnnotatedAnnotatorClass.class, (Object[]) null);
+ assertThat(desc3.getAnalysisEngineMetaData().getOperationalProperties()
+ .isMultipleDeploymentAllowed())
+ .as("Multiple deployment should be allowed on "
+ + desc3.getAnnotatorImplementationName())
+ .isTrue();
}
/*
* This test case illustrates that UIMA throws an exception unless the multipleDeploymentAllowed
* flag is properly set to false when mixing multi-deployment and non-multi-deployment AEs.
*/
- @Test(expected = ResourceInitializationException.class)
+ @Test
public void testAAEMultipleDeploymentPolicyProblem() throws Exception {
{
- AnalysisEngineDescription desc1 = AnalysisEngineFactory.createEngineDescription(
- PristineAnnotatorClass.class, (Object[]) null);
- assertTrue(
- "Multiple deployment should be allowed on " + desc1.getAnnotatorImplementationName(),
- desc1.getAnalysisEngineMetaData().getOperationalProperties()
- .isMultipleDeploymentAllowed());
-
- AnalysisEngineDescription desc2 = AnalysisEngineFactory.createEngineDescription(
- UnannotatedAnnotatorClass.class, (Object[]) null);
- assertFalse(
- "Multiple deployment should be prohibited on "
- + desc2.getAnnotatorImplementationName(), desc2.getAnalysisEngineMetaData()
- .getOperationalProperties().isMultipleDeploymentAllowed());
-
- AnalysisEngineDescription aae = AnalysisEngineFactory
- .createEngineDescription(desc1, desc2);
+ AnalysisEngineDescription desc1 = AnalysisEngineFactory
+ .createEngineDescription(PristineAnnotatorClass.class, (Object[]) null);
+ assertThat(desc1.getAnalysisEngineMetaData().getOperationalProperties()
+ .isMultipleDeploymentAllowed())
+ .as("Multiple deployment should be allowed on "
+ + desc1.getAnnotatorImplementationName())
+ .isTrue();
+
+ AnalysisEngineDescription desc2 = AnalysisEngineFactory
+ .createEngineDescription(UnannotatedAnnotatorClass.class, (Object[]) null);
+ assertThat(desc2.getAnalysisEngineMetaData().getOperationalProperties()
+ .isMultipleDeploymentAllowed())
+ .as("Multiple deployment should be prohibited on "
+ + desc2.getAnnotatorImplementationName())
+ .isFalse();
+
+ AnalysisEngineDescription aae = AnalysisEngineFactory.createEngineDescription(desc1, desc2);
aae.getAnalysisEngineMetaData().getOperationalProperties().setMultipleDeploymentAllowed(true);
- UIMAFramework.produceAnalysisEngine(aae);
+
+ assertThatExceptionOfType(ResourceInitializationException.class)
+ .isThrownBy(() -> UIMAFramework.produceAnalysisEngine(aae));
}
}
@Test
public void testAAEMultipleDeploymentPolicy() throws Exception {
{
- AnalysisEngineDescription desc1 = AnalysisEngineFactory.createEngineDescription(
- PristineAnnotatorClass.class, (Object[]) null);
- assertTrue(
- "Multiple deployment should be allowed on " + desc1.getAnnotatorImplementationName(),
- desc1.getAnalysisEngineMetaData().getOperationalProperties()
- .isMultipleDeploymentAllowed());
-
- AnalysisEngineDescription desc2 = AnalysisEngineFactory.createEngineDescription(
- UnannotatedAnnotatorClass.class, (Object[]) null);
- assertFalse(
- "Multiple deployment should be prohibited on "
- + desc2.getAnnotatorImplementationName(), desc2.getAnalysisEngineMetaData()
- .getOperationalProperties().isMultipleDeploymentAllowed());
-
- AnalysisEngineDescription aae = AnalysisEngineFactory
- .createEngineDescription(desc1, desc2);
+ AnalysisEngineDescription desc1 = AnalysisEngineFactory
+ .createEngineDescription(PristineAnnotatorClass.class, (Object[]) null);
+ assertThat(desc1.getAnalysisEngineMetaData().getOperationalProperties()
+ .isMultipleDeploymentAllowed())
+ .as("Multiple deployment should be allowed on "
+ + desc1.getAnnotatorImplementationName())
+ .isTrue();
+
+ AnalysisEngineDescription desc2 = createEngineDescription(UnannotatedAnnotatorClass.class,
+ (Object[]) null);
+ assertThat(desc2.getAnalysisEngineMetaData().getOperationalProperties()
+ .isMultipleDeploymentAllowed())
+ .as("Multiple deployment should be prohibited on "
+ + desc2.getAnnotatorImplementationName())
+ .isFalse();
+
+ AnalysisEngineDescription aae = createEngineDescription(desc1, desc2);
UIMAFramework.produceAnalysisEngine(aae);
- assertFalse("Multiple deployment should be prohibited on AAE", aae
- .getAnalysisEngineMetaData().getOperationalProperties().isMultipleDeploymentAllowed());
+ assertThat(aae.getAnalysisEngineMetaData().getOperationalProperties()
+ .isMultipleDeploymentAllowed()) //
+ .as("Multiple deployment should be prohibited on AAE").isFalse();
}
{
- AnalysisEngineDescription desc1 = AnalysisEngineFactory.createEngineDescription(
- PristineAnnotatorClass.class, (Object[]) null);
- assertTrue(
- "Multiple deployment should be allowed on " + desc1.getAnnotatorImplementationName(),
- desc1.getAnalysisEngineMetaData().getOperationalProperties()
- .isMultipleDeploymentAllowed());
-
- AnalysisEngineDescription desc3 = AnalysisEngineFactory.createEngineDescription(
- AnnotatedAnnotatorClass.class, (Object[]) null);
- assertTrue(
- "Multiple deployment should be allowed on " + desc3.getAnnotatorImplementationName(),
- desc3.getAnalysisEngineMetaData().getOperationalProperties()
- .isMultipleDeploymentAllowed());
-
- AnalysisEngineDescription aae = AnalysisEngineFactory
- .createEngineDescription(desc1, desc3);
+ AnalysisEngineDescription desc1 = AnalysisEngineFactory
+ .createEngineDescription(PristineAnnotatorClass.class, (Object[]) null);
+ assertThat(desc1.getAnalysisEngineMetaData().getOperationalProperties()
+ .isMultipleDeploymentAllowed())
+ .as("Multiple deployment should be allowed on "
+ + desc1.getAnnotatorImplementationName())
+ .isTrue();
+
+ AnalysisEngineDescription desc3 = AnalysisEngineFactory
+ .createEngineDescription(AnnotatedAnnotatorClass.class, (Object[]) null);
+ assertThat(desc3.getAnalysisEngineMetaData().getOperationalProperties()
+ .isMultipleDeploymentAllowed())
+ .as("Multiple deployment should be allowed on "
+ + desc3.getAnnotatorImplementationName())
+ .isTrue();
+
+ AnalysisEngineDescription aae = AnalysisEngineFactory.createEngineDescription(desc1, desc3);
UIMAFramework.produceAnalysisEngine(aae);
- assertTrue("Multiple deployment should be prohibited on AAE", aae.getAnalysisEngineMetaData()
- .getOperationalProperties().isMultipleDeploymentAllowed());
+ assertThat(aae.getAnalysisEngineMetaData().getOperationalProperties()
+ .isMultipleDeploymentAllowed()).as("Multiple deployment should be prohibited on AAE")
+ .isTrue();
}
}
@@ -501,19 +510,21 @@ public class AnalysisEngineFactoryTest extends ComponentTestBase {
AnalysisEngineFactory.createEngineDescription(ParameterizedAE.class, typeSystemDescription);
}
- @Test(expected = ResourceInitializationException.class)
+ @Test
public void testIssue5b() throws ResourceInitializationException {
- AnalysisEngineFactory.createEngine(ParameterizedAE.class, typeSystemDescription);
+ assertThatExceptionOfType(ResourceInitializationException.class) //
+ .isThrownBy(() -> createEngine(ParameterizedAE.class, typeSystemDescription));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testUnbalancedComponentAndNames() throws ResourceInitializationException {
List<AnalysisEngineDescription> descriptions = new ArrayList<AnalysisEngineDescription>();
descriptions.add(AnalysisEngineFactory.createEngineDescription(NoOpAnnotator.class));
descriptions.add(AnalysisEngineFactory.createEngineDescription(NoOpAnnotator.class));
List<String> names = new ArrayList<String>();
- createEngineDescription(descriptions, names, null, null, null);
+ assertThatExceptionOfType(IllegalArgumentException.class) //
+ .isThrownBy(() -> createEngineDescription(descriptions, names, null, null, null));
}
/**
@@ -533,120 +544,120 @@ public class AnalysisEngineFactoryTest extends ComponentTestBase {
typeSystem, null, null, null, null, null, null);
// Try configuring priorities on the aggregate
- AnalysisEngineDescription aae = createEngineDescription(asList(ae), asList("ae1"),
- extraPrios, null, null);
+ AnalysisEngineDescription aae = createEngineDescription(asList(ae), asList("ae1"), extraPrios,
+ null, null);
AnalysisEngine engine = createEngine(aae);
ProcessingResourceMetaData meta = engine.getProcessingResourceMetaData();
-
- // When the meta data from the ae and the aae are merged in the engine, then it should be a
+
+ // When the meta data from the ae and the aae are merged in the engine, then it should be a
// new instance.
- assertFalse("Merged meta-data is same instance as original",
- aae.getMetaData().hashCode() == meta.hashCode());
- assertFalse("Merged meta-data is same instance as original",
- ae.getMetaData().hashCode() == meta.hashCode());
-
+ assertThat(aae.getMetaData()) //
+ .as("Merged meta-data is not same instance as original") //
+ .isNotSameAs(meta);
+ assertThat(ae.getMetaData()) //
+ .as("Merged meta-data is not same instance as original") //
+ .isNotSameAs(meta);
+
// Check that the priorities arrived
TypePriorities expected = ((ProcessingResourceMetaData) aae.getMetaData()).getTypePriorities();
TypePriorities actual = meta.getTypePriorities();
assertArrayEquals(expected.getPriorityLists()[0].getTypes(),
actual.getPriorityLists()[0].getTypes());
}
-
+
@Test
public void serializeComponent() throws Exception {
File reference = new File("src/test/resources/data/reference/SerializationTestAnnotator.xml");
-
- File target = new File("target/test-output/AnalysisEngineFactoryTest/SerializationTestAnnotator.xml");
+
+ File target = new File(
+ "target/test-output/AnalysisEngineFactoryTest/SerializationTestAnnotator.xml");
target.getParentFile().mkdirs();
-
+
AnalysisEngineDescription desc = createEngineDescription(SerializationTestAnnotator.class);
try (OutputStream os = new FileOutputStream(target)) {
desc.toXML(os);
}
-
+
String actual = FileUtils.readFileToString(target, "UTF-8");
String expected = FileUtils.readFileToString(reference, "UTF-8");
XmlAssert.assertThat(actual).and(expected).ignoreWhitespace().areIdentical();
}
-
+
@Test
public void testPear() throws Exception {
// Install PEAR package
PackageBrowser instPear = PackageInstaller.installPackage(
- new File("target/test-output/AnalysisEngineFactoryTest/testPear"),
+ new File("target/test-output/AnalysisEngineFactoryTest/testPear"),
new File("src/test/resources/pear/DateTime.pear"), true);
// Create analysis engine from the installed PEAR package
XMLInputSource in = new XMLInputSource(instPear.getComponentPearDescPath());
PearSpecifier specifier = UIMAFramework.getXMLParser().parsePearSpecifier(in);
-
+
AnalysisEngine ae = createEngine(createEngineDescription(specifier));
-
- // Create a CAS with a sample document text and process the CAS
+
+ // Create a CAS with a sample document text and process the CAS
CAS cas = ae.newCAS();
cas.setDocumentText("Sample text to process with a date 05/29/07 and a time 9:45 AM");
cas.setDocumentLanguage("en");
ae.process(cas);
}
-
+
@Test
- public void thatCreateEngineDescriptorAutoDetectionWorks() throws Exception
- {
+ public void thatCreateEngineDescriptorAutoDetectionWorks() throws Exception {
AnalysisEngineDescription aed = createEngineDescription(NoOpAnnotator.class);
-
+
TypeSystemDescription tsd = createTypeSystemDescription();
- assertThat(tsd.getType(Token.class.getName()))
- .as("Token type auto-detection")
- .isNotNull();
- assertThat(tsd.getType(Sentence.class.getName()))
- .as("Sentence type auto-detection")
- .isNotNull();
- assertThat(tsd.getType(AnalyzedText.class.getName()))
- .as("AnalyzedText type auto-detection")
- .isNotNull();
+ assertThat(tsd.getType(Token.class.getName())).as("Token type auto-detection").isNotNull();
+ assertThat(tsd.getType(Sentence.class.getName())).as("Sentence type auto-detection")
+ .isNotNull();
+ assertThat(tsd.getType(AnalyzedText.class.getName())).as("AnalyzedText type auto-detection")
+ .isNotNull();
TypePriorityList[] typePrioritiesLists = typePriorities.getPriorityLists();
assertThat(typePrioritiesLists.length).isEqualTo(1);
- assertThat(typePrioritiesLists[0].getTypes())
- .as("Type priorities auto-detection")
- .containsExactly(Sentence.class.getName(), AnalyzedText.class.getName(), Token.class.getName());
+ assertThat(typePrioritiesLists[0].getTypes()).as("Type priorities auto-detection")
+ .containsExactly(Sentence.class.getName(), AnalyzedText.class.getName(),
+ Token.class.getName());
- FsIndexDescription[] indexes = aed.getAnalysisEngineMetaData().getFsIndexCollection().getFsIndexes();
+ FsIndexDescription[] indexes = aed.getAnalysisEngineMetaData().getFsIndexCollection()
+ .getFsIndexes();
assertThat(indexes.length).isEqualTo(1);
- assertThat(indexes[0])
- .extracting(FsIndexDescription::getLabel, FsIndexDescription::getTypeName, FsIndexDescription::getKind)
- .containsExactly("Automatically Scanned Index", Token.class.getName(), FsIndexDescription.KIND_SORTED);
+ assertThat(indexes[0]).extracting(FsIndexDescription::getLabel, FsIndexDescription::getTypeName,
+ FsIndexDescription::getKind).containsExactly("Automatically Scanned Index",
+ Token.class.getName(), FsIndexDescription.KIND_SORTED);
}
-
+
@Test
public void thatGenerationOfDelegateKeysWorks() {
- AnalysisEngineDescription desc = getResourceSpecifierFactory().createAnalysisEngineDescription();
+ AnalysisEngineDescription desc = getResourceSpecifierFactory()
+ .createAnalysisEngineDescription();
desc.setImplementationName("i.am.a.Teapot");
-
+
desc.setPrimitive(false);
assertThat(generateDelegateKey(desc, 0)) //
- .as("Aggregates use 'aggregate' if no name is set in their metadata") //
- .isEqualTo("aggregate-0");
+ .as("Aggregates use 'aggregate' if no name is set in their metadata") //
+ .isEqualTo("aggregate-0");
desc.setPrimitive(true);
assertThat(generateDelegateKey(desc, 0)) //
- .as("Primitives use the class name if no name is set in their metadata") //
- .isEqualTo("i.am.a.Teapot-0");
+ .as("Primitives use the class name if no name is set in their metadata") //
+ .isEqualTo("i.am.a.Teapot-0");
desc.setPrimitive(true);
desc.getAnalysisEngineMetaData().setName("Primitive");
assertThat(generateDelegateKey(desc, 0)) //
- .as("If a name is set in the metdata, that is used") //
- .isEqualTo("Primitive-0");
+ .as("If a name is set in the metdata, that is used") //
+ .isEqualTo("Primitive-0");
desc.setPrimitive(false);
desc.getAnalysisEngineMetaData().setName("Aggregate");
assertThat(generateDelegateKey(desc, 0)) //
- .as("If a name is set in the metdata, that is used") //
- .isEqualTo("Aggregate-0");
+ .as("If a name is set in the metdata, that is used") //
+ .isEqualTo("Aggregate-0");
}
-
+
@Test
public void thatDelegateKeySanitationWorks() {
assertThat(sanitizeDelegateKey(null)).isEqualTo(null);
diff --git a/uimafit-core/src/test/java/org/apache/uima/fit/factory/AnnotationFactoryTest.java b/uimafit-core/src/test/java/org/apache/uima/fit/factory/AnnotationFactoryTest.java
index ed35b05..0ff5185 100644
--- a/uimafit-core/src/test/java/org/apache/uima/fit/factory/AnnotationFactoryTest.java
+++ b/uimafit-core/src/test/java/org/apache/uima/fit/factory/AnnotationFactoryTest.java
@@ -18,12 +18,12 @@
*/
package org.apache.uima.fit.factory;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import org.apache.uima.fit.ComponentTestBase;
import org.apache.uima.fit.type.Sentence;
import org.apache.uima.fit.type.Token;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class AnnotationFactoryTest extends ComponentTestBase {
diff --git a/uimafit-core/src/test/java/org/apache/uima/fit/factory/CollectionReaderFactoryExternalResourceTest.java b/uimafit-core/src/test/java/org/apache/uima/fit/factory/CollectionReaderFactoryExternalResourceTest.java
index 570fbc6..b999ff6 100644
--- a/uimafit-core/src/test/java/org/apache/uima/fit/factory/CollectionReaderFactoryExternalResourceTest.java
+++ b/uimafit-core/src/test/java/org/apache/uima/fit/factory/CollectionReaderFactoryExternalResourceTest.java
@@ -40,7 +40,7 @@ package org.apache.uima.fit.factory;
import static org.apache.uima.fit.factory.CollectionReaderFactory.createReader;
import static org.apache.uima.fit.factory.ExternalResourceFactory.createResourceDescription;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.io.IOException;
@@ -52,18 +52,16 @@ import org.apache.uima.fit.component.CasCollectionReader_ImplBase;
import org.apache.uima.fit.descriptor.ExternalResource;
import org.apache.uima.fit.factory.testRes.TestExternalResource;
import org.apache.uima.util.Progress;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*/
public class CollectionReaderFactoryExternalResourceTest {
@Test
public void testAutoExternalResourceBinding() throws UIMAException, IOException {
- CollectionReader reader = createReader(
- TestReader.class,
- TestReader.PARAM_RESOURCE,
- createResourceDescription(TestExternalResource.class,
- TestExternalResource.PARAM_VALUE, TestExternalResource.EXPECTED_VALUE));
+ CollectionReader reader = createReader(TestReader.class, TestReader.PARAM_RESOURCE,
+ createResourceDescription(TestExternalResource.class, TestExternalResource.PARAM_VALUE,
+ TestExternalResource.EXPECTED_VALUE));
reader.hasNext();
}
diff --git a/uimafit-core/src/test/java/org/apache/uima/fit/factory/CollectionReaderFactoryTest.java b/uimafit-core/src/test/java/org/apache/uima/fit/factory/CollectionReaderFactoryTest.java
index e2f1a73..eef5429 100644
--- a/uimafit-core/src/test/java/org/apache/uima/fit/factory/CollectionReaderFactoryTest.java
+++ b/uimafit-core/src/test/java/org/apache/uima/fit/factory/CollectionReaderFactoryTest.java
@@ -23,8 +23,8 @@ import static org.apache.uima.fit.factory.CollectionReaderFactory.createReaderDe
import static org.apache.uima.fit.factory.CollectionReaderFactory.createReaderFromPath;
import static org.apache.uima.fit.factory.TypeSystemDescriptionFactory.createTypeSystemDescription;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.io.IOException;
@@ -47,17 +47,17 @@ import org.apache.uima.resource.metadata.FsIndexDescription;
import org.apache.uima.resource.metadata.TypePriorityList;
import org.apache.uima.resource.metadata.TypeSystemDescription;
import org.apache.uima.util.Progress;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class CollectionReaderFactoryTest extends ComponentTestBase {
@Test
public void testCreateCollectionReader() throws UIMAException, IOException {
- CollectionReader reader = CollectionReaderFactory.createReader(
- SingleFileXReader.class, typeSystemDescription,
- SingleFileXReader.PARAM_FILE_NAME, "src/test/resources/data/docs/test.xmi",
- SingleFileXReader.PARAM_XML_SCHEME, SingleFileXReader.XMI);
+ CollectionReader reader = CollectionReaderFactory.createReader(SingleFileXReader.class,
+ typeSystemDescription, SingleFileXReader.PARAM_FILE_NAME,
+ "src/test/resources/data/docs/test.xmi", SingleFileXReader.PARAM_XML_SCHEME,
+ SingleFileXReader.XMI);
JCasIterator jCasIterator = new JCasIterator(reader, typeSystemDescription);
jCas = jCasIterator.next();
@@ -68,8 +68,7 @@ public class CollectionReaderFactoryTest extends ComponentTestBase {
assertEquals("A", token.getPos());
assertEquals("all", token.getStem());
- reader = createReader(
- "org.apache.uima.fit.factory.testCrs.SingleFileXReader",
+ reader = createReader("org.apache.uima.fit.factory.testCrs.SingleFileXReader",
SingleFileXReader.PARAM_FILE_NAME, "src/test/resources/data/docs/test.xmi",
SingleFileXReader.PARAM_XML_SCHEME, SingleFileXReader.XMI);
@@ -109,42 +108,37 @@ public class CollectionReaderFactoryTest extends ComponentTestBase {
}
@Test
- public void thatCreateReaderDescriptorAutoDetectionWorks() throws Exception
- {
+ public void thatCreateReaderDescriptorAutoDetectionWorks() throws Exception {
CollectionReaderDescription aed = createReaderDescription(TestCR.class);
-
+
TypeSystemDescription tsd = createTypeSystemDescription();
- assertThat(tsd.getType(Token.class.getName()))
- .as("Token type auto-detection")
- .isNotNull();
- assertThat(tsd.getType(Sentence.class.getName()))
- .as("Sentence type auto-detection")
- .isNotNull();
- assertThat(tsd.getType(AnalyzedText.class.getName()))
- .as("AnalyzedText type auto-detection")
- .isNotNull();
+ assertThat(tsd.getType(Token.class.getName())).as("Token type auto-detection").isNotNull();
+ assertThat(tsd.getType(Sentence.class.getName())).as("Sentence type auto-detection")
+ .isNotNull();
+ assertThat(tsd.getType(AnalyzedText.class.getName())).as("AnalyzedText type auto-detection")
+ .isNotNull();
TypePriorityList[] typePrioritiesLists = typePriorities.getPriorityLists();
assertThat(typePrioritiesLists.length).isEqualTo(1);
- assertThat(typePrioritiesLists[0].getTypes())
- .as("Type priorities auto-detection")
- .containsExactly(Sentence.class.getName(), AnalyzedText.class.getName(), Token.class.getName());
+ assertThat(typePrioritiesLists[0].getTypes()).as("Type priorities auto-detection")
+ .containsExactly(Sentence.class.getName(), AnalyzedText.class.getName(),
+ Token.class.getName());
- FsIndexDescription[] indexes = aed.getCollectionReaderMetaData().getFsIndexCollection().getFsIndexes();
+ FsIndexDescription[] indexes = aed.getCollectionReaderMetaData().getFsIndexCollection()
+ .getFsIndexes();
assertThat(indexes.length).isEqualTo(1);
- assertThat(indexes[0])
- .extracting(FsIndexDescription::getLabel, FsIndexDescription::getTypeName, FsIndexDescription::getKind)
- .containsExactly("Automatically Scanned Index", Token.class.getName(), FsIndexDescription.KIND_SORTED);
+ assertThat(indexes[0]).extracting(FsIndexDescription::getLabel, FsIndexDescription::getTypeName,
+ FsIndexDescription::getKind).containsExactly("Automatically Scanned Index",
+ Token.class.getName(), FsIndexDescription.KIND_SORTED);
}
@Test
- public void testResourceMetaData() throws Exception
- {
+ public void testResourceMetaData() throws Exception {
CollectionReaderDescription desc = CollectionReaderFactory
.createReaderDescription(TestCR.class);
-
+
org.apache.uima.resource.metadata.ResourceMetaData meta = desc.getMetaData();
-
+
assertEquals("dummy", meta.getName());
assertEquals("1.0", meta.getVersion());
assertEquals("Just a dummy", meta.getDescription());
@@ -152,8 +146,6 @@ public class CollectionReaderFactoryTest extends ComponentTestBase {
assertEquals("uimaFIT", meta.getVendor());
}
-
-
@ResourceMetaData(name = "dummy", version = "1.0", description = "Just a dummy", copyright = "ASL 2.0", vendor = "uimaFIT")
private class TestCR extends CollectionReader_ImplBase {
diff --git a/uimafit-core/src/test/java/org/apache/uima/fit/factory/ConfigurationParameterFactoryTest.java b/uimafit-core/src/test/java/org/apache/uima/fit/factory/ConfigurationParameterFactoryTest.java
index 1fb52f3..ce25600 100644
--- a/uimafit-core/src/test/java/org/apache/uima/fit/factory/ConfigurationParameterFactoryTest.java
+++ b/uimafit-core/src/test/java/org/apache/uima/fit/factory/ConfigurationParameterFactoryTest.java
@@ -18,14 +18,16 @@
*/
package org.apache.uima.fit.factory;
+import static org.apache.uima.fit.factory.ConfigurationParameterFactory.createPrimitiveParameter;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.entry;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
import java.lang.reflect.Field;
@@ -37,15 +39,17 @@ import org.apache.uima.fit.descriptor.ConfigurationParameter;
import org.apache.uima.resource.impl.Parameter_impl;
import org.apache.uima.resource.impl.PearSpecifier_impl;
import org.apache.uima.resource.metadata.impl.NameValuePair_impl;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class ConfigurationParameterFactoryTest {
public static final String PARAM_DOUBLE_1 = "double1";
+
@ConfigurationParameter(name = PARAM_DOUBLE_1, mandatory = true, defaultValue = "3.1415")
private Double double1;
public static final String PARAM_DOUBLE_2 = "double2";
+
@ConfigurationParameter(name = PARAM_DOUBLE_2, mandatory = true, defaultValue = "3.3333")
private Double[] double2;
@@ -88,18 +92,19 @@ public class ConfigurationParameterFactoryTest {
IllegalArgumentException iae = null;
try {
- ConfigurationParameterFactory.getDefaultValue(ConfigurationParameterFactoryTest.class
- .getDeclaredField("double3"));
+ ConfigurationParameterFactory
+ .getDefaultValue(ConfigurationParameterFactoryTest.class.getDeclaredField("double3"));
} catch (IllegalArgumentException e) {
iae = e;
}
assertNotNull(iae);
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void test2() throws Exception {
- ConfigurationParameterFactory.createPrimitiveParameter(ConfigurationParameterFactoryTest.class
- .getDeclaredField("double3"));
+ assertThatExceptionOfType(IllegalArgumentException.class)
+ .isThrownBy(() -> createPrimitiveParameter(
+ ConfigurationParameterFactoryTest.class.getDeclaredField("double3")));
}
@ConfigurationParameter
@@ -111,7 +116,8 @@ public class ConfigurationParameterFactoryTest {
org.apache.uima.resource.metadata.ConfigurationParameter cp = ConfigurationParameterFactory
.createPrimitiveParameter(field1);
assertEquals("param1", cp.getName());
- assertEquals(org.apache.uima.resource.metadata.ConfigurationParameter.TYPE_STRING, cp.getType());
+ assertEquals(org.apache.uima.resource.metadata.ConfigurationParameter.TYPE_STRING,
+ cp.getType());
assertEquals("", cp.getDescription());
assertTrue(cp.isMandatory());
assertFalse(cp.isMultiValued());
@@ -170,7 +176,8 @@ public class ConfigurationParameterFactoryTest {
org.apache.uima.resource.metadata.ConfigurationParameter cp = ConfigurationParameterFactory
.createPrimitiveParameter(field4);
assertEquals("param4", cp.getName());
- assertEquals(org.apache.uima.resource.metadata.ConfigurationParameter.TYPE_STRING, cp.getType());
+ assertEquals(org.apache.uima.resource.metadata.ConfigurationParameter.TYPE_STRING,
+ cp.getType());
assertEquals("", cp.getDescription());
assertTrue(cp.isMandatory());
assertTrue(cp.isMultiValued());
@@ -225,13 +232,12 @@ public class ConfigurationParameterFactoryTest {
spec.setPearParameters( //
new NameValuePair_impl("modernKey", 1), //
new NameValuePair_impl("key", true));
-
+
Map<String, Object> params = ConfigurationParameterFactory.getParameterSettings(spec);
-
+
assertThat(params).containsOnly( //
entry("legacyKey", "legacyValue"), //
- entry("modernKey", 1),
- entry("key", true));
+ entry("modernKey", 1), entry("key", true));
}
@Test
@@ -240,7 +246,7 @@ public class ConfigurationParameterFactoryTest {
spec.setPearParameters(new NameValuePair_impl("key", 1));
ConfigurationParameterFactory.setParameter(spec, "key", 2);
-
+
assertThat(spec.getPearParameters()).containsOnly(new NameValuePair_impl("key", 2));
}
@@ -249,7 +255,7 @@ public class ConfigurationParameterFactoryTest {
PearSpecifier_impl spec = new PearSpecifier_impl();
ConfigurationParameterFactory.setParameter(spec, "key", "value");
-
+
assertThat(spec.getPearParameters()).containsOnly(new NameValuePair_impl("key", "value"));
}
@@ -260,7 +266,8 @@ public class ConfigurationParameterFactoryTest {
spec.setParameters(new Parameter_impl("legacyKey", "legacyValue"));
ConfigurationParameterFactory.setParameter(spec, "legacyKey", "newLegacyValue");
-
- assertThat(spec.getParameters()).containsOnly(new Parameter_impl("legacyKey", "newLegacyValue"));
+
+ assertThat(spec.getParameters())
+ .containsOnly(new Parameter_impl("legacyKey", "newLegacyValue"));
}
}
diff --git a/uimafit-core/src/test/java/org/apache/uima/fit/factory/ConfigurationParameterFactory_ParameterValueConversionTest.java b/uimafit-core/src/test/java/org/apache/uima/fit/factory/ConfigurationParameterFactory_ParameterValueConversionTest.java
index d42dbfc..c8822f6 100644
--- a/uimafit-core/src/test/java/org/apache/uima/fit/factory/ConfigurationParameterFactory_ParameterValueConversionTest.java
+++ b/uimafit-core/src/test/java/org/apache/uima/fit/factory/ConfigurationParameterFactory_ParameterValueConversionTest.java
@@ -39,7 +39,7 @@ import java.util.Locale;
import java.util.function.BiFunction;
import org.apache.uima.resource.metadata.ConfigurationParameter;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class ConfigurationParameterFactory_ParameterValueConversionTest {
@Test
diff --git a/uimafit-core/src/test/java/org/apache/uima/fit/factory/ExternalResourceConfiguratorTest.java b/uimafit-core/src/test/java/org/apache/uima/fit/factory/ExternalResourceConfiguratorTest.java
index 049a692..a8568e8 100644
--- a/uimafit-core/src/test/java/org/apache/uima/fit/factory/ExternalResourceConfiguratorTest.java
+++ b/uimafit-core/src/test/java/org/apache/uima/fit/factory/ExternalResourceConfiguratorTest.java
@@ -21,8 +21,8 @@ package org.apache.uima.fit.factory;
import static org.apache.uima.fit.factory.AnalysisEngineFactory.createEngineDescription;
import static org.apache.uima.fit.factory.ExternalResourceFactory.createResourceDependencies;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.util.HashMap;
import java.util.Map;
@@ -32,7 +32,7 @@ import org.apache.uima.fit.ComponentTestBase;
import org.apache.uima.fit.component.initialize.ExternalResourceInitializer;
import org.apache.uima.fit.factory.testAes.ParameterizedAE2;
import org.apache.uima.resource.ExternalResourceDependency;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Test the {@link ExternalResourceInitializer}.
diff --git a/uimafit-core/src/test/java/org/apache/uima/fit/factory/ExternalResourceFactoryTest.java b/uimafit-core/src/test/java/org/apache/uima/fit/factory/ExternalResourceFactoryTest.java
index 6bc7b2f..9332808 100644
--- a/uimafit-core/src/test/java/org/apache/uima/fit/factory/ExternalResourceFactoryTest.java
+++ b/uimafit-core/src/test/java/org/apache/uima/fit/factory/ExternalResourceFactoryTest.java
@@ -29,10 +29,11 @@ import static org.apache.uima.fit.factory.ExternalResourceFactory.createResource
import static org.apache.uima.fit.factory.ExternalResourceFactory.createSharedResourceDescription;
import static org.apache.uima.fit.factory.JCasFactory.createJCas;
import static org.apache.uima.fit.pipeline.SimplePipeline.runPipeline;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
import java.io.IOException;
@@ -74,8 +75,8 @@ import org.apache.uima.resource.ResourceInitializationException;
import org.apache.uima.resource.SharedResourceObject;
import org.apache.uima.util.CasCreationUtils;
import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.springframework.mock.jndi.SimpleNamingContextBuilder;
/**
@@ -90,7 +91,7 @@ public class ExternalResourceFactoryTest extends ComponentTestBase {
private static final String EX_FILE_3 = "src/test/resources/data/docs/test.xmi";
- @BeforeClass
+ @BeforeAll
public static void initJNDI() throws Exception {
// Set up JNDI context to test the JndiResourceLocator
final SimpleNamingContextBuilder builder = new SimpleNamingContextBuilder();
@@ -101,7 +102,8 @@ public class ExternalResourceFactoryTest extends ComponentTestBase {
}
/**
- * This is a test for a regression introduced in the UIMA SDK 2.6.0 RC 1 and which worked in UIMA SDK 2.5.0.
+ * This is a test for a regression introduced in the UIMA SDK 2.6.0 RC 1 and which worked in UIMA
+ * SDK 2.5.0.
* <ul>
* <li>Add a full delegate description to an AAE.</li>
* <li>Serialize to XML: delegate description is serialized.</li>
@@ -120,16 +122,16 @@ public class ExternalResourceFactoryTest extends ComponentTestBase {
StringWriter outerXml = new StringWriter();
outer.toXML(outerXml);
-
+
// Resolving the imports removes the inner AE description
outer.resolveImports(ResourceManagerFactory.newResourceManager());
-
+
StringWriter outerXml2 = new StringWriter();
outer.toXML(outerXml2);
Assert.assertEquals(outerXml.toString(), outerXml2.toString());
}
-
+
/**
* Illustrate two different paths of accessing a resource instance.
*
@@ -137,20 +139,18 @@ public class ExternalResourceFactoryTest extends ComponentTestBase {
*/
@Test
public void testAccessResourceFromAE() throws Exception {
- AnalysisEngine ae = createEngine(
- DummyAE3.class,
- DummyAE3.RES_KEY_1, createNamedResourceDescription(
- "lala", AnnotatedResource.class,
+ AnalysisEngine ae = createEngine(DummyAE3.class, DummyAE3.RES_KEY_1,
+ createNamedResourceDescription("lala", AnnotatedResource.class,
AnnotatedResource.PARAM_VALUE, "1"));
// Two difference paths to access the resource
Object resourceInstance1 = ae.getUimaContext().getResourceObject(DummyAE3.RES_KEY_1);
- Object resourceInstance2 = ae.getResourceManager().getResource(
- ae.getUimaContextAdmin().getQualifiedContextName() + DummyAE3.RES_KEY_1);
-
+ Object resourceInstance2 = ae.getResourceManager()
+ .getResource(ae.getUimaContextAdmin().getQualifiedContextName() + DummyAE3.RES_KEY_1);
+
assertEquals(resourceInstance1, resourceInstance2);
}
-
+
@Test
public void testScanBind() throws Exception {
// Create analysis enginge description
@@ -222,10 +222,10 @@ public class ExternalResourceFactoryTest extends ComponentTestBase {
ExternalResourceDescription extDesc = createResourceDescription(ResourceWithAssert.class);
// Binding external resource to each Annotator individually
- AnalysisEngineDescription aed1 = createEngineDescription(MultiBindAE.class,
- MultiBindAE.RES_KEY, extDesc);
- AnalysisEngineDescription aed2 = createEngineDescription(MultiBindAE.class,
- MultiBindAE.RES_KEY, extDesc);
+ AnalysisEngineDescription aed1 = createEngineDescription(MultiBindAE.class, MultiBindAE.RES_KEY,
+ extDesc);
+ AnalysisEngineDescription aed2 = createEngineDescription(MultiBindAE.class, MultiBindAE.RES_KEY,
+ extDesc);
// Check the external resource was injected
MultiBindAE.reset();
@@ -233,12 +233,11 @@ public class ExternalResourceFactoryTest extends ComponentTestBase {
AnalysisEngine ae = createEngine(aed);
ae.process(ae.newJCas());
-
// Check the external resource was injected
MultiBindAE.reset();
SimplePipeline.runPipeline(CasCreationUtils.createCas(aed), aed);
}
-
+
@Test
public void testMultiBoundNested() throws Exception {
ExternalResourceDescription extDesc = createResourceDescription(
@@ -247,10 +246,10 @@ public class ExternalResourceFactoryTest extends ComponentTestBase {
createResourceDescription(ResourceWithAssert.class));
// Binding external resource to each Annotator individually
- AnalysisEngineDescription aed1 = createEngineDescription(MultiBindAE.class,
- MultiBindAE.RES_KEY, extDesc);
- AnalysisEngineDescription aed2 = createEngineDescription(MultiBindAE.class,
- MultiBindAE.RES_KEY, extDesc);
+ AnalysisEngineDescription aed1 = createEngineDescription(MultiBindAE.class, MultiBindAE.RES_KEY,
+ extDesc);
+ AnalysisEngineDescription aed2 = createEngineDescription(MultiBindAE.class, MultiBindAE.RES_KEY,
+ extDesc);
// Check the external resource was injected
MultiBindAE.reset();
@@ -258,13 +257,12 @@ public class ExternalResourceFactoryTest extends ComponentTestBase {
AnalysisEngine ae = createEngine(aed);
ae.process(ae.newJCas());
-
// Check the external resource was injected
MultiBindAE.reset();
-// SimplePipeline.runPipeline(CasCreationUtils.createCas(aed.getAnalysisEngineMetaData()), aed);
+ // SimplePipeline.runPipeline(CasCreationUtils.createCas(aed.getAnalysisEngineMetaData()), aed);
SimplePipeline.runPipeline(ae.newCAS(), aed);
}
-
+
/**
* Test resource list.
*/
@@ -275,7 +273,7 @@ public class ExternalResourceFactoryTest extends ComponentTestBase {
AnalysisEngineDescription aed = createEngineDescription(MultiValuedResourceAE.class,
MultiValuedResourceAE.RES_RESOURCE_ARRAY, asList(extDesc1, extDesc2));
-
+
AnalysisEngine ae = createEngine(aed);
ae.process(ae.newJCas());
ae.collectionProcessComplete();
@@ -287,7 +285,7 @@ public class ExternalResourceFactoryTest extends ComponentTestBase {
@Test
public void testMultiValue2() throws Exception {
MultiValuedResourceAE.resources.clear();
-
+
ExternalResourceDescription extDesc1 = createResourceDescription(ResourceWithAssert.class);
ExternalResourceDescription extDesc2 = createResourceDescription(ResourceWithAssert.class);
@@ -296,10 +294,10 @@ public class ExternalResourceFactoryTest extends ComponentTestBase {
MultiValuedResourceAE.RES_RESOURCE_ARRAY, asList(extDesc1, extDesc2)),
createEngineDescription(MultiValuedResourceAE.class,
MultiValuedResourceAE.RES_RESOURCE_ARRAY, asList(extDesc1, extDesc2)));
-
+
AnalysisEngine ae = createEngine(aed);
ae.process(ae.newJCas());
-
+
// Check that the shared resources are really the same
assertEquals(MultiValuedResourceAE.resources.get(0), MultiValuedResourceAE.resources.get(2));
assertEquals(MultiValuedResourceAE.resources.get(1), MultiValuedResourceAE.resources.get(3));
@@ -311,7 +309,7 @@ public class ExternalResourceFactoryTest extends ComponentTestBase {
@Test
public void testMultiValue3() throws Exception {
MultiValuedResourceAE.resources.clear();
-
+
ExternalResourceDescription extDesc1 = createResourceDescription(ResourceWithAssert.class);
ExternalResourceDescription extDesc2 = createResourceDescription(ResourceWithAssert.class);
@@ -320,7 +318,7 @@ public class ExternalResourceFactoryTest extends ComponentTestBase {
MultiValuedResourceAE.RES_RESOURCE_ARRAY, asList(extDesc1, extDesc2)),
createEngineDescription(createEngineDescription(MultiValuedResourceAE.class,
MultiValuedResourceAE.RES_RESOURCE_ARRAY, asList(extDesc1, extDesc2))));
-
+
AnalysisEngine ae = createEngine(aed);
ae.process(ae.newJCas());
@@ -336,21 +334,21 @@ public class ExternalResourceFactoryTest extends ComponentTestBase {
public void testMultiValue4() throws Exception {
ExternalResourceDescription extDesc1 = createResourceDescription(ResourceWithAssert.class);
ExternalResourceDescription extDesc2 = createResourceDescription(ResourceWithAssert.class);
-
+
ExternalResourceDescription extDesc3 = createResourceDescription(ResourceWithAssert.class);
ExternalResourceDescription extDesc4 = createResourceDescription(ResourceWithAssert.class);
ExternalResourceDescription mv1 = createResourceDescription(MultiValuedResource.class,
- MultiValuedResource.RES_RESOURCE_LIST, new ExternalResourceDescription[] { extDesc1,
- extDesc2 });
+ MultiValuedResource.RES_RESOURCE_LIST,
+ new ExternalResourceDescription[] { extDesc1, extDesc2 });
ExternalResourceDescription mv2 = createResourceDescription(MultiValuedResource.class,
- MultiValuedResource.RES_RESOURCE_LIST, new ExternalResourceDescription[] { extDesc3,
- extDesc4 });
+ MultiValuedResource.RES_RESOURCE_LIST,
+ new ExternalResourceDescription[] { extDesc3, extDesc4 });
AnalysisEngineDescription aed = createEngineDescription(MultiValuedResourceAE.class,
MultiValuedResourceAE.RES_RESOURCE_ARRAY, asList(mv1, mv2));
-
+
AnalysisEngine ae = createEngine(aed);
ae.process(ae.newJCas());
ae.collectionProcessComplete();
@@ -399,31 +397,31 @@ public class ExternalResourceFactoryTest extends ComponentTestBase {
public static class ResourceDependent extends JCasAnnotator_ImplBase {
- @ExternalResource(key = DummyResource.RESOURCE_KEY)
- private DummyResource dummyResource;
+ @ExternalResource(key = DummyResource.RESOURCE_KEY)
+ private DummyResource dummyResource;
- @Override
- public void process(JCas aJCas) throws AnalysisEngineProcessException {
- // Just marking up that the AE was executed as expected, so that it can be verified.
- AnalyzedText annotation = new AnalyzedText(aJCas, 0, aJCas.getDocumentText().length());
- annotation.setText(dummyResource.getText());
- annotation.addToIndexes();
- }
+ @Override
+ public void process(JCas aJCas) throws AnalysisEngineProcessException {
+ // Just marking up that the AE was executed as expected, so that it can be verified.
+ AnalyzedText annotation = new AnalyzedText(aJCas, 0, aJCas.getDocumentText().length());
+ annotation.setText(dummyResource.getText());
+ annotation.addToIndexes();
+ }
}
-
+
private static void bindResources(AnalysisEngineDescription desc) throws Exception {
bindResource(desc, ResourceWithAssert.class);
- bindResource(desc, DummyAE.RES_KEY_1, AnnotatedResource.class,
- AnnotatedResource.PARAM_VALUE, "1");
- bindResource(desc, DummyAE.RES_KEY_2, AnnotatedResource.class,
- AnnotatedResource.PARAM_VALUE, "2");
+ bindResource(desc, DummyAE.RES_KEY_1, AnnotatedResource.class, AnnotatedResource.PARAM_VALUE,
+ "1");
+ bindResource(desc, DummyAE.RES_KEY_2, AnnotatedResource.class, AnnotatedResource.PARAM_VALUE,
+ "2");
bindResource(desc, DummyAE.RES_KEY_3, AnnotatedParametrizedDataResource.class,
AnnotatedParametrizedDataResource.PARAM_EXTENSION, ".lala");
// https://issues.apache.org/jira/browse/UIMA-5555
- // bindResource(desc, DummySharedResourceObject.class, EX_URI,
- // DummySharedResourceObject.PARAM_VALUE, "3",
- // DummySharedResourceObject.PARAM_ARRAY_VALUE, new String[] {"1", "2", "3"});
-
+ // bindResource(desc, DummySharedResourceObject.class, EX_URI,
+ // DummySharedResourceObject.PARAM_VALUE, "3",
+ // DummySharedResourceObject.PARAM_ARRAY_VALUE, new String[] {"1", "2", "3"});
+
// An undefined URL may be used if the specified file/remote URL does not exist or if
// the network is down.
bindResource(desc, DummyAE.RES_SOME_URL, new File(EX_FILE_1).toURI().toURL());
@@ -433,9 +431,9 @@ public class ExternalResourceFactoryTest extends ComponentTestBase {
JndiResourceLocator.PARAM_NAME, "dictionaries/german");
// https://issues.apache.org/jira/browse/UIMA-5555
- // createDependencyAndBind(desc, "legacyResource", DummySharedResourceObject.class, EX_URI,
- // DummySharedResourceObject.PARAM_VALUE, "3",
- // DummySharedResourceObject.PARAM_ARRAY_VALUE, new String[] {"1", "2", "3"});
+ // createDependencyAndBind(desc, "legacyResource", DummySharedResourceObject.class, EX_URI,
+ // DummySharedResourceObject.PARAM_VALUE, "3",
+ // DummySharedResourceObject.PARAM_ARRAY_VALUE, new String[] {"1", "2", "3"});
}
public static class DummyAE extends JCasAnnotator_ImplBase {
@@ -455,8 +453,8 @@ public class ExternalResourceFactoryTest extends ComponentTestBase {
static final String RES_KEY_3 = "Key3";
// https://issues.apache.org/jira/browse/UIMA-5555
- // @ExternalResource
- // DummySharedResourceObject sharedObject;
+ // @ExternalResource
+ // DummySharedResourceObject sharedObject;
static final String RES_SOME_URL = "SomeUrl";
@@ -498,12 +496,12 @@ public class ExternalResourceFactoryTest extends ComponentTestBase {
}
// https://issues.apache.org/jira/browse/UIMA-5555
- // assertNotNull(sharedObject);
- // assertEquals("3", sharedObject.getValue());
- // assertEquals(asList("1", "2", "3"), asList(sharedObject.getArrayValue()));
+ // assertNotNull(sharedObject);
+ // assertEquals("3", sharedObject.getValue());
+ // assertEquals(asList("1", "2", "3"), asList(sharedObject.getArrayValue()));
//
- // assertNotNull(sharedObject);
- // assertEquals(EX_URI, sharedObject.getUrl().toString());
+ // assertNotNull(sharedObject);
+ // assertEquals(EX_URI, sharedObject.getUrl().toString());
assertNotNull(jndiPropertes);
assertEquals("proper noun", jndiPropertes.get("Hans"));
@@ -515,15 +513,16 @@ public class ExternalResourceFactoryTest extends ComponentTestBase {
assertEquals(new File(EX_FILE_3).toURI().toString(), someOtherUrl.getUri().toString());
assertTrue(someFile.getUrl().toString().startsWith("file:"));
- assertTrue("URL [" + someFile.getUrl() + "] should end in [" + EX_FILE_1 + "]", someFile
- .getUrl().toString().endsWith(EX_FILE_1));
+ assertThat(someFile.getUrl().toString())
+ .as("URL [" + someFile.getUrl() + "] should end in [" + EX_FILE_1 + "]")
+ .endsWith(EX_FILE_1);
// https://issues.apache.org/jira/browse/UIMA-5555
- // try {
- // assertNotNull(getContext().getResourceObject("legacyResource"));
- // } catch (ResourceAccessException e) {
- // throw new AnalysisEngineProcessException(e);
- // }
+ // try {
+ // assertNotNull(getContext().getResourceObject("legacyResource"));
+ // } catch (ResourceAccessException e) {
+ // throw new AnalysisEngineProcessException(e);
+ // }
}
}
@@ -548,6 +547,7 @@ public class ExternalResourceFactoryTest extends ComponentTestBase {
public static class DummyAE3 extends JCasAnnotator_ImplBase {
static final String RES_KEY_1 = "Key1";
+
@ExternalResource(key = RES_KEY_1)
AnnotatedResource configRes1;
@@ -557,30 +557,29 @@ public class ExternalResourceFactoryTest extends ComponentTestBase {
assertEquals("1", configRes1.getValue());
}
}
-
- public static final class MultiValuedResourceAE extends org.apache.uima.fit.component.JCasAnnotator_ImplBase {
+
+ public static final class MultiValuedResourceAE
+ extends org.apache.uima.fit.component.JCasAnnotator_ImplBase {
static final String RES_RESOURCE_ARRAY = "resourceArray";
+
@ExternalResource(key = RES_RESOURCE_ARRAY)
ResourceWithAssert[] resourceArray;
public static List<ResourceWithAssert> resources = new ArrayList<ResourceWithAssert>();
-
+
@Override
public void process(JCas aJCas) throws AnalysisEngineProcessException {
- assertNotNull("Resource array is null", resourceArray);
- assertEquals(2, resourceArray.length);
- assertTrue("Resource array element 0 is not a DummyResource",
- resourceArray[0] instanceof ResourceWithAssert);
- assertTrue("Resource array element 1 is not a DummyResource",
- resourceArray[1] instanceof ResourceWithAssert);
- assertTrue(resourceArray[0] != resourceArray[1]);
-
+ assertThat(resourceArray) //
+ .extracting(item -> item instanceof ResourceWithAssert) //
+ .containsExactly(true, true);
+
resources.add(resourceArray[0]);
resources.add(resourceArray[1]);
-
+ assertThat(resourceArray[0]).isNotSameAs(resourceArray[1]);
+
System.out.printf("Element object 0: %d%n", resourceArray[0].hashCode());
System.out.printf("Element object 1: %d%n", resourceArray[1].hashCode());
-
+
for (ResourceWithAssert res : resourceArray) {
res.doAsserts();
}
@@ -589,27 +588,25 @@ public class ExternalResourceFactoryTest extends ComponentTestBase {
public static final class MultiValuedResource extends ResourceWithAssert {
static final String RES_RESOURCE_LIST = "resourceList";
+
@ExternalResource(key = RES_RESOURCE_LIST)
List<ResourceWithAssert> resourceList;
public static List<ResourceWithAssert> resources = new ArrayList<ResourceWithAssert>();
-
+
@Override
public void doAsserts() {
- assertNotNull("Resource array is null", resourceList);
- assertEquals(2, resourceList.size());
- assertTrue("Resource array element 0 is not a MultiValuedResourceAE",
- resourceList.get(0) instanceof ResourceWithAssert);
- assertTrue("Resource array element 1 is not a MultiValuedResourceAE",
- resourceList.get(1) instanceof ResourceWithAssert);
- assertTrue(resourceList.get(0) != resourceList.get(1));
-
+ assertThat(resourceList) //
+ .extracting(item -> item instanceof ResourceWithAssert) //
+ .containsExactly(true, true);
+ assertThat(resourceList.get(0)).isNotSameAs(resourceList.get(1));
+
resources.add(resourceList.get(0));
resources.add(resourceList.get(1));
-
+
System.out.printf("Element object 0: %d%n", resourceList.get(0).hashCode());
System.out.printf("Element object 1: %d%n", resourceList.get(1).hashCode());
-
+
for (ResourceWithAssert res : resourceList) {
res.doAsserts();
}
@@ -651,11 +648,12 @@ public class ExternalResourceFactoryTest extends ComponentTestBase {
}
public static class IntermediateResourceWithAssert extends ResourceWithAssert {
-
+
public static final String PARAM_NESTED_RESOURCE = "nestedResource";
+
@ExternalResource(key = PARAM_NESTED_RESOURCE)
private ResourceWithAssert nestedResource;
-
+
@Override
public void doAsserts() {
assertNotNull(nestedResource);
@@ -674,8 +672,8 @@ public class ExternalResourceFactoryTest extends ComponentTestBase {
}
}
- public static final class AnnotatedDataResource extends Resource_ImplBase implements
- DataResource {
+ public static final class AnnotatedDataResource extends Resource_ImplBase
+ implements DataResource {
public static final String PARAM_URI = "Uri";
@ConfigurationParameter(name = PARAM_URI, mandatory = true)
@@ -702,8 +700,8 @@ public class ExternalResourceFactoryTest extends ComponentTestBase {
}
}
- public static final class AnnotatedParametrizedDataResource extends Resource_ImplBase implements
- ParameterizedDataResource {
+ public static final class AnnotatedParametrizedDataResource extends Resource_ImplBase
+ implements ParameterizedDataResource {
public static final String PARAM_EXTENSION = "Extension";
@ConfigurationParameter(name = PARAM_EXTENSION, mandatory = true)
@@ -722,33 +720,35 @@ public class ExternalResourceFactoryTest extends ComponentTestBase {
public static final class DummySharedResourceObject implements SharedResourceObject {
public static final String PARAM_VALUE = "Value";
+
@ConfigurationParameter(name = PARAM_VALUE, mandatory = true)
private String value;
public static final String PARAM_ARRAY_VALUE = "arrayValue";
+
@ConfigurationParameter(name = PARAM_ARRAY_VALUE, mandatory = true)
private String[] arrayValue;
// https://issues.apache.org/jira/browse/UIMA-5555
- // private URI uri;
+ // private URI uri;
@Override
public void load(DataResource aData) throws ResourceInitializationException {
ConfigurationParameterInitializer.initialize(this, aData);
// https://issues.apache.org/jira/browse/UIMA-5555
- // assertEquals(EX_URI, aData.getUri().toString());
- // uri = aData.getUri();
+ // assertEquals(EX_URI, aData.getUri().toString());
+ // uri = aData.getUri();
}
// https://issues.apache.org/jira/browse/UIMA-5555
- // public URI getUrl() {
- // return uri;
- // }
+ // public URI getUrl() {
+ // return uri;
+ // }
public String getValue() {
return value;
}
-
+
public String[] getArrayValue() {
return arrayValue;
}
diff --git a/uimafit-core/src/test/java/org/apache/uima/fit/factory/FlowControllerFactoryExternalResourceTest.java b/uimafit-core/src/test/java/org/apache/uima/fit/factory/FlowControllerFactoryExternalResourceTest.java
index 81a1eb8..b1c3b7e 100644
--- a/uimafit-core/src/test/java/org/apache/uima/fit/factory/FlowControllerFactoryExternalResourceTest.java
+++ b/uimafit-core/src/test/java/org/apache/uima/fit/factory/FlowControllerFactoryExternalResourceTest.java
@@ -40,7 +40,7 @@ package org.apache.uima.fit.factory;
import static org.apache.uima.fit.factory.ExternalResourceFactory.createResourceDescription;
import static org.apache.uima.fit.factory.FlowControllerFactory.createFlowControllerDescription;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import org.apache.uima.analysis_engine.AnalysisEngine;
import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
@@ -53,7 +53,7 @@ import org.apache.uima.flow.CasFlow_ImplBase;
import org.apache.uima.flow.FinalStep;
import org.apache.uima.flow.Flow;
import org.apache.uima.flow.Step;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*/
@@ -62,10 +62,8 @@ public class FlowControllerFactoryExternalResourceTest {
public void testAutoExternalResourceBinding() throws Exception {
AggregateBuilder builder = new AggregateBuilder();
builder.add(AnalysisEngineFactory.createEngineDescription(NoOpAnnotator.class));
- builder.setFlowControllerDescription(createFlowControllerDescription(
- TestFlowController.class,
- TestFlowController.PARAM_RESOURCE,
- createResourceDescription(TestExternalResource.class,
+ builder.setFlowControllerDescription(createFlowControllerDescription(TestFlowController.class,
+ TestFlowController.PARAM_RESOURCE, createResourceDescription(TestExternalResource.class,
TestExternalResource.PARAM_VALUE, TestExternalResource.EXPECTED_VALUE)));
AnalysisEngine aggregateEngine = builder.createAggregate();
aggregateEngine.process(aggregateEngine.newCAS());
diff --git a/uimafit-core/src/test/java/org/apache/uima/fit/factory/FlowControllerFactoryTest.java b/uimafit-core/src/test/java/org/apache/uima/fit/factory/FlowControllerFactoryTest.java
index 46c6963..5aa3e3d 100644
--- a/uimafit-core/src/test/java/org/apache/uima/fit/factory/FlowControllerFactoryTest.java
+++ b/uimafit-core/src/test/java/org/apache/uima/fit/factory/FlowControllerFactoryTest.java
@@ -18,25 +18,24 @@
*/
package org.apache.uima.fit.factory;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
import org.apache.uima.fit.descriptor.ResourceMetaData;
import org.apache.uima.flow.Flow;
import org.apache.uima.flow.FlowControllerDescription;
import org.apache.uima.jcas.JCas;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class FlowControllerFactoryTest {
@Test
- public void testResourceMetaData() throws Exception
- {
+ public void testResourceMetaData() throws Exception {
FlowControllerDescription desc = FlowControllerFactory
.createFlowControllerDescription(TestFlowController.class);
-
+
org.apache.uima.resource.metadata.ResourceMetaData meta = desc.getMetaData();
-
+
assertEquals("dummy", meta.getName());
assertEquals("1.0", meta.getVersion());
assertEquals("Just a dummy", meta.getDescription());
@@ -45,8 +44,8 @@ public class FlowControllerFactoryTest {
}
@ResourceMetaData(name = "dummy", version = "1.0", description = "Just a dummy", copyright = "ASL 2.0", vendor = "uimaFIT")
- public class TestFlowController extends
- org.apache.uima.fit.component.JCasFlowController_ImplBase {
+ public class TestFlowController
+ extends org.apache.uima.fit.component.JCasFlowController_ImplBase {
@Override
public Flow computeFlow(JCas aJCas) throws AnalysisEngineProcessException {
diff --git a/uimafit-core/src/test/java/org/apache/uima/fit/factory/FsIndexFactoryTest.java b/uimafit-core/src/test/java/org/apache/uima/fit/factory/FsIndexFactoryTest.java
index 7e4431c..d3530de 100644
--- a/uimafit-core/src/test/java/org/apache/uima/fit/factory/FsIndexFactoryTest.java
+++ b/uimafit-core/src/test/java/org/apache/uima/fit/factory/FsIndexFactoryTest.java
@@ -20,7 +20,7 @@ package org.apache.uima.fit.factory;
import static org.apache.uima.fit.factory.AnalysisEngineFactory.createEngine;
import static org.apache.uima.fit.factory.FsIndexFactory.createFsIndexCollection;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.FileOutputStream;
@@ -38,14 +38,15 @@ import org.apache.uima.fit.type.Token;
import org.apache.uima.jcas.JCas;
import org.apache.uima.resource.metadata.FsIndexDescription;
import org.apache.uima.resource.metadata.FsIndexKeyDescription;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*/
public class FsIndexFactoryTest extends ComponentTestBase {
@Test
public void testCreateIndexCollection() throws Exception {
- org.apache.uima.resource.metadata.FsIndexCollection fsIndexCollection = createFsIndexCollection(IndexTestComponent.class);
+ org.apache.uima.resource.metadata.FsIndexCollection fsIndexCollection = createFsIndexCollection(
+ IndexTestComponent.class);
assertEquals(2, fsIndexCollection.getFsIndexes().length);
@@ -112,7 +113,8 @@ public class FsIndexFactoryTest extends ComponentTestBase {
@FsIndex(label = "index1", type = Token.class, kind = FsIndex.KIND_SORTED, keys = {
@FsIndexKey(featureName = "begin", comparator = FsIndexKey.REVERSE_STANDARD_COMPARE),
@FsIndexKey(featureName = "end", comparator = FsIndexKey.STANDARD_COMPARE) }),
- @FsIndex(label = "index2", type = Sentence.class, kind = FsIndex.KIND_SET, keys = { @FsIndexKey(featureName = "begin", comparator = FsIndexKey.STANDARD_COMPARE) }) })
+ @FsIndex(label = "index2", type = Sentence.class, kind = FsIndex.KIND_SET, keys = {
+ @FsIndexKey(featureName = "begin", comparator = FsIndexKey.STANDARD_COMPARE) }) })
public static class IndexTestComponent extends JCasAnnotator_ImplBase {
@Override
public void process(JCas aJCas) throws AnalysisEngineProcessException {
diff --git a/uimafit-core/src/test/java/org/apache/uima/fit/factory/JCasBuilderTest.java b/uimafit-core/src/test/java/org/apache/uima/fit/factory/JCasBuilderTest.java
index 258b4ce..151d092 100644
--- a/uimafit-core/src/test/java/org/apache/uima/fit/factory/JCasBuilderTest.java
+++ b/uimafit-core/src/test/java/org/apache/uima/fit/factory/JCasBuilderTest.java
@@ -20,27 +20,22 @@ package org.apache.uima.fit.factory;
import static org.apache.commons.io.FileUtils.readFileToString;
import static org.apache.uima.fit.factory.AnalysisEngineFactory.createEngine;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.File;
+import java.nio.file.Path;
import org.apache.uima.analysis_engine.AnalysisEngine;
import org.apache.uima.fit.ComponentTestBase;
import org.apache.uima.fit.component.CasDumpWriter;
import org.apache.uima.fit.type.Sentence;
import org.apache.uima.fit.type.Token;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
-/**
- */
public class JCasBuilderTest extends ComponentTestBase {
- @Rule
- public TemporaryFolder folder = new TemporaryFolder();
-
@Test
- public void test() throws Exception {
+ public void test(@TempDir Path folder) throws Exception {
JCasBuilder jb = new JCasBuilder(jCas);
jb.add("This sentence is not annotated. ");
jb.add("But this sentences is annotated. ", Sentence.class);
@@ -58,9 +53,9 @@ public class JCasBuilderTest extends ComponentTestBase {
jb.add(begin, Sentence.class);
jb.close();
- File outputFile = new File(folder.getRoot(), "dump-output.txt");
- AnalysisEngine writer = createEngine(CasDumpWriter.class, CasDumpWriter.PARAM_OUTPUT_FILE,
- outputFile.getPath());
+ File outputFile = folder.resolve("dump-output.txt").toFile();
+ AnalysisEngine writer = createEngine(CasDumpWriter.class, //
+ CasDumpWriter.PARAM_OUTPUT_FILE, outputFile.getPath());
writer.process(jb.getJCas());
String reference = readFileToString(
diff --git a/uimafit-core/src/test/java/org/apache/uima/fit/factory/JCasFactoryTest.java b/uimafit-core/src/test/java/org/apache/uima/fit/factory/JCasFactoryTest.java
index ce7cbd3..e9b11a4 100644
--- a/uimafit-core/src/test/java/org/apache/uima/fit/factory/JCasFactoryTest.java
+++ b/uimafit-core/src/test/java/org/apache/uima/fit/factory/JCasFactoryTest.java
@@ -18,7 +18,7 @@
*/
package org.apache.uima.fit.factory;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.File;
import java.io.IOException;
@@ -28,7 +28,7 @@ import org.apache.uima.fit.ComponentTestBase;
import org.apache.uima.fit.type.Token;
import org.apache.uima.fit.util.CasIOUtil;
import org.apache.uima.fit.util.JCasUtil;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*/
diff --git a/uimafit-core/src/test/java/org/apache/uima/fit/factory/ResourceCreationSpecifierFactoryTest.java b/uimafit-core/src/test/java/org/apache/uima/fit/factory/ResourceCreationSpecifierFactoryTest.java
index 051d2ae..d3a6cfd 100644
--- a/uimafit-core/src/test/java/org/apache/uima/fit/factory/ResourceCreationSpecifierFactoryTest.java
+++ b/uimafit-core/src/test/java/org/apache/uima/fit/factory/ResourceCreationSpecifierFactoryTest.java
@@ -18,39 +18,48 @@
*/
package org.apache.uima.fit.factory;
+import static org.apache.uima.fit.factory.ResourceCreationSpecifierFactory.createResourceCreationSpecifier;
+import static org.apache.uima.fit.factory.ResourceCreationSpecifierFactory.setConfigurationParameters;
+import static org.apache.uima.fit.factory.UimaContextFactory.createUimaContext;
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
+
import java.awt.Point;
import org.apache.uima.fit.factory.testAes.ParameterizedAE;
import org.apache.uima.resource.ResourceCreationSpecifier;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*/
public class ResourceCreationSpecifierFactoryTest {
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void test4() throws Exception {
- ResourceCreationSpecifierFactory.createResourceCreationSpecifier(
- "src/main/resources/org/apache/uima/fit/component/NoOpAnnotator.xml",
- new String[] { "test" });
+ assertThatExceptionOfType(IllegalArgumentException.class)
+ .isThrownBy(() -> createResourceCreationSpecifier(
+ "src/main/resources/org/apache/uima/fit/component/NoOpAnnotator.xml",
+ new String[] { "test" }));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void test3() throws Exception {
- UimaContextFactory.createUimaContext("test");
+ assertThatExceptionOfType(IllegalArgumentException.class)
+ .isThrownBy(() -> createUimaContext("test"));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void test2() throws Exception {
- ResourceCreationSpecifierFactory.createResourceCreationSpecifier(
- "src/main/resources/org/apache/uima/fit/component/NoOpAnnotator.xml", new Object[] {
- "test", new Point(0, 5) });
+ assertThatExceptionOfType(IllegalArgumentException.class)
+ .isThrownBy(() -> createResourceCreationSpecifier(
+ "src/main/resources/org/apache/uima/fit/component/NoOpAnnotator.xml",
+ new Object[] { "test", new Point(0, 5) }));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void test1() {
- ResourceCreationSpecifierFactory.setConfigurationParameters((ResourceCreationSpecifier) null,
- ParameterizedAE.PARAM_BOOLEAN_1);
+ assertThatExceptionOfType(IllegalArgumentException.class)
+ .isThrownBy(() -> setConfigurationParameters((ResourceCreationSpecifier) null,
+ ParameterizedAE.PARAM_BOOLEAN_1));
}
}
diff --git a/uimafit-core/src/test/java/org/apache/uima/fit/factory/ResourceManagerFactoryTest.java b/uimafit-core/src/test/java/org/apache/uima/fit/factory/ResourceManagerFactoryTest.java
index ffc25ca..cfb7246 100644
--- a/uimafit-core/src/test/java/org/apache/uima/fit/factory/ResourceManagerFactoryTest.java
+++ b/uimafit-core/src/test/java/org/apache/uima/fit/factory/ResourceManagerFactoryTest.java
@@ -23,17 +23,17 @@ import static org.assertj.core.api.Assertions.assertThat;
import org.apache.uima.fit.component.Resource_ImplBase;
import org.apache.uima.fit.descriptor.ConfigurationParameter;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class ResourceManagerFactoryTest {
public static class SimpleResource extends Resource_ImplBase {
// Nothing to do
}
-
+
@Test
public void thatResourceCanBeCreated() throws Exception {
SimpleResource sut = createResource(SimpleResource.class);
-
+
assertThat(sut).isInstanceOf(SimpleResource.class);
}
@@ -41,13 +41,12 @@ public class ResourceManagerFactoryTest {
public @ConfigurationParameter int intValue;
public @ConfigurationParameter String stringValue;
}
-
+
@Test
public void thatResourceCanBeParametrized() throws Exception {
- ResourceWithParameters sut = createResource(ResourceWithParameters.class,
- "intValue", "1",
+ ResourceWithParameters sut = createResource(ResourceWithParameters.class, "intValue", "1",
"stringValue", "test");
-
+
assertThat(sut).isInstanceOf(ResourceWithParameters.class);
assertThat(sut.intValue).isEqualTo(1);
assertThat(sut.stringValue).isEqualTo("test");
diff --git a/uimafit-core/src/test/java/org/apache/uima/fit/factory/ResourceMetaDataFactoryTest.java b/uimafit-core/src/test/java/org/apache/uima/fit/factory/ResourceMetaDataFactoryTest.java
index 51a8103..c40863a 100644
--- a/uimafit-core/src/test/java/org/apache/uima/fit/factory/ResourceMetaDataFactoryTest.java
+++ b/uimafit-core/src/test/java/org/apache/uima/fit/factory/ResourceMetaDataFactoryTest.java
@@ -18,11 +18,11 @@
*/
package org.apache.uima.fit.factory;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import org.apache.uima.UIMAFramework;
import org.apache.uima.fit.descriptor.ResourceMetaData;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class ResourceMetaDataFactoryTest {
diff --git a/uimafit-core/src/test/java/org/apache/uima/fit/factory/SofaMappingFactoryTest.java b/uimafit-core/src/test/java/org/apache/uima/fit/factory/SofaMappingFactoryTest.java
index 78ff778..c1814fe 100644
--- a/uimafit-core/src/test/java/org/apache/uima/fit/factory/SofaMappingFactoryTest.java
+++ b/uimafit-core/src/test/java/org/apache/uima/fit/factory/SofaMappingFactoryTest.java
@@ -18,11 +18,11 @@
*/
package org.apache.uima.fit.factory;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import org.apache.uima.analysis_engine.metadata.SofaMapping;
import org.apache.uima.fit.component.NoOpAnnotator;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*/
diff --git a/uimafit-core/src/test/java/org/apache/uima/fit/factory/TypePrioritiesFactoryTest.java b/uimafit-core/src/test/java/org/apache/uima/fit/factory/TypePrioritiesFactoryTest.java
index 8d2978a..817112a 100644
--- a/uimafit-core/src/test/java/org/apache/uima/fit/factory/TypePrioritiesFactoryTest.java
+++ b/uimafit-core/src/test/java/org/apache/uima/fit/factory/TypePrioritiesFactoryTest.java
@@ -22,6 +22,7 @@ package org.apache.uima.fit.factory;
import static org.apache.uima.fit.factory.TypePrioritiesFactory.createTypePriorities;
import static org.apache.uima.fit.factory.TypeSystemDescriptionFactory.createTypeSystemDescription;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import org.apache.uima.cas.CAS;
import org.apache.uima.fit.type.Sentence;
@@ -30,7 +31,7 @@ import org.apache.uima.jcas.tcas.Annotation;
import org.apache.uima.resource.metadata.TypePriorities;
import org.apache.uima.resource.metadata.TypePriorityList;
import org.apache.uima.util.CasCreationUtils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Tests for the {@link TypePrioritiesFactory}.
@@ -46,7 +47,7 @@ public class TypePrioritiesFactoryTest {
assertThat(prio.getPriorityLists()).hasSize(1);
assertThat(prio.getPriorityLists()[0].getTypes()).containsExactly(CAS.TYPE_NAME_ANNOTATION);
}
-
+
@Test
public void testCreateTypePrioritiesFromClasses() throws Exception {
TypePriorities prio = createTypePriorities(Annotation.class);
@@ -56,20 +57,21 @@ public class TypePrioritiesFactoryTest {
assertThat(prio.getPriorityLists()).hasSize(1);
assertThat(prio.getPriorityLists()[0].getTypes()).containsExactly(CAS.TYPE_NAME_ANNOTATION);
}
-
- @Test(expected = IllegalArgumentException.class)
+
+ @Test
public void testCreateTypePrioritiesFromBadClasses() throws Exception {
- TypePriorities prio = createTypePriorities((Class) Integer.class);
+ assertThatExceptionOfType(IllegalArgumentException.class)
+ .isThrownBy(() -> createTypePriorities((Class) Integer.class));
}
-
+
@Test
public void testAutoDetectTypePriorities() throws Exception {
TypePriorities prio = createTypePriorities();
TypePriorityList[] typePrioritiesLists = prio.getPriorityLists();
assertThat(typePrioritiesLists.length).isEqualTo(1);
- assertThat(typePrioritiesLists[0].getTypes())
- .as("Type priorities auto-detection")
- .containsExactly(Sentence.class.getName(), Token.class.getName());
+ assertThat(typePrioritiesLists[0].getTypes()) //
+ .as("Type priorities auto-detection")
+ .containsExactly(Sentence.class.getName(), Token.class.getName());
}
}
diff --git a/uimafit-core/src/test/java/org/apache/uima/fit/factory/TypeSystemDescriptionFactoryTest.java b/uimafit-core/src/test/java/org/apache/uima/fit/factory/TypeSystemDescriptionFactoryTest.java
index efe9f03..8ac1aa3 100644
--- a/uimafit-core/src/test/java/org/apache/uima/fit/factory/TypeSystemDescriptionFactoryTest.java
+++ b/uimafit-core/src/test/java/org/apache/uima/fit/factory/TypeSystemDescriptionFactoryTest.java
@@ -19,13 +19,13 @@
package org.apache.uima.fit.factory;
import static org.apache.uima.fit.factory.TypeSystemDescriptionFactory.createTypeSystemDescription;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import org.apache.uima.fit.type.AnalyzedText;
import org.apache.uima.fit.type.Sentence;
import org.apache.uima.fit.type.Token;
import org.apache.uima.resource.metadata.TypeSystemDescription;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*/
diff --git a/uimafit-core/src/test/java/org/apache/uima/fit/factory/UimaContextFactoryTest.java b/uimafit-core/src/test/java/org/apache/uima/fit/factory/UimaContextFactoryTest.java
index 555117b..86f9691 100644
--- a/uimafit-core/src/test/java/org/apache/uima/fit/factory/UimaContextFactoryTest.java
+++ b/uimafit-core/src/test/java/org/apache/uima/fit/factory/UimaContextFactoryTest.java
@@ -18,11 +18,11 @@
*/
package org.apache.uima.fit.factory;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import org.apache.uima.UimaContext;
import org.apache.uima.resource.ResourceInitializationException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*/
@@ -31,11 +31,11 @@ public class UimaContextFactoryTest {
@Test
public void test() throws ResourceInitializationException {
- UimaContext context = UimaContextFactory
- .createUimaContext("myBoolean", true, "myBooleans", new Boolean[] { true, false, true,
- false }, "myFloat", 1.0f, "myFloats", new Float[] { 2.0f, 2.1f, 3.0f }, "myInt", 1,
- "myInts", new Integer[] { 2, 3, 4 }, "myString", "yourString", "myStrings",
- new String[] { "yourString1", "yourString2", "yourString3" });
+ UimaContext context = UimaContextFactory.createUimaContext("myBoolean", true, "myBooleans",
+ new Boolean[] { true, false, true, false }, "myFloat", 1.0f, "myFloats",
+ new Float[] { 2.0f, 2.1f, 3.0f }, "myInt", 1, "myInts", new Integer[] { 2, 3, 4 },
+ "myString", "yourString", "myStrings",
+ new String[] { "yourString1", "yourString2", "yourString3" });
assertEquals(true, context.getConfigParameterValue("myBoolean"));
Boolean[] myBooleans = (Boolean[]) context.getConfigParameterValue("myBooleans");
assertEquals(4, myBooleans.length);
diff --git a/uimafit-core/src/test/java/org/apache/uima/fit/factory/initializable/InitializableFactoryTest.java b/uimafit-core/src/test/java/org/apache/uima/fit/factory/initializable/InitializableFactoryTest.java
index 81c44a1..6829766 100644
--- a/uimafit-core/src/test/java/org/apache/uima/fit/factory/initializable/InitializableFactoryTest.java
+++ b/uimafit-core/src/test/java/org/apache/uima/fit/factory/initializable/InitializableFactoryTest.java
@@ -18,8 +18,8 @@
*/
package org.apache.uima.fit.factory.initializable;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import org.apache.uima.UimaContext;
import org.apache.uima.fit.component.initialize.ConfigurationParameterInitializer;
@@ -27,34 +27,38 @@ import org.apache.uima.fit.descriptor.ConfigurationParameter;
import org.apache.uima.fit.factory.UimaContextFactory;
import org.apache.uima.jcas.JCas;
import org.apache.uima.resource.ResourceInitializationException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class InitializableFactoryTest {
@Test
public void testInitializableFactory() throws Exception {
- UimaContext context = UimaContextFactory.createUimaContext(
- InitializableClass.PARAM_BOOLEAN_PARAMETER, true);
+ UimaContext context = UimaContextFactory
+ .createUimaContext(InitializableClass.PARAM_BOOLEAN_PARAMETER, true);
InitializableClass ic = InitializableFactory.create(context, InitializableClass.class);
- assertTrue(ic.booleanParameter);
+ assertThat(ic.booleanParameter).isTrue();
NotInitializableClass nic = InitializableFactory.create(context, NotInitializableClass.class);
- assertFalse(nic.booleanParameter);
+ assertThat(nic.booleanParameter).isFalse();
}
- @Test(expected = ResourceInitializationException.class)
+ @Test
public void testBadConstructor() throws ResourceInitializationException {
- UimaContext context = UimaContextFactory.createUimaContext(
- InitializableClass.PARAM_BOOLEAN_PARAMETER, true);
- InitializableFactory.create(context, NoDefaultConstructor.class);
+ UimaContext context = UimaContextFactory
+ .createUimaContext(InitializableClass.PARAM_BOOLEAN_PARAMETER, true);
+
+ assertThatExceptionOfType(ResourceInitializationException.class)
+ .isThrownBy(() -> InitializableFactory.create(context, NoDefaultConstructor.class));
}
public static class InitializableClass implements Initializable {
public static final String PARAM_BOOLEAN_PARAMETER = "booleanParameter";
+
@ConfigurationParameter
public boolean booleanParameter = false;
+ @Override
public void initialize(UimaContext context) throws ResourceInitializationException {
ConfigurationParameterInitializer.initialize(this, context);
}
@@ -63,6 +67,7 @@ public class InitializableFactoryTest {
public static class NotInitializableClass {
... 6799 lines suppressed ...