Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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
Florian Pirchner is currently offline Florian Pirchner
Messages: 87
Registered: July 2009
Member

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]

Report message to a 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
Sebastian Zarnekow is currently offline Sebastian Zarnekow
Messages: 2809
Registered: July 2009
Senior Member
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: Thu Jul 24 16:12:08 EDT 2014

Powered by FUDForum. Page generated in 0.02220 seconds