Author: scabanovich
Date: 2011-03-17 13:48:25 -0400 (Thu, 17 Mar 2011)
New Revision: 29868
Added:
trunk/common/tests/org.jboss.tools.common.model.test/src/org/jboss/tools/common/model/test/ResourceAdapterTest.java
Modified:
trunk/common/tests/org.jboss.tools.common.model.test/src/org/jboss/tools/common/model/test/CommonModelAllTests.java
Log:
JBIDE-8602
https://issues.jboss.org/browse/JBIDE-8602
Modified:
trunk/common/tests/org.jboss.tools.common.model.test/src/org/jboss/tools/common/model/test/CommonModelAllTests.java
===================================================================
---
trunk/common/tests/org.jboss.tools.common.model.test/src/org/jboss/tools/common/model/test/CommonModelAllTests.java 2011-03-17
17:25:23 UTC (rev 29867)
+++
trunk/common/tests/org.jboss.tools.common.model.test/src/org/jboss/tools/common/model/test/CommonModelAllTests.java 2011-03-17
17:48:25 UTC (rev 29868)
@@ -34,6 +34,7 @@
suite.addTestSuite(PropertiesLoaderTest.class);
suite.addTestSuite(JarAccessTest.class);
suite.addTestSuite(EclipseJavaUtilTest.class);
+ suite.addTestSuite(ResourceAdapterTest.class);
return suite;
}
}
Added:
trunk/common/tests/org.jboss.tools.common.model.test/src/org/jboss/tools/common/model/test/ResourceAdapterTest.java
===================================================================
---
trunk/common/tests/org.jboss.tools.common.model.test/src/org/jboss/tools/common/model/test/ResourceAdapterTest.java
(rev 0)
+++
trunk/common/tests/org.jboss.tools.common.model.test/src/org/jboss/tools/common/model/test/ResourceAdapterTest.java 2011-03-17
17:48:25 UTC (rev 29868)
@@ -0,0 +1,61 @@
+package org.jboss.tools.common.model.test;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.ui.ide.ResourceUtil;
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.test.util.JobUtils;
+import org.jboss.tools.test.util.TestProjectProvider;
+
+/**
+ *
+ * @author V.Kabanovich
+ *
+ */
+public class ResourceAdapterTest extends TestCase {
+ static String BUNDLE_NAME = "org.jboss.tools.common.model.test";
+ TestProjectProvider provider = null;
+ IProject project = null;
+
+ public ResourceAdapterTest() {}
+
+ public void setUp() throws Exception {
+ provider = new TestProjectProvider(BUNDLE_NAME, null, "Test1", true);
+ project = provider.getProject();
+
+ project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+
+ JobUtils.waitForIdle();
+ }
+
+ public void testResourceAdapter() throws CoreException, IOException {
+ IFile f = project.getFile(new Path("src/x.properties"));
+ assertNotNull(f);
+ XModelObject p = EclipseResourceUtil.createObjectForResource(f);
+ assertNotNull(p);
+ XModelObject a = p.getChildByPath("a");
+
+ // XModelObject should not directly adapt to IResource -
+ IResource r = (IResource)a.getAdapter(IResource.class);
+ assertNull(r);
+
+ // There is adapter factory to adapt XModelObject to IResource
+ r = (IResource)ResourceUtil.getAdapter(a, IResource.class, true);
+ assertEquals(f, r);
+
+ // At present, direct adapting to IFile rises no problem.
+ IFile fa = (IFile)a.getAdapter(IFile.class);
+ assertEquals(f, fa);
+
+ }
+
+}
Property changes on:
trunk/common/tests/org.jboss.tools.common.model.test/src/org/jboss/tools/common/model/test/ResourceAdapterTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain