|
|
(no subject) [message #687070 is a reply to message #687058] |
Thu, 26 May 2011 17:52 |
Eclipse User |
|
|
|
Originally posted by:
Below I've pasted code from a JUnit test I have. The idea is to create
an URI mapping from the real URI, with whatever protocol you use, to a
folder URI where the models and model instances are.
Hallvard
URI testUri =
URI.createURI(String.valueOf(getClass().getResource(testData)));
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("xml",
new XMLResourceFactoryImpl());
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("xmi",
new XMIResourceFactoryImpl());
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("ecore",
new EcoreResourceFactoryImpl());
ResourceSetImpl resourceSet = new ResourceSetImpl();
resourceSet.getLoadOptions().put(XMLResource.OPTION_SCHEMA_LOCATION,
Boolean.TRUE);
// make tests independent of location, by using a logical uri
URI testFolderUri = createParentFolderUri(testUri);
resourceSet.getURIConverter().getURIMap().put(TESTS_URI, testFolderUri);
private URI createParentFolderUri(URI uri) {
String lastSegment = uri.lastSegment();
return (lastSegment == null || lastSegment.length() == 0 ? uri :
uri.trimSegments(1).appendSegment(""));
}
On 26.05.11 11.19, exquisitus wrote:
> I want to execute some code as JUnit Test, and not as JUnit Plug-in
> Test. But my code uses plugin:/ URIs for EMF resources. Has anybody
> experiences with this, what the best way is to adapt it to java-only
> execution? We dont need this functionality not only for JUnit test but
> also their should be a commandline facility for the core functionality
> later.
|
|
|
(no subject) [message #687269 is a reply to message #687058] |
Thu, 26 May 2011 12:13 |
Ed Merks Messages: 33142 Registered: July 2009 |
Senior Member |
|
|
What's a plugin: URI? Do you mean platform:/plugin? You could
generated an XyzPlugin class as use it's getBaseURL as the basis for
loading things from it from its URI.
exquisitus wrote:
> I want to execute some code as JUnit Test, and not as JUnit Plug-in
> Test. But my code uses plugin:/ URIs for EMF resources. Has anybody
> experiences with this, what the best way is to adapt it to java-only
> execution? We dont need this functionality not only for JUnit test but
> also their should be a commandline facility for the core functionality
> later.
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
(no subject) [message #687279 is a reply to message #687058] |
Thu, 26 May 2011 17:52 |
Eclipse User |
|
|
|
Originally posted by:
Below I've pasted code from a JUnit test I have. The idea is to create
an URI mapping from the real URI, with whatever protocol you use, to a
folder URI where the models and model instances are.
Hallvard
URI testUri =
URI.createURI(String.valueOf(getClass().getResource(testData)));
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("xml",
new XMLResourceFactoryImpl());
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("xmi",
new XMIResourceFactoryImpl());
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("ecore",
new EcoreResourceFactoryImpl());
ResourceSetImpl resourceSet = new ResourceSetImpl();
resourceSet.getLoadOptions().put(XMLResource.OPTION_SCHEMA_LOCATION,
Boolean.TRUE);
// make tests independent of location, by using a logical uri
URI testFolderUri = createParentFolderUri(testUri);
resourceSet.getURIConverter().getURIMap().put(TESTS_URI, testFolderUri);
private URI createParentFolderUri(URI uri) {
String lastSegment = uri.lastSegment();
return (lastSegment == null || lastSegment.length() == 0 ? uri :
uri.trimSegments(1).appendSegment(""));
}
On 26.05.11 11.19, exquisitus wrote:
> I want to execute some code as JUnit Test, and not as JUnit Plug-in
> Test. But my code uses plugin:/ URIs for EMF resources. Has anybody
> experiences with this, what the best way is to adapt it to java-only
> execution? We dont need this functionality not only for JUnit test but
> also their should be a commandline facility for the core functionality
> later.
|
|
|
Powered by
FUDForum. Page generated in 0.04182 seconds