diff options
Diffstat (limited to 'plugins/org.eclipse.net4j.tests')
26 files changed, 4065 insertions, 0 deletions
diff --git a/plugins/org.eclipse.net4j.tests/.classpath b/plugins/org.eclipse.net4j.tests/.classpath new file mode 100644 index 0000000000..544119ad6b --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/.classpath @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry excluding="org/eclipse/net4j/test/ChannelImplTest.java|org/eclipse/net4j/test/PoolTest.java|org/eclipse/net4j/test/SelectorTest.java|org/eclipse/net4j/test/SocketConnectorTest.java|org/eclipse/net4j/test/old/ChannelImplTest.java|org/eclipse/net4j/test/old/PoolTest.java|org/eclipse/net4j/test/old/SelectorTest.java|org/eclipse/net4j/test/old/SocketConnectorTest.java" kind="src" path="src"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="src" path="/org.eclipse.net4j.core"/> + <classpathentry kind="src" path="/org.eclipse.net4j.embedded"/> + <classpathentry kind="src" path="/org.eclipse.net4j.socket"/> + <classpathentry kind="src" path="/org.eclipse.net4j.spring"/> + <classpathentry kind="src" path="/org.eclipse.net4j.util"/> + <classpathentry sourcepath="/ECLIPSE_HOME/plugins/org.eclipse.jdt.source_3.2.0.v20060215-1200-0cq-cuim1y/src/org.junit_3.8.1/junitsrc.zip" kind="var" path="JUNIT_HOME/junit.jar"/> + <classpathentry kind="lib" path="lib/easymock.jar"/> + <classpathentry kind="lib" path="lib/easymockclassextension.jar"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/plugins/org.eclipse.net4j.tests/.cvsignore b/plugins/org.eclipse.net4j.tests/.cvsignore new file mode 100644 index 0000000000..28c3030d91 --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/.cvsignore @@ -0,0 +1,6 @@ +tmp +bin +dist +build +runtime +*.log diff --git a/plugins/org.eclipse.net4j.tests/.project b/plugins/org.eclipse.net4j.tests/.project new file mode 100644 index 0000000000..980ccde5a3 --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.net4j.test</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/plugins/org.eclipse.net4j.tests/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.net4j.tests/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..fb74a5035d --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,261 @@ +#Mon Mar 13 08:16:19 CET 2006 +eclipse.preferences.version=1 +org.eclipse.jdt.core.codeComplete.argumentPrefixes= +org.eclipse.jdt.core.codeComplete.argumentSuffixes= +org.eclipse.jdt.core.codeComplete.fieldPrefixes= +org.eclipse.jdt.core.codeComplete.fieldSuffixes= +org.eclipse.jdt.core.codeComplete.localPrefixes= +org.eclipse.jdt.core.codeComplete.localSuffixes= +org.eclipse.jdt.core.codeComplete.staticFieldPrefixes= +org.eclipse.jdt.core.codeComplete.staticFieldSuffixes= +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.5 +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=2 +org.eclipse.jdt.core.formatter.blank_lines_after_package=2 +org.eclipse.jdt.core.formatter.blank_lines_before_field=1 +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=2 +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_type_declarations=2 +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=next_line +org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block=next_line +org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=next_line +org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=next_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=next_line +org.eclipse.jdt.core.formatter.brace_position_for_switch=next_line +org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=next_line +org.eclipse.jdt.core.formatter.comment.clear_blank_lines=false +org.eclipse.jdt.core.formatter.comment.format_comments=false +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_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=100 +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=true +org.eclipse.jdt.core.formatter.indentation.size=4 +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation=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=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=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=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=do not 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_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=true +org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false +org.eclipse.jdt.core.formatter.lineSplit=100 +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=space +org.eclipse.jdt.core.formatter.tabulation.size=2 +org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false diff --git a/plugins/org.eclipse.net4j.tests/.settings/org.eclipse.jdt.ui.prefs b/plugins/org.eclipse.net4j.tests/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 0000000000..6b2f797e54 --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,19 @@ +#Mon Mar 13 08:16:19 CET 2006 +comment_clear_blank_lines=false +comment_format_comments=false +comment_format_header=false +comment_format_html=true +comment_format_source_code=true +comment_indent_parameter_description=true +comment_indent_root_tags=true +comment_line_length=100 +comment_new_line_for_parameter=true +comment_separate_root_tags=true +eclipse.preferences.version=1 +formatter_settings_version=10 +org.eclipse.jdt.ui.exception.name=ex +org.eclipse.jdt.ui.gettersetter.use.is=true +org.eclipse.jdt.ui.ignorelowercasenames=true +org.eclipse.jdt.ui.importorder=org.eclipse.net4j;org.eclipse.emf;org.eclipse;org.apache;org;com;java.lang;java.util;java.io;java.nio;java.net;java;javax; +org.eclipse.jdt.ui.keywordthis=false +org.eclipse.jdt.ui.ondemandthreshold=99 diff --git a/plugins/org.eclipse.net4j.tests/META-INF/MANIFEST.MF b/plugins/org.eclipse.net4j.tests/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..901cd80165 --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/META-INF/MANIFEST.MF @@ -0,0 +1,13 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %pluginName +Bundle-SymbolicName: org.eclipse.net4j.test;singleton:=true +Bundle-Version: 1.0.0 +Bundle-ClassPath: library.jar +Bundle-Vendor: %providerName +Bundle-Localization: plugin +Require-Bundle: org.eclipse.core.runtime +Eclipse-LazyStart: false +Export-Package: org.eclipse.net4j.test, + org.eclipse.net4j.test.protocol, + org.eclipse.net4j.test.util diff --git a/plugins/org.eclipse.net4j.tests/META-INF/common.properties b/plugins/org.eclipse.net4j.tests/META-INF/common.properties new file mode 100644 index 0000000000..23de5e4dbf --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/META-INF/common.properties @@ -0,0 +1,8 @@ +bufferPool.bufferSize=4096 + +connectionManager.maxConnections=50 + +channel.responseTimeoutMillis=6000000 + +socket.host=localhost +socket.port=12345 diff --git a/plugins/org.eclipse.net4j.tests/META-INF/embedded.xml b/plugins/org.eclipse.net4j.tests/META-INF/embedded.xml new file mode 100644 index 0000000000..a619b3926c --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/META-INF/embedded.xml @@ -0,0 +1,91 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" + "http://www.springframework.org/dtd/spring-beans.dtd"> +<beans> + + <!-- ######################################################## --> + <bean id="propertyConfigurer" + class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> + <property name="locations"> + <list> + <value>file:META-INF/common.properties</value> + </list> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="bufferPool" class="org.eclipse.net4j.core.impl.BufferPoolImpl"> + <property name="bufferSize"> + <value>${bufferPool.bufferSize}</value> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="connectionManager" class="org.eclipse.net4j.core.impl.ConnectionManagerImpl"> + <property name="maxConnections"> + <value>${connectionManager.maxConnections}</value> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="protocolManager" class="org.eclipse.net4j.core.impl.ProtocolManagerImpl"/> + + <!-- ######################################################## --> + <bean id="multiplexer" class="org.eclipse.net4j.core.impl.MultiplexerImpl"/> + + <!-- ######################################################## --> + <bean id="basicServerProtocol" class="org.eclipse.net4j.core.protocol.BasicServerProtocol"> + <property name="protocolManager"> + <ref local="protocolManager"/> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="basicClientProtocol" class="org.eclipse.net4j.core.protocol.BasicClientProtocol"> + <property name="protocolManager"> + <ref local="protocolManager"/> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="channel" singleton="false" class="org.eclipse.net4j.core.impl.ChannelImpl"> + <property name="multiplexer"> + <ref local="multiplexer"/> + </property> + <property name="responseTimeoutMillis"> + <value>${channel.responseTimeoutMillis}</value> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="protocol" class="org.eclipse.net4j.test.protocol.Net4jTestProtocol"> + <property name="protocolManager"> + <ref local="protocolManager"/> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="connector" class="org.eclipse.net4j.embedded.impl.ActiveEmbeddedConnectorImpl"> + <property name="bufferPool"> + <ref local="bufferPool"/> + </property> + <property name="protocolManager"> + <ref local="protocolManager"/> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="slave" singleton="false" + class="org.eclipse.net4j.embedded.impl.PassiveEmbeddedConnectorImpl"> + <property name="bufferPool"> + <ref local="bufferPool"/> + </property> + <property name="connectionManager"> + <ref local="connectionManager"/> + </property> + <property name="protocolManager"> + <ref local="protocolManager"/> + </property> + </bean> + +</beans> diff --git a/plugins/org.eclipse.net4j.tests/META-INF/socketClient.xml b/plugins/org.eclipse.net4j.tests/META-INF/socketClient.xml new file mode 100644 index 0000000000..ba94843956 --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/META-INF/socketClient.xml @@ -0,0 +1,85 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" + "http://www.springframework.org/dtd/spring-beans.dtd"> +<beans> + + <!-- ######################################################## --> + <bean id="propertyConfigurer" + class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> + <property name="locations"> + <list> + <value>file:META-INF/common.properties</value> + </list> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="bufferPool" class="org.eclipse.net4j.core.impl.BufferPoolImpl"> + <property name="bufferSize"> + <value>${bufferPool.bufferSize}</value> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="connectionManager" class="org.eclipse.net4j.core.impl.ConnectionManagerImpl"> + <property name="maxConnections"> + <value>${connectionManager.maxConnections}</value> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="protocolManager" class="org.eclipse.net4j.core.impl.ProtocolManagerImpl"/> + + <!-- ######################################################## --> + <bean id="multiplexer" class="org.eclipse.net4j.core.impl.MultiplexerImpl"/> + + <!-- ######################################################## --> + <bean id="basicClientProtocol" class="org.eclipse.net4j.core.protocol.BasicClientProtocol"> + <property name="protocolManager"> + <ref local="protocolManager"/> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="channel" singleton="false" class="org.eclipse.net4j.core.impl.ChannelImpl"> + <property name="multiplexer"> + <ref local="multiplexer"/> + </property> + <property name="responseTimeoutMillis"> + <value>${channel.responseTimeoutMillis}</value> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="selectorManager" class="org.eclipse.net4j.socket.impl.SelectorManagerImpl"/> + + <!-- ######################################################## --> + <bean id="protocol" class="org.eclipse.net4j.test.protocol.Net4jTestProtocol"> + <property name="protocolManager"> + <ref local="protocolManager"/> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="connector" class="org.eclipse.net4j.socket.impl.ActiveSocketConnectorImpl"> + <property name="bufferPool"> + <ref local="bufferPool"/> + </property> + <property name="protocolManager"> + <ref local="protocolManager"/> + </property> + <property name="selectorManager"> + <ref local="selectorManager"/> + </property> + <property name="host"> + <value>${socket.host}</value> + </property> + <property name="port"> + <value>${socket.port}</value> + </property> + <property name="autoStart"> + <value>false</value> + </property> + </bean> + +</beans> diff --git a/plugins/org.eclipse.net4j.tests/META-INF/socketServer.xml b/plugins/org.eclipse.net4j.tests/META-INF/socketServer.xml new file mode 100644 index 0000000000..c570efe600 --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/META-INF/socketServer.xml @@ -0,0 +1,90 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" + "http://www.springframework.org/dtd/spring-beans.dtd"> +<beans> + + <!-- ######################################################## --> + <bean id="propertyConfigurer" + class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> + <property name="locations"> + <list> + <value>file:META-INF/common.properties</value> + </list> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="bufferPool" class="org.eclipse.net4j.core.impl.BufferPoolImpl"> + <property name="bufferSize"> + <value>${bufferPool.bufferSize}</value> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="connectionManager" class="org.eclipse.net4j.core.impl.ConnectionManagerImpl"> + <property name="maxConnections"> + <value>${connectionManager.maxConnections}</value> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="protocolManager" class="org.eclipse.net4j.core.impl.ProtocolManagerImpl"/> + + <!-- ######################################################## --> + <bean id="multiplexer" class="org.eclipse.net4j.core.impl.MultiplexerImpl"/> + + <!-- ######################################################## --> + <bean id="basicServerProtocol" class="org.eclipse.net4j.core.protocol.BasicServerProtocol"> + <property name="protocolManager"> + <ref local="protocolManager"/> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="channel" singleton="false" class="org.eclipse.net4j.core.impl.ChannelImpl"> + <property name="multiplexer"> + <ref local="multiplexer"/> + </property> + <property name="responseTimeoutMillis"> + <value>${channel.responseTimeoutMillis}</value> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="selectorManager" class="org.eclipse.net4j.socket.impl.SelectorManagerImpl"/> + + <!-- ######################################################## --> + <bean id="protocol" class="org.eclipse.net4j.test.protocol.Net4jTestProtocol"> + <property name="protocolManager"> + <ref local="protocolManager"/> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="acceptor" class="org.eclipse.net4j.socket.impl.SocketAcceptorImpl"> + <property name="listenAddr"> + <value>0.0.0.0</value> + </property> + <property name="listenPort"> + <value>${socket.port}</value> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="slave" singleton="false" + class="org.eclipse.net4j.socket.impl.PassiveSocketConnectorImpl"> + <property name="bufferPool"> + <ref local="bufferPool"/> + </property> + <property name="connectionManager"> + <ref local="connectionManager"/> + </property> + <property name="protocolManager"> + <ref local="protocolManager"/> + </property> + <property name="selectorManager"> + <ref local="selectorManager"/> + </property> + </bean> + +</beans> diff --git a/plugins/org.eclipse.net4j.tests/build.properties b/plugins/org.eclipse.net4j.tests/build.properties new file mode 100644 index 0000000000..1a993197c7 --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/build.properties @@ -0,0 +1,9 @@ +src.includes = src/ +bin.includes = plugin.xml,\ + META-INF/,\ + epl-v10.html,\ + lib/,\ + library.jar +jars.compile.order = library.jar +source.library.jar = src/ +output.library.jar = bin/ diff --git a/plugins/org.eclipse.net4j.tests/epl-v10.html b/plugins/org.eclipse.net4j.tests/epl-v10.html new file mode 100644 index 0000000000..d7b88e9416 --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/epl-v10.html @@ -0,0 +1,319 @@ +<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40"><head> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta name="ProgId" content="Word.Document"> +<meta name="Generator" content="Microsoft Word 9"> +<meta name="Originator" content="Microsoft Word 9"> +<link rel="File-List" href="http://www.eclipse.org/org/documents/Eclipse%20EPL%202003_11_10%20Final_files/filelist.xml"><title>Eclipse Public License - Version 1.0</title><!--[if gte mso 9]><xml> + <o:DocumentProperties> + <o:Revision>2</o:Revision> + <o:TotalTime>3</o:TotalTime> + <o:Created>2004-03-05T23:03:00Z</o:Created> + <o:LastSaved>2004-03-05T23:03:00Z</o:LastSaved> + <o:Pages>4</o:Pages> + <o:Words>1626</o:Words> + <o:Characters>9270</o:Characters> + <o:Lines>77</o:Lines> + <o:Paragraphs>18</o:Paragraphs> + <o:CharactersWithSpaces>11384</o:CharactersWithSpaces> + <o:Version>9.4402</o:Version> + </o:DocumentProperties> +</xml><![endif]--><!--[if gte mso 9]><xml> + <w:WordDocument> + <w:TrackRevisions/> + </w:WordDocument> +</xml><![endif]--> + + +<style> +<!-- + /* Font Definitions */ +@font-face + {font-family:Tahoma; + panose-1:2 11 6 4 3 5 4 4 2 4; + mso-font-charset:0; + mso-generic-font-family:swiss; + mso-font-pitch:variable; + mso-font-signature:553679495 -2147483648 8 0 66047 0;} + /* Style Definitions */ +p.MsoNormal, li.MsoNormal, div.MsoNormal + {mso-style-parent:""; + margin:0in; + margin-bottom:.0001pt; + mso-pagination:widow-orphan; + font-size:12.0pt; + font-family:"Times New Roman"; + mso-fareast-font-family:"Times New Roman";} +p + {margin-right:0in; + mso-margin-top-alt:auto; + mso-margin-bottom-alt:auto; + margin-left:0in; + mso-pagination:widow-orphan; + font-size:12.0pt; + font-family:"Times New Roman"; + mso-fareast-font-family:"Times New Roman";} +p.BalloonText, li.BalloonText, div.BalloonText + {mso-style-name:"Balloon Text"; + margin:0in; + margin-bottom:.0001pt; + mso-pagination:widow-orphan; + font-size:8.0pt; + font-family:Tahoma; + mso-fareast-font-family:"Times New Roman";} +@page Section1 + {size:8.5in 11.0in; + margin:1.0in 1.25in 1.0in 1.25in; + mso-header-margin:.5in; + mso-footer-margin:.5in; + mso-paper-source:0;} +div.Section1 + {page:Section1;} +--> +</style></head> + +<body style="" lang="EN-US"> + +<div class="Section1"> + +<p style="text-align: center;" align="center"><b>Eclipse Public License - v 1.0</b> +</p> + +<p><span style="font-size: 10pt;">THE ACCOMPANYING PROGRAM IS PROVIDED UNDER +THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, +REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE +OF THIS AGREEMENT.</span> </p> + +<p><b><span style="font-size: 10pt;">1. DEFINITIONS</span></b> </p> + +<p><span style="font-size: 10pt;">"Contribution" means:</span> </p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">a) +in the case of the initial Contributor, the initial code and documentation +distributed under this Agreement, and<br clear="left"> +b) in the case of each subsequent Contributor:</span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">i) +changes to the Program, and</span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">ii) +additions to the Program;</span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">where +such changes and/or additions to the Program originate from and are distributed +by that particular Contributor. A Contribution 'originates' from a Contributor +if it was added to the Program by such Contributor itself or anyone acting on +such Contributor's behalf. Contributions do not include additions to the +Program which: (i) are separate modules of software distributed in conjunction +with the Program under their own license agreement, and (ii) are not derivative +works of the Program. </span></p> + +<p><span style="font-size: 10pt;">"Contributor" means any person or +entity that distributes the Program.</span> </p> + +<p><span style="font-size: 10pt;">"Licensed Patents " mean patent +claims licensable by a Contributor which are necessarily infringed by the use +or sale of its Contribution alone or when combined with the Program. </span></p> + +<p><span style="font-size: 10pt;">"Program" means the Contributions +distributed in accordance with this Agreement.</span> </p> + +<p><span style="font-size: 10pt;">"Recipient" means anyone who +receives the Program under this Agreement, including all Contributors.</span> </p> + +<p><b><span style="font-size: 10pt;">2. GRANT OF RIGHTS</span></b> </p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">a) +Subject to the terms of this Agreement, each Contributor hereby grants Recipient +a non-exclusive, worldwide, royalty-free copyright license to<span style="color: red;"> </span>reproduce, prepare derivative works of, publicly +display, publicly perform, distribute and sublicense the Contribution of such +Contributor, if any, and such derivative works, in source code and object code +form.</span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">b) +Subject to the terms of this Agreement, each Contributor hereby grants +Recipient a non-exclusive, worldwide,<span style="color: green;"> </span>royalty-free +patent license under Licensed Patents to make, use, sell, offer to sell, import +and otherwise transfer the Contribution of such Contributor, if any, in source +code and object code form. This patent license shall apply to the combination +of the Contribution and the Program if, at the time the Contribution is added +by the Contributor, such addition of the Contribution causes such combination +to be covered by the Licensed Patents. The patent license shall not apply to +any other combinations which include the Contribution. No hardware per se is +licensed hereunder. </span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">c) +Recipient understands that although each Contributor grants the licenses to its +Contributions set forth herein, no assurances are provided by any Contributor +that the Program does not infringe the patent or other intellectual property +rights of any other entity. Each Contributor disclaims any liability to Recipient +for claims brought by any other entity based on infringement of intellectual +property rights or otherwise. As a condition to exercising the rights and +licenses granted hereunder, each Recipient hereby assumes sole responsibility +to secure any other intellectual property rights needed, if any. For example, +if a third party patent license is required to allow Recipient to distribute +the Program, it is Recipient's responsibility to acquire that license before +distributing the Program.</span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">d) +Each Contributor represents that to its knowledge it has sufficient copyright +rights in its Contribution, if any, to grant the copyright license set forth in +this Agreement. </span></p> + +<p><b><span style="font-size: 10pt;">3. REQUIREMENTS</span></b> </p> + +<p><span style="font-size: 10pt;">A Contributor may choose to distribute the +Program in object code form under its own license agreement, provided that:</span> +</p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">a) +it complies with the terms and conditions of this Agreement; and</span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">b) +its license agreement:</span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">i) +effectively disclaims on behalf of all Contributors all warranties and +conditions, express and implied, including warranties or conditions of title +and non-infringement, and implied warranties or conditions of merchantability +and fitness for a particular purpose; </span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">ii) +effectively excludes on behalf of all Contributors all liability for damages, +including direct, indirect, special, incidental and consequential damages, such +as lost profits; </span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">iii) +states that any provisions which differ from this Agreement are offered by that +Contributor alone and not by any other party; and</span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">iv) +states that source code for the Program is available from such Contributor, and +informs licensees how to obtain it in a reasonable manner on or through a +medium customarily used for software exchange.<span style="color: blue;"> </span></span></p> + +<p><span style="font-size: 10pt;">When the Program is made available in source +code form:</span> </p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">a) +it must be made available under this Agreement; and </span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">b) a +copy of this Agreement must be included with each copy of the Program. </span></p> + +<p><span style="font-size: 10pt;">Contributors may not remove or alter any +copyright notices contained within the Program. </span></p> + +<p><span style="font-size: 10pt;">Each Contributor must identify itself as the +originator of its Contribution, if any, in a manner that reasonably allows +subsequent Recipients to identify the originator of the Contribution. </span></p> + +<p><b><span style="font-size: 10pt;">4. COMMERCIAL DISTRIBUTION</span></b> </p> + +<p><span style="font-size: 10pt;">Commercial distributors of software may +accept certain responsibilities with respect to end users, business partners +and the like. While this license is intended to facilitate the commercial use +of the Program, the Contributor who includes the Program in a commercial +product offering should do so in a manner which does not create potential +liability for other Contributors. Therefore, if a Contributor includes the +Program in a commercial product offering, such Contributor ("Commercial +Contributor") hereby agrees to defend and indemnify every other +Contributor ("Indemnified Contributor") against any losses, damages and +costs (collectively "Losses") arising from claims, lawsuits and other +legal actions brought by a third party against the Indemnified Contributor to +the extent caused by the acts or omissions of such Commercial Contributor in +connection with its distribution of the Program in a commercial product +offering. The obligations in this section do not apply to any claims or Losses +relating to any actual or alleged intellectual property infringement. In order +to qualify, an Indemnified Contributor must: a) promptly notify the Commercial +Contributor in writing of such claim, and b) allow the Commercial Contributor +to control, and cooperate with the Commercial Contributor in, the defense and +any related settlement negotiations. The Indemnified Contributor may participate +in any such claim at its own expense.</span> </p> + +<p><span style="font-size: 10pt;">For example, a Contributor might include the +Program in a commercial product offering, Product X. That Contributor is then a +Commercial Contributor. If that Commercial Contributor then makes performance +claims, or offers warranties related to Product X, those performance claims and +warranties are such Commercial Contributor's responsibility alone. Under this +section, the Commercial Contributor would have to defend claims against the +other Contributors related to those performance claims and warranties, and if a +court requires any other Contributor to pay any damages as a result, the +Commercial Contributor must pay those damages.</span> </p> + +<p><b><span style="font-size: 10pt;">5. NO WARRANTY</span></b> </p> + +<p><span style="font-size: 10pt;">EXCEPT AS EXPRESSLY SET FORTH IN THIS +AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT +WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, +WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, +MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely +responsible for determining the appropriateness of using and distributing the +Program and assumes all risks associated with its exercise of rights under this +Agreement , including but not limited to the risks and costs of program errors, +compliance with applicable laws, damage to or loss of data, programs or +equipment, and unavailability or interruption of operations. </span></p> + +<p><b><span style="font-size: 10pt;">6. DISCLAIMER OF LIABILITY</span></b> </p> + +<p><span style="font-size: 10pt;">EXCEPT AS EXPRESSLY SET FORTH IN THIS +AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF +THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGES.</span> </p> + +<p><b><span style="font-size: 10pt;">7. GENERAL</span></b> </p> + +<p><span style="font-size: 10pt;">If any provision of this Agreement is invalid +or unenforceable under applicable law, it shall not affect the validity or +enforceability of the remainder of the terms of this Agreement, and without +further action by the parties hereto, such provision shall be reformed to the +minimum extent necessary to make such provision valid and enforceable.</span> </p> + +<p><span style="font-size: 10pt;">If Recipient institutes patent litigation +against any entity (including a cross-claim or counterclaim in a lawsuit) +alleging that the Program itself (excluding combinations of the Program with +other software or hardware) infringes such Recipient's patent(s), then such +Recipient's rights granted under Section 2(b) shall terminate as of the date +such litigation is filed. </span></p> + +<p><span style="font-size: 10pt;">All Recipient's rights under this Agreement +shall terminate if it fails to comply with any of the material terms or +conditions of this Agreement and does not cure such failure in a reasonable +period of time after becoming aware of such noncompliance. If all Recipient's +rights under this Agreement terminate, Recipient agrees to cease use and +distribution of the Program as soon as reasonably practicable. However, +Recipient's obligations under this Agreement and any licenses granted by +Recipient relating to the Program shall continue and survive. </span></p> + +<p><span style="font-size: 10pt;">Everyone is permitted to copy and distribute +copies of this Agreement, but in order to avoid inconsistency the Agreement is +copyrighted and may only be modified in the following manner. The Agreement +Steward reserves the right to publish new versions (including revisions) of +this Agreement from time to time. No one other than the Agreement Steward has +the right to modify this Agreement. The Eclipse Foundation is the initial +Agreement Steward. The Eclipse Foundation may assign the responsibility to +serve as the Agreement Steward to a suitable separate entity. Each new version +of the Agreement will be given a distinguishing version number. The Program +(including Contributions) may always be distributed subject to the version of +the Agreement under which it was received. In addition, after a new version of +the Agreement is published, Contributor may elect to distribute the Program +(including its Contributions) under the new version. Except as expressly stated +in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to +the intellectual property of any Contributor under this Agreement, whether +expressly, by implication, estoppel or otherwise. All rights in the Program not +expressly granted under this Agreement are reserved.</span> </p> + +<p><span style="font-size: 10pt;">This Agreement is governed by the laws of the +State of New York and the intellectual property laws of the United States of +America. No party to this Agreement will bring a legal action under this +Agreement more than one year after the cause of action arose. Each party waives +its rights to a jury trial in any resulting litigation.</span> </p> + +<p class="MsoNormal"><!--[if !supportEmptyParas]--> <!--[endif]--><o:p></o:p></p> + +</div> + +</body></html>
\ No newline at end of file diff --git a/plugins/org.eclipse.net4j.tests/plugin.xml b/plugins/org.eclipse.net4j.tests/plugin.xml new file mode 100644 index 0000000000..8e49b52120 --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/plugin.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.0"?> +<plugin> + +</plugin> diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SocketTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SocketTest.java new file mode 100644 index 0000000000..0f7dea62a9 --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SocketTest.java @@ -0,0 +1,286 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + *******************************************************************************/ +package org.eclipse.net4j.test; + + +import org.eclipse.net4j.core.Channel; +import org.eclipse.net4j.core.Connector; +import org.eclipse.net4j.core.Request; +import org.eclipse.net4j.test.protocol.Net4jTestProtocol; +import org.eclipse.net4j.test.protocol.TestRequest; +import org.eclipse.net4j.util.thread.DeadlockDetector; + +import junit.framework.TestCase; + + +public class SocketTest extends TestCase +{ + private static final boolean PERFORMANCE = true; + + // ValueHelper.sizeOf(VALUES) --> 363 Bytes + private static final Object[] VALUES = { 1, 2, 3, 4, 5, 6, 7, 8, 9, "A rose is a rose is a...", + 1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 9.9, "Eclipse 3", 'a', 'b', 'c', 'd', 'e', 'f', 'g', + 1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f, 9f, "Net4j: An extensible signalling framework", true, false}; + + private TestContainer serverContainer; + + private TestContainer[] clientContainers; + + private int workers; + + private Exception exception; + + private Thread deadlockDetector; + + // static + // { + // System.out.println(ValueHelper.sizeOf(VALUES)); + // } + + public SocketTest(String name) + { + super(name); + } + + protected void setUp() throws Exception + { + super.setUp(); + workers = 0; + exception = null; + + if (DeadlockDetector.DETECTION) + { + deadlockDetector = new Thread("DeadlockDetector") + { + @Override + public void run() + { + for (;;) + { + try + { + Thread.sleep(5000); + } + catch (InterruptedException ex) + { + return; + } + DeadlockDetector.dump(); + } + } + }; + deadlockDetector.setDaemon(true); + deadlockDetector.start(); + } + } + + protected void tearDown() throws Exception + { + if (clientContainers != null) + { + for (int i = 0; i < clientContainers.length; i++) + { + if (clientContainers[i] != null) + { + clientContainers[i].stop(); + clientContainers[i] = null; + } + } + } + + if (serverContainer != null) + { + serverContainer.stop(); + serverContainer = null; + } + + // if (DeadlockDetector.DETECTION) + // { + // DeadlockDetector.dump(); + // } + + if (deadlockDetector != null) + { + deadlockDetector.interrupt(); + deadlockDetector = null; + } + + workers = 0; + exception = null; + super.tearDown(); + } + + protected void startContainers(int numberOfClients) + { + serverContainer = new TestContainer.SocketServer(); + clientContainers = new TestContainer.SocketClient[numberOfClients]; + for (int i = 0; i < numberOfClients; i++) + { + clientContainers[i] = new TestContainer.SocketClient("client" + + (numberOfClients == 1 ? "" : "" + (i + 1))); + } + } + + protected void joinWorkers() throws InterruptedException, Exception + { + for (;;) + { + Thread.sleep(2000); + synchronized (this) + { + if (workers == 0) break; + if (exception != null) + { + exception.printStackTrace(); + throw exception; + } + } + } + } + + public static void echo(Channel channel, Object[] values) + { + Request request = new TestRequest(values); + Object[] echo = (Object[]) channel.transmit(request); + assertEquals(values, echo); + } + + public static void assertEquals(Object[] values, Object[] echo) + { + assertEquals(values.length, echo.length); + for (int i = 0; i < values.length; i++) + { + assertEquals(values[i], echo[i]); + } + } + + + public class ChannelWorker extends Thread + { + private Channel channel; + + private Object[] values; + + private int numberOfRequests; + + public ChannelWorker(Connector connector, Object[] values, int numberOfRequests) + { + channel = connector.addChannel(Net4jTestProtocol.PROTOCOL_NAME); + this.values = values; + this.numberOfRequests = numberOfRequests; + + synchronized (SocketTest.this) + { + workers++; + } + + start(); + } + + @Override + public void run() + { + for (int i = 0; i < numberOfRequests; i++) + { + try + { + if (exception != null) return; + echo(channel, values); + } + catch (Exception ex) + { + exception = ex; + } + } + + synchronized (SocketTest.this) + { + workers--; + } + } + } + + public void stressTest() throws Exception + { + final int NUMBER_OF_CLIENTS = 4; + final int CHANNELS_PER_CLIENT = 4; + final int REQUESTS_PER_CHANNEL = 10000; + + startContainers(NUMBER_OF_CLIENTS); + long t0 = System.currentTimeMillis(); + for (int i = 0; i < NUMBER_OF_CLIENTS; i++) + { + for (int j = 0; j < CHANNELS_PER_CLIENT; j++) + { + new ChannelWorker(clientContainers[i].getConnector(), VALUES, REQUESTS_PER_CHANNEL); + Thread.sleep(200); + } + } + + joinWorkers(); + long t1 = System.currentTimeMillis(); + System.out.println("Duration: " + (t1 - t0) + " millisec"); + } + + public void performanceTest() throws Exception + { + startContainers(1); + Connector connector = clientContainers[0].getConnector(); + Channel channel = connector.addChannel(Net4jTestProtocol.PROTOCOL_NAME); + + double total = 0.0; + for (int i = 1; i <= 1000; i++) + { + long t0 = System.nanoTime(); + echo(channel, VALUES); + long t1 = System.nanoTime(); + + double duration = t1 - t0; + total += duration; + System.out.println("Run " + i + ": " + (duration / 1000000d)); + } + + System.out.println("Average: " + (total / 1000000000d) + " millisec"); + } + + public final void testSocket() throws Exception + { + if (!PERFORMANCE) + { + stressTest(); + } + else + { + performanceTest(); + } + } + + public final void testEmbedded() throws Exception + { + serverContainer = new TestContainer.Embedded(); + Connector connector = serverContainer.getConnector(); + Channel channel = connector.addChannel(Net4jTestProtocol.PROTOCOL_NAME); + + double total = 0.0; + for (int i = 1; i <= 1000; i++) + { + long t0 = System.nanoTime(); + echo(channel, VALUES); + long t1 = System.nanoTime(); + + double duration = t1 - t0; + total += duration; + System.out.println("Run " + i + ": " + (duration / 1000000d)); + } + + System.out.println("Average: " + (total / 1000000000d) + " millisec"); + } +} diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TestContainer.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TestContainer.java new file mode 100644 index 0000000000..ff864c0033 --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TestContainer.java @@ -0,0 +1,73 @@ +package org.eclipse.net4j.test; + + +import org.eclipse.net4j.core.Connector; +import org.eclipse.net4j.spring.Container; +import org.eclipse.net4j.spring.impl.ContainerImpl; + +import org.springframework.beans.BeansException; + + +public class TestContainer extends ContainerImpl +{ + private Connector connector; + + protected TestContainer(String baseResourcePath, String configLocation, String name, + Container parent, ClassLoader classLoader) throws BeansException + { + super(baseResourcePath, configLocation, name, parent, classLoader); + } + + protected TestContainer(String baseResourcePath, String[] configLocations, String name, + Container parent, ClassLoader classLoader) throws BeansException + { + super(baseResourcePath, configLocations, name, parent, classLoader); + } + + public Connector getConnector() + { + if (connector == null) + { + connector = (Connector) getBean("connector"); + + try + { + connector.start(); + } + catch (Exception ex) + { + ex.printStackTrace(); + return null; + } + } + + return connector; + } + + + public static class SocketClient extends TestContainer + { + public SocketClient(String name) throws BeansException + { + super(".", "META-INF/socketClient.xml", name, null, null); + } + } + + + public static class SocketServer extends TestContainer + { + public SocketServer() throws BeansException + { + super(".", "META-INF/socketServer.xml", "server", null, null); + } + } + + + public static class Embedded extends TestContainer + { + public Embedded() throws BeansException + { + super(".", "META-INF/embedded.xml", "embedded", null, null); + } + } +} diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/old/ChannelImplTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/old/ChannelImplTest.java new file mode 100644 index 0000000000..ec86e2f6bb --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/old/ChannelImplTest.java @@ -0,0 +1,763 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + *******************************************************************************/ +package org.eclipse.net4j.test; + + +import org.eclipse.net4j.core.Connector; +import org.eclipse.net4j.core.Executor; +import org.eclipse.net4j.core.Multiplexer; +import org.eclipse.net4j.core.Protocol; +import org.eclipse.net4j.core.impl.BufferImpl; +import org.eclipse.net4j.core.impl.ChannelImpl; +import org.eclipse.net4j.spring.Container; +import org.eclipse.net4j.spring.Service; +import org.eclipse.net4j.spring.ValidationException; +import org.eclipse.net4j.spring.impl.ContainerImpl; +import org.eclipse.net4j.test.util.BlockingDetector; +import org.eclipse.net4j.test.util.ServiceInvoker; +import org.eclipse.net4j.test.util.TestUtils; +import org.eclipse.net4j.util.ImplementationError; + +import org.easymock.MockControl; + +import java.util.Arrays; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.LinkedBlockingQueue; + +import junit.framework.TestCase; + + +public class ChannelImplTest extends TestCase +{ + protected static Container net4j = new ContainerImpl(null, (String[]) null, "net4j", null, null); + + protected ChannelImpl channel; + + protected Connector connectorMock; + + protected MockControl connectorMockControl; + + protected Executor dispatcherMock; + + protected MockControl dispatcherMockControl; + + protected Multiplexer multiplexerMock; + + protected MockControl multiplexerMockControl; + + protected Protocol protocolMock; + + protected MockControl protocolMockControl; + + /* + * @see TestCase#setUp() + */ + protected void setUp() throws Exception + { + super.setUp(); + init(); + } + + protected void init() + { + channel = new ChannelImpl(); + channel.setApplicationContext(net4j); + channel.setBeanName("channel"); + + connectorMockControl = MockControl.createControl(Connector.class); + connectorMock = (Connector) connectorMockControl.getMock(); + + dispatcherMockControl = MockControl.createControl(Executor.class); + dispatcherMock = (Executor) dispatcherMockControl.getMock(); + + multiplexerMockControl = MockControl.createControl(Multiplexer.class); + multiplexerMock = (Multiplexer) multiplexerMockControl.getMock(); + + protocolMockControl = MockControl.createControl(Protocol.class); + protocolMock = (Protocol) protocolMockControl.getMock(); + } + + protected void start() + { + connectorMockControl.replay(); + dispatcherMockControl.replay(); + multiplexerMockControl.replay(); + protocolMockControl.replay(); + } + + protected void verify() + { + protocolMockControl.verify(); + multiplexerMockControl.verify(); + dispatcherMockControl.verify(); + connectorMockControl.verify(); + } + + protected BufferImpl createBuffer(int capacity, int level, boolean flipped) + { + BufferImpl buffer = new BufferImpl(capacity); + + if (level > 0) + { + buffer.put(Byte.MIN_VALUE); // for sequence-error-detection + + for (int i = 1; i < level; i++) + { + buffer.put((byte) (i % 256)); + } + } + + if (flipped) + { + buffer.flip(); + } + + return buffer; + } + + protected BlockingQueue<BufferImpl> createBufferQueue(int[] capacities, int[] levels, + boolean flipped) + { + BlockingQueue<BufferImpl> queue = new LinkedBlockingQueue(); + + for (int i = 0; i < levels.length; i++) + { + queue.add(createBuffer(capacities[i], levels[i], flipped)); + } + + return queue; + } + + protected BlockingQueue<BufferImpl> createBufferQueue(int capacity, int[] levels, boolean flipped) + { + int[] capacities = new int[levels.length]; + Arrays.fill(capacities, capacity); + return createBufferQueue(capacities, levels, flipped); + } + + protected BlockingQueue<BufferImpl> createBufferQueue(int capacity, int level, boolean flipped) + { + return createBufferQueue(new int[] { capacity}, new int[] { level}, flipped); + } + + public final void testSetGetChannelIndex() + { + channel.setChannelIndex((short) 4711); + short result = channel.getChannelIndex(); + assertEquals("getChannelIndex returns the value of setChannelIndex", 4711, result); + + channel.setChannelIndex((short) 0); + result = channel.getChannelIndex(); + assertEquals("getChannelIndex returns 0", 0, result); + } + + public final void testSetGetConnector() + { + channel.setConnector(connectorMock); + Connector result = channel.getConnector(); + assertEquals("getConnector returns the value of setConnector", connectorMock, result); + + channel.setConnector(null); + result = channel.getConnector(); + assertNull("getConnector returns null", result); + } + + public final void testSetGetDispatcher() + { + channel.setDispatcher(dispatcherMock); + Executor result = channel.getDispatcher(); + assertEquals("getDispatcher returns the value of setDispatcher", dispatcherMock, result); + + channel.setDispatcher(null); + result = channel.getDispatcher(); + assertNull("getDispatcher returns null", result); + } + + public final void testSetGetMultiplexer() + { + channel.setMultiplexer(multiplexerMock); + Multiplexer result = channel.getMultiplexer(); + assertEquals("getBufferPool returns the value of setMultiplexer", multiplexerMock, result); + + channel.setMultiplexer(null); + result = channel.getMultiplexer(); + assertNull("getMultiplexer returns null", result); + } + + public final void testSetGetProtocol() + { + channel.setProtocol(protocolMock); + Protocol result = channel.getProtocol(); + assertEquals("getProtocol returns the value of setProtocol", protocolMock, result); + + channel.setProtocol(null); + result = channel.getProtocol(); + assertNull("getProtocol returns null", result); + } + + public final void testSetGetInternalReturnValue() + { + Object returnValue = new Object(); + + channel.internalSetReturnValue(returnValue); + Object result = channel.testGetReturnValue(); + assertEquals("testGetReturnValue returns the value of internalSetReturnValue", returnValue, + result); + + channel.internalSetReturnValue(null); + result = channel.testGetReturnValue(); + assertNull("testGetReturnValue returns null", result); + } + + public final void testSetGetProtocolData() + { + Object protocolData = new Object(); + + channel.setProtocolData(protocolData); + Object result = channel.getProtocolData(); + assertEquals("getProtocolData returns the value of setProtocolData", protocolData, result); + + channel.setProtocolData(null); + result = channel.getProtocolData(); + assertNull("getProtocolData returns null", result); + } + + public final void testServiceGuards() + { + new ServiceInvoker(channel) + { + protected void invokeService(Service bean) throws Exception + { + ((ChannelImpl) bean).handleTransmission(); + } + }; + + new ServiceInvoker(channel) + { + protected void invokeService(Service bean) throws Exception + { + ((ChannelImpl) bean).transmit(null); + } + }; + + new ServiceInvoker(channel) + { + protected void invokeService(Service bean) throws Exception + { + ((ChannelImpl) bean).transmit(null); + } + }; + } + + public final void testValidate() + { + channel.setDispatcher(dispatcherMock); + channel.setMultiplexer(multiplexerMock); + channel.testValidate(); + + try + { + channel.setDispatcher(null); + channel.setMultiplexer(multiplexerMock); + channel.testValidate(); + fail("expected ValidationException"); + } + catch (ValidationException expected) + { + TestUtils.assertContains(expected, "dispatcher"); + } + + try + { + channel.setDispatcher(dispatcherMock); + channel.setMultiplexer(null); + channel.testValidate(); + fail("expected ValidationException"); + } + catch (ValidationException expected) + { + TestUtils.assertContains(expected, "multiplexer"); + } + } + + /** + * PRECONDITION: dataSize == 0 + * + * EXPECTATION: doesn't block; + * throws IllegalArgumentException + */ + public final void testEnsureReceiverBuffer1() throws Throwable + { + BlockingQueue<BufferImpl> receiverQueue = new LinkedBlockingQueue(); + channel.testSetReceiverQueue(receiverQueue); + + start(); + try + { + new BlockingDetector(channel, receiverQueue, false) + { + protected void blockableOperation(Object target) throws Exception + { + ((ChannelImpl) target).testEnsureReceiverBufferData(0); + } + }; + fail("IllegalArgumentException expected"); + } + catch (IllegalArgumentException expected) + { + TestUtils.assertContains(expected, "dataSize"); + } + verify(); + } + + /** + * PRECONDITION: dataSize < 0 + * + * EXPECTATION: doesn't block; + * throws IllegalArgumentException + */ + public final void testEnsureReceiverBuffer2() throws Throwable + { + BlockingQueue<BufferImpl> receiverQueue = new LinkedBlockingQueue(); + channel.testSetReceiverQueue(receiverQueue); + + start(); + try + { + new BlockingDetector(channel, receiverQueue, false) + { + protected void blockableOperation(Object target) throws Exception + { + ((ChannelImpl) target).testEnsureReceiverBufferData(-1); + } + }; + fail("IllegalArgumentException expected"); + } + catch (IllegalArgumentException expected) + { + TestUtils.assertContains(expected, "dataSize"); + } + verify(); + } + + /** + * PRECONDITION: receiverBuffer exists; + * 0 < level < dataSize + * + * EXPECTATION: doesn't block; + * throws ImplementationError + */ + public final void testEnsureReceiverBuffer3() throws Throwable + { + BufferImpl receiverBuffer = createBuffer(20, 3, true); + channel.testSetReceiverBuffer(receiverBuffer); + + BlockingQueue<BufferImpl> receiverQueue = new LinkedBlockingQueue(); + channel.testSetReceiverQueue(receiverQueue); + + start(); + try + { + new BlockingDetector(channel, receiverQueue, false) + { + protected void blockableOperation(Object target) throws Exception + { + ((ChannelImpl) target).testEnsureReceiverBufferData(7); + } + }; + fail("ImplementationError expected"); + } + catch (ImplementationError expected) + { + TestUtils.assertContains(expected, "receiverBuffer level too low"); + } + verify(); + } + + /** + * PRECONDITION: receiverBuffer exists; + * 0 < dataSize < level + * + * EXPECTATION: doesn't block; + * receiverBuffer not returned to bufferPool + */ + public final void testEnsureReceiverBuffer4() throws Throwable + { + BufferImpl receiverBuffer = createBuffer(20, 12, true); + channel.testSetReceiverBuffer(receiverBuffer); + + BlockingQueue<BufferImpl> receiverQueue = new LinkedBlockingQueue(); + channel.testSetReceiverQueue(receiverQueue); + + start(); + new BlockingDetector(channel, receiverQueue, false) + { + protected void blockableOperation(Object target) throws Exception + { + ((ChannelImpl) target).testEnsureReceiverBufferData(7); + } + }; + verify(); + } + + /** + * PRECONDITION: receiverBuffer exists; + * 0 < dataSize == level + * + * EXPECTATION: doesn't block; + * receiverBuffer not returned to bufferPool + */ + public final void testEnsureReceiverBuffer5() throws Throwable + { + BufferImpl receiverBuffer = createBuffer(20, 12, true); + channel.testSetReceiverBuffer(receiverBuffer); + + BlockingQueue<BufferImpl> receiverQueue = new LinkedBlockingQueue(); + channel.testSetReceiverQueue(receiverQueue); + + start(); + new BlockingDetector(channel, receiverQueue, false) + { + protected void blockableOperation(Object target) throws Exception + { + ((ChannelImpl) target).testEnsureReceiverBufferData(12); + } + }; + verify(); + } + + /** + * PRECONDITION: receiverBuffer exists; + * 0 == level < dataSize; + * receiverQueue empty + * + * EXPECTATION: receiverBuffer returned to bufferPool; + * blocks + */ + public final void testEnsureReceiverBuffer6() throws Throwable + { + BufferImpl receiverBuffer = createBuffer(20, 0, true); + channel.testSetReceiverBuffer(receiverBuffer); + + BlockingQueue<BufferImpl> receiverQueue = new LinkedBlockingQueue(); + channel.testSetReceiverQueue(receiverQueue); + + connectorMock.releaseBuffer(receiverBuffer); + channel.setConnector(connectorMock); + + start(); + new BlockingDetector(channel, receiverQueue, true) + { + protected void blockableOperation(Object target) throws Exception + { + ((ChannelImpl) target).testEnsureReceiverBufferData(7); + } + }; + verify(); + } + + /** + * PRECONDITION: receiverBuffer exists; + * 0 == level < dataSize; + * receiverQueue has too small buffer + * + * EXPECTATION: doesn't block; + * receiverBuffer returned to bufferPool + * throws ImplementationError + */ + public final void testEnsureReceiverBuffer7() throws Throwable + { + BufferImpl receiverBuffer = createBuffer(20, 0, true); + channel.testSetReceiverBuffer(receiverBuffer); + + BlockingQueue<BufferImpl> receiverQueue = createBufferQueue(20, 5, true); + channel.testSetReceiverQueue(receiverQueue); + + connectorMock.releaseBuffer(receiverBuffer); + channel.setConnector(connectorMock); + + start(); + try + { + new BlockingDetector(channel, receiverQueue, false) + { + protected void blockableOperation(Object target) throws Exception + { + ((ChannelImpl) target).testEnsureReceiverBufferData(7); + } + }; + fail("ImplementationError expected"); + } + catch (ImplementationError expected) + { + TestUtils.assertContains(expected, "receiverBuffer level too low"); + } + verify(); + } + + /** + * PRECONDITION: receiverBuffer exists; + * 0 == level < dataSize; + * receiverQueue has exact buffer + * + * EXPECTATION: doesn't block; + * receiverBuffer returned to bufferPool + */ + public final void testEnsureReceiverBuffer8() throws Throwable + { + BufferImpl receiverBuffer = createBuffer(20, 0, true); + channel.testSetReceiverBuffer(receiverBuffer); + + BlockingQueue<BufferImpl> receiverQueue = createBufferQueue(20, 7, true); + channel.testSetReceiverQueue(receiverQueue); + + connectorMock.releaseBuffer(receiverBuffer); + channel.setConnector(connectorMock); + + start(); + new BlockingDetector(channel, receiverQueue, false) + { + protected void blockableOperation(Object target) throws Exception + { + ((ChannelImpl) target).testEnsureReceiverBufferData(7); + } + }; + verify(); + } + + /** + * PRECONDITION: receiverBuffer exists; + * 0 == level < dataSize; + * receiverQueue has too big buffer + * + * EXPECTATION: doesn't block; + * receiverBuffer returned to bufferPool + */ + public final void testEnsureReceiverBuffer9() throws Throwable + { + BufferImpl receiverBuffer = createBuffer(20, 0, true); + channel.testSetReceiverBuffer(receiverBuffer); + + BlockingQueue<BufferImpl> receiverQueue = createBufferQueue(20, 12, true); + channel.testSetReceiverQueue(receiverQueue); + + connectorMock.releaseBuffer(receiverBuffer); + channel.setConnector(connectorMock); + + start(); + new BlockingDetector(channel, receiverQueue, false) + { + protected void blockableOperation(Object target) throws Exception + { + ((ChannelImpl) target).testEnsureReceiverBufferData(7); + } + }; + verify(); + } + + /** + * PRECONDITION: transmitterBuffer doesn't exists + * + * EXPECTATION: throws ImplementationError + */ + public final void testFlush1() + { + start(); + try + { + channel.flush(); + fail("ImplementationError expected"); + } + catch (ImplementationError expected) + { + TestUtils.assertContains(expected, "transmitterBuffer must exist"); + } + verify(); + } + + /** + * PRECONDITION: transmitterBuffer exists; + * level == 0 + * + * EXPECTATION: immediately returns + */ + public final void testFlush2() + { + BufferImpl transmitterBuffer = createBuffer(20, 0, false); + channel.testSetTransmitterBuffer(transmitterBuffer); + + start(); + channel.flush(); + verify(); + } + + /** + * PRECONDITION: transmitterBuffer exists; + * level > 0 + * + * EXPECTATION: transmitterBuffer is flipped; + * appended to transmitterQueue; + * channel is scheduled for transmission; + * a new transmitterBuffer is fetched from the bufferPool; + * the new transmitterBuffer is empty + */ + public final void testFlush3() + { + BufferImpl transmitterBuffer = createBuffer(20, 7, false); + channel.testSetTransmitterBuffer(transmitterBuffer); + + BlockingQueue<BufferImpl> transmitterQueue = new LinkedBlockingQueue(); + channel.testSetTransmitterQueue(transmitterQueue); + + multiplexerMock.schedule(channel); + channel.setMultiplexer(multiplexerMock); + + connectorMockControl.expectAndReturn(connectorMock.provideBuffer(), createBuffer(10, 10, true)); + channel.setConnector(connectorMock); + + start(); + channel.flush(); + verify(); + + assertTrue("transmitterBuffer is flipped", transmitterBuffer.position() == 0); + assertTrue("transmitterBuffer is in transmitterQueue", + transmitterQueue.peek() == transmitterBuffer); + assertNotSame("a new transmitterBuffer is expected", transmitterBuffer, channel + .testGetTransmitterBuffer()); + assertTrue("the new transmitterBuffer must be empty", channel.testGetTransmitterBuffer() + .position() < channel.testGetTransmitterBuffer().limit()); // TODO test emptyness + } + + // public final void testReceiveBoolean() + // { + // throw new ImplementationError("Implement receiveBoolean()"); + // } + // + // public final void testReceiveByte() + // { + // throw new ImplementationError("Implement receiveByte()"); + // } + // + // public final void testReceiveChar() + // { + // throw new ImplementationError("Implement receiveChar()"); + // } + // + // public final void testReceiveDouble() + // { + // throw new ImplementationError("Implement receiveDouble()"); + // } + // + // public final void testReceiveFloat() + // { + // throw new ImplementationError("Implement receiveFloat()"); + // } + // + // public final void testReceiveInt() + // { + // throw new ImplementationError("Implement receiveInt()"); + // } + // + // public final void testReceiveLong() + // { + // throw new ImplementationError("Implement receiveLong()"); + // } + // + // public final void testReceiveObject() + // { + // throw new ImplementationError("Implement receiveObject()"); + // } + // + // public final void testReceiveShort() + // { + // throw new ImplementationError("Implement receiveShort()"); + // } + // + // public final void testReceiveString() + // { + // throw new ImplementationError("Implement receiveString()"); + // } + // + // public final void testTransmitBoolean() + // { + // throw new ImplementationError("Implement transmitBoolean()"); + // } + // + // public final void testTransmitByte() + // { + // throw new ImplementationError("Implement transmitByte()"); + // } + // + // public final void testTransmitChar() + // { + // throw new ImplementationError("Implement transmitChar()"); + // } + // + // public final void testTransmitDouble() + // { + // throw new ImplementationError("Implement transmitDouble()"); + // } + // + // public final void testTransmitFloat() + // { + // throw new ImplementationError("Implement transmitFloat()"); + // } + // + // public final void testTransmitInt() + // { + // throw new ImplementationError("Implement transmitInt()"); + // } + // + // public final void testTransmitLong() + // { + // throw new ImplementationError("Implement transmitLong()"); + // } + // + // public final void testTransmitObject() + // { + // throw new ImplementationError("Implement transmitObject()"); + // } + // + // public final void testTransmitShort() + // { + // throw new ImplementationError("Implement transmitShort()"); + // } + // + // public final void testTransmitString() + // { + // throw new ImplementationError("Implement transmitString()"); + // } + // + // public final void testNotifyFinished() + // { + // throw new ImplementationError("Implement notifyFinished()"); + // } + // + // public final void testNotifyData() + // { + // throw new ImplementationError("Implement notifyData()"); + // } + // + // public final void testNotification() + // { + // throw new ImplementationError("Implement notification()"); + // } + // + // public final void testRequest() + // { + // throw new ImplementationError("Implement request()"); + // } + // + // public final void testHandleTransmission() + // { + // throw new ImplementationError("Implement handleTransmission()"); + // } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/old/PoolTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/old/PoolTest.java new file mode 100644 index 0000000000..caf9f07114 --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/old/PoolTest.java @@ -0,0 +1,724 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + *******************************************************************************/ +package org.eclipse.net4j.test; + + +import org.eclipse.net4j.core.impl.AbstractPool; +import org.eclipse.net4j.spring.Container; +import org.eclipse.net4j.spring.impl.ContainerImpl; + +import junit.framework.TestCase; + + +public class PoolTest extends TestCase +{ + protected class TestPooled + { + protected Object key; + + public TestPooled(Object key) + { + this.key = key; + } + + public Object getKey() + { + return key; + } + } + + + protected class TestPool extends AbstractPool + { + protected Class doGetPooledClass(Object key) + { + return TestPooled.class; + } + + protected Object newPooled(Object key) throws Exception + { + return new TestPooled(key); + } + } + + protected static Container net4j = new ContainerImpl(null, (String[]) null, "net4j", null, null); + + protected TestPool pool; + + // protected Pool bufferPoolMock; + // + // protected MockControl bufferPoolMockControl; + // + // protected Connector connectorMock; + // + // protected MockControl connectorMockControl; + // + // protected Executor dispatcherMock; + // + // protected MockControl dispatcherMockControl; + // + // protected Multiplexer multiplexerMock; + // + // protected MockControl multiplexerMockControl; + // + // protected Protocol protocolMock; + // + // protected MockControl protocolMockControl; + + /* + * @see TestCase#setUp() + */ + protected void setUp() throws Exception + { + super.setUp(); + init(); + } + + protected void init() + { + pool = new TestPool(); + pool.setApplicationContext(net4j); + pool.setBeanName("testPool"); + + // bufferPoolMockControl = MockControl.createControl(Pool.class); + // bufferPoolMock = (Pool) bufferPoolMockControl.getMock(); + // + // connectorMockControl = MockControl.createControl(Connector.class); + // connectorMock = (Connector) connectorMockControl.getMock(); + // + // dispatcherMockControl = MockControl.createControl(Executor.class); + // dispatcherMock = (Executor) dispatcherMockControl.getMock(); + // + // multiplexerMockControl = MockControl.createControl(Multiplexer.class); + // multiplexerMock = (Multiplexer) multiplexerMockControl.getMock(); + // + // protocolMockControl = MockControl.createControl(Protocol.class); + // protocolMock = (Protocol) protocolMockControl.getMock(); + } + + protected void start() + { + // bufferPoolMockControl.replay(); + // connectorMockControl.replay(); + // dispatcherMockControl.replay(); + // multiplexerMockControl.replay(); + // protocolMockControl.replay(); + } + + protected void verify() + { + // protocolMockControl.verify(); + // multiplexerMockControl.verify(); + // dispatcherMockControl.verify(); + // connectorMockControl.verify(); + // bufferPoolMockControl.verify(); + } + + // protected BufferImpl createBuffer(int capacity, int level, boolean flipped) + // { + // BufferImpl buffer = new BufferImpl(capacity); + // + // if (level > 0) + // { + // buffer.put(Byte.MIN_VALUE); // for sequence-error-detection + // + // for (int i = 1; i < level; i++) + // { + // buffer.put((byte) (i % 256)); + // } + // } + // + // if (flipped) + // { + // buffer.flip(); + // } + // + // return buffer; + // } + // + // protected NodeCachingLinkedList createBufferQueue(int[] capacities, int[] levels, boolean flipped) + // { + // NodeCachingLinkedList queue = new NodeCachingLinkedList(); + // + // for (int i = 0; i < levels.length; i++) + // { + // queue.add(createBuffer(capacities[i], levels[i], flipped)); + // } + // + // return queue; + // } + // + // protected NodeCachingLinkedList createBufferQueue(int capacity, int[] levels, boolean flipped) + // { + // int[] capacities = new int[levels.length]; + // Arrays.fill(capacities, capacity); + // return createBufferQueue(capacities, levels, flipped); + // } + // + // protected NodeCachingLinkedList createBufferQueue(int capacity, int level, boolean flipped) + // { + // return createBufferQueue(new int[] { capacity}, new int[] { level}, flipped); + // } + + public final void testGet() + { + pool.setMinimumCapacity(0); + pool.setMaximumCapacity(10); + + final int COUNT = 20; + Object[] pooled = new Object[COUNT]; + + for (int i = COUNT - 1; i >= 0; --i) + { + pooled[i] = pool.get(); + assertNotNull(pooled[i]); + assertEquals(0, pool.getLevel()); + } + + for (int i = 0; i < COUNT; i++) + { + assertEquals(i, pool.getLevel()); + pool.put(pooled[i]); + assertEquals(i + 1, pool.getLevel()); + } + + for (int i = COUNT - 1; i >= 0; --i) + { + assertEquals(i + 1, pool.getLevel()); + pooled[i] = pool.get(); + assertNotNull(pooled[i]); + assertEquals(i, pool.getLevel()); + } + + } + + // public final void testSetGetChannelIndex() + // { + // pool.setChannelId((short) 4711); + // short result = pool.getChannelId(); + // assertEquals("getChannelId returns the value of setChannelId", 4711, result); + // + // pool.setChannelId((short) 0); + // result = pool.getChannelId(); + // assertEquals("getChannelId returns 0", 0, result); + // } + // + // public final void testSetGetBufferPool() + // { + // pool.setBufferPool(bufferPoolMock); + // Pool result = pool.getBufferPool(); + // assertEquals("getBufferPool returns the value of setBufferPool", bufferPoolMock, result); + // + // pool.setBufferPool(null); + // result = pool.getBufferPool(); + // assertNull("getBufferPool returns null", result); + // } + // + // public final void testSetGetConnector() + // { + // pool.setConnector(connectorMock); + // Connector result = pool.getConnector(); + // assertEquals("getConnector returns the value of setConnector", connectorMock, result); + // + // pool.setConnector(null); + // result = pool.getConnector(); + // assertNull("getConnector returns null", result); + // } + // + // public final void testSetGetDispatcher() + // { + // pool.setDispatcher(dispatcherMock); + // Executor result = pool.getDispatcher(); + // assertEquals("getDispatcher returns the value of setDispatcher", dispatcherMock, result); + // + // pool.setDispatcher(null); + // result = pool.getDispatcher(); + // assertNull("getDispatcher returns null", result); + // } + // + // public final void testSetGetMultiplexer() + // { + // pool.setMultiplexer(multiplexerMock); + // Multiplexer result = pool.getMultiplexer(); + // assertEquals("getBufferPool returns the value of setMultiplexer", multiplexerMock, result); + // + // pool.setMultiplexer(null); + // result = pool.getMultiplexer(); + // assertNull("getMultiplexer returns null", result); + // } + // + // public final void testSetGetProtocol() + // { + // pool.setProtocol(protocolMock); + // Protocol result = pool.getProtocol(); + // assertEquals("getProtocol returns the value of setProtocol", protocolMock, result); + // + // pool.setProtocol(null); + // result = pool.getProtocol(); + // assertNull("getProtocol returns null", result); + // } + // + // public final void testSetGetInternalReturnValue() + // { + // Object returnValue = new Object(); + // + // pool.internalSetReturnValue(returnValue); + // Object result = pool.testGetReturnValue(); + // assertEquals("testGetReturnValue returns the value of internalSetReturnValue", returnValue, + // result); + // + // pool.internalSetReturnValue(null); + // result = pool.testGetReturnValue(); + // assertNull("testGetReturnValue returns null", result); + // } + // + // public final void testSetGetProtocolData() + // { + // Object protocolData = new Object(); + // + // pool.setProtocolData(protocolData); + // Object result = pool.getProtocolData(); + // assertEquals("getProtocolData returns the value of setProtocolData", protocolData, result); + // + // pool.setProtocolData(null); + // result = pool.getProtocolData(); + // assertNull("getProtocolData returns null", result); + // } + // + // public final void testServiceGuards() + // { + // new ServiceInvoker(pool) + // { + // protected void invokeService(DefaultBean bean) throws Exception + // { + // ((DefaultChannel) bean).handleTransmission(); + // } + // }; + // + // new ServiceInvoker(pool) + // { + // protected void invokeService(DefaultBean bean) throws Exception + // { + // ((DefaultChannel) bean).notification(null); + // } + // }; + // + // new ServiceInvoker(pool) + // { + // protected void invokeService(DefaultBean bean) throws Exception + // { + // ((DefaultChannel) bean).request(null); + // } + // }; + // } + // + // public final void testValidate() + // { + // pool.setBufferPool(bufferPoolMock); + // pool.setDispatcher(dispatcherMock); + // pool.setMultiplexer(multiplexerMock); + // pool.testValidate(); + // + // try + // { + // pool.setBufferPool(null); + // pool.setDispatcher(dispatcherMock); + // pool.setMultiplexer(multiplexerMock); + // pool.testValidate(); + // fail("expected ValidationException"); + // } + // catch (ValidationException expected) + // { + // TestUtils.assertContains(expected, "bufferPool"); + // } + // + // try + // { + // pool.setBufferPool(bufferPoolMock); + // pool.setDispatcher(null); + // pool.setMultiplexer(multiplexerMock); + // pool.testValidate(); + // fail("expected ValidationException"); + // } + // catch (ValidationException expected) + // { + // TestUtils.assertContains(expected, "dispatcher"); + // } + // + // try + // { + // pool.setBufferPool(bufferPoolMock); + // pool.setDispatcher(dispatcherMock); + // pool.setMultiplexer(null); + // pool.testValidate(); + // fail("expected ValidationException"); + // } + // catch (ValidationException expected) + // { + // TestUtils.assertContains(expected, "multiplexer"); + // } + // } + // + // /** + // * PRECONDITION: dataSize == 0 + // * + // * EXPECTATION: doesn't block; + // * throws IllegalArgumentException + // */ + // public final void testEnsureReceiverBuffer1() throws Throwable + // { + // NodeCachingLinkedList receiverQueue = new NodeCachingLinkedList(); + // pool.testSetReceiverQueue(receiverQueue); + // + // start(); + // try + // { + // new BlockingDetector(pool, receiverQueue, false) + // { + // protected void blockableOperation(Object target) throws Exception + // { + // ((DefaultChannel) target).testEnsureReceiverBuffer(0); + // } + // }; + // fail("IllegalArgumentException expected"); + // } + // catch (IllegalArgumentException expected) + // { + // TestUtils.assertContains(expected, "dataSize"); + // } + // verify(); + // } + // + // /** + // * PRECONDITION: dataSize < 0 + // * + // * EXPECTATION: doesn't block; + // * throws IllegalArgumentException + // */ + // public final void testEnsureReceiverBuffer2() throws Throwable + // { + // NodeCachingLinkedList receiverQueue = new NodeCachingLinkedList(); + // pool.testSetReceiverQueue(receiverQueue); + // + // start(); + // try + // { + // new BlockingDetector(pool, receiverQueue, false) + // { + // protected void blockableOperation(Object target) throws Exception + // { + // ((DefaultChannel) target).testEnsureReceiverBuffer(-1); + // } + // }; + // fail("IllegalArgumentException expected"); + // } + // catch (IllegalArgumentException expected) + // { + // TestUtils.assertContains(expected, "dataSize"); + // } + // verify(); + // } + // + // /** + // * PRECONDITION: receiverBuffer exists; + // * 0 < level < dataSize + // * + // * EXPECTATION: doesn't block; + // * throws ImplementationError + // */ + // public final void testEnsureReceiverBuffer3() throws Throwable + // { + // BufferImpl receiverBuffer = createBuffer(20, 3, true); + // pool.testSetReceiverBuffer(receiverBuffer); + // + // NodeCachingLinkedList receiverQueue = new NodeCachingLinkedList(); + // pool.testSetReceiverQueue(receiverQueue); + // + // pool.setBufferPool(bufferPoolMock); + // + // start(); + // try + // { + // new BlockingDetector(pool, receiverQueue, false) + // { + // protected void blockableOperation(Object target) throws Exception + // { + // ((DefaultChannel) target).testEnsureReceiverBuffer(7); + // } + // }; + // fail("ImplementationError expected"); + // } + // catch (ImplementationError expected) + // { + // TestUtils.assertContains(expected, "receiverBuffer level too low"); + // } + // verify(); + // } + // + // /** + // * PRECONDITION: receiverBuffer exists; + // * 0 < dataSize < level + // * + // * EXPECTATION: doesn't block; + // * receiverBuffer not returned to bufferPool + // */ + // public final void testEnsureReceiverBuffer4() throws Throwable + // { + // BufferImpl receiverBuffer = createBuffer(20, 12, true); + // pool.testSetReceiverBuffer(receiverBuffer); + // + // NodeCachingLinkedList receiverQueue = new NodeCachingLinkedList(); + // pool.testSetReceiverQueue(receiverQueue); + // + // pool.setBufferPool(bufferPoolMock); + // + // start(); + // new BlockingDetector(pool, receiverQueue, false) + // { + // protected void blockableOperation(Object target) throws Exception + // { + // ((DefaultChannel) target).testEnsureReceiverBuffer(7); + // } + // }; + // verify(); + // } + // + // /** + // * PRECONDITION: receiverBuffer exists; + // * 0 < dataSize == level + // * + // * EXPECTATION: doesn't block; + // * receiverBuffer not returned to bufferPool + // */ + // public final void testEnsureReceiverBuffer5() throws Throwable + // { + // BufferImpl receiverBuffer = createBuffer(20, 12, true); + // pool.testSetReceiverBuffer(receiverBuffer); + // + // NodeCachingLinkedList receiverQueue = new NodeCachingLinkedList(); + // pool.testSetReceiverQueue(receiverQueue); + // + // pool.setBufferPool(bufferPoolMock); + // + // start(); + // new BlockingDetector(pool, receiverQueue, false) + // { + // protected void blockableOperation(Object target) throws Exception + // { + // ((DefaultChannel) target).testEnsureReceiverBuffer(12); + // } + // }; + // verify(); + // } + // + // /** + // * PRECONDITION: receiverBuffer exists; + // * 0 == level < dataSize; + // * receiverQueue empty + // * + // * EXPECTATION: receiverBuffer returned to bufferPool; + // * blocks + // */ + // public final void testEnsureReceiverBuffer6() throws Throwable + // { + // BufferImpl receiverBuffer = createBuffer(20, 0, true); + // pool.testSetReceiverBuffer(receiverBuffer); + // + // NodeCachingLinkedList receiverQueue = new NodeCachingLinkedList(); + // pool.testSetReceiverQueue(receiverQueue); + // + // bufferPoolMock.put(new Integer(20), receiverBuffer); + // pool.setBufferPool(bufferPoolMock); + // + // start(); + // new BlockingDetector(pool, receiverQueue, true) + // { + // protected void blockableOperation(Object target) throws Exception + // { + // ((DefaultChannel) target).testEnsureReceiverBuffer(7); + // } + // }; + // verify(); + // } + // + // /** + // * PRECONDITION: receiverBuffer exists; + // * 0 == level < dataSize; + // * receiverQueue has too small buffer + // * + // * EXPECTATION: doesn't block; + // * receiverBuffer returned to bufferPool + // * throws ImplementationError + // */ + // public final void testEnsureReceiverBuffer7() throws Throwable + // { + // BufferImpl receiverBuffer = createBuffer(20, 0, true); + // pool.testSetReceiverBuffer(receiverBuffer); + // + // NodeCachingLinkedList receiverQueue = createBufferQueue(20, 5, true); + // pool.testSetReceiverQueue(receiverQueue); + // + // bufferPoolMock.put(new Integer(20), receiverBuffer); + // pool.setBufferPool(bufferPoolMock); + // + // start(); + // try + // { + // new BlockingDetector(pool, receiverQueue, false) + // { + // protected void blockableOperation(Object target) throws Exception + // { + // ((DefaultChannel) target).testEnsureReceiverBuffer(7); + // } + // }; + // fail("ImplementationError expected"); + // } + // catch (ImplementationError expected) + // { + // TestUtils.assertContains(expected, "receiverBuffer level too low"); + // } + // verify(); + // } + // + // /** + // * PRECONDITION: receiverBuffer exists; + // * 0 == level < dataSize; + // * receiverQueue has exact buffer + // * + // * EXPECTATION: doesn't block; + // * receiverBuffer returned to bufferPool + // */ + // public final void testEnsureReceiverBuffer8() throws Throwable + // { + // BufferImpl receiverBuffer = createBuffer(20, 0, true); + // pool.testSetReceiverBuffer(receiverBuffer); + // + // NodeCachingLinkedList receiverQueue = createBufferQueue(20, 7, true); + // pool.testSetReceiverQueue(receiverQueue); + // + // bufferPoolMock.put(new Integer(20), receiverBuffer); + // pool.setBufferPool(bufferPoolMock); + // + // start(); + // new BlockingDetector(pool, receiverQueue, false) + // { + // protected void blockableOperation(Object target) throws Exception + // { + // ((DefaultChannel) target).testEnsureReceiverBuffer(7); + // } + // }; + // verify(); + // } + // + // /** + // * PRECONDITION: receiverBuffer exists; + // * 0 == level < dataSize; + // * receiverQueue has too big buffer + // * + // * EXPECTATION: doesn't block; + // * receiverBuffer returned to bufferPool + // */ + // public final void testEnsureReceiverBuffer9() throws Throwable + // { + // BufferImpl receiverBuffer = createBuffer(20, 0, true); + // pool.testSetReceiverBuffer(receiverBuffer); + // + // NodeCachingLinkedList receiverQueue = createBufferQueue(20, 12, true); + // pool.testSetReceiverQueue(receiverQueue); + // + // bufferPoolMock.put(new Integer(20), receiverBuffer); + // pool.setBufferPool(bufferPoolMock); + // + // start(); + // new BlockingDetector(pool, receiverQueue, false) + // { + // protected void blockableOperation(Object target) throws Exception + // { + // ((DefaultChannel) target).testEnsureReceiverBuffer(7); + // } + // }; + // verify(); + // } + // + // /** + // * PRECONDITION: transmitterBuffer doesn't exists + // * + // * EXPECTATION: throws ImplementationError + // */ + // public final void testFlush1() + // { + // start(); + // try + // { + // pool.flush(); + // fail("ImplementationError expected"); + // } + // catch (ImplementationError expected) + // { + // TestUtils.assertContains(expected, "transmitterBuffer must exist"); + // } + // verify(); + // } + // + // /** + // * PRECONDITION: transmitterBuffer exists; + // * level == 0 + // * + // * EXPECTATION: immediately returns + // */ + // public final void testFlush2() + // { + // BufferImpl transmitterBuffer = createBuffer(20, 0, false); + // pool.testSetTransmitterBuffer(transmitterBuffer); + // + // start(); + // pool.flush(); + // verify(); + // } + // + // /** + // * PRECONDITION: transmitterBuffer exists; + // * level > 0 + // * + // * EXPECTATION: transmitterBuffer is flipped; + // * appended to transmitterQueue; + // * channel is scheduled for transmission; + // * a new transmitterBuffer is fetched from the bufferPool; + // * the new transmitterBuffer is empty + // */ + // public final void testFlush3() + // { + // BufferImpl transmitterBuffer = createBuffer(20, 7, false); + // pool.testSetTransmitterBuffer(transmitterBuffer); + // + // NodeCachingLinkedList transmitterQueue = new NodeCachingLinkedList(); + // pool.testSetTransmitterQueue(transmitterQueue); + // + // multiplexerMock.schedule(pool); + // pool.setMultiplexer(multiplexerMock); + // + // bufferPoolMockControl.expectAndReturn(bufferPoolMock.get(), createBuffer(10, 10, false)); + // pool.setBufferPool(bufferPoolMock); + // + // start(); + // pool.flush(); + // verify(); + // + // assertTrue("transmitterBuffer is flipped", transmitterBuffer.position() == 0); + // assertTrue("transmitterBuffer is in transmitterQueue", + // transmitterQueue.get(0) == transmitterBuffer); + // assertNotSame("a new transmitterBuffer is expected", transmitterBuffer, pool + // .testGetTransmitterBuffer()); + // assertTrue("the new transmitterBuffer must be empty", pool.testGetTransmitterBuffer() + // .position() == 0); + // + // } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/old/SelectorTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/old/SelectorTest.java new file mode 100644 index 0000000000..bdea7d8a69 --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/old/SelectorTest.java @@ -0,0 +1,64 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + *******************************************************************************/ +package org.eclipse.net4j.test; + + +import java.io.IOException; + +import java.nio.channels.ServerSocketChannel; +import java.nio.channels.SocketChannel; + +import java.net.InetAddress; +import java.net.InetSocketAddress; + +import junit.framework.TestCase; + + +public class SelectorTest extends TestCase +{ + protected class Server extends Thread + { + protected ServerSocketChannel serverChannel; + + public Server(String listen, int port) throws IOException + { + serverChannel = ServerSocketChannel.open(); + + InetSocketAddress addr = new InetSocketAddress(InetAddress.getByName(listen), port); + serverChannel.socket().bind(addr); + start(); + } + + public void run() + { + try + { + SocketChannel socketChannel = serverChannel.accept(); + socketChannel.configureBlocking(false); + readSocketChannel(socketChannel); + } + catch (Exception ex) + { + ex.printStackTrace(); + throw new RuntimeException(ex); + } + } + + public void readSocketChannel(SocketChannel socketChannel) + { + } + } + + public void testFlooding() + { + + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/old/SocketConnectorTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/old/SocketConnectorTest.java new file mode 100644 index 0000000000..5f77479267 --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/old/SocketConnectorTest.java @@ -0,0 +1,678 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + *******************************************************************************/ +package org.eclipse.net4j.test; + + +import org.eclipse.net4j.core.Connector; +import org.eclipse.net4j.core.DataListener; +import org.eclipse.net4j.core.impl.BufferImpl; +import org.eclipse.net4j.socket.impl.ActiveSocketConnectorImpl; +import org.eclipse.net4j.socket.impl.PassiveSocketConnectorImpl; +import org.eclipse.net4j.socket.impl.SocketAcceptorImpl; +import org.eclipse.net4j.spring.Container; +import org.eclipse.net4j.spring.impl.ContainerImpl; +import org.eclipse.net4j.test.SocketConnectorTest.TestAcceptor.PassiveTestConnector; + +import java.nio.channels.SocketChannel; + +import junit.framework.TestCase; + + +public class SocketConnectorTest extends TestCase +{ + protected static Container container = new ContainerImpl(null, (String[]) null, "container", + null, null); + + protected PassiveTestConnector slave; + + protected TestConnector client; + + protected DataListener slaveListener = new DataListener() + { + public void notifyData(BufferImpl data) + { + } + }; + + // protected Pool bufferPoolMock; + // + // protected MockControl bufferPoolMockControl; + + /* + * @see TestCase#setUp() + */ + protected void setUp() throws Exception + { + super.setUp(); + init(); + } + + protected void init() + { + client = new TestConnector(); + client.setApplicationContext(container); + client.setBeanName("client"); + + // bufferPoolMockControl = MockControl.createControl(Pool.class); + // bufferPoolMock = (Pool) bufferPoolMockControl.getMock(); + } + + protected void start() + { + // bufferPoolMockControl.replay(); + } + + protected void verify() + { + // bufferPoolMockControl.verify(); + } + + // protected BufferImpl createBuffer(int capacity, int level, boolean flipped) + // { + // BufferImpl buffer = new BufferImpl(capacity); + // + // if (level > 0) + // { + // buffer.put(Byte.MIN_VALUE); // for sequence-error-detection + // + // for (int i = 1; i < level; i++) + // { + // buffer.put((byte) (i % 256)); + // } + // } + // + // if (flipped) + // { + // buffer.flip(); + // } + // + // return buffer; + // } + // + // protected NodeCachingLinkedList createBufferQueue(int[] capacities, int[] levels, boolean flipped) + // { + // NodeCachingLinkedList queue = new NodeCachingLinkedList(); + // + // for (int i = 0; i < levels.length; i++) + // { + // queue.add(createBuffer(capacities[i], levels[i], flipped)); + // } + // + // return queue; + // } + // + // protected NodeCachingLinkedList createBufferQueue(int capacity, int[] levels, boolean flipped) + // { + // int[] capacities = new int[levels.length]; + // Arrays.fill(capacities, capacity); + // return createBufferQueue(capacities, levels, flipped); + // } + // + // protected NodeCachingLinkedList createBufferQueue(int capacity, int level, boolean flipped) + // { + // return createBufferQueue(new int[] { capacity}, new int[] { level}, flipped); + // } + + public final void testGet() + { + } + + + // public final void testSetGetChannelId() + // { + // pool.setChannelId((short) 4711); + // short result = pool.getChannelId(); + // assertEquals("getChannelId returns the value of setChannelId", 4711, result); + // + // pool.setChannelId((short) 0); + // result = pool.getChannelId(); + // assertEquals("getChannelId returns 0", 0, result); + // } + // + // public final void testSetGetBufferPool() + // { + // pool.setBufferPool(bufferPoolMock); + // Pool result = pool.getBufferPool(); + // assertEquals("getBufferPool returns the value of setBufferPool", bufferPoolMock, result); + // + // pool.setBufferPool(null); + // result = pool.getBufferPool(); + // assertNull("getBufferPool returns null", result); + // } + // + // public final void testSetGetConnector() + // { + // pool.setConnector(connectorMock); + // Connector result = pool.getConnector(); + // assertEquals("getConnector returns the value of setConnector", connectorMock, result); + // + // pool.setConnector(null); + // result = pool.getConnector(); + // assertNull("getConnector returns null", result); + // } + // + // public final void testSetGetDispatcher() + // { + // pool.setDispatcher(dispatcherMock); + // Executor result = pool.getDispatcher(); + // assertEquals("getDispatcher returns the value of setDispatcher", dispatcherMock, result); + // + // pool.setDispatcher(null); + // result = pool.getDispatcher(); + // assertNull("getDispatcher returns null", result); + // } + // + // public final void testSetGetMultiplexer() + // { + // pool.setMultiplexer(multiplexerMock); + // Multiplexer result = pool.getMultiplexer(); + // assertEquals("getBufferPool returns the value of setMultiplexer", multiplexerMock, result); + // + // pool.setMultiplexer(null); + // result = pool.getMultiplexer(); + // assertNull("getMultiplexer returns null", result); + // } + // + // public final void testSetGetProtocol() + // { + // pool.setProtocol(protocolMock); + // Protocol result = pool.getProtocol(); + // assertEquals("getProtocol returns the value of setProtocol", protocolMock, result); + // + // pool.setProtocol(null); + // result = pool.getProtocol(); + // assertNull("getProtocol returns null", result); + // } + // + // public final void testSetGetInternalReturnValue() + // { + // Object returnValue = new Object(); + // + // pool.internalSetReturnValue(returnValue); + // Object result = pool.testGetReturnValue(); + // assertEquals("testGetReturnValue returns the value of internalSetReturnValue", returnValue, + // result); + // + // pool.internalSetReturnValue(null); + // result = pool.testGetReturnValue(); + // assertNull("testGetReturnValue returns null", result); + // } + // + // public final void testSetGetProtocolData() + // { + // Object protocolData = new Object(); + // + // pool.setProtocolData(protocolData); + // Object result = pool.getProtocolData(); + // assertEquals("getProtocolData returns the value of setProtocolData", protocolData, result); + // + // pool.setProtocolData(null); + // result = pool.getProtocolData(); + // assertNull("getProtocolData returns null", result); + // } + // + // public final void testServiceGuards() + // { + // new ServiceInvoker(pool) + // { + // protected void invokeService(DefaultBean bean) throws Exception + // { + // ((DefaultChannel) bean).handleTransmission(); + // } + // }; + // + // new ServiceInvoker(pool) + // { + // protected void invokeService(DefaultBean bean) throws Exception + // { + // ((DefaultChannel) bean).notification(null); + // } + // }; + // + // new ServiceInvoker(pool) + // { + // protected void invokeService(DefaultBean bean) throws Exception + // { + // ((DefaultChannel) bean).request(null); + // } + // }; + // } + // + // public final void testValidate() + // { + // pool.setBufferPool(bufferPoolMock); + // pool.setDispatcher(dispatcherMock); + // pool.setMultiplexer(multiplexerMock); + // pool.testValidate(); + // + // try + // { + // pool.setBufferPool(null); + // pool.setDispatcher(dispatcherMock); + // pool.setMultiplexer(multiplexerMock); + // pool.testValidate(); + // fail("expected ValidationException"); + // } + // catch (ValidationException expected) + // { + // TestUtils.assertContains(expected, "bufferPool"); + // } + // + // try + // { + // pool.setBufferPool(bufferPoolMock); + // pool.setDispatcher(null); + // pool.setMultiplexer(multiplexerMock); + // pool.testValidate(); + // fail("expected ValidationException"); + // } + // catch (ValidationException expected) + // { + // TestUtils.assertContains(expected, "dispatcher"); + // } + // + // try + // { + // pool.setBufferPool(bufferPoolMock); + // pool.setDispatcher(dispatcherMock); + // pool.setMultiplexer(null); + // pool.testValidate(); + // fail("expected ValidationException"); + // } + // catch (ValidationException expected) + // { + // TestUtils.assertContains(expected, "multiplexer"); + // } + // } + // + // /** + // * PRECONDITION: dataSize == 0 + // * + // * EXPECTATION: doesn't block; + // * throws IllegalArgumentException + // */ + // public final void testEnsureReceiverBuffer1() throws Throwable + // { + // NodeCachingLinkedList receiverQueue = new NodeCachingLinkedList(); + // pool.testSetReceiverQueue(receiverQueue); + // + // start(); + // try + // { + // new BlockingDetector(pool, receiverQueue, false) + // { + // protected void blockableOperation(Object target) throws Exception + // { + // ((DefaultChannel) target).testEnsureReceiverBuffer(0); + // } + // }; + // fail("IllegalArgumentException expected"); + // } + // catch (IllegalArgumentException expected) + // { + // TestUtils.assertContains(expected, "dataSize"); + // } + // verify(); + // } + // + // /** + // * PRECONDITION: dataSize < 0 + // * + // * EXPECTATION: doesn't block; + // * throws IllegalArgumentException + // */ + // public final void testEnsureReceiverBuffer2() throws Throwable + // { + // NodeCachingLinkedList receiverQueue = new NodeCachingLinkedList(); + // pool.testSetReceiverQueue(receiverQueue); + // + // start(); + // try + // { + // new BlockingDetector(pool, receiverQueue, false) + // { + // protected void blockableOperation(Object target) throws Exception + // { + // ((DefaultChannel) target).testEnsureReceiverBuffer(-1); + // } + // }; + // fail("IllegalArgumentException expected"); + // } + // catch (IllegalArgumentException expected) + // { + // TestUtils.assertContains(expected, "dataSize"); + // } + // verify(); + // } + // + // /** + // * PRECONDITION: receiverBuffer exists; + // * 0 < level < dataSize + // * + // * EXPECTATION: doesn't block; + // * throws ImplementationError + // */ + // public final void testEnsureReceiverBuffer3() throws Throwable + // { + // BufferImpl receiverBuffer = createBuffer(20, 3, true); + // pool.testSetReceiverBuffer(receiverBuffer); + // + // NodeCachingLinkedList receiverQueue = new NodeCachingLinkedList(); + // pool.testSetReceiverQueue(receiverQueue); + // + // pool.setBufferPool(bufferPoolMock); + // + // start(); + // try + // { + // new BlockingDetector(pool, receiverQueue, false) + // { + // protected void blockableOperation(Object target) throws Exception + // { + // ((DefaultChannel) target).testEnsureReceiverBuffer(7); + // } + // }; + // fail("ImplementationError expected"); + // } + // catch (ImplementationError expected) + // { + // TestUtils.assertContains(expected, "receiverBuffer level too low"); + // } + // verify(); + // } + // + // /** + // * PRECONDITION: receiverBuffer exists; + // * 0 < dataSize < level + // * + // * EXPECTATION: doesn't block; + // * receiverBuffer not returned to bufferPool + // */ + // public final void testEnsureReceiverBuffer4() throws Throwable + // { + // BufferImpl receiverBuffer = createBuffer(20, 12, true); + // pool.testSetReceiverBuffer(receiverBuffer); + // + // NodeCachingLinkedList receiverQueue = new NodeCachingLinkedList(); + // pool.testSetReceiverQueue(receiverQueue); + // + // pool.setBufferPool(bufferPoolMock); + // + // start(); + // new BlockingDetector(pool, receiverQueue, false) + // { + // protected void blockableOperation(Object target) throws Exception + // { + // ((DefaultChannel) target).testEnsureReceiverBuffer(7); + // } + // }; + // verify(); + // } + // + // /** + // * PRECONDITION: receiverBuffer exists; + // * 0 < dataSize == level + // * + // * EXPECTATION: doesn't block; + // * receiverBuffer not returned to bufferPool + // */ + // public final void testEnsureReceiverBuffer5() throws Throwable + // { + // BufferImpl receiverBuffer = createBuffer(20, 12, true); + // pool.testSetReceiverBuffer(receiverBuffer); + // + // NodeCachingLinkedList receiverQueue = new NodeCachingLinkedList(); + // pool.testSetReceiverQueue(receiverQueue); + // + // pool.setBufferPool(bufferPoolMock); + // + // start(); + // new BlockingDetector(pool, receiverQueue, false) + // { + // protected void blockableOperation(Object target) throws Exception + // { + // ((DefaultChannel) target).testEnsureReceiverBuffer(12); + // } + // }; + // verify(); + // } + // + // /** + // * PRECONDITION: receiverBuffer exists; + // * 0 == level < dataSize; + // * receiverQueue empty + // * + // * EXPECTATION: receiverBuffer returned to bufferPool; + // * blocks + // */ + // public final void testEnsureReceiverBuffer6() throws Throwable + // { + // BufferImpl receiverBuffer = createBuffer(20, 0, true); + // pool.testSetReceiverBuffer(receiverBuffer); + // + // NodeCachingLinkedList receiverQueue = new NodeCachingLinkedList(); + // pool.testSetReceiverQueue(receiverQueue); + // + // bufferPoolMock.put(new Integer(20), receiverBuffer); + // pool.setBufferPool(bufferPoolMock); + // + // start(); + // new BlockingDetector(pool, receiverQueue, true) + // { + // protected void blockableOperation(Object target) throws Exception + // { + // ((DefaultChannel) target).testEnsureReceiverBuffer(7); + // } + // }; + // verify(); + // } + // + // /** + // * PRECONDITION: receiverBuffer exists; + // * 0 == level < dataSize; + // * receiverQueue has too small buffer + // * + // * EXPECTATION: doesn't block; + // * receiverBuffer returned to bufferPool + // * throws ImplementationError + // */ + // public final void testEnsureReceiverBuffer7() throws Throwable + // { + // BufferImpl receiverBuffer = createBuffer(20, 0, true); + // pool.testSetReceiverBuffer(receiverBuffer); + // + // NodeCachingLinkedList receiverQueue = createBufferQueue(20, 5, true); + // pool.testSetReceiverQueue(receiverQueue); + // + // bufferPoolMock.put(new Integer(20), receiverBuffer); + // pool.setBufferPool(bufferPoolMock); + // + // start(); + // try + // { + // new BlockingDetector(pool, receiverQueue, false) + // { + // protected void blockableOperation(Object target) throws Exception + // { + // ((DefaultChannel) target).testEnsureReceiverBuffer(7); + // } + // }; + // fail("ImplementationError expected"); + // } + // catch (ImplementationError expected) + // { + // TestUtils.assertContains(expected, "receiverBuffer level too low"); + // } + // verify(); + // } + // + // /** + // * PRECONDITION: receiverBuffer exists; + // * 0 == level < dataSize; + // * receiverQueue has exact buffer + // * + // * EXPECTATION: doesn't block; + // * receiverBuffer returned to bufferPool + // */ + // public final void testEnsureReceiverBuffer8() throws Throwable + // { + // BufferImpl receiverBuffer = createBuffer(20, 0, true); + // pool.testSetReceiverBuffer(receiverBuffer); + // + // NodeCachingLinkedList receiverQueue = createBufferQueue(20, 7, true); + // pool.testSetReceiverQueue(receiverQueue); + // + // bufferPoolMock.put(new Integer(20), receiverBuffer); + // pool.setBufferPool(bufferPoolMock); + // + // start(); + // new BlockingDetector(pool, receiverQueue, false) + // { + // protected void blockableOperation(Object target) throws Exception + // { + // ((DefaultChannel) target).testEnsureReceiverBuffer(7); + // } + // }; + // verify(); + // } + // + // /** + // * PRECONDITION: receiverBuffer exists; + // * 0 == level < dataSize; + // * receiverQueue has too big buffer + // * + // * EXPECTATION: doesn't block; + // * receiverBuffer returned to bufferPool + // */ + // public final void testEnsureReceiverBuffer9() throws Throwable + // { + // BufferImpl receiverBuffer = createBuffer(20, 0, true); + // pool.testSetReceiverBuffer(receiverBuffer); + // + // NodeCachingLinkedList receiverQueue = createBufferQueue(20, 12, true); + // pool.testSetReceiverQueue(receiverQueue); + // + // bufferPoolMock.put(new Integer(20), receiverBuffer); + // pool.setBufferPool(bufferPoolMock); + // + // start(); + // new BlockingDetector(pool, receiverQueue, false) + // { + // protected void blockableOperation(Object target) throws Exception + // { + // ((DefaultChannel) target).testEnsureReceiverBuffer(7); + // } + // }; + // verify(); + // } + // + // /** + // * PRECONDITION: transmitterBuffer doesn't exists + // * + // * EXPECTATION: throws ImplementationError + // */ + // public final void testFlush1() + // { + // start(); + // try + // { + // pool.flush(); + // fail("ImplementationError expected"); + // } + // catch (ImplementationError expected) + // { + // TestUtils.assertContains(expected, "transmitterBuffer must exist"); + // } + // verify(); + // } + // + // /** + // * PRECONDITION: transmitterBuffer exists; + // * level == 0 + // * + // * EXPECTATION: immediately returns + // */ + // public final void testFlush2() + // { + // BufferImpl transmitterBuffer = createBuffer(20, 0, false); + // pool.testSetTransmitterBuffer(transmitterBuffer); + // + // start(); + // pool.flush(); + // verify(); + // } + // + // /** + // * PRECONDITION: transmitterBuffer exists; + // * level > 0 + // * + // * EXPECTATION: transmitterBuffer is flipped; + // * appended to transmitterQueue; + // * channel is scheduled for transmission; + // * a new transmitterBuffer is fetched from the bufferPool; + // * the new transmitterBuffer is empty + // */ + // public final void testFlush3() + // { + // BufferImpl transmitterBuffer = createBuffer(20, 7, false); + // pool.testSetTransmitterBuffer(transmitterBuffer); + // + // NodeCachingLinkedList transmitterQueue = new NodeCachingLinkedList(); + // pool.testSetTransmitterQueue(transmitterQueue); + // + // multiplexerMock.schedule(pool); + // pool.setMultiplexer(multiplexerMock); + // + // bufferPoolMockControl.expectAndReturn(bufferPoolMock.get(), createBuffer(10, 10, false)); + // pool.setBufferPool(bufferPoolMock); + // + // start(); + // pool.flush(); + // verify(); + // + // assertTrue("transmitterBuffer is flipped", transmitterBuffer.position() == 0); + // assertTrue("transmitterBuffer is in transmitterQueue", + // transmitterQueue.get(0) == transmitterBuffer); + // assertNotSame("a new transmitterBuffer is expected", transmitterBuffer, pool + // .testGetTransmitterBuffer()); + // assertTrue("the new transmitterBuffer must be empty", pool.testGetTransmitterBuffer() + // .position() == 0); + // + // } + protected class TestAcceptor extends SocketAcceptorImpl + { + protected Connector createSlave(SocketChannel socketChannel) + { + slave = new PassiveTestConnector(); + slave.setApplicationContext(SocketConnectorTest.container); + slave.setBeanName("slave"); + slave.setSocketChannel(socketChannel); + return slave; + } + + + protected class PassiveTestConnector extends PassiveSocketConnectorImpl + { + protected void prepareBasicChannel() + { + } + } + } + + + protected class TestConnector extends ActiveSocketConnectorImpl + { + protected void prepareBasicChannel() + { + } + } + +}
\ No newline at end of file diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/protocol/Net4jTestProtocol.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/protocol/Net4jTestProtocol.java new file mode 100644 index 0000000000..81d5447abf --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/protocol/Net4jTestProtocol.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + *******************************************************************************/ +package org.eclipse.net4j.test.protocol; + + +import org.eclipse.net4j.core.Indication; +import org.eclipse.net4j.core.Protocol; +import org.eclipse.net4j.core.impl.AbstractProtocol; +import org.eclipse.net4j.util.ImplementationError; + + +public class Net4jTestProtocol extends AbstractProtocol implements Protocol +{ + public static final String PROTOCOL_NAME = "test"; + + public static final short TEST_SIGNAL = 4711; + + public Indication createIndication(short signalId) + { + switch (signalId) + { + case TEST_SIGNAL: + return new TestIndication(); + + default: + throw new ImplementationError("Invalid signalId: " + signalId); + } + } + + public String getName() + { + return PROTOCOL_NAME; + } + + public int getType() + { + return SYMMETRIC; + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/protocol/TestIndication.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/protocol/TestIndication.java new file mode 100644 index 0000000000..43c83cacd3 --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/protocol/TestIndication.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + *******************************************************************************/ +package org.eclipse.net4j.test.protocol; + + +import org.eclipse.net4j.core.impl.AbstractIndicationWithResponse; + + +public class TestIndication extends AbstractIndicationWithResponse +{ + protected Object[] values; + + public TestIndication() + { + } + + public short getSignalId() + { + return Net4jTestProtocol.TEST_SIGNAL; + } + + public void indicate() + { + values = ValueHelper.receiveValues(getChannel()); + } + + public void respond() + { + ValueHelper.transmitValues(getChannel(), values); + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/protocol/TestRequest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/protocol/TestRequest.java new file mode 100644 index 0000000000..5a7d1ed137 --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/protocol/TestRequest.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + *******************************************************************************/ +package org.eclipse.net4j.test.protocol; + + +import org.eclipse.net4j.core.impl.AbstractRequestWithConfirmation; + + +public class TestRequest extends AbstractRequestWithConfirmation +{ + protected Object[] values; + + public TestRequest(Object[] values) + { + this.values = values; + } + + public short getSignalId() + { + return Net4jTestProtocol.TEST_SIGNAL; + } + + public void request() + { + ValueHelper.transmitValues(getChannel(), values); + } + + public Object confirm() + { + return ValueHelper.receiveValues(getChannel()); + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/protocol/ValueHelper.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/protocol/ValueHelper.java new file mode 100644 index 0000000000..5f84e4412c --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/protocol/ValueHelper.java @@ -0,0 +1,196 @@ +package org.eclipse.net4j.test.protocol; + + +import org.eclipse.net4j.core.Channel; +import org.eclipse.net4j.util.ImplementationError; + +import java.util.ArrayList; +import java.util.List; + + +public class ValueHelper +{ + public static final byte END_OF_TRANSMISSION = -1; + + public static final byte BOOLEAN = 1; + + public static final byte CHARACTER = 2; + + public static final byte BYTE = 3; + + public static final byte SHORT = 4; + + public static final byte INTEGER = 5; + + public static final byte LONG = 6; + + public static final byte FLOAT = 7; + + public static final byte DOUBLE = 8; + + public static final byte STRING = 9; + + public static void transmitValues(Channel channel, Object[] values) + { + for (int i = 0; i < values.length; i++) + { + Object value = values[i]; + + if (value instanceof Boolean) + { + channel.transmitByte(BOOLEAN); + channel.transmitBoolean(((Boolean) value).booleanValue()); + } + else if (value instanceof Character) + { + channel.transmitByte(CHARACTER); + channel.transmitChar(((Character) value).charValue()); + } + else if (value instanceof Byte) + { + channel.transmitByte(BYTE); + channel.transmitByte(((Byte) value).byteValue()); + } + else if (value instanceof Short) + { + channel.transmitByte(SHORT); + channel.transmitShort(((Short) value).shortValue()); + } + else if (value instanceof Integer) + { + channel.transmitByte(INTEGER); + channel.transmitInt(((Integer) value).intValue()); + } + else if (value instanceof Long) + { + channel.transmitByte(LONG); + channel.transmitLong(((Long) value).longValue()); + } + else if (value instanceof Float) + { + channel.transmitByte(FLOAT); + channel.transmitFloat(((Float) value).floatValue()); + } + else if (value instanceof Double) + { + channel.transmitByte(DOUBLE); + channel.transmitDouble(((Double) value).doubleValue()); + } + else if (value instanceof String) + { + channel.transmitByte(STRING); + channel.transmitString((String) value); + } + else + { + throw new ImplementationError("invalid class: " + value.getClass().getName()); + } + } + + channel.transmitByte(END_OF_TRANSMISSION); + } + + public static Object[] receiveValues(Channel channel) + { + List list = new ArrayList(); + + for (;;) + { + byte type = channel.receiveByte(); + + switch (type) + { + case END_OF_TRANSMISSION: + return list.toArray(); + + case BOOLEAN: + list.add(new Boolean(channel.receiveBoolean())); + break; + + case CHARACTER: + list.add(new Character(channel.receiveChar())); + break; + + case BYTE: + list.add(new Byte(channel.receiveByte())); + break; + + case SHORT: + list.add(new Short(channel.receiveShort())); + break; + + case INTEGER: + list.add(new Integer(channel.receiveInt())); + break; + + case LONG: + list.add(new Long(channel.receiveLong())); + break; + + case FLOAT: + list.add(new Float(channel.receiveFloat())); + break; + + case DOUBLE: + list.add(new Double(channel.receiveDouble())); + break; + + case STRING: + list.add(channel.receiveString()); + break; + } + } + } + + public static int sizeOf(Object[] values) + { + int sum = 4; // END_OF_TRANSMISSION + for (int i = 0; i < values.length; i++) + { + Object value = values[i]; + + if (value instanceof Boolean) + { + sum += 1 + 1; + } + else if (value instanceof Character) + { + sum += 1 + 2; + } + else if (value instanceof Byte) + { + sum += 1 + 1; + } + else if (value instanceof Short) + { + sum += 1 + 2; + } + else if (value instanceof Integer) + { + sum += 1 + 4; + } + else if (value instanceof Long) + { + sum += 1 + 8; + } + else if (value instanceof Float) + { + sum += 1 + 4; + } + else if (value instanceof Double) + { + sum += 1 + 8; + } + else if (value instanceof String) + { + sum += 1 + 4 + 2 * ((String) value).length(); + } + else + { + throw new ImplementationError("invalid class: " + value.getClass().getName()); + } + } + + return sum; + } +} diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/util/BlockingDetector.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/util/BlockingDetector.java new file mode 100644 index 0000000000..6aa8cef915 --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/util/BlockingDetector.java @@ -0,0 +1,100 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + *******************************************************************************/ +package org.eclipse.net4j.test.util; + + +import junit.framework.Assert; + + +public abstract class BlockingDetector +{ + public static final long DEFAULT_WAIT_MILLIS = 100; + + protected Thread thread; + + protected BlockableOperationException exception; + + public BlockingDetector(Object target, Object monitor, boolean blockingExpected) throws Throwable + { + this(target, monitor, blockingExpected, DEFAULT_WAIT_MILLIS); + } + + public BlockingDetector(Object target, Object monitor, boolean blockingExpected, long waitMillis) + throws Throwable + { + startOperation(target); + + try + { + Thread.sleep(waitMillis); + } + catch (InterruptedException ex) + { + throw new BlockableOperationException(ex); + } + + if (exception != null) + { + throw exception.getCause(); + } + + boolean alive = thread.isAlive(); + + if (alive) synchronized (monitor) + { + monitor.notifyAll(); + } + + if (blockingExpected) + { + Assert.assertTrue("blocking expected", alive); + } + else + { + Assert.assertTrue("no blocking expected", !alive); + } + } + + public void startOperation(final Object target) + { + thread = new Thread() + { + + public void run() + { + try + { + blockableOperation(target); + } + catch (Exception ex) + { + exception = new BlockableOperationException(ex); + throw exception; + } + } + }; + + thread.start(); + } + + protected abstract void blockableOperation(Object target) throws Exception; + + + private static class BlockableOperationException extends RuntimeException + { + private static final long serialVersionUID = 1L; + + public BlockableOperationException(Exception ex) + { + super(ex); + } + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/util/ServiceInvoker.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/util/ServiceInvoker.java new file mode 100644 index 0000000000..caa722cce2 --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/util/ServiceInvoker.java @@ -0,0 +1,61 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + *******************************************************************************/ +package org.eclipse.net4j.test.util; + + +import org.eclipse.net4j.spring.InactiveException; +import org.eclipse.net4j.spring.Service; +import org.eclipse.net4j.spring.impl.ServiceImpl; + +import junit.framework.Assert; + + +public abstract class ServiceInvoker +{ + private static final byte[] STATES = { ServiceImpl.ServiceStateMachine.STATE_STOPPING, + ServiceImpl.ServiceStateMachine.STATE_STOPPING, + ServiceImpl.ServiceStateMachine.STATE_INCONSISTENT, + ServiceImpl.ServiceStateMachine.STATE_ACTIVE, ServiceImpl.ServiceStateMachine.STATE_DISPOSED}; + + private static final int OK_INDEX = 2; + + public ServiceInvoker(Service bean) + { + for (int i = 0; i < STATES.length; i++) + { + byte state = STATES[i]; + bean.testSetState(state); + Throwable throwable = null; + + try + { + invokeService(bean); + } + catch (Throwable t) + { + throwable = t; + } + + if (i == OK_INDEX) + { + Assert.assertFalse("No InactiveException is thrown", throwable != null + && throwable instanceof InactiveException); + } + else + { + Assert.assertNotNull("An exception is thrown", throwable); + Assert.assertTrue("An InactiveException is thrown", throwable instanceof InactiveException); + } + } + } + + protected abstract void invokeService(Service bean) throws Exception; +}
\ No newline at end of file diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/util/TestUtils.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/util/TestUtils.java new file mode 100644 index 0000000000..b6b0ab7998 --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/util/TestUtils.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + *******************************************************************************/ +package org.eclipse.net4j.test.util; + + +import junit.framework.Assert; + + +public class TestUtils +{ + public static void assertContains(String message, String text, String word) + { + if (text == null) + { + Assert.assertNull(message, word); + } + + Assert.assertTrue(message, text.matches(".*" + word + ".*")); + } + + public static void assertContains(String text, String word) + { + String message = "'" + text + "' should contain '" + word + "'"; + assertContains(message, text, word); + } + + public static void assertContains(String message, Throwable t, String word) + { + String text = t.getMessage(); + assertContains(message, text, word); + } + + public static void assertContains(Throwable t, String word) + { + String text = t.getMessage(); + assertContains(text, word); + } +}
\ No newline at end of file |