polish: leading spaces -> tabs across .aop and .testsuite bundles
This commit is contained in:
parent
b7cc5d2402
commit
04d3f984b1
|
|
@ -1,4 +1,4 @@
|
||||||
#Fri Oct 24 15:07:09 EDT 2008
|
#Fri Dec 12 11:37:26 PST 2008
|
||||||
eclipse.preferences.version=1
|
eclipse.preferences.version=1
|
||||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||||
|
|
@ -10,3 +10,259 @@ org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||||
org.eclipse.jdt.core.compiler.source=1.6
|
org.eclipse.jdt.core.compiler.source=1.6
|
||||||
|
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
|
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
|
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
|
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
|
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
|
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
|
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_assignment=0
|
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
|
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
|
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
|
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
|
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
|
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
|
||||||
|
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_selector_in_method_invocation=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
|
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
|
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
|
||||||
|
org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
|
||||||
|
org.eclipse.jdt.core.formatter.blank_lines_after_package=1
|
||||||
|
org.eclipse.jdt.core.formatter.blank_lines_before_field=0
|
||||||
|
org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
|
||||||
|
org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
|
||||||
|
org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
|
||||||
|
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_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
|
||||||
|
org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
|
||||||
|
org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line
|
||||||
|
org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line
|
||||||
|
org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line
|
||||||
|
org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line
|
||||||
|
org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line
|
||||||
|
org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line
|
||||||
|
org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
|
||||||
|
org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
|
||||||
|
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false
|
||||||
|
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
|
||||||
|
org.eclipse.jdt.core.formatter.comment.format_block_comments=true
|
||||||
|
org.eclipse.jdt.core.formatter.comment.format_header=false
|
||||||
|
org.eclipse.jdt.core.formatter.comment.format_html=true
|
||||||
|
org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true
|
||||||
|
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=true
|
||||||
|
org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
|
||||||
|
org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
|
||||||
|
org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert
|
||||||
|
org.eclipse.jdt.core.formatter.comment.line_length=80
|
||||||
|
org.eclipse.jdt.core.formatter.compact_else_if=true
|
||||||
|
org.eclipse.jdt.core.formatter.continuation_indentation=2
|
||||||
|
org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
|
||||||
|
org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
|
||||||
|
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
|
||||||
|
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
|
||||||
|
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
|
||||||
|
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
|
||||||
|
org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true
|
||||||
|
org.eclipse.jdt.core.formatter.indent_empty_lines=false
|
||||||
|
org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
|
||||||
|
org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
|
||||||
|
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
|
||||||
|
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false
|
||||||
|
org.eclipse.jdt.core.formatter.indentation.size=4
|
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=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_closing_angle_bracket_in_type_arguments=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
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
|
||||||
|
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_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_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
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
|
||||||
|
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_semicolon_in_for=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=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_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
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
|
||||||
|
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_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_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
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
|
||||||
|
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_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_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
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
|
||||||
|
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_imple_if_on_one_line=false
|
||||||
|
org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
|
||||||
|
org.eclipse.jdt.core.formatter.lineSplit=80
|
||||||
|
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_at_beginning_of_method_body=0
|
||||||
|
org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
|
||||||
|
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.use_tabs_only_for_leading_indentations=false
|
||||||
|
org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
#Fri Dec 12 11:37:26 PST 2008
|
||||||
|
eclipse.preferences.version=1
|
||||||
|
formatter_profile=org.eclipse.jdt.ui.default.eclipse_profile
|
||||||
|
formatter_settings_version=11
|
||||||
|
|
@ -41,8 +41,8 @@ public class MethodLocatingFactoryBean implements FactoryBean, BeanFactoryAware
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the name of the bean to locate the {@link Method} on.
|
* Set the name of the bean to locate the {@link Method} on.
|
||||||
* <p>This property is required.
|
* <p>This property is required.
|
||||||
* @param targetBeanName the name of the bean to locate the {@link Method} on
|
* @param targetBeanName the name of the bean to locate the {@link Method} on
|
||||||
*/
|
*/
|
||||||
public void setTargetBeanName(String targetBeanName) {
|
public void setTargetBeanName(String targetBeanName) {
|
||||||
this.targetBeanName = targetBeanName;
|
this.targetBeanName = targetBeanName;
|
||||||
|
|
@ -50,8 +50,8 @@ public class MethodLocatingFactoryBean implements FactoryBean, BeanFactoryAware
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the name of the {@link Method} to locate.
|
* Set the name of the {@link Method} to locate.
|
||||||
* <p>This property is required.
|
* <p>This property is required.
|
||||||
* @param methodName the name of the {@link Method} to locate
|
* @param methodName the name of the {@link Method} to locate
|
||||||
*/
|
*/
|
||||||
public void setMethodName(String methodName) {
|
public void setMethodName(String methodName) {
|
||||||
this.methodName = methodName;
|
this.methodName = methodName;
|
||||||
|
|
|
||||||
|
|
@ -238,19 +238,19 @@ public class AspectJAdviceParameterNameDiscovererTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testReferenceBinding() {
|
public void testReferenceBinding() {
|
||||||
assertParameterNames(getMethod("onePrimitive"),"somepc(foo)",new String[] {"foo"});
|
assertParameterNames(getMethod("onePrimitive"),"somepc(foo)",new String[] {"foo"});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testReferenceBindingWithAlternateTokenizations() {
|
public void testReferenceBindingWithAlternateTokenizations() {
|
||||||
assertParameterNames(getMethod("onePrimitive"),"call(bar *) && somepc(foo)",new String[] {"foo"});
|
assertParameterNames(getMethod("onePrimitive"),"call(bar *) && somepc(foo)",new String[] {"foo"});
|
||||||
assertParameterNames(getMethod("onePrimitive"),"somepc ( foo )",new String[] {"foo"});
|
assertParameterNames(getMethod("onePrimitive"),"somepc ( foo )",new String[] {"foo"});
|
||||||
assertParameterNames(getMethod("onePrimitive"),"somepc( foo)",new String[] {"foo"});
|
assertParameterNames(getMethod("onePrimitive"),"somepc( foo)",new String[] {"foo"});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected Method getMethod(String name) {
|
protected Method getMethod(String name) {
|
||||||
// assumes no overloading of test methods...
|
// assumes no overloading of test methods...
|
||||||
Method[] candidates = this.getClass().getMethods();
|
Method[] candidates = this.getClass().getMethods();
|
||||||
for (int i = 0; i < candidates.length; i++) {
|
for (int i = 0; i < candidates.length; i++) {
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ import org.springframework.beans.TestBean;
|
||||||
*/
|
*/
|
||||||
public class BeanNamePointcutMatchingTests {
|
public class BeanNamePointcutMatchingTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMatchingPointcuts() {
|
public void testMatchingPointcuts() {
|
||||||
assertMatch("someName", "bean(someName)");
|
assertMatch("someName", "bean(someName)");
|
||||||
|
|
||||||
|
|
@ -64,7 +64,7 @@ public class BeanNamePointcutMatchingTests {
|
||||||
assertMatch("someName", "bean(someName) && !bean(someOtherName)");
|
assertMatch("someName", "bean(someName) && !bean(someOtherName)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNonMatchingPointcuts() {
|
public void testNonMatchingPointcuts() {
|
||||||
assertMisMatch("someName", "bean(someNamex)");
|
assertMisMatch("someName", "bean(someNamex)");
|
||||||
assertMisMatch("someName", "bean(someX*Name)");
|
assertMisMatch("someName", "bean(someX*Name)");
|
||||||
|
|
@ -86,8 +86,8 @@ public class BeanNamePointcutMatchingTests {
|
||||||
matches(beanName, pcExpression));
|
matches(beanName, pcExpression));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean matches(final String beanName, String pcExpression) {
|
private static boolean matches(final String beanName, String pcExpression) {
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut() {
|
AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut() {
|
||||||
protected String getCurrentProxiedBeanName() {
|
protected String getCurrentProxiedBeanName() {
|
||||||
return beanName;
|
return beanName;
|
||||||
|
|
|
||||||
|
|
@ -42,8 +42,8 @@ import org.springframework.beans.TestBean;
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
public class MethodInvocationProceedingJoinPointTests {
|
public class MethodInvocationProceedingJoinPointTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testingBindingWithJoinPoint() {
|
public void testingBindingWithJoinPoint() {
|
||||||
try {
|
try {
|
||||||
AbstractAspectJAdvice.currentJoinPoint();
|
AbstractAspectJAdvice.currentJoinPoint();
|
||||||
|
|
@ -53,8 +53,8 @@ public class MethodInvocationProceedingJoinPointTests {
|
||||||
// expected
|
// expected
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testingBindingWithProceedingJoinPoint() {
|
public void testingBindingWithProceedingJoinPoint() {
|
||||||
try {
|
try {
|
||||||
AbstractAspectJAdvice.currentJoinPoint();
|
AbstractAspectJAdvice.currentJoinPoint();
|
||||||
|
|
@ -64,8 +64,8 @@ public class MethodInvocationProceedingJoinPointTests {
|
||||||
// expected
|
// expected
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCanGetMethodSignatureFromJoinPoint() {
|
public void testCanGetMethodSignatureFromJoinPoint() {
|
||||||
final Object raw = new TestBean();
|
final Object raw = new TestBean();
|
||||||
// Will be set by advice during a method call
|
// Will be set by advice during a method call
|
||||||
|
|
@ -133,8 +133,8 @@ public class MethodInvocationProceedingJoinPointTests {
|
||||||
// Any call will do
|
// Any call will do
|
||||||
assertEquals("Advice reentrantly set age", newAge, itb.getAge());
|
assertEquals("Advice reentrantly set age", newAge, itb.getAge());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCanGetSourceLocationFromJoinPoint() {
|
public void testCanGetSourceLocationFromJoinPoint() {
|
||||||
final Object raw = new TestBean();
|
final Object raw = new TestBean();
|
||||||
ProxyFactory pf = new ProxyFactory(raw);
|
ProxyFactory pf = new ProxyFactory(raw);
|
||||||
|
|
@ -165,8 +165,8 @@ public class MethodInvocationProceedingJoinPointTests {
|
||||||
// Any call will do
|
// Any call will do
|
||||||
itb.getAge();
|
itb.getAge();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCanGetStaticPartFromJoinPoint() {
|
public void testCanGetStaticPartFromJoinPoint() {
|
||||||
final Object raw = new TestBean();
|
final Object raw = new TestBean();
|
||||||
ProxyFactory pf = new ProxyFactory(raw);
|
ProxyFactory pf = new ProxyFactory(raw);
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||||
*/
|
*/
|
||||||
public final class TypePatternClassFilterTests {
|
public final class TypePatternClassFilterTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInvalidPattern() {
|
public void testInvalidPattern() {
|
||||||
try {
|
try {
|
||||||
new TypePatternClassFilter("-");
|
new TypePatternClassFilter("-");
|
||||||
|
|
@ -45,7 +45,7 @@ public final class TypePatternClassFilterTests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testValidPatternMatching() {
|
public void testValidPatternMatching() {
|
||||||
TypePatternClassFilter tpcf = new TypePatternClassFilter("org.springframework.beans.*");
|
TypePatternClassFilter tpcf = new TypePatternClassFilter("org.springframework.beans.*");
|
||||||
assertTrue("Must match: in package", tpcf.matches(TestBean.class));
|
assertTrue("Must match: in package", tpcf.matches(TestBean.class));
|
||||||
|
|
@ -56,7 +56,7 @@ public final class TypePatternClassFilterTests {
|
||||||
assertFalse("Must be excluded: in wrong package", tpcf.matches(DefaultListableBeanFactory.class));
|
assertFalse("Must be excluded: in wrong package", tpcf.matches(DefaultListableBeanFactory.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSubclassMatching() {
|
public void testSubclassMatching() {
|
||||||
TypePatternClassFilter tpcf = new TypePatternClassFilter("org.springframework.beans.ITestBean+");
|
TypePatternClassFilter tpcf = new TypePatternClassFilter("org.springframework.beans.ITestBean+");
|
||||||
assertTrue("Must match: in package", tpcf.matches(TestBean.class));
|
assertTrue("Must match: in package", tpcf.matches(TestBean.class));
|
||||||
|
|
@ -66,7 +66,7 @@ public final class TypePatternClassFilterTests {
|
||||||
assertFalse("Must be excluded: not subclass", tpcf.matches(DefaultListableBeanFactory.class));
|
assertFalse("Must be excluded: not subclass", tpcf.matches(DefaultListableBeanFactory.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAndOrNotReplacement() {
|
public void testAndOrNotReplacement() {
|
||||||
TypePatternClassFilter tpcf = new TypePatternClassFilter("java.lang.Object or java.lang.String");
|
TypePatternClassFilter tpcf = new TypePatternClassFilter("java.lang.Object or java.lang.String");
|
||||||
assertFalse("matches Number",tpcf.matches(Number.class));
|
assertFalse("matches Number",tpcf.matches(Number.class));
|
||||||
|
|
@ -80,12 +80,12 @@ public final class TypePatternClassFilterTests {
|
||||||
assertTrue("matches Double",tpcf.matches(Double.class));
|
assertTrue("matches Double",tpcf.matches(Double.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected=IllegalArgumentException.class)
|
@Test(expected=IllegalArgumentException.class)
|
||||||
public void testSetTypePatternWithNullArgument() throws Exception {
|
public void testSetTypePatternWithNullArgument() throws Exception {
|
||||||
new TypePatternClassFilter(null);
|
new TypePatternClassFilter(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected=IllegalStateException.class)
|
@Test(expected=IllegalStateException.class)
|
||||||
public void testInvocationOfMatchesMethodBlowsUpWhenNoTypePatternHasBeenSet() throws Exception {
|
public void testInvocationOfMatchesMethodBlowsUpWhenNoTypePatternHasBeenSet() throws Exception {
|
||||||
new TypePatternClassFilter().matches(String.class);
|
new TypePatternClassFilter().matches(String.class);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ import org.springframework.beans.TestBean;
|
||||||
*/
|
*/
|
||||||
public class ArgumentBindingTests {
|
public class ArgumentBindingTests {
|
||||||
|
|
||||||
@Test(expected=IllegalArgumentException.class)
|
@Test(expected=IllegalArgumentException.class)
|
||||||
public void testBindingInPointcutUsedByAdvice() {
|
public void testBindingInPointcutUsedByAdvice() {
|
||||||
TestBean tb = new TestBean();
|
TestBean tb = new TestBean();
|
||||||
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(tb);
|
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(tb);
|
||||||
|
|
@ -47,7 +47,7 @@ public class ArgumentBindingTests {
|
||||||
proxiedTestBean.setName("Supercalifragalisticexpialidocious"); // should throw
|
proxiedTestBean.setName("Supercalifragalisticexpialidocious"); // should throw
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected=IllegalStateException.class)
|
@Test(expected=IllegalStateException.class)
|
||||||
public void testAnnotationArgumentNameBinding() {
|
public void testAnnotationArgumentNameBinding() {
|
||||||
TransactionalBean tb = new TransactionalBean();
|
TransactionalBean tb = new TransactionalBean();
|
||||||
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(tb);
|
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(tb);
|
||||||
|
|
@ -57,7 +57,7 @@ public class ArgumentBindingTests {
|
||||||
proxiedTestBean.doInTransaction(); // should throw
|
proxiedTestBean.doInTransaction(); // should throw
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testParameterNameDiscoverWithReferencePointcut() throws Exception {
|
public void testParameterNameDiscoverWithReferencePointcut() throws Exception {
|
||||||
AspectJAdviceParameterNameDiscoverer discoverer =
|
AspectJAdviceParameterNameDiscoverer discoverer =
|
||||||
new AspectJAdviceParameterNameDiscoverer("somepc(formal) && set(* *)");
|
new AspectJAdviceParameterNameDiscoverer("somepc(formal) && set(* *)");
|
||||||
|
|
|
||||||
|
|
@ -32,12 +32,12 @@ import example.aspects.PerTargetAspect;
|
||||||
*/
|
*/
|
||||||
public class AspectMetadataTests {
|
public class AspectMetadataTests {
|
||||||
|
|
||||||
@Test(expected=IllegalArgumentException.class)
|
@Test(expected=IllegalArgumentException.class)
|
||||||
public void testNotAnAspect() {
|
public void testNotAnAspect() {
|
||||||
new AspectMetadata(String.class,"someBean");
|
new AspectMetadata(String.class,"someBean");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSingletonAspect() {
|
public void testSingletonAspect() {
|
||||||
AspectMetadata am = new AspectMetadata(ExceptionAspect.class,"someBean");
|
AspectMetadata am = new AspectMetadata(ExceptionAspect.class,"someBean");
|
||||||
assertFalse(am.isPerThisOrPerTarget());
|
assertFalse(am.isPerThisOrPerTarget());
|
||||||
|
|
@ -45,7 +45,7 @@ public class AspectMetadataTests {
|
||||||
assertEquals(PerClauseKind.SINGLETON, am.getAjType().getPerClause().getKind());
|
assertEquals(PerClauseKind.SINGLETON, am.getAjType().getPerClause().getKind());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPerTargetAspect() {
|
public void testPerTargetAspect() {
|
||||||
AspectMetadata am = new AspectMetadata(PerTargetAspect.class,"someBean");
|
AspectMetadata am = new AspectMetadata(PerTargetAspect.class,"someBean");
|
||||||
assertTrue(am.isPerThisOrPerTarget());
|
assertTrue(am.isPerThisOrPerTarget());
|
||||||
|
|
@ -53,7 +53,7 @@ public class AspectMetadataTests {
|
||||||
assertEquals(PerClauseKind.PERTARGET, am.getAjType().getPerClause().getKind());
|
assertEquals(PerClauseKind.PERTARGET, am.getAjType().getPerClause().getKind());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPerThisAspect() {
|
public void testPerThisAspect() {
|
||||||
AspectMetadata am = new AspectMetadata(PerThisAspect.class,"someBean");
|
AspectMetadata am = new AspectMetadata(PerThisAspect.class,"someBean");
|
||||||
assertTrue(am.isPerThisOrPerTarget());
|
assertTrue(am.isPerThisOrPerTarget());
|
||||||
|
|
|
||||||
|
|
@ -30,13 +30,13 @@ import example.aspects.PerThisAspect;
|
||||||
*/
|
*/
|
||||||
public class AspectProxyFactoryTests {
|
public class AspectProxyFactoryTests {
|
||||||
|
|
||||||
@Test(expected=IllegalArgumentException.class)
|
@Test(expected=IllegalArgumentException.class)
|
||||||
public void testWithNonAspect() {
|
public void testWithNonAspect() {
|
||||||
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(new TestBean());
|
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(new TestBean());
|
||||||
proxyFactory.addAspect(TestBean.class);
|
proxyFactory.addAspect(TestBean.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWithSimpleAspect() throws Exception {
|
public void testWithSimpleAspect() throws Exception {
|
||||||
TestBean bean = new TestBean();
|
TestBean bean = new TestBean();
|
||||||
bean.setAge(2);
|
bean.setAge(2);
|
||||||
|
|
@ -46,7 +46,7 @@ public class AspectProxyFactoryTests {
|
||||||
assertEquals("Multiplication did not occur", bean.getAge() * 2, proxy.getAge());
|
assertEquals("Multiplication did not occur", bean.getAge() * 2, proxy.getAge());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWithPerThisAspect() throws Exception {
|
public void testWithPerThisAspect() throws Exception {
|
||||||
TestBean bean1 = new TestBean();
|
TestBean bean1 = new TestBean();
|
||||||
TestBean bean2 = new TestBean();
|
TestBean bean2 = new TestBean();
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ import org.springframework.core.io.ClassPathResource;
|
||||||
*/
|
*/
|
||||||
public class AopNamespaceHandlerPointcutErrorTests {
|
public class AopNamespaceHandlerPointcutErrorTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDuplicatePointcutConfig() {
|
public void testDuplicatePointcutConfig() {
|
||||||
try {
|
try {
|
||||||
new XmlBeanFactory(new ClassPathResource(
|
new XmlBeanFactory(new ClassPathResource(
|
||||||
|
|
@ -40,8 +40,8 @@ public class AopNamespaceHandlerPointcutErrorTests {
|
||||||
assertTrue(ex.contains(BeanDefinitionParsingException.class));
|
assertTrue(ex.contains(BeanDefinitionParsingException.class));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMissingPointcutConfig() {
|
public void testMissingPointcutConfig() {
|
||||||
try {
|
try {
|
||||||
new XmlBeanFactory(new ClassPathResource(
|
new XmlBeanFactory(new ClassPathResource(
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ import org.springframework.core.io.ClassPathResource;
|
||||||
*/
|
*/
|
||||||
public final class TopLevelAopTagTests {
|
public final class TopLevelAopTagTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testParse() throws Exception {
|
public void testParse() throws Exception {
|
||||||
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
|
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
|
||||||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(beanFactory);
|
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(beanFactory);
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.springframework.aop.framework;
|
package org.springframework.aop.framework;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
* @author Rod Johnson
|
* @author Rod Johnson
|
||||||
*/
|
*/
|
||||||
public class DefaultLockable implements Lockable {
|
public class DefaultLockable implements Lockable {
|
||||||
|
|
||||||
private boolean locked;
|
private boolean locked;
|
||||||
|
|
||||||
public void lock() {
|
public void lock() {
|
||||||
|
|
|
||||||
|
|
@ -32,54 +32,54 @@ import org.springframework.util.StopWatch;
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
public class IntroductionBenchmarkTests {
|
public class IntroductionBenchmarkTests {
|
||||||
|
|
||||||
private static final int EXPECTED_COMPARE = 13;
|
private static final int EXPECTED_COMPARE = 13;
|
||||||
|
|
||||||
/** Increase this if you want meaningful results! */
|
/** Increase this if you want meaningful results! */
|
||||||
private static final int INVOCATIONS = 100000;
|
private static final int INVOCATIONS = 100000;
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public static class SimpleCounterIntroduction extends DelegatingIntroductionInterceptor implements Counter {
|
public static class SimpleCounterIntroduction extends DelegatingIntroductionInterceptor implements Counter {
|
||||||
public int getCount() {
|
public int getCount() {
|
||||||
return EXPECTED_COMPARE;
|
return EXPECTED_COMPARE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static interface Counter {
|
public static interface Counter {
|
||||||
int getCount();
|
int getCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeManyInvocations() {
|
public void timeManyInvocations() {
|
||||||
StopWatch sw = new StopWatch();
|
StopWatch sw = new StopWatch();
|
||||||
|
|
||||||
TestBean target = new TestBean();
|
TestBean target = new TestBean();
|
||||||
ProxyFactory pf = new ProxyFactory(target);
|
ProxyFactory pf = new ProxyFactory(target);
|
||||||
pf.setProxyTargetClass(false);
|
pf.setProxyTargetClass(false);
|
||||||
pf.addAdvice(new SimpleCounterIntroduction());
|
pf.addAdvice(new SimpleCounterIntroduction());
|
||||||
ITestBean proxy = (ITestBean) pf.getProxy();
|
ITestBean proxy = (ITestBean) pf.getProxy();
|
||||||
|
|
||||||
Counter counter = (Counter) proxy;
|
Counter counter = (Counter) proxy;
|
||||||
|
|
||||||
sw.start(INVOCATIONS + " invocations on proxy, not hitting introduction");
|
sw.start(INVOCATIONS + " invocations on proxy, not hitting introduction");
|
||||||
for (int i = 0; i < INVOCATIONS; i++) {
|
for (int i = 0; i < INVOCATIONS; i++) {
|
||||||
proxy.getAge();
|
proxy.getAge();
|
||||||
}
|
}
|
||||||
sw.stop();
|
sw.stop();
|
||||||
|
|
||||||
sw.start(INVOCATIONS + " invocations on proxy, hitting introduction");
|
sw.start(INVOCATIONS + " invocations on proxy, hitting introduction");
|
||||||
for (int i = 0; i < INVOCATIONS; i++) {
|
for (int i = 0; i < INVOCATIONS; i++) {
|
||||||
counter.getCount();
|
counter.getCount();
|
||||||
}
|
}
|
||||||
sw.stop();
|
sw.stop();
|
||||||
|
|
||||||
sw.start(INVOCATIONS + " invocations on target");
|
sw.start(INVOCATIONS + " invocations on target");
|
||||||
for (int i = 0; i < INVOCATIONS; i++) {
|
for (int i = 0; i < INVOCATIONS; i++) {
|
||||||
target.getAge();
|
target.getAge();
|
||||||
}
|
}
|
||||||
sw.stop();
|
sw.stop();
|
||||||
|
|
||||||
System.out.println(sw.prettyPrint());
|
System.out.println(sw.prettyPrint());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ import org.springframework.aop.framework.MethodCounter;
|
||||||
*/
|
*/
|
||||||
public class ThrowsAdviceInterceptorTests {
|
public class ThrowsAdviceInterceptorTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNoHandlerMethods() {
|
public void testNoHandlerMethods() {
|
||||||
Object o = new Object();
|
Object o = new Object();
|
||||||
try {
|
try {
|
||||||
|
|
@ -52,8 +52,8 @@ public class ThrowsAdviceInterceptorTests {
|
||||||
// Ok
|
// Ok
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNotInvoked() throws Throwable {
|
public void testNotInvoked() throws Throwable {
|
||||||
MyThrowsHandler th = new MyThrowsHandler();
|
MyThrowsHandler th = new MyThrowsHandler();
|
||||||
ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th);
|
ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th);
|
||||||
|
|
@ -65,8 +65,8 @@ public class ThrowsAdviceInterceptorTests {
|
||||||
assertEquals(0, th.getCalls());
|
assertEquals(0, th.getCalls());
|
||||||
verify(mi);
|
verify(mi);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNoHandlerMethodForThrowable() throws Throwable {
|
public void testNoHandlerMethodForThrowable() throws Throwable {
|
||||||
MyThrowsHandler th = new MyThrowsHandler();
|
MyThrowsHandler th = new MyThrowsHandler();
|
||||||
ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th);
|
ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th);
|
||||||
|
|
@ -85,8 +85,8 @@ public class ThrowsAdviceInterceptorTests {
|
||||||
assertEquals(0, th.getCalls());
|
assertEquals(0, th.getCalls());
|
||||||
verify(mi);
|
verify(mi);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCorrectHandlerUsed() throws Throwable {
|
public void testCorrectHandlerUsed() throws Throwable {
|
||||||
MyThrowsHandler th = new MyThrowsHandler();
|
MyThrowsHandler th = new MyThrowsHandler();
|
||||||
ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th);
|
ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th);
|
||||||
|
|
@ -108,8 +108,8 @@ public class ThrowsAdviceInterceptorTests {
|
||||||
assertEquals(1, th.getCalls("ioException"));
|
assertEquals(1, th.getCalls("ioException"));
|
||||||
verify(mi);
|
verify(mi);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCorrectHandlerUsedForSubclass() throws Throwable {
|
public void testCorrectHandlerUsedForSubclass() throws Throwable {
|
||||||
MyThrowsHandler th = new MyThrowsHandler();
|
MyThrowsHandler th = new MyThrowsHandler();
|
||||||
ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th);
|
ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th);
|
||||||
|
|
@ -129,11 +129,11 @@ public class ThrowsAdviceInterceptorTests {
|
||||||
assertEquals(1, th.getCalls("remoteException"));
|
assertEquals(1, th.getCalls("remoteException"));
|
||||||
verify(mi);
|
verify(mi);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHandlerMethodThrowsException() throws Throwable {
|
public void testHandlerMethodThrowsException() throws Throwable {
|
||||||
final Throwable t = new Throwable();
|
final Throwable t = new Throwable();
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
MyThrowsHandler th = new MyThrowsHandler() {
|
MyThrowsHandler th = new MyThrowsHandler() {
|
||||||
public void afterThrowing(RemoteException ex) throws Throwable {
|
public void afterThrowing(RemoteException ex) throws Throwable {
|
||||||
|
|
@ -141,7 +141,7 @@ public class ThrowsAdviceInterceptorTests {
|
||||||
throw t;
|
throw t;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th);
|
ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th);
|
||||||
// Extends RemoteException
|
// Extends RemoteException
|
||||||
TransactionRolledbackException ex = new TransactionRolledbackException();
|
TransactionRolledbackException ex = new TransactionRolledbackException();
|
||||||
|
|
@ -159,9 +159,9 @@ public class ThrowsAdviceInterceptorTests {
|
||||||
assertEquals(1, th.getCalls("remoteException"));
|
assertEquals(1, th.getCalls("remoteException"));
|
||||||
verify(mi);
|
verify(mi);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
private static class MyThrowsHandler extends MethodCounter implements ThrowsAdvice {
|
private static class MyThrowsHandler extends MethodCounter implements ThrowsAdvice {
|
||||||
// Full method signature
|
// Full method signature
|
||||||
public void afterThrowing(Method m, Object[] args, Object target, IOException ex) {
|
public void afterThrowing(Method m, Object[] args, Object target, IOException ex) {
|
||||||
count("ioException");
|
count("ioException");
|
||||||
|
|
@ -169,11 +169,11 @@ public class ThrowsAdviceInterceptorTests {
|
||||||
public void afterThrowing(RemoteException ex) throws Throwable {
|
public void afterThrowing(RemoteException ex) throws Throwable {
|
||||||
count("remoteException");
|
count("remoteException");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Not valid, wrong number of arguments */
|
/** Not valid, wrong number of arguments */
|
||||||
public void afterThrowing(Method m, Exception ex) throws Throwable {
|
public void afterThrowing(Method m, Exception ex) throws Throwable {
|
||||||
throw new UnsupportedOperationException("Shouldn't be called");
|
throw new UnsupportedOperationException("Shouldn't be called");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,11 +27,11 @@ public class AuthenticationLogger {
|
||||||
public void logAuthenticationAttempt(String username) {
|
public void logAuthenticationAttempt(String username) {
|
||||||
System.out.println("User [" + username + "] attempting to authenticate");
|
System.out.println("User [" + username + "] attempting to authenticate");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class SecurityManager {
|
class SecurityManager {
|
||||||
public boolean authenticate(String username, String password) {
|
public boolean authenticate(String username, String password) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||||
*/
|
*/
|
||||||
public class OverloadedAdviceTests {
|
public class OverloadedAdviceTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testExceptionOnConfigParsingWithMismatchedAdviceMethod() {
|
public void testExceptionOnConfigParsingWithMismatchedAdviceMethod() {
|
||||||
try {
|
try {
|
||||||
new ClassPathXmlApplicationContext("org/springframework/aop/aspectj/overloaded-advice-tests.xml");
|
new ClassPathXmlApplicationContext("org/springframework/aop/aspectj/overloaded-advice-tests.xml");
|
||||||
|
|
@ -42,8 +42,8 @@ public class OverloadedAdviceTests {
|
||||||
cause.getMessage().indexOf("invalidAbsoluteTypeName") != -1);
|
cause.getMessage().indexOf("invalidAbsoluteTypeName") != -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testExceptionOnConfigParsingWithAmbiguousAdviceMethod() {
|
public void testExceptionOnConfigParsingWithAmbiguousAdviceMethod() {
|
||||||
try {
|
try {
|
||||||
new ClassPathXmlApplicationContext("org/springframework/aop/aspectj/ambiguous-advice-tests.xml");
|
new ClassPathXmlApplicationContext("org/springframework/aop/aspectj/ambiguous-advice-tests.xml");
|
||||||
|
|
|
||||||
|
|
@ -33,22 +33,22 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||||
*/
|
*/
|
||||||
public class PropertyDependentAspectTests {
|
public class PropertyDependentAspectTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPropertyDependentAspectWithPropertyDeclaredBeforeAdvice() throws Exception {
|
public void testPropertyDependentAspectWithPropertyDeclaredBeforeAdvice() throws Exception {
|
||||||
checkXmlAspect("org/springframework/aop/aspectj/property-dependent-aspect-property-before-aspect-test.xml");
|
checkXmlAspect("org/springframework/aop/aspectj/property-dependent-aspect-property-before-aspect-test.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPropertyDependentAspectWithPropertyDeclaredAfterAdvice() throws Exception {
|
public void testPropertyDependentAspectWithPropertyDeclaredAfterAdvice() throws Exception {
|
||||||
checkXmlAspect("org/springframework/aop/aspectj/property-dependent-aspect-property-after-aspect-test.xml");
|
checkXmlAspect("org/springframework/aop/aspectj/property-dependent-aspect-property-after-aspect-test.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPropertyDependentAtAspectJAspectWithPropertyDeclaredBeforeAdvice() throws Exception {
|
public void testPropertyDependentAtAspectJAspectWithPropertyDeclaredBeforeAdvice() throws Exception {
|
||||||
checkAtAspectJAspect("org/springframework/aop/aspectj/property-dependent-atAspectJ-aspect-property-before-aspect-test.xml");
|
checkAtAspectJAspect("org/springframework/aop/aspectj/property-dependent-atAspectJ-aspect-property-before-aspect-test.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPropertyDependentAtAspectJAspectWithPropertyDeclaredAfterAdvice() throws Exception {
|
public void testPropertyDependentAtAspectJAspectWithPropertyDeclaredAfterAdvice() throws Exception {
|
||||||
checkAtAspectJAspect("org/springframework/aop/aspectj/property-dependent-atAspectJ-aspect-property-after-aspect-test.xml");
|
checkAtAspectJAspect("org/springframework/aop/aspectj/property-dependent-atAspectJ-aspect-property-after-aspect-test.xml");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,18 +24,18 @@ import org.aspectj.lang.annotation.Pointcut;
|
||||||
@Aspect
|
@Aspect
|
||||||
public class AdviceUsingThisJoinPoint {
|
public class AdviceUsingThisJoinPoint {
|
||||||
|
|
||||||
private String lastEntry = "";
|
private String lastEntry = "";
|
||||||
|
|
||||||
public String getLastMethodEntered() {
|
public String getLastMethodEntered() {
|
||||||
return this.lastEntry;
|
return this.lastEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Pointcut("execution(* *(..))")
|
@Pointcut("execution(* *(..))")
|
||||||
public void methodExecution() {}
|
public void methodExecution() {}
|
||||||
|
|
||||||
@Before("methodExecution()")
|
@Before("methodExecution()")
|
||||||
public void entryTrace(JoinPoint jp) {
|
public void entryTrace(JoinPoint jp) {
|
||||||
this.lastEntry = jp.toString();
|
this.lastEntry = jp.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ import java.io.IOException;
|
||||||
*/
|
*/
|
||||||
public class AtAspectJAfterThrowingTests {
|
public class AtAspectJAfterThrowingTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAccessThrowable() throws Exception {
|
public void testAccessThrowable() throws Exception {
|
||||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("afterThrowingAdviceTests.xml", getClass());
|
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("afterThrowingAdviceTests.xml", getClass());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ import org.springframework.beans.ITestBean;
|
||||||
*/
|
*/
|
||||||
public class AopNamespaceHandlerProxyTargetClassTests extends AopNamespaceHandlerTests {
|
public class AopNamespaceHandlerProxyTargetClassTests extends AopNamespaceHandlerTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIsClassProxy() {
|
public void testIsClassProxy() {
|
||||||
ITestBean bean = getTestBean();
|
ITestBean bean = getTestBean();
|
||||||
assertTrue("Should be a CGLIB proxy", AopUtils.isCglibProxy(bean));
|
assertTrue("Should be a CGLIB proxy", AopUtils.isCglibProxy(bean));
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||||
*/
|
*/
|
||||||
public class PrototypeProxyTests {
|
public class PrototypeProxyTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInjectionBeforeWrappingCheckDoesNotKickInForPrototypeProxy() {
|
public void testInjectionBeforeWrappingCheckDoesNotKickInForPrototypeProxy() {
|
||||||
new ClassPathXmlApplicationContext("prototypeProxy.xml", getClass());
|
new ClassPathXmlApplicationContext("prototypeProxy.xml", getClass());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -802,7 +802,7 @@ public abstract class AbstractAopProxyTests {
|
||||||
ProxyFactory pc = new ProxyFactory(target);
|
ProxyFactory pc = new ProxyFactory(target);
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
class MyDi extends DelegatingIntroductionInterceptor implements TimeStamped {
|
class MyDi extends DelegatingIntroductionInterceptor implements TimeStamped {
|
||||||
/**
|
/**
|
||||||
* @see org.springframework.aop.framework.TimeStamped#getTimeStamp()
|
* @see org.springframework.aop.framework.TimeStamped#getTimeStamp()
|
||||||
*/
|
*/
|
||||||
|
|
@ -1266,11 +1266,11 @@ public abstract class AbstractAopProxyTests {
|
||||||
public void releaseTarget(Object target) throws Exception {
|
public void releaseTarget(Object target) throws Exception {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Just test anything: it will fail if context wasn't found
|
// Just test anything: it will fail if context wasn't found
|
||||||
assertEquals(0, proxy.getAge());
|
assertEquals(0, proxy.getAge());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEquals() {
|
public void testEquals() {
|
||||||
IOther a = new AllInstancesAreEqual();
|
IOther a = new AllInstancesAreEqual();
|
||||||
|
|
@ -1328,7 +1328,7 @@ public abstract class AbstractAopProxyTests {
|
||||||
assertEquals(1, cba.getCalls());
|
assertEquals(1, cba.getCalls());
|
||||||
assertEquals(26, proxied.getAge());
|
assertEquals(26, proxied.getAge());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUserAttributes() throws Throwable {
|
public void testUserAttributes() throws Throwable {
|
||||||
class MapAwareMethodInterceptor implements MethodInterceptor {
|
class MapAwareMethodInterceptor implements MethodInterceptor {
|
||||||
|
|
@ -1362,7 +1362,7 @@ public abstract class AbstractAopProxyTests {
|
||||||
Map<String, String> finalExpected = new HashMap<String, String>(firstValuesToAdd);
|
Map<String, String> finalExpected = new HashMap<String, String>(firstValuesToAdd);
|
||||||
finalExpected.putAll(secondValuesToAdd);
|
finalExpected.putAll(secondValuesToAdd);
|
||||||
MapAwareMethodInterceptor mami6 = new MapAwareMethodInterceptor(finalExpected, secondValuesToAdd);
|
MapAwareMethodInterceptor mami6 = new MapAwareMethodInterceptor(finalExpected, secondValuesToAdd);
|
||||||
|
|
||||||
pc.addAdvice(mami1);
|
pc.addAdvice(mami1);
|
||||||
pc.addAdvice(mami2);
|
pc.addAdvice(mami2);
|
||||||
pc.addAdvice(mami3);
|
pc.addAdvice(mami3);
|
||||||
|
|
@ -1471,7 +1471,7 @@ public abstract class AbstractAopProxyTests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SummingAfterAdvice aa = new SummingAfterAdvice();
|
SummingAfterAdvice aa = new SummingAfterAdvice();
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
Advisor matchesInt = new StaticMethodMatcherPointcutAdvisor(aa) {
|
Advisor matchesInt = new StaticMethodMatcherPointcutAdvisor(aa) {
|
||||||
public boolean matches(Method m, Class<?> targetClass) {
|
public boolean matches(Method m, Class<?> targetClass) {
|
||||||
return m.getReturnType() == int.class;
|
return m.getReturnType() == int.class;
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.springframework.aop.framework;
|
package org.springframework.aop.framework;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
* @author Rod Johnson
|
* @author Rod Johnson
|
||||||
*/
|
*/
|
||||||
public class DefaultLockable implements Lockable {
|
public class DefaultLockable implements Lockable {
|
||||||
|
|
||||||
private boolean locked;
|
private boolean locked;
|
||||||
|
|
||||||
public void lock() {
|
public void lock() {
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ import org.springframework.util.SerializationTestUtils;
|
||||||
* @since 13.03.2003
|
* @since 13.03.2003
|
||||||
*/
|
*/
|
||||||
public class ProxyFactoryBeanTests extends TestCase {
|
public class ProxyFactoryBeanTests extends TestCase {
|
||||||
|
|
||||||
private BeanFactory factory;
|
private BeanFactory factory;
|
||||||
|
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
|
|
@ -72,7 +72,7 @@ public class ProxyFactoryBeanTests extends TestCase {
|
||||||
ITestBean test1 = (ITestBean) factory.getBean("test1");
|
ITestBean test1 = (ITestBean) factory.getBean("test1");
|
||||||
assertTrue("test1 is a dynamic proxy", Proxy.isProxyClass(test1.getClass()));
|
assertTrue("test1 is a dynamic proxy", Proxy.isProxyClass(test1.getClass()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testIsDynamicProxyWhenInterfaceSpecifiedForPrototype() {
|
public void testIsDynamicProxyWhenInterfaceSpecifiedForPrototype() {
|
||||||
ITestBean test1 = (ITestBean) factory.getBean("test2");
|
ITestBean test1 = (ITestBean) factory.getBean("test2");
|
||||||
assertTrue("test2 is a dynamic proxy", Proxy.isProxyClass(test1.getClass()));
|
assertTrue("test2 is a dynamic proxy", Proxy.isProxyClass(test1.getClass()));
|
||||||
|
|
@ -97,7 +97,7 @@ public class ProxyFactoryBeanTests extends TestCase {
|
||||||
// Now with conversion from arbitrary bean to a TargetSource
|
// Now with conversion from arbitrary bean to a TargetSource
|
||||||
testDoubleTargetSourceIsRejected("arbitraryTarget");
|
testDoubleTargetSourceIsRejected("arbitraryTarget");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testDoubleTargetSourceIsRejected(String name) {
|
private void testDoubleTargetSourceIsRejected(String name) {
|
||||||
try {
|
try {
|
||||||
BeanFactory bf = new XmlBeanFactory(new ClassPathResource("proxyFactoryDoubleTargetSourceTests.xml", getClass()));
|
BeanFactory bf = new XmlBeanFactory(new ClassPathResource("proxyFactoryDoubleTargetSourceTests.xml", getClass()));
|
||||||
|
|
@ -111,7 +111,7 @@ public class ProxyFactoryBeanTests extends TestCase {
|
||||||
assertTrue(aex.getMessage().indexOf("TargetSource") != -1);
|
assertTrue(aex.getMessage().indexOf("TargetSource") != -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testTargetSourceNotAtEndOfInterceptorNamesIsRejected() {
|
public void testTargetSourceNotAtEndOfInterceptorNamesIsRejected() {
|
||||||
try {
|
try {
|
||||||
BeanFactory bf = new XmlBeanFactory(new ClassPathResource("proxyFactoryTargetSourceNotLastTests.xml", getClass()));
|
BeanFactory bf = new XmlBeanFactory(new ClassPathResource("proxyFactoryTargetSourceNotLastTests.xml", getClass()));
|
||||||
|
|
@ -124,22 +124,22 @@ public class ProxyFactoryBeanTests extends TestCase {
|
||||||
assertTrue(aex.getMessage().indexOf("interceptorNames") != -1);
|
assertTrue(aex.getMessage().indexOf("interceptorNames") != -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetObjectTypeWithDirectTarget() {
|
public void testGetObjectTypeWithDirectTarget() {
|
||||||
BeanFactory bf = new XmlBeanFactory(new ClassPathResource("proxyFactoryTargetSourceTests.xml", getClass()));
|
BeanFactory bf = new XmlBeanFactory(new ClassPathResource("proxyFactoryTargetSourceTests.xml", getClass()));
|
||||||
|
|
||||||
// We have a counting before advice here
|
// We have a counting before advice here
|
||||||
CountingBeforeAdvice cba = (CountingBeforeAdvice) bf.getBean("countingBeforeAdvice");
|
CountingBeforeAdvice cba = (CountingBeforeAdvice) bf.getBean("countingBeforeAdvice");
|
||||||
assertEquals(0, cba.getCalls());
|
assertEquals(0, cba.getCalls());
|
||||||
|
|
||||||
ITestBean tb = (ITestBean) bf.getBean("directTarget");
|
ITestBean tb = (ITestBean) bf.getBean("directTarget");
|
||||||
assertTrue(tb.getName().equals("Adam"));
|
assertTrue(tb.getName().equals("Adam"));
|
||||||
assertEquals(1, cba.getCalls());
|
assertEquals(1, cba.getCalls());
|
||||||
|
|
||||||
ProxyFactoryBean pfb = (ProxyFactoryBean) bf.getBean("&directTarget");
|
ProxyFactoryBean pfb = (ProxyFactoryBean) bf.getBean("&directTarget");
|
||||||
assertTrue("Has correct object type", TestBean.class.isAssignableFrom(pfb.getObjectType()));
|
assertTrue("Has correct object type", TestBean.class.isAssignableFrom(pfb.getObjectType()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetObjectTypeWithTargetViaTargetSource() {
|
public void testGetObjectTypeWithTargetViaTargetSource() {
|
||||||
BeanFactory bf = new XmlBeanFactory(new ClassPathResource("proxyFactoryTargetSourceTests.xml", getClass()));
|
BeanFactory bf = new XmlBeanFactory(new ClassPathResource("proxyFactoryTargetSourceTests.xml", getClass()));
|
||||||
ITestBean tb = (ITestBean) bf.getBean("viaTargetSource");
|
ITestBean tb = (ITestBean) bf.getBean("viaTargetSource");
|
||||||
|
|
@ -147,7 +147,7 @@ public class ProxyFactoryBeanTests extends TestCase {
|
||||||
ProxyFactoryBean pfb = (ProxyFactoryBean) bf.getBean("&viaTargetSource");
|
ProxyFactoryBean pfb = (ProxyFactoryBean) bf.getBean("&viaTargetSource");
|
||||||
assertTrue("Has correct object type", TestBean.class.isAssignableFrom(pfb.getObjectType()));
|
assertTrue("Has correct object type", TestBean.class.isAssignableFrom(pfb.getObjectType()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetObjectTypeWithNoTargetOrTargetSource() {
|
public void testGetObjectTypeWithNoTargetOrTargetSource() {
|
||||||
BeanFactory bf = new XmlBeanFactory(new ClassPathResource("proxyFactoryTargetSourceTests.xml", getClass()));
|
BeanFactory bf = new XmlBeanFactory(new ClassPathResource("proxyFactoryTargetSourceTests.xml", getClass()));
|
||||||
|
|
||||||
|
|
@ -162,7 +162,7 @@ public class ProxyFactoryBeanTests extends TestCase {
|
||||||
FactoryBean pfb = (ProxyFactoryBean) bf.getBean("&noTarget");
|
FactoryBean pfb = (ProxyFactoryBean) bf.getBean("&noTarget");
|
||||||
assertTrue("Has correct object type", ITestBean.class.isAssignableFrom(pfb.getObjectType()));
|
assertTrue("Has correct object type", ITestBean.class.isAssignableFrom(pfb.getObjectType()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The instances are equal, but do not have object identity.
|
* The instances are equal, but do not have object identity.
|
||||||
* Interceptors and interfaces and the target are the same.
|
* Interceptors and interfaces and the target are the same.
|
||||||
|
|
@ -189,7 +189,7 @@ public class ProxyFactoryBeanTests extends TestCase {
|
||||||
assertEquals(test1_1.getAge(), test1.getAge());
|
assertEquals(test1_1.getAge(), test1.getAge());
|
||||||
assertEquals(di.getCount(), 3);
|
assertEquals(di.getCount(), 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPrototypeInstancesAreNotEqual() {
|
public void testPrototypeInstancesAreNotEqual() {
|
||||||
assertTrue("Has correct object type", ITestBean.class.isAssignableFrom(factory.getType("prototype")));
|
assertTrue("Has correct object type", ITestBean.class.isAssignableFrom(factory.getType("prototype")));
|
||||||
ITestBean test2 = (ITestBean) factory.getBean("prototype");
|
ITestBean test2 = (ITestBean) factory.getBean("prototype");
|
||||||
|
|
@ -207,9 +207,9 @@ public class ProxyFactoryBeanTests extends TestCase {
|
||||||
private Object testPrototypeInstancesAreIndependent(String beanName) {
|
private Object testPrototypeInstancesAreIndependent(String beanName) {
|
||||||
// Initial count value set in bean factory XML
|
// Initial count value set in bean factory XML
|
||||||
int INITIAL_COUNT = 10;
|
int INITIAL_COUNT = 10;
|
||||||
|
|
||||||
BeanFactory bf = new XmlBeanFactory(new ClassPathResource("prototypeTests.xml", getClass()));
|
BeanFactory bf = new XmlBeanFactory(new ClassPathResource("prototypeTests.xml", getClass()));
|
||||||
|
|
||||||
// Check it works without AOP
|
// Check it works without AOP
|
||||||
SideEffectBean raw = (SideEffectBean) bf.getBean("prototypeTarget");
|
SideEffectBean raw = (SideEffectBean) bf.getBean("prototypeTarget");
|
||||||
assertEquals(INITIAL_COUNT, raw.getCount() );
|
assertEquals(INITIAL_COUNT, raw.getCount() );
|
||||||
|
|
@ -217,7 +217,7 @@ public class ProxyFactoryBeanTests extends TestCase {
|
||||||
assertEquals(INITIAL_COUNT+1, raw.getCount() );
|
assertEquals(INITIAL_COUNT+1, raw.getCount() );
|
||||||
raw = (SideEffectBean) bf.getBean("prototypeTarget");
|
raw = (SideEffectBean) bf.getBean("prototypeTarget");
|
||||||
assertEquals(INITIAL_COUNT, raw.getCount() );
|
assertEquals(INITIAL_COUNT, raw.getCount() );
|
||||||
|
|
||||||
// Now try with advised instances
|
// Now try with advised instances
|
||||||
SideEffectBean prototype2FirstInstance = (SideEffectBean) bf.getBean(beanName);
|
SideEffectBean prototype2FirstInstance = (SideEffectBean) bf.getBean(beanName);
|
||||||
assertEquals(INITIAL_COUNT, prototype2FirstInstance.getCount() );
|
assertEquals(INITIAL_COUNT, prototype2FirstInstance.getCount() );
|
||||||
|
|
@ -228,16 +228,16 @@ public class ProxyFactoryBeanTests extends TestCase {
|
||||||
assertFalse("Prototypes are not ==", prototype2FirstInstance == prototype2SecondInstance);
|
assertFalse("Prototypes are not ==", prototype2FirstInstance == prototype2SecondInstance);
|
||||||
assertEquals(INITIAL_COUNT, prototype2SecondInstance.getCount() );
|
assertEquals(INITIAL_COUNT, prototype2SecondInstance.getCount() );
|
||||||
assertEquals(INITIAL_COUNT + 1, prototype2FirstInstance.getCount() );
|
assertEquals(INITIAL_COUNT + 1, prototype2FirstInstance.getCount() );
|
||||||
|
|
||||||
return prototype2FirstInstance;
|
return prototype2FirstInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCglibPrototypeInstance() {
|
public void testCglibPrototypeInstance() {
|
||||||
Object prototype = testPrototypeInstancesAreIndependent("cglibPrototype");
|
Object prototype = testPrototypeInstancesAreIndependent("cglibPrototype");
|
||||||
assertTrue("It's a cglib proxy", AopUtils.isCglibProxy(prototype));
|
assertTrue("It's a cglib proxy", AopUtils.isCglibProxy(prototype));
|
||||||
assertFalse("It's not a dynamic proxy", AopUtils.isJdkDynamicProxy(prototype));
|
assertFalse("It's not a dynamic proxy", AopUtils.isJdkDynamicProxy(prototype));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test invoker is automatically added to manipulate target.
|
* Test invoker is automatically added to manipulate target.
|
||||||
*/
|
*/
|
||||||
|
|
@ -262,7 +262,7 @@ public class ProxyFactoryBeanTests extends TestCase {
|
||||||
ITestBean tb = (ITestBean) factory.getBean("test1");
|
ITestBean tb = (ITestBean) factory.getBean("test1");
|
||||||
// no exception
|
// no exception
|
||||||
tb.hashCode();
|
tb.hashCode();
|
||||||
|
|
||||||
final Exception ex = new UnsupportedOperationException("invoke");
|
final Exception ex = new UnsupportedOperationException("invoke");
|
||||||
// Add evil interceptor to head of list
|
// Add evil interceptor to head of list
|
||||||
config.addAdvice(0, new MethodInterceptor() {
|
config.addAdvice(0, new MethodInterceptor() {
|
||||||
|
|
@ -271,7 +271,7 @@ public class ProxyFactoryBeanTests extends TestCase {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
assertEquals("Have correct advisor count", 2, config.getAdvisors().length);
|
assertEquals("Have correct advisor count", 2, config.getAdvisors().length);
|
||||||
|
|
||||||
tb = (ITestBean) factory.getBean("test1");
|
tb = (ITestBean) factory.getBean("test1");
|
||||||
try {
|
try {
|
||||||
// Will fail now
|
// Will fail now
|
||||||
|
|
@ -282,14 +282,14 @@ public class ProxyFactoryBeanTests extends TestCase {
|
||||||
assertTrue(thrown == ex);
|
assertTrue(thrown == ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class DependsOnITestBean {
|
public static class DependsOnITestBean {
|
||||||
public final ITestBean tb;
|
public final ITestBean tb;
|
||||||
public DependsOnITestBean(ITestBean tb) {
|
public DependsOnITestBean(ITestBean tb) {
|
||||||
this.tb = tb;
|
this.tb = tb;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test that inner bean for target means that we can use
|
* Test that inner bean for target means that we can use
|
||||||
* autowire without ambiguity from target and proxy
|
* autowire without ambiguity from target and proxy
|
||||||
|
|
@ -302,7 +302,7 @@ public class ProxyFactoryBeanTests extends TestCase {
|
||||||
DependsOnITestBean doit = (DependsOnITestBean) bf.getBean("autowireCheck");
|
DependsOnITestBean doit = (DependsOnITestBean) bf.getBean("autowireCheck");
|
||||||
assertSame(itb, doit.tb);
|
assertSame(itb, doit.tb);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Try adding and removing interfaces and interceptors on prototype.
|
* Try adding and removing interfaces and interceptors on prototype.
|
||||||
* Changes will only affect future references obtained from the factory.
|
* Changes will only affect future references obtained from the factory.
|
||||||
|
|
@ -315,7 +315,7 @@ public class ProxyFactoryBeanTests extends TestCase {
|
||||||
}
|
}
|
||||||
catch (ClassCastException ex) {
|
catch (ClassCastException ex) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ProxyFactoryBean config = (ProxyFactoryBean) factory.getBean("&test2");
|
ProxyFactoryBean config = (ProxyFactoryBean) factory.getBean("&test2");
|
||||||
long time = 666L;
|
long time = 666L;
|
||||||
TimestampIntroductionInterceptor ti = new TimestampIntroductionInterceptor();
|
TimestampIntroductionInterceptor ti = new TimestampIntroductionInterceptor();
|
||||||
|
|
@ -324,28 +324,28 @@ public class ProxyFactoryBeanTests extends TestCase {
|
||||||
int oldCount = config.getAdvisors().length;
|
int oldCount = config.getAdvisors().length;
|
||||||
config.addAdvisor(0, new DefaultIntroductionAdvisor(ti, TimeStamped.class));
|
config.addAdvisor(0, new DefaultIntroductionAdvisor(ti, TimeStamped.class));
|
||||||
assertTrue(config.getAdvisors().length == oldCount + 1);
|
assertTrue(config.getAdvisors().length == oldCount + 1);
|
||||||
|
|
||||||
TimeStamped ts = (TimeStamped) factory.getBean("test2");
|
TimeStamped ts = (TimeStamped) factory.getBean("test2");
|
||||||
assertEquals(time, ts.getTimeStamp());
|
assertEquals(time, ts.getTimeStamp());
|
||||||
|
|
||||||
// Can remove
|
// Can remove
|
||||||
config.removeAdvice(ti);
|
config.removeAdvice(ti);
|
||||||
assertTrue(config.getAdvisors().length == oldCount);
|
assertTrue(config.getAdvisors().length == oldCount);
|
||||||
|
|
||||||
// Check no change on existing object reference
|
// Check no change on existing object reference
|
||||||
assertTrue(ts.getTimeStamp() == time);
|
assertTrue(ts.getTimeStamp() == time);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ts = (TimeStamped) factory.getBean("test2");
|
ts = (TimeStamped) factory.getBean("test2");
|
||||||
fail("Should no longer implement TimeStamped");
|
fail("Should no longer implement TimeStamped");
|
||||||
}
|
}
|
||||||
catch (ClassCastException ex) {
|
catch (ClassCastException ex) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now check non-effect of removing interceptor that isn't there
|
// Now check non-effect of removing interceptor that isn't there
|
||||||
config.removeAdvice(new DebugInterceptor());
|
config.removeAdvice(new DebugInterceptor());
|
||||||
assertTrue(config.getAdvisors().length == oldCount);
|
assertTrue(config.getAdvisors().length == oldCount);
|
||||||
|
|
||||||
ITestBean it = (ITestBean) ts;
|
ITestBean it = (ITestBean) ts;
|
||||||
DebugInterceptor debugInterceptor = new DebugInterceptor();
|
DebugInterceptor debugInterceptor = new DebugInterceptor();
|
||||||
config.addAdvice(0, debugInterceptor);
|
config.addAdvice(0, debugInterceptor);
|
||||||
|
|
@ -357,15 +357,15 @@ public class ProxyFactoryBeanTests extends TestCase {
|
||||||
assertEquals(1, debugInterceptor.getCount());
|
assertEquals(1, debugInterceptor.getCount());
|
||||||
config.removeAdvice(debugInterceptor);
|
config.removeAdvice(debugInterceptor);
|
||||||
it.getSpouse();
|
it.getSpouse();
|
||||||
|
|
||||||
// Still invoked wiht old reference
|
// Still invoked wiht old reference
|
||||||
assertEquals(2, debugInterceptor.getCount());
|
assertEquals(2, debugInterceptor.getCount());
|
||||||
|
|
||||||
// not invoked with new object
|
// not invoked with new object
|
||||||
it = (ITestBean) factory.getBean("test2");
|
it = (ITestBean) factory.getBean("test2");
|
||||||
it.getSpouse();
|
it.getSpouse();
|
||||||
assertEquals(2, debugInterceptor.getCount());
|
assertEquals(2, debugInterceptor.getCount());
|
||||||
|
|
||||||
// Our own timestamped reference should still work
|
// Our own timestamped reference should still work
|
||||||
assertEquals(time, ts.getTimeStamp());
|
assertEquals(time, ts.getTimeStamp());
|
||||||
}
|
}
|
||||||
|
|
@ -400,7 +400,7 @@ public class ProxyFactoryBeanTests extends TestCase {
|
||||||
assertTrue(PointcutForVoid.methodNames.get(0).equals("setAge"));
|
assertTrue(PointcutForVoid.methodNames.get(0).equals("setAge"));
|
||||||
assertTrue(PointcutForVoid.methodNames.get(1).equals("setName"));
|
assertTrue(PointcutForVoid.methodNames.get(1).equals("setName"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCanAddThrowsAdviceWithoutAdvisor() throws Throwable {
|
public void testCanAddThrowsAdviceWithoutAdvisor() throws Throwable {
|
||||||
BeanFactory f = new XmlBeanFactory(new ClassPathResource("throwsAdvice.xml", getClass()));
|
BeanFactory f = new XmlBeanFactory(new ClassPathResource("throwsAdvice.xml", getClass()));
|
||||||
MyThrowsHandler th = (MyThrowsHandler) f.getBean("throwsAdvice");
|
MyThrowsHandler th = (MyThrowsHandler) f.getBean("throwsAdvice");
|
||||||
|
|
@ -423,7 +423,7 @@ public class ProxyFactoryBeanTests extends TestCase {
|
||||||
}
|
}
|
||||||
// No throws handler method: count should still be 0
|
// No throws handler method: count should still be 0
|
||||||
assertEquals(0, th.getCalls());
|
assertEquals(0, th.getCalls());
|
||||||
|
|
||||||
// Handler knows how to handle this exception
|
// Handler knows how to handle this exception
|
||||||
expected = new FileNotFoundException();
|
expected = new FileNotFoundException();
|
||||||
try {
|
try {
|
||||||
|
|
@ -449,7 +449,7 @@ public class ProxyFactoryBeanTests extends TestCase {
|
||||||
// Ok
|
// Ok
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testNoInterceptorNamesWithTarget() {
|
public void testNoInterceptorNamesWithTarget() {
|
||||||
ITestBean tb = (ITestBean) factory.getBean("noInterceptorNamesWithoutTarget");
|
ITestBean tb = (ITestBean) factory.getBean("noInterceptorNamesWithoutTarget");
|
||||||
}
|
}
|
||||||
|
|
@ -489,17 +489,17 @@ public class ProxyFactoryBeanTests extends TestCase {
|
||||||
public void testGlobalsCanAddAspectInterfaces() {
|
public void testGlobalsCanAddAspectInterfaces() {
|
||||||
AddedGlobalInterface agi = (AddedGlobalInterface) factory.getBean("autoInvoker");
|
AddedGlobalInterface agi = (AddedGlobalInterface) factory.getBean("autoInvoker");
|
||||||
assertTrue(agi.globalsAdded() == -1);
|
assertTrue(agi.globalsAdded() == -1);
|
||||||
|
|
||||||
ProxyFactoryBean pfb = (ProxyFactoryBean) factory.getBean("&validGlobals");
|
ProxyFactoryBean pfb = (ProxyFactoryBean) factory.getBean("&validGlobals");
|
||||||
// Trigger lazy initialization.
|
// Trigger lazy initialization.
|
||||||
pfb.getObject();
|
pfb.getObject();
|
||||||
// 2 globals + 2 explicit
|
// 2 globals + 2 explicit
|
||||||
assertEquals("Have 2 globals and 2 explicit advisors", 3, pfb.getAdvisors().length);
|
assertEquals("Have 2 globals and 2 explicit advisors", 3, pfb.getAdvisors().length);
|
||||||
|
|
||||||
ApplicationListener l = (ApplicationListener) factory.getBean("validGlobals");
|
ApplicationListener l = (ApplicationListener) factory.getBean("validGlobals");
|
||||||
agi = (AddedGlobalInterface) l;
|
agi = (AddedGlobalInterface) l;
|
||||||
assertTrue(agi.globalsAdded() == -1);
|
assertTrue(agi.globalsAdded() == -1);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
agi = (AddedGlobalInterface) factory.getBean("test1");
|
agi = (AddedGlobalInterface) factory.getBean("test1");
|
||||||
fail("Aspect interface should't be implemeneted without globals");
|
fail("Aspect interface should't be implemeneted without globals");
|
||||||
|
|
@ -516,14 +516,14 @@ public class ProxyFactoryBeanTests extends TestCase {
|
||||||
assertEquals(p, p2);
|
assertEquals(p, p2);
|
||||||
assertNotSame(p, p2);
|
assertNotSame(p, p2);
|
||||||
assertEquals("serializableSingleton", p2.getName());
|
assertEquals("serializableSingleton", p2.getName());
|
||||||
|
|
||||||
// Add unserializable advice
|
// Add unserializable advice
|
||||||
Advice nop = new NopInterceptor();
|
Advice nop = new NopInterceptor();
|
||||||
((Advised) p).addAdvice(nop);
|
((Advised) p).addAdvice(nop);
|
||||||
// Check it still works
|
// Check it still works
|
||||||
assertEquals(p2.getName(), p2.getName());
|
assertEquals(p2.getName(), p2.getName());
|
||||||
assertFalse("Not serializable because an interceptor isn't serializable", SerializationTestUtils.isSerializable(p));
|
assertFalse("Not serializable because an interceptor isn't serializable", SerializationTestUtils.isSerializable(p));
|
||||||
|
|
||||||
// Remove offending interceptor...
|
// Remove offending interceptor...
|
||||||
assertTrue(((Advised) p).removeAdvice(nop));
|
assertTrue(((Advised) p).removeAdvice(nop));
|
||||||
assertTrue("Serializable again because offending interceptor was removed", SerializationTestUtils.isSerializable(p));
|
assertTrue("Serializable again because offending interceptor was removed", SerializationTestUtils.isSerializable(p));
|
||||||
|
|
@ -614,7 +614,7 @@ public class ProxyFactoryBeanTests extends TestCase {
|
||||||
fail("did not expect LockedException");
|
fail("did not expect LockedException");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple test of a ProxyFactoryBean that has an inner bean as target that specifies autowiring.
|
* Simple test of a ProxyFactoryBean that has an inner bean as target that specifies autowiring.
|
||||||
* Checks for correct use of getType() by bean factory.
|
* Checks for correct use of getType() by bean factory.
|
||||||
|
|
@ -623,12 +623,12 @@ public class ProxyFactoryBeanTests extends TestCase {
|
||||||
BeanFactory bf = new XmlBeanFactory(new ClassPathResource("proxyFactoryBeanAutowiringTests.xml", getClass()));
|
BeanFactory bf = new XmlBeanFactory(new ClassPathResource("proxyFactoryBeanAutowiringTests.xml", getClass()));
|
||||||
bf.getBean("testBean");
|
bf.getBean("testBean");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testFrozenFactoryBean() {
|
public void testFrozenFactoryBean() {
|
||||||
BeanFactory bf = new XmlBeanFactory(new ClassPathResource("frozenProxyFactoryBean.xml", getClass()));
|
BeanFactory bf = new XmlBeanFactory(new ClassPathResource("frozenProxyFactoryBean.xml", getClass()));
|
||||||
|
|
||||||
Advised advised = (Advised)bf.getBean("frozen");
|
Advised advised = (Advised)bf.getBean("frozen");
|
||||||
assertTrue("The proxy should be frozen", advised.isFrozen());
|
assertTrue("The proxy should be frozen", advised.isFrozen());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDetectsInterfaces() throws Exception {
|
public void testDetectsInterfaces() throws Exception {
|
||||||
|
|
@ -643,13 +643,13 @@ public class ProxyFactoryBeanTests extends TestCase {
|
||||||
* Fires only on void methods. Saves list of methods intercepted.
|
* Fires only on void methods. Saves list of methods intercepted.
|
||||||
*/
|
*/
|
||||||
public static class PointcutForVoid extends DefaultPointcutAdvisor {
|
public static class PointcutForVoid extends DefaultPointcutAdvisor {
|
||||||
|
|
||||||
public static List methodNames = new LinkedList();
|
public static List methodNames = new LinkedList();
|
||||||
|
|
||||||
public static void reset() {
|
public static void reset() {
|
||||||
methodNames.clear();
|
methodNames.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public PointcutForVoid() {
|
public PointcutForVoid() {
|
||||||
setAdvice(new MethodInterceptor() {
|
setAdvice(new MethodInterceptor() {
|
||||||
public Object invoke(MethodInvocation invocation) throws Throwable {
|
public Object invoke(MethodInvocation invocation) throws Throwable {
|
||||||
|
|
@ -695,7 +695,7 @@ public class ProxyFactoryBeanTests extends TestCase {
|
||||||
|
|
||||||
|
|
||||||
public static class GlobalIntroductionAdvice implements IntroductionAdvisor {
|
public static class GlobalIntroductionAdvice implements IntroductionAdvisor {
|
||||||
|
|
||||||
private IntroductionInterceptor gi = new GlobalAspectInterfaceInterceptor();
|
private IntroductionInterceptor gi = new GlobalAspectInterfaceInterceptor();
|
||||||
|
|
||||||
public ClassFilter getClassFilter() {
|
public ClassFilter getClassFilter() {
|
||||||
|
|
@ -713,9 +713,9 @@ public class ProxyFactoryBeanTests extends TestCase {
|
||||||
public boolean isPerInstance() {
|
public boolean isPerInstance() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void validateInterfaces() {
|
public void validateInterfaces() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
|
@ -33,24 +33,24 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||||
*/
|
*/
|
||||||
public class AdvisorAdapterRegistrationTests {
|
public class AdvisorAdapterRegistrationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAdvisorAdapterRegistrationManagerNotPresentInContext() {
|
public void testAdvisorAdapterRegistrationManagerNotPresentInContext() {
|
||||||
ApplicationContext ctx = new ClassPathXmlApplicationContext("/org/springframework/aop/framework/adapter/withoutBPPContext.xml");
|
ApplicationContext ctx = new ClassPathXmlApplicationContext("/org/springframework/aop/framework/adapter/withoutBPPContext.xml");
|
||||||
ITestBean tb = (ITestBean) ctx.getBean("testBean");
|
ITestBean tb = (ITestBean) ctx.getBean("testBean");
|
||||||
// just invoke any method to see if advice fired
|
// just invoke any method to see if advice fired
|
||||||
try {
|
try {
|
||||||
tb.getName();
|
tb.getName();
|
||||||
fail("Should throw UnknownAdviceTypeException");
|
fail("Should throw UnknownAdviceTypeException");
|
||||||
}
|
}
|
||||||
catch (UnknownAdviceTypeException ex) {
|
catch (UnknownAdviceTypeException ex) {
|
||||||
// expected
|
// expected
|
||||||
assertEquals(0, getAdviceImpl(tb).getInvocationCounter());
|
assertEquals(0, getAdviceImpl(tb).getInvocationCounter());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAdvisorAdapterRegistrationManagerPresentInContext() {
|
public void testAdvisorAdapterRegistrationManagerPresentInContext() {
|
||||||
ApplicationContext ctx = new ClassPathXmlApplicationContext("/org/springframework/aop/framework/adapter/withBPPContext.xml");
|
ApplicationContext ctx = new ClassPathXmlApplicationContext("/org/springframework/aop/framework/adapter/withBPPContext.xml");
|
||||||
ITestBean tb = (ITestBean) ctx.getBean("testBean");
|
ITestBean tb = (ITestBean) ctx.getBean("testBean");
|
||||||
// just invoke any method to see if advice fired
|
// just invoke any method to see if advice fired
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
|
@ -28,87 +28,87 @@ import org.easymock.MockControl;
|
||||||
*/
|
*/
|
||||||
public final class DebugInterceptorTests extends TestCase {
|
public final class DebugInterceptorTests extends TestCase {
|
||||||
|
|
||||||
public void testSunnyDayPathLogsCorrectly() throws Throwable {
|
public void testSunnyDayPathLogsCorrectly() throws Throwable {
|
||||||
MockControl mockLog = MockControl.createControl(Log.class);
|
MockControl mockLog = MockControl.createControl(Log.class);
|
||||||
final Log log = (Log) mockLog.getMock();
|
final Log log = (Log) mockLog.getMock();
|
||||||
|
|
||||||
MockControl mockMethodInvocation = MockControl.createControl(MethodInvocation.class);
|
MockControl mockMethodInvocation = MockControl.createControl(MethodInvocation.class);
|
||||||
MethodInvocation methodInvocation = (MethodInvocation) mockMethodInvocation.getMock();
|
MethodInvocation methodInvocation = (MethodInvocation) mockMethodInvocation.getMock();
|
||||||
|
|
||||||
log.isTraceEnabled();
|
log.isTraceEnabled();
|
||||||
mockLog.setReturnValue(true);
|
mockLog.setReturnValue(true);
|
||||||
log.trace("Some tracing output");
|
log.trace("Some tracing output");
|
||||||
mockLog.setMatcher(MockControl.ALWAYS_MATCHER);
|
mockLog.setMatcher(MockControl.ALWAYS_MATCHER);
|
||||||
methodInvocation.proceed();
|
methodInvocation.proceed();
|
||||||
mockMethodInvocation.setReturnValue(null);
|
mockMethodInvocation.setReturnValue(null);
|
||||||
log.trace("Some more tracing output");
|
log.trace("Some more tracing output");
|
||||||
mockLog.setMatcher(MockControl.ALWAYS_MATCHER);
|
mockLog.setMatcher(MockControl.ALWAYS_MATCHER);
|
||||||
mockLog.setVoidCallable();
|
mockLog.setVoidCallable();
|
||||||
|
|
||||||
mockMethodInvocation.replay();
|
mockMethodInvocation.replay();
|
||||||
mockLog.replay();
|
mockLog.replay();
|
||||||
|
|
||||||
DebugInterceptor interceptor = new StubDebugInterceptor(log);
|
DebugInterceptor interceptor = new StubDebugInterceptor(log);
|
||||||
interceptor.invoke(methodInvocation);
|
interceptor.invoke(methodInvocation);
|
||||||
checkCallCountTotal(interceptor);
|
checkCallCountTotal(interceptor);
|
||||||
|
|
||||||
mockLog.verify();
|
mockLog.verify();
|
||||||
mockMethodInvocation.verify();
|
mockMethodInvocation.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testExceptionPathStillLogsCorrectly() throws Throwable {
|
public void testExceptionPathStillLogsCorrectly() throws Throwable {
|
||||||
MockControl mockLog = MockControl.createControl(Log.class);
|
MockControl mockLog = MockControl.createControl(Log.class);
|
||||||
final Log log = (Log) mockLog.getMock();
|
final Log log = (Log) mockLog.getMock();
|
||||||
|
|
||||||
MockControl mockMethodInvocation = MockControl.createControl(MethodInvocation.class);
|
MockControl mockMethodInvocation = MockControl.createControl(MethodInvocation.class);
|
||||||
final MethodInvocation methodInvocation = (MethodInvocation) mockMethodInvocation.getMock();
|
final MethodInvocation methodInvocation = (MethodInvocation) mockMethodInvocation.getMock();
|
||||||
|
|
||||||
log.isTraceEnabled();
|
log.isTraceEnabled();
|
||||||
mockLog.setReturnValue(true);
|
mockLog.setReturnValue(true);
|
||||||
log.trace("Some tracing output");
|
log.trace("Some tracing output");
|
||||||
mockLog.setMatcher(MockControl.ALWAYS_MATCHER);
|
mockLog.setMatcher(MockControl.ALWAYS_MATCHER);
|
||||||
methodInvocation.proceed();
|
methodInvocation.proceed();
|
||||||
IllegalArgumentException exception = new IllegalArgumentException();
|
IllegalArgumentException exception = new IllegalArgumentException();
|
||||||
mockMethodInvocation.setThrowable(exception);
|
mockMethodInvocation.setThrowable(exception);
|
||||||
log.trace("Some more tracing output", exception);
|
log.trace("Some more tracing output", exception);
|
||||||
mockLog.setMatcher(MockControl.ALWAYS_MATCHER);
|
mockLog.setMatcher(MockControl.ALWAYS_MATCHER);
|
||||||
mockLog.setVoidCallable();
|
mockLog.setVoidCallable();
|
||||||
|
|
||||||
mockMethodInvocation.replay();
|
mockMethodInvocation.replay();
|
||||||
mockLog.replay();
|
mockLog.replay();
|
||||||
|
|
||||||
DebugInterceptor interceptor = new StubDebugInterceptor(log);
|
DebugInterceptor interceptor = new StubDebugInterceptor(log);
|
||||||
try {
|
try {
|
||||||
interceptor.invoke(methodInvocation);
|
interceptor.invoke(methodInvocation);
|
||||||
fail("Must have propagated the IllegalArgumentException.");
|
fail("Must have propagated the IllegalArgumentException.");
|
||||||
} catch (IllegalArgumentException expected) {
|
} catch (IllegalArgumentException expected) {
|
||||||
}
|
}
|
||||||
checkCallCountTotal(interceptor);
|
checkCallCountTotal(interceptor);
|
||||||
|
|
||||||
mockLog.verify();
|
mockLog.verify();
|
||||||
mockMethodInvocation.verify();
|
mockMethodInvocation.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkCallCountTotal(DebugInterceptor interceptor) {
|
private void checkCallCountTotal(DebugInterceptor interceptor) {
|
||||||
assertEquals("Intercepted call count not being incremented correctly", 1, interceptor.getCount());
|
assertEquals("Intercepted call count not being incremented correctly", 1, interceptor.getCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static final class StubDebugInterceptor extends DebugInterceptor {
|
private static final class StubDebugInterceptor extends DebugInterceptor {
|
||||||
|
|
||||||
private final Log log;
|
private final Log log;
|
||||||
|
|
||||||
|
|
||||||
public StubDebugInterceptor(Log log) {
|
public StubDebugInterceptor(Log log) {
|
||||||
super(true);
|
super(true);
|
||||||
this.log = log;
|
this.log = log;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected Log getLoggerForInvocation(MethodInvocation invocation) {
|
protected Log getLoggerForInvocation(MethodInvocation invocation) {
|
||||||
return log;
|
return log;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
|
@ -30,72 +30,72 @@ import java.lang.reflect.Method;
|
||||||
*/
|
*/
|
||||||
public final class SimpleTraceInterceptorTests extends TestCase {
|
public final class SimpleTraceInterceptorTests extends TestCase {
|
||||||
|
|
||||||
public void testSunnyDayPathLogsCorrectly() throws Throwable {
|
public void testSunnyDayPathLogsCorrectly() throws Throwable {
|
||||||
MockControl mockLog = MockControl.createControl(Log.class);
|
MockControl mockLog = MockControl.createControl(Log.class);
|
||||||
Log log = (Log) mockLog.getMock();
|
Log log = (Log) mockLog.getMock();
|
||||||
|
|
||||||
MockControl mockMethodInvocation = MockControl.createControl(MethodInvocation.class);
|
MockControl mockMethodInvocation = MockControl.createControl(MethodInvocation.class);
|
||||||
MethodInvocation methodInvocation = (MethodInvocation) mockMethodInvocation.getMock();
|
MethodInvocation methodInvocation = (MethodInvocation) mockMethodInvocation.getMock();
|
||||||
|
|
||||||
Method toString = String.class.getMethod("toString", new Class[]{});
|
Method toString = String.class.getMethod("toString", new Class[]{});
|
||||||
|
|
||||||
methodInvocation.getMethod();
|
methodInvocation.getMethod();
|
||||||
mockMethodInvocation.setReturnValue(toString);
|
mockMethodInvocation.setReturnValue(toString);
|
||||||
methodInvocation.getThis();
|
methodInvocation.getThis();
|
||||||
mockMethodInvocation.setReturnValue(this);
|
mockMethodInvocation.setReturnValue(this);
|
||||||
log.trace("Some tracing output");
|
log.trace("Some tracing output");
|
||||||
mockLog.setMatcher(MockControl.ALWAYS_MATCHER);
|
mockLog.setMatcher(MockControl.ALWAYS_MATCHER);
|
||||||
methodInvocation.proceed();
|
methodInvocation.proceed();
|
||||||
mockMethodInvocation.setReturnValue(null);
|
mockMethodInvocation.setReturnValue(null);
|
||||||
log.trace("Some more tracing output");
|
log.trace("Some more tracing output");
|
||||||
mockLog.setMatcher(MockControl.ALWAYS_MATCHER);
|
mockLog.setMatcher(MockControl.ALWAYS_MATCHER);
|
||||||
mockLog.setVoidCallable();
|
mockLog.setVoidCallable();
|
||||||
|
|
||||||
mockMethodInvocation.replay();
|
mockMethodInvocation.replay();
|
||||||
mockLog.replay();
|
mockLog.replay();
|
||||||
|
|
||||||
SimpleTraceInterceptor interceptor = new SimpleTraceInterceptor(true);
|
SimpleTraceInterceptor interceptor = new SimpleTraceInterceptor(true);
|
||||||
interceptor.invokeUnderTrace(methodInvocation, log);
|
interceptor.invokeUnderTrace(methodInvocation, log);
|
||||||
|
|
||||||
mockLog.verify();
|
mockLog.verify();
|
||||||
mockMethodInvocation.verify();
|
mockMethodInvocation.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testExceptionPathStillLogsCorrectly() throws Throwable {
|
public void testExceptionPathStillLogsCorrectly() throws Throwable {
|
||||||
MockControl mockLog = MockControl.createControl(Log.class);
|
MockControl mockLog = MockControl.createControl(Log.class);
|
||||||
final Log log = (Log) mockLog.getMock();
|
final Log log = (Log) mockLog.getMock();
|
||||||
|
|
||||||
MockControl mockMethodInvocation = MockControl.createControl(MethodInvocation.class);
|
MockControl mockMethodInvocation = MockControl.createControl(MethodInvocation.class);
|
||||||
final MethodInvocation methodInvocation = (MethodInvocation) mockMethodInvocation.getMock();
|
final MethodInvocation methodInvocation = (MethodInvocation) mockMethodInvocation.getMock();
|
||||||
|
|
||||||
Method toString = String.class.getMethod("toString", new Class[]{});
|
Method toString = String.class.getMethod("toString", new Class[]{});
|
||||||
|
|
||||||
methodInvocation.getMethod();
|
methodInvocation.getMethod();
|
||||||
mockMethodInvocation.setReturnValue(toString);
|
mockMethodInvocation.setReturnValue(toString);
|
||||||
methodInvocation.getThis();
|
methodInvocation.getThis();
|
||||||
mockMethodInvocation.setReturnValue(this);
|
mockMethodInvocation.setReturnValue(this);
|
||||||
log.trace("Some tracing output");
|
log.trace("Some tracing output");
|
||||||
mockLog.setMatcher(MockControl.ALWAYS_MATCHER);
|
mockLog.setMatcher(MockControl.ALWAYS_MATCHER);
|
||||||
methodInvocation.proceed();
|
methodInvocation.proceed();
|
||||||
IllegalArgumentException exception = new IllegalArgumentException();
|
IllegalArgumentException exception = new IllegalArgumentException();
|
||||||
mockMethodInvocation.setThrowable(exception);
|
mockMethodInvocation.setThrowable(exception);
|
||||||
log.trace("Some more tracing output", exception);
|
log.trace("Some more tracing output", exception);
|
||||||
mockLog.setMatcher(MockControl.ALWAYS_MATCHER);
|
mockLog.setMatcher(MockControl.ALWAYS_MATCHER);
|
||||||
mockLog.setVoidCallable();
|
mockLog.setVoidCallable();
|
||||||
|
|
||||||
mockMethodInvocation.replay();
|
mockMethodInvocation.replay();
|
||||||
mockLog.replay();
|
mockLog.replay();
|
||||||
|
|
||||||
final SimpleTraceInterceptor interceptor = new SimpleTraceInterceptor(true);
|
final SimpleTraceInterceptor interceptor = new SimpleTraceInterceptor(true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
interceptor.invokeUnderTrace(methodInvocation, log);
|
interceptor.invokeUnderTrace(methodInvocation, log);
|
||||||
fail("Must have propagated the IllegalArgumentException.");
|
fail("Must have propagated the IllegalArgumentException.");
|
||||||
} catch (IllegalArgumentException expected) {
|
} catch (IllegalArgumentException expected) {
|
||||||
}
|
}
|
||||||
|
|
||||||
mockLog.verify();
|
mockLog.verify();
|
||||||
mockMethodInvocation.verify();
|
mockMethodInvocation.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
|
@ -50,12 +50,12 @@ public class DelegatingIntroductionInterceptorTests extends TestCase {
|
||||||
// OK
|
// OK
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testIntroductionInterceptorWithDelegation() throws Exception {
|
public void testIntroductionInterceptorWithDelegation() throws Exception {
|
||||||
TestBean raw = new TestBean();
|
TestBean raw = new TestBean();
|
||||||
assertTrue(! (raw instanceof TimeStamped));
|
assertTrue(! (raw instanceof TimeStamped));
|
||||||
ProxyFactory factory = new ProxyFactory(raw);
|
ProxyFactory factory = new ProxyFactory(raw);
|
||||||
|
|
||||||
MockControl tsControl = MockControl.createControl(TimeStamped.class);
|
MockControl tsControl = MockControl.createControl(TimeStamped.class);
|
||||||
TimeStamped ts = (TimeStamped) tsControl.getMock();
|
TimeStamped ts = (TimeStamped) tsControl.getMock();
|
||||||
ts.getTimeStamp();
|
ts.getTimeStamp();
|
||||||
|
|
@ -64,13 +64,13 @@ public class DelegatingIntroductionInterceptorTests extends TestCase {
|
||||||
tsControl.replay();
|
tsControl.replay();
|
||||||
|
|
||||||
factory.addAdvisor(0, new DefaultIntroductionAdvisor(new DelegatingIntroductionInterceptor(ts)));
|
factory.addAdvisor(0, new DefaultIntroductionAdvisor(new DelegatingIntroductionInterceptor(ts)));
|
||||||
|
|
||||||
TimeStamped tsp = (TimeStamped) factory.getProxy();
|
TimeStamped tsp = (TimeStamped) factory.getProxy();
|
||||||
assertTrue(tsp.getTimeStamp() == timestamp);
|
assertTrue(tsp.getTimeStamp() == timestamp);
|
||||||
|
|
||||||
tsControl.verify();
|
tsControl.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testIntroductionInterceptorWithInterfaceHierarchy() throws Exception {
|
public void testIntroductionInterceptorWithInterfaceHierarchy() throws Exception {
|
||||||
TestBean raw = new TestBean();
|
TestBean raw = new TestBean();
|
||||||
assertTrue(! (raw instanceof SubTimeStamped));
|
assertTrue(! (raw instanceof SubTimeStamped));
|
||||||
|
|
@ -121,24 +121,24 @@ public class DelegatingIntroductionInterceptorTests extends TestCase {
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DelegatingIntroductionInterceptor ii = new DelegatingIntroductionInterceptor(new Tester());
|
DelegatingIntroductionInterceptor ii = new DelegatingIntroductionInterceptor(new Tester());
|
||||||
|
|
||||||
TestBean target = new TestBean();
|
TestBean target = new TestBean();
|
||||||
|
|
||||||
ProxyFactory pf = new ProxyFactory(target);
|
ProxyFactory pf = new ProxyFactory(target);
|
||||||
pf.addAdvisor(0, new DefaultIntroductionAdvisor(ii));
|
pf.addAdvisor(0, new DefaultIntroductionAdvisor(ii));
|
||||||
|
|
||||||
//assertTrue(Arrays.binarySearch(pf.getProxiedInterfaces(), TimeStamped.class) != -1);
|
//assertTrue(Arrays.binarySearch(pf.getProxiedInterfaces(), TimeStamped.class) != -1);
|
||||||
TimeStamped ts = (TimeStamped) pf.getProxy();
|
TimeStamped ts = (TimeStamped) pf.getProxy();
|
||||||
|
|
||||||
assertTrue(ts.getTimeStamp() == t);
|
assertTrue(ts.getTimeStamp() == t);
|
||||||
((ITester) ts).foo();
|
((ITester) ts).foo();
|
||||||
|
|
||||||
((ITestBean) ts).getAge();
|
((ITestBean) ts).getAge();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testAutomaticInterfaceRecognitionInSubclass() throws Exception {
|
public void testAutomaticInterfaceRecognitionInSubclass() throws Exception {
|
||||||
final long t = 1001L;
|
final long t = 1001L;
|
||||||
class TestII extends DelegatingIntroductionInterceptor implements TimeStamped, ITester {
|
class TestII extends DelegatingIntroductionInterceptor implements TimeStamped, ITester {
|
||||||
|
|
@ -148,28 +148,28 @@ public class DelegatingIntroductionInterceptorTests extends TestCase {
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DelegatingIntroductionInterceptor ii = new TestII();
|
DelegatingIntroductionInterceptor ii = new TestII();
|
||||||
|
|
||||||
TestBean target = new TestBean();
|
TestBean target = new TestBean();
|
||||||
|
|
||||||
ProxyFactory pf = new ProxyFactory(target);
|
ProxyFactory pf = new ProxyFactory(target);
|
||||||
IntroductionAdvisor ia = new DefaultIntroductionAdvisor(ii);
|
IntroductionAdvisor ia = new DefaultIntroductionAdvisor(ii);
|
||||||
assertTrue(ia.isPerInstance());
|
assertTrue(ia.isPerInstance());
|
||||||
pf.addAdvisor(0, ia);
|
pf.addAdvisor(0, ia);
|
||||||
|
|
||||||
//assertTrue(Arrays.binarySearch(pf.getProxiedInterfaces(), TimeStamped.class) != -1);
|
//assertTrue(Arrays.binarySearch(pf.getProxiedInterfaces(), TimeStamped.class) != -1);
|
||||||
TimeStamped ts = (TimeStamped) pf.getProxy();
|
TimeStamped ts = (TimeStamped) pf.getProxy();
|
||||||
|
|
||||||
assertTrue(ts instanceof TimeStamped);
|
assertTrue(ts instanceof TimeStamped);
|
||||||
// Shoulnd't proxy framework interfaces
|
// Shoulnd't proxy framework interfaces
|
||||||
assertTrue(!(ts instanceof MethodInterceptor));
|
assertTrue(!(ts instanceof MethodInterceptor));
|
||||||
assertTrue(!(ts instanceof IntroductionInterceptor));
|
assertTrue(!(ts instanceof IntroductionInterceptor));
|
||||||
|
|
||||||
assertTrue(ts.getTimeStamp() == t);
|
assertTrue(ts.getTimeStamp() == t);
|
||||||
((ITester) ts).foo();
|
((ITester) ts).foo();
|
||||||
((ITestBean) ts).getAge();
|
((ITestBean) ts).getAge();
|
||||||
|
|
||||||
// Test removal
|
// Test removal
|
||||||
ii.suppressInterface(TimeStamped.class);
|
ii.suppressInterface(TimeStamped.class);
|
||||||
// Note that we need to construct a new proxy factory,
|
// Note that we need to construct a new proxy factory,
|
||||||
|
|
@ -179,12 +179,12 @@ public class DelegatingIntroductionInterceptorTests extends TestCase {
|
||||||
Object o = pf.getProxy();
|
Object o = pf.getProxy();
|
||||||
assertTrue(!(o instanceof TimeStamped));
|
assertTrue(!(o instanceof TimeStamped));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testIntroductionInterceptorDoesntReplaceToString() throws Exception {
|
public void testIntroductionInterceptorDoesntReplaceToString() throws Exception {
|
||||||
TestBean raw = new TestBean();
|
TestBean raw = new TestBean();
|
||||||
assertTrue(! (raw instanceof TimeStamped));
|
assertTrue(! (raw instanceof TimeStamped));
|
||||||
ProxyFactory factory = new ProxyFactory(raw);
|
ProxyFactory factory = new ProxyFactory(raw);
|
||||||
|
|
||||||
TimeStamped ts = new SerializableTimeStamped(0);
|
TimeStamped ts = new SerializableTimeStamped(0);
|
||||||
|
|
||||||
factory.addAdvisor(0, new DefaultIntroductionAdvisor(new DelegatingIntroductionInterceptor(ts) {
|
factory.addAdvisor(0, new DefaultIntroductionAdvisor(new DelegatingIntroductionInterceptor(ts) {
|
||||||
|
|
@ -192,55 +192,55 @@ public class DelegatingIntroductionInterceptorTests extends TestCase {
|
||||||
throw new UnsupportedOperationException("Shouldn't be invoked");
|
throw new UnsupportedOperationException("Shouldn't be invoked");
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
TimeStamped tsp = (TimeStamped) factory.getProxy();
|
TimeStamped tsp = (TimeStamped) factory.getProxy();
|
||||||
assertEquals(0, tsp.getTimeStamp());
|
assertEquals(0, tsp.getTimeStamp());
|
||||||
|
|
||||||
assertEquals(raw.toString(), tsp.toString());
|
assertEquals(raw.toString(), tsp.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDelegateReturnsThisIsMassagedToReturnProxy() {
|
public void testDelegateReturnsThisIsMassagedToReturnProxy() {
|
||||||
NestedTestBean target = new NestedTestBean();
|
NestedTestBean target = new NestedTestBean();
|
||||||
String company = "Interface21";
|
String company = "Interface21";
|
||||||
target.setCompany(company);
|
target.setCompany(company);
|
||||||
TestBean delegate = new TestBean() {
|
TestBean delegate = new TestBean() {
|
||||||
public ITestBean getSpouse() {
|
public ITestBean getSpouse() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
ProxyFactory pf = new ProxyFactory(target);
|
ProxyFactory pf = new ProxyFactory(target);
|
||||||
pf.addAdvice(new DelegatingIntroductionInterceptor(delegate));
|
pf.addAdvice(new DelegatingIntroductionInterceptor(delegate));
|
||||||
INestedTestBean proxy = (INestedTestBean) pf.getProxy();
|
INestedTestBean proxy = (INestedTestBean) pf.getProxy();
|
||||||
|
|
||||||
assertEquals(company, proxy.getCompany());
|
assertEquals(company, proxy.getCompany());
|
||||||
ITestBean introduction = (ITestBean) proxy;
|
ITestBean introduction = (ITestBean) proxy;
|
||||||
assertSame("Introduced method returning delegate returns proxy", introduction, introduction.getSpouse());
|
assertSame("Introduced method returning delegate returns proxy", introduction, introduction.getSpouse());
|
||||||
assertTrue("Introduced method returning delegate returns proxy", AopUtils.isAopProxy(introduction.getSpouse()));
|
assertTrue("Introduced method returning delegate returns proxy", AopUtils.isAopProxy(introduction.getSpouse()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSerializableDelegatingIntroductionInterceptorSerializable() throws Exception {
|
public void testSerializableDelegatingIntroductionInterceptorSerializable() throws Exception {
|
||||||
SerializablePerson serializableTarget = new SerializablePerson();
|
SerializablePerson serializableTarget = new SerializablePerson();
|
||||||
String name = "Tony";
|
String name = "Tony";
|
||||||
serializableTarget.setName("Tony");
|
serializableTarget.setName("Tony");
|
||||||
|
|
||||||
ProxyFactory factory = new ProxyFactory(serializableTarget);
|
ProxyFactory factory = new ProxyFactory(serializableTarget);
|
||||||
factory.addInterface(Person.class);
|
factory.addInterface(Person.class);
|
||||||
long time = 1000;
|
long time = 1000;
|
||||||
TimeStamped ts = new SerializableTimeStamped(time);
|
TimeStamped ts = new SerializableTimeStamped(time);
|
||||||
|
|
||||||
factory.addAdvisor(new DefaultIntroductionAdvisor(new DelegatingIntroductionInterceptor(ts)));
|
factory.addAdvisor(new DefaultIntroductionAdvisor(new DelegatingIntroductionInterceptor(ts)));
|
||||||
factory.addAdvice(new SerializableNopInterceptor());
|
factory.addAdvice(new SerializableNopInterceptor());
|
||||||
|
|
||||||
Person p = (Person) factory.getProxy();
|
Person p = (Person) factory.getProxy();
|
||||||
|
|
||||||
assertEquals(name, p.getName());
|
assertEquals(name, p.getName());
|
||||||
assertEquals(time, ((TimeStamped) p).getTimeStamp());
|
assertEquals(time, ((TimeStamped) p).getTimeStamp());
|
||||||
|
|
||||||
Person p1 = (Person) SerializationTestUtils.serializeAndDeserialize(p);
|
Person p1 = (Person) SerializationTestUtils.serializeAndDeserialize(p);
|
||||||
assertEquals(name, p1.getName());
|
assertEquals(name, p1.getName());
|
||||||
assertEquals(time, ((TimeStamped) p1).getTimeStamp());
|
assertEquals(time, ((TimeStamped) p1).getTimeStamp());
|
||||||
}
|
}
|
||||||
|
|
||||||
// public void testDelegatingIntroductionInterceptorDoesntMakeNonserializableSerializable() throws Exception {
|
// public void testDelegatingIntroductionInterceptorDoesntMakeNonserializableSerializable() throws Exception {
|
||||||
// // Target is NOT serialiable
|
// // Target is NOT serialiable
|
||||||
// TestBean raw = new TestBean();
|
// TestBean raw = new TestBean();
|
||||||
|
|
@ -263,15 +263,15 @@ public class DelegatingIntroductionInterceptorTests extends TestCase {
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DelegatingIntroductionInterceptor ii = new TestII();
|
DelegatingIntroductionInterceptor ii = new TestII();
|
||||||
|
|
||||||
// != t
|
// != t
|
||||||
TestBean target = new TargetClass(t + 1);
|
TestBean target = new TargetClass(t + 1);
|
||||||
|
|
||||||
ProxyFactory pf = new ProxyFactory(target);
|
ProxyFactory pf = new ProxyFactory(target);
|
||||||
pf.addAdvisor(0, new DefaultIntroductionAdvisor(ii));
|
pf.addAdvisor(0, new DefaultIntroductionAdvisor(ii));
|
||||||
|
|
||||||
TimeStamped ts = (TimeStamped) pf.getProxy();
|
TimeStamped ts = (TimeStamped) pf.getProxy();
|
||||||
// From introduction interceptor, not target
|
// From introduction interceptor, not target
|
||||||
assertTrue(ts.getTimeStamp() == t);
|
assertTrue(ts.getTimeStamp() == t);
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ package org.springframework.beans.factory;
|
||||||
* @author Rick Evans
|
* @author Rick Evans
|
||||||
*/
|
*/
|
||||||
class PackageLevelVisibleBean {
|
class PackageLevelVisibleBean {
|
||||||
|
|
||||||
public static final String CONSTANT = "Wuby";
|
public static final String CONSTANT = "Wuby";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,56 +20,56 @@ import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scrap bean for use in tests.
|
* Scrap bean for use in tests.
|
||||||
*
|
*
|
||||||
* @author Colin Sampaleanu
|
* @author Colin Sampaleanu
|
||||||
*/
|
*/
|
||||||
public class TestBean {
|
public class TestBean {
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
private List list;
|
private List list;
|
||||||
|
|
||||||
private Object objRef;
|
private Object objRef;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Returns the name.
|
* @return Returns the name.
|
||||||
*/
|
*/
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name The name to set.
|
* @param name The name to set.
|
||||||
*/
|
*/
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Returns the list.
|
* @return Returns the list.
|
||||||
*/
|
*/
|
||||||
public List getList() {
|
public List getList() {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param list The list to set.
|
* @param list The list to set.
|
||||||
*/
|
*/
|
||||||
public void setList(List list) {
|
public void setList(List list) {
|
||||||
this.list = list;
|
this.list = list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Returns the object.
|
* @return Returns the object.
|
||||||
*/
|
*/
|
||||||
public Object getObjRef() {
|
public Object getObjRef() {
|
||||||
return objRef;
|
return objRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param object The object to set.
|
* @param object The object to set.
|
||||||
*/
|
*/
|
||||||
public void setObjRef(Object object) {
|
public void setObjRef(Object object) {
|
||||||
this.objRef = object;
|
this.objRef = object;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,33 +27,33 @@ import org.springframework.test.AssertThrows;
|
||||||
*/
|
*/
|
||||||
public final class CommonsLogFactoryBeanTests extends TestCase {
|
public final class CommonsLogFactoryBeanTests extends TestCase {
|
||||||
|
|
||||||
public void testIsSingleton() throws Exception {
|
public void testIsSingleton() throws Exception {
|
||||||
CommonsLogFactoryBean factory = new CommonsLogFactoryBean();
|
CommonsLogFactoryBean factory = new CommonsLogFactoryBean();
|
||||||
assertTrue(factory.isSingleton());
|
assertTrue(factory.isSingleton());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetObjectTypeDefaultsToPlainResourceInterfaceifLookupResourceIsNotSupplied() throws Exception {
|
public void testGetObjectTypeDefaultsToPlainResourceInterfaceifLookupResourceIsNotSupplied() throws Exception {
|
||||||
CommonsLogFactoryBean factory = new CommonsLogFactoryBean();
|
CommonsLogFactoryBean factory = new CommonsLogFactoryBean();
|
||||||
assertEquals(Log.class, factory.getObjectType());
|
assertEquals(Log.class, factory.getObjectType());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testWhenLogNameIsMissing() throws Exception {
|
public void testWhenLogNameIsMissing() throws Exception {
|
||||||
new AssertThrows(IllegalArgumentException.class) {
|
new AssertThrows(IllegalArgumentException.class) {
|
||||||
public void test() throws Exception {
|
public void test() throws Exception {
|
||||||
CommonsLogFactoryBean factory = new CommonsLogFactoryBean();
|
CommonsLogFactoryBean factory = new CommonsLogFactoryBean();
|
||||||
factory.afterPropertiesSet();
|
factory.afterPropertiesSet();
|
||||||
}
|
}
|
||||||
}.runTest();
|
}.runTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSunnyDayPath() throws Exception {
|
public void testSunnyDayPath() throws Exception {
|
||||||
CommonsLogFactoryBean factory = new CommonsLogFactoryBean();
|
CommonsLogFactoryBean factory = new CommonsLogFactoryBean();
|
||||||
factory.setLogName("The Tin Drum");
|
factory.setLogName("The Tin Drum");
|
||||||
factory.afterPropertiesSet();
|
factory.afterPropertiesSet();
|
||||||
Object object = factory.getObject();
|
Object object = factory.getObject();
|
||||||
|
|
||||||
assertNotNull("As per FactoryBean contract, the return value of getObject() cannot be null.", object);
|
assertNotNull("As per FactoryBean contract, the return value of getObject() cannot be null.", object);
|
||||||
assertTrue("Obviously not getting a Log back", Log.class.isAssignableFrom(object.getClass()));
|
assertTrue("Obviously not getting a Log back", Log.class.isAssignableFrom(object.getClass()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,11 +48,12 @@ import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
|
* @author Chris Beams
|
||||||
* @since 02.10.2003
|
* @since 02.10.2003
|
||||||
*/
|
*/
|
||||||
public class PropertyResourceConfigurerTests {
|
public class PropertyResourceConfigurerTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPropertyOverrideConfigurer() {
|
public void testPropertyOverrideConfigurer() {
|
||||||
StaticApplicationContext ac = new StaticApplicationContext();
|
StaticApplicationContext ac = new StaticApplicationContext();
|
||||||
ac.registerSingleton("tb1", TestBean.class);
|
ac.registerSingleton("tb1", TestBean.class);
|
||||||
|
|
@ -73,7 +74,7 @@ public class PropertyResourceConfigurerTests {
|
||||||
assertEquals("test", tb2.getName());
|
assertEquals("test", tb2.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPropertyOverrideConfigurerWithNestedProperty() {
|
public void testPropertyOverrideConfigurerWithNestedProperty() {
|
||||||
StaticApplicationContext ac = new StaticApplicationContext();
|
StaticApplicationContext ac = new StaticApplicationContext();
|
||||||
ac.registerSingleton("tb", IndexedTestBean.class);
|
ac.registerSingleton("tb", IndexedTestBean.class);
|
||||||
|
|
@ -86,7 +87,7 @@ public class PropertyResourceConfigurerTests {
|
||||||
assertEquals("test", ((TestBean) tb.getList().get(1)).getName());
|
assertEquals("test", ((TestBean) tb.getList().get(1)).getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPropertyOverrideConfigurerWithNestedPropertyAndDotInBeanName() {
|
public void testPropertyOverrideConfigurerWithNestedPropertyAndDotInBeanName() {
|
||||||
StaticApplicationContext ac = new StaticApplicationContext();
|
StaticApplicationContext ac = new StaticApplicationContext();
|
||||||
ac.registerSingleton("my.tb", IndexedTestBean.class);
|
ac.registerSingleton("my.tb", IndexedTestBean.class);
|
||||||
|
|
@ -100,7 +101,7 @@ public class PropertyResourceConfigurerTests {
|
||||||
assertEquals("test", ((TestBean) tb.getList().get(1)).getName());
|
assertEquals("test", ((TestBean) tb.getList().get(1)).getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPropertyOverrideConfigurerWithNestedMapPropertyAndDotInMapKey() {
|
public void testPropertyOverrideConfigurerWithNestedMapPropertyAndDotInMapKey() {
|
||||||
StaticApplicationContext ac = new StaticApplicationContext();
|
StaticApplicationContext ac = new StaticApplicationContext();
|
||||||
ac.registerSingleton("tb", IndexedTestBean.class);
|
ac.registerSingleton("tb", IndexedTestBean.class);
|
||||||
|
|
@ -113,7 +114,7 @@ public class PropertyResourceConfigurerTests {
|
||||||
assertEquals("test", tb.getMap().get("key2.ext"));
|
assertEquals("test", tb.getMap().get("key2.ext"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPropertyOverrideConfigurerWithJavaMailProperties() {
|
public void testPropertyOverrideConfigurerWithJavaMailProperties() {
|
||||||
StaticApplicationContext ac = new StaticApplicationContext();
|
StaticApplicationContext ac = new StaticApplicationContext();
|
||||||
ac.registerSingleton("tb", JavaMailSenderImpl.class);
|
ac.registerSingleton("tb", JavaMailSenderImpl.class);
|
||||||
|
|
@ -125,7 +126,7 @@ public class PropertyResourceConfigurerTests {
|
||||||
assertEquals("true", tb.getJavaMailProperties().getProperty("mail.smtp.auth"));
|
assertEquals("true", tb.getJavaMailProperties().getProperty("mail.smtp.auth"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPropertyOverrideConfigurerWithPropertiesFile() {
|
public void testPropertyOverrideConfigurerWithPropertiesFile() {
|
||||||
StaticApplicationContext ac = new StaticApplicationContext();
|
StaticApplicationContext ac = new StaticApplicationContext();
|
||||||
ac.registerSingleton("tb", IndexedTestBean.class);
|
ac.registerSingleton("tb", IndexedTestBean.class);
|
||||||
|
|
@ -138,7 +139,7 @@ public class PropertyResourceConfigurerTests {
|
||||||
assertEquals("test", ((TestBean) tb.getList().get(1)).getName());
|
assertEquals("test", ((TestBean) tb.getList().get(1)).getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPropertyOverrideConfigurerWithInvalidPropertiesFile() {
|
public void testPropertyOverrideConfigurerWithInvalidPropertiesFile() {
|
||||||
StaticApplicationContext ac = new StaticApplicationContext();
|
StaticApplicationContext ac = new StaticApplicationContext();
|
||||||
ac.registerSingleton("tb", IndexedTestBean.class);
|
ac.registerSingleton("tb", IndexedTestBean.class);
|
||||||
|
|
@ -154,7 +155,7 @@ public class PropertyResourceConfigurerTests {
|
||||||
assertEquals("test", ((TestBean) tb.getList().get(1)).getName());
|
assertEquals("test", ((TestBean) tb.getList().get(1)).getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPropertyOverrideConfigurerWithPropertiesXmlFile() {
|
public void testPropertyOverrideConfigurerWithPropertiesXmlFile() {
|
||||||
// ignore for JDK < 1.5
|
// ignore for JDK < 1.5
|
||||||
if (JdkVersion.getMajorJavaVersion() < JdkVersion.JAVA_15) {
|
if (JdkVersion.getMajorJavaVersion() < JdkVersion.JAVA_15) {
|
||||||
|
|
@ -172,7 +173,7 @@ public class PropertyResourceConfigurerTests {
|
||||||
assertEquals("test", ((TestBean) tb.getList().get(1)).getName());
|
assertEquals("test", ((TestBean) tb.getList().get(1)).getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPropertyOverrideConfigurerWithConvertProperties() {
|
public void testPropertyOverrideConfigurerWithConvertProperties() {
|
||||||
StaticApplicationContext ac = new StaticApplicationContext();
|
StaticApplicationContext ac = new StaticApplicationContext();
|
||||||
ac.registerSingleton("tb", IndexedTestBean.class);
|
ac.registerSingleton("tb", IndexedTestBean.class);
|
||||||
|
|
@ -185,7 +186,7 @@ public class PropertyResourceConfigurerTests {
|
||||||
assertEquals("Xtest", ((TestBean) tb.getList().get(1)).getName());
|
assertEquals("Xtest", ((TestBean) tb.getList().get(1)).getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPropertyOverrideConfigurerWithInvalidKey() {
|
public void testPropertyOverrideConfigurerWithInvalidKey() {
|
||||||
StaticApplicationContext ac = new StaticApplicationContext();
|
StaticApplicationContext ac = new StaticApplicationContext();
|
||||||
ac.registerSingleton("tb1", TestBean.class);
|
ac.registerSingleton("tb1", TestBean.class);
|
||||||
|
|
@ -206,7 +207,7 @@ public class PropertyResourceConfigurerTests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPropertyOverrideConfigurerWithIgnoreInvalidKeys() {
|
public void testPropertyOverrideConfigurerWithIgnoreInvalidKeys() {
|
||||||
StaticApplicationContext ac = new StaticApplicationContext();
|
StaticApplicationContext ac = new StaticApplicationContext();
|
||||||
ac.registerSingleton("tb1", TestBean.class);
|
ac.registerSingleton("tb1", TestBean.class);
|
||||||
|
|
@ -228,12 +229,12 @@ public class PropertyResourceConfigurerTests {
|
||||||
assertEquals("test", tb2.getName());
|
assertEquals("test", tb2.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPropertyPlaceholderConfigurer() {
|
public void testPropertyPlaceholderConfigurer() {
|
||||||
doTestPropertyPlaceholderConfigurer(false);
|
doTestPropertyPlaceholderConfigurer(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPropertyPlaceholderConfigurerWithParentChildSeparation() {
|
public void testPropertyPlaceholderConfigurerWithParentChildSeparation() {
|
||||||
doTestPropertyPlaceholderConfigurer(true);
|
doTestPropertyPlaceholderConfigurer(true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -276,7 +276,7 @@ public class XmlBeanCollectionTests extends TestCase {
|
||||||
XmlBeanFactory xbf = new XmlBeanFactory(new ClassPathResource("collections.xml", getClass()));
|
XmlBeanFactory xbf = new XmlBeanFactory(new ClassPathResource("collections.xml", getClass()));
|
||||||
HasMap hasMap = (HasMap) xbf.getBean("props");
|
HasMap hasMap = (HasMap) xbf.getBean("props");
|
||||||
assertTrue(hasMap.getProps().size() == 2);
|
assertTrue(hasMap.getProps().size() == 2);
|
||||||
assertTrue(hasMap.getProps().get("foo").equals("bar"));
|
assertTrue(hasMap.getProps().get("foo").equals("bar"));
|
||||||
assertTrue(hasMap.getProps().get("2").equals("TWO"));
|
assertTrue(hasMap.getProps().get("2").equals("TWO"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,19 +23,19 @@ package org.springframework.context;
|
||||||
* @since January 21, 2001
|
* @since January 21, 2001
|
||||||
*/
|
*/
|
||||||
public class TestListener implements ApplicationListener {
|
public class TestListener implements ApplicationListener {
|
||||||
|
|
||||||
private int eventCount;
|
private int eventCount;
|
||||||
|
|
||||||
public int getEventCount() {
|
public int getEventCount() {
|
||||||
return eventCount;
|
return eventCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void zeroCounter() {
|
public void zeroCounter() {
|
||||||
eventCount = 0;
|
eventCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onApplicationEvent(ApplicationEvent e) {
|
public void onApplicationEvent(ApplicationEvent e) {
|
||||||
++eventCount;
|
++eventCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,26 +38,26 @@ import org.springframework.web.context.support.GenericWebApplicationContext;
|
||||||
public class ClassPathBeanDefinitionScannerScopeTests extends TestCase {
|
public class ClassPathBeanDefinitionScannerScopeTests extends TestCase {
|
||||||
|
|
||||||
private static final String DEFAULT_NAME = "default";
|
private static final String DEFAULT_NAME = "default";
|
||||||
|
|
||||||
private static final String MODIFIED_NAME = "modified";
|
private static final String MODIFIED_NAME = "modified";
|
||||||
|
|
||||||
private ServletRequestAttributes oldRequestAttributes;
|
private ServletRequestAttributes oldRequestAttributes;
|
||||||
|
|
||||||
private ServletRequestAttributes newRequestAttributes;
|
private ServletRequestAttributes newRequestAttributes;
|
||||||
|
|
||||||
private ServletRequestAttributes oldRequestAttributesWithSession;
|
private ServletRequestAttributes oldRequestAttributesWithSession;
|
||||||
|
|
||||||
private ServletRequestAttributes newRequestAttributesWithSession;
|
private ServletRequestAttributes newRequestAttributesWithSession;
|
||||||
|
|
||||||
|
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
this.oldRequestAttributes = new ServletRequestAttributes(new MockHttpServletRequest());
|
this.oldRequestAttributes = new ServletRequestAttributes(new MockHttpServletRequest());
|
||||||
this.newRequestAttributes = new ServletRequestAttributes(new MockHttpServletRequest());
|
this.newRequestAttributes = new ServletRequestAttributes(new MockHttpServletRequest());
|
||||||
|
|
||||||
MockHttpServletRequest oldRequestWithSession = new MockHttpServletRequest();
|
MockHttpServletRequest oldRequestWithSession = new MockHttpServletRequest();
|
||||||
oldRequestWithSession.setSession(new MockHttpSession());
|
oldRequestWithSession.setSession(new MockHttpSession());
|
||||||
this.oldRequestAttributesWithSession = new ServletRequestAttributes(oldRequestWithSession);
|
this.oldRequestAttributesWithSession = new ServletRequestAttributes(oldRequestWithSession);
|
||||||
|
|
||||||
MockHttpServletRequest newRequestWithSession = new MockHttpServletRequest();
|
MockHttpServletRequest newRequestWithSession = new MockHttpServletRequest();
|
||||||
newRequestWithSession.setSession(new MockHttpSession());
|
newRequestWithSession.setSession(new MockHttpSession());
|
||||||
this.newRequestAttributesWithSession = new ServletRequestAttributes(newRequestWithSession);
|
this.newRequestAttributesWithSession = new ServletRequestAttributes(newRequestWithSession);
|
||||||
|
|
@ -72,17 +72,17 @@ public class ClassPathBeanDefinitionScannerScopeTests extends TestCase {
|
||||||
RequestContextHolder.setRequestAttributes(oldRequestAttributes);
|
RequestContextHolder.setRequestAttributes(oldRequestAttributes);
|
||||||
ApplicationContext context = createContext(ScopedProxyMode.NO);
|
ApplicationContext context = createContext(ScopedProxyMode.NO);
|
||||||
ScopedTestBean bean = (ScopedTestBean) context.getBean("singleton");
|
ScopedTestBean bean = (ScopedTestBean) context.getBean("singleton");
|
||||||
|
|
||||||
// should not be a proxy
|
// should not be a proxy
|
||||||
assertFalse(AopUtils.isAopProxy(bean));
|
assertFalse(AopUtils.isAopProxy(bean));
|
||||||
|
|
||||||
assertEquals(DEFAULT_NAME, bean.getName());
|
assertEquals(DEFAULT_NAME, bean.getName());
|
||||||
bean.setName(MODIFIED_NAME);
|
bean.setName(MODIFIED_NAME);
|
||||||
|
|
||||||
RequestContextHolder.setRequestAttributes(newRequestAttributes);
|
RequestContextHolder.setRequestAttributes(newRequestAttributes);
|
||||||
// not a proxy so this should not have changed
|
// not a proxy so this should not have changed
|
||||||
assertEquals(MODIFIED_NAME, bean.getName());
|
assertEquals(MODIFIED_NAME, bean.getName());
|
||||||
|
|
||||||
// singleton bean, so name should be modified even after lookup
|
// singleton bean, so name should be modified even after lookup
|
||||||
ScopedTestBean bean2 = (ScopedTestBean) context.getBean("singleton");
|
ScopedTestBean bean2 = (ScopedTestBean) context.getBean("singleton");
|
||||||
assertEquals(MODIFIED_NAME, bean2.getName());
|
assertEquals(MODIFIED_NAME, bean2.getName());
|
||||||
|
|
@ -92,17 +92,17 @@ public class ClassPathBeanDefinitionScannerScopeTests extends TestCase {
|
||||||
RequestContextHolder.setRequestAttributes(oldRequestAttributes);
|
RequestContextHolder.setRequestAttributes(oldRequestAttributes);
|
||||||
ApplicationContext context = createContext(ScopedProxyMode.INTERFACES);
|
ApplicationContext context = createContext(ScopedProxyMode.INTERFACES);
|
||||||
ScopedTestBean bean = (ScopedTestBean) context.getBean("singleton");
|
ScopedTestBean bean = (ScopedTestBean) context.getBean("singleton");
|
||||||
|
|
||||||
// should not be a proxy
|
// should not be a proxy
|
||||||
assertFalse(AopUtils.isAopProxy(bean));
|
assertFalse(AopUtils.isAopProxy(bean));
|
||||||
|
|
||||||
assertEquals(DEFAULT_NAME, bean.getName());
|
assertEquals(DEFAULT_NAME, bean.getName());
|
||||||
bean.setName(MODIFIED_NAME);
|
bean.setName(MODIFIED_NAME);
|
||||||
|
|
||||||
RequestContextHolder.setRequestAttributes(newRequestAttributes);
|
RequestContextHolder.setRequestAttributes(newRequestAttributes);
|
||||||
// not a proxy so this should not have changed
|
// not a proxy so this should not have changed
|
||||||
assertEquals(MODIFIED_NAME, bean.getName());
|
assertEquals(MODIFIED_NAME, bean.getName());
|
||||||
|
|
||||||
// singleton bean, so name should be modified even after lookup
|
// singleton bean, so name should be modified even after lookup
|
||||||
ScopedTestBean bean2 = (ScopedTestBean) context.getBean("singleton");
|
ScopedTestBean bean2 = (ScopedTestBean) context.getBean("singleton");
|
||||||
assertEquals(MODIFIED_NAME, bean2.getName());
|
assertEquals(MODIFIED_NAME, bean2.getName());
|
||||||
|
|
@ -112,37 +112,37 @@ public class ClassPathBeanDefinitionScannerScopeTests extends TestCase {
|
||||||
RequestContextHolder.setRequestAttributes(oldRequestAttributes);
|
RequestContextHolder.setRequestAttributes(oldRequestAttributes);
|
||||||
ApplicationContext context = createContext(ScopedProxyMode.TARGET_CLASS);
|
ApplicationContext context = createContext(ScopedProxyMode.TARGET_CLASS);
|
||||||
ScopedTestBean bean = (ScopedTestBean) context.getBean("singleton");
|
ScopedTestBean bean = (ScopedTestBean) context.getBean("singleton");
|
||||||
|
|
||||||
// should not be a proxy
|
// should not be a proxy
|
||||||
assertFalse(AopUtils.isAopProxy(bean));
|
assertFalse(AopUtils.isAopProxy(bean));
|
||||||
|
|
||||||
assertEquals(DEFAULT_NAME, bean.getName());
|
assertEquals(DEFAULT_NAME, bean.getName());
|
||||||
bean.setName(MODIFIED_NAME);
|
bean.setName(MODIFIED_NAME);
|
||||||
|
|
||||||
RequestContextHolder.setRequestAttributes(newRequestAttributes);
|
RequestContextHolder.setRequestAttributes(newRequestAttributes);
|
||||||
// not a proxy so this should not have changed
|
// not a proxy so this should not have changed
|
||||||
assertEquals(MODIFIED_NAME, bean.getName());
|
assertEquals(MODIFIED_NAME, bean.getName());
|
||||||
|
|
||||||
// singleton bean, so name should be modified even after lookup
|
// singleton bean, so name should be modified even after lookup
|
||||||
ScopedTestBean bean2 = (ScopedTestBean) context.getBean("singleton");
|
ScopedTestBean bean2 = (ScopedTestBean) context.getBean("singleton");
|
||||||
assertEquals(MODIFIED_NAME, bean2.getName());
|
assertEquals(MODIFIED_NAME, bean2.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testRequestScopeWithNoProxy() {
|
public void testRequestScopeWithNoProxy() {
|
||||||
RequestContextHolder.setRequestAttributes(oldRequestAttributes);
|
RequestContextHolder.setRequestAttributes(oldRequestAttributes);
|
||||||
ApplicationContext context = createContext(ScopedProxyMode.NO);
|
ApplicationContext context = createContext(ScopedProxyMode.NO);
|
||||||
ScopedTestBean bean = (ScopedTestBean) context.getBean("request");
|
ScopedTestBean bean = (ScopedTestBean) context.getBean("request");
|
||||||
|
|
||||||
// should not be a proxy
|
// should not be a proxy
|
||||||
assertFalse(AopUtils.isAopProxy(bean));
|
assertFalse(AopUtils.isAopProxy(bean));
|
||||||
|
|
||||||
assertEquals(DEFAULT_NAME, bean.getName());
|
assertEquals(DEFAULT_NAME, bean.getName());
|
||||||
bean.setName(MODIFIED_NAME);
|
bean.setName(MODIFIED_NAME);
|
||||||
|
|
||||||
RequestContextHolder.setRequestAttributes(newRequestAttributes);
|
RequestContextHolder.setRequestAttributes(newRequestAttributes);
|
||||||
// not a proxy so this should not have changed
|
// not a proxy so this should not have changed
|
||||||
assertEquals(MODIFIED_NAME, bean.getName());
|
assertEquals(MODIFIED_NAME, bean.getName());
|
||||||
|
|
||||||
// but a newly retrieved bean should have the default name
|
// but a newly retrieved bean should have the default name
|
||||||
ScopedTestBean bean2 = (ScopedTestBean) context.getBean("request");
|
ScopedTestBean bean2 = (ScopedTestBean) context.getBean("request");
|
||||||
assertEquals(DEFAULT_NAME, bean2.getName());
|
assertEquals(DEFAULT_NAME, bean2.getName());
|
||||||
|
|
@ -152,18 +152,18 @@ public class ClassPathBeanDefinitionScannerScopeTests extends TestCase {
|
||||||
RequestContextHolder.setRequestAttributes(oldRequestAttributes);
|
RequestContextHolder.setRequestAttributes(oldRequestAttributes);
|
||||||
ApplicationContext context = createContext(ScopedProxyMode.INTERFACES);
|
ApplicationContext context = createContext(ScopedProxyMode.INTERFACES);
|
||||||
IScopedTestBean bean = (IScopedTestBean) context.getBean("request");
|
IScopedTestBean bean = (IScopedTestBean) context.getBean("request");
|
||||||
|
|
||||||
// should be dynamic proxy, implementing both interfaces
|
// should be dynamic proxy, implementing both interfaces
|
||||||
assertTrue(AopUtils.isJdkDynamicProxy(bean));
|
assertTrue(AopUtils.isJdkDynamicProxy(bean));
|
||||||
assertTrue(bean instanceof AnotherScopeTestInterface);
|
assertTrue(bean instanceof AnotherScopeTestInterface);
|
||||||
|
|
||||||
assertEquals(DEFAULT_NAME, bean.getName());
|
assertEquals(DEFAULT_NAME, bean.getName());
|
||||||
bean.setName(MODIFIED_NAME);
|
bean.setName(MODIFIED_NAME);
|
||||||
|
|
||||||
RequestContextHolder.setRequestAttributes(newRequestAttributes);
|
RequestContextHolder.setRequestAttributes(newRequestAttributes);
|
||||||
// this is a proxy so it should be reset to default
|
// this is a proxy so it should be reset to default
|
||||||
assertEquals(DEFAULT_NAME, bean.getName());
|
assertEquals(DEFAULT_NAME, bean.getName());
|
||||||
|
|
||||||
RequestContextHolder.setRequestAttributes(oldRequestAttributes);
|
RequestContextHolder.setRequestAttributes(oldRequestAttributes);
|
||||||
assertEquals(MODIFIED_NAME, bean.getName());
|
assertEquals(MODIFIED_NAME, bean.getName());
|
||||||
}
|
}
|
||||||
|
|
@ -172,22 +172,22 @@ public class ClassPathBeanDefinitionScannerScopeTests extends TestCase {
|
||||||
RequestContextHolder.setRequestAttributes(oldRequestAttributes);
|
RequestContextHolder.setRequestAttributes(oldRequestAttributes);
|
||||||
ApplicationContext context = createContext(ScopedProxyMode.TARGET_CLASS);
|
ApplicationContext context = createContext(ScopedProxyMode.TARGET_CLASS);
|
||||||
IScopedTestBean bean = (IScopedTestBean) context.getBean("request");
|
IScopedTestBean bean = (IScopedTestBean) context.getBean("request");
|
||||||
|
|
||||||
// should be a class-based proxy
|
// should be a class-based proxy
|
||||||
assertTrue(AopUtils.isCglibProxy(bean));
|
assertTrue(AopUtils.isCglibProxy(bean));
|
||||||
assertTrue(bean instanceof RequestScopedTestBean);
|
assertTrue(bean instanceof RequestScopedTestBean);
|
||||||
|
|
||||||
assertEquals(DEFAULT_NAME, bean.getName());
|
assertEquals(DEFAULT_NAME, bean.getName());
|
||||||
bean.setName(MODIFIED_NAME);
|
bean.setName(MODIFIED_NAME);
|
||||||
|
|
||||||
RequestContextHolder.setRequestAttributes(newRequestAttributes);
|
RequestContextHolder.setRequestAttributes(newRequestAttributes);
|
||||||
// this is a proxy so it should be reset to default
|
// this is a proxy so it should be reset to default
|
||||||
assertEquals(DEFAULT_NAME, bean.getName());
|
assertEquals(DEFAULT_NAME, bean.getName());
|
||||||
|
|
||||||
RequestContextHolder.setRequestAttributes(oldRequestAttributes);
|
RequestContextHolder.setRequestAttributes(oldRequestAttributes);
|
||||||
assertEquals(MODIFIED_NAME, bean.getName());
|
assertEquals(MODIFIED_NAME, bean.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSessionScopeWithNoProxy() {
|
public void testSessionScopeWithNoProxy() {
|
||||||
RequestContextHolder.setRequestAttributes(oldRequestAttributesWithSession);
|
RequestContextHolder.setRequestAttributes(oldRequestAttributesWithSession);
|
||||||
ApplicationContext context = createContext(ScopedProxyMode.NO);
|
ApplicationContext context = createContext(ScopedProxyMode.NO);
|
||||||
|
|
@ -195,14 +195,14 @@ public class ClassPathBeanDefinitionScannerScopeTests extends TestCase {
|
||||||
|
|
||||||
// should not be a proxy
|
// should not be a proxy
|
||||||
assertFalse(AopUtils.isAopProxy(bean));
|
assertFalse(AopUtils.isAopProxy(bean));
|
||||||
|
|
||||||
assertEquals(DEFAULT_NAME, bean.getName());
|
assertEquals(DEFAULT_NAME, bean.getName());
|
||||||
bean.setName(MODIFIED_NAME);
|
bean.setName(MODIFIED_NAME);
|
||||||
|
|
||||||
RequestContextHolder.setRequestAttributes(newRequestAttributesWithSession);
|
RequestContextHolder.setRequestAttributes(newRequestAttributesWithSession);
|
||||||
// not a proxy so this should not have changed
|
// not a proxy so this should not have changed
|
||||||
assertEquals(MODIFIED_NAME, bean.getName());
|
assertEquals(MODIFIED_NAME, bean.getName());
|
||||||
|
|
||||||
// but a newly retrieved bean should have the default name
|
// but a newly retrieved bean should have the default name
|
||||||
ScopedTestBean bean2 = (ScopedTestBean) context.getBean("session");
|
ScopedTestBean bean2 = (ScopedTestBean) context.getBean("session");
|
||||||
assertEquals(DEFAULT_NAME, bean2.getName());
|
assertEquals(DEFAULT_NAME, bean2.getName());
|
||||||
|
|
@ -212,24 +212,24 @@ public class ClassPathBeanDefinitionScannerScopeTests extends TestCase {
|
||||||
RequestContextHolder.setRequestAttributes(oldRequestAttributesWithSession);
|
RequestContextHolder.setRequestAttributes(oldRequestAttributesWithSession);
|
||||||
ApplicationContext context = createContext(ScopedProxyMode.INTERFACES);
|
ApplicationContext context = createContext(ScopedProxyMode.INTERFACES);
|
||||||
IScopedTestBean bean = (IScopedTestBean) context.getBean("session");
|
IScopedTestBean bean = (IScopedTestBean) context.getBean("session");
|
||||||
|
|
||||||
// should be dynamic proxy, implementing both interfaces
|
// should be dynamic proxy, implementing both interfaces
|
||||||
assertTrue(AopUtils.isJdkDynamicProxy(bean));
|
assertTrue(AopUtils.isJdkDynamicProxy(bean));
|
||||||
assertTrue(bean instanceof AnotherScopeTestInterface);
|
assertTrue(bean instanceof AnotherScopeTestInterface);
|
||||||
|
|
||||||
assertEquals(DEFAULT_NAME, bean.getName());
|
assertEquals(DEFAULT_NAME, bean.getName());
|
||||||
bean.setName(MODIFIED_NAME);
|
bean.setName(MODIFIED_NAME);
|
||||||
|
|
||||||
RequestContextHolder.setRequestAttributes(newRequestAttributesWithSession);
|
RequestContextHolder.setRequestAttributes(newRequestAttributesWithSession);
|
||||||
// this is a proxy so it should be reset to default
|
// this is a proxy so it should be reset to default
|
||||||
assertEquals(DEFAULT_NAME, bean.getName());
|
assertEquals(DEFAULT_NAME, bean.getName());
|
||||||
bean.setName(MODIFIED_NAME);
|
bean.setName(MODIFIED_NAME);
|
||||||
|
|
||||||
IScopedTestBean bean2 = (IScopedTestBean) context.getBean("session");
|
IScopedTestBean bean2 = (IScopedTestBean) context.getBean("session");
|
||||||
assertEquals(MODIFIED_NAME, bean2.getName());
|
assertEquals(MODIFIED_NAME, bean2.getName());
|
||||||
bean2.setName(DEFAULT_NAME);
|
bean2.setName(DEFAULT_NAME);
|
||||||
assertEquals(DEFAULT_NAME, bean.getName());
|
assertEquals(DEFAULT_NAME, bean.getName());
|
||||||
|
|
||||||
RequestContextHolder.setRequestAttributes(oldRequestAttributesWithSession);
|
RequestContextHolder.setRequestAttributes(oldRequestAttributesWithSession);
|
||||||
assertEquals(MODIFIED_NAME, bean.getName());
|
assertEquals(MODIFIED_NAME, bean.getName());
|
||||||
}
|
}
|
||||||
|
|
@ -284,8 +284,8 @@ public class ClassPathBeanDefinitionScannerScopeTests extends TestCase {
|
||||||
context.refresh();
|
context.refresh();
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static @interface ScopeTestComponent {
|
public static @interface ScopeTestComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -296,7 +296,7 @@ public class ClassPathBeanDefinitionScannerScopeTests extends TestCase {
|
||||||
|
|
||||||
void setName(String name);
|
void setName(String name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static abstract class ScopedTestBean implements IScopedTestBean {
|
public static abstract class ScopedTestBean implements IScopedTestBean {
|
||||||
|
|
||||||
|
|
@ -306,16 +306,16 @@ public class ClassPathBeanDefinitionScannerScopeTests extends TestCase {
|
||||||
|
|
||||||
public void setName(String name) { this.name = name; }
|
public void setName(String name) { this.name = name; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ScopeTestComponent
|
@ScopeTestComponent
|
||||||
public static class SingletonScopedTestBean extends ScopedTestBean {
|
public static class SingletonScopedTestBean extends ScopedTestBean {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static interface AnotherScopeTestInterface {
|
public static interface AnotherScopeTestInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Scope("request")
|
@Scope("request")
|
||||||
@ScopeTestComponent
|
@ScopeTestComponent
|
||||||
|
|
|
||||||
|
|
@ -1096,8 +1096,8 @@ public class BridgeMethodResolverTests {
|
||||||
|
|
||||||
public class BusinessDao extends BusinessGenericDao<Business<?>, Long> {
|
public class BusinessDao extends BusinessGenericDao<Business<?>, Long> {
|
||||||
|
|
||||||
public void save(Business<?> business) {
|
public void save(Business<?> business) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Business<?> get(Long id) {
|
public Business<?> get(Long id) {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ import org.springframework.web.context.support.ServletContextResource;
|
||||||
*/
|
*/
|
||||||
public class ResourceTests {
|
public class ResourceTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testByteArrayResource() throws IOException {
|
public void testByteArrayResource() throws IOException {
|
||||||
Resource resource = new ByteArrayResource("testString".getBytes());
|
Resource resource = new ByteArrayResource("testString".getBytes());
|
||||||
assertTrue(resource.exists());
|
assertTrue(resource.exists());
|
||||||
|
|
@ -49,8 +49,8 @@ public class ResourceTests {
|
||||||
assertEquals("testString", content);
|
assertEquals("testString", content);
|
||||||
assertEquals(resource, new ByteArrayResource("testString".getBytes()));
|
assertEquals(resource, new ByteArrayResource("testString".getBytes()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testByteArrayResourceWithDescription() throws IOException {
|
public void testByteArrayResourceWithDescription() throws IOException {
|
||||||
Resource resource = new ByteArrayResource("testString".getBytes(), "my description");
|
Resource resource = new ByteArrayResource("testString".getBytes(), "my description");
|
||||||
assertTrue(resource.exists());
|
assertTrue(resource.exists());
|
||||||
|
|
@ -61,7 +61,7 @@ public class ResourceTests {
|
||||||
assertEquals(resource, new ByteArrayResource("testString".getBytes()));
|
assertEquals(resource, new ByteArrayResource("testString".getBytes()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInputStreamResource() throws IOException {
|
public void testInputStreamResource() throws IOException {
|
||||||
InputStream is = new ByteArrayInputStream("testString".getBytes());
|
InputStream is = new ByteArrayInputStream("testString".getBytes());
|
||||||
Resource resource = new InputStreamResource(is);
|
Resource resource = new InputStreamResource(is);
|
||||||
|
|
@ -72,7 +72,7 @@ public class ResourceTests {
|
||||||
assertEquals(resource, new InputStreamResource(is));
|
assertEquals(resource, new InputStreamResource(is));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInputStreamResourceWithDescription() throws IOException {
|
public void testInputStreamResourceWithDescription() throws IOException {
|
||||||
InputStream is = new ByteArrayInputStream("testString".getBytes());
|
InputStream is = new ByteArrayInputStream("testString".getBytes());
|
||||||
Resource resource = new InputStreamResource(is, "my description");
|
Resource resource = new InputStreamResource(is, "my description");
|
||||||
|
|
@ -84,7 +84,7 @@ public class ResourceTests {
|
||||||
assertEquals(resource, new InputStreamResource(is));
|
assertEquals(resource, new InputStreamResource(is));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testClassPathResource() throws IOException {
|
public void testClassPathResource() throws IOException {
|
||||||
Resource resource = new ClassPathResource("org/springframework/core/io/Resource.class");
|
Resource resource = new ClassPathResource("org/springframework/core/io/Resource.class");
|
||||||
doTestResource(resource);
|
doTestResource(resource);
|
||||||
|
|
@ -100,7 +100,7 @@ public class ResourceTests {
|
||||||
assertEquals(1, resources.size());
|
assertEquals(1, resources.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testClassPathResourceWithClassLoader() throws IOException {
|
public void testClassPathResourceWithClassLoader() throws IOException {
|
||||||
Resource resource =
|
Resource resource =
|
||||||
new ClassPathResource("org/springframework/core/io/Resource.class", getClass().getClassLoader());
|
new ClassPathResource("org/springframework/core/io/Resource.class", getClass().getClassLoader());
|
||||||
|
|
@ -109,15 +109,15 @@ public class ResourceTests {
|
||||||
new ClassPathResource("org/springframework/core/../core/io/./Resource.class", getClass().getClassLoader()));
|
new ClassPathResource("org/springframework/core/../core/io/./Resource.class", getClass().getClassLoader()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testClassPathResourceWithClass() throws IOException {
|
public void testClassPathResourceWithClass() throws IOException {
|
||||||
Resource resource = new ClassPathResource("Resource.class", getClass());
|
Resource resource = new ClassPathResource("Resource.class", getClass());
|
||||||
doTestResource(resource);
|
doTestResource(resource);
|
||||||
assertEquals(resource, new ClassPathResource("Resource.class", getClass()));
|
assertEquals(resource, new ClassPathResource("Resource.class", getClass()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore // passes under eclipse, fails under ant
|
@Ignore // passes under eclipse, fails under ant
|
||||||
@Test
|
@Test
|
||||||
public void testFileSystemResource() throws IOException {
|
public void testFileSystemResource() throws IOException {
|
||||||
Resource resource = new FileSystemResource(getClass().getResource("Resource.class").getFile());
|
Resource resource = new FileSystemResource(getClass().getResource("Resource.class").getFile());
|
||||||
doTestResource(resource);
|
doTestResource(resource);
|
||||||
|
|
@ -126,7 +126,7 @@ public class ResourceTests {
|
||||||
assertEquals(resource2, new FileSystemResource("core/../core/io/./Resource.class"));
|
assertEquals(resource2, new FileSystemResource("core/../core/io/./Resource.class"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUrlResource() throws IOException {
|
public void testUrlResource() throws IOException {
|
||||||
Resource resource = new UrlResource(getClass().getResource("Resource.class"));
|
Resource resource = new UrlResource(getClass().getResource("Resource.class"));
|
||||||
doTestResource(resource);
|
doTestResource(resource);
|
||||||
|
|
@ -135,7 +135,7 @@ public class ResourceTests {
|
||||||
assertEquals(resource2, new UrlResource("file:core/../core/io/./Resource.class"));
|
assertEquals(resource2, new UrlResource("file:core/../core/io/./Resource.class"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testServletContextResource() throws IOException {
|
public void testServletContextResource() throws IOException {
|
||||||
MockServletContext sc = new MockServletContext();
|
MockServletContext sc = new MockServletContext();
|
||||||
Resource resource = new ServletContextResource(sc, "org/springframework/core/io/Resource.class");
|
Resource resource = new ServletContextResource(sc, "org/springframework/core/io/Resource.class");
|
||||||
|
|
|
||||||
|
|
@ -30,403 +30,403 @@ import javax.jms.*;
|
||||||
*/
|
*/
|
||||||
public final class MessageListenerAdapter102Tests extends TestCase {
|
public final class MessageListenerAdapter102Tests extends TestCase {
|
||||||
|
|
||||||
private static final String TEXT = "The Runaways";
|
private static final String TEXT = "The Runaways";
|
||||||
private static final String CORRELATION_ID = "100";
|
private static final String CORRELATION_ID = "100";
|
||||||
private static final String RESPONSE_TEXT = "Old Lace";
|
private static final String RESPONSE_TEXT = "Old Lace";
|
||||||
|
|
||||||
|
|
||||||
public void testWithMessageContentsDelegateForBytesMessage() throws Exception {
|
public void testWithMessageContentsDelegateForBytesMessage() throws Exception {
|
||||||
|
|
||||||
MockControl mockBytesMessage = MockControl.createControl(BytesMessage.class);
|
MockControl mockBytesMessage = MockControl.createControl(BytesMessage.class);
|
||||||
BytesMessage bytesMessage = (BytesMessage) mockBytesMessage.getMock();
|
BytesMessage bytesMessage = (BytesMessage) mockBytesMessage.getMock();
|
||||||
// BytesMessage contents must be unwrapped...
|
// BytesMessage contents must be unwrapped...
|
||||||
bytesMessage.readBytes(null);
|
bytesMessage.readBytes(null);
|
||||||
mockBytesMessage.setMatcher(MockControl.ALWAYS_MATCHER);
|
mockBytesMessage.setMatcher(MockControl.ALWAYS_MATCHER);
|
||||||
mockBytesMessage.setReturnValue(TEXT.getBytes().length);
|
mockBytesMessage.setReturnValue(TEXT.getBytes().length);
|
||||||
mockBytesMessage.replay();
|
mockBytesMessage.replay();
|
||||||
|
|
||||||
MockControl mockDelegate = MockControl.createControl(MessageContentsDelegate.class);
|
MockControl mockDelegate = MockControl.createControl(MessageContentsDelegate.class);
|
||||||
MessageContentsDelegate delegate = (MessageContentsDelegate) mockDelegate.getMock();
|
MessageContentsDelegate delegate = (MessageContentsDelegate) mockDelegate.getMock();
|
||||||
delegate.handleMessage(TEXT.getBytes());
|
delegate.handleMessage(TEXT.getBytes());
|
||||||
mockDelegate.setMatcher(MockControl.ALWAYS_MATCHER);
|
mockDelegate.setMatcher(MockControl.ALWAYS_MATCHER);
|
||||||
mockDelegate.setVoidCallable();
|
mockDelegate.setVoidCallable();
|
||||||
mockDelegate.replay();
|
mockDelegate.replay();
|
||||||
|
|
||||||
MessageListenerAdapter102 adapter = new MessageListenerAdapter102(delegate);
|
MessageListenerAdapter102 adapter = new MessageListenerAdapter102(delegate);
|
||||||
adapter.onMessage(bytesMessage);
|
adapter.onMessage(bytesMessage);
|
||||||
|
|
||||||
mockDelegate.verify();
|
mockDelegate.verify();
|
||||||
mockBytesMessage.verify();
|
mockBytesMessage.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testWithMessageDelegate() throws Exception {
|
public void testWithMessageDelegate() throws Exception {
|
||||||
|
|
||||||
MockControl mockTextMessage = MockControl.createControl(TextMessage.class);
|
MockControl mockTextMessage = MockControl.createControl(TextMessage.class);
|
||||||
TextMessage textMessage = (TextMessage) mockTextMessage.getMock();
|
TextMessage textMessage = (TextMessage) mockTextMessage.getMock();
|
||||||
mockTextMessage.replay();
|
mockTextMessage.replay();
|
||||||
|
|
||||||
MockControl mockDelegate = MockControl.createControl(MessageDelegate.class);
|
MockControl mockDelegate = MockControl.createControl(MessageDelegate.class);
|
||||||
MessageDelegate delegate = (MessageDelegate) mockDelegate.getMock();
|
MessageDelegate delegate = (MessageDelegate) mockDelegate.getMock();
|
||||||
delegate.handleMessage(textMessage);
|
delegate.handleMessage(textMessage);
|
||||||
mockDelegate.setVoidCallable();
|
mockDelegate.setVoidCallable();
|
||||||
mockDelegate.replay();
|
mockDelegate.replay();
|
||||||
|
|
||||||
MessageListenerAdapter102 adapter = new MessageListenerAdapter102(delegate);
|
MessageListenerAdapter102 adapter = new MessageListenerAdapter102(delegate);
|
||||||
// we DON'T want the default SimpleMessageConversion happening...
|
// we DON'T want the default SimpleMessageConversion happening...
|
||||||
adapter.setMessageConverter(null);
|
adapter.setMessageConverter(null);
|
||||||
adapter.onMessage(textMessage);
|
adapter.onMessage(textMessage);
|
||||||
|
|
||||||
mockDelegate.verify();
|
mockDelegate.verify();
|
||||||
mockTextMessage.verify();
|
mockTextMessage.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testThatTheDefaultMessageConverterisIndeedTheSimpleMessageConverter102() throws Exception {
|
public void testThatTheDefaultMessageConverterisIndeedTheSimpleMessageConverter102() throws Exception {
|
||||||
MessageListenerAdapter102 adapter = new MessageListenerAdapter102();
|
MessageListenerAdapter102 adapter = new MessageListenerAdapter102();
|
||||||
assertNotNull("The default [MessageConverter] must never be null.", adapter.getMessageConverter());
|
assertNotNull("The default [MessageConverter] must never be null.", adapter.getMessageConverter());
|
||||||
assertTrue("The default [MessageConverter] must be of the type [SimpleMessageConverter102]; if you've just changed it, then change this test to reflect your change.", adapter.getMessageConverter() instanceof SimpleMessageConverter102);
|
assertTrue("The default [MessageConverter] must be of the type [SimpleMessageConverter102]; if you've just changed it, then change this test to reflect your change.", adapter.getMessageConverter() instanceof SimpleMessageConverter102);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testWithResponsiveMessageDelegate_DoesNotSendReturnTextMessageIfNoSessionSupplied() throws Exception {
|
public void testWithResponsiveMessageDelegate_DoesNotSendReturnTextMessageIfNoSessionSupplied() throws Exception {
|
||||||
|
|
||||||
MockControl mockTextMessage = MockControl.createControl(TextMessage.class);
|
MockControl mockTextMessage = MockControl.createControl(TextMessage.class);
|
||||||
TextMessage textMessage = (TextMessage) mockTextMessage.getMock();
|
TextMessage textMessage = (TextMessage) mockTextMessage.getMock();
|
||||||
mockTextMessage.replay();
|
mockTextMessage.replay();
|
||||||
|
|
||||||
MockControl mockDelegate = MockControl.createControl(ResponsiveMessageDelegate.class);
|
MockControl mockDelegate = MockControl.createControl(ResponsiveMessageDelegate.class);
|
||||||
ResponsiveMessageDelegate delegate = (ResponsiveMessageDelegate) mockDelegate.getMock();
|
ResponsiveMessageDelegate delegate = (ResponsiveMessageDelegate) mockDelegate.getMock();
|
||||||
delegate.handleMessage(textMessage);
|
delegate.handleMessage(textMessage);
|
||||||
mockDelegate.setReturnValue(TEXT);
|
mockDelegate.setReturnValue(TEXT);
|
||||||
mockDelegate.replay();
|
mockDelegate.replay();
|
||||||
|
|
||||||
MessageListenerAdapter102 adapter = new MessageListenerAdapter102(delegate);
|
MessageListenerAdapter102 adapter = new MessageListenerAdapter102(delegate);
|
||||||
// we DON'T want the default SimpleMessageConversion happening...
|
// we DON'T want the default SimpleMessageConversion happening...
|
||||||
adapter.setMessageConverter(null);
|
adapter.setMessageConverter(null);
|
||||||
adapter.onMessage(textMessage);
|
adapter.onMessage(textMessage);
|
||||||
|
|
||||||
mockDelegate.verify();
|
mockDelegate.verify();
|
||||||
mockTextMessage.verify();
|
mockTextMessage.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testWithResponsiveMessageDelegateWithDefaultDestination_SendsReturnTextMessageWhenSessionSuppliedForQueue() throws Exception {
|
public void testWithResponsiveMessageDelegateWithDefaultDestination_SendsReturnTextMessageWhenSessionSuppliedForQueue() throws Exception {
|
||||||
|
|
||||||
MockControl mockDestination = MockControl.createControl(Queue.class);
|
MockControl mockDestination = MockControl.createControl(Queue.class);
|
||||||
Queue destination = (Queue) mockDestination.getMock();
|
Queue destination = (Queue) mockDestination.getMock();
|
||||||
mockDestination.replay();
|
mockDestination.replay();
|
||||||
|
|
||||||
MockControl mockSentTextMessage = MockControl.createControl(TextMessage.class);
|
MockControl mockSentTextMessage = MockControl.createControl(TextMessage.class);
|
||||||
TextMessage sentTextMessage = (TextMessage) mockSentTextMessage.getMock();
|
TextMessage sentTextMessage = (TextMessage) mockSentTextMessage.getMock();
|
||||||
// correlation ID is queried when response is being created...
|
// correlation ID is queried when response is being created...
|
||||||
sentTextMessage.getJMSCorrelationID();
|
sentTextMessage.getJMSCorrelationID();
|
||||||
mockSentTextMessage.setReturnValue(CORRELATION_ID);
|
mockSentTextMessage.setReturnValue(CORRELATION_ID);
|
||||||
// Reply-To is queried when response is being created...
|
// Reply-To is queried when response is being created...
|
||||||
sentTextMessage.getJMSReplyTo();
|
sentTextMessage.getJMSReplyTo();
|
||||||
mockSentTextMessage.setReturnValue(null); // we want to fall back to the default...
|
mockSentTextMessage.setReturnValue(null); // we want to fall back to the default...
|
||||||
mockSentTextMessage.replay();
|
mockSentTextMessage.replay();
|
||||||
|
|
||||||
MockControl mockResponseTextMessage = MockControl.createControl(TextMessage.class);
|
MockControl mockResponseTextMessage = MockControl.createControl(TextMessage.class);
|
||||||
TextMessage responseTextMessage = (TextMessage) mockResponseTextMessage.getMock();
|
TextMessage responseTextMessage = (TextMessage) mockResponseTextMessage.getMock();
|
||||||
responseTextMessage.setJMSCorrelationID(CORRELATION_ID);
|
responseTextMessage.setJMSCorrelationID(CORRELATION_ID);
|
||||||
mockResponseTextMessage.setVoidCallable();
|
mockResponseTextMessage.setVoidCallable();
|
||||||
mockResponseTextMessage.replay();
|
mockResponseTextMessage.replay();
|
||||||
|
|
||||||
MockControl mockQueueSender = MockControl.createControl(QueueSender.class);
|
MockControl mockQueueSender = MockControl.createControl(QueueSender.class);
|
||||||
QueueSender queueSender = (QueueSender) mockQueueSender.getMock();
|
QueueSender queueSender = (QueueSender) mockQueueSender.getMock();
|
||||||
queueSender.send(responseTextMessage);
|
queueSender.send(responseTextMessage);
|
||||||
mockQueueSender.setVoidCallable();
|
mockQueueSender.setVoidCallable();
|
||||||
queueSender.close();
|
queueSender.close();
|
||||||
mockQueueSender.setVoidCallable();
|
mockQueueSender.setVoidCallable();
|
||||||
mockQueueSender.replay();
|
mockQueueSender.replay();
|
||||||
|
|
||||||
MockControl mockSession = MockControl.createControl(QueueSession.class);
|
MockControl mockSession = MockControl.createControl(QueueSession.class);
|
||||||
QueueSession session = (QueueSession) mockSession.getMock();
|
QueueSession session = (QueueSession) mockSession.getMock();
|
||||||
session.createTextMessage(RESPONSE_TEXT);
|
session.createTextMessage(RESPONSE_TEXT);
|
||||||
mockSession.setReturnValue(responseTextMessage);
|
mockSession.setReturnValue(responseTextMessage);
|
||||||
session.createSender(destination);
|
session.createSender(destination);
|
||||||
mockSession.setReturnValue(queueSender);
|
mockSession.setReturnValue(queueSender);
|
||||||
mockSession.replay();
|
mockSession.replay();
|
||||||
|
|
||||||
MockControl mockDelegate = MockControl.createControl(ResponsiveMessageDelegate.class);
|
MockControl mockDelegate = MockControl.createControl(ResponsiveMessageDelegate.class);
|
||||||
ResponsiveMessageDelegate delegate = (ResponsiveMessageDelegate) mockDelegate.getMock();
|
ResponsiveMessageDelegate delegate = (ResponsiveMessageDelegate) mockDelegate.getMock();
|
||||||
delegate.handleMessage(sentTextMessage);
|
delegate.handleMessage(sentTextMessage);
|
||||||
mockDelegate.setReturnValue(RESPONSE_TEXT);
|
mockDelegate.setReturnValue(RESPONSE_TEXT);
|
||||||
mockDelegate.replay();
|
mockDelegate.replay();
|
||||||
|
|
||||||
MessageListenerAdapter102 adapter = new MessageListenerAdapter102(delegate) {
|
MessageListenerAdapter102 adapter = new MessageListenerAdapter102(delegate) {
|
||||||
protected Object extractMessage(Message message) {
|
protected Object extractMessage(Message message) {
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
adapter.setDefaultResponseDestination(destination);
|
adapter.setDefaultResponseDestination(destination);
|
||||||
adapter.onMessage(sentTextMessage, session);
|
adapter.onMessage(sentTextMessage, session);
|
||||||
|
|
||||||
mockDelegate.verify();
|
mockDelegate.verify();
|
||||||
mockSentTextMessage.verify();
|
mockSentTextMessage.verify();
|
||||||
mockResponseTextMessage.verify();
|
mockResponseTextMessage.verify();
|
||||||
mockSession.verify();
|
mockSession.verify();
|
||||||
mockDestination.verify();
|
mockDestination.verify();
|
||||||
mockQueueSender.verify();
|
mockQueueSender.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testWithResponsiveMessageDelegateWithDefaultDestination_SendsReturnTextMessageWhenSessionSuppliedForTopic() throws Exception {
|
public void testWithResponsiveMessageDelegateWithDefaultDestination_SendsReturnTextMessageWhenSessionSuppliedForTopic() throws Exception {
|
||||||
|
|
||||||
MockControl mockDestination = MockControl.createControl(Topic.class);
|
MockControl mockDestination = MockControl.createControl(Topic.class);
|
||||||
Topic destination = (Topic) mockDestination.getMock();
|
Topic destination = (Topic) mockDestination.getMock();
|
||||||
mockDestination.replay();
|
mockDestination.replay();
|
||||||
|
|
||||||
MockControl mockSentTextMessage = MockControl.createControl(TextMessage.class);
|
MockControl mockSentTextMessage = MockControl.createControl(TextMessage.class);
|
||||||
TextMessage sentTextMessage = (TextMessage) mockSentTextMessage.getMock();
|
TextMessage sentTextMessage = (TextMessage) mockSentTextMessage.getMock();
|
||||||
// correlation ID is queried when response is being created...
|
// correlation ID is queried when response is being created...
|
||||||
sentTextMessage.getJMSCorrelationID();
|
sentTextMessage.getJMSCorrelationID();
|
||||||
mockSentTextMessage.setReturnValue(CORRELATION_ID);
|
mockSentTextMessage.setReturnValue(CORRELATION_ID);
|
||||||
// Reply-To is queried when response is being created...
|
// Reply-To is queried when response is being created...
|
||||||
sentTextMessage.getJMSReplyTo();
|
sentTextMessage.getJMSReplyTo();
|
||||||
mockSentTextMessage.setReturnValue(null); // we want to fall back to the default...
|
mockSentTextMessage.setReturnValue(null); // we want to fall back to the default...
|
||||||
mockSentTextMessage.replay();
|
mockSentTextMessage.replay();
|
||||||
|
|
||||||
MockControl mockResponseTextMessage = MockControl.createControl(TextMessage.class);
|
MockControl mockResponseTextMessage = MockControl.createControl(TextMessage.class);
|
||||||
TextMessage responseTextMessage = (TextMessage) mockResponseTextMessage.getMock();
|
TextMessage responseTextMessage = (TextMessage) mockResponseTextMessage.getMock();
|
||||||
responseTextMessage.setJMSCorrelationID(CORRELATION_ID);
|
responseTextMessage.setJMSCorrelationID(CORRELATION_ID);
|
||||||
mockResponseTextMessage.setVoidCallable();
|
mockResponseTextMessage.setVoidCallable();
|
||||||
mockResponseTextMessage.replay();
|
mockResponseTextMessage.replay();
|
||||||
|
|
||||||
MockControl mockTopicPublisher = MockControl.createControl(TopicPublisher.class);
|
MockControl mockTopicPublisher = MockControl.createControl(TopicPublisher.class);
|
||||||
TopicPublisher topicPublisher = (TopicPublisher) mockTopicPublisher.getMock();
|
TopicPublisher topicPublisher = (TopicPublisher) mockTopicPublisher.getMock();
|
||||||
topicPublisher.publish(responseTextMessage);
|
topicPublisher.publish(responseTextMessage);
|
||||||
mockTopicPublisher.setVoidCallable();
|
mockTopicPublisher.setVoidCallable();
|
||||||
topicPublisher.close();
|
topicPublisher.close();
|
||||||
mockTopicPublisher.setVoidCallable();
|
mockTopicPublisher.setVoidCallable();
|
||||||
mockTopicPublisher.replay();
|
mockTopicPublisher.replay();
|
||||||
|
|
||||||
MockControl mockSession = MockControl.createControl(TopicSession.class);
|
MockControl mockSession = MockControl.createControl(TopicSession.class);
|
||||||
TopicSession session = (TopicSession) mockSession.getMock();
|
TopicSession session = (TopicSession) mockSession.getMock();
|
||||||
session.createTextMessage(RESPONSE_TEXT);
|
session.createTextMessage(RESPONSE_TEXT);
|
||||||
mockSession.setReturnValue(responseTextMessage);
|
mockSession.setReturnValue(responseTextMessage);
|
||||||
session.createPublisher(destination);
|
session.createPublisher(destination);
|
||||||
mockSession.setReturnValue(topicPublisher);
|
mockSession.setReturnValue(topicPublisher);
|
||||||
mockSession.replay();
|
mockSession.replay();
|
||||||
|
|
||||||
MockControl mockDelegate = MockControl.createControl(ResponsiveMessageDelegate.class);
|
MockControl mockDelegate = MockControl.createControl(ResponsiveMessageDelegate.class);
|
||||||
ResponsiveMessageDelegate delegate = (ResponsiveMessageDelegate) mockDelegate.getMock();
|
ResponsiveMessageDelegate delegate = (ResponsiveMessageDelegate) mockDelegate.getMock();
|
||||||
delegate.handleMessage(sentTextMessage);
|
delegate.handleMessage(sentTextMessage);
|
||||||
mockDelegate.setReturnValue(RESPONSE_TEXT);
|
mockDelegate.setReturnValue(RESPONSE_TEXT);
|
||||||
mockDelegate.replay();
|
mockDelegate.replay();
|
||||||
|
|
||||||
MessageListenerAdapter102 adapter = new MessageListenerAdapter102(delegate) {
|
MessageListenerAdapter102 adapter = new MessageListenerAdapter102(delegate) {
|
||||||
protected Object extractMessage(Message message) {
|
protected Object extractMessage(Message message) {
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
adapter.setDefaultResponseDestination(destination);
|
adapter.setDefaultResponseDestination(destination);
|
||||||
adapter.onMessage(sentTextMessage, session);
|
adapter.onMessage(sentTextMessage, session);
|
||||||
|
|
||||||
mockDelegate.verify();
|
mockDelegate.verify();
|
||||||
mockSentTextMessage.verify();
|
mockSentTextMessage.verify();
|
||||||
mockResponseTextMessage.verify();
|
mockResponseTextMessage.verify();
|
||||||
mockSession.verify();
|
mockSession.verify();
|
||||||
mockDestination.verify();
|
mockDestination.verify();
|
||||||
mockTopicPublisher.verify();
|
mockTopicPublisher.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testWithResponsiveMessageDelegateNoDefaultDestination_SendsReturnTextMessageWhenSessionSupplied() throws Exception {
|
public void testWithResponsiveMessageDelegateNoDefaultDestination_SendsReturnTextMessageWhenSessionSupplied() throws Exception {
|
||||||
|
|
||||||
MockControl mockDestination = MockControl.createControl(Queue.class);
|
MockControl mockDestination = MockControl.createControl(Queue.class);
|
||||||
Queue destination = (Queue) mockDestination.getMock();
|
Queue destination = (Queue) mockDestination.getMock();
|
||||||
mockDestination.replay();
|
mockDestination.replay();
|
||||||
|
|
||||||
MockControl mockSentTextMessage = MockControl.createControl(TextMessage.class);
|
MockControl mockSentTextMessage = MockControl.createControl(TextMessage.class);
|
||||||
TextMessage sentTextMessage = (TextMessage) mockSentTextMessage.getMock();
|
TextMessage sentTextMessage = (TextMessage) mockSentTextMessage.getMock();
|
||||||
// correlation ID is queried when response is being created...
|
// correlation ID is queried when response is being created...
|
||||||
sentTextMessage.getJMSCorrelationID();
|
sentTextMessage.getJMSCorrelationID();
|
||||||
mockSentTextMessage.setReturnValue(CORRELATION_ID);
|
mockSentTextMessage.setReturnValue(CORRELATION_ID);
|
||||||
// Reply-To is queried when response is being created...
|
// Reply-To is queried when response is being created...
|
||||||
sentTextMessage.getJMSReplyTo();
|
sentTextMessage.getJMSReplyTo();
|
||||||
mockSentTextMessage.setReturnValue(destination);
|
mockSentTextMessage.setReturnValue(destination);
|
||||||
mockSentTextMessage.replay();
|
mockSentTextMessage.replay();
|
||||||
|
|
||||||
MockControl mockResponseTextMessage = MockControl.createControl(TextMessage.class);
|
MockControl mockResponseTextMessage = MockControl.createControl(TextMessage.class);
|
||||||
TextMessage responseTextMessage = (TextMessage) mockResponseTextMessage.getMock();
|
TextMessage responseTextMessage = (TextMessage) mockResponseTextMessage.getMock();
|
||||||
responseTextMessage.setJMSCorrelationID(CORRELATION_ID);
|
responseTextMessage.setJMSCorrelationID(CORRELATION_ID);
|
||||||
mockResponseTextMessage.setVoidCallable();
|
mockResponseTextMessage.setVoidCallable();
|
||||||
mockResponseTextMessage.replay();
|
mockResponseTextMessage.replay();
|
||||||
|
|
||||||
MockControl mockQueueSender = MockControl.createControl(QueueSender.class);
|
MockControl mockQueueSender = MockControl.createControl(QueueSender.class);
|
||||||
QueueSender queueSender = (QueueSender) mockQueueSender.getMock();
|
QueueSender queueSender = (QueueSender) mockQueueSender.getMock();
|
||||||
queueSender.send(responseTextMessage);
|
queueSender.send(responseTextMessage);
|
||||||
mockQueueSender.setVoidCallable();
|
mockQueueSender.setVoidCallable();
|
||||||
queueSender.close();
|
queueSender.close();
|
||||||
mockQueueSender.setVoidCallable();
|
mockQueueSender.setVoidCallable();
|
||||||
mockQueueSender.replay();
|
mockQueueSender.replay();
|
||||||
|
|
||||||
MockControl mockSession = MockControl.createControl(QueueSession.class);
|
MockControl mockSession = MockControl.createControl(QueueSession.class);
|
||||||
QueueSession session = (QueueSession) mockSession.getMock();
|
QueueSession session = (QueueSession) mockSession.getMock();
|
||||||
session.createTextMessage(RESPONSE_TEXT);
|
session.createTextMessage(RESPONSE_TEXT);
|
||||||
mockSession.setReturnValue(responseTextMessage);
|
mockSession.setReturnValue(responseTextMessage);
|
||||||
session.createSender(destination);
|
session.createSender(destination);
|
||||||
mockSession.setReturnValue(queueSender);
|
mockSession.setReturnValue(queueSender);
|
||||||
mockSession.replay();
|
mockSession.replay();
|
||||||
|
|
||||||
MockControl mockDelegate = MockControl.createControl(ResponsiveMessageDelegate.class);
|
MockControl mockDelegate = MockControl.createControl(ResponsiveMessageDelegate.class);
|
||||||
ResponsiveMessageDelegate delegate = (ResponsiveMessageDelegate) mockDelegate.getMock();
|
ResponsiveMessageDelegate delegate = (ResponsiveMessageDelegate) mockDelegate.getMock();
|
||||||
delegate.handleMessage(sentTextMessage);
|
delegate.handleMessage(sentTextMessage);
|
||||||
mockDelegate.setReturnValue(RESPONSE_TEXT);
|
mockDelegate.setReturnValue(RESPONSE_TEXT);
|
||||||
mockDelegate.replay();
|
mockDelegate.replay();
|
||||||
|
|
||||||
MessageListenerAdapter102 adapter = new MessageListenerAdapter102(delegate) {
|
MessageListenerAdapter102 adapter = new MessageListenerAdapter102(delegate) {
|
||||||
protected Object extractMessage(Message message) {
|
protected Object extractMessage(Message message) {
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
adapter.onMessage(sentTextMessage, session);
|
adapter.onMessage(sentTextMessage, session);
|
||||||
|
|
||||||
mockDelegate.verify();
|
mockDelegate.verify();
|
||||||
mockSentTextMessage.verify();
|
mockSentTextMessage.verify();
|
||||||
mockResponseTextMessage.verify();
|
mockResponseTextMessage.verify();
|
||||||
mockSession.verify();
|
mockSession.verify();
|
||||||
mockDestination.verify();
|
mockDestination.verify();
|
||||||
mockQueueSender.verify();
|
mockQueueSender.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testWithResponsiveMessageDelegateNoDefaultDestinationAndNoReplyToDestination_SendsReturnTextMessageWhenSessionSupplied() throws Exception {
|
public void testWithResponsiveMessageDelegateNoDefaultDestinationAndNoReplyToDestination_SendsReturnTextMessageWhenSessionSupplied() throws Exception {
|
||||||
|
|
||||||
MockControl mockSentTextMessage = MockControl.createControl(TextMessage.class);
|
MockControl mockSentTextMessage = MockControl.createControl(TextMessage.class);
|
||||||
final TextMessage sentTextMessage = (TextMessage) mockSentTextMessage.getMock();
|
final TextMessage sentTextMessage = (TextMessage) mockSentTextMessage.getMock();
|
||||||
// correlation ID is queried when response is being created...
|
// correlation ID is queried when response is being created...
|
||||||
sentTextMessage.getJMSCorrelationID();
|
sentTextMessage.getJMSCorrelationID();
|
||||||
mockSentTextMessage.setReturnValue(CORRELATION_ID);
|
mockSentTextMessage.setReturnValue(CORRELATION_ID);
|
||||||
// Reply-To is queried when response is being created...
|
// Reply-To is queried when response is being created...
|
||||||
sentTextMessage.getJMSReplyTo();
|
sentTextMessage.getJMSReplyTo();
|
||||||
mockSentTextMessage.setReturnValue(null);
|
mockSentTextMessage.setReturnValue(null);
|
||||||
mockSentTextMessage.replay();
|
mockSentTextMessage.replay();
|
||||||
|
|
||||||
MockControl mockResponseTextMessage = MockControl.createControl(TextMessage.class);
|
MockControl mockResponseTextMessage = MockControl.createControl(TextMessage.class);
|
||||||
TextMessage responseTextMessage = (TextMessage) mockResponseTextMessage.getMock();
|
TextMessage responseTextMessage = (TextMessage) mockResponseTextMessage.getMock();
|
||||||
responseTextMessage.setJMSCorrelationID(CORRELATION_ID);
|
responseTextMessage.setJMSCorrelationID(CORRELATION_ID);
|
||||||
mockResponseTextMessage.setVoidCallable();
|
mockResponseTextMessage.setVoidCallable();
|
||||||
mockResponseTextMessage.replay();
|
mockResponseTextMessage.replay();
|
||||||
|
|
||||||
MockControl mockSession = MockControl.createControl(QueueSession.class);
|
MockControl mockSession = MockControl.createControl(QueueSession.class);
|
||||||
final QueueSession session = (QueueSession) mockSession.getMock();
|
final QueueSession session = (QueueSession) mockSession.getMock();
|
||||||
session.createTextMessage(RESPONSE_TEXT);
|
session.createTextMessage(RESPONSE_TEXT);
|
||||||
mockSession.setReturnValue(responseTextMessage);
|
mockSession.setReturnValue(responseTextMessage);
|
||||||
mockSession.replay();
|
mockSession.replay();
|
||||||
|
|
||||||
MockControl mockDelegate = MockControl.createControl(ResponsiveMessageDelegate.class);
|
MockControl mockDelegate = MockControl.createControl(ResponsiveMessageDelegate.class);
|
||||||
ResponsiveMessageDelegate delegate = (ResponsiveMessageDelegate) mockDelegate.getMock();
|
ResponsiveMessageDelegate delegate = (ResponsiveMessageDelegate) mockDelegate.getMock();
|
||||||
delegate.handleMessage(sentTextMessage);
|
delegate.handleMessage(sentTextMessage);
|
||||||
mockDelegate.setReturnValue(RESPONSE_TEXT);
|
mockDelegate.setReturnValue(RESPONSE_TEXT);
|
||||||
mockDelegate.replay();
|
mockDelegate.replay();
|
||||||
|
|
||||||
final MessageListenerAdapter102 adapter = new MessageListenerAdapter102(delegate) {
|
final MessageListenerAdapter102 adapter = new MessageListenerAdapter102(delegate) {
|
||||||
protected Object extractMessage(Message message) {
|
protected Object extractMessage(Message message) {
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
new AssertThrows(InvalidDestinationException.class) {
|
new AssertThrows(InvalidDestinationException.class) {
|
||||||
public void test() throws Exception {
|
public void test() throws Exception {
|
||||||
adapter.onMessage(sentTextMessage, session);
|
adapter.onMessage(sentTextMessage, session);
|
||||||
}
|
}
|
||||||
}.runTest();
|
}.runTest();
|
||||||
|
|
||||||
mockDelegate.verify();
|
mockDelegate.verify();
|
||||||
mockSentTextMessage.verify();
|
mockSentTextMessage.verify();
|
||||||
mockResponseTextMessage.verify();
|
mockResponseTextMessage.verify();
|
||||||
mockSession.verify();
|
mockSession.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testWithResponsiveMessageDelegateNoDefaultDestination_SendsReturnTextMessageWhenSessionSupplied_AndSendingThrowsJMSException() throws Exception {
|
public void testWithResponsiveMessageDelegateNoDefaultDestination_SendsReturnTextMessageWhenSessionSupplied_AndSendingThrowsJMSException() throws Exception {
|
||||||
|
|
||||||
MockControl mockDestination = MockControl.createControl(Queue.class);
|
MockControl mockDestination = MockControl.createControl(Queue.class);
|
||||||
Queue destination = (Queue) mockDestination.getMock();
|
Queue destination = (Queue) mockDestination.getMock();
|
||||||
mockDestination.replay();
|
mockDestination.replay();
|
||||||
|
|
||||||
MockControl mockSentTextMessage = MockControl.createControl(TextMessage.class);
|
MockControl mockSentTextMessage = MockControl.createControl(TextMessage.class);
|
||||||
final TextMessage sentTextMessage = (TextMessage) mockSentTextMessage.getMock();
|
final TextMessage sentTextMessage = (TextMessage) mockSentTextMessage.getMock();
|
||||||
// correlation ID is queried when response is being created...
|
// correlation ID is queried when response is being created...
|
||||||
sentTextMessage.getJMSCorrelationID();
|
sentTextMessage.getJMSCorrelationID();
|
||||||
mockSentTextMessage.setReturnValue(CORRELATION_ID);
|
mockSentTextMessage.setReturnValue(CORRELATION_ID);
|
||||||
// Reply-To is queried when response is being created...
|
// Reply-To is queried when response is being created...
|
||||||
sentTextMessage.getJMSReplyTo();
|
sentTextMessage.getJMSReplyTo();
|
||||||
mockSentTextMessage.setReturnValue(destination);
|
mockSentTextMessage.setReturnValue(destination);
|
||||||
mockSentTextMessage.replay();
|
mockSentTextMessage.replay();
|
||||||
|
|
||||||
MockControl mockResponseTextMessage = MockControl.createControl(TextMessage.class);
|
MockControl mockResponseTextMessage = MockControl.createControl(TextMessage.class);
|
||||||
TextMessage responseTextMessage = (TextMessage) mockResponseTextMessage.getMock();
|
TextMessage responseTextMessage = (TextMessage) mockResponseTextMessage.getMock();
|
||||||
responseTextMessage.setJMSCorrelationID(CORRELATION_ID);
|
responseTextMessage.setJMSCorrelationID(CORRELATION_ID);
|
||||||
mockResponseTextMessage.setVoidCallable();
|
mockResponseTextMessage.setVoidCallable();
|
||||||
mockResponseTextMessage.replay();
|
mockResponseTextMessage.replay();
|
||||||
|
|
||||||
MockControl mockQueueSender = MockControl.createControl(QueueSender.class);
|
MockControl mockQueueSender = MockControl.createControl(QueueSender.class);
|
||||||
QueueSender queueSender = (QueueSender) mockQueueSender.getMock();
|
QueueSender queueSender = (QueueSender) mockQueueSender.getMock();
|
||||||
queueSender.send(responseTextMessage);
|
queueSender.send(responseTextMessage);
|
||||||
mockQueueSender.setThrowable(new JMSException("Dow!"));
|
mockQueueSender.setThrowable(new JMSException("Dow!"));
|
||||||
// ensure that regardless of a JMSException the producer is closed...
|
// ensure that regardless of a JMSException the producer is closed...
|
||||||
queueSender.close();
|
queueSender.close();
|
||||||
mockQueueSender.setVoidCallable();
|
mockQueueSender.setVoidCallable();
|
||||||
mockQueueSender.replay();
|
mockQueueSender.replay();
|
||||||
|
|
||||||
MockControl mockSession = MockControl.createControl(QueueSession.class);
|
MockControl mockSession = MockControl.createControl(QueueSession.class);
|
||||||
final QueueSession session = (QueueSession) mockSession.getMock();
|
final QueueSession session = (QueueSession) mockSession.getMock();
|
||||||
session.createTextMessage(RESPONSE_TEXT);
|
session.createTextMessage(RESPONSE_TEXT);
|
||||||
mockSession.setReturnValue(responseTextMessage);
|
mockSession.setReturnValue(responseTextMessage);
|
||||||
session.createSender(destination);
|
session.createSender(destination);
|
||||||
mockSession.setReturnValue(queueSender);
|
mockSession.setReturnValue(queueSender);
|
||||||
mockSession.replay();
|
mockSession.replay();
|
||||||
|
|
||||||
MockControl mockDelegate = MockControl.createControl(ResponsiveMessageDelegate.class);
|
MockControl mockDelegate = MockControl.createControl(ResponsiveMessageDelegate.class);
|
||||||
ResponsiveMessageDelegate delegate = (ResponsiveMessageDelegate) mockDelegate.getMock();
|
ResponsiveMessageDelegate delegate = (ResponsiveMessageDelegate) mockDelegate.getMock();
|
||||||
delegate.handleMessage(sentTextMessage);
|
delegate.handleMessage(sentTextMessage);
|
||||||
mockDelegate.setReturnValue(RESPONSE_TEXT);
|
mockDelegate.setReturnValue(RESPONSE_TEXT);
|
||||||
mockDelegate.replay();
|
mockDelegate.replay();
|
||||||
|
|
||||||
final MessageListenerAdapter102 adapter = new MessageListenerAdapter102(delegate) {
|
final MessageListenerAdapter102 adapter = new MessageListenerAdapter102(delegate) {
|
||||||
protected Object extractMessage(Message message) {
|
protected Object extractMessage(Message message) {
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
new AssertThrows(JMSException.class) {
|
new AssertThrows(JMSException.class) {
|
||||||
public void test() throws Exception {
|
public void test() throws Exception {
|
||||||
adapter.onMessage(sentTextMessage, session);
|
adapter.onMessage(sentTextMessage, session);
|
||||||
}
|
}
|
||||||
}.runTest();
|
}.runTest();
|
||||||
|
|
||||||
mockDelegate.verify();
|
mockDelegate.verify();
|
||||||
mockSentTextMessage.verify();
|
mockSentTextMessage.verify();
|
||||||
mockResponseTextMessage.verify();
|
mockResponseTextMessage.verify();
|
||||||
mockSession.verify();
|
mockSession.verify();
|
||||||
mockDestination.verify();
|
mockDestination.verify();
|
||||||
mockQueueSender.verify();
|
mockQueueSender.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testWithResponsiveMessageDelegateDoesNotSendReturnTextMessageWhenSessionSupplied_AndListenerMethodThrowsException() throws Exception {
|
public void testWithResponsiveMessageDelegateDoesNotSendReturnTextMessageWhenSessionSupplied_AndListenerMethodThrowsException() throws Exception {
|
||||||
|
|
||||||
MockControl mockSentTextMessage = MockControl.createControl(TextMessage.class);
|
MockControl mockSentTextMessage = MockControl.createControl(TextMessage.class);
|
||||||
final TextMessage sentTextMessage = (TextMessage) mockSentTextMessage.getMock();
|
final TextMessage sentTextMessage = (TextMessage) mockSentTextMessage.getMock();
|
||||||
mockSentTextMessage.replay();
|
mockSentTextMessage.replay();
|
||||||
|
|
||||||
MockControl mockSession = MockControl.createControl(QueueSession.class);
|
MockControl mockSession = MockControl.createControl(QueueSession.class);
|
||||||
final QueueSession session = (QueueSession) mockSession.getMock();
|
final QueueSession session = (QueueSession) mockSession.getMock();
|
||||||
mockSession.replay();
|
mockSession.replay();
|
||||||
|
|
||||||
MockControl mockDelegate = MockControl.createControl(ResponsiveMessageDelegate.class);
|
MockControl mockDelegate = MockControl.createControl(ResponsiveMessageDelegate.class);
|
||||||
ResponsiveMessageDelegate delegate = (ResponsiveMessageDelegate) mockDelegate.getMock();
|
ResponsiveMessageDelegate delegate = (ResponsiveMessageDelegate) mockDelegate.getMock();
|
||||||
delegate.handleMessage(sentTextMessage);
|
delegate.handleMessage(sentTextMessage);
|
||||||
mockDelegate.setThrowable(new IllegalArgumentException("Dow!"));
|
mockDelegate.setThrowable(new IllegalArgumentException("Dow!"));
|
||||||
mockDelegate.replay();
|
mockDelegate.replay();
|
||||||
|
|
||||||
final MessageListenerAdapter102 adapter = new MessageListenerAdapter102(delegate) {
|
final MessageListenerAdapter102 adapter = new MessageListenerAdapter102(delegate) {
|
||||||
protected Object extractMessage(Message message) {
|
protected Object extractMessage(Message message) {
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
new AssertThrows(ListenerExecutionFailedException.class) {
|
new AssertThrows(ListenerExecutionFailedException.class) {
|
||||||
public void test() throws Exception {
|
public void test() throws Exception {
|
||||||
adapter.onMessage(sentTextMessage, session);
|
adapter.onMessage(sentTextMessage, session);
|
||||||
}
|
}
|
||||||
}.runTest();
|
}.runTest();
|
||||||
|
|
||||||
mockDelegate.verify();
|
mockDelegate.verify();
|
||||||
mockSentTextMessage.verify();
|
mockSentTextMessage.verify();
|
||||||
mockSession.verify();
|
mockSession.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,45 +28,45 @@ import javax.jms.Session;
|
||||||
*/
|
*/
|
||||||
public final class JmsAccessorTests extends TestCase {
|
public final class JmsAccessorTests extends TestCase {
|
||||||
|
|
||||||
public void testChokesIfConnectionFactoryIsNotSupplied() throws Exception {
|
public void testChokesIfConnectionFactoryIsNotSupplied() throws Exception {
|
||||||
new AssertThrows(IllegalArgumentException.class) {
|
new AssertThrows(IllegalArgumentException.class) {
|
||||||
public void test() throws Exception {
|
public void test() throws Exception {
|
||||||
JmsAccessor accessor = new StubJmsAccessor();
|
JmsAccessor accessor = new StubJmsAccessor();
|
||||||
accessor.afterPropertiesSet();
|
accessor.afterPropertiesSet();
|
||||||
}
|
}
|
||||||
}.runTest();
|
}.runTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSessionTransactedModeReallyDoesDefaultToFalse() throws Exception {
|
public void testSessionTransactedModeReallyDoesDefaultToFalse() throws Exception {
|
||||||
JmsAccessor accessor = new StubJmsAccessor();
|
JmsAccessor accessor = new StubJmsAccessor();
|
||||||
assertFalse("The [sessionTransacted] property of JmsAccessor must default to " +
|
assertFalse("The [sessionTransacted] property of JmsAccessor must default to " +
|
||||||
"false. Change this test (and the attendant Javadoc) if you have " +
|
"false. Change this test (and the attendant Javadoc) if you have " +
|
||||||
"changed the default.",
|
"changed the default.",
|
||||||
accessor.isSessionTransacted());
|
accessor.isSessionTransacted());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAcknowledgeModeReallyDoesDefaultToAutoAcknowledge() throws Exception {
|
public void testAcknowledgeModeReallyDoesDefaultToAutoAcknowledge() throws Exception {
|
||||||
JmsAccessor accessor = new StubJmsAccessor();
|
JmsAccessor accessor = new StubJmsAccessor();
|
||||||
assertEquals("The [sessionAcknowledgeMode] property of JmsAccessor must default to " +
|
assertEquals("The [sessionAcknowledgeMode] property of JmsAccessor must default to " +
|
||||||
"[Session.AUTO_ACKNOWLEDGE]. Change this test (and the attendant " +
|
"[Session.AUTO_ACKNOWLEDGE]. Change this test (and the attendant " +
|
||||||
"Javadoc) if you have changed the default.",
|
"Javadoc) if you have changed the default.",
|
||||||
Session.AUTO_ACKNOWLEDGE,
|
Session.AUTO_ACKNOWLEDGE,
|
||||||
accessor.getSessionAcknowledgeMode());
|
accessor.getSessionAcknowledgeMode());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSetAcknowledgeModeNameChokesIfBadAckModeIsSupplied() throws Exception {
|
public void testSetAcknowledgeModeNameChokesIfBadAckModeIsSupplied() throws Exception {
|
||||||
new AssertThrows(IllegalArgumentException.class) {
|
new AssertThrows(IllegalArgumentException.class) {
|
||||||
public void test() throws Exception {
|
public void test() throws Exception {
|
||||||
new StubJmsAccessor().setSessionAcknowledgeModeName("Tally ho chaps!");
|
new StubJmsAccessor().setSessionAcknowledgeModeName("Tally ho chaps!");
|
||||||
}
|
}
|
||||||
}.runTest();
|
}.runTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Crummy, stub, do-nothing subclass of the JmsAccessor class for use in testing.
|
* Crummy, stub, do-nothing subclass of the JmsAccessor class for use in testing.
|
||||||
*/
|
*/
|
||||||
private static final class StubJmsAccessor extends JmsAccessor {
|
private static final class StubJmsAccessor extends JmsAccessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,42 +35,42 @@ import java.util.Arrays;
|
||||||
*/
|
*/
|
||||||
public final class SimpleMessageConverter102Tests extends TestCase {
|
public final class SimpleMessageConverter102Tests extends TestCase {
|
||||||
|
|
||||||
public void testByteArrayConversion102() throws JMSException {
|
public void testByteArrayConversion102() throws JMSException {
|
||||||
MockControl sessionControl = MockControl.createControl(Session.class);
|
MockControl sessionControl = MockControl.createControl(Session.class);
|
||||||
Session session = (Session) sessionControl.getMock();
|
Session session = (Session) sessionControl.getMock();
|
||||||
MockControl messageControl = MockControl.createControl(BytesMessage.class);
|
MockControl messageControl = MockControl.createControl(BytesMessage.class);
|
||||||
BytesMessage message = (BytesMessage) messageControl.getMock();
|
BytesMessage message = (BytesMessage) messageControl.getMock();
|
||||||
|
|
||||||
byte[] content = new byte[5000];
|
byte[] content = new byte[5000];
|
||||||
|
|
||||||
session.createBytesMessage();
|
session.createBytesMessage();
|
||||||
sessionControl.setReturnValue(message, 1);
|
sessionControl.setReturnValue(message, 1);
|
||||||
message.writeBytes(content);
|
message.writeBytes(content);
|
||||||
messageControl.setVoidCallable(1);
|
messageControl.setVoidCallable(1);
|
||||||
message.readBytes(new byte[SimpleMessageConverter102.BUFFER_SIZE]);
|
message.readBytes(new byte[SimpleMessageConverter102.BUFFER_SIZE]);
|
||||||
messageControl.setMatcher(new ArgumentsMatcher() {
|
messageControl.setMatcher(new ArgumentsMatcher() {
|
||||||
public boolean matches(Object[] arg0, Object[] arg1) {
|
public boolean matches(Object[] arg0, Object[] arg1) {
|
||||||
byte[] one = (byte[]) arg0[0];
|
byte[] one = (byte[]) arg0[0];
|
||||||
byte[] two = (byte[]) arg1[0];
|
byte[] two = (byte[]) arg1[0];
|
||||||
return Arrays.equals(one, two);
|
return Arrays.equals(one, two);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString(Object[] arg0) {
|
public String toString(Object[] arg0) {
|
||||||
return "bla";
|
return "bla";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
messageControl.setReturnValue(SimpleMessageConverter102.BUFFER_SIZE, 1);
|
messageControl.setReturnValue(SimpleMessageConverter102.BUFFER_SIZE, 1);
|
||||||
message.readBytes(new byte[SimpleMessageConverter102.BUFFER_SIZE]);
|
message.readBytes(new byte[SimpleMessageConverter102.BUFFER_SIZE]);
|
||||||
messageControl.setReturnValue(5000 - SimpleMessageConverter102.BUFFER_SIZE, 1);
|
messageControl.setReturnValue(5000 - SimpleMessageConverter102.BUFFER_SIZE, 1);
|
||||||
sessionControl.replay();
|
sessionControl.replay();
|
||||||
messageControl.replay();
|
messageControl.replay();
|
||||||
|
|
||||||
SimpleMessageConverter102 converter = new SimpleMessageConverter102();
|
SimpleMessageConverter102 converter = new SimpleMessageConverter102();
|
||||||
Message msg = converter.toMessage(content, session);
|
Message msg = converter.toMessage(content, session);
|
||||||
assertEquals(content.length, ((byte[]) converter.fromMessage(msg)).length);
|
assertEquals(content.length, ((byte[]) converter.fromMessage(msg)).length);
|
||||||
|
|
||||||
sessionControl.verify();
|
sessionControl.verify();
|
||||||
messageControl.verify();
|
messageControl.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,222 +38,222 @@ import java.util.Map;
|
||||||
*/
|
*/
|
||||||
public final class SimpleMessageConverterTests extends TestCase {
|
public final class SimpleMessageConverterTests extends TestCase {
|
||||||
|
|
||||||
public void testStringConversion() throws JMSException {
|
public void testStringConversion() throws JMSException {
|
||||||
MockControl sessionControl = MockControl.createControl(Session.class);
|
MockControl sessionControl = MockControl.createControl(Session.class);
|
||||||
Session session = (Session) sessionControl.getMock();
|
Session session = (Session) sessionControl.getMock();
|
||||||
MockControl messageControl = MockControl.createControl(TextMessage.class);
|
MockControl messageControl = MockControl.createControl(TextMessage.class);
|
||||||
TextMessage message = (TextMessage) messageControl.getMock();
|
TextMessage message = (TextMessage) messageControl.getMock();
|
||||||
|
|
||||||
String content = "test";
|
String content = "test";
|
||||||
|
|
||||||
session.createTextMessage(content);
|
session.createTextMessage(content);
|
||||||
sessionControl.setReturnValue(message, 1);
|
sessionControl.setReturnValue(message, 1);
|
||||||
message.getText();
|
message.getText();
|
||||||
messageControl.setReturnValue(content, 1);
|
messageControl.setReturnValue(content, 1);
|
||||||
sessionControl.replay();
|
sessionControl.replay();
|
||||||
messageControl.replay();
|
messageControl.replay();
|
||||||
|
|
||||||
SimpleMessageConverter converter = new SimpleMessageConverter();
|
SimpleMessageConverter converter = new SimpleMessageConverter();
|
||||||
Message msg = converter.toMessage(content, session);
|
Message msg = converter.toMessage(content, session);
|
||||||
assertEquals(content, converter.fromMessage(msg));
|
assertEquals(content, converter.fromMessage(msg));
|
||||||
|
|
||||||
sessionControl.verify();
|
sessionControl.verify();
|
||||||
messageControl.verify();
|
messageControl.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testByteArrayConversion() throws JMSException {
|
public void testByteArrayConversion() throws JMSException {
|
||||||
MockControl sessionControl = MockControl.createControl(Session.class);
|
MockControl sessionControl = MockControl.createControl(Session.class);
|
||||||
Session session = (Session) sessionControl.getMock();
|
Session session = (Session) sessionControl.getMock();
|
||||||
MockControl messageControl = MockControl.createControl(BytesMessage.class);
|
MockControl messageControl = MockControl.createControl(BytesMessage.class);
|
||||||
BytesMessage message = (BytesMessage) messageControl.getMock();
|
BytesMessage message = (BytesMessage) messageControl.getMock();
|
||||||
|
|
||||||
byte[] content = "test".getBytes();
|
byte[] content = "test".getBytes();
|
||||||
|
|
||||||
session.createBytesMessage();
|
session.createBytesMessage();
|
||||||
sessionControl.setReturnValue(message, 1);
|
sessionControl.setReturnValue(message, 1);
|
||||||
message.writeBytes(content);
|
message.writeBytes(content);
|
||||||
messageControl.setVoidCallable(1);
|
messageControl.setVoidCallable(1);
|
||||||
message.getBodyLength();
|
message.getBodyLength();
|
||||||
messageControl.setReturnValue(content.length, 1);
|
messageControl.setReturnValue(content.length, 1);
|
||||||
message.readBytes(new byte[content.length]);
|
message.readBytes(new byte[content.length]);
|
||||||
messageControl.setMatcher(new ArgumentsMatcher() {
|
messageControl.setMatcher(new ArgumentsMatcher() {
|
||||||
public boolean matches(Object[] arg0, Object[] arg1) {
|
public boolean matches(Object[] arg0, Object[] arg1) {
|
||||||
byte[] one = (byte[]) arg0[0];
|
byte[] one = (byte[]) arg0[0];
|
||||||
byte[] two = (byte[]) arg1[0];
|
byte[] two = (byte[]) arg1[0];
|
||||||
return Arrays.equals(one, two);
|
return Arrays.equals(one, two);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString(Object[] arg0) {
|
public String toString(Object[] arg0) {
|
||||||
return "bla";
|
return "bla";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
messageControl.setReturnValue(content.length, 1);
|
messageControl.setReturnValue(content.length, 1);
|
||||||
sessionControl.replay();
|
sessionControl.replay();
|
||||||
messageControl.replay();
|
messageControl.replay();
|
||||||
|
|
||||||
SimpleMessageConverter converter = new SimpleMessageConverter();
|
SimpleMessageConverter converter = new SimpleMessageConverter();
|
||||||
Message msg = converter.toMessage(content, session);
|
Message msg = converter.toMessage(content, session);
|
||||||
assertEquals(content.length, ((byte[]) converter.fromMessage(msg)).length);
|
assertEquals(content.length, ((byte[]) converter.fromMessage(msg)).length);
|
||||||
|
|
||||||
sessionControl.verify();
|
sessionControl.verify();
|
||||||
messageControl.verify();
|
messageControl.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testMapConversion() throws JMSException {
|
public void testMapConversion() throws JMSException {
|
||||||
|
|
||||||
MockControl sessionControl = MockControl.createControl(Session.class);
|
MockControl sessionControl = MockControl.createControl(Session.class);
|
||||||
Session session = (Session) sessionControl.getMock();
|
Session session = (Session) sessionControl.getMock();
|
||||||
MockControl messageControl = MockControl.createControl(MapMessage.class);
|
MockControl messageControl = MockControl.createControl(MapMessage.class);
|
||||||
MapMessage message = (MapMessage) messageControl.getMock();
|
MapMessage message = (MapMessage) messageControl.getMock();
|
||||||
|
|
||||||
Map content = new HashMap();
|
Map content = new HashMap();
|
||||||
content.put("key1", "value1");
|
content.put("key1", "value1");
|
||||||
content.put("key2", "value2");
|
content.put("key2", "value2");
|
||||||
|
|
||||||
session.createMapMessage();
|
session.createMapMessage();
|
||||||
sessionControl.setReturnValue(message, 1);
|
sessionControl.setReturnValue(message, 1);
|
||||||
message.setObject("key1", "value1");
|
message.setObject("key1", "value1");
|
||||||
messageControl.setVoidCallable(1);
|
messageControl.setVoidCallable(1);
|
||||||
message.setObject("key2", "value2");
|
message.setObject("key2", "value2");
|
||||||
messageControl.setVoidCallable(1);
|
messageControl.setVoidCallable(1);
|
||||||
message.getMapNames();
|
message.getMapNames();
|
||||||
messageControl.setReturnValue(Collections.enumeration(content.keySet()));
|
messageControl.setReturnValue(Collections.enumeration(content.keySet()));
|
||||||
message.getObject("key1");
|
message.getObject("key1");
|
||||||
messageControl.setReturnValue("value1", 1);
|
messageControl.setReturnValue("value1", 1);
|
||||||
message.getObject("key2");
|
message.getObject("key2");
|
||||||
messageControl.setReturnValue("value2", 1);
|
messageControl.setReturnValue("value2", 1);
|
||||||
|
|
||||||
sessionControl.replay();
|
sessionControl.replay();
|
||||||
messageControl.replay();
|
messageControl.replay();
|
||||||
|
|
||||||
SimpleMessageConverter converter = new SimpleMessageConverter();
|
SimpleMessageConverter converter = new SimpleMessageConverter();
|
||||||
Message msg = converter.toMessage(content, session);
|
Message msg = converter.toMessage(content, session);
|
||||||
assertEquals(content, converter.fromMessage(msg));
|
assertEquals(content, converter.fromMessage(msg));
|
||||||
|
|
||||||
sessionControl.verify();
|
sessionControl.verify();
|
||||||
messageControl.verify();
|
messageControl.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSerializableConversion() throws JMSException {
|
public void testSerializableConversion() throws JMSException {
|
||||||
MockControl sessionControl = MockControl.createControl(Session.class);
|
MockControl sessionControl = MockControl.createControl(Session.class);
|
||||||
Session session = (Session) sessionControl.getMock();
|
Session session = (Session) sessionControl.getMock();
|
||||||
MockControl messageControl = MockControl.createControl(ObjectMessage.class);
|
MockControl messageControl = MockControl.createControl(ObjectMessage.class);
|
||||||
ObjectMessage message = (ObjectMessage) messageControl.getMock();
|
ObjectMessage message = (ObjectMessage) messageControl.getMock();
|
||||||
|
|
||||||
Integer content = new Integer(5);
|
Integer content = new Integer(5);
|
||||||
|
|
||||||
session.createObjectMessage(content);
|
session.createObjectMessage(content);
|
||||||
sessionControl.setReturnValue(message, 1);
|
sessionControl.setReturnValue(message, 1);
|
||||||
message.getObject();
|
message.getObject();
|
||||||
messageControl.setReturnValue(content, 1);
|
messageControl.setReturnValue(content, 1);
|
||||||
sessionControl.replay();
|
sessionControl.replay();
|
||||||
messageControl.replay();
|
messageControl.replay();
|
||||||
|
|
||||||
SimpleMessageConverter converter = new SimpleMessageConverter();
|
SimpleMessageConverter converter = new SimpleMessageConverter();
|
||||||
Message msg = converter.toMessage(content, session);
|
Message msg = converter.toMessage(content, session);
|
||||||
assertEquals(content, converter.fromMessage(msg));
|
assertEquals(content, converter.fromMessage(msg));
|
||||||
|
|
||||||
sessionControl.verify();
|
sessionControl.verify();
|
||||||
messageControl.verify();
|
messageControl.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testToMessageThrowsExceptionIfGivenNullObjectToConvert() throws Exception {
|
public void testToMessageThrowsExceptionIfGivenNullObjectToConvert() throws Exception {
|
||||||
new AssertThrows(MessageConversionException.class) {
|
new AssertThrows(MessageConversionException.class) {
|
||||||
public void test() throws Exception {
|
public void test() throws Exception {
|
||||||
new SimpleMessageConverter().toMessage(null, null);
|
new SimpleMessageConverter().toMessage(null, null);
|
||||||
}
|
}
|
||||||
}.runTest();
|
}.runTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testToMessageThrowsExceptionIfGivenIncompatibleObjectToConvert() throws Exception {
|
public void testToMessageThrowsExceptionIfGivenIncompatibleObjectToConvert() throws Exception {
|
||||||
new AssertThrows(MessageConversionException.class) {
|
new AssertThrows(MessageConversionException.class) {
|
||||||
public void test() throws Exception {
|
public void test() throws Exception {
|
||||||
new SimpleMessageConverter().toMessage(new Object(), null);
|
new SimpleMessageConverter().toMessage(new Object(), null);
|
||||||
}
|
}
|
||||||
}.runTest();
|
}.runTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testToMessageSimplyReturnsMessageAsIsIfSuppliedWithMessage() throws JMSException {
|
public void testToMessageSimplyReturnsMessageAsIsIfSuppliedWithMessage() throws JMSException {
|
||||||
|
|
||||||
MockControl sessionControl = MockControl.createControl(Session.class);
|
MockControl sessionControl = MockControl.createControl(Session.class);
|
||||||
Session session = (Session) sessionControl.getMock();
|
Session session = (Session) sessionControl.getMock();
|
||||||
|
|
||||||
MockControl messageControl = MockControl.createControl(ObjectMessage.class);
|
MockControl messageControl = MockControl.createControl(ObjectMessage.class);
|
||||||
ObjectMessage message = (ObjectMessage) messageControl.getMock();
|
ObjectMessage message = (ObjectMessage) messageControl.getMock();
|
||||||
|
|
||||||
sessionControl.replay();
|
sessionControl.replay();
|
||||||
messageControl.replay();
|
messageControl.replay();
|
||||||
|
|
||||||
SimpleMessageConverter converter = new SimpleMessageConverter();
|
SimpleMessageConverter converter = new SimpleMessageConverter();
|
||||||
Message msg = converter.toMessage(message, session);
|
Message msg = converter.toMessage(message, session);
|
||||||
assertSame(message, msg);
|
assertSame(message, msg);
|
||||||
|
|
||||||
sessionControl.verify();
|
sessionControl.verify();
|
||||||
messageControl.verify();
|
messageControl.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testFromMessageSimplyReturnsMessageAsIsIfSuppliedWithMessage() throws JMSException {
|
public void testFromMessageSimplyReturnsMessageAsIsIfSuppliedWithMessage() throws JMSException {
|
||||||
|
|
||||||
MockControl messageControl = MockControl.createControl(Message.class);
|
MockControl messageControl = MockControl.createControl(Message.class);
|
||||||
Message message = (Message) messageControl.getMock();
|
Message message = (Message) messageControl.getMock();
|
||||||
|
|
||||||
messageControl.replay();
|
messageControl.replay();
|
||||||
|
|
||||||
SimpleMessageConverter converter = new SimpleMessageConverter();
|
SimpleMessageConverter converter = new SimpleMessageConverter();
|
||||||
Object msg = converter.fromMessage(message);
|
Object msg = converter.fromMessage(message);
|
||||||
assertSame(message, msg);
|
assertSame(message, msg);
|
||||||
|
|
||||||
messageControl.verify();
|
messageControl.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testMapConversionWhereMapHasNonStringTypesForKeys() throws JMSException {
|
public void testMapConversionWhereMapHasNonStringTypesForKeys() throws JMSException {
|
||||||
|
|
||||||
MockControl messageControl = MockControl.createControl(MapMessage.class);
|
MockControl messageControl = MockControl.createControl(MapMessage.class);
|
||||||
MapMessage message = (MapMessage) messageControl.getMock();
|
MapMessage message = (MapMessage) messageControl.getMock();
|
||||||
messageControl.replay();
|
messageControl.replay();
|
||||||
|
|
||||||
MockControl sessionControl = MockControl.createControl(Session.class);
|
MockControl sessionControl = MockControl.createControl(Session.class);
|
||||||
final Session session = (Session) sessionControl.getMock();
|
final Session session = (Session) sessionControl.getMock();
|
||||||
session.createMapMessage();
|
session.createMapMessage();
|
||||||
sessionControl.setReturnValue(message);
|
sessionControl.setReturnValue(message);
|
||||||
sessionControl.replay();
|
sessionControl.replay();
|
||||||
|
|
||||||
final Map content = new HashMap();
|
final Map content = new HashMap();
|
||||||
content.put(new Integer(1), "value1");
|
content.put(new Integer(1), "value1");
|
||||||
|
|
||||||
final SimpleMessageConverter converter = new SimpleMessageConverter();
|
final SimpleMessageConverter converter = new SimpleMessageConverter();
|
||||||
new AssertThrows(MessageConversionException.class) {
|
new AssertThrows(MessageConversionException.class) {
|
||||||
public void test() throws Exception {
|
public void test() throws Exception {
|
||||||
converter.toMessage(content, session);
|
converter.toMessage(content, session);
|
||||||
}
|
}
|
||||||
}.runTest();
|
}.runTest();
|
||||||
|
|
||||||
sessionControl.verify();
|
sessionControl.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testMapConversionWhereMapHasNNullForKey() throws JMSException {
|
public void testMapConversionWhereMapHasNNullForKey() throws JMSException {
|
||||||
|
|
||||||
MockControl messageControl = MockControl.createControl(MapMessage.class);
|
MockControl messageControl = MockControl.createControl(MapMessage.class);
|
||||||
MapMessage message = (MapMessage) messageControl.getMock();
|
MapMessage message = (MapMessage) messageControl.getMock();
|
||||||
messageControl.replay();
|
messageControl.replay();
|
||||||
|
|
||||||
MockControl sessionControl = MockControl.createControl(Session.class);
|
MockControl sessionControl = MockControl.createControl(Session.class);
|
||||||
final Session session = (Session) sessionControl.getMock();
|
final Session session = (Session) sessionControl.getMock();
|
||||||
session.createMapMessage();
|
session.createMapMessage();
|
||||||
sessionControl.setReturnValue(message);
|
sessionControl.setReturnValue(message);
|
||||||
sessionControl.replay();
|
sessionControl.replay();
|
||||||
|
|
||||||
final Map content = new HashMap();
|
final Map content = new HashMap();
|
||||||
content.put(null, "value1");
|
content.put(null, "value1");
|
||||||
|
|
||||||
final SimpleMessageConverter converter = new SimpleMessageConverter();
|
final SimpleMessageConverter converter = new SimpleMessageConverter();
|
||||||
new AssertThrows(MessageConversionException.class) {
|
new AssertThrows(MessageConversionException.class) {
|
||||||
public void test() throws Exception {
|
public void test() throws Exception {
|
||||||
converter.toMessage(content, session);
|
converter.toMessage(content, session);
|
||||||
}
|
}
|
||||||
}.runTest();
|
}.runTest();
|
||||||
|
|
||||||
sessionControl.verify();
|
sessionControl.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,8 +35,8 @@ import org.springframework.transaction.support.TransactionSynchronizationManager
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
*/
|
*/
|
||||||
public class SharedEntityManagerFactoryTests {
|
public class SharedEntityManagerFactoryTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testValidUsage() {
|
public void testValidUsage() {
|
||||||
Object o = new Object();
|
Object o = new Object();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ import edu.emory.mathcs.backport.java.util.concurrent.ThreadFactory;
|
||||||
*/
|
*/
|
||||||
public class ScheduledExecutorFactoryBeanTests {
|
public class ScheduledExecutorFactoryBeanTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testThrowsExceptionIfPoolSizeIsLessThanZero() throws Exception {
|
public void testThrowsExceptionIfPoolSizeIsLessThanZero() throws Exception {
|
||||||
try {
|
try {
|
||||||
ScheduledExecutorFactoryBean factory = new ScheduledExecutorFactoryBean();
|
ScheduledExecutorFactoryBean factory = new ScheduledExecutorFactoryBean();
|
||||||
|
|
@ -51,7 +51,7 @@ public class ScheduledExecutorFactoryBeanTests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testShutdownNowIsPropagatedToTheExecutorOnDestroy() throws Exception {
|
public void testShutdownNowIsPropagatedToTheExecutorOnDestroy() throws Exception {
|
||||||
MockControl mockScheduledExecutorService = MockControl.createNiceControl(ScheduledExecutorService.class);
|
MockControl mockScheduledExecutorService = MockControl.createNiceControl(ScheduledExecutorService.class);
|
||||||
final ScheduledExecutorService executor = (ScheduledExecutorService) mockScheduledExecutorService.getMock();
|
final ScheduledExecutorService executor = (ScheduledExecutorService) mockScheduledExecutorService.getMock();
|
||||||
|
|
@ -73,7 +73,7 @@ public class ScheduledExecutorFactoryBeanTests {
|
||||||
mockScheduledExecutorService.verify();
|
mockScheduledExecutorService.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testShutdownIsPropagatedToTheExecutorOnDestroy() throws Exception {
|
public void testShutdownIsPropagatedToTheExecutorOnDestroy() throws Exception {
|
||||||
MockControl mockScheduledExecutorService = MockControl.createNiceControl(ScheduledExecutorService.class);
|
MockControl mockScheduledExecutorService = MockControl.createNiceControl(ScheduledExecutorService.class);
|
||||||
final ScheduledExecutorService executor = (ScheduledExecutorService) mockScheduledExecutorService.getMock();
|
final ScheduledExecutorService executor = (ScheduledExecutorService) mockScheduledExecutorService.getMock();
|
||||||
|
|
@ -96,7 +96,7 @@ public class ScheduledExecutorFactoryBeanTests {
|
||||||
mockScheduledExecutorService.verify();
|
mockScheduledExecutorService.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testOneTimeExecutionIsSetUpAndFiresCorrectly() throws Exception {
|
public void testOneTimeExecutionIsSetUpAndFiresCorrectly() throws Exception {
|
||||||
MockControl mockRunnable = MockControl.createControl(Runnable.class);
|
MockControl mockRunnable = MockControl.createControl(Runnable.class);
|
||||||
Runnable runnable = (Runnable) mockRunnable.getMock();
|
Runnable runnable = (Runnable) mockRunnable.getMock();
|
||||||
|
|
@ -115,7 +115,7 @@ public class ScheduledExecutorFactoryBeanTests {
|
||||||
mockRunnable.verify();
|
mockRunnable.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFixedRepeatedExecutionIsSetUpAndFiresCorrectly() throws Exception {
|
public void testFixedRepeatedExecutionIsSetUpAndFiresCorrectly() throws Exception {
|
||||||
MockControl mockRunnable = MockControl.createControl(Runnable.class);
|
MockControl mockRunnable = MockControl.createControl(Runnable.class);
|
||||||
Runnable runnable = (Runnable) mockRunnable.getMock();
|
Runnable runnable = (Runnable) mockRunnable.getMock();
|
||||||
|
|
@ -138,7 +138,7 @@ public class ScheduledExecutorFactoryBeanTests {
|
||||||
mockRunnable.verify();
|
mockRunnable.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFixedRepeatedExecutionIsSetUpAndFiresCorrectlyAfterException() throws Exception {
|
public void testFixedRepeatedExecutionIsSetUpAndFiresCorrectlyAfterException() throws Exception {
|
||||||
MockControl mockRunnable = MockControl.createControl(Runnable.class);
|
MockControl mockRunnable = MockControl.createControl(Runnable.class);
|
||||||
Runnable runnable = (Runnable) mockRunnable.getMock();
|
Runnable runnable = (Runnable) mockRunnable.getMock();
|
||||||
|
|
@ -162,8 +162,8 @@ public class ScheduledExecutorFactoryBeanTests {
|
||||||
mockRunnable.verify();
|
mockRunnable.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
@Test
|
@Test
|
||||||
public void testWithInitialDelayRepeatedExecutionIsSetUpAndFiresCorrectly() throws Exception {
|
public void testWithInitialDelayRepeatedExecutionIsSetUpAndFiresCorrectly() throws Exception {
|
||||||
MockControl mockRunnable = MockControl.createControl(Runnable.class);
|
MockControl mockRunnable = MockControl.createControl(Runnable.class);
|
||||||
Runnable runnable = (Runnable) mockRunnable.getMock();
|
Runnable runnable = (Runnable) mockRunnable.getMock();
|
||||||
|
|
@ -192,8 +192,8 @@ public class ScheduledExecutorFactoryBeanTests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
@Test
|
@Test
|
||||||
public void testWithInitialDelayRepeatedExecutionIsSetUpAndFiresCorrectlyAfterException() throws Exception {
|
public void testWithInitialDelayRepeatedExecutionIsSetUpAndFiresCorrectlyAfterException() throws Exception {
|
||||||
MockControl mockRunnable = MockControl.createControl(Runnable.class);
|
MockControl mockRunnable = MockControl.createControl(Runnable.class);
|
||||||
Runnable runnable = (Runnable) mockRunnable.getMock();
|
Runnable runnable = (Runnable) mockRunnable.getMock();
|
||||||
|
|
@ -223,7 +223,7 @@ public class ScheduledExecutorFactoryBeanTests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSettingThreadFactoryToNullForcesUseOfDefaultButIsOtherwiseCool() throws Exception {
|
public void testSettingThreadFactoryToNullForcesUseOfDefaultButIsOtherwiseCool() throws Exception {
|
||||||
ScheduledExecutorFactoryBean factory = new ScheduledExecutorFactoryBean() {
|
ScheduledExecutorFactoryBean factory = new ScheduledExecutorFactoryBean() {
|
||||||
protected ScheduledExecutorService createExecutor(int poolSize, ThreadFactory threadFactory, RejectedExecutionHandler rejectedExecutionHandler) {
|
protected ScheduledExecutorService createExecutor(int poolSize, ThreadFactory threadFactory, RejectedExecutionHandler rejectedExecutionHandler) {
|
||||||
|
|
@ -239,7 +239,7 @@ public class ScheduledExecutorFactoryBeanTests {
|
||||||
factory.destroy();
|
factory.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSettingRejectedExecutionHandlerToNullForcesUseOfDefaultButIsOtherwiseCool() throws Exception {
|
public void testSettingRejectedExecutionHandlerToNullForcesUseOfDefaultButIsOtherwiseCool() throws Exception {
|
||||||
ScheduledExecutorFactoryBean factory = new ScheduledExecutorFactoryBean() {
|
ScheduledExecutorFactoryBean factory = new ScheduledExecutorFactoryBean() {
|
||||||
protected ScheduledExecutorService createExecutor(int poolSize, ThreadFactory threadFactory, RejectedExecutionHandler rejectedExecutionHandler) {
|
protected ScheduledExecutorService createExecutor(int poolSize, ThreadFactory threadFactory, RejectedExecutionHandler rejectedExecutionHandler) {
|
||||||
|
|
@ -255,7 +255,7 @@ public class ScheduledExecutorFactoryBeanTests {
|
||||||
factory.destroy();
|
factory.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testObjectTypeReportsCorrectType() throws Exception {
|
public void testObjectTypeReportsCorrectType() throws Exception {
|
||||||
ScheduledExecutorFactoryBean factory = new ScheduledExecutorFactoryBean();
|
ScheduledExecutorFactoryBean factory = new ScheduledExecutorFactoryBean();
|
||||||
assertEquals(ScheduledExecutorService.class, factory.getObjectType());
|
assertEquals(ScheduledExecutorService.class, factory.getObjectType());
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ import org.springframework.core.task.NoOpRunnable;
|
||||||
*/
|
*/
|
||||||
public class ScheduledExecutorFactoryBeanTests {
|
public class ScheduledExecutorFactoryBeanTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testThrowsExceptionIfPoolSizeIsLessThanZero() throws Exception {
|
public void testThrowsExceptionIfPoolSizeIsLessThanZero() throws Exception {
|
||||||
try {
|
try {
|
||||||
ScheduledExecutorFactoryBean factory = new ScheduledExecutorFactoryBean();
|
ScheduledExecutorFactoryBean factory = new ScheduledExecutorFactoryBean();
|
||||||
|
|
@ -52,7 +52,7 @@ public class ScheduledExecutorFactoryBeanTests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testShutdownNowIsPropagatedToTheExecutorOnDestroy() throws Exception {
|
public void testShutdownNowIsPropagatedToTheExecutorOnDestroy() throws Exception {
|
||||||
MockControl mockScheduledExecutorService = MockControl.createNiceControl(ScheduledExecutorService.class);
|
MockControl mockScheduledExecutorService = MockControl.createNiceControl(ScheduledExecutorService.class);
|
||||||
final ScheduledExecutorService executor = (ScheduledExecutorService) mockScheduledExecutorService.getMock();
|
final ScheduledExecutorService executor = (ScheduledExecutorService) mockScheduledExecutorService.getMock();
|
||||||
|
|
@ -74,7 +74,7 @@ public class ScheduledExecutorFactoryBeanTests {
|
||||||
mockScheduledExecutorService.verify();
|
mockScheduledExecutorService.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testShutdownIsPropagatedToTheExecutorOnDestroy() throws Exception {
|
public void testShutdownIsPropagatedToTheExecutorOnDestroy() throws Exception {
|
||||||
MockControl mockScheduledExecutorService = MockControl.createNiceControl(ScheduledExecutorService.class);
|
MockControl mockScheduledExecutorService = MockControl.createNiceControl(ScheduledExecutorService.class);
|
||||||
final ScheduledExecutorService executor = (ScheduledExecutorService) mockScheduledExecutorService.getMock();
|
final ScheduledExecutorService executor = (ScheduledExecutorService) mockScheduledExecutorService.getMock();
|
||||||
|
|
@ -97,7 +97,7 @@ public class ScheduledExecutorFactoryBeanTests {
|
||||||
mockScheduledExecutorService.verify();
|
mockScheduledExecutorService.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testOneTimeExecutionIsSetUpAndFiresCorrectly() throws Exception {
|
public void testOneTimeExecutionIsSetUpAndFiresCorrectly() throws Exception {
|
||||||
MockControl mockRunnable = MockControl.createControl(Runnable.class);
|
MockControl mockRunnable = MockControl.createControl(Runnable.class);
|
||||||
Runnable runnable = (Runnable) mockRunnable.getMock();
|
Runnable runnable = (Runnable) mockRunnable.getMock();
|
||||||
|
|
@ -116,7 +116,7 @@ public class ScheduledExecutorFactoryBeanTests {
|
||||||
mockRunnable.verify();
|
mockRunnable.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFixedRepeatedExecutionIsSetUpAndFiresCorrectly() throws Exception {
|
public void testFixedRepeatedExecutionIsSetUpAndFiresCorrectly() throws Exception {
|
||||||
MockControl mockRunnable = MockControl.createControl(Runnable.class);
|
MockControl mockRunnable = MockControl.createControl(Runnable.class);
|
||||||
Runnable runnable = (Runnable) mockRunnable.getMock();
|
Runnable runnable = (Runnable) mockRunnable.getMock();
|
||||||
|
|
@ -139,7 +139,7 @@ public class ScheduledExecutorFactoryBeanTests {
|
||||||
mockRunnable.verify();
|
mockRunnable.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFixedRepeatedExecutionIsSetUpAndFiresCorrectlyAfterException() throws Exception {
|
public void testFixedRepeatedExecutionIsSetUpAndFiresCorrectlyAfterException() throws Exception {
|
||||||
MockControl mockRunnable = MockControl.createControl(Runnable.class);
|
MockControl mockRunnable = MockControl.createControl(Runnable.class);
|
||||||
Runnable runnable = (Runnable) mockRunnable.getMock();
|
Runnable runnable = (Runnable) mockRunnable.getMock();
|
||||||
|
|
@ -163,8 +163,8 @@ public class ScheduledExecutorFactoryBeanTests {
|
||||||
mockRunnable.verify();
|
mockRunnable.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
@Test
|
@Test
|
||||||
public void testWithInitialDelayRepeatedExecutionIsSetUpAndFiresCorrectly() throws Exception {
|
public void testWithInitialDelayRepeatedExecutionIsSetUpAndFiresCorrectly() throws Exception {
|
||||||
MockControl mockRunnable = MockControl.createControl(Runnable.class);
|
MockControl mockRunnable = MockControl.createControl(Runnable.class);
|
||||||
Runnable runnable = (Runnable) mockRunnable.getMock();
|
Runnable runnable = (Runnable) mockRunnable.getMock();
|
||||||
|
|
@ -193,8 +193,8 @@ public class ScheduledExecutorFactoryBeanTests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
@Test
|
@Test
|
||||||
public void testWithInitialDelayRepeatedExecutionIsSetUpAndFiresCorrectlyAfterException() throws Exception {
|
public void testWithInitialDelayRepeatedExecutionIsSetUpAndFiresCorrectlyAfterException() throws Exception {
|
||||||
MockControl mockRunnable = MockControl.createControl(Runnable.class);
|
MockControl mockRunnable = MockControl.createControl(Runnable.class);
|
||||||
Runnable runnable = (Runnable) mockRunnable.getMock();
|
Runnable runnable = (Runnable) mockRunnable.getMock();
|
||||||
|
|
@ -224,7 +224,7 @@ public class ScheduledExecutorFactoryBeanTests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSettingThreadFactoryToNullForcesUseOfDefaultButIsOtherwiseCool() throws Exception {
|
public void testSettingThreadFactoryToNullForcesUseOfDefaultButIsOtherwiseCool() throws Exception {
|
||||||
ScheduledExecutorFactoryBean factory = new ScheduledExecutorFactoryBean() {
|
ScheduledExecutorFactoryBean factory = new ScheduledExecutorFactoryBean() {
|
||||||
protected ScheduledExecutorService createExecutor(int poolSize, ThreadFactory threadFactory, RejectedExecutionHandler rejectedExecutionHandler) {
|
protected ScheduledExecutorService createExecutor(int poolSize, ThreadFactory threadFactory, RejectedExecutionHandler rejectedExecutionHandler) {
|
||||||
|
|
@ -240,7 +240,7 @@ public class ScheduledExecutorFactoryBeanTests {
|
||||||
factory.destroy();
|
factory.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSettingRejectedExecutionHandlerToNullForcesUseOfDefaultButIsOtherwiseCool() throws Exception {
|
public void testSettingRejectedExecutionHandlerToNullForcesUseOfDefaultButIsOtherwiseCool() throws Exception {
|
||||||
ScheduledExecutorFactoryBean factory = new ScheduledExecutorFactoryBean() {
|
ScheduledExecutorFactoryBean factory = new ScheduledExecutorFactoryBean() {
|
||||||
protected ScheduledExecutorService createExecutor(int poolSize, ThreadFactory threadFactory, RejectedExecutionHandler rejectedExecutionHandler) {
|
protected ScheduledExecutorService createExecutor(int poolSize, ThreadFactory threadFactory, RejectedExecutionHandler rejectedExecutionHandler) {
|
||||||
|
|
@ -256,7 +256,7 @@ public class ScheduledExecutorFactoryBeanTests {
|
||||||
factory.destroy();
|
factory.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testObjectTypeReportsCorrectType() throws Exception {
|
public void testObjectTypeReportsCorrectType() throws Exception {
|
||||||
ScheduledExecutorFactoryBean factory = new ScheduledExecutorFactoryBean();
|
ScheduledExecutorFactoryBean factory = new ScheduledExecutorFactoryBean();
|
||||||
assertEquals(ScheduledExecutorService.class, factory.getObjectType());
|
assertEquals(ScheduledExecutorService.class, factory.getObjectType());
|
||||||
|
|
|
||||||
|
|
@ -28,162 +28,162 @@ import java.util.Timer;
|
||||||
*/
|
*/
|
||||||
public final class TimerTaskExecutorTests extends TestCase {
|
public final class TimerTaskExecutorTests extends TestCase {
|
||||||
|
|
||||||
public void testExecuteChokesWithNullTimer() throws Exception {
|
public void testExecuteChokesWithNullTimer() throws Exception {
|
||||||
new AssertThrows(IllegalArgumentException.class) {
|
new AssertThrows(IllegalArgumentException.class) {
|
||||||
public void test() throws Exception {
|
public void test() throws Exception {
|
||||||
TimerTaskExecutor executor = new TimerTaskExecutor();
|
TimerTaskExecutor executor = new TimerTaskExecutor();
|
||||||
executor.execute(new NoOpRunnable());
|
executor.execute(new NoOpRunnable());
|
||||||
}
|
}
|
||||||
}.runTest();
|
}.runTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testExecuteChokesWithNullTask() throws Exception {
|
public void testExecuteChokesWithNullTask() throws Exception {
|
||||||
new AssertThrows(IllegalArgumentException.class) {
|
new AssertThrows(IllegalArgumentException.class) {
|
||||||
public void test() throws Exception {
|
public void test() throws Exception {
|
||||||
TimerTaskExecutor executor = new TimerTaskExecutor(new Timer());
|
TimerTaskExecutor executor = new TimerTaskExecutor(new Timer());
|
||||||
executor.execute(null);
|
executor.execute(null);
|
||||||
}
|
}
|
||||||
}.runTest();
|
}.runTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testExecuteChokesWithNegativeDelay() throws Exception {
|
public void testExecuteChokesWithNegativeDelay() throws Exception {
|
||||||
new AssertThrows(IllegalArgumentException.class) {
|
new AssertThrows(IllegalArgumentException.class) {
|
||||||
public void test() throws Exception {
|
public void test() throws Exception {
|
||||||
TimerTaskExecutor executor = new TimerTaskExecutor(new Timer());
|
TimerTaskExecutor executor = new TimerTaskExecutor(new Timer());
|
||||||
executor.setDelay(-10);
|
executor.setDelay(-10);
|
||||||
executor.execute(new NoOpRunnable());
|
executor.execute(new NoOpRunnable());
|
||||||
}
|
}
|
||||||
}.runTest();
|
}.runTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testExecuteReallyDoesScheduleTheSuppliedTask() throws Exception {
|
public void testExecuteReallyDoesScheduleTheSuppliedTask() throws Exception {
|
||||||
final Object monitor = new Object();
|
final Object monitor = new Object();
|
||||||
|
|
||||||
RunAwareRunnable task = new RunAwareRunnable(monitor);
|
RunAwareRunnable task = new RunAwareRunnable(monitor);
|
||||||
|
|
||||||
TimerTaskExecutor executor = new TimerTaskExecutor(new Timer());
|
TimerTaskExecutor executor = new TimerTaskExecutor(new Timer());
|
||||||
executor.execute(task);
|
executor.execute(task);
|
||||||
|
|
||||||
synchronized (monitor) {
|
synchronized (monitor) {
|
||||||
monitor.wait(5000);
|
monitor.wait(5000);
|
||||||
}
|
}
|
||||||
|
|
||||||
assertTrue("Supplied task (a Runnable) is not being invoked.", task.isRunWasCalled());
|
assertTrue("Supplied task (a Runnable) is not being invoked.", task.isRunWasCalled());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCtorWithNullTimer() throws Exception {
|
public void testCtorWithNullTimer() throws Exception {
|
||||||
new AssertThrows(IllegalArgumentException.class) {
|
new AssertThrows(IllegalArgumentException.class) {
|
||||||
public void test() throws Exception {
|
public void test() throws Exception {
|
||||||
new TimerTaskExecutor(null);
|
new TimerTaskExecutor(null);
|
||||||
}
|
}
|
||||||
}.runTest();
|
}.runTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCreateTimerMethodIsCalledIfNoTimerIsExplicitlySupplied() throws Exception {
|
public void testCreateTimerMethodIsCalledIfNoTimerIsExplicitlySupplied() throws Exception {
|
||||||
CreationAwareTimerTaskExecutor executor = new CreationAwareTimerTaskExecutor();
|
CreationAwareTimerTaskExecutor executor = new CreationAwareTimerTaskExecutor();
|
||||||
executor.afterPropertiesSet();
|
executor.afterPropertiesSet();
|
||||||
assertTrue("If no Timer is set explicitly, then the protected createTimer() " +
|
assertTrue("If no Timer is set explicitly, then the protected createTimer() " +
|
||||||
"method must be called to create the Timer (it obviously isn't being called).",
|
"method must be called to create the Timer (it obviously isn't being called).",
|
||||||
executor.isCreateTimerWasCalled());
|
executor.isCreateTimerWasCalled());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCreateTimerMethodIsNotCalledIfTimerIsExplicitlySupplied() throws Exception {
|
public void testCreateTimerMethodIsNotCalledIfTimerIsExplicitlySupplied() throws Exception {
|
||||||
CreationAwareTimerTaskExecutor executor = new CreationAwareTimerTaskExecutor();
|
CreationAwareTimerTaskExecutor executor = new CreationAwareTimerTaskExecutor();
|
||||||
executor.setTimer(new Timer());
|
executor.setTimer(new Timer());
|
||||||
executor.afterPropertiesSet();
|
executor.afterPropertiesSet();
|
||||||
assertFalse("If a Timer is set explicitly, then the protected createTimer() " +
|
assertFalse("If a Timer is set explicitly, then the protected createTimer() " +
|
||||||
"method must not be called to create the Timer (it obviously is being called, in error).",
|
"method must not be called to create the Timer (it obviously is being called, in error).",
|
||||||
executor.isCreateTimerWasCalled());
|
executor.isCreateTimerWasCalled());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testThatTheDestroyCallbackCancelsTheTimerIfNoTimerIsExplicitlySupplied() throws Exception {
|
public void testThatTheDestroyCallbackCancelsTheTimerIfNoTimerIsExplicitlySupplied() throws Exception {
|
||||||
|
|
||||||
final CancelAwareTimer timer = new CancelAwareTimer();
|
final CancelAwareTimer timer = new CancelAwareTimer();
|
||||||
|
|
||||||
TimerTaskExecutor executor = new TimerTaskExecutor() {
|
TimerTaskExecutor executor = new TimerTaskExecutor() {
|
||||||
|
|
||||||
protected Timer createTimer() {
|
protected Timer createTimer() {
|
||||||
return timer;
|
return timer;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
executor.afterPropertiesSet();
|
executor.afterPropertiesSet();
|
||||||
executor.destroy();
|
executor.destroy();
|
||||||
assertTrue("When the Timer used is created by the TimerTaskExecutor because " +
|
assertTrue("When the Timer used is created by the TimerTaskExecutor because " +
|
||||||
"no Timer was set explicitly, then the destroy() callback must cancel() said Timer (it obviously isn't doing this).",
|
"no Timer was set explicitly, then the destroy() callback must cancel() said Timer (it obviously isn't doing this).",
|
||||||
timer.isCancelWasCalled());
|
timer.isCancelWasCalled());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testThatTheDestroyCallbackDoesNotCancelTheTimerIfTheTimerWasSuppliedExplictly() throws Exception {
|
public void testThatTheDestroyCallbackDoesNotCancelTheTimerIfTheTimerWasSuppliedExplictly() throws Exception {
|
||||||
TimerTaskExecutor executor = new TimerTaskExecutor();
|
TimerTaskExecutor executor = new TimerTaskExecutor();
|
||||||
CancelAwareTimer timer = new CancelAwareTimer();
|
CancelAwareTimer timer = new CancelAwareTimer();
|
||||||
executor.setTimer(timer);
|
executor.setTimer(timer);
|
||||||
executor.afterPropertiesSet();
|
executor.afterPropertiesSet();
|
||||||
executor.destroy();
|
executor.destroy();
|
||||||
assertFalse("When the Timer used is not created by the TimerTaskExecutor because " +
|
assertFalse("When the Timer used is not created by the TimerTaskExecutor because " +
|
||||||
"it Timer was set explicitly, then the destroy() callback must NOT cancel() said Timer (it obviously is, in error).",
|
"it Timer was set explicitly, then the destroy() callback must NOT cancel() said Timer (it obviously is, in error).",
|
||||||
timer.isCancelWasCalled());
|
timer.isCancelWasCalled());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private final static class CreationAwareTimerTaskExecutor extends TimerTaskExecutor {
|
private final static class CreationAwareTimerTaskExecutor extends TimerTaskExecutor {
|
||||||
|
|
||||||
private boolean createTimerWasCalled = false;
|
private boolean createTimerWasCalled = false;
|
||||||
|
|
||||||
|
|
||||||
public boolean isCreateTimerWasCalled() {
|
public boolean isCreateTimerWasCalled() {
|
||||||
return this.createTimerWasCalled;
|
return this.createTimerWasCalled;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Timer createTimer() {
|
protected Timer createTimer() {
|
||||||
this.createTimerWasCalled = true;
|
this.createTimerWasCalled = true;
|
||||||
return super.createTimer();
|
return super.createTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class CancelAwareTimer extends Timer {
|
private static class CancelAwareTimer extends Timer {
|
||||||
|
|
||||||
private boolean cancelWasCalled;
|
private boolean cancelWasCalled;
|
||||||
|
|
||||||
|
|
||||||
public boolean isCancelWasCalled() {
|
public boolean isCancelWasCalled() {
|
||||||
return this.cancelWasCalled;
|
return this.cancelWasCalled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void cancel() {
|
public void cancel() {
|
||||||
this.cancelWasCalled = true;
|
this.cancelWasCalled = true;
|
||||||
super.cancel();
|
super.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class RunAwareRunnable implements Runnable {
|
private static class RunAwareRunnable implements Runnable {
|
||||||
private boolean runWasCalled;
|
private boolean runWasCalled;
|
||||||
private final Object monitor;
|
private final Object monitor;
|
||||||
|
|
||||||
public RunAwareRunnable(Object monitor) {
|
public RunAwareRunnable(Object monitor) {
|
||||||
this.monitor = monitor;
|
this.monitor = monitor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isRunWasCalled() {
|
public boolean isRunWasCalled() {
|
||||||
return this.runWasCalled;
|
return this.runWasCalled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
this.runWasCalled = true;
|
this.runWasCalled = true;
|
||||||
synchronized (monitor) {
|
synchronized (monitor) {
|
||||||
monitor.notifyAll();
|
monitor.notifyAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class NoOpRunnable implements Runnable {
|
private static final class NoOpRunnable implements Runnable {
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
// explicit no-op
|
// explicit no-op
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ package org.springframework.scripting;
|
||||||
* @author Rick Evans
|
* @author Rick Evans
|
||||||
*/
|
*/
|
||||||
public interface ScriptBean {
|
public interface ScriptBean {
|
||||||
|
|
||||||
String getName();
|
String getName();
|
||||||
|
|
||||||
void setName(String name);
|
void setName(String name);
|
||||||
|
|
@ -30,5 +30,5 @@ public interface ScriptBean {
|
||||||
int getAge();
|
int getAge();
|
||||||
|
|
||||||
void setAge(int age);
|
void setAge(int age);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -55,239 +55,239 @@ import org.testng.annotations.Test;
|
||||||
@Ignore // renamed to Tests_ to avoid being picked up by junit. Spring Build support for TestNG is pending.
|
@Ignore // renamed to Tests_ to avoid being picked up by junit. Spring Build support for TestNG is pending.
|
||||||
@ContextConfiguration
|
@ContextConfiguration
|
||||||
public class ConcreteTransactionalTestNGSpringContextTests_ extends AbstractTransactionalTestNGSpringContextTests
|
public class ConcreteTransactionalTestNGSpringContextTests_ extends AbstractTransactionalTestNGSpringContextTests
|
||||||
implements BeanNameAware, InitializingBean {
|
implements BeanNameAware, InitializingBean {
|
||||||
|
|
||||||
// ------------------------------------------------------------------------|
|
// ------------------------------------------------------------------------|
|
||||||
// --- CONSTANTS ----------------------------------------------------------|
|
// --- CONSTANTS ----------------------------------------------------------|
|
||||||
// ------------------------------------------------------------------------|
|
// ------------------------------------------------------------------------|
|
||||||
|
|
||||||
private static final String BOB = "bob";
|
private static final String BOB = "bob";
|
||||||
private static final String JANE = "jane";
|
private static final String JANE = "jane";
|
||||||
private static final String SUE = "sue";
|
private static final String SUE = "sue";
|
||||||
private static final String YODA = "yoda";
|
private static final String YODA = "yoda";
|
||||||
|
|
||||||
// ------------------------------------------------------------------------|
|
// ------------------------------------------------------------------------|
|
||||||
// --- STATIC VARIABLES ---------------------------------------------------|
|
// --- STATIC VARIABLES ---------------------------------------------------|
|
||||||
// ------------------------------------------------------------------------|
|
// ------------------------------------------------------------------------|
|
||||||
|
|
||||||
private static int numSetUpCalls = 0;
|
private static int numSetUpCalls = 0;
|
||||||
private static int numSetUpCallsInTransaction = 0;
|
private static int numSetUpCallsInTransaction = 0;
|
||||||
private static int numTearDownCalls = 0;
|
private static int numTearDownCalls = 0;
|
||||||
private static int numTearDownCallsInTransaction = 0;
|
private static int numTearDownCallsInTransaction = 0;
|
||||||
|
|
||||||
// ------------------------------------------------------------------------|
|
// ------------------------------------------------------------------------|
|
||||||
// --- INSTANCE VARIABLES -------------------------------------------------|
|
// --- INSTANCE VARIABLES -------------------------------------------------|
|
||||||
// ------------------------------------------------------------------------|
|
// ------------------------------------------------------------------------|
|
||||||
|
|
||||||
private boolean beanInitialized = false;
|
private boolean beanInitialized = false;
|
||||||
|
|
||||||
private String beanName = "replace me with [" + getClass().getName() + "]";
|
private String beanName = "replace me with [" + getClass().getName() + "]";
|
||||||
|
|
||||||
private Employee employee;
|
private Employee employee;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private Pet pet;
|
private Pet pet;
|
||||||
|
|
||||||
@Autowired(required = false)
|
@Autowired(required = false)
|
||||||
protected Long nonrequiredLong;
|
protected Long nonrequiredLong;
|
||||||
|
|
||||||
@Resource()
|
@Resource()
|
||||||
protected String foo;
|
protected String foo;
|
||||||
|
|
||||||
protected String bar;
|
protected String bar;
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------|
|
// ------------------------------------------------------------------------|
|
||||||
// --- STATIC METHODS -----------------------------------------------------|
|
// --- STATIC METHODS -----------------------------------------------------|
|
||||||
// ------------------------------------------------------------------------|
|
// ------------------------------------------------------------------------|
|
||||||
|
|
||||||
private static int clearPersonTable(SimpleJdbcTemplate simpleJdbcTemplate) {
|
private static int clearPersonTable(SimpleJdbcTemplate simpleJdbcTemplate) {
|
||||||
return SimpleJdbcTestUtils.deleteFromTables(simpleJdbcTemplate, "person");
|
return SimpleJdbcTestUtils.deleteFromTables(simpleJdbcTemplate, "person");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void createPersonTable(SimpleJdbcTemplate simpleJdbcTemplate) {
|
private static void createPersonTable(SimpleJdbcTemplate simpleJdbcTemplate) {
|
||||||
try {
|
try {
|
||||||
simpleJdbcTemplate.update("CREATE TABLE person (name VARCHAR(20) NOT NULL, PRIMARY KEY(name))");
|
simpleJdbcTemplate.update("CREATE TABLE person (name VARCHAR(20) NOT NULL, PRIMARY KEY(name))");
|
||||||
}
|
}
|
||||||
catch (BadSqlGrammarException bsge) {
|
catch (BadSqlGrammarException bsge) {
|
||||||
/* ignore */
|
/* ignore */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int countRowsInPersonTable(SimpleJdbcTemplate simpleJdbcTemplate) {
|
private static int countRowsInPersonTable(SimpleJdbcTemplate simpleJdbcTemplate) {
|
||||||
return SimpleJdbcTestUtils.countRowsInTable(simpleJdbcTemplate, "person");
|
return SimpleJdbcTestUtils.countRowsInTable(simpleJdbcTemplate, "person");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int addPerson(SimpleJdbcTemplate simpleJdbcTemplate, String name) {
|
private static int addPerson(SimpleJdbcTemplate simpleJdbcTemplate, String name) {
|
||||||
return simpleJdbcTemplate.update("INSERT INTO person VALUES(?)", name);
|
return simpleJdbcTemplate.update("INSERT INTO person VALUES(?)", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int deletePerson(SimpleJdbcTemplate simpleJdbcTemplate, String name) {
|
private static int deletePerson(SimpleJdbcTemplate simpleJdbcTemplate, String name) {
|
||||||
return simpleJdbcTemplate.update("DELETE FROM person WHERE name=?", name);
|
return simpleJdbcTemplate.update("DELETE FROM person WHERE name=?", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------|
|
// ------------------------------------------------------------------------|
|
||||||
// --- INSTANCE METHODS ---------------------------------------------------|
|
// --- INSTANCE METHODS ---------------------------------------------------|
|
||||||
// ------------------------------------------------------------------------|
|
// ------------------------------------------------------------------------|
|
||||||
|
|
||||||
public void afterPropertiesSet() throws Exception {
|
public void afterPropertiesSet() throws Exception {
|
||||||
this.beanInitialized = true;
|
this.beanInitialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBeanName(String beanName) {
|
public void setBeanName(String beanName) {
|
||||||
this.beanName = beanName;
|
this.beanName = beanName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected void setEmployee(Employee employee) {
|
protected void setEmployee(Employee employee) {
|
||||||
this.employee = employee;
|
this.employee = employee;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
protected void setBar(String bar) {
|
protected void setBar(String bar) {
|
||||||
this.bar = bar;
|
this.bar = bar;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------|
|
// ------------------------------------------------------------------------|
|
||||||
|
|
||||||
private void assertNumRowsInPersonTable(int expectedNumRows, String testState) {
|
private void assertNumRowsInPersonTable(int expectedNumRows, String testState) {
|
||||||
assertEquals(countRowsInPersonTable(this.simpleJdbcTemplate), expectedNumRows,
|
assertEquals(countRowsInPersonTable(this.simpleJdbcTemplate), expectedNumRows,
|
||||||
"Verifying the number of rows in the person table (" + testState + ").");
|
"Verifying the number of rows in the person table (" + testState + ").");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertAddPerson(final String name) {
|
private void assertAddPerson(final String name) {
|
||||||
assertEquals(addPerson(this.simpleJdbcTemplate, name), 1, "Adding '" + name + "'");
|
assertEquals(addPerson(this.simpleJdbcTemplate, name), 1, "Adding '" + name + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------|
|
// ------------------------------------------------------------------------|
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public void beforeClass() {
|
public void beforeClass() {
|
||||||
numSetUpCalls = 0;
|
numSetUpCalls = 0;
|
||||||
numSetUpCallsInTransaction = 0;
|
numSetUpCallsInTransaction = 0;
|
||||||
numTearDownCalls = 0;
|
numTearDownCalls = 0;
|
||||||
numTearDownCallsInTransaction = 0;
|
numTearDownCallsInTransaction = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
public void afterClass() {
|
public void afterClass() {
|
||||||
assertEquals(numSetUpCalls, 8, "Verifying number of calls to setUp().");
|
assertEquals(numSetUpCalls, 8, "Verifying number of calls to setUp().");
|
||||||
assertEquals(numSetUpCallsInTransaction, 1, "Verifying number of calls to setUp() within a transaction.");
|
assertEquals(numSetUpCallsInTransaction, 1, "Verifying number of calls to setUp() within a transaction.");
|
||||||
assertEquals(numTearDownCalls, 8, "Verifying number of calls to tearDown().");
|
assertEquals(numTearDownCalls, 8, "Verifying number of calls to tearDown().");
|
||||||
assertEquals(numTearDownCallsInTransaction, 1, "Verifying number of calls to tearDown() within a transaction.");
|
assertEquals(numTearDownCallsInTransaction, 1, "Verifying number of calls to tearDown() within a transaction.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@NotTransactional
|
@NotTransactional
|
||||||
public void verifyApplicationContextSet() {
|
public void verifyApplicationContextSet() {
|
||||||
assertInTransaction(false);
|
assertInTransaction(false);
|
||||||
assertNotNull(super.applicationContext,
|
assertNotNull(super.applicationContext,
|
||||||
"The application context should have been set due to ApplicationContextAware semantics.");
|
"The application context should have been set due to ApplicationContextAware semantics.");
|
||||||
Employee employeeBean = (Employee) super.applicationContext.getBean("employee");
|
Employee employeeBean = (Employee) super.applicationContext.getBean("employee");
|
||||||
assertEquals(employeeBean.getName(), "John Smith", "Verifying employee's name.");
|
assertEquals(employeeBean.getName(), "John Smith", "Verifying employee's name.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@NotTransactional
|
@NotTransactional
|
||||||
public void verifyBeanInitialized() {
|
public void verifyBeanInitialized() {
|
||||||
assertInTransaction(false);
|
assertInTransaction(false);
|
||||||
assertTrue(this.beanInitialized,
|
assertTrue(this.beanInitialized,
|
||||||
"This test instance should have been initialized due to InitializingBean semantics.");
|
"This test instance should have been initialized due to InitializingBean semantics.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@NotTransactional
|
@NotTransactional
|
||||||
public void verifyBeanNameSet() {
|
public void verifyBeanNameSet() {
|
||||||
assertInTransaction(false);
|
assertInTransaction(false);
|
||||||
assertEquals(this.beanName, getClass().getName(),
|
assertEquals(this.beanName, getClass().getName(),
|
||||||
"The bean name of this test instance should have been set due to BeanNameAware semantics.");
|
"The bean name of this test instance should have been set due to BeanNameAware semantics.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@NotTransactional
|
@NotTransactional
|
||||||
public void verifyAnnotationAutowiredFields() {
|
public void verifyAnnotationAutowiredFields() {
|
||||||
assertInTransaction(false);
|
assertInTransaction(false);
|
||||||
assertNull(this.nonrequiredLong, "The nonrequiredLong field should NOT have been autowired.");
|
assertNull(this.nonrequiredLong, "The nonrequiredLong field should NOT have been autowired.");
|
||||||
assertNotNull(this.pet, "The pet field should have been autowired.");
|
assertNotNull(this.pet, "The pet field should have been autowired.");
|
||||||
assertEquals(this.pet.getName(), "Fido", "Verifying pet's name.");
|
assertEquals(this.pet.getName(), "Fido", "Verifying pet's name.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@NotTransactional
|
@NotTransactional
|
||||||
public void verifyAnnotationAutowiredMethods() {
|
public void verifyAnnotationAutowiredMethods() {
|
||||||
assertInTransaction(false);
|
assertInTransaction(false);
|
||||||
assertNotNull(this.employee, "The setEmployee() method should have been autowired.");
|
assertNotNull(this.employee, "The setEmployee() method should have been autowired.");
|
||||||
assertEquals(this.employee.getName(), "John Smith", "Verifying employee's name.");
|
assertEquals(this.employee.getName(), "John Smith", "Verifying employee's name.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@NotTransactional
|
@NotTransactional
|
||||||
public void verifyResourceAnnotationInjectedFields() {
|
public void verifyResourceAnnotationInjectedFields() {
|
||||||
assertInTransaction(false);
|
assertInTransaction(false);
|
||||||
assertEquals(this.foo, "Foo", "The foo field should have been injected via @Resource.");
|
assertEquals(this.foo, "Foo", "The foo field should have been injected via @Resource.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@NotTransactional
|
@NotTransactional
|
||||||
public void verifyResourceAnnotationInjectedMethods() {
|
public void verifyResourceAnnotationInjectedMethods() {
|
||||||
assertInTransaction(false);
|
assertInTransaction(false);
|
||||||
assertEquals(this.bar, "Bar", "The setBar() method should have been injected via @Resource.");
|
assertEquals(this.bar, "Bar", "The setBar() method should have been injected via @Resource.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------|
|
// ------------------------------------------------------------------------|
|
||||||
|
|
||||||
@BeforeTransaction
|
@BeforeTransaction
|
||||||
public void beforeTransaction() {
|
public void beforeTransaction() {
|
||||||
assertNumRowsInPersonTable(1, "before a transactional test method");
|
assertNumRowsInPersonTable(1, "before a transactional test method");
|
||||||
assertAddPerson(YODA);
|
assertAddPerson(YODA);
|
||||||
}
|
}
|
||||||
|
|
||||||
@BeforeMethod
|
@BeforeMethod
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
numSetUpCalls++;
|
numSetUpCalls++;
|
||||||
if (inTransaction()) {
|
if (inTransaction()) {
|
||||||
numSetUpCallsInTransaction++;
|
numSetUpCallsInTransaction++;
|
||||||
}
|
}
|
||||||
assertNumRowsInPersonTable((inTransaction() ? 2 : 1), "before a test method");
|
assertNumRowsInPersonTable((inTransaction() ? 2 : 1), "before a test method");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void modifyTestDataWithinTransaction() {
|
public void modifyTestDataWithinTransaction() {
|
||||||
assertInTransaction(true);
|
assertInTransaction(true);
|
||||||
assertAddPerson(JANE);
|
assertAddPerson(JANE);
|
||||||
assertAddPerson(SUE);
|
assertAddPerson(SUE);
|
||||||
assertNumRowsInPersonTable(4, "in modifyTestDataWithinTransaction()");
|
assertNumRowsInPersonTable(4, "in modifyTestDataWithinTransaction()");
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterMethod
|
@AfterMethod
|
||||||
public void tearDown() throws Exception {
|
public void tearDown() throws Exception {
|
||||||
numTearDownCalls++;
|
numTearDownCalls++;
|
||||||
if (inTransaction()) {
|
if (inTransaction()) {
|
||||||
numTearDownCallsInTransaction++;
|
numTearDownCallsInTransaction++;
|
||||||
}
|
}
|
||||||
assertNumRowsInPersonTable((inTransaction() ? 4 : 1), "after a test method");
|
assertNumRowsInPersonTable((inTransaction() ? 4 : 1), "after a test method");
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterTransaction
|
@AfterTransaction
|
||||||
public void afterTransaction() {
|
public void afterTransaction() {
|
||||||
assertEquals(deletePerson(this.simpleJdbcTemplate, YODA), 1, "Deleting yoda");
|
assertEquals(deletePerson(this.simpleJdbcTemplate, YODA), 1, "Deleting yoda");
|
||||||
assertNumRowsInPersonTable(1, "after a transactional test method");
|
assertNumRowsInPersonTable(1, "after a transactional test method");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------|
|
// ------------------------------------------------------------------------|
|
||||||
// --- TYPES --------------------------------------------------------------|
|
// --- TYPES --------------------------------------------------------------|
|
||||||
// ------------------------------------------------------------------------|
|
// ------------------------------------------------------------------------|
|
||||||
|
|
||||||
public static class DatabaseSetup {
|
public static class DatabaseSetup {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
void setDataSource(DataSource dataSource) {
|
void setDataSource(DataSource dataSource) {
|
||||||
SimpleJdbcTemplate simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource);
|
SimpleJdbcTemplate simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource);
|
||||||
createPersonTable(simpleJdbcTemplate);
|
createPersonTable(simpleJdbcTemplate);
|
||||||
clearPersonTable(simpleJdbcTemplate);
|
clearPersonTable(simpleJdbcTemplate);
|
||||||
addPerson(simpleJdbcTemplate, BOB);
|
addPerson(simpleJdbcTemplate, BOB);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,8 +41,8 @@ import org.springframework.transaction.TransactionDefinition;
|
||||||
* @see org.springframework.transaction.interceptor.TransactionProxyFactoryBean
|
* @see org.springframework.transaction.interceptor.TransactionProxyFactoryBean
|
||||||
*/
|
*/
|
||||||
public final class TransactionAttributeSourceTests {
|
public final class TransactionAttributeSourceTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMatchAlwaysTransactionAttributeSource() throws Exception {
|
public void testMatchAlwaysTransactionAttributeSource() throws Exception {
|
||||||
MatchAlwaysTransactionAttributeSource tas = new MatchAlwaysTransactionAttributeSource();
|
MatchAlwaysTransactionAttributeSource tas = new MatchAlwaysTransactionAttributeSource();
|
||||||
TransactionAttribute ta = tas.getTransactionAttribute(
|
TransactionAttribute ta = tas.getTransactionAttribute(
|
||||||
|
|
@ -57,8 +57,8 @@ public final class TransactionAttributeSourceTests {
|
||||||
assertTrue(TransactionDefinition.PROPAGATION_SUPPORTS == ta.getPropagationBehavior());
|
assertTrue(TransactionDefinition.PROPAGATION_SUPPORTS == ta.getPropagationBehavior());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
@Test
|
@Test
|
||||||
public void testMethodMapTransactionAttributeSource() throws NoSuchMethodException {
|
public void testMethodMapTransactionAttributeSource() throws NoSuchMethodException {
|
||||||
MethodMapTransactionAttributeSource tas = new MethodMapTransactionAttributeSource();
|
MethodMapTransactionAttributeSource tas = new MethodMapTransactionAttributeSource();
|
||||||
Map methodMap = new HashMap();
|
Map methodMap = new HashMap();
|
||||||
|
|
@ -76,8 +76,8 @@ public final class TransactionAttributeSourceTests {
|
||||||
assertEquals(TransactionDefinition.PROPAGATION_SUPPORTS, ta.getPropagationBehavior());
|
assertEquals(TransactionDefinition.PROPAGATION_SUPPORTS, ta.getPropagationBehavior());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
@Test
|
@Test
|
||||||
public void testMethodMapTransactionAttributeSourceWithLazyInit() throws NoSuchMethodException {
|
public void testMethodMapTransactionAttributeSourceWithLazyInit() throws NoSuchMethodException {
|
||||||
MethodMapTransactionAttributeSource tas = new MethodMapTransactionAttributeSource();
|
MethodMapTransactionAttributeSource tas = new MethodMapTransactionAttributeSource();
|
||||||
Map methodMap = new HashMap();
|
Map methodMap = new HashMap();
|
||||||
|
|
@ -94,8 +94,8 @@ public final class TransactionAttributeSourceTests {
|
||||||
assertEquals(TransactionDefinition.PROPAGATION_SUPPORTS, ta.getPropagationBehavior());
|
assertEquals(TransactionDefinition.PROPAGATION_SUPPORTS, ta.getPropagationBehavior());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
@Test
|
@Test
|
||||||
public void testNameMatchTransactionAttributeSource() throws NoSuchMethodException {
|
public void testNameMatchTransactionAttributeSource() throws NoSuchMethodException {
|
||||||
NameMatchTransactionAttributeSource tas = new NameMatchTransactionAttributeSource();
|
NameMatchTransactionAttributeSource tas = new NameMatchTransactionAttributeSource();
|
||||||
Map methodMap = new HashMap();
|
Map methodMap = new HashMap();
|
||||||
|
|
@ -111,7 +111,7 @@ public final class TransactionAttributeSourceTests {
|
||||||
assertEquals(TransactionDefinition.PROPAGATION_SUPPORTS, ta.getPropagationBehavior());
|
assertEquals(TransactionDefinition.PROPAGATION_SUPPORTS, ta.getPropagationBehavior());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNameMatchTransactionAttributeSourceWithStarAtStartOfMethodName() throws NoSuchMethodException {
|
public void testNameMatchTransactionAttributeSourceWithStarAtStartOfMethodName() throws NoSuchMethodException {
|
||||||
NameMatchTransactionAttributeSource tas = new NameMatchTransactionAttributeSource();
|
NameMatchTransactionAttributeSource tas = new NameMatchTransactionAttributeSource();
|
||||||
Properties attributes = new Properties();
|
Properties attributes = new Properties();
|
||||||
|
|
@ -123,7 +123,7 @@ public final class TransactionAttributeSourceTests {
|
||||||
assertEquals(TransactionDefinition.PROPAGATION_REQUIRED, ta.getPropagationBehavior());
|
assertEquals(TransactionDefinition.PROPAGATION_REQUIRED, ta.getPropagationBehavior());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNameMatchTransactionAttributeSourceWithStarAtEndOfMethodName() throws NoSuchMethodException {
|
public void testNameMatchTransactionAttributeSourceWithStarAtEndOfMethodName() throws NoSuchMethodException {
|
||||||
NameMatchTransactionAttributeSource tas = new NameMatchTransactionAttributeSource();
|
NameMatchTransactionAttributeSource tas = new NameMatchTransactionAttributeSource();
|
||||||
Properties attributes = new Properties();
|
Properties attributes = new Properties();
|
||||||
|
|
@ -135,7 +135,7 @@ public final class TransactionAttributeSourceTests {
|
||||||
assertEquals(TransactionDefinition.PROPAGATION_REQUIRED, ta.getPropagationBehavior());
|
assertEquals(TransactionDefinition.PROPAGATION_REQUIRED, ta.getPropagationBehavior());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNameMatchTransactionAttributeSourceMostSpecificMethodNameIsDefinitelyMatched() throws NoSuchMethodException {
|
public void testNameMatchTransactionAttributeSourceMostSpecificMethodNameIsDefinitelyMatched() throws NoSuchMethodException {
|
||||||
NameMatchTransactionAttributeSource tas = new NameMatchTransactionAttributeSource();
|
NameMatchTransactionAttributeSource tas = new NameMatchTransactionAttributeSource();
|
||||||
Properties attributes = new Properties();
|
Properties attributes = new Properties();
|
||||||
|
|
@ -148,7 +148,7 @@ public final class TransactionAttributeSourceTests {
|
||||||
assertEquals(TransactionDefinition.PROPAGATION_MANDATORY, ta.getPropagationBehavior());
|
assertEquals(TransactionDefinition.PROPAGATION_MANDATORY, ta.getPropagationBehavior());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNameMatchTransactionAttributeSourceWithEmptyMethodName() throws NoSuchMethodException {
|
public void testNameMatchTransactionAttributeSourceWithEmptyMethodName() throws NoSuchMethodException {
|
||||||
NameMatchTransactionAttributeSource tas = new NameMatchTransactionAttributeSource();
|
NameMatchTransactionAttributeSource tas = new NameMatchTransactionAttributeSource();
|
||||||
Properties attributes = new Properties();
|
Properties attributes = new Properties();
|
||||||
|
|
|
||||||
|
|
@ -35,154 +35,154 @@ import java.io.IOException;
|
||||||
*/
|
*/
|
||||||
public final class PortletWrappingControllerTests extends TestCase {
|
public final class PortletWrappingControllerTests extends TestCase {
|
||||||
|
|
||||||
private static final String RESULT_RENDER_PARAMETER_NAME = "result";
|
private static final String RESULT_RENDER_PARAMETER_NAME = "result";
|
||||||
private static final String PORTLET_WRAPPING_CONTROLLER_BEAN_NAME = "controller";
|
private static final String PORTLET_WRAPPING_CONTROLLER_BEAN_NAME = "controller";
|
||||||
private static final String RENDERED_RESPONSE_CONTENT = "myPortlet-view";
|
private static final String RENDERED_RESPONSE_CONTENT = "myPortlet-view";
|
||||||
private static final String PORTLET_NAME_ACTION_REQUEST_PARAMETER_NAME = "portletName";
|
private static final String PORTLET_NAME_ACTION_REQUEST_PARAMETER_NAME = "portletName";
|
||||||
|
|
||||||
|
|
||||||
private PortletWrappingController controller;
|
private PortletWrappingController controller;
|
||||||
|
|
||||||
|
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
ConfigurablePortletApplicationContext applicationContext = new MyApplicationContext();
|
ConfigurablePortletApplicationContext applicationContext = new MyApplicationContext();
|
||||||
MockPortletConfig config = new MockPortletConfig(new MockPortletContext(), "wrappedPortlet");
|
MockPortletConfig config = new MockPortletConfig(new MockPortletContext(), "wrappedPortlet");
|
||||||
applicationContext.setPortletConfig(config);
|
applicationContext.setPortletConfig(config);
|
||||||
applicationContext.refresh();
|
applicationContext.refresh();
|
||||||
controller = (PortletWrappingController) applicationContext.getBean(PORTLET_WRAPPING_CONTROLLER_BEAN_NAME);
|
controller = (PortletWrappingController) applicationContext.getBean(PORTLET_WRAPPING_CONTROLLER_BEAN_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testActionRequest() throws Exception {
|
public void testActionRequest() throws Exception {
|
||||||
MockActionRequest request = new MockActionRequest();
|
MockActionRequest request = new MockActionRequest();
|
||||||
MockActionResponse response = new MockActionResponse();
|
MockActionResponse response = new MockActionResponse();
|
||||||
request.setParameter("test", "test");
|
request.setParameter("test", "test");
|
||||||
controller.handleActionRequest(request, response);
|
controller.handleActionRequest(request, response);
|
||||||
String result = response.getRenderParameter(RESULT_RENDER_PARAMETER_NAME);
|
String result = response.getRenderParameter(RESULT_RENDER_PARAMETER_NAME);
|
||||||
assertEquals("myPortlet-action", result);
|
assertEquals("myPortlet-action", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testRenderRequest() throws Exception {
|
public void testRenderRequest() throws Exception {
|
||||||
MockRenderRequest request = new MockRenderRequest();
|
MockRenderRequest request = new MockRenderRequest();
|
||||||
MockRenderResponse response = new MockRenderResponse();
|
MockRenderResponse response = new MockRenderResponse();
|
||||||
controller.handleRenderRequest(request, response);
|
controller.handleRenderRequest(request, response);
|
||||||
String result = response.getContentAsString();
|
String result = response.getContentAsString();
|
||||||
assertEquals(RENDERED_RESPONSE_CONTENT, result);
|
assertEquals(RENDERED_RESPONSE_CONTENT, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testActionRequestWithNoParameters() throws Exception {
|
public void testActionRequestWithNoParameters() throws Exception {
|
||||||
final MockActionRequest request = new MockActionRequest();
|
final MockActionRequest request = new MockActionRequest();
|
||||||
final MockActionResponse response = new MockActionResponse();
|
final MockActionResponse response = new MockActionResponse();
|
||||||
new AssertThrows(IllegalArgumentException.class) {
|
new AssertThrows(IllegalArgumentException.class) {
|
||||||
public void test() throws Exception {
|
public void test() throws Exception {
|
||||||
controller.handleActionRequest(request, response);
|
controller.handleActionRequest(request, response);
|
||||||
}
|
}
|
||||||
}.runTest();
|
}.runTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testRejectsPortletClassThatDoesNotImplementPortletInterface() throws Exception {
|
public void testRejectsPortletClassThatDoesNotImplementPortletInterface() throws Exception {
|
||||||
new AssertThrows(IllegalArgumentException.class) {
|
new AssertThrows(IllegalArgumentException.class) {
|
||||||
public void test() throws Exception {
|
public void test() throws Exception {
|
||||||
PortletWrappingController controller = new PortletWrappingController();
|
PortletWrappingController controller = new PortletWrappingController();
|
||||||
controller.setPortletClass(String.class);
|
controller.setPortletClass(String.class);
|
||||||
controller.afterPropertiesSet();
|
controller.afterPropertiesSet();
|
||||||
}
|
}
|
||||||
}.runTest();
|
}.runTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testRejectsIfPortletClassIsNotSupplied() throws Exception {
|
public void testRejectsIfPortletClassIsNotSupplied() throws Exception {
|
||||||
new AssertThrows(IllegalArgumentException.class) {
|
new AssertThrows(IllegalArgumentException.class) {
|
||||||
public void test() throws Exception {
|
public void test() throws Exception {
|
||||||
PortletWrappingController controller = new PortletWrappingController();
|
PortletWrappingController controller = new PortletWrappingController();
|
||||||
controller.setPortletClass(null);
|
controller.setPortletClass(null);
|
||||||
controller.afterPropertiesSet();
|
controller.afterPropertiesSet();
|
||||||
}
|
}
|
||||||
}.runTest();
|
}.runTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDestroyingTheControllerPropagatesDestroyToWrappedPortlet() throws Exception {
|
public void testDestroyingTheControllerPropagatesDestroyToWrappedPortlet() throws Exception {
|
||||||
final PortletWrappingController controller = new PortletWrappingController();
|
final PortletWrappingController controller = new PortletWrappingController();
|
||||||
controller.setPortletClass(MyPortlet.class);
|
controller.setPortletClass(MyPortlet.class);
|
||||||
controller.afterPropertiesSet();
|
controller.afterPropertiesSet();
|
||||||
// test for destroy() call being propagated via exception being thrown :(
|
// test for destroy() call being propagated via exception being thrown :(
|
||||||
new AssertThrows(IllegalStateException.class) {
|
new AssertThrows(IllegalStateException.class) {
|
||||||
public void test() throws Exception {
|
public void test() throws Exception {
|
||||||
controller.destroy();
|
controller.destroy();
|
||||||
}
|
}
|
||||||
}.runTest();
|
}.runTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPortletName() throws Exception {
|
public void testPortletName() throws Exception {
|
||||||
MockActionRequest request = new MockActionRequest();
|
MockActionRequest request = new MockActionRequest();
|
||||||
MockActionResponse response = new MockActionResponse();
|
MockActionResponse response = new MockActionResponse();
|
||||||
request.setParameter(PORTLET_NAME_ACTION_REQUEST_PARAMETER_NAME, "test");
|
request.setParameter(PORTLET_NAME_ACTION_REQUEST_PARAMETER_NAME, "test");
|
||||||
controller.handleActionRequest(request, response);
|
controller.handleActionRequest(request, response);
|
||||||
String result = response.getRenderParameter(RESULT_RENDER_PARAMETER_NAME);
|
String result = response.getRenderParameter(RESULT_RENDER_PARAMETER_NAME);
|
||||||
assertEquals("wrappedPortlet", result);
|
assertEquals("wrappedPortlet", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDelegationToMockPortletConfigIfSoConfigured() throws Exception {
|
public void testDelegationToMockPortletConfigIfSoConfigured() throws Exception {
|
||||||
|
|
||||||
final String BEAN_NAME = "Sixpence None The Richer";
|
final String BEAN_NAME = "Sixpence None The Richer";
|
||||||
|
|
||||||
MockActionRequest request = new MockActionRequest();
|
MockActionRequest request = new MockActionRequest();
|
||||||
MockActionResponse response = new MockActionResponse();
|
MockActionResponse response = new MockActionResponse();
|
||||||
|
|
||||||
PortletWrappingController controller = new PortletWrappingController();
|
PortletWrappingController controller = new PortletWrappingController();
|
||||||
controller.setPortletClass(MyPortlet.class);
|
controller.setPortletClass(MyPortlet.class);
|
||||||
controller.setUseSharedPortletConfig(false);
|
controller.setUseSharedPortletConfig(false);
|
||||||
controller.setBeanName(BEAN_NAME);
|
controller.setBeanName(BEAN_NAME);
|
||||||
controller.afterPropertiesSet();
|
controller.afterPropertiesSet();
|
||||||
|
|
||||||
request.setParameter(PORTLET_NAME_ACTION_REQUEST_PARAMETER_NAME, "true");
|
request.setParameter(PORTLET_NAME_ACTION_REQUEST_PARAMETER_NAME, "true");
|
||||||
controller.handleActionRequest(request, response);
|
controller.handleActionRequest(request, response);
|
||||||
|
|
||||||
String result = response.getRenderParameter(RESULT_RENDER_PARAMETER_NAME);
|
String result = response.getRenderParameter(RESULT_RENDER_PARAMETER_NAME);
|
||||||
assertEquals(BEAN_NAME, result);
|
assertEquals(BEAN_NAME, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static final class MyPortlet implements Portlet {
|
public static final class MyPortlet implements Portlet {
|
||||||
|
|
||||||
private PortletConfig portletConfig;
|
private PortletConfig portletConfig;
|
||||||
|
|
||||||
|
|
||||||
public void init(PortletConfig portletConfig) {
|
public void init(PortletConfig portletConfig) {
|
||||||
this.portletConfig = portletConfig;
|
this.portletConfig = portletConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void processAction(ActionRequest request, ActionResponse response) throws PortletException {
|
public void processAction(ActionRequest request, ActionResponse response) throws PortletException {
|
||||||
if (request.getParameter("test") != null) {
|
if (request.getParameter("test") != null) {
|
||||||
response.setRenderParameter(RESULT_RENDER_PARAMETER_NAME, "myPortlet-action");
|
response.setRenderParameter(RESULT_RENDER_PARAMETER_NAME, "myPortlet-action");
|
||||||
} else if (request.getParameter(PORTLET_NAME_ACTION_REQUEST_PARAMETER_NAME) != null) {
|
} else if (request.getParameter(PORTLET_NAME_ACTION_REQUEST_PARAMETER_NAME) != null) {
|
||||||
response.setRenderParameter(RESULT_RENDER_PARAMETER_NAME, getPortletConfig().getPortletName());
|
response.setRenderParameter(RESULT_RENDER_PARAMETER_NAME, getPortletConfig().getPortletName());
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException("no request parameters");
|
throw new IllegalArgumentException("no request parameters");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void render(RenderRequest request, RenderResponse response) throws IOException {
|
public void render(RenderRequest request, RenderResponse response) throws IOException {
|
||||||
response.getWriter().write(RENDERED_RESPONSE_CONTENT);
|
response.getWriter().write(RENDERED_RESPONSE_CONTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PortletConfig getPortletConfig() {
|
public PortletConfig getPortletConfig() {
|
||||||
return this.portletConfig;
|
return this.portletConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
throw new IllegalStateException("Being destroyed...");
|
throw new IllegalStateException("Being destroyed...");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class MyApplicationContext extends StaticPortletApplicationContext {
|
private static final class MyApplicationContext extends StaticPortletApplicationContext {
|
||||||
|
|
||||||
public void refresh() throws BeansException {
|
public void refresh() throws BeansException {
|
||||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||||
pvs.addPropertyValue("portletClass", MyPortlet.class);
|
pvs.addPropertyValue("portletClass", MyPortlet.class);
|
||||||
registerSingleton(PORTLET_WRAPPING_CONTROLLER_BEAN_NAME, PortletWrappingController.class, pvs);
|
registerSingleton(PORTLET_WRAPPING_CONTROLLER_BEAN_NAME, PortletWrappingController.class, pvs);
|
||||||
super.refresh();
|
super.refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue