Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Stand-alone tests for cross-model/multi-model projects
Stand-alone tests for cross-model/multi-model projects [message #646089] Tue, 21 December 2010 20:16 Go to next message
Eclipse UserFriend
Hi all,

we're trying to put together some basic tests for a parser that has cross-references into another model. Interactively, the editor works fine, i.e., when you control-click on a name that refers to the other model the underlying file will be opened in the editor that's appropriate for the other model. So far, so good.
In the non-UI test set-up we simply call the set-ups for both models ("Flow" has cross-references into "Dialog"):

	public static void doSetup()
	{
		new DialogStandaloneSetup().createInjectorAndDoEMFRegistration();
                new FlowStandaloneSetup().createInjectorAndDoEMFRegistration();
	}


The tests simply create an Xtext resource and obtain the EList of Diagnostics to determine that a file parses all right and/or shows the expected errors.
The problem is that in our tests we get error markers for cross-references into the other model (i.e., the reference cannot be resolved). Apparently, in the test environment, the "Flow" and "Dialog" models are not connected properly. So, it seems that there is some additional initialization happening that is performed automatically when the editor is launched interactively but is missing in our test set-up. Our test framework is also performing an EcoreUtil2.resolveAll(...) on the tested resource, so we assumed that all the cross references would be resolved by that. But maybe we're not understanding this properly.

Any ideas what we're missing here?

Thanks and happy holidays Smile
Re: Stand-alone tests for cross-model/multi-model projects [message #646119 is a reply to message #646089] Wed, 22 December 2010 03:22 Go to previous messageGo to next message
Eclipse UserFriend
You could try and set the platform URI using
new StandaloneSetup().setPlatformUri("..");

".." means workspace root (more-or-less), "." would be current project.
Re: Stand-alone tests for cross-model/multi-model projects [message #646120 is a reply to message #646089] Wed, 22 December 2010 03:32 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

are you using AbstractXtextTests as the basis for your tests? You may also have a look at the domain model example shipped with Xtext. It contains a couple of tests that might serve as inspiration. The said class is useful in particular for getting to work the test setup and model loading.

Alex
Re: Stand-alone tests for cross-model/multi-model projects [message #646124 is a reply to message #646089] Wed, 22 December 2010 03:48 Go to previous messageGo to next message
Eclipse UserFriend
How do you create the XtextResource? You should use

myResourceSet.getResource(URI.createURI("somename.dialog"))

or use the ResourceFactoryRegistry directly

Resource.Factory.Registry.INSTANCE.createResource(URI.create URI( "somename.dialog"))

in order to get the same Injector instance every time.


Am 22.12.10 02:16, schrieb Mirko Raner:
> Hi all,
>
> we're trying to put together some basic tests for a parser that has
> cross-references into another model. Interactively, the editor works
> fine, i.e., when you control-click on a name that refers to the other
> model the underlying file will be opened in the editor that's
> appropriate for the other model. So far, so good.
> In the non-UI test set-up we simply call the set-ups for both models
> ("Flow" has cross-references into "Dialog"):
>
>
> public static void doSetup()
> {
> new DialogStandaloneSetup().createInjectorAndDoEMFRegistration() ;
> new FlowStandaloneSetup().createInjectorAndDoEMFRegistration();
> }
>
>
> The tests simply create an Xtext resource and obtain the EList of
> Diagnostics to determine that a file parses all right and/or shows the
> expected errors.
> The problem is that in our tests we get error markers for
> cross-references into the other model (i.e., the reference cannot be
> resolved). Apparently, in the test environment, the "Flow" and "Dialog"
> models are not connected properly. So, it seems that there is some
> additional initialization happening that is performed automatically when
> the editor is launched interactively but is missing in our test set-up.
> Our test framework is also performing an EcoreUtil2.resolveAll(...) on
> the tested resource, so we assumed that all the cross references would
> be resolved by that. But maybe we're not understanding this properly.
>
> Any ideas what we're missing here?
>
> Thanks and happy holidays :)
>


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Re: Stand-alone tests for cross-model/multi-model projects [message #646242 is a reply to message #646089] Wed, 22 December 2010 15:54 Go to previous messageGo to next message
Eclipse UserFriend
Thanks for all the good suggestions, now it works

we do setup for both projects

DialogStandaloneSetup.doSetup();
FlowStandaloneSetup.doSetup();

and use the same resourceSet to create the resources for both files

ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getResource(dialogFileURI, true);
resourceSet.getResource(flowFileURI, true);

and that make the cross-model/multi-model projects work together for our non-ui tests Smile

Re: Stand-alone tests for cross-model/multi-model projects [message #701683 is a reply to message #646242] Mon, 25 July 2011 08:43 Go to previous messageGo to next message
Eclipse UserFriend
I have exactly the same problem but initializing both modules and settings the base path did not solve the issue.
Is there anything else to do?
Re: Stand-alone tests for cross-model/multi-model projects [message #701885 is a reply to message #701683] Mon, 25 July 2011 13:55 Go to previous message
Eclipse UserFriend
As Qing pointed out, you also have to make sure that all resources end up in the same ResourceSet.

HTH,

Mirko
Previous Topic:What has happened to org.eclipse.xtext.builder.builderState.PersistableResourceDescriptionsImpl?
Next Topic:Install issue
Goto Forum:
  


Current Time: Wed Jul 23 09:39:49 EDT 2025

Powered by FUDForum. Page generated in 1.54709 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top