Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EMF-IncQuery » Invoke IncQuery in JUnit test cases
Invoke IncQuery in JUnit test cases [message #1023916] Mon, 25 March 2013 13:05 Go to next message
Jan Reimann is currently offline Jan Reimann
Messages: 127
Registered: July 2009
Senior Member
Hi all,
I integrated IncQuery functionality into my Eclipse plugins. But now I
want to implement a test suite which then should be executed on our
build server. The problem is that I always get the following exception:

java.lang.AssertionError: Configuration error: EMF-IncQuery injector not
initialized.

It is raised in the following line:

IncQueryMatcher<IPatternMatch> matcher = matcherFactory.getMatcher(rs);

So I thought this is caused by some registration isses in my JUnit test
case. The registration is done like this:

EMFPatternLanguageStandaloneSetupGenerated setup = new
EMFPatternLanguageStandaloneSetupGenerated();
Injector injector = setup.createInjectorAndDoEMFRegistration();
EPackage.Registry.INSTANCE.put(XbasePackage.eNS_URI,
XbasePackage.eINSTANCE);
EPackage.Registry.INSTANCE.put(PatternLanguagePackage.eNS_URI,
PatternLanguagePackage.eINSTANCE);
EPackage.Registry.INSTANCE.put(EMFPatternLanguagePackage.eNS_URI,
EMFPatternLanguagePackage.eINSTANCE);
IResourceFactory resourceFactory =
injector.getInstance(IResourceFactory.class);
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("eiq",
resourceFactory);

While debugging I found out that the XtextInjectorProvider is needed to
have an instance registered. But this class is internal. From the thread
in [1] I know that standalone execution is not supported yet. Is this
still the case? How can I solve my problem?

[1] https://groups.google.com/forum/#!topic/incquery-users/umGNFRTyzSQ

best regards,
Jan
Re: Invoke IncQuery in JUnit test cases [message #1024019 is a reply to message #1023916] Mon, 25 March 2013 16:49 Go to previous messageGo to next message
Istvan Rath is currently offline Istvan Rath
Messages: 54
Registered: July 2009
Member
Quote:
I integrated IncQuery functionality into my Eclipse plugins. But now I
want to implement a test suite which then should be executed on our
build server. The problem is that I always get the following exception:

java.lang.AssertionError: Configuration error: EMF-IncQuery injector not
initialized.


Hi Jan, are you trying to execute a "Plug-in JUnit Test" run configuration? Because basically that is the only feasible way (at the moment) of achieving what you wish to do. (We also test IncQuery this way.)

Re: Invoke IncQuery in JUnit test cases [message #1024444 is a reply to message #1024019] Tue, 26 March 2013 07:55 Go to previous messageGo to next message
Jan Reimann is currently offline Jan Reimann
Messages: 127
Registered: July 2009
Senior Member
Hi Istvan,

Istvan Rath wrote:
> Hi Jan, are you trying to execute a "Plug-in JUnit Test" run
No I wanted to run it in a plain JUnit test.

> configuration? Because basically that is the only feasible way (at the
> moment) of achieving what you wish to do. (We also test IncQuery this
way.)
Is it planned to make plain tests available, too?

best regards
Jan
Re: Invoke IncQuery in JUnit test cases [message #1027311 is a reply to message #1024444] Tue, 26 March 2013 20:57 Go to previous messageGo to next message
Istvan Rath is currently offline Istvan Rath
Messages: 54
Registered: July 2009
Member
Hi Jan,

Jan Reimann wrote:
> Hi Istvan,
>
> Istvan Rath wrote:
>> Hi Jan, are you trying to execute a "Plug-in JUnit Test" run
> No I wanted to run it in a plain JUnit test.
>
>> configuration? Because basically that is the only feasible way (at the
>> moment) of achieving what you wish to do. (We also test IncQuery this
> way.)
> Is it planned to make plain tests available, too?

Running IncQuery is still only supported in an Eclipse-aware runtime
configuration, as injectors and the plug-in registry are necessary for
the IncQuery Runtime to work.

Note that headless execution *is* supported, see e.g. the headless
example mentioned in
http://wiki.eclipse.org/EMFIncQuery/UserDocumentation/API, and also
JUnit Plug-in tests do work (see e.g. our test suites in Git).

So basically, in order to get your tests on the build server running, I
recommend to simply configure it in a way to execute your tests in a
junit plugin test environment. (We achieve this in our Maven/Tycho
environment by configuring the test modules for the
"eclipse-test-plugin" packaging, see
http://git.eclipse.org/c/incquery/org.eclipse.incquery.git/tree/tests/org.eclipse.incquery.runtime.tests/pom.xml)

I assume that this can (should?) be done anyway since you wrote that you
want to test your Eclipse plugins (which should also require an
Eclipse-aware environment).

Regards
Istvan
Re: Invoke IncQuery in JUnit test cases [message #1027744 is a reply to message #1027311] Wed, 27 March 2013 11:08 Go to previous message
Eclipse User
Hi Istvan,
thanks for your reply.

Istvan Rath wrote:
> Running IncQuery is still only supported in an Eclipse-aware runtime
> configuration, as injectors and the plug-in registry are necessary for
> the IncQuery Runtime to work.
Ok

> Note that headless execution *is* supported, see e.g. the headless
> example mentioned in
> http://wiki.eclipse.org/EMFIncQuery/UserDocumentation/API, and also
> JUnit Plug-in tests do work (see e.g. our test suites in Git).
Ok, then I got this wrong. I thought that headless isn't supported either.

> So basically, in order to get your tests on the build server running, I
> recommend to simply configure it in a way to execute your tests in a
> junit plugin test environment. (We achieve this in our Maven/Tycho
> environment by configuring the test modules for the
> "eclipse-test-plugin" packaging, see
>
http://git.eclipse.org/c/incquery/org.eclipse.incquery.git/tree/tests/org.eclipse.incquery.runtime.tests/pom.xml)
thanks a lot. I'll try this.

> I assume that this can (should?) be done anyway since you wrote that you
> want to test your Eclipse plugins (which should also require an
> Eclipse-aware environment).
No, until now I implemented my tests without Eclipse runtime dependencies.

best regards
Jan
Previous Topic:EMF-IncQuery Eclipse.org migration is complete
Next Topic:Model transformation: how to force the order of output elements based on the order of input elements
Goto Forum:
  


Current Time: Tue Sep 16 21:38:29 GMT 2014

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

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