Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarin Wright2009-11-12 20:03:34 +0000
committerDarin Wright2009-11-12 20:03:34 +0000
commit92698767bf2efdc2e3593c7bdc85bfef39f0577b (patch)
tree6530987b34d056524c1b14775460593f7dd23933 /org.eclipse.debug.tests
parent0fa95669809df9a1b738e67cd443931ad5427627 (diff)
downloadeclipse.platform.debug-92698767bf2efdc2e3593c7bdc85bfef39f0577b.tar.gz
eclipse.platform.debug-92698767bf2efdc2e3593c7bdc85bfef39f0577b.tar.xz
eclipse.platform.debug-92698767bf2efdc2e3593c7bdc85bfef39f0577b.zip
REVERT CHANGES FOR Bug 41353 - [launching] Launch config templates
Diffstat (limited to 'org.eclipse.debug.tests')
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/LaunchConfigurationTests.java257
1 files changed, 2 insertions, 255 deletions
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/LaunchConfigurationTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/LaunchConfigurationTests.java
index c9de10cba..71d9ad534 100644
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/LaunchConfigurationTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/LaunchConfigurationTests.java
@@ -140,28 +140,7 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau
assertTrue("Should need saving", wc.isDirty()); //$NON-NLS-1$
return wc;
}
-
- /**
- * Creates and returns a new launch config the given name, local
- * or shared, with 4 attributes:
- * - String1 = "String1"
- * - Int1 = 1
- * - Boolean1 = true
- * - Boolean2 = false
- */
- protected ILaunchConfigurationWorkingCopy newTemplate(IContainer container, String name) throws CoreException {
- ILaunchConfigurationType type = getLaunchManager().getLaunchConfigurationType(ID_TEST_LAUNCH_TYPE);
- assertTrue("Should support debug mode", type.supportsMode(ILaunchManager.DEBUG_MODE)); //$NON-NLS-1$
- assertTrue("Should support run mode", type.supportsMode(ILaunchManager.RUN_MODE)); //$NON-NLS-1$
- ILaunchConfigurationWorkingCopy wc = type.newTemplate(container, name);
- wc.setAttribute("String1", "String1"); //$NON-NLS-1$ //$NON-NLS-2$
- wc.setAttribute("Int1", 1); //$NON-NLS-1$
- wc.setAttribute("Boolean1", true); //$NON-NLS-1$
- wc.setAttribute("Boolean2", false); //$NON-NLS-1$
- assertTrue("Should need saving", wc.isDirty()); //$NON-NLS-1$
- return wc;
- }
-
+
/**
* Creates and returns a new launch configuration with the given name, local
* or shared, with no attributes
@@ -172,17 +151,6 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau
assertEquals("Should have no attributes", 0, wc.getAttributes().size());
return wc;
}
-
- /**
- * Creates and returns a new launch configuration template with the given name, local
- * or shared, with no attributes
- */
- protected ILaunchConfigurationWorkingCopy newEmptyTemplate(IContainer container, String name) throws CoreException {
- ILaunchConfigurationType type = getLaunchManager().getLaunchConfigurationType(ID_TEST_LAUNCH_TYPE);
- ILaunchConfigurationWorkingCopy wc = type.newTemplate(container, name);
- assertEquals("Should have no attributes", 0, wc.getAttributes().size());
- return wc;
- }
/**
* Returns whether the given handle is contained in the specified
@@ -1077,228 +1045,7 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau
IPath location = workingCopy.getLocation();
assertEquals("Wrong path for local working copy", LaunchManager.LOCAL_LAUNCH_CONFIGURATION_CONTAINER_PATH.append("test-get-location.launch"), location);
}
-
- /**
- * Test copying attributes from one configuration to another.
- *
- * @throws CoreException
- */
- public void testCopyAttributes() throws CoreException {
- ILaunchConfigurationWorkingCopy source = newConfiguration(null, "test-copy-attributes-source");
- ILaunchConfigurationWorkingCopy dest = newEmptyConfiguration(null, "test-copy-attributes-dest");
- dest.copyAttributes(source);
- assertTrue("String1 should be String1", dest.getAttribute("String1", "Missing").equals("String1"));
- assertTrue("Int1 should be 1", dest.getAttribute("Int1", 0) == 1);
- assertTrue("Boolean1 should be true", dest.getAttribute("Boolean1", false));
- assertTrue("Boolean2 should be false", !dest.getAttribute("Boolean2", true));
- }
-
- /**
- * Tests that creation from a template works.
- *
- * @throws CoreException
- */
- public void testCreationFromTemplate() throws CoreException {
- ILaunchConfigurationWorkingCopy temp = newTemplate(null, "test-creation-from-template");
- temp.setAttribute("TEMPLATE", "TEMPLATE");
- ILaunchConfiguration template = temp.doSave();
- ILaunchConfigurationType type = temp.getType();
-
- // create a new configuration in project scope priority
- ILaunchConfigurationWorkingCopy config = type.newInstance(null, "test-scopes", template);
- assertNotNull("Made from wrong template", config.getAttribute("TEMPLATE", (String)null));
- assertEquals("Should refer to creation template", template, config.getTemplate());
- }
-
- /**
- * Tests setting the 'isTemplate' attribute.
- *
- * @throws CoreException
- */
- public void testIsTemplate() throws CoreException {
- ILaunchConfigurationWorkingCopy wc = newTemplate(null, "test-is-template");
- ILaunchConfiguration template = wc.doSave();
- assertTrue("Should be a template", template.isTemplate());
- ILaunchConfiguration[] templates = wc.getType().getTemplates();
- List list = new ArrayList();
- for (int i = 0; i < templates.length; i++) {
- list.add(templates[i]);
- }
- assertFalse("Expecting at least template", list.isEmpty());
- assertTrue("Missing created template", list.contains(template));
- }
-
- /**
- * Tests finding references to a template.
- *
- * @throws CoreException
- */
- public void testTemplateChildren() throws CoreException {
- ILaunchConfigurationWorkingCopy wc = newTemplate(null, "test-references");
- ILaunchConfiguration template = wc.doSave();
-
- ILaunchConfigurationWorkingCopy r1 = newConfiguration(null, "referee-1");
- ILaunchConfigurationWorkingCopy r2 = newConfiguration(null, "referee-2");
-
- r1.setTemplate(template, false);
- r2.setTemplate(template, false);
-
- ILaunchConfiguration s1 = r1.doSave();
- ILaunchConfiguration s2 = r2.doSave();
-
- ILaunchConfiguration[] children = template.getTemplateChildren();
- assertEquals("Wrong number of template children", 2, children.length);
- List list = new ArrayList();
- for (int i = 0; i < children.length; i++) {
- list.add(children[i]);
- }
- assertTrue("Missing reference", list.contains(s1));
- assertTrue("Missing reference", list.contains(s2));
- }
-
- /**
- * Tests that when an attribute is removed from a working copy, it does not
- * get inherited from its template.
- *
- * @throws CoreException
- */
- public void testTemplateRemoveBehavior() throws CoreException {
- ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "test-remove");
- ILaunchConfigurationWorkingCopy t1 = newEmptyTemplate(null, "template-1");
- t1.setAttribute("COMMON", "TEMPLATE-1");
- t1.setAttribute("T1", "T1");
- t1.setAttribute("String1", "String2");
- ILaunchConfiguration template = t1.doSave();
-
- assertEquals("String1", wc.getAttribute("String1", "wrong"));
-
- wc.setTemplate(template, true);
- wc.removeAttribute("String1");
- assertEquals("TEMPLATE-1", wc.getAttribute("COMMON", (String)null));
- assertEquals("T1", wc.getAttribute("T1", (String)null));
- assertNull(wc.getAttribute("String1", (String)null));
-
- }
-
- /**
- * Tests that setting a configuration's template to null cleans its template
- * association.
- *
- * @throws CoreException
- */
- public void testUnTemplate() throws CoreException {
- ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "test-un-template");
- ILaunchConfigurationWorkingCopy t1 = newEmptyTemplate(null, "template-un");
- t1.setAttribute("COMMON", "TEMPLATE-1");
- t1.setAttribute("T1", "T1");
- t1.setAttribute("String1", "String2");
- ILaunchConfiguration template = t1.doSave();
- wc.setTemplate(template, true);
- ILaunchConfiguration configuration = wc.doSave();
- assertEquals(template, configuration.getTemplate());
- wc = configuration.getWorkingCopy();
- wc.setTemplate(null, false);
- configuration = wc.doSave();
- assertNull(configuration.getTemplate());
- ILaunchConfiguration[] children = t1.getTemplateChildren();
- assertEquals(0, children.length);
- }
-
- /**
- * Tests that nested templates are not allowed.
- *
- * @throws CoreException
- */
- public void testNestedTemplates() throws CoreException {
- ILaunchConfigurationWorkingCopy t1 = newTemplate(null, "test-nest-root");
- ILaunchConfigurationWorkingCopy t2 = newTemplate(null, "template-nested");
- ILaunchConfiguration template = t1.doSave();
- try {
- t2.setTemplate(template, true);
- } catch (CoreException e) {
- return;
- }
- assertTrue("Shoud not be able to nest templates", false);
- }
-
- /**
- * Test that you cannot set a config's template to be a non-template.
- *
- * @throws CoreException
- */
- public void testIllegalTemplate() throws CoreException {
- ILaunchConfigurationWorkingCopy c1 = newConfiguration(null, "test-config");
- ILaunchConfigurationWorkingCopy t1 = newConfiguration(null, "test-not-a-template");
- ILaunchConfiguration config = t1.doSave();
- try {
- c1.setTemplate(config, true);
- } catch (CoreException e) {
- // expected
- return;
- }
- assertTrue("Should not be able to set configration as template", false);
- }
-
- /**
- * Test that a template can be duplicated (and results in a template).
- *
- * @throws CoreException
- */
- public void testCopyTemplate() throws CoreException {
- ILaunchConfigurationWorkingCopy t1 = newEmptyTemplate(null, "template-to-duplicate");
- ILaunchConfigurationWorkingCopy t2 = t1.copy("duplicate-template");
- assertTrue(t2.isTemplate());
- }
-
- /**
- * Tests that a template that adds an attribute is not considered to override any template
- * values.
- *
- * @throws CoreException
- */
- public void testTemplateNoOverride() throws CoreException {
- ILaunchConfigurationWorkingCopy t1 = newTemplate(null, "2-b-the-same");
- ILaunchConfiguration template = t1.doSave();
- ILaunchConfigurationWorkingCopy wc = template.getType().newInstance(null, "will-b-the-same", template);
- wc.setAttribute("EXTEND-ATTRIBUTES", "EXTEND-ATTRIBUTES");
- Map dif = wc.findDifferences(template.getAttributes());
- assertTrue("Should not override any values", dif.isEmpty());
- }
-
- /**
- * Tests that a template that changes an attribute is considered to override its template
- * values.
- *
- * @throws CoreException
- */
- public void testTemplateOverride() throws CoreException {
- ILaunchConfigurationWorkingCopy t1 = newTemplate(null, "2-b-diff");
- ILaunchConfiguration template = t1.doSave();
- ILaunchConfigurationWorkingCopy wc = template.getType().newInstance(null, "will-b-diff", template);
- wc.setAttribute("String1", "String2");
- Map dif = wc.findDifferences(template.getAttributes());
- assertEquals("Should override String1 value", 1, dif.size());
- assertTrue("Should override String1 value", dif.containsKey("String1"));
- assertEquals("Should override String1 value with String2", "String2", dif.get("String1"));
- }
-
- /**
- * Test that a configuration that omits a template value shows the difference with
- * a <code>null</code> entry in the difference map.
- *
- * @throws CoreException
- */
- public void testMissingTemaplteValue() throws CoreException {
- ILaunchConfigurationWorkingCopy t1 = newTemplate(null, "2-b-missing");
- ILaunchConfiguration template = t1.doSave();
- ILaunchConfigurationWorkingCopy wc = template.getType().newInstance(null, "will-b-diff", template);
- wc.removeAttribute("String1");
- Map dif = wc.findDifferences(template.getAttributes());
- assertEquals("Should be missing String1 value", 1, dif.size());
- assertTrue("Should be missing String1 value", dif.containsKey("String1"));
- assertNull("Should be null value", dif.get("String1"));
- }
-
+
}

Back to the top