Skip to main content
summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorpelder2006-04-06 04:09:26 -0400
committerpelder2006-04-06 04:09:26 -0400
commitd0b9babba1bde4cf2ae11f3728ba970516dd569d (patch)
tree4759411a264bd52e60284c1621a2f20626e42e8c /tests
parent5859f0d3fa0037f1aa103e92a962ef839b9ce043 (diff)
downloadorg.eclipse.jet-d0b9babba1bde4cf2ae11f3728ba970516dd569d.tar.gz
org.eclipse.jet-d0b9babba1bde4cf2ae11f3728ba970516dd569d.tar.xz
org.eclipse.jet-d0b9babba1bde4cf2ae11f3728ba970516dd569d.zip
[131192] Add parsing and use of information in plugin.xml
Diffstat (limited to 'tests')
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/runtime/TestBundleDescriptions.java18
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/runtime/TestBundleLoading.java75
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/control/LoadTagTests.java15
3 files changed, 78 insertions, 30 deletions
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/runtime/TestBundleDescriptions.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/runtime/TestBundleDescriptions.java
index 25b77d1..67d2751 100644
--- a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/runtime/TestBundleDescriptions.java
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/runtime/TestBundleDescriptions.java
@@ -12,7 +12,7 @@ public class TestBundleDescriptions extends TestCase {
public void testGetProjectDescription()
{
- final IStatus result = JET2Platform.execute("org.eclipse.jet.transforms.newproject",
+ final IStatus result = JET2Platform.runTransformOnString("org.eclipse.jet.transforms.newproject",
"<newProjectModel><project name=\"foo.bar\"/></newProjectModel>",
new NullProgressMonitor());
@@ -26,13 +26,17 @@ public class TestBundleDescriptions extends TestCase {
assertNotNull(tlRefs);
assertEquals(4, tlRefs.length);
assertEquals("c", tlRefs[0].getPrefix());
- assertEquals("f", tlRefs[1].getPrefix());
- assertEquals("ws", tlRefs[2].getPrefix());
- assertEquals("java", tlRefs[3].getPrefix());
+ assertEquals("java", tlRefs[1].getPrefix());
+ assertEquals("f", tlRefs[2].getPrefix());
+ assertEquals("ws", tlRefs[3].getPrefix());
assertEquals("org.eclipse.jet.controlTags", tlRefs[0].getTagLibraryId());
- assertEquals("org.eclipse.jet.formatTags", tlRefs[1].getTagLibraryId());
- assertEquals("org.eclipse.jet.workspaceTags", tlRefs[2].getTagLibraryId());
- assertEquals("org.eclipse.jet.javaTags", tlRefs[3].getTagLibraryId());
+ assertEquals("org.eclipse.jet.javaTags", tlRefs[1].getTagLibraryId());
+ assertEquals("org.eclipse.jet.formatTags", tlRefs[2].getTagLibraryId());
+ assertEquals("org.eclipse.jet.workspaceTags", tlRefs[3].getTagLibraryId());
+ assertTrue(tlRefs[0].isAutoImport());
+ assertTrue(tlRefs[1].isAutoImport());
+ assertTrue(tlRefs[2].isAutoImport());
+ assertFalse(tlRefs[3].isAutoImport());
}
}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/runtime/TestBundleLoading.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/runtime/TestBundleLoading.java
index fa37fc9..c333464 100644
--- a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/runtime/TestBundleLoading.java
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/runtime/TestBundleLoading.java
@@ -2,30 +2,75 @@ package org.eclipse.jet.tests.runtime;
import junit.framework.TestCase;
-import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jet.JET2Platform;
import org.eclipse.jet.JET2Template;
import org.eclipse.jet.JET2TemplateLoader;
-import org.eclipse.jet.internal.InternalJET2Platform;
-import org.eclipse.jet.internal.runtime.IJET2Runnable;
-import org.eclipse.jet.transform.IJETBundle;
+import org.eclipse.jet.taglib.TagLibraryReference;
+import org.eclipse.jet.transform.IJETBundleDescriptor;
+import org.eclipse.jet.transform.IJETBundleManager;
+import org.eclipse.jet.transform.IJETRunnable;
public class TestBundleLoading extends TestCase {
-
+
public void testLoadSimpleBundle() throws Exception {
- IJETBundle tx = InternalJET2Platform.getDefault().getTemplateBundle("org.eclipse.jet.transforms.newproject", null);
-
- assertNotNull(tx);
-
- tx.execute(new IJET2Runnable() {
+ final IJETBundleManager bundleManager = JET2Platform.getJETBundleManager();
+ final boolean[] executed = new boolean[1];
+ executed[0] = false;
+ bundleManager.run("org.eclipse.jet.transforms.newproject", new IJETRunnable() {
- public Diagnostic run(JET2TemplateLoader loader) {
- JET2Template template = loader.getTemplate("templates/control.jet");
-
+ public void run(IJETBundleDescriptor descriptor, JET2TemplateLoader templateLoader, IProgressMonitor monitor) {
+ executed[0] = true;
+ final JET2Template template = templateLoader.getTemplate(descriptor.getMainTemplate());
assertNotNull(template);
- return Diagnostic.OK_INSTANCE;
- }});
+ }}, new NullProgressMonitor());
+
+ assertTrue("executed", executed[0]);
+ }
+
+ public void testGetBundles() throws Exception {
+ String projectName = getClass().getName() + ".testGetBundles";
+ String source = "<newProjectModel><project name=\"" + projectName
+ + "\"/></newProjectModel>";
+ JET2Platform.runTransformOnString("org.eclipse.jet.transforms.newproject", source,
+ new NullProgressMonitor());
+
+ IJETBundleManager mgr = JET2Platform.getJETBundleManager();
+
+ final IJETBundleDescriptor[] all = mgr.getAllJETBundleDescriptors();
+ assertNotNull(all);
+ assertTrue(all.length > 0);
+ IJETBundleDescriptor myDescriptor = null;
+ for (int i = 0; i < all.length; i++) {
+ if (all[i].getId().equals(projectName)) {
+ myDescriptor = all[i];
+ break;
+ }
+ }
+ assertNotNull(myDescriptor);
+ assertEquals(projectName, myDescriptor.getId());
}
+ public void testGetDescriptionForProject() {
+ String projectName = getClass().getName() + ".getDescriptionForProject";
+ String source = "<newProjectModel><project name=\"" + projectName
+ + "\"/></newProjectModel>";
+ JET2Platform.runTransformOnString(
+ "org.eclipse.jet.transforms.newproject", source,
+ new NullProgressMonitor());
+ IJETBundleManager mgr = JET2Platform.getJETBundleManager();
+ final IJETBundleDescriptor descriptor = mgr
+ .getDescriptorForProject(projectName);
+ assertNotNull(descriptor);
+ final TagLibraryReference[] tlrefs = descriptor
+ .getTagLibraryReferences();
+ assertEquals(4, tlrefs.length);
+ assertEquals("c", tlrefs[0].getPrefix());
+ assertEquals("java", tlrefs[1].getPrefix());
+ assertEquals("f", tlrefs[2].getPrefix());
+ assertEquals("ws", tlrefs[3].getPrefix());
+ }
}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/control/LoadTagTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/control/LoadTagTests.java
index 7186820..b38c31e 100644
--- a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/control/LoadTagTests.java
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/control/LoadTagTests.java
@@ -1,19 +1,19 @@
package org.eclipse.jet.tests.taglib.control;
+import junit.framework.TestCase;
+
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jet.BodyContentWriter;
import org.eclipse.jet.JET2Context;
+import org.eclipse.jet.JET2Platform;
import org.eclipse.jet.JET2Writer;
import org.eclipse.jet.XPathContextExtender;
-import org.eclipse.jet.internal.InternalJET2Platform;
import org.eclipse.jet.internal.taglib.control.LoadTag;
import org.eclipse.jet.taglib.JET2TagException;
import org.eclipse.jet.taglib.TagInfo;
-import org.eclipse.jet.transform.IJETBundle;
+import org.eclipse.jet.transform.IJETBundleDescriptor;
import org.eclipse.jet.transform.TransformContextExtender;
-import junit.framework.TestCase;
-
public class LoadTagTests extends TestCase {
/*
@@ -25,12 +25,11 @@ public class LoadTagTests extends TestCase {
JET2Context context = new JET2Context((Object)null);
TransformContextExtender tce = new TransformContextExtender(context);
- final IJETBundle templateBundle = InternalJET2Platform.getDefault().getTemplateBundle(id, null);
- tce.setId(id);
- tce.setTransform(templateBundle);
+ final IJETBundleDescriptor descriptor = JET2Platform.getJETBundleManager().getDescriptor(id);
+ tce.setBundleDescriptor(descriptor);
LoadTag tag = new LoadTag();
- TagInfo td = new TagInfo("", 0, 0, 0,
+ TagInfo td = new TagInfo("", 1, 1,
new String[] { "url", "var", "type" },
new String[] { "templates/project/sample.xml.jet", "root", "xml" });
tag.setTagInfo(td);

Back to the top