From f670a768bf24610cc5539fb83cccc2ff8a15efc5 Mon Sep 17 00:00:00 2001 From: David Dykstal Date: Tue, 18 Mar 2008 14:51:21 +0000 Subject: [PATCH] [223080] SystemRegistry.getSubSystems(IHost, Class) returns wrong results https://bugs.eclipse.org/bugs/show_bug.cgi?id=223080 --- .../internal/core/model/SystemRegistry.java | 2 +- .../META-INF/MANIFEST.MF | 1 + .../registries/SubSystemInterfacesTest.java | 64 +++++++++++++++++++ 3 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/registries/SubSystemInterfacesTest.java diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/core/model/SystemRegistry.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/core/model/SystemRegistry.java index 8a0cfdc0ddd..3d484224066 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/core/model/SystemRegistry.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/core/model/SystemRegistry.java @@ -993,7 +993,7 @@ public class SystemRegistry implements ISystemRegistry for (int i = 0; i < allSS.length; i++) { ISubSystem ss = allSS[i]; - if (subsystemInterface.isInstance(subsystemInterface)) + if (subsystemInterface.isInstance(ss)) { matches.add(ss); } diff --git a/rse/tests/org.eclipse.rse.tests/META-INF/MANIFEST.MF b/rse/tests/org.eclipse.rse.tests/META-INF/MANIFEST.MF index 6019493553e..868de1a25d2 100644 --- a/rse/tests/org.eclipse.rse.tests/META-INF/MANIFEST.MF +++ b/rse/tests/org.eclipse.rse.tests/META-INF/MANIFEST.MF @@ -13,6 +13,7 @@ Require-Bundle: org.junit, org.eclipse.rse.core;bundle-version="[3.0.0,4.0.0)", org.eclipse.rse.ui;bundle-version="[3.0.0,4.0.0)", org.eclipse.rse.subsystems.files.core;bundle-version="[3.0.0,4.0.0)", + org.eclipse.rse.subsystems.processes.core;bundle-version="[3.0.0,4.0.0)", org.eclipse.rse.subsystems.shells.core;bundle-version="[3.0.0,4.0.0)", org.eclipse.rse.tests.framework;bundle-version="[2.0.0,3.0.0)", org.eclipse.ui.views, diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/registries/SubSystemInterfacesTest.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/registries/SubSystemInterfacesTest.java new file mode 100644 index 00000000000..fb5bdd349d6 --- /dev/null +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/registries/SubSystemInterfacesTest.java @@ -0,0 +1,64 @@ +/******************************************************************************* + * Copyright (c) 2008 IBM Corporation 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: + * David Dykstal (IBM) - initial implementation + *******************************************************************************/ +package org.eclipse.rse.tests.core.registries; + +import org.eclipse.rse.core.IRSESystemType; +import org.eclipse.rse.core.RSECorePlugin; +import org.eclipse.rse.core.model.IHost; +import org.eclipse.rse.core.model.ISystemProfile; +import org.eclipse.rse.core.model.ISystemProfileManager; +import org.eclipse.rse.core.model.ISystemRegistry; +import org.eclipse.rse.core.subsystems.ISubSystem; +import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem; +import org.eclipse.rse.subsystems.processes.core.subsystem.IRemoteProcessSubSystem; +import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCmdSubSystem; +import org.eclipse.rse.tests.core.RSECoreTestCase; + +/** + * Tests the subsystem configuration proxy functionality. + * + * @author uwe.stieber@windriver.com + */ +public class SubSystemInterfacesTest extends RSECoreTestCase { + + public void testSubSystemFinding() { + //-test-author-:DavidDykstal + try { + ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry(); + assertNotNull("system registry not found", registry); //$NON-NLS-1$ + ISystemProfileManager profileManager = registry.getSystemProfileManager(); + // create an empty profile (profile1) + ISystemProfile profile = profileManager.createSystemProfile("profile1", true); + // populate profile1 with a connection (host1) + IRSESystemType systemType = RSECorePlugin.getTheCoreRegistry().getSystemTypeById(IRSESystemType.SYSTEMTYPE_UNIX_ID); + IHost host = registry.createHost(profile.getName(), systemType, "host1", "localhost", "host1", true); + // find all of its subsystems one way + ISubSystem[] subsystems = registry.getSubSystems(host); + int n = subsystems.length; + // find all of its subsystems another way + subsystems = registry.getSubsystems(host, ISubSystem.class); + assertEquals(n, subsystems.length); + // find its file subsystem + subsystems = registry.getSubsystems(host, IRemoteFileSubSystem.class); + assertEquals(1, subsystems.length); + // find its process subsystem + subsystems = registry.getSubsystems(host, IRemoteProcessSubSystem.class); + assertEquals(1, subsystems.length); + // find its shell subsystem + subsystems = registry.getSubsystems(host, IRemoteCmdSubSystem.class); + assertEquals(1, subsystems.length); + // remove the profile + registry.deleteSystemProfile(profile); + } catch (Exception e) { + throw new RuntimeException(e); + } + } +}