diff options
Diffstat (limited to 'build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ResourceBuildCoreTests.java')
-rw-r--r-- | build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ResourceBuildCoreTests.java | 360 |
1 files changed, 195 insertions, 165 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ResourceBuildCoreTests.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ResourceBuildCoreTests.java index dd111a996dc..5adb0f5c1ed 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ResourceBuildCoreTests.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ResourceBuildCoreTests.java @@ -50,14 +50,12 @@ import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; - public class ResourceBuildCoreTests extends TestCase { private static final boolean boolVal = true; private static IProjectType exeType; private static IProjectType libType; private static IProjectType dllType; - private static final String projectName = "T1"; private static final String renamedProjectName1 = "T1_1"; private static final String renamedProjectName2 = "T1_2"; @@ -70,8 +68,8 @@ public class ResourceBuildCoreTests extends TestCase { TestSuite suite = new TestSuite(ResourceBuildCoreTests.class.getName()); suite.addTest(new ResourceBuildCoreTests("testResourceConfigurations")); suite.addTest(new ResourceBuildCoreTests("testResourceConfigurationReset")); -// suite.addTest(new ResourceBuildCoreTests("testResourceConfigurationBuildInfo")); -// suite.addTest(new ResourceBuildCoreTests("testResourceRename")); + // suite.addTest(new ResourceBuildCoreTests("testResourceConfigurationBuildInfo")); + // suite.addTest(new ResourceBuildCoreTests("testResourceRename")); return suite; } @@ -121,14 +119,20 @@ public class ResourceBuildCoreTests extends TestCase { ManagedBuildManager.setNewProjectVersion(project); // Create a couple of resources ( 'main.c' & 'bar.c') - IFile mainFile = project.getProject().getFile( "main.c" ); - if( !mainFile.exists() ){ - mainFile.create( new ByteArrayInputStream( "#include <stdio.h>\n extern void bar(); \n int main() { \nprintf(\"Hello, World!!\"); \n bar();\n return 0; }".getBytes() ), false, null ); + IFile mainFile = project.getProject().getFile("main.c"); + if (!mainFile.exists()) { + mainFile.create(new ByteArrayInputStream( + "#include <stdio.h>\n extern void bar(); \n int main() { \nprintf(\"Hello, World!!\"); \n bar();\n return 0; }" + .getBytes()), + false, null); } - IFile barFile = project.getProject().getFile( "bar.c" ); - if( !barFile.exists() ){ - barFile.create( new ByteArrayInputStream( "#include <stdio.h>\n void bar() { \nprintf(\"Hello, bar()!!\");\n return; }".getBytes() ), false, null ); + IFile barFile = project.getProject().getFile("bar.c"); + if (!barFile.exists()) { + barFile.create( + new ByteArrayInputStream( + "#include <stdio.h>\n void bar() { \nprintf(\"Hello, bar()!!\");\n return; }".getBytes()), + false, null); } // Get the configurations and make one of them as default configuration. @@ -150,17 +154,17 @@ public class ResourceBuildCoreTests extends TestCase { // Check whether defaultConfig has two resource configurations or not. IResourceConfiguration resConfigs[] = defaultConfig.getResourceConfigurations(); - assertEquals(2,resConfigs.length); + assertEquals(2, resConfigs.length); // Get the tools associated with the resource 'main.c'. ITool resMainTools[] = resMainConfig.getTools(); assertNotNull(resMainTools); - assertEquals(1,resMainTools.length); + assertEquals(1, resMainTools.length); // Get the tools associated with the resource 'bar.c'. ITool resBarTools[] = resBarConfig.getTools(); assertNotNull(resBarTools); - assertEquals(1,resBarTools.length); + assertEquals(1, resBarTools.length); // Get the build properties for the resource main.c ITool resMainTool = resMainTools[0]; @@ -179,19 +183,19 @@ public class ResourceBuildCoreTests extends TestCase { Tool projTool = null; String projBuildProps = ""; //$NON-NLS-1$ for (int i = 0; i < tools.length; i++) { - if( tools[i].buildsFileType(extString) ) { + if (tools[i].buildsFileType(extString)) { // Get the build properties of a project in default configuration - projTool = (Tool)tools[i]; + projTool = (Tool) tools[i]; projBuildProps = projTool.getToolFlags(); break; } } // Initially, Project build properties and resource build properties are same. - assertEquals(resMainBuildProps,projBuildProps); + assertEquals(resMainBuildProps, projBuildProps); // Initially, build properties of files with same extension ( example , .c files) are equal. - assertEquals(resMainBuildProps,resBarBuildProps); + assertEquals(resMainBuildProps, resBarBuildProps); // Now modify project build properties and it should reflect in resource build properties also. @@ -201,30 +205,31 @@ public class ResourceBuildCoreTests extends TestCase { // Override options in the default configuration. // Set the debug option value to '-g2' at Project level - IOption newProjDebugOption = ManagedBuildManager.setOption(defaultConfig,projTool,projDebugOption,"testgnu.c.debugging.level.default"); + IOption newProjDebugOption = ManagedBuildManager.setOption(defaultConfig, projTool, projDebugOption, + "testgnu.c.debugging.level.default"); // Get the option 'id' and 'value'. String newProjDebugOptionId = newProjDebugOption.getId(); - String newProjDebugOptionValue = newProjDebugOption.getStringValue(); + String newProjDebugOptionValue = newProjDebugOption.getStringValue(); // Assert old & new(overridden) debug option values of project are different. - assertNotSame(projDebugOption.getStringValue(),newProjDebugOptionValue); + assertNotSame(projDebugOption.getStringValue(), newProjDebugOptionValue); // Check whether the overridden option at project level is reflecting at resource level or not. IOption resMainDebugOption = null; IOption resMainOptions[] = resMainTool.getOptions(); - for(int i=0; i< resMainOptions.length; i++){ + for (int i = 0; i < resMainOptions.length; i++) { IOption opt = resMainOptions[i]; - if( opt != null ) { - if(opt.getId().equals(newProjDebugOptionId)){ + if (opt != null) { + if (opt.getId().equals(newProjDebugOptionId)) { // Resource Configuration doesnot have overridden value for this option. resMainDebugOption = opt; break; } - if ( opt.getSuperClass() != null ) { - if(opt.getSuperClass().getId().equals(newProjDebugOptionId)){ + if (opt.getSuperClass() != null) { + if (opt.getSuperClass().getId().equals(newProjDebugOptionId)) { // Resource Configuration does have overridden value for this option. resMainDebugOption = opt; break; @@ -242,16 +247,17 @@ public class ResourceBuildCoreTests extends TestCase { // and verify whether the modified option is reflected at project level. // It should not reflect at project level. - IOption newResMainDebugOption = ManagedBuildManager.setOption(resMainConfig,resMainTool,resMainDebugOption,"gnu.c.debugging.level.minimal"); + IOption newResMainDebugOption = ManagedBuildManager.setOption(resMainConfig, resMainTool, resMainDebugOption, + "gnu.c.debugging.level.minimal"); //Get the latest project Debug option. tools = defaultConfig.getFilteredTools(); projTool = null; for (int i = 0; i < tools.length; i++) { - if( tools[i].buildsFileType(extString) ) { + if (tools[i].buildsFileType(extString)) { // Get the build properties of a project in default configuration - projTool = (Tool)tools[i]; + projTool = (Tool) tools[i]; break; } } @@ -309,9 +315,12 @@ public class ResourceBuildCoreTests extends TestCase { ManagedBuildManager.setNewProjectVersion(project); // Create a resource ( 'hello.c') - IFile helloFile = project.getProject().getFile( "hello.c" ); - if( !helloFile.exists() ){ - helloFile.create( new ByteArrayInputStream( "#include <stdio.h>\n\n int main() { \nprintf(\"Hello, World!!\"); \n bar();\n return 0; }".getBytes() ), false, null ); + IFile helloFile = project.getProject().getFile("hello.c"); + if (!helloFile.exists()) { + helloFile.create(new ByteArrayInputStream( + "#include <stdio.h>\n\n int main() { \nprintf(\"Hello, World!!\"); \n bar();\n return 0; }" + .getBytes()), + false, null); } // Get the configurations and make one of them as default configuration. @@ -332,12 +341,12 @@ public class ResourceBuildCoreTests extends TestCase { // Check whether defaultConfig has the correct number of resource configurations or not. IResourceConfiguration resConfigs[] = defaultConfig.getResourceConfigurations(); - assertEquals(1,resConfigs.length); + assertEquals(1, resConfigs.length); // Get the tools associated with the resource 'hello.c'. ITool resTools[] = resConfig.getTools(); assertNotNull(resTools); - assertEquals(1,resTools.length); + assertEquals(1, resTools.length); // Get the build properties for the resource hello.c ITool resTool = resTools[0]; @@ -350,21 +359,22 @@ public class ResourceBuildCoreTests extends TestCase { String defaultResDebugOptVal = resDebugOption.getStringValue(); // Now, override the value with "gnu.c.debugging.level.minimal" - IOption newResDebugOption = ManagedBuildManager.setOption(resConfig,resTool,resDebugOption,"gnu.c.debugging.level.minimal"); + IOption newResDebugOption = ManagedBuildManager.setOption(resConfig, resTool, resDebugOption, + "gnu.c.debugging.level.minimal"); // Get the overridden value of debug option. String newResDebugOptVal = newResDebugOption.getStringValue(); String newResToolFlags = resTool.getToolFlags(); // Make sure, default and overridden values are different. - assertNotSame(defaultResDebugOptVal,newResDebugOptVal); + assertNotSame(defaultResDebugOptVal, newResDebugOptVal); // Reset the resource configuration. - ManagedBuildManager.resetResourceConfiguration(project,resConfig); + ManagedBuildManager.resetResourceConfiguration(project, resConfig); String resetResToolFlags = resTool.getToolFlags(); - assertNotSame(resetResToolFlags,newResToolFlags); - assertEquals(defaultResToolFlags,resetResToolFlags); + assertNotSame(resetResToolFlags, newResToolFlags); + assertEquals(defaultResToolFlags, resetResToolFlags); // Close and remove project. ResourceHelper.joinIndexerBeforeCleanup(getName()); @@ -411,14 +421,20 @@ public class ResourceBuildCoreTests extends TestCase { ManagedBuildManager.setNewProjectVersion(project); // Create a couple of resources ( 'main.c' & 'bar.c') - IFile mainFile = project.getProject().getFile( "main.c" ); - if( !mainFile.exists() ){ - mainFile.create( new ByteArrayInputStream( "#include <stdio.h>\n extern void bar(); \n int main() { \nprintf(\"Hello, World!!\"); \n bar();\n return 0; }".getBytes() ), false, null ); + IFile mainFile = project.getProject().getFile("main.c"); + if (!mainFile.exists()) { + mainFile.create(new ByteArrayInputStream( + "#include <stdio.h>\n extern void bar(); \n int main() { \nprintf(\"Hello, World!!\"); \n bar();\n return 0; }" + .getBytes()), + false, null); } - IFile barFile = project.getProject().getFile( "bar.c" ); - if( !barFile.exists() ){ - barFile.create( new ByteArrayInputStream( "#include <stdio.h>\n void bar() { \nprintf(\"Hello, bar()!!\");\n return; }".getBytes() ), false, null ); + IFile barFile = project.getProject().getFile("bar.c"); + if (!barFile.exists()) { + barFile.create( + new ByteArrayInputStream( + "#include <stdio.h>\n void bar() { \nprintf(\"Hello, bar()!!\");\n return; }".getBytes()), + false, null); } // Get the configurations and make one of them as default configuration. @@ -443,21 +459,21 @@ public class ResourceBuildCoreTests extends TestCase { // Check whether defaultConfig has two resource configurations or not. IResourceConfiguration resConfigs[] = defaultConfig.getResourceConfigurations(); - assertEquals(2,resConfigs.length); + assertEquals(2, resConfigs.length); // Get the paths of resource configurations. String resMainPath = resMainConfig.getResourcePath(); - String resBarPath = resBarConfig.getResourcePath(); + String resBarPath = resBarConfig.getResourcePath(); // Get the tools associated with the resource 'main.c'. ITool resMainTools[] = resMainConfig.getTools(); assertNotNull(resMainTools); - assertEquals(1,resMainTools.length); + assertEquals(1, resMainTools.length); // Get the tools associated with the resource 'bar.c'. ITool resBarTools[] = resBarConfig.getTools(); assertNotNull(resBarTools); - assertEquals(1,resBarTools.length); + assertEquals(1, resBarTools.length); // Get the build properties for the resource main.c ITool resMainTool = resMainTools[0]; @@ -468,7 +484,6 @@ public class ResourceBuildCoreTests extends TestCase { ITool resBarTool = resBarTools[0]; String defaultBarBuildProps = resBarTool.getToolFlags(); - // Now, override debug and optimization options. // In Debug Configuration, Currently default values in resource configurations are // optimization : -O0, debug : -g3 @@ -476,28 +491,36 @@ public class ResourceBuildCoreTests extends TestCase { // main.c : optimization : '-O1' debug : '-g1' // bar.c : optimization : '-O2' debug : '-g2' - IOption defaultResMainOptOption = resMainTool.getOptionById("testgnu.c.compiler.exe.debug.option.optimization.level"); + IOption defaultResMainOptOption = resMainTool + .getOptionById("testgnu.c.compiler.exe.debug.option.optimization.level"); String defaultResMainOptVal = defaultResMainOptOption.getStringValue(); - IOption resMainOptOption = ManagedBuildManager.setOption(resMainConfig,resMainTool,defaultResMainOptOption,"gnu.c.optimization.level.optimize"); + IOption resMainOptOption = ManagedBuildManager.setOption(resMainConfig, resMainTool, defaultResMainOptOption, + "gnu.c.optimization.level.optimize"); String resMainOptVal = resMainOptOption.getStringValue(); - IOption defaultResMainDebugOption = resMainTool.getOptionById("testgnu.c.compiler.exe.debug.option.debugging.level"); + IOption defaultResMainDebugOption = resMainTool + .getOptionById("testgnu.c.compiler.exe.debug.option.debugging.level"); String defaultResMainDebugVal = defaultResMainDebugOption.getStringValue(); - IOption resMainDebugOption = ManagedBuildManager.setOption(resMainConfig,resMainTool,defaultResMainDebugOption,"gnu.c.debugging.level.minimal"); + IOption resMainDebugOption = ManagedBuildManager.setOption(resMainConfig, resMainTool, + defaultResMainDebugOption, "gnu.c.debugging.level.minimal"); String resMainDebugVal = resMainDebugOption.getStringValue(); - IOption defaultResBarOptOption = resBarTool.getOptionById("testgnu.c.compiler.exe.debug.option.optimization.level"); + IOption defaultResBarOptOption = resBarTool + .getOptionById("testgnu.c.compiler.exe.debug.option.optimization.level"); String defaultResBarOptVal = defaultResBarOptOption.getStringValue(); - IOption resBarOptOption = ManagedBuildManager.setOption(resBarConfig,resBarTool,defaultResBarOptOption,"gnu.c.optimization.level.more"); - String resBarOptVal = resBarOptOption.getStringValue(); + IOption resBarOptOption = ManagedBuildManager.setOption(resBarConfig, resBarTool, defaultResBarOptOption, + "gnu.c.optimization.level.more"); + String resBarOptVal = resBarOptOption.getStringValue(); - IOption defaultResBarDebugOption = resBarTool.getOptionById("testgnu.c.compiler.exe.debug.option.debugging.level"); + IOption defaultResBarDebugOption = resBarTool + .getOptionById("testgnu.c.compiler.exe.debug.option.debugging.level"); String defaultResBarDebugVal = defaultResBarDebugOption.getStringValue(); - IOption resBarDebugOption = ManagedBuildManager.setOption(resBarConfig,resBarTool,defaultResBarDebugOption,"gnu.c.debugging.level.default"); + IOption resBarDebugOption = ManagedBuildManager.setOption(resBarConfig, resBarTool, defaultResBarDebugOption, + "gnu.c.debugging.level.default"); String resBarDebugVal = resBarDebugOption.getStringValue(); assertNotSame(defaultResMainOptVal, resMainOptVal); @@ -507,7 +530,7 @@ public class ResourceBuildCoreTests extends TestCase { assertNotSame(defaultResBarDebugVal, resBarDebugVal); // Save and Close the project. - ManagedBuildManager.saveBuildInfo(project,false); + ManagedBuildManager.saveBuildInfo(project, false); ManagedBuildManager.removeBuildInfo(project); ResourceHelper.joinIndexerBeforeCleanup(getName()); @@ -539,7 +562,7 @@ public class ResourceBuildCoreTests extends TestCase { assertNotNull(newResMainConfig); ITool newResMainTools[] = newResMainConfig.getTools(); - assertEquals(1,newResMainTools.length); + assertEquals(1, newResMainTools.length); // Get the Optimization and Debug option values for the resource 'main.c'. ITool newResMainTool = newResMainTools[0]; @@ -554,14 +577,14 @@ public class ResourceBuildCoreTests extends TestCase { // Assert that optimization & debug option values for the resource main.c are same between the sessions. assertEquals(resMainOptVal, newResMainOptVal); - assertEquals(resMainDebugVal,newResMainDebugVal); + assertEquals(resMainDebugVal, newResMainDebugVal); // Get the resource configuration for bar.c IResourceConfiguration newResBarConfig = newDefaultConfig.getResourceConfiguration(resBarPath); assertNotNull(newResBarConfig); ITool newResBarTools[] = newResBarConfig.getTools(); - assertEquals(1,newResBarTools.length); + assertEquals(1, newResBarTools.length); //Get the Optimization and Debug option values for the resource 'bar.c' ITool newResBarTool = newResBarTools[0]; @@ -576,7 +599,7 @@ public class ResourceBuildCoreTests extends TestCase { // Assert that optimization & debug option values for the resource main.c are same between the sessions. assertEquals(resBarOptVal, newResBarOptVal); - assertEquals(resBarDebugVal,newResBarDebugVal); + assertEquals(resBarDebugVal, newResBarDebugVal); // Close and remove project. ResourceHelper.joinIndexerBeforeCleanup(getName()); @@ -597,7 +620,8 @@ public class ResourceBuildCoreTests extends TestCase { workspace.setDescription(workspaceDesc); IProjectDescription description = workspace.newProjectDescription(newProjectHandle.getName()); //description.setLocation(root.getLocation()); - project = CCorePlugin.getDefault().createCProject(description, newProjectHandle, new NullProgressMonitor(), ManagedBuilderCorePlugin.MANAGED_MAKE_PROJECT_ID); + project = CCorePlugin.getDefault().createCProject(description, newProjectHandle, new NullProgressMonitor(), + ManagedBuilderCorePlugin.MANAGED_MAKE_PROJECT_ID); } else { IWorkspace workspace = ResourcesPlugin.getWorkspace(); IWorkspaceRunnable runnable = new IWorkspaceRunnable() { @@ -689,11 +713,12 @@ public class ResourceBuildCoreTests extends TestCase { // Initialize the path entry container IStatus initResult = ManagedBuildManager.initBuildInfoContainer(project); if (initResult.getCode() != IStatus.OK) { - fail("Initializing build information failed for: " + project.getName() + " because: " + initResult.getMessage()); + fail("Initializing build information failed for: " + project.getName() + " because: " + + initResult.getMessage()); } // Now test the results out - // checkRootManagedProject(newProject, "x"); + // checkRootManagedProject(newProject, "x"); // Override the "String Option in Category" option value configs = newProject.getConfigurations(); @@ -701,16 +726,16 @@ public class ResourceBuildCoreTests extends TestCase { IOptionCategory topCategory = tools[0].getTopOptionCategory(); IOptionCategory[] categories = topCategory.getChildCategories(); Object[][] options = categories[0].getOptions(configs[0]); - ITool tool = (ITool)options[0][0]; - IOption option = (IOption)options[0][1]; + ITool tool = (ITool) options[0][0]; + IOption option = (IOption) options[0][1]; configs[0].setOption(tool, option, "1"); - options = categories[0].getOptions((IConfiguration)null); - tool = (ITool)options[0][0]; - option = (IOption)options[0][1]; + options = categories[0].getOptions((IConfiguration) null); + tool = (ITool) options[0][0]; + option = (IOption) options[0][1]; assertEquals("x", option.getStringValue()); options = categories[0].getOptions(configs[0]); - tool = (ITool)options[0][0]; - option = (IOption)options[0][1]; + tool = (ITool) options[0][0]; + option = (IOption) options[0][1]; assertEquals("z", option.getStringValue()); // Save, close, reopen and test again @@ -733,10 +758,10 @@ public class ResourceBuildCoreTests extends TestCase { assertEquals(defaultConfig.getId(), info.getDefaultConfiguration().getId()); // Check the rest of the default information -// checkRootManagedProject(newProject, "z"); + // checkRootManagedProject(newProject, "z"); // Now test the information the makefile builder needs - // checkBuildTestSettings(info); + // checkBuildTestSettings(info); ManagedBuildManager.removeBuildInfo(project); } @@ -772,22 +797,31 @@ public class ResourceBuildCoreTests extends TestCase { ManagedBuildManager.setNewProjectVersion(project); // Create a couple of resources ( 'main.c' & 'bar.c') - IFile mainFile = project.getProject().getFile( "main.c" ); - if( !mainFile.exists() ){ - mainFile.create( new ByteArrayInputStream( "#include <stdio.h>\n extern void bar(); \n int main() { \nprintf(\"Hello, World!!\"); \n bar();\n return 0; }".getBytes() ), false, null ); + IFile mainFile = project.getProject().getFile("main.c"); + if (!mainFile.exists()) { + mainFile.create(new ByteArrayInputStream( + "#include <stdio.h>\n extern void bar(); \n int main() { \nprintf(\"Hello, World!!\"); \n bar();\n return 0; }" + .getBytes()), + false, null); } - IFile aFile = project.getProject().getFile( "a.c" ); - if( !aFile.exists() ){ - aFile.create( new ByteArrayInputStream( "#include <stdio.h>\n void bar() { \nprintf(\"Hello, bar()!!\");\n return; }".getBytes() ), false, null ); + IFile aFile = project.getProject().getFile("a.c"); + if (!aFile.exists()) { + aFile.create( + new ByteArrayInputStream( + "#include <stdio.h>\n void bar() { \nprintf(\"Hello, bar()!!\");\n return; }".getBytes()), + false, null); } - IFolder dirFolder = project.getProject().getFolder( "dir" ); - if(!dirFolder.exists()) - dirFolder.create(true,true,null); - IFile bFile = dirFolder.getFile( "b.c" ); - if( !bFile.exists() ){ - bFile.create( new ByteArrayInputStream( "#include <stdio.h>\n void bar1() { \nprintf(\"Hello, bar1()!!\");\n return; }".getBytes() ), false, null ); + IFolder dirFolder = project.getProject().getFolder("dir"); + if (!dirFolder.exists()) + dirFolder.create(true, true, null); + IFile bFile = dirFolder.getFile("b.c"); + if (!bFile.exists()) { + bFile.create( + new ByteArrayInputStream( + "#include <stdio.h>\n void bar1() { \nprintf(\"Hello, bar1()!!\");\n return; }".getBytes()), + false, null); } // Get the configurations and make one of them as default configuration. @@ -810,50 +844,49 @@ public class ResourceBuildCoreTests extends TestCase { // Check whether defaultConfig has three resource configurations or not. IResourceConfiguration resConfigs[] = defaultConfig.getResourceConfigurations(); - assertEquals(resMainConfig,defaultConfig.getResourceConfiguration(mainFile.getFullPath().toString())); - assertEquals(resAConfig,defaultConfig.getResourceConfiguration(aFile.getFullPath().toString())); - assertEquals(resBConfig,defaultConfig.getResourceConfiguration(bFile.getFullPath().toString())); - assertEquals(3,resConfigs.length); - - - mainFile.move(mainFile.getFullPath().removeLastSegments(1).append("main1.c"),true,false,null); - mainFile = (IFile)project.findMember("main1.c"); - assertEquals(resMainConfig,defaultConfig.getResourceConfiguration(mainFile.getFullPath().toString())); - assertEquals(resAConfig,defaultConfig.getResourceConfiguration(aFile.getFullPath().toString())); - assertEquals(resBConfig,defaultConfig.getResourceConfiguration(bFile.getFullPath().toString())); + assertEquals(resMainConfig, defaultConfig.getResourceConfiguration(mainFile.getFullPath().toString())); + assertEquals(resAConfig, defaultConfig.getResourceConfiguration(aFile.getFullPath().toString())); + assertEquals(resBConfig, defaultConfig.getResourceConfiguration(bFile.getFullPath().toString())); + assertEquals(3, resConfigs.length); + + mainFile.move(mainFile.getFullPath().removeLastSegments(1).append("main1.c"), true, false, null); + mainFile = (IFile) project.findMember("main1.c"); + assertEquals(resMainConfig, defaultConfig.getResourceConfiguration(mainFile.getFullPath().toString())); + assertEquals(resAConfig, defaultConfig.getResourceConfiguration(aFile.getFullPath().toString())); + assertEquals(resBConfig, defaultConfig.getResourceConfiguration(bFile.getFullPath().toString())); resConfigs = defaultConfig.getResourceConfigurations(); - assertEquals(3,resConfigs.length); - - dirFolder.move(dirFolder.getFullPath().removeLastSegments(1).append("dir1"),true,false,null); - dirFolder = (IFolder)project.findMember("dir1"); - bFile = (IFile)dirFolder.findMember("b.c"); - assertEquals(resMainConfig,defaultConfig.getResourceConfiguration(mainFile.getFullPath().toString())); - assertEquals(resAConfig,defaultConfig.getResourceConfiguration(aFile.getFullPath().toString())); - assertEquals(resBConfig,defaultConfig.getResourceConfiguration(bFile.getFullPath().toString())); + assertEquals(3, resConfigs.length); + + dirFolder.move(dirFolder.getFullPath().removeLastSegments(1).append("dir1"), true, false, null); + dirFolder = (IFolder) project.findMember("dir1"); + bFile = (IFile) dirFolder.findMember("b.c"); + assertEquals(resMainConfig, defaultConfig.getResourceConfiguration(mainFile.getFullPath().toString())); + assertEquals(resAConfig, defaultConfig.getResourceConfiguration(aFile.getFullPath().toString())); + assertEquals(resBConfig, defaultConfig.getResourceConfiguration(bFile.getFullPath().toString())); resConfigs = defaultConfig.getResourceConfigurations(); - assertEquals(3,resConfigs.length); + assertEquals(3, resConfigs.length); - bFile.move(bFile.getFullPath().removeLastSegments(1).append("b1.c"),true,false,null); - bFile = (IFile)dirFolder.findMember("b1.c"); - assertEquals(resMainConfig,defaultConfig.getResourceConfiguration(mainFile.getFullPath().toString())); - assertEquals(resAConfig,defaultConfig.getResourceConfiguration(aFile.getFullPath().toString())); - assertEquals(resBConfig,defaultConfig.getResourceConfiguration(bFile.getFullPath().toString())); + bFile.move(bFile.getFullPath().removeLastSegments(1).append("b1.c"), true, false, null); + bFile = (IFile) dirFolder.findMember("b1.c"); + assertEquals(resMainConfig, defaultConfig.getResourceConfiguration(mainFile.getFullPath().toString())); + assertEquals(resAConfig, defaultConfig.getResourceConfiguration(aFile.getFullPath().toString())); + assertEquals(resBConfig, defaultConfig.getResourceConfiguration(bFile.getFullPath().toString())); resConfigs = defaultConfig.getResourceConfigurations(); - assertEquals(3,resConfigs.length); + assertEquals(3, resConfigs.length); IProjectDescription des = project.getDescription(); des.setName(renamedProjectName1); - project.move(des,true,null); - project = (IProject)root.findMember(renamedProjectName1); - mainFile = (IFile)project.findMember("main1.c"); - aFile = (IFile)project.findMember("a.c"); - dirFolder = (IFolder)project.findMember("dir1"); - bFile = (IFile)dirFolder.findMember("b1.c"); - assertEquals(resMainConfig,defaultConfig.getResourceConfiguration(mainFile.getFullPath().toString())); - assertEquals(resAConfig,defaultConfig.getResourceConfiguration(aFile.getFullPath().toString())); - assertEquals(resBConfig,defaultConfig.getResourceConfiguration(bFile.getFullPath().toString())); + project.move(des, true, null); + project = (IProject) root.findMember(renamedProjectName1); + mainFile = (IFile) project.findMember("main1.c"); + aFile = (IFile) project.findMember("a.c"); + dirFolder = (IFolder) project.findMember("dir1"); + bFile = (IFile) dirFolder.findMember("b1.c"); + assertEquals(resMainConfig, defaultConfig.getResourceConfiguration(mainFile.getFullPath().toString())); + assertEquals(resAConfig, defaultConfig.getResourceConfiguration(aFile.getFullPath().toString())); + assertEquals(resBConfig, defaultConfig.getResourceConfiguration(bFile.getFullPath().toString())); resConfigs = defaultConfig.getResourceConfigurations(); - assertEquals(3,resConfigs.length); + assertEquals(3, resConfigs.length); final IResource rcBuf[] = new IResource[5]; rcBuf[0] = project; @@ -862,36 +895,36 @@ public class ResourceBuildCoreTests extends TestCase { rcBuf[3] = dirFolder; rcBuf[4] = bFile; - ResourcesPlugin.getWorkspace().run( new IWorkspaceRunnable(){ + ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() { @Override public void run(IProgressMonitor monitor) throws CoreException { - IProject project = (IProject)rcBuf[0]; - IFile mainFile = (IFile)rcBuf[1]; - IFile aFile = (IFile)rcBuf[2]; - IFolder dirFolder = (IFolder)rcBuf[3]; - IFile bFile = (IFile)rcBuf[4]; + IProject project = (IProject) rcBuf[0]; + IFile mainFile = (IFile) rcBuf[1]; + IFile aFile = (IFile) rcBuf[2]; + IFolder dirFolder = (IFolder) rcBuf[3]; + IFile bFile = (IFile) rcBuf[4]; // TODO Auto-generated method stub - mainFile.move(mainFile.getFullPath().removeLastSegments(1).append("main2.c"),true,false,null); - mainFile = (IFile)project.findMember("main2.c"); + mainFile.move(mainFile.getFullPath().removeLastSegments(1).append("main2.c"), true, false, null); + mainFile = (IFile) project.findMember("main2.c"); - dirFolder.move(dirFolder.getFullPath().removeLastSegments(1).append("dir2"),true,false,null); - dirFolder = (IFolder)project.findMember("dir2"); - bFile = (IFile)dirFolder.findMember("b1.c"); + dirFolder.move(dirFolder.getFullPath().removeLastSegments(1).append("dir2"), true, false, null); + dirFolder = (IFolder) project.findMember("dir2"); + bFile = (IFile) dirFolder.findMember("b1.c"); - bFile.move(bFile.getFullPath().removeLastSegments(1).append("b2.c"),true,false,null); - bFile = (IFile)dirFolder.findMember("b2.c"); + bFile.move(bFile.getFullPath().removeLastSegments(1).append("b2.c"), true, false, null); + bFile = (IFile) dirFolder.findMember("b2.c"); -// project.move(project.getFullPath().removeLastSegments(1).append(renamedProjectName2),true,null); + // project.move(project.getFullPath().removeLastSegments(1).append(renamedProjectName2),true,null); IProjectDescription des = project.getDescription(); des.setName(renamedProjectName2); - project.move(des,true,null); - project = (IProject)ResourcesPlugin.getWorkspace().getRoot().findMember(renamedProjectName2); + project.move(des, true, null); + project = (IProject) ResourcesPlugin.getWorkspace().getRoot().findMember(renamedProjectName2); - mainFile = (IFile)project.findMember("main2.c"); - aFile = (IFile)project.findMember("a.c"); - dirFolder = (IFolder)project.findMember("dir2"); - bFile = (IFile)dirFolder.findMember("b2.c"); + mainFile = (IFile) project.findMember("main2.c"); + aFile = (IFile) project.findMember("a.c"); + dirFolder = (IFolder) project.findMember("dir2"); + bFile = (IFile) dirFolder.findMember("b2.c"); rcBuf[0] = project; rcBuf[1] = mainFile; @@ -900,38 +933,35 @@ public class ResourceBuildCoreTests extends TestCase { rcBuf[4] = bFile; } - }, - root, - IWorkspace.AVOID_UPDATE, - null); + }, root, IWorkspace.AVOID_UPDATE, null); - project = (IProject)rcBuf[0]; - mainFile = (IFile)rcBuf[1]; - aFile = (IFile)rcBuf[2]; - dirFolder = (IFolder)rcBuf[3]; - bFile = (IFile)rcBuf[4]; + project = (IProject) rcBuf[0]; + mainFile = (IFile) rcBuf[1]; + aFile = (IFile) rcBuf[2]; + dirFolder = (IFolder) rcBuf[3]; + bFile = (IFile) rcBuf[4]; - assertEquals(resMainConfig,defaultConfig.getResourceConfiguration(mainFile.getFullPath().toString())); - assertEquals(resAConfig,defaultConfig.getResourceConfiguration(aFile.getFullPath().toString())); - assertEquals(resBConfig,defaultConfig.getResourceConfiguration(bFile.getFullPath().toString())); + assertEquals(resMainConfig, defaultConfig.getResourceConfiguration(mainFile.getFullPath().toString())); + assertEquals(resAConfig, defaultConfig.getResourceConfiguration(aFile.getFullPath().toString())); + assertEquals(resBConfig, defaultConfig.getResourceConfiguration(bFile.getFullPath().toString())); resConfigs = defaultConfig.getResourceConfigurations(); - assertEquals(3,resConfigs.length); + assertEquals(3, resConfigs.length); - aFile.delete(true,null); + aFile.delete(true, null); // Check whether defaultConfig has two resource configurations or not. - assertEquals(resMainConfig,defaultConfig.getResourceConfiguration(mainFile.getFullPath().toString())); - assertEquals(null,defaultConfig.getResourceConfiguration(aFile.getFullPath().toString())); - assertEquals(resBConfig,defaultConfig.getResourceConfiguration(bFile.getFullPath().toString())); + assertEquals(resMainConfig, defaultConfig.getResourceConfiguration(mainFile.getFullPath().toString())); + assertEquals(null, defaultConfig.getResourceConfiguration(aFile.getFullPath().toString())); + assertEquals(resBConfig, defaultConfig.getResourceConfiguration(bFile.getFullPath().toString())); resConfigs = defaultConfig.getResourceConfigurations(); - assertEquals(2,resConfigs.length); + assertEquals(2, resConfigs.length); dirFolder.delete(true, null); // Check whether defaultConfig has one resource configuration or not. - assertEquals(resMainConfig,defaultConfig.getResourceConfiguration(mainFile.getFullPath().toString())); - assertEquals(null,defaultConfig.getResourceConfiguration(aFile.getFullPath().toString())); - assertEquals(null,defaultConfig.getResourceConfiguration(bFile.getFullPath().toString())); + assertEquals(resMainConfig, defaultConfig.getResourceConfiguration(mainFile.getFullPath().toString())); + assertEquals(null, defaultConfig.getResourceConfiguration(aFile.getFullPath().toString())); + assertEquals(null, defaultConfig.getResourceConfiguration(bFile.getFullPath().toString())); resConfigs = defaultConfig.getResourceConfigurations(); - assertEquals(1,resConfigs.length); + assertEquals(1, resConfigs.length); // Close and remove project. ResourceHelper.joinIndexerBeforeCleanup(getName()); |