Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtend JUnit test in domainmodel example stop running
Xtend JUnit test in domainmodel example stop running [message #1298570] Wed, 16 April 2014 11:04 Go to next message
Alfredo Capozucca is currently offline Alfredo CapozuccaFriend
Messages: 12
Registered: November 2011
Junior Member
Hi,

I'm trying to start writing tests for my DSL.
I started having a look at the org.eclipse.xtext.example.domainmodel.tests example to see how to write JUnit tests mainly for the grammar and the validator.

I decided to modify a little bit the DomainmodelJavaValidator to make it look likes mine. However, when I added

@Inject IResourceSetProvider resourceSetProvider;

into the DomainmodelJavaValidator

the Junit tests stopped being executed and I got the following exception


com.google.inject.CreationException: Guice creation errors:

1) No implementation for org.eclipse.xtext.ui.resource.IResourceSetProvider was bound.
while locating org.eclipse.xtext.ui.resource.IResourceSetProvider
for field at org.eclipse.xtext.example.domainmodel.validation.DomainmodelJavaValidator.resourceSetProvider(Unknown Source)
at org.eclipse.xtext.service.MethodBasedModule.configure(MethodBasedModule.java:55)

1 error
at com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:435)
at com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:154)
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:106)
at com.google.inject.Guice.createInjector(Guice.java:95)
at com.google.inject.Guice.createInjector(Guice.java:72)
at com.google.inject.Guice.createInjector(Guice.java:62)
at org.eclipse.xtext.example.domainmodel.tests.InjectorProviderCustom$1.createInjector(InjectorProviderCustom.java:23)
at org.eclipse.xtext.example.domainmodel.DomainmodelStandaloneSetupGenerated.createInjectorAndDoEMFRegistration(DomainmodelStandaloneSetupGenerated.java:22)
at org.eclipse.xtext.example.domainmodel.tests.InjectorProviderCustom.internalCreateInjector(InjectorProviderCustom.java:47)
at org.eclipse.xtext.example.domainmodel.DomainmodelInjectorProvider.getInjector(DomainmodelInjectorProvider.java:27)
at org.eclipse.xtext.example.domainmodel.DomainmodelInjectorProvider.setupRegistry(DomainmodelInjectorProvider.java:42)
at org.eclipse.xtext.junit4.XtextRunner.methodBlock(XtextRunner.java:43)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)


Any ideas way injecting the IResourceSetProvider into the Validator breaks the JUnit tests?
Thanks!

-Alfredo.
Re: Xtend JUnit test in domainmodel example stop running [message #1298576 is a reply to message #1298570] Wed, 16 April 2014 11:06 Go to previous messageGo to next message
Alfredo Capozucca is currently offline Alfredo CapozuccaFriend
Messages: 12
Registered: November 2011
Junior Member
Just to add that I have installed Xtext v2.4.3 in Eclipse 4.2.2
Re: Xtend JUnit test in domainmodel example stop running [message #1298596 is a reply to message #1298570] Wed, 16 April 2014 11:20 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi iresourcesetprovider is a ui component not a standalone component

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtend JUnit test in domainmodel example stop running [message #1298657 is a reply to message #1298596] Wed, 16 April 2014 12:09 Go to previous messageGo to next message
Alfredo Capozucca is currently offline Alfredo CapozuccaFriend
Messages: 12
Registered: November 2011
Junior Member
Is there any way to keep the iresourcesetprovider in the validator and testing with Xtend JUnit?
I'd like to avoid removing iresourcesetprovider from the validator.
Re: Xtend JUnit test in domainmodel example stop running [message #1298761 is a reply to message #1298657] Wed, 16 April 2014 13:32 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
What about running ui Tests? What are you doing with the provider in
the validator. Of course you could bind a special impl for the tests
as well. But the solution depends on why you need the provider

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtend JUnit test in domainmodel example stop running [message #1298913 is a reply to message #1298761] Wed, 16 April 2014 15:45 Go to previous messageGo to next message
Alfredo Capozucca is currently offline Alfredo CapozuccaFriend
Messages: 12
Registered: November 2011
Junior Member
I use the iresourcesetprovider in the validator to resolve a proxy. Such provider allows me to retrieve the second parameter required by EcoreUtil2.resolve

EcoreUtil2.resolve(EObject proxy, ResourceSet resourceset);

Re: Xtend JUnit test in domainmodel example stop running [message #1298967 is a reply to message #1298913] Wed, 16 April 2014 16:37 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
HI,

a Provider<ResourceSet> does the very same.
but: where does this eobject come from.
it is not ususal to explicitely resolve things in validators


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtend JUnit test in domainmodel example stop running [message #1299945 is a reply to message #1298967] Thu, 17 April 2014 08:10 Go to previous messageGo to next message
Alfredo Capozucca is currently offline Alfredo CapozuccaFriend
Messages: 12
Registered: November 2011
Junior Member
HI,
Thanks for the tip. It works fine!
The reason why I resolve things in the validator is because the information convey by the IEObjectDescription is not sufficient to make a decision.
I believe (can you confirm, please this) that the best solution would be to enrich the IEObjectDescriptiondata with the required data as suggested in

https://www.eclipse.org/forums/index.php/m/1053596/#msg_1053596

but I haven't succeeded so far to do that (tips and pointers on that would be more than welcome).
Re: Xtend JUnit test in domainmodel example stop running [message #1300035 is a reply to message #1299945] Thu, 17 April 2014 09:26 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

You can pass additional information in the eAdapter on the EObject,.
which is the workaround I use for
https://bugs.eclipse.org/bugs/show_bug.cgi?id=368280.

Regards

Ed Willink




On 17/04/2014 09:10, Alfredo Capozucca wrote:
> HI,
> Thanks for the tip. It works fine!
> The reason why I resolve things in the validator is because the
> information convey by the IEObjectDescription is not sufficient to
> make a decision.
> I believe (can you confirm, please this) that the best solution would
> be to enrich the IEObjectDescriptiondata with the required data as
> suggested in
> https://www.eclipse.org/forums/index.php/m/1053596/#msg_1053596
>
> but I haven't succeeded so far to do that (tips and pointers on that
> would be more than welcome).
Previous Topic:How can I generate code from my XText DSL without IDE?
Next Topic:Xtext' editor embedded in a Java Application
Goto Forum:
  


Current Time: Thu Mar 28 19:08:28 GMT 2024

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

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

Back to the top