| package org.eclipse.jst.j2ee.dependency.tests; |
| |
| //import org.eclipse.core.resources.IFolder; |
| import org.eclipse.core.resources.IProject; |
| import org.eclipse.core.runtime.IPath; |
| import org.eclipse.core.runtime.Path; |
| import org.eclipse.jst.j2ee.dependency.tests.util.DependencyUtil; |
| import org.eclipse.jst.j2ee.dependency.tests.util.ProjectUtil; |
| |
| import junit.framework.Test; |
| import junit.framework.TestSuite; |
| |
| /** |
| * Tests refactoring logic that updates component mappings when source IClasspathEntries are |
| * added to/removed from the Java build path. |
| */ |
| public class ProjectClasspathRefactoringTests extends AbstractTests { |
| |
| public ProjectClasspathRefactoringTests(String name) { |
| super(name); |
| } |
| |
| public static Test suite(){ |
| final TestSuite suite = new TestSuite(); |
| suite.setName("Project Classpath Refactoring Tests" ); |
| suite.addTest(new ProjectClasspathRefactoringTests("testSourcePathAdditionWeb")); |
| suite.addTest(new ProjectClasspathRefactoringTests("testSourcePathRemovalWeb")); |
| //suite.addTest(new ProjectClasspathRefactoringTests("testSourcePathRenameWeb")); |
| suite.addTest(new ProjectClasspathRefactoringTests("testSourcePathAdditionUtil")); |
| suite.addTest(new ProjectClasspathRefactoringTests("testSourcePathRemovalUtil")); |
| //suite.addTest(new ProjectClasspathRefactoringTests("testSourcePathRenameUtil")); |
| return suite; |
| } |
| |
| public void testSourcePathAdditionWeb() throws Exception { |
| testSourcePathAddition(ProjectUtil.createWebProject("TestWeb", null)); |
| } |
| |
| public void testSourcePathAdditionUtil() throws Exception { |
| testSourcePathAddition(ProjectUtil.createUtilityProject("TestUtil", null)); |
| } |
| |
| private static void testSourcePathAddition(final IProject project) throws Exception { |
| final IPath srcPath = new Path("src"); |
| final IPath newSrcPath = new Path("newSrc"); |
| |
| DependencyUtil.verifyComponentMapping(project, srcPath, true); |
| DependencyUtil.verifyComponentMapping(project, newSrcPath, false); |
| |
| assertTrue("Failed to add new source path " + newSrcPath, DependencyUtil.addJavaSrcPath(project, newSrcPath)); |
| |
| DependencyUtil.verifyComponentMapping(project, srcPath, true); |
| DependencyUtil.verifyComponentMapping(project, newSrcPath, true); |
| } |
| |
| public void testSourcePathRemovalWeb() throws Exception { |
| testSourcePathRemoval(ProjectUtil.createWebProject("TestWeb", null)); |
| } |
| |
| public void testSourcePathRemovalUtil() throws Exception { |
| testSourcePathRemoval(ProjectUtil.createUtilityProject("TestUtil", null)); |
| } |
| |
| private static void testSourcePathRemoval(final IProject project) throws Exception { |
| final IPath srcPath = new Path("src"); |
| DependencyUtil.verifyComponentMapping(project, srcPath, true); |
| assertTrue("Failed to remove src path " + srcPath, DependencyUtil.removeJavaSrcPath(project, srcPath)); |
| DependencyUtil.verifyComponentMapping(project, srcPath, false); |
| } |
| |
| // XXX need to change to execute a refactor->rename |
| // public void testSourcePathRenameWeb() throws Exception { |
| // testSourcePathRename(ProjectUtil.createWebProject("TestWeb", null)); |
| // } |
| // |
| // public void testSourcePathRenameUtil() throws Exception { |
| // testSourcePathRename(ProjectUtil.createUtilityProject("TestUtil", null)); |
| // } |
| // |
| // private static void testSourcePathRename(final IProject project) throws Exception { |
| // final IPath srcPath = new Path("src"); |
| // final IPath newSrcPath = new Path("newSrc"); |
| // |
| // DependencyUtil.verifyComponentMapping(project, srcPath, true); |
| // |
| // final IFolder srcFolder = project.getFolder(srcPath); |
| // srcFolder.move(newSrcPath, true, null); |
| // |
| // DependencyUtil.verifyComponentMapping(project, srcPath, false); |
| // DependencyUtil.verifyComponentMapping(project, newSrcPath, true); |
| // } |
| } |