Skip to main content



      Home
Home » Modeling » EMF » MissingResourceException in a unit test with EMF commands(How can I avoid the MRE in a unit test that calls CreateChildCommand?)
MissingResourceException in a unit test with EMF commands [message #1638662] Fri, 27 February 2015 03:21 Go to next message
Eclipse UserFriend
Hi all,

I get a MissingResourceException when I run a JUnit test on code that creates a CreateChildCommand. The stack trace says:

java.util.MissingResourceException: The string resource '_UI_XYZ_abc_feature' could not be located
	at org.eclipse.emf.common.util.DelegatingResourceLocator.delegatedGetString(DelegatingResourceLocator.java:480)
	at org.eclipse.emf.common.util.DelegatingResourceLocator.getString(DelegatingResourceLocator.java:385)
	at org.eclipse.emf.common.util.DelegatingResourceLocator.getString(DelegatingResourceLocator.java:359)
	at org.eclipse.emf.edit.provider.ItemProviderAdapter.getFeatureText(ItemProviderAdapter.java:1965)
	at org.eclipse.emf.edit.provider.ItemProviderAdapter.getCreateChildText(ItemProviderAdapter.java:1775)
	at org.eclipse.emf.edit.command.CreateChildCommand.<init>(CreateChildCommand.java:214)
	at org.eclipse.emf.edit.provider.ItemProviderAdapter.createCreateChildCommand(ItemProviderAdapter.java:1310)
	at org.eclipse.emf.edit.provider.ItemProviderAdapter.createCreateChildCommand(ItemProviderAdapter.java:1294)
	at org.eclipse.emf.edit.provider.ItemProviderAdapter.createCommand(ItemProviderAdapter.java:1089)
	at org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain.createCommand(AdapterFactoryEditingDomain.java:462)
	at org.eclipse.emf.edit.command.CreateChildCommand.create(CreateChildCommand.java:60)

Is there a way to make the resource available in a unit test environment?

I have seen a few discussions on this type of exception in this forum, but I could not find a solution that matches my case.

Thanks,
Uwe

Re: MissingResourceException in a unit test with EMF commands [message #1638721 is a reply to message #1638662] Fri, 27 February 2015 04:04 Go to previous messageGo to next message
Eclipse UserFriend
Are you running this as a pure JUnit test case or as an Eclipse
Application Unit? (Not sure the exact choices in the menu right now.)

On 27.02.2015 09:21, Uwe San wrote:
> Hi all,
>
> I get a MissingResourceException when I run a JUnit test on code that
> creates a CreateChildCommand. The stack trace says:
>
> java.util.MissingResourceException: The string resource
> '_UI_XYZ_abc_feature' could not be located
> at
> org.eclipse.emf.common.util.DelegatingResourceLocator.delegatedGetString(DelegatingResourceLocator.java:480)
>
> at
> org.eclipse.emf.common.util.DelegatingResourceLocator.getString(DelegatingResourceLocator.java:385)
>
> at
> org.eclipse.emf.common.util.DelegatingResourceLocator.getString(DelegatingResourceLocator.java:359)
>
> at
> org.eclipse.emf.edit.provider.ItemProviderAdapter.getFeatureText(ItemProviderAdapter.java:1965)
>
> at
> org.eclipse.emf.edit.provider.ItemProviderAdapter.getCreateChildText(ItemProviderAdapter.java:1775)
>
> at
> org.eclipse.emf.edit.command.CreateChildCommand.<init>(CreateChildCommand.java:214)
>
> at
> org.eclipse.emf.edit.provider.ItemProviderAdapter.createCreateChildCommand(ItemProviderAdapter.java:1310)
>
> at
> org.eclipse.emf.edit.provider.ItemProviderAdapter.createCreateChildCommand(ItemProviderAdapter.java:1294)
>
> at
> org.eclipse.emf.edit.provider.ItemProviderAdapter.createCommand(ItemProviderAdapter.java:1089)
>
> at
> org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain.createCommand(AdapterFactoryEditingDomain.java:462)
>
> at
> org.eclipse.emf.edit.command.CreateChildCommand.create(CreateChildCommand.java:60)
>
> Is there a way to make the resource available in a unit test environment?
>
> I have seen a few discussions on this type of exception in this forum,
> but I could not find a solution that matches my case.
>
> Thanks,
> Uwe
>
>
Re: MissingResourceException in a unit test with EMF commands [message #1638745 is a reply to message #1638721] Fri, 27 February 2015 04:17 Go to previous messageGo to next message
Eclipse UserFriend
I'm running this as a pure JUnit test case. I could try to run it as a plug-in test, but if there is a solution for pure unit tests, I'd prefer that.
Re: MissingResourceException in a unit test with EMF commands [message #1638874 is a reply to message #1638745] Fri, 27 February 2015 05:39 Go to previous messageGo to next message
Eclipse UserFriend
Uwe,

The problem is that at development time, only the contents of the bin
folder are on the classpath (for stand alone), so all the additional
things specified in the build.properties are not (yet) on the classpath.
When deployed as a bundle at development runtime, PDE's magic ensures
they're available nevertheless...


On 27.02.2015 10:17, Uwe San wrote:
> I'm running this as a pure JUnit test case. I could try to run it as a
> plug-in test, but if there is a solution for pure unit tests, I'd prefer
> that.
Re: MissingResourceException in a unit test with EMF commands [message #1639123 is a reply to message #1638874] Fri, 27 February 2015 08:25 Go to previous message
Eclipse UserFriend
Thank you for your reply, Ed. It seems that the creation of a CreateChildCommand is not compatible with a unit test environment. This might explain why there is no unit test for the CreateChildCommand class in the EMF git repo.

I'll try another approach to test my code.
Previous Topic:[Compare] Understanding the comparison panes
Next Topic:EMF diagram search
Goto Forum:
  


Current Time: Sun Aug 31 03:31:17 EDT 2025

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

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

Back to the top