Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.equinox.common.tests/.settings/org.eclipse.jdt.core.prefs65
-rw-r--r--bundles/org.eclipse.equinox.common.tests/.settings/org.eclipse.jdt.ui.prefs70
-rw-r--r--bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/PathTest.java7
-rw-r--r--bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/SubMonitorSmallTicksTest.java23
-rw-r--r--bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/SubMonitorTest.java555
-rw-r--r--bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/SubProgressTest.java355
-rw-r--r--bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/adaptable/AdapterManagerDynamicTest.java35
-rw-r--r--bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/adaptable/IAdapterManagerServiceTest.java100
-rw-r--r--bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/adaptable/IAdapterManagerTest.java134
-rw-r--r--bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/ContributorsTest.java54
-rw-r--r--bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/InputErrorTest.java3
-rw-r--r--bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/NamespaceTest.java20
-rw-r--r--bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/RegistryListenerTest.java64
-rw-r--r--bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/StaleObjects.java110
-rw-r--r--bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/simple/BaseExtensionRegistryRun.java44
-rw-r--r--bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/simple/DirectExtensionCreateTest.java28
-rw-r--r--bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/simple/DirectExtensionCreateTwoRegistriesTest.java26
-rw-r--r--bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/simple/DirectExtensionRemoveTest.java75
-rw-r--r--bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/simple/DuplicatePointsTest.java34
-rw-r--r--bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/simple/MergeContributionTest.java27
-rw-r--r--bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/simple/TokenAccessTest.java34
-rw-r--r--bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/simple/XMLExecutableExtensionTest.java55
-rw-r--r--bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/simple/XMLExtensionCreateEclipseTest.java26
-rw-r--r--bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/simple/XMLExtensionCreateTest.java40
24 files changed, 935 insertions, 1049 deletions
diff --git a/bundles/org.eclipse.equinox.common.tests/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.equinox.common.tests/.settings/org.eclipse.jdt.core.prefs
index f89109329..0a998040a 100644
--- a/bundles/org.eclipse.equinox.common.tests/.settings/org.eclipse.jdt.core.prefs
+++ b/bundles/org.eclipse.equinox.common.tests/.settings/org.eclipse.jdt.core.prefs
@@ -119,8 +119,12 @@ org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
org.eclipse.jdt.core.compiler.source=1.8
+org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false
org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647
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_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
@@ -129,19 +133,27 @@ 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_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
org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
+org.eclipse.jdt.core.formatter.alignment_for_conditional_expression_chain=0
org.eclipse.jdt.core.formatter.alignment_for_enum_constants=16
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0
+org.eclipse.jdt.core.formatter.alignment_for_logical_operator=16
org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0
org.eclipse.jdt.core.formatter.alignment_for_module_statements=16
org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
+org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator=16
org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_relational_operator=0
org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80
org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
+org.eclipse.jdt.core.formatter.alignment_for_shift_operator=0
+org.eclipse.jdt.core.formatter.alignment_for_string_concatenation=16
org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
@@ -151,7 +163,9 @@ 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
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=0
org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
@@ -160,6 +174,7 @@ org.eclipse.jdt.core.formatter.blank_lines_before_method=1
org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1
org.eclipse.jdt.core.formatter.blank_lines_before_package=0
org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1
+org.eclipse.jdt.core.formatter.blank_lines_between_statement_group_in_switch=0
org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1
org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line
@@ -188,7 +203,9 @@ org.eclipse.jdt.core.formatter.comment.format_line_comments=true
org.eclipse.jdt.core.formatter.comment.format_source_code=true
org.eclipse.jdt.core.formatter.comment.indent_parameter_description=false
org.eclipse.jdt.core.formatter.comment.indent_root_tags=false
+org.eclipse.jdt.core.formatter.comment.indent_tag_description=false
org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
+org.eclipse.jdt.core.formatter.comment.insert_new_line_between_different_tags=do not insert
org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert
org.eclipse.jdt.core.formatter.comment.line_length=80
org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true
@@ -235,11 +252,15 @@ 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
+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=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
@@ -266,10 +287,14 @@ org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declar
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_switch_case_expressions=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert
+org.eclipse.jdt.core.formatter.insert_space_after_logical_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_not_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
@@ -294,13 +319,20 @@ org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_relational_operator=insert
org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert
+org.eclipse.jdt.core.formatter.insert_space_after_shift_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation=insert
org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_additive_operator=insert
org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
+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
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
@@ -344,10 +376,13 @@ org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_decla
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_switch_case_expressions=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert
+org.eclipse.jdt.core.formatter.insert_space_before_logical_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_multiplicative_operator=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
@@ -384,9 +419,12 @@ org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not inser
org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_relational_operator=insert
org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_shift_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_string_concatenation=insert
org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
@@ -398,14 +436,33 @@ org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_decla
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
org.eclipse.jdt.core.formatter.join_lines_in_comments=true
org.eclipse.jdt.core.formatter.join_wrapped_lines=true
+org.eclipse.jdt.core.formatter.keep_annotation_declaration_on_one_line=one_line_never
+org.eclipse.jdt.core.formatter.keep_anonymous_type_declaration_on_one_line=one_line_never
+org.eclipse.jdt.core.formatter.keep_code_block_on_one_line=one_line_never
org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
+org.eclipse.jdt.core.formatter.keep_enum_constant_declaration_on_one_line=one_line_never
+org.eclipse.jdt.core.formatter.keep_enum_declaration_on_one_line=one_line_never
+org.eclipse.jdt.core.formatter.keep_if_then_body_block_on_one_line=one_line_never
org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
+org.eclipse.jdt.core.formatter.keep_lambda_body_block_on_one_line=one_line_never
+org.eclipse.jdt.core.formatter.keep_loop_body_block_on_one_line=one_line_never
+org.eclipse.jdt.core.formatter.keep_method_body_on_one_line=one_line_never
+org.eclipse.jdt.core.formatter.keep_simple_do_while_body_on_same_line=false
+org.eclipse.jdt.core.formatter.keep_simple_for_body_on_same_line=false
+org.eclipse.jdt.core.formatter.keep_simple_getter_setter_on_one_line=false
+org.eclipse.jdt.core.formatter.keep_simple_while_body_on_same_line=false
org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
+org.eclipse.jdt.core.formatter.keep_type_declaration_on_one_line=one_line_never
org.eclipse.jdt.core.formatter.lineSplit=120
org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
+org.eclipse.jdt.core.formatter.number_of_blank_lines_after_code_block=0
+org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_code_block=0
org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
+org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_code_block=0
+org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_method_body=0
+org.eclipse.jdt.core.formatter.number_of_blank_lines_before_code_block=0
org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation=common_lines
org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause=common_lines
@@ -420,12 +477,20 @@ org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause=common_lines
org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
org.eclipse.jdt.core.formatter.tabulation.char=tab
org.eclipse.jdt.core.formatter.tabulation.size=4
+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_tabs_only_for_leading_indentations=false
+org.eclipse.jdt.core.formatter.wrap_before_additive_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
+org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator=true
org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true
+org.eclipse.jdt.core.formatter.wrap_before_relational_operator=true
+org.eclipse.jdt.core.formatter.wrap_before_shift_operator=true
+org.eclipse.jdt.core.formatter.wrap_before_string_concatenation=true
org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true
org.eclipse.jdt.core.incompatibleJDKLevel=ignore
org.eclipse.jdt.core.incompleteClasspath=error
diff --git a/bundles/org.eclipse.equinox.common.tests/.settings/org.eclipse.jdt.ui.prefs b/bundles/org.eclipse.equinox.common.tests/.settings/org.eclipse.jdt.ui.prefs
new file mode 100644
index 000000000..777af582a
--- /dev/null
+++ b/bundles/org.eclipse.equinox.common.tests/.settings/org.eclipse.jdt.ui.prefs
@@ -0,0 +1,70 @@
+eclipse.preferences.version=1
+editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
+formatter_profile=org.eclipse.jdt.ui.default.eclipse_profile
+formatter_settings_version=18
+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.convert_functional_interfaces=true
+sp_cleanup.convert_to_enhanced_for_loop=true
+sp_cleanup.correct_indentation=false
+sp_cleanup.format_source_code=true
+sp_cleanup.format_source_code_changes_only=true
+sp_cleanup.insert_inferred_type_arguments=false
+sp_cleanup.make_local_variable_final=true
+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.never_use_blocks=false
+sp_cleanup.never_use_parentheses_in_expressions=true
+sp_cleanup.number_suffix=false
+sp_cleanup.on_save_use_additional_actions=true
+sp_cleanup.organize_imports=true
+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.remove_private_constructors=true
+sp_cleanup.remove_redundant_modifiers=true
+sp_cleanup.remove_redundant_semicolons=true
+sp_cleanup.remove_redundant_type_arguments=true
+sp_cleanup.remove_trailing_whitespaces=true
+sp_cleanup.remove_trailing_whitespaces_all=true
+sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
+sp_cleanup.remove_unnecessary_array_creation=true
+sp_cleanup.remove_unnecessary_casts=true
+sp_cleanup.remove_unnecessary_nls_tags=false
+sp_cleanup.remove_unused_imports=false
+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.sort_members=false
+sp_cleanup.sort_members_all=false
+sp_cleanup.use_anonymous_class_creation=false
+sp_cleanup.use_autoboxing=false
+sp_cleanup.use_blocks=false
+sp_cleanup.use_blocks_only_for_return_and_throw=false
+sp_cleanup.use_directly_map_method=false
+sp_cleanup.use_lambda=true
+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
diff --git a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/PathTest.java b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/PathTest.java
index f20625867..a94d01d9d 100644
--- a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/PathTest.java
+++ b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/PathTest.java
@@ -15,6 +15,7 @@
package org.eclipse.equinox.common.tests;
import java.util.ArrayList;
+
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.tests.harness.CoreTest;
@@ -81,9 +82,9 @@ public class PathTest extends CoreTest {
assertEquals("1.0", combo, fore.append(aft));
assertEquals("1.1", combo, fore.removeTrailingSeparator().append(aft));
assertEquals("1.2", combo, Path.ROOT.append(fore).append(aft));
- assertTrue("1.3", !fore.append(aft).hasTrailingSeparator());
- assertTrue("1.4", !Path.ROOT.append(fore).append(aft).hasTrailingSeparator());
- assertTrue("1.5", !fore.removeTrailingSeparator().append(aft).hasTrailingSeparator());
+ assertFalse("1.3", fore.append(aft).hasTrailingSeparator());
+ assertFalse("1.4", Path.ROOT.append(fore).append(aft).hasTrailingSeparator());
+ assertFalse("1.5", fore.removeTrailingSeparator().append(aft).hasTrailingSeparator());
// append empty and root path together
assertEquals("1.6", Path.EMPTY, Path.EMPTY.append(Path.EMPTY));
assertEquals("1.7", Path.EMPTY, Path.EMPTY.append(Path.ROOT));
diff --git a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/SubMonitorSmallTicksTest.java b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/SubMonitorSmallTicksTest.java
index 535fe1e82..05a834b35 100644
--- a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/SubMonitorSmallTicksTest.java
+++ b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/SubMonitorSmallTicksTest.java
@@ -13,29 +13,29 @@
*******************************************************************************/
package org.eclipse.equinox.common.tests;
-import junit.framework.TestCase;
import org.eclipse.core.runtime.SubMonitor;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
/**
* Ensures that creating a SubMonitor with a small number of
* ticks will not prevent it from reporting accurate progress.
*/
-public class SubMonitorSmallTicksTest extends TestCase {
+public class SubMonitorSmallTicksTest {
private TestProgressMonitor topmostMonitor;
private SubMonitor smallTicksChild;
- private long startTime;
private static int TOTAL_WORK = 1000;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
topmostMonitor = new TestProgressMonitor();
smallTicksChild = SubMonitor.convert(topmostMonitor, 10);
- super.setUp();
- startTime = System.currentTimeMillis();
}
+ @Test
public void testWorked() {
SubMonitor bigTicksChild = smallTicksChild.newChild(10).setWorkRemaining(TOTAL_WORK);
for (int i = 0; i < TOTAL_WORK; i++) {
@@ -44,6 +44,7 @@ public class SubMonitorSmallTicksTest extends TestCase {
bigTicksChild.done();
}
+ @Test
public void testInternalWorked() {
double delta = 10.0d / TOTAL_WORK;
@@ -52,6 +53,7 @@ public class SubMonitorSmallTicksTest extends TestCase {
}
}
+ @Test
public void testSplit() {
SubMonitor bigTicksChild = smallTicksChild.newChild(10).setWorkRemaining(TOTAL_WORK);
for (int i = 0; i < TOTAL_WORK; i++) {
@@ -60,14 +62,11 @@ public class SubMonitorSmallTicksTest extends TestCase {
bigTicksChild.done();
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
smallTicksChild.done();
topmostMonitor.done();
- long endTime = System.currentTimeMillis();
- SubMonitorTest.reportPerformance(getClass().getName(), getName(), startTime, endTime);
topmostMonitor.assertOptimal();
- super.tearDown();
}
}
diff --git a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/SubMonitorTest.java b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/SubMonitorTest.java
index d1da6453c..9e6a8bde0 100644
--- a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/SubMonitorTest.java
+++ b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/SubMonitorTest.java
@@ -18,63 +18,61 @@
*******************************************************************************/
package org.eclipse.equinox.common.tests;
-import java.util.*;
-import junit.framework.TestCase;
-import org.eclipse.core.runtime.*;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThrows;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.SubMonitor;
import org.junit.Assert;
+import org.junit.Test;
-/**
- *
- */
-public class SubMonitorTest extends TestCase {
+public class SubMonitorTest {
- private long startTime;
/**
- * <p>Number of calls to worked() within each test. This was chosen to be significantly larger
- * than 1000 to test how well the monitor can optimize unnecessary resolution
- * in reported progress, but small enough that the test completes in a reasonable
- * amount of time.</p>
+ * <p>
+ * Number of calls to worked() within each test. This was chosen to be
+ * significantly larger than 1000 to test how well the monitor can optimize
+ * unnecessary resolution in reported progress, but small enough that the test
+ * completes in a reasonable amount of time.
+ * </p>
*
- * <p>Note: changing this constant will invalidate comparisons with old performance data.</p>
+ * <p>
+ * Note: changing this constant will invalidate comparisons with old performance
+ * data.
+ * </p>
*/
public static final int PROGRESS_SIZE = SubProgressTest.PROGRESS_SIZE;
/**
- * <p>Depth of the chain chain of progress monitors. In all of the tests, we create
+ * <p>
+ * Depth of the chain chain of progress monitors. In all of the tests, we create
* a nested chain of progress monitors rather than a single monitor, to test its
* scalability under recursion. We pick a number representing a moderately deep
- * recursion, but is still small enough that it could correspond to a real call stack
- * without causing overflow.</p>
+ * recursion, but is still small enough that it could correspond to a real call
+ * stack without causing overflow.
+ * </p>
*
- * <p>Note: changing this constant will invalidate comparisons with old performance data.</p>
+ * <p>
+ * Note: changing this constant will invalidate comparisons with old performance
+ * data.
+ * </p>
*/
public static final int CHAIN_DEPTH = SubProgressTest.CHAIN_DEPTH;
- public SubMonitorTest() {
- super();
- }
-
- public SubMonitorTest(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- startTime = System.currentTimeMillis();
- super.setUp();
- }
-
- @Override
- protected void tearDown() throws Exception {
- long endTime = System.currentTimeMillis();
- reportPerformance(getClass().getName(), getName(), startTime, endTime);
- super.tearDown();
- }
-
/**
- * Reports progress by iterating over a loop of the given size, reporting 1 progress
- * at each iteration. Simulates the progress of worked(int) in loops.
+ * Reports progress by iterating over a loop of the given size, reporting 1
+ * progress at each iteration. Simulates the progress of worked(int) in loops.
*
- * @param monitor progress monitor (callers are responsible for calling done() if necessary)
+ * @param monitor progress monitor (callers are responsible for calling done()
+ * if necessary)
* @param loopSize size of the loop
*/
private static void reportWorkInLoop(IProgressMonitor monitor, int loopSize) {
@@ -85,10 +83,12 @@ public class SubMonitorTest extends TestCase {
}
/**
- * Reports progress by iterating over a loop of the given size, reporting 1 progress
- * at each iteration. Simulates the progress of internalWorked(double) in loops.
+ * Reports progress by iterating over a loop of the given size, reporting 1
+ * progress at each iteration. Simulates the progress of internalWorked(double)
+ * in loops.
*
- * @param monitor progress monitor (callers are responsible for calling done() if necessary)
+ * @param monitor progress monitor (callers are responsible for calling done()
+ * if necessary)
* @param loopSize size of the loop
*/
private static void reportFloatingPointWorkInLoop(IProgressMonitor monitor, int loopSize) {
@@ -99,9 +99,9 @@ public class SubMonitorTest extends TestCase {
}
/**
- * Runs an "infinite progress" loop. Each iteration will consume 1/ratio
- * of the remaining work, and will run for the given number of iterations.
- * Retuns the number of ticks reported (out of 1000).
+ * Runs an "infinite progress" loop. Each iteration will consume 1/ratio of the
+ * remaining work, and will run for the given number of iterations. Retuns the
+ * number of ticks reported (out of 1000).
*
* @param ratio
* @return the number of ticks reported
@@ -118,8 +118,10 @@ public class SubMonitorTest extends TestCase {
return monitor.getTotalWork();
}
+ @Test
public void testInfiniteProgress() {
- // In theory when reporting "infinite" progress, the actual progress reported after
+ // In theory when reporting "infinite" progress, the actual progress reported
+ // after
// n iterations should be f(n) = T(1-(1-R)^n)
//
// where T is the total ticks allocated on the root (T=1000) and R is the ratio
@@ -129,15 +131,18 @@ public class SubMonitorTest extends TestCase {
double test1 = runInfiniteProgress(100, 500);
assertEquals(993.4, test1, 1.0);
- // Reporting 0.1% per iteration, we should be at 950.2 ticks after 3000 iterations
+ // Reporting 0.1% per iteration, we should be at 950.2 ticks after 3000
+ // iterations
double test2 = runInfiniteProgress(1000, 3000);
assertEquals(950.2, test2, 1.0);
- // Reporting 0.01% per iteration, we should be at 393.5 ticks after 5000 iterations
+ // Reporting 0.01% per iteration, we should be at 393.5 ticks after 5000
+ // iterations
double test3 = runInfiniteProgress(10000, 5000);
assertEquals(393.5, test3, 1.0);
- // Reporting 0.01% per iteration, we should be at 864.7 ticks after 20000 iterations
+ // Reporting 0.01% per iteration, we should be at 864.7 ticks after 20000
+ // iterations
double test4 = runInfiniteProgress(10000, 20000);
assertEquals(864.7, test4, 1.0);
@@ -152,6 +157,7 @@ public class SubMonitorTest extends TestCase {
/**
* Ensures that we don't lose any progress when calling setWorkRemaining
*/
+ @Test
public void testSetWorkRemaining() {
TestProgressMonitor monitor = new TestProgressMonitor();
SubMonitor mon = SubMonitor.convert(monitor, 0);
@@ -171,9 +177,10 @@ public class SubMonitorTest extends TestCase {
}
/**
- * Tests that SubMonitor.done() will clean up after an unconsumed child
- * that was created with the explicit constructor
+ * Tests that SubMonitor.done() will clean up after an unconsumed child that was
+ * created with the explicit constructor
*/
+ @Test
public void testCleanupConstructedChildren() {
TestProgressMonitor top = new TestProgressMonitor();
@@ -185,7 +192,8 @@ public class SubMonitorTest extends TestCase {
child2.done();
- Assert.assertEquals("Ensure that done() reports unconsumed progress, even if beginTask wasn't called", 600.0, top.getTotalWork(), 0.01d);
+ assertEquals("Ensure that done() reports unconsumed progress, even if beginTask wasn't called", 600.0,
+ top.getTotalWork(), 0.01d);
SubMonitor child3 = monitor.newChild(100);
@@ -194,18 +202,20 @@ public class SubMonitorTest extends TestCase {
monitor.done();
- Assert.assertEquals("Ensure that done() cleans up after unconsumed children that were created by their constructor", 1000.0, top.getTotalWork(), 0.01d);
+ assertEquals("Ensure that done() cleans up after unconsumed children that were created by their constructor",
+ 1000.0, top.getTotalWork(), 0.01d);
child3.worked(100);
- Assert.assertEquals("Ensure that children can't report any progress if their parent has completed", 1000.0, top.getTotalWork(), 0.01d);
+ assertEquals("Ensure that children can't report any progress if their parent has completed", 1000.0,
+ top.getTotalWork(), 0.01d);
}
/**
- * Tests SubMonitor under typical usage. This is the same
- * as the performance test as the same name, but it verifies correctness
- * rather than performance.
+ * Tests SubMonitor under typical usage. This is the same as the performance
+ * test as the same name, but it verifies correctness rather than performance.
*/
+ @Test
public void testTypicalUsage() {
TestProgressMonitor monitor = new TestProgressMonitor();
SubMonitorTest.runTestTypicalUsage(monitor);
@@ -213,10 +223,10 @@ public class SubMonitorTest extends TestCase {
}
/**
- * Tests creating a tree of SubMonitors. This is the same
- * as the performance test as the same name, but it verifies correctness
- * rather than performance.
+ * Tests creating a tree of SubMonitors. This is the same as the performance
+ * test as the same name, but it verifies correctness rather than performance.
*/
+ @Test
public void testCreateTree() {
TestProgressMonitor monitor = new TestProgressMonitor();
SubMonitorTest.runTestCreateTree(monitor);
@@ -226,6 +236,7 @@ public class SubMonitorTest extends TestCase {
/**
* Tests claimed problem reported in bug 2100394.
*/
+ @Test
public void testBug210394() {
TestProgressMonitor testMonitor = new TestProgressMonitor();
SubMonitor monitor = SubMonitor.convert(testMonitor);
@@ -252,24 +263,25 @@ public class SubMonitorTest extends TestCase {
}
/**
- * Ensures that SubMonitor won't report more than 100% progress
- * when a child is created with more than the amount of available progress.
+ * Ensures that SubMonitor won't report more than 100% progress when a child is
+ * created with more than the amount of available progress.
*/
+ @Test
public void testChildOverflow() {
TestProgressMonitor top = new TestProgressMonitor();
SubMonitor mon1 = SubMonitor.convert(top, 1000);
- Assert.assertEquals(0.0, top.getTotalWork(), 0.1d);
+ assertEquals(0.0, top.getTotalWork(), 0.1d);
SubMonitor child2 = mon1.newChild(700);
child2.done();
- Assert.assertEquals(700.0, top.getTotalWork(), 0.1d);
+ assertEquals(700.0, top.getTotalWork(), 0.1d);
SubMonitor child3 = mon1.newChild(700);
child3.done();
- Assert.assertEquals("The reported work should not exceed 1000", 1000.0, top.getTotalWork(), 0.1d);
+ assertEquals("The reported work should not exceed 1000", 1000.0, top.getTotalWork(), 0.1d);
mon1.done();
@@ -279,45 +291,48 @@ public class SubMonitorTest extends TestCase {
/**
* Tests the 1-argument convert(...) method
*/
+ @Test
public void testConvert() {
TestProgressMonitor top = new TestProgressMonitor();
SubMonitor mon1 = SubMonitor.convert(top);
- Assert.assertEquals(0.0, top.getTotalWork(), 0.1d);
+ assertEquals(0.0, top.getTotalWork(), 0.1d);
mon1.worked(10);
- Assert.assertEquals(0.0, top.getTotalWork(), 0.1d);
+ assertEquals(0.0, top.getTotalWork(), 0.1d);
mon1.setWorkRemaining(100);
mon1.worked(50);
- Assert.assertEquals(500.0, top.getTotalWork(), 0.1d);
+ assertEquals(500.0, top.getTotalWork(), 0.1d);
mon1.done();
- Assert.assertEquals(1000.0, top.getTotalWork(), 0.1d);
+ assertEquals(1000.0, top.getTotalWork(), 0.1d);
top.done();
}
/**
* Tests the function of the SUPPRESS_* flags
*/
+ @Test
public void testFlags() {
TestProgressMonitor top = new TestProgressMonitor();
SubMonitor mon1 = SubMonitor.convert(top, "initial", 100);
// Ensure that we've called begintask on the root with the correct argument
- Assert.assertEquals(top.getBeginTaskCalls(), 1);
- Assert.assertEquals(top.getBeginTaskName(), "initial");
+ assertEquals(top.getBeginTaskCalls(), 1);
+ assertEquals(top.getBeginTaskName(), "initial");
mon1.beginTask("beginTask", 1000);
- // Ensure that beginTask on the child does NOT result in more than 1 call to beginTask on the root
- Assert.assertEquals(top.getBeginTaskCalls(), 1);
+ // Ensure that beginTask on the child does NOT result in more than 1 call to
+ // beginTask on the root
+ assertEquals(top.getBeginTaskCalls(), 1);
// Ensure that the task name was propogated correctly
- Assert.assertEquals(top.getTaskName(), "beginTask");
+ assertEquals(top.getTaskName(), "beginTask");
mon1.setTaskName("setTaskName");
- Assert.assertEquals(top.getTaskName(), "setTaskName");
+ assertEquals(top.getTaskName(), "setTaskName");
mon1.subTask("subTask");
- Assert.assertEquals(top.getSubTaskName(), "subTask");
+ assertEquals(top.getSubTaskName(), "subTask");
// Create a child monitor that permits calls to beginTask
{
@@ -325,13 +340,13 @@ public class SubMonitorTest extends TestCase {
// Ensure that everything is propogated
mon2.beginTask("mon2.beginTask", 100);
- Assert.assertEquals(top.getTaskName(), "mon2.beginTask");
+ assertEquals(top.getTaskName(), "mon2.beginTask");
mon2.setTaskName("mon2.setTaskName");
- Assert.assertEquals(top.getTaskName(), "mon2.setTaskName");
+ assertEquals(top.getTaskName(), "mon2.setTaskName");
mon2.subTask("mon2.subTask");
- Assert.assertEquals(top.getSubTaskName(), "mon2.subTask");
+ assertEquals(top.getSubTaskName(), "mon2.subTask");
}
}
@@ -346,17 +361,15 @@ public class SubMonitorTest extends TestCase {
return results.toArray(new String[results.size()]);
}
+ @Test
public void testSplitPerformsAutoCancel() {
NullProgressMonitor npm = new NullProgressMonitor();
npm.setCanceled(true);
SubMonitor subMonitor = SubMonitor.convert(npm, 1000);
- try {
- subMonitor.split(500);
- fail("split should have thrown an exception");
- } catch (OperationCanceledException exception) {
- }
+ assertThrows(OperationCanceledException.class, () -> subMonitor.split(500));
}
+ @Test
public void testNewChildDoesNotAutoCancel() {
NullProgressMonitor npm = new NullProgressMonitor();
npm.setCanceled(true);
@@ -364,12 +377,14 @@ public class SubMonitorTest extends TestCase {
subMonitor.newChild(500);
}
+ @Test
public void testSplitDoesNotThrowExceptionIfParentNotCanceled() {
NullProgressMonitor npm = new NullProgressMonitor();
SubMonitor subMonitor = SubMonitor.convert(npm, 1000);
subMonitor.split(500);
}
+ @Test
public void testAutoCancelDoesNothingForTrivialConversions() {
NullProgressMonitor npm = new NullProgressMonitor();
npm.setCanceled(true);
@@ -377,6 +392,7 @@ public class SubMonitorTest extends TestCase {
subMonitor.split(1000);
}
+ @Test
public void testAutoCancelDoesNothingForSingleTrivialOperation() {
NullProgressMonitor npm = new NullProgressMonitor();
npm.setCanceled(true);
@@ -384,57 +400,57 @@ public class SubMonitorTest extends TestCase {
subMonitor.split(0);
}
+ @Test
public void testAutoCancelThrowsExceptionEventuallyForManyTrivialOperations() {
NullProgressMonitor npm = new NullProgressMonitor();
npm.setCanceled(true);
SubMonitor subMonitor = SubMonitor.convert(npm, 1000);
- try {
+ assertThrows(OperationCanceledException.class, () -> {
for (int counter = 0; counter < 1000; counter++) {
subMonitor.split(0);
}
- fail("split should have thrown an exception");
- } catch (OperationCanceledException exception) {
- }
+ });
}
+ @Test
public void testConsumingEndOfMonitorNotTreatedAsTrivial() {
NullProgressMonitor npm = new NullProgressMonitor();
SubMonitor subMonitor = SubMonitor.convert(npm, 1000);
subMonitor.newChild(500);
- try {
- npm.setCanceled(true);
- subMonitor.split(500);
- fail("split should have thrown an exception");
- } catch (OperationCanceledException exception) {
- }
+ npm.setCanceled(true);
+ assertThrows(OperationCanceledException.class, () -> subMonitor.split(500));
}
+ @Test
public void testIsCanceled() {
NullProgressMonitor npm = new NullProgressMonitor();
SubMonitor subMonitor = SubMonitor.convert(npm);
- assertTrue("subMonitor should not be canceled", !subMonitor.isCanceled());
+ assertFalse("subMonitor should not be canceled", subMonitor.isCanceled());
npm.setCanceled(true);
assertTrue("subMonitor should be canceled", subMonitor.isCanceled());
}
+ @Test
public void testSuppressIsCanceled() {
NullProgressMonitor npm = new NullProgressMonitor();
SubMonitor subMonitor = SubMonitor.convert(npm).newChild(0, SubMonitor.SUPPRESS_ISCANCELED);
- assertTrue("subMonitor should not be canceled", !subMonitor.isCanceled());
+ assertFalse("subMonitor should not be canceled", subMonitor.isCanceled());
npm.setCanceled(true);
- assertTrue("subMonitor should not be canceled", !subMonitor.isCanceled());
+ assertFalse("subMonitor should not be canceled", subMonitor.isCanceled());
}
+ @Test
public void testSuppressIsCanceledFlagIsInherited() {
NullProgressMonitor npm = new NullProgressMonitor();
SubMonitor subMonitor = SubMonitor.convert(npm).newChild(0, SubMonitor.SUPPRESS_ISCANCELED).newChild(0);
- assertTrue("subMonitor should not be canceled", !subMonitor.isCanceled());
+ assertFalse("subMonitor should not be canceled", subMonitor.isCanceled());
npm.setCanceled(true);
- assertTrue("subMonitor should not be canceled", !subMonitor.isCanceled());
+ assertFalse("subMonitor should not be canceled", subMonitor.isCanceled());
}
+ @Test
public void testSuppressIsCanceledAffectsSplit() {
NullProgressMonitor npm = new NullProgressMonitor();
SubMonitor subMonitor = SubMonitor.convert(npm, 100).newChild(100, SubMonitor.SUPPRESS_ISCANCELED);
@@ -446,83 +462,88 @@ public class SubMonitorTest extends TestCase {
/**
* Tests the style bits in SubProgressMonitor
*/
+ @Test
public void testStyles() {
- int[] styles = new int[] {SubMonitor.SUPPRESS_NONE, SubMonitor.SUPPRESS_BEGINTASK, SubMonitor.SUPPRESS_SETTASKNAME, SubMonitor.SUPPRESS_SUBTASK, SubMonitor.SUPPRESS_BEGINTASK | SubMonitor.SUPPRESS_SETTASKNAME, SubMonitor.SUPPRESS_BEGINTASK | SubMonitor.SUPPRESS_SUBTASK, SubMonitor.SUPPRESS_SETTASKNAME | SubMonitor.SUPPRESS_SUBTASK, SubMonitor.SUPPRESS_ALL_LABELS};
+ int[] styles = new int[] { SubMonitor.SUPPRESS_NONE, SubMonitor.SUPPRESS_BEGINTASK,
+ SubMonitor.SUPPRESS_SETTASKNAME, SubMonitor.SUPPRESS_SUBTASK,
+ SubMonitor.SUPPRESS_BEGINTASK | SubMonitor.SUPPRESS_SETTASKNAME,
+ SubMonitor.SUPPRESS_BEGINTASK | SubMonitor.SUPPRESS_SUBTASK,
+ SubMonitor.SUPPRESS_SETTASKNAME | SubMonitor.SUPPRESS_SUBTASK, SubMonitor.SUPPRESS_ALL_LABELS };
HashMap<String, String[]> expected = new HashMap<>();
- expected.put("style 5 below style 7", new String[] {"", "", ""});
- expected.put("style 7 below style 5", new String[] {"beginTask0", "", "beginTask0"});
- expected.put("style 7 below style 4", new String[] {"beginTask0", "subTask0", "beginTask0"});
- expected.put("style 5 below style 6", new String[] {"", "subTask0", ""});
- expected.put("style 3 below style 7", new String[] {"", "", ""});
- expected.put("style 5 below style 5", new String[] {"beginTask0", "", "beginTask0"});
- expected.put("style 7 below style 3", new String[] {"setTaskName0", "", "setTaskName0"});
- expected.put("style 7 below style 2", new String[] {"setTaskName0", "subTask0", "setTaskName0"});
- expected.put("style 5 below style 4", new String[] {"beginTask0", "subTask0", "beginTask0"});
- expected.put("style 3 below style 6", new String[] {"", "subTask0", ""});
- expected.put("style 1 below style 7", new String[] {"", "", ""});
- expected.put("style 3 below style 5", new String[] {"beginTask0", "", "beginTask0"});
- expected.put("style 5 below style 3", new String[] {"beginTask1", "", "beginTask1"});
- expected.put("style 7 below style 1", new String[] {"setTaskName0", "", "setTaskName0"});
- expected.put("style 3 below style 4", new String[] {"beginTask0", "subTask0", "beginTask0"});
- expected.put("style 5 below style 2", new String[] {"beginTask1", "subTask0", "beginTask1"});
- expected.put("style 7 below style 0", new String[] {"setTaskName0", "subTask0", "setTaskName0"});
- expected.put("style 1 below style 6", new String[] {"", "subTask0", ""});
- expected.put("style 1 below style 5", new String[] {"beginTask0", "", "beginTask0"});
- expected.put("style 3 below style 3", new String[] {"setTaskName0", "", "setTaskName1"});
- expected.put("style 5 below style 1", new String[] {"beginTask1", "", "beginTask1"});
- expected.put("style 1 below style 4", new String[] {"beginTask0", "subTask0", "beginTask0"});
- expected.put("style 3 below style 2", new String[] {"setTaskName0", "subTask0", "setTaskName1"});
- expected.put("style 5 below style 0", new String[] {"beginTask1", "subTask0", "beginTask1"});
- expected.put("style 1 below style 3", new String[] {"beginTask1", "", "setTaskName1"});
- expected.put("style 3 below style 1", new String[] {"setTaskName0", "", "setTaskName1"});
- expected.put("style 1 below style 2", new String[] {"beginTask1", "subTask0", "setTaskName1"});
- expected.put("style 3 below style 0", new String[] {"setTaskName0", "subTask0", "setTaskName1"});
- expected.put("style 1 below style 1", new String[] {"beginTask1", "", "setTaskName1"});
- expected.put("style 1 below style 0", new String[] {"beginTask1", "subTask0", "setTaskName1"});
- expected.put("style 3 as top-level monitor", new String[] {"", "", "setTaskName0"});
- expected.put("style 7 as top-level monitor", new String[] {"", "", ""});
- expected.put("style 2 as top-level monitor", new String[] {"", "subTask0", "setTaskName0"});
- expected.put("style 6 as top-level monitor", new String[] {"", "subTask0", ""});
- expected.put("style 6 below style 7", new String[] {"", "", ""});
- expected.put("style 6 below style 6", new String[] {"", "subTask1", ""});
- expected.put("style 4 below style 7", new String[] {"", "", ""});
- expected.put("style 6 below style 5", new String[] {"beginTask0", "", "beginTask0"});
- expected.put("style 6 below style 4", new String[] {"beginTask0", "subTask1", "beginTask0"});
- expected.put("style 4 below style 6", new String[] {"", "subTask1", ""});
- expected.put("style 2 below style 7", new String[] {"", "", ""});
- expected.put("style 4 below style 5", new String[] {"beginTask0", "", "beginTask0"});
- expected.put("style 6 below style 3", new String[] {"setTaskName0", "", "setTaskName0"});
- expected.put("style 4 below style 4", new String[] {"beginTask0", "subTask1", "beginTask0"});
- expected.put("style 6 below style 2", new String[] {"setTaskName0", "subTask1", "setTaskName0"});
- expected.put("style 2 below style 6", new String[] {"", "subTask1", ""});
- expected.put("style 0 below style 7", new String[] {"", "", ""});
- expected.put("style 2 below style 5", new String[] {"beginTask0", "", "beginTask0"});
- expected.put("style 6 below style 1", new String[] {"setTaskName0", "", "setTaskName0"});
- expected.put("style 4 below style 3", new String[] {"beginTask1", "", "beginTask1"});
- expected.put("style 2 below style 4", new String[] {"beginTask0", "subTask1", "beginTask0"});
- expected.put("style 6 below style 0", new String[] {"setTaskName0", "subTask1", "setTaskName0"});
- expected.put("style 4 below style 2", new String[] {"beginTask1", "subTask1", "beginTask1"});
- expected.put("style 0 below style 6", new String[] {"", "subTask1", ""});
- expected.put("style 0 below style 5", new String[] {"beginTask0", "", "beginTask0"});
- expected.put("style 4 below style 1", new String[] {"beginTask1", "", "beginTask1"});
- expected.put("style 2 below style 3", new String[] {"setTaskName0", "", "setTaskName1"});
- expected.put("style 0 below style 4", new String[] {"beginTask0", "subTask1", "beginTask0"});
- expected.put("style 4 below style 0", new String[] {"beginTask1", "subTask1", "beginTask1"});
- expected.put("style 2 below style 2", new String[] {"setTaskName0", "subTask1", "setTaskName1"});
- expected.put("style 1 as top-level monitor", new String[] {"beginTask0", "", "setTaskName0"});
- expected.put("style 2 below style 1", new String[] {"setTaskName0", "", "setTaskName1"});
- expected.put("style 0 below style 3", new String[] {"beginTask1", "", "setTaskName1"});
- expected.put("style 2 below style 0", new String[] {"setTaskName0", "subTask1", "setTaskName1"});
- expected.put("style 0 below style 2", new String[] {"beginTask1", "subTask1", "setTaskName1"});
- expected.put("style 0 below style 1", new String[] {"beginTask1", "", "setTaskName1"});
- expected.put("style 0 below style 0", new String[] {"beginTask1", "subTask1", "setTaskName1"});
- expected.put("style 5 as top-level monitor", new String[] {"beginTask0", "", "beginTask0"});
- expected.put("style 0 as top-level monitor", new String[] {"beginTask0", "subTask0", "setTaskName0"});
- expected.put("style 4 as top-level monitor", new String[] {"beginTask0", "subTask0", "beginTask0"});
- expected.put("style 7 below style 7", new String[] {"", "", ""});
- expected.put("style 7 below style 6", new String[] {"", "subTask0", ""});
+ expected.put("style 5 below style 7", new String[] { "", "", "" });
+ expected.put("style 7 below style 5", new String[] { "beginTask0", "", "beginTask0" });
+ expected.put("style 7 below style 4", new String[] { "beginTask0", "subTask0", "beginTask0" });
+ expected.put("style 5 below style 6", new String[] { "", "subTask0", "" });
+ expected.put("style 3 below style 7", new String[] { "", "", "" });
+ expected.put("style 5 below style 5", new String[] { "beginTask0", "", "beginTask0" });
+ expected.put("style 7 below style 3", new String[] { "setTaskName0", "", "setTaskName0" });
+ expected.put("style 7 below style 2", new String[] { "setTaskName0", "subTask0", "setTaskName0" });
+ expected.put("style 5 below style 4", new String[] { "beginTask0", "subTask0", "beginTask0" });
+ expected.put("style 3 below style 6", new String[] { "", "subTask0", "" });
+ expected.put("style 1 below style 7", new String[] { "", "", "" });
+ expected.put("style 3 below style 5", new String[] { "beginTask0", "", "beginTask0" });
+ expected.put("style 5 below style 3", new String[] { "beginTask1", "", "beginTask1" });
+ expected.put("style 7 below style 1", new String[] { "setTaskName0", "", "setTaskName0" });
+ expected.put("style 3 below style 4", new String[] { "beginTask0", "subTask0", "beginTask0" });
+ expected.put("style 5 below style 2", new String[] { "beginTask1", "subTask0", "beginTask1" });
+ expected.put("style 7 below style 0", new String[] { "setTaskName0", "subTask0", "setTaskName0" });
+ expected.put("style 1 below style 6", new String[] { "", "subTask0", "" });
+ expected.put("style 1 below style 5", new String[] { "beginTask0", "", "beginTask0" });
+ expected.put("style 3 below style 3", new String[] { "setTaskName0", "", "setTaskName1" });
+ expected.put("style 5 below style 1", new String[] { "beginTask1", "", "beginTask1" });
+ expected.put("style 1 below style 4", new String[] { "beginTask0", "subTask0", "beginTask0" });
+ expected.put("style 3 below style 2", new String[] { "setTaskName0", "subTask0", "setTaskName1" });
+ expected.put("style 5 below style 0", new String[] { "beginTask1", "subTask0", "beginTask1" });
+ expected.put("style 1 below style 3", new String[] { "beginTask1", "", "setTaskName1" });
+ expected.put("style 3 below style 1", new String[] { "setTaskName0", "", "setTaskName1" });
+ expected.put("style 1 below style 2", new String[] { "beginTask1", "subTask0", "setTaskName1" });
+ expected.put("style 3 below style 0", new String[] { "setTaskName0", "subTask0", "setTaskName1" });
+ expected.put("style 1 below style 1", new String[] { "beginTask1", "", "setTaskName1" });
+ expected.put("style 1 below style 0", new String[] { "beginTask1", "subTask0", "setTaskName1" });
+ expected.put("style 3 as top-level monitor", new String[] { "", "", "setTaskName0" });
+ expected.put("style 7 as top-level monitor", new String[] { "", "", "" });
+ expected.put("style 2 as top-level monitor", new String[] { "", "subTask0", "setTaskName0" });
+ expected.put("style 6 as top-level monitor", new String[] { "", "subTask0", "" });
+ expected.put("style 6 below style 7", new String[] { "", "", "" });
+ expected.put("style 6 below style 6", new String[] { "", "subTask1", "" });
+ expected.put("style 4 below style 7", new String[] { "", "", "" });
+ expected.put("style 6 below style 5", new String[] { "beginTask0", "", "beginTask0" });
+ expected.put("style 6 below style 4", new String[] { "beginTask0", "subTask1", "beginTask0" });
+ expected.put("style 4 below style 6", new String[] { "", "subTask1", "" });
+ expected.put("style 2 below style 7", new String[] { "", "", "" });
+ expected.put("style 4 below style 5", new String[] { "beginTask0", "", "beginTask0" });
+ expected.put("style 6 below style 3", new String[] { "setTaskName0", "", "setTaskName0" });
+ expected.put("style 4 below style 4", new String[] { "beginTask0", "subTask1", "beginTask0" });
+ expected.put("style 6 below style 2", new String[] { "setTaskName0", "subTask1", "setTaskName0" });
+ expected.put("style 2 below style 6", new String[] { "", "subTask1", "" });
+ expected.put("style 0 below style 7", new String[] { "", "", "" });
+ expected.put("style 2 below style 5", new String[] { "beginTask0", "", "beginTask0" });
+ expected.put("style 6 below style 1", new String[] { "setTaskName0", "", "setTaskName0" });
+ expected.put("style 4 below style 3", new String[] { "beginTask1", "", "beginTask1" });
+ expected.put("style 2 below style 4", new String[] { "beginTask0", "subTask1", "beginTask0" });
+ expected.put("style 6 below style 0", new String[] { "setTaskName0", "subTask1", "setTaskName0" });
+ expected.put("style 4 below style 2", new String[] { "beginTask1", "subTask1", "beginTask1" });
+ expected.put("style 0 below style 6", new String[] { "", "subTask1", "" });
+ expected.put("style 0 below style 5", new String[] { "beginTask0", "", "beginTask0" });
+ expected.put("style 4 below style 1", new String[] { "beginTask1", "", "beginTask1" });
+ expected.put("style 2 below style 3", new String[] { "setTaskName0", "", "setTaskName1" });
+ expected.put("style 0 below style 4", new String[] { "beginTask0", "subTask1", "beginTask0" });
+ expected.put("style 4 below style 0", new String[] { "beginTask1", "subTask1", "beginTask1" });
+ expected.put("style 2 below style 2", new String[] { "setTaskName0", "subTask1", "setTaskName1" });
+ expected.put("style 1 as top-level monitor", new String[] { "beginTask0", "", "setTaskName0" });
+ expected.put("style 2 below style 1", new String[] { "setTaskName0", "", "setTaskName1" });
+ expected.put("style 0 below style 3", new String[] { "beginTask1", "", "setTaskName1" });
+ expected.put("style 2 below style 0", new String[] { "setTaskName0", "subTask1", "setTaskName1" });
+ expected.put("style 0 below style 2", new String[] { "beginTask1", "subTask1", "setTaskName1" });
+ expected.put("style 0 below style 1", new String[] { "beginTask1", "", "setTaskName1" });
+ expected.put("style 0 below style 0", new String[] { "beginTask1", "subTask1", "setTaskName1" });
+ expected.put("style 5 as top-level monitor", new String[] { "beginTask0", "", "beginTask0" });
+ expected.put("style 0 as top-level monitor", new String[] { "beginTask0", "subTask0", "setTaskName0" });
+ expected.put("style 4 as top-level monitor", new String[] { "beginTask0", "subTask0", "beginTask0" });
+ expected.put("style 7 below style 7", new String[] { "", "", "" });
+ expected.put("style 7 below style 6", new String[] { "", "subTask0", "" });
HashMap<String, String[]> results = new HashMap<>();
for (int style : styles) {
@@ -554,8 +575,8 @@ public class SubMonitorTest extends TestCase {
}
}
- String failure = null;
- // Output the code for the observed results, in case one of them has changed intentionally
+ // Output the code for the observed results, in case one of them has changed
+ // intentionally
for (Map.Entry<String, String[]> entry : results.entrySet()) {
String[] expectedResult = expected.get(entry.getKey());
if (expectedResult == null) {
@@ -563,59 +584,14 @@ public class SubMonitorTest extends TestCase {
}
String[] value = entry.getValue();
- if (compareArray(value, expectedResult)) {
- continue;
- }
-
- System.out.print("expected.put(\"" + entry.getKey() + "\", new String[] {");
- failure = entry.getKey();
- String list = concatArray(value);
- System.out.println(list + "});");
- }
-
- if (failure != null) {
- Assert.assertEquals(failure, concatArray(expected.get(failure)), concatArray(results.get(failure)));
- }
- }
-
- private boolean compareArray(String[] value, String[] expectedResult) {
- if (value == null || expectedResult == null) {
- return value == null && expectedResult == null;
- }
-
- if (value.length != expectedResult.length) {
- return false;
- }
- for (int i = 0; i < expectedResult.length; i++) {
- String next = expectedResult[i];
- if (!next.equals(value[i])) {
- return false;
- }
+ assertArrayEquals(value, expectedResult);
}
- return true;
- }
-
- private String concatArray(String[] value) {
- if (value == null) {
- return "";
- }
-
- StringBuilder buf = new StringBuilder();
- boolean isFirst = true;
- for (String nextValue : value) {
- if (!isFirst) {
- buf.append(", ");
- }
- isFirst = false;
- buf.append("\"" + nextValue + "\"");
- }
- String list = buf.toString();
- return list;
}
/**
* Ensures that SubMonitor doesn't propogate redundant progress to its parent.
*/
+ @Test
public void testRedundantWork() {
TestProgressMonitor top = new TestProgressMonitor();
@@ -634,6 +610,7 @@ public class SubMonitorTest extends TestCase {
top.assertOptimal();
}
+ @Test
public void testCancellation() {
TestProgressMonitor root = new TestProgressMonitor();
@@ -641,13 +618,13 @@ public class SubMonitorTest extends TestCase {
// Test that changes at the root propogate to the child
root.setCanceled(true);
- Assert.assertTrue(spm.isCanceled());
+ assertTrue(spm.isCanceled());
root.setCanceled(false);
Assert.assertFalse(spm.isCanceled());
// Test that changes to the child propogate to the root
spm.setCanceled(true);
- Assert.assertTrue(root.isCanceled());
+ assertTrue(root.isCanceled());
spm.setCanceled(false);
Assert.assertFalse(root.isCanceled());
@@ -657,17 +634,18 @@ public class SubMonitorTest extends TestCase {
// Test that changes at the root propogate to the child
root.setCanceled(true);
- Assert.assertTrue(spm2.isCanceled());
+ assertTrue(spm2.isCanceled());
root.setCanceled(false);
Assert.assertFalse(spm2.isCanceled());
// Test that changes to the child propogate to the root
spm2.setCanceled(true);
- Assert.assertTrue(root.isCanceled());
+ assertTrue(root.isCanceled());
spm2.setCanceled(false);
Assert.assertFalse(root.isCanceled());
}
+ @Test
public void testNullParent() {
// Touch everything in the public API to ensure we don't throw an NPE
SubMonitor mon = SubMonitor.convert(null, 1000);
@@ -678,57 +656,63 @@ public class SubMonitorTest extends TestCase {
mon.internalWorked(50.0);
Assert.assertFalse(mon.isCanceled());
mon.setCanceled(true);
- Assert.assertTrue(mon.isCanceled());
+ assertTrue(mon.isCanceled());
mon.subTask("subtask");
mon.setTaskName("taskname");
mon.done();
}
/**
- * Tests the automatic cleanup when progress monitors are created via their constructor
+ * Tests the automatic cleanup when progress monitors are created via their
+ * constructor
*/
+ @Test
public void testNewChild() {
TestProgressMonitor top = new TestProgressMonitor();
SubMonitor mon = SubMonitor.convert(top, 1000);
- Assert.assertEquals("Ensure no work has been reported yet", 0.0, top.getTotalWork(), 0.01d);
+ assertEquals("Ensure no work has been reported yet", 0.0, top.getTotalWork(), 0.01d);
mon.newChild(100);
- Assert.assertEquals("Ensure no work has been reported yet", 0.0, top.getTotalWork(), 0.01d);
+ assertEquals("Ensure no work has been reported yet", 0.0, top.getTotalWork(), 0.01d);
mon.newChild(200);
- Assert.assertEquals("Ensure monitor1 was collected", 100.0, top.getTotalWork(), 0.01d);
+ assertEquals("Ensure monitor1 was collected", 100.0, top.getTotalWork(), 0.01d);
- // The following behavior is necessary to make it possible to pass multiple progress monitors as
+ // The following behavior is necessary to make it possible to pass multiple
+ // progress monitors as
// arguments to the same method.
- Assert.assertEquals("Monitor2 should not have been collected yet (when the public constructor is used, collection should happen when beginTask() or setWorkRemaining() is called.", 100.0, top.getTotalWork(), 0.01d);
+ assertEquals(
+ "Monitor2 should not have been collected yet (when the public constructor is used, collection should happen when beginTask() or setWorkRemaining() is called.",
+ 100.0, top.getTotalWork(), 0.01d);
SubMonitor monitor4 = mon.newChild(300);
- Assert.assertEquals("Now monitor2 should be collected", 300.0, top.getTotalWork(), 0.01d);
+ assertEquals("Now monitor2 should be collected", 300.0, top.getTotalWork(), 0.01d);
monitor4.done();
- Assert.assertEquals("Now monitor4 should be collected", 600.0, top.getTotalWork(), 0.01d);
+ assertEquals("Now monitor4 should be collected", 600.0, top.getTotalWork(), 0.01d);
mon.newChild(10);
- Assert.assertEquals("Creating a child when there are no active children should not report any work", 600.0, top.getTotalWork(), 0.01d);
+ assertEquals("Creating a child when there are no active children should not report any work", 600.0,
+ top.getTotalWork(), 0.01d);
mon.worked(20);
// Test for bug 210394
- Assert.assertEquals("Reporting work should cause the active child to be destroyed", 630.0, top.getTotalWork(), 0.01d);
+ assertEquals("Reporting work should cause the active child to be destroyed", 630.0, top.getTotalWork(), 0.01d);
mon.newChild(10);
- Assert.assertEquals("monitor5 should have been cleaned up", 630.0, top.getTotalWork(), 0.01d);
+ assertEquals("monitor5 should have been cleaned up", 630.0, top.getTotalWork(), 0.01d);
mon.internalWorked(60);
- Assert.assertEquals("Calling internalWorked should clean up active children", 700.0, top.getTotalWork(), 0.01d);
+ assertEquals("Calling internalWorked should clean up active children", 700.0, top.getTotalWork(), 0.01d);
// Now create a chain of undisposed children
SubMonitor monitor7 = mon.newChild(100);
@@ -739,29 +723,32 @@ public class SubMonitorTest extends TestCase {
mon.done();
- Assert.assertEquals("Calling done should clean up unused work", 1000.0, top.getTotalWork(), 0.01d);
+ assertEquals("Calling done should clean up unused work", 1000.0, top.getTotalWork(), 0.01d);
}
/**
- * Tests creating progress monitors under a custom progress monitor
- * parent. This is the same as the performance test as the same name,
- * but it verifies correctness rather than performance.
+ * Tests creating progress monitors under a custom progress monitor parent. This
+ * is the same as the performance test as the same name, but it verifies
+ * correctness rather than performance.
*/
+ @Test
public void testCreateChildrenUnderCustomParent() {
TestProgressMonitor monitor = new TestProgressMonitor();
createChildrenUnderParent(monitor, SubMonitorTest.PROGRESS_SIZE);
- // We don't actually expect the progress to be optimal in this case since the progress monitor wouldn't
- // know what it was rooted under and would have had to report more progress than necessary... but we
+ // We don't actually expect the progress to be optimal in this case since the
+ // progress monitor wouldn't
+ // know what it was rooted under and would have had to report more progress than
+ // necessary... but we
// should be able to check that there was no redundancy.
- Assert.assertTrue(monitor.getRedundantWorkCalls() == 0);
- Assert.assertTrue(monitor.getWorkCalls() >= 100);
+ assertEquals(0, monitor.getRedundantWorkCalls());
+ assertTrue(monitor.getWorkCalls() >= 100);
}
/**
- * Creates a chain of n nested progress monitors. Calls beginTask on all monitors
- * except for the innermost one.
+ * Creates a chain of n nested progress monitors. Calls beginTask on all
+ * monitors except for the innermost one.
*
* @param parent
* @param depth
@@ -780,11 +767,12 @@ public class SubMonitorTest extends TestCase {
}
/**
- * Creates a balanced binary tree of progress monitors, without calling worked. Tests
- * progress monitor creation and cleanup time, and ensures that excess progress is
- * being collected when IProgressMonitor.done() is called.
+ * Creates a balanced binary tree of progress monitors, without calling worked.
+ * Tests progress monitor creation and cleanup time, and ensures that excess
+ * progress is being collected when IProgressMonitor.done() is called.
*
- * @param monitor progress monitor (callers are responsible for calling done() if necessary)
+ * @param monitor progress monitor (callers are responsible for calling done()
+ * if necessary)
* @param loopSize total size of the recursion tree
*/
public static void createBalancedTree(IProgressMonitor parent, int loopSize) {
@@ -802,13 +790,22 @@ public class SubMonitorTest extends TestCase {
}
/**
- * <p>The innermost loop for the create tree test. We make this a static method so
- * that it can be used both in this performance test and in the correctness test.</p>
+ * <p>
+ * The innermost loop for the create tree test. We make this a static method so
+ * that it can be used both in this performance test and in the correctness
+ * test.
+ * </p>
*
- * <p>The performance test ensures that it is fast to create a lot of progress monitors.</p>
+ * <p>
+ * The performance test ensures that it is fast to create a lot of progress
+ * monitors.
+ * </p>
*
- * <p>The correctness test ensures that creating and destroying SubMonitors
- * is enough to report progress, even if worked(int) and worked(double) are never called</p>
+ * <p>
+ * The correctness test ensures that creating and destroying SubMonitors is
+ * enough to report progress, even if worked(int) and worked(double) are never
+ * called
+ * </p>
*/
public static void runTestCreateTree(IProgressMonitor monitor) {
SubMonitor progress = SubMonitor.convert(monitor, 100);
@@ -821,12 +818,14 @@ public class SubMonitorTest extends TestCase {
}
/**
- * Reports progress by creating a balanced binary tree of progress monitors. Simulates
- * mixed usage of IProgressMonitor in a typical usage. Calls isCanceled once each time work
- * is reported. Half of the work is reported using internalWorked and half is reported using worked,
- * to simulate mixed usage of the progress monitor.
+ * Reports progress by creating a balanced binary tree of progress monitors.
+ * Simulates mixed usage of IProgressMonitor in a typical usage. Calls
+ * isCanceled once each time work is reported. Half of the work is reported
+ * using internalWorked and half is reported using worked, to simulate mixed
+ * usage of the progress monitor.
*
- * @param monitor progress monitor (callers are responsible for calling done() if necessary)
+ * @param monitor progress monitor (callers are responsible for calling done()
+ * if necessary)
* @param loopSize total size of the recursion tree
*/
public static void reportWorkInBalancedTree(IProgressMonitor parent, int loopSize) {
@@ -853,7 +852,8 @@ public class SubMonitorTest extends TestCase {
/**
* The innermost loop for the recursion test. We make this a static method so
- * that it can be used both in this performance test and in the correctness test.
+ * that it can be used both in this performance test and in the correctness
+ * test.
*/
public static void runTestTypicalUsage(IProgressMonitor monitor) {
SubMonitor progress = SubMonitor.convert(monitor, 100);
@@ -866,10 +866,10 @@ public class SubMonitorTest extends TestCase {
}
/**
- * Tests SubMonitor.worked. This is the same
- * as the performance test as the same name, but it verifies correctness
- * rather than performance.
+ * Tests SubMonitor.worked. This is the same as the performance test as the same
+ * name, but it verifies correctness rather than performance.
*/
+ @Test
public void testWorked() {
TestProgressMonitor monitor = new TestProgressMonitor();
SubMonitor progress = SubMonitor.convert(monitor, 100);
@@ -884,10 +884,10 @@ public class SubMonitorTest extends TestCase {
}
/**
- * Tests SubMonitor.worked. This is the same
- * as the performance test as the same name, but it verifies correctness
- * rather than performance.
+ * Tests SubMonitor.worked. This is the same as the performance test as the same
+ * name, but it verifies correctness rather than performance.
*/
+ @Test
public void testInternalWorked() {
TestProgressMonitor monitor = new TestProgressMonitor();
SubMonitor progress = SubMonitor.convert(monitor, 100);
@@ -906,6 +906,7 @@ public class SubMonitorTest extends TestCase {
* {@link SubMonitor#split(int, int)} when passing in the
* {@link SubMonitor#SUPPRESS_ISCANCELED} flag.
*/
+ @Test
public void testSplitDoesNotCancelWhenCancellationSuppressed() {
TestProgressMonitor monitor = new TestProgressMonitor();
monitor.setCanceled(true);
@@ -919,10 +920,11 @@ public class SubMonitorTest extends TestCase {
}
/**
- * Creates and destroys the given number of child progress monitors under the given parent.
+ * Creates and destroys the given number of child progress monitors under the
+ * given parent.
*
- * @param parent monitor to create children under. The caller must call done on this monitor
- * if necessary.
+ * @param parent monitor to create children under. The caller must call
+ * done on this monitor if necessary.
* @param progressSize total number of children to create.
*/
private static void createChildrenUnderParent(IProgressMonitor parent, int progressSize) {
@@ -934,9 +936,4 @@ public class SubMonitorTest extends TestCase {
}
}
- static public void reportPerformance(String className, String methodName, long startTime, long endTime) {
- // enable to see performance results for the progress monitors
- // System.out.println(className + "#" + methodName + " elapsed time: " + (endTime - startTime) / 1000.0d + "s");
- }
-
}
diff --git a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/SubProgressTest.java b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/SubProgressTest.java
index 59494520a..64f905cac 100644
--- a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/SubProgressTest.java
+++ b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/SubProgressTest.java
@@ -14,19 +14,25 @@
*******************************************************************************/
package org.eclipse.equinox.common.tests;
-import java.util.*;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.junit.Assert;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TestName;
-/**
- *
- */
@SuppressWarnings("deprecation")
-public class SubProgressTest extends TestCase {
+public class SubProgressTest {
- private long startTime;
/**
* <p>Depth of the chain chain of progress monitors. In all of the tests, we create
* a nested chain of progress monitors rathar than a single monitor, to test its
@@ -47,54 +53,15 @@ public class SubProgressTest extends TestCase {
*/
public static final int PROGRESS_SIZE = 100000;
- public SubProgressTest() {
- super();
- }
-
- public SubProgressTest(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- startTime = System.currentTimeMillis();
- super.setUp();
- }
-
- @Override
- protected void tearDown() throws Exception {
- long endTime = System.currentTimeMillis();
- SubMonitorTest.reportPerformance(getClass().getName(), getName(), startTime, endTime);
- super.tearDown();
- }
-
- /**
- * Calls done on the given progress monitor and all of its parents, to a maximum
- * of the given depth.
- *
- * @deprecated to suppress deprecation warnings
- *
- * @param monitor
- * @param depth
- */
- @Deprecated
- public static void callDoneOnChain(IProgressMonitor monitor, int depth) {
- IProgressMonitor current = monitor;
- for (int count = 0; count < depth; count++) {
- current.done();
- if (!(current instanceof SubProgressMonitor)) {
- return;
- }
- SubProgressMonitor cur = (SubProgressMonitor) current;
- current = cur.getWrappedProgressMonitor();
- }
- }
+ @Rule
+ public TestName name = new TestName();
/**
* Tests the style bits in SubProgressMonitor
* @deprecated to suppress deprecation warnings
*/
@Deprecated
+ @Test
public void testStyles() {
int[] styles = new int[] {0, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK | SubProgressMonitor.SUPPRESS_SUBTASK_LABEL};
@@ -139,51 +106,13 @@ public class SubProgressTest extends TestCase {
child.done();
}
- String failure = null;
// Output the code for the observed results, in case one of them has changed intentionally
for (Map.Entry<String, String[]> entry : results.entrySet()) {
String[] expectedResult = expected.get(entry.getKey());
String[] value = entry.getValue();
- if (compareArray(value, expectedResult)) {
- continue;
- }
-
- System.out.print("expected.put(\"" + entry.getKey() + "\", new String[] {");
- failure = entry.getKey();
- String list = concatArray(value);
- System.out.println(list + "});");
- }
-
- if (failure != null) {
- Assert.assertEquals(failure, concatArray(expected.get(failure)), concatArray(results.get(failure)));
- }
- }
-
- private boolean compareArray(String[] value, String[] expectedResult) {
- if (value.length != expectedResult.length) {
- return false;
- }
- for (int i = 0; i < expectedResult.length; i++) {
- String next = expectedResult[i];
- if (!next.equals(value[i])) {
- return false;
- }
+ assertArrayEquals(value, expectedResult);
}
- return true;
- }
- private String concatArray(String[] value) {
- StringBuilder buf = new StringBuilder();
- boolean isFirst = true;
- for (String nextValue : value) {
- if (!isFirst) {
- buf.append(", ");
- }
- isFirst = false;
- buf.append("\"" + nextValue + "\"");
- }
- String list = buf.toString();
- return list;
}
private String[] runChildTest(int depth, TestProgressMonitor root, IProgressMonitor child, int ticks) {
@@ -203,6 +132,7 @@ public class SubProgressTest extends TestCase {
* @deprecated to suppress deprecation warnings
*/
@Deprecated
+ @Test
public void testConstructorNestingFP() {
TestProgressMonitor top = new TestProgressMonitor();
top.beginTask("", 2000);
@@ -213,7 +143,7 @@ public class SubProgressTest extends TestCase {
fpMonitor.internalWorked(50.0);
fpMonitor.internalWorked(-10.0); // should have no effect
- Assert.assertEquals(500.0, top.getTotalWork(), 0.01d);
+ assertEquals(500.0, top.getTotalWork(), 0.01d);
// Create a child monitor, and ensure that it grabs the correct amount of work
// from the parent.
@@ -222,7 +152,7 @@ public class SubProgressTest extends TestCase {
childMonitor.worked(100);
childMonitor.done();
- Assert.assertEquals(700.0, top.getTotalWork(), 0.01d);
+ assertEquals(700.0, top.getTotalWork(), 0.01d);
// Create a child monitor, and ensure that it grabs the correct amount of work
// from the parent.
@@ -231,7 +161,7 @@ public class SubProgressTest extends TestCase {
childMonitor2.worked(100);
childMonitor2.done();
- Assert.assertEquals(1000.0, top.getTotalWork(), 0.01d);
+ assertEquals(1000.0, top.getTotalWork(), 0.01d);
// Ensure that creating another child will have no effect
SubProgressMonitor childMonitor3 = new SubProgressMonitor(fpMonitor, 10);
@@ -239,11 +169,11 @@ public class SubProgressTest extends TestCase {
childMonitor3.worked(100);
childMonitor3.done();
- Assert.assertEquals(1000.0, top.getTotalWork(), 0.01d);
+ assertEquals(1000.0, top.getTotalWork(), 0.01d);
fpMonitor.worked(100);
- Assert.assertEquals(1000.0, top.getTotalWork(), 0.01d);
+ assertEquals(1000.0, top.getTotalWork(), 0.01d);
fpMonitor.done();
- Assert.assertEquals(1000.0, top.getTotalWork(), 0.01d);
+ assertEquals(1000.0, top.getTotalWork(), 0.01d);
}
/**
@@ -252,6 +182,7 @@ public class SubProgressTest extends TestCase {
* @deprecated to suppress deprecation warnings
*/
@Deprecated
+ @Test
public void testConstructorNestingInt() {
TestProgressMonitor top = new TestProgressMonitor();
top.beginTask("", 2000);
@@ -261,7 +192,7 @@ public class SubProgressTest extends TestCase {
fpMonitor.beginTask("", 100);
fpMonitor.worked(50);
- Assert.assertEquals(500.0, top.getTotalWork(), 0.01d);
+ assertEquals(500.0, top.getTotalWork(), 0.01d);
// Create a child monitor, and ensure that it grabs the correct amount of work
// from the parent.
@@ -270,7 +201,7 @@ public class SubProgressTest extends TestCase {
childMonitor.worked(100);
childMonitor.done();
- Assert.assertEquals(700.0, top.getTotalWork(), 0.01d);
+ assertEquals(700.0, top.getTotalWork(), 0.01d);
// Create a child monitor, and ensure that it grabs the correct amount of work
// from the parent.
@@ -279,7 +210,7 @@ public class SubProgressTest extends TestCase {
childMonitor2.worked(100);
childMonitor2.done();
- Assert.assertEquals(1000.0, top.getTotalWork(), 0.01d);
+ assertEquals(1000.0, top.getTotalWork(), 0.01d);
// Ensure that creating another child will have no effect
SubProgressMonitor childMonitor3 = new SubProgressMonitor(fpMonitor, 10);
@@ -287,11 +218,11 @@ public class SubProgressTest extends TestCase {
childMonitor3.worked(100);
childMonitor3.done();
- Assert.assertEquals(1000.0, top.getTotalWork(), 0.01d);
+ assertEquals(1000.0, top.getTotalWork(), 0.01d);
fpMonitor.worked(100);
- Assert.assertEquals(1000.0, top.getTotalWork(), 0.01d);
+ assertEquals(1000.0, top.getTotalWork(), 0.01d);
fpMonitor.done();
- Assert.assertEquals(1000.0, top.getTotalWork(), 0.01d);
+ assertEquals(1000.0, top.getTotalWork(), 0.01d);
}
/**
@@ -299,6 +230,7 @@ public class SubProgressTest extends TestCase {
* @deprecated to suppress deprecation warnings
*/
@Deprecated
+ @Test
public void testParallelChildren() {
TestProgressMonitor top = new TestProgressMonitor();
top.beginTask("", 1000);
@@ -308,35 +240,36 @@ public class SubProgressTest extends TestCase {
SubProgressMonitor monitor1 = new SubProgressMonitor(mon, 200);
SubProgressMonitor monitor2 = new SubProgressMonitor(mon, 200);
- Assert.assertEquals("Ensure no work has been reported yet", 0.0, top.getTotalWork(), 0.01d);
+ assertEquals("Ensure no work has been reported yet", 0.0, top.getTotalWork(), 0.01d);
monitor1.beginTask("", 1000);
- Assert.assertEquals("Ensure no work has been reported yet", 0.0, top.getTotalWork(), 0.01d);
+ assertEquals("Ensure no work has been reported yet", 0.0, top.getTotalWork(), 0.01d);
monitor2.beginTask("", 1000);
- Assert.assertEquals("Should not have cleaned up monitor 1", 0.0, top.getTotalWork(), 0.01d);
+ assertEquals("Should not have cleaned up monitor 1", 0.0, top.getTotalWork(), 0.01d);
monitor1.done();
- Assert.assertEquals("Should have cleaned up monitor 1", 200.0, top.getTotalWork(), 0.01d);
+ assertEquals("Should have cleaned up monitor 1", 200.0, top.getTotalWork(), 0.01d);
monitor1.worked(1000);
- Assert.assertEquals("Monitor1 shouldn't report work once it's complete", 200.0, top.getTotalWork(), 0.01d);
+ assertEquals("Monitor1 shouldn't report work once it's complete", 200.0, top.getTotalWork(), 0.01d);
monitor2.worked(500);
- Assert.assertEquals(300.0, top.getTotalWork(), 0.01d);
+ assertEquals(300.0, top.getTotalWork(), 0.01d);
// Create a monitor that will leak - monitors won't be auto-completed until their done methods are
// called
SubProgressMonitor monitor3 = new SubProgressMonitor(mon, 300);
- Assert.assertEquals("Monitor2 should not have been cleaned up yet", 300.0, top.getTotalWork(), 0.01d);
+ assertEquals("Monitor2 should not have been cleaned up yet", 300.0, top.getTotalWork(), 0.01d);
SubProgressMonitor monitor4 = new SubProgressMonitor(mon, 300);
monitor4.beginTask("", 100);
mon.done();
Assert.assertNotNull(monitor3);
- Assert.assertEquals("All leaked work should have been collected", 1000.0, top.getTotalWork(), 0.01d);
+ assertEquals("All leaked work should have been collected", 1000.0, top.getTotalWork(), 0.01d);
}
/**
* @deprecated to suppress deprecation warnings
*/
@Deprecated
+ @Test
public void testCancellation() {
TestProgressMonitor root = new TestProgressMonitor();
root.beginTask("", 1000);
@@ -345,15 +278,15 @@ public class SubProgressTest extends TestCase {
// Test that changes at the root propogate to the child
root.setCanceled(true);
- Assert.assertTrue(spm.isCanceled());
+ assertTrue(spm.isCanceled());
root.setCanceled(false);
- Assert.assertFalse(spm.isCanceled());
+ assertFalse(spm.isCanceled());
// Test that changes to the child propogate to the root
spm.setCanceled(true);
- Assert.assertTrue(root.isCanceled());
+ assertTrue(root.isCanceled());
spm.setCanceled(false);
- Assert.assertFalse(root.isCanceled());
+ assertFalse(root.isCanceled());
// Test a chain of depth 2
spm.beginTask("", 1000);
@@ -361,22 +294,23 @@ public class SubProgressTest extends TestCase {
// Test that changes at the root propogate to the child
root.setCanceled(true);
- Assert.assertTrue(spm2.isCanceled());
+ assertTrue(spm2.isCanceled());
root.setCanceled(false);
- Assert.assertFalse(spm2.isCanceled());
+ assertFalse(spm2.isCanceled());
// Test that changes to the child propogate to the root
spm2.setCanceled(true);
- Assert.assertTrue(root.isCanceled());
+ assertTrue(root.isCanceled());
spm2.setCanceled(false);
- Assert.assertFalse(root.isCanceled());
+ assertFalse(root.isCanceled());
}
/**
- * Tests creating progress monitors under a custom progress monitor
- * parent. This is the same as the performance test as the same name,
- * but it verifies correctness rather than performance.
+ * Tests creating progress monitors under a custom progress monitor parent. This
+ * is the same as the performance test as the same name, but it verifies
+ * correctness rather than performance.
*/
+ @Test
public void testCreateChildrenUnderCustomParent() {
TestProgressMonitor monitor = new TestProgressMonitor();
createChildrenUnderParent(monitor, SubProgressTest.PROGRESS_SIZE);
@@ -385,182 +319,8 @@ public class SubProgressTest extends TestCase {
// know what it was rooted under and would have had to report more progress than necessary... but we
// should be able to check that there was no redundancy.
- Assert.assertTrue(monitor.getRedundantWorkCalls() == 0);
- Assert.assertTrue(monitor.getWorkCalls() >= 100);
- }
-
- /**
- * Creates a chain of n nested progress monitors. Calls beginTask on all monitors
- * except for the innermost one.
- *
- * @deprecated to suppress deprecation warnings
- *
- * @param parent
- * @param depth
- * @return the innermost SubProgressMonitor
- */
- @Deprecated
- private static SubProgressMonitor createSubProgressChain(IProgressMonitor parent, int depth) {
- SubProgressMonitor current;
- do {
- parent.beginTask("", 100);
- current = new SubProgressMonitor(parent, 100);
- parent = current;
- depth--;
- } while (depth > 0);
- return current;
- }
-
- /**
- * Reports progress by iterating over a loop of the given size, reporting 1 progress
- * at each iteration. Simulates the progress of worked(int) in loops.
- *
- * @param monitor progress monitor (callers are responsible for calling done() if necessary)
- * @param loopSize size of the loop
- */
- private static void reportWorkInLoop(IProgressMonitor monitor, int loopSize) {
- monitor.beginTask("", loopSize);
- for (int i = 0; i < loopSize; i++) {
- monitor.worked(1);
- }
- }
-
- /**
- * Reports progress by iterating over a loop of the given size, reporting 1 progress
- * at each iteration. Simulates the progress of internalWorked(double) in loops.
- *
- * @param monitor progress monitor (callers are responsible for calling done() if necessary)
- * @param loopSize size of the loop
- */
- private static void reportFloatingPointWorkInLoop(IProgressMonitor monitor, int loopSize) {
- monitor.beginTask("", loopSize);
- for (int i = 0; i < loopSize; i++) {
- monitor.internalWorked(1.0d);
- }
- }
-
- /**
- * Reports progress by creating a balanced binary tree of progress monitors. Simulates
- * mixed usage of IProgressMonitor in a typical usage. Calls isCanceled once each time work
- * is reported. Half of the work is reported using internalWorked and half is reported using worked,
- * to simulate mixed usage of the progress monitor.
- *
- * @deprecated to suppress deprecation warnings
- *
- * @param monitor progress monitor (callers are responsible for calling done() if necessary)
- * @param loopSize total size of the recursion tree
- */
- @Deprecated
- public static void reportWorkInBalancedTree(IProgressMonitor monitor, int loopSize) {
- monitor.beginTask("", 100);
- int leftBranch = loopSize / 2;
- int rightBranch = loopSize - leftBranch;
-
- if (leftBranch > 1) {
- SubProgressMonitor leftProgress = new SubProgressMonitor(monitor, 50);
- reportWorkInBalancedTree(leftProgress, leftBranch);
- leftProgress.done();
- } else {
- monitor.worked(25);
- monitor.internalWorked(25.0);
- monitor.isCanceled();
- }
-
- if (rightBranch > 1) {
- SubProgressMonitor rightProgress = new SubProgressMonitor(monitor, 50);
- reportWorkInBalancedTree(rightProgress, rightBranch);
- rightProgress.done();
- } else {
- monitor.worked(25);
- monitor.internalWorked(25.0);
- monitor.isCanceled();
- }
- }
-
- /**
- * Creates a balanced binary tree of progress monitors, without calling worked. Tests
- * progress monitor creation and cleanup time, and ensures that excess progress is
- * being collected when IProgressMonitor.done() is called.
- *
- * @deprecated to suppress deprecation warnings
- *
- * @param monitor progress monitor (callers are responsible for calling done() if necessary)
- * @param loopSize total size of the recursion tree
- */
- @Deprecated
- public static void createBalancedTree(IProgressMonitor monitor, int loopSize) {
- monitor.beginTask("", 100);
- int leftBranch = loopSize / 2;
- int rightBranch = loopSize - leftBranch;
-
- if (leftBranch > 1) {
- SubProgressMonitor leftProgress = new SubProgressMonitor(monitor, 50);
- createBalancedTree(leftProgress, leftBranch);
- leftProgress.done();
- }
-
- if (rightBranch > 1) {
- SubProgressMonitor rightProgress = new SubProgressMonitor(monitor, 50);
- createBalancedTree(rightProgress, rightBranch);
- rightProgress.done();
- }
- }
-
- /**
- * The innermost loop for the looping test. We make this a static method so
- * that it can be used both in this performance test and in the correctness test.
- *
- * @deprecated to suppress deprecation warnings
- */
- @Deprecated
- public static void runTestWorked(IProgressMonitor monitor) {
- SubProgressMonitor nestedMonitor = createSubProgressChain(monitor, SubProgressTest.CHAIN_DEPTH);
- reportWorkInLoop(nestedMonitor, SubProgressTest.PROGRESS_SIZE);
- callDoneOnChain(nestedMonitor, SubProgressTest.CHAIN_DEPTH + 1);
- }
-
- /**
- * The innermost loop for the looping test. We make this a static method so
- * that it can be used both in this performance test and in the correctness test.
- *
- * @deprecated to suppress deprecation warnings
- */
- @Deprecated
- public static void runTestInternalWorked(IProgressMonitor monitor) {
- SubProgressMonitor nestedMonitor = createSubProgressChain(monitor, SubProgressTest.CHAIN_DEPTH);
- reportFloatingPointWorkInLoop(nestedMonitor, SubProgressTest.PROGRESS_SIZE);
- callDoneOnChain(nestedMonitor, SubProgressTest.CHAIN_DEPTH + 1);
- }
-
- /**
- * The innermost loop for the recursion test. We make this a static method so
- * that it can be used both in this performance test and in the correctness test.
- *
- * @deprecated to suppress deprecation warnings
- */
- @Deprecated
- public static void runTestTypicalUsage(IProgressMonitor monitor) {
- SubProgressMonitor nestedMonitor = createSubProgressChain(monitor, SubProgressTest.CHAIN_DEPTH);
- reportWorkInBalancedTree(nestedMonitor, SubProgressTest.PROGRESS_SIZE);
- callDoneOnChain(nestedMonitor, SubProgressTest.CHAIN_DEPTH + 1);
- }
-
- /**
- * <p>The innermost loop for the create tree test. We make this a static method so
- * that it can be used both in this performance test and in the correctness test.</p>
- *
- * <p>The performance test ensures that it is fast to create a lot of progress monitors.</p>
- *
- * <p>The correctness test ensures that creating and destroying SubProgressMonitors
- * is enough to report progress, even if worked(int) and worked(double) are never called</p>
- *
- * @deprecated to suppress deprecation warnings
- */
- @Deprecated
- public static void runTestCreateTree(IProgressMonitor monitor) {
- SubProgressMonitor nestedMonitor = createSubProgressChain(monitor, SubProgressTest.CHAIN_DEPTH);
- createBalancedTree(nestedMonitor, SubProgressTest.PROGRESS_SIZE);
- callDoneOnChain(nestedMonitor, SubProgressTest.CHAIN_DEPTH + 1);
+ assertEquals(0, monitor.getRedundantWorkCalls());
+ assertTrue(monitor.getWorkCalls() >= 100);
}
/**
@@ -586,6 +346,7 @@ public class SubProgressTest extends TestCase {
/**
* Test SubProgressMonitor's created with negative a work value.
*/
+ @Test
public void testNegativeWorkValues() {
TestProgressMonitor top = new TestProgressMonitor();
top.beginTask("", 10);
@@ -593,9 +354,9 @@ public class SubProgressTest extends TestCase {
SubProgressMonitor childMonitor = new SubProgressMonitor(top, IProgressMonitor.UNKNOWN); // -1
childMonitor.beginTask("", 10);
childMonitor.worked(5);
- Assert.assertEquals(0.0, top.getTotalWork(), 0.01d);
+ assertEquals(0.0, top.getTotalWork(), 0.01d);
childMonitor.done();
- Assert.assertEquals(0.0, top.getTotalWork(), 0.01d);
+ assertEquals(0.0, top.getTotalWork(), 0.01d);
top.done();
}
diff --git a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/adaptable/AdapterManagerDynamicTest.java b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/adaptable/AdapterManagerDynamicTest.java
index 2a24ba409..b34a59f44 100644
--- a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/adaptable/AdapterManagerDynamicTest.java
+++ b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/adaptable/AdapterManagerDynamicTest.java
@@ -13,13 +13,19 @@
*******************************************************************************/
package org.eclipse.equinox.common.tests.adaptable;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import java.io.IOException;
-import junit.framework.TestCase;
import org.eclipse.core.internal.runtime.AdapterManager;
import org.eclipse.core.runtime.IAdapterManager;
import org.eclipse.core.tests.harness.BundleTestingHelper;
import org.eclipse.equinox.common.tests.registry.WaitingRegistryListener;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
@@ -29,7 +35,7 @@ import org.osgi.framework.FrameworkUtil;
* Tests reaction of AdapterManager on addition and removal of adapters from
* the extension registry.
*/
-public class AdapterManagerDynamicTest extends TestCase {
+public class AdapterManagerDynamicTest {
final private static int MAX_TIME_PER_BUNDLE = 10000; // maximum time to wait for bundle event in milliseconds
@@ -45,30 +51,21 @@ public class AdapterManagerDynamicTest extends TestCase {
private IAdapterManager manager;
- public AdapterManagerDynamicTest(String name) {
- super(name);
- }
-
- public AdapterManagerDynamicTest() {
- super("");
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
manager = AdapterManager.getDefault();
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
manager = null;
- super.tearDown();
}
/**
* This test uses waiting listener for synchronization (events from bundle being
* installed or un-installed are not propagated right away).
*/
+ @Test
public void testDynamicBundles() throws IOException, BundleException {
// check that adapters not available
@@ -89,7 +86,7 @@ public class AdapterManagerDynamicTest extends TestCase {
BundleTestingHelper.refreshPackages(bundleContext, new Bundle[] {bundle01, bundle02});
// synchronization: listener should receive 2 groups of events
- assertTrue(listener.waitFor(2, 2 * MAX_TIME_PER_BUNDLE) == 2);
+ assertEquals(2, listener.waitFor(2, 2 * MAX_TIME_PER_BUNDLE));
// now has to have all 4 adapters
assertTrue(manager.hasAdapter(adaptable, BUNDLE1_TYPE_ID));
@@ -102,7 +99,7 @@ public class AdapterManagerDynamicTest extends TestCase {
bundle02 = null;
// synchronization: listener should receive 1 group of events
- assertTrue(listener.waitFor(1, MAX_TIME_PER_BUNDLE) == 1);
+ assertEquals(1, listener.waitFor(1, MAX_TIME_PER_BUNDLE));
// now 2 installed; 2 not
assertTrue(manager.hasAdapter(adaptable, BUNDLE1_TYPE_ID));
@@ -115,7 +112,7 @@ public class AdapterManagerDynamicTest extends TestCase {
bundle01 = null;
// synchronization: listener should receive 1 group of events
- assertTrue(listener.waitFor(1, MAX_TIME_PER_BUNDLE) == 1);
+ assertEquals(1, listener.waitFor(1, MAX_TIME_PER_BUNDLE));
// and all should be uninstalled again
assertFalse(manager.hasAdapter(adaptable, BUNDLE1_TYPE_ID));
diff --git a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/adaptable/IAdapterManagerServiceTest.java b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/adaptable/IAdapterManagerServiceTest.java
index 950330a59..aae64bf3b 100644
--- a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/adaptable/IAdapterManagerServiceTest.java
+++ b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/adaptable/IAdapterManagerServiceTest.java
@@ -14,9 +14,14 @@
*******************************************************************************/
package org.eclipse.equinox.common.tests.adaptable;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.core.runtime.IAdapterManager;
+import org.junit.BeforeClass;
+import org.junit.Test;
import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
import org.osgi.util.tracker.ServiceTracker;
@@ -27,58 +32,41 @@ import org.osgi.util.tracker.ServiceTracker;
* This class is a copy of IAdapterManagerTest modified to use an OSGi service
* instead of the Platform API.
*/
-public class IAdapterManagerServiceTest extends TestCase {
+public class IAdapterManagerServiceTest {
private static final String NON_EXISTING = "com.does.not.Exist";
private static final String TEST_ADAPTER = "org.eclipse.equinox.common.tests.adaptable.TestAdapter";
- private ServiceTracker<IAdapterManager, IAdapterManager> adapterManagerTracker;
-
- public IAdapterManagerServiceTest(String name) {
- super(name);
- }
-
- public IAdapterManagerServiceTest() {
- super("");
- }
+ private static IAdapterManager manager;
/*
* Return the framework log service, if available.
*/
- public IAdapterManager getAdapterManager() {
- if (adapterManagerTracker == null) {
- BundleContext context = FrameworkUtil.getBundle(getClass()).getBundleContext();
- adapterManagerTracker = new ServiceTracker<>(context, IAdapterManager.class, null);
- adapterManagerTracker.open();
- }
- return adapterManagerTracker.getService();
- }
-
- @Override
- protected void tearDown() throws Exception {
- if (adapterManagerTracker != null) {
- adapterManagerTracker.close();
- adapterManagerTracker = null;
- }
- super.tearDown();
+ @BeforeClass
+ public static void getAdapterManager() {
+ BundleContext context = FrameworkUtil.getBundle(IAdapterManagerServiceTest.class).getBundleContext();
+ ServiceTracker<IAdapterManager, IAdapterManager> adapterManagerTracker = new ServiceTracker<>(context,
+ IAdapterManager.class, null);
+ adapterManagerTracker.open();
+ manager = adapterManagerTracker.getService();
+ adapterManagerTracker.close();
}
/**
* Tests API method IAdapterManager.hasAdapter.
*/
+ @Test
public void testHasAdapter() {
- IAdapterManager manager = getAdapterManager();
-
TestAdaptable adaptable = new TestAdaptable();
- //request non-existing adaptable
- assertTrue("1.0", !manager.hasAdapter("", NON_EXISTING));
+ // request non-existing adaptable
+ assertFalse("1.0", manager.hasAdapter("", NON_EXISTING));
- //request adapter that is in XML but has no registered factory
+ // request adapter that is in XML but has no registered factory
assertTrue("1.1", manager.hasAdapter(adaptable, TEST_ADAPTER));
- //request adapter that is not in XML
- assertTrue("1.2", !manager.hasAdapter(adaptable, "java.lang.String"));
+ // request adapter that is not in XML
+ assertFalse("1.2", manager.hasAdapter(adaptable, "java.lang.String"));
- //register an adapter factory that maps adaptables to strings
+ // register an adapter factory that maps adaptables to strings
IAdapterFactory fac = new IAdapterFactory() {
@Override
public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
@@ -90,39 +78,38 @@ public class IAdapterManagerServiceTest extends TestCase {
@Override
public Class<?>[] getAdapterList() {
- return new Class[] {String.class};
+ return new Class[] { String.class };
}
};
manager.registerAdapters(fac, TestAdaptable.class);
try {
- //request adapter for factory that we've just added
+ // request adapter for factory that we've just added
assertTrue("1.3", manager.hasAdapter(adaptable, "java.lang.String"));
} finally {
manager.unregisterAdapters(fac, TestAdaptable.class);
}
- //request adapter that was unloaded
- assertTrue("1.4", !manager.hasAdapter(adaptable, "java.lang.String"));
+ // request adapter that was unloaded
+ assertFalse("1.4", manager.hasAdapter(adaptable, "java.lang.String"));
}
/**
* Tests API method IAdapterManager.getAdapter.
*/
+ @Test
public void testGetAdapter() {
- IAdapterManager manager = getAdapterManager();
-
TestAdaptable adaptable = new TestAdaptable();
- //request non-existing adaptable
+ // request non-existing adaptable
assertNull("1.0", manager.getAdapter("", NON_EXISTING));
- //request adapter that is in XML but has no registered factory
+ // request adapter that is in XML but has no registered factory
Object result = manager.getAdapter(adaptable, TEST_ADAPTER);
assertTrue("1.1", result instanceof TestAdapter);
- //request adapter that is not in XML
+ // request adapter that is not in XML
assertNull("1.2", manager.getAdapter(adaptable, "java.lang.String"));
- //register an adapter factory that maps adaptables to strings
+ // register an adapter factory that maps adaptables to strings
IAdapterFactory fac = new IAdapterFactory() {
@Override
public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
@@ -134,39 +121,38 @@ public class IAdapterManagerServiceTest extends TestCase {
@Override
public Class<?>[] getAdapterList() {
- return new Class[] {String.class};
+ return new Class[] { String.class };
}
};
manager.registerAdapters(fac, TestAdaptable.class);
try {
- //request adapter for factory that we've just added
+ // request adapter for factory that we've just added
result = manager.getAdapter(adaptable, "java.lang.String");
assertTrue("1.3", result instanceof String);
} finally {
manager.unregisterAdapters(fac, TestAdaptable.class);
}
- //request adapter that was unloaded
+ // request adapter that was unloaded
assertNull("1.4", manager.getAdapter(adaptable, "java.lang.String"));
}
/**
* Tests API method IAdapterManager.loadAdapter.
*/
+ @Test
public void testLoadAdapter() {
- IAdapterManager manager = getAdapterManager();
-
TestAdaptable adaptable = new TestAdaptable();
- //request non-existing adaptable
+ // request non-existing adaptable
assertNull("1.0", manager.loadAdapter("", NON_EXISTING));
- //request adapter that is in XML but has no registered factory
+ // request adapter that is in XML but has no registered factory
Object result = manager.loadAdapter(adaptable, TEST_ADAPTER);
assertTrue("1.1", result instanceof TestAdapter);
- //request adapter that is not in XML
+ // request adapter that is not in XML
assertNull("1.2", manager.loadAdapter(adaptable, "java.lang.String"));
- //register an adapter factory that maps adaptables to strings
+ // register an adapter factory that maps adaptables to strings
IAdapterFactory fac = new IAdapterFactory() {
@Override
public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
@@ -178,18 +164,18 @@ public class IAdapterManagerServiceTest extends TestCase {
@Override
public Class<?>[] getAdapterList() {
- return new Class[] {String.class};
+ return new Class[] { String.class };
}
};
manager.registerAdapters(fac, TestAdaptable.class);
try {
- //request adapter for factory that we've just added
+ // request adapter for factory that we've just added
result = manager.loadAdapter(adaptable, "java.lang.String");
assertTrue("1.3", result instanceof String);
} finally {
manager.unregisterAdapters(fac, TestAdaptable.class);
}
- //request adapter that was unloaded
+ // request adapter that was unloaded
assertNull("1.4", manager.loadAdapter(adaptable, "java.lang.String"));
}
}
diff --git a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/adaptable/IAdapterManagerTest.java b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/adaptable/IAdapterManagerTest.java
index 07697e21f..191ce0dff 100644
--- a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/adaptable/IAdapterManagerTest.java
+++ b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/adaptable/IAdapterManagerTest.java
@@ -13,13 +13,23 @@
*******************************************************************************/
package org.eclipse.equinox.common.tests.adaptable;
+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.assertThrows;
+import static org.junit.Assert.assertTrue;
+
import java.io.IOException;
import java.net.MalformedURLException;
-import junit.framework.TestCase;
import org.eclipse.core.internal.runtime.AdapterManager;
-import org.eclipse.core.runtime.*;
+import org.eclipse.core.runtime.AssertionFailedException;
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.core.runtime.IAdapterManager;
import org.eclipse.core.tests.harness.BundleTestingHelper;
+import org.junit.Before;
+import org.junit.Test;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
@@ -28,21 +38,21 @@ import org.osgi.framework.FrameworkUtil;
/**
* Tests API on the IAdapterManager class.
*/
-public class IAdapterManagerTest extends TestCase {
- //following classes are for testComputeClassOrder
- static interface C {
+public class IAdapterManagerTest {
+ // following classes are for testComputeClassOrder
+ interface C {
}
- static interface D {
+ interface D {
}
- static interface M {
+ interface M {
}
- static interface N {
+ interface N {
}
- static interface O {
+ interface O {
}
interface A extends M, N {
@@ -62,34 +72,27 @@ public class IAdapterManagerTest extends TestCase {
private static final String TEST_ADAPTER_CL = "testAdapter.testUnknown";
private IAdapterManager manager;
- public IAdapterManagerTest(String name) {
- super(name);
- }
-
- public IAdapterManagerTest() {
- super("");
- }
-
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
manager = AdapterManager.getDefault();
}
/**
* Tests API method IAdapterManager.hasAdapter.
*/
+ @Test
public void testHasAdapter() {
TestAdaptable adaptable = new TestAdaptable();
- //request non-existing adaptable
- assertTrue("1.0", !manager.hasAdapter("", NON_EXISTING));
+ // request non-existing adaptable
+ assertFalse("1.0", manager.hasAdapter("", NON_EXISTING));
- //request adapter that is in XML but has no registered factory
+ // request adapter that is in XML but has no registered factory
assertTrue("1.1", manager.hasAdapter(adaptable, TEST_ADAPTER));
- //request adapter that is not in XML
- assertTrue("1.2", !manager.hasAdapter(adaptable, "java.lang.String"));
+ // request adapter that is not in XML
+ assertFalse("1.2", manager.hasAdapter(adaptable, "java.lang.String"));
- //register an adapter factory that maps adaptables to strings
+ // register an adapter factory that maps adaptables to strings
IAdapterFactory fac = new IAdapterFactory() {
@Override
public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
@@ -101,37 +104,38 @@ public class IAdapterManagerTest extends TestCase {
@Override
public Class<?>[] getAdapterList() {
- return new Class[] {String.class};
+ return new Class[] { String.class };
}
};
manager.registerAdapters(fac, TestAdaptable.class);
try {
- //request adapter for factory that we've just added
+ // request adapter for factory that we've just added
assertTrue("1.3", manager.hasAdapter(adaptable, "java.lang.String"));
} finally {
manager.unregisterAdapters(fac, TestAdaptable.class);
}
- //request adapter that was unloaded
- assertTrue("1.4", !manager.hasAdapter(adaptable, "java.lang.String"));
+ // request adapter that was unloaded
+ assertFalse("1.4", manager.hasAdapter(adaptable, "java.lang.String"));
}
/**
* Tests API method IAdapterManager.getAdapter.
*/
+ @Test
public void testGetAdapter() {
TestAdaptable adaptable = new TestAdaptable();
- //request non-existing adaptable
+ // request non-existing adaptable
assertNull("1.0", manager.getAdapter("", NON_EXISTING));
- //request adapter that is in XML but has no registered factory
+ // request adapter that is in XML but has no registered factory
Object result = manager.getAdapter(adaptable, TEST_ADAPTER);
assertTrue("1.1", result instanceof TestAdapter);
- //request adapter that is not in XML
+ // request adapter that is not in XML
assertNull("1.2", manager.getAdapter(adaptable, "java.lang.String"));
- //register an adapter factory that maps adaptables to strings
+ // register an adapter factory that maps adaptables to strings
IAdapterFactory fac = new IAdapterFactory() {
@Override
public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
@@ -143,54 +147,45 @@ public class IAdapterManagerTest extends TestCase {
@Override
public Class<?>[] getAdapterList() {
- return new Class[] {String.class};
+ return new Class[] { String.class };
}
};
manager.registerAdapters(fac, TestAdaptable.class);
try {
- //request adapter for factory that we've just added
+ // request adapter for factory that we've just added
result = manager.getAdapter(adaptable, "java.lang.String");
assertTrue("1.3", result instanceof String);
} finally {
manager.unregisterAdapters(fac, TestAdaptable.class);
}
- //request adapter that was unloaded
+ // request adapter that was unloaded
assertNull("1.4", manager.getAdapter(adaptable, "java.lang.String"));
}
+ @Test
public void testGetAdapterNullArgs() {
TestAdaptable adaptable = new TestAdaptable();
- try {
- manager.getAdapter(adaptable, (Class<?>) null);
- fail("1.0");
- } catch (RuntimeException e) {
- //expected
- }
- try {
- manager.getAdapter(null, NON_EXISTING);
- fail("1.0");
- } catch (RuntimeException e) {
- //expected
- }
-
+ assertThrows(RuntimeException.class, () -> manager.getAdapter(adaptable, (Class<?>) null));
+ assertThrows(RuntimeException.class, () -> manager.getAdapter(null, NON_EXISTING));
}
/**
* Tests API method IAdapterManager.loadAdapter.
*/
+ @Test
public void testLoadAdapter() {
TestAdaptable adaptable = new TestAdaptable();
- //request non-existing adaptable
+ // request non-existing adaptable
assertNull("1.0", manager.loadAdapter("", NON_EXISTING));
- //request adapter that is in XML but has no registered factory
+ // request adapter that is in XML but has no registered factory
Object result = manager.loadAdapter(adaptable, TEST_ADAPTER);
assertTrue("1.1", result instanceof TestAdapter);
- //request adapter that is not in XML
+ // request adapter that is not in XML
assertNull("1.2", manager.loadAdapter(adaptable, "java.lang.String"));
- //register an adapter factory that maps adaptables to strings
+ // register an adapter factory that maps adaptables to strings
IAdapterFactory fac = new IAdapterFactory() {
@Override
public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
@@ -202,27 +197,27 @@ public class IAdapterManagerTest extends TestCase {
@Override
public Class<?>[] getAdapterList() {
- return new Class[] {String.class};
+ return new Class[] { String.class };
}
};
manager.registerAdapters(fac, TestAdaptable.class);
try {
- //request adapter for factory that we've just added
+ // request adapter for factory that we've just added
result = manager.loadAdapter(adaptable, "java.lang.String");
assertTrue("1.3", result instanceof String);
} finally {
manager.unregisterAdapters(fac, TestAdaptable.class);
}
- //request adapter that was unloaded
+ // request adapter that was unloaded
assertNull("1.4", manager.loadAdapter(adaptable, "java.lang.String"));
}
/**
* Test adapting to classes not reachable by the default bundle class loader
- * (bug 200068).
- * NOTE: This test uses .class file compiled with 1.4 JRE. As a result,
- * the test can not be run on pre-1.4 JRE.
+ * (bug 200068). NOTE: This test uses .class file compiled with 1.4 JRE. As a
+ * result, the test can not be run on pre-1.4 JRE.
*/
+ @Test
public void testAdapterClassLoader() throws MalformedURLException, BundleException, IOException {
TestAdaptable adaptable = new TestAdaptable();
assertTrue(manager.hasAdapter(adaptable, TEST_ADAPTER_CL));
@@ -230,8 +225,9 @@ public class IAdapterManagerTest extends TestCase {
Bundle bundle = null;
try {
BundleContext bundleContext = FrameworkUtil.getBundle(getClass()).getBundleContext();
- bundle = BundleTestingHelper.installBundle("0.1", bundleContext, "Plugin_Testing/adapters/testAdapter_1.0.0");
- BundleTestingHelper.refreshPackages(bundleContext, new Bundle[] {bundle});
+ bundle = BundleTestingHelper.installBundle("0.1", bundleContext,
+ "Plugin_Testing/adapters/testAdapter_1.0.0");
+ BundleTestingHelper.refreshPackages(bundleContext, new Bundle[] { bundle });
assertTrue(manager.hasAdapter(adaptable, TEST_ADAPTER_CL));
Object result = manager.loadAdapter(adaptable, TEST_ADAPTER_CL);
@@ -247,6 +243,7 @@ public class IAdapterManagerTest extends TestCase {
/**
* Tests for {@link IAdapterManager#computeClassOrder(Class)}.
*/
+ @Test
public void testComputeClassOrder() {
Class<?>[] expected = new Class[] { X.class, Y.class, Object.class, A.class, B.class, M.class, N.class, O.class,
C.class, D.class };
@@ -257,6 +254,7 @@ public class IAdapterManagerTest extends TestCase {
}
}
+ @Test
public void testFactoryViolatingContract() {
class Private {
}
@@ -279,14 +277,12 @@ public class IAdapterManagerTest extends TestCase {
};
try {
manager.registerAdapters(fac, Private.class);
- try {
- manager.getAdapter(new Private(), Private.class);
- fail("Should throw AssertionFailedException!");
- } catch (AssertionFailedException e) {
- assertTrue(e.getMessage().contains(fac.getClass().getName()));
- assertTrue(e.getMessage().contains(Boolean.class.getName()));
- assertTrue(e.getMessage().contains(Private.class.getName()));
- }
+ AssertionFailedException e = assertThrows(
+ AssertionFailedException.class,
+ () -> manager.getAdapter(new Private(), Private.class));
+ assertTrue(e.getMessage().contains(fac.getClass().getName()));
+ assertTrue(e.getMessage().contains(Boolean.class.getName()));
+ assertTrue(e.getMessage().contains(Private.class.getName()));
} finally {
manager.unregisterAdapters(fac, Private.class);
}
diff --git a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/ContributorsTest.java b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/ContributorsTest.java
index 46132e3c4..53924c0f2 100644
--- a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/ContributorsTest.java
+++ b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/ContributorsTest.java
@@ -13,6 +13,7 @@
*******************************************************************************/
package org.eclipse.equinox.common.tests.registry;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
@@ -20,7 +21,14 @@ import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
-import org.eclipse.core.runtime.*;
+
+import org.eclipse.core.runtime.ContributorFactoryOSGi;
+import org.eclipse.core.runtime.ContributorFactorySimple;
+import org.eclipse.core.runtime.IContributor;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.RegistryFactory;
import org.eclipse.core.runtime.spi.IDynamicExtensionRegistry;
import org.eclipse.core.tests.harness.BundleTestingHelper;
import org.junit.Test;
@@ -43,8 +51,9 @@ public class ContributorsTest {
try {
BundleContext bundleContext = FrameworkUtil.getBundle(getClass()).getBundleContext();
bundle = BundleTestingHelper.installBundle("0.1", bundleContext, "Plugin_Testing/registry/contributors/A");
- fragment = BundleTestingHelper.installBundle("0.2", bundleContext, "Plugin_Testing/registry/contributors/B");
- BundleTestingHelper.refreshPackages(bundleContext, new Bundle[] {bundle, fragment});
+ fragment = BundleTestingHelper.installBundle("0.2", bundleContext,
+ "Plugin_Testing/registry/contributors/B");
+ BundleTestingHelper.refreshPackages(bundleContext, new Bundle[] { bundle, fragment });
IExtensionRegistry registry = RegistryFactory.getRegistry();
IExtensionPoint bundleExtPoint = registry.getExtensionPoint("testContributors.xptContibutorsA");
@@ -69,9 +78,9 @@ public class ContributorsTest {
}
/**
- * bundleA, bundleB, and fragment on bundleA all use the same namespace. Verify that getting
- * elements by contributor returns all elements from the contributor and only from that
- * contributor.
+ * bundleA, bundleB, and fragment on bundleA all use the same namespace. Verify
+ * that getting elements by contributor returns all elements from the
+ * contributor and only from that contributor.
*
* @throws IOException
* @throws BundleException
@@ -83,10 +92,13 @@ public class ContributorsTest {
Bundle fragment = null;
try {
BundleContext bundleContext = FrameworkUtil.getBundle(getClass()).getBundleContext();
- bundleA = BundleTestingHelper.installBundle("0.1", bundleContext, "Plugin_Testing/registry/elementsByContributor/A");
- bundleB = BundleTestingHelper.installBundle("0.2", bundleContext, "Plugin_Testing/registry/elementsByContributor/B");
- fragment = BundleTestingHelper.installBundle("0.2", bundleContext, "Plugin_Testing/registry/elementsByContributor/Afragment");
- BundleTestingHelper.refreshPackages(bundleContext, new Bundle[] {bundleA, bundleB, fragment});
+ bundleA = BundleTestingHelper.installBundle("0.1", bundleContext,
+ "Plugin_Testing/registry/elementsByContributor/A");
+ bundleB = BundleTestingHelper.installBundle("0.2", bundleContext,
+ "Plugin_Testing/registry/elementsByContributor/B");
+ fragment = BundleTestingHelper.installBundle("0.2", bundleContext,
+ "Plugin_Testing/registry/elementsByContributor/Afragment");
+ BundleTestingHelper.refreshPackages(bundleContext, new Bundle[] { bundleA, bundleB, fragment });
IExtensionRegistry registry = RegistryFactory.getRegistry();
@@ -95,24 +107,25 @@ public class ContributorsTest {
IExtensionPoint[] extPointsA = registry.getExtensionPoints(contributorA);
assertNotNull(extPointsA);
- assertTrue(extPointsA.length == 1);
+ assertEquals(1, extPointsA.length);
assertTrue(extPointsA[0].getUniqueIdentifier().equals("org.eclipse.test.registryByContrib.PointA"));
IExtension[] extsA = registry.getExtensions(contributorA);
assertNotNull(extsA);
- assertTrue(extsA.length == 1);
+ assertEquals(1, extsA.length);
assertTrue(extsA[0].getUniqueIdentifier().equals("org.eclipse.test.registryByContrib.ExtensionA"));
// verify fragment
IContributor contributorAF = ContributorFactoryOSGi.createContributor(fragment);
IExtensionPoint[] extPointsFragmentA = registry.getExtensionPoints(contributorAF);
assertNotNull(extPointsFragmentA);
- assertTrue(extPointsFragmentA.length == 1);
- assertTrue(extPointsFragmentA[0].getUniqueIdentifier().equals("org.eclipse.test.registryByContrib.PointFA"));
+ assertEquals(1, extPointsFragmentA.length);
+ assertTrue(
+ extPointsFragmentA[0].getUniqueIdentifier().equals("org.eclipse.test.registryByContrib.PointFA"));
IExtension[] extsFragmentA = registry.getExtensions(contributorAF);
assertNotNull(extsFragmentA);
- assertTrue(extsFragmentA.length == 1);
+ assertEquals(1, extsFragmentA.length);
assertTrue(extsFragmentA[0].getUniqueIdentifier().equals("org.eclipse.test.registryByContrib.ExtensionFA"));
} finally {
@@ -129,8 +142,10 @@ public class ContributorsTest {
}
/**
- * Checks {@link IDynamicExtensionRegistry#removeContributor(IContributor, Object)}. A separate
- * registry is created as removal functionality is not allowed by the default Eclipse registry.
+ * Checks
+ * {@link IDynamicExtensionRegistry#removeContributor(IContributor, Object)}. A
+ * separate registry is created as removal functionality is not allowed by the
+ * default Eclipse registry.
*
* @throws IOException
* @throws BundleException
@@ -148,7 +163,7 @@ public class ContributorsTest {
IContributor[] contributors = ((IDynamicExtensionRegistry) registry).getAllContributors();
assertNotNull(contributors);
- assertTrue(contributors.length == 2);
+ assertEquals(2, contributors.length);
IContributor contributorB = null;
for (IContributor contributor : contributors) {
if ("B".equals(contributor.getName())) {
@@ -168,7 +183,8 @@ public class ContributorsTest {
String fullPath = "Plugin_Testing/registry/elementsByContributor/" + fileName + "/plugin.xml";
URL urlA = FrameworkUtil.getBundle(getClass()).getEntry(fullPath);
if (urlA == null) {
- throw new IOException("No entry to '"+fullPath+"' could be found or caller does not have the appropriate permissions.");//$NON-NLS-1$ //$NON-NLS-2$
+ throw new IOException("No entry to '" + fullPath //$NON-NLS-1$
+ + "' could be found or caller does not have the appropriate permissions.");//$NON-NLS-1$
}
InputStream is = urlA.openStream();
IContributor nonBundleContributor = ContributorFactorySimple.createContributor(fileName);
diff --git a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/InputErrorTest.java b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/InputErrorTest.java
index 89ca84a91..47efa407f 100644
--- a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/InputErrorTest.java
+++ b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/InputErrorTest.java
@@ -13,6 +13,7 @@
*******************************************************************************/
package org.eclipse.equinox.common.tests.registry;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
@@ -151,7 +152,7 @@ public class InputErrorTest {
IExtension extensionA = registry.getExtension(extID);
assertNotNull(extensionA);
IConfigurationElement[] configElements = extensionA.getConfigurationElements();
- assertTrue(configElements.length == 1);
+ assertEquals(1, configElements.length);
String value = configElements[0].getAttribute("testAttr");
assertTrue(expectedValue.equals(value));
}
diff --git a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/NamespaceTest.java b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/NamespaceTest.java
index b6477919a..78ab0c4ec 100644
--- a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/NamespaceTest.java
+++ b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/NamespaceTest.java
@@ -13,12 +13,16 @@
*******************************************************************************/
package org.eclipse.equinox.common.tests.registry;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
-import org.eclipse.core.runtime.*;
+
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.RegistryFactory;
import org.eclipse.core.tests.harness.BundleTestingHelper;
import org.junit.FixMethodOrder;
import org.junit.Test;
@@ -56,22 +60,22 @@ public class NamespaceTest {
// Check linkage extension <-> extension point
assertTrue(ext.getExtensionPointUniqueIdentifier().equals(extpt.getUniqueIdentifier()));
IExtension[] extensions = extpt.getExtensions();
- assertTrue(extensions.length == 1);
+ assertEquals(1, extensions.length);
assertTrue(extensions[0].equals(ext));
// Exactly one extension and one extension point in the "org.abc" namespace
IExtensionPoint[] namespaceExtensionPoints = RegistryFactory.getRegistry().getExtensionPoints("org.abc");
- assertTrue(namespaceExtensionPoints.length == 1);
+ assertEquals(1, namespaceExtensionPoints.length);
assertTrue(namespaceExtensionPoints[0].equals(extpt));
IExtension[] namespaceExtensions = RegistryFactory.getRegistry().getExtensions("org.abc");
- assertTrue(namespaceExtensions.length == 1);
+ assertEquals(1, namespaceExtensions.length);
assertTrue(namespaceExtensions[0].equals(ext));
// There should not be extension points or extensions in the default namespace
IExtensionPoint[] defaultExtensionPoints = RegistryFactory.getRegistry().getExtensionPoints("testNamespace1");
- assertTrue(defaultExtensionPoints.length == 0);
+ assertEquals(0, defaultExtensionPoints.length);
IExtension[] defaultExtensions = RegistryFactory.getRegistry().getExtensions("testNamespace1");
- assertTrue(defaultExtensions.length == 0);
+ assertEquals(0, defaultExtensions.length);
// remove the first bundle
bundle01.uninstall();
@@ -100,10 +104,10 @@ public class NamespaceTest {
// Exactly one extension and one extension point in the "org.abc" namespace
IExtensionPoint[] namespaceExtensionPoints2 = RegistryFactory.getRegistry().getExtensionPoints("org.abc");
- assertTrue(namespaceExtensionPoints2.length == 1);
+ assertEquals(1, namespaceExtensionPoints2.length);
assertTrue(namespaceExtensionPoints2[0].equals(extpt2));
IExtension[] namespaceExtensions2 = RegistryFactory.getRegistry().getExtensions("org.abc");
- assertTrue(namespaceExtensions2.length == 1);
+ assertEquals(1, namespaceExtensions2.length);
assertTrue(namespaceExtensions2[0].equals(ext2));
// remove the second bundle
diff --git a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/RegistryListenerTest.java b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/RegistryListenerTest.java
index a3253f4fa..ab532a5c0 100644
--- a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/RegistryListenerTest.java
+++ b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/RegistryListenerTest.java
@@ -13,6 +13,8 @@
*******************************************************************************/
package org.eclipse.equinox.common.tests.registry;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
@@ -37,7 +39,7 @@ public class RegistryListenerTest {
final private static int MAX_TIME_PER_BUNDLE = 10000; // maximum time to wait for bundle event in milliseconds
private static BundleContext fBundleContext;
-
+
@BeforeClass
public static void setUp() throws Exception {
fBundleContext = FrameworkUtil.getBundle(RegistryListenerTest.class).getBundleContext();
@@ -64,11 +66,11 @@ public class RegistryListenerTest {
assertTrue(listener.isAdded());
assertNotNull(extPointIDs);
- assertTrue(extPointIDs.length == 1);
+ assertEquals(1, extPointIDs.length);
assertTrue("bundle01.xp1".equals(extPointIDs[0]));
assertNotNull(extensionsReceived);
- assertTrue(extensionsReceived.length == 1);
+ assertEquals(1, extensionsReceived.length);
assertTrue("bundle02.ext1".equals(extensionsReceived[0]));
listener.reset();
@@ -84,11 +86,11 @@ public class RegistryListenerTest {
assertTrue(listener.isRemoved());
assertNotNull(extPointIDs);
- assertTrue(extPointIDs.length == 1);
+ assertEquals(1, extPointIDs.length);
assertTrue("bundle01.xp1".equals(extPointIDs[0]));
assertNotNull(extensionsReceived);
- assertTrue(extensionsReceived.length == 1);
+ assertEquals(1, extensionsReceived.length);
assertTrue("bundle02.ext1".equals(extensionsReceived[0]));
} finally {
@@ -123,11 +125,11 @@ public class RegistryListenerTest {
assertTrue(listener.isAdded());
assertNotNull(extPointIDs);
- assertTrue(extPointIDs.length == 1);
+ assertEquals(1, extPointIDs.length);
assertTrue("bundle01.xp1".equals(extPointIDs[0]));
assertNotNull(extensionsReceived);
- assertTrue(extensionsReceived.length == 1);
+ assertEquals(1, extensionsReceived.length);
assertTrue("bundle02.ext1".equals(extensionsReceived[0]));
listener.reset();
@@ -143,11 +145,11 @@ public class RegistryListenerTest {
assertTrue(listener.isRemoved());
assertNotNull(extPointIDs);
- assertTrue(extPointIDs.length == 1);
+ assertEquals(1, extPointIDs.length);
assertTrue("bundle01.xp1".equals(extPointIDs[0]));
assertNotNull(extensionsReceived);
- assertTrue(extensionsReceived.length == 1);
+ assertEquals(1, extensionsReceived.length);
assertTrue("bundle02.ext1".equals(extensionsReceived[0]));
} finally {
@@ -184,21 +186,21 @@ public class RegistryListenerTest {
String[] extPointIDs = listenerGlobal.extPointsReceived(MAX_TIME_PER_BUNDLE);
String[] extensionsReceived = listenerGlobal.extensionsReceived(MAX_TIME_PER_BUNDLE);
assertTrue(listenerGlobal.isAdded());
- checkIDs(extPointIDs, new String[] {"bundleMultiple.xp1", "bundleMultiple.xp2"});
- checkIDs(extensionsReceived, new String[] {"bundleMultiple.ext11", "bundleMultiple.ext12"});
+ assertArrayEquals(extPointIDs, new String[] { "bundleMultiple.xp1", "bundleMultiple.xp2" });
+ assertArrayEquals(extensionsReceived, new String[] { "bundleMultiple.ext11", "bundleMultiple.ext12" });
// test additions on listener on extension point with extensions
String[] extPointIDs1 = listener1.extPointsReceived(20000);
String[] extensionsReceived1 = listener1.extensionsReceived(20000);
assertTrue(listener1.isAdded());
- checkIDs(extPointIDs1, new String[] {"bundleMultiple.xp1"});
- checkIDs(extensionsReceived1, new String[] {"bundleMultiple.ext11", "bundleMultiple.ext12"});
+ assertArrayEquals(extPointIDs1, new String[] { "bundleMultiple.xp1" });
+ assertArrayEquals(extensionsReceived1, new String[] { "bundleMultiple.ext11", "bundleMultiple.ext12" });
// test additions on listener on extension point with no extensions
String[] extPointIDs2 = listener2.extPointsReceived(MAX_TIME_PER_BUNDLE);
String[] extensionsReceived2 = listener2.extensionsReceived(50);
assertTrue(listener2.isAdded());
- checkIDs(extPointIDs2, new String[] {"bundleMultiple.xp2"});
+ assertArrayEquals(extPointIDs2, new String[] { "bundleMultiple.xp2" });
assertNull(extensionsReceived2);
// removal
@@ -213,21 +215,21 @@ public class RegistryListenerTest {
extPointIDs = listenerGlobal.extPointsReceived(MAX_TIME_PER_BUNDLE);
extensionsReceived = listenerGlobal.extensionsReceived(MAX_TIME_PER_BUNDLE);
assertTrue(listenerGlobal.isRemoved());
- checkIDs(extPointIDs, new String[] {"bundleMultiple.xp1", "bundleMultiple.xp2"});
- checkIDs(extensionsReceived, new String[] {"bundleMultiple.ext11", "bundleMultiple.ext12"});
+ assertArrayEquals(extPointIDs, new String[] { "bundleMultiple.xp1", "bundleMultiple.xp2" });
+ assertArrayEquals(extensionsReceived, new String[] { "bundleMultiple.ext11", "bundleMultiple.ext12" });
// test removals on listener on extension point with extensions
extPointIDs1 = listener1.extPointsReceived(MAX_TIME_PER_BUNDLE);
extensionsReceived1 = listener1.extensionsReceived(MAX_TIME_PER_BUNDLE);
assertTrue(listener1.isRemoved());
- checkIDs(extPointIDs1, new String[] {"bundleMultiple.xp1"});
- checkIDs(extensionsReceived1, new String[] {"bundleMultiple.ext11", "bundleMultiple.ext12"});
+ assertArrayEquals(extPointIDs1, new String[] { "bundleMultiple.xp1" });
+ assertArrayEquals(extensionsReceived1, new String[] { "bundleMultiple.ext11", "bundleMultiple.ext12" });
// test removals on listener on extension point with no extensions
extPointIDs2 = listener2.extPointsReceived(MAX_TIME_PER_BUNDLE);
extensionsReceived2 = listener2.extensionsReceived(50);
assertTrue(listener2.isRemoved());
- checkIDs(extPointIDs2, new String[] {"bundleMultiple.xp2"});
+ assertArrayEquals(extPointIDs2, new String[] { "bundleMultiple.xp2" });
assertNull(extensionsReceived2);
} finally {
@@ -258,14 +260,14 @@ public class RegistryListenerTest {
// 1st registration: extension point; extension => 2 callbacks
// 2nd registration should be ignored: extension => 0 callbacks
// total: 2 callbacks
- assertTrue(listener.waitFor(2, MAX_TIME_PER_BUNDLE) == 2);
+ assertEquals(2, listener.waitFor(2, MAX_TIME_PER_BUNDLE));
// test additions on listener on extension point with extensions
String[] extPointIDs = listener.extPointsReceived(50);
String[] extensionsReceived = listener.extensionsReceived(50);
assertTrue(listener.isAdded());
- checkIDs(extPointIDs, new String[] {"bundleMultiple.xp1"});
- checkIDs(extensionsReceived, new String[] {"bundleMultiple.ext11", "bundleMultiple.ext12"});
+ assertArrayEquals(extPointIDs, new String[] { "bundleMultiple.xp1" });
+ assertArrayEquals(extensionsReceived, new String[] { "bundleMultiple.ext11", "bundleMultiple.ext12" });
// removal: unregistering listener once should remove both registrations
listener.reset();
@@ -275,7 +277,7 @@ public class RegistryListenerTest {
BundleTestingHelper.refreshPackages(fBundleContext, testBundles);
// test removals on listener on extension point with extensions
- assertTrue(listener.waitFor(3, 200) == 0);
+ assertEquals(0, listener.waitFor(3, 200));
extPointIDs = listener.extPointsReceived(50);
extensionsReceived = listener.extensionsReceived(50);
assertNull(extPointIDs);
@@ -289,20 +291,4 @@ public class RegistryListenerTest {
}
}
- // For simplicity, this method does not expect duplicate IDs in either array
- private void checkIDs(String[] receivedIDs, String[] expectedIDs) {
- assertNotNull(receivedIDs);
- assertNotNull(expectedIDs);
- assertTrue(receivedIDs.length == expectedIDs.length);
- for (String expected : expectedIDs) {
- boolean found = false;
- for (String receivedID : receivedIDs) {
- if (expected.equals(receivedID)) {
- found = true;
- break;
- }
- }
- assertTrue(found);
- }
- }
}
diff --git a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/StaleObjects.java b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/StaleObjects.java
index 99510e8ac..80ffd58cb 100644
--- a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/StaleObjects.java
+++ b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/StaleObjects.java
@@ -14,16 +14,26 @@
*******************************************************************************/
package org.eclipse.equinox.common.tests.registry;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThrows;
+
import java.io.IOException;
-import junit.framework.TestCase;
-import org.eclipse.core.runtime.*;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IRegistryChangeEvent;
+import org.eclipse.core.runtime.IRegistryChangeListener;
+import org.eclipse.core.runtime.InvalidRegistryObjectException;
+import org.eclipse.core.runtime.RegistryFactory;
import org.eclipse.core.tests.harness.BundleTestingHelper;
+import org.junit.Test;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
import org.osgi.framework.FrameworkUtil;
-public class StaleObjects extends TestCase {
+public class StaleObjects {
private class HandleCatcher implements IRegistryChangeListener {
private IExtension extensionFromTheListener;
@@ -33,14 +43,8 @@ public class StaleObjects extends TestCase {
@Override
public void registryChanged(IRegistryChangeEvent event) {
- boolean gotException = false;
- try {
- extensionFromTheListener = event.getExtensionDeltas()[0].getExtension();
- extensionFromTheListener.getSimpleIdentifier();
- } catch (InvalidRegistryObjectException e) {
- gotException = true;
- }
- assertEquals(false, gotException);
+ extensionFromTheListener = event.getExtensionDeltas()[0].getExtension();
+ assertThrows(InvalidRegistryObjectException.class, () -> extensionFromTheListener.getSimpleIdentifier());
}
public IExtension getAcquiredHandle() {
@@ -48,89 +52,71 @@ public class StaleObjects extends TestCase {
}
}
+ @Test
public synchronized void testA() throws IOException, BundleException {
HandleCatcher listener = new HandleCatcher();
BundleContext bundleContext = FrameworkUtil.getBundle(getClass()).getBundleContext();
Bundle bundle01 = BundleTestingHelper.installBundle("", bundleContext, "Plugin_Testing/registry/testStale1");
- BundleTestingHelper.refreshPackages(bundleContext, new Bundle[] {bundle01});
+ BundleTestingHelper.refreshPackages(bundleContext, new Bundle[] { bundle01 });
IExtension willBeStale = RegistryFactory.getRegistry().getExtension("testStale.ext1");
- //Test that handles obtained from deltas are working.
+ // Test that handles obtained from deltas are working.
- //Test that handles obtained from an addition deltas are working even after the delta is done being broadcasted.
- boolean gotException = false;
- try {
- IExtension result = null;
- while ((result = listener.getAcquiredHandle()) == null) {
- try {
- wait(200);
- } catch (InterruptedException e) {
- //ignore.
- }
+ // Test that handles obtained from an addition deltas are working even after the
+ // delta is done being broadcasted.
+ IExtension result = null;
+ while ((result = listener.getAcquiredHandle()) == null) {
+ try {
+ wait(200);
+ } catch (InterruptedException e) {
+ // ignore.
}
- result.getSimpleIdentifier();
- } catch (InvalidRegistryObjectException e) {
- gotException = true;
}
- assertEquals(false, gotException);
+ result.getSimpleIdentifier();
- //Add a listener capturing a handle removal. Inside the handle catcher the handle is valid
+ // Add a listener capturing a handle removal. Inside the handle catcher the
+ // handle is valid
HandleCatcher listener2 = new HandleCatcher();
try {
- wait(500); //Wait for the listeners to be done
+ wait(500); // Wait for the listeners to be done
} catch (InterruptedException e) {
- //ignore.
+ // ignore.
}
bundle01.uninstall();
- BundleTestingHelper.refreshPackages(bundleContext, new Bundle[] {bundle01});
+ BundleTestingHelper.refreshPackages(bundleContext, new Bundle[] { bundle01 });
- //Outside of the event notification the handle from a removed object should be invalid
- gotException = false;
- try {
- while (listener2.getAcquiredHandle() == null) {
- try {
- wait(200);
- } catch (InterruptedException e) {
- //ignore.
- }
+ // Outside of the event notification the handle from a removed object should be
+ // invalid
+ while (listener2.getAcquiredHandle() == null) {
+ try {
+ wait(200);
+ } catch (InterruptedException e) {
+ // ignore.
}
- listener2.getAcquiredHandle().getSimpleIdentifier();
- } catch (InvalidRegistryObjectException e) {
- gotException = true;
}
- assertEquals(true, gotException);
+ assertThrows(InvalidRegistryObjectException.class, () -> listener2.getAcquiredHandle().getSimpleIdentifier());
- //Check that the initial handles are stale as well
- gotException = false;
- try {
- willBeStale.getSimpleIdentifier();
- } catch (InvalidRegistryObjectException e) {
- gotException = true;
- }
- assertEquals(true, gotException);
+ // Check that the initial handles are stale as well
+ assertThrows(InvalidRegistryObjectException.class, () -> willBeStale.getSimpleIdentifier());
RegistryFactory.getRegistry().removeRegistryChangeListener(listener2);
RegistryFactory.getRegistry().removeRegistryChangeListener(listener);
}
+ @Test
public void testStaleConfigurationElement() throws IOException, BundleException {
BundleContext bundleContext = FrameworkUtil.getBundle(getClass()).getBundleContext();
Bundle bundle01 = BundleTestingHelper.installBundle("", bundleContext, "Plugin_Testing/registry/testStale2");
- BundleTestingHelper.refreshPackages(bundleContext, new Bundle[] {bundle01});
+ BundleTestingHelper.refreshPackages(bundleContext, new Bundle[] { bundle01 });
- IConfigurationElement ce = RegistryFactory.getRegistry().getExtension("testStale2.ext1").getConfigurationElements()[0];
+ IConfigurationElement ce = RegistryFactory.getRegistry().getExtension("testStale2.ext1")
+ .getConfigurationElements()[0];
assertNotNull(ce);
bundle01.uninstall();
- BundleTestingHelper.refreshPackages(bundleContext, new Bundle[] {bundle01});
+ BundleTestingHelper.refreshPackages(bundleContext, new Bundle[] { bundle01 });
- boolean gotException = false;
- try {
- ce.createExecutableExtension("name");
- } catch (CoreException c) {
- gotException = true;
- }
- assertEquals(true, gotException);
+ assertThrows(CoreException.class, () -> ce.createExecutableExtension("name"));
}
}
diff --git a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/simple/BaseExtensionRegistryRun.java b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/simple/BaseExtensionRegistryRun.java
index da7c864b5..47c63314e 100644
--- a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/simple/BaseExtensionRegistryRun.java
+++ b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/simple/BaseExtensionRegistryRun.java
@@ -13,16 +13,24 @@
*******************************************************************************/
package org.eclipse.equinox.common.tests.registry.simple;
-import java.io.*;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
import java.net.URL;
-import junit.framework.TestCase;
import org.eclipse.core.internal.runtime.MetaDataKeeper;
-import org.eclipse.core.runtime.*;
+import org.eclipse.core.runtime.IContributor;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.RegistryFactory;
import org.eclipse.core.runtime.spi.RegistryStrategy;
+import org.junit.After;
+import org.junit.Before;
import org.osgi.framework.FrameworkUtil;
-public class BaseExtensionRegistryRun extends TestCase {
+public class BaseExtensionRegistryRun {
// The imaging device registry
protected IExtensionRegistry simpleRegistry;
@@ -32,14 +40,6 @@ public class BaseExtensionRegistryRun extends TestCase {
// Path to the XML files
private final static String xmlPath = "Plugin_Testing/registry/testSimple/"; //$NON-NLS-1$
- public BaseExtensionRegistryRun() {
- super();
- }
-
- public BaseExtensionRegistryRun(String name) {
- super(name);
- }
-
protected URL getXML(String fileName) {
return FrameworkUtil.getBundle(getClass()).getEntry(xmlPath + fileName);
}
@@ -47,8 +47,8 @@ public class BaseExtensionRegistryRun extends TestCase {
/**
* Create the "imaging device" registry
*/
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
// create the imaging device registry
simpleRegistry = startRegistry();
}
@@ -56,8 +56,8 @@ public class BaseExtensionRegistryRun extends TestCase {
/**
* Properly dispose of the extension registry
*/
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
stopRegistry();
}
@@ -90,24 +90,20 @@ public class BaseExtensionRegistryRun extends TestCase {
simpleRegistry.stop(masterToken);
}
- protected void processXMLContribution(IContributor nonBundleContributor, URL url) {
+ protected void processXMLContribution(IContributor nonBundleContributor, URL url) throws IOException {
processXMLContribution(nonBundleContributor, url, false);
}
- protected void processXMLContribution(IContributor nonBundleContributor, URL url, boolean persist) {
- try {
+ protected void processXMLContribution(IContributor nonBundleContributor, URL url, boolean persist)
+ throws IOException {
InputStream is = url.openStream();
simpleRegistry.addContribution(is, nonBundleContributor, persist, url.getFile(), null, persist ? masterToken : userToken);
- } catch (IOException eFile) {
- fail(eFile.getMessage());
- return;
- }
}
protected String qualifiedName(String namespace, String simpleName) {
return namespace + "." + simpleName; //$NON-NLS-1$
}
-
+
protected IPath getStateLocation() {
IPath stateLocation = MetaDataKeeper.getMetaArea().getStateLocation(FrameworkUtil.getBundle(getClass()));
stateLocation.toFile().mkdirs();
diff --git a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/simple/DirectExtensionCreateTest.java b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/simple/DirectExtensionCreateTest.java
index 2c317b874..0523ddfb5 100644
--- a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/simple/DirectExtensionCreateTest.java
+++ b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/simple/DirectExtensionCreateTest.java
@@ -13,10 +13,19 @@
*******************************************************************************/
package org.eclipse.equinox.common.tests.registry.simple;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
import org.eclipse.core.internal.registry.ExtensionRegistry;
import org.eclipse.core.internal.registry.spi.ConfigurationElementAttribute;
import org.eclipse.core.internal.registry.spi.ConfigurationElementDescription;
-import org.eclipse.core.runtime.*;
+import org.eclipse.core.runtime.ContributorFactorySimple;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IContributor;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.junit.Test;
/**
* Tests programmatic creation of extension and extension point by using direct
@@ -29,14 +38,7 @@ import org.eclipse.core.runtime.*;
*/
public class DirectExtensionCreateTest extends BaseExtensionRegistryRun {
- public DirectExtensionCreateTest() {
- super();
- }
-
- public DirectExtensionCreateTest(String name) {
- super(name);
- }
-
+ @Test
public void testExtensionPointAddition() {
IContributor contributor = ContributorFactorySimple.createContributor("1"); //$NON-NLS-1$
String extensionPointId = "DirectExtPoint"; //$NON-NLS-1$
@@ -108,10 +110,10 @@ public class DirectExtensionCreateTest extends BaseExtensionRegistryRun {
IExtension[] namespaceExtensions = simpleRegistry.getExtensions(namespace);
assertNotNull(namespaceExtensions);
- assertTrue(namespaceExtensions.length == 1);
+ assertEquals(1, namespaceExtensions.length);
IExtension[] extensions = extensionPoint.getExtensions();
assertNotNull(extensions);
- assertTrue(extensions.length == 1);
+ assertEquals(1, extensions.length);
for (IExtension extension : extensions) {
String storedExtensionId = extension.getUniqueIdentifier();
assertTrue(storedExtensionId.equals(qualifiedName(namespace, extensionId)));
@@ -127,9 +129,9 @@ public class DirectExtensionCreateTest extends BaseExtensionRegistryRun {
String configElementValue = configElement.getValue();
assertTrue(configElementValue.equals(extensionValue));
String[] attributeNames = configElement.getAttributeNames();
- assertTrue(attributeNames.length == 2);
+ assertEquals(2, attributeNames.length);
IConfigurationElement[] configElementChildren = configElement.getChildren();
- assertTrue(configElementChildren.length == 2);
+ assertEquals(2, configElementChildren.length);
}
}
}
diff --git a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/simple/DirectExtensionCreateTwoRegistriesTest.java b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/simple/DirectExtensionCreateTwoRegistriesTest.java
index 0287fa5c6..342cad8b1 100644
--- a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/simple/DirectExtensionCreateTwoRegistriesTest.java
+++ b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/simple/DirectExtensionCreateTwoRegistriesTest.java
@@ -13,8 +13,18 @@
*******************************************************************************/
package org.eclipse.equinox.common.tests.registry.simple;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
import org.eclipse.core.internal.registry.ExtensionRegistry;
-import org.eclipse.core.runtime.*;
+import org.eclipse.core.runtime.ContributorFactorySimple;
+import org.eclipse.core.runtime.IContributor;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
/**
* Test simultaneous work of two extension registries.
@@ -29,21 +39,16 @@ public class DirectExtensionCreateTwoRegistriesTest extends BaseExtensionRegistr
private IExtensionRegistry theDeviceRegistryA;
private IExtensionRegistry theDeviceRegistryB;
- public DirectExtensionCreateTwoRegistriesTest() {
- super();
- }
-
- public DirectExtensionCreateTwoRegistriesTest(String name) {
- super(name);
- }
@Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
startRegistries();
}
@Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
stopRegistries();
}
@@ -60,6 +65,7 @@ public class DirectExtensionCreateTwoRegistriesTest extends BaseExtensionRegistr
theDeviceRegistryB.stop(masterToken);
}
+ @Test
public void testExtensionPointAddition() {
// Test with non-bundle contributor
IContributor nonBundleContributor = ContributorFactorySimple.createContributor("ABC"); //$NON-NLS-1$
diff --git a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/simple/DirectExtensionRemoveTest.java b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/simple/DirectExtensionRemoveTest.java
index b05d8370d..4321dcf48 100644
--- a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/simple/DirectExtensionRemoveTest.java
+++ b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/simple/DirectExtensionRemoveTest.java
@@ -13,8 +13,25 @@
*******************************************************************************/
package org.eclipse.equinox.common.tests.registry.simple;
-import org.eclipse.core.runtime.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertThrows;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+
+import org.eclipse.core.runtime.ContributorFactorySimple;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IContributor;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionDelta;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IRegistryChangeEvent;
+import org.eclipse.core.runtime.IRegistryChangeListener;
+import org.eclipse.core.runtime.InvalidRegistryObjectException;
import org.eclipse.equinox.common.tests.registry.simple.utils.SimpleRegistryListener;
+import org.junit.Test;
/**
* Tests removal APIs using a simple registry.
@@ -28,16 +45,10 @@ public class DirectExtensionRemoveTest extends BaseExtensionRegistryRun {
private final static String extensionA1 = "TestExtensionA1"; //$NON-NLS-1$
private final static String extensionA2 = "TestExtensionA2"; //$NON-NLS-1$
- public DirectExtensionRemoveTest() {
- super();
- }
-
- public DirectExtensionRemoveTest(String name) {
- super(name);
- }
// Fill the registry; remove half; check listener; check what's left
- public void testExtensionPointAddition() {
+ @Test
+ public void testExtensionPointAddition() throws IOException {
IContributor nonBundleContributor = ContributorFactorySimple.createContributor("DirectRemoveProvider"); //$NON-NLS-1$
String namespace = nonBundleContributor.getName();
fillRegistry(nonBundleContributor);
@@ -53,10 +64,13 @@ public class DirectExtensionRemoveTest extends BaseExtensionRegistryRun {
}
/**
- * Tests that configuration elements associated with the removed extension
- * are removed.
+ * Tests that configuration elements associated with the removed extension are
+ * removed.
+ *
+ * @throws IOException
*/
- public void testAssociatedConfigElements() {
+ @Test
+ public void testAssociatedConfigElements() throws IOException {
IContributor nonBundleContributor = ContributorFactorySimple.createContributor("CETest"); //$NON-NLS-1$
String namespace = nonBundleContributor.getName();
processXMLContribution(nonBundleContributor, getXML("CERemovalTest.xml")); //$NON-NLS-1$
@@ -64,7 +78,7 @@ public class DirectExtensionRemoveTest extends BaseExtensionRegistryRun {
IExtensionPoint extensionPointA = simpleRegistry.getExtensionPoint(qualifiedName(namespace, "PointA")); //$NON-NLS-1$
assertNotNull(extensionPointA);
IExtension[] extensionsA = extensionPointA.getExtensions();
- assertTrue(extensionsA.length == 2);
+ assertEquals(2, extensionsA.length);
// check first extension
IExtension ext1 = extensionPointA.getExtension(qualifiedName(namespace, "TestExtensionA1")); //$NON-NLS-1$
@@ -98,9 +112,9 @@ public class DirectExtensionRemoveTest extends BaseExtensionRegistryRun {
// listener to verify that valid CEs are included in the notification
IRegistryChangeListener listener = event -> {
IExtensionDelta[] deltas = event.getExtensionDeltas();
- assertTrue(deltas.length == 1);
+ assertEquals(1, deltas.length);
for (IExtensionDelta delta : deltas) {
- assertTrue(delta.getKind() == IExtensionDelta.REMOVED);
+ assertEquals(IExtensionDelta.REMOVED, delta.getKind());
IExtension extension = delta.getExtension();
assertNotNull(extension);
@@ -131,25 +145,12 @@ public class DirectExtensionRemoveTest extends BaseExtensionRegistryRun {
// basic checks
IExtension[] extensionsRemoved = extensionPointA.getExtensions();
- assertTrue(extensionsRemoved.length == 1);
+ assertEquals(1, extensionsRemoved.length);
// re-check configuration elements
- boolean exceptionFound = false;
- try {
- ces11[0].getAttributeNames(); // should produce an exception
- } catch (InvalidRegistryObjectException e) {
- exceptionFound = true;
- }
- assertTrue(exceptionFound);
-
- exceptionFound = false;
- try {
- ces12[0].getAttributeNames(); // should produce an exception
- } catch (InvalidRegistryObjectException e) {
- exceptionFound = true;
- }
+ assertThrows(InvalidRegistryObjectException.class, () -> ces11[0].getAttributeNames()); // should produce an
- assertTrue(exceptionFound);
+ assertThrows(InvalidRegistryObjectException.class, () -> ces12[0].getAttributeNames()); // should produce an
// the non-removed extension CEs should still be valid
String[] attrs22removed = ces22[0].getAttributeNames();
assertNotNull(attrs22removed);
@@ -157,7 +158,7 @@ public class DirectExtensionRemoveTest extends BaseExtensionRegistryRun {
assertEquals("value", attrs22removed[0]); //$NON-NLS-1$
}
- private void fillRegistry(IContributor contributor) {
+ private void fillRegistry(IContributor contributor) throws IOException {
processXMLContribution(contributor, getXML("RemovalTest.xml")); //$NON-NLS-1$
}
@@ -167,9 +168,9 @@ public class DirectExtensionRemoveTest extends BaseExtensionRegistryRun {
IExtensionPoint extensionPointB = simpleRegistry.getExtensionPoint(qualifiedName(namespace, pointB));
assertNotNull(extensionPointB);
IExtension[] extensionsA = extensionPointA.getExtensions();
- assertTrue(extensionsA.length == 2);
+ assertEquals(2, extensionsA.length);
IExtension[] extensionsB = extensionPointB.getExtensions();
- assertTrue(extensionsB.length == 2);
+ assertEquals(2, extensionsB.length);
}
private void remove(String namespace) {
@@ -186,7 +187,7 @@ public class DirectExtensionRemoveTest extends BaseExtensionRegistryRun {
IExtensionPoint extensionPointB = simpleRegistry.getExtensionPoint(qualifiedName(namespace, pointB));
assertNull(extensionPointB);
IExtension[] extensionsA = extensionPointA.getExtensions();
- assertTrue(extensionsA.length == 1);
+ assertEquals(1, extensionsA.length);
String Id = extensionsA[0].getUniqueIdentifier();
assertTrue(qualifiedName(namespace, extensionA2).equals(Id));
}
@@ -194,9 +195,9 @@ public class DirectExtensionRemoveTest extends BaseExtensionRegistryRun {
private void checkListener(SimpleRegistryListener listener) {
IRegistryChangeEvent event = listener.getEvent(5000);
IExtensionDelta[] deltas = event.getExtensionDeltas();
- assertTrue(deltas.length == 2);
+ assertEquals(2, deltas.length);
for (IExtensionDelta delta : deltas) {
- assertTrue(delta.getKind() == IExtensionDelta.REMOVED);
+ assertEquals(IExtensionDelta.REMOVED, delta.getKind());
assertNotNull(delta.getExtension());
assertNotNull(delta.getExtensionPoint());
}
diff --git a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/simple/DuplicatePointsTest.java b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/simple/DuplicatePointsTest.java
index 7e420647b..43bb3b294 100644
--- a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/simple/DuplicatePointsTest.java
+++ b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/simple/DuplicatePointsTest.java
@@ -13,10 +13,23 @@
*******************************************************************************/
package org.eclipse.equinox.common.tests.registry.simple;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
import java.io.File;
-import org.eclipse.core.runtime.*;
+import java.io.IOException;
+
+import org.eclipse.core.runtime.ContributorFactorySimple;
+import org.eclipse.core.runtime.IContributor;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.RegistryFactory;
import org.eclipse.core.runtime.spi.RegistryStrategy;
import org.eclipse.equinox.common.tests.registry.simple.utils.HiddenLogRegistryStrategy;
+import org.junit.Test;
/**
* Tests addition of extensions and extension points with duplicate IDs.
@@ -31,14 +44,6 @@ public class DuplicatePointsTest extends BaseExtensionRegistryRun {
private final static String errMsg1 = "Error: Ignored duplicate extension point \"testDuplicates.duplicateExtensionPoint\" supplied by \"2\"." + "Warning: Extensions supplied by \"2\" and \"1\" have the same Id: \"testDuplicates.duplicateExtension\".";
private final static String errMsg2 = "Error: Ignored duplicate extension point \"testSame.duplicateExtensionPointSame\" supplied by \"3\"." + "Warning: Extensions supplied by \"3\" and \"3\" have the same Id: \"testSame.duplicateExtensionSame\".";
- public DuplicatePointsTest() {
- super();
- }
-
- public DuplicatePointsTest(String name) {
- super(name);
- }
-
/**
* Use registry strategy with modified logging
* @return - open extension registry
@@ -53,7 +58,8 @@ public class DuplicatePointsTest extends BaseExtensionRegistryRun {
return RegistryFactory.createRegistry(registryStrategy, masterToken, userToken);
}
- public void testDuplicates() {
+ @Test
+ public void testDuplicates() throws IOException {
HiddenLogRegistryStrategy.output = ""; //$NON-NLS-1$
IContributor contributor1 = ContributorFactorySimple.createContributor("1"); //$NON-NLS-1$
processXMLContribution(contributor1, getXML("DuplicatePoints1.xml")); //$NON-NLS-1$
@@ -74,10 +80,10 @@ public class DuplicatePointsTest extends BaseExtensionRegistryRun {
assertTrue(errMsg1.equals(HiddenLogRegistryStrategy.output));
IExtensionPoint[] extensionPoints = simpleRegistry.getExtensionPoints(namespace);
- assertTrue(extensionPoints.length == 2);
+ assertEquals(2, extensionPoints.length);
IExtension[] extensions = simpleRegistry.getExtensions(namespace);
- assertTrue(extensions.length == 3);
+ assertEquals(3, extensions.length);
IExtension extension = simpleRegistry.getExtension(qualifiedName(namespace, "nonDuplicateExtension")); //$NON-NLS-1$
assertNotNull(extension);
@@ -87,9 +93,9 @@ public class DuplicatePointsTest extends BaseExtensionRegistryRun {
assertTrue(errMsg2.equals(HiddenLogRegistryStrategy.output));
IExtensionPoint[] extensionPoints = simpleRegistry.getExtensionPoints(namespace);
- assertTrue(extensionPoints.length == 1);
+ assertEquals(1, extensionPoints.length);
IExtension[] extensions = simpleRegistry.getExtensions(namespace);
- assertTrue(extensions.length == 2);
+ assertEquals(2, extensions.length);
}
}
diff --git a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/simple/MergeContributionTest.java b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/simple/MergeContributionTest.java
index eb8662469..b3642bab8 100644
--- a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/simple/MergeContributionTest.java
+++ b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/simple/MergeContributionTest.java
@@ -13,7 +13,16 @@
*******************************************************************************/
package org.eclipse.equinox.common.tests.registry.simple;
-import org.eclipse.core.runtime.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.IOException;
+
+import org.eclipse.core.runtime.ContributorFactorySimple;
+import org.eclipse.core.runtime.IContributor;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.junit.Test;
/**
* Tests merging static and dynamic contributions.
@@ -21,16 +30,8 @@ import org.eclipse.core.runtime.*;
* @since 3.2
*/
public class MergeContributionTest extends BaseExtensionRegistryRun {
-
- public MergeContributionTest() {
- super();
- }
-
- public MergeContributionTest(String name) {
- super(name);
- }
-
- public void testMergeStaticDynamic() {
+ @Test
+ public void testMergeStaticDynamic() throws IOException {
// Test with non-bundle contributor
IContributor nonBundleContributor = ContributorFactorySimple.createContributor("ABC"); //$NON-NLS-1$
String namespace = nonBundleContributor.getName();
@@ -48,11 +49,11 @@ public class MergeContributionTest extends BaseExtensionRegistryRun {
checkRegistry(namespace, 6);
}
- private void fillRegistryStatic(IContributor contributor) {
+ private void fillRegistryStatic(IContributor contributor) throws IOException {
processXMLContribution(contributor, getXML("MergeStatic.xml"), true); //$NON-NLS-1$
}
- private void fillRegistryDynamic(IContributor contributor) {
+ private void fillRegistryDynamic(IContributor contributor) throws IOException {
processXMLContribution(contributor, getXML("MergeDynamic.xml"), false); //$NON-NLS-1$
}
diff --git a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/simple/TokenAccessTest.java b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/simple/TokenAccessTest.java
index 14bbd702a..297bbbbfc 100644
--- a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/simple/TokenAccessTest.java
+++ b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/simple/TokenAccessTest.java
@@ -13,27 +13,24 @@
*******************************************************************************/
package org.eclipse.equinox.common.tests.registry.simple;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThrows;
+
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.RegistryFactory;
+import org.junit.Test;
/**
* Tests registry token-based access rules.
+ *
* @since 3.2
*/
-public class TokenAccessTest extends TestCase {
-
- public TokenAccessTest() {
- super();
- }
-
- public TokenAccessTest(String name) {
- super(name);
- }
+public class TokenAccessTest {
/**
* Tests token access to sensetive registry methods
*/
+ @Test
public void testControlledAccess() {
Object tokenGood = new Object();
Object tokenBad = new Object();
@@ -56,17 +53,12 @@ public class TokenAccessTest extends TestCase {
// and stopped with a good token - should be no exception
registry.stop(tokenGood);
- // registry created with a good token
- registry = RegistryFactory.createRegistry(null, tokenGood, null);
- assertNotNull(registry);
+
// and stopped with a bad token - should be an exception
- boolean bException = false;
- try {
- registry.stop(tokenBad);
- } catch (IllegalArgumentException e) {
- // this is good; this is expected
- bException = true;
- }
- assertTrue(bException);
+ assertThrows(IllegalArgumentException.class, () -> {// registry created with a good token
+ IExtensionRegistry registry1 = RegistryFactory.createRegistry(null, tokenGood, null);
+ assertNotNull(registry1);
+ registry1.stop(tokenBad);
+ });
}
}
diff --git a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/simple/XMLExecutableExtensionTest.java b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/simple/XMLExecutableExtensionTest.java
index 990f58c1c..c31889aab 100644
--- a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/simple/XMLExecutableExtensionTest.java
+++ b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/simple/XMLExecutableExtensionTest.java
@@ -13,42 +13,51 @@
*******************************************************************************/
package org.eclipse.equinox.common.tests.registry.simple;
+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 java.io.File;
-import org.eclipse.core.runtime.*;
+import java.io.IOException;
+
+import org.eclipse.core.runtime.ContributorFactorySimple;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IContributor;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.RegistryFactory;
import org.eclipse.core.runtime.spi.RegistryStrategy;
import org.eclipse.equinox.common.tests.registry.simple.utils.ExeExtensionStrategy;
import org.eclipse.equinox.common.tests.registry.simple.utils.ExecutableRegistryObject;
+import org.junit.Test;
/**
- * Tests that executable extensions present in the simple registry actually
- * gets processed.
+ * Tests that executable extensions present in the simple registry actually gets
+ * processed.
+ *
* @since 3.2
*/
public class XMLExecutableExtensionTest extends BaseExtensionRegistryRun {
- public XMLExecutableExtensionTest() {
- super();
- }
-
- public XMLExecutableExtensionTest(String name) {
- super(name);
- }
-
/**
* Provide own class loader to the registry executable element strategry
+ *
* @return - open extension registry
*/
@Override
protected IExtensionRegistry startRegistry() {
// use plugin's metadata directory to save cache data
IPath userDataPath = getStateLocation();
- File[] registryLocations = new File[] {new File(userDataPath.toOSString())};
- boolean[] readOnly = new boolean[] {false};
+ File[] registryLocations = new File[] { new File(userDataPath.toOSString()) };
+ boolean[] readOnly = new boolean[] { false };
RegistryStrategy registryStrategy = new ExeExtensionStrategy(registryLocations, readOnly);
return RegistryFactory.createRegistry(registryStrategy, masterToken, userToken);
}
- public void testExecutableExtensionCreation() {
+ @Test
+ public void testExecutableExtensionCreation() throws IOException, CoreException {
// Test with non-bundle contributor
IContributor nonBundleContributor = ContributorFactorySimple.createContributor("ABC"); //$NON-NLS-1$
assertFalse(ExecutableRegistryObject.createCalled);
@@ -60,21 +69,17 @@ public class XMLExecutableExtensionTest extends BaseExtensionRegistryRun {
assertTrue(ExecutableRegistryObject.createCalled);
}
- private void fillRegistry(IContributor contributor) {
+ private void fillRegistry(IContributor contributor) throws IOException {
processXMLContribution(contributor, getXML("ExecutableExtension.xml")); //$NON-NLS-1$
}
- private void checkRegistry(String namespace) {
- IConfigurationElement[] elements = simpleRegistry.getConfigurationElementsFor(qualifiedName(namespace, "XMLExecutableExtPoint")); //$NON-NLS-1$
- assertTrue(elements.length == 1);
+ private void checkRegistry(String namespace) throws CoreException {
+ IConfigurationElement[] elements = simpleRegistry
+ .getConfigurationElementsFor(qualifiedName(namespace, "XMLExecutableExtPoint")); //$NON-NLS-1$
+ assertEquals(1, elements.length);
for (IConfigurationElement element : elements) {
- try {
- Object object = element.createExecutableExtension("class"); //$NON-NLS-1$
- assertNotNull(object);
- } catch (CoreException e) {
- assertTrue(false);
- e.printStackTrace();
- }
+ Object object = element.createExecutableExtension("class"); //$NON-NLS-1$
+ assertNotNull(object);
}
}
}
diff --git a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/simple/XMLExtensionCreateEclipseTest.java b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/simple/XMLExtensionCreateEclipseTest.java
index 38f28450d..659e04da2 100644
--- a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/simple/XMLExtensionCreateEclipseTest.java
+++ b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/simple/XMLExtensionCreateEclipseTest.java
@@ -13,10 +13,21 @@
*******************************************************************************/
package org.eclipse.equinox.common.tests.registry.simple;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
import java.io.IOException;
import java.net.URL;
+
import org.eclipse.core.internal.registry.ExtensionRegistry;
-import org.eclipse.core.runtime.*;
+import org.eclipse.core.runtime.ContributorFactoryOSGi;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IContributor;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.RegistryFactory;
+import org.junit.Test;
import org.osgi.framework.Bundle;
import org.osgi.framework.FrameworkUtil;
@@ -25,8 +36,8 @@ import org.osgi.framework.FrameworkUtil;
* @since 3.2
*/
public class XMLExtensionCreateEclipseTest extends BaseExtensionRegistryRun {
-
- public void testDynamicContribution() {
+ @Test
+ public void testDynamicContribution() throws IllegalArgumentException, IOException {
// specify this bundle as a contributor
Bundle thisBundle = FrameworkUtil.getBundle(getClass());
IContributor thisContributor = ContributorFactoryOSGi.createContributor(thisBundle);
@@ -34,15 +45,10 @@ public class XMLExtensionCreateEclipseTest extends BaseExtensionRegistryRun {
checkRegistry(thisContributor.getName());
}
- private void fillRegistry(IContributor contributor) {
- try {
+ private void fillRegistry(IContributor contributor) throws IllegalArgumentException, IOException {
Object userKey = ((ExtensionRegistry) RegistryFactory.getRegistry()).getTemporaryUserToken();
URL xmlURL = getXML("DynamicExtension.xml"); //$NON-NLS-1$
RegistryFactory.getRegistry().addContribution(xmlURL.openStream(), contributor, false, xmlURL.getFile(), null, userKey);
- } catch (IOException eFile) {
- fail(eFile.getMessage());
- return;
- }
}
private void checkRegistry(String namespace) {
@@ -51,7 +57,7 @@ public class XMLExtensionCreateEclipseTest extends BaseExtensionRegistryRun {
IExtensionPoint dynamicExtensionPoint = eclipseRegistry.getExtensionPoint(uniqueId);
assertNotNull(dynamicExtensionPoint);
IConfigurationElement[] elements = eclipseRegistry.getConfigurationElementsFor(uniqueId);
- assertTrue(elements.length == 1);
+ assertEquals(1, elements.length);
for (IConfigurationElement element : elements) {
assertTrue("org.eclipse.equinox.common.tests.registry.simple.utils.ExecutableRegistryObject".equals(element.getAttribute("class")));
}
diff --git a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/simple/XMLExtensionCreateTest.java b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/simple/XMLExtensionCreateTest.java
index 94d1e7635..81d14e1a0 100644
--- a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/simple/XMLExtensionCreateTest.java
+++ b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/simple/XMLExtensionCreateTest.java
@@ -13,8 +13,21 @@
*******************************************************************************/
package org.eclipse.equinox.common.tests.registry.simple;
-import org.eclipse.core.runtime.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+
+import org.eclipse.core.runtime.ContributorFactorySimple;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IContributor;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionDelta;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IRegistryChangeEvent;
import org.eclipse.equinox.common.tests.registry.simple.utils.SimpleRegistryListener;
+import org.junit.Test;
/**
* Tests addition of extension point and the extension to the registry via
@@ -25,15 +38,8 @@ import org.eclipse.equinox.common.tests.registry.simple.utils.SimpleRegistryList
*/
public class XMLExtensionCreateTest extends BaseExtensionRegistryRun {
- public XMLExtensionCreateTest() {
- super();
- }
-
- public XMLExtensionCreateTest(String name) {
- super(name);
- }
-
- public void testExtensionPointAddition() {
+ @Test
+ public void testExtensionPointAddition() throws IOException {
SimpleRegistryListener listener = new SimpleRegistryListener();
listener.register(simpleRegistry);
@@ -53,7 +59,7 @@ public class XMLExtensionCreateTest extends BaseExtensionRegistryRun {
checkRegistry(nonBundleContributor.getName());
}
- private void fillRegistry(IContributor contributor) {
+ private void fillRegistry(IContributor contributor) throws IOException {
// Add extension point
processXMLContribution(contributor, getXML("ExtensionPoint.xml")); //$NON-NLS-1$
// Add extension
@@ -65,10 +71,10 @@ public class XMLExtensionCreateTest extends BaseExtensionRegistryRun {
assertNotNull(extensionPoint);
IExtension[] namespaceExtensions = simpleRegistry.getExtensions(namespace);
assertNotNull(namespaceExtensions);
- assertTrue(namespaceExtensions.length == 1);
+ assertEquals(1, namespaceExtensions.length);
IExtension[] extensions = extensionPoint.getExtensions();
assertNotNull(extensions);
- assertTrue(extensions.length == 1);
+ assertEquals(1, extensions.length);
for (IExtension extension : extensions) {
String extensionId = extension.getUniqueIdentifier();
assertTrue(extensionId.equals(qualifiedName(namespace, "XMLDirectExtensionID"))); //$NON-NLS-1$
@@ -82,9 +88,9 @@ public class XMLExtensionCreateTest extends BaseExtensionRegistryRun {
String configElementName = configElement.getName();
assertTrue(configElementName.equals("StorageDevice")); //$NON-NLS-1$
String[] attributeNames = configElement.getAttributeNames();
- assertTrue(attributeNames.length == 1);
+ assertEquals(1, attributeNames.length);
IConfigurationElement[] configElementChildren = configElement.getChildren();
- assertTrue(configElementChildren.length == 2);
+ assertEquals(2, configElementChildren.length);
}
}
}
@@ -92,9 +98,9 @@ public class XMLExtensionCreateTest extends BaseExtensionRegistryRun {
private void checkListener(String namespace, SimpleRegistryListener listener) {
IRegistryChangeEvent event = listener.getEvent(5000);
IExtensionDelta[] deltas = event.getExtensionDeltas();
- assertTrue(deltas.length == 1); // only one notification
+ assertEquals(1, deltas.length); // only one notification
for (IExtensionDelta delta : deltas) {
- assertTrue(delta.getKind() == IExtensionDelta.ADDED);
+ assertEquals(delta.getKind(), IExtensionDelta.ADDED);
IExtensionPoint theExtensionPoint = delta.getExtensionPoint();
IExtension theExtension = delta.getExtension();
String Id1 = theExtension.getExtensionPointUniqueIdentifier();

Back to the top