Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 08:21 Go to next message
Uwe San is currently offline Uwe SanFriend
Messages: 119
Registered: January 2012
Senior Member
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 09:04 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30439
Registered: July 2009
Senior Member
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 09:17 Go to previous messageGo to next message
Uwe San is currently offline Uwe SanFriend
Messages: 119
Registered: January 2012
Senior Member
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 10:39 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30439
Registered: July 2009
Senior Member
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 13:25 Go to previous message
Uwe San is currently offline Uwe SanFriend
Messages: 119
Registered: January 2012
Senior Member
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: Mon Sep 16 02:03:41 GMT 2019

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

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

Back to the top