Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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] Wed, 22 December 2010 01:16 Go to next message
Mirko Raner is currently offline Mirko RanerFriend
Messages: 125
Registered: July 2009
Location: New York City, NY
Senior Member
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 08:22 Go to previous messageGo to next message
Meinte Boersma is currently offline Meinte BoersmaFriend
Messages: 434
Registered: July 2009
Location: Leiden, Netherlands
Senior Member
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 08:32 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
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 08:48 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
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


---
Get professional support from the Xtext committers at www.typefox.io
Re: Stand-alone tests for cross-model/multi-model projects [message #646242 is a reply to message #646089] Wed, 22 December 2010 20:54 Go to previous messageGo to next message
Qing  is currently offline Qing Friend
Messages: 1
Registered: December 2010
Junior Member
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 12:43 Go to previous messageGo to next message
Jan  is currently offline Jan Friend
Messages: 1
Registered: July 2011
Junior Member
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 17:55 Go to previous message
Mirko Raner is currently offline Mirko RanerFriend
Messages: 125
Registered: July 2009
Location: New York City, NY
Senior Member
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: Thu Mar 28 12:43:32 GMT 2024

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

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

Back to the top