Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Strange Exception thrown in JUNIT test
Strange Exception thrown in JUNIT test [message #1009038] Thu, 14 February 2013 05:25
Oliver Zhou is currently offline Oliver Zhou
Messages: 41
Registered: February 2012
Member
Hi All,

I have a Spring-based web application and use a customized Xtext DSL.
I have a Spring bean that will load my DSL using XtextResourceSet during the startup of the application.
Everything is fine when the web application is run under Jetty/Tomcat.

But if I write a unit test that using SpringTestRunner, when initializing this bean, a lot of exceptions are thrown by xtext like the following:
java.lang.StringIndexOutOfBoundsException: String index out of range: 6700
	at java.lang.String.substring(String.java:1934)
	at org.eclipse.xtext.nodemodel.impl.AbstractNode.getText(AbstractNode.java:95)
	at org.eclipse.xtext.nodemodel.util.NodeModelUtils.getTokenText(NodeModelUtils.java:381)
	at org.eclipse.xtext.linking.impl.LinkingHelper.getCrossRefNodeAsString(LinkingHelper.java:51)
	at org.eclipse.xtext.linking.impl.DefaultLinkingService.getCrossRefNodeAsString(DefaultLinkingService.java:132)
	at org.eclipse.xtext.linking.impl.DefaultLinkingService.getLinkedObjects(DefaultLinkingService.java:113)
	at org.eclipse.xtext.linking.lazy.LazyLinkingResource.getEObject(LazyLinkingResource.java:179)
	at org.eclipse.xtext.xbase.resource.XbaseResource.access$0(XbaseResource.java:1)
	at org.eclipse.xtext.xbase.resource.XbaseResource$2.exec(XbaseResource.java:239)
	at org.eclipse.xtext.xbase.resource.XbaseResource$2.exec(XbaseResource.java:1)
	at org.eclipse.xtext.util.OnChangeEvictingCache.execWithoutCacheClear(OnChangeEvictingCache.java:124)
	at org.eclipse.xtext.xbase.resource.XbaseResource.getEObject(XbaseResource.java:237)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getEObject(ResourceSetImpl.java:219)
	at org.eclipse.emf.ecore.util.EcoreUtil.resolve(EcoreUtil.java:207)
	at org.eclipse.emf.ecore.util.EcoreUtil.resolve(EcoreUtil.java:263)
	at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eResolveProxy(BasicEObjectImpl.java:1483)
	at com.ebao.appframework.natExprLang.impl.EnumAttributeImpl.getType(EnumAttributeImpl.java:96)
	at com.ebao.appframework.jvmmodel.NatExprLangJvmModelInferrer.mapToJvmTypeRef(NatExprLangJvmModelInferrer.java:207)
	at com.ebao.appframework.jvmmodel.NatExprLangJvmModelInferrer._transform(NatExprLangJvmModelInferrer.java:235)
	at com.ebao.appframework.jvmmodel.NatExprLangJvmModelInferrer.transform(NatExprLangJvmModelInferrer.java:355)
	at com.ebao.appframework.jvmmodel.NatExprLangJvmModelInferrer._transform(NatExprLangJvmModelInferrer.java:192)
	at com.ebao.appframework.jvmmodel.NatExprLangJvmModelInferrer.transform(NatExprLangJvmModelInferrer.java:344)
	at com.ebao.appframework.jvmmodel.NatExprLangJvmModelInferrer._infer(NatExprLangJvmModelInferrer.java:68)
	at com.ebao.appframework.jvmmodel.NatExprLangJvmModelInferrer.infer(NatExprLangJvmModelInferrer.java:331)
	at org.eclipse.xtext.xbase.jvmmodel.AbstractModelInferrer._infer(AbstractModelInferrer.java:69)
	at com.ebao.appframework.jvmmodel.NatExprLangJvmModelInferrer.infer(NatExprLangJvmModelInferrer.java:334)
	at org.eclipse.xtext.xbase.jvmmodel.AbstractModelInferrer._infer(AbstractModelInferrer.java:69)
	at com.ebao.appframework.jvmmodel.NatExprLangJvmModelInferrer.infer(NatExprLangJvmModelInferrer.java:334)
	at org.eclipse.xtext.xbase.jvmmodel.AbstractModelInferrer._infer(AbstractModelInferrer.java:69)
	at com.ebao.appframework.jvmmodel.NatExprLangJvmModelInferrer.infer(NatExprLangJvmModelInferrer.java:334)
	at org.eclipse.xtext.xbase.jvmmodel.JvmModelAssociator.installDerivedState(JvmModelAssociator.java:231)
	at org.eclipse.xtext.resource.DerivedStateAwareResource.installDerivedState(DerivedStateAwareResource.java:125)
	at org.eclipse.xtext.resource.DerivedStateAwareResource.getContents(DerivedStateAwareResource.java:48)


What I don't understand is why these exceptions only happen in JUNIT test and how to resolve it?
Previous Topic:Generating from BNF Grammar at runtime
Next Topic:How to replace XtextDocument in the editor with a projection of it
Goto Forum:
  


Current Time: Sat Apr 19 16:06:06 EDT 2014

Powered by FUDForum. Page generated in 0.01441 seconds