mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 06:45:43 +02:00
[202630][api][persistence] SystemProfileManager.getDefaultPrivateSystemProfile() is inconsistent with ensureDefaultPrivateProfile()
https://bugs.eclipse.org/bugs/show_bug.cgi?id=202630
This commit is contained in:
parent
25f4c5be00
commit
2261632a16
2 changed files with 193 additions and 0 deletions
|
@ -0,0 +1,135 @@
|
|||
/*******************************************************************************
|
||||
* 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.profiles;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.rse.core.RSECorePlugin;
|
||||
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.tests.core.RSECoreTestCase;
|
||||
import org.eclipse.rse.ui.SystemPreferencesManager;
|
||||
|
||||
/**
|
||||
* Tests for {@link SystemPreferencesManager}.
|
||||
* Since these are persistence tests they will play with the creation and deletion of
|
||||
* profiles, hosts, filters, and other model objects. You should run this only in a
|
||||
* clean workspace.
|
||||
*/
|
||||
public class ProfileTest extends RSECoreTestCase {
|
||||
|
||||
ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
|
||||
ISystemProfileManager manager = registry.getSystemProfileManager();
|
||||
ISystemProfile defaultProfile = manager.getDefaultPrivateSystemProfile();
|
||||
|
||||
public ProfileTest(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.rse.tests.core.RSECoreTestCase#setUp()
|
||||
*/
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.rse.tests.core.RSECoreTestCase#tearDown()
|
||||
*/
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
public void testDefaultProfileMarking() {
|
||||
//-test-author-:DavidDykstal
|
||||
assertNotNull("default profile is null", defaultProfile);
|
||||
assertTrue("default profile is not active - 1", defaultProfile.isActive());
|
||||
assertTrue("default profile is not marked as default", defaultProfile.isDefaultPrivate());
|
||||
}
|
||||
|
||||
public void testDefaultProfileActivation() {
|
||||
//-test-author-:DavidDykstal
|
||||
registry.setSystemProfileActive(defaultProfile, true);
|
||||
assertTrue("default profile is not active - 2", defaultProfile.isActive());
|
||||
registry.setSystemProfileActive(defaultProfile, false); // this should be ignored
|
||||
assertTrue("default profile is not active - 3", defaultProfile.isActive());
|
||||
}
|
||||
|
||||
public void testDefaultProfileRename() {
|
||||
//-test-author-:DavidDykstal
|
||||
try {
|
||||
ISystemProfile profile = registry.getSystemProfile("bogus");
|
||||
assertNull(profile);
|
||||
String oldName = defaultProfile.getName();
|
||||
registry.renameSystemProfile(defaultProfile, "bogus");
|
||||
assertEquals("bogus", defaultProfile.getName());
|
||||
assertSame(defaultProfile, manager.getDefaultPrivateSystemProfile());
|
||||
profile = registry.getSystemProfile("bogus");
|
||||
assertSame(profile, manager.getDefaultPrivateSystemProfile());
|
||||
registry.renameSystemProfile(defaultProfile, oldName);
|
||||
assertEquals(oldName, defaultProfile.getName());
|
||||
assertSame(defaultProfile, manager.getDefaultPrivateSystemProfile());
|
||||
profile = registry.getSystemProfile(oldName);
|
||||
assertSame(profile, manager.getDefaultPrivateSystemProfile());
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void testProfileActivation() {
|
||||
//-test-author-:DavidDykstal
|
||||
try {
|
||||
ISystemProfile profile = registry.getSystemProfile("bogus");
|
||||
assertNull(profile);
|
||||
profile = registry.createSystemProfile("bogus", true);
|
||||
assertNotNull(profile);
|
||||
assertTrue("profile is not active, but should be", profile.isActive());
|
||||
registry.setSystemProfileActive(profile, false);
|
||||
assertFalse("profile is active, but should not be", profile.isActive());
|
||||
registry.setSystemProfileActive(profile, true);
|
||||
assertTrue("profile is not active, but should be", profile.isActive());
|
||||
registry.deleteSystemProfile(profile);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void testDefaultProfileDeletion() {
|
||||
//-test-author-:DavidDykstal
|
||||
try {
|
||||
registry.deleteSystemProfile(defaultProfile); // this should be ignored
|
||||
List profiles = Arrays.asList(manager.getSystemProfiles());
|
||||
assertTrue("default profile was deleted", profiles.contains(defaultProfile));
|
||||
assertTrue("default profile is not registered with manager", manager.getDefaultPrivateSystemProfile() == defaultProfile);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void testProfileDeletion() {
|
||||
//-test-author-:DavidDykstal
|
||||
try {
|
||||
ISystemProfile profile = registry.getSystemProfile("bogus");
|
||||
assertNull(profile);
|
||||
profile = registry.createSystemProfile("bogus", true);
|
||||
assertNotNull(profile);
|
||||
registry.deleteSystemProfile(profile);
|
||||
List profiles = Arrays.asList(manager.getSystemProfiles());
|
||||
assertFalse("profile was not deleted", profiles.contains(profile));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 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 API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.rse.tests.profiles;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.rse.tests.framework.DelegatingTestSuiteHolder;
|
||||
|
||||
public class ProfileTestSuite extends DelegatingTestSuiteHolder {
|
||||
/**
|
||||
* Standard Java application main method. Allows to launch the test
|
||||
* suite from outside as part of nightly runs, headless runs or other.
|
||||
* <p><b>Note:</b> Use only <code>junit.textui.TestRunner</code> here as
|
||||
* it is explicitly supposed to output the test output to the shell the
|
||||
* test suite has been launched from.
|
||||
* <p>
|
||||
* @param args The standard Java application command line parameters passed in.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
junit.textui.TestRunner.run(suite());
|
||||
}
|
||||
|
||||
/**
|
||||
* Combine all tests into a suite and returns the test suite instance.
|
||||
* <p>
|
||||
* <b>Note: This method must be always called <i><code>suite</code></i> ! Otherwise
|
||||
* the JUnit plug-in test launcher will fail to detect this class!</b>
|
||||
* <p>
|
||||
* @return The test suite instance.
|
||||
*/
|
||||
public static Test suite() {
|
||||
TestSuite suite = new TestSuite("RSE Profile Test Suite"); //$NON-NLS-1$
|
||||
suite.addTest(new ProfileTest("testDefaultProfileMarking"));
|
||||
suite.addTest(new ProfileTest("testDefaultProfileActivation"));
|
||||
suite.addTest(new ProfileTest("testDefaultProfileDeletion"));
|
||||
suite.addTest(new ProfileTest("testDefaultProfileRename"));
|
||||
suite.addTest(new ProfileTest("testProfileActivation"));
|
||||
suite.addTest(new ProfileTest("testProfileDeletion"));
|
||||
return suite;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.rse.tests.framework.AbstractTestSuiteHolder#getTestSuite()
|
||||
*/
|
||||
public TestSuite getTestSuite() {
|
||||
return (TestSuite)ProfileTestSuite.suite();
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue