Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Java.Lang.NullpointerException in UNIT TEST(Return null domainmodel)
Java.Lang.NullpointerException in UNIT TEST [message #1004771] Wed, 23 January 2013 21:06 Go to next message
junior developer is currently offline junior developer
Messages: 335
Registered: January 2013
Senior Member
Hi,

I teste my DSL but take an error from unit testing genareted language. Sad

my xtend class is below :

package org.eclipse.xtext.example.domainmodel.tests
import org.eclipse.xtext.junit4.XtextRunner
import org.eclipse.xtext.example.domainmodel.DomainmodelInjectorProvider
import org.eclipse.xtext.junit4.util.ParseHelper
import static org.junit.Assert.*


import org.eclipse.xtext.example.domainmodel.Domainmodel
import org.eclipse.xtext.example.domainmodel.Entity


import org.eclipse.xtext.junit4.InjectWith

import org.junit.Test
import org.junit.runner.RunWith
import com.google.inject.Inject

@InjectWith(typeof(DomainmodelInjectorProvider))
@RunWith(typeof(XtextRunner))

class ParserTest {
@Inject
ParseHelper<Domainmodel> parser

@Test
def void parseDomainmodel() {
val model = parser.parse(
"entity MyEntity {
parent: MyEntity
}")
val entity = model.elements.head as Entity
assertSame(entity, entity.features.head.type)
}

}

Also,when ı create xtext project ,my project name is org.eclipse.xtext.example.domainmodel,language name is org.eclipse.xtext.example.Domainmodel,extension is dmodel.And then ı write grammar and ı generate language artifacts,consited org.eclipse.xtext.example under the org.eclipse.xtext.example.domainmodel.tests .these generated org.eclipse.example package consist DomainmodelInjectorProvider.java that ı used test class.So that,generated org.eclipse.xtext.example refactor org.eclipse.xtext.example.domainmodel manually,(if ı refactor this package name,ı take other error:( So the error can be encountered in current?

[Updated on: Wed, 23 January 2013 21:06]

Report message to a moderator

Re: Java.Lang.NullpointerException in UNIT TEST [message #1004993 is a reply to message #1004771] Thu, 24 January 2013 09:25 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian Zarnekow
Messages: 2832
Registered: July 2009
Senior Member
Did you try to debug the test? Can you post a stacktrace?

Regards,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 23.01.13 22:06, schrieb junior developer:
> Hi,
>
> I teste my DSL but give an error from unit testing genareted language. :(
> my xtend class is below :
>
> package org.eclipse.xtext.example.domainmodel.tests
> import org.eclipse.xtext.junit4.XtextRunner
> import org.eclipse.xtext.example.domainmodel.DomainmodelInjectorProvider
> import org.eclipse.xtext.junit4.util.ParseHelper
> import static org.junit.Assert.*
>
>
> import org.eclipse.xtext.example.domainmodel.Domainmodel
> import org.eclipse.xtext.example.domainmodel.Entity
>
>
> import org.eclipse.xtext.junit4.InjectWith
>
> import org.junit.Test
> import org.junit.runner.RunWith
> import com.google.inject.Inject
>
> @InjectWith(typeof(DomainmodelInjectorProvider))
> @RunWith(typeof(XtextRunner))
>
> class ParserTest {
> @Inject
> ParseHelper<Domainmodel> parser
>
> @Test def void parseDomainmodel() {
> val model = parser.parse(
> "entity MyEntity {
> parent: MyEntity
> }")
> val entity = model.elements.head as Entity
> assertSame(entity, entity.features.head.type)
> }
>
> }
>
> Also,when ı create xtext project ,my project name is
> org.eclipse.xtext.example.domainmodel,language name is
> org.eclipse.xtext.example.Domainmodel,extension is dmodel.And then ı
> write grammar and ı generate language artifacts,consited
> org.eclipse.xtext.example under the
> org.eclipse.xtext.example.domainmodel.tests .these generated
> org.eclipse.example package consist DomainmodelInjectorProvider.java
> that ı used test class.So that,generated org.eclipse.xtext.example
> refactor org.eclipse.xtext.example.domainmodel manually,(if ı refactor
> this package name,ı take other error:( So the error can be encountered
> in current?
Re: Java.Lang.NullpointerException in UNIT TEST [message #1005368 is a reply to message #1004993] Fri, 25 January 2013 06:50 Go to previous message
junior developer is currently offline junior developer
Messages: 335
Registered: January 2013
Senior Member
Hi ,
I solved Problem ,thank you for your help .My ParserTesd.xtend class and ı add org.eclipse.xtext.xbase.lib;bundle-version="2.3.1" in the plug-in dependency .Test is succesfull.

package org.eclipse.xtext.example.domainmodel.tests
import org.eclipse.xtext.junit4.XtextRunner
import org.eclipse.xtext.example.domainmodel.DomainmodelInjectorProvider
import org.eclipse.xtext.junit4.util.ParseHelper
import static org.junit.Assert.*
import org.eclipse.xtext.example.domainmodel.Domainmodel
import org.eclipse.xtext.example.domainmodel.Entity


import org.eclipse.xtext.junit4.InjectWith

import org.junit.Test
import org.junit.runner.RunWith
import com.google.inject.Inject

@InjectWith(typeof(DomainmodelInjectorProvider))
@RunWith(typeof(XtextRunner))

class ParserTest {
@Inject
ParseHelper<Domainmodel> parser

@Test
def void parseDomainmodel() {
val model = parser.parse(
"entity MyEntity {
parent: MyEntity
}")
val entity = model.elements.head as Entity
assertSame(entity, entity.features.head.type)
}

}

Best Regard.
Previous Topic:Save one file, all files rebuilt?
Next Topic:Alternative Cross reference not working as expected
Goto Forum:
  


Current Time: Sun Sep 21 14:15:23 GMT 2014

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

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