diff options
author | Sergey Prigogin | 2011-12-23 23:57:35 +0000 |
---|---|---|
committer | Sergey Prigogin | 2011-12-23 23:57:35 +0000 |
commit | 2ee14c041ca14ab7e2e8a382f8e4981b51c4cf63 (patch) | |
tree | c91768f79b4b4340b8522ed22d0f7ebf7d106172 /core/org.eclipse.cdt.core.tests | |
parent | 46e94156ee3e704bd585a3bd84c8f875f13ee356 (diff) | |
download | org.eclipse.cdt-2ee14c041ca14ab7e2e8a382f8e4981b51c4cf63.tar.gz org.eclipse.cdt-2ee14c041ca14ab7e2e8a382f8e4981b51c4cf63.tar.xz org.eclipse.cdt-2ee14c041ca14ab7e2e8a382f8e4981b51c4cf63.zip |
Moved template engine tests to org.eclipse.cdt.ui.tests plug-in since
they fail in headless mode due to loading of
TestExtraPagesProvider.java
Diffstat (limited to 'core/org.eclipse.cdt.core.tests')
12 files changed, 4 insertions, 809 deletions
diff --git a/core/org.eclipse.cdt.core.tests/.classpath b/core/org.eclipse.cdt.core.tests/.classpath index 71e490e81a7..30f15fb8d9e 100644 --- a/core/org.eclipse.cdt.core.tests/.classpath +++ b/core/org.eclipse.cdt.core.tests/.classpath @@ -5,7 +5,6 @@ <classpathentry kind="src" path="parser"/> <classpathentry kind="src" path="suite"/> <classpathentry kind="src" path="regression"/> - <classpathentry kind="src" path="templateengine"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="output" path="bin"/> diff --git a/core/org.eclipse.cdt.core.tests/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.core.tests/META-INF/MANIFEST.MF index 24768732e86..34e30a14a40 100644 --- a/core/org.eclipse.cdt.core.tests/META-INF/MANIFEST.MF +++ b/core/org.eclipse.cdt.core.tests/META-INF/MANIFEST.MF @@ -31,7 +31,6 @@ Export-Package: org.eclipse.cdt.core.cdescriptor.tests, org.eclipse.cdt.core.testplugin, org.eclipse.cdt.core.testplugin.util, org.eclipse.cdt.core.tests, - org.eclipse.cdt.core.tests.templateengine, org.eclipse.cdt.core.winreg.tests, org.eclipse.cdt.internal.index.tests;x-internal:=true, org.eclipse.cdt.internal.pdom.tests;x-internal:=true, diff --git a/core/org.eclipse.cdt.core.tests/build.properties b/core/org.eclipse.cdt.core.tests/build.properties index 016d8b57403..4f12cd40852 100644 --- a/core/org.eclipse.cdt.core.tests/build.properties +++ b/core/org.eclipse.cdt.core.tests/build.properties @@ -25,8 +25,7 @@ source.. = model/,\ parser/,\ suite/,\ misc/,\ - regression/,\ - templateengine/ + regression/ jre.compilation.profile=JavaSE-1.6 javacSource=1.6 diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java index 80f2946e55e..c40a37e2dc0 100644 --- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java +++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java @@ -6,9 +6,9 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM Corporation - initial API and implementation - * Markus Schorn (Wind River Systems) - * Norbert Ploett (Siemens AG) + * IBM Corporation - initial API and implementation + * Markus Schorn (Wind River Systems) + * Norbert Ploett (Siemens AG) *******************************************************************************/ package org.eclipse.cdt.core.suite; @@ -30,7 +30,6 @@ import org.eclipse.cdt.core.model.tests.WorkingCopyTests; import org.eclipse.cdt.core.parser.tests.ParserTestSuite; import org.eclipse.cdt.core.parser.tests.rewrite.RewriteTests; import org.eclipse.cdt.core.resources.tests.RefreshScopeTests; -import org.eclipse.cdt.core.tests.templateengine.AllTemplateEngineTests; import org.eclipse.cdt.internal.index.tests.IndexTests; import org.eclipse.cdt.internal.pdom.tests.PDOMTests; import org.eclipse.cdt.utils.CdtVariableResolverTest; @@ -82,12 +81,9 @@ public class AutomatedIntegrationSuite extends TestSuite { // Add in PDOM tests suite.addTest(PDOMTests.suite()); suite.addTest(IndexTests.suite()); - - suite.addTest(AllTemplateEngineTests.suite()); suite.addTest(RefreshScopeTests.suite()); return suite; } - } diff --git a/core/org.eclipse.cdt.core.tests/templateengine/org/eclipse/cdt/core/tests/templateengine/AllTemplateEngineTests.java b/core/org.eclipse.cdt.core.tests/templateengine/org/eclipse/cdt/core/tests/templateengine/AllTemplateEngineTests.java deleted file mode 100644 index 13b8cd7c4b6..00000000000 --- a/core/org.eclipse.cdt.core.tests/templateengine/org/eclipse/cdt/core/tests/templateengine/AllTemplateEngineTests.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Symbian Software Limited 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: - * Bala Torati (Symbian) - Initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.core.tests.templateengine; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * This is a TestSuite, the TestCases created to test Template engine are - * added to testsuite. - * The test suite will execute all the Testcases added to the Suite. - * - * @since 4.0 - */ - -public class AllTemplateEngineTests extends TestSuite { - - public static void main(String[] args) { - junit.textui.TestRunner.run(AllTemplateEngineTests.suite()); - } - - /** - * Since the TemplateEngine consists of UI(Wizard). - * A TestWizard is created to which the dynamically generated - * UIPages are added. The Wizard is launched from here. - * The TestCases created to test the TemplateEngine is initialised here. - * @return - * - * @since 4.0 - */ - public static Test suite() { - TestSuite suite = new TestSuite("Template engine tests"); //$NON-NLS-1$ - //$JUnit-BEGIN$ - - suite.addTestSuite(TestTemplateEngine.class); - suite.addTestSuite(TestTemplateCore.class); - suite.addTestSuite(TestValueStore.class); - suite.addTestSuite(TestSharedDefaults.class); - suite.addTestSuite(TestProcesses.class); - suite.addTestSuite(TestTemplateEngineBugs.class); - - //$JUnit-END$ - return suite; - } -} diff --git a/core/org.eclipse.cdt.core.tests/templateengine/org/eclipse/cdt/core/tests/templateengine/TemplateEngineTestsHelper.java b/core/org.eclipse.cdt.core.tests/templateengine/org/eclipse/cdt/core/tests/templateengine/TemplateEngineTestsHelper.java deleted file mode 100644 index 41fd7ca8ed9..00000000000 --- a/core/org.eclipse.cdt.core.tests/templateengine/org/eclipse/cdt/core/tests/templateengine/TemplateEngineTestsHelper.java +++ /dev/null @@ -1,116 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Symbian Software Limited 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: - * Bala Torati (Symbian) - Initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.core.tests.templateengine; - -import java.io.IOException; -import java.net.URL; -import java.util.ArrayList; -import java.util.List; - -import junit.framework.Assert; - -import org.eclipse.cdt.core.templateengine.TemplateCore; -import org.eclipse.cdt.core.templateengine.TemplateDescriptor; -import org.eclipse.cdt.core.templateengine.TemplateEngine; -import org.eclipse.cdt.core.testplugin.CTestPlugin; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.IWorkspaceDescription; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Platform; -import org.osgi.framework.Bundle; -import org.w3c.dom.Element; -import org.w3c.dom.NamedNodeMap; - -/** - * - * All supporting functions which are not part of Testing class. - * - * @since 4.0 -*/ - -public class TemplateEngineTestsHelper { - - public static final String LOGGER_FILE_NAME="TemplateEngineTests"; //$NON-NLS-1$ - - /** - * get the url of a xml template, by passing the xml file name. - * @param templateName - * @return URL - */ - public static URL getTemplateURL(String templateName){ - Bundle bundle = Platform.getBundle(CTestPlugin.PLUGIN_ID); - URL url = FileLocator.find(bundle, new Path("resources/templateengine/"+templateName), null); //$NON-NLS-1$ - if ( url != null ) - { - try { - url = FileLocator.toFileURL(url); - } catch (IOException e) { - e.printStackTrace(); - } - } - return url; - } - - public static TemplateCore[] getTestTemplates() { - TemplateCore[] templates = TemplateEngine.getDefault().getTemplates(); - List testTemplates = new ArrayList(); - for (int i =0; i < templates.length; i++) { - if (templates[i].getTemplateType().equals("TestTemplate")) { - testTemplates.add(templates[i]); - } - } - return (TemplateCore[]) testTemplates.toArray(new TemplateCore[testTemplates.size()]); - } - - public static int getChildCount(TemplateDescriptor templateDescriptor, String propertyGroupID){ - List list = templateDescriptor.getPropertyGroupList(); - for (int i = 0, l = list.size(); i < l; i++) { - Element element = (Element) list.get(i); - NamedNodeMap attributes = element.getAttributes(); - for (int j = 0, l1 = attributes.getLength(); j < l1; j++) { - String value = attributes.item(j).getNodeValue(); - if (value.equals(propertyGroupID)) { - return TemplateEngine.getChildrenOfElement(element).size(); - } - } - } - return 0; - } - - public static boolean failIfErrorStatus(IStatus[] statuses) { - for(int i=0; i<statuses.length; i++) { - IStatus status = statuses[i]; - if (status.getCode() == IStatus.ERROR) { - Assert.fail(status.getMessage()); - return true; - } - IStatus[] children = status.getChildren(); - if (children != null) { - if (failIfErrorStatus(children)) { - return true; - } - } - } - return false; - } - - public static void turnOffAutoBuild() throws CoreException { - IWorkspace workspace = ResourcesPlugin.getWorkspace(); - IWorkspaceDescription workspaceDesc = workspace.getDescription(); - workspaceDesc.setAutoBuilding(false); - workspace.setDescription(workspaceDesc); - } - -} diff --git a/core/org.eclipse.cdt.core.tests/templateengine/org/eclipse/cdt/core/tests/templateengine/TestProcesses.java b/core/org.eclipse.cdt.core.tests/templateengine/org/eclipse/cdt/core/tests/templateengine/TestProcesses.java deleted file mode 100644 index 2bb9af58ad6..00000000000 --- a/core/org.eclipse.cdt.core.tests/templateengine/org/eclipse/cdt/core/tests/templateengine/TestProcesses.java +++ /dev/null @@ -1,260 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Symbian Software Limited 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: - * Bala Torati (Symbian) - Initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.core.tests.templateengine; - -import java.io.File; -import java.util.Map; - -import org.eclipse.cdt.core.CCorePlugin; -import org.eclipse.cdt.core.templateengine.TemplateCore; -import org.eclipse.cdt.core.templateengine.TemplateEngine; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IProjectDescription; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Platform; - -public class TestProcesses extends BaseTestCase { - - private static final String workspaceLocation = ResourcesPlugin.getWorkspace().getRoot().getRawLocation().toOSString(); - private static final String PROJECT_NAME = "TemplateEngineTestsProject"; //$NON-NLS-1$ - private static final String SOURCE_FOLDER = "Source"; //$NON-NLS-1$ - private static final String FILE_NAME = "File"; //$NON-NLS-1$ - private static final String LINK = "Link"; //$NON-NLS-1$ - private static final String CPP_EXT = ".cpp"; //$NON-NLS-1$ - private static final String H_EXT = ".h"; //$NON-NLS-1$ - - private static final String PROJECT_TYPE = "org.eclipse.cdt.core.tests.projectType"; //$NON-NLS-1$ - - protected void setUp() throws Exception { - TemplateEngineTestsHelper.turnOffAutoBuild(); - IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME); - IPath projectLocation = project.getRawLocation(); - - if (project.exists()) { - project.delete(true, true, null); - } - IWorkspace workspace = ResourcesPlugin.getWorkspace(); - IProjectDescription description = workspace.newProjectDescription(project.getName()); - - if ((projectLocation != null) && (!projectLocation.equals(Platform.getLocation()))) { - description.setLocation(projectLocation); - } - - CCorePlugin.getDefault().createCDTProject(description, project, null); - if (!project.isOpen()) { - project.open(null); - } - - } - - public void testAddFile() { - TemplateCore template = TemplateEngine.getDefault().getFirstTemplate(PROJECT_TYPE, null, ".*AddFile"); //$NON-NLS-1$ - Map valueStore = template.getValueStore(); - valueStore.put("projectName", PROJECT_NAME); //$NON-NLS-1$ - valueStore.put("projectType", PROJECT_TYPE); //$NON-NLS-1$ - valueStore.put("location", ""); //$NON-NLS-1$ //$NON-NLS-2$ - valueStore.put("isCProject", "false"); //$NON-NLS-1$ //$NON-NLS-2$ - valueStore.put("baseName", FILE_NAME); //$NON-NLS-1$ - - if (TemplateEngineTestsHelper.failIfErrorStatus(template.executeTemplateProcesses(null, false))) { - return; - } - - IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME); - assertTrue(project.exists()); - IFile file = project.getFile(FILE_NAME + CPP_EXT); - assertTrue(file.exists()); - file = project.getFile(FILE_NAME + H_EXT); - assertTrue(file.exists()); - } - - public void testAddFiles() { - TemplateCore template = TemplateEngine.getDefault().getFirstTemplate(PROJECT_TYPE, null, ".*AddFiles"); //$NON-NLS-1$ - Map valueStore = template.getValueStore(); - valueStore.put("projectName", PROJECT_NAME); //$NON-NLS-1$ - valueStore.put("projectType", PROJECT_TYPE); //$NON-NLS-1$ - valueStore.put("location", ""); //$NON-NLS-1$ //$NON-NLS-2$ - valueStore.put("isCProject", "false"); //$NON-NLS-1$ //$NON-NLS-2$ - valueStore.put("baseName", FILE_NAME); //$NON-NLS-1$ - - if (TemplateEngineTestsHelper.failIfErrorStatus(template.executeTemplateProcesses(null, false))) { - return; - } - - IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME); - assertTrue(project.exists()); - IFile file = project.getFile(FILE_NAME + CPP_EXT); - assertTrue(file.exists()); - file = project.getFile(FILE_NAME + H_EXT); - assertTrue(file.exists()); - } - - public void testAddLink() { - TemplateCore template = TemplateEngine.getDefault().getFirstTemplate(PROJECT_TYPE, null, ".*AddLink"); //$NON-NLS-1$ - Map valueStore = template.getValueStore(); - valueStore.put("projectName", PROJECT_NAME); //$NON-NLS-1$ - valueStore.put("projectType", PROJECT_TYPE); //$NON-NLS-1$ - valueStore.put("location", ""); //$NON-NLS-1$ //$NON-NLS-2$ - valueStore.put("isCProject", "false"); //$NON-NLS-1$ //$NON-NLS-2$ - valueStore.put("baseName", FILE_NAME); //$NON-NLS-1$ - - if (TemplateEngineTestsHelper.failIfErrorStatus(template.executeTemplateProcesses(null, false))) { - return; - } - - try { - IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME); - assertTrue(project.exists()); - project.refreshLocal(1, null); - IFile file = project.getFile(FILE_NAME + CPP_EXT); - assertTrue(file.exists()); - file = project.getFile(FILE_NAME + LINK + CPP_EXT); - assertTrue(file.exists()); - } catch (CoreException e) { - fail(e.getMessage()); - } - } - - public void testAppend() { - TemplateCore template = TemplateEngine.getDefault().getFirstTemplate(PROJECT_TYPE, null, ".*Append"); //$NON-NLS-1$ - Map valueStore = template.getValueStore(); - valueStore.put("projectName", PROJECT_NAME); //$NON-NLS-1$ - valueStore.put("projectType", PROJECT_TYPE); //$NON-NLS-1$ - valueStore.put("location", ""); //$NON-NLS-1$ //$NON-NLS-2$ - valueStore.put("isCProject", "false"); //$NON-NLS-1$ //$NON-NLS-2$ - valueStore.put("baseName", FILE_NAME); //$NON-NLS-1$ - - valueStore.put("targetSourceName", workspaceLocation + File.separator + PROJECT_NAME + File.separator + FILE_NAME + CPP_EXT); //$NON-NLS-1$ - valueStore.put("targetHeaderName", workspaceLocation + File.separator + PROJECT_NAME + File.separator + FILE_NAME + H_EXT); //$NON-NLS-1$ - - if (TemplateEngineTestsHelper.failIfErrorStatus(template.executeTemplateProcesses(null, false))) { - return; - } - - try { - IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME); - assertTrue(project.exists()); - project.refreshLocal(1, null); - IFile file = project.getFile(FILE_NAME + CPP_EXT); - assertTrue(file.exists()); - file = project.getFile(FILE_NAME + H_EXT); - assertTrue(file.exists()); - } catch (CoreException e) { - fail(e.getMessage()); - } - } - - public void testAppendCreate() { - TemplateCore template = TemplateEngine.getDefault().getFirstTemplate(PROJECT_TYPE, null, ".*AppendCreate"); //$NON-NLS-1$ - Map valueStore = template.getValueStore(); - valueStore.put("projectName", PROJECT_NAME); //$NON-NLS-1$ - valueStore.put("projectType", PROJECT_TYPE); //$NON-NLS-1$ - valueStore.put("location", ""); //$NON-NLS-1$ //$NON-NLS-2$ - valueStore.put("isCProject", "false"); //$NON-NLS-1$ //$NON-NLS-2$ - valueStore.put("baseName", FILE_NAME); //$NON-NLS-1$ - - valueStore.put("targetSourceName", FILE_NAME + CPP_EXT); //$NON-NLS-1$ - valueStore.put("targetHeaderName", FILE_NAME + H_EXT); //$NON-NLS-1$ - - if (TemplateEngineTestsHelper.failIfErrorStatus(template.executeTemplateProcesses(null, false))) { - return; - } - - IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME); - assertTrue(project.exists()); - IFile file = project.getFile(FILE_NAME + CPP_EXT); - assertTrue(file.exists()); - file = project.getFile(FILE_NAME + H_EXT); - assertTrue(file.exists()); - } - - public void testCopy() { - TemplateCore template = TemplateEngine.getDefault().getFirstTemplate(PROJECT_TYPE, null, ".*Copy"); //$NON-NLS-1$ - Map valueStore = template.getValueStore(); - valueStore.put("projectName", PROJECT_NAME); //$NON-NLS-1$ - valueStore.put("projectType", PROJECT_TYPE); //$NON-NLS-1$ - valueStore.put("location", ""); //$NON-NLS-1$ //$NON-NLS-2$ - valueStore.put("isCProject", "false"); //$NON-NLS-1$ //$NON-NLS-2$ - valueStore.put("baseName", FILE_NAME); //$NON-NLS-1$ - - valueStore.put("targetSourceName", workspaceLocation + File.separator + PROJECT_NAME + File.separator + FILE_NAME + CPP_EXT); //$NON-NLS-1$ - valueStore.put("targetHeaderName", workspaceLocation + File.separator + PROJECT_NAME + File.separator + FILE_NAME + H_EXT); //$NON-NLS-1$ - - if (TemplateEngineTestsHelper.failIfErrorStatus(template.executeTemplateProcesses(null, false))) { - return; - } - - try { - IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME); - assertTrue(project.exists()); - project.refreshLocal(1, null); - IFile file = project.getFile(FILE_NAME + CPP_EXT); - assertTrue(file.exists()); - file = project.getFile(FILE_NAME + H_EXT); - assertTrue(file.exists()); - } catch (CoreException e) { - fail(e.getMessage()); - } - } - - public void testCreateResourceIdentifier() { - TemplateCore template = TemplateEngine.getDefault().getFirstTemplate(PROJECT_TYPE, null, ".*CreateResourceIdentifier"); //$NON-NLS-1$ - Map valueStore = template.getValueStore(); - valueStore.put("projectName", PROJECT_NAME); //$NON-NLS-1$ - valueStore.put("projectType", PROJECT_TYPE); //$NON-NLS-1$ - valueStore.put("location", ""); //$NON-NLS-1$ //$NON-NLS-2$ - valueStore.put("isCProject", "false"); //$NON-NLS-1$ //$NON-NLS-2$ - valueStore.put("valueName1", "baseName1"); //$NON-NLS-1$ //$NON-NLS-2$ - valueStore.put("appName1", "Hello"); //$NON-NLS-1$ //$NON-NLS-2$ - valueStore.put("valueName2", "baseName2"); //$NON-NLS-1$ //$NON-NLS-2$ - valueStore.put("appName2", "He"); //$NON-NLS-1$ //$NON-NLS-2$ - - if (TemplateEngineTestsHelper.failIfErrorStatus(template.executeTemplateProcesses(null, false))) { - return; - } - - IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME); - assertTrue(project.exists()); - IFile file = project.getFile("HELL" + CPP_EXT); //$NON-NLS-1$ - assertTrue(file.exists()); - file = project.getFile("HEXX" + CPP_EXT); //$NON-NLS-1$ - assertTrue(file.exists()); - } - - public void testCreateSourceFolder() { - TemplateCore template = TemplateEngine.getDefault().getFirstTemplate(PROJECT_TYPE, null, ".*CreateSourceFolder"); //$NON-NLS-1$ - Map valueStore = template.getValueStore(); - valueStore.put("projectName", PROJECT_NAME); //$NON-NLS-1$ - valueStore.put("projectType", PROJECT_TYPE); //$NON-NLS-1$ - valueStore.put("location", ""); //$NON-NLS-1$ //$NON-NLS-2$ - valueStore.put("isCProject", "false"); //$NON-NLS-1$ //$NON-NLS-2$ - valueStore.put("sourceDir1", SOURCE_FOLDER + 1); //$NON-NLS-1$ - valueStore.put("sourceDir2", SOURCE_FOLDER + 2); //$NON-NLS-1$ - - if (TemplateEngineTestsHelper.failIfErrorStatus(template.executeTemplateProcesses(null, false))) { - return; - } - - IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME); - assertTrue(project.exists()); - IFolder folder = project.getFolder(SOURCE_FOLDER + 1); - assertTrue(folder.exists()); - folder = project.getFolder(SOURCE_FOLDER + 2); - assertTrue(folder.exists()); - } - -} diff --git a/core/org.eclipse.cdt.core.tests/templateengine/org/eclipse/cdt/core/tests/templateengine/TestSharedDefaults.java b/core/org.eclipse.cdt.core.tests/templateengine/org/eclipse/cdt/core/tests/templateengine/TestSharedDefaults.java deleted file mode 100644 index f38821233dd..00000000000 --- a/core/org.eclipse.cdt.core.tests/templateengine/org/eclipse/cdt/core/tests/templateengine/TestSharedDefaults.java +++ /dev/null @@ -1,123 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Symbian Software Limited 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: - * Bala Torati (Symbian) - Initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.core.tests.templateengine; - - -import java.util.Iterator; -import java.util.Map; -import java.util.Set; - -import org.eclipse.cdt.core.templateengine.SharedDefaults; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; - - -/** -* Executes all the test cases of SharedDefaults backend functionality -*/ - -public class TestSharedDefaults extends BaseTestCase { - private SharedDefaults sharedDefaults; - - /* - * @see TestCase#setUp() - */ - protected void setUp() throws Exception { - sharedDefaults = SharedDefaults.getInstance(); - } - - /* - * @see TestCase#tearDown() - */ - - protected void tearDown(){ - sharedDefaults = null; - } - - /** - * This test checks if data gets added to the back end - * New data gets persisted in SharedDefault XML file - */ - - public void testAddToBackEndStorage() { - Map actualSharedDefaults=sharedDefaults.getSharedDefaultsMap(); - - actualSharedDefaults.put("provider.name","eclipse"); //$NON-NLS-1$ //$NON-NLS-2$ - actualSharedDefaults.put("copyright","Symbian Software Ltd."); //$NON-NLS-1$ //$NON-NLS-2$ - actualSharedDefaults.put("author","Bala Torati"); //$NON-NLS-1$ //$NON-NLS-2$ - - Map expectedSharedDefaults=sharedDefaults.getSharedDefaultsMap(); - - assertEquals("Contents are different :", //$NON-NLS-1$ - expectedSharedDefaults, - actualSharedDefaults); - - } - - - /** - * This tests the updateToBackEndStorage of SharedDefaults - * to verify whether the key-value pair gets updated with new value - * New data gets persisted in SharedDefault XML file - */ - - public void testUpdateToBackEndStorage() { - Map actualSharedDefaults = sharedDefaults.getSharedDefaultsMap(); - Set keySet = actualSharedDefaults.keySet(); - Iterator iterator = keySet.iterator(); - - while (iterator.hasNext()) { - Object key = iterator.next(); - Object value = actualSharedDefaults.get(key); - String keyName = (String)key; - String valueName = (String)value; - if (keyName.equals("org.eclipse.cdt.templateengine.project.HelloWorld.basename")){ //$NON-NLS-1$ - valueName = "Astala Vista"; //$NON-NLS-1$ - actualSharedDefaults.put(keyName, valueName); - sharedDefaults.updateToBackEndStorage("org.eclipse.cdt.templateengine.project.HelloWorld.basename", valueName); //$NON-NLS-1$ - } - } - - Map expectedSharedDefaults=sharedDefaults.getSharedDefaultsMap(); - - assertEquals("Contents are different :", //$NON-NLS-1$ - expectedSharedDefaults, - actualSharedDefaults); - } - - /** - * This tests the deleteBackEndStorage of SharedDefaults - * to verify whether the key-value pair gets deleted at the backend - */ - - public void testDeleteBackEndStorage() { - Map actualSharedDefaults=sharedDefaults.getSharedDefaultsMap(); - Set keySet = actualSharedDefaults.keySet(); - Iterator iterator = keySet.iterator(); - String keyName = null; - - while (iterator.hasNext()) { - - Object key = iterator.next(); - keyName = (String)key; - if (keyName.equals("org.eclipse.cdt.templateengine.project.HelloWorld.basename")) { //$NON-NLS-1$ - actualSharedDefaults.remove(keyName); - break; - } - } - - sharedDefaults.deleteBackEndStorage(new String[]{keyName}); - Map expectedSharedDefaults=sharedDefaults.getSharedDefaultsMap(); - - assertEquals("Contents are different :", //$NON-NLS-1$ - expectedSharedDefaults, - actualSharedDefaults); - } -} diff --git a/core/org.eclipse.cdt.core.tests/templateengine/org/eclipse/cdt/core/tests/templateengine/TestTemplateCore.java b/core/org.eclipse.cdt.core.tests/templateengine/org/eclipse/cdt/core/tests/templateengine/TestTemplateCore.java deleted file mode 100644 index 6073e8aa739..00000000000 --- a/core/org.eclipse.cdt.core.tests/templateengine/org/eclipse/cdt/core/tests/templateengine/TestTemplateCore.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Symbian Software Limited 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: - * Bala Torati (Symbian) - Initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.core.tests.templateengine; - -import org.eclipse.cdt.core.templateengine.TemplateCore; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; - -/** - * Test the functionality of Tempalte Class. - */ -public class TestTemplateCore extends BaseTestCase { - - public TemplateCore[] templates = null; - - protected void setUp() throws Exception { - super.setUp(); - templates = TemplateEngineTestsHelper.getTestTemplates(); - } - - /* - * @see TestCase#tearDown() - */ - protected void tearDown() throws Exception { - super.tearDown(); - } - - /** - * Constructor for Template. - * @param name - */ - public TestTemplateCore(String name) { - super(name); - } - - /** - * check that the Template contains a Non Null ValueStore - */ - public void testValueStoreNotNull(){ - for (int i=0; i < templates.length; i++) { - assertNotNull(templates[i].getValueStore()); - } - } - - /** - * Check the IDs to be persisited in SharedDefaults. - */ - public void testPersistTrueIDs(){ - for (int i=0; i < templates.length; i++) { - assertNotNull(templates[i].getPersistTrueIDs()); - } - } - - public void testGetAllMissingMacrosInProcesses(){ - for (int i=0; i < templates.length; i++) { - assertNotNull(templates[i].getAllMissingMacrosInProcesses()); - assertTrue(templates[i].getAllMissingMacrosInProcesses().size() > 0); - } - } - -} diff --git a/core/org.eclipse.cdt.core.tests/templateengine/org/eclipse/cdt/core/tests/templateengine/TestTemplateEngine.java b/core/org.eclipse.cdt.core.tests/templateengine/org/eclipse/cdt/core/tests/templateengine/TestTemplateEngine.java deleted file mode 100644 index 9c313c66565..00000000000 --- a/core/org.eclipse.cdt.core.tests/templateengine/org/eclipse/cdt/core/tests/templateengine/TestTemplateEngine.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2011 Symbian Software Limited 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: - * Bala Torati (Symbian) - Initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.core.tests.templateengine; - -import org.eclipse.cdt.core.templateengine.TemplateEngine; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; - -/** - * Test the functionality of TemplateEngine. - */ -public class TestTemplateEngine extends BaseTestCase { - - - TemplateEngine templateEngine = null; - - /* - * @see TestCase#setUp() - */ - protected void setUp() throws Exception { - super.setUp(); - - templateEngine = TemplateEngine.getDefault(); - } - - /* - * @see TestCase#tearDown() - */ - protected void tearDown() throws Exception { - super.tearDown(); - } - - /** - * Constructor for TestTemplateEngine. - * @param name - */ - public TestTemplateEngine(String name) { - super(name); - } - - /** - * check for non null SharedDefaults - * - */ - public void testSharedDefaults() { - assertNotNull(TemplateEngine.getSharedDefaults()); - } - - /** - * check that the instance is created once(Singleton). - */ - public void testSingleton() { - assertSame(templateEngine, TemplateEngine.getDefault()); - } - -} diff --git a/core/org.eclipse.cdt.core.tests/templateengine/org/eclipse/cdt/core/tests/templateengine/TestTemplateEngineBugs.java b/core/org.eclipse.cdt.core.tests/templateengine/org/eclipse/cdt/core/tests/templateengine/TestTemplateEngineBugs.java deleted file mode 100644 index a11dfebed19..00000000000 --- a/core/org.eclipse.cdt.core.tests/templateengine/org/eclipse/cdt/core/tests/templateengine/TestTemplateEngineBugs.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 Symbian Software Limited 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: - * Andrew Ferguson (Symbian) - Initial Implementation - *******************************************************************************/ -package org.eclipse.cdt.core.tests.templateengine; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; - -import org.eclipse.cdt.core.templateengine.process.ProcessHelper; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; - -public class TestTemplateEngineBugs extends BaseTestCase { - - public void testBug215283() { - assertEquals(set("a"), ProcessHelper.getReplaceKeys("$(a)")); - assertEquals(set("a","b"), ProcessHelper.getReplaceKeys("$(a)$(b)")); - assertEquals(set("a","b","cc","ddd"), ProcessHelper.getReplaceKeys("$(a)$(b)$(cc)$(ddd)")); - assertEquals(set("aaa","b","c","dd"), ProcessHelper.getReplaceKeys("$(aaa)$(b)$(c)$(dd)")); - assertEquals(set("a"), ProcessHelper.getReplaceKeys("($(a))")); - assertEquals(set("a","b"), ProcessHelper.getReplaceKeys("$(b)$(a)")); - assertEquals(set("a"), ProcessHelper.getReplaceKeys(" \n$(a)")); - assertEquals(set("a"), ProcessHelper.getReplaceKeys("$(a) ")); - } - - private Set<String> set(String ... s) { - HashSet<String> result= new HashSet<String>(); - result.addAll(Arrays.asList(s)); - return result; - } -} diff --git a/core/org.eclipse.cdt.core.tests/templateengine/org/eclipse/cdt/core/tests/templateengine/TestValueStore.java b/core/org.eclipse.cdt.core.tests/templateengine/org/eclipse/cdt/core/tests/templateengine/TestValueStore.java deleted file mode 100644 index 42f0e45c710..00000000000 --- a/core/org.eclipse.cdt.core.tests/templateengine/org/eclipse/cdt/core/tests/templateengine/TestValueStore.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Symbian Software Limited 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: - * Bala Torati (Symbian) - Initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.core.tests.templateengine; - -import java.util.Iterator; -import java.util.Map; - -import org.eclipse.cdt.core.templateengine.TemplateCore; -import org.eclipse.cdt.core.templateengine.TemplateDescriptor; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; - - -/** - * Test the functionality of the ValueStore class. - */ -public class TestValueStore extends BaseTestCase { - - - /** - * setUp is called before execution of test method. - */ - protected void setUp() throws Exception { - super.setUp(); - } - - /** - * release resources held. - */ - protected void tearDown() throws Exception { - super.tearDown(); - } - - public TestValueStore(String name) { - super(name); - } - - /** - * Test ValueStore for Not Null condition. - * - */ - public void testValueStoreNotNull(){ - TemplateCore[] templates = TemplateEngineTestsHelper.getTestTemplates(); - for (int i=0; i <templates.length; i++) { - Map valueStore = templates[i].getValueStore(); - assertNotNull(valueStore); - } - } - - /** - * ValueStore is expected to consist all the IDs from - * FactoryDefaults. Test the same. - */ - public void testCompareValueStoreWithTemplateDefaluts(){ - TemplateCore[] templates = TemplateEngineTestsHelper.getTestTemplates(); - for (int i=0; i <templates.length; i++) { - Map valueStore = templates[i].getValueStore(); - TemplateDescriptor templateDescriptor = templates[i].getTemplateDescriptor(); - Map templateDefaults = templateDescriptor.getTemplateDefaults(templateDescriptor.getRootElement()); - - Iterator defaultsIterator = templateDefaults.keySet().iterator(); - while(defaultsIterator.hasNext()){ - String key = (String)defaultsIterator.next(); - assertNotNull(valueStore.get(key)); - } - } - } - - -} |