diff options
26 files changed, 1876 insertions, 0 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/.classpath b/bundles/org.eclipse.equinox.p2.tests.ui/.classpath new file mode 100644 index 000000000..2fbb7a23e --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests.ui/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="src" path="src"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/.project b/bundles/org.eclipse.equinox.p2.tests.ui/.project new file mode 100644 index 000000000..c9255c38a --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests.ui/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.equinox.p2.tests.ui</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/bundles/org.eclipse.equinox.p2.tests.ui/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.equinox.p2.tests.ui/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..b4fdaeb4b --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests.ui/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,343 @@ +#Tue Aug 19 22:58:53 EDT 2008 +eclipse.preferences.version=1 +instance/org.eclipse.core.net/org.eclipse.core.net.hasMigrated=true +org.eclipse.jdt.core.builder.cleanOutputFolder=clean +org.eclipse.jdt.core.builder.duplicateResourceTask=warning +org.eclipse.jdt.core.builder.invalidClasspath=abort +org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch +org.eclipse.jdt.core.circularClasspath=error +org.eclipse.jdt.core.classpath.exclusionPatterns=enabled +org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.4 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.doc.comment.support=enabled +org.eclipse.jdt.core.compiler.maxProblemPerUnit=1000 +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=ignore +org.eclipse.jdt.core.compiler.problem.emptyStatement=warning +org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=warning +org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=error +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning +org.eclipse.jdt.core.compiler.problem.invalidJavadoc=error +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private +org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore +org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=enabled +org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public +org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=enabled +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=enabled +org.eclipse.jdt.core.compiler.problem.unusedImport=error +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=enabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=error +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.3 +org.eclipse.jdt.core.formatter.align_type_members_on_columns=false +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_assignment=0 +org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 +org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 +org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 +org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 +org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_after_package=1 +org.eclipse.jdt.core.formatter.blank_lines_before_field=0 +org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 +org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 +org.eclipse.jdt.core.formatter.blank_lines_before_method=1 +org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 +org.eclipse.jdt.core.formatter.blank_lines_before_package=0 +org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 +org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 +org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false +org.eclipse.jdt.core.formatter.comment.format_block_comments=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_javadoc_comments=false +org.eclipse.jdt.core.formatter.comment.format_line_comments=false +org.eclipse.jdt.core.formatter.comment.format_source_code=true +org.eclipse.jdt.core.formatter.comment.indent_parameter_description=false +org.eclipse.jdt.core.formatter.comment.indent_root_tags=false +org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert +org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert +org.eclipse.jdt.core.formatter.comment.line_length=80 +org.eclipse.jdt.core.formatter.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_opening_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=do not 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=do not 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=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert +org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false +org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false +org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false +org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false +org.eclipse.jdt.core.formatter.lineSplit=800 +org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false +org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 +org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 +org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=false +org.eclipse.jdt.core.formatter.tabulation.char=tab +org.eclipse.jdt.core.formatter.tabulation.size=4 +org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false +org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true +org.eclipse.jdt.core.incompatibleJDKLevel=ignore +org.eclipse.jdt.core.incompleteClasspath=error diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/.settings/org.eclipse.jdt.ui.prefs b/bundles/org.eclipse.equinox.p2.tests.ui/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 000000000..c72c9885b --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests.ui/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,57 @@ +#Tue Nov 13 12:02:11 EST 2007 +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +formatter_profile=_core +formatter_settings_version=11 +org.eclipse.jdt.ui.ignorelowercasenames=true +org.eclipse.jdt.ui.importorder=; +org.eclipse.jdt.ui.ondemandthreshold=3 +org.eclipse.jdt.ui.staticondemandthreshold=3 +org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates/> +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=false +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_to_enhanced_for_loop=false +sp_cleanup.format_source_code=true +sp_cleanup.make_local_variable_final=false +sp_cleanup.make_parameters_final=false +sp_cleanup.make_private_fields_final=true +sp_cleanup.make_variable_declarations_final=true +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=true +sp_cleanup.on_save_use_additional_actions=false +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=false +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_trailing_whitespaces=false +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=false +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=false +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=false +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/.settings/org.eclipse.pde.core.prefs b/bundles/org.eclipse.equinox.p2.tests.ui/.settings/org.eclipse.pde.core.prefs new file mode 100644 index 000000000..63331939d --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests.ui/.settings/org.eclipse.pde.core.prefs @@ -0,0 +1,4 @@ +#Thu Aug 23 14:59:00 CEST 2007 +eclipse.preferences.version=1 +pluginProject.extensions=true +resolve.requirebundle=false diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.tests.ui/META-INF/MANIFEST.MF new file mode 100644 index 000000000..13064e311 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests.ui/META-INF/MANIFEST.MF @@ -0,0 +1,20 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %pluginName +Bundle-Vendor: %providerName +Bundle-Localization: plugin +Bundle-SymbolicName: org.eclipse.equinox.p2.tests.ui +Bundle-Version: 1.0.0 +Bundle-RequiredExecutionEnvironment: J2SE-1.4 +Require-Bundle: org.eclipse.equinox.p2.tests;bundle-version="1.1.0", + org.eclipse.core.runtime;bundle-version="3.4.100", + org.eclipse.ui;bundle-version="3.5.0", + org.eclipse.equinox.p2.metadata;bundle-version="1.0.0", + org.eclipse.equinox.p2.metadata.repository;bundle-version="1.0.100", + org.eclipse.equinox.p2.ui;bundle-version="1.0.100", + org.eclipse.core.tests.harness;bundle-version="3.4.0", + org.eclipse.equinox.p2.core;bundle-version="1.0.100", + org.junit;bundle-version="3.8.2", + org.eclipse.equinox.p2.engine;bundle-version="1.0.100", + org.eclipse.equinox.p2.director;bundle-version="1.0.100", + org.eclipse.equinox.p2.artifact.repository;bundle-version="1.0.100" diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/about.html b/bundles/org.eclipse.equinox.p2.tests.ui/about.html new file mode 100644 index 000000000..460233046 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests.ui/about.html @@ -0,0 +1,28 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/> +<title>About</title> +</head> +<body lang="EN-US"> +<h2>About This Content</h2> + +<p>June 2, 2006</p> +<h3>License</h3> + +<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise +indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available +at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>. +For purposes of the EPL, "Program" will mean the Content.</p> + +<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is +being redistributed by another party ("Redistributor") and different terms and conditions may +apply to your use of any object code in the Content. Check the Redistributor's license that was +provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise +indicated below, the terms and conditions of the EPL still apply to any source code in the Content +and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p> + +</body> +</html>
\ No newline at end of file diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/build.properties b/bundles/org.eclipse.equinox.p2.tests.ui/build.properties new file mode 100644 index 000000000..36ea22a5e --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests.ui/build.properties @@ -0,0 +1,18 @@ +############################################################################### +# Copyright (c) 2007 IBM Corporation and others. +# 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: +# IBM Corporation - initial API and implementation +############################################################################### +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + about.html,\ + plugin.properties,\ + test.xml +src.includes = about.html diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/plugin.properties b/bundles/org.eclipse.equinox.p2.tests.ui/plugin.properties new file mode 100644 index 000000000..41d712037 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests.ui/plugin.properties @@ -0,0 +1,12 @@ +############################################################################### +# Copyright (c) 2007 IBM Corporation and others. +# 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: +# IBM Corporation - initial API and implementation +############################################################################### +pluginName = Equinox Provisioning Tests (Incubation) +providerName = Eclipse.org diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/AutomatedTests.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/AutomatedTests.java new file mode 100644 index 000000000..ed4594438 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/AutomatedTests.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2008 IBM Corporation and others. + * 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: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.p2.tests.ui; + +import junit.framework.*; + +/** + * This is the master test suite for all automated provisioning UI tests. It runs every test + * that is suitable for running in an automated fashion as part of a build. + */ +public class AutomatedTests extends TestCase { + public static Test suite() { + TestSuite suite = new TestSuite(AutomatedTests.class.getName()); + suite.addTest(org.eclipse.equinox.p2.tests.ui.operations.AllTests.suite()); + suite.addTest(org.eclipse.equinox.p2.tests.ui.query.AllTests.suite()); + return suite; + } +} diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/AddColocatedRepositoryOperationTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/AddColocatedRepositoryOperationTest.java new file mode 100644 index 000000000..fdc7fd8e6 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/AddColocatedRepositoryOperationTest.java @@ -0,0 +1,113 @@ +/******************************************************************************* + * Copyright (c) 2008 IBM Corporation and others. + * 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: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.p2.tests.ui.operations; + +import java.net.URL; +import java.util.Arrays; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; +import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager; +import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager; +import org.eclipse.equinox.internal.provisional.p2.ui.operations.AddColocatedRepositoryOperation; +import org.eclipse.equinox.p2.tests.*; + +/** + * Tests for {@link AddColocatedRepositoryOperation}. + */ +public class AddColocatedRepositoryOperationTest extends AbstractProvisioningTest { + public void testAddSingleRepository() { + URL repoLocation = null; + try { + repoLocation = TestData.getFile("artifactRepo", "").toURL(); + } catch (Exception e) { + fail("0.99", e); + } + AddColocatedRepositoryOperation op = new AddColocatedRepositoryOperation("label", repoLocation); + assertTrue("1.0", op.canExecute()); + assertTrue("1.1", !op.canUndo()); + assertTrue("1.2", op.runInBackground()); + Object[] affected = op.getAffectedObjects(); + assertEquals("1.3", 1, affected.length); + assertEquals("1.4", repoLocation, affected[0]); + + try { + IStatus result = op.execute(getMonitor(), null); + assertTrue("1.9", result.isOK()); + } catch (ExecutionException e) { + fail("1.99", e); + } + + IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(TestActivator.getContext(), IMetadataRepositoryManager.class.getName()); + URL[] repos = manager.getKnownRepositories(0); + assertTrue("2.0", Arrays.asList(repos).contains(repoLocation)); + assertTrue("2.1", manager.isEnabled(repoLocation)); + + IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) ServiceHelper.getService(TestActivator.getContext(), IArtifactRepositoryManager.class.getName()); + repos = artifactManager.getKnownRepositories(0); + assertTrue("3.0", Arrays.asList(repos).contains(repoLocation)); + assertTrue("3.1", artifactManager.isEnabled(repoLocation)); + } + + public void testUndoRedo() { + URL repoLocation = null; + try { + repoLocation = TestData.getFile("artifactRepo", "").toURL(); + } catch (Exception e) { + fail("0.99", e); + } + AddColocatedRepositoryOperation op = new AddColocatedRepositoryOperation("label", repoLocation); + + try { + op.execute(getMonitor(), null); + } catch (ExecutionException e) { + fail("1.99", e); + } + + //should be undoable + assertTrue("1.0", op.canUndo()); + assertTrue("1.1", !op.canExecute()); + + try { + op.undo(getMonitor(), null); + } catch (ExecutionException e) { + fail("2.99", e); + } + + IMetadataRepositoryManager metadataManager = (IMetadataRepositoryManager) ServiceHelper.getService(TestActivator.getContext(), IMetadataRepositoryManager.class.getName()); + URL[] repos = metadataManager.getKnownRepositories(0); + assertTrue("2.0", !Arrays.asList(repos).contains(repoLocation)); + assertTrue("2.1", !metadataManager.isEnabled(repoLocation)); + + IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) ServiceHelper.getService(TestActivator.getContext(), IArtifactRepositoryManager.class.getName()); + repos = artifactManager.getKnownRepositories(0); + assertTrue("3.0", !Arrays.asList(repos).contains(repoLocation)); + assertTrue("3.1", !artifactManager.isEnabled(repoLocation)); + + //should be redoable + assertTrue("4.0", !op.canUndo()); + assertTrue("4.1", op.canRedo()); + + try { + op.redo(getMonitor(), null); + } catch (ExecutionException e) { + fail("4.99", e); + } + repos = metadataManager.getKnownRepositories(0); + assertTrue("2.0", Arrays.asList(repos).contains(repoLocation)); + assertTrue("2.1", metadataManager.isEnabled(repoLocation)); + + repos = artifactManager.getKnownRepositories(0); + assertTrue("3.0", Arrays.asList(repos).contains(repoLocation)); + assertTrue("3.1", artifactManager.isEnabled(repoLocation)); + + } +} diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/AddProfileOperationTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/AddProfileOperationTest.java new file mode 100644 index 000000000..b0d726a4e --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/AddProfileOperationTest.java @@ -0,0 +1,144 @@ +/******************************************************************************* + * Copyright (c) 2008 IBM Corporation and others. + * 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: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.p2.tests.ui.operations; + +import java.util.HashMap; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; +import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; +import org.eclipse.equinox.internal.provisional.p2.ui.operations.AddProfileOperation; +import org.eclipse.equinox.internal.provisional.p2.ui.operations.ProvisioningUtil; +import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; + +/** + * Tests for {@link AddProfileOperation}. + */ +public class AddProfileOperationTest extends AbstractProvisioningTest { + public static final String TEST_PROP_KEY = "TEST_PROP_KEY"; + public static final String TEST_PROP_VALUE = "TEST_PROP_VALUE"; + + /** + * Tests attempting to add a profile that already exists. + */ + public void testAddExistingProfile() { + String profileId = "add-existing"; + IProfile profile = createProfile(profileId, null, new HashMap()); + profilesToRemove.add(profileId); + AddProfileOperation op = new AddProfileOperation("label", profile); + + assertTrue("1.0", !op.canUndo()); + assertTrue("1.1", op.canExecute()); + + try { + op.execute(getMonitor(), null); + fail("1.2");//should have failed + } catch (ExecutionException e) { + //failure expected + } + + //it should not be possible to undo because it failed + assertTrue("2.0", !op.canUndo()); + assertTrue("2.1", op.canExecute()); + assertTrue("2.2", op.canRedo()); + } + + /** + * Tests a simple profile addition that should succeed + */ + public void testAddSimple() { + HashMap properties = new HashMap(); + properties.put(TEST_PROP_KEY, TEST_PROP_VALUE); + String profileId = "add-simple"; + profilesToRemove.add(profileId); + AddProfileOperation op = new AddProfileOperation("label", profileId, properties); + + assertTrue("1.0", !op.canUndo()); + assertTrue("1.1", op.canExecute()); + + try { + IStatus result = op.execute(getMonitor(), null); + assertTrue("1.2", result.isOK()); + } catch (ExecutionException e) { + fail("0.99", e); + } + + //it should be possible to undo + assertTrue("2.0", op.canUndo()); + assertTrue("2.1", !op.canExecute()); + assertTrue("2.2", !op.canRedo()); + + IProfile profile = null; + try { + profile = ProvisioningUtil.getProfile(profileId); + } catch (ProvisionException e) { + fail("2.99", e); + return; + } + assertNotNull("3.0", profile); + assertEquals("3.1", TEST_PROP_VALUE, profile.getProperty(TEST_PROP_KEY)); + } + + /** + * Tests undoing a simple profile addition. + */ + public void testUndoRedo() { + String profileId = "simple-undo"; + profilesToRemove.add(profileId); + HashMap properties = new HashMap(); + properties.put(TEST_PROP_KEY, TEST_PROP_VALUE); + AddProfileOperation op = new AddProfileOperation("label", profileId, properties); + + try { + op.execute(getMonitor(), null); + } catch (ExecutionException e) { + fail("0.99", e); + } + + //now undo + try { + IStatus result = op.undo(getMonitor(), null); + assertTrue("1.0", result.isOK()); + } catch (ExecutionException e1) { + fail("1.99", e1); + } + + assertTrue("1.1", !op.canUndo()); + assertTrue("1.2", op.canRedo()); + + IProfile profile = null; + try { + profile = ProvisioningUtil.getProfile(profileId); + } catch (ProvisionException e) { + fail("2.99", e); + return; + } + //profile should not exist + assertNull("2.0", profile); + + //now redo the operation + try { + op.redo(getMonitor(), null); + } catch (ExecutionException e) { + fail("3.99", e); + } + + //the profile should exist + try { + profile = ProvisioningUtil.getProfile(profileId); + } catch (ProvisionException e) { + fail("4.99", e); + return; + } + assertNotNull("4.0", profile); + assertEquals("4.1", TEST_PROP_VALUE, profile.getProperty(TEST_PROP_KEY)); + } +} diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/AllTests.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/AllTests.java new file mode 100644 index 000000000..0d66ffd24 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/AllTests.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * Copyright (c) 2008 IBM Corporation and others. + * 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: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.p2.tests.ui.operations; + +import junit.framework.*; + +/** + * Performs all UI operation tests. + */ +public class AllTests extends TestCase { + + public static Test suite() { + TestSuite suite = new TestSuite(AllTests.class.getName()); + suite.addTestSuite(AddColocatedRepositoryOperationTest.class); + suite.addTestSuite(AddProfileOperationTest.class); + suite.addTestSuite(RemoveProfilesOperationTest.class); + suite.addTestSuite(SizingTest.class); + return suite; + } +} diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/RemoveColocatedRepositoryOperationTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/RemoveColocatedRepositoryOperationTest.java new file mode 100644 index 000000000..b217a1caf --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/RemoveColocatedRepositoryOperationTest.java @@ -0,0 +1,113 @@ +/******************************************************************************* + * Copyright (c) 2008 IBM Corporation and others. + * 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: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.p2.tests.ui.operations; + +import java.net.URL; +import java.util.Arrays; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; +import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager; +import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager; +import org.eclipse.equinox.internal.provisional.p2.ui.operations.AddColocatedRepositoryOperation; +import org.eclipse.equinox.p2.tests.*; + +/** + * Tests for {@link AddColocatedRepositoryOperation}. + */ +public class RemoveColocatedRepositoryOperationTest extends AbstractProvisioningTest { + public void testRemoveSingleRepository() { + URL repoLocation = null; + try { + repoLocation = TestData.getFile("artifactRepo", "").toURL(); + } catch (Exception e) { + fail("0.99", e); + } + AddColocatedRepositoryOperation op = new AddColocatedRepositoryOperation("label", repoLocation); + assertTrue("1.0", op.canExecute()); + assertTrue("1.1", !op.canUndo()); + assertTrue("1.2", op.runInBackground()); + Object[] affected = op.getAffectedObjects(); + assertEquals("1.3", 1, affected.length); + assertEquals("1.4", repoLocation, affected[0]); + + try { + IStatus result = op.execute(getMonitor(), null); + assertTrue("1.9", result.isOK()); + } catch (ExecutionException e) { + fail("1.99", e); + } + + IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(TestActivator.getContext(), IMetadataRepositoryManager.class.getName()); + URL[] repos = manager.getKnownRepositories(0); + assertTrue("2.0", Arrays.asList(repos).contains(repoLocation)); + assertTrue("2.1", manager.isEnabled(repoLocation)); + + IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) ServiceHelper.getService(TestActivator.getContext(), IArtifactRepositoryManager.class.getName()); + repos = artifactManager.getKnownRepositories(0); + assertTrue("3.0", Arrays.asList(repos).contains(repoLocation)); + assertTrue("3.1", artifactManager.isEnabled(repoLocation)); + } + + public void testUndoRedo() { + URL repoLocation = null; + try { + repoLocation = TestData.getFile("artifactRepo", "").toURL(); + } catch (Exception e) { + fail("0.99", e); + } + AddColocatedRepositoryOperation op = new AddColocatedRepositoryOperation("label", repoLocation); + + try { + op.execute(getMonitor(), null); + } catch (ExecutionException e) { + fail("1.99", e); + } + + //should be undoable + assertTrue("1.0", op.canUndo()); + assertTrue("1.1", !op.canExecute()); + + try { + op.undo(getMonitor(), null); + } catch (ExecutionException e) { + fail("2.99", e); + } + + IMetadataRepositoryManager metadataManager = (IMetadataRepositoryManager) ServiceHelper.getService(TestActivator.getContext(), IMetadataRepositoryManager.class.getName()); + URL[] repos = metadataManager.getKnownRepositories(0); + assertTrue("2.0", !Arrays.asList(repos).contains(repoLocation)); + assertTrue("2.1", !metadataManager.isEnabled(repoLocation)); + + IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) ServiceHelper.getService(TestActivator.getContext(), IArtifactRepositoryManager.class.getName()); + repos = artifactManager.getKnownRepositories(0); + assertTrue("3.0", !Arrays.asList(repos).contains(repoLocation)); + assertTrue("3.1", !artifactManager.isEnabled(repoLocation)); + + //should be redoable + assertTrue("4.0", !op.canUndo()); + assertTrue("4.1", op.canRedo()); + + try { + op.redo(getMonitor(), null); + } catch (ExecutionException e) { + fail("4.99", e); + } + repos = metadataManager.getKnownRepositories(0); + assertTrue("2.0", Arrays.asList(repos).contains(repoLocation)); + assertTrue("2.1", metadataManager.isEnabled(repoLocation)); + + repos = artifactManager.getKnownRepositories(0); + assertTrue("3.0", Arrays.asList(repos).contains(repoLocation)); + assertTrue("3.1", artifactManager.isEnabled(repoLocation)); + + } +} diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/RemoveProfilesOperationTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/RemoveProfilesOperationTest.java new file mode 100644 index 000000000..76b3bb953 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/RemoveProfilesOperationTest.java @@ -0,0 +1,120 @@ +/******************************************************************************* + * Copyright (c) 2008 IBM Corporation and others. + * 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: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.p2.tests.ui.operations; + +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; +import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; +import org.eclipse.equinox.internal.provisional.p2.ui.operations.ProvisioningUtil; +import org.eclipse.equinox.internal.provisional.p2.ui.operations.RemoveProfilesOperation; +import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; + +/** + * Tests for {@link RemoveProfilesOperation} + */ +public class RemoveProfilesOperationTest extends AbstractProvisioningTest { + public static final String TEST_PROP_KEY = "TEST_PROP_KEY"; + public static final String TEST_PROP_VALUE = "TEST_PROP_VALUE"; + + public void testRemoveExisting() { + String profileId = "testRemoveNonExisting"; + IProfile profile = createProfile(profileId); + RemoveProfilesOperation op = new RemoveProfilesOperation("label", new IProfile[] {profile}); + + assertTrue("1.0", op.canExecute()); + assertTrue("1.1", !op.canUndo()); + + try { + op.execute(getMonitor(), null); + } catch (ExecutionException e) { + fail("0.99", e); + } + + try { + profile = ProvisioningUtil.getProfile(profileId); + } catch (ProvisionException e) { + fail("1.99", e); + } + assertNull("2.0", profile); + } + + public void testRemoveNonExisting() { + String profileId = "testRemoveNonExisting"; + IProfile profile = createProfile(profileId); + try { + ProvisioningUtil.removeProfile(profileId, getMonitor()); + } catch (ProvisionException e) { + fail("0.99", e); + } + RemoveProfilesOperation op = new RemoveProfilesOperation("label", new IProfile[] {profile}); + + //currently running doesn't fail and behavior is not specific either way + try { + op.execute(getMonitor(), null); + } catch (ExecutionException e) { + //expected + } + + //redo shouldn't recreate the profile since we never removed it + try { + op.undo(getMonitor(), null); + } catch (ExecutionException e) { + fail("1.99", e); + } + + try { + profile = ProvisioningUtil.getProfile(profileId); + } catch (ProvisionException e) { + fail("2.99", e); + } + assertNull("1.0", profile); + } + + public void testUndoRedo() { + String profileId = "testUndoRedo"; + IProfile profile = createProfile(profileId); + RemoveProfilesOperation op = new RemoveProfilesOperation("label", new IProfile[] {profile}); + + try { + op.execute(getMonitor(), null); + } catch (ExecutionException e) { + fail("0.99", e); + } + + //now undo + try { + op.undo(getMonitor(), null); + } catch (ExecutionException e1) { + fail("1.99", e1); + } + + try { + profile = ProvisioningUtil.getProfile(profileId); + } catch (ProvisionException e) { + fail("2.99", e); + } + assertNotNull("2.0", profile); + assertEquals("2.1", profileId, profile.getProfileId()); + + try { + op.redo(getMonitor(), null); + } catch (ExecutionException e) { + fail("3.99", e); + } + try { + profile = ProvisioningUtil.getProfile(profileId); + } catch (ProvisionException e) { + fail("2.99", e); + } + + assertNull("4.0", profile); + } +} diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/SizingTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/SizingTest.java new file mode 100644 index 000000000..d10ef8a2d --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/SizingTest.java @@ -0,0 +1,73 @@ +/******************************************************************************* + * Copyright (c) 2008 IBM Corporation and others. + * 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: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.p2.tests.ui.operations; + +import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; +import org.eclipse.equinox.internal.provisional.p2.director.ProvisioningPlan; +import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; +import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningContext; +import org.eclipse.equinox.internal.provisional.p2.engine.phases.Sizing; +import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.internal.provisional.p2.ui.operations.ProvisioningUtil; +import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; + +/** + * + */ +public class SizingTest extends AbstractProvisioningTest { + public void testEmptySizing() { + String profileId = "testEmptySizing"; + IProfile profile = createProfile(profileId); + ProfileChangeRequest request = new ProfileChangeRequest(profile); + ProvisioningPlan plan = null; + try { + plan = ProvisioningUtil.getProvisioningPlan(request, new ProvisioningContext(), getMonitor()); + } catch (ProvisionException e) { + fail("0.99", e); + return; + } + Sizing sizing = null; + try { + sizing = ProvisioningUtil.getSizeInfo(plan, profileId, getMonitor()); + } catch (ProvisionException e) { + fail("1.99", e); + } + assertEquals("1.0", 0, sizing.getDiskSize()); + assertEquals("1.1", 0, sizing.getDlSize()); + } + + /** + * Tests a simple sizing operation with an IU containing no artifacts + */ + public void testSimpleSizing() { + IInstallableUnit f1 = createIU("f1", DEFAULT_VERSION, true); + String profileId = "testSimpleSizing"; + IProfile profile = createProfile(profileId); + ProfileChangeRequest request = new ProfileChangeRequest(profile); + request.addInstallableUnits(new IInstallableUnit[] {f1}); + ProvisioningPlan plan = null; + try { + plan = ProvisioningUtil.getProvisioningPlan(request, new ProvisioningContext(), getMonitor()); + } catch (ProvisionException e) { + fail("0.99", e); + return; + } + Sizing sizing = null; + try { + sizing = ProvisioningUtil.getSizeInfo(plan, profileId, getMonitor()); + } catch (ProvisionException e) { + fail("1.99", e); + } + assertEquals("1.0", 0, sizing.getDiskSize()); + assertEquals("1.1", 0, sizing.getDlSize()); + } +} diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/AllTests.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/AllTests.java new file mode 100644 index 000000000..36e362645 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/AllTests.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 2008 IBM Corporation and others. + * 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: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.p2.tests.ui.query; + +import junit.framework.*; + +/** + * Performs all UI query tests. + */ +public class AllTests extends TestCase { + + public static Test suite() { + TestSuite suite = new TestSuite(AllTests.class.getName()); + suite.addTestSuite(AnyRequiredCapabilityTest.class); + suite.addTestSuite(AvailableIUCollectorTest.class); + suite.addTestSuite(CategoryElementCollectorTest.class); + suite.addTestSuite(IUPropertyUtilsTest.class); + suite.addTestSuite(LatestIUVersionCollectorTest.class); + suite.addTestSuite(LatestIUVersionElementCollectorTest.class); + suite.addTestSuite(QueryableMetadataRepositoryManagerTest.class); + return suite; + } +} diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/AnyRequiredCapabilityTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/AnyRequiredCapabilityTest.java new file mode 100644 index 000000000..448e44eaa --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/AnyRequiredCapabilityTest.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * Copyright (c) 2008 IBM Corporation and others. + * 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: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.p2.tests.ui.query; + +import java.net.URL; +import java.util.ArrayList; +import java.util.List; +import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.internal.provisional.p2.metadata.RequiredCapability; +import org.eclipse.equinox.internal.provisional.p2.query.Collector; +import org.eclipse.equinox.internal.provisional.p2.ui.model.MetadataRepositories; +import org.eclipse.equinox.internal.provisional.p2.ui.query.AnyRequiredCapabilityQuery; +import org.eclipse.equinox.internal.provisional.p2.ui.query.QueryableMetadataRepositoryManager; +import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; +import org.eclipse.equinox.p2.tests.TestData; + +/** + * Tests for {@link AnyRequiredCapabilityQuery}. + */ +public class AnyRequiredCapabilityTest extends AbstractProvisioningTest { + public void testMatchOtherObjects() { + RequiredCapability[] requires = createRequiredCapabilities("org.eclipse.equinox.p2.iu", "test.bundle", null); + AnyRequiredCapabilityQuery query = new AnyRequiredCapabilityQuery(requires); + IInstallableUnit match = createIU("test.bundle"); + IInstallableUnit noMatch = createIU("another.bundle"); + List items = new ArrayList(); + items.add(match); + items.add(noMatch); + items.add(new Object()); + items.add(requires); + Collector result = query.perform(items.iterator(), new Collector()); + assertEquals("1.0", 1, result.size()); + assertEquals("1.1", match, result.iterator().next()); + } + + public void testExistingRepository() { + URL location; + try { + location = TestData.getFile("metadataRepo", "good").toURL(); + } catch (Exception e) { + fail("0.99", e); + return; + } + MetadataRepositories repos = new MetadataRepositories(new URL[] {location}); + QueryableMetadataRepositoryManager manager = new QueryableMetadataRepositoryManager(repos); + RequiredCapability[] requires = createRequiredCapabilities("org.eclipse.equinox.p2.iu", "test.bundle", null); + AnyRequiredCapabilityQuery query = new AnyRequiredCapabilityQuery(requires); + Collector result = manager.query(query, new Collector(), getMonitor()); + assertEquals("1.0", 1, result.size()); + IInstallableUnit iu = (IInstallableUnit) result.iterator().next(); + assertEquals("1.1", "test.bundle", iu.getId()); + } + +} diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/AvailableIUCollectorTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/AvailableIUCollectorTest.java new file mode 100644 index 000000000..706553fac --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/AvailableIUCollectorTest.java @@ -0,0 +1,140 @@ +/******************************************************************************* + * Copyright (c) 2008 IBM Corporation and others. + * 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: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.p2.tests.ui.query; + +import java.util.*; +import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.internal.provisional.p2.metadata.query.IUPropertyQuery; +import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery; +import org.eclipse.equinox.internal.provisional.p2.query.Collector; +import org.eclipse.equinox.internal.provisional.p2.query.Query; +import org.eclipse.equinox.internal.provisional.p2.ui.model.CategoryElement; +import org.eclipse.equinox.internal.provisional.p2.ui.model.IUElement; +import org.eclipse.equinox.internal.provisional.p2.ui.query.AvailableIUCollector; +import org.eclipse.equinox.internal.provisional.p2.ui.query.ElementQueryDescriptor; +import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; +import org.eclipse.equinox.p2.tests.MockQueryable; +import org.osgi.framework.Version; + +/** + * Tests for {@link AvailableIUCollector}. + */ +public class AvailableIUCollectorTest extends AbstractProvisioningTest { + protected AvailableIUCollector createCollector() { + return createCollector(true); + } + + protected AvailableIUCollector createCollector(boolean makeCategories) { + return new AvailableIUCollector(new MockQueryProvider(new IUPropertyQuery("key", "value")), new MockQueryable(), null, makeCategories); + } + + /** + * Returns the IU corresponding to the collected element. + */ + protected IInstallableUnit getIU(Object collected) { + return ((IUElement) collected).getIU(); + } + + /** + * Tests collecting items AvailableIUCollector doesn't care about. + */ + public void testCollectObject() { + AvailableIUCollector collector = createCollector(); + Object object = new Object(); + collector.accept(object); + assertEquals("1.0", 1, collector.size()); + assertEquals("1.1", object, collector.iterator().next()); + } + + /** + * Tests collecting an IU. + */ + public void testCollectIU() { + AvailableIUCollector collector = createCollector(); + IInstallableUnit unit = createIU("f1"); + collector.accept(unit); + assertEquals("1.0", 1, collector.size()); + IInstallableUnit collectedIU = getIU(collector.iterator().next()); + assertEquals("1.1", unit, collectedIU); + } + + /** + * Tests collecting a category when makeCategory=true. + */ + public void testMakeCategory() { + AvailableIUCollector collector = createCollector(true); + Map properties = new HashMap(); + properties.put(IInstallableUnit.PROP_TYPE_CATEGORY, "true"); + IInstallableUnit category = createIU("category", new Version(1, 0, 0), NO_REQUIRES, properties, false); + IInstallableUnit unit = createIU("basicIU"); + collector.accept(category); + collector.accept(unit); + assertEquals("1.0", 2, collector.size()); + boolean categoryFound = false; + for (Iterator it = collector.iterator(); it.hasNext();) { + Object element = it.next(); + IInstallableUnit collected = getIU(element); + if (collected.equals(category)) { + categoryFound = true; + assertTrue("1.1", element instanceof CategoryElement); + } else { + assertEquals("1.2", unit, collected); + } + } + assertTrue("1.3", categoryFound); + } + + /** + * Tests collecting a category when makeCategory=false + */ + public void testNoMakeCategory() { + AvailableIUCollector collector = createCollector(false); + Map properties = new HashMap(); + properties.put(IInstallableUnit.PROP_TYPE_CATEGORY, "true"); + IInstallableUnit category = createIU("category", new Version(1, 0, 0), NO_REQUIRES, properties, false); + IInstallableUnit unit = createIU("basicIU"); + collector.accept(category); + collector.accept(unit); + assertEquals("1.0", 2, collector.size()); + boolean categoryFound = false; + for (Iterator it = collector.iterator(); it.hasNext();) { + Object element = it.next(); + IInstallableUnit collected = getIU(element); + if (collected.equals(category)) { + categoryFound = true; + assertFalse("1.1", element instanceof CategoryElement); + } else { + assertEquals("1.2", unit, collected); + } + } + assertTrue("1.3", categoryFound); + } + + /** + * Tests hiding installed IUs. + */ + public void testHideInstalled() { + AvailableIUCollector collector = createCollector(true); + IInstallableUnit installed = createIU("installed"); + IInstallableUnit notInstalled = createIU("notInstalled"); + Query installedQuery = new InstallableUnitQuery("installed"); + ElementQueryDescriptor installedDescriptor = new ElementQueryDescriptor(new MockQueryable(installed), installedQuery, new Collector()); + assertTrue("1.0", installedDescriptor.isComplete()); + collector.hideInstalledIUs(installedDescriptor); + + //now feed in the installed and non-installed units, and the installed unit should be ignored. + collector.accept(installed); + collector.accept(notInstalled); + assertEquals("1.1", 1, collector.size()); + Object iuElement = collector.iterator().next(); + assertEquals("1.2", notInstalled, getIU(iuElement)); + } +} diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/CategoryElementCollectorTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/CategoryElementCollectorTest.java new file mode 100644 index 000000000..b83812ff8 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/CategoryElementCollectorTest.java @@ -0,0 +1,88 @@ +/******************************************************************************* + * Copyright (c) 2008 IBM Corporation and others. + * 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: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.p2.tests.ui.query; + +import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.internal.provisional.p2.metadata.RequiredCapability; +import org.eclipse.equinox.internal.provisional.p2.query.Collector; +import org.eclipse.equinox.internal.provisional.p2.query.Query; +import org.eclipse.equinox.internal.provisional.p2.ui.model.CategoryElement; +import org.eclipse.equinox.internal.provisional.p2.ui.query.CategoryElementCollector; +import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; +import org.eclipse.equinox.p2.tests.MockQueryable; + +/** + * Tests for {@link CategoryElementCollector}. + */ +public class CategoryElementCollectorTest extends AbstractProvisioningTest { + private CategoryElementCollector createCollector(boolean showCategorized) { + IInstallableUnit category = createIU("default category"); + Query query = new Query() { + public boolean isMatch(Object candidate) { + return true; + } + }; + return new CategoryElementCollector(new MockQueryProvider(query), new MockQueryable(category), null, showCategorized); + } + + public void testCollectObject() { + CategoryElementCollector collector = createCollector(false); + collector.accept("AnObjectThatIsNotAnIU"); + assertTrue("1.0", collector.isEmpty()); + } + + /** + * Tests for the {@link Collector#isEmpty()} method. + */ + public void testIsEmpty() { + //if we have an uncategorized category, the collector is not initially empty + CategoryElementCollector collector = createCollector(true); + assertTrue("1.0", !collector.isEmpty()); + + //now create a collector with no uncategorized category + collector = createCollector(false); + assertTrue("1.1", collector.isEmpty()); + + IInstallableUnit category1 = createIU("category1"); + collector.accept(category1); + assertTrue("1.2", !collector.isEmpty()); + } + + /** + * Tests for the {@link Collector#size()} method. + */ + public void testSize() { + //if we have an uncategorized category, the collector is not initially empty + CategoryElementCollector collector = createCollector(true); + assertEquals("1.0", 1, collector.size()); + + //now create a collector with no uncategorized category + collector = createCollector(false); + assertEquals("1.1", 0, collector.size()); + + IInstallableUnit category1 = createIU("category1"); + collector.accept(category1); + assertEquals("1.2", 1, collector.size()); + assertEquals("1.3", category1, ((CategoryElement) collector.iterator().next()).getIU()); + assertEquals("1.4", category1, ((CategoryElement) collector.toCollection().iterator().next()).getIU()); + assertEquals("1.5", category1, ((CategoryElement) collector.toArray(CategoryElement.class)[0]).getIU()); + + //adding the same category twice shouldn't affect size + collector.accept(category1); + assertEquals("1.6", 1, collector.size()); + + //adding a nested category shouldn't affected size + RequiredCapability[] required = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "category1", null); + IInstallableUnit nested = createIU("Nested", required); + collector.accept(nested); + assertEquals("1.7", 1, collector.size()); + } +} diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/IUPropertyUtilsTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/IUPropertyUtilsTest.java new file mode 100644 index 000000000..a6edf6d90 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/IUPropertyUtilsTest.java @@ -0,0 +1,73 @@ +/******************************************************************************* + * Copyright (c) 2008 IBM Corporation and others. + * 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: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.p2.tests.ui.query; + +import java.io.File; +import java.net.MalformedURLException; +import java.net.URL; +import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; +import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; +import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery; +import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository; +import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager; +import org.eclipse.equinox.internal.provisional.p2.query.Collector; +import org.eclipse.equinox.internal.provisional.p2.ui.query.IUPropertyUtils; +import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; +import org.eclipse.equinox.p2.tests.TestActivator; + +/** + * Tests for {@link IUPropertyUtils}. + */ +public class IUPropertyUtilsTest extends AbstractProvisioningTest { + public void testFeatureProperties() { + IMetadataRepositoryManager repoMan = (IMetadataRepositoryManager) ServiceHelper.getService(TestActivator.getContext(), IMetadataRepositoryManager.class.getName()); + File site = getTestData("0.1", "/testData/metadataRepo/externalized"); + URL location = null; + try { + location = site.toURL(); + } catch (MalformedURLException e) { + fail("0.99", e); + } + IMetadataRepository repository; + try { + repository = repoMan.loadRepository(location, getMonitor()); + } catch (ProvisionException e) { + fail("1.99", e); + return; + } + Collector result = repository.query(new InstallableUnitQuery("test.feature.feature.group"), new Collector(), getMonitor()); + assertTrue("1.0", !result.isEmpty()); + IInstallableUnit unit = (IInstallableUnit) result.iterator().next(); + + Copyright copyright = IUPropertyUtils.getCopyright(unit); + assertEquals("1.1", "Test Copyright", copyright.getBody()); + License license = IUPropertyUtils.getLicense(unit); + assertEquals("1.2", "Test License", license.getBody()); + // assertEquals("1.3", "license.html", license.getURL().toExternalForm()); + String name = IUPropertyUtils.getIUProperty(unit, IInstallableUnit.PROP_NAME); + assertEquals("1.4", "Test Feature Name", name); + String description = IUPropertyUtils.getIUProperty(unit, IInstallableUnit.PROP_DESCRIPTION); + assertEquals("1.5", "Test Description", description); + String provider = IUPropertyUtils.getIUProperty(unit, IInstallableUnit.PROP_PROVIDER); + assertEquals("1.6", "Test Provider Name", provider); + } + + public void testBasicIU() { + IInstallableUnit unit = createIU("f1"); + + assertNull("1.1", IUPropertyUtils.getCopyright(unit)); + assertNull("1.2", IUPropertyUtils.getLicense(unit)); + assertNull("1.3", IUPropertyUtils.getIUProperty(unit, IInstallableUnit.PROP_NAME)); + assertNull("1.4", IUPropertyUtils.getIUProperty(unit, IInstallableUnit.PROP_DESCRIPTION)); + assertNull("1.5", IUPropertyUtils.getIUProperty(unit, IInstallableUnit.PROP_PROVIDER)); + } +} diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/LatestIUVersionCollectorTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/LatestIUVersionCollectorTest.java new file mode 100644 index 000000000..ebf359aa1 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/LatestIUVersionCollectorTest.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * Copyright (c) 2008 IBM Corporation and others. + * 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: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.p2.tests.ui.query; + +import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.internal.provisional.p2.metadata.query.IUPropertyQuery; +import org.eclipse.equinox.internal.provisional.p2.ui.model.IUElement; +import org.eclipse.equinox.internal.provisional.p2.ui.query.AvailableIUCollector; +import org.eclipse.equinox.internal.provisional.p2.ui.query.LatestIUVersionCollector; +import org.eclipse.equinox.p2.tests.MockQueryable; +import org.osgi.framework.Version; + +/** + * Tests for {@link LatestIUVersionCollector}. This has all the tests of the superclass, + * plus some extras for testing the latest IU capabilities. + */ +public class LatestIUVersionCollectorTest extends AvailableIUCollectorTest { + + protected AvailableIUCollector createCollector(boolean makeCategories) { + return new LatestIUVersionCollector(new MockQueryProvider(new IUPropertyQuery("key", "value")), new MockQueryable(), null, makeCategories); + } + + /** + * Returns the IU corresponding to the collected element. + */ + protected IInstallableUnit getIU(Object collected) { + if (collected instanceof IInstallableUnit) + return (IInstallableUnit) collected; + return ((IUElement) collected).getIU(); + } + + /** + * Tests collecting items AvailableIUCollector doesn't care about. + */ + public void testCollectObject() { + AvailableIUCollector collector = createCollector(); + Object object = new Object(); + collector.accept(object); + assertEquals("1.0", 0, collector.size()); + } + + /** + * Tests that only the latest version is collected. + */ + public void testCollectLatestIU() { + AvailableIUCollector collector = createCollector(); + IInstallableUnit unit1 = createIU("f1", new Version(1, 0, 0)); + IInstallableUnit unit2 = createIU("f1", new Version(1, 0, 1)); + collector.accept(unit1); + collector.accept(unit2); + assertEquals("1.0", 1, collector.size()); + IInstallableUnit collectedIU = getIU(collector.iterator().next()); + assertEquals("1.1", unit2, collectedIU); + } +} diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/LatestIUVersionElementCollectorTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/LatestIUVersionElementCollectorTest.java new file mode 100644 index 000000000..bcaa32a59 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/LatestIUVersionElementCollectorTest.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2008 IBM Corporation and others. + * 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: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.p2.tests.ui.query; + +import org.eclipse.equinox.internal.provisional.p2.metadata.query.IUPropertyQuery; +import org.eclipse.equinox.internal.provisional.p2.ui.query.AvailableIUCollector; +import org.eclipse.equinox.internal.provisional.p2.ui.query.LatestIUVersionElementCollector; +import org.eclipse.equinox.p2.tests.MockQueryable; + +/** + * + */ +public class LatestIUVersionElementCollectorTest extends LatestIUVersionCollectorTest { + protected AvailableIUCollector createCollector(boolean makeCategories) { + return new LatestIUVersionElementCollector(new MockQueryProvider(new IUPropertyQuery("key", "value")), new MockQueryable(), null, makeCategories); + } +} diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/MockQueryProvider.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/MockQueryProvider.java new file mode 100644 index 000000000..9ede1bbf6 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/MockQueryProvider.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2008 IBM Corporation and others. + * 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: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.p2.tests.ui.query; + +import org.eclipse.equinox.internal.provisional.p2.query.Collector; +import org.eclipse.equinox.internal.provisional.p2.query.Query; +import org.eclipse.equinox.internal.provisional.p2.ui.policy.IQueryProvider; +import org.eclipse.equinox.internal.provisional.p2.ui.query.ElementQueryDescriptor; +import org.eclipse.equinox.p2.tests.MockQueryable; + +/** + * A fake query provider for unit testing. + */ +public class MockQueryProvider implements IQueryProvider { + private Query query; + + public MockQueryProvider(Query query) { + this.query = query; + } + + public ElementQueryDescriptor getQueryDescriptor(Object element, int queryType) { + return new ElementQueryDescriptor(new MockQueryable(element), query, new Collector()); + } +} diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/QueryableMetadataRepositoryManagerTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/QueryableMetadataRepositoryManagerTest.java new file mode 100644 index 000000000..c2b52d1a4 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/QueryableMetadataRepositoryManagerTest.java @@ -0,0 +1,169 @@ +/******************************************************************************* + * Copyright (c) 2008 IBM Corporation and others. + * 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: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.p2.tests.ui.query; + +import java.io.File; +import java.net.URL; +import java.util.Collection; +import org.eclipse.core.tests.harness.CancelingProgressMonitor; +import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery; +import org.eclipse.equinox.internal.provisional.p2.query.Collector; +import org.eclipse.equinox.internal.provisional.p2.ui.model.MetadataRepositories; +import org.eclipse.equinox.internal.provisional.p2.ui.query.QueryableMetadataRepositoryManager; +import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; +import org.eclipse.equinox.p2.tests.TestData; +import org.osgi.framework.Version; + +/** + * Tests for {@link QueryableMetadataRepositoryManager}. + */ +public class QueryableMetadataRepositoryManagerTest extends AbstractProvisioningTest { + /** + * Tests querying against a non-existent repository + */ + public void testBrokenRepository() { + URL brokenRepo; + try { + brokenRepo = TestData.getFile("metadataRepo", "bad").toURL(); + } catch (Exception e) { + fail("0.99", e); + return; + } + MetadataRepositories repos = new MetadataRepositories(new URL[] {brokenRepo}); + QueryableMetadataRepositoryManager manager = new QueryableMetadataRepositoryManager(repos); + assertTrue("1.0", !manager.areRepositoriesLoaded()); + + manager.loadAll(getMonitor()); + + //false because the broken repository is not loaded + assertTrue("1.1", !manager.areRepositoriesLoaded()); + } + + /** + * Tests canceling a load + */ + public void testCancelLoad() { + URL location; + try { + location = TestData.getFile("metadataRepo", "good").toURL(); + } catch (Exception e) { + fail("0.99", e); + return; + } + MetadataRepositories repos = new MetadataRepositories(new URL[] {location}); + QueryableMetadataRepositoryManager manager = new QueryableMetadataRepositoryManager(repos); + assertTrue("1.0", !manager.areRepositoriesLoaded()); + + manager.loadAll(new CancelingProgressMonitor()); + + //should not be loaded due to cancelation + assertTrue("1.1", !manager.areRepositoriesLoaded()); + } + + public void testCancelQuery() { + URL existing, nonExisting, broken; + try { + existing = TestData.getFile("metadataRepo", "good").toURL(); + nonExisting = new File("does/not/exist/testNotFoundRepository").toURL(); + broken = TestData.getFile("metadataRepo", "bad").toURL(); + } catch (Exception e) { + fail("0.99", e); + return; + } + MetadataRepositories repos = new MetadataRepositories(new URL[] {existing, nonExisting, broken}); + QueryableMetadataRepositoryManager manager = new QueryableMetadataRepositoryManager(repos); + + Collector result = manager.query(new InstallableUnitQuery("test.bundle", new Version(1, 0, 0)), new Collector(), new CancelingProgressMonitor()); + assertEquals("1.0", 0, result.size()); + + //null query collects repository URLs + result = manager.query(null, new Collector(), new CancelingProgressMonitor()); + assertEquals("2.0", 0, result.size()); + } + + public void testExistingRepository() { + URL location; + try { + location = TestData.getFile("metadataRepo", "good").toURL(); + } catch (Exception e) { + fail("0.99", e); + return; + } + MetadataRepositories repos = new MetadataRepositories(new URL[] {location}); + QueryableMetadataRepositoryManager manager = new QueryableMetadataRepositoryManager(repos); + assertTrue("1.0", !manager.areRepositoriesLoaded()); + + manager.loadAll(getMonitor()); + + assertTrue("1.1", manager.areRepositoriesLoaded()); + } + + /** + * Tests querying against a non-existent repository + */ + public void testNotFoundRepository() { + URL existing, nonExisting; + try { + existing = TestData.getFile("metadataRepo", "good").toURL(); + nonExisting = new File("does/not/exist/testNotFoundRepository").toURL(); + } catch (Exception e) { + fail("0.99", e); + return; + } + MetadataRepositories repos = new MetadataRepositories(new URL[] {existing, nonExisting}); + QueryableMetadataRepositoryManager manager = new QueryableMetadataRepositoryManager(repos); + assertTrue("1.0", !manager.areRepositoriesLoaded()); + + manager.loadAll(getMonitor()); + + //false because the non-existent repository is not loaded + assertTrue("1.1", !manager.areRepositoriesLoaded()); + } + + /** + * When QueryableMetadataRepositoryManager has a null set of repositories, it uses all known repositories + */ + public void testNullRepositories() { + MetadataRepositories repos = new MetadataRepositories(); + repos.setIncludeDisabledRepositories(true); + QueryableMetadataRepositoryManager manager = new QueryableMetadataRepositoryManager(repos); + manager.loadAll(getMonitor()); + manager.areRepositoriesLoaded(); + } + + public void testQuery() { + URL existing, nonExisting, broken; + try { + existing = TestData.getFile("metadataRepo", "good").toURL(); + nonExisting = new File("does/not/exist/testNotFoundRepository").toURL(); + broken = TestData.getFile("metadataRepo", "bad").toURL(); + } catch (Exception e) { + fail("0.99", e); + return; + } + MetadataRepositories repos = new MetadataRepositories(new URL[] {existing, nonExisting, broken}); + QueryableMetadataRepositoryManager manager = new QueryableMetadataRepositoryManager(repos); + + Collector result = manager.query(new InstallableUnitQuery("test.bundle", new Version(1, 0, 0)), new Collector(), getMonitor()); + assertEquals("1.0", 1, result.size()); + IInstallableUnit iu = (IInstallableUnit) result.iterator().next(); + assertEquals("1.1", "test.bundle", iu.getId()); + + //null query collects repository URLs + result = manager.query(null, new Collector(), getMonitor()); + assertEquals("2.0", 3, result.size()); + Collection resultCollection = result.toCollection(); + assertTrue("2.1", resultCollection.contains(existing)); + assertTrue("2.1", resultCollection.contains(nonExisting)); + assertTrue("2.1", resultCollection.contains(broken)); + } +} diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/test.xml b/bundles/org.eclipse.equinox.p2.tests.ui/test.xml new file mode 100644 index 000000000..856774cf7 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests.ui/test.xml @@ -0,0 +1,59 @@ +<?xml version="1.0"?> +<project name="p2 Automated Tests" default="run" basedir="."> + + <!-- The property ${eclipse-home} should be passed into this script --> + <!-- sets the properties eclipse-home, and library-file --> + <property name="eclipse-home" value="${basedir}/../../" /> + <property name="library-file" value="${eclipse-home}/plugins/org.eclipse.test/library.xml" /> + <property name="p2_location" value="${eclipse-home}/p2_sniff_folder" /> + <property name="plugin-name" value="org.eclipse.equinox.p2.tests" /> + + <!-- This target holds all initialization code that needs to be done for --> + <!-- all tests that are to be run. Initialization for individual tests --> + <!-- should be done within the body of the suite target. --> + <target name="init"> + <tstamp /> + </target> + + <!-- This target holds code to cleanup the testing environment after the tests --> + <!-- have been run. You can use this to delete temporary files that are created. --> + <target name="cleanup"> + <delete dir="${p2_location}" quiet="true" /> + </target> + + <!-- This target runs the test suite. Any actions that need to happen after all --> + <!-- the tests have been run should go here. --> + <target name="run" depends="init,suite,cleanup"> + <ant target="collect" antfile="${library-file}" dir="${eclipse-home}"> + <property name="includes" value="org*.xml" /> + <property name="output-file" value="${plugin-name}.xml" /> + </ant> + </target> + + <!-- This target runs the performance test suites. Any actions that need to happen after all --> + <!-- the tests have been run should go here. --> + <target name="performance" depends="init,performance-suite,cleanup"> + <ant target="collect" antfile="${library-file}" dir="${eclipse-home}"> + <property name="includes" value="org*.xml" /> + <property name="output-file" value="${plugin-name}.xml" /> + </ant> + </target> + + <target name="p2Tests" depends="init,cleanup"> + <ant target="core-test" antfile="${library-file}" dir="${eclipse-home}"> + <property name="data-dir" value="${p2_location}" /> + <property name="plugin-name" value="org.eclipse.equinox.p2.tests" /> + <property name="classname" value="org.eclipse.equinox.p2.tests.AutomatedTests" /> + </ant> + </target> + + <!-- This target defines the tests that need to be run. --> + <target name="suite" depends="p2Tests" /> + + <!-- This target defines the performance tests that need to be run. --> + <target name="performance-suite" depends="p2PerformanceTests" /> + + <target name="p2PerformanceTests"> + <!-- TODO --> + </target> +</project> |