Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcletavernie2013-03-11 18:22:18 +0000
committercletavernie2013-03-11 18:22:18 +0000
commitaa79b57f3f930fdf3c8e5e6b0d50821cf6d9596d (patch)
tree2dc2ae606af33f6cf6b10d311accd89195ad75d5
parent4cafc9ba9b52c13b89a4ad6557afeea15621b6b8 (diff)
downloadorg.eclipse.papyrus-aa79b57f3f930fdf3c8e5e6b0d50821cf6d9596d.tar.gz
org.eclipse.papyrus-aa79b57f3f930fdf3c8e5e6b0d50821cf6d9596d.tar.xz
org.eclipse.papyrus-aa79b57f3f930fdf3c8e5e6b0d50821cf6d9596d.zip
290952: [CDO] Support for CDO model repository
https://bugs.eclipse.org/bugs/show_bug.cgi?id=290952 Merge the tests from cdo_kepler to the trunk (From r10476)
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/.classpath7
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/.project28
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/.settings/org.eclipse.jdt.core.prefs287
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/.settings/org.eclipse.jdt.ui.prefs58
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/META-INF/MANIFEST.MF27
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/about.html28
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/build.properties8
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/plugin.properties13
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/resources/empty/model.di17
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/resources/empty/model.notation5
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/resources/empty/model.uml2
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/resources/projects/has_dependencies.zipbin0 -> 4928 bytes
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/resources/projects/has_dependents.zipbin0 -> 2389 bytes
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/resources/projects/isolated.zipbin0 -> 4790 bytes
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/core/resource/tests/CDOAwareModelSetTest.java246
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/core/tests/AbstractPapyrusCDOTest.java241
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/core/tests/AllTests.java37
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/core/tests/TestProject.java178
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/core/util/tests/AllUtilTests.java30
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/core/util/tests/CDOFunctionsTest.java107
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/core/util/tests/CDOPredicatesTest.java78
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/exporter/tests/AbstractModelExportTest.java130
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/exporter/tests/AllModelExportTests.java29
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/exporter/tests/ModelExportMappingTest.java164
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/exporter/tests/ModelExporterTest.java161
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/expressions/tests/AllExpressionsTests.java30
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/expressions/tests/EObjectPropertyTesterTest.java40
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/importer/tests/AllModelImportTests.java31
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/importer/tests/ManyToOneModelImportMappingTest.java137
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/importer/tests/ModelImportConfigurationTest.java196
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/importer/tests/ModelImporterTest.java205
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/importer/tests/OneToOneModelImportMappingTest.java179
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/tests/PapyrusRepositoryManagerTest.java442
33 files changed, 3141 insertions, 0 deletions
diff --git a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/.classpath b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/.classpath
new file mode 100644
index 00000000000..64c5e31b7a2
--- /dev/null
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/.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.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/.project b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/.project
new file mode 100644
index 00000000000..b8f6f8a443a
--- /dev/null
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.cdo.core.tests</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/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/.settings/org.eclipse.jdt.core.prefs b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..a13557a0d1f
--- /dev/null
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,287 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=0
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=0
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=0
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=0
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=0
+org.eclipse.jdt.core.formatter.alignment_for_assignment=0
+org.eclipse.jdt.core.formatter.alignment_for_binary_expression=0
+org.eclipse.jdt.core.formatter.alignment_for_compact_if=0
+org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=0
+org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
+org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=0
+org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0
+org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
+org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=0
+org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=0
+org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80
+org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=0
+org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=0
+org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=0
+org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=0
+org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=0
+org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=0
+org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16
+org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
+org.eclipse.jdt.core.formatter.blank_lines_after_package=1
+org.eclipse.jdt.core.formatter.blank_lines_before_field=1
+org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=1
+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=next_line
+org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=next_line
+org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false
+org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
+org.eclipse.jdt.core.formatter.comment.format_block_comments=true
+org.eclipse.jdt.core.formatter.comment.format_header=false
+org.eclipse.jdt.core.formatter.comment.format_html=true
+org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true
+org.eclipse.jdt.core.formatter.comment.format_line_comments=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=true
+org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
+org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert
+org.eclipse.jdt.core.formatter.comment.line_length=150
+org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true
+org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true
+org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false
+org.eclipse.jdt.core.formatter.compact_else_if=true
+org.eclipse.jdt.core.formatter.continuation_indentation=1
+org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=1
+org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off
+org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on
+org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
+org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
+org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true
+org.eclipse.jdt.core.formatter.indent_empty_lines=false
+org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
+org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
+org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
+org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false
+org.eclipse.jdt.core.formatter.indentation.size=4
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
+org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=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_semicolon_in_try_resources=insert
+org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
+org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=do not 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=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=do not 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=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=do not 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_semicolon_in_try_resources=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.join_lines_in_comments=false
+org.eclipse.jdt.core.formatter.join_wrapped_lines=true
+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=200
+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=5
+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_on_off_tags=false
+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.formatter.wrap_before_or_operator_multicatch=true
+org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true
diff --git a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/.settings/org.eclipse.jdt.ui.prefs b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/.settings/org.eclipse.jdt.ui.prefs
new file mode 100644
index 00000000000..272e835ec52
--- /dev/null
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/.settings/org.eclipse.jdt.ui.prefs
@@ -0,0 +1,58 @@
+eclipse.preferences.version=1
+editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
+formatter_profile=_Papyrus Formatter Profile CDM
+formatter_settings_version=12
+org.eclipse.jdt.ui.javadoc=true
+org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\n * @return the ${bare_field_name}\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\n * @param ${param} the ${bare_field_name} to set\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\n * ${tags}\n */</template><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/*****************************************************************************\n * Copyright (c) ${year} CEA LIST.\n * \n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http\://www.eclipse.org/legal/epl-v10.html\n *\n * Contributors\:\n * CEA LIST - Initial API and implementation\n *****************************************************************************/</template><template autoinsert\="false" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\n * This is the ${type_name} type. Enjoy.\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\n * \n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\n * ${tags}\n */</template><template autoinsert\="false" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment"/><template autoinsert\="true" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\n * ${tags}\n * ${see_to_target}\n */</template><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\n${package_declaration}\n\n${typecomment}\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\n</template><template autoinsert\="true" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\n${exception_var}.printStackTrace();</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method stub\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></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_methods=false
+sp_cleanup.add_missing_nls_tags=false
+sp_cleanup.add_missing_override_annotations=true
+sp_cleanup.add_missing_override_annotations_interface_methods=true
+sp_cleanup.add_serial_version_id=false
+sp_cleanup.always_use_blocks=true
+sp_cleanup.always_use_parentheses_in_expressions=false
+sp_cleanup.always_use_this_for_non_static_field_access=false
+sp_cleanup.always_use_this_for_non_static_method_access=false
+sp_cleanup.convert_to_enhanced_for_loop=false
+sp_cleanup.correct_indentation=false
+sp_cleanup.format_source_code=true
+sp_cleanup.format_source_code_changes_only=false
+sp_cleanup.make_local_variable_final=false
+sp_cleanup.make_parameters_final=false
+sp_cleanup.make_private_fields_final=true
+sp_cleanup.make_type_abstract_if_missing_method=false
+sp_cleanup.make_variable_declarations_final=true
+sp_cleanup.never_use_blocks=false
+sp_cleanup.never_use_parentheses_in_expressions=true
+sp_cleanup.on_save_use_additional_actions=true
+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/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/META-INF/MANIFEST.MF b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..64367d30cd4
--- /dev/null
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/META-INF/MANIFEST.MF
@@ -0,0 +1,27 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.eclipse.papyrus.cdo.core.tests
+Bundle-Version: 0.10.0.qualifier
+Bundle-Vendor: %providerName
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-Localization: plugin
+Require-Bundle: org.eclipse.papyrus.cdo.core;bundle-version="0.10.0";visibility:=reexport,
+ org.junit;bundle-version="4.8.0";visibility:=reexport,
+ org.eclipse.uml2.uml;bundle-version="[4.0.0,5.0.0)";visibility:=reexport,
+ org.eclipse.emf.cdo.server.net4j;bundle-version="[4.1.0,5.0.0)",
+ org.eclipse.emf.cdo.net4j;bundle-version="[4.1.0,5.0.0)",
+ org.eclipse.net4j.jvm;bundle-version="[4.1.0,5.0.0)",
+ org.eclipse.papyrus.uml.tools;bundle-version="0.10.0",
+ org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="0.10.0",
+ org.eclipse.core.expressions;bundle-version="3.4.0"
+Import-Package: com.google.common.base;version="10.0.1",
+ com.google.common.collect;version="10.0.1",
+ com.google.common.io;version="10.0.1"
+Export-Package: org.eclipse.papyrus.cdo.core.resource.tests,
+ org.eclipse.papyrus.cdo.core.tests,
+ org.eclipse.papyrus.cdo.core.util.tests,
+ org.eclipse.papyrus.cdo.internal.core.exporter.tests;x-internal:=true,
+ org.eclipse.papyrus.cdo.internal.core.expressions.tests;x-internal:=true,
+ org.eclipse.papyrus.cdo.internal.core.importer.tests;x-internal:=true,
+ org.eclipse.papyrus.cdo.internal.core.tests;x-internal:=true
diff --git a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/about.html b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/about.html
new file mode 100644
index 00000000000..209103075a7
--- /dev/null
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/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>November 14, 2008</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). 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, &quot;Program&quot; 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 (&quot;Redistributor&quot;) 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/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/build.properties b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/build.properties
new file mode 100644
index 00000000000..9de44fbc9f5
--- /dev/null
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/build.properties
@@ -0,0 +1,8 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.properties,\
+ about.html,\
+ resources/
+src.includes = about.html
diff --git a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/plugin.properties b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/plugin.properties
new file mode 100644
index 00000000000..f984f57b278
--- /dev/null
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/plugin.properties
@@ -0,0 +1,13 @@
+# Copyright (c) 2013 CEA LIST.
+#
+# 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:
+# CEA LIST - Initial API and implementation
+#
+
+pluginName = Papyrus CDO Model Repository Core Tests (Incubation)
+providerName = Eclipse Modeling Project
diff --git a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/resources/empty/model.di b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/resources/empty/model.di
new file mode 100644
index 00000000000..1e92730aa66
--- /dev/null
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/resources/empty/model.di
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<di:SashWindowsMngr xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.eclipse.org/papyrus/0.7.0/sashdi">
+ <pageList>
+ <availablePage>
+ <emfPageIdentifier href="model.notation#_4OB64IgIEeKgsNTItrb1JA"/>
+ </availablePage>
+ </pageList>
+ <sashModel currentSelection="//@sashModel/@windows.0/@children.0">
+ <windows>
+ <children xsi:type="di:TabFolder">
+ <children>
+ <emfPageIdentifier href="model.notation#_4OB64IgIEeKgsNTItrb1JA"/>
+ </children>
+ </children>
+ </windows>
+ </sashModel>
+</di:SashWindowsMngr>
diff --git a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/resources/empty/model.notation b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/resources/empty/model.notation
new file mode 100644
index 00000000000..f032e67e18c
--- /dev/null
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/resources/empty/model.notation
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<notation:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.2/notation" xmlns:uml="http://www.eclipse.org/uml2/4.0.0/UML" xmi:id="_4OB64IgIEeKgsNTItrb1JA" type="PapyrusUMLClassDiagram" name="NewDiagram" measurementUnit="Pixel">
+ <styles xmi:type="notation:DiagramStyle" xmi:id="_4OB64YgIEeKgsNTItrb1JA"/>
+ <element xmi:type="uml:Model" href="model.uml#_4NgWcIgIEeKgsNTItrb1JA"/>
+</notation:Diagram>
diff --git a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/resources/empty/model.uml b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/resources/empty/model.uml
new file mode 100644
index 00000000000..f0388b55607
--- /dev/null
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/resources/empty/model.uml
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<uml:Model xmi:version="20110701" xmlns:xmi="http://www.omg.org/spec/XMI/20110701" xmlns:uml="http://www.eclipse.org/uml2/4.0.0/UML" xmi:id="_4NgWcIgIEeKgsNTItrb1JA" name="model"/>
diff --git a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/resources/projects/has_dependencies.zip b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/resources/projects/has_dependencies.zip
new file mode 100644
index 00000000000..58a7e32a64f
--- /dev/null
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/resources/projects/has_dependencies.zip
Binary files differ
diff --git a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/resources/projects/has_dependents.zip b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/resources/projects/has_dependents.zip
new file mode 100644
index 00000000000..616ca0c1597
--- /dev/null
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/resources/projects/has_dependents.zip
Binary files differ
diff --git a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/resources/projects/isolated.zip b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/resources/projects/isolated.zip
new file mode 100644
index 00000000000..d305aa1f86e
--- /dev/null
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/resources/projects/isolated.zip
Binary files differ
diff --git a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/core/resource/tests/CDOAwareModelSetTest.java b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/core/resource/tests/CDOAwareModelSetTest.java
new file mode 100644
index 00000000000..1d834ce0867
--- /dev/null
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/core/resource/tests/CDOAwareModelSetTest.java
@@ -0,0 +1,246 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.core.resource.tests;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assume.assumeThat;
+import static org.junit.matchers.JUnitMatchers.containsString;
+
+import java.util.Collections;
+
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.net4j.util.lifecycle.LifecycleException;
+import org.eclipse.papyrus.cdo.core.resource.CDOAwareModelSet;
+import org.eclipse.papyrus.cdo.core.resource.CDOAwareTransactionalEditingDomain;
+import org.eclipse.papyrus.cdo.core.resource.PapyrusCDOResourceFactory;
+import org.eclipse.papyrus.cdo.core.tests.AbstractPapyrusCDOTest;
+import org.eclipse.papyrus.infra.core.Activator;
+import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.core.services.ExtensionServicesRegistry;
+import org.eclipse.papyrus.infra.core.services.ServiceMultiException;
+import org.eclipse.papyrus.infra.core.services.ServiceNotFoundException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.emf.readonly.ReadOnlyManager;
+import org.eclipse.uml2.uml.Model;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.UMLPackage;
+import org.hamcrest.CoreMatchers;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.matchers.JUnitMatchers;
+
+import com.google.common.base.Function;
+import com.google.common.base.Predicates;
+import com.google.common.collect.Iterables;
+
+/**
+ * This is the CDOAwareModelSetTest type. Enjoy.
+ */
+public class CDOAwareModelSetTest
+ extends AbstractPapyrusCDOTest {
+
+ private static final String MODEL_FILENAME = "model.uml";
+
+ private ServicesRegistry services;
+
+ private ModelSet fixture;
+
+ public CDOAwareModelSetTest() {
+ super();
+ }
+
+ @Test
+ public void modelSetCreated() {
+ Resource resource = fixture.getResource(
+ getTestResourceURI(MODEL_FILENAME), false);
+ assertThat(resource, notNullValue());
+
+ CDOTransaction transaction = getTransaction(fixture);
+
+ assertThat(transaction.isClosed(), is(false));
+ assertThat(transaction.isDirty(), is(false));
+ }
+
+ @Test
+ public void unloadModelSet()
+ throws Exception {
+ fixture.unload();
+
+ assertThat(fixture.getResources(), equalTo(Collections.EMPTY_LIST));
+
+ fixture.loadModels(getTestResourceURI(MODEL_FILENAME));
+
+ CDOTransaction transaction = getTransaction(fixture);
+ assertThat(transaction.isDirty(), is(false));
+
+ Resource resource = fixture.getResource(
+ getTestResourceURI(MODEL_FILENAME), false);
+ assertThat(resource, notNullValue());
+ assertThat(resource.isLoaded(), is(true));
+ }
+
+ @Test
+ public void cdoResourceFactory() {
+ CDOTransaction transaction = getTransaction(fixture);
+
+ Resource resource = transaction
+ .getOrCreateResource(getResourcePath(MODEL_FILENAME));
+ assertThat(
+ fixture.getResourceFactoryRegistry().getFactory(resource.getURI()),
+ instanceOf(PapyrusCDOResourceFactory.class));
+ }
+
+ @Test
+ public void editingDomain() {
+ assertThat(fixture.getTransactionalEditingDomain(),
+ instanceOf(CDOAwareTransactionalEditingDomain.class));
+ }
+
+ @Test
+ public void cdoResourceNotReadOnly() {
+ CDOTransaction transaction = getTransaction(fixture);
+
+ Resource resource = transaction
+ .getOrCreateResource(getResourcePath(MODEL_FILENAME));
+ assertThat(
+ ReadOnlyManager.isReadOnly(resource,
+ fixture.getTransactionalEditingDomain()), is(false));
+ }
+
+ @Test
+ public void getEObject()
+ throws Exception {
+
+ ResourceSet other = getPapyrusRepository().createTransaction(
+ new ResourceSetImpl());
+
+ Resource resource = getTransaction(other).getOrCreateResource(
+ getResourcePath("other.uml"));
+
+ Model model = UMLFactory.eINSTANCE.createModel();
+ model.setName("test");
+ resource.getContents().add(model);
+
+ getPapyrusRepository().commit(other);
+
+ // must get the URI *after* commit, because the fragment of a
+ // persisted object is different than that of a transient object
+ URI uri = EcoreUtil.getURI(model);
+
+ getPapyrusRepository().close(other);
+
+ EObject retrieved = fixture.getEObject(uri, true);
+ model = cast(retrieved, Model.class);
+ assertThat(model.getName(), equalTo("test"));
+ }
+
+ @Test
+ public void resolveProxy()
+ throws Exception {
+
+ ResourceSet other = getPapyrusRepository().createTransaction(
+ new ResourceSetImpl());
+
+ Resource resource1 = getTransaction(other).getOrCreateResource(
+ getResourcePath(MODEL_FILENAME));
+ Model model1 = UMLFactory.eINSTANCE.createModel();
+ model1.setName("model1");
+ resource1.getContents().add(model1);
+
+ Resource resource2 = getTransaction(other).getOrCreateResource(
+ getResourcePath("other.uml"));
+ Model model2 = UMLFactory.eINSTANCE.createModel();
+ model2.setName("model2");
+ resource2.getContents().add(model2);
+ model2.createPackageImport(model1);
+
+ URI uri = resource2.getURI();
+
+ getPapyrusRepository().commit(other);
+ getPapyrusRepository().close(other);
+
+ Resource resource = fixture.getResource(uri, true);
+ Model referencer = (Model) EcoreUtil.getObjectByType(
+ resource.getContents(), UMLPackage.Literals.MODEL);
+ assertThat(referencer.getImportedPackages(),
+ JUnitMatchers.<Package> hasItem(CoreMatchers.<Package> anything()));
+ Package imported = referencer.getImportedPackages().get(0);
+ assertThat(imported.eIsProxy(), is(false));
+ assertThat(imported.getName(), equalTo("model1"));
+ }
+
+ //
+ // Test framework
+ //
+
+ @Before
+ public void createModelSet()
+ throws Exception {
+
+ services = new ExtensionServicesRegistry(Activator.PLUGIN_ID);
+
+ try {
+ // start the ModelSet and its dependencies
+ services.startServicesByClassKeys(ModelSet.class);
+ } catch (ServiceMultiException e) {
+ for (ServiceNotFoundException next : Iterables.filter(
+ e.getExceptions(), ServiceNotFoundException.class)) {
+ assertThat(next.getLocalizedMessage(),
+ not(containsString("ModelSet")));
+ }
+ }
+
+ fixture = services.getService(ModelSet.class);
+
+ assumeThat(fixture, instanceOf(CDOAwareModelSet.class));
+
+ fixture.createModels(getTestResourceURI(MODEL_FILENAME));
+ getPapyrusRepository().commit(fixture);
+ }
+
+ @After
+ public void disposeModelSet()
+ throws Exception {
+
+ try {
+ services.disposeRegistry();
+ } catch (ServiceMultiException e) {
+ if (Iterables.any(Iterables.transform(e.getExceptions(),
+ new Function<Throwable, Throwable>() {
+
+ public Throwable apply(Throwable input) {
+ return input.getCause();
+ }
+ }), Predicates.instanceOf(LifecycleException.class))) {
+
+ // known exception due to minimal CDOObject implementation
+ } else {
+ throw e;
+ }
+ } finally {
+ services = null;
+ }
+ }
+}
diff --git a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/core/tests/AbstractPapyrusCDOTest.java b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/core/tests/AbstractPapyrusCDOTest.java
new file mode 100644
index 00000000000..0a169bf397e
--- /dev/null
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/core/tests/AbstractPapyrusCDOTest.java
@@ -0,0 +1,241 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.core.tests;
+
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.junit.Assert.assertThat;
+
+import java.util.Map;
+import java.util.regex.Pattern;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.CDOCommonRepository;
+import org.eclipse.emf.cdo.net4j.CDONet4jUtil;
+import org.eclipse.emf.cdo.server.CDOServerUtil;
+import org.eclipse.emf.cdo.server.IRepository.Props;
+import org.eclipse.emf.cdo.server.mem.MEMStoreUtil;
+import org.eclipse.emf.cdo.server.net4j.CDONet4jServerUtil;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.spi.server.InternalRepository;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.view.CDOView;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.net4j.Net4jUtil;
+import org.eclipse.net4j.jvm.JVMUtil;
+import org.eclipse.net4j.util.container.ContainerUtil;
+import org.eclipse.net4j.util.container.IManagedContainer;
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+import org.eclipse.papyrus.cdo.core.IPapyrusRepository;
+import org.eclipse.papyrus.cdo.internal.core.IInternalPapyrusRepository;
+import org.eclipse.papyrus.cdo.internal.core.PapyrusRepositoryManager;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.rules.TestName;
+
+import com.google.common.collect.Maps;
+
+/**
+ * This is the AbstractPapyrusCDOTest type. Enjoy.
+ */
+public abstract class AbstractPapyrusCDOTest {
+
+ private static final Pattern LEADING_SLASHES = Pattern.compile("^/+");
+
+ @Rule
+ public final TestName name = new TestName();
+
+ private String repoUUID;
+
+ private String repoURL;
+
+ private IManagedContainer container;
+
+ private IPapyrusRepository repository;
+
+ public AbstractPapyrusCDOTest() {
+ super();
+ }
+
+ @Before
+ public void createRepository() throws Exception {
+
+ container = createServerContainer();
+ InternalRepository repo = createRepository(container);
+
+ repoUUID = repo.getUUID();
+ repoURL = "jvm://default?repositoryName=" + repo.getName();
+
+ if(needPapyrusRepository()) {
+ repository = PapyrusRepositoryManager.INSTANCE.createRepository(repoURL);
+ repository.setName(name.getMethodName());
+ repository.connect();
+
+ CDOSession session = ((IInternalPapyrusRepository)repository).getCDOSession();
+
+ // ensure the test resource path
+ CDOTransaction transaction = session.openTransaction();
+ transaction.getOrCreateResourceFolder(getResourceFolder());
+ transaction.commit();
+ transaction.close();
+ }
+ }
+
+ @After
+ public void disposeRepository() throws Exception {
+
+ if(repository != null) {
+ repository.disconnect();
+ PapyrusRepositoryManager.INSTANCE.removeRepository(repository);
+ repository = null;
+ }
+
+ LifecycleUtil.deactivate(container);
+ }
+
+ protected Map<String, String> getRepositoryProperties() {
+ Map<String, String> result = Maps.newHashMap();
+
+ addRepositoryProperties(result);
+
+ return result;
+ }
+
+ protected void addRepositoryProperties(Map<String, String> props) {
+ props.put(Props.OVERRIDE_UUID, ""); // use the name as the UUID
+ props.put(Props.SUPPORTING_AUDITS, "false");
+ props.put(Props.SUPPORTING_BRANCHES, "false");
+ props.put(Props.SUPPORTING_ECORE, "true");
+ props.put(Props.ID_GENERATION_LOCATION, CDOCommonRepository.IDGenerationLocation.STORE.toString());
+ }
+
+ protected IManagedContainer createServerContainer() {
+ IManagedContainer result = ContainerUtil.createContainer();
+
+ prepareContainer(result);
+
+ LifecycleUtil.activate(result);
+
+ return result;
+ }
+
+ protected void prepareContainer(IManagedContainer container) {
+ Net4jUtil.prepareContainer(container);
+ CDONet4jUtil.prepareContainer(container);
+ CDONet4jServerUtil.prepareContainer(container);
+ JVMUtil.prepareContainer(container);
+ }
+
+ protected InternalRepository createRepository(IManagedContainer container) {
+ InternalRepository result = (InternalRepository)CDOServerUtil.createRepository("MEM", MEMStoreUtil.createMEMStore(), getRepositoryProperties());
+
+ CDOServerUtil.addRepository(container, result);
+ LifecycleUtil.activate(JVMUtil.getAcceptor(container, "default"));
+ return result;
+ }
+
+ protected IPapyrusRepository getPapyrusRepository() {
+ return repository;
+ }
+
+ protected IInternalPapyrusRepository getInternalPapyrusRepository() {
+ return (IInternalPapyrusRepository)getPapyrusRepository();
+ }
+
+ protected CDOTransaction createTransaction() {
+ IInternalPapyrusRepository repo = getInternalPapyrusRepository();
+
+ CDOTransaction result = getTransaction(repo.createTransaction(new ResourceSetImpl()));
+
+ return result;
+ }
+
+ protected CDOTransaction getTransaction(ResourceSet resourceSet) {
+ return cast(getInternalPapyrusRepository().getCDOView(resourceSet), CDOTransaction.class);
+ }
+
+ protected String getRepositoryURL() {
+ return repoURL;
+ }
+
+ protected boolean needPapyrusRepository() {
+ return true;
+ }
+
+ protected String getResourceFolder() {
+ return String.format("/%s/%s", getClass().getSimpleName(), name.getMethodName());
+ }
+
+ protected String getResourcePath(String path) {
+ java.util.regex.Matcher m = LEADING_SLASHES.matcher(path);
+ if(m.find()) {
+ path = path.substring(m.end());
+ }
+ return String.format("%s/%s", getResourceFolder(), path);
+ }
+
+ protected URI getTestResourceURI(String path) {
+ return URI.createURI("cdo://" + repoUUID + getResourcePath(path), false);
+ }
+
+ protected static <T> T cast(Object object, Class<T> type) {
+ assertThat(object, instanceOf(type));
+ return type.cast(object);
+ }
+
+ protected URI getTemplateResourceURI(String templateName, String resourceName, String extension) {
+ return URI.createPlatformPluginURI(String.format("/org.eclipse.papyrus.cdo.core.tests/resources/%s/%s.%s", templateName, resourceName, extension), true);
+ }
+
+ protected void loadTemplate(String templateName, String resourceName, Resource... resource) {
+ ResourceSet rset = resource[0].getResourceSet();
+
+ // load all the templates
+ Resource[] templates = new Resource[resource.length];
+ for(int i = 0; i < templates.length; i++) {
+ templates[i] = rset.getResource(getTemplateResourceURI(templateName, resourceName, resource[i].getURI().fileExtension()), true);
+ }
+
+ // resolve their cross-references
+ for(int i = 0; i < templates.length; i++) {
+ EcoreUtil.resolveAll(templates[i]);
+ }
+
+ // move them into the destination resources
+ for(int i = 0; i < resource.length; i++) {
+ resource[i].getContents().addAll(templates[i].getContents());
+ }
+
+ // unload the now empty template resources
+ for(int i = 0; i < templates.length; i++) {
+ templates[i].unload();
+ rset.getResources().remove(templates[i]);
+ templates[i].eAdapters().clear();
+ }
+ }
+
+ protected <T extends EObject> T getMasterViewObject(T object) {
+ CDOObject cdo = CDOUtil.getCDOObject(object);
+
+ CDOView view = getInternalPapyrusRepository().getMasterView();
+ @SuppressWarnings("unchecked")
+ T result = (T)CDOUtil.getEObject(view.getObject(cdo.cdoID()));
+
+ return result;
+ }
+}
diff --git a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/core/tests/AllTests.java b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/core/tests/AllTests.java
new file mode 100644
index 00000000000..6d5865486f3
--- /dev/null
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/core/tests/AllTests.java
@@ -0,0 +1,37 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.core.tests;
+
+import org.eclipse.papyrus.cdo.core.resource.tests.CDOAwareModelSetTest;
+import org.eclipse.papyrus.cdo.core.util.tests.AllUtilTests;
+import org.eclipse.papyrus.cdo.internal.core.exporter.tests.AllModelExportTests;
+import org.eclipse.papyrus.cdo.internal.core.expressions.tests.AllExpressionsTests;
+import org.eclipse.papyrus.cdo.internal.core.importer.tests.AllModelImportTests;
+import org.eclipse.papyrus.cdo.internal.core.tests.PapyrusRepositoryManagerTest;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ * This is the AllTests type. Enjoy.
+ */
+@RunWith(Suite.class)
+@SuiteClasses({ AllUtilTests.class, AllExpressionsTests.class, //
+PapyrusRepositoryManagerTest.class, CDOAwareModelSetTest.class, //
+AllModelImportTests.class, AllModelExportTests.class })
+public class AllTests {
+
+ public AllTests() {
+ super();
+ }
+
+}
diff --git a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/core/tests/TestProject.java b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/core/tests/TestProject.java
new file mode 100644
index 00000000000..a3f307d9efd
--- /dev/null
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/core/tests/TestProject.java
@@ -0,0 +1,178 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.core.tests;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
+
+import java.io.FilterInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.emf.common.util.URI;
+import org.junit.rules.TestWatcher;
+import org.junit.runner.Description;
+
+/**
+ * This is the TestProject type. Enjoy.
+ */
+public class TestProject
+ extends TestWatcher {
+
+ private IProject project;
+
+ public TestProject(String name) {
+ super();
+
+ this.project = ResourcesPlugin.getWorkspace().getRoot()
+ .getProject(name);
+ }
+
+ public IProject getProject() {
+ return project;
+ }
+
+ public IFile getFile(String path) {
+ IFile result = getProject().getFile(new Path(path));
+
+ assertThat(result, notNullValue());
+ assertThat(result.exists(), is(true));
+
+ return result;
+ }
+
+ public URI getResourceURI(String path) {
+ return URI.createPlatformResourceURI(getFile(path).getFullPath()
+ .toString(), true);
+ }
+
+ @Override
+ protected void starting(Description description) {
+ try {
+ // ensure that the project doesn't exist
+ if (project.exists()) {
+ project.delete(true, null);
+ }
+
+ // create the project
+ project.create(null);
+ project.open(null);
+
+ // fill it
+ unzip();
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Failed to create test project: " + e.getLocalizedMessage());
+ }
+ }
+
+ @Override
+ protected void finished(Description description) {
+ try {
+ project.delete(true, null);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void unzip()
+ throws Exception {
+
+ URL zipResource = Platform.getBundle(
+ "org.eclipse.papyrus.cdo.core.tests").getEntry(
+ String.format("resources/projects/%s.zip", project.getName()));
+ ZipInputStream zip = new ZipInputStream(zipResource.openStream());
+
+ for (ZipEntry entry = zip.getNextEntry(); entry != null; entry = zip
+ .getNextEntry()) {
+ if (entry.isDirectory()) {
+ createDirectory(project, entry.getName());
+ } else {
+ createFile(project, entry.getName(),
+ new ZipEntryInputStreamWrapper(zip));
+ }
+ }
+
+ zip.close();
+ }
+
+ private void createDirectory(IProject project, String name)
+ throws Exception {
+
+ createDirectory(project, new Path(name));
+ }
+
+ private IFolder createDirectory(IProject project, IPath path)
+ throws Exception {
+ IContainer container = project;
+
+ for (String next : path.segments()) {
+ IFolder folder = container.getFolder(new Path(next));
+ if (!folder.exists()) {
+ folder.create(true, true, null);
+ }
+ container = folder;
+ }
+
+ return (IFolder) container;
+ }
+
+ private void createFile(IProject project, String name, InputStream contents)
+ throws Exception {
+
+ IPath path = new Path(name);
+
+ IContainer container = project;
+ if (path.segmentCount() > 1) {
+ container = createDirectory(project, path.removeLastSegments(1));
+ }
+
+ IFile file = container.getFile(new Path(path.lastSegment()));
+ if (!file.exists()) {
+ file.create(contents, true, null);
+ } else {
+ file.setContents(contents, true, false, null);
+ }
+ }
+
+ private static class ZipEntryInputStreamWrapper
+ extends FilterInputStream {
+
+ private ZipInputStream zip;
+
+ public ZipEntryInputStreamWrapper(ZipInputStream input) {
+ super(input);
+
+ this.zip = input;
+ }
+
+ @Override
+ public void close()
+ throws IOException {
+
+ zip.closeEntry();
+ }
+ }
+}
diff --git a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/core/util/tests/AllUtilTests.java b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/core/util/tests/AllUtilTests.java
new file mode 100644
index 00000000000..379679d1451
--- /dev/null
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/core/util/tests/AllUtilTests.java
@@ -0,0 +1,30 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.core.util.tests;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+
+/**
+ * This is the AllExpressionsTests type. Enjoy.
+ */
+@RunWith(Suite.class)
+@SuiteClasses({ CDOPredicatesTest.class, CDOFunctionsTest.class })
+public class AllUtilTests {
+
+ public AllUtilTests() {
+ super();
+ }
+
+}
diff --git a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/core/util/tests/CDOFunctionsTest.java b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/core/util/tests/CDOFunctionsTest.java
new file mode 100644
index 00000000000..e3a46bb6b3e
--- /dev/null
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/core/util/tests/CDOFunctionsTest.java
@@ -0,0 +1,107 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.core.util.tests;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.CoreMatchers.sameInstance;
+import static org.junit.Assert.assertThat;
+import static org.junit.matchers.JUnitMatchers.containsString;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.cdo.eresource.CDOResourceNode;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.papyrus.cdo.core.tests.AbstractPapyrusCDOTest;
+import org.eclipse.papyrus.cdo.core.util.CDOFunctions;
+import org.junit.Test;
+
+import com.google.common.base.Function;
+
+
+/**
+ * This is the CDOFunctionsTest type. Enjoy.
+ */
+public class CDOFunctionsTest extends AbstractPapyrusCDOTest {
+
+ @Test
+ public void testAdapt_instanceOf() {
+ Function<Object, CDOResourceNode> func = CDOFunctions.adapt(CDOResourceNode.class);
+ CDOTransaction transaction = createTransaction();
+
+ CDOResourceNode res = transaction.createResource(getResourcePath("/folder1/foo.uml"));
+ assertThat(func.apply(res), sameInstance(res));
+
+ CDOResourceNode folder = res.getFolder();
+ assertThat(func.apply(folder), sameInstance(folder));
+
+ assertThat(func.apply(transaction), nullValue());
+ }
+
+ @Test
+ public void testAdapt_adapter() {
+ Function<Object, String> func = CDOFunctions.adapt(String.class);
+ CDOTransaction transaction = createTransaction();
+
+ CDOResourceNode res = transaction.createResource(getResourcePath("/folder1/foo.uml"));
+ assertThat(func.apply(res), nullValue());
+
+ StringAdapter adapter = new StringAdapter(res);
+ assertThat(func.apply(adapter), is(res.getPath()));
+ }
+
+ @Test
+ public void testAdaptFunction_equals() {
+ Function<Object, String> func1 = CDOFunctions.adapt(String.class);
+ Function<Object, CDOResourceNode> func2 = CDOFunctions.adapt(CDOResourceNode.class);
+ Function<Object, CDOResourceNode> func3 = CDOFunctions.adapt(CDOResourceNode.class);
+
+ assertThat(func1.equals(func2), is(false));
+ assertThat(func2 == func3, is(false));
+ assertThat(func2, equalTo(func3));
+ assertThat(func3, equalTo(func2));
+ }
+
+ @Test
+ public void testAdaptFunction_hashCode() {
+ Function<Object, String> func1 = CDOFunctions.adapt(String.class);
+ Function<Object, CDOResourceNode> func2 = CDOFunctions.adapt(CDOResourceNode.class);
+ Function<Object, CDOResourceNode> func3 = CDOFunctions.adapt(CDOResourceNode.class);
+
+ assertThat(func1.hashCode() == func2.hashCode(), is(String.class.hashCode() == CDOResourceNode.class.hashCode()));
+ assertThat(func2.hashCode(), is(func3.hashCode()));
+ }
+
+ @Test
+ public void testAdaptFunction_toString() {
+ Function<Object, String> func = CDOFunctions.adapt(String.class);
+
+ assertThat(func.toString(), containsString("adapt("));
+ }
+
+ //
+ // Test framework
+ //
+
+ static class StringAdapter implements IAdaptable {
+
+ private final CDOResourceNode node;
+
+ StringAdapter(CDOResourceNode node) {
+ this.node = node;
+ }
+
+ public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
+ return (adapter == String.class) ? node.getPath() : null;
+ }
+ }
+}
diff --git a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/core/util/tests/CDOPredicatesTest.java b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/core/util/tests/CDOPredicatesTest.java
new file mode 100644
index 00000000000..8415e78e093
--- /dev/null
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/core/util/tests/CDOPredicatesTest.java
@@ -0,0 +1,78 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.core.util.tests;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.eresource.CDOResourceFolder;
+import org.eclipse.emf.cdo.eresource.CDOResourceNode;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.papyrus.cdo.core.tests.AbstractPapyrusCDOTest;
+import org.eclipse.papyrus.cdo.core.util.CDOPredicates;
+import org.junit.Test;
+
+import com.google.common.base.Predicate;
+
+
+/**
+ * This is the CDOPredicatesTest type. Enjoy.
+ */
+public class CDOPredicatesTest extends AbstractPapyrusCDOTest {
+
+ @Test
+ public void testAdaptsTo_instanceOf() {
+ Predicate<Object> pred = CDOPredicates.adaptsTo(CDOResourceNode.class);
+ CDOTransaction transaction = createTransaction();
+
+ CDOResource res = transaction.createResource(getResourcePath("/folder1/foo.uml"));
+ assertThat(pred.apply(res), is(true));
+
+ CDOResourceFolder folder = res.getFolder();
+ assertThat(pred.apply(folder), is(true));
+
+ assertThat(pred.apply(transaction.getRootResource()), is(true));
+
+ assertThat(pred.apply(transaction), is(false));
+ }
+
+ @Test
+ public void testAdaptsTo_adapter() {
+ Predicate<Object> pred = CDOPredicates.adaptsTo(String.class);
+ CDOTransaction transaction = createTransaction();
+
+ CDOResource res = transaction.createResource(getResourcePath("/folder1/foo.uml"));
+ assertThat(pred.apply(res), is(false));
+
+ StringAdapter adapter = new StringAdapter(res);
+ assertThat(pred.apply(adapter), is(true));
+ }
+
+ //
+ // Test framework
+ //
+
+ static class StringAdapter implements IAdaptable {
+
+ private final CDOResourceNode node;
+
+ StringAdapter(CDOResourceNode node) {
+ this.node = node;
+ }
+
+ public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
+ return (adapter == String.class) ? node.getPath() : null;
+ }
+ }
+}
diff --git a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/exporter/tests/AbstractModelExportTest.java b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/exporter/tests/AbstractModelExportTest.java
new file mode 100644
index 00000000000..e112cbf8066
--- /dev/null
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/exporter/tests/AbstractModelExportTest.java
@@ -0,0 +1,130 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.core.exporter.tests;
+
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.CoreMatchers.not;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assume.assumeThat;
+import static org.junit.matchers.JUnitMatchers.containsString;
+
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.papyrus.cdo.core.importer.IModelTransferConfiguration;
+import org.eclipse.papyrus.cdo.core.importer.IModelTransferNode;
+import org.eclipse.papyrus.cdo.core.resource.CDOAwareModelSet;
+import org.eclipse.papyrus.cdo.core.tests.AbstractPapyrusCDOTest;
+import org.eclipse.papyrus.infra.core.Activator;
+import org.eclipse.papyrus.infra.core.resource.AbstractBaseModel;
+import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.core.resource.sasheditor.DiModel;
+import org.eclipse.papyrus.infra.core.services.ExtensionServicesRegistry;
+import org.eclipse.papyrus.infra.core.services.ServiceMultiException;
+import org.eclipse.papyrus.infra.core.services.ServiceNotFoundException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationModel;
+import org.eclipse.papyrus.uml.tools.model.UmlModel;
+import org.eclipse.uml2.common.util.UML2Util;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Model;
+import org.eclipse.uml2.uml.UMLPackage;
+
+import com.google.common.collect.Iterables;
+
+
+/**
+ * This is the AbstractModelExportTest type. Enjoy.
+ */
+public abstract class AbstractModelExportTest extends AbstractPapyrusCDOTest {
+
+ protected static final String DEPENDENT_MODEL_NAME = "dependent.uml";
+
+ protected static final String DEPENDENCY_MODEL_NAME = "dependency.uml";
+
+ protected static final String DEPENDENT_MODEL_DI = "dependent.di";
+
+ protected static final String DEPENDENCY_MODEL_DI = "dependency.di";
+
+ protected void createModels() throws Exception {
+ ServicesRegistry[] services = { null };
+
+ // create the model that the other model depends on
+ ModelSet modelSet = createModelSet(DEPENDENCY_MODEL_NAME, services);
+
+ UmlModel uml = (UmlModel)modelSet.getModel(UmlModel.MODEL_ID);
+ Model model = (Model)uml.lookupRoot();
+ model.createOwnedClass("Superclass", false);
+
+ modelSet.save(new NullProgressMonitor());
+
+ services[0].disposeRegistry();
+
+ // create the model that depends on the first one
+ modelSet = createModelSet(DEPENDENT_MODEL_NAME, services);
+
+ uml = (UmlModel)modelSet.getModel(UmlModel.MODEL_ID);
+ model = (Model)uml.lookupRoot();
+ Class subclass = model.createOwnedClass("Subclass", false);
+
+ // add the dependency
+ Model dependency = UML2Util.load(modelSet, getTestResourceURI(DEPENDENCY_MODEL_NAME), UMLPackage.Literals.MODEL);
+ model.createPackageImport(dependency);
+ subclass.createGeneralization((Class)dependency.getOwnedType("Superclass"));
+
+ modelSet.save(new NullProgressMonitor());
+
+ services[0].disposeRegistry();
+ }
+
+ protected ModelSet createModelSet(String name, ServicesRegistry[] outServices) throws Exception {
+
+ outServices[0] = new ExtensionServicesRegistry(Activator.PLUGIN_ID);
+
+ try {
+ // start the ModelSet and its dependencies
+ outServices[0].startServicesByClassKeys(ModelSet.class);
+ } catch (ServiceMultiException e) {
+ for(ServiceNotFoundException next : Iterables.filter(e.getExceptions(), ServiceNotFoundException.class)) {
+ assertThat(next.getLocalizedMessage(), not(containsString("ModelSet")));
+ }
+ }
+
+ ModelSet result = outServices[0].getService(ModelSet.class);
+
+ assumeThat(result, instanceOf(CDOAwareModelSet.class));
+
+ result.createModels(getTestResourceURI(name));
+
+ // load blank model
+ Resource uml = ((AbstractBaseModel)result.getModel(UmlModel.MODEL_ID)).getResource();
+ Resource notation = ((AbstractBaseModel)result.getModel(NotationModel.MODEL_ID)).getResource();
+ Resource di = ((AbstractBaseModel)result.getModel(DiModel.MODEL_ID)).getResource();
+ loadTemplate("empty", "model", uml, notation, di);
+
+ return result;
+ }
+
+ protected IModelTransferNode getNode(IModelTransferConfiguration config, URI uri) {
+ IModelTransferNode result = null;
+
+ for(IModelTransferNode next : config.getModelsToTransfer()) {
+ if(next.getPrimaryResourceURI().equals(uri)) {
+ result = next;
+ break;
+ }
+ }
+
+ return result;
+ }
+
+}
diff --git a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/exporter/tests/AllModelExportTests.java b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/exporter/tests/AllModelExportTests.java
new file mode 100644
index 00000000000..491c18d11de
--- /dev/null
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/exporter/tests/AllModelExportTests.java
@@ -0,0 +1,29 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.core.exporter.tests;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ * This is the AllModelExportTests type. Enjoy.
+ */
+@RunWith(Suite.class)
+@SuiteClasses({ ModelExportMappingTest.class, ModelExporterTest.class })
+public class AllModelExportTests {
+
+ public AllModelExportTests() {
+ super();
+ }
+
+}
diff --git a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/exporter/tests/ModelExportMappingTest.java b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/exporter/tests/ModelExportMappingTest.java
new file mode 100644
index 00000000000..a70c2f5b717
--- /dev/null
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/exporter/tests/ModelExportMappingTest.java
@@ -0,0 +1,164 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.core.exporter.tests;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.sameInstance;
+import static org.junit.Assert.assertThat;
+import static org.junit.matchers.JUnitMatchers.containsString;
+import static org.junit.matchers.JUnitMatchers.either;
+
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.papyrus.cdo.core.exporter.IModelExportMapping;
+import org.eclipse.papyrus.cdo.core.importer.IModelTransferConfiguration;
+import org.eclipse.papyrus.cdo.core.importer.IModelTransferNode;
+import org.eclipse.papyrus.cdo.core.importer.IModelTransferOperation;
+import org.eclipse.papyrus.cdo.core.tests.TestProject;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+/**
+ * This is the ModelExportMappingTest type. Enjoy.
+ */
+public class ModelExportMappingTest extends AbstractModelExportTest {
+
+ private IModelTransferConfiguration config;
+
+ private IModelExportMapping fixture;
+
+ @Rule
+ public TestProject hasDependencies = new TestProject("has_dependencies");
+
+ @Rule
+ public TestProject hasDependents = new TestProject("has_dependents");
+
+ public ModelExportMappingTest() {
+ super();
+ }
+
+ @Test
+ public void testValidation_ok() throws Exception {
+ URI uri1 = getTestResourceURI(DEPENDENT_MODEL_DI);
+ URI uri2 = getTestResourceURI(DEPENDENCY_MODEL_DI);
+
+ config.addModelToTransfer(uri1);
+ config.addModelToTransfer(uri2);
+
+ fixture.mapTo(getNode(uri1), new Path("/has_dependencies/exported.di"));
+ fixture.mapTo(getNode(uri2), new Path("/has_dependents/exported.di"));
+
+ Diagnostic problems = fixture.validate();
+
+ assertThat(problems.getSeverity(), is(Diagnostic.OK));
+ assertThat(problems.getChildren().size(), is(0));
+ }
+
+ @Test
+ public void testValidation_resourceExists() throws Exception {
+ URI uri1 = getTestResourceURI(DEPENDENT_MODEL_DI);
+ URI uri2 = getTestResourceURI(DEPENDENCY_MODEL_DI);
+
+ config.addModelToTransfer(uri1);
+ config.addModelToTransfer(uri2);
+
+ fixture.mapTo(getNode(uri1), new Path("/has_dependencies/model.di"));
+ fixture.mapTo(getNode(uri2), new Path("/has_dependents/exported.di"));
+
+ Diagnostic problems = fixture.validate();
+
+ assertThat(problems.getChildren().size(), is(1));
+ Diagnostic child = problems.getChildren().get(0);
+ assertThat(child.getSeverity(), is(Diagnostic.ERROR));
+ assertThat(child.getMessage(), containsString("esource already exists"));
+ assertThat(child.getData().get(0), sameInstance((Object)getNode(uri1)));
+ }
+
+ @SuppressWarnings("restriction")
+ @Test
+ public void testValidation_nonUniqueMappings() throws Exception {
+ URI uri1 = getTestResourceURI(DEPENDENT_MODEL_DI);
+ URI uri2 = getTestResourceURI(DEPENDENCY_MODEL_DI);
+
+ config.addModelToTransfer(uri1);
+ config.addModelToTransfer(uri2);
+
+ fixture.mapTo(getNode(uri1), new Path("/has_dependencies/exported.di"));
+ fixture.mapTo(getNode(uri2), new Path("/has_dependencies/exported.di"));
+
+ Diagnostic problems = fixture.validate();
+
+ assertThat(problems.getChildren().size(), is(1));
+ Diagnostic child = problems.getChildren().get(0);
+ assertThat(child.getSeverity(), is(Diagnostic.ERROR));
+ assertThat(child.getMessage(), containsString("Multiple models map"));
+ assertThat(child.getData().get(0), either(sameInstance((Object)getNode(uri1))).or(sameInstance((Object)getNode(uri2))));
+ }
+
+ @Test
+ public void testValidation_mappingAbsent() {
+ URI uri1 = getTestResourceURI(DEPENDENT_MODEL_DI);
+ URI uri2 = getTestResourceURI(DEPENDENCY_MODEL_DI);
+
+ config.addModelToTransfer(uri1);
+ config.addModelToTransfer(uri2);
+
+ fixture.mapTo(getNode(uri1), new Path("/has_dependencies/exported.di"));
+ // don't map uri2
+
+ Diagnostic problems = fixture.validate();
+
+ assertThat(problems.getChildren().size(), is(1));
+ Diagnostic child = problems.getChildren().get(0);
+ assertThat(child.getSeverity(), is(Diagnostic.ERROR));
+ assertThat(child.getMessage(), containsString("No mapping"));
+ assertThat(child.getData().get(0), sameInstance((Object)getNode(uri2)));
+ }
+
+ //
+ // Test framework
+ //
+
+ @Before
+ public void createTestFixture() throws Exception {
+ ResourceSet rset = getInternalPapyrusRepository().getMasterView().getResourceSet();
+ createModels();
+
+ config = IModelTransferConfiguration.Factory.EXPORT.create(new IModelTransferOperation.Context() {
+
+ public Diagnostic run(IModelTransferOperation operation) {
+ operation.run(new NullProgressMonitor());
+ return Diagnostic.OK_INSTANCE;
+ }
+ }, rset);
+
+ fixture = IModelExportMapping.Factory.DEFAULT.create(config);
+ fixture.setRepository(getPapyrusRepository());
+ }
+
+ @After
+ public void disposeTestFixture() {
+ fixture = null;
+
+ config.dispose();
+ config = null;
+ }
+
+ IModelTransferNode getNode(URI uri) {
+ return getNode(config, uri);
+ }
+}
diff --git a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/exporter/tests/ModelExporterTest.java b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/exporter/tests/ModelExporterTest.java
new file mode 100644
index 00000000000..52d204f7018
--- /dev/null
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/exporter/tests/ModelExporterTest.java
@@ -0,0 +1,161 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.core.exporter.tests;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.io.File;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.papyrus.cdo.core.exporter.IModelExportMapping;
+import org.eclipse.papyrus.cdo.core.exporter.IModelExporter;
+import org.eclipse.papyrus.cdo.core.importer.IModelTransferConfiguration;
+import org.eclipse.papyrus.cdo.core.importer.IModelTransferNode;
+import org.eclipse.papyrus.cdo.core.importer.IModelTransferOperation;
+import org.eclipse.papyrus.cdo.core.tests.TestProject;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+
+/**
+ * This is the ModelImporterTest type. Enjoy.
+ */
+public class ModelExporterTest extends AbstractModelExportTest {
+
+ private IModelTransferConfiguration config;
+
+ private IModelExporter fixture;
+
+ @Rule
+ public TestProject hasDependencies = new TestProject("has_dependencies");
+
+ @Rule
+ public TestProject hasDependents = new TestProject("has_dependents");
+
+ public ModelExporterTest() {
+ super();
+ }
+
+ @Test
+ public void testExportWithDependencies() {
+ URI uri1 = getTestResourceURI(DEPENDENT_MODEL_DI);
+ URI uri2 = getTestResourceURI(DEPENDENCY_MODEL_DI);
+
+ config.addModelToTransfer(uri1);
+ config.addModelToTransfer(uri2);
+
+ IModelExportMapping mapping = IModelExportMapping.Factory.DEFAULT.create(config);
+ mapping.setRepository(getPapyrusRepository());
+ mapping.mapTo(getNode(uri1), new Path("/has_dependencies/exported.di"));
+ mapping.mapTo(getNode(uri2), new Path("/has_dependents/exported.di"));
+
+ Diagnostic problems = fixture.exportModels(mapping);
+ assertThat(problems.getSeverity(), is(Diagnostic.OK));
+ assertThat(problems.getChildren().size(), is(0));
+
+ assertResource(new Path("/has_dependencies/exported.di"), "di");
+ assertResource(new Path("/has_dependencies/exported.uml"), "uml");
+ assertResource(new Path("/has_dependencies/exported.notation"), "notation");
+
+ assertResource(new Path("/has_dependents/exported.di"), "di");
+ assertResource(new Path("/has_dependents/exported.uml"), "uml");
+ assertResource(new Path("/has_dependents/exported.notation"), "notation");
+ }
+
+ //
+ // Test framework
+ //
+
+ @Before
+ public void createTestFixture() throws Exception {
+ ResourceSet rset = getInternalPapyrusRepository().getMasterView().getResourceSet();
+ createModels();
+
+ config = IModelTransferConfiguration.Factory.EXPORT.create(new IModelTransferOperation.Context() {
+
+ public Diagnostic run(IModelTransferOperation operation) {
+ operation.run(new NullProgressMonitor());
+ return Diagnostic.OK_INSTANCE;
+ }
+ }, rset);
+
+ fixture = IModelExporter.Factory.DEFAULT.create();
+ }
+
+ @After
+ public void disposeTestFixture() {
+ fixture = null;
+
+ config.dispose();
+ config = null;
+ }
+
+ void assertResource(IPath path, final String metamodel) {
+ IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
+ assertThat(file.exists(), is(true));
+
+ File osFile = new File(file.getLocationURI());
+ assertThat(osFile.length() > 0L, is(true));
+
+ ResourceSet rset = new ResourceSetImpl();
+ try {
+ Resource resource = rset.getResource(URI.createPlatformResourceURI(path.toString(), true), true);
+
+ assertThat(Iterables.size(Iterables.filter(resource.getContents(), new Predicate<EObject>() {
+
+ public boolean apply(EObject input) {
+ boolean result = false;
+
+ if(input != null) {
+ EPackage epackage = input.eClass().getEPackage();
+ result = epackage.getName().equalsIgnoreCase(metamodel);
+ }
+
+ return result;
+ }
+ })), is(1));
+
+ } finally {
+ cleanUp(rset);
+ }
+ }
+
+ protected void cleanUp(ResourceSet rset) {
+ for(Resource next : rset.getResources()) {
+ next.unload();
+ next.eAdapters().clear();
+ }
+
+ rset.getResources().clear();
+ rset.eAdapters().clear();
+ }
+
+ IModelTransferNode getNode(URI uri) {
+ return getNode(config, uri);
+ }
+}
diff --git a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/expressions/tests/AllExpressionsTests.java b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/expressions/tests/AllExpressionsTests.java
new file mode 100644
index 00000000000..f9e48c4a986
--- /dev/null
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/expressions/tests/AllExpressionsTests.java
@@ -0,0 +1,30 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.core.expressions.tests;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+
+/**
+ * This is the AllExpressionsTests type. Enjoy.
+ */
+@RunWith(Suite.class)
+@SuiteClasses({ EObjectPropertyTesterTest.class })
+public class AllExpressionsTests {
+
+ public AllExpressionsTests() {
+ super();
+ }
+
+}
diff --git a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/expressions/tests/EObjectPropertyTesterTest.java b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/expressions/tests/EObjectPropertyTesterTest.java
new file mode 100644
index 00000000000..a21611767b1
--- /dev/null
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/expressions/tests/EObjectPropertyTesterTest.java
@@ -0,0 +1,40 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.core.expressions.tests;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.papyrus.cdo.core.tests.AbstractPapyrusCDOTest;
+import org.eclipse.papyrus.cdo.internal.core.expressions.EObjectPropertyTester;
+import org.junit.Test;
+
+
+/**
+ * This is the EObjectPropertyTesterTest type. Enjoy.
+ */
+public class EObjectPropertyTesterTest extends AbstractPapyrusCDOTest {
+
+ private final EObjectPropertyTester fixture = new EObjectPropertyTester();
+
+ @Test
+ public void testTest_isCDOObject() {
+ CDOResource res = createTransaction().createResource(getResourcePath("foo.uml"));
+
+ assertThat(fixture.test(res, "isCDOObject", null, true), is(true));
+
+ assertThat(fixture.test(EcorePackage.Literals.ECLASS, "isCDOObject", null, true), is(false));
+ }
+
+}
diff --git a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/importer/tests/AllModelImportTests.java b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/importer/tests/AllModelImportTests.java
new file mode 100644
index 00000000000..149fdd6b40d
--- /dev/null
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/importer/tests/AllModelImportTests.java
@@ -0,0 +1,31 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.core.importer.tests;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ * This is the AllModelImportTests type. Enjoy.
+ */
+@RunWith(Suite.class)
+@SuiteClasses({ModelImportConfigurationTest.class,
+ OneToOneModelImportMappingTest.class,
+ ManyToOneModelImportMappingTest.class, ModelImporterTest.class})
+public class AllModelImportTests {
+
+ public AllModelImportTests() {
+ super();
+ }
+
+}
diff --git a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/importer/tests/ManyToOneModelImportMappingTest.java b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/importer/tests/ManyToOneModelImportMappingTest.java
new file mode 100644
index 00000000000..41adc0811a7
--- /dev/null
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/importer/tests/ManyToOneModelImportMappingTest.java
@@ -0,0 +1,137 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.core.importer.tests;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.util.Set;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.papyrus.cdo.core.importer.IModelImportMapping;
+import org.eclipse.papyrus.cdo.core.importer.IModelTransferConfiguration;
+import org.eclipse.papyrus.cdo.core.importer.IModelTransferNode;
+import org.eclipse.papyrus.cdo.core.importer.IModelTransferOperation;
+import org.eclipse.papyrus.cdo.core.importer.ModelTransferMappingListenerAdapter;
+import org.eclipse.papyrus.cdo.core.tests.AbstractPapyrusCDOTest;
+import org.eclipse.papyrus.cdo.core.tests.TestProject;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Sets;
+
+/**
+ * This is the ManyToOneModelImportMappingTest type. Enjoy.
+ */
+public class ManyToOneModelImportMappingTest extends AbstractPapyrusCDOTest {
+
+ private IModelTransferConfiguration config;
+
+ private IModelImportMapping fixture;
+
+ @Rule
+ public TestProject hasDependencies = new TestProject("has_dependencies");
+
+ @Rule
+ public TestProject hasDependents = new TestProject("has_dependents");
+
+ public ManyToOneModelImportMappingTest() {
+ super();
+ }
+
+ @Test
+ public void testDefaultMappings() {
+ URI uri1 = hasDependencies.getResourceURI("model.di");
+ URI uri2 = hasDependents.getResourceURI("Datatypes.di");
+
+ config.addModelToTransfer(uri1);
+ config.addModelToTransfer(uri2);
+
+ assertThat(fixture.getMapping(getNode(uri1)), is((IPath)new Path("/has_dependencies/model.di")));
+ assertThat(fixture.getMapping(getNode(uri2)), is((IPath)new Path("/has_dependencies/model.di")));
+ }
+
+ @Test
+ public void testMappings() {
+ URI uri1 = hasDependencies.getResourceURI("model.di");
+ URI uri2 = hasDependents.getResourceURI("Datatypes.di");
+
+ config.addModelToTransfer(uri1);
+ config.addModelToTransfer(uri2);
+
+ class Test extends ModelTransferMappingListenerAdapter {
+
+ Set<IModelTransferNode> notified = Sets.newHashSet();
+
+ @Override
+ public void modelTransferMappingChanged(IModelTransferNode node) {
+ notified.add(node);
+ }
+ }
+ Test test = new Test();
+ fixture.addModelTransferMappingListener(test);
+
+ IPath path = new Path("/myfolder/MyModel.di");
+ fixture.mapTo(getNode(uri1), path);
+
+ assertThat(test.notified, is((Set<IModelTransferNode>)ImmutableSet.of(getNode(uri1), getNode(uri2))));
+
+ assertThat(fixture.getMapping(getNode(uri1)), is(path));
+ assertThat(fixture.getMapping(getNode(uri2)), is(path));
+ }
+
+ //
+ // Test framework
+ //
+
+ @Before
+ public void createTestFixture() {
+ config = IModelTransferConfiguration.Factory.IMPORT.create(new IModelTransferOperation.Context() {
+
+ public Diagnostic run(IModelTransferOperation operation) {
+ operation.run(new NullProgressMonitor());
+ return Diagnostic.OK_INSTANCE;
+ }
+ }, null);
+
+ fixture = IModelImportMapping.Factory.MANY_TO_ONE.create(config);
+ fixture.setRepository(getPapyrusRepository());
+ }
+
+ @After
+ public void disposeTestFixture() {
+ fixture = null;
+
+ config.dispose();
+ config = null;
+ }
+
+ IModelTransferNode getNode(URI uri) {
+ IModelTransferNode result = null;
+
+ for(IModelTransferNode next : config.getModelsToTransfer()) {
+ if(next.getPrimaryResourceURI().equals(uri)) {
+ result = next;
+ break;
+ }
+ }
+
+ return result;
+ }
+}
diff --git a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/importer/tests/ModelImportConfigurationTest.java b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/importer/tests/ModelImportConfigurationTest.java
new file mode 100644
index 00000000000..44ca8e1e597
--- /dev/null
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/importer/tests/ModelImportConfigurationTest.java
@@ -0,0 +1,196 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.core.importer.tests;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.sameInstance;
+import static org.junit.Assert.assertThat;
+import static org.junit.matchers.JUnitMatchers.hasItem;
+
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.papyrus.cdo.core.importer.IModelTransferConfiguration;
+import org.eclipse.papyrus.cdo.core.importer.IModelTransferNode;
+import org.eclipse.papyrus.cdo.core.importer.IModelTransferOperation;
+import org.eclipse.papyrus.cdo.core.tests.TestProject;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import com.google.common.collect.Iterables;
+
+/**
+ * This is the ModelImportConfigurationTest type. Enjoy.
+ */
+public class ModelImportConfigurationTest {
+
+ private IModelTransferConfiguration fixture;
+
+ @Rule
+ public TestProject isolated = new TestProject("isolated");
+
+ @Rule
+ public TestProject hasDependencies = new TestProject("has_dependencies");
+
+ @Rule
+ public TestProject hasDependents = new TestProject("has_dependents");
+
+ public ModelImportConfigurationTest() {
+ super();
+ }
+
+ @Test
+ public void testIsolatedModel() {
+ URI uri = isolated.getResourceURI("model.di");
+
+ fixture.addModelToTransfer(uri);
+
+ assertThat(fixture.getModelsToTransfer().size(), is(1));
+ IModelTransferNode node = Iterables.getOnlyElement(fixture.getModelsToTransfer());
+
+ assertThat(node.getPrimaryResourceURI(), is(uri));
+ assertThat(node.getDependencies().size(), is(0));
+ assertThat(node.getDependents().size(), is(0));
+
+ assertThat(node.getResourceURIs().size(), is(3));
+ assertThat(node.getResourceURIs(), hasItem(uri));
+ assertThat(node.getResourceURIs(), hasItem(uml(uri)));
+ assertThat(node.getResourceURIs(), hasItem(notation(uri)));
+ }
+
+ @Test
+ public void testModelHavingDependencies() {
+ URI uri = hasDependencies.getResourceURI("model.di");
+
+ fixture.addModelToTransfer(uri);
+
+ assertThat(fixture.getModelsToTransfer().size(), is(1));
+ IModelTransferNode node = Iterables.getOnlyElement(fixture.getModelsToTransfer());
+
+ assertThat(node.getPrimaryResourceURI(), is(uri));
+
+ assertThat(node.getDependencies().size(), is(1));
+ IModelTransferNode dep = Iterables.getOnlyElement(node.getDependencies());
+ assertThat(dep.getPrimaryResourceURI(), is(hasDependents.getResourceURI("Datatypes.di")));
+
+ assertThat(node.getDependents().size(), is(0));
+
+ assertThat(node.getResourceURIs().size(), is(3));
+ assertThat(node.getResourceURIs(), hasItem(uri));
+ assertThat(node.getResourceURIs(), hasItem(uml(uri)));
+ assertThat(node.getResourceURIs(), hasItem(notation(uri)));
+ }
+
+ @Test
+ public void testModelHavingDependents() {
+ URI uri = hasDependents.getResourceURI("Datatypes.di");
+
+ fixture.addModelToTransfer(uri);
+
+ assertThat(fixture.getModelsToTransfer().size(), is(1));
+ IModelTransferNode node = Iterables.getOnlyElement(fixture.getModelsToTransfer());
+
+ assertThat(node.getPrimaryResourceURI(), is(uri));
+
+ assertThat(node.getDependencies().size(), is(0));
+
+ assertThat(node.getDependents().size(), is(1));
+ IModelTransferNode dep = Iterables.getOnlyElement(node.getDependents());
+ assertThat(dep.getPrimaryResourceURI(), is(hasDependencies.getResourceURI("model.di")));
+
+ assertThat(node.getResourceURIs().size(), is(3));
+ assertThat(node.getResourceURIs(), hasItem(uri));
+ assertThat(node.getResourceURIs(), hasItem(uml(uri)));
+ assertThat(node.getResourceURIs(), hasItem(notation(uri)));
+ }
+
+ @Test
+ public void testValidationOfDependents() {
+ URI uri = hasDependents.getResourceURI("Datatypes.di");
+
+ fixture.addModelToTransfer(uri);
+
+ assertThat(fixture.getModelsToTransfer().size(), is(1));
+ IModelTransferNode node = Iterables.getOnlyElement(fixture.getModelsToTransfer());
+
+ Diagnostic problems = fixture.validate();
+
+ assertThat(problems.getChildren().size(), is(1));
+ Diagnostic child = problems.getChildren().get(0);
+ assertThat(child.getSeverity(), is(Diagnostic.WARNING));
+ assertThat(child.getData().get(0), sameInstance((Object)node));
+ assertThat(child.getData().get(1), is((Object)node.getDependents()));
+
+ fixture.addModelToTransfer(hasDependencies.getResourceURI("model.di"));
+
+ problems = fixture.validate();
+
+ assertThat(problems.getSeverity(), is(Diagnostic.OK));
+ assertThat(problems.getChildren().size(), is(0));
+ }
+
+ @Test
+ public void testValidationOfDependencies() {
+ URI uri = hasDependencies.getResourceURI("model.di");
+
+ fixture.addModelToTransfer(uri);
+
+ assertThat(fixture.getModelsToTransfer().size(), is(1));
+ IModelTransferNode node = Iterables.getOnlyElement(fixture.getModelsToTransfer());
+
+ Diagnostic problems = fixture.validate();
+
+ assertThat(problems.getChildren().size(), is(1));
+ Diagnostic child = problems.getChildren().get(0);
+ assertThat(child.getSeverity(), is(Diagnostic.INFO));
+ assertThat(child.getData().get(0), sameInstance((Object)node));
+ assertThat(child.getData().get(1), is((Object)node.getDependencies()));
+
+ fixture.addModelToTransfer(hasDependents.getResourceURI("Datatypes.di"));
+
+ problems = fixture.validate();
+
+ assertThat(problems.getSeverity(), is(Diagnostic.OK));
+ assertThat(problems.getChildren().size(), is(0));
+ }
+
+ //
+ // Test framework
+ //
+
+ @Before
+ public void createTestFixture() {
+ fixture = IModelTransferConfiguration.Factory.IMPORT.create(new IModelTransferOperation.Context() {
+
+ public Diagnostic run(IModelTransferOperation operation) {
+ operation.run(new NullProgressMonitor());
+ return Diagnostic.OK_INSTANCE;
+ }
+ }, null);
+ }
+
+ @After
+ public void disposeTestFixture() {
+ fixture.dispose();
+ fixture = null;
+ }
+
+ URI uml(URI uri) {
+ return uri.trimFileExtension().appendFileExtension("uml");
+ }
+
+ URI notation(URI uri) {
+ return uri.trimFileExtension().appendFileExtension("notation");
+ }
+}
diff --git a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/importer/tests/ModelImporterTest.java b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/importer/tests/ModelImporterTest.java
new file mode 100644
index 00000000000..f5a291602ee
--- /dev/null
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/importer/tests/ModelImporterTest.java
@@ -0,0 +1,205 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.core.importer.tests;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.junit.Assert.assertThat;
+import static org.junit.matchers.JUnitMatchers.containsString;
+
+import java.io.InputStreamReader;
+import java.io.Reader;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.emf.cdo.view.CDOView;
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.papyrus.cdo.core.importer.IModelImportMapping;
+import org.eclipse.papyrus.cdo.core.importer.IModelImporter;
+import org.eclipse.papyrus.cdo.core.importer.IModelTransferConfiguration;
+import org.eclipse.papyrus.cdo.core.importer.IModelTransferOperation;
+import org.eclipse.papyrus.cdo.core.tests.AbstractPapyrusCDOTest;
+import org.eclipse.papyrus.cdo.core.tests.TestProject;
+import org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage;
+import org.eclipse.papyrus.infra.core.sashwindows.di.SashWindowsMngr;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+import com.google.common.io.CharStreams;
+
+/**
+ * This is the ModelImporterTest type. Enjoy.
+ */
+public class ModelImporterTest extends AbstractPapyrusCDOTest {
+
+ private IModelTransferConfiguration config;
+
+ private IModelImporter fixture;
+
+ @Rule
+ public TestProject hasDependencies = new TestProject("has_dependencies");
+
+ @Rule
+ public TestProject hasDependents = new TestProject("has_dependents");
+
+ public ModelImporterTest() {
+ super();
+ }
+
+ @Test
+ public void testOneToOneImport() {
+ URI uri1 = hasDependencies.getResourceURI("model.di");
+ URI uri2 = hasDependents.getResourceURI("Datatypes.di");
+
+ config.addModelToTransfer(uri1);
+ config.addModelToTransfer(uri2);
+
+ IModelImportMapping mapping = IModelImportMapping.Factory.ONE_TO_ONE.create(config);
+ mapping.setRepository(getPapyrusRepository());
+
+ Diagnostic problems = fixture.importModels(mapping);
+ assertThat(problems.getSeverity(), is(Diagnostic.OK));
+ assertThat(problems.getChildren().size(), is(0));
+
+ CDOView view = getInternalPapyrusRepository().getMasterView();
+ sleep(3); // give the view invalidation a moment to catch up
+
+ assertResource(view.getResource("has_dependencies/model.di"));
+ assertResource(view.getResource("has_dependencies/model.uml"));
+ assertResource(view.getResource("has_dependencies/model.notation"));
+
+ assertResource(view.getResource("has_dependents/Datatypes.di"));
+ assertResource(view.getResource("has_dependents/Datatypes.uml"));
+ assertResource(view.getResource("has_dependents/Datatypes.notation"));
+ }
+
+ @Test
+ public void testManyToOneImport() {
+ URI uri1 = hasDependencies.getResourceURI("model.di");
+ URI uri2 = hasDependents.getResourceURI("Datatypes.di");
+
+ config.addModelToTransfer(uri1);
+ config.addModelToTransfer(uri2);
+
+ IModelImportMapping mapping = IModelImportMapping.Factory.MANY_TO_ONE.create(config);
+ mapping.setRepository(getPapyrusRepository());
+ mapping.mapTo(Iterables.get(config.getModelsToTransfer(), 0), new Path("my_import/combined.di"));
+
+ Diagnostic problems = fixture.importModels(mapping);
+ assertThat(problems.getSeverity(), is(Diagnostic.OK));
+ assertThat(problems.getChildren().size(), is(0));
+
+ CDOView view = getInternalPapyrusRepository().getMasterView();
+ sleep(3); // give the view invalidation a moment to catch up
+
+ assertResource(view.getResource("my_import/combined.di"), "di", 1);
+ assertResource(view.getResource("my_import/combined.uml"), "uml", 2);
+ assertResource(view.getResource("my_import/combined.notation"), "notation", 2);
+
+ SashWindowsMngr mngr = (SashWindowsMngr)EcoreUtil.getObjectByType(view.getResource("my_import/combined.di").getContents(), DiPackage.Literals.SASH_WINDOWS_MNGR);
+ assertThat(mngr.getSashModel().getWindows().size(), is(2));
+ assertThat(mngr.getPageList().getAvailablePage().size(), is(3));
+ }
+
+ /**
+ * Tests that, following an import, any workspace resources that reference
+ * resources that have now been imported but that were not, themselves,
+ * imported, now reference the imported resources.
+ */
+ @Test
+ public void testWorkspaceResourcesURIsUpdated() throws Exception {
+
+ config.addModelToTransfer(hasDependents.getResourceURI("Datatypes.di"));
+
+ IModelImportMapping mapping = IModelImportMapping.Factory.ONE_TO_ONE.create(config);
+ mapping.setRepository(getPapyrusRepository());
+
+ fixture.importModels(mapping);
+
+ IFile notImported = hasDependencies.getFile("model.uml");
+ Reader reader = new InputStreamReader(notImported.getContents(), notImported.getCharset());
+ String text = CharStreams.toString(reader);
+ reader.close();
+
+ assertThat(text, not(containsString("href=\"../has_dependents/Datatypes.uml")));
+ assertThat(text, containsString("href=\"cdo://MEM/has_dependents/Datatypes.uml"));
+ }
+
+ //
+ // Test framework
+ //
+
+ @Before
+ public void createTestFixture() {
+ config = IModelTransferConfiguration.Factory.IMPORT.create(new IModelTransferOperation.Context() {
+
+ public Diagnostic run(IModelTransferOperation operation) {
+ operation.run(new NullProgressMonitor());
+ return Diagnostic.OK_INSTANCE;
+ }
+ }, null);
+
+ fixture = IModelImporter.Factory.DEFAULT.create();
+ }
+
+ @After
+ public void disposeTestFixture() {
+ fixture = null;
+
+ config.dispose();
+ config = null;
+ }
+
+ void sleep(int seconds) {
+ for(int i = 0; i < seconds; i++) {
+ try {
+ Thread.sleep(1000);
+ } catch (Exception e) {
+ // fine. We just won't sleep as long
+ }
+ }
+ }
+
+ void assertResource(Resource resource) {
+ assertThat(resource, notNullValue());
+ assertThat(resource.getContents().size(), not(0));
+ }
+
+ void assertResource(Resource resource, final String metamodel, int count) {
+ assertResource(resource);
+
+ assertThat(Iterables.size(Iterables.filter(resource.getContents(), new Predicate<EObject>() {
+
+ public boolean apply(EObject input) {
+ boolean result = false;
+
+ if(input != null) {
+ EPackage epackage = input.eClass().getEPackage();
+ result = epackage.getName().equalsIgnoreCase(metamodel);
+ }
+
+ return result;
+ }
+ })), is(count));
+ }
+}
diff --git a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/importer/tests/OneToOneModelImportMappingTest.java b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/importer/tests/OneToOneModelImportMappingTest.java
new file mode 100644
index 00000000000..ead25f4d24e
--- /dev/null
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/importer/tests/OneToOneModelImportMappingTest.java
@@ -0,0 +1,179 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.core.importer.tests;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.sameInstance;
+import static org.junit.Assert.assertThat;
+import static org.junit.matchers.JUnitMatchers.containsString;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.papyrus.cdo.core.importer.IModelImportMapping;
+import org.eclipse.papyrus.cdo.core.importer.IModelTransferConfiguration;
+import org.eclipse.papyrus.cdo.core.importer.IModelTransferNode;
+import org.eclipse.papyrus.cdo.core.importer.IModelTransferOperation;
+import org.eclipse.papyrus.cdo.core.tests.AbstractPapyrusCDOTest;
+import org.eclipse.papyrus.cdo.core.tests.TestProject;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+/**
+ * This is the OneToOneModelImportMappingTest type. Enjoy.
+ */
+public class OneToOneModelImportMappingTest extends AbstractPapyrusCDOTest {
+
+ private IModelTransferConfiguration config;
+
+ private IModelImportMapping fixture;
+
+ @Rule
+ public TestProject hasDependencies = new TestProject("has_dependencies");
+
+ @Rule
+ public TestProject hasDependents = new TestProject("has_dependents");
+
+ public OneToOneModelImportMappingTest() {
+ super();
+ }
+
+ @Test
+ public void testDefaultMappings() {
+ URI uri1 = hasDependencies.getResourceURI("model.di");
+ URI uri2 = hasDependents.getResourceURI("Datatypes.di");
+
+ config.addModelToTransfer(uri1);
+ config.addModelToTransfer(uri2);
+
+ assertThat(fixture.getMapping(getNode(uri1)), is((IPath)new Path("/has_dependencies/model.di")));
+ assertThat(fixture.getMapping(getNode(uri2)), is((IPath)new Path("/has_dependents/Datatypes.di")));
+ }
+
+ @Test
+ public void testValidation_ok() throws Exception {
+
+ URI uri1 = hasDependencies.getResourceURI("model.di");
+ URI uri2 = hasDependents.getResourceURI("Datatypes.di");
+
+ config.addModelToTransfer(uri1);
+ config.addModelToTransfer(uri2);
+
+ Diagnostic problems = fixture.validate();
+
+ assertThat(problems.getSeverity(), is(Diagnostic.OK));
+ assertThat(problems.getChildren().size(), is(0));
+ }
+
+ @Test
+ public void testValidation_resourceExists() throws Exception {
+
+ CDOTransaction transaction = createTransaction();
+ transaction.getOrCreateResource("has_dependencies/model.di");
+ transaction.commit();
+ transaction.close();
+
+ URI uri = hasDependencies.getResourceURI("model.di");
+ config.addModelToTransfer(uri);
+
+ Diagnostic problems = fixture.validate();
+
+ assertThat(problems.getChildren().size(), is(1));
+ Diagnostic child = problems.getChildren().get(0);
+ assertThat(child.getSeverity(), is(Diagnostic.ERROR));
+ assertThat(child.getMessage(), containsString("Resource already exists"));
+ assertThat(child.getData().get(0), sameInstance((Object)getNode(uri)));
+ }
+
+ @Test
+ public void testValidation_mappingAbsent() {
+ URI uri = hasDependencies.getResourceURI("model.di");
+ config.addModelToTransfer(uri);
+
+ fixture.mapTo(getNode(uri), null);
+
+ Diagnostic problems = fixture.validate();
+
+ assertThat(problems.getChildren().size(), is(1));
+ Diagnostic child = problems.getChildren().get(0);
+ assertThat(child.getSeverity(), is(Diagnostic.ERROR));
+ assertThat(child.getMessage(), containsString("No mapping"));
+ assertThat(child.getData().get(0), sameInstance((Object)getNode(uri)));
+ }
+
+ @Test
+ public void testValidation_repository() throws Exception {
+
+ getPapyrusRepository().disconnect();
+
+ Diagnostic problems = fixture.validate();
+
+ assertThat(problems.getChildren().size(), is(1));
+ Diagnostic child = problems.getChildren().get(0);
+ assertThat(child.getSeverity(), is(Diagnostic.ERROR));
+ assertThat(child.getMessage(), containsString("is not connected"));
+ assertThat(child.getData().get(0), sameInstance((Object)getPapyrusRepository()));
+
+ fixture.setRepository(null);
+
+ problems = fixture.validate();
+
+ assertThat(problems.getChildren().size(), is(1));
+ child = problems.getChildren().get(0);
+ assertThat(child.getSeverity(), is(Diagnostic.ERROR));
+ assertThat(child.getMessage(), containsString("No repository"));
+ }
+
+ //
+ // Test framework
+ //
+
+ @Before
+ public void createTestFixture() {
+ config = IModelTransferConfiguration.Factory.IMPORT.create(new IModelTransferOperation.Context() {
+
+ public Diagnostic run(IModelTransferOperation operation) {
+ operation.run(new NullProgressMonitor());
+ return Diagnostic.OK_INSTANCE;
+ }
+ }, null);
+
+ fixture = IModelImportMapping.Factory.ONE_TO_ONE.create(config);
+ fixture.setRepository(getPapyrusRepository());
+ }
+
+ @After
+ public void disposeTestFixture() {
+ fixture = null;
+
+ config.dispose();
+ config = null;
+ }
+
+ IModelTransferNode getNode(URI uri) {
+ IModelTransferNode result = null;
+
+ for(IModelTransferNode next : config.getModelsToTransfer()) {
+ if(next.getPrimaryResourceURI().equals(uri)) {
+ result = next;
+ break;
+ }
+ }
+
+ return result;
+ }
+}
diff --git a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/tests/PapyrusRepositoryManagerTest.java b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/tests/PapyrusRepositoryManagerTest.java
new file mode 100644
index 00000000000..8b191a13c02
--- /dev/null
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/tests/PapyrusRepositoryManagerTest.java
@@ -0,0 +1,442 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.core.tests;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.CoreMatchers.sameInstance;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertThat;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import org.eclipse.emf.cdo.eresource.CDOResourceNode;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.transaction.CDOTransactionFinishedEvent;
+import org.eclipse.emf.cdo.view.CDOView;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.net4j.util.container.ContainerEventAdapter;
+import org.eclipse.net4j.util.container.IContainer;
+import org.eclipse.net4j.util.event.IEvent;
+import org.eclipse.net4j.util.event.IListener;
+import org.eclipse.papyrus.cdo.core.IPapyrusRepository;
+import org.eclipse.papyrus.cdo.core.IResourceSetDisposalApprover;
+import org.eclipse.papyrus.cdo.core.tests.AbstractPapyrusCDOTest;
+import org.eclipse.papyrus.cdo.internal.core.IRepositoryModelStorage;
+import org.eclipse.papyrus.cdo.internal.core.PapyrusRepository;
+import org.eclipse.papyrus.cdo.internal.core.PapyrusRepositoryManager;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+
+/**
+ * This is the PapyrusRepositoryManagerTest type. Enjoy.
+ */
+public class PapyrusRepositoryManagerTest
+ extends AbstractPapyrusCDOTest {
+
+ private PapyrusRepositoryManager fixture;
+
+ public PapyrusRepositoryManagerTest() {
+ super();
+ }
+
+ @Test
+ public void createAndRemoveRepository()
+ throws Exception {
+
+ ContainerListener<IPapyrusRepository> listener = new ContainerListener<IPapyrusRepository>();
+ fixture.addListener(listener);
+
+ assertThat(fixture.isEmpty(), is(true));
+
+ IPapyrusRepository repo = fixture.createRepository(getRepositoryURL());
+
+ assertThat(fixture.isEmpty(), is(false));
+ assertThat(repo, notNullValue());
+
+ repo.setName("My Repository");
+
+ assertThat(listener.getAdded(),
+ equalTo(Collections.singletonList(repo)));
+ assertThat(listener.getRemoved(),
+ equalTo(Collections.<IPapyrusRepository> emptyList()));
+
+ assertArrayEquals(new IPapyrusRepository[]{repo}, fixture.getElements());
+ assertThat(ImmutableSet.copyOf(fixture.getRepositories()),
+ equalTo(ImmutableSet.of(repo)));
+
+ repo.connect();
+
+ assertThat(repo.isConnected(), is(true));
+
+ repo.disconnect();
+
+ assertThat(repo.isConnected(), is(false));
+
+ fixture.removeRepository(repo);
+ assertThat(listener.getRemoved(),
+ equalTo(Collections.singletonList(repo)));
+ }
+
+ @Test
+ public void createTransaction_ResourceSet()
+ throws Exception {
+
+ PapyrusRepository repo = (PapyrusRepository) fixture
+ .createRepository(getRepositoryURL());
+
+ ContainerListener<CDOResourceNode> listener = new ContainerListener<CDOResourceNode>();
+ repo.addListener(listener);
+
+ assertThat(repo.isEmpty(), is(true));
+
+ repo.connect();
+
+ ResourceSet rset = new ResourceSetImpl();
+ assertThat(repo.createTransaction(rset), sameInstance(rset));
+
+ CDOTransaction transaction = (CDOTransaction) repo.getCDOView(rset);
+ assertThat(transaction.isClosed(), is(false));
+ assertThat(transaction.isDirty(), is(false));
+
+ Resource res = rset.createResource(getTestResourceURI("model.uml"));
+ res.getContents().add(UMLFactory.eINSTANCE.createModel());
+ assertThat(transaction.isDirty(), is(true));
+
+ assertThat(fixture.getRepositoryForURI(res.getURI()),
+ sameInstance((IPapyrusRepository) repo));
+
+ repo.commit(rset);
+ assertThat(transaction.isDirty(), is(false));
+
+ // passive update of the view reports the new resource folder
+ assertThat(listener.getAdded(1).size(), equalTo(1));
+ assertThat(listener.getRemoved().size(), equalTo(0));
+
+ assertThat(repo.isEmpty(), is(false));
+ assertThat(repo.getElements().length, equalTo(1));
+
+ repo.close(rset);
+ assertThat(transaction.isClosed(), is(true));
+
+ repo.disconnect();
+
+ assertThat(listener.getRemoved(1).size(), equalTo(1));
+ }
+
+ @Test
+ public void loadAndSave()
+ throws Exception {
+ StringStorage storage = new StringStorage();
+
+ PapyrusRepositoryManager mgr = new PapyrusRepositoryManager(storage);
+ assertThat(mgr.getRepositories().size(), equalTo(0));
+
+ mgr.createRepository(getRepositoryURL()).setName("My Repository");
+
+ mgr.saveRepositories();
+
+ mgr.dispose();
+
+ mgr = new PapyrusRepositoryManager(storage);
+
+ try {
+ assertThat(mgr.getRepositories().size(), equalTo(1));
+ PapyrusRepository repo = (PapyrusRepository) Iterables
+ .getOnlyElement(mgr.getRepositories());
+ assertThat(repo.getName(), equalTo("My Repository"));
+ assertThat(repo.getURL(), equalTo(getRepositoryURL()));
+ assertThat(repo.isConnected(), is(false));
+ assertThat(repo.isEmpty(), is(true));
+ } finally {
+ mgr.dispose();
+ }
+ }
+
+ @Test
+ public void disposalNoAction()
+ throws Exception {
+
+ PapyrusRepository repo = (PapyrusRepository) fixture
+ .createRepository(getRepositoryURL());
+ repo.connect();
+
+ repo.addResourceSetDisposalApprover(new IResourceSetDisposalApprover() {
+
+ public DisposeAction disposalRequested(
+ IPapyrusRepository repository,
+ Collection<ResourceSet> resourceSets) {
+
+ return DisposeAction.NONE;
+ }
+ });
+
+ ResourceSet rset = repo.createTransaction(new ResourceSetImpl());
+ CommitListener listener = new CommitListener();
+ repo.getCDOView(rset).addListener(listener);
+
+ // dirty the transaction
+ rset.createResource(getTestResourceURI("model.uml"));
+
+ repo.disconnect();
+
+ // still connected and transaction dirty
+ assertThat(repo.isConnected(), is(true));
+ assertThat(repo.getCDOView(rset).isDirty(), is(true));
+ assertThat(listener.testAndClearCommitted(), is(false));
+ }
+
+ @Test
+ public void disposalSaveAction()
+ throws Exception {
+
+ PapyrusRepository repo = (PapyrusRepository) fixture
+ .createRepository(getRepositoryURL());
+ repo.connect();
+
+ repo.addResourceSetDisposalApprover(new IResourceSetDisposalApprover() {
+
+ public DisposeAction disposalRequested(
+ IPapyrusRepository repository,
+ Collection<ResourceSet> resourceSets) {
+
+ return DisposeAction.SAVE;
+ }
+ });
+
+ ResourceSet rset = repo.createTransaction(new ResourceSetImpl());
+ CDOView view = repo.getCDOView(rset);
+ CommitListener listener = new CommitListener();
+ view.addListener(listener);
+
+ // dirty the transaction
+ rset.createResource(getTestResourceURI("model.uml"));
+
+ repo.disconnect();
+
+ // not connected and transaction closed, but committed
+ assertThat(repo.isConnected(), is(false));
+ assertThat(view.isClosed(), is(true));
+ assertThat(listener.testAndClearCommitted(), is(true));
+ }
+
+ @Test
+ public void disposalCloseAction()
+ throws Exception {
+
+ PapyrusRepository repo = (PapyrusRepository) fixture
+ .createRepository(getRepositoryURL());
+ repo.connect();
+
+ repo.addResourceSetDisposalApprover(new IResourceSetDisposalApprover() {
+
+ public DisposeAction disposalRequested(
+ IPapyrusRepository repository,
+ Collection<ResourceSet> resourceSets) {
+
+ return DisposeAction.CLOSE;
+ }
+ });
+
+ ResourceSet rset = repo.createTransaction(new ResourceSetImpl());
+ CDOView view = repo.getCDOView(rset);
+ CommitListener listener = new CommitListener();
+ view.addListener(listener);
+
+ // dirty the transaction
+ rset.createResource(getTestResourceURI("model.uml"));
+
+ repo.disconnect();
+
+ // not connected and transaction closed, but *not* committed
+ assertThat(repo.isConnected(), is(false));
+ assertThat(view.isClosed(), is(true));
+ assertThat(listener.testAndClearCommitted(), is(false));
+ }
+
+ //
+ // Test framework
+ //
+
+ @Override
+ protected boolean needPapyrusRepository() {
+ return false; // I create my own repository manager for testing
+ }
+
+ @Before
+ public void createRepositoryManager()
+ throws Exception {
+
+ fixture = new PapyrusRepositoryManager();
+ }
+
+ @After
+ public void disposeRepositoryManager()
+ throws Exception {
+
+ if (fixture != null) {
+ fixture.dispose();
+ fixture = null;
+ }
+ }
+
+ static class ContainerListener<T>
+ extends ContainerEventAdapter<T> {
+
+ private List<T> added = Lists.newArrayListWithExpectedSize(1);
+
+ private boolean addedChanged;
+
+ private List<T> removed = Lists.newArrayListWithExpectedSize(1);
+
+ private boolean removedChanged;
+
+ List<T> getAdded() {
+ synchronized (added) {
+ // clear the flag
+ addedChanged = false;
+ return added;
+ }
+ }
+
+ List<T> getAdded(long seconds) {
+ synchronized (added) {
+ long timeout = TimeUnit.SECONDS.toMillis(seconds);
+ while (!addedChanged && (timeout > 0L)) {
+ timeout = waitFor(added, timeout);
+ }
+
+ assertThat("No element added.", addedChanged, is(true));
+
+ addedChanged = false;
+ return added;
+ }
+ }
+
+ private long waitFor(Object monitor, long millis) {
+ long before = System.currentTimeMillis();
+
+ try {
+ monitor.wait(millis);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ Assert.fail("Interrupted while waiting for " + monitor);
+ }
+
+ return millis - (System.currentTimeMillis() - before);
+ }
+
+ List<T> getRemoved() {
+ synchronized (added) {
+ // clear the flag
+ removedChanged = false;
+ return removed;
+ }
+ }
+
+ List<T> getRemoved(long seconds) {
+ synchronized (removed) {
+ long timeout = TimeUnit.SECONDS.toMillis(seconds);
+ while (!removedChanged && (timeout > 0L)) {
+ timeout = waitFor(removed, timeout);
+ }
+
+ assertThat("No element removed.", removedChanged, is(true));
+
+ removedChanged = false;
+ return removed;
+ }
+ }
+
+ protected void onAdded(IContainer<T> container, T element) {
+ synchronized (added) {
+ added.add(element);
+ addedChanged = true;
+ added.notifyAll();
+ }
+ }
+
+ protected void onRemoved(IContainer<T> container, T element) {
+ synchronized (removed) {
+ removed.add(element);
+ removedChanged = true;
+ removed.notifyAll();
+ }
+ }
+ }
+
+ static class CommitListener
+ implements IListener {
+
+ private volatile boolean committed;
+
+ boolean testAndClearCommitted() {
+ boolean result = committed;
+ committed = false;
+ return result;
+ }
+
+ public void notifyEvent(IEvent event) {
+ if (event instanceof CDOTransactionFinishedEvent) {
+ committed = true;
+ }
+ }
+ }
+
+ static class StringStorage
+ implements IRepositoryModelStorage {
+
+ String storage = null;
+
+ public InputStream createInputStream()
+ throws IOException {
+
+ return (storage == null
+ ? null
+ : new ByteArrayInputStream(storage.getBytes("UTF-8")));
+ }
+
+ public OutputStream createOutputStream()
+ throws IOException {
+
+ return new ByteArrayOutputStream() {
+
+ @Override
+ public void close()
+ throws IOException {
+
+ super.close();
+
+ storage = toString("UTF-8");
+ }
+ };
+ }
+ }
+}

Back to the top