summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Pingel2012-02-12 14:37:28 (EST)
committerSteffen Pingel2012-02-12 14:37:28 (EST)
commit1f37f45a3c23642fbb8706a682b2eb42cae2ec09 (patch)
treeb9b432a6bc38a746eb7d3f5cfb0a5bcd76fe61a3
parentce1b34fa428a8dc6e69db1f78bcef47e97038686 (diff)
downloadorg.eclipse.mylyn.commons-1f37f45a3c23642fbb8706a682b2eb42cae2ec09.zip
org.eclipse.mylyn.commons-1f37f45a3c23642fbb8706a682b2eb42cae2ec09.tar.gz
org.eclipse.mylyn.commons-1f37f45a3c23642fbb8706a682b2eb42cae2ec09.tar.bz2
NEW - bug 370620: [api] extend ExtensionPointReader to support filtering
and priority https://bugs.eclipse.org/bugs/show_bug.cgi?id=370620 Change-Id: I8381f861c4290e9d924a7c6ad5570618a0918f36
-rw-r--r--org.eclipse.mylyn.commons.tests/plugin.xml6
-rw-r--r--org.eclipse.mylyn.commons.tests/schema/extensionPointReaderTest.exsd98
-rw-r--r--org.eclipse.mylyn.commons.tests/src/org/eclipse/mylyn/commons/tests/AllCommonsTests.java2
-rw-r--r--org.eclipse.mylyn.commons.tests/src/org/eclipse/mylyn/commons/tests/core/ExtensionPointReaderTest.java75
4 files changed, 181 insertions, 0 deletions
diff --git a/org.eclipse.mylyn.commons.tests/plugin.xml b/org.eclipse.mylyn.commons.tests/plugin.xml
index 9673b12..26fc453 100644
--- a/org.eclipse.mylyn.commons.tests/plugin.xml
+++ b/org.eclipse.mylyn.commons.tests/plugin.xml
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
+ <extension-point id="extensionPointReaderTest" name="ExtensionPointReader Test" schema="schema/extensionPointReaderTest.exsd"/>
<extension
point="org.eclipse.ui.views">
<view
@@ -21,5 +22,10 @@
id="org.eclipse.mylyn.commons.tests.handler.LowPriority">
</handler>
</extension>
+ <extension
+ point="org.eclipse.mylyn.commons.tests.extensionPointReaderTest">
+ <extensionElement
+ class="org.eclipse.mylyn.commons.tests.core.ExtensionPointReaderTest$ExtensionPointReaderExtensionImplementation"></extensionElement>
+ </extension>
</plugin>
diff --git a/org.eclipse.mylyn.commons.tests/schema/extensionPointReaderTest.exsd b/org.eclipse.mylyn.commons.tests/schema/extensionPointReaderTest.exsd
new file mode 100644
index 0000000..06a40f7
--- /dev/null
+++ b/org.eclipse.mylyn.commons.tests/schema/extensionPointReaderTest.exsd
@@ -0,0 +1,98 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.mylyn.commons.tests" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.mylyn.commons.tests" id="extensionPointReaderTest" name="ExtensionPointReader Test"/>
+ </appinfo>
+ <documentation>
+ Test extenstion point for ExtensionPointReader.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element internal="true" />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="extensionElement" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="extensionElement">
+ <complexType>
+ <attribute name="class" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.mylyn.commons.tests.core.ExtensionPointReaderTest$ExtensionPointReaderExtension"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ 3.7
+ </documentation>
+ </annotation>
+
+
+
+
+ <annotation>
+ <appinfo>
+ <meta.section type="copyright"/>
+ </appinfo>
+ <documentation>
+ Copyright (c) 2012 Tasktop Technologies and others.
+All rights reserved. This program and the accompanying materials
+are made available under the terms of the Eclipse Public License v1.0
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/epl-v10.html
+
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/org.eclipse.mylyn.commons.tests/src/org/eclipse/mylyn/commons/tests/AllCommonsTests.java b/org.eclipse.mylyn.commons.tests/src/org/eclipse/mylyn/commons/tests/AllCommonsTests.java
index db228c6..720f47a 100644
--- a/org.eclipse.mylyn.commons.tests/src/org/eclipse/mylyn/commons/tests/AllCommonsTests.java
+++ b/org.eclipse.mylyn.commons.tests/src/org/eclipse/mylyn/commons/tests/AllCommonsTests.java
@@ -16,6 +16,7 @@ import junit.framework.TestSuite;
import org.eclipse.mylyn.commons.tests.core.AuthenticatedProxyTest;
import org.eclipse.mylyn.commons.tests.core.CoreUtilTest;
+import org.eclipse.mylyn.commons.tests.core.ExtensionPointReaderTest;
import org.eclipse.mylyn.commons.tests.net.NetUtilTest;
import org.eclipse.mylyn.commons.tests.net.SslProtocolSocketFactoryTest;
import org.eclipse.mylyn.commons.tests.net.TimeoutInputStreamTest;
@@ -38,6 +39,7 @@ public class AllCommonsTests {
suite.addTestSuite(WebUtilTest.class);
suite.addTestSuite(TimeoutInputStreamTest.class);
suite.addTestSuite(BrowserUtilTest.class);
+ suite.addTestSuite(ExtensionPointReaderTest.class);
return suite;
}
diff --git a/org.eclipse.mylyn.commons.tests/src/org/eclipse/mylyn/commons/tests/core/ExtensionPointReaderTest.java b/org.eclipse.mylyn.commons.tests/src/org/eclipse/mylyn/commons/tests/core/ExtensionPointReaderTest.java
new file mode 100644
index 0000000..63ef09d
--- /dev/null
+++ b/org.eclipse.mylyn.commons.tests/src/org/eclipse/mylyn/commons/tests/core/ExtensionPointReaderTest.java
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Tasktop Technologies and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.commons.tests.core;
+
+import java.util.Collections;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.mylyn.commons.core.ExtensionPointReader;
+
+/**
+ * @author Steffen Pingel
+ */
+public class ExtensionPointReaderTest extends TestCase {
+
+ public static interface ExtensionPointReaderExtension {
+
+ }
+
+ public static class ExtensionPointReaderExtensionImplementation implements ExtensionPointReaderExtension {
+
+ String id;
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((id == null) ? 0 : id.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ ExtensionPointReaderExtensionImplementation other = (ExtensionPointReaderExtensionImplementation) obj;
+ if (id == null) {
+ if (other.id != null) {
+ return false;
+ }
+ } else if (!id.equals(other.id)) {
+ return false;
+ }
+ return true;
+ }
+ }
+
+ private static final String ID_PLUGIN = "org.eclipse.mylyn.commons.tests";
+
+ public void testRead() {
+ ExtensionPointReader<ExtensionPointReaderExtension> reader = new ExtensionPointReader<ExtensionPointReaderExtension>(
+ ID_PLUGIN, "extensionPointReaderTest", "extensionElement", ExtensionPointReaderExtension.class);
+ IStatus status = reader.read();
+ assertEquals(IStatus.OK, status.getSeverity());
+ assertEquals(Collections.singletonList(new ExtensionPointReaderExtensionImplementation()), reader.getItems());
+ }
+
+}