Bug 530835: Cleanup of pojos and interfaces for holding scheme info
use the appropriate interfaces for
- reading schemes from extension point
- enriching them with operating system related information
- adding/removing them in the operating system
Change-Id: I61c53d0011cb86b835db9d916b05b31b59183302
Signed-off-by: Marcus Hoepfner <marcus.hoepfner@sap.com>
diff --git a/bundles/org.eclipse.ui.ide.application/src/org/eclipse/ui/internal/ide/application/dialogs/UriSchemeHandlerPreferencePage.java b/bundles/org.eclipse.ui.ide.application/src/org/eclipse/ui/internal/ide/application/dialogs/UriSchemeHandlerPreferencePage.java
index 8c8c59a..9a5d339 100644
--- a/bundles/org.eclipse.ui.ide.application/src/org/eclipse/ui/internal/ide/application/dialogs/UriSchemeHandlerPreferencePage.java
+++ b/bundles/org.eclipse.ui.ide.application/src/org/eclipse/ui/internal/ide/application/dialogs/UriSchemeHandlerPreferencePage.java
@@ -44,9 +44,9 @@
import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
import org.eclipse.ui.statushandlers.StatusManager;
import org.eclipse.urischeme.IOperatingSystemRegistration;
+import org.eclipse.urischeme.IScheme;
import org.eclipse.urischeme.ISchemeInformation;
import org.eclipse.urischeme.IUriSchemeExtensionReader;
-import org.eclipse.urischeme.IUriSchemeExtensionReader.Scheme;
/**
* This page contributes to URL handler for URISchemes in preference page of
@@ -149,7 +149,7 @@
*/
private Collection<UiSchemeInformation> retrieveSchemeInformationList() throws Exception {
Collection<UiSchemeInformation> returnList = new ArrayList<>();
- Collection<Scheme> schemes = IUriSchemeExtensionReader.INSTANCE.getSchemes();
+ Collection<IScheme> schemes = IUriSchemeExtensionReader.INSTANCE.getSchemes();
if (operatingSystemRegistration != null) {
for (ISchemeInformation info : operatingSystemRegistration.getSchemesInformation(schemes)) {
returnList.add(new UiSchemeInformation(info.isHandled(), info));
@@ -177,8 +177,8 @@
return true;
}
- List<ISchemeInformation> toAdd = new ArrayList<>();
- List<ISchemeInformation> toRemove = new ArrayList<>();
+ List<IScheme> toAdd = new ArrayList<>();
+ List<IScheme> toRemove = new ArrayList<>();
for (UiSchemeInformation info : schemeInformationList) {
if (info.checked && !info.information.isHandled()) {
toAdd.add(info.information);
@@ -251,7 +251,7 @@
IDEWorkbenchMessages.UriHandlerPreferencePage_Warning_OtherApp,
NLS.bind(IDEWorkbenchMessages.UriHandlerPreferencePage_Warning_OtherApp_Description,
schemeInformation.information.getHandlerInstanceLocation(),
- schemeInformation.information.getScheme()));
+ schemeInformation.information.getName()));
return;
}
schemeInformation.checked = tableItem.getChecked();
@@ -280,7 +280,7 @@
UiSchemeInformation schemeInfo = (UiSchemeInformation) element;
switch (columnIndex) {
case 0:
- return schemeInfo.information.getScheme();
+ return schemeInfo.information.getName();
case 1:
return schemeInfo.information.getDescription();
default:
diff --git a/bundles/org.eclipse.urischeme/src/org/eclipse/urischeme/IOperatingSystemRegistration.java b/bundles/org.eclipse.urischeme/src/org/eclipse/urischeme/IOperatingSystemRegistration.java
index 84dc609..605cb61 100644
--- a/bundles/org.eclipse.urischeme/src/org/eclipse/urischeme/IOperatingSystemRegistration.java
+++ b/bundles/org.eclipse.urischeme/src/org/eclipse/urischeme/IOperatingSystemRegistration.java
@@ -14,7 +14,6 @@
import java.util.List;
import org.eclipse.core.runtime.Platform;
-import org.eclipse.urischeme.IUriSchemeExtensionReader.Scheme;
import org.eclipse.urischeme.internal.registration.RegistrationLinux;
import org.eclipse.urischeme.internal.registration.RegistrationMacOsX;
import org.eclipse.urischeme.internal.registration.RegistrationWindows;
@@ -51,7 +50,7 @@
* @param toRemove the uri schemes which this Eclipse should not handle anymore
* @throws Exception something went wrong
*/
- void handleSchemes(Collection<ISchemeInformation> toAdd, Collection<ISchemeInformation> toRemove) throws Exception;
+ void handleSchemes(Collection<IScheme> toAdd, Collection<IScheme> toRemove) throws Exception;
/**
* Takes the given schemes and fills information like whether they are
@@ -61,7 +60,7 @@
* @return schemes with information
* @throws Exception something went wrong
*/
- List<ISchemeInformation> getSchemesInformation(Collection<Scheme> schemes) throws Exception;
+ List<ISchemeInformation> getSchemesInformation(Collection<IScheme> schemes) throws Exception;
/**
* @return the Eclipse executable
diff --git a/bundles/org.eclipse.urischeme/src/org/eclipse/urischeme/IScheme.java b/bundles/org.eclipse.urischeme/src/org/eclipse/urischeme/IScheme.java
new file mode 100644
index 0000000..bed6fb9
--- /dev/null
+++ b/bundles/org.eclipse.urischeme/src/org/eclipse/urischeme/IScheme.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2018 SAP SE 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:
+ * SAP SE - initial version
+ *******************************************************************************/
+package org.eclipse.urischeme;
+
+/**
+ * The basic information of an URI scheme like name and description.
+ *
+ */
+public interface IScheme {
+
+ /**
+ * @return the name of the scheme
+ */
+ String getName();
+
+ /**
+ * @return the description of the scheme
+ */
+ String getDescription();
+}
diff --git a/bundles/org.eclipse.urischeme/src/org/eclipse/urischeme/ISchemeInformation.java b/bundles/org.eclipse.urischeme/src/org/eclipse/urischeme/ISchemeInformation.java
index e366541..4c8ee8e 100644
--- a/bundles/org.eclipse.urischeme/src/org/eclipse/urischeme/ISchemeInformation.java
+++ b/bundles/org.eclipse.urischeme/src/org/eclipse/urischeme/ISchemeInformation.java
@@ -10,23 +10,11 @@
*******************************************************************************/
package org.eclipse.urischeme;
-import org.eclipse.urischeme.internal.registration.SchemeInformation;
-
/**
* The basic information of an URI scheme with regards to the handler.
*
*/
-public interface ISchemeInformation {
-
- /**
- * @return the name of the scheme
- */
- String getScheme();
-
- /**
- * @return the description of the scheme
- */
- String getDescription();
+public interface ISchemeInformation extends IScheme {
/**
* @return true if the scheme is handled by the running Eclipse installation;
@@ -35,31 +23,7 @@
boolean isHandled();
/**
- * Sets the handled value to true if scheme is handled by current Eclipse
- * installation and false otherwise
- * @param value
- */
- void setHandled(boolean value);
-
- /**
* @return the path of the application
*/
String getHandlerInstanceLocation();
-
- /**
- * @param location
- */
- void setHandlerLocation(String location);
-
- /**
- * Returns the instance of ISchemeInformation interface.
- *
- * @param schemeName
- * @param schemeDescription
- * @param handlerLocation
- * @return instance of ISchemeInformation
- */
- static ISchemeInformation getInstance(String schemeName, String schemeDescription, String handlerLocation) {
- return new SchemeInformation(schemeName, schemeDescription, handlerLocation);
- }
}
\ No newline at end of file
diff --git a/bundles/org.eclipse.urischeme/src/org/eclipse/urischeme/IUriSchemeExtensionReader.java b/bundles/org.eclipse.urischeme/src/org/eclipse/urischeme/IUriSchemeExtensionReader.java
index 511ab4b..fcc1dea 100644
--- a/bundles/org.eclipse.urischeme/src/org/eclipse/urischeme/IUriSchemeExtensionReader.java
+++ b/bundles/org.eclipse.urischeme/src/org/eclipse/urischeme/IUriSchemeExtensionReader.java
@@ -12,45 +12,6 @@
public interface IUriSchemeExtensionReader {
/**
- * Simple pojo holding information about an available URI scheme
- *
- */
- public static class Scheme {
-
- private String uriScheme;
- private String uriSchemeDescription;
-
- /**
- * Returns an instance of Scheme
- *
- * @param uriScheme The URI scheme
- * @param uriSchemeDescription The description of the URI scheme
- */
- public Scheme(String uriScheme, String uriSchemeDescription) {
- super();
- this.uriScheme = uriScheme;
- this.uriSchemeDescription = uriSchemeDescription;
- }
-
- /**
- *
- * @return The URI scheme
- */
- public String getUriScheme() {
- return uriScheme;
- }
-
- /**
- *
- * @return The description of the URI scheme
- */
- public String getUriSchemeDescription() {
- return uriSchemeDescription;
- }
-
- }
-
- /**
* The instance of IUriSchemeExtensionReader
*/
IUriSchemeExtensionReader INSTANCE = UriSchemeExtensionReader.getInstance();
@@ -59,7 +20,7 @@
*
* @return The list of available URI schemes
*/
- Collection<Scheme> getSchemes();
+ Collection<IScheme> getSchemes();
/**
* Creates the handler for a given URI scheme as registered in extension point
diff --git a/bundles/org.eclipse.urischeme/src/org/eclipse/urischeme/internal/UriSchemeExtensionReader.java b/bundles/org.eclipse.urischeme/src/org/eclipse/urischeme/internal/UriSchemeExtensionReader.java
index f6a5496..2715a81 100644
--- a/bundles/org.eclipse.urischeme/src/org/eclipse/urischeme/internal/UriSchemeExtensionReader.java
+++ b/bundles/org.eclipse.urischeme/src/org/eclipse/urischeme/internal/UriSchemeExtensionReader.java
@@ -9,6 +9,7 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.RegistryFactory;
import org.eclipse.core.runtime.Status;
+import org.eclipse.urischeme.IScheme;
import org.eclipse.urischeme.IUriSchemeExtensionReader;
import org.eclipse.urischeme.IUriSchemeHandler;
@@ -54,13 +55,13 @@
}
@Override
- public Collection<Scheme> getSchemes() {
+ public Collection<IScheme> getSchemes() {
IConfigurationElement[] elements = getOrReadConfigurationElements();
- Collection<Scheme> schemes = new ArrayList<>();
+ Collection<IScheme> schemes = new ArrayList<>();
for (IConfigurationElement element : elements) {
String schemeName = element.getAttribute(EXT_POINT_ATTRIBUTE_URI_SCHEME);
String schemeDescription = element.getAttribute(EXT_POINT_ATTRIBUTE_URI_SCHEME_DESCRIPTION);
- Scheme scheme = new Scheme(schemeName, schemeDescription);
+ IScheme scheme = new Scheme(schemeName, schemeDescription);
schemes.add(scheme);
}
return schemes;
@@ -96,4 +97,26 @@
"Registered class has wrong type: " + executableExtension.getClass())); //$NON-NLS-1$
}
+ private static class Scheme implements IScheme {
+
+ private String uriScheme;
+ private String uriSchemeDescription;
+
+ public Scheme(String uriScheme, String uriSchemeDescription) {
+ super();
+ this.uriScheme = uriScheme;
+ this.uriSchemeDescription = uriSchemeDescription;
+ }
+
+ @Override
+ public String getName() {
+ return uriScheme;
+ }
+
+ @Override
+ public String getDescription() {
+ return uriSchemeDescription;
+ }
+
+ }
}
diff --git a/bundles/org.eclipse.urischeme/src/org/eclipse/urischeme/internal/registration/RegistrationLinux.java b/bundles/org.eclipse.urischeme/src/org/eclipse/urischeme/internal/registration/RegistrationLinux.java
index 1e3b2c8..6ecad0e 100644
--- a/bundles/org.eclipse.urischeme/src/org/eclipse/urischeme/internal/registration/RegistrationLinux.java
+++ b/bundles/org.eclipse.urischeme/src/org/eclipse/urischeme/internal/registration/RegistrationLinux.java
@@ -17,8 +17,8 @@
import java.util.stream.Collectors;
import org.eclipse.urischeme.IOperatingSystemRegistration;
+import org.eclipse.urischeme.IScheme;
import org.eclipse.urischeme.ISchemeInformation;
-import org.eclipse.urischeme.IUriSchemeExtensionReader.Scheme;
@SuppressWarnings("javadoc")
public class RegistrationLinux implements IOperatingSystemRegistration {
@@ -46,7 +46,7 @@
}
@Override
- public void handleSchemes(Collection<ISchemeInformation> toAdd, Collection<ISchemeInformation> toRemove)
+ public void handleSchemes(Collection<IScheme> toAdd, Collection<IScheme> toRemove)
throws Exception {
String desktopFileName = getDesktopFileName();
@@ -56,14 +56,14 @@
}
@Override
- public List<ISchemeInformation> getSchemesInformation(Collection<Scheme> schemes) throws Exception {
+ public List<ISchemeInformation> getSchemesInformation(Collection<IScheme> schemes) throws Exception {
List<ISchemeInformation> returnList = new ArrayList<>();
- for (Scheme scheme : schemes) {
- SchemeInformation schemeInfo = new SchemeInformation(scheme.getUriScheme(),
- scheme.getUriSchemeDescription(), null);
+ for (IScheme scheme : schemes) {
+ SchemeInformation schemeInfo = new SchemeInformation(scheme.getName(),
+ scheme.getDescription());
- String location = determineHandlerLocation(scheme.getUriScheme());
+ String location = determineHandlerLocation(scheme.getName());
if (location.equals(getEclipseLauncher())) {
schemeInfo.setHandled(true);
}
@@ -81,17 +81,17 @@
return ""; //$NON-NLS-1$
}
- private void changeDesktopFile(Iterable<ISchemeInformation> toAdd, Iterable<ISchemeInformation> toRemove,
+ private void changeDesktopFile(Iterable<IScheme> toAdd, Iterable<IScheme> toRemove,
String desktopFilePath) throws IOException {
List<String> lines = readFileOrGetInitialContent(desktopFilePath);
DesktopFileWriter writer = new DesktopFileWriter(lines);
- for (ISchemeInformation add : toAdd) {
- writer.addScheme(add.getScheme());
+ for (IScheme scheme : toAdd) {
+ writer.addScheme(scheme.getName());
}
- for (ISchemeInformation remove : toRemove) {
- writer.removeScheme(remove.getScheme());
+ for (IScheme scheme : toRemove) {
+ writer.removeScheme(scheme.getName());
}
fileProvider.write(desktopFilePath, writer.getResult());
@@ -105,13 +105,13 @@
}
}
- private void registerSchemesWithXdgMime(Collection<ISchemeInformation> schemes, String desktopFilePath)
+ private void registerSchemesWithXdgMime(Collection<IScheme> schemes, String desktopFilePath)
throws Exception {
if (schemes.isEmpty()) {
return;
}
String scheme = schemes.stream(). //
- map(s -> s.getScheme()). //
+ map(s -> s.getName()). //
collect(Collectors.joining(" " + X_SCHEME_HANDLER_PREFIX, X_SCHEME_HANDLER_PREFIX, "")); //$NON-NLS-1$ //$NON-NLS-2$
processExecutor.execute(XDG_MIME, DEFAULT, desktopFilePath, scheme);
}
diff --git a/bundles/org.eclipse.urischeme/src/org/eclipse/urischeme/internal/registration/RegistrationMacOsX.java b/bundles/org.eclipse.urischeme/src/org/eclipse/urischeme/internal/registration/RegistrationMacOsX.java
index 743ae08..2340f9a 100644
--- a/bundles/org.eclipse.urischeme/src/org/eclipse/urischeme/internal/registration/RegistrationMacOsX.java
+++ b/bundles/org.eclipse.urischeme/src/org/eclipse/urischeme/internal/registration/RegistrationMacOsX.java
@@ -20,8 +20,8 @@
import java.util.stream.Stream;
import org.eclipse.urischeme.IOperatingSystemRegistration;
+import org.eclipse.urischeme.IScheme;
import org.eclipse.urischeme.ISchemeInformation;
-import org.eclipse.urischeme.IUriSchemeExtensionReader.Scheme;
@SuppressWarnings("javadoc")
public class RegistrationMacOsX implements IOperatingSystemRegistration {
@@ -45,7 +45,7 @@
}
@Override
- public void handleSchemes(Collection<ISchemeInformation> toAdd, Collection<ISchemeInformation> toRemove)
+ public void handleSchemes(Collection<IScheme> toAdd, Collection<IScheme> toRemove)
throws Exception {
String pathToEclipseApp = getPathToEclipseApp();
@@ -55,19 +55,19 @@
}
@Override
- public List<ISchemeInformation> getSchemesInformation(Collection<Scheme> schemes) throws Exception {
+ public List<ISchemeInformation> getSchemesInformation(Collection<IScheme> schemes) throws Exception {
List<ISchemeInformation> returnList = new ArrayList<>();
String lsRegisterOutput = processExecutor.execute(LSREGISTER, DUMP);
String[] lsRegisterEntries = lsRegisterOutput.split("-{80}\n"); //$NON-NLS-1$
- for (Scheme scheme : schemes) {
+ for (IScheme scheme : schemes) {
- SchemeInformation schemeInfo = new SchemeInformation(scheme.getUriScheme(),
- scheme.getUriSchemeDescription(), null);
+ SchemeInformation schemeInfo = new SchemeInformation(scheme.getName(),
+ scheme.getDescription());
- String location = determineHandlerLocation(lsRegisterEntries, scheme.getUriScheme());
+ String location = determineHandlerLocation(lsRegisterEntries, scheme.getName());
if (location != "" && getEclipseLauncher().startsWith(location)) { //$NON-NLS-1$
schemeInfo.setHandled(true);
}
@@ -114,18 +114,18 @@
processExecutor.execute(LSREGISTER, RECURSIVE, pathToEclipseApp);
}
- private void changePlistFile(Collection<ISchemeInformation> toAdd, Collection<ISchemeInformation> toRemove,
+ private void changePlistFile(Collection<IScheme> toAdd, Collection<IScheme> toRemove,
String pathToEclipseApp) throws IOException {
String plistPath = pathToEclipseApp + PLIST_PATH_SUFFIX;
PlistFileWriter writer = getPlistFileWriter(plistPath);
- for (ISchemeInformation scheme : toAdd) {
- writer.addScheme(scheme.getScheme(), scheme.getDescription());
+ for (IScheme scheme : toAdd) {
+ writer.addScheme(scheme.getName(), scheme.getDescription());
}
- for (ISchemeInformation scheme : toRemove) {
- writer.removeScheme(scheme.getScheme());
+ for (IScheme scheme : toRemove) {
+ writer.removeScheme(scheme.getName());
}
writer.writeTo(fileProvider.newWriter(plistPath));
diff --git a/bundles/org.eclipse.urischeme/src/org/eclipse/urischeme/internal/registration/RegistrationWindows.java b/bundles/org.eclipse.urischeme/src/org/eclipse/urischeme/internal/registration/RegistrationWindows.java
index a5676a1..682a2a8 100644
--- a/bundles/org.eclipse.urischeme/src/org/eclipse/urischeme/internal/registration/RegistrationWindows.java
+++ b/bundles/org.eclipse.urischeme/src/org/eclipse/urischeme/internal/registration/RegistrationWindows.java
@@ -15,8 +15,8 @@
import java.util.List;
import org.eclipse.urischeme.IOperatingSystemRegistration;
+import org.eclipse.urischeme.IScheme;
import org.eclipse.urischeme.ISchemeInformation;
-import org.eclipse.urischeme.IUriSchemeExtensionReader.Scheme;
/**
* Windows OS specific handling of schemes
*
@@ -46,13 +46,13 @@
}
@Override
- public void handleSchemes(Collection<ISchemeInformation> toAdd, Collection<ISchemeInformation> toRemove)
+ public void handleSchemes(Collection<IScheme> toAdd, Collection<IScheme> toRemove)
throws Exception {
- for (ISchemeInformation scheme : toAdd) {
- registryWriter.addScheme(scheme.getScheme());
+ for (IScheme scheme : toAdd) {
+ registryWriter.addScheme(scheme.getName());
}
- for (ISchemeInformation scheme : toRemove) {
- registryWriter.removeScheme(scheme.getScheme());
+ for (IScheme scheme : toRemove) {
+ registryWriter.removeScheme(scheme.getName());
}
}
@@ -67,15 +67,15 @@
* @throws Exception
*/
@Override
- public List<ISchemeInformation> getSchemesInformation(Collection<Scheme> schemes) throws Exception {
+ public List<ISchemeInformation> getSchemesInformation(Collection<IScheme> schemes) throws Exception {
String launcher = getEclipseLauncher();
List<ISchemeInformation> schemeInformations = new ArrayList<>();
- for (Scheme scheme : schemes) {
- SchemeInformation schemeInfo = new SchemeInformation(scheme.getUriScheme(),
- scheme.getUriSchemeDescription(), null);
- String path = registryWriter.getRegisteredHandlerPath(schemeInfo.getScheme());
+ for (IScheme scheme : schemes) {
+ SchemeInformation schemeInfo = new SchemeInformation(scheme.getName(),
+ scheme.getDescription());
+ String path = registryWriter.getRegisteredHandlerPath(schemeInfo.getName());
if (path == null) {
path = ""; //$NON-NLS-1$
}
diff --git a/bundles/org.eclipse.urischeme/src/org/eclipse/urischeme/internal/registration/SchemeInformation.java b/bundles/org.eclipse.urischeme/src/org/eclipse/urischeme/internal/registration/SchemeInformation.java
index 344909d..5dae9d0 100644
--- a/bundles/org.eclipse.urischeme/src/org/eclipse/urischeme/internal/registration/SchemeInformation.java
+++ b/bundles/org.eclipse.urischeme/src/org/eclipse/urischeme/internal/registration/SchemeInformation.java
@@ -18,22 +18,21 @@
*/
public class SchemeInformation implements ISchemeInformation {
- private String scheme;
- private String schemeDescription;
+ private String name;
+ private String description;
private boolean handled;
private String handlerInstanceLocation;
@SuppressWarnings("javadoc")
- public SchemeInformation(String schemeName, String schemeDescription, String handlerLocation) {
+ public SchemeInformation(String schemeName, String schemeDescription) {
super();
- this.scheme = schemeName;
- this.schemeDescription = schemeDescription;
- setHandlerLocation(handlerLocation);
+ this.name = schemeName;
+ this.description = schemeDescription;
}
@Override
- public String getScheme() {
- return scheme;
+ public String getName() {
+ return name;
}
@Override
@@ -46,18 +45,23 @@
return handlerInstanceLocation;
}
- @Override
+ /**
+ * Sets the handled value to true if scheme is handled by current Eclipse
+ * installation and false otherwise
+ *
+ * @param handled
+ */
public void setHandled(boolean handled) {
this.handled = handled;
}
- @Override
+ @SuppressWarnings("javadoc")
public void setHandlerLocation(String handlerInstanceLocation) {
this.handlerInstanceLocation = handlerInstanceLocation;
}
@Override
public String getDescription() {
- return schemeDescription;
+ return description;
}
}
diff --git a/tests/org.eclipse.tests.urischeme/src/org/eclipse/urischeme/internal/UriSchemeExtensionReaderUnitTest.java b/tests/org.eclipse.tests.urischeme/src/org/eclipse/urischeme/internal/UriSchemeExtensionReaderUnitTest.java
index b4a5406..4934862 100644
--- a/tests/org.eclipse.tests.urischeme/src/org/eclipse/urischeme/internal/UriSchemeExtensionReaderUnitTest.java
+++ b/tests/org.eclipse.tests.urischeme/src/org/eclipse/urischeme/internal/UriSchemeExtensionReaderUnitTest.java
@@ -20,7 +20,7 @@
import org.eclipse.core.runtime.IContributor;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.InvalidRegistryObjectException;
-import org.eclipse.urischeme.IUriSchemeExtensionReader.Scheme;
+import org.eclipse.urischeme.IScheme;
import org.junit.Before;
import org.junit.Test;
@@ -73,14 +73,14 @@
ConfigurationElementMock element2 = new ConfigurationElementMock("xyz", "xyz Scheme", new Object());
setExtensionsInReader(element1, element2);
- Collection<Scheme> schemes = extensionReader.getSchemes();
+ Collection<IScheme> schemes = extensionReader.getSchemes();
assertEquals(2, schemes.size());
- Scheme[] schemesArray = schemes.toArray(new Scheme[0]);
- assertEquals("abc", schemesArray[0].getUriScheme());
- assertEquals("abc Scheme", schemesArray[0].getUriSchemeDescription());
- assertEquals("xyz", schemesArray[1].getUriScheme());
- assertEquals("xyz Scheme", schemesArray[1].getUriSchemeDescription());
+ IScheme[] schemesArray = schemes.toArray(new IScheme[0]);
+ assertEquals("abc", schemesArray[0].getName());
+ assertEquals("abc Scheme", schemesArray[0].getDescription());
+ assertEquals("xyz", schemesArray[1].getName());
+ assertEquals("xyz Scheme", schemesArray[1].getDescription());
}
private void setExtensionsInReader(IConfigurationElement... element) throws Exception {
diff --git a/tests/org.eclipse.tests.urischeme/src/org/eclipse/urischeme/internal/UriSchemeProcessorUnitTest.java b/tests/org.eclipse.tests.urischeme/src/org/eclipse/urischeme/internal/UriSchemeProcessorUnitTest.java
index cdda424..d651c83 100644
--- a/tests/org.eclipse.tests.urischeme/src/org/eclipse/urischeme/internal/UriSchemeProcessorUnitTest.java
+++ b/tests/org.eclipse.tests.urischeme/src/org/eclipse/urischeme/internal/UriSchemeProcessorUnitTest.java
@@ -22,6 +22,7 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Status;
+import org.eclipse.urischeme.IScheme;
import org.eclipse.urischeme.IUriSchemeExtensionReader;
import org.eclipse.urischeme.IUriSchemeHandler;
import org.junit.Before;
@@ -80,7 +81,7 @@
public Map<String, Integer> readCount = new HashMap<>();
@Override
- public Collection<Scheme> getSchemes() {
+ public Collection<IScheme> getSchemes() {
return null;
}
diff --git a/tests/org.eclipse.tests.urischeme/src/org/eclipse/urischeme/internal/registration/Scheme.java b/tests/org.eclipse.tests.urischeme/src/org/eclipse/urischeme/internal/registration/Scheme.java
new file mode 100644
index 0000000..8b22903
--- /dev/null
+++ b/tests/org.eclipse.tests.urischeme/src/org/eclipse/urischeme/internal/registration/Scheme.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2018 SAP SE 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:
+ * SAP SE - initial version
+ *******************************************************************************/
+package org.eclipse.urischeme.internal.registration;
+
+import org.eclipse.urischeme.IScheme;
+
+/**
+ * Implementation of {@link IScheme} for testing purpose.
+ *
+ */
+public class Scheme implements IScheme {
+
+ private String name;
+ private String desription;
+
+ public Scheme(String name, String desription) {
+ this.name = name;
+ this.desription = desription;
+
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public String getDescription() {
+ return desription;
+ }
+
+}
diff --git a/tests/org.eclipse.tests.urischeme/src/org/eclipse/urischeme/internal/registration/TestUnitRegistrationLinux.java b/tests/org.eclipse.tests.urischeme/src/org/eclipse/urischeme/internal/registration/TestUnitRegistrationLinux.java
index d209d33..dd2ec51 100644
--- a/tests/org.eclipse.tests.urischeme/src/org/eclipse/urischeme/internal/registration/TestUnitRegistrationLinux.java
+++ b/tests/org.eclipse.tests.urischeme/src/org/eclipse/urischeme/internal/registration/TestUnitRegistrationLinux.java
@@ -23,8 +23,8 @@
import java.util.stream.Collectors;
import org.eclipse.urischeme.IOperatingSystemRegistration;
+import org.eclipse.urischeme.IScheme;
import org.eclipse.urischeme.ISchemeInformation;
-import org.eclipse.urischeme.IUriSchemeExtensionReader.Scheme;
import org.hamcrest.core.IsNot;
import org.hamcrest.core.StringContains;
import org.junit.AfterClass;
@@ -45,10 +45,10 @@
private static final String OWN_DESKTOP_FILE = "_home_myuser_Eclipse_.desktop";
private static final String PATH_OWN_DESKTOP_FILE = "~/.local/share/applications/" + OWN_DESKTOP_FILE;
- private static final Scheme ADT_SCHEME = new Scheme("adt", "");
+ private static final IScheme ADT_SCHEME = new Scheme("adt", "");
- private static final ISchemeInformation OTHER_SCHEME_INFO = new SchemeInformation("other", "", null);
- private static final ISchemeInformation ADT_SCHEME_INFO = new SchemeInformation("adt", "", null);
+ private static final ISchemeInformation OTHER_SCHEME_INFO = new SchemeInformation("other", "");
+ private static final ISchemeInformation ADT_SCHEME_INFO = new SchemeInformation("adt", "");
private static String originalEclipseHomeLocation;
private static String originalEclipseLauncher;
@@ -166,7 +166,7 @@
List<ISchemeInformation> registeredSchemes = registration.getSchemesInformation(Arrays.asList(ADT_SCHEME));
assertEquals(1, registeredSchemes.size());
- assertEquals("adt", registeredSchemes.get(0).getScheme());
+ assertEquals("adt", registeredSchemes.get(0).getName());
assertTrue("Scheme should be handled", registeredSchemes.get(0).isHandled());
}
@@ -182,7 +182,7 @@
List<ISchemeInformation> infos = registration.getSchemesInformation(Arrays.asList(ADT_SCHEME));
assertEquals(1, infos.size());
- assertEquals("adt", infos.get(0).getScheme());
+ assertEquals("adt", infos.get(0).getName());
assertFalse(infos.get(0).isHandled());
assertEquals(OTHER_APP_EXECUTABLE_PATH, infos.get(0).getHandlerInstanceLocation());
}
@@ -203,7 +203,7 @@
List<ISchemeInformation> infos = registration.getSchemesInformation(Arrays.asList(ADT_SCHEME));
assertEquals(1, infos.size());
- assertEquals("adt", infos.get(0).getScheme());
+ assertEquals("adt", infos.get(0).getName());
assertFalse(infos.get(0).isHandled());
assertEquals(OTHER_APP_EXECUTABLE_PATH, infos.get(0).getHandlerInstanceLocation());
}
@@ -220,7 +220,7 @@
List<ISchemeInformation> infos = registration.getSchemesInformation(Arrays.asList(ADT_SCHEME));
assertEquals(1, infos.size());
- assertEquals("adt", infos.get(0).getScheme());
+ assertEquals("adt", infos.get(0).getName());
assertFalse(infos.get(0).isHandled());
assertEquals("", infos.get(0).getHandlerInstanceLocation());
}
@@ -236,7 +236,7 @@
List<ISchemeInformation> infos = registration.getSchemesInformation(Arrays.asList(ADT_SCHEME));
assertEquals(1, infos.size());
- assertEquals("adt", infos.get(0).getScheme());
+ assertEquals("adt", infos.get(0).getName());
assertFalse(infos.get(0).isHandled());
assertEquals("", infos.get(0).getHandlerInstanceLocation());
}
@@ -252,7 +252,7 @@
List<ISchemeInformation> infos = registration.getSchemesInformation(Arrays.asList(ADT_SCHEME));
assertEquals(1, infos.size());
- assertEquals("adt", infos.get(0).getScheme());
+ assertEquals("adt", infos.get(0).getName());
assertFalse(infos.get(0).isHandled());
assertEquals("", infos.get(0).getHandlerInstanceLocation());
}
@@ -268,7 +268,7 @@
List<ISchemeInformation> infos = registration.getSchemesInformation(Arrays.asList(ADT_SCHEME));
assertEquals(1, infos.size());
- assertEquals("adt", infos.get(0).getScheme());
+ assertEquals("adt", infos.get(0).getName());
assertFalse(infos.get(0).isHandled());
assertEquals("", infos.get(0).getHandlerInstanceLocation());
}
diff --git a/tests/org.eclipse.tests.urischeme/src/org/eclipse/urischeme/internal/registration/TestUnitRegistrationMacOsX.java b/tests/org.eclipse.tests.urischeme/src/org/eclipse/urischeme/internal/registration/TestUnitRegistrationMacOsX.java
index 5fe77e4..3e9b0ae 100644
--- a/tests/org.eclipse.tests.urischeme/src/org/eclipse/urischeme/internal/registration/TestUnitRegistrationMacOsX.java
+++ b/tests/org.eclipse.tests.urischeme/src/org/eclipse/urischeme/internal/registration/TestUnitRegistrationMacOsX.java
@@ -27,8 +27,8 @@
import java.util.Scanner;
import org.eclipse.urischeme.IOperatingSystemRegistration;
+import org.eclipse.urischeme.IScheme;
import org.eclipse.urischeme.ISchemeInformation;
-import org.eclipse.urischeme.IUriSchemeExtensionReader.Scheme;
import org.hamcrest.core.IsNot;
import org.hamcrest.core.StringContains;
import org.junit.AfterClass;
@@ -42,9 +42,9 @@
private static final String OTHER_APP_PLIST_PATH = "/Users/myuser/Applications/OtherApp.app/Contents/Info.plist";
private static final String OTHER_APP_BUNDLE_PATH = "/Users/myuser/Applications/OtherApp.app";
- private static final Scheme ADT_SCHEME = new Scheme("adt", "");
- private static final ISchemeInformation OTHER_SCHEME_INFO = new SchemeInformation("other", "", null);
- private static final ISchemeInformation ADT_SCHEME_INFO = new SchemeInformation("adt", "", null);
+ private static final IScheme ADT_SCHEME = new Scheme("adt", "");
+ private static final ISchemeInformation OTHER_SCHEME_INFO = new SchemeInformation("other", "");
+ private static final ISchemeInformation ADT_SCHEME_INFO = new SchemeInformation("adt", "");
private IOperatingSystemRegistration registration;
private FileProviderMock fileProvider;
@@ -144,7 +144,7 @@
List<ISchemeInformation> infos = registration.getSchemesInformation(Arrays.asList(ADT_SCHEME));
assertEquals(1, infos.size());
- assertEquals("adt", infos.get(0).getScheme());
+ assertEquals("adt", infos.get(0).getName());
assertTrue(infos.get(0).isHandled());
}
@@ -157,7 +157,7 @@
List<ISchemeInformation> infos = registration.getSchemesInformation(Arrays.asList(ADT_SCHEME));
assertEquals(1, infos.size());
- assertEquals("adt", infos.get(0).getScheme());
+ assertEquals("adt", infos.get(0).getName());
assertFalse(infos.get(0).isHandled());
assertEquals(OTHER_APP_BUNDLE_PATH, infos.get(0).getHandlerInstanceLocation());
}
@@ -172,7 +172,7 @@
List<ISchemeInformation> infos = registration.getSchemesInformation(Arrays.asList(ADT_SCHEME));
assertEquals(1, infos.size());
- assertEquals("adt", infos.get(0).getScheme());
+ assertEquals("adt", infos.get(0).getName());
assertFalse(infos.get(0).isHandled());
assertEquals(OTHER_APP_BUNDLE_PATH, infos.get(0).getHandlerInstanceLocation());
}
diff --git a/tests/org.eclipse.tests.urischeme/src/org/eclipse/urischeme/internal/registration/TestUnitRegistrationWindows.java b/tests/org.eclipse.tests.urischeme/src/org/eclipse/urischeme/internal/registration/TestUnitRegistrationWindows.java
index 7c5e93a..71f41a2 100644
--- a/tests/org.eclipse.tests.urischeme/src/org/eclipse/urischeme/internal/registration/TestUnitRegistrationWindows.java
+++ b/tests/org.eclipse.tests.urischeme/src/org/eclipse/urischeme/internal/registration/TestUnitRegistrationWindows.java
@@ -17,8 +17,8 @@
import java.util.Collections;
import java.util.List;
+import org.eclipse.urischeme.IScheme;
import org.eclipse.urischeme.ISchemeInformation;
-import org.eclipse.urischeme.IUriSchemeExtensionReader.Scheme;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -28,10 +28,10 @@
private static final String PATH_TO_OTHER_APPLICATION_EXE = "/path/to/otherApplication.exe";
private static final String PATH_TO_ECLIPSE_EXE = "/path/to/Eclipse.exe";
- private static final Scheme OTHER_SCHEME = new Scheme("other", "");
- private static final Scheme ADT_SCHEME = new Scheme("adt", "");
- private static final ISchemeInformation OTHER_SCHEME_INFO = new SchemeInformation("other", "", null);
- private static final ISchemeInformation ADT_SCHEME_INFO = new SchemeInformation("adt", "", null);
+ private static final IScheme OTHER_SCHEME = new Scheme("other", "");
+ private static final IScheme ADT_SCHEME = new Scheme("adt", "");
+ private static final ISchemeInformation OTHER_SCHEME_INFO = new SchemeInformation("other", "");
+ private static final ISchemeInformation ADT_SCHEME_INFO = new SchemeInformation("adt", "");
RegistryWriterMock registryWriter;
private static String originalEclipseLauncher;
@@ -59,8 +59,8 @@
registrationWindows.handleSchemes(Arrays.asList(OTHER_SCHEME_INFO, ADT_SCHEME_INFO), Collections.emptyList());
assertEquals("Too many schemes added", 2, registryWriter.addedSchemes.size());
- assertTrue("Scheme not added", registryWriter.addedSchemes.contains(OTHER_SCHEME_INFO.getScheme()));
- assertTrue("Scheme not added", registryWriter.addedSchemes.contains(ADT_SCHEME_INFO.getScheme()));
+ assertTrue("Scheme not added", registryWriter.addedSchemes.contains(OTHER_SCHEME_INFO.getName()));
+ assertTrue("Scheme not added", registryWriter.addedSchemes.contains(ADT_SCHEME_INFO.getName()));
assertEquals("Too many schemes removed", 0, registryWriter.removedSchemes.size());
}
@@ -70,10 +70,10 @@
registrationWindows.handleSchemes(Arrays.asList(OTHER_SCHEME_INFO), Arrays.asList(OTHER_SCHEME_INFO));
assertEquals("Too many schemes added", 1, registryWriter.addedSchemes.size());
- assertTrue("Scheme not added", registryWriter.addedSchemes.contains(OTHER_SCHEME_INFO.getScheme()));
+ assertTrue("Scheme not added", registryWriter.addedSchemes.contains(OTHER_SCHEME_INFO.getName()));
assertEquals("Too many schemes removed", 1, registryWriter.removedSchemes.size());
- assertTrue("Scheme not removed", registryWriter.removedSchemes.contains(OTHER_SCHEME_INFO.getScheme()));
+ assertTrue("Scheme not removed", registryWriter.removedSchemes.contains(OTHER_SCHEME_INFO.getName()));
}
@Test
@@ -82,12 +82,12 @@
Arrays.asList(OTHER_SCHEME_INFO, ADT_SCHEME_INFO), Arrays.asList(ADT_SCHEME_INFO, OTHER_SCHEME_INFO));
assertEquals("Too many schemes added", 2, registryWriter.addedSchemes.size());
- assertTrue("Scheme not added", registryWriter.addedSchemes.contains(OTHER_SCHEME_INFO.getScheme()));
- assertTrue("Scheme not added", registryWriter.addedSchemes.contains(ADT_SCHEME_INFO.getScheme()));
+ assertTrue("Scheme not added", registryWriter.addedSchemes.contains(OTHER_SCHEME_INFO.getName()));
+ assertTrue("Scheme not added", registryWriter.addedSchemes.contains(ADT_SCHEME_INFO.getName()));
assertEquals("Too many schemes removed", 2, registryWriter.removedSchemes.size());
- assertTrue("Scheme not removed", registryWriter.removedSchemes.contains(OTHER_SCHEME_INFO.getScheme()));
- assertTrue("Scheme not removed", registryWriter.removedSchemes.contains(ADT_SCHEME_INFO.getScheme()));
+ assertTrue("Scheme not removed", registryWriter.removedSchemes.contains(OTHER_SCHEME_INFO.getName()));
+ assertTrue("Scheme not removed", registryWriter.removedSchemes.contains(ADT_SCHEME_INFO.getName()));
}
@Test
@@ -102,7 +102,7 @@
@Test
public void returnsRegisteredSchemeInformationForThisEclipse() throws Exception {
- registryWriter.schemeToHandlerPath.put(ADT_SCHEME.getUriScheme(), PATH_TO_ECLIPSE_EXE);
+ registryWriter.schemeToHandlerPath.put(ADT_SCHEME.getName(), PATH_TO_ECLIPSE_EXE);
List<ISchemeInformation> schemeInformation = registrationWindows
.getSchemesInformation(Arrays.asList(ADT_SCHEME));
@@ -113,7 +113,7 @@
@Test
public void returnsRegisteredSchemeInformationForOtherApplication() throws Exception {
- registryWriter.schemeToHandlerPath.put(ADT_SCHEME.getUriScheme(), PATH_TO_OTHER_APPLICATION_EXE);
+ registryWriter.schemeToHandlerPath.put(ADT_SCHEME.getName(), PATH_TO_OTHER_APPLICATION_EXE);
List<ISchemeInformation> schemeInformation = registrationWindows
.getSchemesInformation(Arrays.asList(ADT_SCHEME));
@@ -122,10 +122,10 @@
assertSchemeInformation(schemeInformation.get(0), ADT_SCHEME, PATH_TO_OTHER_APPLICATION_EXE, false);
}
- private void assertSchemeInformation(ISchemeInformation schemeInformation, Scheme scheme, String handlerlocation,
+ private void assertSchemeInformation(ISchemeInformation schemeInformation, IScheme scheme, String handlerlocation,
boolean isHandled) {
- assertEquals("Scheme not set correctly", scheme.getUriScheme(), schemeInformation.getScheme());
- assertEquals("Scheme description not set correctly", scheme.getUriSchemeDescription(),
+ assertEquals("Scheme not set correctly", scheme.getName(), schemeInformation.getName());
+ assertEquals("Scheme description not set correctly", scheme.getDescription(),
schemeInformation.getDescription());
assertEquals("Handler location not set correctly", handlerlocation,
schemeInformation.getHandlerInstanceLocation());