Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » AbstractXtextTests in 2.0
AbstractXtextTests in 2.0 [message #650887] Thu, 27 January 2011 03:09 Go to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
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 08:00 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
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 #650960 is a reply to message #650931] Thu, 27 January 2011 10:18 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
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 #651080 is a reply to message #650960] Thu, 27 January 2011 17:04 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
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 17:12 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
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 #651088 is a reply to message #651081] Thu, 27 January 2011 17:19 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
Yes !!
The super class method returns true, setting it to false makes it work.
Should I just override it or do something else?

It makes sense that the validator does not know that this is "My"
language as it was only fed a String. I guess the correct thing would be
to somehow indicate what language the string is supposed to be...

- henrik

On 1/27/11 6:12 PM, Sebastian Zarnekow wrote:
> Hi Henrik,
>
> does it make a differnce if your return a different result from
> AbstractDeclarativeValidator#isLanguageSpecific?
>
> Regards,
> Sebastian
Re: AbstractXtextTests in 2.0 [message #651094 is a reply to message #651088] Thu, 27 January 2011 17:37 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
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
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 27.01.11 18:19, schrieb Henrik Lindberg:
> Yes !!
> The super class method returns true, setting it to false makes it work.
> Should I just override it or do something else?
>
> It makes sense that the validator does not know that this is "My"
> language as it was only fed a String. I guess the correct thing would be
> to somehow indicate what language the string is supposed to be...
>
> - henrik
>
> On 1/27/11 6:12 PM, Sebastian Zarnekow wrote:
>> Hi Henrik,
>>
>> does it make a differnce if your return a different result from
>> AbstractDeclarativeValidator#isLanguageSpecific?
>>
>> Regards,
>> Sebastian
>
Re: AbstractXtextTests in 2.0 [message #651124 is a reply to message #651094] Thu, 27 January 2011 21:33 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
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
Re: AbstractXtextTests in 2.0 [message #651131 is a reply to message #651124] Thu, 27 January 2011 21:44 Go to previous message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
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
>
Previous Topic:Left recursion
Next Topic:NamesAreUniqueValidationHelper ALWAYS using SimpleAttributeResolver.NAME_RESOLVER
Goto Forum:
  


Current Time: Thu Sep 26 00:49:29 GMT 2024

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

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

Back to the top