AbstractXtextTests in 2.0 [message #650887] |
Wed, 26 January 2011 22:09  |
Eclipse User |
|
|
|
Hi,
how is the Validator used in Xtext 2.0 AbstractXtextTest ?
There is an extra parameter EValidatorRegistrar and I tried a wild guess
how it was supposed to be used.
In my setUp I now have:
with(MyStandaloneSetup.class);
// TODO: Xtext 2.0 - is the below ok ? (registrar is new parameter).
PPJavaValidator validator = get(MyJavaValidator.class);
EValidatorRegistrar registrar = get(EValidatorRegistrar.class);
tester = new ValidatorTester<MyJavaValidator>(validator, registrar);
Is this the correct way to get the EValidatorRegistrar?
I was able to call the validator, but I have lots of errors from failing
serialization, and problems with unresolved proxies - probably not
related to the ValidatorTester, but best to ask...
The editor parses and produces the model ok, but not when run using the
AbstractXtextTest. Is there some registration of my (external model)
that may be missing and that is done differently in 2.0 ?
Regards
- henrik
|
|
|
Re: AbstractXtextTests in 2.0 [message #650931 is a reply to message #650887] |
Thu, 27 January 2011 03:00   |
Eclipse User |
|
|
|
Hi Henrik,
that's the right way to initialize the validator tester. It ensures,
that the global EMF registries will not be messed up after on test
execution.
Are you sure that your standalone setup registeres all the necessary
metamodels and resource factories?
Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Am 27.01.11 04:09, schrieb Henrik Lindberg:
> Hi,
> how is the Validator used in Xtext 2.0 AbstractXtextTest ?
> There is an extra parameter EValidatorRegistrar and I tried a wild guess
> how it was supposed to be used.
>
> In my setUp I now have:
>
> with(MyStandaloneSetup.class);
> // TODO: Xtext 2.0 - is the below ok ? (registrar is new parameter).
> PPJavaValidator validator = get(MyJavaValidator.class);
> EValidatorRegistrar registrar = get(EValidatorRegistrar.class);
> tester = new ValidatorTester<MyJavaValidator>(validator, registrar);
>
> Is this the correct way to get the EValidatorRegistrar?
>
> I was able to call the validator, but I have lots of errors from failing
> serialization, and problems with unresolved proxies - probably not
> related to the ValidatorTester, but best to ask...
>
> The editor parses and produces the model ok, but not when run using the
> AbstractXtextTest. Is there some registration of my (external model)
> that may be missing and that is done differently in 2.0 ?
>
> Regards
> - henrik
|
|
|
|
Re: AbstractXtextTests in 2.0 [message #651080 is a reply to message #650960] |
Thu, 27 January 2011 12:04   |
Eclipse User |
|
|
|
First part of the problem was a red herring - it was a toasted launch
config for the tests... - it now finds models as it is supposed to.
I do however not get calls to MyJavaValidator when running the tests
(works in the IDE and in 1.0). (I checked with the debugger, I can't say
I understand the data that is passed around when it is performing
validation, but the MyJavaValidator is included.
Do I need to make some specific declarations when running the tests?
Basically, the MyJavaValidator has a bunch of @Check methods for model
elements in the imported "MyModel" - in 1.0 it was enough to return the
MyPackage.eInstance from getPackages() (in 2.0, the imported package was
already registered by the super class so I added a check to not add it
twice).
Hints what to check next?
- henrik
On 1/27/11 11:18 AM, Henrik Lindberg wrote:
> I did not change anything in the standalone setup from the working setup
> for Xtext 1.0. Will investigate...
>
> - henrik
>
> On 1/27/11 9:00 AM, Sebastian Zarnekow wrote:
>> Hi Henrik,
>>
>> that's the right way to initialize the validator tester. It ensures,
>> that the global EMF registries will not be messed up after on test
>> execution.
>>
>> Are you sure that your standalone setup registeres all the necessary
>> metamodels and resource factories?
>>
>> Regards,
>> Sebastian
>
|
|
|
Re: AbstractXtextTests in 2.0 [message #651081 is a reply to message #651080] |
Thu, 27 January 2011 12:12   |
Eclipse User |
|
|
|
Hi Henrik,
does it make a differnce if your return a different result from
AbstractDeclarativeValidator#isLanguageSpecific?
Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Am 27.01.11 18:04, schrieb Henrik Lindberg:
> First part of the problem was a red herring - it was a toasted launch
> config for the tests... - it now finds models as it is supposed to.
>
> I do however not get calls to MyJavaValidator when running the tests
> (works in the IDE and in 1.0). (I checked with the debugger, I can't say
> I understand the data that is passed around when it is performing
> validation, but the MyJavaValidator is included.
>
> Do I need to make some specific declarations when running the tests?
> Basically, the MyJavaValidator has a bunch of @Check methods for model
> elements in the imported "MyModel" - in 1.0 it was enough to return the
> MyPackage.eInstance from getPackages() (in 2.0, the imported package was
> already registered by the super class so I added a check to not add it
> twice).
>
> Hints what to check next?
>
> - henrik
>
> On 1/27/11 11:18 AM, Henrik Lindberg wrote:
>> I did not change anything in the standalone setup from the working setup
>> for Xtext 1.0. Will investigate...
>>
>> - henrik
>>
>> On 1/27/11 9:00 AM, Sebastian Zarnekow wrote:
>>> Hi Henrik,
>>>
>>> that's the right way to initialize the validator tester. It ensures,
>>> that the global EMF registries will not be messed up after on test
>>> execution.
>>>
>>> Are you sure that your standalone setup registeres all the necessary
>>> metamodels and resource factories?
>>>
>>> Regards,
>>> Sebastian
>>
>
|
|
|
|
|
|
Re: AbstractXtextTests in 2.0 [message #651131 is a reply to message #651124] |
Thu, 27 January 2011 16:44  |
Eclipse User |
|
|
|
Logged https://bugs.eclipse.org/bugs/show_bug.cgi?id=335624
- henrik
On 1/27/11 10:33 PM, Henrik Lindberg wrote:
> The key
> org.eclipse.xtext.validation.AbstractInjectableValidator.cur rentLanguageName
> does not get a value in the context.
>
> Is this perhaps because I am only creating some model objects and then
> calling the validator without having the model in a resource?
>
> Basically like it is shown in the documentation:
> public void testError2() {
> FooElement model = MyLanguageFactory.eINSTANCE.createFooElement()
> model.setBarAttribute("barbarbarbarfoo");
>
> tester.validate(model).assertError(101);
> }
>
> - henrik
>
> On 1/27/11 6:37 PM, Sebastian Zarnekow wrote:
>> Hi Henrik,
>>
>> the validator will try to determine the language from the resource of
>> the object by means of XtextResource#getLanguageName. Could you please
>> investigate why it fails in your case and file a ticket with your
>> findings?
>>
>> Regards,
>> Sebastian
>
|
|
|
Powered by
FUDForum. Page generated in 0.04432 seconds