| Summary: | AbstractXtextTests does not set current language when there is no resource | ||
|---|---|---|---|
| Product: | [Modeling] TMF | Reporter: | Henrik Lindberg <henrik.lindberg> |
| Component: | Xtext | Assignee: | Project Inbox <tmf.xtext-inbox> |
| Status: | CLOSED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | sebastian.zarnekow, sven.efftinge |
| Version: | 2.0.0 | Flags: | sebastian.zarnekow:
indigo+
|
| Target Milestone: | M5 | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | |||
I think the ValidatorTester should put the language name into the diagnostic context when #valiator() is called. What do others think? (In reply to comment #1) > I think the ValidatorTester should put the language name into the diagnostic > context when #valiator() is called. What do others think? Yes, that seems to be ok in a test-context. We shouldn't require EObjects being contained in a resource in tests. Pushed the fix to master. Closing all bugs that were set to RESOLVED before Neon.0 Closing all bugs that were set to RESOLVED before Neon.0 |
When a test is performed (as this snippet from the documentation): public void testError2() { FooElement model = MyLanguageFactory.eINSTANCE.createFooElement() model.setBarAttribute("barbarbarbarfoo"); tester.validate(model).assertError(101); } And the validator is initialized in the setUp() method like this: super.setUp(); with(MyStandaloneSetup.class); MyJavaValidator validator = get(MyJavaValidator.class); EValidatorRegistrar registrar = get(EValidatorRegistrar.class); tester = new ValidatorTester<MyJavaValidator>(validator, registrar); Then, no methods will be called in the MyValidator unless it's isLanguageSpecific() method is overridden and returns false. The problem seems to be that the key org.eclipse.xtext.validation.AbstractInjectableValidator.currentLanguageName is set to an empty string in the context. Looks like it is setting that from the model's resource, but since it does not have one, the result is that the language name is empty.