11/*******************************************************************************
22 * SysML 2 Pilot Implementation
33 * Copyright (c) 2026 Obeo
4+ * Copyright (c) 2026 Model Driven Solutions, Inc.
45 *
56 * This program and the accompanying materials are made available under the
67 * terms of the Eclipse Public License 2.0 which is available at
2021
2122import java .io .ByteArrayInputStream ;
2223import java .io .ByteArrayOutputStream ;
23- import java .nio .charset .StandardCharsets ;
24- import java .nio .file .Path ;
2524import java .util .ArrayList ;
2625import java .util .List ;
2726import java .util .Map ;
2827
2928import org .eclipse .emf .common .util .URI ;
3029import org .eclipse .emf .ecore .EObject ;
3130import org .eclipse .emf .ecore .resource .Resource ;
32- import org .eclipse .emf .ecore .resource .ResourceSet ;
3331import org .eclipse .emf .ecore .xmi .impl .XMIResourceImpl ;
3432import org .eclipse .xtext .EcoreUtil2 ;
35- import org .junit .After ;
36- import org .junit .BeforeClass ;
3733import org .junit .Test ;
38- import org .omg .sysml .interactive .SysMLInteractive ;
3934import org .omg .sysml .lang .sysml .Element ;
4035import org .omg .sysml .lang .sysml .Expression ;
4136import org .omg .sysml .lang .sysml .Feature ;
5449import org .omg .sysml .xtext .postprocessing .SysMLParserPostProcessorFactory ;
5550
5651/** Characterizes feature-chain structure and semantics across consultation and editing. */
57- public class FeatureChainConsultationTest {
58- private static ResourceSet resourceSet ;
59- private final List <Resource > models = new ArrayList <>();
60-
61- /** Loads and resolves the standard library once for the textual scenarios. */
62- @ BeforeClass
63- public static void loadLibraries () {
64- SysMLInteractive interactive = SysMLInteractive .createInstance ();
65- interactive .setVerbose (false );
66- interactive .getLibraryIndexCache ().setIndexDisabled (true );
67- interactive .loadLibrary (Path .of (System .getProperty ("libraryPath" )).toAbsolutePath ().toString ());
68- resourceSet = interactive .getResourceSet ();
69- for (int i = 0 ; i < resourceSet .getResources ().size (); i ++) {
70- EcoreUtil2 .resolveLazyCrossReferences (resourceSet .getResources ().get (i ), null );
71- }
72- }
73-
74- /** Removes each test model while retaining the shared resolved libraries. */
75- @ After
76- public void removeModels () {
77- for (Resource resource : models ) {
78- resource .unload ();
79- resourceSet .getResources ().remove (resource );
80- }
81- }
82-
83- private Resource parse (String name , String text ) throws Exception {
84- Resource resource = resourceSet .createResource (URI .createURI ("memory:/" + name ));
85- models .add (resource );
86- resource .load (new ByteArrayInputStream (text .getBytes (StandardCharsets .UTF_8 )), Map .of ());
87- assertTrue (resource .getErrors ().toString (), resource .getErrors ().isEmpty ());
88- return resource ;
89- }
90-
91- private static <T extends Type > T findByName (Resource resource , String name , Class <T > kind ) {
92- for (var contents = resource .getAllContents (); contents .hasNext ();) {
93- var object = contents .next ();
94- if (kind .isInstance (object ) && name .equals (kind .cast (object ).getDeclaredName ())) {
95- return kind .cast (object );
96- }
97- }
98- throw new AssertionError ("Missing " + name );
99- }
52+ public class FeatureChainConsultationTest extends SysMLInteractiveTest {
10053
10154 private static <T > T findSingle (Resource resource , Class <T > kind ) {
10255 T found = null ;
@@ -115,7 +68,6 @@ private static <T> T findSingle(Resource resource, Class<T> kind) {
11568 return found ;
11669 }
11770
118-
11971 /**
12072 * A cached textual chain retains its source target, output and argument order
12173 * through queries, cache clearing and repeated materialization.
0 commit comments