From 1f37f45a3c23642fbb8706a682b2eb42cae2ec09 Mon Sep 17 00:00:00 2001 From: Steffen Pingel Date: Sun, 12 Feb 2012 20:37:28 +0100 Subject: NEW - bug 370620: [api] extend ExtensionPointReader to support filtering and priority https://bugs.eclipse.org/bugs/show_bug.cgi?id=370620 Change-Id: I8381f861c4290e9d924a7c6ad5570618a0918f36 --- org.eclipse.mylyn.commons.tests/plugin.xml | 6 ++ .../schema/extensionPointReaderTest.exsd | 98 ++++++++++++++++++++++ .../mylyn/commons/tests/AllCommonsTests.java | 2 + .../tests/core/ExtensionPointReaderTest.java | 75 +++++++++++++++++ 4 files changed, 181 insertions(+) create mode 100644 org.eclipse.mylyn.commons.tests/schema/extensionPointReaderTest.exsd create mode 100644 org.eclipse.mylyn.commons.tests/src/org/eclipse/mylyn/commons/tests/core/ExtensionPointReaderTest.java 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 @@ + + + + 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 @@ + + + + + + + + + Test extenstion point for ExtensionPointReader. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 3.7 + + + + + + + + + + + + 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 + + + + + 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 reader = new ExtensionPointReader( + ID_PLUGIN, "extensionPointReaderTest", "extensionElement", ExtensionPointReaderExtension.class); + IStatus status = reader.read(); + assertEquals(IStatus.OK, status.getSeverity()); + assertEquals(Collections.singletonList(new ExtensionPointReaderExtensionImplementation()), reader.getItems()); + } + +} -- cgit v1.2.3