Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpelder2006-05-01 13:49:08 -0400
committerpelder2006-05-01 13:49:08 -0400
commit6c16e3b86706c3c3b2bdfa4145864c0f5cbdf0e7 (patch)
tree35b080afe3a75fbcf57cd4e053e4cf35a7775dc4 /tests/org.eclipse.jet.tests
parentaf5f21cb3853157ecea1ec27a82c2aee59545a5e (diff)
downloadorg.eclipse.jet-6c16e3b86706c3c3b2bdfa4145864c0f5cbdf0e7.tar.gz
org.eclipse.jet-6c16e3b86706c3c3b2bdfa4145864c0f5cbdf0e7.tar.xz
org.eclipse.jet-6c16e3b86706c3c3b2bdfa4145864c0f5cbdf0e7.zip
[139484] Allow JETCompiler to see tag library definitions from workspace projects.
Diffstat (limited to 'tests/org.eclipse.jet.tests')
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/AllTests.java4
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/TagLibraryDataFactoryTests.java104
2 files changed, 106 insertions, 2 deletions
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/AllTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/AllTests.java
index 3f0f0ea..21f8f54 100644
--- a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/AllTests.java
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/AllTests.java
@@ -6,9 +6,9 @@ import junit.framework.TestSuite;
public class AllTests {
public static Test suite() {
- TestSuite suite = new TestSuite(
- "Test for org.eclipse.jet.tests.taglib");
+ TestSuite suite = new TestSuite("Test for org.eclipse.jet.tests.taglib");
//$JUnit-BEGIN$
+ suite.addTestSuite(TagLibraryDataFactoryTests.class);
suite.addTestSuite(TestTagLibManager.class);
//$JUnit-END$
return suite;
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/TagLibraryDataFactoryTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/TagLibraryDataFactoryTests.java
new file mode 100644
index 0000000..3fe82d9
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/TagLibraryDataFactoryTests.java
@@ -0,0 +1,104 @@
+package org.eclipse.jet.tests.taglib;
+
+import java.net.URL;
+import java.util.Iterator;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.InvalidRegistryObjectException;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jet.internal.JETActivatorWrapper;
+import org.eclipse.jet.internal.extensionpoints.TagLibraryDataFactory;
+import org.eclipse.jet.taglib.TagAttributeDefinition;
+import org.eclipse.jet.taglib.TagDefinition;
+import org.eclipse.jet.taglib.TagLibrary;
+
+public class TagLibraryDataFactoryTests extends TestCase {
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.extensionpoints.TagLibraryDataFactory.createTagLibrary(String, IConfigurationElement)'
+ */
+ public void testCreateTagLibraryStringIConfigurationElement() {
+
+ final TagLibrary tagLibrary = getControlTagLibrary();
+
+ assertNotNull("TagLibrary instance", tagLibrary);
+ assertEquals("c", tagLibrary.getDefaultPrefix());
+ assertEquals("org.eclipse.jet.controlTags", tagLibrary.getLibraryId());
+ assertTrue("<c:get> found", tagLibrary.hasTag("get"));
+ }
+
+ /**
+ * @return
+ * @throws InvalidRegistryObjectException
+ */
+ private TagLibrary getControlTagLibrary() throws InvalidRegistryObjectException {
+ IConfigurationElement element = null;
+ final IExtension[] extensions = Platform.getExtensionRegistry().getExtensions("org.eclipse.jet");
+ for (int i = 0; i < extensions.length; i++) {
+ if("org.eclipse.jet.tagLibraries".equals(extensions[i].getExtensionPointUniqueIdentifier())) {
+ element = extensions[i].getConfigurationElements()[0]; // the first tag library
+ }
+ }
+ assertNotNull("Setup failure", element);
+ final TagLibrary tagLibrary = TagLibraryDataFactory.INSTANCE.createTagLibrary("org.eclipse.jet", element);
+ return tagLibrary;
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.extensionpoints.TagLibraryDataFactory.createTagLibraries(String, Object)'
+ */
+ public void testCreateTagLibraries() throws Exception {
+ final TagLibrary tagLibrary = getControlTagLibrary();
+
+ URL pluginURL = new URL("platform:/plugin/org.eclipse.jet/plugin.xml");
+ Object pluginDocRoot = JETActivatorWrapper.INSTANCE.getLoaderManager().getLoader(pluginURL.toExternalForm(), null, null).load(pluginURL);
+ assertNotNull("setup failure: doc root is null", pluginDocRoot);
+
+ final TagLibrary[] libraries = TagLibraryDataFactory.INSTANCE.createTagLibraries("org.eclipse.jet", pluginDocRoot);
+ assertNotNull("libraries not null", libraries);
+ assertTrue("libraries.length > 0", libraries.length > 0);
+
+ assertEquals(tagLibrary.getDefaultPrefix(), libraries[0].getDefaultPrefix());
+ assertEquals(tagLibrary.getLibraryId(), libraries[0].getLibraryId());
+ assertEquals(tagLibrary.getLibraryName(), libraries[0].getLibraryName());
+ final String[] tagNames = tagLibrary.getTagNames();
+ assertEquals(tagNames.length, libraries[0].getTagNames().length);
+
+ for (int i = 0; i < tagNames.length; i++) {
+ TagDefinition xtd = tagLibrary.getTagDefinition(tagNames[i]);
+ TagDefinition ptd = libraries[0].getTagDefinition(tagNames[i]);
+ assertNotNull(tagNames[i] + ": xtd", xtd);
+ assertNotNull(tagNames[i] + ": ptd", ptd);
+ assertEquals(tagNames[i], xtd.isContentAllowed(), ptd.isContentAllowed());
+ assertEquals(tagNames[i], xtd.isDeprecated(), ptd.isDeprecated());
+ assertEquals(tagNames[i], xtd.isEmptyTagAllowed(), ptd.isEmptyTagAllowed());
+ assertEquals(tagNames[i], xtd.removeWhenContainingLineIsEmpty(), ptd.removeWhenContainingLineIsEmpty());
+ assertEquals(tagNames[i], xtd.requiresNewWriter(), ptd.requiresNewWriter());
+ assertEquals(tagNames[i], xtd.getDescription(), ptd.getDescription());
+ assertEquals(tagNames[i], xtd.getKind(), ptd.getKind());
+ assertEquals(tagNames[i], xtd.getName(), ptd.getName());
+
+ final List xtdAttrs = xtd.getAttributeDefinitions();
+ final List ptdAttrs = ptd.getAttributeDefinitions();
+ assertNotNull(tagNames[i] + ": xtdAttrs", xtdAttrs);
+ assertNotNull(tagNames[i] + ": ptdAttrs", ptdAttrs);
+ assertEquals(xtdAttrs.size(), ptdAttrs.size());
+
+ for (Iterator j = xtdAttrs.iterator(), k = ptdAttrs.iterator(); j.hasNext();) {
+ TagAttributeDefinition xtad = (TagAttributeDefinition) j.next();
+ TagAttributeDefinition ptad = (TagAttributeDefinition) k.next();
+ final String attrName = xtad.getName();
+ assertEquals(tagNames[i], attrName, ptad.getName());
+ assertEquals(tagNames[i] + ":" + attrName, xtad.getDescription(), ptad.getDescription());
+ assertEquals(tagNames[i] + ":" + attrName, xtad.isDeprecated(), ptad.isDeprecated());
+ assertEquals(tagNames[i] + ":" + attrName, xtad.isRequired(), ptad.isRequired());
+ assertEquals(tagNames[i] + ":" + attrName, xtad.getType(), ptad.getType());
+ }
+ }
+ }
+
+}

Back to the top