summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjmusset2009-03-05 11:34:14 (EST)
committer jmusset2009-03-05 11:34:14 (EST)
commit9d7b9e36fc2770ff27a792ddd4b9ecbb039271bf (patch)
tree5a75c452531e0ff65baf3b1a363644c71a3cfcdf
parent4a6b8ad4715be67da93ba8333a0c5a13bb3d1d83 (diff)
downloadorg.eclipse.acceleo-9d7b9e36fc2770ff27a792ddd4b9ecbb039271bf.zip
org.eclipse.acceleo-9d7b9e36fc2770ff27a792ddd4b9ecbb039271bf.tar.gz
org.eclipse.acceleo-9d7b9e36fc2770ff27a792ddd4b9ecbb039271bf.tar.bz2
Project renaming from MTL to Acceleo
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/.checkstyle9
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/.classpath7
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/.project28
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/META-INF/MANIFEST.MF17
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/about.html57
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/build.properties20
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/data/ForBlock/template_for.mtl71
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/data/GenericEngine/generic_engine.mtl19
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/data/IfBlock/template_if.mtl57
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/data/Listeners/listeners.mtl19
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/data/ProtectedAreaBlock/protected_areas.mtl52
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/data/Resolution/Namesake/Guard/extended.mtl12
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/data/Resolution/Namesake/Guard/imported.mtl12
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/data/Resolution/Namesake/Guard/local.mtl33
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/data/Resolution/Namesake/ParameterTypeNarrowing/extended.mtl28
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/data/Resolution/Namesake/ParameterTypeNarrowing/imported.mtl28
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/data/Resolution/Namesake/ParameterTypeNarrowing/local.mtl85
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/data/Resolution/Namesake/Simple/extended.mtl12
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/data/Resolution/Namesake/Simple/imported.mtl12
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/data/Resolution/Namesake/Simple/local.mtl53
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/data/Resolution/Override/Guard/extended.mtl12
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/data/Resolution/Override/Guard/imported.mtl8
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/data/Resolution/Override/Guard/local.mtl29
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/data/Resolution/Override/ParameterTypeNarrowing/extended.mtl12
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/data/Resolution/Override/ParameterTypeNarrowing/imported.mtl8
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/data/Resolution/Override/ParameterTypeNarrowing/local.mtl29
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/data/Resolution/Override/Simple/extended.mtl12
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/data/Resolution/Override/Simple/imported.mtl8
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/data/Resolution/Override/Simple/local.mtl53
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/data/Template/extended.mtl16
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/data/Template/local.mtl79
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/data/TemplateInvocation/dual_template_call.mtl20
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/data/Variables/template_self.mtl39
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/data/abstractClass.ecore9
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/data/target.ecore27
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/data/target_uml.uml45
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/plugin.properties12
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/ForBlock/GenerationTest/AfterKeyword/testForAfter4
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/ForBlock/GenerationTest/BasicExample/testForSimple4
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/ForBlock/GenerationTest/BeforeKeyword/testForBefore4
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/ForBlock/GenerationTest/GuardKeyword/testForGuard1
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/ForBlock/GenerationTest/SeparatorKeyword/testForSeparator4
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/ForBlock/ReferenceResult/AfterKeyword/testForAfter4
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/ForBlock/ReferenceResult/BasicExample/testForSimple4
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/ForBlock/ReferenceResult/BeforeKeyword/testForBefore5
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/ForBlock/ReferenceResult/GuardKeyword/testForGuard1
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/ForBlock/ReferenceResult/SeparatorKeyword/testForSeparator2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/GenericEngine/GenerationTest/PublicTemplateValidArgs/test_generic_engine2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/GenericEngine/ReferenceResult/PublicTemplateValidArgs/test_generic_engine2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/IfBlock/GenerationTest/CompleteIf/testCompleteIf4
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/IfBlock/GenerationTest/Else/testElse1
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/IfBlock/GenerationTest/Elseif/testElseif3
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/IfBlock/GenerationTest/If/testIf1
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/IfBlock/GenerationTest/NestedIf/testNestedIf4
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/IfBlock/ReferenceResult/CompleteIf/testCompleteIf4
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/IfBlock/ReferenceResult/Else/testElse1
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/IfBlock/ReferenceResult/Elseif/testElseif3
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/IfBlock/ReferenceResult/If/testIf1
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/IfBlock/ReferenceResult/NestedIf/testNestedIf6
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/Listeners/GenerationTest/Listeners/AbstractClass.java3
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/Listeners/GenerationTest/Listeners/ClasseA.java7
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/Listeners/GenerationTest/Listeners/ClasseB.java6
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Guard/GenerationTest/NamesakeGuard/resolution_namesake_guard2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Guard/GenerationTest/NamesakeGuardImportSpecific/resolution_namesake_guard_import_specific2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Guard/GenerationTest/NamesakeGuardedSpecific/resolution_namesake_guarded_specific2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Guard/ReferenceResult/NamesakeGuard/resolution_namesake_guard3
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Guard/ReferenceResult/NamesakeGuardImportSpecific/resolution_namesake_guard_import_specific3
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Guard/ReferenceResult/NamesakeGuardedSpecific/resolution_namesake_guarded_specific3
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/GenerationTest/NamesakeExtendMostSpecific/resolution_namesake_extend_specific2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/GenerationTest/NamesakeExternalExtendSpecific/resolution_namesake_external_extend_specific2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/GenerationTest/NamesakeExternalImportSpecific/resolution_namesake_external_import_specific2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/GenerationTest/NamesakeImportMostSpecific/resolution_namesake_import_specific2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/GenerationTest/NamesakeLocalMostSpecific/resolution_namesake_local_specific2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/GenerationTest/NamesakeOnExtendExtendSpecific/resolution_namesake_extend_extend_specific2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/GenerationTest/NamesakeOnExtendLocalSpecific/resolution_namesake_extend_local_specific2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/GenerationTest/NamesakeOnImportImportSpecific/resolution_namesake_import_import_specific2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/GenerationTest/NamesakeOnImportLocalSpecific/resolution_namesake_import_local_specific2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/ReferenceResult/NamesakeExtendMostSpecific/resolution_namesake_extend_specific3
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/ReferenceResult/NamesakeExternalExtendSpecific/resolution_namesake_external_extend_specific3
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/ReferenceResult/NamesakeExternalImportSpecific/resolution_namesake_external_import_specific3
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/ReferenceResult/NamesakeImportMostSpecific/resolution_namesake_import_specific3
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/ReferenceResult/NamesakeLocalMostSpecific/resolution_namesake_local_specific3
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/ReferenceResult/NamesakeOnExtendExtendSpecific/resolution_namesake_extend_extend_specific3
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/ReferenceResult/NamesakeOnExtendLocalSpecific/resolution_namesake_extend_local_specific3
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/ReferenceResult/NamesakeOnImportImportSpecific/resolution_namesake_import_import_specific3
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/ReferenceResult/NamesakeOnImportLocalSpecific/resolution_namesake_import_local_specific3
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Simple/GenerationTest/NamesakeDistinctParameterNames/distinct_param_name2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Simple/GenerationTest/NamesakeExtendConflict/resolution_extended2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Simple/GenerationTest/NamesakeExternalConflict/resolution_external2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Simple/GenerationTest/NamesakeImportConflict/resolution_imported2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Simple/GenerationTest/NamesakePriority/resolution_priority2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Simple/ReferenceResult/NamesakeDistinctParameterNames/distinct_param_name2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Simple/ReferenceResult/NamesakeExtendConflict/resolution_extended3
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Simple/ReferenceResult/NamesakeExternalConflict/resolution_external3
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Simple/ReferenceResult/NamesakeImportConflict/resolution_imported3
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Simple/ReferenceResult/NamesakePriority/resolution_priority3
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Guard/GenerationTest/ExternalDefinitionGuarded/resolution_external_override_definition_guarded2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Guard/GenerationTest/LocalDefinitionGuarded/resolution_local_override_definition_guarded2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Guard/GenerationTest/SpecificGuarded/resolution_override_specific_guarded2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Guard/ReferenceResult/ExternalDefinitionGuarded/resolution_external_override_definition_guarded3
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Guard/ReferenceResult/LocalDefinitionGuarded/resolution_local_override_definition_guarded3
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Guard/ReferenceResult/SpecificGuarded/resolution_override_specific_guarded3
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/ParameterTypeNarrowing/GenerationTest/ParameterNarrowing/resolution_override_specific2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/ParameterTypeNarrowing/GenerationTest/ParameterNarrowingExternal/resolution_external_override2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/ParameterTypeNarrowing/GenerationTest/ParameterNarrowingLocal/resolution_local_override2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/ParameterTypeNarrowing/ReferenceResult/ParameterNarrowing/resolution_override_specific3
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/ParameterTypeNarrowing/ReferenceResult/ParameterNarrowingExternal/resolution_external_override3
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/ParameterTypeNarrowing/ReferenceResult/ParameterNarrowingLocal/resolution_local_override3
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/GenerationTest/ExtendOverrideDirectCall/resolution_extend_overriden_direct2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/GenerationTest/ExtendOverrideIndirectCall/resolution_extend_overriden_indirect2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/GenerationTest/LocalOverrideDirectCall/resolution_local_overriden_direct2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/GenerationTest/LocalOverrideIndirectCall/resolution_local_overriden_indirect2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/GenerationTest/OverridePriorityDirectCall/resolution_override_priority_direct2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/GenerationTest/OverridePriorityIndirectCall/resolution_override_priority_indirect2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/GenerationTest/OverridePriorityMidIndirectCall/resolution_override_priority_indirect_extend2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/ReferenceResult/ExtendOverrideDirectCall/resolution_extend_overriden_direct3
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/ReferenceResult/ExtendOverrideIndirectCall/resolution_extend_overriden_indirect3
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/ReferenceResult/LocalOverrideDirectCall/resolution_local_overriden_direct3
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/ReferenceResult/LocalOverrideIndirectCall/resolution_local_overriden_indirect3
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/ReferenceResult/OverridePriorityDirectCall/resolution_override_priority_direct3
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/ReferenceResult/OverridePriorityIndirectCall/resolution_override_priority_indirect3
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/ReferenceResult/OverridePriorityMidIndirectCall/resolution_override_priority_indirect_extend3
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/ProtectedAreaBlock/GenerationTest/LostProtectedArea/lost_protected_areas6
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/ProtectedAreaBlock/GenerationTest/LostProtectedArea/lost_protected_areas.lost7
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/ProtectedAreaBlock/GenerationTest/RemovedProtectedArea/removed_protected_areas4
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/ProtectedAreaBlock/GenerationTest/RemovedProtectedArea/removed_protected_areas.lost7
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/ProtectedAreaBlock/GenerationTest/Standard/protected_areas7
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/ProtectedAreaBlock/ReferenceResult/LostProtectedArea/lost_protected_areas10
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/ProtectedAreaBlock/ReferenceResult/LostProtectedArea/lost_protected_areas.lost7
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/ProtectedAreaBlock/ReferenceResult/RemovedProtectedArea/removed_protected_areas7
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/ProtectedAreaBlock/ReferenceResult/RemovedProtectedArea/removed_protected_areas.lost7
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/ProtectedAreaBlock/ReferenceResult/Standard/protected_areas10
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/Template/GenerationTest/After/after_test2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/Template/GenerationTest/Before/before_test2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/Template/GenerationTest/FalseGuard/false_guard2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/Template/GenerationTest/Import/import2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/Template/GenerationTest/PrivateVisibility/private_visibility2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/Template/GenerationTest/ProtectOverride/protected_override2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/Template/GenerationTest/ProtectedVisibility/protected_visibility2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/Template/GenerationTest/Super/super2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/Template/GenerationTest/TrueGuard/true_guard2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/Template/ReferenceResult/After/after_test3
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/Template/ReferenceResult/Before/before_test4
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/Template/ReferenceResult/FalseGuard/false_guard2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/Template/ReferenceResult/Import/import3
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/Template/ReferenceResult/PrivateVisibility/private_visibility3
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/Template/ReferenceResult/ProtectOverride/protected_override3
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/Template/ReferenceResult/ProtectedVisibility/protected_visibility3
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/Template/ReferenceResult/Super/super4
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/Template/ReferenceResult/TrueGuard/true_guard3
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/TemplateInvocation/GenerationTest/DualTemplateInvocation/dual_query_invocation2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/TemplateInvocation/GenerationTest/DualTemplateInvocation/dual_template_invocation2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/TemplateInvocation/ReferenceResult/DualTemplateInvocation/dual_template_invocation3
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/Variables/GenerationTest/ImplicitSelfQuery/implicit_self_query2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/Variables/GenerationTest/ImplicitSelfTemplate/implicit_self_template2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/Variables/GenerationTest/SelfQuery/self_query2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/Variables/GenerationTest/SelfTemplate/self_template2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/Variables/ReferenceResult/ImplicitSelfQuery/implicit_self_query2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/Variables/ReferenceResult/ImplicitSelfTemplate/implicit_self_template2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/Variables/ReferenceResult/SelfQuery/self_query2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src-gen/Variables/ReferenceResult/SelfTemplate/self_template2
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/AcceleoEngineTestPlugin.java64
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/suite/AllTests.java96
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/AbstractAcceleoTest.java374
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/blocks/forBlock/ForBlockTest.java144
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/blocks/ifBlock/IfBlockTest.java144
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/blocks/protectedareablock/ProtectedAreaBlockTest.java199
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/blocks/template/TemplateTest.java284
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/blocks/templateinvocation/DualTemplateInvocationTest.java70
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/engine/AcceleoGenericEngineTest.java395
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/environment/AcceleoNonStandardLibraryTest.java658
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/environment/AcceleoStandardLibraryTest.java567
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/listeners/AcceleoListenersTest.java217
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/resolution/namesake/NamesakeGuardResolutionTest.java165
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/resolution/namesake/ParameterTypeNarrowingResolutionTest.java316
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/resolution/namesake/SimpleNamesakeResolutionTest.java210
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/resolution/override/OverrideGuardResolutionTest.java168
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/resolution/override/OverrideParameterTypeNarrowingResolutionTest.java161
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/resolution/override/SimpleOverridesResolutionTest.java263
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/utils/AcceleoEnginePluginTest.java300
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/utils/MessagesTest.java231
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/variables/SelfTest.java148
-rw-r--r--tests/org.eclipse.acceleo.engine.tests/test.xml66
184 files changed, 6667 insertions, 0 deletions
diff --git a/tests/org.eclipse.acceleo.engine.tests/.checkstyle b/tests/org.eclipse.acceleo.engine.tests/.checkstyle
new file mode 100644
index 0000000..60d2e33
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/.checkstyle
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<fileset-config file-format-version="1.2.0" simple-config="true">
+ <local-check-config name="Acceleo" location="/org.eclipse.acceleo-feature/codestyle/AcceleoCheckstyleConfiguration.xml" type="project" description="">
+ <additional-data name="protect-config-file" value="false"/>
+ </local-check-config>
+ <fileset name="tous" enabled="true" check-config-name="Acceleo" local="true">
+ <file-match-pattern match-pattern="." include-pattern="true"/>
+ </fileset>
+</fileset-config>
diff --git a/tests/org.eclipse.acceleo.engine.tests/.classpath b/tests/org.eclipse.acceleo.engine.tests/.classpath
new file mode 100644
index 0000000..64c5e31
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.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/org.eclipse.acceleo.engine.tests/.project b/tests/org.eclipse.acceleo.engine.tests/.project
new file mode 100644
index 0000000..958e345
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.acceleo.engine.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/org.eclipse.acceleo.engine.tests/.settings/org.eclipse.jdt.core.prefs b/tests/org.eclipse.acceleo.engine.tests/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..d541d1b
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+#Wed May 28 17:44:06 CEST 2008
+eclipse.preferences.version=1
+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
diff --git a/tests/org.eclipse.acceleo.engine.tests/META-INF/MANIFEST.MF b/tests/org.eclipse.acceleo.engine.tests/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..ded03e6
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/META-INF/MANIFEST.MF
@@ -0,0 +1,17 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.eclipse.acceleo.engine.tests;singleton:=true
+Bundle-Version: 0.8.0.qualifier
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Require-Bundle: org.eclipse.acceleo.engine,
+ org.eclipse.core.runtime,
+ org.eclipse.acceleo.model,
+ org.eclipse.acceleo.common,
+ org.eclipse.ocl.ecore,
+ org.junit,
+ org.eclipse.acceleo.parser
+Eclipse-LazyStart: true
+Bundle-ActivationPolicy: lazy
+Bundle-Activator: org.eclipse.acceleo.engine.tests.AcceleoEngineTestPlugin
+Bundle-Vendor: %providerName
diff --git a/tests/org.eclipse.acceleo.engine.tests/about.html b/tests/org.eclipse.acceleo.engine.tests/about.html
new file mode 100644
index 0000000..7e1117e
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/about.html
@@ -0,0 +1,57 @@
+<!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>
+
+<em>July 25, 2008</em></p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, "Program" will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party ("Redistributor") and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+
+ <h3>Third Party Content</h3>
+ <p>The Content includes items that have been sourced from third parties as set out below. If you
+ did not receive this Content directly from the Eclipse Foundation, the following is provided
+ for informational purposes only, and you should look to the Redistributor's license for
+ terms and conditions of use.</p>
+ <p><em>
+ <br><br>
+ <strong>OMG MOF 2.0 Specification (06-01-01)</strong> <br>
+ <ul>
+ <li><a href="http://www.omg.org/technology/documents/formal/mof.htm">MOF 2.0 main page</a></li>
+ <li><a href="http://www.omg.org/docs/formal/06-01-01.pdf">MOF 2.0 specification</a></li>
+ <li><a href="http://www.omg.org/">OMG site</a></li>
+ </ul>
+ <br>
+ <strong>OMG OCL 2.0 specification (06-05-01)</strong> <br>
+ <ul>
+ <li><a href="http://www.omg.org/technology/documents/formal/ocl.htm">OCL 2.0 main page</a></li>
+ <li><a href="http://www.omg.org/docs/formal/06-05-01.pdf">OCL 2.0 specification</a></li>
+ <li><a href="http://www.omg.org/">OMG site</a></li>
+ </ul>
+ <br>
+ <strong>OMG MTL 1.0 specification (08-01-16)</strong> <br>
+ <ul>
+ <li><a href="http://www.omg.org/spec/MOFM2T/1.0/">MTL 1.0 main page</a></li>
+ <li><a href="http://www.omg.org/spec/MOFM2T/1.0/PDF">MTL 1.0 specification</a></li>
+ <li><a href="http://www.omg.org/">OMG site</a></li>
+ </ul>
+ <br>
+ </em></p>
+ <p>A detailed list of fixes and clarifications with respect to those specifications may be found in the plug-in directly realizing them.</p>
+</body></html> \ No newline at end of file
diff --git a/tests/org.eclipse.acceleo.engine.tests/build.properties b/tests/org.eclipse.acceleo.engine.tests/build.properties
new file mode 100644
index 0000000..4aaa282
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/build.properties
@@ -0,0 +1,20 @@
+################################################################################
+# Copyright (c) 2008, 2009 Obeo.
+# 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:
+# Obeo - initial API and implementation
+################################################################################
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ test.xml,\
+ data/,\
+ about.html,\
+ src-gen/,\
+ plugin.properties
+Bundle-ClassPath: .
diff --git a/tests/org.eclipse.acceleo.engine.tests/data/ForBlock/template_for.mtl b/tests/org.eclipse.acceleo.engine.tests/data/ForBlock/template_for.mtl
new file mode 100644
index 0000000..9a00bf4
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/data/ForBlock/template_for.mtl
@@ -0,0 +1,71 @@
+[module template_for_1('http://www.eclipse.org/emf/2002/Ecore')/]
+
+[comment simple "for" example to test minimal for statement /]
+[template public testingSimple(c : EPackage)]
+ [file ('testForSimple', false)]
+ [for (cl : EClassifier | c.eClassifiers)]
+ [cl.name/]
+ [/for]
+ [/file]
+[/template]
+
+[comment simple "for" example to test "separator" keyword /]
+[template public testingSeparator(c : EPackage)]
+ [file ('testForSeparator', false)]
+ [for (cl : EClassifier | c.eClassifiers) separator ('/') ]
+ [cl.name/]
+ [/for]
+ [/file]
+[/template]
+
+[comment simple "for" example to test "before" keyword /]
+[template public testingBefore(c : EPackage)]
+ [file ('testForBefore', false)]
+ [for (cl : EClassifier | c.eClassifiers) before ('before test') ]
+ [cl.name/]
+ [/for]
+ [/file]
+[/template]
+
+[comment simple "for" example to test "after" keyword/]
+[template public testingAfter(c : EPackage)]
+ [file ('testForAfter', false)]
+ [for (cl : EClassifier | c.eClassifiers) after ('after test') ]
+ [cl.name/]
+ [/for]
+ [/file]
+[/template]
+
+[comment simple "for" example to test "guard" keyword /]
+[template public testingGuard(c : EPackage)]
+ [file ('testForGuard', false)]
+ [for (cl : EClassifier | c.eClassifiers) ? (cl.name.startsWith('S'))]
+ [cl.name/]
+ [/for]
+ [/file]
+[/template]
+
+[comment Init is not implemented yet]
+[template public testingInit(c : EPackage)]
+ [file ('test', false)]
+ [for (cl : EClassifier | c.eClassifiers) { starter: EString = 'test'; }]
+ [cl.name/]
+ [/for]
+ [/file]
+[/template]
+[/comment]
+
+[template public testingComplexFor(c : EClass) {name : String = '';}]
+ [file ('test', false)]
+ [if (c.name <> 'ClasseB')]Nothing should be generated here if the for guard is evaluated correctly[/if]
+ value of 'name' outside of for: '[name/]' (should be empty)
+ [for (a : EAttribute | c.eAllAttributes) before ('before') separator ('in-between') after('after') ? (name.substring(name.size(), name.size()) = 'B') {name : String = c.name;}]
+ value of 'name' inside first for: '[name/]' (should be '[c.name/]')
+ [for (cl : EClassifier | a.eType) {name : String = a.name;}]
+ value of 'name' inside second for: '[name/]' (should be '[a.name/]')
+ [/for]
+ value of 'name' inside first for: '[name/]' (should be '[c.name/]')
+ [/for]
+ value of 'name' outside of for: '[name/]' (should be empty)
+ [/file]
+[/template] \ No newline at end of file
diff --git a/tests/org.eclipse.acceleo.engine.tests/data/GenericEngine/generic_engine.mtl b/tests/org.eclipse.acceleo.engine.tests/data/GenericEngine/generic_engine.mtl
new file mode 100644
index 0000000..0c1e462
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/data/GenericEngine/generic_engine.mtl
@@ -0,0 +1,19 @@
+[module template_generic_engine('http://www.eclipse.org/emf/2002/Ecore')/]
+
+[template public public_template(p : EPackage, s : String)]
+ [file ('test_generic_engine', false)]
+ constant output
+ [/file]
+[/template]
+
+[template public public_template_false_guard(p : EPackage, s : String) ? (false)]
+ [file ('test_generic_engine', false)]
+ shouldn't be generated
+ [/file]
+[/template]
+
+[template private private_template(p : EPackage, s : String)]
+ [file ('test_generic_engine', false)]
+ shouldn't be generated
+ [/file]
+[/template] \ No newline at end of file
diff --git a/tests/org.eclipse.acceleo.engine.tests/data/IfBlock/template_if.mtl b/tests/org.eclipse.acceleo.engine.tests/data/IfBlock/template_if.mtl
new file mode 100644
index 0000000..cb601ae
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/data/IfBlock/template_if.mtl
@@ -0,0 +1,57 @@
+[module template_if('http://www.eclipse.org/emf/2002/Ecore')/]
+
+[comment If test /]
+[template public testingIf(p : EPackage) {name : String = '';}]
+ [file ('testIf', false)]
+ [for (c : EClass | p.eClassifiers)]
+ [if (c.name = 'ClasseA')]Class name [c.name/] = ClasseA.[/if]
+ [/for]
+ [/file]
+[/template]
+
+[comment Else test /]
+[template public testingElse(p : EPackage) {name : String = '';}]
+ [file ('testElse', false)]
+ [for (c : EClass | p.eClassifiers)]
+ [if (c.name = 'NotMatched')]Must not be displayed.[else]Class name is [c.name/].[/if]
+ [/for]
+ [/file]
+[/template]
+
+[comment Elseif test /]
+[template public testingElseif(p : EPackage) {name : String = '';}]
+ [file ('testElseif', false)]
+ [for (c : EClass | p.eClassifiers)]
+ [if (c.name = 'ClasseA')]Class name is ClasseA.
+ [elseif (c.name = 'ClasseB')]Class name is ClasseB.
+ [/if]
+ [/for]
+ [/file]
+[/template]
+
+[comment Complete If test /]
+[template public testingCompleteIf(p : EPackage) {name : String = '';}]
+ [file ('testCompleteIf', false)]
+ [for (c : EClass | p.eClassifiers)]
+ [if (c.name = 'ClasseA')]Class name is ClasseA.
+ [elseif (c.name = 'ClasseB')]Class name is ClasseB.
+ [else]Class name is different from ClasseA and ClasseB.
+ [/if]
+ [/for]
+ [/file]
+[/template]
+
+[comment Nested If /]
+[template public testingNestedIf(p : EPackage) {name : String = '';}]
+ [file ('testNestedIf', false)]
+ [for (c : EClass | p.eClassifiers)]
+ [if (c.name = 'ClasseA')]Class name is A.
+ [if (c.abstract)]Class is abstract[else]Class is not abstract.[/if]
+ [elseif (c.name = 'ClasseB')]Class name is B.
+ [if (c.abstract)]Class is abstract[else]Class is not abstract.[/if]
+ [else]Class name is different.
+ [if (c.abstract)]Class is abstract[else]Class is not abstract.[/if]
+ [/if]
+ [/for]
+ [/file]
+[/template]
diff --git a/tests/org.eclipse.acceleo.engine.tests/data/Listeners/listeners.mtl b/tests/org.eclipse.acceleo.engine.tests/data/Listeners/listeners.mtl
new file mode 100644
index 0000000..06a5f03
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/data/Listeners/listeners.mtl
@@ -0,0 +1,19 @@
+[module traceability('http://www.eclipse.org/emf/2002/Ecore')/]
+
+[template public test_generation_listeners(class : EClass)]
+ [file (class.classNameQuery().concat('.java'), false)]
+ package [class.packageNameTemplate()/]
+
+ [for (feature : EStructuralFeature | eStructuralFeatures) separator(', ')]
+ [name/]
+ [/for]
+ [/file]
+[/template]
+
+[template public test_generation_event(p : EPackage)][file ('generation_event', false)]constant output[/file][/template]
+
+[template private packageNameTemplate(class : EClass)]
+ [ePackage.name/]
+[/template]
+
+[query private classNameQuery(class : EClass) : String = name/] \ No newline at end of file
diff --git a/tests/org.eclipse.acceleo.engine.tests/data/ProtectedAreaBlock/protected_areas.mtl b/tests/org.eclipse.acceleo.engine.tests/data/ProtectedAreaBlock/protected_areas.mtl
new file mode 100644
index 0000000..c1eeb60
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/data/ProtectedAreaBlock/protected_areas.mtl
@@ -0,0 +1,52 @@
+[module protected_areas(http://www.eclipse.org/emf/2002/Ecore)/]
+[template public test_protected_area(c:EClassifier)]
+ [file('protected_areas', false)]
+ [local_template_protected_area(c)/]
+ [/file]
+ [file('protected_areas', false)]
+ [local_template_protected_area(c)/]
+ [/file]
+[/template]
+
+[template public test_removed_protected_area(c:EClassifier)]
+ [file('removed_protected_areas', false)]
+ [local_template_protected_area(c)/]
+ [/file]
+ [file('removed_protected_areas', false)]
+ [local_template_removed_protected_area(c)/]
+ [/file]
+[/template]
+
+[template public test_lost_protected_area(c:EClassifier)]
+ [file('lost_protected_areas', false)]
+ [local_template_protected_area(c)/]
+ [/file]
+ [file('lost_protected_areas', false)]
+ [local_template_lost_protected_area(c)/]
+ [/file]
+[/template]
+
+[comment template definitions/]
+[template public local_template_protected_area(c:EClassifier)]
+ // [protected('user code 1 '.concat(c.name))]
+ first protected area
+ // [/protected]
+ // [protected('user code 2 '.concat(c.name))]
+ second protected area
+ // [/protected]
+[/template]
+
+[template public local_template_removed_protected_area(c:EClassifier)]
+ // [protected('user code 2 '.concat(c.name))]
+ second protected area
+ // [/protected]
+[/template]
+
+[template public local_template_lost_protected_area(c:EClassifier)]
+ // [protected('user code 2 '.concat(c.name))]
+ second protected area
+ // [/protected]
+ // [protected('user code 3 '.concat(c.name))]
+ third protected area
+ // [/protected]
+[/template] \ No newline at end of file
diff --git a/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Namesake/Guard/extended.mtl b/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Namesake/Guard/extended.mtl
new file mode 100644
index 0000000..329898e
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Namesake/Guard/extended.mtl
@@ -0,0 +1,12 @@
+[module extended(http://www.eclipse.org/emf/2002/Ecore)/]
+[template public namesake_guard(c:EClassifier) ? (c.oclIsKindOf(EClass) and not c.oclAsType(EClass).abstract)]
+ extended.namesake_guard called on [c.oclAsType(EClass).eClass().name/] [c.name/]
+[/template]
+
+[template public namesake_guard_import_specific(c:EClassifier) ? (c.oclIsKindOf(EClass) and c.oclAsType(EClass).abstract)]
+ extended.namesake_guard_import_specific called on [c.eClass().name/] [c.name/]
+[/template]
+
+[template public namesake_guarded_specific(c:EClass) ? (c.oclIsKindOf(EClass) and not c.oclAsType(EClass).abstract)]
+ extended.namesake_guarded_specific called on [c.eClass().name/] [c.name/]
+[/template] \ No newline at end of file
diff --git a/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Namesake/Guard/imported.mtl b/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Namesake/Guard/imported.mtl
new file mode 100644
index 0000000..8ca2be6
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Namesake/Guard/imported.mtl
@@ -0,0 +1,12 @@
+[module imported(http://www.eclipse.org/emf/2002/Ecore)/]
+[template public namesake_guard(c:EClassifier) ? (c.oclIsKindOf(EClass) and c.oclAsType(EClass).abstract)]
+ imported.namesake_guard called on [c.eClass().name/] [c.name/]
+[/template]
+
+[template public namesake_guard_import_specific(c:EClass) ? (c.oclIsKindOf(EClass) and c.oclAsType(EClass).abstract)]
+ imported.namesake_guard_import_specific called on [c.eClass().name/] [c.name/]
+[/template]
+
+[template public namesake_guarded_specific(c:EClassifier) ? (c.oclIsKindOf(EClass) and c.oclAsType(EClass).abstract)]
+ imported.namesake_guarded_specific called on [c.eClass().name/] [c.name/]
+[/template] \ No newline at end of file
diff --git a/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Namesake/Guard/local.mtl b/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Namesake/Guard/local.mtl
new file mode 100644
index 0000000..fba1c19
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Namesake/Guard/local.mtl
@@ -0,0 +1,33 @@
+[module local(http://www.eclipse.org/emf/2002/Ecore) extends extended/]
+[import imported/]
+
+[template public test_namesake_guard(c:EClassifier)]
+ [file('resolution_namesake_guard', false)]
+ [namesake_guard(c)/]
+ [/file]
+[/template]
+
+[template public test_namesake_guard_import_specific(c:EClassifier)]
+ [file('resolution_namesake_guard_import_specific', false)]
+ [namesake_guard_import_specific(c)/]
+ [/file]
+[/template]
+
+[template public test_namesake_guarded_specific(c:EClassifier)]
+ [file('resolution_namesake_guarded_specific', false)]
+ [namesake_guarded_specific(c)/]
+ [/file]
+[/template]
+
+[comment template definitions/]
+[template public namesake_guard(c:EClassifier) ? (c.oclIsKindOf(EClass) and not c.oclAsType(EClass).abstract)]
+ local.namesake_guard called on [c.eClass().name/] [c.name/]
+[/template]
+
+[template public namesake_guard_import_specific(c:EClass) ? (c.oclIsKindOf(EClass) and not c.oclAsType(EClass).abstract)]
+ local.namesake_guard_import_specific called on [c.eClass().name/] [c.name/]
+[/template]
+
+[template public namesake_guarded_specific(c:EClass) ? (c.oclIsKindOf(EClass) and not c.oclAsType(EClass).abstract)]
+ local.namesake_guarded_specific called on [c.eClass().name/] [c.name/]
+[/template] \ No newline at end of file
diff --git a/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Namesake/ParameterTypeNarrowing/extended.mtl b/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Namesake/ParameterTypeNarrowing/extended.mtl
new file mode 100644
index 0000000..b428849
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Namesake/ParameterTypeNarrowing/extended.mtl
@@ -0,0 +1,28 @@
+[module extended(http://www.eclipse.org/emf/2002/Ecore)/]
+[template public namesake_3_import_specific(c:EClassifier, d:EClassifier)]
+ extended.namesake_3_import_specific called on [c.eClass().name/] [c.name/]
+[/template]
+
+[template public namesake_3_extend_specific(c:EClass, d:EClass)]
+ extended.namesake_3_extend_specific called on [c.eClass().name/] [c.name/]
+[/template]
+
+[template public namesake_3_local_specific(c:EClassifier, d:EClassifier)]
+ extended.namesake_3_local_specific called on [c.eClass().name/] [c.name/]
+[/template]
+
+[template public namesake_extend_local_specific(c:EClassifier, d:EClassifier)]
+ extended.namesake_extend_local_specific called on [c.eClass().name/] [c.name/]
+[/template]
+
+[template public namesake_extend_extend_specific(c:EClass, d:EClass)]
+ extended.namesake_extend_extend_specific called on [c.eClass().name/] [c.name/]
+[/template]
+
+[template public namesake_external_import_specific(c:EClassifier, d:EClassifier)]
+ extended.namesake_external_import_specific called on [c.eClass().name/] [c.name/]
+[/template]
+
+[template public namesake_external_extend_specific(c:EClass, d:EClass)]
+ extended.namesake_external_extend_specific called on [c.eClass().name/] [c.name/]
+[/template] \ No newline at end of file
diff --git a/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Namesake/ParameterTypeNarrowing/imported.mtl b/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Namesake/ParameterTypeNarrowing/imported.mtl
new file mode 100644
index 0000000..8f431c1
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Namesake/ParameterTypeNarrowing/imported.mtl
@@ -0,0 +1,28 @@
+[module imported(http://www.eclipse.org/emf/2002/Ecore)/]
+[template public namesake_3_import_specific(c:EClass, d:EClass)]
+ imported.namesake_3_import_specific called on [c.eClass().name/] [c.name/]
+[/template]
+
+[template public namesake_3_extend_specific(c:EClassifier, d:EClassifier)]
+ imported.namesake_3_extend_specific called on [c.eClass().name/] [c.name/]
+[/template]
+
+[template public namesake_3_local_specific(c:EClassifier, d:EClassifier)]
+ imported.namesake_3_local_specific called on [c.eClass().name/] [c.name/]
+[/template]
+
+[template public namesake_import_local_specific(c:EClassifier, d:EClassifier)]
+ imported.namesake_import_local_specific called on [c.eClass().name/] [c.name/]
+[/template]
+
+[template public namesake_import_import_specific(c:EClass, d:EClass)]
+ imported.namesake_import_import_specific called on [c.eClass().name/] [c.name/]
+[/template]
+
+[template public namesake_external_import_specific(c:EClass, d:EClass)]
+ imported.namesake_external_import_specific called on [c.eClass().name/] [c.name/]
+[/template]
+
+[template public namesake_external_extend_specific(c:EClassifier, d:EClassifier)]
+ imported.namesake_external_extend_specific called on [c.eClass().name/] [c.name/]
+[/template] \ No newline at end of file
diff --git a/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Namesake/ParameterTypeNarrowing/local.mtl b/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Namesake/ParameterTypeNarrowing/local.mtl
new file mode 100644
index 0000000..26511fc
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Namesake/ParameterTypeNarrowing/local.mtl
@@ -0,0 +1,85 @@
+[module local(http://www.eclipse.org/emf/2002/Ecore) extends extended/]
+[import imported/]
+
+[template public test_namesake_3_local_specific(c:EClassifier)]
+ [file('resolution_namesake_local_specific', false)]
+ [namesake_3_local_specific(c, c)/]
+ [/file]
+[/template]
+
+[template public test_namesake_3_import_specific(c:EClassifier)]
+ [file('resolution_namesake_import_specific', false)]
+ [namesake_3_import_specific(c, c)/]
+ [/file]
+[/template]
+
+[template public test_namesake_3_extend_specific(c:EClassifier)]
+ [file('resolution_namesake_extend_specific', false)]
+ [namesake_3_extend_specific(c, c)/]
+ [/file]
+[/template]
+
+[template public test_namesake_import_local_specific(c:EClassifier)]
+ [file('resolution_namesake_import_local_specific', false)]
+ [namesake_import_local_specific(c, c)/]
+ [/file]
+[/template]
+
+[template public test_namesake_import_import_specific(c:EClassifier)]
+ [file('resolution_namesake_import_import_specific', false)]
+ [namesake_import_import_specific(c, c)/]
+ [/file]
+[/template]
+
+[template public test_namesake_extend_local_specific(c:EClassifier)]
+ [file('resolution_namesake_extend_local_specific', false)]
+ [namesake_extend_local_specific(c, c)/]
+ [/file]
+[/template]
+
+[template public test_namesake_extend_extend_specific(c:EClassifier)]
+ [file('resolution_namesake_extend_extend_specific', false)]
+ [namesake_extend_extend_specific(c, c)/]
+ [/file]
+[/template]
+
+[template public test_namesake_external_import_specific(c:EClassifier)]
+ [file('resolution_namesake_external_import_specific', false)]
+ [namesake_external_import_specific(c, c)/]
+ [/file]
+[/template]
+
+[template public test_namesake_external_extend_specific(c:EClassifier)]
+ [file('resolution_namesake_external_extend_specific', false)]
+ [namesake_external_extend_specific(c, c)/]
+ [/file]
+[/template]
+
+[comment template definitions/]
+[template public namesake_3_import_specific(c:EClassifier, d:EClassifier)]
+ local.namesake_3_import_specific called on [c.eClass().name/] [c.name/]
+[/template]
+
+[template public namesake_3_extend_specific(c:EClassifier, d:EClassifier)]
+ local.namesake_3_extend_specific called on [c.eClass().name/] [c.name/]
+[/template]
+
+[template public namesake_3_local_specific(c:EClass, d:EClass)]
+ local.namesake_3_local_specific called on [c.eClass().name/] [c.name/]
+[/template]
+
+[template public namesake_import_local_specific(c:EClass, d:EClass)]
+ local.namesake_import_local_specific called on [c.eClass().name/] [c.name/]
+[/template]
+
+[template public namesake_import_import_specific(c:EClassifier, d:EClassifier)]
+ local.namesake_import_import_specific called on [c.eClass().name/] [c.name/]
+[/template]
+
+[template public namesake_extend_local_specific(c:EClass, d:EClass)]
+ local.namesake_extend_local_specific called on [c.eClass().name/] [c.name/]
+[/template]
+
+[template public namesake_extend_extend_specific(c:EClassifier, d:EClassifier)]
+ local.namesake_extend_extend_specific called on [c.eClass().name/] [c.name/]
+[/template] \ No newline at end of file
diff --git a/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Namesake/Simple/extended.mtl b/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Namesake/Simple/extended.mtl
new file mode 100644
index 0000000..a1d16b7
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Namesake/Simple/extended.mtl
@@ -0,0 +1,12 @@
+[module extended(http://www.eclipse.org/emf/2002/Ecore)/]
+[template public namesake_3(c:EClassifier)]
+ extended.namesake_3 called on [c.eClass().name/] [c.name/]
+[/template]
+
+[template public namesake_extend(c:EClassifier)]
+ extended.namesake_extend called on [c.eClass().name/] [c.name/]
+[/template]
+
+[template public namesake_external(c:EClassifier)]
+ extended.namesake_external called on [c.eClass().name/] [c.name/]
+[/template] \ No newline at end of file
diff --git a/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Namesake/Simple/imported.mtl b/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Namesake/Simple/imported.mtl
new file mode 100644
index 0000000..caba7db
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Namesake/Simple/imported.mtl
@@ -0,0 +1,12 @@
+[module imported(http://www.eclipse.org/emf/2002/Ecore)/]
+[template public namesake_3(c:EClassifier)]
+ imported.namesake_3 called on [c.eClass().name/] [c.name/]
+[/template]
+
+[template public namesake_import(c:EClassifier)]
+ imported.namesake_import called on [c.eClass().name/] [c.name/]
+[/template]
+
+[template public namesake_external(c:EClassifier)]
+ imported.namesake_external called on [c.eClass().name/] [c.name/]
+[/template] \ No newline at end of file
diff --git a/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Namesake/Simple/local.mtl b/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Namesake/Simple/local.mtl
new file mode 100644
index 0000000..a9d6283
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Namesake/Simple/local.mtl
@@ -0,0 +1,53 @@
+[module local(http://www.eclipse.org/emf/2002/Ecore) extends extended/]
+[import imported/]
+
+[template public test_namesake_3(c:EClassifier)]
+ [file('resolution_priority', false)]
+ [namesake_3(c)/]
+ [/file]
+[/template]
+
+[template public test_namesake_extend(c:EClassifier)]
+ [file('resolution_extended', false)]
+ [namesake_extend(c)/]
+ [/file]
+[/template]
+
+[template public test_namesake_import(c:EClassifier)]
+ [file('resolution_imported', false)]
+ [namesake_import(c)/]
+ [/file]
+[/template]
+
+[template public test_namesake_external(c:EClassifier)]
+ [file('resolution_external', false)]
+ [namesake_external(c)/]
+ [/file]
+[/template]
+
+[template public test_namesake_distinct_param_name(c:EClassifier)]
+ [file('distinct_param_name', false)]
+ [namesake_param_names(c)/]
+ [/file]
+[/template]
+
+[comment template definitions/]
+[template public namesake_3(c:EClassifier)]
+ local.namesake_3 called on [c.eClass().name/] [c.name/]
+[/template]
+
+[template public namesake_extend(c:EClassifier)]
+ local.namesake_extend called on [c.eClass().name/] [c.name/]
+[/template]
+
+[template public namesake_import(c:EClassifier)]
+ local.namesake_import called on [c.eClass().name/] [c.name/]
+[/template]
+
+[template public namesake_param_names(c:EClassifier)]
+ Shouldn't be called
+[/template]
+
+[template public namesake_param_names(class:EClass)]
+ local.namesake_param_names called on [class.eClass().name/] [class.name/]
+[/template] \ No newline at end of file
diff --git a/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Override/Guard/extended.mtl b/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Override/Guard/extended.mtl
new file mode 100644
index 0000000..7539ec8
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Override/Guard/extended.mtl
@@ -0,0 +1,12 @@
+[module extended(http://www.eclipse.org/emf/2002/Ecore) extends imported/]
+[template public override_resolution_notguard(c:EClass) overrides override_resolution_definition_guard ? (not c.abstract)]
+ extended.override_resolution_notguard called on [c.eClass().name/] [c.name/]
+[/template]
+
+[template public override_resolution_external_guard(c:EClass) overrides override_resolution_external_definition_notguard ? (c.abstract)]
+ extended.override_resolution_external_guard called on [c.eClass().name/] [c.name/]
+[/template]
+
+[template public override_resolution_extend_definition_notguard(c:EClassifier) ? (c.oclIsKindOf(EClass) and not c.oclAsType(EClass).abstract)]
+ extended.override_resolution_extend_definition_notguard called on [c.eClass().name/] [c.name/]
+[/template] \ No newline at end of file
diff --git a/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Override/Guard/imported.mtl b/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Override/Guard/imported.mtl
new file mode 100644
index 0000000..20f51d1
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Override/Guard/imported.mtl
@@ -0,0 +1,8 @@
+[module imported(http://www.eclipse.org/emf/2002/Ecore)/]
+[template public override_resolution_definition_guard(c:EClassifier) ? (c.oclIsKindOf(EClass) and c.oclAsType(EClass).abstract)]
+ imported.override_resolution_definition_guard called on [c.eClass().name/] [c.name/]
+[/template]
+
+[template public override_resolution_external_definition_notguard(c:EClassifier) ? (c.oclIsKindOf(EClass) and not c.oclAsType(EClass).abstract)]
+ imported.override_resolution_definition_notguard called on [c.eClass().name/] [c.name/]
+[/template] \ No newline at end of file
diff --git a/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Override/Guard/local.mtl b/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Override/Guard/local.mtl
new file mode 100644
index 0000000..278e052
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Override/Guard/local.mtl
@@ -0,0 +1,29 @@
+[module local(http://www.eclipse.org/emf/2002/Ecore) extends extended/]
+[import imported/]
+
+[template public test_resolution_override_specific_guarded(c:EClassifier)]
+ [file('resolution_override_specific_guarded', false)]
+ [override_resolution_definition_guard(c)/]
+ [/file]
+[/template]
+
+[template public test_resolution_external_override_definition_guarded(c:EClassifier)]
+ [file('resolution_external_override_definition_guarded', false)]
+ [override_resolution_external_definition_notguard(c)/]
+ [/file]
+[/template]
+
+[template public test_resolution_local_override_definition_guarded(c:EClassifier)]
+ [file('resolution_local_override_definition_guarded', false)]
+ [override_resolution_extend_definition_notguard(c)/]
+ [/file]
+[/template]
+
+[comment template definitions/]
+[template public override_resolution_3_local_notguard(c:EClass) overrides override_resolution_notguard ? (not c.abstract)]
+ local.override_resolution_3_local_notguard called on [c.eClass().name/] [c.name/]
+[/template]
+
+[template public override_resolution_local_guard(c:EClass) overrides override_resolution_extend_definition_notguard ? (c.abstract)]
+ local.override_resolution_local_guard called on [c.eClass().name/] [c.name/]
+[/template] \ No newline at end of file
diff --git a/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Override/ParameterTypeNarrowing/extended.mtl b/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Override/ParameterTypeNarrowing/extended.mtl
new file mode 100644
index 0000000..29f8016
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Override/ParameterTypeNarrowing/extended.mtl
@@ -0,0 +1,12 @@
+[module extended(http://www.eclipse.org/emf/2002/Ecore) extends imported/]
+[template public parameter_narrowing_extend_override(c:EClassifier) overrides parameter_narrowing_definition]
+ extended.parameter_narrowing_extend_override called on [c.eClass().name/] [c.name/]
+[/template]
+
+[template public parameter_narrowing_external_override(c:EClass) overrides parameter_narrowing_external_definition]
+ extended.parameter_narrowing_external_override called on [c.eClass().name/] [c.name/]
+[/template]
+
+[template public parameter_narrowing_extend_definition(c:EClassifier)]
+ extended.parameter_narrowing_extend_definition called on [c.eClass().name/] [c.name/]
+[/template] \ No newline at end of file
diff --git a/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Override/ParameterTypeNarrowing/imported.mtl b/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Override/ParameterTypeNarrowing/imported.mtl
new file mode 100644
index 0000000..4f2b929
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Override/ParameterTypeNarrowing/imported.mtl
@@ -0,0 +1,8 @@
+[module imported(http://www.eclipse.org/emf/2002/Ecore)/]
+[template public parameter_narrowing_definition(c:ENamedElement) ? (c.oclIsKindOf(EClassifier))]
+ imported.parameter_narrowing_definition called on [c.eClass().name/] [c.name/]
+[/template]
+
+[template public parameter_narrowing_external_definition(c:EClassifier)]
+ imported.parameter_narrowing_external_definition called on [c.eClass().name/] [c.name/]
+[/template] \ No newline at end of file
diff --git a/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Override/ParameterTypeNarrowing/local.mtl b/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Override/ParameterTypeNarrowing/local.mtl
new file mode 100644
index 0000000..7141fe8
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Override/ParameterTypeNarrowing/local.mtl
@@ -0,0 +1,29 @@
+[module local(http://www.eclipse.org/emf/2002/Ecore) extends extended/]
+[import imported/]
+
+[template public test_resolution_override_specific(c:EClassifier)]
+ [file('resolution_override_specific', false)]
+ [parameter_narrowing_definition(c)/]
+ [/file]
+[/template]
+
+[template public test_resolution_external_override(c:EClassifier)]
+ [file('resolution_external_override', false)]
+ [parameter_narrowing_external_definition(c)/]
+ [/file]
+[/template]
+
+[template public test_resolution_local_override(c:EClassifier)]
+ [file('resolution_local_override', false)]
+ [parameter_narrowing_extend_definition(c)/]
+ [/file]
+[/template]
+
+[comment template definitions/]
+[template public parameter_narrowing_3_local_override(c:EClass) overrides parameter_narrowing_extend_override]
+ local.parameter_narrowing_3_local_override called on [c.eClass().name/] [c.name/]
+[/template]
+
+[template public parameter_narrowing_local_override(c:EClass) overrides parameter_narrowing_extend_definition]
+ local.parameter_narrowing_local_override called on [c.eClass().name/] [c.name/]
+[/template] \ No newline at end of file
diff --git a/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Override/Simple/extended.mtl b/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Override/Simple/extended.mtl
new file mode 100644
index 0000000..b49428d
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Override/Simple/extended.mtl
@@ -0,0 +1,12 @@
+[module extended(http://www.eclipse.org/emf/2002/Ecore) extends imported/]
+[template public extend_overriden(c:EClassifier) overrides import_defined]
+ extended.extend_overriden called on [c.eClass().name/] [c.name/]
+[/template]
+
+[template public extend_override_3(c:EClassifier) overrides import_defined_3]
+ extended.extend_override_3 called on [c.eClass().name/] [c.name/]
+[/template]
+
+[template public extend_defined(c:EClassifier)]
+ extended.extend_defined called on [c.eClass().name/] [c.name/]
+[/template] \ No newline at end of file
diff --git a/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Override/Simple/imported.mtl b/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Override/Simple/imported.mtl
new file mode 100644
index 0000000..0b0333e
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Override/Simple/imported.mtl
@@ -0,0 +1,8 @@
+[module imported(http://www.eclipse.org/emf/2002/Ecore)/]
+[template public import_defined(c:EClassifier)]
+ imported.import_defined called on [c.eClass().name/] [c.name/]
+[/template]
+
+[template public import_defined_3(c:EClassifier)]
+ imported.import_defined_3 called on [c.eClass().name/] [c.name/]
+[/template] \ No newline at end of file
diff --git a/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Override/Simple/local.mtl b/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Override/Simple/local.mtl
new file mode 100644
index 0000000..754b415
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/data/Resolution/Override/Simple/local.mtl
@@ -0,0 +1,53 @@
+[module local(http://www.eclipse.org/emf/2002/Ecore) extends extended/]
+[import imported/]
+
+[template public test_local_overriden_indirect_call(c:EClassifier)]
+ [file('resolution_local_overriden_indirect', false)]
+ [extend_defined(c)/]
+ [/file]
+[/template]
+
+[template public test_local_overriden_direct_call(c:EClassifier)]
+ [file('resolution_local_overriden_direct', false)]
+ [local_overriden(c)/]
+ [/file]
+[/template]
+
+[template public test_extend_overriden_indirect_call(c:EClassifier)]
+ [file('resolution_extend_overriden_indirect', false)]
+ [import_defined(c)/]
+ [/file]
+[/template]
+
+[template public test_extend_overriden_direct_call(c:EClassifier)]
+ [file('resolution_extend_overriden_direct', false)]
+ [extend_overriden(c)/]
+ [/file]
+[/template]
+
+[template public test_override_priority_direct(c:EClassifier)]
+ [file('resolution_override_priority_direct', false)]
+ [local_override_3(c)/]
+ [/file]
+[/template]
+
+[template public test_override_priority_indirect_extend(c:EClassifier)]
+ [file('resolution_override_priority_indirect_extend', false)]
+ [extend_override_3(c)/]
+ [/file]
+[/template]
+
+[template public test_override_priority_indirect(c:EClassifier)]
+ [file('resolution_override_priority_indirect', false)]
+ [import_defined_3(c)/]
+ [/file]
+[/template]
+
+[comment template definitions/]
+[template public local_overriden(c:EClassifier) overrides extend_defined]
+ local.local_overriden called on [c.eClass().name/] [c.name/]
+[/template]
+
+[template public local_override_3(c:EClassifier) overrides extend_override_3]
+ local.local_override_3 called on [c.eClass().name/] [c.name/]
+[/template] \ No newline at end of file
diff --git a/tests/org.eclipse.acceleo.engine.tests/data/Template/extended.mtl b/tests/org.eclipse.acceleo.engine.tests/data/Template/extended.mtl
new file mode 100644
index 0000000..24ae330
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/data/Template/extended.mtl
@@ -0,0 +1,16 @@
+[module extended(http://www.eclipse.org/emf/2002/Ecore)/]
+[template protected protected_extended_template(c:EClass)]
+ extended.protected_extended_template called on [c.eClass().name/] [c.name/]
+[/template]
+
+[template protected super_extended_template(c:EClass)]
+ extended.super_extended_template called on [c.eClass().name/] [c.name/]
+[/template]
+
+[template private private_extended_template(c:EClass)]
+ extended.private_extended_template called on [c.eClass().name/] [c.name/]
+[/template]
+
+[template public imported_template(c:EClass)]
+ extended.imported_template called on [c.eClass().name/] [c.name/]
+[/template] \ No newline at end of file
diff --git a/tests/org.eclipse.acceleo.engine.tests/data/Template/local.mtl b/tests/org.eclipse.acceleo.engine.tests/data/Template/local.mtl
new file mode 100644
index 0000000..d1a5102
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/data/Template/local.mtl
@@ -0,0 +1,79 @@
+[module local(http://www.eclipse.org/emf/2002/Ecore) extends extended/]
+[comment test definitions/]
+[template public test_protected_visibility(c:EClass)]
+ [file('protected_visibility', false)]
+ [c.protected_overriding_template()/]
+ [/file]
+[/template]
+
+[template public test_private_visibility(c:EClass)]
+ [file('private_visibility', false)]
+ [private_local_template(c)/]
+ [/file]
+[/template]
+
+[template public test_super(c:EClass)]
+ [file('super', false)]
+ [call_to_super(c)/]
+ [/file]
+[/template]
+
+[template public test_before(c:EClass)]
+ [file('before_test', false)]
+ [c.protected_overriding_template() before('before')/]
+ [/file]
+[/template]
+
+[template public test_after(c:EClass)]
+ [file('after_test', false)]
+ [c.protected_overriding_template() after('after')/]
+ [/file]
+[/template]
+
+[template public test_false_guard(c:EClass)]
+ [file('false_guard', false)]
+ [false_guard_template(c)/]
+ [/file]
+[/template]
+
+[template public test_true_guard(c:EClass)]
+ [file('true_guard', false)]
+ [true_guard_template(c)/]
+ [/file]
+[/template]
+
+[template public test_protect_override(c:EClass)]
+ [file('protected_override', false)]
+ [c.protected_extended_template()/]
+ [/file]
+[/template]
+
+[template public test_import(c:EClass)]
+ [file('import', false)]
+ [imported_template(c)/]
+ [/file]
+[/template]
+
+[comment template definitions/]
+[comment visibility tests/]
+[template protected protected_overriding_template(c:EClass) overrides protected_extended_template]
+ local.protected_overriding_template called on [c.eClass().name/] [c.name/]
+[/template]
+
+[template private private_local_template(c:EClass)]
+ local.private_local_template called on [c.eClass().name/] [c.name/]
+[/template]
+
+[comment super test/]
+[template public call_to_super(c:EClass) overrides super_extended_template]
+ overriding call to [super/]
+[/template]
+
+[comment guard tests/]
+[template public false_guard_template(c:EClass) ? (not c.abstract)]
+ local.false_guard_template called on [c.eClass().name/] [c.name/]
+[/template]
+
+[template public true_guard_template(c:EClass) ? (c.abstract)]
+ local.true_guard_template called on [c.eClass().name/] [c.name/]
+[/template] \ No newline at end of file
diff --git a/tests/org.eclipse.acceleo.engine.tests/data/TemplateInvocation/dual_template_call.mtl b/tests/org.eclipse.acceleo.engine.tests/data/TemplateInvocation/dual_template_call.mtl
new file mode 100644
index 0000000..d83a8d2
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/data/TemplateInvocation/dual_template_call.mtl
@@ -0,0 +1,20 @@
+[module dual_query_call(http://www.eclipse.org/emf/2002/Ecore)/]
+[template public test(c:EClass)]
+ [file ('dual_template_invocation', false)]
+ [c.name.toLowerLast().toUpperLast()/]
+ [/file]
+ [file ('dual_query_invocation', false)]
+ [c.name.toLowerLastQuery().toUpperLastQuery()/]
+ [/file]
+[/template]
+
+[template public toUpperLast(s:String)]
+ [s.substring(1, s.size() - 1).concat(s.substring(s.size() - 1, s.size() - 1).toUpper())/]
+[/template]
+
+[template public toLowerLast(s:String)]
+ [s.substring(1, s.size() - 1).concat(s.substring(s.size(), s.size()).toLower())/]
+[/template]
+
+[query public toLowerLastQuery(s:String) : String = s.substring(1, s.size() - 1).concat(s.substring(s.size(), s.size()).toLower())/]
+[query public toUpperLastQuery(s:String) : String = s.substring(1, s.size() - 1).concat(s.substring(s.size() - 1, s.size() - 1).toUpper())/] \ No newline at end of file
diff --git a/tests/org.eclipse.acceleo.engine.tests/data/Variables/template_self.mtl b/tests/org.eclipse.acceleo.engine.tests/data/Variables/template_self.mtl
new file mode 100644
index 0000000..fbfb9e8
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/data/Variables/template_self.mtl
@@ -0,0 +1,39 @@
+[module template_self('http://www.eclipse.org/emf/2002/Ecore')/]
+
+[template public test_implicit_self_query(p : EPackage)]
+ [file ('implicit_self_query', false)]
+ [p.packageNameImplicitQuery()/]
+ [/file]
+[/template]
+
+[template public test_implicit_self_template(p : EPackage)]
+ [file ('implicit_self_template', false)]
+ [p.packageNameImplicitTemplate()/]
+ [/file]
+[/template]
+
+[template public test_self_query(p : EPackage)]
+ [file ('self_query', false)]
+ [p.packageNameQuery()/]
+ [/file]
+[/template]
+
+[template public test_self_template(p : EPackage)]
+ [file ('self_template', false)]
+ [p.packageNameTemplate()/]
+ [/file]
+[/template]
+
+
+
+[query private packageNameImplicitQuery(package : EPackage) : String = name/]
+
+[query private packageNameQuery(package : EPackage) : String = self.name/]
+
+[template private packageNameImplicitTemplate(package : EPackage)]
+ [name/]
+[/template]
+
+[template private packageNameTemplate(package : EPackage)]
+ [self.name/]
+[/template] \ No newline at end of file
diff --git a/tests/org.eclipse.acceleo.engine.tests/data/abstractClass.ecore b/tests/org.eclipse.acceleo.engine.tests/data/abstractClass.ecore
new file mode 100644
index 0000000..708ed4c
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/data/abstractClass.ecore
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ecore:EPackage xmi:version="2.0"
+ xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="target"
+ nsURI="target" nsPrefix="target">
+ <eClassifiers xsi:type="ecore:EClass" name="AbstractClass" abstract="true">
+ <eOperations name="anOperationFromAbstractSuperClass" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ </eClassifiers>
+</ecore:EPackage>
diff --git a/tests/org.eclipse.acceleo.engine.tests/data/target.ecore b/tests/org.eclipse.acceleo.engine.tests/data/target.ecore
new file mode 100644
index 0000000..ef3f70d
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/data/target.ecore
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ecore:EPackage xmi:version="2.0"
+ xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="target"
+ nsURI="target" nsPrefix="target">
+ <eClassifiers xsi:type="ecore:EClass" name="ClasseA" eSuperTypes="#//AbstractClass">
+ <eOperations name="computeSomething" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EJavaObject">
+ <eParameters name="doubleParam" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EDouble"/>
+ <eParameters name="anObject" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EJavaObject"/>
+ <eParameters name="someParam" upperBound="-1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EJavaObject"/>
+ </eOperations>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="anAttribute" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="multivaluedAttribute" upperBound="-1"
+ eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="aReferenceFromA" eType="ecore:EClass http://www.eclipse.org/emf/2002/Ecore#//EObject"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="multivaluedReference" upperBound="-1"
+ eType="ecore:EClass http://www.eclipse.org/emf/2002/Ecore#//EObject"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="ClasseB" eSuperTypes="#//AbstractClass">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="anAttributeOfB" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EChar"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="anotherAttributeOfB" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//ELongObject"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="aReferenceFromB" eType="#//ClasseA"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="AbstractClass" abstract="true">
+ <eOperations name="anOperationFromAbstractSuperClass" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ </eClassifiers>
+</ecore:EPackage>
diff --git a/tests/org.eclipse.acceleo.engine.tests/data/target_uml.uml b/tests/org.eclipse.acceleo.engine.tests/data/target_uml.uml
new file mode 100644
index 0000000..f7d7374
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/data/target_uml.uml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<uml:Package xmi:version="2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:uml="http://www.eclipse.org/uml2/2.1.0/UML" xmi:id="_1fPo8C4xEd2O7eFv9kd9OA" name="package">
+ <packagedElement xmi:type="uml:Class" xmi:id="_4W6ZoC4xEd2O7eFv9kd9OA" name="Person">
+ <ownedAttribute xmi:id="_6FieoC4xEd2O7eFv9kd9OA" name="firstName">
+ <type xmi:type="uml:PrimitiveType" href="pathmap://UML_METAMODELS/UML.metamodel.uml#String"/>
+ </ownedAttribute>
+ <ownedAttribute xmi:id="__VvM8C4xEd2O7eFv9kd9OA" name="lastName">
+ <type xmi:type="uml:PrimitiveType" href="pathmap://UML_METAMODELS/UML.metamodel.uml#String"/>
+ </ownedAttribute>
+ <ownedAttribute xmi:id="_aBYioC5SEd2ZtZnFdNdU5w" name="gender" type="_T5ae0C5SEd2ZtZnFdNdU5w"/>
+ <ownedOperation xmi:id="_EqGpkC4yEd2O7eFv9kd9OA" name="computeAge">
+ <ownedParameter xmi:id="_QX6UgC4yEd2O7eFv9kd9OA" direction="return">
+ <type xmi:type="uml:PrimitiveType" href="pathmap://UML_METAMODELS/UML.metamodel.uml#Integer"/>
+ </ownedParameter>
+ </ownedOperation>
+ </packagedElement>
+ <packagedElement xmi:type="uml:Class" xmi:id="_SLs1QC5REd2ZtZnFdNdU5w" name="Employee">
+ <generalization xmi:id="_YgRxsC5REd2ZtZnFdNdU5w" general="_4W6ZoC4xEd2O7eFv9kd9OA"/>
+ <ownedAttribute xmi:id="_ctYrUC5REd2ZtZnFdNdU5w" name="ID">
+ <type xmi:type="uml:PrimitiveType" href="pathmap://UML_METAMODELS/UML.metamodel.uml#Integer"/>
+ </ownedAttribute>
+ <ownedAttribute xmi:id="_gRGCoC5REd2ZtZnFdNdU5w" name="company">
+ <type xmi:type="uml:PrimitiveType" href="pathmap://UML_METAMODELS/UML.metamodel.uml#String"/>
+ </ownedAttribute>
+ </packagedElement>
+ <packagedElement xmi:type="uml:Class" xmi:id="_sqJNgC5SEd2ZtZnFdNdU5w" name="Student">
+ <generalization xmi:id="_gY7SgC5dEd2J9L9zqH5KEw" general="_4W6ZoC4xEd2O7eFv9kd9OA"/>
+ <ownedAttribute xmi:id="_vN7Y4C5SEd2ZtZnFdNdU5w" name="ID">
+ <type xmi:type="uml:PrimitiveType" href="pathmap://UML_METAMODELS/UML.metamodel.uml#Integer"/>
+ </ownedAttribute>
+ <ownedAttribute xmi:id="_d9mfkC5dEd2J9L9zqH5KEw" name="School">
+ <type xmi:type="uml:PrimitiveType" href="pathmap://UML_METAMODELS/UML.metamodel.uml#String"/>
+ </ownedAttribute>
+ </packagedElement>
+ <packagedElement xmi:type="uml:Enumeration" xmi:id="_T5ae0C5SEd2ZtZnFdNdU5w" name="Gender">
+ <ownedLiteral xmi:id="_VaAH0C5SEd2ZtZnFdNdU5w" name="Male"/>
+ <ownedLiteral xmi:id="_XHsYsC5SEd2ZtZnFdNdU5w" name="Female"/>
+ </packagedElement>
+ <profileApplication xmi:id="_JffrMC4yEd2O7eFv9kd9OA">
+ <eAnnotations xmi:id="_JflKwC4yEd2O7eFv9kd9OA" source="http://www.eclipse.org/uml2/2.0.0/UML">
+ <references xmi:type="ecore:EPackage" href="pathmap://UML_PROFILES/Standard.profile.uml#_yzU58YinEdqtvbnfB2L_5w"/>
+ </eAnnotations>
+ <appliedProfile href="pathmap://UML_PROFILES/Standard.profile.uml#_0"/>
+ </profileApplication>
+</uml:Package>
diff --git a/tests/org.eclipse.acceleo.engine.tests/plugin.properties b/tests/org.eclipse.acceleo.engine.tests/plugin.properties
new file mode 100644
index 0000000..700a25a
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/plugin.properties
@@ -0,0 +1,12 @@
+#################################################################################
+# Copyright (c) 2008, 2009 Obeo.
+# 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:
+# Obeo - initial API and implementation
+#################################################################################
+pluginName = Acceleo engine tests
+providerName = Eclipse Modeling Project \ No newline at end of file
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/ForBlock/GenerationTest/AfterKeyword/testForAfter b/tests/org.eclipse.acceleo.engine.tests/src-gen/ForBlock/GenerationTest/AfterKeyword/testForAfter
new file mode 100644
index 0000000..9e00782
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/ForBlock/GenerationTest/AfterKeyword/testForAfter
@@ -0,0 +1,4 @@
+ ClasseA
+ ClasseB
+ AbstractClass
+after test
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/ForBlock/GenerationTest/BasicExample/testForSimple b/tests/org.eclipse.acceleo.engine.tests/src-gen/ForBlock/GenerationTest/BasicExample/testForSimple
new file mode 100644
index 0000000..4a0345b
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/ForBlock/GenerationTest/BasicExample/testForSimple
@@ -0,0 +1,4 @@
+ ClasseA
+ ClasseB
+ AbstractClass
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/ForBlock/GenerationTest/BeforeKeyword/testForBefore b/tests/org.eclipse.acceleo.engine.tests/src-gen/ForBlock/GenerationTest/BeforeKeyword/testForBefore
new file mode 100644
index 0000000..b84153f
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/ForBlock/GenerationTest/BeforeKeyword/testForBefore
@@ -0,0 +1,4 @@
+before test ClasseA
+ ClasseB
+ AbstractClass
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/ForBlock/GenerationTest/GuardKeyword/testForGuard b/tests/org.eclipse.acceleo.engine.tests/src-gen/ForBlock/GenerationTest/GuardKeyword/testForGuard
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/ForBlock/GenerationTest/GuardKeyword/testForGuard
@@ -0,0 +1 @@
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/ForBlock/GenerationTest/SeparatorKeyword/testForSeparator b/tests/org.eclipse.acceleo.engine.tests/src-gen/ForBlock/GenerationTest/SeparatorKeyword/testForSeparator
new file mode 100644
index 0000000..1426470
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/ForBlock/GenerationTest/SeparatorKeyword/testForSeparator
@@ -0,0 +1,4 @@
+ ClasseA
+/ ClasseB
+/ AbstractClass
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/ForBlock/ReferenceResult/AfterKeyword/testForAfter b/tests/org.eclipse.acceleo.engine.tests/src-gen/ForBlock/ReferenceResult/AfterKeyword/testForAfter
new file mode 100644
index 0000000..630d74b
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/ForBlock/ReferenceResult/AfterKeyword/testForAfter
@@ -0,0 +1,4 @@
+ ClasseA
+ ClasseB
+ AbstractClass
+ after test
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/ForBlock/ReferenceResult/BasicExample/testForSimple b/tests/org.eclipse.acceleo.engine.tests/src-gen/ForBlock/ReferenceResult/BasicExample/testForSimple
new file mode 100644
index 0000000..37c65e2
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/ForBlock/ReferenceResult/BasicExample/testForSimple
@@ -0,0 +1,4 @@
+ ClasseA
+ ClasseB
+ AbstractClass
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/ForBlock/ReferenceResult/BeforeKeyword/testForBefore b/tests/org.eclipse.acceleo.engine.tests/src-gen/ForBlock/ReferenceResult/BeforeKeyword/testForBefore
new file mode 100644
index 0000000..c7e0163
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/ForBlock/ReferenceResult/BeforeKeyword/testForBefore
@@ -0,0 +1,5 @@
+ before test
+ ClasseA
+ ClasseB
+ AbstractClass
+ \ No newline at end of file
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/ForBlock/ReferenceResult/GuardKeyword/testForGuard b/tests/org.eclipse.acceleo.engine.tests/src-gen/ForBlock/ReferenceResult/GuardKeyword/testForGuard
new file mode 100644
index 0000000..81cb010
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/ForBlock/ReferenceResult/GuardKeyword/testForGuard
@@ -0,0 +1 @@
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/ForBlock/ReferenceResult/SeparatorKeyword/testForSeparator b/tests/org.eclipse.acceleo.engine.tests/src-gen/ForBlock/ReferenceResult/SeparatorKeyword/testForSeparator
new file mode 100644
index 0000000..9b45743
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/ForBlock/ReferenceResult/SeparatorKeyword/testForSeparator
@@ -0,0 +1,2 @@
+ ClasseA / ClasseB / AbstractClass
+ \ No newline at end of file
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/GenericEngine/GenerationTest/PublicTemplateValidArgs/test_generic_engine b/tests/org.eclipse.acceleo.engine.tests/src-gen/GenericEngine/GenerationTest/PublicTemplateValidArgs/test_generic_engine
new file mode 100644
index 0000000..4047236
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/GenericEngine/GenerationTest/PublicTemplateValidArgs/test_generic_engine
@@ -0,0 +1,2 @@
+ constant output
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/GenericEngine/ReferenceResult/PublicTemplateValidArgs/test_generic_engine b/tests/org.eclipse.acceleo.engine.tests/src-gen/GenericEngine/ReferenceResult/PublicTemplateValidArgs/test_generic_engine
new file mode 100644
index 0000000..4047236
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/GenericEngine/ReferenceResult/PublicTemplateValidArgs/test_generic_engine
@@ -0,0 +1,2 @@
+ constant output
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/IfBlock/GenerationTest/CompleteIf/testCompleteIf b/tests/org.eclipse.acceleo.engine.tests/src-gen/IfBlock/GenerationTest/CompleteIf/testCompleteIf
new file mode 100644
index 0000000..a3d84c5
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/IfBlock/GenerationTest/CompleteIf/testCompleteIf
@@ -0,0 +1,4 @@
+Class name is ClasseA.
+Class name is ClasseB.
+Class name is different from ClasseA and ClasseB.
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/IfBlock/GenerationTest/Else/testElse b/tests/org.eclipse.acceleo.engine.tests/src-gen/IfBlock/GenerationTest/Else/testElse
new file mode 100644
index 0000000..f216ef4
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/IfBlock/GenerationTest/Else/testElse
@@ -0,0 +1 @@
+Class name is ClasseA.Class name is ClasseB.Class name is AbstractClass.
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/IfBlock/GenerationTest/Elseif/testElseif b/tests/org.eclipse.acceleo.engine.tests/src-gen/IfBlock/GenerationTest/Elseif/testElseif
new file mode 100644
index 0000000..70c741f
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/IfBlock/GenerationTest/Elseif/testElseif
@@ -0,0 +1,3 @@
+Class name is ClasseA.
+Class name is ClasseB.
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/IfBlock/GenerationTest/If/testIf b/tests/org.eclipse.acceleo.engine.tests/src-gen/IfBlock/GenerationTest/If/testIf
new file mode 100644
index 0000000..0978a41
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/IfBlock/GenerationTest/If/testIf
@@ -0,0 +1 @@
+Class name ClasseA = ClasseA.
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/IfBlock/GenerationTest/NestedIf/testNestedIf b/tests/org.eclipse.acceleo.engine.tests/src-gen/IfBlock/GenerationTest/NestedIf/testNestedIf
new file mode 100644
index 0000000..18b03b6
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/IfBlock/GenerationTest/NestedIf/testNestedIf
@@ -0,0 +1,4 @@
+Class name is A.
+Class is not abstract.Class name is B.
+Class is not abstract.Class name is different.
+Class is abstract
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/IfBlock/ReferenceResult/CompleteIf/testCompleteIf b/tests/org.eclipse.acceleo.engine.tests/src-gen/IfBlock/ReferenceResult/CompleteIf/testCompleteIf
new file mode 100644
index 0000000..9bd49b5
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/IfBlock/ReferenceResult/CompleteIf/testCompleteIf
@@ -0,0 +1,4 @@
+ Class name is ClasseA.
+ Class name is ClasseB.
+ Class name is different from ClasseA and ClasseB.
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/IfBlock/ReferenceResult/Else/testElse b/tests/org.eclipse.acceleo.engine.tests/src-gen/IfBlock/ReferenceResult/Else/testElse
new file mode 100644
index 0000000..850c7c9
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/IfBlock/ReferenceResult/Else/testElse
@@ -0,0 +1 @@
+ Class name is ClasseA. Class name is ClasseB. Class name is AbstractClass.
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/IfBlock/ReferenceResult/Elseif/testElseif b/tests/org.eclipse.acceleo.engine.tests/src-gen/IfBlock/ReferenceResult/Elseif/testElseif
new file mode 100644
index 0000000..4d7af3a
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/IfBlock/ReferenceResult/Elseif/testElseif
@@ -0,0 +1,3 @@
+ Class name is ClasseA.
+ Class name is ClasseB.
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/IfBlock/ReferenceResult/If/testIf b/tests/org.eclipse.acceleo.engine.tests/src-gen/IfBlock/ReferenceResult/If/testIf
new file mode 100644
index 0000000..a32f224
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/IfBlock/ReferenceResult/If/testIf
@@ -0,0 +1 @@
+ Class name ClasseA = ClasseA.
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/IfBlock/ReferenceResult/NestedIf/testNestedIf b/tests/org.eclipse.acceleo.engine.tests/src-gen/IfBlock/ReferenceResult/NestedIf/testNestedIf
new file mode 100644
index 0000000..88ae57f
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/IfBlock/ReferenceResult/NestedIf/testNestedIf
@@ -0,0 +1,6 @@
+ Class name is A.
+ Class is not abstract.
+ Class name is B.
+ Class is not abstract.
+ Class name is different.
+ Class is abstract \ No newline at end of file
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/Listeners/GenerationTest/Listeners/AbstractClass.java b/tests/org.eclipse.acceleo.engine.tests/src-gen/Listeners/GenerationTest/Listeners/AbstractClass.java
new file mode 100644
index 0000000..62ae497
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/Listeners/GenerationTest/Listeners/AbstractClass.java
@@ -0,0 +1,3 @@
+ package target
+
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/Listeners/GenerationTest/Listeners/ClasseA.java b/tests/org.eclipse.acceleo.engine.tests/src-gen/Listeners/GenerationTest/Listeners/ClasseA.java
new file mode 100644
index 0000000..f4990f4
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/Listeners/GenerationTest/Listeners/ClasseA.java
@@ -0,0 +1,7 @@
+ package target
+
+ anAttribute
+, multivaluedAttribute
+, aReferenceFromA
+, multivaluedReference
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/Listeners/GenerationTest/Listeners/ClasseB.java b/tests/org.eclipse.acceleo.engine.tests/src-gen/Listeners/GenerationTest/Listeners/ClasseB.java
new file mode 100644
index 0000000..d6d08b8
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/Listeners/GenerationTest/Listeners/ClasseB.java
@@ -0,0 +1,6 @@
+ package target
+
+ anAttributeOfB
+, anotherAttributeOfB
+, aReferenceFromB
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Guard/GenerationTest/NamesakeGuard/resolution_namesake_guard b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Guard/GenerationTest/NamesakeGuard/resolution_namesake_guard
new file mode 100644
index 0000000..bec44b3
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Guard/GenerationTest/NamesakeGuard/resolution_namesake_guard
@@ -0,0 +1,2 @@
+ imported.namesake_guard called on EClass AbstractClass
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Guard/GenerationTest/NamesakeGuardImportSpecific/resolution_namesake_guard_import_specific b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Guard/GenerationTest/NamesakeGuardImportSpecific/resolution_namesake_guard_import_specific
new file mode 100644
index 0000000..85c34cc
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Guard/GenerationTest/NamesakeGuardImportSpecific/resolution_namesake_guard_import_specific
@@ -0,0 +1,2 @@
+ imported.namesake_guard_import_specific called on EClass AbstractClass
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Guard/GenerationTest/NamesakeGuardedSpecific/resolution_namesake_guarded_specific b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Guard/GenerationTest/NamesakeGuardedSpecific/resolution_namesake_guarded_specific
new file mode 100644
index 0000000..e3c5a22
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Guard/GenerationTest/NamesakeGuardedSpecific/resolution_namesake_guarded_specific
@@ -0,0 +1,2 @@
+ imported.namesake_guarded_specific called on EClass AbstractClass
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Guard/ReferenceResult/NamesakeGuard/resolution_namesake_guard b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Guard/ReferenceResult/NamesakeGuard/resolution_namesake_guard
new file mode 100644
index 0000000..eacec82
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Guard/ReferenceResult/NamesakeGuard/resolution_namesake_guard
@@ -0,0 +1,3 @@
+ imported.namesake_guard called on EClass AbstractClass
+
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Guard/ReferenceResult/NamesakeGuardImportSpecific/resolution_namesake_guard_import_specific b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Guard/ReferenceResult/NamesakeGuardImportSpecific/resolution_namesake_guard_import_specific
new file mode 100644
index 0000000..cd942e3
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Guard/ReferenceResult/NamesakeGuardImportSpecific/resolution_namesake_guard_import_specific
@@ -0,0 +1,3 @@
+ imported.namesake_guard_import_specific called on EClass AbstractClass
+
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Guard/ReferenceResult/NamesakeGuardedSpecific/resolution_namesake_guarded_specific b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Guard/ReferenceResult/NamesakeGuardedSpecific/resolution_namesake_guarded_specific
new file mode 100644
index 0000000..6f3c20b
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Guard/ReferenceResult/NamesakeGuardedSpecific/resolution_namesake_guarded_specific
@@ -0,0 +1,3 @@
+ imported.namesake_guarded_specific called on EClass AbstractClass
+
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/GenerationTest/NamesakeExtendMostSpecific/resolution_namesake_extend_specific b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/GenerationTest/NamesakeExtendMostSpecific/resolution_namesake_extend_specific
new file mode 100644
index 0000000..b62ac85
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/GenerationTest/NamesakeExtendMostSpecific/resolution_namesake_extend_specific
@@ -0,0 +1,2 @@
+ extended.namesake_3_extend_specific called on EClass AbstractClass
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/GenerationTest/NamesakeExternalExtendSpecific/resolution_namesake_external_extend_specific b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/GenerationTest/NamesakeExternalExtendSpecific/resolution_namesake_external_extend_specific
new file mode 100644
index 0000000..cf6582f
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/GenerationTest/NamesakeExternalExtendSpecific/resolution_namesake_external_extend_specific
@@ -0,0 +1,2 @@
+ extended.namesake_external_extend_specific called on EClass AbstractClass
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/GenerationTest/NamesakeExternalImportSpecific/resolution_namesake_external_import_specific b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/GenerationTest/NamesakeExternalImportSpecific/resolution_namesake_external_import_specific
new file mode 100644
index 0000000..4788892
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/GenerationTest/NamesakeExternalImportSpecific/resolution_namesake_external_import_specific
@@ -0,0 +1,2 @@
+ imported.namesake_external_import_specific called on EClass AbstractClass
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/GenerationTest/NamesakeImportMostSpecific/resolution_namesake_import_specific b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/GenerationTest/NamesakeImportMostSpecific/resolution_namesake_import_specific
new file mode 100644
index 0000000..9df42e7
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/GenerationTest/NamesakeImportMostSpecific/resolution_namesake_import_specific
@@ -0,0 +1,2 @@
+ imported.namesake_3_import_specific called on EClass AbstractClass
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/GenerationTest/NamesakeLocalMostSpecific/resolution_namesake_local_specific b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/GenerationTest/NamesakeLocalMostSpecific/resolution_namesake_local_specific
new file mode 100644
index 0000000..6b15c80
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/GenerationTest/NamesakeLocalMostSpecific/resolution_namesake_local_specific
@@ -0,0 +1,2 @@
+ local.namesake_3_local_specific called on EClass AbstractClass
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/GenerationTest/NamesakeOnExtendExtendSpecific/resolution_namesake_extend_extend_specific b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/GenerationTest/NamesakeOnExtendExtendSpecific/resolution_namesake_extend_extend_specific
new file mode 100644
index 0000000..402a27b
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/GenerationTest/NamesakeOnExtendExtendSpecific/resolution_namesake_extend_extend_specific
@@ -0,0 +1,2 @@
+ extended.namesake_extend_extend_specific called on EClass AbstractClass
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/GenerationTest/NamesakeOnExtendLocalSpecific/resolution_namesake_extend_local_specific b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/GenerationTest/NamesakeOnExtendLocalSpecific/resolution_namesake_extend_local_specific
new file mode 100644
index 0000000..1d13679
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/GenerationTest/NamesakeOnExtendLocalSpecific/resolution_namesake_extend_local_specific
@@ -0,0 +1,2 @@
+ local.namesake_extend_local_specific called on EClass AbstractClass
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/GenerationTest/NamesakeOnImportImportSpecific/resolution_namesake_import_import_specific b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/GenerationTest/NamesakeOnImportImportSpecific/resolution_namesake_import_import_specific
new file mode 100644
index 0000000..c84371d
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/GenerationTest/NamesakeOnImportImportSpecific/resolution_namesake_import_import_specific
@@ -0,0 +1,2 @@
+ imported.namesake_import_import_specific called on EClass AbstractClass
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/GenerationTest/NamesakeOnImportLocalSpecific/resolution_namesake_import_local_specific b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/GenerationTest/NamesakeOnImportLocalSpecific/resolution_namesake_import_local_specific
new file mode 100644
index 0000000..264ba2a
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/GenerationTest/NamesakeOnImportLocalSpecific/resolution_namesake_import_local_specific
@@ -0,0 +1,2 @@
+ local.namesake_import_local_specific called on EClass AbstractClass
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/ReferenceResult/NamesakeExtendMostSpecific/resolution_namesake_extend_specific b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/ReferenceResult/NamesakeExtendMostSpecific/resolution_namesake_extend_specific
new file mode 100644
index 0000000..46ac58c
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/ReferenceResult/NamesakeExtendMostSpecific/resolution_namesake_extend_specific
@@ -0,0 +1,3 @@
+ extended.namesake_3_extend_specific called on EClass AbstractClass
+
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/ReferenceResult/NamesakeExternalExtendSpecific/resolution_namesake_external_extend_specific b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/ReferenceResult/NamesakeExternalExtendSpecific/resolution_namesake_external_extend_specific
new file mode 100644
index 0000000..78f41d5
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/ReferenceResult/NamesakeExternalExtendSpecific/resolution_namesake_external_extend_specific
@@ -0,0 +1,3 @@
+ extended.namesake_external_extend_specific called on EClass AbstractClass
+
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/ReferenceResult/NamesakeExternalImportSpecific/resolution_namesake_external_import_specific b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/ReferenceResult/NamesakeExternalImportSpecific/resolution_namesake_external_import_specific
new file mode 100644
index 0000000..a71502d
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/ReferenceResult/NamesakeExternalImportSpecific/resolution_namesake_external_import_specific
@@ -0,0 +1,3 @@
+ imported.namesake_external_import_specific called on EClass AbstractClass
+
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/ReferenceResult/NamesakeImportMostSpecific/resolution_namesake_import_specific b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/ReferenceResult/NamesakeImportMostSpecific/resolution_namesake_import_specific
new file mode 100644
index 0000000..4dddf6e
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/ReferenceResult/NamesakeImportMostSpecific/resolution_namesake_import_specific
@@ -0,0 +1,3 @@
+ imported.namesake_3_import_specific called on EClass AbstractClass
+
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/ReferenceResult/NamesakeLocalMostSpecific/resolution_namesake_local_specific b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/ReferenceResult/NamesakeLocalMostSpecific/resolution_namesake_local_specific
new file mode 100644
index 0000000..e9603b4
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/ReferenceResult/NamesakeLocalMostSpecific/resolution_namesake_local_specific
@@ -0,0 +1,3 @@
+ local.namesake_3_local_specific called on EClass AbstractClass
+
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/ReferenceResult/NamesakeOnExtendExtendSpecific/resolution_namesake_extend_extend_specific b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/ReferenceResult/NamesakeOnExtendExtendSpecific/resolution_namesake_extend_extend_specific
new file mode 100644
index 0000000..d602cb8
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/ReferenceResult/NamesakeOnExtendExtendSpecific/resolution_namesake_extend_extend_specific
@@ -0,0 +1,3 @@
+ extended.namesake_extend_extend_specific called on EClass AbstractClass
+
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/ReferenceResult/NamesakeOnExtendLocalSpecific/resolution_namesake_extend_local_specific b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/ReferenceResult/NamesakeOnExtendLocalSpecific/resolution_namesake_extend_local_specific
new file mode 100644
index 0000000..499998d
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/ReferenceResult/NamesakeOnExtendLocalSpecific/resolution_namesake_extend_local_specific
@@ -0,0 +1,3 @@
+ local.namesake_extend_local_specific called on EClass AbstractClass
+
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/ReferenceResult/NamesakeOnImportImportSpecific/resolution_namesake_import_import_specific b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/ReferenceResult/NamesakeOnImportImportSpecific/resolution_namesake_import_import_specific
new file mode 100644
index 0000000..065f586
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/ReferenceResult/NamesakeOnImportImportSpecific/resolution_namesake_import_import_specific
@@ -0,0 +1,3 @@
+ imported.namesake_import_import_specific called on EClass AbstractClass
+
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/ReferenceResult/NamesakeOnImportLocalSpecific/resolution_namesake_import_local_specific b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/ReferenceResult/NamesakeOnImportLocalSpecific/resolution_namesake_import_local_specific
new file mode 100644
index 0000000..222a675
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/ParameterNarrowing/ReferenceResult/NamesakeOnImportLocalSpecific/resolution_namesake_import_local_specific
@@ -0,0 +1,3 @@
+ local.namesake_import_local_specific called on EClass AbstractClass
+
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Simple/GenerationTest/NamesakeDistinctParameterNames/distinct_param_name b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Simple/GenerationTest/NamesakeDistinctParameterNames/distinct_param_name
new file mode 100644
index 0000000..c93066f
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Simple/GenerationTest/NamesakeDistinctParameterNames/distinct_param_name
@@ -0,0 +1,2 @@
+ local.namesake_param_names called on EClass AbstractClass
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Simple/GenerationTest/NamesakeExtendConflict/resolution_extended b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Simple/GenerationTest/NamesakeExtendConflict/resolution_extended
new file mode 100644
index 0000000..b4d152e
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Simple/GenerationTest/NamesakeExtendConflict/resolution_extended
@@ -0,0 +1,2 @@
+ local.namesake_extend called on EClass AbstractClass
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Simple/GenerationTest/NamesakeExternalConflict/resolution_external b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Simple/GenerationTest/NamesakeExternalConflict/resolution_external
new file mode 100644
index 0000000..5be67a0
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Simple/GenerationTest/NamesakeExternalConflict/resolution_external
@@ -0,0 +1,2 @@
+ extended.namesake_external called on EClass AbstractClass
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Simple/GenerationTest/NamesakeImportConflict/resolution_imported b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Simple/GenerationTest/NamesakeImportConflict/resolution_imported
new file mode 100644
index 0000000..8bf6690
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Simple/GenerationTest/NamesakeImportConflict/resolution_imported
@@ -0,0 +1,2 @@
+ local.namesake_import called on EClass AbstractClass
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Simple/GenerationTest/NamesakePriority/resolution_priority b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Simple/GenerationTest/NamesakePriority/resolution_priority
new file mode 100644
index 0000000..6fbaf1e
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Simple/GenerationTest/NamesakePriority/resolution_priority
@@ -0,0 +1,2 @@
+ local.namesake_3 called on EClass AbstractClass
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Simple/ReferenceResult/NamesakeDistinctParameterNames/distinct_param_name b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Simple/ReferenceResult/NamesakeDistinctParameterNames/distinct_param_name
new file mode 100644
index 0000000..c93066f
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Simple/ReferenceResult/NamesakeDistinctParameterNames/distinct_param_name
@@ -0,0 +1,2 @@
+ local.namesake_param_names called on EClass AbstractClass
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Simple/ReferenceResult/NamesakeExtendConflict/resolution_extended b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Simple/ReferenceResult/NamesakeExtendConflict/resolution_extended
new file mode 100644
index 0000000..04e60ec
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Simple/ReferenceResult/NamesakeExtendConflict/resolution_extended
@@ -0,0 +1,3 @@
+ local.namesake_extend called on EClass AbstractClass
+
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Simple/ReferenceResult/NamesakeExternalConflict/resolution_external b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Simple/ReferenceResult/NamesakeExternalConflict/resolution_external
new file mode 100644
index 0000000..5fdfe17
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Simple/ReferenceResult/NamesakeExternalConflict/resolution_external
@@ -0,0 +1,3 @@
+ extended.namesake_external called on EClass AbstractClass
+
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Simple/ReferenceResult/NamesakeImportConflict/resolution_imported b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Simple/ReferenceResult/NamesakeImportConflict/resolution_imported
new file mode 100644
index 0000000..f233dc4
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Simple/ReferenceResult/NamesakeImportConflict/resolution_imported
@@ -0,0 +1,3 @@
+ local.namesake_import called on EClass AbstractClass
+
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Simple/ReferenceResult/NamesakePriority/resolution_priority b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Simple/ReferenceResult/NamesakePriority/resolution_priority
new file mode 100644
index 0000000..a136ef5
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/NamesakeResolution/Simple/ReferenceResult/NamesakePriority/resolution_priority
@@ -0,0 +1,3 @@
+ local.namesake_3 called on EClass AbstractClass
+
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Guard/GenerationTest/ExternalDefinitionGuarded/resolution_external_override_definition_guarded b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Guard/GenerationTest/ExternalDefinitionGuarded/resolution_external_override_definition_guarded
new file mode 100644
index 0000000..7907b10
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Guard/GenerationTest/ExternalDefinitionGuarded/resolution_external_override_definition_guarded
@@ -0,0 +1,2 @@
+ extended.override_resolution_external_guard called on EClass AbstractClass
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Guard/GenerationTest/LocalDefinitionGuarded/resolution_local_override_definition_guarded b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Guard/GenerationTest/LocalDefinitionGuarded/resolution_local_override_definition_guarded
new file mode 100644
index 0000000..fe189f5
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Guard/GenerationTest/LocalDefinitionGuarded/resolution_local_override_definition_guarded
@@ -0,0 +1,2 @@
+ local.override_resolution_local_guard called on EClass AbstractClass
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Guard/GenerationTest/SpecificGuarded/resolution_override_specific_guarded b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Guard/GenerationTest/SpecificGuarded/resolution_override_specific_guarded
new file mode 100644
index 0000000..3f48807
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Guard/GenerationTest/SpecificGuarded/resolution_override_specific_guarded
@@ -0,0 +1,2 @@
+ imported.override_resolution_definition_guard called on EClass AbstractClass
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Guard/ReferenceResult/ExternalDefinitionGuarded/resolution_external_override_definition_guarded b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Guard/ReferenceResult/ExternalDefinitionGuarded/resolution_external_override_definition_guarded
new file mode 100644
index 0000000..1d57504
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Guard/ReferenceResult/ExternalDefinitionGuarded/resolution_external_override_definition_guarded
@@ -0,0 +1,3 @@
+ extended.override_resolution_external_guard called on EClass AbstractClass
+
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Guard/ReferenceResult/LocalDefinitionGuarded/resolution_local_override_definition_guarded b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Guard/ReferenceResult/LocalDefinitionGuarded/resolution_local_override_definition_guarded
new file mode 100644
index 0000000..62ba869
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Guard/ReferenceResult/LocalDefinitionGuarded/resolution_local_override_definition_guarded
@@ -0,0 +1,3 @@
+ local.override_resolution_local_guard called on EClass AbstractClass
+
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Guard/ReferenceResult/SpecificGuarded/resolution_override_specific_guarded b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Guard/ReferenceResult/SpecificGuarded/resolution_override_specific_guarded
new file mode 100644
index 0000000..c596c9c
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Guard/ReferenceResult/SpecificGuarded/resolution_override_specific_guarded
@@ -0,0 +1,3 @@
+ imported.override_resolution_definition_guard called on EClass AbstractClass
+
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/ParameterTypeNarrowing/GenerationTest/ParameterNarrowing/resolution_override_specific b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/ParameterTypeNarrowing/GenerationTest/ParameterNarrowing/resolution_override_specific
new file mode 100644
index 0000000..45fc016
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/ParameterTypeNarrowing/GenerationTest/ParameterNarrowing/resolution_override_specific
@@ -0,0 +1,2 @@
+ local.parameter_narrowing_3_local_override called on EClass AbstractClass
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/ParameterTypeNarrowing/GenerationTest/ParameterNarrowingExternal/resolution_external_override b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/ParameterTypeNarrowing/GenerationTest/ParameterNarrowingExternal/resolution_external_override
new file mode 100644
index 0000000..68a5460
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/ParameterTypeNarrowing/GenerationTest/ParameterNarrowingExternal/resolution_external_override
@@ -0,0 +1,2 @@
+ extended.parameter_narrowing_external_override called on EClass AbstractClass
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/ParameterTypeNarrowing/GenerationTest/ParameterNarrowingLocal/resolution_local_override b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/ParameterTypeNarrowing/GenerationTest/ParameterNarrowingLocal/resolution_local_override
new file mode 100644
index 0000000..f1f65a0
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/ParameterTypeNarrowing/GenerationTest/ParameterNarrowingLocal/resolution_local_override
@@ -0,0 +1,2 @@
+ local.parameter_narrowing_local_override called on EClass AbstractClass
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/ParameterTypeNarrowing/ReferenceResult/ParameterNarrowing/resolution_override_specific b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/ParameterTypeNarrowing/ReferenceResult/ParameterNarrowing/resolution_override_specific
new file mode 100644
index 0000000..d4f2fc1
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/ParameterTypeNarrowing/ReferenceResult/ParameterNarrowing/resolution_override_specific
@@ -0,0 +1,3 @@
+ local.parameter_narrowing_3_local_override called on EClass AbstractClass
+
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/ParameterTypeNarrowing/ReferenceResult/ParameterNarrowingExternal/resolution_external_override b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/ParameterTypeNarrowing/ReferenceResult/ParameterNarrowingExternal/resolution_external_override
new file mode 100644
index 0000000..7f30518
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/ParameterTypeNarrowing/ReferenceResult/ParameterNarrowingExternal/resolution_external_override
@@ -0,0 +1,3 @@
+ extended.parameter_narrowing_external_override called on EClass AbstractClass
+
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/ParameterTypeNarrowing/ReferenceResult/ParameterNarrowingLocal/resolution_local_override b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/ParameterTypeNarrowing/ReferenceResult/ParameterNarrowingLocal/resolution_local_override
new file mode 100644
index 0000000..3059e99
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/ParameterTypeNarrowing/ReferenceResult/ParameterNarrowingLocal/resolution_local_override
@@ -0,0 +1,3 @@
+ local.parameter_narrowing_local_override called on EClass AbstractClass
+
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/GenerationTest/ExtendOverrideDirectCall/resolution_extend_overriden_direct b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/GenerationTest/ExtendOverrideDirectCall/resolution_extend_overriden_direct
new file mode 100644
index 0000000..f6f64d9
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/GenerationTest/ExtendOverrideDirectCall/resolution_extend_overriden_direct
@@ -0,0 +1,2 @@
+ extended.extend_overriden called on EClass AbstractClass
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/GenerationTest/ExtendOverrideIndirectCall/resolution_extend_overriden_indirect b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/GenerationTest/ExtendOverrideIndirectCall/resolution_extend_overriden_indirect
new file mode 100644
index 0000000..f6f64d9
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/GenerationTest/ExtendOverrideIndirectCall/resolution_extend_overriden_indirect
@@ -0,0 +1,2 @@
+ extended.extend_overriden called on EClass AbstractClass
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/GenerationTest/LocalOverrideDirectCall/resolution_local_overriden_direct b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/GenerationTest/LocalOverrideDirectCall/resolution_local_overriden_direct
new file mode 100644
index 0000000..7a743d5
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/GenerationTest/LocalOverrideDirectCall/resolution_local_overriden_direct
@@ -0,0 +1,2 @@
+ local.local_overriden called on EClass AbstractClass
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/GenerationTest/LocalOverrideIndirectCall/resolution_local_overriden_indirect b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/GenerationTest/LocalOverrideIndirectCall/resolution_local_overriden_indirect
new file mode 100644
index 0000000..7a743d5
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/GenerationTest/LocalOverrideIndirectCall/resolution_local_overriden_indirect
@@ -0,0 +1,2 @@
+ local.local_overriden called on EClass AbstractClass
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/GenerationTest/OverridePriorityDirectCall/resolution_override_priority_direct b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/GenerationTest/OverridePriorityDirectCall/resolution_override_priority_direct
new file mode 100644
index 0000000..ce6f49e
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/GenerationTest/OverridePriorityDirectCall/resolution_override_priority_direct
@@ -0,0 +1,2 @@
+ local.local_override_3 called on EClass AbstractClass
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/GenerationTest/OverridePriorityIndirectCall/resolution_override_priority_indirect b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/GenerationTest/OverridePriorityIndirectCall/resolution_override_priority_indirect
new file mode 100644
index 0000000..ce6f49e
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/GenerationTest/OverridePriorityIndirectCall/resolution_override_priority_indirect
@@ -0,0 +1,2 @@
+ local.local_override_3 called on EClass AbstractClass
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/GenerationTest/OverridePriorityMidIndirectCall/resolution_override_priority_indirect_extend b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/GenerationTest/OverridePriorityMidIndirectCall/resolution_override_priority_indirect_extend
new file mode 100644
index 0000000..ce6f49e
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/GenerationTest/OverridePriorityMidIndirectCall/resolution_override_priority_indirect_extend
@@ -0,0 +1,2 @@
+ local.local_override_3 called on EClass AbstractClass
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/ReferenceResult/ExtendOverrideDirectCall/resolution_extend_overriden_direct b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/ReferenceResult/ExtendOverrideDirectCall/resolution_extend_overriden_direct
new file mode 100644
index 0000000..0bf15e7
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/ReferenceResult/ExtendOverrideDirectCall/resolution_extend_overriden_direct
@@ -0,0 +1,3 @@
+ extended.extend_overriden called on EClass AbstractClass
+
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/ReferenceResult/ExtendOverrideIndirectCall/resolution_extend_overriden_indirect b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/ReferenceResult/ExtendOverrideIndirectCall/resolution_extend_overriden_indirect
new file mode 100644
index 0000000..0bf15e7
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/ReferenceResult/ExtendOverrideIndirectCall/resolution_extend_overriden_indirect
@@ -0,0 +1,3 @@
+ extended.extend_overriden called on EClass AbstractClass
+
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/ReferenceResult/LocalOverrideDirectCall/resolution_local_overriden_direct b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/ReferenceResult/LocalOverrideDirectCall/resolution_local_overriden_direct
new file mode 100644
index 0000000..d574bf0
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/ReferenceResult/LocalOverrideDirectCall/resolution_local_overriden_direct
@@ -0,0 +1,3 @@
+ local.local_overriden called on EClass AbstractClass
+
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/ReferenceResult/LocalOverrideIndirectCall/resolution_local_overriden_indirect b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/ReferenceResult/LocalOverrideIndirectCall/resolution_local_overriden_indirect
new file mode 100644
index 0000000..d574bf0
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/ReferenceResult/LocalOverrideIndirectCall/resolution_local_overriden_indirect
@@ -0,0 +1,3 @@
+ local.local_overriden called on EClass AbstractClass
+
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/ReferenceResult/OverridePriorityDirectCall/resolution_override_priority_direct b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/ReferenceResult/OverridePriorityDirectCall/resolution_override_priority_direct
new file mode 100644
index 0000000..06ee0af
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/ReferenceResult/OverridePriorityDirectCall/resolution_override_priority_direct
@@ -0,0 +1,3 @@
+ local.local_override_3 called on EClass AbstractClass
+
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/ReferenceResult/OverridePriorityIndirectCall/resolution_override_priority_indirect b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/ReferenceResult/OverridePriorityIndirectCall/resolution_override_priority_indirect
new file mode 100644
index 0000000..06ee0af
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/ReferenceResult/OverridePriorityIndirectCall/resolution_override_priority_indirect
@@ -0,0 +1,3 @@
+ local.local_override_3 called on EClass AbstractClass
+
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/ReferenceResult/OverridePriorityMidIndirectCall/resolution_override_priority_indirect_extend b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/ReferenceResult/OverridePriorityMidIndirectCall/resolution_override_priority_indirect_extend
new file mode 100644
index 0000000..06ee0af
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/OverrideResolution/Simple/ReferenceResult/OverridePriorityMidIndirectCall/resolution_override_priority_indirect_extend
@@ -0,0 +1,3 @@
+ local.local_override_3 called on EClass AbstractClass
+
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/ProtectedAreaBlock/GenerationTest/LostProtectedArea/lost_protected_areas b/tests/org.eclipse.acceleo.engine.tests/src-gen/ProtectedAreaBlock/GenerationTest/LostProtectedArea/lost_protected_areas
new file mode 100644
index 0000000..01e072b
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/ProtectedAreaBlock/GenerationTest/LostProtectedArea/lost_protected_areas
@@ -0,0 +1,6 @@
+ // Start of user code user code 2 ClasseA
+ second protected area
+ // End of user code // Start of user code user code 3 ClasseA
+ third protected area
+ // End of user code
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/ProtectedAreaBlock/GenerationTest/LostProtectedArea/lost_protected_areas.lost b/tests/org.eclipse.acceleo.engine.tests/src-gen/ProtectedAreaBlock/GenerationTest/LostProtectedArea/lost_protected_areas.lost
new file mode 100644
index 0000000..b8d93d0
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/ProtectedAreaBlock/GenerationTest/LostProtectedArea/lost_protected_areas.lost
@@ -0,0 +1,7 @@
+
+Thu Mar 05 16:44:24 CET 2009
+================================================================================
+Start of user code user code 1 ClasseA
+ first protected area
+ // End of user code
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/ProtectedAreaBlock/GenerationTest/RemovedProtectedArea/removed_protected_areas b/tests/org.eclipse.acceleo.engine.tests/src-gen/ProtectedAreaBlock/GenerationTest/RemovedProtectedArea/removed_protected_areas
new file mode 100644
index 0000000..9d7c8c1
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/ProtectedAreaBlock/GenerationTest/RemovedProtectedArea/removed_protected_areas
@@ -0,0 +1,4 @@
+ // Start of user code user code 2 ClasseA
+ second protected area
+ // End of user code
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/ProtectedAreaBlock/GenerationTest/RemovedProtectedArea/removed_protected_areas.lost b/tests/org.eclipse.acceleo.engine.tests/src-gen/ProtectedAreaBlock/GenerationTest/RemovedProtectedArea/removed_protected_areas.lost
new file mode 100644
index 0000000..b8d93d0
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/ProtectedAreaBlock/GenerationTest/RemovedProtectedArea/removed_protected_areas.lost
@@ -0,0 +1,7 @@
+
+Thu Mar 05 16:44:24 CET 2009
+================================================================================
+Start of user code user code 1 ClasseA
+ first protected area
+ // End of user code
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/ProtectedAreaBlock/GenerationTest/Standard/protected_areas b/tests/org.eclipse.acceleo.engine.tests/src-gen/ProtectedAreaBlock/GenerationTest/Standard/protected_areas
new file mode 100644
index 0000000..94df6de
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/ProtectedAreaBlock/GenerationTest/Standard/protected_areas
@@ -0,0 +1,7 @@
+ // Start of user code user code 1 ClasseA
+ first protected area
+ // End of user code
+ // Start of user code user code 2 ClasseA
+ second protected area
+ // End of user code
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/ProtectedAreaBlock/ReferenceResult/LostProtectedArea/lost_protected_areas b/tests/org.eclipse.acceleo.engine.tests/src-gen/ProtectedAreaBlock/ReferenceResult/LostProtectedArea/lost_protected_areas
new file mode 100644
index 0000000..2840da5
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/ProtectedAreaBlock/ReferenceResult/LostProtectedArea/lost_protected_areas
@@ -0,0 +1,10 @@
+
+
+ // Start of user code user code 2 ClasseA
+ second protected area
+ // End of user code
+ // Start of user code user code 3 ClasseA
+ third protected area
+ // End of user code
+
+ \ No newline at end of file
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/ProtectedAreaBlock/ReferenceResult/LostProtectedArea/lost_protected_areas.lost b/tests/org.eclipse.acceleo.engine.tests/src-gen/ProtectedAreaBlock/ReferenceResult/LostProtectedArea/lost_protected_areas.lost
new file mode 100644
index 0000000..3380865
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/ProtectedAreaBlock/ReferenceResult/LostProtectedArea/lost_protected_areas.lost
@@ -0,0 +1,7 @@
+
+Tue Jan 27 18:11:28 CET 2009
+================================================================================
+Start of user code user code 1 ClasseA
+ first protected area
+ // End of user code
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/ProtectedAreaBlock/ReferenceResult/RemovedProtectedArea/removed_protected_areas b/tests/org.eclipse.acceleo.engine.tests/src-gen/ProtectedAreaBlock/ReferenceResult/RemovedProtectedArea/removed_protected_areas
new file mode 100644
index 0000000..102e1cb
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/ProtectedAreaBlock/ReferenceResult/RemovedProtectedArea/removed_protected_areas
@@ -0,0 +1,7 @@
+
+
+ // Start of user code user code 2 ClasseA
+ second protected area
+ // End of user code
+
+ \ No newline at end of file
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/ProtectedAreaBlock/ReferenceResult/RemovedProtectedArea/removed_protected_areas.lost b/tests/org.eclipse.acceleo.engine.tests/src-gen/ProtectedAreaBlock/ReferenceResult/RemovedProtectedArea/removed_protected_areas.lost
new file mode 100644
index 0000000..3380865
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/ProtectedAreaBlock/ReferenceResult/RemovedProtectedArea/removed_protected_areas.lost
@@ -0,0 +1,7 @@
+
+Tue Jan 27 18:11:28 CET 2009
+================================================================================
+Start of user code user code 1 ClasseA
+ first protected area
+ // End of user code
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/ProtectedAreaBlock/ReferenceResult/Standard/protected_areas b/tests/org.eclipse.acceleo.engine.tests/src-gen/ProtectedAreaBlock/ReferenceResult/Standard/protected_areas
new file mode 100644
index 0000000..23397e2
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/ProtectedAreaBlock/ReferenceResult/Standard/protected_areas
@@ -0,0 +1,10 @@
+
+
+ // Start of user code user code 1 ClasseA
+ first protected area
+ // End of user code
+ // Start of user code user code 2 ClasseA
+ second protected area
+ // End of user code
+
+ \ No newline at end of file
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/GenerationTest/After/after_test b/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/GenerationTest/After/after_test
new file mode 100644
index 0000000..29fe08d
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/GenerationTest/After/after_test
@@ -0,0 +1,2 @@
+ local.protected_overriding_template called on EClass AbstractClassafter
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/GenerationTest/Before/before_test b/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/GenerationTest/Before/before_test
new file mode 100644
index 0000000..4078202
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/GenerationTest/Before/before_test
@@ -0,0 +1,2 @@
+ before local.protected_overriding_template called on EClass AbstractClass
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/GenerationTest/FalseGuard/false_guard b/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/GenerationTest/FalseGuard/false_guard
new file mode 100644
index 0000000..40aef63
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/GenerationTest/FalseGuard/false_guard
@@ -0,0 +1,2 @@
+
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/GenerationTest/Import/import b/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/GenerationTest/Import/import
new file mode 100644
index 0000000..de7551f
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/GenerationTest/Import/import
@@ -0,0 +1,2 @@
+ extended.imported_template called on EClass AbstractClass
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/GenerationTest/PrivateVisibility/private_visibility b/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/GenerationTest/PrivateVisibility/private_visibility
new file mode 100644
index 0000000..909fb2c
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/GenerationTest/PrivateVisibility/private_visibility
@@ -0,0 +1,2 @@
+ local.private_local_template called on EClass AbstractClass
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/GenerationTest/ProtectOverride/protected_override b/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/GenerationTest/ProtectOverride/protected_override
new file mode 100644
index 0000000..7158f8b
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/GenerationTest/ProtectOverride/protected_override
@@ -0,0 +1,2 @@
+ local.protected_overriding_template called on EClass AbstractClass
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/GenerationTest/ProtectedVisibility/protected_visibility b/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/GenerationTest/ProtectedVisibility/protected_visibility
new file mode 100644
index 0000000..7158f8b
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/GenerationTest/ProtectedVisibility/protected_visibility
@@ -0,0 +1,2 @@
+ local.protected_overriding_template called on EClass AbstractClass
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/GenerationTest/Super/super b/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/GenerationTest/Super/super
new file mode 100644
index 0000000..f9eb11e
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/GenerationTest/Super/super
@@ -0,0 +1,2 @@
+ overriding call to extended.super_extended_template called on EClass AbstractClass
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/GenerationTest/TrueGuard/true_guard b/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/GenerationTest/TrueGuard/true_guard
new file mode 100644
index 0000000..594045f
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/GenerationTest/TrueGuard/true_guard
@@ -0,0 +1,2 @@
+ local.true_guard_template called on EClass AbstractClass
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/ReferenceResult/After/after_test b/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/ReferenceResult/After/after_test
new file mode 100644
index 0000000..9b31a54
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/ReferenceResult/After/after_test
@@ -0,0 +1,3 @@
+ local.protected_overriding_template called on EClass AbstractClass
+after
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/ReferenceResult/Before/before_test b/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/ReferenceResult/Before/before_test
new file mode 100644
index 0000000..2a3d07f
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/ReferenceResult/Before/before_test
@@ -0,0 +1,4 @@
+ before
+ local.protected_overriding_template called on EClass AbstractClass
+
+ \ No newline at end of file
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/ReferenceResult/FalseGuard/false_guard b/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/ReferenceResult/FalseGuard/false_guard
new file mode 100644
index 0000000..c1ccada
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/ReferenceResult/FalseGuard/false_guard
@@ -0,0 +1,2 @@
+
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/ReferenceResult/Import/import b/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/ReferenceResult/Import/import
new file mode 100644
index 0000000..5a57612
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/ReferenceResult/Import/import
@@ -0,0 +1,3 @@
+ extended.imported_template called on EClass AbstractClass
+
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/ReferenceResult/PrivateVisibility/private_visibility b/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/ReferenceResult/PrivateVisibility/private_visibility
new file mode 100644
index 0000000..a837004
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/ReferenceResult/PrivateVisibility/private_visibility
@@ -0,0 +1,3 @@
+ local.private_local_template called on EClass AbstractClass
+
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/ReferenceResult/ProtectOverride/protected_override b/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/ReferenceResult/ProtectOverride/protected_override
new file mode 100644
index 0000000..cf440a6
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/ReferenceResult/ProtectOverride/protected_override
@@ -0,0 +1,3 @@
+ local.protected_overriding_template called on EClass AbstractClass
+
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/ReferenceResult/ProtectedVisibility/protected_visibility b/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/ReferenceResult/ProtectedVisibility/protected_visibility
new file mode 100644
index 0000000..cf440a6
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/ReferenceResult/ProtectedVisibility/protected_visibility
@@ -0,0 +1,3 @@
+ local.protected_overriding_template called on EClass AbstractClass
+
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/ReferenceResult/Super/super b/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/ReferenceResult/Super/super
new file mode 100644
index 0000000..3106bd9
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/ReferenceResult/Super/super
@@ -0,0 +1,4 @@
+ overriding call to extended.super_extended_template called on EClass AbstractClass
+
+
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/ReferenceResult/TrueGuard/true_guard b/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/ReferenceResult/TrueGuard/true_guard
new file mode 100644
index 0000000..b4b731e
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/Template/ReferenceResult/TrueGuard/true_guard
@@ -0,0 +1,3 @@
+ local.true_guard_template called on EClass AbstractClass
+
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/TemplateInvocation/GenerationTest/DualTemplateInvocation/dual_query_invocation b/tests/org.eclipse.acceleo.engine.tests/src-gen/TemplateInvocation/GenerationTest/DualTemplateInvocation/dual_query_invocation
new file mode 100644
index 0000000..4b76f9f
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/TemplateInvocation/GenerationTest/DualTemplateInvocation/dual_query_invocation
@@ -0,0 +1,2 @@
+ AbstractClasS
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/TemplateInvocation/GenerationTest/DualTemplateInvocation/dual_template_invocation b/tests/org.eclipse.acceleo.engine.tests/src-gen/TemplateInvocation/GenerationTest/DualTemplateInvocation/dual_template_invocation
new file mode 100644
index 0000000..0424343
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/TemplateInvocation/GenerationTest/DualTemplateInvocation/dual_template_invocation
@@ -0,0 +1,2 @@
+ AbstractClasS
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/TemplateInvocation/ReferenceResult/DualTemplateInvocation/dual_template_invocation b/tests/org.eclipse.acceleo.engine.tests/src-gen/TemplateInvocation/ReferenceResult/DualTemplateInvocation/dual_template_invocation
new file mode 100644
index 0000000..b5e16e4
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/TemplateInvocation/ReferenceResult/DualTemplateInvocation/dual_template_invocation
@@ -0,0 +1,3 @@
+ AbstractClasS
+
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/Variables/GenerationTest/ImplicitSelfQuery/implicit_self_query b/tests/org.eclipse.acceleo.engine.tests/src-gen/Variables/GenerationTest/ImplicitSelfQuery/implicit_self_query
new file mode 100644
index 0000000..f2b936c
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/Variables/GenerationTest/ImplicitSelfQuery/implicit_self_query
@@ -0,0 +1,2 @@
+ target
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/Variables/GenerationTest/ImplicitSelfTemplate/implicit_self_template b/tests/org.eclipse.acceleo.engine.tests/src-gen/Variables/GenerationTest/ImplicitSelfTemplate/implicit_self_template
new file mode 100644
index 0000000..d4e7e0c
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/Variables/GenerationTest/ImplicitSelfTemplate/implicit_self_template
@@ -0,0 +1,2 @@
+ target
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/Variables/GenerationTest/SelfQuery/self_query b/tests/org.eclipse.acceleo.engine.tests/src-gen/Variables/GenerationTest/SelfQuery/self_query
new file mode 100644
index 0000000..f2b936c
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/Variables/GenerationTest/SelfQuery/self_query
@@ -0,0 +1,2 @@
+ target
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/Variables/GenerationTest/SelfTemplate/self_template b/tests/org.eclipse.acceleo.engine.tests/src-gen/Variables/GenerationTest/SelfTemplate/self_template
new file mode 100644
index 0000000..d4e7e0c
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/Variables/GenerationTest/SelfTemplate/self_template
@@ -0,0 +1,2 @@
+ target
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/Variables/ReferenceResult/ImplicitSelfQuery/implicit_self_query b/tests/org.eclipse.acceleo.engine.tests/src-gen/Variables/ReferenceResult/ImplicitSelfQuery/implicit_self_query
new file mode 100644
index 0000000..f2b936c
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/Variables/ReferenceResult/ImplicitSelfQuery/implicit_self_query
@@ -0,0 +1,2 @@
+ target
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/Variables/ReferenceResult/ImplicitSelfTemplate/implicit_self_template b/tests/org.eclipse.acceleo.engine.tests/src-gen/Variables/ReferenceResult/ImplicitSelfTemplate/implicit_self_template
new file mode 100644
index 0000000..d4e7e0c
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/Variables/ReferenceResult/ImplicitSelfTemplate/implicit_self_template
@@ -0,0 +1,2 @@
+ target
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/Variables/ReferenceResult/SelfQuery/self_query b/tests/org.eclipse.acceleo.engine.tests/src-gen/Variables/ReferenceResult/SelfQuery/self_query
new file mode 100644
index 0000000..f2b936c
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/Variables/ReferenceResult/SelfQuery/self_query
@@ -0,0 +1,2 @@
+ target
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src-gen/Variables/ReferenceResult/SelfTemplate/self_template b/tests/org.eclipse.acceleo.engine.tests/src-gen/Variables/ReferenceResult/SelfTemplate/self_template
new file mode 100644
index 0000000..d4e7e0c
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src-gen/Variables/ReferenceResult/SelfTemplate/self_template
@@ -0,0 +1,2 @@
+ target
+
diff --git a/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/AcceleoEngineTestPlugin.java b/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/AcceleoEngineTestPlugin.java
new file mode 100644
index 0000000..c52b115
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/AcceleoEngineTestPlugin.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.acceleo.engine.tests;
+
+import org.eclipse.core.runtime.Plugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle.
+ *
+ * @author <a href="mailto:laurent.goubet@obeo.fr">Laurent Goubet</a>
+ */
+public class AcceleoEngineTestPlugin extends Plugin {
+ /** The plug-in ID. */
+ public static final String PLUGIN_ID = "org.eclipse.acceleo.engine.tests"; //$NON-NLS-1$
+
+ /** This plug-in's shared instance. */
+ private static AcceleoEngineTestPlugin plugin;
+
+ /**
+ * Default constructor for the plugin.
+ */
+ public AcceleoEngineTestPlugin() {
+ plugin = this;
+ }
+
+ /**
+ * Returns the shared instance.
+ *
+ * @return the shared instance
+ */
+ public static AcceleoEngineTestPlugin getDefault() {
+ return plugin;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void start(final BundleContext context) throws Exception {
+ super.start(context);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void stop(final BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+}
diff --git a/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/suite/AllTests.java b/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/suite/AllTests.java
new file mode 100644
index 0000000..e16299b
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/suite/AllTests.java
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.acceleo.engine.tests.suite;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+import org.eclipse.acceleo.engine.tests.unit.blocks.forBlock.ForBlockTest;
+import org.eclipse.acceleo.engine.tests.unit.blocks.ifBlock.IfBlockTest;
+import org.eclipse.acceleo.engine.tests.unit.blocks.protectedareablock.ProtectedAreaBlockTest;
+import org.eclipse.acceleo.engine.tests.unit.blocks.template.TemplateTest;
+import org.eclipse.acceleo.engine.tests.unit.blocks.templateinvocation.DualTemplateInvocationTest;
+import org.eclipse.acceleo.engine.tests.unit.engine.AcceleoGenericEngineTest;
+import org.eclipse.acceleo.engine.tests.unit.environment.AcceleoNonStandardLibraryTest;
+import org.eclipse.acceleo.engine.tests.unit.environment.AcceleoStandardLibraryTest;
+import org.eclipse.acceleo.engine.tests.unit.resolution.namesake.NamesakeGuardResolutionTest;
+import org.eclipse.acceleo.engine.tests.unit.resolution.namesake.ParameterTypeNarrowingResolutionTest;
+import org.eclipse.acceleo.engine.tests.unit.resolution.namesake.SimpleNamesakeResolutionTest;
+import org.eclipse.acceleo.engine.tests.unit.resolution.override.OverrideGuardResolutionTest;
+import org.eclipse.acceleo.engine.tests.unit.resolution.override.OverrideParameterTypeNarrowingResolutionTest;
+import org.eclipse.acceleo.engine.tests.unit.resolution.override.SimpleOverridesResolutionTest;
+import org.eclipse.acceleo.engine.tests.unit.utils.AcceleoEnginePluginTest;
+import org.eclipse.acceleo.engine.tests.unit.utils.MessagesTest;
+import org.eclipse.acceleo.engine.tests.unit.variables.SelfTest;
+
+/**
+ * This suite will launch all the tests defined for the Acceleo engine.
+ *
+ * @author <a href="mailto:laurent.goubet@obeo.fr">Laurent Goubet</a>
+ */
+public class AllTests extends TestCase {
+ /**
+ * Launches the test with the given arguments.
+ *
+ * @param args
+ * Arguments of the testCase.
+ */
+ public static void main(String[] args) {
+ TestRunner.run(suite());
+ }
+
+ /**
+ * Creates the {@link junit.framework.TestSuite TestSuite} for all the test.
+ *
+ * @return The test suite containing all the tests
+ */
+ public static Test suite() {
+ final TestSuite suite = new TestSuite("Acceleo engine test suite"); //$NON-NLS-1$
+
+ // Blocks
+ suite.addTestSuite(ForBlockTest.class);
+ suite.addTestSuite(IfBlockTest.class);
+ suite.addTestSuite(ProtectedAreaBlockTest.class);
+ suite.addTestSuite(TemplateTest.class);
+ suite.addTestSuite(DualTemplateInvocationTest.class);
+
+ // Engine
+ suite.addTestSuite(AcceleoGenericEngineTest.class);
+
+ // Listeners
+ //FIXME LGO suite.addTestSuite(AcceleoListenersTest.class);
+
+ // Namesakes
+ suite.addTestSuite(SimpleNamesakeResolutionTest.class);
+ suite.addTestSuite(ParameterTypeNarrowingResolutionTest.class);
+ suite.addTestSuite(NamesakeGuardResolutionTest.class);
+
+ // overrides
+ suite.addTestSuite(SimpleOverridesResolutionTest.class);
+ suite.addTestSuite(OverrideParameterTypeNarrowingResolutionTest.class);
+ suite.addTestSuite(OverrideGuardResolutionTest.class);
+
+ // variables
+ suite.addTestSuite(SelfTest.class);
+
+ // utilities
+ suite.addTestSuite(MessagesTest.class);
+ suite.addTestSuite(AcceleoEnginePluginTest.class);
+
+ // operation libraries
+ suite.addTestSuite(AcceleoStandardLibraryTest.class);
+ suite.addTestSuite(AcceleoNonStandardLibraryTest.class);
+
+ return suite;
+ }
+}
diff --git a/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/AbstractAcceleoTest.java b/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/AbstractAcceleoTest.java
new file mode 100644
index 0000000..b8be8fb
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/AbstractAcceleoTest.java
@@ -0,0 +1,374 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.acceleo.engine.tests.unit;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+
+import junit.framework.Assert;
+import junit.framework.AssertionFailedError;
+import junit.framework.TestCase;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+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.acceleo.model.mtl.Module;
+import org.eclipse.acceleo.common.utils.ModelUtils;
+import org.eclipse.acceleo.engine.tests.AcceleoEngineTestPlugin;
+import org.eclipse.acceleo.parser.AcceleoParser;
+import org.eclipse.acceleo.parser.AcceleoSourceBuffer;
+import org.osgi.framework.Bundle;
+
+/**
+ * Abstract class for Acceleo Engine unit tests.
+ *
+ * @author <a href="mailto:freddy.allilaire@obeo.fr">Freddy Allilaire</a>
+ */
+public abstract class AbstractAcceleoTest extends TestCase {
+ /**
+ * EMTL extension.
+ */
+ protected static final String EMTL_EXTENSION = "emtl"; //$NON-NLS-1$
+
+ /**
+ * Location of the target model. Clients can load a distinct model in their tests' default constructor if
+ * needed.
+ */
+ private static final String DEFAULT_MODEL_LOCATION = "data/target.ecore"; //$NON-NLS-1$
+
+ /**
+ * Plugin bundle.
+ */
+ protected final Bundle bundle = Platform.getBundle(AcceleoEngineTestPlugin.PLUGIN_ID);
+
+ /**
+ * Error message to report if compareDirectories method fails.
+ */
+ protected String errorMessageForCompareDirectoriesMethod = "I/O exception while comparing reference and generated directories"; //$NON-NLS-1$
+
+ /**
+ * File of the generation root.
+ */
+ protected File generationRoot;
+
+ /** This is the input model as loaded from initializer. */
+ protected EObject inputModel;
+
+ /** This is the module loaded from {@link #moduleLocation} at setup. */
+ protected Module module;
+
+ /**
+ * Acceleo Engine Plugin Test root URL.
+ */
+ protected final URL pluginRoot = bundle.getEntry("/"); //$NON-NLS-1$
+
+ /**
+ * File of the reference root.
+ */
+ protected File referenceRoot;
+
+ /**
+ * Path of the reference root.
+ */
+ protected String referenceRootPath;
+
+ /** Resource set we'll use throughout the test sub-classes. */
+ protected final ResourceSet resourceSet = new ResourceSetImpl();
+
+ {
+ try {
+ final URI inputModelURI = URI.createPlatformPluginURI('/' + AcceleoEngineTestPlugin.PLUGIN_ID + '/'
+ + DEFAULT_MODEL_LOCATION, true);
+ inputModel = ModelUtils.load(inputModelURI, resourceSet);
+ } catch (IOException e) {
+ fail("Error loading the input model."); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * A tool method to get the content of the file specified by its absolute path.
+ *
+ * @param fileName
+ * the absolute path of the file
+ * @return the content of the file
+ * @throws IOException
+ * if I/O error occurs
+ */
+ protected static String getAbsoluteFileContent(String fileName) throws IOException {
+ String ret = ""; //$NON-NLS-1$
+ FileInputStream is = new FileInputStream(fileName);
+ int length = 0;
+ final int bufferSize = 512;
+ byte[] buffer = new byte[bufferSize];
+ while ((length = is.read(buffer)) > 0) {
+ ret += new String(buffer, 0, length);
+ }
+ return ret;
+ }
+
+ /**
+ * Returns the location of the module on which tests templates will be called.
+ *
+ * @return Location of the test module.
+ */
+ public abstract String getModuleLocation();
+
+ /**
+ * This must be overriden to return the save location for the test reference and generation results.
+ *
+ * @return Save location of the results.
+ */
+ public abstract String getResultPath();
+
+ /**
+ * This should be called by each test to empty its target generation root prior to the test.
+ */
+ protected void cleanGenerationRoot() {
+ if (generationRoot.isDirectory()) {
+ final File[] children = getFiles(generationRoot);
+ for (File child : children) {
+ deleteFile(child);
+ }
+ }
+ }
+
+ /**
+ * Return the files contained by <code>directory</code>, not including VCS directories.
+ *
+ * @param directory
+ * The directory we seek children of.
+ * @return All children of the given directory that do not correspond to VCS directories.
+ */
+ protected File[] getFiles(File directory) {
+ if (!directory.exists()) {
+ return new File[0];
+ }
+ File[] children = directory.listFiles(new FileFilter() {
+ public boolean accept(File pathname) {
+ if (!pathname.getAbsolutePath().matches("^.*(CVS|\\\\.svn)$")) { //$NON-NLS-1$
+ return true;
+ }
+ return false;
+ }
+ });
+ return children;
+ }
+
+ /**
+ * Compare two directories.
+ *
+ * @param refDir
+ * reference directory containing reference results
+ * @param genDir
+ * generation directory
+ * @throws IOException
+ * if I/O error occurs
+ */
+ protected void compareDirectories(File refDir, File genDir) throws IOException {
+ boolean compared = false;
+
+ // Does not accept directories named ".svn" or "CVS"
+ File[] children = getFiles(refDir);
+
+ if (children != null) {
+ for (File child : children) {
+ String dir2fileName = genDir.getAbsolutePath() + File.separator + child.getName();
+ if (child.isDirectory()) {
+ compareDirectories(child, new File(dir2fileName));
+ } else if (child.getName().endsWith(".lost")) { //$NON-NLS-1$
+ assertEquals(dir2fileName, deleteWhitespaces(removeTimeStamp(getAbsoluteFileContent(child
+ .getAbsolutePath()))),
+ deleteWhitespaces(removeTimeStamp(getAbsoluteFileContent(dir2fileName))));
+ } else {
+ assertEquals(dir2fileName, deleteWhitespaces(getAbsoluteFileContent(child
+ .getAbsolutePath())), deleteWhitespaces(getAbsoluteFileContent(dir2fileName)));
+ compared = true;
+ }
+ }
+ }
+ if (!compared) {
+ fail("Couldn't compare the reference at " + refDir.getAbsolutePath() + " for result " //$NON-NLS-1$ //$NON-NLS-2$
+ + genDir.getAbsolutePath());
+ }
+ }
+
+ /**
+ * Removes the time stamp inserted at the beginning of lost files.
+ *
+ * @param text
+ * lost file content.
+ */
+ private String removeTimeStamp(String text) {
+ if (text.contains("===============================================================")) { //$NON-NLS-1$
+ return text.replaceAll(".*?(\\n|\\r|\\r\\n)={10,}(\\n|\\r|\\r\\n)(?s)(.*)", "$1"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return text;
+ }
+
+ /**
+ * Deletes all white spaces of the given string.
+ *
+ * @param text
+ * is the text
+ * @return the text without white spaces
+ */
+ private String deleteWhitespaces(String text) {
+ StringBuilder result = new StringBuilder();
+ for (int i = 0; i < text.length(); i++) {
+ char c = text.charAt(i);
+ if (!Character.isWhitespace(c)) {
+ result.append(c);
+ }
+ }
+ return result.toString();
+ }
+
+ /**
+ * Creates a File from a file path.
+ *
+ * @param pathName
+ * is the path of the file
+ * @return a File from a file path
+ */
+ protected File createFile(String pathName) {
+ try {
+ String fileLocation = FileLocator.resolve(bundle.getEntry(pathName)).getPath();
+ return new File(fileLocation);
+ } catch (IOException e) {
+ throw new AssertionFailedError(e.getMessage());
+ }
+ }
+
+ /**
+ * Creates an URI from a file path.
+ *
+ * @param pathName
+ * is the path of the file
+ * @return an URI from a file path
+ */
+ protected URI createFileURI(String pathName) {
+ try {
+ String fileLocation = FileLocator.resolve(bundle.getEntry(pathName)).getPath();
+ return URI.createFileURI(fileLocation);
+ } catch (IOException e) {
+ throw new AssertionFailedError(e.getMessage());
+ }
+ }
+
+ /**
+ * Returns generation root path.
+ *
+ * @param unitTestName
+ * is the name of current unit test
+ * @return generation root path
+ * @throws IOException
+ * if I/O error occurs
+ */
+ protected String getGenerationRootPath(String unitTestName) throws IOException {
+ return FileLocator.resolve(pluginRoot).getFile() + "/src-gen/" + getResultPath() + "/GenerationTest/" //$NON-NLS-1$ //$NON-NLS-2$
+ + unitTestName;
+ }
+
+ /**
+ * Returns reference root path.
+ *
+ * @param unitTestName
+ * is the name of current unit test
+ * @return reference root path
+ * @throws IOException
+ * if I/O error occurs
+ */
+ protected String getReferenceRootPath(String unitTestName) throws IOException {
+ return FileLocator.resolve(pluginRoot).getFile() + "/src-gen/" //$NON-NLS-1$
+ + getResultPath() + "/ReferenceResult/" + unitTestName; //$NON-NLS-1$
+ }
+
+ /**
+ * This methods parses an Acceleo file and creates a model representation of it (.emtl).
+ *
+ * @param mtlPath
+ * is the path of Acceleo file
+ * @param resourceSet
+ * is the resourceSet
+ * @return a model representation of Acceleo file
+ */
+ protected Resource parse(String mtlPath) {
+ File file = createFile(mtlPath);
+ AcceleoSourceBuffer source = new AcceleoSourceBuffer(file);
+
+ final URI moduleURI = URI.createPlatformPluginURI('/' + AcceleoEngineTestPlugin.PLUGIN_ID + '/'
+ + (new Path(mtlPath)).removeFileExtension().addFileExtension(EMTL_EXTENSION), true);
+
+ Resource modelResource = ModelUtils.createResource(moduleURI, resourceSet);
+ AcceleoParser parser = new AcceleoParser();
+ assertNull(parser.getProblems(file));
+ parser.parse(source, modelResource, new ArrayList<URI>());
+ return modelResource;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ Resource modelResource = parse(getModuleLocation());
+ EObject rootTemplate = modelResource.getContents().get(0);
+ if (rootTemplate instanceof Module) {
+ module = (Module)rootTemplate;
+ } else {
+ Assert.fail("Couldn't load the input template."); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+
+ // Unload all but the input model
+ for (Resource resource : resourceSet.getResources()) {
+ if (resource != inputModel.eResource()) {
+ resource.unload();
+ }
+ }
+ }
+
+ /**
+ * Deletes the given {@link File}. If <code>file</code> is a directory, it will also recursively delete
+ * all of its content prior to deletion.
+ *
+ * @param file
+ * The file that is to be deleted.
+ */
+ private void deleteFile(File file) {
+ if (file.isDirectory()) {
+ final File[] children = getFiles(file);
+ for (File child : children) {
+ deleteFile(child);
+ }
+ } else {
+ file.delete();
+ }
+ }
+}
diff --git a/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/blocks/forBlock/ForBlockTest.java b/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/blocks/forBlock/ForBlockTest.java
new file mode 100644
index 0000000..d90b830
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/blocks/forBlock/ForBlockTest.java
@@ -0,0 +1,144 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.acceleo.engine.tests.unit.blocks.forBlock;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.eclipse.acceleo.engine.service.AcceleoService;
+import org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest;
+
+/**
+ * Class to test For block.
+ *
+ * @author <a href="mailto:freddy.allilaire@obeo.fr">Freddy Allilaire</a>
+ */
+public class ForBlockTest extends AbstractAcceleoTest {
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest#getModuleLocation()
+ */
+ @Override
+ public String getModuleLocation() {
+ return "data/ForBlock/template_for.mtl"; //$NON-NLS-1$
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest#getResultPath()
+ */
+ @Override
+ public String getResultPath() {
+ return "ForBlock"; //$NON-NLS-1$
+ }
+
+ /**
+ * Test For statement with After keyword.
+ *
+ * @throws IOException
+ * Thrown when the output cannot be saved.
+ */
+ public void testForStatementAfterKeyword() throws IOException {
+ generationRoot = new File(getGenerationRootPath("AfterKeyword")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("AfterKeyword")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module, "testingAfter", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+ }
+
+ /**
+ * Test For statement with basic example.
+ *
+ * @throws IOException
+ * Thrown when the output cannot be saved.
+ */
+ public void testForStatementBasicExample() throws IOException {
+ generationRoot = new File(getGenerationRootPath("BasicExample")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("BasicExample")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module, "testingSimple", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+ }
+
+ /**
+ * Test For statement with Before keyword.
+ *
+ * @throws IOException
+ * Thrown when the output cannot be saved.
+ */
+ public void testForStatementBeforeKeyword() throws IOException {
+ generationRoot = new File(getGenerationRootPath("BeforeKeyword")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("BeforeKeyword")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module, "testingBefore", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+ }
+
+ /**
+ * Test For statement with Guard keyword.
+ *
+ * @throws IOException
+ * Thrown when the output cannot be saved.
+ */
+ public void testForStatementGuardKeyword() throws IOException {
+ generationRoot = new File(getGenerationRootPath("GuardKeyword")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("GuardKeyword")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module, "testingGuard", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+ }
+
+ /**
+ * Test For statement with Separator keyword.
+ *
+ * @throws IOException
+ * Thrown when the output cannot be saved.
+ */
+ public void testForStatementSeparatorKeyword() throws IOException {
+ generationRoot = new File(getGenerationRootPath("SeparatorKeyword")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("SeparatorKeyword")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module, "testingSeparator", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+ }
+}
diff --git a/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/blocks/ifBlock/IfBlockTest.java b/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/blocks/ifBlock/IfBlockTest.java
new file mode 100644
index 0000000..961ce9d
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/blocks/ifBlock/IfBlockTest.java
@@ -0,0 +1,144 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.acceleo.engine.tests.unit.blocks.ifBlock;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.eclipse.acceleo.engine.service.AcceleoService;
+import org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest;
+
+/**
+ * Class to test If block.
+ *
+ * @author <a href="mailto:freddy.allilaire@obeo.fr">Freddy Allilaire</a>
+ */
+public class IfBlockTest extends AbstractAcceleoTest {
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest#getModuleLocation()
+ */
+ @Override
+ public String getModuleLocation() {
+ return "data/IfBlock/template_if.mtl"; //$NON-NLS-1$
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest#getResultPath()
+ */
+ @Override
+ public String getResultPath() {
+ return "IfBlock"; //$NON-NLS-1$
+ }
+
+ /**
+ * Test.
+ *
+ * @throws IOException
+ * Thrown when the output cannot be saved.
+ */
+ public void testIfStatementCompleteIf() throws IOException {
+ generationRoot = new File(getGenerationRootPath("CompleteIf")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("CompleteIf")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module, "testingCompleteIf", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+ }
+
+ /**
+ * Test.
+ *
+ * @throws IOException
+ * Thrown when the output cannot be saved.
+ */
+ public void testIfStatementElse() throws IOException {
+ generationRoot = new File(getGenerationRootPath("Else")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("Else")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module, "testingElse", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+ }
+
+ /**
+ * Test.
+ *
+ * @throws IOException
+ * Thrown when the output cannot be saved.
+ */
+ public void testIfStatementElseif() throws IOException {
+ generationRoot = new File(getGenerationRootPath("Elseif")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("Elseif")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module, "testingElseif", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+ }
+
+ /**
+ * Test.
+ *
+ * @throws IOException
+ * Thrown when the output cannot be saved.
+ */
+ public void testIfStatementIf() throws IOException {
+ generationRoot = new File(getGenerationRootPath("If")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("If")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module, "testingIf", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+ }
+
+ /**
+ * Test.
+ *
+ * @throws IOException
+ * Thrown when the output cannot be saved.
+ */
+ public void testIfStatementNestedIf() throws IOException {
+ generationRoot = new File(getGenerationRootPath("NestedIf")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("NestedIf")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module, "testingNestedIf", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+ }
+}
diff --git a/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/blocks/protectedareablock/ProtectedAreaBlockTest.java b/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/blocks/protectedareablock/ProtectedAreaBlockTest.java
new file mode 100644
index 0000000..f6c011b
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/blocks/protectedareablock/ProtectedAreaBlockTest.java
@@ -0,0 +1,199 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.acceleo.engine.tests.unit.blocks.protectedareablock;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.acceleo.engine.internal.evaluation.AcceleoEvaluationContext;
+import org.eclipse.acceleo.engine.service.AcceleoService;
+import org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest;
+
+/**
+ * Class to test Protected Area block.
+ *
+ * @author <a href="mailto:freddy.allilaire@obeo.fr">Freddy Allilaire</a>
+ */
+public class ProtectedAreaBlockTest extends AbstractAcceleoTest {
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest#getModuleLocation()
+ */
+ @Override
+ public String getModuleLocation() {
+ return "data/ProtectedAreaBlock/protected_areas.mtl"; //$NON-NLS-1$
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest#getResultPath()
+ */
+ @Override
+ public String getResultPath() {
+ return "ProtectedAreaBlock"; //$NON-NLS-1$
+ }
+
+ /**
+ * Tests that the protected areas blocks are accurately generated.
+ *
+ * @throws IOException
+ * Thrown when the output cannot be saved.
+ */
+ public void testProtectedAreaBlock() throws IOException {
+ generationRoot = new File(getGenerationRootPath("Standard")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("Standard")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ // We'll only generate for a single class
+ EObject target = null;
+ for (EObject child : inputModel.eContents()) {
+ if (child instanceof EClass) {
+ target = child;
+ break;
+ }
+ }
+ assertNotNull(target);
+ final List<EObject> templateArgs = new ArrayList<EObject>(1);
+ templateArgs.add(target);
+
+ AcceleoService.doGenerateTemplate(module, "test_protected_area", templateArgs, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+
+ for (File generated : getFiles(generationRoot)) {
+ assertFalse("a lost file shouldn't have been created", generated.getName().endsWith(".lost")); //$NON-NLS-1$ //$NON-NLS-2$
+ final String content = getAbsoluteFileContent(generated.getAbsolutePath());
+ // We expect two protected areas to have been created
+ assertTrue(content.contains("user code 1")); //$NON-NLS-1$
+ assertTrue(content.contains("user code 2")); //$NON-NLS-1$
+ assertTrue(content.contains("first protected area")); //$NON-NLS-1$
+ assertTrue(content.contains("second protected area")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Tests that lost files are indeed created when a protected area no longer appears in the template.
+ *
+ * @throws IOException
+ * Thrown when the output cannot be saved.
+ */
+ public void testRemovedProtectedArea() throws IOException {
+ generationRoot = new File(getGenerationRootPath("RemovedProtectedArea")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("RemovedProtectedArea")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ // We'll only generate for a single class
+ EObject target = null;
+ for (EObject child : inputModel.eContents()) {
+ if (child instanceof EClass) {
+ target = child;
+ break;
+ }
+ }
+ assertNotNull(target);
+ final List<EObject> templateArgs = new ArrayList<EObject>(1);
+ templateArgs.add(target);
+
+ AcceleoService.doGenerateTemplate(module,
+ "test_removed_protected_area", templateArgs, generationRoot, false); //$NON-NLS-1$
+
+ try {
+ AcceleoEvaluationContext.awaitCompletion();
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod + ':' + e.getMessage());
+ } catch (InterruptedException e) {
+ fail("Lost file creator pool termination interrupted."); //$NON-NLS-1$
+ }
+
+ int lostFiles = 0;
+ for (File generated : getFiles(generationRoot)) {
+ final String content = getAbsoluteFileContent(generated.getAbsolutePath());
+ if (generated.getName().endsWith(".lost")) { //$NON-NLS-1$
+ lostFiles++;
+ // We expect a protected area to have been lost
+ assertTrue(content.contains("user code 1")); //$NON-NLS-1$
+ assertTrue(content.contains("first protected area")); //$NON-NLS-1$
+ } else {
+ // We expect a single protected areas to have been created
+ assertTrue(content.contains("user code 2")); //$NON-NLS-1$
+ assertTrue(content.contains("second protected area")); //$NON-NLS-1$
+ }
+ }
+ assertEquals("There should have been a lost file created", 1, lostFiles); //$NON-NLS-1$
+ }
+
+ /**
+ * Tests that lost files are indeed created when a protected area changes its id.
+ *
+ * @throws IOException
+ * Thrown when the output cannot be saved.
+ */
+ public void testLostProtectedArea() throws IOException {
+ generationRoot = new File(getGenerationRootPath("LostProtectedArea")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("LostProtectedArea")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ // We'll only generate for a single class
+ EObject target = null;
+ for (EObject child : inputModel.eContents()) {
+ if (child instanceof EClass) {
+ target = child;
+ break;
+ }
+ }
+ assertNotNull(target);
+ final List<EObject> templateArgs = new ArrayList<EObject>(1);
+ templateArgs.add(target);
+
+ AcceleoService
+ .doGenerateTemplate(module, "test_lost_protected_area", templateArgs, generationRoot, false); //$NON-NLS-1$
+
+ try {
+ AcceleoEvaluationContext.awaitCompletion();
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod + ':' + e.getMessage());
+ } catch (InterruptedException e) {
+ fail("Lost file creator pool termination interrupted."); //$NON-NLS-1$
+ }
+
+ int lostFiles = 0;
+ for (File generated : getFiles(generationRoot)) {
+ final String content = getAbsoluteFileContent(generated.getAbsolutePath());
+ if (generated.getName().endsWith(".lost")) { //$NON-NLS-1$
+ lostFiles++;
+ // We expect a protected area to have been lost
+ assertTrue(content.contains("user code 1")); //$NON-NLS-1$
+ assertTrue(content.contains("first protected area")); //$NON-NLS-1$
+ } else {
+ // We expect two protected areas to have been created
+ assertTrue(content.contains("user code 2")); //$NON-NLS-1$
+ assertTrue(content.contains("second protected area")); //$NON-NLS-1$
+ assertTrue(content.contains("user code 3")); //$NON-NLS-1$
+ assertTrue(content.contains("third protected area")); //$NON-NLS-1$
+ }
+ }
+ assertEquals("There should have been a lost file created", 1, lostFiles); //$NON-NLS-1$
+ }
+}
diff --git a/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/blocks/template/TemplateTest.java b/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/blocks/template/TemplateTest.java
new file mode 100644
index 0000000..48ff26c
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/blocks/template/TemplateTest.java
@@ -0,0 +1,284 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.acceleo.engine.tests.unit.blocks.template;
+
+import java.io.File;
+import java.io.IOException;
+
+import junit.framework.Assert;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.acceleo.model.mtl.Module;
+import org.eclipse.acceleo.common.utils.ModelUtils;
+import org.eclipse.acceleo.engine.service.AcceleoService;
+import org.eclipse.acceleo.engine.tests.AcceleoEngineTestPlugin;
+import org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest;
+
+/**
+ * This will test the behavior of the Acceleo engine on all aspects of the "template" Acceleo block. This includes
+ * template invocation specific features such as "before" and "after".
+ *
+ * @author <a href="mailto:laurent.goubet@obeo.fr">Laurent Goubet</a>
+ */
+public class TemplateTest extends AbstractAcceleoTest {
+ {
+ try {
+ final URI inputModelURI = URI.createPlatformPluginURI('/' + AcceleoEngineTestPlugin.PLUGIN_ID + '/'
+ + "data/abstractClass.ecore", true); //$NON-NLS-1$
+ inputModel = ModelUtils.load(inputModelURI, resourceSet);
+ } catch (IOException e) {
+ fail("Error loading the input model."); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest#getModuleLocation()
+ */
+ @Override
+ public String getModuleLocation() {
+ // useless for this test as we won't call super#setup()
+ return ""; //$NON-NLS-1$
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest#getResultPath()
+ */
+ @Override
+ public String getResultPath() {
+ return "Template"; //$NON-NLS-1$
+ }
+
+ /**
+ * Tests the "super" call of an overriding template.
+ */
+ public void testSuperCall() throws IOException {
+ generationRoot = new File(getGenerationRootPath("Super")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("Super")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module, "test_super", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+
+ for (File generated : getFiles(generationRoot)) {
+ final String content = getAbsoluteFileContent(generated.getAbsolutePath());
+ assertTrue(content.contains("overriding call to")); //$NON-NLS-1$
+ assertTrue(content.contains("extended.super_extended_template")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Tests calls to a local protected template.
+ */
+ public void testProtectedCall() throws IOException {
+ generationRoot = new File(getGenerationRootPath("ProtectedVisibility")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("ProtectedVisibility")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module, "test_protected_visibility", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+
+ for (File generated : getFiles(generationRoot)) {
+ final String content = getAbsoluteFileContent(generated.getAbsolutePath());
+ assertTrue(content.contains("local.protected_overriding_template")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Tests calls to a local private template.
+ */
+ public void testPrivateCall() throws IOException {
+ generationRoot = new File(getGenerationRootPath("PrivateVisibility")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("PrivateVisibility")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module, "test_private_visibility", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+
+ for (File generated : getFiles(generationRoot)) {
+ final String content = getAbsoluteFileContent(generated.getAbsolutePath());
+ assertTrue(content.contains("local.private_local_template")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Tests the effect of the "before" attribute of a template invocation.
+ */
+ public void testBefore() throws IOException {
+ generationRoot = new File(getGenerationRootPath("Before")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("Before")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module, "test_before", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+
+ for (File generated : getFiles(generationRoot)) {
+ final String content = getAbsoluteFileContent(generated.getAbsolutePath());
+ assertTrue(content.contains("before")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Tests the effect of the "after" attribute of a template invocation.
+ */
+ public void testAfter() throws IOException {
+ generationRoot = new File(getGenerationRootPath("After")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("After")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module, "test_after", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+
+ for (File generated : getFiles(generationRoot)) {
+ final String content = getAbsoluteFileContent(generated.getAbsolutePath());
+ assertTrue(content.contains("after")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Tests the behavior of a template call when calling a template which guard evaluates to false.
+ */
+ public void testFalseGuard() throws IOException {
+ generationRoot = new File(getGenerationRootPath("FalseGuard")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("FalseGuard")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module, "test_false_guard", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+
+ for (File generated : getFiles(generationRoot)) {
+ final String content = getAbsoluteFileContent(generated.getAbsolutePath());
+ assertTrue(content.trim().length() == 0);
+ }
+ }
+
+ /**
+ * Tests the behavior of a template call when calling a template which guard evaluates to true.
+ */
+ public void testTrueGuard() throws IOException {
+ generationRoot = new File(getGenerationRootPath("TrueGuard")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("TrueGuard")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module, "test_true_guard", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+
+ for (File generated : getFiles(generationRoot)) {
+ final String content = getAbsoluteFileContent(generated.getAbsolutePath());
+ assertTrue(content.contains("local.true_guard_template")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Tests the behavior of a template call when calling a template overriding a protected one.
+ */
+ public void testProtectOverride() throws IOException {
+ generationRoot = new File(getGenerationRootPath("ProtectOverride")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("ProtectOverride")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module, "test_protect_override", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+
+ for (File generated : getFiles(generationRoot)) {
+ final String content = getAbsoluteFileContent(generated.getAbsolutePath());
+ assertTrue(content.contains("local.protected_overriding_template")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Tests the behavior of the engine when calling a template imported from an extended module.
+ */
+ public void testImport() throws IOException {
+ generationRoot = new File(getGenerationRootPath("Import")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("Import")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module, "test_import", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+
+ for (File generated : getFiles(generationRoot)) {
+ final String content = getAbsoluteFileContent(generated.getAbsolutePath());
+ assertTrue(content.contains("extended.imported_template")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest#setUp()
+ */
+ @Override
+ protected void setUp() throws Exception {
+ String localTemplateLocation = "data/Template/local.mtl"; //$NON-NLS-1$
+ String extendedTemplateLocation = "data/Template/extended.mtl"; //$NON-NLS-1$
+
+ parse(extendedTemplateLocation);
+ Resource localResource = parse(localTemplateLocation);
+
+ EObject rootTemplate = localResource.getContents().get(0);
+ if (rootTemplate instanceof Module) {
+ module = (Module)rootTemplate;
+ } else {
+ Assert.fail("Failed to parse the templates."); //$NON-NLS-1$
+ }
+ }
+}
diff --git a/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/blocks/templateinvocation/DualTemplateInvocationTest.java b/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/blocks/templateinvocation/DualTemplateInvocationTest.java
new file mode 100644
index 0000000..6a7db61
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/blocks/templateinvocation/DualTemplateInvocationTest.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.acceleo.engine.tests.unit.blocks.templateinvocation;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.eclipse.acceleo.engine.service.AcceleoService;
+import org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest;
+
+/**
+ * Tests the behavior of template invocations.
+ *
+ * @author <a href="mailto:laurent.goubet@obeo.fr">Laurent Goubet</a>
+ */
+public class DualTemplateInvocationTest extends AbstractAcceleoTest {
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest#getModuleLocation()
+ */
+ @Override
+ public String getModuleLocation() {
+ return "data/TemplateInvocation/dual_template_call.mtl"; //$NON-NLS-1$
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest#getResultPath()
+ */
+ @Override
+ public String getResultPath() {
+ return "TemplateInvocation"; //$NON-NLS-1$
+ }
+
+ /**
+ * Tests that the template invocations can be used as parameters of other template invocations.
+ *
+ * @throws IOException
+ * Thrown when the output cannot be saved.
+ */
+ public void testDualTemplateInvocation() throws IOException {
+ generationRoot = new File(getGenerationRootPath("DualTemplateInvocation")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("DualTemplateInvocation")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module, "test", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+
+ for (File generated : getFiles(generationRoot)) {
+ final String content = getAbsoluteFileContent(generated.getAbsolutePath());
+ // We expect two protected areas to have been created
+ assertTrue(content.contains("AbstractClasS")); //$NON-NLS-1$
+ }
+ }
+}
diff --git a/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/engine/AcceleoGenericEngineTest.java b/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/engine/AcceleoGenericEngineTest.java
new file mode 100644
index 0000000..2353266
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/engine/AcceleoGenericEngineTest.java
@@ -0,0 +1,395 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.acceleo.engine.tests.unit.engine;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.acceleo.model.mtl.ModuleElement;
+import org.eclipse.acceleo.model.mtl.Template;
+import org.eclipse.acceleo.model.mtl.VisibilityKind;
+import org.eclipse.acceleo.common.utils.ModelUtils;
+import org.eclipse.acceleo.engine.AcceleoEvaluationException;
+import org.eclipse.acceleo.engine.generation.AcceleoGenericEngine;
+import org.eclipse.acceleo.engine.tests.AcceleoEngineTestPlugin;
+import org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest;
+
+/**
+ * This will be used to test the behavior of the generic Acceleo engine.
+ *
+ * @author <a href="mailto:laurent.goubet@obeo.fr">Laurent Goubet</a>
+ */
+@SuppressWarnings("nls")
+public class AcceleoGenericEngineTest extends AbstractAcceleoTest {
+ /** Error message displayed for test failure when expected AcceleoEvaluationExceptions aren't thrown. */
+ private static final String EVALUATION_EXCEPTION_FAILURE = "Expected AcceleoEvaluationException hasn't been thrown by the evaluation engine.";
+
+ /** Error message displayed for test failure when expected NPEs aren't thrown. */
+ private static final String NPE_FAILURE = "Expected NullPointerException hasn't been thrown by the evaluation engine.";
+
+ /** List of invalid arguments for the template call. */
+ private List<Object> invalidArguments = new ArrayList<Object>();
+
+ /** The template that is to be called for tests on a private one. */
+ private Template privateTemplate;
+
+ /** The template that is to be called for tests on a public, guarded template (guard evaluates to false). */
+ private Template publicGuardedTemplate;
+
+ /** The template that is to be called for tests on a public one. */
+ private Template publicTemplate;
+
+ /** List of valid arguments for the template call. */
+ private List<Object> validArguments = new ArrayList<Object>();
+
+ /** This initializer allows us to initialize all required input. */
+ {
+ try {
+ final URI inputModelURI = URI.createPlatformPluginURI('/' + AcceleoEngineTestPlugin.PLUGIN_ID + '/'
+ + "data/abstractClass.ecore", true);
+ inputModel = ModelUtils.load(inputModelURI, resourceSet);
+ } catch (IOException e) {
+ fail("Error loading the input model.");
+ }
+ validArguments.add(inputModel);
+ validArguments.add("aString");
+
+ invalidArguments.add(inputModel);
+ invalidArguments.add(Integer.valueOf(5));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest#getModuleLocation()
+ */
+ @Override
+ public String getModuleLocation() {
+ return "data/GenericEngine/generic_engine.mtl";
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest#getResultPath()
+ */
+ @Override
+ public String getResultPath() {
+ return "GenericEngine";
+ }
+
+ /**
+ * Tests the behavior of {@link AcceleoGenericEngine#evaluate(Template, List, File, boolean)} on a public
+ * template which guard evaluates to false.
+ * <p>
+ * Whatever the arguments (when falling in "valid" categories as tested otherwise for NPEs), expects the
+ * evaluation not to generate a single file and the evaluation preview to be empty.
+ * </p>
+ *
+ * @throws IOException
+ * Thrown if the evaluation fails unexpectedly.
+ */
+ public void testEvaluateGuardedTemplate() throws IOException {
+ generationRoot = new File(getGenerationRootPath("GuardedTemplate"));
+
+ // preview mode
+ Map<String, StringWriter> previewMode = new AcceleoGenericEngine().evaluate(publicGuardedTemplate,
+ validArguments, generationRoot, true);
+
+ assertTrue("Preview map should have been empty", previewMode.isEmpty());
+ assertSame("There shouldn't have been generated files", 0, getFiles(generationRoot).length);
+
+ // generation mode
+ Map<String, StringWriter> generationMode = new AcceleoGenericEngine().evaluate(publicGuardedTemplate,
+ validArguments, generationRoot, false);
+
+ assertTrue("Preview map should have been empty", generationMode.isEmpty());
+ assertSame("There shouldn't have been generated files", 0, getFiles(generationRoot).length);
+ }
+
+ /**
+ * Tests the behavior of {@link AcceleoGenericEngine#evaluate(Template, List, File, boolean)} with a
+ * <code>null</code> list of arguments.
+ * <p>
+ * Expects a NullPointerException to be thrown.
+ * </p>
+ *
+ * @throws IOException
+ * Thrown if the evaluation fails unexpectedly.
+ */
+ public void testEvaluateNullArgs() throws IOException {
+ generationRoot = new File(getGenerationRootPath("InvalidNullArgs"));
+ try {
+ new AcceleoGenericEngine().evaluate(publicTemplate, null, generationRoot, true);
+ fail(NPE_FAILURE);
+ } catch (NullPointerException e) {
+ // expected behavior
+ }
+ try {
+ new AcceleoGenericEngine().evaluate(privateTemplate, null, generationRoot, false);
+ fail(NPE_FAILURE);
+ } catch (NullPointerException e) {
+ // expected behavior
+ }
+ }
+
+ /**
+ * Tests the behavior of {@link AcceleoGenericEngine#evaluate(Template, List, File, boolean)} with a
+ * <code>null</code> generationRoot and not in preview mode.
+ * <p>
+ * Expects a NullPointerException to be thrown.
+ * </p>
+ *
+ * @throws IOException
+ * Thrown if the evaluation fails unexpectedly.
+ */
+ public void testEvaluateNullRootNoPreview() throws IOException {
+ try {
+ new AcceleoGenericEngine().evaluate(publicTemplate, validArguments, null, false);
+ fail(NPE_FAILURE);
+ } catch (NullPointerException e) {
+ // expected behavior
+ }
+ try {
+ new AcceleoGenericEngine().evaluate(privateTemplate, invalidArguments, null, false);
+ fail(NPE_FAILURE);
+ } catch (NullPointerException e) {
+ // expected behavior
+ }
+ }
+
+ /**
+ * Tests the behavior of {@link AcceleoGenericEngine#evaluate(Template, List, File, boolean)} with a
+ * <code>null</code> template.
+ * <p>
+ * Expects a NullPointerException to be thrown.
+ * </p>
+ *
+ * @throws IOException
+ * Thrown if the evaluation fails unexpectedly.
+ */
+ public void testEvaluateNullTemplate() throws IOException {
+ generationRoot = new File(getGenerationRootPath("InvalidNullTemplate"));
+ try {
+ new AcceleoGenericEngine().evaluate(null, validArguments, generationRoot, true);
+ fail(NPE_FAILURE);
+ } catch (NullPointerException e) {
+ // expected behavior
+ }
+ try {
+ new AcceleoGenericEngine().evaluate(null, invalidArguments, generationRoot, false);
+ fail(NPE_FAILURE);
+ } catch (NullPointerException e) {
+ // expected behavior
+ }
+ }
+
+ /**
+ * Tests the behavior of {@link AcceleoGenericEngine#evaluate(Template, List, File, boolean)} on a private
+ * template. Regardless of the arguments (when falling in "valid" categories as tested otherwise for
+ * NPEs), we expect an {@link AcceleoEvaluationException} to be thrown.
+ *
+ * @throws IOException
+ * Thrown if the evaluation fails unexpectedly.
+ */
+ public void testEvaluatePrivateTemplate() throws IOException {
+ generationRoot = new File(getGenerationRootPath("PrivateTemplate"));
+ try {
+ new AcceleoGenericEngine().evaluate(privateTemplate, validArguments, generationRoot, false);
+ fail(EVALUATION_EXCEPTION_FAILURE);
+ } catch (AcceleoEvaluationException e) {
+ // Expected behavior
+ }
+ try {
+ new AcceleoGenericEngine().evaluate(privateTemplate, validArguments, generationRoot, true);
+ fail(EVALUATION_EXCEPTION_FAILURE);
+ } catch (AcceleoEvaluationException e) {
+ // Expected behavior
+ }
+ }
+
+ /**
+ * Tests the behavior of {@link AcceleoGenericEngine#evaluate(Template, List, File, boolean)} on a valid
+ * template with mismatching arguments.
+ * <p>
+ * Expects an {@link AcceleoEvaluationException} to be thrown.
+ * </p>
+ *
+ * @throws IOException
+ * Thrown if the evaluation fails unexpectedly.
+ */
+ public void testEvaluatePublicTemplateMismatchingArgs() throws IOException {
+ generationRoot = new File(getGenerationRootPath("MismatchingArgs"));
+ try {
+ new AcceleoGenericEngine().evaluate(publicTemplate, invalidArguments, generationRoot, false);
+ fail(EVALUATION_EXCEPTION_FAILURE);
+ } catch (AcceleoEvaluationException e) {
+ // Expected behavior
+ }
+ try {
+ new AcceleoGenericEngine().evaluate(publicTemplate, invalidArguments, generationRoot, true);
+ fail(EVALUATION_EXCEPTION_FAILURE);
+ } catch (AcceleoEvaluationException e) {
+ // Expected behavior
+ }
+ }
+
+ /**
+ * Tests the behavior of {@link AcceleoGenericEngine#evaluate(Template, List, File, boolean)} with a valid
+ * generationRoot when not in preview mode. Valid arguments are passed to the engine and a public template
+ * is called.
+ * <p>
+ * Expects the generation to run accurately and create the reference file.
+ * </p>
+ *
+ * @throws IOException
+ * Thrown if the evaluation fails unexpectedly.
+ */
+ public void testEvaluatePublicTemplateValidArgs() throws IOException {
+ generationRoot = new File(getGenerationRootPath("PublicTemplateValidArgs"));
+ referenceRoot = new File(getReferenceRootPath("PublicTemplateValidArgs"));
+
+ cleanGenerationRoot();
+
+ Map<String, StringWriter> preview = new AcceleoGenericEngine().evaluate(publicTemplate, validArguments,
+ generationRoot, false);
+
+ assertTrue("Preview map should have been empty", preview.isEmpty());
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+
+ for (File generated : getFiles(generationRoot)) {
+ final String content = getAbsoluteFileContent(generated.getAbsolutePath());
+ assertTrue(content.contains("constant output")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Tests the behavior of {@link AcceleoGenericEngine#evaluate(Template, List, File, boolean)} with a
+ * <code>null</code> generationRoot in preview mode. Valid arguments are passed to the engine and a public
+ * template is called.
+ * <p>
+ * Expects the generation to run accurately and return the generation preview.
+ * </p>
+ *
+ * @throws IOException
+ * Thrown if the evaluation fails unexpectedly.
+ */
+ public void testEvaluatePublicTemplateValidArgsNullRootPreview() throws IOException {
+ generationRoot = new File(getGenerationRootPath("PublicTemplateValidArgsNullRootPreview"));
+
+ Map<String, StringWriter> preview = new AcceleoGenericEngine().evaluate(publicTemplate, validArguments,
+ null, true);
+
+ assertFalse("Preview map was empty", preview.isEmpty());
+ assertSame("There should have been a single result for preview", 1, preview.size());
+ assertSame("There shouldn't have been generated files", 0, getFiles(generationRoot).length);
+
+ Entry<String, StringWriter> entry = preview.entrySet().iterator().next();
+ assertEquals("Preview didn't contain the accurate file preview.", "test_generic_engine", entry
+ .getKey());
+ assertTrue("Preview didn't contain the accurate output.", entry.getValue().getBuffer().toString()
+ .contains("constant output"));
+ }
+
+ /**
+ * Tests the behavior of {@link AcceleoGenericEngine#evaluate(Template, List, File, boolean)} with a valid
+ * generationRoot in preview mode. Valid arguments are passed to the engine and a public template is
+ * called.
+ * <p>
+ * Expects the generation to run accurately and create the accurate preview.
+ * </p>
+ *
+ * @throws IOException
+ * Thrown if the evaluation fails unexpectedly.
+ */
+ public void testEvaluatePublicTemplateValidArgsPreview() throws IOException {
+ generationRoot = new File(getGenerationRootPath("PublicTemplateValidArgsPreview"));
+
+ Map<String, StringWriter> preview = new AcceleoGenericEngine().evaluate(publicTemplate, validArguments,
+ generationRoot, true);
+
+ assertFalse("Preview map was empty", preview.isEmpty());
+ assertSame("There should have been a single result for preview", 1, preview.size());
+ assertSame("There shouldn't have been generated files", 0, getFiles(generationRoot).length);
+
+ Entry<String, StringWriter> entry = preview.entrySet().iterator().next();
+ assertEquals("Preview didn't contain the accurate file preview.", generationRoot.getPath()
+ + File.separatorChar + "test_generic_engine", entry.getKey());
+ assertTrue("Preview didn't contain the accurate output.", entry.getValue().getBuffer().toString()
+ .contains("constant output"));
+ }
+
+ /**
+ * Tests the behavior of {@link AcceleoGenericEngine#evaluate(Template, List, File, boolean)} on a valid
+ * template with a wrong number of arguments.
+ * <p>
+ * Whether we provide too many arguments or too few, expects an {@link AcceleoEvaluationException} to be
+ * thrown.
+ * </p>
+ *
+ * @throws IOException
+ * Thrown if the evaluation fails unexpectedly.
+ */
+ public void testEvaluatePublicTemplateWrongArgCount() throws IOException {
+ generationRoot = new File(getGenerationRootPath("WrongArgCount"));
+ // Too many args
+ validArguments.add(Integer.valueOf(5));
+ try {
+ new AcceleoGenericEngine().evaluate(publicTemplate, validArguments, generationRoot, false);
+ fail(EVALUATION_EXCEPTION_FAILURE);
+ } catch (AcceleoEvaluationException e) {
+ // Expected behavior
+ }
+ // Too few arguments
+ validArguments.remove(0);
+ validArguments.remove(0);
+ try {
+ new AcceleoGenericEngine().evaluate(publicTemplate, validArguments, generationRoot, true);
+ fail(EVALUATION_EXCEPTION_FAILURE);
+ } catch (AcceleoEvaluationException e) {
+ // Expected behavior
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest#setUp()
+ */
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ for (ModuleElement element : module.getOwnedModuleElement()) {
+ if (element instanceof Template) {
+ Template candidate = (Template)element;
+ if (candidate.getVisibility() == VisibilityKind.PUBLIC
+ && candidate.getName().endsWith("guard")) {
+ publicGuardedTemplate = candidate;
+ } else if (candidate.getVisibility() == VisibilityKind.PUBLIC) {
+ publicTemplate = candidate;
+ } else {
+ privateTemplate = candidate;
+ }
+ }
+ }
+ }
+}
diff --git a/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/environment/AcceleoNonStandardLibraryTest.java b/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/environment/AcceleoNonStandardLibraryTest.java
new file mode 100644
index 0000000..654e0a5
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/environment/AcceleoNonStandardLibraryTest.java
@@ -0,0 +1,658 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.acceleo.engine.tests.unit.environment;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+import org.eclipse.emf.common.util.TreeIterator;
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EGenericType;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EOperation;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.acceleo.common.utils.AcceleoNonStandardLibrary;
+import org.eclipse.acceleo.engine.event.AcceleoTextGenerationListener;
+import org.eclipse.acceleo.engine.internal.environment.AcceleoEnvironmentFactory;
+import org.eclipse.acceleo.engine.internal.environment.AcceleoEvaluationEnvironment;
+import org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest;
+import org.eclipse.ocl.ecore.OCL;
+
+/**
+ * This will test the behavior of the Acceleo non standard library's operations.
+ *
+ * @author <a href="mailto:laurent.goubet@obeo.fr">Laurent Goubet</a>
+ */
+@SuppressWarnings("nls")
+public class AcceleoNonStandardLibraryTest extends AbstractAcceleoTest {
+ /** The evaluation environment to call for non standard operations on. */
+ private AcceleoEvaluationEnvironment evaluationEnvironment;
+
+ /** EOperations defined in the non standard lib. */
+ private final Map<String, List<EOperation>> nonStdLib = new HashMap<String, List<EOperation>>();
+
+ /** Values that will be used to test non standard string operations. */
+ private final String[] stringValues = new String[] {"a", "\u00e9\u00e8\u0020\u00f1", "", "Foehn12",
+ "Standard sentence."};
+
+ {
+ AcceleoNonStandardLibrary lib = new AcceleoNonStandardLibrary();
+
+ List<EOperation> stringOperations = lib
+ .getExistingOperations(AcceleoNonStandardLibrary.PRIMITIVE_STRING_NAME);
+ List<EOperation> copyOperations = new ArrayList<EOperation>(stringOperations.size());
+ for (EOperation operation : stringOperations) {
+ copyOperations.add((EOperation)EcoreUtil.copy(operation));
+ }
+ nonStdLib.put(AcceleoNonStandardLibrary.PRIMITIVE_STRING_NAME, copyOperations);
+
+ List<EOperation> oclAnyOperations = lib.getExistingOperations(AcceleoNonStandardLibrary.TYPE_OCLANY_NAME);
+ copyOperations = new ArrayList<EOperation>(oclAnyOperations.size());
+ for (EOperation operation : oclAnyOperations) {
+ copyOperations.add((EOperation)EcoreUtil.copy(operation));
+ }
+ nonStdLib.put(AcceleoNonStandardLibrary.TYPE_OCLANY_NAME, copyOperations);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest#setUp()
+ */
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ // only used for initialization
+ generationRoot = new File(getGenerationRootPath("NonStdLib"));
+ final AcceleoEnvironmentFactory factory = new AcceleoEnvironmentFactory(generationRoot, module,
+ new ArrayList<AcceleoTextGenerationListener>(), true);
+ final OCL ocl = OCL.newInstance(factory);
+ evaluationEnvironment = (AcceleoEvaluationEnvironment)ocl.getEvaluationEnvironment();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest#getModuleLocation()
+ */
+ @Override
+ public String getModuleLocation() {
+ // Reusing the generic engine test template. This is only used for setup.
+ return "data/GenericEngine/generic_engine.mtl";
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest#getResultPath()
+ */
+ @Override
+ public String getResultPath() {
+ return "";
+ }
+
+ /**
+ * Tests the behavior of the non standard "ancestors" operation on OclAny.
+ * <p>
+ * Expects the result to contain all of the containers of the given object.
+ * </p>
+ */
+ public void testOclAnyAncestors() {
+ EOperation operation = getOperation(AcceleoNonStandardLibrary.TYPE_OCLANY_NAME,
+ AcceleoNonStandardLibrary.OPERATION_OCLANY_ANCESTORS);
+
+ final EPackage root = EcoreFactory.eINSTANCE.createEPackage();
+ final EPackage sub = EcoreFactory.eINSTANCE.createEPackage();
+ final EPackage subSub = EcoreFactory.eINSTANCE.createEPackage();
+ final EClass clazz = EcoreFactory.eINSTANCE.createEClass();
+ final EAttribute attribute = EcoreFactory.eINSTANCE.createEAttribute();
+ clazz.getEStructuralFeatures().add(attribute);
+ subSub.getEClassifiers().add(clazz);
+ sub.getESubpackages().add(subSub);
+ root.getESubpackages().add(sub);
+
+ Object result = evaluationEnvironment.callNonStandardOperation(operation, attribute);
+ assertSame("Unexpected count of ancestors returned", 4, ((Collection<?>)result).size());
+ final Iterator<?> children = ((Collection<?>)result).iterator();
+ assertSame("The first container of the attribute should have been the class", clazz, children.next());
+ assertSame("The second container of the attribute should have been the second sub-package", subSub,
+ children.next());
+ assertSame("The third container of the attribute should have been the first sub-package", sub,
+ children.next());
+ assertSame("The fourth container of the attribute should have been the root package", root, children
+ .next());
+ }
+
+ /**
+ * Tests the behavior of the non standard "eAllContents()" operation on OclAny.
+ * <p>
+ * Expects the result to contain all of the Objects that can be iterated over through
+ * {@link EObject#eAllContents()}.
+ * </p>
+ */
+ public void testOclAnyUnparameterizableEAllContents() {
+ EOperation operation = getOperation(AcceleoNonStandardLibrary.TYPE_OCLANY_NAME,
+ AcceleoNonStandardLibrary.OPERATION_OCLANY_EALLCONTENTS);
+
+ final EPackage root = EcoreFactory.eINSTANCE.createEPackage();
+ final EPackage sub = EcoreFactory.eINSTANCE.createEPackage();
+ final EPackage subSub = EcoreFactory.eINSTANCE.createEPackage();
+ final EPackage subSub2 = EcoreFactory.eINSTANCE.createEPackage();
+ final EClass clazz = EcoreFactory.eINSTANCE.createEClass();
+ final EAttribute attribute = EcoreFactory.eINSTANCE.createEAttribute();
+ clazz.getEStructuralFeatures().add(attribute);
+ subSub.getEClassifiers().add(clazz);
+ sub.getESubpackages().add(subSub);
+ sub.getESubpackages().add(subSub2);
+ root.getESubpackages().add(sub);
+
+ Object result = evaluationEnvironment.callNonStandardOperation(operation, root);
+ assertSame("Unexpected count of descendants returned", 5, ((Collection<?>)result).size());
+ final Iterator<?> children = ((Collection<?>)result).iterator();
+ assertSame("The first descendant of the root should have been the first sub-package", sub, children
+ .next());
+ assertSame("The second descendant of the root should have been the second sub-package", subSub,
+ children.next());
+ assertSame("The third descendant of the root should have been the EClass", clazz, children.next());
+ assertSame("The fourth descendant of the root should have been the attribute", attribute, children
+ .next());
+ assertSame("The fifth descendant of the root should have been the third sub-package", subSub2,
+ children.next());
+ }
+
+ /**
+ * Tests the behavior of the non standard "eAllContents(OclAny)" operation on OclAny.
+ * <p>
+ * Expects the result to contain all of the Objects that can be iterated over through
+ * {@link EObject#eAllContents()} of ther given type.
+ * </p>
+ */
+ public void testOclAnyParameterizableEAllContents() {
+ EOperation operation = getOperation(AcceleoNonStandardLibrary.TYPE_OCLANY_NAME,
+ AcceleoNonStandardLibrary.OPERATION_OCLANY_EALLCONTENTS);
+
+ final EPackage root = EcoreFactory.eINSTANCE.createEPackage();
+ final EPackage sub = EcoreFactory.eINSTANCE.createEPackage();
+ final EPackage subSub = EcoreFactory.eINSTANCE.createEPackage();
+ final EPackage subSub2 = EcoreFactory.eINSTANCE.createEPackage();
+ final EClass clazz = EcoreFactory.eINSTANCE.createEClass();
+ final EAttribute attribute = EcoreFactory.eINSTANCE.createEAttribute();
+ clazz.getEStructuralFeatures().add(attribute);
+ subSub.getEClassifiers().add(clazz);
+ sub.getESubpackages().add(subSub);
+ sub.getESubpackages().add(subSub2);
+ root.getESubpackages().add(sub);
+
+ Object result = evaluationEnvironment.callNonStandardOperation(operation, root,
+ EcorePackage.eINSTANCE.getEPackage());
+ assertSame("Unexpected count of descendants returned", 3, ((Collection<?>)result).size());
+ final Iterator<?> children = ((Collection<?>)result).iterator();
+ assertSame("The first descendant of the root should have been the first sub-package", sub, children
+ .next());
+ assertSame("The second descendant of the root should have been the second sub-package", subSub,
+ children.next());
+ assertSame("The third descendant of the root should have been the third sub-package", subSub2,
+ children.next());
+
+ // Ensure the behavior when passing null as argument doesn't evolve
+ try {
+ evaluationEnvironment.callNonStandardOperation(operation, root, (EObject)null);
+ fail("The non standard eAllContents(OclAny) operation previously threw NPEs when called with null argument");
+ } catch (NullPointerException e) {
+ // Expected behavior
+ }
+ }
+
+ /**
+ * Tests the behavior of the non standard "eInverse()" operation on OclAny.
+ * <p>
+ * Expects the result to contain all of the Objects that have a reference towards self.
+ * </p>
+ */
+ public void testOclAnyEInverse() {
+ EOperation operation = getOperation(AcceleoNonStandardLibrary.TYPE_OCLANY_NAME,
+ AcceleoNonStandardLibrary.OPERATION_OCLANY_EINVERSE);
+
+ final EPackage root = EcoreFactory.eINSTANCE.createEPackage();
+ final EPackage sub = EcoreFactory.eINSTANCE.createEPackage();
+ final EPackage subSub = EcoreFactory.eINSTANCE.createEPackage();
+ final EPackage subSub2 = EcoreFactory.eINSTANCE.createEPackage();
+ final EClass clazz = EcoreFactory.eINSTANCE.createEClass();
+ final EClass clazz2 = EcoreFactory.eINSTANCE.createEClass();
+ final EAttribute attribute = EcoreFactory.eINSTANCE.createEAttribute();
+ clazz.getEStructuralFeatures().add(attribute);
+ subSub.getEClassifiers().add(clazz);
+ sub.getESubpackages().add(subSub);
+ subSub2.getEClassifiers().add(clazz2);
+ sub.getESubpackages().add(subSub2);
+ root.getESubpackages().add(sub);
+ clazz.getESuperTypes().add(clazz2);
+
+ Object result = evaluationEnvironment.callNonStandardOperation(operation, clazz2);
+ assertSame("Unexpected count of inverse references returned", 2, ((Collection<?>)result).size());
+ final Iterator<?> children = ((Collection<?>)result).iterator();
+ assertSame("The first inverse reference on the second EClass should have been the first EClass",
+ clazz, children.next());
+ assertTrue("The second inverse reference on the second EClass should have been a GenericType",
+ children.next() instanceof EGenericType);
+ }
+
+ /**
+ * Tests the behavior of the non standard "siblings" operation on OclAny.
+ * <p>
+ * Expects the result to contain all of the siblings of the given object, excluding self.
+ * </p>
+ */
+ public void testOclAnySiblings() {
+ EOperation operation = getOperation(AcceleoNonStandardLibrary.TYPE_OCLANY_NAME,
+ AcceleoNonStandardLibrary.OPERATION_OCLANY_SIBLINGS);
+
+ final EPackage root = EcoreFactory.eINSTANCE.createEPackage();
+ final EPackage sub = EcoreFactory.eINSTANCE.createEPackage();
+ final EPackage subSub = EcoreFactory.eINSTANCE.createEPackage();
+ final EClass clazz1 = EcoreFactory.eINSTANCE.createEClass();
+ final EClass clazz2 = EcoreFactory.eINSTANCE.createEClass();
+ final EClass clazz3 = EcoreFactory.eINSTANCE.createEClass();
+ subSub.getEClassifiers().add(clazz1);
+ subSub.getEClassifiers().add(clazz2);
+ subSub.getEClassifiers().add(clazz3);
+ sub.getESubpackages().add(subSub);
+ root.getESubpackages().add(sub);
+
+ Object result = evaluationEnvironment.callNonStandardOperation(operation, clazz2);
+ assertSame("Unexpected count of siblings returned", 2, ((Collection<?>)result).size());
+ Iterator<?> children = ((Collection<?>)result).iterator();
+ assertSame("The sibling should have been the first added EClass.", clazz1, children.next());
+ assertSame("The sibling should have been the third added EClass.", clazz3, children.next());
+
+ result = evaluationEnvironment.callNonStandardOperation(operation, clazz1);
+ assertSame("Unexpected count of siblings returned", 2, ((Collection<?>)result).size());
+ children = ((Collection<?>)result).iterator();
+ assertSame("The sibling should have been the second added EClass.", clazz2, children.next());
+ assertSame("The sibling should have been the third added EClass.", clazz3, children.next());
+ }
+
+ /**
+ * Tests the behavior of the non standard "toString()" operation on OclAny.
+ * <p>
+ * Expects the result to be the same as a call to Object#toString() on the receiver.
+ * </p>
+ */
+ public void testOclAnyToString() {
+ EOperation operation = getOperation(AcceleoNonStandardLibrary.TYPE_OCLANY_NAME,
+ AcceleoNonStandardLibrary.OPERATION_OCLANY_TOSTRING);
+
+ final EPackage root = EcoreFactory.eINSTANCE.createEPackage();
+ final EPackage sub = EcoreFactory.eINSTANCE.createEPackage();
+ final EPackage subSub = EcoreFactory.eINSTANCE.createEPackage();
+ final EPackage subSub2 = EcoreFactory.eINSTANCE.createEPackage();
+ final EClass clazz = EcoreFactory.eINSTANCE.createEClass();
+ final EClass clazz2 = EcoreFactory.eINSTANCE.createEClass();
+ final EAttribute attribute = EcoreFactory.eINSTANCE.createEAttribute();
+ clazz.getEStructuralFeatures().add(attribute);
+ subSub.getEClassifiers().add(clazz);
+ sub.getESubpackages().add(subSub);
+ subSub2.getEClassifiers().add(clazz2);
+ sub.getESubpackages().add(subSub2);
+ root.getESubpackages().add(sub);
+ clazz.getESuperTypes().add(clazz2);
+
+ final TreeIterator<EObject> childrenIterator = root.eAllContents();
+ while (childrenIterator.hasNext()) {
+ final EObject child = childrenIterator.next();
+ assertEquals("Unexpected result of the non-standard toString operation on " + child, child
+ .toString(), evaluationEnvironment.callNonStandardOperation(operation, child));
+ }
+
+ for (String value : stringValues) {
+ assertEquals("Unexpected result of the non-standard toString operation on a String", value,
+ evaluationEnvironment.callNonStandardOperation(operation, value));
+ }
+
+ assertEquals("Unexpected result of the non-standard toString operation on an Integer", "0",
+ evaluationEnvironment.callNonStandardOperation(operation, Integer.valueOf(0)));
+ }
+
+ /**
+ * Tests the behavior of the non standard "endsWith(String)" operation on String.
+ * <p>
+ * Expects the result to be the same as {@link String#endsWith(String)}.
+ * </p>
+ */
+ public void testStringEndsWith() {
+ EOperation operation = getOperation(AcceleoNonStandardLibrary.PRIMITIVE_STRING_NAME,
+ AcceleoNonStandardLibrary.OPERATION_STRING_ENDSWITH);
+
+ final String uncontainedString = "tgdjfsleo";
+
+ // Taking random characters as the end value : expecting endsWith to return false
+ for (String value : stringValues) {
+ final Object result = evaluationEnvironment.callNonStandardOperation(operation, value,
+ uncontainedString);
+ assertTrue("Result of endsWith should have been a boolean", result instanceof Boolean);
+ assertEquals("Result should have been false.", Boolean.FALSE, result);
+ assertEquals("The non standard operation should have returned the same result as "
+ + "String#endsWith(String)", value.endsWith(uncontainedString), result);
+ }
+
+ // Taking last part of the value : expecting endsWith to return true
+ for (String value : stringValues) {
+ final String lastPart;
+ if (value.length() == 0) {
+ lastPart = value;
+ } else {
+ lastPart = value.substring(Math.max(value.length() / 2, 1));
+ }
+ final Object result = evaluationEnvironment.callNonStandardOperation(operation, value, lastPart);
+ assertTrue("Result of endsWith should have been a boolean", result instanceof Boolean);
+ assertEquals("Result should have been true.", Boolean.TRUE, result);
+ assertEquals("The non standard operation should have returned the same result as "
+ + "String#endsWith(String)", value.endsWith(lastPart), result);
+ }
+
+ // Checking if value "endsWith" itself : expecting endsWith to return true
+ for (String value : stringValues) {
+ final Object result = evaluationEnvironment.callNonStandardOperation(operation, value, value);
+ assertTrue("Result of endsWith should have been a boolean", result instanceof Boolean);
+ assertEquals("Result should have been true.", Boolean.TRUE, result);
+ assertEquals("The non standard operation should have returned the same result as "
+ + "String#endsWith(String)", value.endsWith(value), result);
+ }
+
+ // Ensure the behavior when passing null as argument doesn't evolve
+ try {
+ evaluationEnvironment.callNonStandardOperation(operation, stringValues[0], (Object)null);
+ fail("The non standard String.endsWith operation previously threw NPEs when called with null argument");
+ } catch (NullPointerException e) {
+ // Expected behavior
+ }
+ }
+
+ /**
+ * Tests the behavior of the non standard "replace(String, String)" operation on String.
+ * <p>
+ * Expects the result to be the same as {@link String#replaceFirst(String, String)}.
+ * </p>
+ */
+ public void testStringReplace() {
+ EOperation operation = getOperation(AcceleoNonStandardLibrary.PRIMITIVE_STRING_NAME,
+ AcceleoNonStandardLibrary.OPERATION_STRING_REPLACE);
+
+ final String value = "start .*abc.* - .*abc.* end";
+ String search = "(.*?)abc.*( end)";
+ String replace = "$1 -$2";
+ Object result = evaluationEnvironment.callNonStandardOperation(operation, value, search, replace);
+ assertEquals("Non standard operation String.replace(String, String) didn't return the "
+ + "expected result.", "start .* - end", result);
+ assertEquals("Non standard replace didn't yield the same result as String.replace().", value
+ .replaceFirst(search, replace), result);
+
+ search = "not contained substring";
+ replace = "random replacement";
+ result = evaluationEnvironment.callNonStandardOperation(operation, value, search, replace);
+ assertEquals("standard operation String.replace(String, String) didn't return the "
+ + "expected result.", "start .*abc.* - .*abc.* end", result);
+ assertEquals("Non standard replace didn't yield the same result as String.replace().", value
+ .replaceFirst(search, replace), result);
+
+ // Ensure the behavior when passing null as argument doesn't evolve
+ try {
+ evaluationEnvironment.callNonStandardOperation(operation, value, (Object)null, "abc");
+ fail("The non standard String.replace operation previously threw NPEs when called with null argument");
+ } catch (NullPointerException e) {
+ // Expected behavior
+ }
+ try {
+ evaluationEnvironment.callNonStandardOperation(operation, value, "abc", (Object)null);
+ fail("The non standard String.replace operation previously threw NPEs when called with null argument");
+ } catch (NullPointerException e) {
+ // Expected behavior
+ }
+ }
+
+ /**
+ * Tests the behavior of the non standard "replaceAll(String, String)" operation on String.
+ * <p>
+ * Expects the result to be the same as {@link String#replaceAll(String, String)}.
+ * </p>
+ */
+ public void testStringReplaceAll() {
+ EOperation operation = getOperation(AcceleoNonStandardLibrary.PRIMITIVE_STRING_NAME,
+ AcceleoNonStandardLibrary.OPERATION_STRING_REPLACEALL);
+
+ final String value = "start .*abc.* - .*abc.* end";
+ String search = "(.*?)abc";
+ String replace = "$1def";
+ Object result = evaluationEnvironment.callNonStandardOperation(operation, value, search, replace);
+ assertEquals("Non standard operation String.replaceAll(String, String) didn't return the "
+ + "expected result.", "start .*def.* - .*def.* end", result);
+ assertEquals("Non standard replace didn't yield the same result as String.replaceAll().", value
+ .replaceAll(search, replace), result);
+
+ search = "not contained substring";
+ replace = "random replacement";
+ result = evaluationEnvironment.callNonStandardOperation(operation, value, search, replace);
+ assertEquals("standard operation String.replaceAll(String, String) didn't return the "
+ + "expected result.", "start .*abc.* - .*abc.* end", result);
+ assertEquals("Non standard replaceAll didn't yield the same result as String.replaceAll().", value
+ .replaceAll(search, replace), result);
+
+ // Ensure the behavior when passing null as argument doesn't evolve
+ try {
+ evaluationEnvironment.callNonStandardOperation(operation, value, (Object)null, "abc");
+ fail("The non standard String.replaceAll operation previously threw NPEs when called with null argument");
+ } catch (NullPointerException e) {
+ // Expected behavior
+ }
+ try {
+ evaluationEnvironment.callNonStandardOperation(operation, value, "abc", (Object)null);
+ fail("The non standard String.replaceAll operation previously threw NPEs when called with null argument");
+ } catch (NullPointerException e) {
+ // Expected behavior
+ }
+ }
+
+ /**
+ * Tests the behavior of the non standard "startsWith(String)" operation on String.
+ * <p>
+ * Expects the result to be the same as {@link String#startsWith(String)}.
+ * </p>
+ */
+ public void testStringStartsWith() {
+ EOperation operation = getOperation(AcceleoNonStandardLibrary.PRIMITIVE_STRING_NAME,
+ AcceleoNonStandardLibrary.OPERATION_STRING_STARTSWITH);
+
+ final String uncontainedString = "tgdjfsleo";
+
+ // Taking random characters as the end value : expecting startsWith to return false
+ for (String value : stringValues) {
+ final Object result = evaluationEnvironment.callNonStandardOperation(operation, value,
+ uncontainedString);
+ assertTrue("Result of startsWith should have been a boolean", result instanceof Boolean);
+ assertEquals("Result should have been false.", Boolean.FALSE, result);
+ assertEquals("The non standard operation should have returned the same result as "
+ + "String#startsWith(String)", value.startsWith(uncontainedString), result);
+ }
+
+ // Taking first part of the value : expecting startsWith to return true
+ for (String value : stringValues) {
+ final String firstPart;
+ if (value.length() == 0) {
+ firstPart = value;
+ } else {
+ firstPart = value.substring(0, Math.max(value.length() / 2, 1));
+ }
+ final Object result = evaluationEnvironment.callNonStandardOperation(operation, value, firstPart);
+ assertTrue("Result of startsWith should have been a boolean", result instanceof Boolean);
+ assertEquals("Result should have been true.", Boolean.TRUE, result);
+ assertEquals("The non standard operation should have returned the same result as "
+ + "String#startsWith(String)", value.startsWith(firstPart), result);
+ }
+
+ // Checking if value "startsWith" itself : expecting startsWith to return true
+ for (String value : stringValues) {
+ final Object result = evaluationEnvironment.callNonStandardOperation(operation, value, value);
+ assertTrue("Result of startsWith should have been a boolean", result instanceof Boolean);
+ assertEquals("Result should have been true.", Boolean.TRUE, result);
+ assertEquals("The non standard operation should have returned the same result as "
+ + "String#startsWith(String)", value.startsWith(value), result);
+ }
+
+ // Ensure the behavior when passing null as argument doesn't evolve
+ try {
+ evaluationEnvironment.callNonStandardOperation(operation, stringValues[0], (Object)null);
+ fail("The non standard String.startsWith operation previously threw NPEs when called with null argument");
+ } catch (NullPointerException e) {
+ // Expected behavior
+ }
+ }
+
+ /**
+ * Tests the behavior of the non standard String.substituteAll(String, String) operation.
+ * <p>
+ * We expect the call to replace all occurences of the substring by the replacement, not considering both
+ * parameters as regular expressions. Result should be the same as
+ * {@link String#replace(CharSequence, CharSequence)}.
+ * </p>
+ */
+ public void testStringSubstituteAll() {
+ EOperation operation = getOperation(AcceleoNonStandardLibrary.PRIMITIVE_STRING_NAME,
+ AcceleoNonStandardLibrary.OPERATION_STRING_SUBSTITUTEALL);
+
+ final String value = "start .*abc.* - .*abc.* end";
+ String search = ".*abc.*";
+ String replace = "\\$1\\1def\\2$2\\";
+ Object result = evaluationEnvironment.callNonStandardOperation(operation, value, search, replace);
+ assertEquals("Non standard operation String.substituteAll(String, String) didn't return the "
+ + "expected result.", "start \\$1\\1def\\2$2\\ - \\$1\\1def\\2$2\\ end", result);
+ assertEquals("Result of the non standard substituteAll should have been the same as calling"
+ + "String#replace(CharSequence, CharSequence).", value.replace(search, replace), result);
+
+ search = "not contained substring";
+ replace = "random replacement";
+ result = evaluationEnvironment.callNonStandardOperation(operation, value, search, replace);
+ assertEquals("Non standard operation String.substituteAll(String, String) didn't return the "
+ + "expected result.", "start .*abc.* - .*abc.* end", result);
+
+ // Ensure the behavior when passing null as argument doesn't evolve
+ try {
+ evaluationEnvironment.callNonStandardOperation(operation, value, (EObject)null, "abc");
+ fail("The non standard String.substituteAll operation previously threw NPEs when called with null argument");
+ } catch (NullPointerException e) {
+ // Expected behavior
+ }
+ try {
+ evaluationEnvironment.callNonStandardOperation(operation, value, "abc", (EObject)null);
+ fail("The non standard String.substitute operation previously threw NPEs when called with null argument");
+ } catch (NullPointerException e) {
+ // Expected behavior
+ }
+ }
+
+ /**
+ * Tests the behavior of the non standard "tokenize(String)" operation on String.
+ * <p>
+ * Expects the behavior to mimic that of the {@link StringTokenizer}.
+ * </p>
+ */
+ @SuppressWarnings("unchecked")
+ public void testStringTokenize() {
+ EOperation operation = getOperation(AcceleoNonStandardLibrary.PRIMITIVE_STRING_NAME,
+ AcceleoNonStandardLibrary.OPERATION_STRING_TOKENIZE);
+
+ final String[] expected = {"this", "is", "a", "randomly", "delimited", "sentence",};
+ final String value = "this/is.a\\randomly_delimited^sentence";
+ final Object result = evaluationEnvironment.callNonStandardOperation(operation, value, "^/_.\\");
+ assertTrue("Result should have been a list.", result instanceof List);
+ assertSame("Result should have contained 6 words.", expected.length, ((List<String>)result).size());
+ for (int i = 0; i < expected.length; i++) {
+ assertEquals("unexpected String in the tokenized list.", expected[i], ((List<String>)result)
+ .get(i));
+ }
+
+ // Ensure the behavior when passing null as argument doesn't evolve
+ try {
+ evaluationEnvironment.callNonStandardOperation(operation, value, (EObject)null);
+ fail("The non standard String.tokenize operation previously threw NPEs when called with null argument");
+ } catch (NullPointerException e) {
+ // Expected behavior
+ }
+ }
+
+ /**
+ * Tests the behavior of the non standard "trim()" operation on String.
+ */
+ public void testStringTrim() {
+ EOperation operation = getOperation(AcceleoNonStandardLibrary.PRIMITIVE_STRING_NAME,
+ AcceleoNonStandardLibrary.OPERATION_STRING_TRIM);
+
+ final String value = " abc abc\nabc\n ";
+ final Object result = evaluationEnvironment.callNonStandardOperation(operation, value.trim());
+ assertEquals("Unexpected result of the non standard String.trim operation.", "abc abc\nabc", result);
+ assertEquals("Non standard String.trim did not yield the same result as java's String#trim().", value
+ .trim(), result);
+ }
+
+ /**
+ * Tests the behavior of the environment when calling for an undefined operation.
+ * <p>
+ * Expects an {@link UnsupportedOperationException} to be thrown with an accurate error message.
+ * </p>
+ */
+ public void testUndefinedOperation() {
+ final EOperation operation = EcoreFactory.eINSTANCE.createEOperation();
+ operation.setName("undefinedOperation");
+ operation.setEType(EcorePackage.eINSTANCE.getEString());
+ final EAnnotation acceleoAnnotation = EcoreFactory.eINSTANCE.createEAnnotation();
+ acceleoAnnotation.setSource("Acceleo non-standard");
+ operation.getEAnnotations().add(acceleoAnnotation);
+
+ try {
+ evaluationEnvironment.callNonStandardOperation(operation, "source");
+ fail("Expected Unsupported Operation hasn't been thrown by the evaluation environment.");
+ } catch (UnsupportedOperationException e) {
+ // Expected behavior
+ final String expectedErrMsg = "undefinedOperation()";
+ assertTrue("Exception hasn't been affected an accurate error message", e.getMessage().contains(
+ expectedErrMsg));
+ }
+ }
+
+ /**
+ * Returns the operation named <code>operationName</code> registered against the type
+ * <code>typeName</code> in the standard library.
+ *
+ * @param typeName
+ * Name of the classifier we seek an operation of.
+ * @return The sought operation.
+ */
+ private EOperation getOperation(String typeName, String operationName) {
+ final List<EOperation> candidates = nonStdLib.get(typeName);
+ for (EOperation candidate : candidates) {
+ if (candidate.getName().equals(operationName)) {
+ return candidate;
+ }
+ }
+ // not guarded
+ return null;
+ }
+}
diff --git a/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/environment/AcceleoStandardLibraryTest.java b/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/environment/AcceleoStandardLibraryTest.java
new file mode 100644
index 0000000..2f33fdd
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/environment/AcceleoStandardLibraryTest.java
@@ -0,0 +1,567 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.acceleo.engine.tests.unit.environment;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EOperation;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.acceleo.common.utils.AcceleoStandardLibrary;
+import org.eclipse.acceleo.engine.event.AcceleoTextGenerationListener;
+import org.eclipse.acceleo.engine.internal.environment.AcceleoEnvironmentFactory;
+import org.eclipse.acceleo.engine.internal.environment.AcceleoEvaluationEnvironment;
+import org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest;
+import org.eclipse.ocl.ecore.OCL;
+
+/**
+ * This will test the behavior of the Acceleo standard library's operations.
+ *
+ * @author <a href="mailto:laurent.goubet@obeo.fr">Laurent Goubet</a>
+ */
+@SuppressWarnings("nls")
+public class AcceleoStandardLibraryTest extends AbstractAcceleoTest {
+ /** The evaluation environment to call for standard operations on. */
+ private AcceleoEvaluationEnvironment evaluationEnvironment;
+
+ /** EOperations defined in the standard lib. */
+ private final Map<String, List<EOperation>> stdLib = new HashMap<String, List<EOperation>>();
+
+ /** Values that will be used to test standard string operations. */
+ private final String[] stringValues = new String[] {"a", "\u00e9\u00e8\u0020\u00f1", "", "Foehn12",
+ "Standard sentence."};
+
+ {
+ AcceleoStandardLibrary lib = new AcceleoStandardLibrary();
+
+ List<EOperation> intOperations = lib.getExistingOperations(AcceleoStandardLibrary.PRIMITIVE_INTEGER_NAME);
+ List<EOperation> copyOperations = new ArrayList<EOperation>(intOperations.size());
+ for (EOperation operation : intOperations) {
+ copyOperations.add((EOperation)EcoreUtil.copy(operation));
+ }
+ stdLib.put(AcceleoStandardLibrary.PRIMITIVE_INTEGER_NAME, copyOperations);
+
+ List<EOperation> realOperations = lib.getExistingOperations(AcceleoStandardLibrary.PRIMITIVE_REAL_NAME);
+ copyOperations = new ArrayList<EOperation>(realOperations.size());
+ for (EOperation operation : realOperations) {
+ copyOperations.add((EOperation)EcoreUtil.copy(operation));
+ }
+ stdLib.put(AcceleoStandardLibrary.PRIMITIVE_REAL_NAME, copyOperations);
+
+ List<EOperation> stringOperations = lib
+ .getExistingOperations(AcceleoStandardLibrary.PRIMITIVE_STRING_NAME);
+ copyOperations = new ArrayList<EOperation>(stringOperations.size());
+ for (EOperation operation : stringOperations) {
+ copyOperations.add((EOperation)EcoreUtil.copy(operation));
+ }
+ stdLib.put(AcceleoStandardLibrary.PRIMITIVE_STRING_NAME, copyOperations);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest#setUp()
+ */
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ // only used for initialization
+ generationRoot = new File(getGenerationRootPath("StdLib"));
+ final AcceleoEnvironmentFactory factory = new AcceleoEnvironmentFactory(generationRoot, module,
+ new ArrayList<AcceleoTextGenerationListener>(), true);
+ final OCL ocl = OCL.newInstance(factory);
+ evaluationEnvironment = (AcceleoEvaluationEnvironment)ocl.getEvaluationEnvironment();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest#getModuleLocation()
+ */
+ @Override
+ public String getModuleLocation() {
+ // Reusing the generic engine test template. This is only used for setup.
+ return "data/GenericEngine/generic_engine.mtl";
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest#getResultPath()
+ */
+ @Override
+ public String getResultPath() {
+ return "";
+ }
+
+ /**
+ * Tests the behavior of the standard "toString" operation on Integers. Expects the result to be that of
+ * the source's toString method.
+ */
+ public void testIntegerToString() {
+ EOperation operation = getOperation(AcceleoStandardLibrary.PRIMITIVE_INTEGER_NAME,
+ AcceleoStandardLibrary.OPERATION_INTEGER_TOSTRING);
+ final List<Number> values = new ArrayList<Number>(7);
+ values.add(Long.MIN_VALUE);
+ values.add(Integer.MIN_VALUE);
+ values.add(Long.valueOf(-5));
+ values.add(Integer.valueOf(0));
+ values.add(Long.valueOf(5));
+ values.add(Integer.MAX_VALUE);
+ values.add(Long.MAX_VALUE);
+ for (Number value : values) {
+ Object result = evaluationEnvironment.callStandardOperation(operation, value);
+ assertEquals("Integer.toString() standard operation didn't evaluate to the accurate result.",
+ value.toString(), result);
+ }
+ }
+
+ /**
+ * Tests the behavior of the standard "toString" operation on Reals. Expects the result to be that of the
+ * source's toString method.
+ */
+ public void testRealToString() {
+ EOperation operation = getOperation(AcceleoStandardLibrary.PRIMITIVE_REAL_NAME,
+ AcceleoStandardLibrary.OPERATION_REAL_TOSTRING);
+ final List<Number> values = new ArrayList<Number>(7);
+ values.add(Double.MIN_VALUE);
+ values.add(Float.MIN_VALUE);
+ values.add(Double.valueOf(-5));
+ values.add(Float.valueOf(0));
+ values.add(Double.valueOf(5));
+ values.add(Float.MAX_VALUE);
+ values.add(Double.MAX_VALUE);
+ for (Number value : values) {
+ Object result = evaluationEnvironment.callStandardOperation(operation, value);
+ assertEquals("Real.toString() standard operation didn't evaluate to the accurate result.", value
+ .toString(), result);
+ }
+ }
+
+ /**
+ * Tests the behavior of the standard "first(int)" operation on Strings. Expects the result to be the same
+ * as source.substring(0, int).
+ */
+ public void testStringFirst() {
+ EOperation operation = getOperation(AcceleoStandardLibrary.PRIMITIVE_STRING_NAME,
+ AcceleoStandardLibrary.OPERATION_STRING_FIRST);
+
+ for (String value : stringValues) {
+ Object result = evaluationEnvironment.callStandardOperation(operation, value,
+ new Object[] {Integer.valueOf(-5)});
+ assertEquals("Calling the standard operation String.first(int) with a negative "
+ + "parameter should return self.", value, result);
+ result = evaluationEnvironment.callStandardOperation(operation, value, Integer.valueOf(0));
+ assertEquals("Calling the standard operation String.first(0) should return the empty String.",
+ "", result);
+ result = evaluationEnvironment.callStandardOperation(operation, value, Integer.valueOf(1));
+ if (value.length() == 0) {
+ assertEquals("calling the standard operation String.first(int) on the empty String "
+ + "should return the empty String.", "", result);
+ } else {
+ assertEquals("calling the standard operation String.first(1) should return the first "
+ + "character of self.", String.valueOf(value.charAt(0)), result);
+ }
+ result = evaluationEnvironment.callStandardOperation(operation, value, Integer.valueOf(3));
+ if (value.length() == 0) {
+ assertEquals("calling the standard operation String.first(int) on the empty String should "
+ + "return the empty String.", "", result);
+ } else if (value.length() < 3) {
+ assertEquals("calling the standard operation String.first(3) on Strings which size is less "
+ + "than 3 should return self.", value, result);
+ } else {
+ assertEquals("calling the standard operation String.first(3) on Strings which size is more "
+ + "than 3 should return the first three characters of self.", value.substring(0, 3),
+ result);
+ }
+ }
+
+ // Ensure the behavior when passing null as argument doesn't evolve
+ try {
+ evaluationEnvironment.callStandardOperation(operation, stringValues[0], (EObject)null);
+ fail("The standard String.first operation previously threw NPEs when called with null argument");
+ } catch (NullPointerException e) {
+ // Expected behavior
+ }
+ }
+
+ /**
+ * Tests the behavior of the standard "index(String)" operation on Strings. Expects the result to be the
+ * same as source.indexOf(String).
+ */
+ public void testStringIndex() {
+ EOperation operation = getOperation(AcceleoStandardLibrary.PRIMITIVE_STRING_NAME,
+ AcceleoStandardLibrary.OPERATION_STRING_INDEX);
+
+ for (String value : stringValues) {
+ Object result = evaluationEnvironment.callStandardOperation(operation, value, "jgfduigelgrkj");
+ assertEquals("Calling the standard operation String.index(String) with a String that is "
+ + "not contained by self should have returned -1.", -1, result);
+ if (value.length() > 1) {
+ result = evaluationEnvironment.callStandardOperation(operation, value, value.substring(2,
+ value.length() - 1));
+ assertEquals("Calling the standard operation String.index(String) with a String that is "
+ + "contained by self should have had the same result as source.indexOf(String).",
+ value.indexOf(value.substring(2, value.length() - 1)), result);
+ }
+ }
+
+ // Ensure the behavior when passing null as argument doesn't evolve
+ try {
+ evaluationEnvironment.callStandardOperation(operation, stringValues[0], (EObject)null);
+ fail("The standard String.index operation previously threw NPEs when called with null argument");
+ } catch (NullPointerException e) {
+ // Expected behavior
+ }
+ }
+
+ /**
+ * Tests the behavior of the standard "isAlpha()" operation on Strings. Expects the result to be
+ * <code>true</code> if and only if {@link Character#isLetter(char)} returns <code>true</code> for each
+ * and every character of the source value.
+ */
+ public void testStringIsAlpha() {
+ EOperation operation = getOperation(AcceleoStandardLibrary.PRIMITIVE_STRING_NAME,
+ AcceleoStandardLibrary.OPERATION_STRING_ISALPHA);
+
+ for (String value : stringValues) {
+ Object result = evaluationEnvironment.callStandardOperation(operation, value);
+ boolean isAlpha = true;
+ for (char c : value.toCharArray()) {
+ if (!Character.isLetter(c)) {
+ isAlpha = false;
+ break;
+ }
+ }
+ assertEquals("The standard operation String.isAlpha() returned an unexpected result.", isAlpha,
+ result);
+ }
+ }
+
+ /**
+ * Tests the behavior of the standard "isAlphanum()" operation on Strings. Expects the result to be
+ * <code>true</code> if and only if {@link Character#isLetterOrDigit(char)} returns <code>true</code> for
+ * each and every character of the source value.
+ */
+ public void testStringIsAlphanum() {
+ EOperation operation = getOperation(AcceleoStandardLibrary.PRIMITIVE_STRING_NAME,
+ AcceleoStandardLibrary.OPERATION_STRING_ISALPHANUM);
+
+ for (String value : stringValues) {
+ Object result = evaluationEnvironment.callStandardOperation(operation, value);
+ boolean isAlphanum = true;
+ for (char c : value.toCharArray()) {
+ if (!Character.isLetterOrDigit(c)) {
+ isAlphanum = false;
+ break;
+ }
+ }
+ assertEquals("The standard operation String.isAlphanum() returned an unexpected result.",
+ isAlphanum, result);
+ }
+ }
+
+ /**
+ * Tests the behavior of the standard "last(int)" operation on Strings. Expects the result to be the same
+ * as source.substring(source.length() - int, source.length()).
+ */
+ public void testStringLast() {
+ EOperation operation = getOperation(AcceleoStandardLibrary.PRIMITIVE_STRING_NAME,
+ AcceleoStandardLibrary.OPERATION_STRING_LAST);
+
+ for (String value : stringValues) {
+ Object result = evaluationEnvironment
+ .callStandardOperation(operation, value, Integer.valueOf(-5));
+ assertEquals("Calling the standard operation String.last(int) with a negative "
+ + "parameter should return self.", value, result);
+ result = evaluationEnvironment.callStandardOperation(operation, value, Integer.valueOf(0));
+ assertEquals("Calling the standard operation String.last(0) should return the empty String.", "",
+ result);
+ result = evaluationEnvironment.callStandardOperation(operation, value, Integer.valueOf(1));
+ if (value.length() == 0) {
+ assertEquals("calling the standard operation String.last(int) on the empty String "
+ + "should return the empty String.", "", result);
+ } else {
+ assertEquals("calling the standard operation String.last(1) should return the last "
+ + "character of self.", String.valueOf(value.charAt(value.length() - 1)), result);
+ }
+ result = evaluationEnvironment.callStandardOperation(operation, value, Integer.valueOf(3));
+ if (value.length() == 0) {
+ assertEquals("calling the standard operation String.last(int) on the empty String should "
+ + "return the empty String.", "", result);
+ } else if (value.length() < 3) {
+ assertEquals("calling the standard operation String.last(3) on Strings which size is less "
+ + "than 3 should return self.", value, result);
+ } else {
+ assertEquals("calling the standard operation String.last(3) on Strings which size is more "
+ + "than 3 should return the last three characters of self.", value.substring(value
+ .length() - 3, value.length()), result);
+ }
+ }
+
+ // Ensure the behavior when passing null as argument doesn't evolve
+ try {
+ evaluationEnvironment.callStandardOperation(operation, stringValues[0], (EObject)null);
+ fail("The standard String.last operation previously threw NPEs when called with null argument");
+ } catch (NullPointerException e) {
+ // Expected behavior
+ }
+ }
+
+ /**
+ * Tests the behavior of the standard "strcmp(String)" operation on Strings. Expects the result to be the
+ * same as source.compareTo(String).
+ */
+ public void testStringStrcmp() {
+ EOperation operation = getOperation(AcceleoStandardLibrary.PRIMITIVE_STRING_NAME,
+ AcceleoStandardLibrary.OPERATION_STRING_STRCMP);
+
+ for (int i = 0; i < stringValues.length; i++) {
+ for (int j = stringValues.length - 1; j >= 0; j--) {
+ Object result = evaluationEnvironment.callStandardOperation(operation, stringValues[i],
+ stringValues[j]);
+ assertEquals("Unexpected result of the standard String.strcmp(String) operation.",
+ stringValues[i].compareTo(stringValues[j]), result);
+ }
+ }
+
+ // Ensure the behavior when passing null as argument doesn't evolve
+ try {
+ evaluationEnvironment.callStandardOperation(operation, stringValues[0], (EObject)null);
+ fail("The standard String.strcmp operation previously threw NPEs when called with null argument");
+ } catch (NullPointerException e) {
+ // Expected behavior
+ }
+ }
+
+ /**
+ * Tests the behavior of the standard "strstr(String)" operation on Strings. Expects the result to be the
+ * same as source.contains(String).
+ */
+ public void testStringStrstr() {
+ EOperation operation = getOperation(AcceleoStandardLibrary.PRIMITIVE_STRING_NAME,
+ AcceleoStandardLibrary.OPERATION_STRING_STRSTR);
+
+ for (String value : stringValues) {
+ // string contains itself
+ Object result = evaluationEnvironment.callStandardOperation(operation, value, value);
+ assertTrue("Standard String.strstr(String) operation reports source does not contain itself.",
+ result instanceof Boolean && ((Boolean)result).booleanValue());
+
+ // contained string
+ String search = "";
+ if (value.length() == 1) {
+ search = value;
+ } else if (value.length() > 1) {
+ search = value.substring(1, value.length() - 1);
+ }
+ result = evaluationEnvironment.callStandardOperation(operation, value, search);
+ assertTrue("Standard String.strstr(String) operation reports source does not contain its "
+ + "substring.", result instanceof Boolean && ((Boolean)result).booleanValue());
+
+ // not contained String
+ result = evaluationEnvironment.callStandardOperation(operation, value,
+ "This substring is not contained by any value");
+ assertTrue("Standard String.strstr(String) operation reports source contains a random, "
+ + "not contained string.", result instanceof Boolean && !((Boolean)result).booleanValue());
+ }
+
+ // Ensure the behavior when passing null as argument doesn't evolve
+ try {
+ evaluationEnvironment.callStandardOperation(operation, stringValues[0], (EObject)null);
+ fail("The standard String.strstr operation previously threw NPEs when called with null argument");
+ } catch (NullPointerException e) {
+ // Expected behavior
+ }
+ }
+
+ /**
+ * Tests the behavior of the standard "strtok(String, int)" operation on Strings.
+ */
+ public void testStringStrtok() {
+ EOperation operation = getOperation(AcceleoStandardLibrary.PRIMITIVE_STRING_NAME,
+ AcceleoStandardLibrary.OPERATION_STRING_STRTOK);
+
+ final String value = "Standard english sentence with space-separated words.";
+ Object result = evaluationEnvironment
+ .callStandardOperation(operation, value, " ", Integer.valueOf(0));
+ assertEquals("Call to standard operation String.strtok(\" \", 0) did not return the first word "
+ + "of self", "Standard", result);
+
+ final String[] words = value.split(" ");
+ for (int i = 1; i < words.length; i++) {
+ result = evaluationEnvironment.callStandardOperation(operation, value, " ", Integer.valueOf(1));
+ assertEquals("Subsequent call to standard operation String.strtok(\" \", 1) did not return the "
+ + "next word of self", words[i], result);
+ }
+
+ /*
+ * We've consumed all of the tokenizer's tokens. Any subsequent call is expected to return the empty
+ * String.
+ */
+ result = evaluationEnvironment.callStandardOperation(operation, value, " ", Integer.valueOf(1));
+ assertEquals("Calling the standard operation String.strtok(\" \", 1) is expected to return the "
+ + "empty String when all tokens have been consumed.", "", result);
+
+ /*
+ * Calling strtok on a given String with the flag set to 0 a second time is expected to reset the
+ * tokenizer and return the first word again.
+ */
+ result = evaluationEnvironment.callStandardOperation(operation, value, " ", Integer.valueOf(0));
+ assertEquals("Call to standard operation String.strtok(\" \", 0) did not return the first word "
+ + "of self", "Standard", result);
+
+ // Ensure the behavior when passing null as argument doesn't evolve
+ try {
+ evaluationEnvironment.callStandardOperation(operation, stringValues[0], (EObject)null, Integer
+ .valueOf(0));
+ fail("The standard String.strtok operation previously threw NPEs when called with null argument");
+ } catch (NullPointerException e) {
+ // Expected behavior
+ }
+ try {
+ evaluationEnvironment.callStandardOperation(operation, stringValues[0], " ", (EObject)null);
+ fail("The standard String.strtok operation previously threw NPEs when called with null argument");
+ } catch (NullPointerException e) {
+ // Expected behavior
+ }
+ }
+
+ /**
+ * Tests the behavior of the standard String.substitute(String, String) operation.
+ * <p>
+ * We expect the call to replace the first occurence of the substring by the replacement, not considering
+ * both parameters as regular expressions.
+ * </p>
+ */
+ public void testStringSubstitute() {
+ EOperation operation = getOperation(AcceleoStandardLibrary.PRIMITIVE_STRING_NAME,
+ AcceleoStandardLibrary.OPERATION_STRING_SUBSTITUTE);
+
+ final String value = "start .*abc.* - .*abc.* end";
+ Object result = evaluationEnvironment.callStandardOperation(operation, value, ".*abc.*",
+ "\\$1\\1def\\2$2\\");
+ assertEquals("standard operation String.substitute(String, String) didn't return the "
+ + "expected result.", "start \\$1\\1def\\2$2\\ - .*abc.* end", result);
+
+ result = evaluationEnvironment.callStandardOperation(operation, value, "not contained substring",
+ "random replacement");
+ assertEquals("standard operation String.substitute(String, String) didn't return the "
+ + "expected result.", "start .*abc.* - .*abc.* end", result);
+
+ // Ensure the behavior when passing null as argument doesn't evolve
+ try {
+ evaluationEnvironment.callStandardOperation(operation, stringValues[0], (EObject)null, "abc");
+ fail("The standard String.substitute operation previously threw NPEs when called with null argument");
+ } catch (NullPointerException e) {
+ // Expected behavior
+ }
+ try {
+ evaluationEnvironment.callStandardOperation(operation, stringValues[0], "abc", (EObject)null);
+ fail("The standard String.substitute operation previously threw NPEs when called with null argument");
+ } catch (NullPointerException e) {
+ // Expected behavior
+ }
+ }
+
+ /**
+ * Tests the behavior of the standard String.toLowerFirst() operation.
+ */
+ public void testStringToLowerFirst() {
+ EOperation operation = getOperation(AcceleoStandardLibrary.PRIMITIVE_STRING_NAME,
+ AcceleoStandardLibrary.OPERATION_STRING_TOLOWERFIRST);
+
+ for (String value : stringValues) {
+ final String expected;
+ if (value.length() == 0) {
+ expected = value;
+ } else {
+ expected = Character.toLowerCase(value.charAt(0)) + value.substring(1);
+ }
+ // string contains itself
+ Object result = evaluationEnvironment.callStandardOperation(operation, value);
+ assertEquals("Standard String.toLowerFirst() operation did not return the expect result.",
+ expected, result);
+ }
+ }
+
+ /**
+ * Tests the behavior of the standard String.toUpperFirst() operation.
+ */
+ public void testStringToUpperFirst() {
+ EOperation operation = getOperation(AcceleoStandardLibrary.PRIMITIVE_STRING_NAME,
+ AcceleoStandardLibrary.OPERATION_STRING_TOUPPERFIRST);
+
+ for (String value : stringValues) {
+ // string contains itself
+ Object result = evaluationEnvironment.callStandardOperation(operation, value);
+ final String expected;
+ if (value.length() == 0) {
+ expected = value;
+ } else {
+ expected = Character.toUpperCase(value.charAt(0)) + value.substring(1);
+ }
+ assertEquals("Standard String.toUpperFirst() operation did not return the expect result.",
+ expected, result);
+ }
+ }
+
+ /**
+ * Tests the behavior of the environment when calling for an undefined operation.
+ * <p>
+ * Expects an {@link UnsupportedOperationException} to be thrown with an accurate error message.
+ * </p>
+ */
+ public void testUndefinedOperation() {
+ final EOperation operation = EcoreFactory.eINSTANCE.createEOperation();
+ operation.setName("undefinedOperation");
+ operation.setEType(EcorePackage.eINSTANCE.getEString());
+ final EAnnotation acceleoAnnotation = EcoreFactory.eINSTANCE.createEAnnotation();
+ acceleoAnnotation.setSource("MTL");
+ operation.getEAnnotations().add(acceleoAnnotation);
+
+ try {
+ evaluationEnvironment.callStandardOperation(operation, "source");
+ fail("Expected Unsupported Operation hasn't been thrown by the evaluation environment.");
+ } catch (UnsupportedOperationException e) {
+ // Expected behavior
+ final String expectedErrMsg = "undefinedOperation()";
+ assertTrue("Exception hasn't been affected an accurate error message", e.getMessage().contains(
+ expectedErrMsg));
+ }
+ }
+
+ /**
+ * Returns the operation named <code>operationName</code> registered against the type
+ * <code>typeName</code> in the standard library.
+ *
+ * @param typeName
+ * Name of the classifier we seek an operation of.
+ * @return The sought operation.
+ */
+ private EOperation getOperation(String typeName, String operationName) {
+ final List<EOperation> candidates = stdLib.get(typeName);
+ for (EOperation candidate : candidates) {
+ if (candidate.getName().equals(operationName)) {
+ return candidate;
+ }
+ }
+ // not guarded
+ return null;
+ }
+}
diff --git a/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/listeners/AcceleoListenersTest.java b/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/listeners/AcceleoListenersTest.java
new file mode 100644
index 0000000..83ed823
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/listeners/AcceleoListenersTest.java
@@ -0,0 +1,217 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.acceleo.engine.tests.unit.listeners;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.eclipse.emf.common.util.TreeIterator;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.acceleo.model.mtl.Block;
+import org.eclipse.acceleo.engine.event.AcceleoTextGenerationEvent;
+import org.eclipse.acceleo.engine.event.AcceleoTextGenerationListener;
+import org.eclipse.acceleo.engine.service.AcceleoService;
+import org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest;
+
+/**
+ * This test allows us to check the behavior of the listeners that can be set up on the Acceleo generation engine.
+ *
+ * @author <a href="mailto:laurent.goubet@obeo.fr">Laurent Goubet</a>
+ */
+public class AcceleoListenersTest extends AbstractAcceleoTest {
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest#getModuleLocation()
+ */
+ @Override
+ public String getModuleLocation() {
+ return "data/Listeners/listeners.mtl"; //$NON-NLS-1$
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest#getResultPath()
+ */
+ @Override
+ public String getResultPath() {
+ return "Listeners"; //$NON-NLS-1$
+ }
+
+ /**
+ * Tests that the generation listeners are accurately called.
+ *
+ * @throws IOException
+ * Thrown when the output cannot be saved.
+ */
+ public void testAcceleoGenerationListener() throws IOException {
+ generationRoot = new File(getGenerationRootPath("Listeners")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoGenerationCountListener listener = new AcceleoGenerationCountListener();
+ AcceleoService.addListener(listener);
+
+ AcceleoService.doGenerate(module, "test_generation_listeners", inputModel, generationRoot, false); //$NON-NLS-1$
+
+ int eClassCount = 0;
+ final TreeIterator<EObject> iterator = inputModel.eAllContents();
+ while (iterator.hasNext()) {
+ EObject next = iterator.next();
+ if (next instanceof EClass) {
+ eClassCount++;
+ }
+ }
+
+ // We know 62 text generations were called. If this changes, check generated files.
+ final int generationCount = 62;
+ assertSame("Unexpected count of text generations.", generationCount, listener.generationCount); //$NON-NLS-1$
+ assertSame("Wrong count of generated files.", eClassCount, listener.generatedFileCount); //$NON-NLS-1$
+
+ AcceleoService.removeListener(listener);
+ }
+
+ /**
+ * Tests that the generation events are initialized with the accurated data.
+ *
+ * @throws IOException
+ * Thrown when the output cannot be saved.
+ */
+ public void testAcceleoGenerationEvent() throws IOException {
+ generationRoot = new File(getGenerationRootPath("Events")); //$NON-NLS-1$
+
+ AcceleoGenerationEventTestListener listener = new AcceleoGenerationEventTestListener();
+ AcceleoService.addListener(listener);
+
+ final Map<String, StringWriter> preview = AcceleoService.doGenerate(module,
+ "test_generation_event", inputModel, generationRoot, true); //$NON-NLS-1$
+
+ assertFalse("There should have been a preview generated.", preview.isEmpty()); //$NON-NLS-1$
+ assertSame("We expected a single preview to be available.", 1, preview.size()); //$NON-NLS-1$
+
+ final Entry<String, StringWriter> previewEntry = preview.entrySet().iterator().next();
+ // We know the file block is the first element of the second template
+ final EObject fileBlock = module.eContents().get(2).eContents().get(0);
+
+ // file generation event
+ assertSame("The FileBlock hasn't been set accurately on the file generation event.", //$NON-NLS-1$
+ fileBlock, listener.fileSourceBlock);
+ assertSame("Source element hasn't been set accurately on the file generation event.", inputModel, //$NON-NLS-1$
+ listener.fileSourceElement);
+ assertEquals("File path hasn't been set accurately on the file generation event.", previewEntry //$NON-NLS-1$
+ .getKey(), listener.generatedFile);
+
+ // text generation event
+ assertSame("The FileBlock hasn't been set accurately on the text generation event.", fileBlock, //$NON-NLS-1$
+ listener.textSourceBlock);
+ assertSame("Source element hasn't been set accurately on the text generation event.", inputModel, //$NON-NLS-1$
+ listener.textSourceElement);
+ assertEquals("File path hasn't been set accurately on the text generation event.", previewEntry //$NON-NLS-1$
+ .getKey(), listener.generatedFile);
+
+ AcceleoService.removeListener(listener);
+ }
+
+ /**
+ * This implementation of an AcceleoTextGenerationListener allows us to check that the accurate info is set on
+ * the generation events.
+ */
+ private class AcceleoGenerationEventTestListener implements AcceleoTextGenerationListener {
+ /** The generated text itself. */
+ String generatedText;
+
+ /** EObject for which text has been generated. */
+ EObject textSourceElement;
+
+ /** Block which triggered the text generation. */
+ Block textSourceBlock;
+
+ /** Computed path for the generated file. */
+ String generatedFile;
+
+ /** EObject for which a file has been created. */
+ EObject fileSourceElement;
+
+ /** Block for which this path has been calculated. */
+ Block fileSourceBlock;
+
+ /**
+ * Increases visibility of the default constructor.
+ */
+ public AcceleoGenerationEventTestListener() {
+ // increases visibility
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.acceleo.engine.event.AcceleoTextGenerationListener#textGenerated(org.eclipse.acceleo.engine.event.AcceleoTextGenerationEvent)
+ */
+ public void textGenerated(AcceleoTextGenerationEvent event) {
+ textSourceBlock = event.getBlock();
+ textSourceElement = event.getSource();
+ generatedText = event.getText();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.acceleo.engine.event.AcceleoTextGenerationListener#filePathComputed(org.eclipse.acceleo.engine.event.AcceleoTextGenerationEvent)
+ */
+ public void filePathComputed(AcceleoTextGenerationEvent event) {
+ fileSourceBlock = event.getBlock();
+ fileSourceElement = event.getSource();
+ generatedFile = event.getText();
+ }
+ }
+
+ /**
+ * This implementation of an AcceleoTextGenerationListener allows us to count the number of times the engine
+ * generated text.
+ */
+ private class AcceleoGenerationCountListener implements AcceleoTextGenerationListener {
+ /** This will be incremented for each call to {@link #textGenerated(AcceleoTextGenerationEvent)}. */
+ int generationCount;
+
+ /** This will be incremented for each call to {@link #filePathComputed(AcceleoTextGenerationEvent)}. */
+ int generatedFileCount;
+
+ /**
+ * Increases visibility of the default constructor.
+ */
+ public AcceleoGenerationCountListener() {
+ // increases visibility
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.acceleo.engine.event.AcceleoTextGenerationListener#textGenerated(org.eclipse.acceleo.engine.event.AcceleoTextGenerationEvent)
+ */
+ public void textGenerated(AcceleoTextGenerationEvent event) {
+ generationCount++;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.acceleo.engine.event.AcceleoTextGenerationListener#filePathComputed(org.eclipse.acceleo.engine.event.AcceleoTextGenerationEvent)
+ */
+ public void filePathComputed(AcceleoTextGenerationEvent event) {
+ generatedFileCount++;
+ }
+ }
+}
diff --git a/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/resolution/namesake/NamesakeGuardResolutionTest.java b/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/resolution/namesake/NamesakeGuardResolutionTest.java
new file mode 100644
index 0000000..387b536
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/resolution/namesake/NamesakeGuardResolutionTest.java
@@ -0,0 +1,165 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.acceleo.engine.tests.unit.resolution.namesake;
+
+import java.io.File;
+import java.io.IOException;
+
+import junit.framework.Assert;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.acceleo.model.mtl.Module;
+import org.eclipse.acceleo.common.utils.ModelUtils;
+import org.eclipse.acceleo.engine.service.AcceleoService;
+import org.eclipse.acceleo.engine.tests.AcceleoEngineTestPlugin;
+import org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest;
+
+/**
+ * This will test the behavior of the Acceleo engine when resolving name conflicts in guarded template calls.
+ *
+ * @author <a href="mailto:laurent.goubet@obeo.fr">Laurent Goubet</a>
+ */
+public class NamesakeGuardResolutionTest extends AbstractAcceleoTest {
+ {
+ try {
+ final URI inputModelURI = URI.createPlatformPluginURI('/' + AcceleoEngineTestPlugin.PLUGIN_ID + '/'
+ + "data/abstractClass.ecore", true); //$NON-NLS-1$
+ inputModel = ModelUtils.load(inputModelURI, resourceSet);
+ } catch (IOException e) {
+ fail("Error loading the input model."); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest#getModuleLocation()
+ */
+ @Override
+ public String getModuleLocation() {
+ // useless for this test as we won't call super#setup()
+ return ""; //$NON-NLS-1$
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest#getResultPath()
+ */
+ @Override
+ public String getResultPath() {
+ return "NamesakeResolution/Guard"; //$NON-NLS-1$
+ }
+
+ /**
+ * This will test the behavior of the Acceleo evaluation engine when resolving a template with namesakes on
+ * both its extended module and its imported module. No template is more specific than the other as far as
+ * parameters are concerned, but only the imported template has its guard evaluated to true. We then
+ * expect the engine to use the imported template.
+ */
+ public void testNamesakeGuard() throws IOException {
+ generationRoot = new File(getGenerationRootPath("NamesakeGuard")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("NamesakeGuard")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module, "test_namesake_guard", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+
+ for (File generated : getFiles(generationRoot)) {
+ final String content = getAbsoluteFileContent(generated.getAbsolutePath());
+ // We expect the called template to be the imported one
+ assertTrue(content.contains("imported.namesake_guard")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * This will test the behavior of the Acceleo evaluation engine when resolving a template with namesakes on
+ * both its extended module and its imported module. The extended template is less specific than the local
+ * and imported ones, yet the local one has its guard evaluated to false. We then expect the engine to use
+ * the imported template.
+ */
+ public void testNamesakeGuardImportSpecific() throws IOException {
+ generationRoot = new File(getGenerationRootPath("NamesakeGuardImportSpecific")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("NamesakeGuardImportSpecific")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module,
+ "test_namesake_guard_import_specific", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+
+ for (File generated : getFiles(generationRoot)) {
+ final String content = getAbsoluteFileContent(generated.getAbsolutePath());
+ // We expect the called template to be the imported one
+ assertTrue(content.contains("imported.namesake_guard_import_specific")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * This will test the behavior of the Acceleo evaluation engine when resolving a template with namesakes on
+ * both its extended module and its imported module. The imported template is less specific than the local
+ * and extended ones, yet both have their guards evaluated to false. We then expect the engine to use the
+ * imported template even though less specific.
+ */
+ public void testNamesakeGuardedSpecific() throws IOException {
+ generationRoot = new File(getGenerationRootPath("NamesakeGuardedSpecific")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("NamesakeGuardedSpecific")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module, "test_namesake_guarded_specific", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+
+ for (File generated : getFiles(generationRoot)) {
+ final String content = getAbsoluteFileContent(generated.getAbsolutePath());
+ // We expect the called template to be the imported one
+ assertTrue(content.contains("imported.namesake_guarded_specific")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest#setUp()
+ */
+ @Override
+ protected void setUp() throws Exception {
+ String localTemplateLocation = "data/Resolution/Namesake/Guard/local.mtl"; //$NON-NLS-1$
+ String importedTemplateLocation = "data/Resolution/Namesake/Guard/imported.mtl"; //$NON-NLS-1$
+ String extendedTemplateLocation = "data/Resolution/Namesake/Guard/extended.mtl"; //$NON-NLS-1$
+
+ parse(importedTemplateLocation);
+ parse(extendedTemplateLocation);
+ Resource localResource = parse(localTemplateLocation);
+
+ EObject rootTemplate = localResource.getContents().get(0);
+ if (rootTemplate instanceof Module) {
+ module = (Module)rootTemplate;
+ } else {
+ Assert.fail("Failed to parse the templates."); //$NON-NLS-1$
+ }
+ }
+}
diff --git a/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/resolution/namesake/ParameterTypeNarrowingResolutionTest.java b/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/resolution/namesake/ParameterTypeNarrowingResolutionTest.java
new file mode 100644
index 0000000..0b5095e
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/resolution/namesake/ParameterTypeNarrowingResolutionTest.java
@@ -0,0 +1,316 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.acceleo.engine.tests.unit.resolution.namesake;
+
+import java.io.File;
+import java.io.IOException;
+
+import junit.framework.Assert;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.acceleo.model.mtl.Module;
+import org.eclipse.acceleo.common.utils.ModelUtils;
+import org.eclipse.acceleo.engine.service.AcceleoService;
+import org.eclipse.acceleo.engine.tests.AcceleoEngineTestPlugin;
+import org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest;
+
+/**
+ * This will test the behavior of the Acceleo engine when resolving name conflicts in template calls. Templates
+ * will narrow the parameter type : some have parameter types "EClassifier" while namesakes have "EClass".
+ *
+ * @author <a href="mailto:laurent.goubet@obeo.fr">Laurent Goubet</a>
+ */
+public class ParameterTypeNarrowingResolutionTest extends AbstractAcceleoTest {
+ {
+ try {
+ final URI inputModelURI = URI.createPlatformPluginURI('/' + AcceleoEngineTestPlugin.PLUGIN_ID + '/'
+ + "data/abstractClass.ecore", true); //$NON-NLS-1$
+ inputModel = ModelUtils.load(inputModelURI, resourceSet);
+ } catch (IOException e) {
+ fail("Error loading the input model."); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest#getModuleLocation()
+ */
+ @Override
+ public String getModuleLocation() {
+ // useless for this test as we won't call super#setup()
+ return ""; //$NON-NLS-1$
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest#getResultPath()
+ */
+ @Override
+ public String getResultPath() {
+ return "NamesakeResolution/ParameterNarrowing"; //$NON-NLS-1$
+ }
+
+ /**
+ * This will test the behavior of the Acceleo evaluation engine when resolving a template with namesakes on
+ * both its extended module and its imported module. We expect it to select the most specific one which is
+ * here on the extended template.
+ */
+ public void testNamesakeResolutionExtendMostSpecific() throws IOException {
+ generationRoot = new File(getGenerationRootPath("NamesakeExtendMostSpecific")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("NamesakeExtendMostSpecific")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module, "test_namesake_3_extend_specific", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+
+ for (File generated : getFiles(generationRoot)) {
+ final String content = getAbsoluteFileContent(generated.getAbsolutePath());
+ // We expect the called template to be the extended one
+ assertTrue(content.contains("extended.namesake_3_extend_specific")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * This will test the behavior of the Acceleo evaluation engine when resolving a template defined with the
+ * same name on both its extended module and its imported module yet not present on the local module. We
+ * expect it to select the most specific one which is here on the extended template.
+ */
+ public void testNamesakeResolutionExternalExtendSpecific() throws IOException {
+ generationRoot = new File(getGenerationRootPath("NamesakeExternalExtendSpecific")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("NamesakeExternalExtendSpecific")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module,
+ "test_namesake_external_extend_specific", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+
+ for (File generated : getFiles(generationRoot)) {
+ final String content = getAbsoluteFileContent(generated.getAbsolutePath());
+ // We expect the called template to be the extended one
+ assertTrue(content.contains("extended.namesake_external_extend_specific")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * This will test the behavior of the Acceleo evaluation engine when resolving a template defined with the
+ * same name on both its extended module and its imported module yet not present on the local module. We
+ * expect it to select the most specific one which is here on the imported template.
+ */
+ public void testNamesakeResolutionExternalImportSpecific() throws IOException {
+ generationRoot = new File(getGenerationRootPath("NamesakeExternalImportSpecific")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("NamesakeExternalImportSpecific")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module,
+ "test_namesake_external_import_specific", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+
+ for (File generated : getFiles(generationRoot)) {
+ final String content = getAbsoluteFileContent(generated.getAbsolutePath());
+ // We expect the called template to be the imported one
+ assertTrue(content.contains("imported.namesake_external_import_specific")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * This will test the behavior of the Acceleo evaluation engine when resolving a template with namesakes on
+ * both its extended module and its imported module. We expect it to select the most specific one which is
+ * here on the imported template.
+ */
+ public void testNamesakeResolutionImportMostSpecific() throws IOException {
+ generationRoot = new File(getGenerationRootPath("NamesakeImportMostSpecific")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("NamesakeImportMostSpecific")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module, "test_namesake_3_import_specific", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+
+ for (File generated : getFiles(generationRoot)) {
+ final String content = getAbsoluteFileContent(generated.getAbsolutePath());
+ // We expect the called template to be the imported one
+ assertTrue(content.contains("imported.namesake_3_import_specific")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * This will test the behavior of the Acceleo evaluation engine when resolving a template with namesakes on
+ * both its extended module and its imported module. We expect it to select the most specific one which is
+ * here on the local template.
+ */
+ public void testNamesakeResolutionLocalMostSpecific() throws IOException {
+ generationRoot = new File(getGenerationRootPath("NamesakeLocalMostSpecific")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("NamesakeLocalMostSpecific")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module, "test_namesake_3_local_specific", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+
+ for (File generated : getFiles(generationRoot)) {
+ final String content = getAbsoluteFileContent(generated.getAbsolutePath());
+ // We expect the called template to be the local one
+ assertTrue(content.contains("local.namesake_3_local_specific")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * This will test the behavior of the Acceleo evaluation engine when resolving a template with namesakes on
+ * its extended module. We expect it to select the most specific one which is here on the extended
+ * template.
+ */
+ public void testNamesakeResolutionOnExtendExtendSpecific() throws IOException {
+ generationRoot = new File(getGenerationRootPath("NamesakeOnExtendExtendSpecific")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("NamesakeOnExtendExtendSpecific")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module,
+ "test_namesake_extend_extend_specific", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+
+ for (File generated : getFiles(generationRoot)) {
+ final String content = getAbsoluteFileContent(generated.getAbsolutePath());
+ // We expect the called template to be the extended one
+ assertTrue(content.contains("extended.namesake_extend_extend_specific")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * This will test the behavior of the Acceleo evaluation engine when resolving a template with namesakes on
+ * its extended module. We expect it to select the most specific one which is here on the local template.
+ */
+ public void testNamesakeResolutionOnExtendLocalSpecific() throws IOException {
+ generationRoot = new File(getGenerationRootPath("NamesakeOnExtendLocalSpecific")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("NamesakeOnExtendLocalSpecific")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module,
+ "test_namesake_extend_local_specific", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+
+ for (File generated : getFiles(generationRoot)) {
+ final String content = getAbsoluteFileContent(generated.getAbsolutePath());
+ // We expect the called template to be the local one
+ assertTrue(content.contains("local.namesake_extend_local_specific")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * This will test the behavior of the Acceleo evaluation engine when resolving a template with namesakes on
+ * its imported module. We expect it to select the most specific one which is here on the imported
+ * template.
+ */
+ public void testNamesakeResolutionOnImportImportSpecific() throws IOException {
+ generationRoot = new File(getGenerationRootPath("NamesakeOnImportImportSpecific")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("NamesakeOnImportImportSpecific")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module,
+ "test_namesake_import_import_specific", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+
+ for (File generated : getFiles(generationRoot)) {
+ final String content = getAbsoluteFileContent(generated.getAbsolutePath());
+ // We expect the called template to be the imported one
+ assertTrue(content.contains("imported.namesake_import_import_specific")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * This will test the behavior of the Acceleo evaluation engine when resolving a template with namesakes on
+ * its imported module. We expect it to select the most specific one which is here on the local template.
+ */
+ public void testNamesakeResolutionOnImportLocalSpecific() throws IOException {
+ generationRoot = new File(getGenerationRootPath("NamesakeOnImportLocalSpecific")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("NamesakeOnImportLocalSpecific")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module,
+ "test_namesake_import_local_specific", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+
+ for (File generated : getFiles(generationRoot)) {
+ final String content = getAbsoluteFileContent(generated.getAbsolutePath());
+ // We expect the called template to be the local one
+ assertTrue(content.contains("local.namesake_import_local_specific")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest#setUp()
+ */
+ @Override
+ protected void setUp() throws Exception {
+ String localTemplateLocation = "data/Resolution/Namesake/ParameterTypeNarrowing/local.mtl"; //$NON-NLS-1$
+ String importedTemplateLocation = "data/Resolution/Namesake/ParameterTypeNarrowing/imported.mtl"; //$NON-NLS-1$
+ String extendedTemplateLocation = "data/Resolution/Namesake/ParameterTypeNarrowing/extended.mtl"; //$NON-NLS-1$
+
+ parse(importedTemplateLocation);
+ parse(extendedTemplateLocation);
+ Resource localResource = parse(localTemplateLocation);
+
+ EObject rootTemplate = localResource.getContents().get(0);
+ if (rootTemplate instanceof Module) {
+ module = (Module)rootTemplate;
+ } else {
+ Assert.fail("Failed to parse the templates."); //$NON-NLS-1$
+ }
+ }
+}
diff --git a/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/resolution/namesake/SimpleNamesakeResolutionTest.java b/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/resolution/namesake/SimpleNamesakeResolutionTest.java
new file mode 100644
index 0000000..0e40d07
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/resolution/namesake/SimpleNamesakeResolutionTest.java
@@ -0,0 +1,210 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.acceleo.engine.tests.unit.resolution.namesake;
+
+import java.io.File;
+import java.io.IOException;
+
+import junit.framework.Assert;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.acceleo.model.mtl.Module;
+import org.eclipse.acceleo.common.utils.ModelUtils;
+import org.eclipse.acceleo.engine.service.AcceleoService;
+import org.eclipse.acceleo.engine.tests.AcceleoEngineTestPlugin;
+import org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest;
+
+/**
+ * This will test the behavior of the Acceleo engine when resolving &quot;simple&quot; name conflicts in template
+ * calls. These are considered simple conflicts since no overriding or changes in parameter count is present.
+ *
+ * @author <a href="mailto:laurent.goubet@obeo.fr">Laurent Goubet</a>
+ */
+public class SimpleNamesakeResolutionTest extends AbstractAcceleoTest {
+ {
+ try {
+ final URI inputModelURI = URI.createPlatformPluginURI('/' + AcceleoEngineTestPlugin.PLUGIN_ID + '/'
+ + "data/abstractClass.ecore", true); //$NON-NLS-1$
+ inputModel = ModelUtils.load(inputModelURI, resourceSet);
+ } catch (IOException e) {
+ fail("Error loading the input model."); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest#getModuleLocation()
+ */
+ @Override
+ public String getModuleLocation() {
+ // useless for this test as we won't call super#setup()
+ return ""; //$NON-NLS-1$
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest#getResultPath()
+ */
+ @Override
+ public String getResultPath() {
+ return "NamesakeResolution/Simple"; //$NON-NLS-1$
+ }
+
+ /**
+ * This will test the behavior of the Acceleo evaluation engine when resolving a template with namesakes on
+ * its extended module. We expect it to select the one present on the current module.
+ */
+ public void testNameResolutionConflictOnExtended() throws IOException {
+ generationRoot = new File(getGenerationRootPath("NamesakeExtendConflict")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("NamesakeExtendConflict")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module, "test_namesake_extend", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+
+ for (File generated : getFiles(generationRoot)) {
+ final String content = getAbsoluteFileContent(generated.getAbsolutePath());
+ // We expect the called template to be the local one
+ assertTrue(content.contains("local.namesake_extend")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * This will test the behavior of the Acceleo evaluation engine when resolving a template with namesakes on
+ * its imported module. We expect it to select the one present on the current module.
+ */
+ public void testNameResolutionConflictOnImported() throws IOException {
+ generationRoot = new File(getGenerationRootPath("NamesakeImportConflict")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("NamesakeImportConflict")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module, "test_namesake_import", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+
+ for (File generated : getFiles(generationRoot)) {
+ final String content = getAbsoluteFileContent(generated.getAbsolutePath());
+ // We expect the called template to be the local one
+ assertTrue(content.contains("local.namesake_import")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * This will test the behavior of the Acceleo evaluation engine when resolving a template not present ont the
+ * current module but with namesakes on its extended and imported modules. We expect it to select the one
+ * present on the extended module.
+ */
+ public void testNameResolutionExternalConflict() throws IOException {
+ generationRoot = new File(getGenerationRootPath("NamesakeExternalConflict")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("NamesakeExternalConflict")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module, "test_namesake_external", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+
+ for (File generated : getFiles(generationRoot)) {
+ final String content = getAbsoluteFileContent(generated.getAbsolutePath());
+ // We expect the called template to be the extend one
+ assertTrue(content.contains("extended.namesake_external")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * This will test tge behavior of the Acceleo evaluation engine when resolving a template with namesakes
+ * sharing parameters with distinct names. We expect the engine to select the most specific template
+ * regardless of parameter names.
+ */
+ public void testNameResolutionDistinctParamNames() throws IOException {
+ generationRoot = new File(getGenerationRootPath("NamesakeDistinctParameterNames")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("NamesakeDistinctParameterNames")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module, "test_namesake_distinct_param_name", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+
+ for (File generated : getFiles(generationRoot)) {
+ final String content = getAbsoluteFileContent(generated.getAbsolutePath());
+ // We expect the called template to be the local one
+ assertTrue(content.contains("local.namesake_param_names")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * This will test the behavior of the Acceleo evaluation engine when resolving a template with namesakes on
+ * each three possible places : extended, current and imported module. We expect it to select the one
+ * present on the current module.
+ */
+ public void testNameResolutionPriority() throws IOException {
+ generationRoot = new File(getGenerationRootPath("NamesakePriority")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("NamesakePriority")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module, "test_namesake_3", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+
+ for (File generated : getFiles(generationRoot)) {
+ final String content = getAbsoluteFileContent(generated.getAbsolutePath());
+ // We expect the called template to be the local one
+ assertTrue(content.contains("local.namesake_3")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest#setUp()
+ */
+ @Override
+ protected void setUp() throws Exception {
+ String localTemplateLocation = "data/Resolution/Namesake/Simple/local.mtl"; //$NON-NLS-1$
+ String importedTemplateLocation = "data/Resolution/Namesake/Simple/imported.mtl"; //$NON-NLS-1$
+ String extendedTemplateLocation = "data/Resolution/Namesake/Simple/extended.mtl"; //$NON-NLS-1$
+
+ parse(importedTemplateLocation);
+ parse(extendedTemplateLocation);
+ Resource localResource = parse(localTemplateLocation);
+
+ EObject rootTemplate = localResource.getContents().get(0);
+ if (rootTemplate instanceof Module) {
+ module = (Module)rootTemplate;
+ } else {
+ Assert.fail("Failed to parse the templates."); //$NON-NLS-1$
+ }
+ }
+}
diff --git a/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/resolution/override/OverrideGuardResolutionTest.java b/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/resolution/override/OverrideGuardResolutionTest.java
new file mode 100644
index 0000000..e2adaaf
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/resolution/override/OverrideGuardResolutionTest.java
@@ -0,0 +1,168 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.acceleo.engine.tests.unit.resolution.override;
+
+import java.io.File;
+import java.io.IOException;
+
+import junit.framework.Assert;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.acceleo.model.mtl.Module;
+import org.eclipse.acceleo.common.utils.ModelUtils;
+import org.eclipse.acceleo.engine.service.AcceleoService;
+import org.eclipse.acceleo.engine.tests.AcceleoEngineTestPlugin;
+import org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest;
+
+/**
+ * This will test the behavior of the Acceleo engine when resolving overriding template calls. Overriding
+ * templates define guards, some of which <code>true</code>.
+ *
+ * @author <a href="mailto:laurent.goubet@obeo.fr">Laurent Goubet</a>
+ */
+public class OverrideGuardResolutionTest extends AbstractAcceleoTest {
+ {
+ try {
+ final URI inputModelURI = URI.createPlatformPluginURI('/' + AcceleoEngineTestPlugin.PLUGIN_ID + '/'
+ + "data/abstractClass.ecore", true); //$NON-NLS-1$
+ inputModel = ModelUtils.load(inputModelURI, resourceSet);
+ } catch (IOException e) {
+ fail("Error loading the input model."); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest#getModuleLocation()
+ */
+ @Override
+ public String getModuleLocation() {
+ // useless for this test as we won't call super#setup()
+ return ""; //$NON-NLS-1$
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest#getResultPath()
+ */
+ @Override
+ public String getResultPath() {
+ return "OverrideResolution/Guard"; //$NON-NLS-1$
+ }
+
+ /**
+ * This will test the behavior of the Acceleo evaluation engine when resolving a template defined in the
+ * imported module yet overriden in both the current module and the extended module. Local and Extended
+ * are the most specific, but their guard evaluates to false. We expect the imported template to be
+ * called.
+ */
+ public void testOverrideSpecificGuarded() throws IOException {
+ generationRoot = new File(getGenerationRootPath("SpecificGuarded")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("SpecificGuarded")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module,
+ "test_resolution_override_specific_guarded", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+
+ for (File generated : getFiles(generationRoot)) {
+ final String content = getAbsoluteFileContent(generated.getAbsolutePath());
+ // We expect the called template to be the imported one
+ assertTrue(content.contains("imported.override_resolution_definition_guard")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * This will test the behavior of the Acceleo evaluation engine when resolving a template defined in the
+ * exended module and overriden in the current module. The Local template is the most specific and its
+ * super has its guard evaluated to false. We expect the local template to be called.
+ */
+ public void testOverrideLocalDefinitionGuarded() throws IOException {
+ generationRoot = new File(getGenerationRootPath("LocalDefinitionGuarded")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("LocalDefinitionGuarded")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module,
+ "test_resolution_local_override_definition_guarded", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+
+ for (File generated : getFiles(generationRoot)) {
+ final String content = getAbsoluteFileContent(generated.getAbsolutePath());
+ // We expect the called template to be the local override
+ assertTrue(content.contains("local.override_resolution_local_guard")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * This will test the behavior of the Acceleo evaluation engine when resolving a template defined in the
+ * imported module yet overriden in the extended module. The imported module's template has its guard
+ * evaluating to false, we then expect the extended one to be called.
+ */
+ public void testOverrideParameterNarrowingExternal() throws IOException {
+ generationRoot = new File(getGenerationRootPath("ExternalDefinitionGuarded")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("ExternalDefinitionGuarded")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module,
+ "test_resolution_external_override_definition_guarded", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+
+ for (File generated : getFiles(generationRoot)) {
+ final String content = getAbsoluteFileContent(generated.getAbsolutePath());
+ // We expect the called template to be the extend override
+ assertTrue(content.contains("extended.override_resolution_external_guard")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest#setUp()
+ */
+ @Override
+ protected void setUp() throws Exception {
+ String localTemplateLocation = "data/Resolution/Override/Guard/local.mtl"; //$NON-NLS-1$
+ String importedTemplateLocation = "data/Resolution/Override/Guard/imported.mtl"; //$NON-NLS-1$
+ String extendedTemplateLocation = "data/Resolution/Override/Guard/extended.mtl"; //$NON-NLS-1$
+
+ // parse imported template before since it is extended by the extended template which in turn is
+ // extended by the local
+ parse(importedTemplateLocation);
+ parse(extendedTemplateLocation);
+ Resource localResource = parse(localTemplateLocation);
+
+ EObject rootTemplate = localResource.getContents().get(0);
+ if (rootTemplate instanceof Module) {
+ module = (Module)rootTemplate;
+ } else {
+ Assert.fail("Failed to parse the templates."); //$NON-NLS-1$
+ }
+ }
+}
diff --git a/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/resolution/override/OverrideParameterTypeNarrowingResolutionTest.java b/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/resolution/override/OverrideParameterTypeNarrowingResolutionTest.java
new file mode 100644
index 0000000..297c332
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/resolution/override/OverrideParameterTypeNarrowingResolutionTest.java
@@ -0,0 +1,161 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.acceleo.engine.tests.unit.resolution.override;
+
+import java.io.File;
+import java.io.IOException;
+
+import junit.framework.Assert;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.acceleo.model.mtl.Module;
+import org.eclipse.acceleo.common.utils.ModelUtils;
+import org.eclipse.acceleo.engine.service.AcceleoService;
+import org.eclipse.acceleo.engine.tests.AcceleoEngineTestPlugin;
+import org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest;
+
+/**
+ * This will test the behavior of the Acceleo engine when resolving overriding template calls. Overriding
+ * templates narrow their parameter types.
+ *
+ * @author <a href="mailto:laurent.goubet@obeo.fr">Laurent Goubet</a>
+ */
+public class OverrideParameterTypeNarrowingResolutionTest extends AbstractAcceleoTest {
+ {
+ try {
+ final URI inputModelURI = URI.createPlatformPluginURI('/' + AcceleoEngineTestPlugin.PLUGIN_ID + '/'
+ + "data/abstractClass.ecore", true); //$NON-NLS-1$
+ inputModel = ModelUtils.load(inputModelURI, resourceSet);
+ } catch (IOException e) {
+ fail("Error loading the input model."); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest#getModuleLocation()
+ */
+ @Override
+ public String getModuleLocation() {
+ // useless for this test as we won't call super#setup()
+ return ""; //$NON-NLS-1$
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest#getResultPath()
+ */
+ @Override
+ public String getResultPath() {
+ return "OverrideResolution/ParameterTypeNarrowing"; //$NON-NLS-1$
+ }
+
+ /**
+ * This will test the behavior of the Acceleo evaluation engine when resolving a template defined in the
+ * imported module yet overriden in both the current module and the extended module.
+ */
+ public void testOverrideParameterNarrowing() throws IOException {
+ generationRoot = new File(getGenerationRootPath("ParameterNarrowing")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("ParameterNarrowing")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module, "test_resolution_override_specific", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+
+ for (File generated : getFiles(generationRoot)) {
+ final String content = getAbsoluteFileContent(generated.getAbsolutePath());
+ // We expect the called template to be the local override
+ assertTrue(content.contains("local.parameter_narrowing_3_local_override")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * This will test the behavior of the Acceleo evaluation engine when resolving a template defined in the
+ * exended module and overriden in the current module.
+ */
+ public void testOverrideParameterNarrowingLocal() throws IOException {
+ generationRoot = new File(getGenerationRootPath("ParameterNarrowingLocal")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("ParameterNarrowingLocal")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module, "test_resolution_local_override", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+
+ for (File generated : getFiles(generationRoot)) {
+ final String content = getAbsoluteFileContent(generated.getAbsolutePath());
+ // We expect the called template to be the local override
+ assertTrue(content.contains("local.parameter_narrowing_local_override")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * This will test the behavior of the Acceleo evaluation engine when resolving a template defined in the
+ * imported module yet overriden in the extended module.
+ */
+ public void testOverrideParameterNarrowingExternal() throws IOException {
+ generationRoot = new File(getGenerationRootPath("ParameterNarrowingExternal")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("ParameterNarrowingExternal")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module, "test_resolution_external_override", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+
+ for (File generated : getFiles(generationRoot)) {
+ final String content = getAbsoluteFileContent(generated.getAbsolutePath());
+ // We expect the called template to be the extend override
+ assertTrue(content.contains("extended.parameter_narrowing_external_override")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest#setUp()
+ */
+ @Override
+ protected void setUp() throws Exception {
+ String localTemplateLocation = "data/Resolution/Override/ParameterTypeNarrowing/local.mtl"; //$NON-NLS-1$
+ String importedTemplateLocation = "data/Resolution/Override/ParameterTypeNarrowing/imported.mtl"; //$NON-NLS-1$
+ String extendedTemplateLocation = "data/Resolution/Override/ParameterTypeNarrowing/extended.mtl"; //$NON-NLS-1$
+
+ // parse imported template before since it is extended by the extended template which in turn is
+ // extended by the local
+ parse(importedTemplateLocation);
+ parse(extendedTemplateLocation);
+ Resource localResource = parse(localTemplateLocation);
+
+ EObject rootTemplate = localResource.getContents().get(0);
+ if (rootTemplate instanceof Module) {
+ module = (Module)rootTemplate;
+ } else {
+ Assert.fail("Failed to parse the templates."); //$NON-NLS-1$
+ }
+ }
+}
diff --git a/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/resolution/override/SimpleOverridesResolutionTest.java b/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/resolution/override/SimpleOverridesResolutionTest.java
new file mode 100644
index 0000000..e6def7e
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/resolution/override/SimpleOverridesResolutionTest.java
@@ -0,0 +1,263 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.acceleo.engine.tests.unit.resolution.override;
+
+import java.io.File;
+import java.io.IOException;
+
+import junit.framework.Assert;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.acceleo.model.mtl.Module;
+import org.eclipse.acceleo.common.utils.ModelUtils;
+import org.eclipse.acceleo.engine.service.AcceleoService;
+import org.eclipse.acceleo.engine.tests.AcceleoEngineTestPlugin;
+import org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest;
+
+/**
+ * This will test the behavior of the Acceleo engine when resolving &quot;simple&quot; overriding template calls.
+ * These are considered simple overrides since no parameter narrowing is done.
+ *
+ * @author <a href="mailto:laurent.goubet@obeo.fr">Laurent Goubet</a>
+ */
+public class SimpleOverridesResolutionTest extends AbstractAcceleoTest {
+ {
+ try {
+ final URI inputModelURI = URI.createPlatformPluginURI('/' + AcceleoEngineTestPlugin.PLUGIN_ID + '/'
+ + "data/abstractClass.ecore", true); //$NON-NLS-1$
+ inputModel = ModelUtils.load(inputModelURI, resourceSet);
+ } catch (IOException e) {
+ fail("Error loading the input model."); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest#getModuleLocation()
+ */
+ @Override
+ public String getModuleLocation() {
+ // useless for this test as we won't call super#setup()
+ return ""; //$NON-NLS-1$
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest#getResultPath()
+ */
+ @Override
+ public String getResultPath() {
+ return "OverrideResolution/Simple"; //$NON-NLS-1$
+ }
+
+ /**
+ * This will test the behavior of the Acceleo evaluation engine when resolving a template defined in the
+ * imported module but overriden in the extended module called directly.
+ */
+ public void testExtendOverrideDirectCall() throws IOException {
+ generationRoot = new File(getGenerationRootPath("ExtendOverrideDirectCall")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("ExtendOverrideDirectCall")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module, "test_extend_overriden_direct_call", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+
+ for (File generated : getFiles(generationRoot)) {
+ final String content = getAbsoluteFileContent(generated.getAbsolutePath());
+ // We expect the actually called template to be the extend override
+ assertTrue(content.contains("extended.extend_overriden")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * This will test the behavior of the Acceleo evaluation engine when resolving a template defined in the
+ * imported module but overriden in the extended module called indirectly.
+ */
+ public void testExtendOverrideIndirectCall() throws IOException {
+ generationRoot = new File(getGenerationRootPath("ExtendOverrideIndirectCall")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("ExtendOverrideIndirectCall")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module,
+ "test_extend_overriden_indirect_call", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+
+ for (File generated : getFiles(generationRoot)) {
+ final String content = getAbsoluteFileContent(generated.getAbsolutePath());
+ // We expect the actually called template to be the extend override
+ assertTrue(content.contains("extended.extend_overriden")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * This will test the behavior of the Acceleo evaluation engine when resolving a template defined in the
+ * extended module yet locally overriden called directly.
+ */
+ public void testLocalOverrideDirectCall() throws IOException {
+ generationRoot = new File(getGenerationRootPath("LocalOverrideDirectCall")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("LocalOverrideDirectCall")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module, "test_local_overriden_direct_call", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+
+ for (File generated : getFiles(generationRoot)) {
+ final String content = getAbsoluteFileContent(generated.getAbsolutePath());
+ // We expect the actually called template to be the local override
+ assertTrue(content.contains("local.local_override")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * This will test the behavior of the Acceleo evaluation engine when resolving a template defined in the
+ * extended module yet locally overriden called indirectly
+ */
+ public void testLocalOverrideIndirectCall() throws IOException {
+ generationRoot = new File(getGenerationRootPath("LocalOverrideIndirectCall")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("LocalOverrideIndirectCall")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService
+ .doGenerate(module, "test_local_overriden_indirect_call", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+
+ for (File generated : getFiles(generationRoot)) {
+ final String content = getAbsoluteFileContent(generated.getAbsolutePath());
+ // We expect the actually called template to be the local override
+ assertTrue(content.contains("local.local_override")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * This will test the behavior of the Acceleo evaluation engine when resolving a template defined in the
+ * imported module yet overriden in both the current module and the extended module and called directly
+ * from the current module.
+ */
+ public void testOverridePriorityDirectCall() throws IOException {
+ generationRoot = new File(getGenerationRootPath("OverridePriorityDirectCall")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("OverridePriorityDirectCall")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module, "test_override_priority_direct", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+
+ for (File generated : getFiles(generationRoot)) {
+ final String content = getAbsoluteFileContent(generated.getAbsolutePath());
+ // We expect the called template to be the local override
+ assertTrue(content.contains("local.local_override_3")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * This will test the behavior of the Acceleo evaluation engine when resolving a template defined in the
+ * imported module yet overriden in both the current module and the extended module and called indirectly
+ * in the imported module.
+ */
+ public void testOverridePriorityIndirectCall() throws IOException {
+ generationRoot = new File(getGenerationRootPath("OverridePriorityIndirectCall")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("OverridePriorityIndirectCall")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module, "test_override_priority_indirect", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+
+ for (File generated : getFiles(generationRoot)) {
+ final String content = getAbsoluteFileContent(generated.getAbsolutePath());
+ // We expect the called template to be the local override
+ assertTrue(content.contains("local.local_override_3")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * This will test the behavior of the Acceleo evaluation engine when resolving a template defined in the
+ * imported module yet overriden in both the current module and the extended module and called indirectly
+ * in the extended module.
+ */
+ public void testOverridePriorityMidIndirectCall() throws IOException {
+ generationRoot = new File(getGenerationRootPath("OverridePriorityMidIndirectCall")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("OverridePriorityMidIndirectCall")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module,
+ "test_override_priority_indirect_extend", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+
+ for (File generated : getFiles(generationRoot)) {
+ final String content = getAbsoluteFileContent(generated.getAbsolutePath());
+ // We expect the called template to be the local override
+ assertTrue(content.contains("local.local_override_3")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest#setUp()
+ */
+ @Override
+ protected void setUp() throws Exception {
+ String localTemplateLocation = "data/Resolution/Override/Simple/local.mtl"; //$NON-NLS-1$
+ String importedTemplateLocation = "data/Resolution/Override/Simple/imported.mtl"; //$NON-NLS-1$
+ String extendedTemplateLocation = "data/Resolution/Override/Simple/extended.mtl"; //$NON-NLS-1$
+
+ // parse imported template before since it is extended by the extended template which in turn is
+ // extended by the local
+ parse(importedTemplateLocation);
+ parse(extendedTemplateLocation);
+ Resource localResource = parse(localTemplateLocation);
+
+ EObject rootTemplate = localResource.getContents().get(0);
+ if (rootTemplate instanceof Module) {
+ module = (Module)rootTemplate;
+ } else {
+ Assert.fail("Failed to parse the templates."); //$NON-NLS-1$
+ }
+ }
+}
diff --git a/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/utils/AcceleoEnginePluginTest.java b/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/utils/AcceleoEnginePluginTest.java
new file mode 100644
index 0000000..2c07db7
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/utils/AcceleoEnginePluginTest.java
@@ -0,0 +1,300 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.acceleo.engine.tests.unit.utils;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintStream;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.ILogListener;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.acceleo.engine.AcceleoEngineMessages;
+import org.eclipse.acceleo.engine.AcceleoEnginePlugin;
+import org.eclipse.acceleo.engine.tests.AcceleoEngineTestPlugin;
+
+/**
+ * Tests for the engine plug-in activator. Will mainly test behavior of utility methods it declares.
+ *
+ * @author <a href="mailto:laurent.goubet@obeo.fr">Laurent Goubet</a>
+ */
+@SuppressWarnings("nls")
+public class AcceleoEnginePluginTest extends TestCase {
+ /** Error messages to use for these tests. */
+ private static final String[] ERROR_MESSAGES = {"NullPointerException has been thrown.",
+ "failed to build.", "\u00ec", "test",};
+
+ /** Possible severities for an exception. */
+ private static final int[] ERROR_SEVERITIES = {IStatus.WARNING, IStatus.ERROR, IStatus.INFO,};
+
+ /** This will keep track of the last {@link IStatus} that has been logged. */
+ protected IStatus loggedStatus;
+
+ /** This listener will be used to keep track of {@link IStatus}es logged. */
+ private ILogListener logListener;
+
+ /** The output stream that will be used as a temporary System.err. */
+ private PrintStream temporaryErr;
+
+ /** File that will serve as an output for the temporary System.err. */
+ private File temporaryLog;
+
+ /**
+ * Tests the behavior of {@link AcceleoEnginePlugin#log(Exception, boolean)} passing an arbitrary exception
+ * other than {@link NullPointerException} and {@link CoreException} to be logged. Expects the exception
+ * to be logged with the specified severity. The error message should be the one specified in
+ * org.eclipse.acceleo.engine.acceleoenginemessages.properties with key &quot;AcceleoEnginePlugin.JavaException&quot;.
+ */
+ public void testLogExceptionArbitraryException() {
+ boolean blocker = false;
+ for (String message : ERROR_MESSAGES) {
+ final PrintStream systemErr = System.err;
+ // disables standard error to avoid all logged exception to be displayed in console.
+ System.setErr(temporaryErr);
+ AcceleoEnginePlugin.log(new IllegalArgumentException(message), blocker);
+ System.setErr(systemErr);
+
+ final String expectedMessage = AcceleoEngineMessages.getString("AcceleoEnginePlugin.JavaException");
+ final int expectedSeverity;
+ if (blocker) {
+ expectedSeverity = IStatus.ERROR;
+ } else {
+ expectedSeverity = IStatus.WARNING;
+ }
+ blocker = !blocker;
+
+ assertEquals("Unexpected message of the logged exception.", expectedMessage, loggedStatus
+ .getMessage());
+ assertEquals("Unexpected severity of the logged exception.", expectedSeverity, loggedStatus
+ .getSeverity());
+ assertEquals("Exception logged with unexpected plug-in ID.", AcceleoEnginePlugin.PLUGIN_ID,
+ loggedStatus.getPlugin());
+ }
+ }
+
+ /**
+ * Tests the behavior of {@link AcceleoEnginePlugin#log(Exception, boolean)} passing a {@link CoreException}
+ * to be logged. Expects the exception to be logged with the specified error message and severity.
+ */
+ public void testLogExceptionCoreException() {
+ for (int severity : ERROR_SEVERITIES) {
+ for (String message : ERROR_MESSAGES) {
+ final Status coreExceptionStatus = new Status(severity, AcceleoEngineTestPlugin.PLUGIN_ID,
+ message);
+ // disables standard error to avoid all logged exception to be displayed in console.
+ final PrintStream systemErr = System.err;
+ System.setErr(temporaryErr);
+ AcceleoEnginePlugin.log(new CoreException(coreExceptionStatus), true);
+ System.setErr(systemErr);
+
+ assertEquals("Unexpected message of the logged core exception.", message, loggedStatus
+ .getMessage());
+ assertEquals("Unexpected severity of the logged core exception.", severity, loggedStatus
+ .getSeverity());
+ assertEquals("Core exception logged with unexpected plug-in ID.",
+ AcceleoEngineTestPlugin.PLUGIN_ID, loggedStatus.getPlugin());
+ }
+ }
+ }
+
+ /**
+ * Tests the behavior of {@link AcceleoEnginePlugin#log(Exception, boolean)} with <code>null</code> as the
+ * exception argument. Expects a {@link NullPointerException} to be thrown.
+ */
+ public void testLogExceptionNullException() {
+ try {
+ AcceleoEnginePlugin.log((Exception)null, true);
+ fail("Logging null didn't throw expected NullPointerException.");
+ } catch (NullPointerException e) {
+ // This was expected behavior
+ }
+ }
+
+ /**
+ * Tests the behavior of {@link AcceleoEnginePlugin#log(Exception, boolean)} passing a
+ * {@link NullPointerException} to be logged. Expects the exception to be logged with the specified
+ * severity. The error message should be the one specified in
+ * org.eclipse.acceleo.engine.acceleoenginemessages.properties with key
+ * &quot;AcceleoEnginePlugin.ElementNotFound&quot;.
+ */
+ public void testLogExceptionNullPointerException() {
+ boolean blocker = false;
+ for (String message : ERROR_MESSAGES) {
+ // disables standard error to avoid all logged exception to be displayed in console.
+ final PrintStream systemErr = System.err;
+ System.setErr(temporaryErr);
+ AcceleoEnginePlugin.log(new NullPointerException(message), blocker);
+ System.setErr(systemErr);
+
+ final String expectedMessage = AcceleoEngineMessages.getString("AcceleoEnginePlugin.ElementNotFound");
+ final int expectedSeverity;
+ if (blocker) {
+ expectedSeverity = IStatus.ERROR;
+ } else {
+ expectedSeverity = IStatus.WARNING;
+ }
+ blocker = !blocker;
+
+ assertEquals("Unexpected message of the logged NullPointerException.", expectedMessage,
+ loggedStatus.getMessage());
+ assertEquals("Unexpected severity of the logged NullPointerException.", expectedSeverity,
+ loggedStatus.getSeverity());
+ assertEquals("NullPointerException logged with unexpected plug-in ID.",
+ AcceleoEnginePlugin.PLUGIN_ID, loggedStatus.getPlugin());
+ }
+ }
+
+ /**
+ * Tests the behavior of {@link AcceleoEnginePlugin#log(String, boolean)} with <code>null</code> as the
+ * message to be logged. Expects a new entry to be logged with the given severity and the message
+ * specified in org.eclipse.acceleo.engine.acceleoenginemessages.properties with key
+ * &quot;AcceleoEnginePlugin.UnexpectedException&quot;.
+ */
+ public void testLogMessageNullMessage() {
+ boolean blocker = false;
+ for (int i = 0; i < ERROR_MESSAGES.length; i++) {
+ final PrintStream systemErr = System.err;
+ // disables standard error to avoid all logged exception to be displayed in console.
+ System.setErr(temporaryErr);
+ AcceleoEnginePlugin.log((String)null, blocker);
+ System.setErr(systemErr);
+
+ final String expectedMessage = AcceleoEngineMessages.getString("AcceleoEnginePlugin.UnexpectedException");
+ final int expectedSeverity;
+ if (blocker) {
+ expectedSeverity = IStatus.ERROR;
+ } else {
+ expectedSeverity = IStatus.WARNING;
+ }
+ blocker = !blocker;
+
+ assertEquals("Unexpected message of the logged message.", expectedMessage, loggedStatus
+ .getMessage());
+ assertEquals("Unexpected severity of the logged message.", expectedSeverity, loggedStatus
+ .getSeverity());
+ assertEquals("Message logged with unexpected plug-in ID.", AcceleoEnginePlugin.PLUGIN_ID,
+ loggedStatus.getPlugin());
+ }
+ }
+
+ /**
+ * Tests the behavior of {@link AcceleoEnginePlugin#log(String, boolean)} with a valid message to be logged.
+ * Expects a new entry to be logged with the given severity and message.
+ */
+ public void testLogMessageValidMessage() {
+ boolean blocker = false;
+ for (String message : ERROR_MESSAGES) {
+ final PrintStream systemErr = System.err;
+ // disables standard error to avoid all logged exception to be displayed in console.
+ System.setErr(temporaryErr);
+ AcceleoEnginePlugin.log(message, blocker);
+ System.setErr(systemErr);
+
+ final int expectedSeverity;
+ if (blocker) {
+ expectedSeverity = IStatus.ERROR;
+ } else {
+ expectedSeverity = IStatus.WARNING;
+ }
+ blocker = !blocker;
+
+ assertEquals("Unexpected message logged.", message, loggedStatus.getMessage());
+ assertEquals("Unexpected severity of the logged message.", expectedSeverity, loggedStatus
+ .getSeverity());
+ assertEquals("Message logged with unexpected plug-in ID.", AcceleoEnginePlugin.PLUGIN_ID,
+ loggedStatus.getPlugin());
+ }
+ }
+
+ /**
+ * Tests the behavior of {@link AcceleoEnginePlugin#log(IStatus)} with <code>null</code> as the status to be
+ * logged. Expects a {@link NullPointerException} to be thrown with the given status' error message.
+ */
+ public void testLogStatusNullStatus() {
+ try {
+ AcceleoEnginePlugin.log(null);
+ fail("Logging null status didn't throw expected NullPointerException.");
+ } catch (NullPointerException e) {
+ // This ws expected behavior
+ }
+ }
+
+ /**
+ * Tests the behavior of {@link AcceleoEnginePlugin#log(IStatus)} with a valid status to be logged. Expects
+ * the status to be logged with the specified severity, error message and source plugin.
+ */
+ public void testLogStatusValidStatus() {
+ for (int severity : ERROR_SEVERITIES) {
+ for (String message : ERROR_MESSAGES) {
+ final Status status = new Status(severity, AcceleoEngineTestPlugin.PLUGIN_ID, message);
+ final PrintStream systemErr = System.err;
+ // disables standard error to avoid all logged exception to be displayed in console.
+ System.setErr(temporaryErr);
+ AcceleoEnginePlugin.log(status);
+ System.setErr(systemErr);
+
+ assertEquals("Unexpected message of the logged exception.", message, loggedStatus
+ .getMessage());
+ assertEquals("Unexpected severity of the logged exception.", severity, loggedStatus
+ .getSeverity());
+ assertEquals("Exception logged with unexpected plug-in ID.", AcceleoEngineTestPlugin.PLUGIN_ID,
+ loggedStatus.getPlugin());
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see junit.framework.TestCase#setUp()
+ */
+ @Override
+ protected void setUp() {
+ // Creates a log listener that will update the field loggedStatus as needed
+ logListener = new ILogListener() {
+ public void logging(IStatus status, String message) {
+ loggedStatus = status;
+ }
+ };
+ // Then sets it to listen to the log
+ AcceleoEnginePlugin.getDefault().getLog().addLogListener(logListener);
+
+ try {
+ // Creates temporary error log
+ final File dataDir = new File(FileLocator.toFileURL(
+ AcceleoEngineTestPlugin.getDefault().getBundle().getEntry("/data")).getFile());
+ temporaryLog = new File(dataDir.getAbsolutePath() + "/testLogErrorLog");
+ temporaryErr = new PrintStream(temporaryLog);
+ } catch (IOException e) {
+ fail("Couldn't create temporary error log.");
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see junit.framework.TestCase#tearDown()
+ */
+ @Override
+ protected void tearDown() {
+ AcceleoEnginePlugin.getDefault().getLog().removeLogListener(logListener);
+ if (temporaryErr != null) {
+ temporaryErr.close();
+ }
+ if (temporaryLog.exists()) {
+ temporaryLog.delete();
+ }
+ }
+}
diff --git a/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/utils/MessagesTest.java b/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/utils/MessagesTest.java
new file mode 100644
index 0000000..2f16193
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/utils/MessagesTest.java
@@ -0,0 +1,231 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.acceleo.engine.tests.unit.utils;
+
+import java.lang.reflect.Array;
+import java.util.HashSet;
+import java.util.Locale;
+
+import junit.framework.TestCase;
+
+import org.eclipse.acceleo.engine.AcceleoEngineMessages;
+
+/**
+ * Tests Messages class. These tests' successful completion heavily depends on
+ * org.eclipse.acceleo.engine.acceleoenginemessages.properties file contents.
+ *
+ * @author <a href="mailto:laurent.goubet@obeo.fr">Laurent Goubet</a>
+ */
+@SuppressWarnings( {"unchecked", "nls",})
+public class MessagesTest extends TestCase {
+ /** Expected result of the parameterisable keys (only used if locale is en). */
+ private final String[] expectedForParameterisable = {"Operation {0}({1}) is undefined on type {2}.",
+ "Could not create lost file for {0}. Lost content : {1}",
+ "Could not find public template {0} in module {1}.",};
+
+ /** Contains the expected results for the valid keys (only used if locale is en). */
+ private final String[] expectedForValidKeys = {"Start of user code",
+ "Cannot iterate on empty iteration.", "Cannot invoke non-public template for generation.",
+ "Arguments of a generation cannot be null.",};
+
+ /** These will be used when testing message retrieval with invalid keys. */
+ private final String[] invalidKeys = {"invalidKey", "AcceleoEvaluationContext.CleanUpError1", "", "\u00ec",};
+
+ /** Contains possible parameters for the messages. */
+ private final Object[] messageParameters = {null, "", "Foehn", -1, new Long(10), '\u0043', new HashSet(),
+ "0x6c9a.^\\/",};
+
+ /** These two are valid, parameterisable keys. See org.eclipse.acceleo.engine.acceleoenginemessages.properties. */
+ private final String[] parameterisableKeys = {"AcceleoEvaluationEnvironment.UndefinedOperation",
+ "AcceleoEvaluationContext.LostContent", "AcceleoService.UndefinedTemplate",};
+
+ /** These are valid, un-parameterisable keys. See org.eclipse.acceleo.engine.acceleoenginemessages.properties. */
+ private final String[] validKeys = {"usercode.start", "AcceleoEvaluationVisitor.NullForIteration",
+ "AcceleoEngine.IllegalTemplateInvocation", "AcceleoService.NullArguments",};
+
+ /**
+ * Tests {@link AcceleoEngineMessages#getString(String, Object...)} with an invalid key. Expects the String
+ *
+ * <pre>
+ * &quot;!&quot; + key + &quot;!&quot;
+ * </pre>
+ *
+ * to be returned. Parameters won't affect result here.
+ */
+ public void testFormattedGetStringInvalidKey() {
+ for (int i = 0; i < messageParameters.length; i++) {
+ for (int j = i; j < messageParameters.length; j++) {
+ final Object[] parameters = partialArrayCopy(messageParameters, i, j);
+ for (String invalidKey : invalidKeys) {
+ assertEquals("Unexpected result of getString() with an invalid key.",
+ '!' + invalidKey + '!', AcceleoEngineMessages.getString(invalidKey, parameters));
+ }
+ }
+ }
+ }
+
+ /**
+ * Tests {@link AcceleoEngineMessages#getString(String, Object...)} with <code>null</code> key. Expects a
+ * NullPointerException to be thrown. Parameters won't affect result here.
+ */
+ public void testFormattedGetStringNullKey() {
+ for (int i = 0; i < messageParameters.length; i++) {
+ for (int j = i; j < messageParameters.length; j++) {
+ final Object[] parameters = partialArrayCopy(messageParameters, i, j);
+ try {
+ AcceleoEngineMessages.getString(null, parameters);
+ fail("Calling getString() with null key did not throw NullPointerException.");
+ } catch (NullPointerException e) {
+ // This was expected
+ }
+ }
+ }
+ }
+
+ /**
+ * Tests {@link AcceleoEngineMessages#getString(String, Object...)} with valid keys.
+ * <p>
+ * If the System locale is configured for english language, expects the String associated to the key in
+ * the properties file to be returned with all occurences of <code>&quot;{[0-9]*}&quot;</code> replaced by
+ * the correct parameter if any. Otherwise, expects the key to have been found, and the parameters to be
+ * correctly substituted.
+ * </p>
+ */
+ public void testFormattedGetStringValidKey() {
+ for (int i = 0; i < messageParameters.length; i++) {
+ for (int j = i; j < messageParameters.length; j++) {
+ final Object[] parameters = partialArrayCopy(messageParameters, i, j);
+ for (int k = 0; k < parameterisableKeys.length; k++) {
+ String expectedResult = expectedForParameterisable[k];
+ int parameterCount = 0;
+ while (expectedResult.matches(".*\\{[0-9]+\\}.*") && parameterCount < parameters.length) {
+ if (parameters[parameterCount] == null) {
+ expectedResult = expectedResult.replaceFirst("\\{[0-9]+\\}", "null");
+ } else {
+ expectedResult = expectedResult.replaceFirst("\\{[0-9]+\\}",
+ parameters[parameterCount].toString());
+ }
+ parameterCount++;
+ }
+ Locale previousLocale = null;
+ if (Locale.getDefault() != Locale.ENGLISH) {
+ previousLocale = Locale.getDefault();
+ }
+ Locale.setDefault(Locale.ENGLISH);
+ assertEquals("Unexpected formatted String returned by getString(String, Object...).",
+ expectedResult, AcceleoEngineMessages.getString(parameterisableKeys[k], parameters));
+ if (previousLocale != null) {
+ Locale.setDefault(previousLocale);
+ } else {
+ Locale.setDefault(Locale.FRENCH);
+ }
+ final String result = AcceleoEngineMessages.getString(parameterisableKeys[k], parameters);
+ assertFalse("Message class did not find an existing parameterisable key.", result
+ .equals('!' + parameterisableKeys[k] + '!'));
+ for (int l = 0; l < parameterCount; l++) {
+ if (parameters[l] != null) {
+ assertTrue("Message class did not substitute the parameter in the result.",
+ result.contains(parameters[l].toString()));
+ } else {
+ assertTrue("Message class did not substitute the parameter in the result.",
+ result.contains("null"));
+ }
+ }
+ if (previousLocale == null) {
+ Locale.setDefault(Locale.ENGLISH);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Tests {@link AcceleoEngineMessages#getString(String, Object...)} with valid keys and <code>null</code> as
+ * formatting parameter. Expects the result to be the same as the
+ * {@link AcceleoEngineMessages#getString(String)}.
+ */
+ public void testFormattedGetStringValidKeyNullParameter() {
+ for (int i = 0; i < parameterisableKeys.length; i++) {
+ assertEquals("Unexpected formatted String returned by getString(String, Object...).",
+ AcceleoEngineMessages.getString(parameterisableKeys[i]), AcceleoEngineMessages.getString(
+ parameterisableKeys[i], (Object[])null));
+ }
+ }
+
+ /**
+ * Tests {@link AcceleoEngineMessages#getString(String)} with an invalid key. Expects the String
+ *
+ * <pre>
+ * &quot;!&quot; + key + &quot;!&quot;
+ * </pre>
+ *
+ * to be returned.
+ */
+ public void testUnFormattedGetStringInvalidKey() {
+ for (String invalidKey : invalidKeys) {
+ assertEquals("Unexpected result of getString() with an invalid key.", '!' + invalidKey + '!',
+ AcceleoEngineMessages.getString(invalidKey));
+ }
+ }
+
+ /**
+ * Tests {@link EMFCompareMessages#getString(String)} with <code>null</code> argument. Expects a
+ * NullPointerException to be thrown.
+ */
+ public void testUnFormattedGetStringNullKey() {
+ try {
+ AcceleoEngineMessages.getString(null);
+ fail("Calling getString() with null argument did not throw NullPointerException.");
+ } catch (NullPointerException e) {
+ // This was expected
+ }
+ }
+
+ /**
+ * Tests {@link AcceleoEngineMessages#getString(String)} with valid keys. Expects the String associated to the
+ * key in the properties file to be returned.
+ */
+ public void testUnFormattedGetStringValidKey() {
+ for (int i = 0; i < validKeys.length; i++) {
+ if (Locale.getDefault().getLanguage().equalsIgnoreCase("en")) {
+ assertEquals("Unexpected String returned by getString(String).", expectedForValidKeys[i],
+ AcceleoEngineMessages.getString(validKeys[i]));
+ } else {
+ final String result = AcceleoEngineMessages.getString(validKeys[i]);
+ assertFalse("Message class did not find an existing parameterisable key.", result
+ .equals('!' + validKeys[i] + '!'));
+ }
+ }
+ }
+
+ /**
+ * This will return a partial copy of an array.
+ *
+ * @param <T>
+ * Type of the copied array.
+ * @param original
+ * Array to be copied.
+ * @param start
+ * starting index of the copy.
+ * @param end
+ * end index of the copy.
+ * @return Array containing a copy of the given range from <code>original</code>.
+ */
+ private <T> T[] partialArrayCopy(T[] original, int start, int end) {
+ final int range = end - start;
+ if (range < 0) {
+ throw new IllegalArgumentException("Illegal copy range.");
+ }
+ final T[] copy = (T[])Array.newInstance(original.getClass().getComponentType(), range);
+ System.arraycopy(original, start, copy, 0, Math.min(original.length - start, range));
+ return copy;
+ }
+}
diff --git a/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/variables/SelfTest.java b/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/variables/SelfTest.java
new file mode 100644
index 0000000..6b12712
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/src/org/eclipse/acceleo/engine/tests/unit/variables/SelfTest.java
@@ -0,0 +1,148 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.acceleo.engine.tests.unit.variables;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.eclipse.acceleo.engine.service.AcceleoService;
+import org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest;
+
+/**
+ * This test allows us to check the behavior of the Acceleo engine when dealing with the OCL "self" variable.
+ *
+ * @author <a href="mailto:laurent.goubet@obeo.fr">Laurent Goubet</a>
+ */
+public class SelfTest extends AbstractAcceleoTest {
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest#getModuleLocation()
+ */
+ @Override
+ public String getModuleLocation() {
+ return "data/Variables/template_self.mtl"; //$NON-NLS-1$
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.acceleo.engine.tests.unit.AbstractAcceleoTest#getResultPath()
+ */
+ @Override
+ public String getResultPath() {
+ return "Variables"; //$NON-NLS-1$
+ }
+
+ /**
+ * Tests the usage of the self variable in a query.
+ *
+ * @throws IOException
+ * Thrown when the output cannot be saved.
+ */
+ public void testSelfVariableInQuery() throws IOException {
+ generationRoot = new File(getGenerationRootPath("SelfQuery")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("SelfQuery")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module, "test_self_query", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+
+ for (File generated : getFiles(generationRoot)) {
+ final String content = getAbsoluteFileContent(generated.getAbsolutePath());
+ // We expect the name of the package to have been generated
+ assertTrue(content.contains("target")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Tests the usage of the self variable in a template.
+ *
+ * @throws IOException
+ * Thrown when the output cannot be saved.
+ */
+ public void testSelfVariableInTemplate() throws IOException {
+ generationRoot = new File(getGenerationRootPath("SelfTemplate")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("SelfTemplate")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module, "test_self_template", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+
+ for (File generated : getFiles(generationRoot)) {
+ final String content = getAbsoluteFileContent(generated.getAbsolutePath());
+ // We expect the name of the package to have been generated
+ assertTrue(content.contains("target")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Tests the implicit usage of the self variable in a query.
+ *
+ * @throws IOException
+ * Thrown when the output cannot be saved.
+ */
+ public void testImplicitSelfVariableInQuery() throws IOException {
+ generationRoot = new File(getGenerationRootPath("ImplicitSelfQuery")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("ImplicitSelfQuery")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module, "test_implicit_self_query", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+
+ for (File generated : getFiles(generationRoot)) {
+ final String content = getAbsoluteFileContent(generated.getAbsolutePath());
+ // We expect the name of the package to have been generated
+ assertTrue(content.contains("target")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Tests the implicit usage of the self variable in a template.
+ *
+ * @throws IOException
+ * Thrown when the output cannot be saved.
+ */
+ public void testImplicitSelfVariableInTemplate() throws IOException {
+ generationRoot = new File(getGenerationRootPath("ImplicitSelfTemplate")); //$NON-NLS-1$
+ referenceRoot = new File(getReferenceRootPath("ImplicitSelfTemplate")); //$NON-NLS-1$
+
+ cleanGenerationRoot();
+
+ AcceleoService.doGenerate(module, "test_implicit_self_template", inputModel, generationRoot, false); //$NON-NLS-1$
+ try {
+ compareDirectories(referenceRoot, generationRoot);
+ } catch (IOException e) {
+ fail(errorMessageForCompareDirectoriesMethod);
+ }
+
+ for (File generated : getFiles(generationRoot)) {
+ final String content = getAbsoluteFileContent(generated.getAbsolutePath());
+ // We expect the name of the package to have been generated
+ assertTrue(content.contains("target")); //$NON-NLS-1$
+ }
+ }
+}
diff --git a/tests/org.eclipse.acceleo.engine.tests/test.xml b/tests/org.eclipse.acceleo.engine.tests/test.xml
new file mode 100644
index 0000000..85fc017
--- /dev/null
+++ b/tests/org.eclipse.acceleo.engine.tests/test.xml
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!--
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2008, 2009 Obeo and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - Initial API and implementation
+ *
+ * </copyright>
+ *
+ * $Id: test.xml,v 1.1 2009/03/05 16:34:14 jmusset Exp $
+ */
+-->
+
+<project name="testsuite" default="run" basedir=".">
+ <!-- The property ${eclipse-home} should be passed into this script -->
+ <!-- Set a meaningful default value for when it is not. -->
+ <property name="eclipse-home" value="${basedir}\..\.."/>
+
+ <!-- sets the properties plugin-name, and library-file -->
+ <property name="plugin-name" value="org.eclipse.acceleo.engine.tests"/>
+ <property name="library-file" value="${eclipse-home}/dropins/eclipse/plugins/org.eclipse.test/library.xml"/>
+
+ <!-- This target holds all initialization code that needs to be done for -->
+ <!-- all tests that are to be run. Initialization for individual tests -->
+ <!-- should be done within the body of the suite target. -->
+ <target name="init">
+ <tstamp/>
+ <delete>
+ <fileset dir="${eclipse-home}" includes="org*.xml"/>
+ </delete>
+ </target>
+
+ <!-- This target defines the tests that need to be run. -->
+ <target name="suite">
+ <property name="m2t-folder" value="${eclipse-home}/emf_folder"/>
+ <delete dir="${m2t-folder}" quiet="true"/>
+ <ant target="core-test" antfile="${library-file}" dir="${eclipse-home}">
+ <property name="data-dir" value="${m2t-folder}"/>
+ <property name="plugin-name" value="${plugin-name}"/>
+ <property name="classname" value="org.eclipse.acceleo.engine.tests.suite.AllTests"/>
+ </ant>
+ </target>
+
+ <!-- This target holds code to cleanup the testing environment after -->
+ <!-- after all of the tests have been run. You can use this target to -->
+ <!-- delete temporary files that have been created. -->
+ <target name="cleanup">
+ </target>
+
+ <!-- This target runs the test suite. Any actions that need to happen -->
+ <!-- after all the tests have been run should go here. -->
+ <target name="run" depends="init,suite,cleanup">
+ <ant target="collect" antfile="${library-file}" dir="${eclipse-home}">
+ <property name="includes" value="org*.xml"/>
+ <property name="output-file" value="${plugin-name}.xml"/>
+ </ant>
+ </target>
+
+</project>