Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » running validation from an application (or a junit test)
running validation from an application (or a junit test) [message #412679] Sun, 02 September 2007 15:02 Go to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
Hi

I was trying to run validation from an application (also tried from a
junit test) using the extlibrary example, with the following code:

EXTLibraryFactory factory = EXTLibraryFactory.eINSTANCE;

Library library = factory.createLibrary();
Book book = factory.createBook();

book.setTitle("foo");
library.getBooks().add(book);

System.out.println("book: " + book);

IBatchValidator validator = (IBatchValidator) ModelValidationService
.getInstance().newValidator(EvaluationMode.BATCH);

IStatus status = validator.validate(library);

System.out.println("result: " + status);

but I get the following error:

Exception in thread "main" java.lang.ExceptionInInitializerError
at
org.eclipse.emf.validation.internal.service.BatchValidator$D efaultRecursiveTraversalStrategy.initDelegates(BatchValidato r.java:338)
at
org.eclipse.emf.validation.internal.service.BatchValidator$D efaultRecursiveTraversalStrategy.startTraversal(BatchValidat or.java:259)
at
org.eclipse.emf.validation.internal.service.BatchValidator.v alidate(BatchValidator.java:169)
at
org.eclipse.emf.validation.internal.service.BatchValidator.d oValidate(BatchValidator.java:137)
at
org.eclipse.emf.validation.internal.service.AbstractValidato r.validate(AbstractValidator.java:141)
at
org.eclipse.emf.validation.internal.service.AbstractValidato r.validate(AbstractValidator.java:120)
at
org.eclipse.emf.examples.extlibrary.tests.EXTLibraryExample. main(EXTLibraryExample.java:74)
Caused by: java.lang.NullPointerException
at
org.eclipse.emf.validation.internal.EMFModelValidationPlugin .getPluginId(EMFModelValidationPlugin.java:203)
at
org.eclipse.emf.validation.internal.service.TraversalStrateg yManager.initStrategies(TraversalStrategyManager.java:100)
at
org.eclipse.emf.validation.internal.service.TraversalStrateg yManager. <init>(TraversalStrategyManager.java:62)
at
org.eclipse.emf.validation.internal.service.TraversalStrateg yManager. <clinit>(TraversalStrategyManager.java:54)
... 7 more

what am I doing wrong?

thanks in advance
Lorenzo

--
Lorenzo Bettini, PhD in Computer Science, DSI, Univ. di Firenze
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net


Re: running validation from an application (or a junit test) [message #412680 is a reply to message #412679] Sun, 02 September 2007 16:00 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Lorenzo,

I don't think the validation framework supports standalone execution.
Are you running this as a JUnit Plugin test?


Lorenzo Bettini wrote:
> Hi
>
> I was trying to run validation from an application (also tried from a
> junit test) using the extlibrary example, with the following code:
>
> EXTLibraryFactory factory = EXTLibraryFactory.eINSTANCE;
>
> Library library = factory.createLibrary();
> Book book = factory.createBook();
>
> book.setTitle("foo");
> library.getBooks().add(book);
>
> System.out.println("book: " + book);
>
> IBatchValidator validator = (IBatchValidator) ModelValidationService
> .getInstance().newValidator(EvaluationMode.BATCH);
>
> IStatus status = validator.validate(library);
>
> System.out.println("result: " + status);
>
> but I get the following error:
>
> Exception in thread "main" java.lang.ExceptionInInitializerError
> at
> org.eclipse.emf.validation.internal.service.BatchValidator$D efaultRecursiveTraversalStrategy.initDelegates(BatchValidato r.java:338)
>
> at
> org.eclipse.emf.validation.internal.service.BatchValidator$D efaultRecursiveTraversalStrategy.startTraversal(BatchValidat or.java:259)
>
> at
> org.eclipse.emf.validation.internal.service.BatchValidator.v alidate(BatchValidator.java:169)
>
> at
> org.eclipse.emf.validation.internal.service.BatchValidator.d oValidate(BatchValidator.java:137)
>
> at
> org.eclipse.emf.validation.internal.service.AbstractValidato r.validate(AbstractValidator.java:141)
>
> at
> org.eclipse.emf.validation.internal.service.AbstractValidato r.validate(AbstractValidator.java:120)
>
> at
> org.eclipse.emf.examples.extlibrary.tests.EXTLibraryExample. main(EXTLibraryExample.java:74)
>
> Caused by: java.lang.NullPointerException
> at
> org.eclipse.emf.validation.internal.EMFModelValidationPlugin .getPluginId(EMFModelValidationPlugin.java:203)
>
> at
> org.eclipse.emf.validation.internal.service.TraversalStrateg yManager.initStrategies(TraversalStrategyManager.java:100)
>
> at
> org.eclipse.emf.validation.internal.service.TraversalStrateg yManager. <init>(TraversalStrategyManager.java:62)
>
> at
> org.eclipse.emf.validation.internal.service.TraversalStrateg yManager. <clinit>(TraversalStrategyManager.java:54)
>
> ... 7 more
>
> what am I doing wrong?
>
> thanks in advance
> Lorenzo
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: running validation from an application (or a junit test) [message #412690 is a reply to message #412680] Mon, 03 September 2007 09:23 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
Ed Merks wrote:
> Lorenzo,
>
> I don't think the validation framework supports standalone execution.
> Are you running this as a JUnit Plugin test?
>
>

Hi

you're right: if I run it as a Junit Plugin test it runs without
exception (let alone that I still have problems since no constraint is
used, see my other post "problems with validation tutorial").

--
Lorenzo Bettini, PhD in Computer Science, DSI, Univ. di Firenze
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net


Re: running validation from an application (or a junit test) [message #655555 is a reply to message #412680] Mon, 21 February 2011 18:15 Go to previous messageGo to next message
Ronan B is currently offline Ronan BFriend
Messages: 273
Registered: July 2009
Senior Member
Hi,
I'm just wondering if there is still a limitation on the emf validation framework working in a standalone execution environment i.e. Headless.

When I run my validation code in Eclipse/IBM RSA it runs fine. When I run it headless the validation framework never sets the IStatus to anything but "Status OK: org.eclipse.emf.validation code=10 No constraints were evaluated" The validation is being performed on exactly the same model

The validator itself is just a simple UML Batch validator using IBatchValidator.

Any ideas?

Thanks,
Ronan
Re: running validation from an application (or a junit test) [message #655639 is a reply to message #655555] Tue, 22 February 2011 06:07 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Ronan,

Comments below.

Ronan wrote:
> Hi,
> I'm just wondering if there is still a limitation on the emf
> validation framework working in a standalone execution environment
> i.e. Headless.
Stand alone and headless don't mean the same thing. The later is
running an Eclipse/Equinox application without a UI the former is
running directly from some Java class' main() method.
>
> When I run my validation code in Eclipse/IBM RSA it runs fine. When I
> run it headless the validation framework never sets the IStatus to
> anything but "Status OK: org.eclipse.emf.validation code=10 No
> constraints were evaluated" The validation is being performed on
> exactly the same model
Perhaps something it's relying on is missing. E.g.,
org.eclipse.core.resources I think is necessary.
>
> The validator itself is just a simple UML Batch validator using
> IBatchValidator.
>
> Any ideas?
>
> Thanks,
> Ronan


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: running validation from an application (or a junit test) [message #655900 is a reply to message #412679] Wed, 23 February 2011 09:12 Go to previous message
Ronan B is currently offline Ronan BFriend
Messages: 273
Registered: July 2009
Senior Member
Hi,
My bad Sad Your right I should have said just Headless Smile

Yes I have org.eclipse.core.resources included as a dependency.

With some more debugging we have found that the ClientContext is not getting setup correctly in Headless mode. This means we get no validation rules returned. It looks like perhaps the IBM UMLvalidation code we rely on is creating an EditingDomain that has dependencies on GMF. Obviously this is bad news as GMF has no place in our headless environment. I'll try and follow this up further and report back.

Regards,
Ronan
Previous Topic:Losing atributes after saving and reopening Dynamic Instances
Next Topic:[CDO] TimeoutRuntime Exception while opening a session
Goto Forum:
  


Current Time: Thu Apr 25 11:28:44 GMT 2024

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

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

Back to the top