From 06da385853c6f012d96c3f198fa10a947a74195c Mon Sep 17 00:00:00 2001 From: Leo Treggiari Date: Thu, 17 Nov 2005 14:29:42 +0000 Subject: [PATCH] 1. Add project conversion test 2. Change newly added getToolBySuperClassId to getToolsBySuperClassId --- .../plugin.xml | 95 ++++++++++++++++++ .../testProjectConversion.zip | Bin 0 -> 1788 bytes .../ManagedCommandLineGeneratorTest.java | 4 +- .../core/tests/MultiVersionSupportTests.java | 50 ++++++--- .../core/tests/TestProjectConverter.java | 43 ++++++++ 5 files changed, 179 insertions(+), 13 deletions(-) create mode 100644 build/org.eclipse.cdt.managedbuilder.core.tests/resources/toolChainConversionProjects/testProjectConversion/testProjectConversion.zip create mode 100644 build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/TestProjectConverter.java diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml b/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml index a47c161d1b8..6673c37b18d 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml @@ -4388,6 +4388,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -4401,6 +4486,16 @@ toId="test.toolchain_1.2.0" mbsVersion="3.0.0"> + + + + lYIS~9R%9m ztNml&^u4L-Q-I2rAZMi;8P#U5-*sdsPUG=*{=av3K+dAfwae#LKA)TZEnBKI^kr_N z)KbHg>;FVQGqg_Q>YlJRy!)hX_d7lPWr7_+S9yI}OxXYTe%-yvG-9vXU(Q1nUTr?X z58p@EM1Rum+r#kl+NvO?pH9L(QOC>=+~Ik_vw*pJYgk5|^RIQ{2L&60YOZ@emE|iQYdGy@_qg1+JzWGdw0=Bo0{7?9% zw`IFrf$x6~D8|z1&&i-|nor z&=`K~rSIpzU$@oeZhQO5^UJ~i3QL&XIF|X}oO`pi;8N0TgJu1J_p99#o5I)5I1t^f zx3$TC`JtesH4W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HzSh>1MY$vl#Un~ z6hIUZAQju_8qv!skaCDdD_{zPm0IY!(DODzmklttBhoF=IUQmF?yLZ^fPp~(i1V0{ mEkJh|de#8xf_P^dNFOYt1bDNufuvZ0&>rZ|<-nZ8zyJXCtJ>B8 literal 0 HcmV?d00001 diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedCommandLineGeneratorTest.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedCommandLineGeneratorTest.java index c6c5d772b59..520301c8f04 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedCommandLineGeneratorTest.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedCommandLineGeneratorTest.java @@ -164,7 +164,9 @@ public class ManagedCommandLineGeneratorTest extends TestCase { IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project); IConfiguration config = info.getDefaultConfiguration(); // Set values for the options - ITool tool = config.getToolBySuperClassId("cdt.test.dollarValue.Tool"); + ITool[] tools = config.getToolsBySuperClassId("cdt.test.dollarValue.Tool"); + assertEquals(tools.length, 1); + ITool tool = tools[0]; IOption option1 = tool.getOptionBySuperClassId("cdt.test.dollarValue.option1"); IOption option2 = tool.getOptionBySuperClassId("cdt.test.dollarValue.option2"); IOption option3 = tool.getOptionBySuperClassId("cdt.test.dollarValue.option3"); diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/MultiVersionSupportTests.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/MultiVersionSupportTests.java index c261c01d206..88a34a01f7c 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/MultiVersionSupportTests.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/MultiVersionSupportTests.java @@ -80,7 +80,7 @@ public class MultiVersionSupportTests extends TestCase { suite.addTest(new MultiVersionSupportTests("testVersionsSupportedAttribute")); //$NON-NLS-1$ suite.addTest(new MultiVersionSupportTests("testToolChainConversion_CDT20")); //$NON-NLS-1$ suite.addTest(new MultiVersionSupportTests("testToolChainConversion_CDT21")); //$NON-NLS-1$ - + suite.addTest(new MultiVersionSupportTests("testProjectConversion")); //$NON-NLS-1$ //$JUnit-END$ return suite; } @@ -394,8 +394,8 @@ public class MultiVersionSupportTests extends TestCase { } public void testToolChainConversion_CDT20() throws Exception { - // Pass CDT version as '2.0', and 'true' to update Project - doTestProjectUpdate("2.0", true); //$NON-NLS-1$ + // Pass projDirName as 'test20', and 'true' to update Project + doTestProjectUpdate("test20", true); //$NON-NLS-1$ String tmpDir = System.getProperty("java.io.tmpdir"); //$NON-NLS-1$ @@ -419,8 +419,8 @@ public class MultiVersionSupportTests extends TestCase { } public void testToolChainConversion_CDT21() throws Exception { - // Pass CDT version as '2.1', and 'true' to update Project - doTestProjectUpdate("2.1", true); //$NON-NLS-1$ + // Pass projDirName as 'test21', and 'true' to update Project + doTestProjectUpdate("test21", true); //$NON-NLS-1$ String tmpDir = System.getProperty("java.io.tmpdir"); //$NON-NLS-1$ @@ -443,20 +443,46 @@ public class MultiVersionSupportTests extends TestCase { } } + public void testProjectConversion() throws Exception { + // Pass the 'projDirName' as 'testProjectConversion', and 'true' to update Project + doTestProjectUpdate("testProjectConversion", true); //$NON-NLS-1$ + + String tmpDir = System.getProperty("java.io.tmpdir"); //$NON-NLS-1$ + + File inputFile = new File(tmpDir + "/testProjectConverterOutput.txt"); //$NON-NLS-1$ + try { + assertTrue(inputFile.exists()); + + String expectedContent = "The converter for the projectType testProject_1.0.0 is invoked"; //$NON-NLS-1$ + + BufferedReader data = new BufferedReader(new FileReader(inputFile)); + String actualContent; + + if ((actualContent = data.readLine()) != null) { + assertEquals(actualContent,expectedContent); + } + + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } - - private IProject getCDT_TestProject(String cdtVersion) { + private IProject getCDT_TestProject(String projDirName) { IProject project = null; File file = null; - if (cdtVersion.equalsIgnoreCase("2.0")) { //$NON-NLS-1$ + if (projDirName.equalsIgnoreCase("test20")) { //$NON-NLS-1$ file = CTestPlugin.getFileInPlugin(new Path( "resources/toolChainConversionProjects/test20")); //$NON-NLS-1$ - } else if (cdtVersion.equals("2.1")) { //$NON-NLS-1$ + } else if (projDirName.equals("test21")) { //$NON-NLS-1$ file = CTestPlugin.getFileInPlugin(new Path( "resources/toolChainConversionProjects/test21")); //$NON-NLS-1$ - } + } else if (projDirName.equals("testProjectConversion")) { //$NON-NLS-1$ + file = CTestPlugin.getFileInPlugin(new Path( + "resources/toolChainConversionProjects/testProjectConversion")); //$NON-NLS-1$ + } if (file == null) { fail("Test project directory " + file.getName() //$NON-NLS-1$ @@ -508,7 +534,7 @@ public class MultiVersionSupportTests extends TestCase { return project; } - private void doTestProjectUpdate(String cdtVersion, boolean updateProject) { + private void doTestProjectUpdate(String projDirName, boolean updateProject) { IOverwriteQuery queryALL = new IOverwriteQuery(){ public String queryOverwrite(String file) { return ALL; @@ -520,7 +546,7 @@ public class MultiVersionSupportTests extends TestCase { UpdateManagedProjectManager.setUpdateProjectQuery(updateProject ? queryALL : queryNOALL); - final IProject project = getCDT_TestProject(cdtVersion); + final IProject project = getCDT_TestProject(projDirName); if (project == null) return; diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/TestProjectConverter.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/TestProjectConverter.java new file mode 100644 index 00000000000..1f3a06a26df --- /dev/null +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/TestProjectConverter.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2005 Intel 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: + * Intel Corporation - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.cdt.managedbuilder.core.tests; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; + +import org.eclipse.cdt.managedbuilder.core.IBuildObject; +import org.eclipse.cdt.managedbuilder.core.IConvertManagedBuildObject; + + +public class TestProjectConverter implements IConvertManagedBuildObject { + + /* (non-Javadoc) + * @see org.eclipse.cdt.managedbuilder.core.IConvertManagedBuildObject#convert(org.eclipse.cdt.managedbuilder.core.IBuildObject, java.lang.String, java.lang.String, boolean) + */ + public IBuildObject convert(IBuildObject buildObj, String fromId, + String toId, boolean isConfirmed) { + + String tmpDir = System.getProperty("java.io.tmpdir"); //$NON-NLS-1$ + + File outputFile = new File(tmpDir + "/testProjectConverterOutput.txt"); //$NON-NLS-1$ + try { + FileWriter out = new FileWriter(outputFile); + out.write("The converter for the projectType testProject_1.0.0 is invoked"); //$NON-NLS-1$ + out.close(); + } catch (IOException e) { + System.out.println("Exception raised."); //$NON-NLS-1$ + } + return buildObj; + } +} +