Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/org.eclipse.wst.sse.sieditor.core/api/org/eclipse/wst/sse/sieditor/core/editorfwk/ModelHandler.java17
-rw-r--r--plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/core/editorfwk/ModelHandlerTest.java20
2 files changed, 37 insertions, 0 deletions
diff --git a/plugins/org.eclipse.wst.sse.sieditor.core/api/org/eclipse/wst/sse/sieditor/core/editorfwk/ModelHandler.java b/plugins/org.eclipse.wst.sse.sieditor.core/api/org/eclipse/wst/sse/sieditor/core/editorfwk/ModelHandler.java
index f0108d7..952ed52 100644
--- a/plugins/org.eclipse.wst.sse.sieditor.core/api/org/eclipse/wst/sse/sieditor/core/editorfwk/ModelHandler.java
+++ b/plugins/org.eclipse.wst.sse.sieditor.core/api/org/eclipse/wst/sse/sieditor/core/editorfwk/ModelHandler.java
@@ -100,4 +100,21 @@ public class ModelHandler {
// how to get the
// correct state?
}
+
+ public static IModelObject retrieveModelObjectURIFragmentNone(String s, String uri) {
+ ResourceSet rs = new ResourceSetImpl();
+ Resource resource = rs.createResource(URI.createURI(uri,true,URI.FRAGMENT_NONE));
+
+ try {
+ ByteArrayInputStream is = new ByteArrayInputStream(s.getBytes("UTF-8")); //$NON-NLS-1$
+ resource.load(is, null);
+ } catch (IOException e) {
+ Logger.log(SIEditorCoreActivator.PLUGIN_ID, IStatus.ERROR, "Can not load resource " + resource.getURI(), e); //$NON-NLS-1$
+ return null;
+ }
+ Object emfObjectList = resource.getContents();
+ String extension = uri.substring(uri.lastIndexOf('.') + 1);
+ ExtensibleObjectFactory factory = ExtensibleObjectFactoryRegistry.get(extension);
+ return factory.createModelObject(emfObjectList, false);
+ }
}
diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/core/editorfwk/ModelHandlerTest.java b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/core/editorfwk/ModelHandlerTest.java
index 3a38f86..db612d2 100644
--- a/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/core/editorfwk/ModelHandlerTest.java
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/core/editorfwk/ModelHandlerTest.java
@@ -37,6 +37,7 @@ import org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema;
public class ModelHandlerTest extends SIEditorBaseTest {
+ private static final String FOLDER_NAME_WITH_HASH = "hash#test";
@Test
public void testLoadXSDfromFile() throws IOException, CoreException {
final IFile file = ResourceUtils.copyFileIntoTestProject("pub/xsd/example.xsd", Document_FOLDER_NAME, this.getProject(),
@@ -74,6 +75,25 @@ public class ModelHandlerTest extends SIEditorBaseTest {
assertTrue(modelObject instanceof IWsdlModelRoot);
}
+
+ @Test
+ public void testLoadWSDLfromFile_URIwithHASH() throws IOException, CoreException {
+ final IFile file = ResourceUtils.copyFileIntoTestProject("pub/self/mix2/ChangePurchaseOrder_WSD.wsdl",
+ FOLDER_NAME_WITH_HASH, this.getProject(), "ChangePurchaseOrder_WSD.wsdl");
+ refreshProjectNFile(file);
+
+ StringBuffer sb = new StringBuffer();
+ BufferedInputStream bis = new BufferedInputStream(file.getContents());
+ int readedByte;
+ while ((readedByte = bis.read()) > 0) {
+ sb.append((char) readedByte);
+ }
+
+ String fileContent = sb.toString();
+ IModelObject modelObject = ModelHandler.retrieveModelObjectURIFragmentNone(fileContent, "file:/"+file.getLocation().toString());
+
+ assertTrue(modelObject instanceof IWsdlModelRoot);
+ }
@Test
public void testOperationHistoryNotClearedAfterRetrivingModelObject() throws IOException, CoreException, ExecutionException {

Back to the top