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

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(
at org.eclipse.viatra.query.runtime.api.ViatraQueryEngineOptions.getSystemDefaultBackend(
at org.eclipse.viatra.query.runtime.api.ViatraQueryEngineOptions.access$4(
at org.eclipse.viatra.query.runtime.api.ViatraQueryEngineOptions$Builder.getDefaultBackend(
at org.eclipse.viatra.query.runtime.api.ViatraQueryEngineOptions$
at org.eclipse.viatra.query.runtime.api.ViatraQueryEngineOptions.getDefault(
at org.eclipse.viatra.query.runtime.api.ViatraQueryEngineManager.getQueryEngine(
at org.eclipse.viatra.query.runtime.api.ViatraQueryEngine.on(
at fr.tpt.mem4csd.mtbench.aadl2aadl.viatra.tests.AbstractAadl2AadlTest.executeAadl2AadlTransformation(
at fr.tpt.mem4csd.mtbench.aadl2aadl.viatra.tests.Aadl2AadlTest.testAadl2Aadl(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(
at org.junit.runners.model.FrameworkMethod.invokeExplosively(
at org.junit.internal.runners.statements.InvokeMethod.evaluate(
at org.junit.runners.ParentRunner.runLeaf(
at org.junit.runners.BlockJUnit4ClassRunner.runChild(
at org.junit.runners.BlockJUnit4ClassRunner.runChild(
at org.junit.runners.ParentRunner$
at org.junit.runners.ParentRunner$1.schedule(
at org.junit.runners.ParentRunner.runChildren(
at org.junit.runners.ParentRunner.access$000(
at org.junit.runners.ParentRunner$2.evaluate(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(

I found this old page 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: 380
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,

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 May 15 19:41:08 GMT 2021

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

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

Back to the top