Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » VIATRA » Using JUnit to test Viatra transformations
Using JUnit to test Viatra transformations [message #1809750] Mon, 22 July 2019 14:41 Go to next message
Hana Mkaouar is currently offline Hana MkaouarFriend
Messages: 7
Registered: January 2019
Junior Member
Hi,

I want to test a viatra project using JUnit plug-in tests. But I get errors such as:
java.lang.NullPointerException: System default backend not found
at java.util.Objects.requireNonNull(Objects.java:228)
at org.eclipse.viatra.query.runtime.api.ViatraQueryEngineOptions.getSystemDefaultBackend(ViatraQueryEngineOptions.java:75)
at org.eclipse.viatra.query.runtime.api.ViatraQueryEngineOptions.access$4(ViatraQueryEngineOptions.java:71)
at org.eclipse.viatra.query.runtime.api.ViatraQueryEngineOptions$Builder.getDefaultBackend(ViatraQueryEngineOptions.java:173)
at org.eclipse.viatra.query.runtime.api.ViatraQueryEngineOptions$Builder.build(ViatraQueryEngineOptions.java:162)
at org.eclipse.viatra.query.runtime.api.ViatraQueryEngineOptions.getDefault(ViatraQueryEngineOptions.java:105)
at org.eclipse.viatra.query.runtime.api.ViatraQueryEngineManager.getQueryEngine(ViatraQueryEngineManager.java:86)
at org.eclipse.viatra.query.runtime.api.ViatraQueryEngine.on(ViatraQueryEngine.java:70)
at fr.tpt.mem4csd.mtbench.aadl2aadl.viatra.tests.AbstractAadl2AadlTest.executeAadl2AadlTransformation(AbstractAadl2AadlTest.java:143)
at fr.tpt.mem4csd.mtbench.aadl2aadl.viatra.tests.Aadl2AadlTest.testAadl2Aadl(Aadl2AadlTest.java:18)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)



I found this old page https://wiki.eclipse.org/VIATRA/Query/UserDocumentation/HeadlessExecution#Running_JUnit_plug-in_tests_supported_by_VIATRA_Query_queries but it misses the documentation about the use of viatra + juint

Is that possible to test a viatra transformation with Junit ?

Re: Using JUnit to test Viatra transformations [message #1809753 is a reply to message #1809750] Mon, 22 July 2019 15:24 Go to previous messageGo to next message
Zoltan Ujhelyi is currently offline Zoltan UjhelyiFriend
Messages: 373
Registered: July 2015
Senior Member
Hi Hana,

it is possible to run VIATRA queries and transformations in JUnit; the error message refers to a configuration issue, most likely caused by missing dependencies. More specifically, this behaviour was introduced in v2.0 [1] that changes the order of a few internal dependencies.

To fix the issue, you have to ensure that the classpath should have the `org.eclipse.viatra.query.runtime`, the `org.eclipse.viatra.query.runtime.rete` and the `org.eclipse.viatra.query.runtime.localsearch` bundles on the Java classpath. More specifically:

1. If you are working with Eclipse plugins, ensure all three mentioned bundles are present to the required plugins section. If you generate a new VIATRA project, the wizard ensures this.
2. If you aim to use VIATRA in a headless environment, you could rely on the `org.eclipse.viatra` : `viatra-query-runtime` Maven dependency to access every required dependency. [2]


I hope this was helpful; if not, feel free to ask for clarification.

Best regards,
Zoltán

[1] https://www.eclipse.org/viatra/documentation/releases.html#_dependency_updates_in_query_runtime
[2] https://www.eclipse.org/viatra/documentation/query-tools.html#_repository
Re: Using JUnit to test Viatra transformations [message #1809963 is a reply to message #1809753] Fri, 26 July 2019 14:55 Go to previous message
Hana Mkaouar is currently offline Hana MkaouarFriend
Messages: 7
Registered: January 2019
Junior Member
Hi Zoltan,
It works !
Thank you.
Previous Topic:Generic pattern matcher invoking registered pattern from a bundle
Next Topic:Check Class Diagram with Modal Object Diagram Specifications
Goto Forum:
  


Current Time: Sat Jul 11 10:38:15 GMT 2020

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

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

Back to the top