Setting up OCLInEcore and standalone junit [message #794451] |
Thu, 09 February 2012 05:03  |
Eclipse User |
|
|
|
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 05:19   |
Eclipse User |
|
|
|
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 #1062572 is a reply to message #931210] |
Sun, 09 June 2013 05:15  |
Eclipse User |
|
|
|
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.
>
|
|
|
Powered by
FUDForum. Page generated in 0.08812 seconds