diff options
author | Steffen Pingel | 2012-02-12 19:37:28 +0000 |
---|---|---|
committer | Steffen Pingel | 2012-02-12 19:37:28 +0000 |
commit | 1f37f45a3c23642fbb8706a682b2eb42cae2ec09 (patch) | |
tree | b9b432a6bc38a746eb7d3f5cfb0a5bcd76fe61a3 | |
parent | ce1b34fa428a8dc6e69db1f78bcef47e97038686 (diff) | |
download | org.eclipse.mylyn.commons-1f37f45a3c23642fbb8706a682b2eb42cae2ec09.tar.gz org.eclipse.mylyn.commons-1f37f45a3c23642fbb8706a682b2eb42cae2ec09.tar.xz org.eclipse.mylyn.commons-1f37f45a3c23642fbb8706a682b2eb42cae2ec09.zip |
NEW - bug 370620: [api] extend ExtensionPointReader to support filtering
and priority
https://bugs.eclipse.org/bugs/show_bug.cgi?id=370620
Change-Id: I8381f861c4290e9d924a7c6ad5570618a0918f36
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 9673b124..26fc4537 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 00000000..06a40f79 --- /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 db228c66..720f47ab 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 00000000..63ef09d0 --- /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()); + } + +} |