Skip to main content



      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 07:04 Go to next message
Eclipse UserFriend
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 07:06 Go to previous messageGo to next message
Eclipse UserFriend
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 07:20 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: Xtend JUnit test in domainmodel example stop running [message #1298657 is a reply to message #1298596] Wed, 16 April 2014 08:09 Go to previous messageGo to next message
Eclipse UserFriend
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 09:32 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: Xtend JUnit test in domainmodel example stop running [message #1298913 is a reply to message #1298761] Wed, 16 April 2014 11:45 Go to previous messageGo to next message
Eclipse UserFriend
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 12:37 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: Xtend JUnit test in domainmodel example stop running [message #1299945 is a reply to message #1298967] Thu, 17 April 2014 04:10 Go to previous messageGo to next message
Eclipse UserFriend
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 05:26 Go to previous message
Eclipse UserFriend
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: Fri Jul 04 05:24:36 EDT 2025

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

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

Back to the top