Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Unit Test - type is 'null'
Unit Test - type is 'null' [message #1006476] Thu, 31 January 2013 07:47 Go to next message
Eclipse UserFriend
Hi,

i am running an unit test that tests the generation of java code. But it can not resolve references to JVMTypes.


My entity dsl uses Xbase to generate java code. That works really fine in the IDE.
But if I try to run the generator as a plugin unit test, it fails since cross references to JVMTypes can not be resolved properly.


I am using the CompilationTestHelper to compile my model.

Input is:

         package my.test {
	    entity Library {
	  	   refers Book containedBook opposite library composition
	    }
				
	    entity Book {
		   refers Library library opposite containedBook
	    }
         }


In IDE that compiles to:
@Entity
public class Book {
  @OneToOne
  @JoinColumn(name = "LIBRARY")
  private Library library;


But if i am using the CompilationTestHelper in an unit test the reference to Library can not be resolved.

@Entity
public class Book {
  @OneToOne
  @JoinColumn(name = "LIBRARY")
  private /* type is 'null' */ library;


I checked my target platform and my run configuration several times. All required bundles seem to be available. And i do not have any idea what happens.

Any hints?

Thanks a lot
Florian

[Updated on: Thu, 31 January 2013 09:42] by Moderator

Re: Unit Test - type is 'null' [message #1006527 is a reply to message #1006476] Thu, 31 January 2013 10:20 Go to previous message
Eclipse UserFriend
Am 31.01.13 13:47, schrieb Florian Pirchner:
> Hi,
>
> i am running a unit test that tests the generation of java code that can
> not resolve references to JVMTypes.
>
>
> My entity dsl uses Xbase to generate java code. That works really fine
> in the IDE.
> But if I try to run the generator as a plugin unit test, it fails since
> cross references to JVMTypes can not be resolved properly.
>
>
> I am using the CompilationTestHelper to compile my model.
>
> Input is:
>
>
> package my.test {
> entity Library {
> refers Book containedBook opposite library composition
> }
>
> entity Book {
> refers Library library opposite containedBook
> }
> }
>
>
> In IDE that compiles to:
>
> @Entity
> public class Book {
> @OneToOne
> @JoinColumn(name = "LIBRARY")
> private Library library;
>
>
> But if i am using the CompilationTestHelper in an unit test the
> reference to Library can not be resolved.
>
>
> @Entity
> public class Book {
> @OneToOne
> @JoinColumn(name = "LIBRARY")
> private /* type is 'null' */ library;
>
>
> I checked my target platform and my run configuration several times. All
> required bundles seem to be available. And i do not have any idea what
> happens.
>
> Any hints?
>
> Thanks a lot
> Florian
>

You have to bind the classloader of your test plugin in order to make
the test data visible. OSGi prevents access to them otherwise.

Regards,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com
Previous Topic:Run xtext workflow from another plugin project
Next Topic:Change file to parse
Goto Forum:
  


Current Time: Tue Jul 15 00:00:52 EDT 2025

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

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

Back to the top