Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Setting up OCLInEcore and standalone junit
Setting up OCLInEcore and standalone junit [message #794451] Thu, 09 February 2012 10:03 Go to next message
Filip Krikava is currently offline Filip KrikavaFriend
Messages: 45
Registered: January 2012
Member
Hi,

I'm trying to setup standalone junit tests for validating the OCL invariants I have in my model. If I use the Ecore metamodel (http[:]//www.eclipse.org/emf/2002/Ecore/OCL) and following the Standalone Configuration section in the documentation it all works fine.

However, if I try to use the Pivot metamodel then I have some troubles that I think are manly because I miss something in the setup (I hope I did not miss something obvious).

Following the documentation I have this in my test class:
import org.eclipse.ocl.examples.pivot.delegate.OCLDelegateDomain;
import org.eclipse.ocl.examples.pivot.delegate.OCLValidationDelegateFactory;

@BeforeClass
public static void initialize() {
  org.eclipse.ocl.examples.pivot.OCL.OCL.initialize(null); // do it globally

  // initialize OCL validation
  EValidator.ValidationDelegate.Registry.INSTANCE.put(
		OCLDelegateDomain.OCL_DELEGATE_URI_PIVOT,
		new OCLValidationDelegateFactory.Global());
}


And in the MANIFEST.MF:
Require-Bundle: org.junit;bundle-version="4.8.2",
 fr.unice.salty.core.model;bundle-version="1.0.0",
 fr.unice.salty.core.model.resource.scm;bundle-version="1.0.0",
 org.eclipse.ocl.examples.xtext.oclinecore;bundle-version="3.1.0"


But that does not work and during validation using (org.eclipse.emf.ecore.util.Diagnostician) I get:
An exception occurred while delegating evaluation of the 'uniqueDataTypeNames' constraint on 'fr.unice.salty.core.model.salty.impl.ControlSystemImpl@202264da{file:/var/folders/0f/85kh4b4j7g926q4k3lmgt48w0000gn/T/emfutils7731788511457067198.scm#/}': org/apache/log4j/Logger


If I add the org.apache.log4j dependency then I get a step further:
An exception occurred while delegating evaluation of the 'uniqueDataTypeNames' constraint on 'fr.unice.salty.core.model.salty.impl.ControlSystemImpl@6bd9e2c7{file:/var/folders/0f/85kh4b4j7g926q4k3lmgt48w0000gn/T/emfutils3021211280825794027.scm#/}': No OCL Standard Library content available


In the end what works is adding these two lines in my test initialization method:
OCLinEcoreStandaloneSetup.doSetup();
OCLstdlib.install();


My questions are:
What are the proper initialization steps I should do?
What are the proper dependencies I should add into the MANIFEST.MF?

Thanks a lot,
Filip
Re: Setting up OCLInEcore and standalone junit [message #794462 is a reply to message #794451] Thu, 09 February 2012 10:19 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi Filip

Well done, you've found what I consider the correct solution.

OCLinEcoreStandaloneSetup.doSetup();

is mentioned in the Standalone Setup part of the (Help Contents) OCL
Documentation.

But

OCLstdlib.install();

is missing. (https://bugs.eclipse.org/bugs/show_bug.cgi?id=371053 raised).

The dependencies are what's needed to make the JDT compilation errors go
away. I suspect that you've found them already. Most of the plugins have
transitive exports so org.eclipse.ocl.examples.xtext.oclinecore as
you've used is probably sufficient.

You might want to look at org.eclipse.ocl.examples.xtext.tests where all
the JUnit tests are. There are a variety of helper routines that ensure
that MetaModelManager's don't leak. One of many pending jobs is to merge
all these helpers together into a helper/facade API.

Regards

Ed Willink

On 09/02/2012 10:03, Filip Krikava wrote:
> Hi,
>
> I'm trying to setup standalone junit tests for validating the OCL
> invariants I have in my model. If I use the Ecore metamodel
> (http[:]//www.eclipse.org/emf/2002/Ecore/OCL) and following the
> Standalone Configuration section in the documentation it all works fine.
> However, if I try to use the Pivot metamodel then I have some troubles
> that I think are manly because I miss something in the setup (I hope I
> did not miss something obvious).
>
> Following the documentation I have this in my test class:
>
> import org.eclipse.ocl.examples.pivot.delegate.OCLDelegateDomain;
> import
> org.eclipse.ocl.examples.pivot.delegate.OCLValidationDelegateFactory;
>
> @BeforeClass
> public static void initialize() {
> org.eclipse.ocl.examples.pivot.OCL.OCL.initialize(null); // do it
> globally
>
> // initialize OCL validation
> EValidator.ValidationDelegate.Registry.INSTANCE.put(
> OCLDelegateDomain.OCL_DELEGATE_URI_PIVOT,
> new OCLValidationDelegateFactory.Global());
> }
>
>
> And in the MANIFEST.MF:
>
> Require-Bundle: org.junit;bundle-version="4.8.2",
> fr.unice.salty.core.model;bundle-version="1.0.0",
> fr.unice.salty.core.model.resource.scm;bundle-version="1.0.0",
> org.eclipse.ocl.examples.xtext.oclinecore;bundle-version="3.1.0"
>
>
> But that does not work and during validation using
> (org.eclipse.emf.ecore.util.Diagnostician) I get:
>
> An exception occurred while delegating evaluation of the
> 'uniqueDataTypeNames' constraint on
> 'fr.unice.salty.core.model.salty.impl.ControlSystemImpl@202264da{file:/var/folders/0f/85kh4b4j7g926q4k3lmgt48w0000gn/T/emfutils7731788511457067198.scm#/}':
> org/apache/log4j/Logger
>
>
> If I add the org.apache.log4j dependency then I get a step further:
>
> An exception occurred while delegating evaluation of the
> 'uniqueDataTypeNames' constraint on
> 'fr.unice.salty.core.model.salty.impl.ControlSystemImpl@6bd9e2c7{file:/var/folders/0f/85kh4b4j7g926q4k3lmgt48w0000gn/T/emfutils3021211280825794027.scm#/}':
> No OCL Standard Library content available
>
>
> In the end what works is adding these two lines in my test
> initialization method:
>
> OCLinEcoreStandaloneSetup.doSetup();
> OCLstdlib.install();
>
>
> My questions are: What are the proper initialization steps I should
> do? What are the proper dependencies I should add into the MANIFEST.MF?
>
> Thanks a lot,
> Filip
Re: Setting up OCLInEcore and standalone junit [message #931210 is a reply to message #794462] Wed, 03 October 2012 02:21 Go to previous messageGo to next message
David Rees is currently offline David ReesFriend
Messages: 47
Registered: September 2012
Member
<updated, but please see later post>

After trying to make the query Pivot example work and running into Null Pointer with just the above, I found this blog post http://blog.mattsch.com/2012/05/31/how-to-use-ocl-when-running-emf-standalone/.

In addition to that page's code I also had to add "org.eclipse.ocl.examples.pivot.model.OCLstdlib.install()" and add dependencies on org.eclipse.ocl.examples.xtext.oclinecore and com.google.log4j.

So it seems there is still something missing from the steps in the post above and/or the help?

FYI, Pivot Ecore also depends on com.google.guava, but that is currently included through oclinecore.

[Updated on: Wed, 03 October 2012 15:08]

Report message to a moderator

Re: Setting up OCLInEcore and standalone junit [message #931332 is a reply to message #931210] Wed, 03 October 2012 05:18 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

I'm afraid that I don't understand your comments.

What is 'the simple Pivot example'? How do I run Null Pointer after
NullPointer?

My previous reply mentioned OCLstdlib.install() so I'm unclear why you
report this as a new discovery.

Regards

Ed Willink

On 03/10/2012 04:21, David Rees wrote:
> After trying to make the simple Pivot example work and running Null
> Pointer after NullPointer with just the above, I found this blog post
> blog<dot>mattsch<dot>com/2012/05/31/how-to-use-ocl-when-running-emf-standalone/
> (sorry for ugly URL, ,I don't have 25 posts yet so I can't post
> non-Eclipse URLs).
>
> In addition to that page's code I also had to add
> "org.eclipse.ocl.examples.pivot.model.OCLstdlib.install()" and add
> dependencies on org.eclipse.ocl.examples.xtext.oclinecore and
> com.google.log4j.
>
> I'll add link to here in the doc issue, but is there an issue yet for
> doing the cleanup/simplification of running OCL Pivot standalone where
> I can add this info also? I think its needed not just for ease of use,
> but also because there is a noticeable performance cost in these
> initialization steps relative to old OCL. Perhaps because we are
> having to setup all of OCLinEcore.
>
> FYI, Pivot Ecore also depends on com.google.guava, but that is
> currently included through oclinecore.
>
Re: Setting up OCLInEcore and standalone junit [message #931820 is a reply to message #931332] Wed, 03 October 2012 15:03 Go to previous messageGo to next message
David Rees is currently offline David ReesFriend
Messages: 47
Registered: September 2012
Member
Sorry for the confusion, its probably not very clear without the real URL to the blog post. Happily I answered a few more Newbie questions and I can now post real links. So I have updated the original post with the real link. I also updated the link I missed to the simple example I was talking about.

That said, in the light of day I seem to have things a little more straight now. Long story short, I would suggest (assuming I have things straight now) the help be updated to mention that com.google.log4j is a dependency. I would also suggest more explicitly stating that one of the xtext doSetup() calls is needed even if the user is using Pivot OCL outside the Xtext Editors. As it reads now I assumed incorrectly that those were only needed when supporting an editor.

I would also suggest perhaps adding a null check on the results of resourceSet.createResource(uri) in org.eclipse.ocl.examples.pivot.context.AbstractParserContext.createBaseResource that provides a helpful error telling users they need to register an OCL Resource.

d

PS, Kind of funny - as I am writing this post the news is doing a story on "pivots" in debates (the first US presidential debates are tonight Smile.
Re: Setting up OCLInEcore and standalone junit [message #931846 is a reply to message #931820] Wed, 03 October 2012 15:25 Go to previous messageGo to next message
David Rees is currently offline David ReesFriend
Messages: 47
Registered: September 2012
Member
PS, If you agree with these changes I'm happy to try my hand at them and providing a patch.
Re: Setting up OCLInEcore and standalone junit [message #931858 is a reply to message #931846] Wed, 03 October 2012 15:30 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

They seem sensible and you seem worth investing a bit of training time
in. I need all the help I can get.

I recommend providing simple obvious methods in the ...pivot.OCL.java
class.

Regards

Ed Willink


On 03/10/2012 17:25, David Rees wrote:
> PS, If you agree with these changes I'm happy to try my hand at them
> and providing a patch.
Re: Setting up OCLInEcore and standalone junit [message #1062572 is a reply to message #931210] Sun, 09 June 2013 09:15 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

You should find that the Kepler documentation addresses the failings
described in this thread.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=371053

Regards

Ed Willink

On 03/10/2012 03:21, David Rees wrote:
> After trying to make the simple Pivot example work and running Null
> Pointer after NullPointer with just the above, I found this blog post
> blog<dot>mattsch<dot>com/2012/05/31/how-to-use-ocl-when-running-emf-standalone/
> (sorry for ugly URL, ,I don't have 25 posts yet so I can't post
> non-Eclipse URLs).
>
> In addition to that page's code I also had to add
> "org.eclipse.ocl.examples.pivot.model.OCLstdlib.install()" and add
> dependencies on org.eclipse.ocl.examples.xtext.oclinecore and
> com.google.log4j.
>
> I'll add link to here in the doc issue, but is there an issue yet for
> doing the cleanup/simplification of running OCL Pivot standalone where
> I can add this info also? I think its needed not just for ease of use,
> but also because there is a noticeable performance cost in these
> initialization steps relative to old OCL. Perhaps because we are
> having to setup all of OCLinEcore.
>
> FYI, Pivot Ecore also depends on com.google.guava, but that is
> currently included through oclinecore.
>
Previous Topic:[Announce] OCL 2013
Next Topic:OCL closure works properly with Interactive OCL, not Interactive Xtext OCL
Goto Forum:
  


Current Time: Sat Apr 20 16:11:20 GMT 2024

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

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

Back to the top