polish: leading spaces -> tabs across .aop and .testsuite bundles

This commit is contained in:
Chris Beams 2008-12-12 19:39:14 +00:00
parent b7cc5d2402
commit 04d3f984b1
50 changed files with 1873 additions and 1611 deletions

View File

@ -1,4 +1,4 @@
#Fri Oct 24 15:07:09 EDT 2008
#Fri Dec 12 11:37:26 PST 2008
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
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.enumIdentifier=error
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

View File

@ -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

View File

@ -41,8 +41,8 @@ public class MethodLocatingFactoryBean implements FactoryBean, BeanFactoryAware
/**
* Set the name of the bean to locate the {@link Method} on.
* <p>This property is required.
* @param targetBeanName the name of the bean to locate the {@link Method} on
* <p>This property is required.
* @param targetBeanName the name of the bean to locate the {@link Method} on
*/
public void setTargetBeanName(String targetBeanName) {
this.targetBeanName = targetBeanName;
@ -50,8 +50,8 @@ public class MethodLocatingFactoryBean implements FactoryBean, BeanFactoryAware
/**
* Set the name of the {@link Method} to locate.
* <p>This property is required.
* @param methodName the name of the {@link Method} to locate
* <p>This property is required.
* @param methodName the name of the {@link Method} to locate
*/
public void setMethodName(String methodName) {
this.methodName = methodName;

View File

@ -238,19 +238,19 @@ public class AspectJAdviceParameterNameDiscovererTests {
}
@Test
public void testReferenceBinding() {
assertParameterNames(getMethod("onePrimitive"),"somepc(foo)",new String[] {"foo"});
}
public void testReferenceBinding() {
assertParameterNames(getMethod("onePrimitive"),"somepc(foo)",new String[] {"foo"});
}
@Test
public void testReferenceBindingWithAlternateTokenizations() {
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"});
}
public void testReferenceBindingWithAlternateTokenizations() {
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"});
}
protected Method getMethod(String name) {
protected Method getMethod(String name) {
// assumes no overloading of test methods...
Method[] candidates = this.getClass().getMethods();
for (int i = 0; i < candidates.length; i++) {

View File

@ -29,7 +29,7 @@ import org.springframework.beans.TestBean;
*/
public class BeanNamePointcutMatchingTests {
@Test
@Test
public void testMatchingPointcuts() {
assertMatch("someName", "bean(someName)");
@ -64,7 +64,7 @@ public class BeanNamePointcutMatchingTests {
assertMatch("someName", "bean(someName) && !bean(someOtherName)");
}
@Test
@Test
public void testNonMatchingPointcuts() {
assertMisMatch("someName", "bean(someNamex)");
assertMisMatch("someName", "bean(someX*Name)");
@ -86,8 +86,8 @@ public class BeanNamePointcutMatchingTests {
matches(beanName, pcExpression));
}
private static boolean matches(final String beanName, String pcExpression) {
@SuppressWarnings("serial")
private static boolean matches(final String beanName, String pcExpression) {
@SuppressWarnings("serial")
AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut() {
protected String getCurrentProxiedBeanName() {
return beanName;

View File

@ -43,7 +43,7 @@ import org.springframework.beans.TestBean;
*/
public class MethodInvocationProceedingJoinPointTests {
@Test
@Test
public void testingBindingWithJoinPoint() {
try {
AbstractAspectJAdvice.currentJoinPoint();
@ -54,7 +54,7 @@ public class MethodInvocationProceedingJoinPointTests {
}
}
@Test
@Test
public void testingBindingWithProceedingJoinPoint() {
try {
AbstractAspectJAdvice.currentJoinPoint();
@ -65,7 +65,7 @@ public class MethodInvocationProceedingJoinPointTests {
}
}
@Test
@Test
public void testCanGetMethodSignatureFromJoinPoint() {
final Object raw = new TestBean();
// Will be set by advice during a method call
@ -134,7 +134,7 @@ public class MethodInvocationProceedingJoinPointTests {
assertEquals("Advice reentrantly set age", newAge, itb.getAge());
}
@Test
@Test
public void testCanGetSourceLocationFromJoinPoint() {
final Object raw = new TestBean();
ProxyFactory pf = new ProxyFactory(raw);
@ -166,7 +166,7 @@ public class MethodInvocationProceedingJoinPointTests {
itb.getAge();
}
@Test
@Test
public void testCanGetStaticPartFromJoinPoint() {
final Object raw = new TestBean();
ProxyFactory pf = new ProxyFactory(raw);

View File

@ -35,7 +35,7 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory;
*/
public final class TypePatternClassFilterTests {
@Test
@Test
public void testInvalidPattern() {
try {
new TypePatternClassFilter("-");
@ -45,7 +45,7 @@ public final class TypePatternClassFilterTests {
}
}
@Test
@Test
public void testValidPatternMatching() {
TypePatternClassFilter tpcf = new TypePatternClassFilter("org.springframework.beans.*");
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));
}
@Test
@Test
public void testSubclassMatching() {
TypePatternClassFilter tpcf = new TypePatternClassFilter("org.springframework.beans.ITestBean+");
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));
}
@Test
@Test
public void testAndOrNotReplacement() {
TypePatternClassFilter tpcf = new TypePatternClassFilter("java.lang.Object or java.lang.String");
assertFalse("matches Number",tpcf.matches(Number.class));
@ -80,12 +80,12 @@ public final class TypePatternClassFilterTests {
assertTrue("matches Double",tpcf.matches(Double.class));
}
@Test(expected=IllegalArgumentException.class)
@Test(expected=IllegalArgumentException.class)
public void testSetTypePatternWithNullArgument() throws Exception {
new TypePatternClassFilter(null);
new TypePatternClassFilter(null);
}
@Test(expected=IllegalStateException.class)
@Test(expected=IllegalStateException.class)
public void testInvocationOfMatchesMethodBlowsUpWhenNoTypePatternHasBeenSet() throws Exception {
new TypePatternClassFilter().matches(String.class);
}

View File

@ -37,7 +37,7 @@ import org.springframework.beans.TestBean;
*/
public class ArgumentBindingTests {
@Test(expected=IllegalArgumentException.class)
@Test(expected=IllegalArgumentException.class)
public void testBindingInPointcutUsedByAdvice() {
TestBean tb = new TestBean();
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(tb);
@ -47,7 +47,7 @@ public class ArgumentBindingTests {
proxiedTestBean.setName("Supercalifragalisticexpialidocious"); // should throw
}
@Test(expected=IllegalStateException.class)
@Test(expected=IllegalStateException.class)
public void testAnnotationArgumentNameBinding() {
TransactionalBean tb = new TransactionalBean();
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(tb);
@ -57,7 +57,7 @@ public class ArgumentBindingTests {
proxiedTestBean.doInTransaction(); // should throw
}
@Test
@Test
public void testParameterNameDiscoverWithReferencePointcut() throws Exception {
AspectJAdviceParameterNameDiscoverer discoverer =
new AspectJAdviceParameterNameDiscoverer("somepc(formal) && set(* *)");

View File

@ -32,12 +32,12 @@ import example.aspects.PerTargetAspect;
*/
public class AspectMetadataTests {
@Test(expected=IllegalArgumentException.class)
@Test(expected=IllegalArgumentException.class)
public void testNotAnAspect() {
new AspectMetadata(String.class,"someBean");
}
@Test
@Test
public void testSingletonAspect() {
AspectMetadata am = new AspectMetadata(ExceptionAspect.class,"someBean");
assertFalse(am.isPerThisOrPerTarget());
@ -45,7 +45,7 @@ public class AspectMetadataTests {
assertEquals(PerClauseKind.SINGLETON, am.getAjType().getPerClause().getKind());
}
@Test
@Test
public void testPerTargetAspect() {
AspectMetadata am = new AspectMetadata(PerTargetAspect.class,"someBean");
assertTrue(am.isPerThisOrPerTarget());
@ -53,7 +53,7 @@ public class AspectMetadataTests {
assertEquals(PerClauseKind.PERTARGET, am.getAjType().getPerClause().getKind());
}
@Test
@Test
public void testPerThisAspect() {
AspectMetadata am = new AspectMetadata(PerThisAspect.class,"someBean");
assertTrue(am.isPerThisOrPerTarget());

View File

@ -30,13 +30,13 @@ import example.aspects.PerThisAspect;
*/
public class AspectProxyFactoryTests {
@Test(expected=IllegalArgumentException.class)
@Test(expected=IllegalArgumentException.class)
public void testWithNonAspect() {
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(new TestBean());
proxyFactory.addAspect(TestBean.class);
}
@Test
@Test
public void testWithSimpleAspect() throws Exception {
TestBean bean = new TestBean();
bean.setAge(2);
@ -46,7 +46,7 @@ public class AspectProxyFactoryTests {
assertEquals("Multiplication did not occur", bean.getAge() * 2, proxy.getAge());
}
@Test
@Test
public void testWithPerThisAspect() throws Exception {
TestBean bean1 = new TestBean();
TestBean bean2 = new TestBean();

View File

@ -29,7 +29,7 @@ import org.springframework.core.io.ClassPathResource;
*/
public class AopNamespaceHandlerPointcutErrorTests {
@Test
@Test
public void testDuplicatePointcutConfig() {
try {
new XmlBeanFactory(new ClassPathResource(
@ -41,7 +41,7 @@ public class AopNamespaceHandlerPointcutErrorTests {
}
}
@Test
@Test
public void testMissingPointcutConfig() {
try {
new XmlBeanFactory(new ClassPathResource(

View File

@ -30,7 +30,7 @@ import org.springframework.core.io.ClassPathResource;
*/
public final class TopLevelAopTagTests {
@Test
@Test
public void testParse() throws Exception {
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(beanFactory);

View File

@ -62,24 +62,24 @@ public class IntroductionBenchmarkTests {
Counter counter = (Counter) proxy;
sw.start(INVOCATIONS + " invocations on proxy, not hitting introduction");
for (int i = 0; i < INVOCATIONS; i++) {
proxy.getAge();
}
sw.stop();
sw.start(INVOCATIONS + " invocations on proxy, not hitting introduction");
for (int i = 0; i < INVOCATIONS; i++) {
proxy.getAge();
}
sw.stop();
sw.start(INVOCATIONS + " invocations on proxy, hitting introduction");
for (int i = 0; i < INVOCATIONS; i++) {
counter.getCount();
}
sw.stop();
sw.start(INVOCATIONS + " invocations on proxy, hitting introduction");
for (int i = 0; i < INVOCATIONS; i++) {
counter.getCount();
}
sw.stop();
sw.start(INVOCATIONS + " invocations on target");
for (int i = 0; i < INVOCATIONS; i++) {
target.getAge();
}
sw.stop();
sw.start(INVOCATIONS + " invocations on target");
for (int i = 0; i < INVOCATIONS; i++) {
target.getAge();
}
sw.stop();
System.out.println(sw.prettyPrint());
}
System.out.println(sw.prettyPrint());
}
}

View File

@ -41,7 +41,7 @@ import org.springframework.aop.framework.MethodCounter;
*/
public class ThrowsAdviceInterceptorTests {
@Test
@Test
public void testNoHandlerMethods() {
Object o = new Object();
try {
@ -53,7 +53,7 @@ public class ThrowsAdviceInterceptorTests {
}
}
@Test
@Test
public void testNotInvoked() throws Throwable {
MyThrowsHandler th = new MyThrowsHandler();
ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th);
@ -66,7 +66,7 @@ public class ThrowsAdviceInterceptorTests {
verify(mi);
}
@Test
@Test
public void testNoHandlerMethodForThrowable() throws Throwable {
MyThrowsHandler th = new MyThrowsHandler();
ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th);
@ -86,7 +86,7 @@ public class ThrowsAdviceInterceptorTests {
verify(mi);
}
@Test
@Test
public void testCorrectHandlerUsed() throws Throwable {
MyThrowsHandler th = new MyThrowsHandler();
ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th);
@ -109,7 +109,7 @@ public class ThrowsAdviceInterceptorTests {
verify(mi);
}
@Test
@Test
public void testCorrectHandlerUsedForSubclass() throws Throwable {
MyThrowsHandler th = new MyThrowsHandler();
ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th);
@ -130,7 +130,7 @@ public class ThrowsAdviceInterceptorTests {
verify(mi);
}
@Test
@Test
public void testHandlerMethodThrowsException() throws Throwable {
final Throwable t = new Throwable();
@ -161,7 +161,7 @@ public class ThrowsAdviceInterceptorTests {
}
@SuppressWarnings("serial")
private static class MyThrowsHandler extends MethodCounter implements ThrowsAdvice {
private static class MyThrowsHandler extends MethodCounter implements ThrowsAdvice {
// Full method signature
public void afterThrowing(Method m, Object[] args, Object target, IOException ex) {
count("ioException");

View File

@ -31,7 +31,7 @@ public class AuthenticationLogger {
}
class SecurityManager {
public boolean authenticate(String username, String password) {
return false;
}
public boolean authenticate(String username, String password) {
return false;
}
}

View File

@ -30,7 +30,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
*/
public class OverloadedAdviceTests {
@Test
@Test
public void testExceptionOnConfigParsingWithMismatchedAdviceMethod() {
try {
new ClassPathXmlApplicationContext("org/springframework/aop/aspectj/overloaded-advice-tests.xml");
@ -43,7 +43,7 @@ public class OverloadedAdviceTests {
}
}
@Test
@Test
public void testExceptionOnConfigParsingWithAmbiguousAdviceMethod() {
try {
new ClassPathXmlApplicationContext("org/springframework/aop/aspectj/ambiguous-advice-tests.xml");

View File

@ -33,22 +33,22 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
*/
public class PropertyDependentAspectTests {
@Test
@Test
public void testPropertyDependentAspectWithPropertyDeclaredBeforeAdvice() throws Exception {
checkXmlAspect("org/springframework/aop/aspectj/property-dependent-aspect-property-before-aspect-test.xml");
}
@Test
@Test
public void testPropertyDependentAspectWithPropertyDeclaredAfterAdvice() throws Exception {
checkXmlAspect("org/springframework/aop/aspectj/property-dependent-aspect-property-after-aspect-test.xml");
}
@Test
@Test
public void testPropertyDependentAtAspectJAspectWithPropertyDeclaredBeforeAdvice() throws Exception {
checkAtAspectJAspect("org/springframework/aop/aspectj/property-dependent-atAspectJ-aspect-property-before-aspect-test.xml");
}
@Test
@Test
public void testPropertyDependentAtAspectJAspectWithPropertyDeclaredAfterAdvice() throws Exception {
checkAtAspectJAspect("org/springframework/aop/aspectj/property-dependent-atAspectJ-aspect-property-after-aspect-test.xml");
}

View File

@ -24,18 +24,18 @@ import org.aspectj.lang.annotation.Pointcut;
@Aspect
public class AdviceUsingThisJoinPoint {
private String lastEntry = "";
private String lastEntry = "";
public String getLastMethodEntered() {
return this.lastEntry;
}
public String getLastMethodEntered() {
return this.lastEntry;
}
@Pointcut("execution(* *(..))")
public void methodExecution() {}
@Pointcut("execution(* *(..))")
public void methodExecution() {}
@Before("methodExecution()")
public void entryTrace(JoinPoint jp) {
this.lastEntry = jp.toString();
}
@Before("methodExecution()")
public void entryTrace(JoinPoint jp) {
this.lastEntry = jp.toString();
}
}

View File

@ -31,7 +31,7 @@ import java.io.IOException;
*/
public class AtAspectJAfterThrowingTests {
@Test
@Test
public void testAccessThrowable() throws Exception {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("afterThrowingAdviceTests.xml", getClass());

View File

@ -27,7 +27,7 @@ import org.springframework.beans.ITestBean;
*/
public class AopNamespaceHandlerProxyTargetClassTests extends AopNamespaceHandlerTests {
@Test
@Test
public void testIsClassProxy() {
ITestBean bean = getTestBean();
assertTrue("Should be a CGLIB proxy", AopUtils.isCglibProxy(bean));

View File

@ -24,7 +24,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
*/
public class PrototypeProxyTests {
@Test
@Test
public void testInjectionBeforeWrappingCheckDoesNotKickInForPrototypeProxy() {
new ClassPathXmlApplicationContext("prototypeProxy.xml", getClass());
}

View File

@ -802,7 +802,7 @@ public abstract class AbstractAopProxyTests {
ProxyFactory pc = new ProxyFactory(target);
@SuppressWarnings("serial")
class MyDi extends DelegatingIntroductionInterceptor implements TimeStamped {
class MyDi extends DelegatingIntroductionInterceptor implements TimeStamped {
/**
* @see org.springframework.aop.framework.TimeStamped#getTimeStamp()
*/
@ -1471,7 +1471,7 @@ public abstract class AbstractAopProxyTests {
}
}
SummingAfterAdvice aa = new SummingAfterAdvice();
@SuppressWarnings("serial")
@SuppressWarnings("serial")
Advisor matchesInt = new StaticMethodMatcherPointcutAdvisor(aa) {
public boolean matches(Method m, Class<?> targetClass) {
return m.getReturnType() == int.class;

View File

@ -627,8 +627,8 @@ public class ProxyFactoryBeanTests extends TestCase {
public void testFrozenFactoryBean() {
BeanFactory bf = new XmlBeanFactory(new ClassPathResource("frozenProxyFactoryBean.xml", getClass()));
Advised advised = (Advised)bf.getBean("frozen");
assertTrue("The proxy should be frozen", advised.isFrozen());
Advised advised = (Advised)bf.getBean("frozen");
assertTrue("The proxy should be frozen", advised.isFrozen());
}
public void testDetectsInterfaces() throws Exception {

View File

@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@ -33,24 +33,24 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
*/
public class AdvisorAdapterRegistrationTests {
@Test
public void testAdvisorAdapterRegistrationManagerNotPresentInContext() {
ApplicationContext ctx = new ClassPathXmlApplicationContext("/org/springframework/aop/framework/adapter/withoutBPPContext.xml");
ITestBean tb = (ITestBean) ctx.getBean("testBean");
@Test
public void testAdvisorAdapterRegistrationManagerNotPresentInContext() {
ApplicationContext ctx = new ClassPathXmlApplicationContext("/org/springframework/aop/framework/adapter/withoutBPPContext.xml");
ITestBean tb = (ITestBean) ctx.getBean("testBean");
// just invoke any method to see if advice fired
try {
try {
tb.getName();
fail("Should throw UnknownAdviceTypeException");
}
catch (UnknownAdviceTypeException ex) {
// expected
// expected
assertEquals(0, getAdviceImpl(tb).getInvocationCounter());
}
}
@Test
@Test
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");
// just invoke any method to see if advice fired
try {

View File

@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@ -28,87 +28,87 @@ import org.easymock.MockControl;
*/
public final class DebugInterceptorTests extends TestCase {
public void testSunnyDayPathLogsCorrectly() throws Throwable {
MockControl mockLog = MockControl.createControl(Log.class);
final Log log = (Log) mockLog.getMock();
public void testSunnyDayPathLogsCorrectly() throws Throwable {
MockControl mockLog = MockControl.createControl(Log.class);
final Log log = (Log) mockLog.getMock();
MockControl mockMethodInvocation = MockControl.createControl(MethodInvocation.class);
MethodInvocation methodInvocation = (MethodInvocation) mockMethodInvocation.getMock();
MockControl mockMethodInvocation = MockControl.createControl(MethodInvocation.class);
MethodInvocation methodInvocation = (MethodInvocation) mockMethodInvocation.getMock();
log.isTraceEnabled();
mockLog.setReturnValue(true);
log.trace("Some tracing output");
mockLog.setMatcher(MockControl.ALWAYS_MATCHER);
methodInvocation.proceed();
mockMethodInvocation.setReturnValue(null);
log.trace("Some more tracing output");
mockLog.setMatcher(MockControl.ALWAYS_MATCHER);
mockLog.setVoidCallable();
log.isTraceEnabled();
mockLog.setReturnValue(true);
log.trace("Some tracing output");
mockLog.setMatcher(MockControl.ALWAYS_MATCHER);
methodInvocation.proceed();
mockMethodInvocation.setReturnValue(null);
log.trace("Some more tracing output");
mockLog.setMatcher(MockControl.ALWAYS_MATCHER);
mockLog.setVoidCallable();
mockMethodInvocation.replay();
mockLog.replay();
mockMethodInvocation.replay();
mockLog.replay();
DebugInterceptor interceptor = new StubDebugInterceptor(log);
interceptor.invoke(methodInvocation);
checkCallCountTotal(interceptor);
DebugInterceptor interceptor = new StubDebugInterceptor(log);
interceptor.invoke(methodInvocation);
checkCallCountTotal(interceptor);
mockLog.verify();
mockMethodInvocation.verify();
}
mockLog.verify();
mockMethodInvocation.verify();
}
public void testExceptionPathStillLogsCorrectly() throws Throwable {
MockControl mockLog = MockControl.createControl(Log.class);
final Log log = (Log) mockLog.getMock();
public void testExceptionPathStillLogsCorrectly() throws Throwable {
MockControl mockLog = MockControl.createControl(Log.class);
final Log log = (Log) mockLog.getMock();
MockControl mockMethodInvocation = MockControl.createControl(MethodInvocation.class);
final MethodInvocation methodInvocation = (MethodInvocation) mockMethodInvocation.getMock();
MockControl mockMethodInvocation = MockControl.createControl(MethodInvocation.class);
final MethodInvocation methodInvocation = (MethodInvocation) mockMethodInvocation.getMock();
log.isTraceEnabled();
mockLog.setReturnValue(true);
log.trace("Some tracing output");
mockLog.setMatcher(MockControl.ALWAYS_MATCHER);
methodInvocation.proceed();
IllegalArgumentException exception = new IllegalArgumentException();
mockMethodInvocation.setThrowable(exception);
log.trace("Some more tracing output", exception);
mockLog.setMatcher(MockControl.ALWAYS_MATCHER);
mockLog.setVoidCallable();
log.isTraceEnabled();
mockLog.setReturnValue(true);
log.trace("Some tracing output");
mockLog.setMatcher(MockControl.ALWAYS_MATCHER);
methodInvocation.proceed();
IllegalArgumentException exception = new IllegalArgumentException();
mockMethodInvocation.setThrowable(exception);
log.trace("Some more tracing output", exception);
mockLog.setMatcher(MockControl.ALWAYS_MATCHER);
mockLog.setVoidCallable();
mockMethodInvocation.replay();
mockLog.replay();
mockMethodInvocation.replay();
mockLog.replay();
DebugInterceptor interceptor = new StubDebugInterceptor(log);
try {
interceptor.invoke(methodInvocation);
fail("Must have propagated the IllegalArgumentException.");
} catch (IllegalArgumentException expected) {
}
checkCallCountTotal(interceptor);
DebugInterceptor interceptor = new StubDebugInterceptor(log);
try {
interceptor.invoke(methodInvocation);
fail("Must have propagated the IllegalArgumentException.");
} catch (IllegalArgumentException expected) {
}
checkCallCountTotal(interceptor);
mockLog.verify();
mockMethodInvocation.verify();
}
mockLog.verify();
mockMethodInvocation.verify();
}
private void checkCallCountTotal(DebugInterceptor interceptor) {
assertEquals("Intercepted call count not being incremented correctly", 1, interceptor.getCount());
}
private void checkCallCountTotal(DebugInterceptor interceptor) {
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) {
super(true);
this.log = log;
}
public StubDebugInterceptor(Log log) {
super(true);
this.log = log;
}
protected Log getLoggerForInvocation(MethodInvocation invocation) {
return log;
}
protected Log getLoggerForInvocation(MethodInvocation invocation) {
return log;
}
}
}
}

View File

@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@ -30,72 +30,72 @@ import java.lang.reflect.Method;
*/
public final class SimpleTraceInterceptorTests extends TestCase {
public void testSunnyDayPathLogsCorrectly() throws Throwable {
MockControl mockLog = MockControl.createControl(Log.class);
Log log = (Log) mockLog.getMock();
public void testSunnyDayPathLogsCorrectly() throws Throwable {
MockControl mockLog = MockControl.createControl(Log.class);
Log log = (Log) mockLog.getMock();
MockControl mockMethodInvocation = MockControl.createControl(MethodInvocation.class);
MethodInvocation methodInvocation = (MethodInvocation) mockMethodInvocation.getMock();
MockControl mockMethodInvocation = MockControl.createControl(MethodInvocation.class);
MethodInvocation methodInvocation = (MethodInvocation) mockMethodInvocation.getMock();
Method toString = String.class.getMethod("toString", new Class[]{});
Method toString = String.class.getMethod("toString", new Class[]{});
methodInvocation.getMethod();
mockMethodInvocation.setReturnValue(toString);
methodInvocation.getThis();
mockMethodInvocation.setReturnValue(this);
log.trace("Some tracing output");
mockLog.setMatcher(MockControl.ALWAYS_MATCHER);
methodInvocation.proceed();
mockMethodInvocation.setReturnValue(null);
log.trace("Some more tracing output");
mockLog.setMatcher(MockControl.ALWAYS_MATCHER);
mockLog.setVoidCallable();
methodInvocation.getMethod();
mockMethodInvocation.setReturnValue(toString);
methodInvocation.getThis();
mockMethodInvocation.setReturnValue(this);
log.trace("Some tracing output");
mockLog.setMatcher(MockControl.ALWAYS_MATCHER);
methodInvocation.proceed();
mockMethodInvocation.setReturnValue(null);
log.trace("Some more tracing output");
mockLog.setMatcher(MockControl.ALWAYS_MATCHER);
mockLog.setVoidCallable();
mockMethodInvocation.replay();
mockLog.replay();
mockMethodInvocation.replay();
mockLog.replay();
SimpleTraceInterceptor interceptor = new SimpleTraceInterceptor(true);
interceptor.invokeUnderTrace(methodInvocation, log);
SimpleTraceInterceptor interceptor = new SimpleTraceInterceptor(true);
interceptor.invokeUnderTrace(methodInvocation, log);
mockLog.verify();
mockMethodInvocation.verify();
}
mockLog.verify();
mockMethodInvocation.verify();
}
public void testExceptionPathStillLogsCorrectly() throws Throwable {
MockControl mockLog = MockControl.createControl(Log.class);
final Log log = (Log) mockLog.getMock();
public void testExceptionPathStillLogsCorrectly() throws Throwable {
MockControl mockLog = MockControl.createControl(Log.class);
final Log log = (Log) mockLog.getMock();
MockControl mockMethodInvocation = MockControl.createControl(MethodInvocation.class);
final MethodInvocation methodInvocation = (MethodInvocation) mockMethodInvocation.getMock();
MockControl mockMethodInvocation = MockControl.createControl(MethodInvocation.class);
final MethodInvocation methodInvocation = (MethodInvocation) mockMethodInvocation.getMock();
Method toString = String.class.getMethod("toString", new Class[]{});
Method toString = String.class.getMethod("toString", new Class[]{});
methodInvocation.getMethod();
mockMethodInvocation.setReturnValue(toString);
methodInvocation.getThis();
mockMethodInvocation.setReturnValue(this);
log.trace("Some tracing output");
mockLog.setMatcher(MockControl.ALWAYS_MATCHER);
methodInvocation.proceed();
IllegalArgumentException exception = new IllegalArgumentException();
mockMethodInvocation.setThrowable(exception);
log.trace("Some more tracing output", exception);
mockLog.setMatcher(MockControl.ALWAYS_MATCHER);
mockLog.setVoidCallable();
methodInvocation.getMethod();
mockMethodInvocation.setReturnValue(toString);
methodInvocation.getThis();
mockMethodInvocation.setReturnValue(this);
log.trace("Some tracing output");
mockLog.setMatcher(MockControl.ALWAYS_MATCHER);
methodInvocation.proceed();
IllegalArgumentException exception = new IllegalArgumentException();
mockMethodInvocation.setThrowable(exception);
log.trace("Some more tracing output", exception);
mockLog.setMatcher(MockControl.ALWAYS_MATCHER);
mockLog.setVoidCallable();
mockMethodInvocation.replay();
mockLog.replay();
mockMethodInvocation.replay();
mockLog.replay();
final SimpleTraceInterceptor interceptor = new SimpleTraceInterceptor(true);
final SimpleTraceInterceptor interceptor = new SimpleTraceInterceptor(true);
try {
interceptor.invokeUnderTrace(methodInvocation, log);
fail("Must have propagated the IllegalArgumentException.");
} catch (IllegalArgumentException expected) {
}
try {
interceptor.invokeUnderTrace(methodInvocation, log);
fail("Must have propagated the IllegalArgumentException.");
} catch (IllegalArgumentException expected) {
}
mockLog.verify();
mockMethodInvocation.verify();
}
mockLog.verify();
mockMethodInvocation.verify();
}
}

View File

@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@ -200,22 +200,22 @@ public class DelegatingIntroductionInterceptorTests extends TestCase {
}
public void testDelegateReturnsThisIsMassagedToReturnProxy() {
NestedTestBean target = new NestedTestBean();
String company = "Interface21";
target.setCompany(company);
TestBean delegate = new TestBean() {
public ITestBean getSpouse() {
return this;
}
};
ProxyFactory pf = new ProxyFactory(target);
pf.addAdvice(new DelegatingIntroductionInterceptor(delegate));
INestedTestBean proxy = (INestedTestBean) pf.getProxy();
NestedTestBean target = new NestedTestBean();
String company = "Interface21";
target.setCompany(company);
TestBean delegate = new TestBean() {
public ITestBean getSpouse() {
return this;
}
};
ProxyFactory pf = new ProxyFactory(target);
pf.addAdvice(new DelegatingIntroductionInterceptor(delegate));
INestedTestBean proxy = (INestedTestBean) pf.getProxy();
assertEquals(company, proxy.getCompany());
ITestBean introduction = (ITestBean) proxy;
assertSame("Introduced method returning delegate returns proxy", introduction, introduction.getSpouse());
assertTrue("Introduced method returning delegate returns proxy", AopUtils.isAopProxy(introduction.getSpouse()));
assertEquals(company, proxy.getCompany());
ITestBean introduction = (ITestBean) proxy;
assertSame("Introduced method returning delegate returns proxy", introduction, introduction.getSpouse());
assertTrue("Introduced method returning delegate returns proxy", AopUtils.isAopProxy(introduction.getSpouse()));
}
public void testSerializableDelegatingIntroductionInterceptorSerializable() throws Exception {

View File

@ -24,5 +24,6 @@ package org.springframework.beans.factory;
*/
class PackageLevelVisibleBean {
public static final String CONSTANT = "Wuby";
public static final String CONSTANT = "Wuby";
}

View File

@ -25,51 +25,51 @@ import java.util.List;
*/
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.
*/
public String getName() {
return name;
}
/**
* @return Returns the name.
*/
public String getName() {
return name;
}
/**
* @param name The name to set.
*/
public void setName(String name) {
this.name = name;
}
/**
* @param name The name to set.
*/
public void setName(String name) {
this.name = name;
}
/**
* @return Returns the list.
*/
public List getList() {
return list;
}
/**
* @return Returns the list.
*/
public List getList() {
return list;
}
/**
* @param list The list to set.
*/
public void setList(List list) {
this.list = list;
}
/**
* @param list The list to set.
*/
public void setList(List list) {
this.list = list;
}
/**
* @return Returns the object.
*/
public Object getObjRef() {
return objRef;
}
/**
* @return Returns the object.
*/
public Object getObjRef() {
return objRef;
}
/**
* @param object The object to set.
*/
public void setObjRef(Object object) {
this.objRef = object;
}
/**
* @param object The object to set.
*/
public void setObjRef(Object object) {
this.objRef = object;
}
}

View File

@ -27,33 +27,33 @@ import org.springframework.test.AssertThrows;
*/
public final class CommonsLogFactoryBeanTests extends TestCase {
public void testIsSingleton() throws Exception {
CommonsLogFactoryBean factory = new CommonsLogFactoryBean();
assertTrue(factory.isSingleton());
}
public void testIsSingleton() throws Exception {
CommonsLogFactoryBean factory = new CommonsLogFactoryBean();
assertTrue(factory.isSingleton());
}
public void testGetObjectTypeDefaultsToPlainResourceInterfaceifLookupResourceIsNotSupplied() throws Exception {
CommonsLogFactoryBean factory = new CommonsLogFactoryBean();
assertEquals(Log.class, factory.getObjectType());
}
public void testGetObjectTypeDefaultsToPlainResourceInterfaceifLookupResourceIsNotSupplied() throws Exception {
CommonsLogFactoryBean factory = new CommonsLogFactoryBean();
assertEquals(Log.class, factory.getObjectType());
}
public void testWhenLogNameIsMissing() throws Exception {
new AssertThrows(IllegalArgumentException.class) {
public void test() throws Exception {
CommonsLogFactoryBean factory = new CommonsLogFactoryBean();
factory.afterPropertiesSet();
}
}.runTest();
}
public void testWhenLogNameIsMissing() throws Exception {
new AssertThrows(IllegalArgumentException.class) {
public void test() throws Exception {
CommonsLogFactoryBean factory = new CommonsLogFactoryBean();
factory.afterPropertiesSet();
}
}.runTest();
}
public void testSunnyDayPath() throws Exception {
CommonsLogFactoryBean factory = new CommonsLogFactoryBean();
factory.setLogName("The Tin Drum");
factory.afterPropertiesSet();
Object object = factory.getObject();
public void testSunnyDayPath() throws Exception {
CommonsLogFactoryBean factory = new CommonsLogFactoryBean();
factory.setLogName("The Tin Drum");
factory.afterPropertiesSet();
Object object = factory.getObject();
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()));
}
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()));
}
}

View File

@ -48,11 +48,12 @@ import org.springframework.util.StringUtils;
/**
* @author Juergen Hoeller
* @author Chris Beams
* @since 02.10.2003
*/
public class PropertyResourceConfigurerTests {
@Test
@Test
public void testPropertyOverrideConfigurer() {
StaticApplicationContext ac = new StaticApplicationContext();
ac.registerSingleton("tb1", TestBean.class);
@ -73,7 +74,7 @@ public class PropertyResourceConfigurerTests {
assertEquals("test", tb2.getName());
}
@Test
@Test
public void testPropertyOverrideConfigurerWithNestedProperty() {
StaticApplicationContext ac = new StaticApplicationContext();
ac.registerSingleton("tb", IndexedTestBean.class);
@ -86,7 +87,7 @@ public class PropertyResourceConfigurerTests {
assertEquals("test", ((TestBean) tb.getList().get(1)).getName());
}
@Test
@Test
public void testPropertyOverrideConfigurerWithNestedPropertyAndDotInBeanName() {
StaticApplicationContext ac = new StaticApplicationContext();
ac.registerSingleton("my.tb", IndexedTestBean.class);
@ -100,7 +101,7 @@ public class PropertyResourceConfigurerTests {
assertEquals("test", ((TestBean) tb.getList().get(1)).getName());
}
@Test
@Test
public void testPropertyOverrideConfigurerWithNestedMapPropertyAndDotInMapKey() {
StaticApplicationContext ac = new StaticApplicationContext();
ac.registerSingleton("tb", IndexedTestBean.class);
@ -113,7 +114,7 @@ public class PropertyResourceConfigurerTests {
assertEquals("test", tb.getMap().get("key2.ext"));
}
@Test
@Test
public void testPropertyOverrideConfigurerWithJavaMailProperties() {
StaticApplicationContext ac = new StaticApplicationContext();
ac.registerSingleton("tb", JavaMailSenderImpl.class);
@ -125,7 +126,7 @@ public class PropertyResourceConfigurerTests {
assertEquals("true", tb.getJavaMailProperties().getProperty("mail.smtp.auth"));
}
@Test
@Test
public void testPropertyOverrideConfigurerWithPropertiesFile() {
StaticApplicationContext ac = new StaticApplicationContext();
ac.registerSingleton("tb", IndexedTestBean.class);
@ -138,7 +139,7 @@ public class PropertyResourceConfigurerTests {
assertEquals("test", ((TestBean) tb.getList().get(1)).getName());
}
@Test
@Test
public void testPropertyOverrideConfigurerWithInvalidPropertiesFile() {
StaticApplicationContext ac = new StaticApplicationContext();
ac.registerSingleton("tb", IndexedTestBean.class);
@ -154,7 +155,7 @@ public class PropertyResourceConfigurerTests {
assertEquals("test", ((TestBean) tb.getList().get(1)).getName());
}
@Test
@Test
public void testPropertyOverrideConfigurerWithPropertiesXmlFile() {
// ignore for JDK < 1.5
if (JdkVersion.getMajorJavaVersion() < JdkVersion.JAVA_15) {
@ -172,7 +173,7 @@ public class PropertyResourceConfigurerTests {
assertEquals("test", ((TestBean) tb.getList().get(1)).getName());
}
@Test
@Test
public void testPropertyOverrideConfigurerWithConvertProperties() {
StaticApplicationContext ac = new StaticApplicationContext();
ac.registerSingleton("tb", IndexedTestBean.class);
@ -185,7 +186,7 @@ public class PropertyResourceConfigurerTests {
assertEquals("Xtest", ((TestBean) tb.getList().get(1)).getName());
}
@Test
@Test
public void testPropertyOverrideConfigurerWithInvalidKey() {
StaticApplicationContext ac = new StaticApplicationContext();
ac.registerSingleton("tb1", TestBean.class);
@ -206,7 +207,7 @@ public class PropertyResourceConfigurerTests {
}
}
@Test
@Test
public void testPropertyOverrideConfigurerWithIgnoreInvalidKeys() {
StaticApplicationContext ac = new StaticApplicationContext();
ac.registerSingleton("tb1", TestBean.class);
@ -228,12 +229,12 @@ public class PropertyResourceConfigurerTests {
assertEquals("test", tb2.getName());
}
@Test
@Test
public void testPropertyPlaceholderConfigurer() {
doTestPropertyPlaceholderConfigurer(false);
}
@Test
@Test
public void testPropertyPlaceholderConfigurerWithParentChildSeparation() {
doTestPropertyPlaceholderConfigurer(true);
}

View File

@ -276,7 +276,7 @@ public class XmlBeanCollectionTests extends TestCase {
XmlBeanFactory xbf = new XmlBeanFactory(new ClassPathResource("collections.xml", getClass()));
HasMap hasMap = (HasMap) xbf.getBean("props");
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"));
}

View File

@ -1096,8 +1096,8 @@ public class BridgeMethodResolverTests {
public class BusinessDao extends BusinessGenericDao<Business<?>, Long> {
public void save(Business<?> business) {
}
public void save(Business<?> business) {
}
public Business<?> get(Long id) {
return null;

View File

@ -40,7 +40,7 @@ import org.springframework.web.context.support.ServletContextResource;
*/
public class ResourceTests {
@Test
@Test
public void testByteArrayResource() throws IOException {
Resource resource = new ByteArrayResource("testString".getBytes());
assertTrue(resource.exists());
@ -50,7 +50,7 @@ public class ResourceTests {
assertEquals(resource, new ByteArrayResource("testString".getBytes()));
}
@Test
@Test
public void testByteArrayResourceWithDescription() throws IOException {
Resource resource = new ByteArrayResource("testString".getBytes(), "my description");
assertTrue(resource.exists());
@ -61,7 +61,7 @@ public class ResourceTests {
assertEquals(resource, new ByteArrayResource("testString".getBytes()));
}
@Test
@Test
public void testInputStreamResource() throws IOException {
InputStream is = new ByteArrayInputStream("testString".getBytes());
Resource resource = new InputStreamResource(is);
@ -72,7 +72,7 @@ public class ResourceTests {
assertEquals(resource, new InputStreamResource(is));
}
@Test
@Test
public void testInputStreamResourceWithDescription() throws IOException {
InputStream is = new ByteArrayInputStream("testString".getBytes());
Resource resource = new InputStreamResource(is, "my description");
@ -84,7 +84,7 @@ public class ResourceTests {
assertEquals(resource, new InputStreamResource(is));
}
@Test
@Test
public void testClassPathResource() throws IOException {
Resource resource = new ClassPathResource("org/springframework/core/io/Resource.class");
doTestResource(resource);
@ -100,7 +100,7 @@ public class ResourceTests {
assertEquals(1, resources.size());
}
@Test
@Test
public void testClassPathResourceWithClassLoader() throws IOException {
Resource resource =
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()));
}
@Test
@Test
public void testClassPathResourceWithClass() throws IOException {
Resource resource = new ClassPathResource("Resource.class", getClass());
doTestResource(resource);
assertEquals(resource, new ClassPathResource("Resource.class", getClass()));
}
@Ignore // passes under eclipse, fails under ant
@Test
@Ignore // passes under eclipse, fails under ant
@Test
public void testFileSystemResource() throws IOException {
Resource resource = new FileSystemResource(getClass().getResource("Resource.class").getFile());
doTestResource(resource);
@ -126,7 +126,7 @@ public class ResourceTests {
assertEquals(resource2, new FileSystemResource("core/../core/io/./Resource.class"));
}
@Test
@Test
public void testUrlResource() throws IOException {
Resource resource = new UrlResource(getClass().getResource("Resource.class"));
doTestResource(resource);
@ -135,7 +135,7 @@ public class ResourceTests {
assertEquals(resource2, new UrlResource("file:core/../core/io/./Resource.class"));
}
@Test
@Test
public void testServletContextResource() throws IOException {
MockServletContext sc = new MockServletContext();
Resource resource = new ServletContextResource(sc, "org/springframework/core/io/Resource.class");

View File

@ -30,403 +30,403 @@ import javax.jms.*;
*/
public final class MessageListenerAdapter102Tests extends TestCase {
private static final String TEXT = "The Runaways";
private static final String CORRELATION_ID = "100";
private static final String RESPONSE_TEXT = "Old Lace";
public void testWithMessageContentsDelegateForBytesMessage() throws Exception {
MockControl mockBytesMessage = MockControl.createControl(BytesMessage.class);
BytesMessage bytesMessage = (BytesMessage) mockBytesMessage.getMock();
// BytesMessage contents must be unwrapped...
bytesMessage.readBytes(null);
mockBytesMessage.setMatcher(MockControl.ALWAYS_MATCHER);
mockBytesMessage.setReturnValue(TEXT.getBytes().length);
mockBytesMessage.replay();
MockControl mockDelegate = MockControl.createControl(MessageContentsDelegate.class);
MessageContentsDelegate delegate = (MessageContentsDelegate) mockDelegate.getMock();
delegate.handleMessage(TEXT.getBytes());
mockDelegate.setMatcher(MockControl.ALWAYS_MATCHER);
mockDelegate.setVoidCallable();
mockDelegate.replay();
MessageListenerAdapter102 adapter = new MessageListenerAdapter102(delegate);
adapter.onMessage(bytesMessage);
mockDelegate.verify();
mockBytesMessage.verify();
}
public void testWithMessageDelegate() throws Exception {
MockControl mockTextMessage = MockControl.createControl(TextMessage.class);
TextMessage textMessage = (TextMessage) mockTextMessage.getMock();
mockTextMessage.replay();
MockControl mockDelegate = MockControl.createControl(MessageDelegate.class);
MessageDelegate delegate = (MessageDelegate) mockDelegate.getMock();
delegate.handleMessage(textMessage);
mockDelegate.setVoidCallable();
mockDelegate.replay();
MessageListenerAdapter102 adapter = new MessageListenerAdapter102(delegate);
// we DON'T want the default SimpleMessageConversion happening...
adapter.setMessageConverter(null);
adapter.onMessage(textMessage);
mockDelegate.verify();
mockTextMessage.verify();
}
public void testThatTheDefaultMessageConverterisIndeedTheSimpleMessageConverter102() throws Exception {
MessageListenerAdapter102 adapter = new MessageListenerAdapter102();
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);
}
public void testWithResponsiveMessageDelegate_DoesNotSendReturnTextMessageIfNoSessionSupplied() throws Exception {
MockControl mockTextMessage = MockControl.createControl(TextMessage.class);
TextMessage textMessage = (TextMessage) mockTextMessage.getMock();
mockTextMessage.replay();
MockControl mockDelegate = MockControl.createControl(ResponsiveMessageDelegate.class);
ResponsiveMessageDelegate delegate = (ResponsiveMessageDelegate) mockDelegate.getMock();
delegate.handleMessage(textMessage);
mockDelegate.setReturnValue(TEXT);
mockDelegate.replay();
MessageListenerAdapter102 adapter = new MessageListenerAdapter102(delegate);
// we DON'T want the default SimpleMessageConversion happening...
adapter.setMessageConverter(null);
adapter.onMessage(textMessage);
mockDelegate.verify();
mockTextMessage.verify();
}
public void testWithResponsiveMessageDelegateWithDefaultDestination_SendsReturnTextMessageWhenSessionSuppliedForQueue() throws Exception {
MockControl mockDestination = MockControl.createControl(Queue.class);
Queue destination = (Queue) mockDestination.getMock();
mockDestination.replay();
MockControl mockSentTextMessage = MockControl.createControl(TextMessage.class);
TextMessage sentTextMessage = (TextMessage) mockSentTextMessage.getMock();
// correlation ID is queried when response is being created...
sentTextMessage.getJMSCorrelationID();
mockSentTextMessage.setReturnValue(CORRELATION_ID);
// Reply-To is queried when response is being created...
sentTextMessage.getJMSReplyTo();
mockSentTextMessage.setReturnValue(null); // we want to fall back to the default...
mockSentTextMessage.replay();
MockControl mockResponseTextMessage = MockControl.createControl(TextMessage.class);
TextMessage responseTextMessage = (TextMessage) mockResponseTextMessage.getMock();
responseTextMessage.setJMSCorrelationID(CORRELATION_ID);
mockResponseTextMessage.setVoidCallable();
mockResponseTextMessage.replay();
MockControl mockQueueSender = MockControl.createControl(QueueSender.class);
QueueSender queueSender = (QueueSender) mockQueueSender.getMock();
queueSender.send(responseTextMessage);
mockQueueSender.setVoidCallable();
queueSender.close();
mockQueueSender.setVoidCallable();
mockQueueSender.replay();
MockControl mockSession = MockControl.createControl(QueueSession.class);
QueueSession session = (QueueSession) mockSession.getMock();
session.createTextMessage(RESPONSE_TEXT);
mockSession.setReturnValue(responseTextMessage);
session.createSender(destination);
mockSession.setReturnValue(queueSender);
mockSession.replay();
MockControl mockDelegate = MockControl.createControl(ResponsiveMessageDelegate.class);
ResponsiveMessageDelegate delegate = (ResponsiveMessageDelegate) mockDelegate.getMock();
delegate.handleMessage(sentTextMessage);
mockDelegate.setReturnValue(RESPONSE_TEXT);
mockDelegate.replay();
MessageListenerAdapter102 adapter = new MessageListenerAdapter102(delegate) {
protected Object extractMessage(Message message) {
return message;
}
};
adapter.setDefaultResponseDestination(destination);
adapter.onMessage(sentTextMessage, session);
mockDelegate.verify();
mockSentTextMessage.verify();
mockResponseTextMessage.verify();
mockSession.verify();
mockDestination.verify();
mockQueueSender.verify();
}
public void testWithResponsiveMessageDelegateWithDefaultDestination_SendsReturnTextMessageWhenSessionSuppliedForTopic() throws Exception {
MockControl mockDestination = MockControl.createControl(Topic.class);
Topic destination = (Topic) mockDestination.getMock();
mockDestination.replay();
MockControl mockSentTextMessage = MockControl.createControl(TextMessage.class);
TextMessage sentTextMessage = (TextMessage) mockSentTextMessage.getMock();
// correlation ID is queried when response is being created...
sentTextMessage.getJMSCorrelationID();
mockSentTextMessage.setReturnValue(CORRELATION_ID);
// Reply-To is queried when response is being created...
sentTextMessage.getJMSReplyTo();
mockSentTextMessage.setReturnValue(null); // we want to fall back to the default...
mockSentTextMessage.replay();
MockControl mockResponseTextMessage = MockControl.createControl(TextMessage.class);
TextMessage responseTextMessage = (TextMessage) mockResponseTextMessage.getMock();
responseTextMessage.setJMSCorrelationID(CORRELATION_ID);
mockResponseTextMessage.setVoidCallable();
mockResponseTextMessage.replay();
MockControl mockTopicPublisher = MockControl.createControl(TopicPublisher.class);
TopicPublisher topicPublisher = (TopicPublisher) mockTopicPublisher.getMock();
topicPublisher.publish(responseTextMessage);
mockTopicPublisher.setVoidCallable();
topicPublisher.close();
mockTopicPublisher.setVoidCallable();
mockTopicPublisher.replay();
MockControl mockSession = MockControl.createControl(TopicSession.class);
TopicSession session = (TopicSession) mockSession.getMock();
session.createTextMessage(RESPONSE_TEXT);
mockSession.setReturnValue(responseTextMessage);
session.createPublisher(destination);
mockSession.setReturnValue(topicPublisher);
mockSession.replay();
MockControl mockDelegate = MockControl.createControl(ResponsiveMessageDelegate.class);
ResponsiveMessageDelegate delegate = (ResponsiveMessageDelegate) mockDelegate.getMock();
delegate.handleMessage(sentTextMessage);
mockDelegate.setReturnValue(RESPONSE_TEXT);
mockDelegate.replay();
MessageListenerAdapter102 adapter = new MessageListenerAdapter102(delegate) {
protected Object extractMessage(Message message) {
return message;
}
};
adapter.setDefaultResponseDestination(destination);
adapter.onMessage(sentTextMessage, session);
mockDelegate.verify();
mockSentTextMessage.verify();
mockResponseTextMessage.verify();
mockSession.verify();
mockDestination.verify();
mockTopicPublisher.verify();
}
public void testWithResponsiveMessageDelegateNoDefaultDestination_SendsReturnTextMessageWhenSessionSupplied() throws Exception {
MockControl mockDestination = MockControl.createControl(Queue.class);
Queue destination = (Queue) mockDestination.getMock();
mockDestination.replay();
MockControl mockSentTextMessage = MockControl.createControl(TextMessage.class);
TextMessage sentTextMessage = (TextMessage) mockSentTextMessage.getMock();
// correlation ID is queried when response is being created...
sentTextMessage.getJMSCorrelationID();
mockSentTextMessage.setReturnValue(CORRELATION_ID);
// Reply-To is queried when response is being created...
sentTextMessage.getJMSReplyTo();
mockSentTextMessage.setReturnValue(destination);
mockSentTextMessage.replay();
MockControl mockResponseTextMessage = MockControl.createControl(TextMessage.class);
TextMessage responseTextMessage = (TextMessage) mockResponseTextMessage.getMock();
responseTextMessage.setJMSCorrelationID(CORRELATION_ID);
mockResponseTextMessage.setVoidCallable();
mockResponseTextMessage.replay();
MockControl mockQueueSender = MockControl.createControl(QueueSender.class);
QueueSender queueSender = (QueueSender) mockQueueSender.getMock();
queueSender.send(responseTextMessage);
mockQueueSender.setVoidCallable();
queueSender.close();
mockQueueSender.setVoidCallable();
mockQueueSender.replay();
MockControl mockSession = MockControl.createControl(QueueSession.class);
QueueSession session = (QueueSession) mockSession.getMock();
session.createTextMessage(RESPONSE_TEXT);
mockSession.setReturnValue(responseTextMessage);
session.createSender(destination);
mockSession.setReturnValue(queueSender);
mockSession.replay();
MockControl mockDelegate = MockControl.createControl(ResponsiveMessageDelegate.class);
ResponsiveMessageDelegate delegate = (ResponsiveMessageDelegate) mockDelegate.getMock();
delegate.handleMessage(sentTextMessage);
mockDelegate.setReturnValue(RESPONSE_TEXT);
mockDelegate.replay();
MessageListenerAdapter102 adapter = new MessageListenerAdapter102(delegate) {
protected Object extractMessage(Message message) {
return message;
}
};
adapter.onMessage(sentTextMessage, session);
mockDelegate.verify();
mockSentTextMessage.verify();
mockResponseTextMessage.verify();
mockSession.verify();
mockDestination.verify();
mockQueueSender.verify();
}
public void testWithResponsiveMessageDelegateNoDefaultDestinationAndNoReplyToDestination_SendsReturnTextMessageWhenSessionSupplied() throws Exception {
MockControl mockSentTextMessage = MockControl.createControl(TextMessage.class);
final TextMessage sentTextMessage = (TextMessage) mockSentTextMessage.getMock();
// correlation ID is queried when response is being created...
sentTextMessage.getJMSCorrelationID();
mockSentTextMessage.setReturnValue(CORRELATION_ID);
// Reply-To is queried when response is being created...
sentTextMessage.getJMSReplyTo();
mockSentTextMessage.setReturnValue(null);
mockSentTextMessage.replay();
MockControl mockResponseTextMessage = MockControl.createControl(TextMessage.class);
TextMessage responseTextMessage = (TextMessage) mockResponseTextMessage.getMock();
responseTextMessage.setJMSCorrelationID(CORRELATION_ID);
mockResponseTextMessage.setVoidCallable();
mockResponseTextMessage.replay();
MockControl mockSession = MockControl.createControl(QueueSession.class);
final QueueSession session = (QueueSession) mockSession.getMock();
session.createTextMessage(RESPONSE_TEXT);
mockSession.setReturnValue(responseTextMessage);
mockSession.replay();
MockControl mockDelegate = MockControl.createControl(ResponsiveMessageDelegate.class);
ResponsiveMessageDelegate delegate = (ResponsiveMessageDelegate) mockDelegate.getMock();
delegate.handleMessage(sentTextMessage);
mockDelegate.setReturnValue(RESPONSE_TEXT);
mockDelegate.replay();
final MessageListenerAdapter102 adapter = new MessageListenerAdapter102(delegate) {
protected Object extractMessage(Message message) {
return message;
}
};
new AssertThrows(InvalidDestinationException.class) {
public void test() throws Exception {
adapter.onMessage(sentTextMessage, session);
}
}.runTest();
mockDelegate.verify();
mockSentTextMessage.verify();
mockResponseTextMessage.verify();
mockSession.verify();
}
public void testWithResponsiveMessageDelegateNoDefaultDestination_SendsReturnTextMessageWhenSessionSupplied_AndSendingThrowsJMSException() throws Exception {
MockControl mockDestination = MockControl.createControl(Queue.class);
Queue destination = (Queue) mockDestination.getMock();
mockDestination.replay();
MockControl mockSentTextMessage = MockControl.createControl(TextMessage.class);
final TextMessage sentTextMessage = (TextMessage) mockSentTextMessage.getMock();
// correlation ID is queried when response is being created...
sentTextMessage.getJMSCorrelationID();
mockSentTextMessage.setReturnValue(CORRELATION_ID);
// Reply-To is queried when response is being created...
sentTextMessage.getJMSReplyTo();
mockSentTextMessage.setReturnValue(destination);
mockSentTextMessage.replay();
MockControl mockResponseTextMessage = MockControl.createControl(TextMessage.class);
TextMessage responseTextMessage = (TextMessage) mockResponseTextMessage.getMock();
responseTextMessage.setJMSCorrelationID(CORRELATION_ID);
mockResponseTextMessage.setVoidCallable();
mockResponseTextMessage.replay();
MockControl mockQueueSender = MockControl.createControl(QueueSender.class);
QueueSender queueSender = (QueueSender) mockQueueSender.getMock();
queueSender.send(responseTextMessage);
mockQueueSender.setThrowable(new JMSException("Dow!"));
// ensure that regardless of a JMSException the producer is closed...
queueSender.close();
mockQueueSender.setVoidCallable();
mockQueueSender.replay();
MockControl mockSession = MockControl.createControl(QueueSession.class);
final QueueSession session = (QueueSession) mockSession.getMock();
session.createTextMessage(RESPONSE_TEXT);
mockSession.setReturnValue(responseTextMessage);
session.createSender(destination);
mockSession.setReturnValue(queueSender);
mockSession.replay();
MockControl mockDelegate = MockControl.createControl(ResponsiveMessageDelegate.class);
ResponsiveMessageDelegate delegate = (ResponsiveMessageDelegate) mockDelegate.getMock();
delegate.handleMessage(sentTextMessage);
mockDelegate.setReturnValue(RESPONSE_TEXT);
mockDelegate.replay();
final MessageListenerAdapter102 adapter = new MessageListenerAdapter102(delegate) {
protected Object extractMessage(Message message) {
return message;
}
};
new AssertThrows(JMSException.class) {
public void test() throws Exception {
adapter.onMessage(sentTextMessage, session);
}
}.runTest();
mockDelegate.verify();
mockSentTextMessage.verify();
mockResponseTextMessage.verify();
mockSession.verify();
mockDestination.verify();
mockQueueSender.verify();
}
public void testWithResponsiveMessageDelegateDoesNotSendReturnTextMessageWhenSessionSupplied_AndListenerMethodThrowsException() throws Exception {
MockControl mockSentTextMessage = MockControl.createControl(TextMessage.class);
final TextMessage sentTextMessage = (TextMessage) mockSentTextMessage.getMock();
mockSentTextMessage.replay();
MockControl mockSession = MockControl.createControl(QueueSession.class);
final QueueSession session = (QueueSession) mockSession.getMock();
mockSession.replay();
MockControl mockDelegate = MockControl.createControl(ResponsiveMessageDelegate.class);
ResponsiveMessageDelegate delegate = (ResponsiveMessageDelegate) mockDelegate.getMock();
delegate.handleMessage(sentTextMessage);
mockDelegate.setThrowable(new IllegalArgumentException("Dow!"));
mockDelegate.replay();
final MessageListenerAdapter102 adapter = new MessageListenerAdapter102(delegate) {
protected Object extractMessage(Message message) {
return message;
}
};
new AssertThrows(ListenerExecutionFailedException.class) {
public void test() throws Exception {
adapter.onMessage(sentTextMessage, session);
}
}.runTest();
mockDelegate.verify();
mockSentTextMessage.verify();
mockSession.verify();
}
private static final String TEXT = "The Runaways";
private static final String CORRELATION_ID = "100";
private static final String RESPONSE_TEXT = "Old Lace";
public void testWithMessageContentsDelegateForBytesMessage() throws Exception {
MockControl mockBytesMessage = MockControl.createControl(BytesMessage.class);
BytesMessage bytesMessage = (BytesMessage) mockBytesMessage.getMock();
// BytesMessage contents must be unwrapped...
bytesMessage.readBytes(null);
mockBytesMessage.setMatcher(MockControl.ALWAYS_MATCHER);
mockBytesMessage.setReturnValue(TEXT.getBytes().length);
mockBytesMessage.replay();
MockControl mockDelegate = MockControl.createControl(MessageContentsDelegate.class);
MessageContentsDelegate delegate = (MessageContentsDelegate) mockDelegate.getMock();
delegate.handleMessage(TEXT.getBytes());
mockDelegate.setMatcher(MockControl.ALWAYS_MATCHER);
mockDelegate.setVoidCallable();
mockDelegate.replay();
MessageListenerAdapter102 adapter = new MessageListenerAdapter102(delegate);
adapter.onMessage(bytesMessage);
mockDelegate.verify();
mockBytesMessage.verify();
}
public void testWithMessageDelegate() throws Exception {
MockControl mockTextMessage = MockControl.createControl(TextMessage.class);
TextMessage textMessage = (TextMessage) mockTextMessage.getMock();
mockTextMessage.replay();
MockControl mockDelegate = MockControl.createControl(MessageDelegate.class);
MessageDelegate delegate = (MessageDelegate) mockDelegate.getMock();
delegate.handleMessage(textMessage);
mockDelegate.setVoidCallable();
mockDelegate.replay();
MessageListenerAdapter102 adapter = new MessageListenerAdapter102(delegate);
// we DON'T want the default SimpleMessageConversion happening...
adapter.setMessageConverter(null);
adapter.onMessage(textMessage);
mockDelegate.verify();
mockTextMessage.verify();
}
public void testThatTheDefaultMessageConverterisIndeedTheSimpleMessageConverter102() throws Exception {
MessageListenerAdapter102 adapter = new MessageListenerAdapter102();
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);
}
public void testWithResponsiveMessageDelegate_DoesNotSendReturnTextMessageIfNoSessionSupplied() throws Exception {
MockControl mockTextMessage = MockControl.createControl(TextMessage.class);
TextMessage textMessage = (TextMessage) mockTextMessage.getMock();
mockTextMessage.replay();
MockControl mockDelegate = MockControl.createControl(ResponsiveMessageDelegate.class);
ResponsiveMessageDelegate delegate = (ResponsiveMessageDelegate) mockDelegate.getMock();
delegate.handleMessage(textMessage);
mockDelegate.setReturnValue(TEXT);
mockDelegate.replay();
MessageListenerAdapter102 adapter = new MessageListenerAdapter102(delegate);
// we DON'T want the default SimpleMessageConversion happening...
adapter.setMessageConverter(null);
adapter.onMessage(textMessage);
mockDelegate.verify();
mockTextMessage.verify();
}
public void testWithResponsiveMessageDelegateWithDefaultDestination_SendsReturnTextMessageWhenSessionSuppliedForQueue() throws Exception {
MockControl mockDestination = MockControl.createControl(Queue.class);
Queue destination = (Queue) mockDestination.getMock();
mockDestination.replay();
MockControl mockSentTextMessage = MockControl.createControl(TextMessage.class);
TextMessage sentTextMessage = (TextMessage) mockSentTextMessage.getMock();
// correlation ID is queried when response is being created...
sentTextMessage.getJMSCorrelationID();
mockSentTextMessage.setReturnValue(CORRELATION_ID);
// Reply-To is queried when response is being created...
sentTextMessage.getJMSReplyTo();
mockSentTextMessage.setReturnValue(null); // we want to fall back to the default...
mockSentTextMessage.replay();
MockControl mockResponseTextMessage = MockControl.createControl(TextMessage.class);
TextMessage responseTextMessage = (TextMessage) mockResponseTextMessage.getMock();
responseTextMessage.setJMSCorrelationID(CORRELATION_ID);
mockResponseTextMessage.setVoidCallable();
mockResponseTextMessage.replay();
MockControl mockQueueSender = MockControl.createControl(QueueSender.class);
QueueSender queueSender = (QueueSender) mockQueueSender.getMock();
queueSender.send(responseTextMessage);
mockQueueSender.setVoidCallable();
queueSender.close();
mockQueueSender.setVoidCallable();
mockQueueSender.replay();
MockControl mockSession = MockControl.createControl(QueueSession.class);
QueueSession session = (QueueSession) mockSession.getMock();
session.createTextMessage(RESPONSE_TEXT);
mockSession.setReturnValue(responseTextMessage);
session.createSender(destination);
mockSession.setReturnValue(queueSender);
mockSession.replay();
MockControl mockDelegate = MockControl.createControl(ResponsiveMessageDelegate.class);
ResponsiveMessageDelegate delegate = (ResponsiveMessageDelegate) mockDelegate.getMock();
delegate.handleMessage(sentTextMessage);
mockDelegate.setReturnValue(RESPONSE_TEXT);
mockDelegate.replay();
MessageListenerAdapter102 adapter = new MessageListenerAdapter102(delegate) {
protected Object extractMessage(Message message) {
return message;
}
};
adapter.setDefaultResponseDestination(destination);
adapter.onMessage(sentTextMessage, session);
mockDelegate.verify();
mockSentTextMessage.verify();
mockResponseTextMessage.verify();
mockSession.verify();
mockDestination.verify();
mockQueueSender.verify();
}
public void testWithResponsiveMessageDelegateWithDefaultDestination_SendsReturnTextMessageWhenSessionSuppliedForTopic() throws Exception {
MockControl mockDestination = MockControl.createControl(Topic.class);
Topic destination = (Topic) mockDestination.getMock();
mockDestination.replay();
MockControl mockSentTextMessage = MockControl.createControl(TextMessage.class);
TextMessage sentTextMessage = (TextMessage) mockSentTextMessage.getMock();
// correlation ID is queried when response is being created...
sentTextMessage.getJMSCorrelationID();
mockSentTextMessage.setReturnValue(CORRELATION_ID);
// Reply-To is queried when response is being created...
sentTextMessage.getJMSReplyTo();
mockSentTextMessage.setReturnValue(null); // we want to fall back to the default...
mockSentTextMessage.replay();
MockControl mockResponseTextMessage = MockControl.createControl(TextMessage.class);
TextMessage responseTextMessage = (TextMessage) mockResponseTextMessage.getMock();
responseTextMessage.setJMSCorrelationID(CORRELATION_ID);
mockResponseTextMessage.setVoidCallable();
mockResponseTextMessage.replay();
MockControl mockTopicPublisher = MockControl.createControl(TopicPublisher.class);
TopicPublisher topicPublisher = (TopicPublisher) mockTopicPublisher.getMock();
topicPublisher.publish(responseTextMessage);
mockTopicPublisher.setVoidCallable();
topicPublisher.close();
mockTopicPublisher.setVoidCallable();
mockTopicPublisher.replay();
MockControl mockSession = MockControl.createControl(TopicSession.class);
TopicSession session = (TopicSession) mockSession.getMock();
session.createTextMessage(RESPONSE_TEXT);
mockSession.setReturnValue(responseTextMessage);
session.createPublisher(destination);
mockSession.setReturnValue(topicPublisher);
mockSession.replay();
MockControl mockDelegate = MockControl.createControl(ResponsiveMessageDelegate.class);
ResponsiveMessageDelegate delegate = (ResponsiveMessageDelegate) mockDelegate.getMock();
delegate.handleMessage(sentTextMessage);
mockDelegate.setReturnValue(RESPONSE_TEXT);
mockDelegate.replay();
MessageListenerAdapter102 adapter = new MessageListenerAdapter102(delegate) {
protected Object extractMessage(Message message) {
return message;
}
};
adapter.setDefaultResponseDestination(destination);
adapter.onMessage(sentTextMessage, session);
mockDelegate.verify();
mockSentTextMessage.verify();
mockResponseTextMessage.verify();
mockSession.verify();
mockDestination.verify();
mockTopicPublisher.verify();
}
public void testWithResponsiveMessageDelegateNoDefaultDestination_SendsReturnTextMessageWhenSessionSupplied() throws Exception {
MockControl mockDestination = MockControl.createControl(Queue.class);
Queue destination = (Queue) mockDestination.getMock();
mockDestination.replay();
MockControl mockSentTextMessage = MockControl.createControl(TextMessage.class);
TextMessage sentTextMessage = (TextMessage) mockSentTextMessage.getMock();
// correlation ID is queried when response is being created...
sentTextMessage.getJMSCorrelationID();
mockSentTextMessage.setReturnValue(CORRELATION_ID);
// Reply-To is queried when response is being created...
sentTextMessage.getJMSReplyTo();
mockSentTextMessage.setReturnValue(destination);
mockSentTextMessage.replay();
MockControl mockResponseTextMessage = MockControl.createControl(TextMessage.class);
TextMessage responseTextMessage = (TextMessage) mockResponseTextMessage.getMock();
responseTextMessage.setJMSCorrelationID(CORRELATION_ID);
mockResponseTextMessage.setVoidCallable();
mockResponseTextMessage.replay();
MockControl mockQueueSender = MockControl.createControl(QueueSender.class);
QueueSender queueSender = (QueueSender) mockQueueSender.getMock();
queueSender.send(responseTextMessage);
mockQueueSender.setVoidCallable();
queueSender.close();
mockQueueSender.setVoidCallable();
mockQueueSender.replay();
MockControl mockSession = MockControl.createControl(QueueSession.class);
QueueSession session = (QueueSession) mockSession.getMock();
session.createTextMessage(RESPONSE_TEXT);
mockSession.setReturnValue(responseTextMessage);
session.createSender(destination);
mockSession.setReturnValue(queueSender);
mockSession.replay();
MockControl mockDelegate = MockControl.createControl(ResponsiveMessageDelegate.class);
ResponsiveMessageDelegate delegate = (ResponsiveMessageDelegate) mockDelegate.getMock();
delegate.handleMessage(sentTextMessage);
mockDelegate.setReturnValue(RESPONSE_TEXT);
mockDelegate.replay();
MessageListenerAdapter102 adapter = new MessageListenerAdapter102(delegate) {
protected Object extractMessage(Message message) {
return message;
}
};
adapter.onMessage(sentTextMessage, session);
mockDelegate.verify();
mockSentTextMessage.verify();
mockResponseTextMessage.verify();
mockSession.verify();
mockDestination.verify();
mockQueueSender.verify();
}
public void testWithResponsiveMessageDelegateNoDefaultDestinationAndNoReplyToDestination_SendsReturnTextMessageWhenSessionSupplied() throws Exception {
MockControl mockSentTextMessage = MockControl.createControl(TextMessage.class);
final TextMessage sentTextMessage = (TextMessage) mockSentTextMessage.getMock();
// correlation ID is queried when response is being created...
sentTextMessage.getJMSCorrelationID();
mockSentTextMessage.setReturnValue(CORRELATION_ID);
// Reply-To is queried when response is being created...
sentTextMessage.getJMSReplyTo();
mockSentTextMessage.setReturnValue(null);
mockSentTextMessage.replay();
MockControl mockResponseTextMessage = MockControl.createControl(TextMessage.class);
TextMessage responseTextMessage = (TextMessage) mockResponseTextMessage.getMock();
responseTextMessage.setJMSCorrelationID(CORRELATION_ID);
mockResponseTextMessage.setVoidCallable();
mockResponseTextMessage.replay();
MockControl mockSession = MockControl.createControl(QueueSession.class);
final QueueSession session = (QueueSession) mockSession.getMock();
session.createTextMessage(RESPONSE_TEXT);
mockSession.setReturnValue(responseTextMessage);
mockSession.replay();
MockControl mockDelegate = MockControl.createControl(ResponsiveMessageDelegate.class);
ResponsiveMessageDelegate delegate = (ResponsiveMessageDelegate) mockDelegate.getMock();
delegate.handleMessage(sentTextMessage);
mockDelegate.setReturnValue(RESPONSE_TEXT);
mockDelegate.replay();
final MessageListenerAdapter102 adapter = new MessageListenerAdapter102(delegate) {
protected Object extractMessage(Message message) {
return message;
}
};
new AssertThrows(InvalidDestinationException.class) {
public void test() throws Exception {
adapter.onMessage(sentTextMessage, session);
}
}.runTest();
mockDelegate.verify();
mockSentTextMessage.verify();
mockResponseTextMessage.verify();
mockSession.verify();
}
public void testWithResponsiveMessageDelegateNoDefaultDestination_SendsReturnTextMessageWhenSessionSupplied_AndSendingThrowsJMSException() throws Exception {
MockControl mockDestination = MockControl.createControl(Queue.class);
Queue destination = (Queue) mockDestination.getMock();
mockDestination.replay();
MockControl mockSentTextMessage = MockControl.createControl(TextMessage.class);
final TextMessage sentTextMessage = (TextMessage) mockSentTextMessage.getMock();
// correlation ID is queried when response is being created...
sentTextMessage.getJMSCorrelationID();
mockSentTextMessage.setReturnValue(CORRELATION_ID);
// Reply-To is queried when response is being created...
sentTextMessage.getJMSReplyTo();
mockSentTextMessage.setReturnValue(destination);
mockSentTextMessage.replay();
MockControl mockResponseTextMessage = MockControl.createControl(TextMessage.class);
TextMessage responseTextMessage = (TextMessage) mockResponseTextMessage.getMock();
responseTextMessage.setJMSCorrelationID(CORRELATION_ID);
mockResponseTextMessage.setVoidCallable();
mockResponseTextMessage.replay();
MockControl mockQueueSender = MockControl.createControl(QueueSender.class);
QueueSender queueSender = (QueueSender) mockQueueSender.getMock();
queueSender.send(responseTextMessage);
mockQueueSender.setThrowable(new JMSException("Dow!"));
// ensure that regardless of a JMSException the producer is closed...
queueSender.close();
mockQueueSender.setVoidCallable();
mockQueueSender.replay();
MockControl mockSession = MockControl.createControl(QueueSession.class);
final QueueSession session = (QueueSession) mockSession.getMock();
session.createTextMessage(RESPONSE_TEXT);
mockSession.setReturnValue(responseTextMessage);
session.createSender(destination);
mockSession.setReturnValue(queueSender);
mockSession.replay();
MockControl mockDelegate = MockControl.createControl(ResponsiveMessageDelegate.class);
ResponsiveMessageDelegate delegate = (ResponsiveMessageDelegate) mockDelegate.getMock();
delegate.handleMessage(sentTextMessage);
mockDelegate.setReturnValue(RESPONSE_TEXT);
mockDelegate.replay();
final MessageListenerAdapter102 adapter = new MessageListenerAdapter102(delegate) {
protected Object extractMessage(Message message) {
return message;
}
};
new AssertThrows(JMSException.class) {
public void test() throws Exception {
adapter.onMessage(sentTextMessage, session);
}
}.runTest();
mockDelegate.verify();
mockSentTextMessage.verify();
mockResponseTextMessage.verify();
mockSession.verify();
mockDestination.verify();
mockQueueSender.verify();
}
public void testWithResponsiveMessageDelegateDoesNotSendReturnTextMessageWhenSessionSupplied_AndListenerMethodThrowsException() throws Exception {
MockControl mockSentTextMessage = MockControl.createControl(TextMessage.class);
final TextMessage sentTextMessage = (TextMessage) mockSentTextMessage.getMock();
mockSentTextMessage.replay();
MockControl mockSession = MockControl.createControl(QueueSession.class);
final QueueSession session = (QueueSession) mockSession.getMock();
mockSession.replay();
MockControl mockDelegate = MockControl.createControl(ResponsiveMessageDelegate.class);
ResponsiveMessageDelegate delegate = (ResponsiveMessageDelegate) mockDelegate.getMock();
delegate.handleMessage(sentTextMessage);
mockDelegate.setThrowable(new IllegalArgumentException("Dow!"));
mockDelegate.replay();
final MessageListenerAdapter102 adapter = new MessageListenerAdapter102(delegate) {
protected Object extractMessage(Message message) {
return message;
}
};
new AssertThrows(ListenerExecutionFailedException.class) {
public void test() throws Exception {
adapter.onMessage(sentTextMessage, session);
}
}.runTest();
mockDelegate.verify();
mockSentTextMessage.verify();
mockSession.verify();
}
}

View File

@ -28,45 +28,45 @@ import javax.jms.Session;
*/
public final class JmsAccessorTests extends TestCase {
public void testChokesIfConnectionFactoryIsNotSupplied() throws Exception {
new AssertThrows(IllegalArgumentException.class) {
public void test() throws Exception {
JmsAccessor accessor = new StubJmsAccessor();
accessor.afterPropertiesSet();
}
}.runTest();
}
public void testChokesIfConnectionFactoryIsNotSupplied() throws Exception {
new AssertThrows(IllegalArgumentException.class) {
public void test() throws Exception {
JmsAccessor accessor = new StubJmsAccessor();
accessor.afterPropertiesSet();
}
}.runTest();
}
public void testSessionTransactedModeReallyDoesDefaultToFalse() throws Exception {
JmsAccessor accessor = new StubJmsAccessor();
assertFalse("The [sessionTransacted] property of JmsAccessor must default to " +
"false. Change this test (and the attendant Javadoc) if you have " +
"changed the default.",
accessor.isSessionTransacted());
}
public void testSessionTransactedModeReallyDoesDefaultToFalse() throws Exception {
JmsAccessor accessor = new StubJmsAccessor();
assertFalse("The [sessionTransacted] property of JmsAccessor must default to " +
"false. Change this test (and the attendant Javadoc) if you have " +
"changed the default.",
accessor.isSessionTransacted());
}
public void testAcknowledgeModeReallyDoesDefaultToAutoAcknowledge() throws Exception {
JmsAccessor accessor = new StubJmsAccessor();
assertEquals("The [sessionAcknowledgeMode] property of JmsAccessor must default to " +
"[Session.AUTO_ACKNOWLEDGE]. Change this test (and the attendant " +
"Javadoc) if you have changed the default.",
Session.AUTO_ACKNOWLEDGE,
accessor.getSessionAcknowledgeMode());
}
public void testAcknowledgeModeReallyDoesDefaultToAutoAcknowledge() throws Exception {
JmsAccessor accessor = new StubJmsAccessor();
assertEquals("The [sessionAcknowledgeMode] property of JmsAccessor must default to " +
"[Session.AUTO_ACKNOWLEDGE]. Change this test (and the attendant " +
"Javadoc) if you have changed the default.",
Session.AUTO_ACKNOWLEDGE,
accessor.getSessionAcknowledgeMode());
}
public void testSetAcknowledgeModeNameChokesIfBadAckModeIsSupplied() throws Exception {
new AssertThrows(IllegalArgumentException.class) {
public void test() throws Exception {
new StubJmsAccessor().setSessionAcknowledgeModeName("Tally ho chaps!");
}
}.runTest();
}
public void testSetAcknowledgeModeNameChokesIfBadAckModeIsSupplied() throws Exception {
new AssertThrows(IllegalArgumentException.class) {
public void test() throws Exception {
new StubJmsAccessor().setSessionAcknowledgeModeName("Tally ho chaps!");
}
}.runTest();
}
/**
* Crummy, stub, do-nothing subclass of the JmsAccessor class for use in testing.
*/
private static final class StubJmsAccessor extends JmsAccessor {
}
/**
* Crummy, stub, do-nothing subclass of the JmsAccessor class for use in testing.
*/
private static final class StubJmsAccessor extends JmsAccessor {
}
}

View File

@ -35,42 +35,42 @@ import java.util.Arrays;
*/
public final class SimpleMessageConverter102Tests extends TestCase {
public void testByteArrayConversion102() throws JMSException {
MockControl sessionControl = MockControl.createControl(Session.class);
Session session = (Session) sessionControl.getMock();
MockControl messageControl = MockControl.createControl(BytesMessage.class);
BytesMessage message = (BytesMessage) messageControl.getMock();
public void testByteArrayConversion102() throws JMSException {
MockControl sessionControl = MockControl.createControl(Session.class);
Session session = (Session) sessionControl.getMock();
MockControl messageControl = MockControl.createControl(BytesMessage.class);
BytesMessage message = (BytesMessage) messageControl.getMock();
byte[] content = new byte[5000];
byte[] content = new byte[5000];
session.createBytesMessage();
sessionControl.setReturnValue(message, 1);
message.writeBytes(content);
messageControl.setVoidCallable(1);
message.readBytes(new byte[SimpleMessageConverter102.BUFFER_SIZE]);
messageControl.setMatcher(new ArgumentsMatcher() {
public boolean matches(Object[] arg0, Object[] arg1) {
byte[] one = (byte[]) arg0[0];
byte[] two = (byte[]) arg1[0];
return Arrays.equals(one, two);
}
session.createBytesMessage();
sessionControl.setReturnValue(message, 1);
message.writeBytes(content);
messageControl.setVoidCallable(1);
message.readBytes(new byte[SimpleMessageConverter102.BUFFER_SIZE]);
messageControl.setMatcher(new ArgumentsMatcher() {
public boolean matches(Object[] arg0, Object[] arg1) {
byte[] one = (byte[]) arg0[0];
byte[] two = (byte[]) arg1[0];
return Arrays.equals(one, two);
}
public String toString(Object[] arg0) {
return "bla";
}
});
messageControl.setReturnValue(SimpleMessageConverter102.BUFFER_SIZE, 1);
message.readBytes(new byte[SimpleMessageConverter102.BUFFER_SIZE]);
messageControl.setReturnValue(5000 - SimpleMessageConverter102.BUFFER_SIZE, 1);
sessionControl.replay();
messageControl.replay();
public String toString(Object[] arg0) {
return "bla";
}
});
messageControl.setReturnValue(SimpleMessageConverter102.BUFFER_SIZE, 1);
message.readBytes(new byte[SimpleMessageConverter102.BUFFER_SIZE]);
messageControl.setReturnValue(5000 - SimpleMessageConverter102.BUFFER_SIZE, 1);
sessionControl.replay();
messageControl.replay();
SimpleMessageConverter102 converter = new SimpleMessageConverter102();
Message msg = converter.toMessage(content, session);
assertEquals(content.length, ((byte[]) converter.fromMessage(msg)).length);
SimpleMessageConverter102 converter = new SimpleMessageConverter102();
Message msg = converter.toMessage(content, session);
assertEquals(content.length, ((byte[]) converter.fromMessage(msg)).length);
sessionControl.verify();
messageControl.verify();
}
sessionControl.verify();
messageControl.verify();
}
}

View File

@ -38,222 +38,222 @@ import java.util.Map;
*/
public final class SimpleMessageConverterTests extends TestCase {
public void testStringConversion() throws JMSException {
MockControl sessionControl = MockControl.createControl(Session.class);
Session session = (Session) sessionControl.getMock();
MockControl messageControl = MockControl.createControl(TextMessage.class);
TextMessage message = (TextMessage) messageControl.getMock();
public void testStringConversion() throws JMSException {
MockControl sessionControl = MockControl.createControl(Session.class);
Session session = (Session) sessionControl.getMock();
MockControl messageControl = MockControl.createControl(TextMessage.class);
TextMessage message = (TextMessage) messageControl.getMock();
String content = "test";
String content = "test";
session.createTextMessage(content);
sessionControl.setReturnValue(message, 1);
message.getText();
messageControl.setReturnValue(content, 1);
sessionControl.replay();
messageControl.replay();
session.createTextMessage(content);
sessionControl.setReturnValue(message, 1);
message.getText();
messageControl.setReturnValue(content, 1);
sessionControl.replay();
messageControl.replay();
SimpleMessageConverter converter = new SimpleMessageConverter();
Message msg = converter.toMessage(content, session);
assertEquals(content, converter.fromMessage(msg));
SimpleMessageConverter converter = new SimpleMessageConverter();
Message msg = converter.toMessage(content, session);
assertEquals(content, converter.fromMessage(msg));
sessionControl.verify();
messageControl.verify();
}
sessionControl.verify();
messageControl.verify();
}
public void testByteArrayConversion() throws JMSException {
MockControl sessionControl = MockControl.createControl(Session.class);
Session session = (Session) sessionControl.getMock();
MockControl messageControl = MockControl.createControl(BytesMessage.class);
BytesMessage message = (BytesMessage) messageControl.getMock();
public void testByteArrayConversion() throws JMSException {
MockControl sessionControl = MockControl.createControl(Session.class);
Session session = (Session) sessionControl.getMock();
MockControl messageControl = MockControl.createControl(BytesMessage.class);
BytesMessage message = (BytesMessage) messageControl.getMock();
byte[] content = "test".getBytes();
byte[] content = "test".getBytes();
session.createBytesMessage();
sessionControl.setReturnValue(message, 1);
message.writeBytes(content);
messageControl.setVoidCallable(1);
message.getBodyLength();
messageControl.setReturnValue(content.length, 1);
message.readBytes(new byte[content.length]);
messageControl.setMatcher(new ArgumentsMatcher() {
public boolean matches(Object[] arg0, Object[] arg1) {
byte[] one = (byte[]) arg0[0];
byte[] two = (byte[]) arg1[0];
return Arrays.equals(one, two);
}
session.createBytesMessage();
sessionControl.setReturnValue(message, 1);
message.writeBytes(content);
messageControl.setVoidCallable(1);
message.getBodyLength();
messageControl.setReturnValue(content.length, 1);
message.readBytes(new byte[content.length]);
messageControl.setMatcher(new ArgumentsMatcher() {
public boolean matches(Object[] arg0, Object[] arg1) {
byte[] one = (byte[]) arg0[0];
byte[] two = (byte[]) arg1[0];
return Arrays.equals(one, two);
}
public String toString(Object[] arg0) {
return "bla";
}
});
messageControl.setReturnValue(content.length, 1);
sessionControl.replay();
messageControl.replay();
public String toString(Object[] arg0) {
return "bla";
}
});
messageControl.setReturnValue(content.length, 1);
sessionControl.replay();
messageControl.replay();
SimpleMessageConverter converter = new SimpleMessageConverter();
Message msg = converter.toMessage(content, session);
assertEquals(content.length, ((byte[]) converter.fromMessage(msg)).length);
SimpleMessageConverter converter = new SimpleMessageConverter();
Message msg = converter.toMessage(content, session);
assertEquals(content.length, ((byte[]) converter.fromMessage(msg)).length);
sessionControl.verify();
messageControl.verify();
}
sessionControl.verify();
messageControl.verify();
}
public void testMapConversion() throws JMSException {
public void testMapConversion() throws JMSException {
MockControl sessionControl = MockControl.createControl(Session.class);
Session session = (Session) sessionControl.getMock();
MockControl messageControl = MockControl.createControl(MapMessage.class);
MapMessage message = (MapMessage) messageControl.getMock();
MockControl sessionControl = MockControl.createControl(Session.class);
Session session = (Session) sessionControl.getMock();
MockControl messageControl = MockControl.createControl(MapMessage.class);
MapMessage message = (MapMessage) messageControl.getMock();
Map content = new HashMap();
content.put("key1", "value1");
content.put("key2", "value2");
Map content = new HashMap();
content.put("key1", "value1");
content.put("key2", "value2");
session.createMapMessage();
sessionControl.setReturnValue(message, 1);
message.setObject("key1", "value1");
messageControl.setVoidCallable(1);
message.setObject("key2", "value2");
messageControl.setVoidCallable(1);
message.getMapNames();
messageControl.setReturnValue(Collections.enumeration(content.keySet()));
message.getObject("key1");
messageControl.setReturnValue("value1", 1);
message.getObject("key2");
messageControl.setReturnValue("value2", 1);
session.createMapMessage();
sessionControl.setReturnValue(message, 1);
message.setObject("key1", "value1");
messageControl.setVoidCallable(1);
message.setObject("key2", "value2");
messageControl.setVoidCallable(1);
message.getMapNames();
messageControl.setReturnValue(Collections.enumeration(content.keySet()));
message.getObject("key1");
messageControl.setReturnValue("value1", 1);
message.getObject("key2");
messageControl.setReturnValue("value2", 1);
sessionControl.replay();
messageControl.replay();
sessionControl.replay();
messageControl.replay();
SimpleMessageConverter converter = new SimpleMessageConverter();
Message msg = converter.toMessage(content, session);
assertEquals(content, converter.fromMessage(msg));
SimpleMessageConverter converter = new SimpleMessageConverter();
Message msg = converter.toMessage(content, session);
assertEquals(content, converter.fromMessage(msg));
sessionControl.verify();
messageControl.verify();
}
sessionControl.verify();
messageControl.verify();
}
public void testSerializableConversion() throws JMSException {
MockControl sessionControl = MockControl.createControl(Session.class);
Session session = (Session) sessionControl.getMock();
MockControl messageControl = MockControl.createControl(ObjectMessage.class);
ObjectMessage message = (ObjectMessage) messageControl.getMock();
public void testSerializableConversion() throws JMSException {
MockControl sessionControl = MockControl.createControl(Session.class);
Session session = (Session) sessionControl.getMock();
MockControl messageControl = MockControl.createControl(ObjectMessage.class);
ObjectMessage message = (ObjectMessage) messageControl.getMock();
Integer content = new Integer(5);
Integer content = new Integer(5);
session.createObjectMessage(content);
sessionControl.setReturnValue(message, 1);
message.getObject();
messageControl.setReturnValue(content, 1);
sessionControl.replay();
messageControl.replay();
session.createObjectMessage(content);
sessionControl.setReturnValue(message, 1);
message.getObject();
messageControl.setReturnValue(content, 1);
sessionControl.replay();
messageControl.replay();
SimpleMessageConverter converter = new SimpleMessageConverter();
Message msg = converter.toMessage(content, session);
assertEquals(content, converter.fromMessage(msg));
SimpleMessageConverter converter = new SimpleMessageConverter();
Message msg = converter.toMessage(content, session);
assertEquals(content, converter.fromMessage(msg));
sessionControl.verify();
messageControl.verify();
}
sessionControl.verify();
messageControl.verify();
}
public void testToMessageThrowsExceptionIfGivenNullObjectToConvert() throws Exception {
new AssertThrows(MessageConversionException.class) {
public void test() throws Exception {
new SimpleMessageConverter().toMessage(null, null);
}
}.runTest();
}
public void testToMessageThrowsExceptionIfGivenNullObjectToConvert() throws Exception {
new AssertThrows(MessageConversionException.class) {
public void test() throws Exception {
new SimpleMessageConverter().toMessage(null, null);
}
}.runTest();
}
public void testToMessageThrowsExceptionIfGivenIncompatibleObjectToConvert() throws Exception {
new AssertThrows(MessageConversionException.class) {
public void test() throws Exception {
new SimpleMessageConverter().toMessage(new Object(), null);
}
}.runTest();
}
public void testToMessageThrowsExceptionIfGivenIncompatibleObjectToConvert() throws Exception {
new AssertThrows(MessageConversionException.class) {
public void test() throws Exception {
new SimpleMessageConverter().toMessage(new Object(), null);
}
}.runTest();
}
public void testToMessageSimplyReturnsMessageAsIsIfSuppliedWithMessage() throws JMSException {
public void testToMessageSimplyReturnsMessageAsIsIfSuppliedWithMessage() throws JMSException {
MockControl sessionControl = MockControl.createControl(Session.class);
Session session = (Session) sessionControl.getMock();
MockControl sessionControl = MockControl.createControl(Session.class);
Session session = (Session) sessionControl.getMock();
MockControl messageControl = MockControl.createControl(ObjectMessage.class);
ObjectMessage message = (ObjectMessage) messageControl.getMock();
MockControl messageControl = MockControl.createControl(ObjectMessage.class);
ObjectMessage message = (ObjectMessage) messageControl.getMock();
sessionControl.replay();
messageControl.replay();
sessionControl.replay();
messageControl.replay();
SimpleMessageConverter converter = new SimpleMessageConverter();
Message msg = converter.toMessage(message, session);
assertSame(message, msg);
SimpleMessageConverter converter = new SimpleMessageConverter();
Message msg = converter.toMessage(message, session);
assertSame(message, msg);
sessionControl.verify();
messageControl.verify();
}
sessionControl.verify();
messageControl.verify();
}
public void testFromMessageSimplyReturnsMessageAsIsIfSuppliedWithMessage() throws JMSException {
public void testFromMessageSimplyReturnsMessageAsIsIfSuppliedWithMessage() throws JMSException {
MockControl messageControl = MockControl.createControl(Message.class);
Message message = (Message) messageControl.getMock();
MockControl messageControl = MockControl.createControl(Message.class);
Message message = (Message) messageControl.getMock();
messageControl.replay();
messageControl.replay();
SimpleMessageConverter converter = new SimpleMessageConverter();
Object msg = converter.fromMessage(message);
assertSame(message, msg);
SimpleMessageConverter converter = new SimpleMessageConverter();
Object msg = converter.fromMessage(message);
assertSame(message, msg);
messageControl.verify();
}
messageControl.verify();
}
public void testMapConversionWhereMapHasNonStringTypesForKeys() throws JMSException {
public void testMapConversionWhereMapHasNonStringTypesForKeys() throws JMSException {
MockControl messageControl = MockControl.createControl(MapMessage.class);
MapMessage message = (MapMessage) messageControl.getMock();
messageControl.replay();
MockControl messageControl = MockControl.createControl(MapMessage.class);
MapMessage message = (MapMessage) messageControl.getMock();
messageControl.replay();
MockControl sessionControl = MockControl.createControl(Session.class);
final Session session = (Session) sessionControl.getMock();
session.createMapMessage();
sessionControl.setReturnValue(message);
sessionControl.replay();
MockControl sessionControl = MockControl.createControl(Session.class);
final Session session = (Session) sessionControl.getMock();
session.createMapMessage();
sessionControl.setReturnValue(message);
sessionControl.replay();
final Map content = new HashMap();
content.put(new Integer(1), "value1");
final Map content = new HashMap();
content.put(new Integer(1), "value1");
final SimpleMessageConverter converter = new SimpleMessageConverter();
new AssertThrows(MessageConversionException.class) {
public void test() throws Exception {
converter.toMessage(content, session);
}
}.runTest();
final SimpleMessageConverter converter = new SimpleMessageConverter();
new AssertThrows(MessageConversionException.class) {
public void test() throws Exception {
converter.toMessage(content, session);
}
}.runTest();
sessionControl.verify();
}
sessionControl.verify();
}
public void testMapConversionWhereMapHasNNullForKey() throws JMSException {
public void testMapConversionWhereMapHasNNullForKey() throws JMSException {
MockControl messageControl = MockControl.createControl(MapMessage.class);
MapMessage message = (MapMessage) messageControl.getMock();
messageControl.replay();
MockControl messageControl = MockControl.createControl(MapMessage.class);
MapMessage message = (MapMessage) messageControl.getMock();
messageControl.replay();
MockControl sessionControl = MockControl.createControl(Session.class);
final Session session = (Session) sessionControl.getMock();
session.createMapMessage();
sessionControl.setReturnValue(message);
sessionControl.replay();
MockControl sessionControl = MockControl.createControl(Session.class);
final Session session = (Session) sessionControl.getMock();
session.createMapMessage();
sessionControl.setReturnValue(message);
sessionControl.replay();
final Map content = new HashMap();
content.put(null, "value1");
final Map content = new HashMap();
content.put(null, "value1");
final SimpleMessageConverter converter = new SimpleMessageConverter();
new AssertThrows(MessageConversionException.class) {
public void test() throws Exception {
converter.toMessage(content, session);
}
}.runTest();
final SimpleMessageConverter converter = new SimpleMessageConverter();
new AssertThrows(MessageConversionException.class) {
public void test() throws Exception {
converter.toMessage(content, session);
}
}.runTest();
sessionControl.verify();
}
sessionControl.verify();
}
}

View File

@ -36,7 +36,7 @@ import org.springframework.transaction.support.TransactionSynchronizationManager
*/
public class SharedEntityManagerFactoryTests {
@Test
@Test
public void testValidUsage() {
Object o = new Object();

View File

@ -36,7 +36,7 @@ import edu.emory.mathcs.backport.java.util.concurrent.ThreadFactory;
*/
public class ScheduledExecutorFactoryBeanTests {
@Test
@Test
public void testThrowsExceptionIfPoolSizeIsLessThanZero() throws Exception {
try {
ScheduledExecutorFactoryBean factory = new ScheduledExecutorFactoryBean();
@ -51,7 +51,7 @@ public class ScheduledExecutorFactoryBeanTests {
}
}
@Test
@Test
public void testShutdownNowIsPropagatedToTheExecutorOnDestroy() throws Exception {
MockControl mockScheduledExecutorService = MockControl.createNiceControl(ScheduledExecutorService.class);
final ScheduledExecutorService executor = (ScheduledExecutorService) mockScheduledExecutorService.getMock();
@ -73,7 +73,7 @@ public class ScheduledExecutorFactoryBeanTests {
mockScheduledExecutorService.verify();
}
@Test
@Test
public void testShutdownIsPropagatedToTheExecutorOnDestroy() throws Exception {
MockControl mockScheduledExecutorService = MockControl.createNiceControl(ScheduledExecutorService.class);
final ScheduledExecutorService executor = (ScheduledExecutorService) mockScheduledExecutorService.getMock();
@ -96,7 +96,7 @@ public class ScheduledExecutorFactoryBeanTests {
mockScheduledExecutorService.verify();
}
@Test
@Test
public void testOneTimeExecutionIsSetUpAndFiresCorrectly() throws Exception {
MockControl mockRunnable = MockControl.createControl(Runnable.class);
Runnable runnable = (Runnable) mockRunnable.getMock();
@ -115,7 +115,7 @@ public class ScheduledExecutorFactoryBeanTests {
mockRunnable.verify();
}
@Test
@Test
public void testFixedRepeatedExecutionIsSetUpAndFiresCorrectly() throws Exception {
MockControl mockRunnable = MockControl.createControl(Runnable.class);
Runnable runnable = (Runnable) mockRunnable.getMock();
@ -138,7 +138,7 @@ public class ScheduledExecutorFactoryBeanTests {
mockRunnable.verify();
}
@Test
@Test
public void testFixedRepeatedExecutionIsSetUpAndFiresCorrectlyAfterException() throws Exception {
MockControl mockRunnable = MockControl.createControl(Runnable.class);
Runnable runnable = (Runnable) mockRunnable.getMock();
@ -162,8 +162,8 @@ public class ScheduledExecutorFactoryBeanTests {
mockRunnable.verify();
}
@Ignore
@Test
@Ignore
@Test
public void testWithInitialDelayRepeatedExecutionIsSetUpAndFiresCorrectly() throws Exception {
MockControl mockRunnable = MockControl.createControl(Runnable.class);
Runnable runnable = (Runnable) mockRunnable.getMock();
@ -192,8 +192,8 @@ public class ScheduledExecutorFactoryBeanTests {
}
}
@Ignore
@Test
@Ignore
@Test
public void testWithInitialDelayRepeatedExecutionIsSetUpAndFiresCorrectlyAfterException() throws Exception {
MockControl mockRunnable = MockControl.createControl(Runnable.class);
Runnable runnable = (Runnable) mockRunnable.getMock();
@ -223,7 +223,7 @@ public class ScheduledExecutorFactoryBeanTests {
}
}
@Test
@Test
public void testSettingThreadFactoryToNullForcesUseOfDefaultButIsOtherwiseCool() throws Exception {
ScheduledExecutorFactoryBean factory = new ScheduledExecutorFactoryBean() {
protected ScheduledExecutorService createExecutor(int poolSize, ThreadFactory threadFactory, RejectedExecutionHandler rejectedExecutionHandler) {
@ -239,7 +239,7 @@ public class ScheduledExecutorFactoryBeanTests {
factory.destroy();
}
@Test
@Test
public void testSettingRejectedExecutionHandlerToNullForcesUseOfDefaultButIsOtherwiseCool() throws Exception {
ScheduledExecutorFactoryBean factory = new ScheduledExecutorFactoryBean() {
protected ScheduledExecutorService createExecutor(int poolSize, ThreadFactory threadFactory, RejectedExecutionHandler rejectedExecutionHandler) {
@ -255,7 +255,7 @@ public class ScheduledExecutorFactoryBeanTests {
factory.destroy();
}
@Test
@Test
public void testObjectTypeReportsCorrectType() throws Exception {
ScheduledExecutorFactoryBean factory = new ScheduledExecutorFactoryBean();
assertEquals(ScheduledExecutorService.class, factory.getObjectType());

View File

@ -37,7 +37,7 @@ import org.springframework.core.task.NoOpRunnable;
*/
public class ScheduledExecutorFactoryBeanTests {
@Test
@Test
public void testThrowsExceptionIfPoolSizeIsLessThanZero() throws Exception {
try {
ScheduledExecutorFactoryBean factory = new ScheduledExecutorFactoryBean();
@ -52,7 +52,7 @@ public class ScheduledExecutorFactoryBeanTests {
}
}
@Test
@Test
public void testShutdownNowIsPropagatedToTheExecutorOnDestroy() throws Exception {
MockControl mockScheduledExecutorService = MockControl.createNiceControl(ScheduledExecutorService.class);
final ScheduledExecutorService executor = (ScheduledExecutorService) mockScheduledExecutorService.getMock();
@ -74,7 +74,7 @@ public class ScheduledExecutorFactoryBeanTests {
mockScheduledExecutorService.verify();
}
@Test
@Test
public void testShutdownIsPropagatedToTheExecutorOnDestroy() throws Exception {
MockControl mockScheduledExecutorService = MockControl.createNiceControl(ScheduledExecutorService.class);
final ScheduledExecutorService executor = (ScheduledExecutorService) mockScheduledExecutorService.getMock();
@ -97,7 +97,7 @@ public class ScheduledExecutorFactoryBeanTests {
mockScheduledExecutorService.verify();
}
@Test
@Test
public void testOneTimeExecutionIsSetUpAndFiresCorrectly() throws Exception {
MockControl mockRunnable = MockControl.createControl(Runnable.class);
Runnable runnable = (Runnable) mockRunnable.getMock();
@ -116,7 +116,7 @@ public class ScheduledExecutorFactoryBeanTests {
mockRunnable.verify();
}
@Test
@Test
public void testFixedRepeatedExecutionIsSetUpAndFiresCorrectly() throws Exception {
MockControl mockRunnable = MockControl.createControl(Runnable.class);
Runnable runnable = (Runnable) mockRunnable.getMock();
@ -139,7 +139,7 @@ public class ScheduledExecutorFactoryBeanTests {
mockRunnable.verify();
}
@Test
@Test
public void testFixedRepeatedExecutionIsSetUpAndFiresCorrectlyAfterException() throws Exception {
MockControl mockRunnable = MockControl.createControl(Runnable.class);
Runnable runnable = (Runnable) mockRunnable.getMock();
@ -163,8 +163,8 @@ public class ScheduledExecutorFactoryBeanTests {
mockRunnable.verify();
}
@Ignore
@Test
@Ignore
@Test
public void testWithInitialDelayRepeatedExecutionIsSetUpAndFiresCorrectly() throws Exception {
MockControl mockRunnable = MockControl.createControl(Runnable.class);
Runnable runnable = (Runnable) mockRunnable.getMock();
@ -193,8 +193,8 @@ public class ScheduledExecutorFactoryBeanTests {
}
}
@Ignore
@Test
@Ignore
@Test
public void testWithInitialDelayRepeatedExecutionIsSetUpAndFiresCorrectlyAfterException() throws Exception {
MockControl mockRunnable = MockControl.createControl(Runnable.class);
Runnable runnable = (Runnable) mockRunnable.getMock();
@ -224,7 +224,7 @@ public class ScheduledExecutorFactoryBeanTests {
}
}
@Test
@Test
public void testSettingThreadFactoryToNullForcesUseOfDefaultButIsOtherwiseCool() throws Exception {
ScheduledExecutorFactoryBean factory = new ScheduledExecutorFactoryBean() {
protected ScheduledExecutorService createExecutor(int poolSize, ThreadFactory threadFactory, RejectedExecutionHandler rejectedExecutionHandler) {
@ -240,7 +240,7 @@ public class ScheduledExecutorFactoryBeanTests {
factory.destroy();
}
@Test
@Test
public void testSettingRejectedExecutionHandlerToNullForcesUseOfDefaultButIsOtherwiseCool() throws Exception {
ScheduledExecutorFactoryBean factory = new ScheduledExecutorFactoryBean() {
protected ScheduledExecutorService createExecutor(int poolSize, ThreadFactory threadFactory, RejectedExecutionHandler rejectedExecutionHandler) {
@ -256,7 +256,7 @@ public class ScheduledExecutorFactoryBeanTests {
factory.destroy();
}
@Test
@Test
public void testObjectTypeReportsCorrectType() throws Exception {
ScheduledExecutorFactoryBean factory = new ScheduledExecutorFactoryBean();
assertEquals(ScheduledExecutorService.class, factory.getObjectType());

View File

@ -28,162 +28,162 @@ import java.util.Timer;
*/
public final class TimerTaskExecutorTests extends TestCase {
public void testExecuteChokesWithNullTimer() throws Exception {
new AssertThrows(IllegalArgumentException.class) {
public void test() throws Exception {
TimerTaskExecutor executor = new TimerTaskExecutor();
executor.execute(new NoOpRunnable());
}
}.runTest();
}
public void testExecuteChokesWithNullTimer() throws Exception {
new AssertThrows(IllegalArgumentException.class) {
public void test() throws Exception {
TimerTaskExecutor executor = new TimerTaskExecutor();
executor.execute(new NoOpRunnable());
}
}.runTest();
}
public void testExecuteChokesWithNullTask() throws Exception {
new AssertThrows(IllegalArgumentException.class) {
public void test() throws Exception {
TimerTaskExecutor executor = new TimerTaskExecutor(new Timer());
executor.execute(null);
}
}.runTest();
}
public void testExecuteChokesWithNullTask() throws Exception {
new AssertThrows(IllegalArgumentException.class) {
public void test() throws Exception {
TimerTaskExecutor executor = new TimerTaskExecutor(new Timer());
executor.execute(null);
}
}.runTest();
}
public void testExecuteChokesWithNegativeDelay() throws Exception {
new AssertThrows(IllegalArgumentException.class) {
public void test() throws Exception {
TimerTaskExecutor executor = new TimerTaskExecutor(new Timer());
executor.setDelay(-10);
executor.execute(new NoOpRunnable());
}
}.runTest();
}
public void testExecuteChokesWithNegativeDelay() throws Exception {
new AssertThrows(IllegalArgumentException.class) {
public void test() throws Exception {
TimerTaskExecutor executor = new TimerTaskExecutor(new Timer());
executor.setDelay(-10);
executor.execute(new NoOpRunnable());
}
}.runTest();
}
public void testExecuteReallyDoesScheduleTheSuppliedTask() throws Exception {
final Object monitor = new Object();
public void testExecuteReallyDoesScheduleTheSuppliedTask() throws Exception {
final Object monitor = new Object();
RunAwareRunnable task = new RunAwareRunnable(monitor);
RunAwareRunnable task = new RunAwareRunnable(monitor);
TimerTaskExecutor executor = new TimerTaskExecutor(new Timer());
executor.execute(task);
TimerTaskExecutor executor = new TimerTaskExecutor(new Timer());
executor.execute(task);
synchronized (monitor) {
monitor.wait(5000);
}
synchronized (monitor) {
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 {
new AssertThrows(IllegalArgumentException.class) {
public void test() throws Exception {
new TimerTaskExecutor(null);
}
}.runTest();
}
public void testCtorWithNullTimer() throws Exception {
new AssertThrows(IllegalArgumentException.class) {
public void test() throws Exception {
new TimerTaskExecutor(null);
}
}.runTest();
}
public void testCreateTimerMethodIsCalledIfNoTimerIsExplicitlySupplied() throws Exception {
CreationAwareTimerTaskExecutor executor = new CreationAwareTimerTaskExecutor();
executor.afterPropertiesSet();
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).",
executor.isCreateTimerWasCalled());
}
public void testCreateTimerMethodIsCalledIfNoTimerIsExplicitlySupplied() throws Exception {
CreationAwareTimerTaskExecutor executor = new CreationAwareTimerTaskExecutor();
executor.afterPropertiesSet();
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).",
executor.isCreateTimerWasCalled());
}
public void testCreateTimerMethodIsNotCalledIfTimerIsExplicitlySupplied() throws Exception {
CreationAwareTimerTaskExecutor executor = new CreationAwareTimerTaskExecutor();
executor.setTimer(new Timer());
executor.afterPropertiesSet();
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).",
executor.isCreateTimerWasCalled());
}
public void testCreateTimerMethodIsNotCalledIfTimerIsExplicitlySupplied() throws Exception {
CreationAwareTimerTaskExecutor executor = new CreationAwareTimerTaskExecutor();
executor.setTimer(new Timer());
executor.afterPropertiesSet();
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).",
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() {
return timer;
}
};
executor.afterPropertiesSet();
executor.destroy();
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).",
timer.isCancelWasCalled());
}
protected Timer createTimer() {
return timer;
}
};
executor.afterPropertiesSet();
executor.destroy();
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).",
timer.isCancelWasCalled());
}
public void testThatTheDestroyCallbackDoesNotCancelTheTimerIfTheTimerWasSuppliedExplictly() throws Exception {
TimerTaskExecutor executor = new TimerTaskExecutor();
CancelAwareTimer timer = new CancelAwareTimer();
executor.setTimer(timer);
executor.afterPropertiesSet();
executor.destroy();
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).",
timer.isCancelWasCalled());
}
public void testThatTheDestroyCallbackDoesNotCancelTheTimerIfTheTimerWasSuppliedExplictly() throws Exception {
TimerTaskExecutor executor = new TimerTaskExecutor();
CancelAwareTimer timer = new CancelAwareTimer();
executor.setTimer(timer);
executor.afterPropertiesSet();
executor.destroy();
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).",
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() {
return this.createTimerWasCalled;
}
public boolean isCreateTimerWasCalled() {
return this.createTimerWasCalled;
}
protected Timer createTimer() {
this.createTimerWasCalled = true;
return super.createTimer();
}
protected Timer createTimer() {
this.createTimerWasCalled = true;
return super.createTimer();
}
}
}
private static class CancelAwareTimer extends Timer {
private static class CancelAwareTimer extends Timer {
private boolean cancelWasCalled;
private boolean cancelWasCalled;
public boolean isCancelWasCalled() {
return this.cancelWasCalled;
}
public boolean isCancelWasCalled() {
return this.cancelWasCalled;
}
public void cancel() {
this.cancelWasCalled = true;
super.cancel();
}
}
public void cancel() {
this.cancelWasCalled = true;
super.cancel();
}
}
private static class RunAwareRunnable implements Runnable {
private boolean runWasCalled;
private final Object monitor;
private static class RunAwareRunnable implements Runnable {
private boolean runWasCalled;
private final Object monitor;
public RunAwareRunnable(Object monitor) {
this.monitor = monitor;
}
public RunAwareRunnable(Object monitor) {
this.monitor = monitor;
}
public boolean isRunWasCalled() {
return this.runWasCalled;
}
public boolean isRunWasCalled() {
return this.runWasCalled;
}
public void run() {
this.runWasCalled = true;
synchronized (monitor) {
monitor.notifyAll();
}
}
}
public void run() {
this.runWasCalled = true;
synchronized (monitor) {
monitor.notifyAll();
}
}
}
private static final class NoOpRunnable implements Runnable {
private static final class NoOpRunnable implements Runnable {
public void run() {
// explicit no-op
}
}
public void run() {
// explicit no-op
}
}
}

View File

@ -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.
@ContextConfiguration
public class ConcreteTransactionalTestNGSpringContextTests_ extends AbstractTransactionalTestNGSpringContextTests
implements BeanNameAware, InitializingBean {
implements BeanNameAware, InitializingBean {
// ------------------------------------------------------------------------|
// --- CONSTANTS ----------------------------------------------------------|
// ------------------------------------------------------------------------|
// ------------------------------------------------------------------------|
// --- CONSTANTS ----------------------------------------------------------|
// ------------------------------------------------------------------------|
private static final String BOB = "bob";
private static final String JANE = "jane";
private static final String SUE = "sue";
private static final String YODA = "yoda";
private static final String BOB = "bob";
private static final String JANE = "jane";
private static final String SUE = "sue";
private static final String YODA = "yoda";
// ------------------------------------------------------------------------|
// --- STATIC VARIABLES ---------------------------------------------------|
// ------------------------------------------------------------------------|
// ------------------------------------------------------------------------|
// --- STATIC VARIABLES ---------------------------------------------------|
// ------------------------------------------------------------------------|
private static int numSetUpCalls = 0;
private static int numSetUpCallsInTransaction = 0;
private static int numTearDownCalls = 0;
private static int numTearDownCallsInTransaction = 0;
private static int numSetUpCalls = 0;
private static int numSetUpCallsInTransaction = 0;
private static int numTearDownCalls = 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
private Pet pet;
@Autowired
private Pet pet;
@Autowired(required = false)
protected Long nonrequiredLong;
@Autowired(required = false)
protected Long nonrequiredLong;
@Resource()
protected String foo;
@Resource()
protected String foo;
protected String bar;
protected String bar;
// ------------------------------------------------------------------------|
// --- STATIC METHODS -----------------------------------------------------|
// ------------------------------------------------------------------------|
// ------------------------------------------------------------------------|
// --- STATIC METHODS -----------------------------------------------------|
// ------------------------------------------------------------------------|
private static int clearPersonTable(SimpleJdbcTemplate simpleJdbcTemplate) {
return SimpleJdbcTestUtils.deleteFromTables(simpleJdbcTemplate, "person");
}
private static int clearPersonTable(SimpleJdbcTemplate simpleJdbcTemplate) {
return SimpleJdbcTestUtils.deleteFromTables(simpleJdbcTemplate, "person");
}
private static void createPersonTable(SimpleJdbcTemplate simpleJdbcTemplate) {
try {
simpleJdbcTemplate.update("CREATE TABLE person (name VARCHAR(20) NOT NULL, PRIMARY KEY(name))");
}
catch (BadSqlGrammarException bsge) {
/* ignore */
}
}
private static void createPersonTable(SimpleJdbcTemplate simpleJdbcTemplate) {
try {
simpleJdbcTemplate.update("CREATE TABLE person (name VARCHAR(20) NOT NULL, PRIMARY KEY(name))");
}
catch (BadSqlGrammarException bsge) {
/* ignore */
}
}
private static int countRowsInPersonTable(SimpleJdbcTemplate simpleJdbcTemplate) {
return SimpleJdbcTestUtils.countRowsInTable(simpleJdbcTemplate, "person");
}
private static int countRowsInPersonTable(SimpleJdbcTemplate simpleJdbcTemplate) {
return SimpleJdbcTestUtils.countRowsInTable(simpleJdbcTemplate, "person");
}
private static int addPerson(SimpleJdbcTemplate simpleJdbcTemplate, String name) {
return simpleJdbcTemplate.update("INSERT INTO person VALUES(?)", name);
}
private static int addPerson(SimpleJdbcTemplate simpleJdbcTemplate, String name) {
return simpleJdbcTemplate.update("INSERT INTO person VALUES(?)", name);
}
private static int deletePerson(SimpleJdbcTemplate simpleJdbcTemplate, String name) {
return simpleJdbcTemplate.update("DELETE FROM person WHERE name=?", name);
}
private static int deletePerson(SimpleJdbcTemplate simpleJdbcTemplate, String name) {
return simpleJdbcTemplate.update("DELETE FROM person WHERE name=?", name);
}
// ------------------------------------------------------------------------|
// --- INSTANCE METHODS ---------------------------------------------------|
// ------------------------------------------------------------------------|
// ------------------------------------------------------------------------|
// --- INSTANCE METHODS ---------------------------------------------------|
// ------------------------------------------------------------------------|
public void afterPropertiesSet() throws Exception {
this.beanInitialized = true;
}
public void afterPropertiesSet() throws Exception {
this.beanInitialized = true;
}
public void setBeanName(String beanName) {
this.beanName = beanName;
}
public void setBeanName(String beanName) {
this.beanName = beanName;
}
@Autowired
protected void setEmployee(Employee employee) {
this.employee = employee;
}
@Autowired
protected void setEmployee(Employee employee) {
this.employee = employee;
}
@Resource
protected void setBar(String bar) {
this.bar = bar;
}
@Resource
protected void setBar(String bar) {
this.bar = bar;
}
// ------------------------------------------------------------------------|
// ------------------------------------------------------------------------|
private void assertNumRowsInPersonTable(int expectedNumRows, String testState) {
assertEquals(countRowsInPersonTable(this.simpleJdbcTemplate), expectedNumRows,
"Verifying the number of rows in the person table (" + testState + ").");
}
private void assertNumRowsInPersonTable(int expectedNumRows, String testState) {
assertEquals(countRowsInPersonTable(this.simpleJdbcTemplate), expectedNumRows,
"Verifying the number of rows in the person table (" + testState + ").");
}
private void assertAddPerson(final String name) {
assertEquals(addPerson(this.simpleJdbcTemplate, name), 1, "Adding '" + name + "'");
}
private void assertAddPerson(final String name) {
assertEquals(addPerson(this.simpleJdbcTemplate, name), 1, "Adding '" + name + "'");
}
// ------------------------------------------------------------------------|
// ------------------------------------------------------------------------|
@BeforeClass
public void beforeClass() {
numSetUpCalls = 0;
numSetUpCallsInTransaction = 0;
numTearDownCalls = 0;
numTearDownCallsInTransaction = 0;
}
@BeforeClass
public void beforeClass() {
numSetUpCalls = 0;
numSetUpCallsInTransaction = 0;
numTearDownCalls = 0;
numTearDownCallsInTransaction = 0;
}
@AfterClass
public void afterClass() {
assertEquals(numSetUpCalls, 8, "Verifying number of calls to setUp().");
assertEquals(numSetUpCallsInTransaction, 1, "Verifying number of calls to setUp() within a transaction.");
assertEquals(numTearDownCalls, 8, "Verifying number of calls to tearDown().");
assertEquals(numTearDownCallsInTransaction, 1, "Verifying number of calls to tearDown() within a transaction.");
}
@AfterClass
public void afterClass() {
assertEquals(numSetUpCalls, 8, "Verifying number of calls to setUp().");
assertEquals(numSetUpCallsInTransaction, 1, "Verifying number of calls to setUp() within a transaction.");
assertEquals(numTearDownCalls, 8, "Verifying number of calls to tearDown().");
assertEquals(numTearDownCallsInTransaction, 1, "Verifying number of calls to tearDown() within a transaction.");
}
@Test
@NotTransactional
public void verifyApplicationContextSet() {
assertInTransaction(false);
assertNotNull(super.applicationContext,
"The application context should have been set due to ApplicationContextAware semantics.");
Employee employeeBean = (Employee) super.applicationContext.getBean("employee");
assertEquals(employeeBean.getName(), "John Smith", "Verifying employee's name.");
}
@Test
@NotTransactional
public void verifyApplicationContextSet() {
assertInTransaction(false);
assertNotNull(super.applicationContext,
"The application context should have been set due to ApplicationContextAware semantics.");
Employee employeeBean = (Employee) super.applicationContext.getBean("employee");
assertEquals(employeeBean.getName(), "John Smith", "Verifying employee's name.");
}
@Test
@NotTransactional
public void verifyBeanInitialized() {
assertInTransaction(false);
assertTrue(this.beanInitialized,
"This test instance should have been initialized due to InitializingBean semantics.");
}
@Test
@NotTransactional
public void verifyBeanInitialized() {
assertInTransaction(false);
assertTrue(this.beanInitialized,
"This test instance should have been initialized due to InitializingBean semantics.");
}
@Test
@NotTransactional
public void verifyBeanNameSet() {
assertInTransaction(false);
assertEquals(this.beanName, getClass().getName(),
"The bean name of this test instance should have been set due to BeanNameAware semantics.");
}
@Test
@NotTransactional
public void verifyBeanNameSet() {
assertInTransaction(false);
assertEquals(this.beanName, getClass().getName(),
"The bean name of this test instance should have been set due to BeanNameAware semantics.");
}
@Test
@NotTransactional
public void verifyAnnotationAutowiredFields() {
assertInTransaction(false);
assertNull(this.nonrequiredLong, "The nonrequiredLong field should NOT have been autowired.");
assertNotNull(this.pet, "The pet field should have been autowired.");
assertEquals(this.pet.getName(), "Fido", "Verifying pet's name.");
}
@Test
@NotTransactional
public void verifyAnnotationAutowiredFields() {
assertInTransaction(false);
assertNull(this.nonrequiredLong, "The nonrequiredLong field should NOT have been autowired.");
assertNotNull(this.pet, "The pet field should have been autowired.");
assertEquals(this.pet.getName(), "Fido", "Verifying pet's name.");
}
@Test
@NotTransactional
public void verifyAnnotationAutowiredMethods() {
assertInTransaction(false);
assertNotNull(this.employee, "The setEmployee() method should have been autowired.");
assertEquals(this.employee.getName(), "John Smith", "Verifying employee's name.");
}
@Test
@NotTransactional
public void verifyAnnotationAutowiredMethods() {
assertInTransaction(false);
assertNotNull(this.employee, "The setEmployee() method should have been autowired.");
assertEquals(this.employee.getName(), "John Smith", "Verifying employee's name.");
}
@Test
@NotTransactional
public void verifyResourceAnnotationInjectedFields() {
assertInTransaction(false);
assertEquals(this.foo, "Foo", "The foo field should have been injected via @Resource.");
}
@Test
@NotTransactional
public void verifyResourceAnnotationInjectedFields() {
assertInTransaction(false);
assertEquals(this.foo, "Foo", "The foo field should have been injected via @Resource.");
}
@Test
@NotTransactional
public void verifyResourceAnnotationInjectedMethods() {
assertInTransaction(false);
assertEquals(this.bar, "Bar", "The setBar() method should have been injected via @Resource.");
}
@Test
@NotTransactional
public void verifyResourceAnnotationInjectedMethods() {
assertInTransaction(false);
assertEquals(this.bar, "Bar", "The setBar() method should have been injected via @Resource.");
}
// ------------------------------------------------------------------------|
// ------------------------------------------------------------------------|
@BeforeTransaction
public void beforeTransaction() {
assertNumRowsInPersonTable(1, "before a transactional test method");
assertAddPerson(YODA);
}
@BeforeTransaction
public void beforeTransaction() {
assertNumRowsInPersonTable(1, "before a transactional test method");
assertAddPerson(YODA);
}
@BeforeMethod
public void setUp() throws Exception {
numSetUpCalls++;
if (inTransaction()) {
numSetUpCallsInTransaction++;
}
assertNumRowsInPersonTable((inTransaction() ? 2 : 1), "before a test method");
}
@BeforeMethod
public void setUp() throws Exception {
numSetUpCalls++;
if (inTransaction()) {
numSetUpCallsInTransaction++;
}
assertNumRowsInPersonTable((inTransaction() ? 2 : 1), "before a test method");
}
@Test
public void modifyTestDataWithinTransaction() {
assertInTransaction(true);
assertAddPerson(JANE);
assertAddPerson(SUE);
assertNumRowsInPersonTable(4, "in modifyTestDataWithinTransaction()");
}
@Test
public void modifyTestDataWithinTransaction() {
assertInTransaction(true);
assertAddPerson(JANE);
assertAddPerson(SUE);
assertNumRowsInPersonTable(4, "in modifyTestDataWithinTransaction()");
}
@AfterMethod
public void tearDown() throws Exception {
numTearDownCalls++;
if (inTransaction()) {
numTearDownCallsInTransaction++;
}
assertNumRowsInPersonTable((inTransaction() ? 4 : 1), "after a test method");
}
@AfterMethod
public void tearDown() throws Exception {
numTearDownCalls++;
if (inTransaction()) {
numTearDownCallsInTransaction++;
}
assertNumRowsInPersonTable((inTransaction() ? 4 : 1), "after a test method");
}
@AfterTransaction
public void afterTransaction() {
assertEquals(deletePerson(this.simpleJdbcTemplate, YODA), 1, "Deleting yoda");
assertNumRowsInPersonTable(1, "after a transactional test method");
}
@AfterTransaction
public void afterTransaction() {
assertEquals(deletePerson(this.simpleJdbcTemplate, YODA), 1, "Deleting yoda");
assertNumRowsInPersonTable(1, "after a transactional test method");
}
// ------------------------------------------------------------------------|
// --- TYPES --------------------------------------------------------------|
// ------------------------------------------------------------------------|
// ------------------------------------------------------------------------|
// --- TYPES --------------------------------------------------------------|
// ------------------------------------------------------------------------|
public static class DatabaseSetup {
public static class DatabaseSetup {
@Autowired
void setDataSource(DataSource dataSource) {
SimpleJdbcTemplate simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource);
createPersonTable(simpleJdbcTemplate);
clearPersonTable(simpleJdbcTemplate);
addPerson(simpleJdbcTemplate, BOB);
}
}
@Autowired
void setDataSource(DataSource dataSource) {
SimpleJdbcTemplate simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource);
createPersonTable(simpleJdbcTemplate);
clearPersonTable(simpleJdbcTemplate);
addPerson(simpleJdbcTemplate, BOB);
}
}
}

View File

@ -42,7 +42,7 @@ import org.springframework.transaction.TransactionDefinition;
*/
public final class TransactionAttributeSourceTests {
@Test
@Test
public void testMatchAlwaysTransactionAttributeSource() throws Exception {
MatchAlwaysTransactionAttributeSource tas = new MatchAlwaysTransactionAttributeSource();
TransactionAttribute ta = tas.getTransactionAttribute(
@ -57,8 +57,8 @@ public final class TransactionAttributeSourceTests {
assertTrue(TransactionDefinition.PROPAGATION_SUPPORTS == ta.getPropagationBehavior());
}
@Ignore
@Test
@Ignore
@Test
public void testMethodMapTransactionAttributeSource() throws NoSuchMethodException {
MethodMapTransactionAttributeSource tas = new MethodMapTransactionAttributeSource();
Map methodMap = new HashMap();
@ -76,8 +76,8 @@ public final class TransactionAttributeSourceTests {
assertEquals(TransactionDefinition.PROPAGATION_SUPPORTS, ta.getPropagationBehavior());
}
@Ignore
@Test
@Ignore
@Test
public void testMethodMapTransactionAttributeSourceWithLazyInit() throws NoSuchMethodException {
MethodMapTransactionAttributeSource tas = new MethodMapTransactionAttributeSource();
Map methodMap = new HashMap();
@ -94,8 +94,8 @@ public final class TransactionAttributeSourceTests {
assertEquals(TransactionDefinition.PROPAGATION_SUPPORTS, ta.getPropagationBehavior());
}
@Ignore
@Test
@Ignore
@Test
public void testNameMatchTransactionAttributeSource() throws NoSuchMethodException {
NameMatchTransactionAttributeSource tas = new NameMatchTransactionAttributeSource();
Map methodMap = new HashMap();
@ -111,7 +111,7 @@ public final class TransactionAttributeSourceTests {
assertEquals(TransactionDefinition.PROPAGATION_SUPPORTS, ta.getPropagationBehavior());
}
@Test
@Test
public void testNameMatchTransactionAttributeSourceWithStarAtStartOfMethodName() throws NoSuchMethodException {
NameMatchTransactionAttributeSource tas = new NameMatchTransactionAttributeSource();
Properties attributes = new Properties();
@ -123,7 +123,7 @@ public final class TransactionAttributeSourceTests {
assertEquals(TransactionDefinition.PROPAGATION_REQUIRED, ta.getPropagationBehavior());
}
@Test
@Test
public void testNameMatchTransactionAttributeSourceWithStarAtEndOfMethodName() throws NoSuchMethodException {
NameMatchTransactionAttributeSource tas = new NameMatchTransactionAttributeSource();
Properties attributes = new Properties();
@ -135,7 +135,7 @@ public final class TransactionAttributeSourceTests {
assertEquals(TransactionDefinition.PROPAGATION_REQUIRED, ta.getPropagationBehavior());
}
@Test
@Test
public void testNameMatchTransactionAttributeSourceMostSpecificMethodNameIsDefinitelyMatched() throws NoSuchMethodException {
NameMatchTransactionAttributeSource tas = new NameMatchTransactionAttributeSource();
Properties attributes = new Properties();
@ -148,7 +148,7 @@ public final class TransactionAttributeSourceTests {
assertEquals(TransactionDefinition.PROPAGATION_MANDATORY, ta.getPropagationBehavior());
}
@Test
@Test
public void testNameMatchTransactionAttributeSourceWithEmptyMethodName() throws NoSuchMethodException {
NameMatchTransactionAttributeSource tas = new NameMatchTransactionAttributeSource();
Properties attributes = new Properties();

View File

@ -35,154 +35,154 @@ import java.io.IOException;
*/
public final class PortletWrappingControllerTests extends TestCase {
private static final String RESULT_RENDER_PARAMETER_NAME = "result";
private static final String PORTLET_WRAPPING_CONTROLLER_BEAN_NAME = "controller";
private static final String RENDERED_RESPONSE_CONTENT = "myPortlet-view";
private static final String PORTLET_NAME_ACTION_REQUEST_PARAMETER_NAME = "portletName";
private static final String RESULT_RENDER_PARAMETER_NAME = "result";
private static final String PORTLET_WRAPPING_CONTROLLER_BEAN_NAME = "controller";
private static final String RENDERED_RESPONSE_CONTENT = "myPortlet-view";
private static final String PORTLET_NAME_ACTION_REQUEST_PARAMETER_NAME = "portletName";
private PortletWrappingController controller;
private PortletWrappingController controller;
public void setUp() {
ConfigurablePortletApplicationContext applicationContext = new MyApplicationContext();
MockPortletConfig config = new MockPortletConfig(new MockPortletContext(), "wrappedPortlet");
applicationContext.setPortletConfig(config);
applicationContext.refresh();
controller = (PortletWrappingController) applicationContext.getBean(PORTLET_WRAPPING_CONTROLLER_BEAN_NAME);
}
public void setUp() {
ConfigurablePortletApplicationContext applicationContext = new MyApplicationContext();
MockPortletConfig config = new MockPortletConfig(new MockPortletContext(), "wrappedPortlet");
applicationContext.setPortletConfig(config);
applicationContext.refresh();
controller = (PortletWrappingController) applicationContext.getBean(PORTLET_WRAPPING_CONTROLLER_BEAN_NAME);
}
public void testActionRequest() throws Exception {
MockActionRequest request = new MockActionRequest();
MockActionResponse response = new MockActionResponse();
request.setParameter("test", "test");
controller.handleActionRequest(request, response);
String result = response.getRenderParameter(RESULT_RENDER_PARAMETER_NAME);
assertEquals("myPortlet-action", result);
}
public void testActionRequest() throws Exception {
MockActionRequest request = new MockActionRequest();
MockActionResponse response = new MockActionResponse();
request.setParameter("test", "test");
controller.handleActionRequest(request, response);
String result = response.getRenderParameter(RESULT_RENDER_PARAMETER_NAME);
assertEquals("myPortlet-action", result);
}
public void testRenderRequest() throws Exception {
MockRenderRequest request = new MockRenderRequest();
MockRenderResponse response = new MockRenderResponse();
controller.handleRenderRequest(request, response);
String result = response.getContentAsString();
assertEquals(RENDERED_RESPONSE_CONTENT, result);
}
public void testRenderRequest() throws Exception {
MockRenderRequest request = new MockRenderRequest();
MockRenderResponse response = new MockRenderResponse();
controller.handleRenderRequest(request, response);
String result = response.getContentAsString();
assertEquals(RENDERED_RESPONSE_CONTENT, result);
}
public void testActionRequestWithNoParameters() throws Exception {
final MockActionRequest request = new MockActionRequest();
final MockActionResponse response = new MockActionResponse();
new AssertThrows(IllegalArgumentException.class) {
public void test() throws Exception {
controller.handleActionRequest(request, response);
}
}.runTest();
}
public void testActionRequestWithNoParameters() throws Exception {
final MockActionRequest request = new MockActionRequest();
final MockActionResponse response = new MockActionResponse();
new AssertThrows(IllegalArgumentException.class) {
public void test() throws Exception {
controller.handleActionRequest(request, response);
}
}.runTest();
}
public void testRejectsPortletClassThatDoesNotImplementPortletInterface() throws Exception {
new AssertThrows(IllegalArgumentException.class) {
public void test() throws Exception {
PortletWrappingController controller = new PortletWrappingController();
controller.setPortletClass(String.class);
controller.afterPropertiesSet();
}
}.runTest();
}
public void testRejectsPortletClassThatDoesNotImplementPortletInterface() throws Exception {
new AssertThrows(IllegalArgumentException.class) {
public void test() throws Exception {
PortletWrappingController controller = new PortletWrappingController();
controller.setPortletClass(String.class);
controller.afterPropertiesSet();
}
}.runTest();
}
public void testRejectsIfPortletClassIsNotSupplied() throws Exception {
new AssertThrows(IllegalArgumentException.class) {
public void test() throws Exception {
PortletWrappingController controller = new PortletWrappingController();
controller.setPortletClass(null);
controller.afterPropertiesSet();
}
}.runTest();
}
public void testRejectsIfPortletClassIsNotSupplied() throws Exception {
new AssertThrows(IllegalArgumentException.class) {
public void test() throws Exception {
PortletWrappingController controller = new PortletWrappingController();
controller.setPortletClass(null);
controller.afterPropertiesSet();
}
}.runTest();
}
public void testDestroyingTheControllerPropagatesDestroyToWrappedPortlet() throws Exception {
final PortletWrappingController controller = new PortletWrappingController();
controller.setPortletClass(MyPortlet.class);
controller.afterPropertiesSet();
// test for destroy() call being propagated via exception being thrown :(
new AssertThrows(IllegalStateException.class) {
public void test() throws Exception {
controller.destroy();
}
}.runTest();
}
public void testDestroyingTheControllerPropagatesDestroyToWrappedPortlet() throws Exception {
final PortletWrappingController controller = new PortletWrappingController();
controller.setPortletClass(MyPortlet.class);
controller.afterPropertiesSet();
// test for destroy() call being propagated via exception being thrown :(
new AssertThrows(IllegalStateException.class) {
public void test() throws Exception {
controller.destroy();
}
}.runTest();
}
public void testPortletName() throws Exception {
MockActionRequest request = new MockActionRequest();
MockActionResponse response = new MockActionResponse();
request.setParameter(PORTLET_NAME_ACTION_REQUEST_PARAMETER_NAME, "test");
controller.handleActionRequest(request, response);
String result = response.getRenderParameter(RESULT_RENDER_PARAMETER_NAME);
assertEquals("wrappedPortlet", result);
}
public void testPortletName() throws Exception {
MockActionRequest request = new MockActionRequest();
MockActionResponse response = new MockActionResponse();
request.setParameter(PORTLET_NAME_ACTION_REQUEST_PARAMETER_NAME, "test");
controller.handleActionRequest(request, response);
String result = response.getRenderParameter(RESULT_RENDER_PARAMETER_NAME);
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();
MockActionResponse response = new MockActionResponse();
MockActionRequest request = new MockActionRequest();
MockActionResponse response = new MockActionResponse();
PortletWrappingController controller = new PortletWrappingController();
controller.setPortletClass(MyPortlet.class);
controller.setUseSharedPortletConfig(false);
controller.setBeanName(BEAN_NAME);
controller.afterPropertiesSet();
PortletWrappingController controller = new PortletWrappingController();
controller.setPortletClass(MyPortlet.class);
controller.setUseSharedPortletConfig(false);
controller.setBeanName(BEAN_NAME);
controller.afterPropertiesSet();
request.setParameter(PORTLET_NAME_ACTION_REQUEST_PARAMETER_NAME, "true");
controller.handleActionRequest(request, response);
request.setParameter(PORTLET_NAME_ACTION_REQUEST_PARAMETER_NAME, "true");
controller.handleActionRequest(request, response);
String result = response.getRenderParameter(RESULT_RENDER_PARAMETER_NAME);
assertEquals(BEAN_NAME, result);
}
String result = response.getRenderParameter(RESULT_RENDER_PARAMETER_NAME);
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) {
this.portletConfig = portletConfig;
}
public void init(PortletConfig portletConfig) {
this.portletConfig = portletConfig;
}
public void processAction(ActionRequest request, ActionResponse response) throws PortletException {
if (request.getParameter("test") != null) {
response.setRenderParameter(RESULT_RENDER_PARAMETER_NAME, "myPortlet-action");
} else if (request.getParameter(PORTLET_NAME_ACTION_REQUEST_PARAMETER_NAME) != null) {
response.setRenderParameter(RESULT_RENDER_PARAMETER_NAME, getPortletConfig().getPortletName());
} else {
throw new IllegalArgumentException("no request parameters");
}
}
public void processAction(ActionRequest request, ActionResponse response) throws PortletException {
if (request.getParameter("test") != null) {
response.setRenderParameter(RESULT_RENDER_PARAMETER_NAME, "myPortlet-action");
} else if (request.getParameter(PORTLET_NAME_ACTION_REQUEST_PARAMETER_NAME) != null) {
response.setRenderParameter(RESULT_RENDER_PARAMETER_NAME, getPortletConfig().getPortletName());
} else {
throw new IllegalArgumentException("no request parameters");
}
}
public void render(RenderRequest request, RenderResponse response) throws IOException {
response.getWriter().write(RENDERED_RESPONSE_CONTENT);
}
public void render(RenderRequest request, RenderResponse response) throws IOException {
response.getWriter().write(RENDERED_RESPONSE_CONTENT);
}
public PortletConfig getPortletConfig() {
return this.portletConfig;
}
public PortletConfig getPortletConfig() {
return this.portletConfig;
}
public void destroy() {
throw new IllegalStateException("Being destroyed...");
}
public void destroy() {
throw new IllegalStateException("Being destroyed...");
}
}
}
private static final class MyApplicationContext extends StaticPortletApplicationContext {
private static final class MyApplicationContext extends StaticPortletApplicationContext {
public void refresh() throws BeansException {
MutablePropertyValues pvs = new MutablePropertyValues();
pvs.addPropertyValue("portletClass", MyPortlet.class);
registerSingleton(PORTLET_WRAPPING_CONTROLLER_BEAN_NAME, PortletWrappingController.class, pvs);
super.refresh();
}
}
public void refresh() throws BeansException {
MutablePropertyValues pvs = new MutablePropertyValues();
pvs.addPropertyValue("portletClass", MyPortlet.class);
registerSingleton(PORTLET_WRAPPING_CONTROLLER_BEAN_NAME, PortletWrappingController.class, pvs);
super.refresh();
}
}
}