Project dependency/refactoring unit tests
diff --git a/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/jst/j2ee/dependency/tests/AbstractTests.java b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/jst/j2ee/dependency/tests/AbstractTests.java
new file mode 100644
index 0000000..1ce60c3
--- /dev/null
+++ b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/jst/j2ee/dependency/tests/AbstractTests.java
@@ -0,0 +1,15 @@
+package org.eclipse.jst.j2ee.dependency.tests;
+
+import org.eclipse.wst.common.tests.OperationTestCase;
+
+/**
+ * Abstract base class for unit tests
+ * 
+ * @author rfrost@bea.com
+ */
+public abstract class AbstractTests extends OperationTestCase {
+    
+    protected AbstractTests(final String name) {
+        super(name);
+    }
+}
diff --git a/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/jst/j2ee/dependency/tests/AllTests.java b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/jst/j2ee/dependency/tests/AllTests.java
new file mode 100644
index 0000000..350af60
--- /dev/null
+++ b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/jst/j2ee/dependency/tests/AllTests.java
@@ -0,0 +1,24 @@
+package org.eclipse.jst.j2ee.dependency.tests;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class AllTests extends TestCase {
+    public static Test suite() {
+        final TestSuite suite = new TestSuite();
+        
+        suite.setName("All J2EE Dependency/Refactoring Tests");
+        
+        suite.addTest(ProjectCreationTests.suite());
+        suite.addTest(ProjectDependencyTests.suite());
+        suite.addTest(ProjectEARRefactoringTests.suite());
+        suite.addTest(ProjectModuleRefactoringTests.suite());
+        suite.addTest(ProjectWebLibRefactoringTests.suite());
+        suite.addTest(ProjectClasspathRefactoringTests.suite());
+        suite.addTest(ProjectServerRefactoringTests.suite());
+        
+        return suite;
+    }
+
+}
diff --git a/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/jst/j2ee/dependency/tests/ProjectClasspathRefactoringTests.java b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/jst/j2ee/dependency/tests/ProjectClasspathRefactoringTests.java
new file mode 100644
index 0000000..a843c7a
--- /dev/null
+++ b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/jst/j2ee/dependency/tests/ProjectClasspathRefactoringTests.java
@@ -0,0 +1,92 @@
+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);
+//	}
+}
diff --git a/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/jst/j2ee/dependency/tests/ProjectCreationTests.java b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/jst/j2ee/dependency/tests/ProjectCreationTests.java
new file mode 100644
index 0000000..639838c
--- /dev/null
+++ b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/jst/j2ee/dependency/tests/ProjectCreationTests.java
@@ -0,0 +1,75 @@
+package org.eclipse.jst.j2ee.dependency.tests;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jst.j2ee.dependency.tests.util.DependencyVerificationUtil;
+import org.eclipse.jst.j2ee.dependency.tests.util.ProjectUtil;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Tests project creation logic in the ProjectCreationUtil helper class.
+ */
+public class ProjectCreationTests extends AbstractTests {
+
+    private ProjectCreationTests(final String name) {
+        super(name);
+    }
+    
+    public static Test suite(){
+        final TestSuite suite = new TestSuite();
+        suite.setName("Project Creation Tests" );
+        suite.addTest(new ProjectCreationTests("testEARCreation"));
+        suite.addTest(new ProjectCreationTests("testWebCreation"));
+        suite.addTest(new ProjectCreationTests("testWebWithEARCreation"));
+        suite.addTest(new ProjectCreationTests("testEJBCreation"));
+        suite.addTest(new ProjectCreationTests("testEJBWithEARCreation"));
+        suite.addTest(new ProjectCreationTests("testUtilCreation"));
+        suite.addTest(new ProjectCreationTests("testUtilWithEARCreation"));
+        return suite;
+    }
+    
+    public void testEARCreation() throws Exception {
+    	ProjectUtil.createEARProject("TestEAR");
+    }
+    
+    public void testWebCreation() throws Exception {
+    	ProjectUtil.createWebProject("TestWeb", null);
+    }
+    
+    public void testWebWithEARCreation() throws Exception {
+    	final IProject earProject = ProjectUtil.getProject("TestEAR"); 
+    	DependencyVerificationUtil.verifyEARDependency(earProject, ProjectUtil.createWebProject("TestWeb", earProject.getName()), true);
+    }
+    
+    public void testEJBCreation() throws Exception {
+    	ProjectUtil.createEJBProject("TestEJB", null);
+    }
+    
+    public void testEJBWithEARCreation() throws Exception {
+    	final IProject earProject = ProjectUtil.getProject("TestEAR"); 
+    	final IProject ejbProject = ProjectUtil.createEJBProject("TestEJB", earProject.getName());
+    	DependencyVerificationUtil.verifyEARDependency(earProject, ejbProject, true);
+    	testEJBClient(ejbProject, earProject);
+    }
+
+    private void testEJBClient(final IProject ejbProject, final IProject earProject) throws Exception {
+    	final IProject ejbClient = ProjectUtil.getProject(ejbProject.getName() + "Client"); 
+    	// check dependencies from EAR to EJB client
+    	DependencyVerificationUtil.verifyProjectReference(earProject, ejbClient, true);
+    	DependencyVerificationUtil.verifyComponentReference(earProject, ejbClient, DependencyVerificationUtil.ROOT, true);
+    	
+    	// check dependencies from EJB to EJB client
+    	DependencyVerificationUtil.verifyModuleDependency(ejbProject, ejbClient);
+    	DependencyVerificationUtil.verifyManifestReference(ejbProject, ejbClient.getName() + ".jar", true);    	
+    }
+    
+    public void testUtilCreation() throws Exception {
+    	ProjectUtil.createUtilityProject("TestUtil", null);
+    }
+    
+    public void testUtilWithEARCreation() throws Exception {
+    	final IProject earProject = ProjectUtil.getProject("TestEAR");
+    	DependencyVerificationUtil.verifyEARDependency(earProject, ProjectUtil.createUtilityProject("TestUtil", earProject.getName()), false);
+    }
+}
diff --git a/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/jst/j2ee/dependency/tests/ProjectDependencyTests.java b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/jst/j2ee/dependency/tests/ProjectDependencyTests.java
new file mode 100644
index 0000000..a2b66f6
--- /dev/null
+++ b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/jst/j2ee/dependency/tests/ProjectDependencyTests.java
@@ -0,0 +1,87 @@
+package org.eclipse.jst.j2ee.dependency.tests;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jst.j2ee.dependency.tests.util.DependencyCreationUtil;
+import org.eclipse.jst.j2ee.dependency.tests.util.DependencyVerificationUtil;
+import org.eclipse.jst.j2ee.dependency.tests.util.ProjectUtil;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Tests project creation logic in the DependencyCreationUtil helper class.
+ */
+public class ProjectDependencyTests extends AbstractTests {
+	
+    private ProjectDependencyTests(final String name) {
+        super(name);
+    }
+    
+    public static Test suite(){
+        final TestSuite suite = new TestSuite();
+        suite.setName("Project Dependency Tests" );
+        suite.addTest(new ProjectDependencyTests("testEARWebDependency"));
+        suite.addTest(new ProjectDependencyTests("testEARDependencyRemoval"));
+        suite.addTest(new ProjectDependencyTests("testEARUtilDependency"));
+        suite.addTest(new ProjectDependencyTests("testEAREJBDependency"));
+        suite.addTest(new ProjectDependencyTests("testStandaloneWebUtilDependency"));
+        suite.addTest(new ProjectDependencyTests("testWebUtilWebInfLibDependency"));
+        suite.addTest(new ProjectDependencyTests("testWebEJBModuleDependency"));
+        return suite;
+    }
+    
+    public void testEARWebDependency() throws Exception {
+    	testEARDependency(ProjectUtil.createEARProject("TestEAR"),
+    			ProjectUtil.createWebProject("TestWeb", null), true);
+    }
+    
+    public void testEARDependencyRemoval() throws Exception {
+    	final IProject earProject = ProjectUtil.createEARProject("TestEAR");
+    	final IProject webProject = ProjectUtil.createWebProject("TestWeb", null);
+    	final String moduleURI = testEARDependency(earProject, webProject, true);
+    	DependencyCreationUtil.removeEARDependency(earProject, webProject);
+    	DependencyVerificationUtil.verifyEARDependencyRemoved(earProject, webProject, moduleURI);
+    }
+    
+    public void testEARUtilDependency() throws Exception {
+    	testEARDependency(ProjectUtil.createEARProject("TestEAR"),
+    			ProjectUtil.createUtilityProject("TestUtil", null), false);
+    }
+    
+    public void testEAREJBDependency() throws Exception {
+    	testEARDependency(ProjectUtil.createEARProject("TestEAR"),
+    			ProjectUtil.createEJBProject("TestEJB", null), true);
+    }
+    
+    private String testEARDependency(final IProject earProject, final IProject childProject, final boolean moduleRef) throws Exception {
+    	DependencyCreationUtil.createEARDependency(earProject, childProject);
+    	return DependencyVerificationUtil.verifyEARDependency(earProject, childProject, moduleRef);
+    }
+    
+    public void testStandaloneWebUtilDependency() throws Exception {
+    	final IProject saWeb =  ProjectUtil.createWebProject("TestWeb", null);
+    	final IProject util =  ProjectUtil.createUtilityProject("TestUtil", null);
+    	DependencyCreationUtil.createWebLibDependency(saWeb, util);
+    	DependencyVerificationUtil.verifyWebLibDependency(saWeb, util);
+    }
+    
+    public void testWebUtilWebInfLibDependency() throws Exception {
+    	final IProject web =  ProjectUtil.createWebProject("TestWeb", null);
+    	final IProject util =  ProjectUtil.createUtilityProject("TestUtil", null);
+    	final IProject ear = ProjectUtil.createEARProject("TestEAR");
+    	testEARDependency(ear, web, true);
+    	testEARDependency(ear, util, false);
+    	DependencyCreationUtil.createWebLibDependency(web, util);
+    	DependencyVerificationUtil.verifyWebLibDependency(web, util);
+    }
+    
+    public void testWebEJBModuleDependency() throws Exception {
+    	final IProject web =  ProjectUtil.createWebProject("TestWeb", null);
+    	final IProject ejb =  ProjectUtil.createEJBProject("TestEJB", null);
+    	final IProject ear = ProjectUtil.createEARProject("TestEAR");
+    	testEARDependency(ear, web, true);
+    	testEARDependency(ear, ejb, true);
+    	DependencyCreationUtil.createModuleDependency(web, ejb);
+    	DependencyVerificationUtil.verifyModuleDependency(web, ejb);	
+    }
+}
\ No newline at end of file
diff --git a/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/jst/j2ee/dependency/tests/ProjectEARRefactoringTests.java b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/jst/j2ee/dependency/tests/ProjectEARRefactoringTests.java
new file mode 100644
index 0000000..b42cf84
--- /dev/null
+++ b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/jst/j2ee/dependency/tests/ProjectEARRefactoringTests.java
@@ -0,0 +1,270 @@
+package org.eclipse.jst.j2ee.dependency.tests;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jst.j2ee.dependency.tests.util.DependencyCreationUtil;
+import org.eclipse.jst.j2ee.dependency.tests.util.DependencyUtil;
+import org.eclipse.jst.j2ee.dependency.tests.util.DependencyVerificationUtil;
+import org.eclipse.jst.j2ee.dependency.tests.util.ProjectUtil;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Tests the refactoring logic that handles rename/delete refactoring of EAR child
+ * projects. 
+ */
+public class ProjectEARRefactoringTests extends AbstractTests {
+	
+	public ProjectEARRefactoringTests(String name) {
+		super(name);
+	}
+	
+	public static Test suite(){
+        final TestSuite suite = new TestSuite();
+        suite.setName("Project EAR Refactoring Tests" );
+        suite.addTest(new ProjectEARRefactoringTests("testDeleteEARWebModule"));
+        // XXX this can fail
+        //suite.addTest(new ProjectEARRefactoringTests("testDeleteEARWebModuleWithValidation"));
+        suite.addTest(new ProjectEARRefactoringTests("testDeleteEARUtilModule"));        
+        suite.addTest(new ProjectEARRefactoringTests("testDeleteEAREJBModule"));
+        suite.addTest(new ProjectEARRefactoringTests("testRenameEARWebModule"));
+        suite.addTest(new ProjectEARRefactoringTests("testRenameEARUtilModule"));
+        suite.addTest(new ProjectEARRefactoringTests("testRenameEAREJBModule"));
+        suite.addTest(new ProjectEARRefactoringTests("testMultipleEARWebDelete"));
+        suite.addTest(new ProjectEARRefactoringTests("testMultipleEARWebRename"));
+        suite.addTest(new ProjectEARRefactoringTests("testMultipleEARUtilDelete"));
+        suite.addTest(new ProjectEARRefactoringTests("testMultipleEARUtilRename"));
+        suite.addTest(new ProjectEARRefactoringTests("testDeleteWithEARModuleDependency"));
+        suite.addTest(new ProjectEARRefactoringTests("testRenameWithMultipleEARModuleDependency"));
+        //suite.addTest(new ProjectEARRefactoringTests("testDependencyRemovalWithMultipleEARModuleDependency"));        
+        return suite;
+    }
+    
+	public void testDeleteEARWebModule() throws Exception {
+		DependencyUtil.disableValidation();
+		
+		final IProject earProject = ProjectUtil.getProject("TestEAR");
+		final IProject webProject = ProjectUtil.createWebProject("TestWeb", earProject.getName());
+		String moduleURI = DependencyVerificationUtil.verifyEARDependency(earProject, webProject, true);
+		
+		ProjectUtil.deleteProject(webProject);
+		
+		DependencyVerificationUtil.verifyEARDependencyRemoved(earProject, webProject, moduleURI);
+		
+		DependencyUtil.enableValidation();
+	}
+	
+	public void testDeleteEARWebModuleWithValidation() throws Exception {
+		final IProject earProject = ProjectUtil.getProject("TestEAR");
+		final IProject webProject = ProjectUtil.createWebProject("TestWeb", earProject.getName());
+		String moduleURI = DependencyVerificationUtil.verifyEARDependency(earProject, webProject, true);
+		ProjectUtil.deleteProject(webProject);
+		DependencyVerificationUtil.verifyEARDependencyRemoved(earProject, webProject, moduleURI);
+	}
+	
+	public void testDeleteEARUtilModule() throws Exception {
+		final IProject earProject = ProjectUtil.getProject("TestEAR");
+		final IProject utilProject = ProjectUtil.createUtilityProject("TestUtil", earProject.getName());
+		
+		DependencyVerificationUtil.verifyEARDependency(earProject, utilProject, false);
+		
+		ProjectUtil.deleteProject(utilProject);
+		
+		DependencyVerificationUtil.verifyEARDependencyRemoved(earProject, utilProject);	
+    }
+	
+	public void testDeleteEAREJBModule() throws Exception {
+		final IProject earProject = ProjectUtil.getProject("TestEAR");
+		final IProject ejbProject = ProjectUtil.createEJBProject("TestEJB", earProject.getName());
+		final IProject ejbClientProject = ProjectUtil.getProject("TestEJBClient");
+		String moduleURI = DependencyVerificationUtil.verifyEARDependency(earProject, ejbProject, true);
+		
+		DependencyVerificationUtil.verifyEARDependency(earProject, ejbClientProject, false);
+		DependencyVerificationUtil.verifyModuleDependency(ejbProject, ejbClientProject);
+		
+		ProjectUtil.deleteProject(ejbProject);
+		ProjectUtil.deleteProject(ejbClientProject);
+		
+		DependencyVerificationUtil.verifyEARDependencyRemoved(earProject, ejbProject, moduleURI);
+		DependencyVerificationUtil.verifyEARDependencyRemoved(earProject, ejbClientProject);
+    }
+	
+	public void testRenameEARWebModule() throws Exception {
+		DependencyUtil.disableValidation();
+
+		final IProject earProject = ProjectUtil.getProject("TestEAR");
+		final IProject webProject = ProjectUtil.createWebProject("TestWeb", earProject.getName());
+		String moduleURI = DependencyVerificationUtil.verifyEARDependency(earProject, webProject, true);
+		
+		ProjectUtil.deleteProject(webProject);
+		
+		DependencyVerificationUtil.verifyEARDependencyRemoved(earProject, webProject, moduleURI);
+		
+		DependencyUtil.enableValidation();
+	}
+	
+	public void testRenameEARUtilModule() throws Exception {
+		final IProject earProject = ProjectUtil.getProject("TestEAR");
+		final IProject utilProject = ProjectUtil.createUtilityProject("TestUtil", earProject.getName());
+		
+		DependencyVerificationUtil.verifyEARDependency(earProject, utilProject, false);
+		
+		final IProject newUtil = ProjectUtil.renameProject(utilProject, "newUtil");
+		
+		DependencyVerificationUtil.verifyEARDependencyChanged(earProject, utilProject, newUtil);	
+    }
+	
+	public void testRenameEAREJBModule() throws Exception {
+		final IProject earProject = ProjectUtil.getProject("TestEAR");
+		final IProject ejbProject = ProjectUtil.createEJBProject("TestEJB", earProject.getName());
+		final IProject ejbClientProject = ProjectUtil.getProject("TestEJBClient");
+		
+		String moduleURI = DependencyVerificationUtil.verifyEARDependency(earProject, ejbProject, true);
+		DependencyVerificationUtil.verifyEARDependency(earProject, ejbClientProject, false);
+		
+		final IProject newEJB = ProjectUtil.renameProject(ejbProject, "newEJB");
+		
+		DependencyVerificationUtil.verifyEARDependencyChanged(earProject, ejbProject, moduleURI, newEJB);
+		DependencyVerificationUtil.verifyModuleDependency(newEJB, ejbClientProject);
+    }
+	
+	public void testMultipleEARWebDelete() throws Exception {
+		DependencyUtil.disableValidation();
+
+		final IProject earProject1 = ProjectUtil.getProject("TestEAR1");
+		final IProject earProject2 = ProjectUtil.createEARProject("TestEAR2");
+		final IProject webProject = ProjectUtil.createWebProject("TestWeb", earProject1.getName());
+		DependencyCreationUtil.createEARDependency(earProject2, webProject);
+		
+		final String moduleURI1 = DependencyVerificationUtil.verifyEARDependency(earProject1, webProject, true);	
+		final String moduleURI2 = DependencyVerificationUtil.verifyEARDependency(earProject2, webProject, true);
+		
+		ProjectUtil.deleteProject(webProject);
+		
+		DependencyVerificationUtil.verifyEARDependencyRemoved(earProject1, webProject, moduleURI1);	
+		DependencyVerificationUtil.verifyEARDependencyRemoved(earProject2, webProject, moduleURI2);	
+		
+		DependencyUtil.enableValidation();
+	}
+	
+	public void testMultipleEARWebRename() throws Exception {
+		DependencyUtil.disableValidation();
+		
+		final IProject earProject1 = ProjectUtil.getProject("TestEAR1");
+		final IProject earProject2 = ProjectUtil.createEARProject("TestEAR2");
+		final IProject webProject = ProjectUtil.createWebProject("TestWeb", earProject1.getName());
+		DependencyCreationUtil.createEARDependency(earProject2, webProject);
+		
+		final String moduleURI1 = DependencyVerificationUtil.verifyEARDependency(earProject1, webProject, true);	
+		final String moduleURI2 = DependencyVerificationUtil.verifyEARDependency(earProject2, webProject, true);
+		
+		final IProject newWeb = ProjectUtil.renameProject(webProject, "newWeb");
+		
+		DependencyVerificationUtil.verifyEARDependencyChanged(earProject1, webProject, moduleURI1, newWeb);	
+		DependencyVerificationUtil.verifyEARDependencyChanged(earProject2, webProject, moduleURI2, newWeb);		
+
+		DependencyUtil.enableValidation();
+	}
+	
+	public void testMultipleEARUtilDelete() throws Exception {
+		final IProject earProject1 = ProjectUtil.getProject("TestEAR1");
+		final IProject earProject2 = ProjectUtil.createEARProject("TestEAR2");
+		final IProject utilProject = ProjectUtil.createUtilityProject("TestUtil", earProject1.getName());
+		DependencyCreationUtil.createEARDependency(earProject2, utilProject);
+		DependencyVerificationUtil.verifyEARDependency(earProject1, utilProject, false);	
+		DependencyVerificationUtil.verifyEARDependency(earProject2, utilProject, false);
+		ProjectUtil.deleteProject(utilProject);
+		DependencyVerificationUtil.verifyEARDependencyRemoved(earProject1, utilProject);	
+		DependencyVerificationUtil.verifyEARDependencyRemoved(earProject2, utilProject);		
+	}
+	
+	public void testMultipleEARUtilRename() throws Exception {
+		final IProject earProject1 = ProjectUtil.getProject("TestEAR1");
+		final IProject earProject2 = ProjectUtil.createEARProject("TestEAR2");
+		final IProject utilProject = ProjectUtil.createUtilityProject("TestUtil", earProject1.getName());
+		DependencyCreationUtil.createEARDependency(earProject2, utilProject);
+		DependencyVerificationUtil.verifyEARDependency(earProject1, utilProject, false);	
+		DependencyVerificationUtil.verifyEARDependency(earProject2, utilProject, false);
+		
+		final IProject newUtil= ProjectUtil.renameProject(utilProject, "newUtil");
+		
+		DependencyVerificationUtil.verifyEARDependencyChanged(earProject1, utilProject, newUtil);	
+		DependencyVerificationUtil.verifyEARDependencyChanged(earProject2, utilProject, newUtil);				
+	}
+	
+	public void testDeleteWithEARModuleDependency() throws Exception {
+		final IProject earProject = ProjectUtil.getProject("TestEAR");
+		final IProject utilProject = ProjectUtil.createUtilityProject("TestUtil", earProject.getName());
+		final IProject webProject = ProjectUtil.createWebProject("TestWeb", earProject.getName());
+		DependencyCreationUtil.createModuleDependency(webProject, utilProject);
+		DependencyVerificationUtil.verifyEARDependency(earProject, utilProject, false);	
+		DependencyVerificationUtil.verifyEARDependency(earProject, webProject, true);
+		DependencyVerificationUtil.verifyModuleDependency(webProject, utilProject);
+		
+		ProjectUtil.deleteProject(utilProject);
+		
+		DependencyVerificationUtil.verifyEARDependencyRemoved(earProject, utilProject);	
+		DependencyVerificationUtil.verifyModuleDependencyRemoved(webProject, utilProject);
+		DependencyVerificationUtil.verifyEARDependency(earProject, webProject, true);
+	}
+	
+	public void testRenameWithMultipleEARModuleDependency() throws Exception {
+		final IProject earProject1 = ProjectUtil.getProject("TestEAR1");
+		final IProject earProject2 = ProjectUtil.createEARProject("TestEAR2");
+		final IProject ejbProject = ProjectUtil.createEJBProject("TestEJB", earProject1.getName());
+		DependencyCreationUtil.createEARDependency(earProject2, ejbProject);
+		final IProject webProject1 = ProjectUtil.createWebProject("TestWeb1", earProject1.getName());
+		final IProject webProject2 = ProjectUtil.createWebProject("TestWeb2", earProject2.getName());
+		DependencyCreationUtil.createModuleDependency(webProject1, ejbProject);
+		DependencyCreationUtil.createWebLibDependency(webProject2, ejbProject);
+		
+		final String moduleURI1 = DependencyVerificationUtil.verifyEARDependency(earProject1, ejbProject, true);
+		final String moduleURI2 = DependencyVerificationUtil.verifyEARDependency(earProject2, ejbProject, true);	
+		DependencyVerificationUtil.verifyEARDependency(earProject1, webProject1, true);
+		DependencyVerificationUtil.verifyEARDependency(earProject2, webProject2, true);
+		DependencyVerificationUtil.verifyModuleDependency(webProject1, ejbProject);
+		DependencyVerificationUtil.verifyWebLibDependency(webProject2, ejbProject);
+		
+		IProject newEJB = ProjectUtil.renameProject(ejbProject, "newEJB");
+		
+		DependencyVerificationUtil.verifyEARDependencyChanged(earProject1, ejbProject, moduleURI1, newEJB);	
+		DependencyVerificationUtil.verifyEARDependencyChanged(earProject2, ejbProject, moduleURI2, newEJB);	
+		DependencyVerificationUtil.verifyModuleDependencyChanged(webProject1, ejbProject, newEJB);
+		DependencyVerificationUtil.verifyWebLibDependencyChanged(webProject2, ejbProject, newEJB);
+	}
+	
+	/* XXX only works through the UI right now
+	public void testDependencyRemovalWithMultipleEARModuleDependency() throws Exception {
+		final IProject earProject1 = ProjectUtil.getProject("TestEAR1");
+		final IProject earProject2 = ProjectUtil.createEARProject("TestEAR2");
+		final IProject utilProject = ProjectUtil.createUtilityProject("TestUtil", earProject1.getName());
+		DependencyCreationUtil.createEARDependency(earProject2, utilProject);
+		final IProject webProject1 = ProjectUtil.createWebProject("TestWeb1", earProject1.getName());
+		final IProject webProject2 = ProjectUtil.createWebProject("TestWeb2", earProject2.getName());
+		DependencyCreationUtil.createModuleDependency(webProject1, utilProject);
+		DependencyCreationUtil.createModuleDependency(webProject2, utilProject);
+		
+		// verify all of the dependencies
+		DependencyVerificationUtil.verifyEARDependency(earProject1, utilProject, false);
+		DependencyVerificationUtil.verifyEARDependency(earProject2, utilProject, false);	
+		DependencyVerificationUtil.verifyEARDependency(earProject1, webProject1, true);
+		DependencyVerificationUtil.verifyEARDependency(earProject2, webProject2, true);
+		DependencyVerificationUtil.verifyModuleDependency(webProject1, utilProject);
+		DependencyVerificationUtil.verifyModuleDependency(webProject2, utilProject);
+		
+		// remove the dependency between the util and just EAR1
+		DependencyCreationUtil.removeEARDependency(earProject1, utilProject);
+		
+		// verify the changed dependencies
+		DependencyVerificationUtil.verifyEARDependencyRemoved(earProject1, utilProject);
+		DependencyVerificationUtil.verifyModuleDependencyRemoved(webProject1, utilProject);
+		
+		// verify the dependencies that should be unchanged
+		DependencyVerificationUtil.verifyEARDependency(earProject1, webProject1, true);
+		DependencyVerificationUtil.verifyEARDependency(earProject2, webProject2, true);
+		DependencyVerificationUtil.verifyEARDependency(earProject2, utilProject, false);
+		DependencyVerificationUtil.verifyWebLibDependency(webProject2, utilProject);
+	}
+	*/
+	
+}
diff --git a/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/jst/j2ee/dependency/tests/ProjectModuleRefactoringTests.java b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/jst/j2ee/dependency/tests/ProjectModuleRefactoringTests.java
new file mode 100644
index 0000000..04a7a96
--- /dev/null
+++ b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/jst/j2ee/dependency/tests/ProjectModuleRefactoringTests.java
@@ -0,0 +1,124 @@
+package org.eclipse.jst.j2ee.dependency.tests;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jst.j2ee.dependency.tests.util.DependencyCreationUtil;
+import org.eclipse.jst.j2ee.dependency.tests.util.DependencyVerificationUtil;
+import org.eclipse.jst.j2ee.dependency.tests.util.ProjectUtil;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Tests the refactoring logic that handles rename/delete refactoring of projects that
+ * participate in inter-module dependencies.
+ */
+public class ProjectModuleRefactoringTests extends AbstractTests {
+	
+	public ProjectModuleRefactoringTests(String name) {
+		super(name);
+	}
+	
+	public static Test suite(){
+        final TestSuite suite = new TestSuite();
+        suite.setName("Project Module Dependency Refactoring Tests" );
+        suite.addTest(new ProjectModuleRefactoringTests("testDeleteModuleDependency"));
+        suite.addTest(new ProjectModuleRefactoringTests("testRenameModuleDependency"));
+        suite.addTest(new ProjectModuleRefactoringTests("testDeleteMultipleDependency"));
+        suite.addTest(new ProjectModuleRefactoringTests("testRenameMultipleModuleDependency"));
+        return suite;
+    }
+	
+	public void testDeleteModuleDependency() throws Exception {
+		final IProject[] projects = setupModuleDependency();
+		final IProject earProject = projects[0];
+		final IProject webProject = projects[1];
+		final IProject utilProject = projects[2];
+
+		ProjectUtil.deleteProject(utilProject);
+		
+		DependencyVerificationUtil.verifyEARDependencyRemoved(earProject, utilProject);	
+		DependencyVerificationUtil.verifyModuleDependencyRemoved(webProject, utilProject);
+    }
+
+	public void testRenameModuleDependency() throws Exception {
+		final IProject[] projects = setupModuleDependency();
+		final IProject earProject = projects[0];
+		final IProject webProject = projects[1];
+		final IProject utilProject = projects[2];
+		
+		final IProject newUtil = ProjectUtil.renameProject(utilProject, "newUtil");
+		
+		DependencyVerificationUtil.verifyEARDependencyChanged(earProject, utilProject, newUtil);	
+		DependencyVerificationUtil.verifyModuleDependencyChanged(webProject, utilProject, newUtil);
+    }
+
+	public void testDeleteMultipleDependency() throws Exception {
+		final IProject[] projects = setupMultipleDependency();
+		final IProject earProject1 = projects[0];
+		final IProject earProject2 = projects[1];
+		final IProject webProject = projects[2];
+		final IProject ejbProject = projects[3];
+		final IProject utilProject = projects[4];
+
+		ProjectUtil.deleteProject(utilProject);
+		
+		DependencyVerificationUtil.verifyEARDependencyRemoved(earProject1, utilProject);	
+		DependencyVerificationUtil.verifyEARDependencyRemoved(earProject2, utilProject);	
+		DependencyVerificationUtil.verifyModuleDependencyRemoved(webProject, utilProject);
+		DependencyVerificationUtil.verifyModuleDependencyRemoved(ejbProject, utilProject);
+	}
+	
+	public void testRenameMultipleModuleDependency() throws Exception {
+		final IProject[] projects = setupMultipleDependency();
+		final IProject earProject1 = projects[0];
+		final IProject earProject2 = projects[1];
+		final IProject webProject = projects[2];
+		final IProject ejbProject = projects[3];
+		final IProject utilProject = projects[4];
+
+		final IProject newUtil = ProjectUtil.renameProject(utilProject, "newUtil");
+		
+		DependencyVerificationUtil.verifyEARDependencyChanged(earProject1, utilProject, newUtil);
+		DependencyVerificationUtil.verifyEARDependencyChanged(earProject2, utilProject, newUtil);
+		DependencyVerificationUtil.verifyModuleDependencyChanged(webProject, utilProject, newUtil);
+		DependencyVerificationUtil.verifyModuleDependencyChanged(ejbProject, utilProject, newUtil);
+	}
+	
+	private static IProject[] setupModuleDependency() throws Exception {
+		final IProject earProject = ProjectUtil.getProject("TestEAR");
+		final IProject utilProject = ProjectUtil.createUtilityProject("TestUtil", earProject.getName());
+		final IProject webProject = ProjectUtil.createWebProject("TestWeb", earProject.getName());
+		DependencyCreationUtil.createModuleDependency(webProject, utilProject);
+		DependencyVerificationUtil.verifyEARDependency(earProject, utilProject, false);	
+		DependencyVerificationUtil.verifyEARDependency(earProject, webProject, true);
+		DependencyVerificationUtil.verifyModuleDependency(webProject, utilProject);	
+		return new IProject[] {earProject, webProject, utilProject};
+	}
+
+	private static IProject[] setupMultipleDependency() throws Exception {
+		// create the projects
+		final IProject earProject1 = ProjectUtil.getProject("TestEAR1");
+		final IProject earProject2 = ProjectUtil.createEARProject("TestEAR2");
+		final IProject utilProject = ProjectUtil.createUtilityProject("TestUtil", earProject1.getName());
+
+		// create the dependencies
+		DependencyCreationUtil.createEARDependency(earProject2, utilProject);
+		final IProject webProject = ProjectUtil.createWebProject("TestWeb", earProject1.getName());
+		final IProject ejbProject = ProjectUtil.createEJBProject("TestEJB", earProject2.getName());
+		final IProject ejbClientProject = ProjectUtil.getProject("TestEJBClient");
+		DependencyCreationUtil.createModuleDependency(webProject, utilProject);
+		DependencyCreationUtil.createModuleDependency(ejbProject, utilProject);
+
+		// verify the dependencies
+		DependencyVerificationUtil.verifyEARDependency(earProject1, utilProject, false);
+		DependencyVerificationUtil.verifyEARDependency(earProject1, webProject, true);
+		DependencyVerificationUtil.verifyEARDependency(earProject2, utilProject, false);
+		DependencyVerificationUtil.verifyEARDependency(earProject2, ejbProject, true);
+		DependencyVerificationUtil.verifyEARDependency(earProject2, ejbClientProject, false);
+		DependencyVerificationUtil.verifyModuleDependency(webProject, utilProject);	
+		DependencyVerificationUtil.verifyModuleDependency(ejbProject, utilProject);
+		
+		return new IProject[] {earProject1, earProject2, webProject, ejbProject, utilProject};
+	}
+
+}
diff --git a/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/jst/j2ee/dependency/tests/ProjectServerRefactoringTests.java b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/jst/j2ee/dependency/tests/ProjectServerRefactoringTests.java
new file mode 100644
index 0000000..32cdbbf
--- /dev/null
+++ b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/jst/j2ee/dependency/tests/ProjectServerRefactoringTests.java
@@ -0,0 +1,23 @@
+package org.eclipse.jst.j2ee.dependency.tests;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Tests refactoring logic that updates server instances when associated modules are
+ * renamed or deleted. 
+ */
+public class ProjectServerRefactoringTests extends AbstractTests {
+	
+	public ProjectServerRefactoringTests(String name) {
+		super(name);
+	}
+	
+	public static Test suite(){
+        final TestSuite suite = new TestSuite();
+        suite.setName("Project Server Refactoring Tests" );
+        //suite.addTest(new ProjectServerRefactoringTests("testEARWebDependency"));
+        return suite;
+    }
+
+}
diff --git a/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/jst/j2ee/dependency/tests/ProjectWebLibRefactoringTests.java b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/jst/j2ee/dependency/tests/ProjectWebLibRefactoringTests.java
new file mode 100644
index 0000000..dafa162
--- /dev/null
+++ b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/jst/j2ee/dependency/tests/ProjectWebLibRefactoringTests.java
@@ -0,0 +1,123 @@
+package org.eclipse.jst.j2ee.dependency.tests;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jst.j2ee.dependency.tests.util.DependencyCreationUtil;
+import org.eclipse.jst.j2ee.dependency.tests.util.DependencyVerificationUtil;
+import org.eclipse.jst.j2ee.dependency.tests.util.ProjectUtil;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Tests the refactoring logic that handles rename/delete refactoring of projects that
+ * participate in web-inf/lib module dependencies.
+ */
+public class ProjectWebLibRefactoringTests extends AbstractTests {
+	
+	public ProjectWebLibRefactoringTests(String name) {
+		super(name);
+	}
+	
+	public static Test suite(){
+        final TestSuite suite = new TestSuite();
+        suite.setName("Project WEB-INF/lib Dependency Refactoring Tests" );
+        suite.addTest(new ProjectWebLibRefactoringTests("testDeleteWebLibDependency"));
+        suite.addTest(new ProjectWebLibRefactoringTests("testRenameWebLibDependency"));
+        suite.addTest(new ProjectWebLibRefactoringTests("testDeleteMultipleDependency"));
+        suite.addTest(new ProjectWebLibRefactoringTests("testRenameMultipleModuleDependency"));
+        return suite;
+    }
+
+	public void testDeleteWebLibDependency() throws Exception {
+		final IProject[] projects = setupWebLibDependency();
+		final IProject earProject = projects[0];
+		final IProject webProject = projects[1];
+		final IProject utilProject = projects[2];
+		
+		ProjectUtil.deleteProject(utilProject);
+		
+		DependencyVerificationUtil.verifyEARDependencyRemoved(earProject, utilProject);	
+		DependencyVerificationUtil.verifyWebLibDependencyRemoved(webProject, utilProject);
+    }
+
+	public void testRenameWebLibDependency() throws Exception {
+		final IProject[] projects = setupWebLibDependency();
+		final IProject earProject = projects[0];
+		final IProject webProject = projects[1];
+		final IProject utilProject = projects[2];
+		
+		final IProject newUtil = ProjectUtil.renameProject(utilProject, "newUtil");
+		
+		DependencyVerificationUtil.verifyEARDependencyChanged(earProject, utilProject, newUtil);	
+		DependencyVerificationUtil.verifyWebLibDependencyChanged(webProject, utilProject, newUtil);
+    }
+	
+	public void testDeleteMultipleDependency() throws Exception {
+		final IProject[] projects = setupMultipleDependency();
+		final IProject earProject1 = projects[0];
+		final IProject earProject2 = projects[1];
+		final IProject webProject1 = projects[2];
+		final IProject webProject2 = projects[3];
+		final IProject utilProject = projects[4];
+
+		ProjectUtil.deleteProject(utilProject);
+		
+		DependencyVerificationUtil.verifyEARDependencyRemoved(earProject1, utilProject);	
+		DependencyVerificationUtil.verifyEARDependencyRemoved(earProject2, utilProject);	
+		DependencyVerificationUtil.verifyWebLibDependencyRemoved(webProject1, utilProject);
+		DependencyVerificationUtil.verifyWebLibDependencyRemoved(webProject2, utilProject);
+	}
+	
+	public void testRenameMultipleModuleDependency() throws Exception {
+		final IProject[] projects = setupMultipleDependency();
+		final IProject earProject1 = projects[0];
+		final IProject earProject2 = projects[1];
+		final IProject webProject1 = projects[2];
+		final IProject webProject2 = projects[3];
+		final IProject utilProject = projects[4];
+
+		final IProject newUtil = ProjectUtil.renameProject(utilProject, "newUtil");
+		
+		DependencyVerificationUtil.verifyEARDependencyChanged(earProject1, utilProject, newUtil);
+		DependencyVerificationUtil.verifyEARDependencyChanged(earProject2, utilProject, newUtil);
+		DependencyVerificationUtil.verifyWebLibDependencyChanged(webProject1, utilProject, newUtil);
+		DependencyVerificationUtil.verifyWebLibDependencyChanged(webProject2, utilProject, newUtil);
+	}
+	
+	private static IProject[] setupWebLibDependency() throws Exception {
+		final IProject earProject = ProjectUtil.getProject("TestEAR");
+		final IProject utilProject = ProjectUtil.createUtilityProject("TestUtil", earProject.getName());
+		final IProject webProject = ProjectUtil.createWebProject("TestWeb", earProject.getName());
+		DependencyCreationUtil.createWebLibDependency(webProject, utilProject);
+		DependencyVerificationUtil.verifyEARDependency(earProject, utilProject, false);	
+		DependencyVerificationUtil.verifyEARDependency(earProject, webProject, true);
+		DependencyVerificationUtil.verifyWebLibDependency(webProject, utilProject);
+		return new IProject[] {earProject, webProject, utilProject};
+	}
+	
+	private static IProject[] setupMultipleDependency() throws Exception {
+		// create the projects
+		final IProject earProject1 = ProjectUtil.getProject("TestEAR1");
+		final IProject earProject2 = ProjectUtil.createEARProject("TestEAR2");
+		final IProject utilProject = ProjectUtil.createUtilityProject("TestUtil", earProject1.getName());
+
+		// create the dependencies
+		DependencyCreationUtil.createEARDependency(earProject2, utilProject);
+		final IProject webProject1 = ProjectUtil.createWebProject("TestWeb1", earProject1.getName());
+		final IProject webProject2 = ProjectUtil.createWebProject("TestWeb2", earProject2.getName());
+
+		DependencyCreationUtil.createWebLibDependency(webProject1, utilProject);
+		DependencyCreationUtil.createWebLibDependency(webProject2, utilProject);
+
+		// verify the dependencies
+		DependencyVerificationUtil.verifyEARDependency(earProject1, utilProject, false);
+		DependencyVerificationUtil.verifyEARDependency(earProject1, webProject1, true);
+		DependencyVerificationUtil.verifyEARDependency(earProject2, utilProject, false);
+		DependencyVerificationUtil.verifyEARDependency(earProject2, webProject2, true);
+		DependencyVerificationUtil.verifyWebLibDependency(webProject1, utilProject);	
+		DependencyVerificationUtil.verifyWebLibDependency(webProject2, utilProject);	
+		
+		return new IProject[] {earProject1, earProject2, webProject1, webProject2, utilProject};
+	}
+
+}
diff --git a/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/jst/j2ee/dependency/tests/util/DependencyCreationUtil.java b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/jst/j2ee/dependency/tests/util/DependencyCreationUtil.java
new file mode 100644
index 0000000..bbcb326
--- /dev/null
+++ b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/jst/j2ee/dependency/tests/util/DependencyCreationUtil.java
@@ -0,0 +1,122 @@
+package org.eclipse.jst.j2ee.dependency.tests.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.jar.Manifest;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jst.j2ee.application.internal.operations.AddComponentToEnterpriseApplicationDataModelProvider;
+import org.eclipse.jst.j2ee.application.internal.operations.RemoveComponentFromEnterpriseApplicationDataModelProvider;
+import org.eclipse.jst.j2ee.application.internal.operations.UpdateManifestDataModelProperties;
+import org.eclipse.jst.j2ee.application.internal.operations.UpdateManifestDataModelProvider;
+import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveManifest;
+import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveManifestImpl;
+import org.eclipse.jst.j2ee.internal.J2EEConstants;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.datamodel.properties.ICreateReferenceComponentsDataModelProperties;
+import org.eclipse.wst.common.componentcore.internal.operation.CreateReferenceComponentsDataModelProvider;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.componentcore.resources.IVirtualFile;
+import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+
+/**
+ * Test utility class that programmatically creates J2EE dependencies. 
+ */
+public class DependencyCreationUtil {
+	
+	public static void createEARDependency(final IProject earProject, final IProject childProject) throws ExecutionException {
+		final IDataModel dm = DataModelFactory.createDataModel(new AddComponentToEnterpriseApplicationDataModelProvider());
+		IVirtualComponent earComp = ComponentCore.createComponent(earProject);
+		IVirtualComponent childComp = ComponentCore.createComponent(childProject);
+		dm.setProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT, earComp); 
+		final List depList = new ArrayList();
+		depList.add(childComp);
+		dm.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST, depList);
+		dm.getDefaultOperation().execute(null, null);
+	}
+	
+	public static void removeEARDependency(final IProject earProject, final IProject childProject) throws ExecutionException {
+		final IDataModel dm = DataModelFactory.createDataModel(new RemoveComponentFromEnterpriseApplicationDataModelProvider());
+		IVirtualComponent earComp = ComponentCore.createComponent(earProject);
+		IVirtualComponent childComp = ComponentCore.createComponent(childProject);
+		dm.setProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT, earComp); 
+		final List depList = new ArrayList();
+		depList.add(childComp);
+		dm.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST, depList);
+		dm.getDefaultOperation().execute(null, null);
+	}
+
+	public static void createModuleDependency(final IProject source, final IProject target) throws ExecutionException, CoreException, IOException {
+		createProjectDependency(source, target, false);
+	}
+	
+	public static void createWebLibDependency(final IProject source, final IProject target) throws ExecutionException, CoreException, IOException {
+		createProjectDependency(source, target, true);
+	}
+	
+	private static void createProjectDependency(final IProject source, final IProject target, final boolean webLibDep) throws ExecutionException, CoreException, IOException {
+		IVirtualComponent sourceComp = ComponentCore.createComponent(source);
+		IVirtualComponent targetComp = ComponentCore.createComponent(target);
+		if (webLibDep) {
+			// add component and project refs
+			final IDataModel refdm = DataModelFactory.createDataModel(new CreateReferenceComponentsDataModelProvider());
+			final List targetCompList = (List) refdm.getProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST);
+			targetCompList.add(targetComp);
+			refdm.setProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT, sourceComp);
+			refdm.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST, targetCompList);
+			refdm.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_DEPLOY_PATH,"/WEB-INF/lib"); //$NON-NLS-1$
+			refdm.getDefaultOperation().execute(null, null);
+		} else {
+			// just add a manifest ref
+			final IVirtualComponent dependentComp = sourceComp;
+			final String dependentProjName = source.getName();
+			final String refactoredProjName = target.getName();
+			final IVirtualFile vf = dependentComp.getRootFolder().getFile(new Path(J2EEConstants.MANIFEST_URI) );
+			final IFile manifestmf = vf.getUnderlyingFile();
+			final IProgressMonitor monitor = new NullProgressMonitor();
+			final IDataModel updateManifestDataModel = DataModelFactory.createDataModel(new UpdateManifestDataModelProvider());
+			updateManifestDataModel.setProperty(UpdateManifestDataModelProperties.PROJECT_NAME, dependentProjName);
+			updateManifestDataModel.setBooleanProperty(UpdateManifestDataModelProperties.MERGE, false);
+			updateManifestDataModel.setProperty(UpdateManifestDataModelProperties.MANIFEST_FILE, manifestmf);
+			final ArchiveManifest manifest = getArchiveManifest(manifestmf);
+			String[] cp = manifest.getClassPathTokenized();
+			List cpList = new ArrayList();
+			String newCp = refactoredProjName + ".jar";//$NON-NLS-1$
+			for (int i = 0; i < cp.length; i++) {
+				if (!cp[i].equals(newCp)) {
+					cpList.add(cp[i]);
+				}
+			}
+			cpList.add(newCp);
+			updateManifestDataModel.setProperty(UpdateManifestDataModelProperties.JAR_LIST, cpList);
+			updateManifestDataModel.getDefaultOperation().execute(monitor, null );
+		
+		}
+	}
+	
+	public static ArchiveManifest getArchiveManifest(final IFile manifestFile) throws CoreException, IOException {
+		InputStream in = null;
+		try {
+			in = manifestFile.getContents();
+			ArchiveManifest mf = new ArchiveManifestImpl(new Manifest(in));
+			return mf;
+		} finally {
+			if (in != null) {
+				try {
+					in.close();
+				} catch (IOException weTried) {
+					//Ignore
+				}
+			}
+		}
+	}
+}
diff --git a/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/jst/j2ee/dependency/tests/util/DependencyUtil.java b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/jst/j2ee/dependency/tests/util/DependencyUtil.java
new file mode 100644
index 0000000..7081c8d
--- /dev/null
+++ b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/jst/j2ee/dependency/tests/util/DependencyUtil.java
@@ -0,0 +1,215 @@
+package org.eclipse.jst.j2ee.dependency.tests.util;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Assert;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+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.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.jobs.IJobManager;
+import org.eclipse.core.runtime.jobs.Job;
+
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jst.j2ee.internal.J2EEConstants;
+import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
+import org.eclipse.jst.j2ee.refactor.listeners.J2EEElementChangedListener;
+import org.eclipse.jst.j2ee.refactor.listeners.ProjectRefactoringListener;
+
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
+import org.eclipse.wst.common.tests.OperationTestCase;
+import org.eclipse.wst.common.tests.ProjectUtility;
+import org.eclipse.wst.validation.internal.ConfigurationManager;
+import org.eclipse.wst.validation.internal.GlobalConfiguration;
+
+/**
+ * Various utility methods.
+ */
+public class DependencyUtil {
+	
+	public static final IWorkspace ws = ResourcesPlugin.getWorkspace();
+	
+	/**
+	 * Retrieves a unique name.
+	 * @param prefix
+	 * @return
+	 */
+	public static String getUniqueName(final String prefix) {
+		return prefix + System.currentTimeMillis();
+	}
+	
+	public static void waitForValidationJobs() {
+		// Wait for all validation jobs to end
+		final IJobManager jobMgr = Platform.getJobManager();
+		IProject[] projects = ProjectUtility.getAllProjects();
+		for (int i = 0; i < projects.length; i++) {
+			final IProject p = projects[i];
+			final String family = p.getName() + OperationTestCase.VALIDATOR_JOB_FAMILY;
+			final Job[] jobs = jobMgr.find(family);
+			if (jobs.length > 0) {
+				try {
+					Platform.getJobManager().join(family, null);
+				} catch (InterruptedException ie) {
+				}
+			}
+		}
+	}
+	
+	public static void waitForProjectRefactoringJobs() {
+		waitForJobs(ProjectRefactoringListener.PROJECT_REFACTORING_JOB_FAMILY);
+	}
+		
+	public static void waitForComponentRefactoringJobs() {
+		waitForJobs(J2EEElementChangedListener.PROJECT_COMPONENT_UPDATE_JOB_FAMILY);
+	}
+	
+	/**
+	 * Waits for jobs in the specified family
+	 * @param family
+	 */
+	public static void waitForJobs(final String family) {
+		final IJobManager jobMgr = Platform.getJobManager();
+		for (int i = 0; i < 5; i++) {
+			final Job[] jobs = jobMgr.find(family);
+			//System.out.println("Number of refactoring jobs: " + jobs.length);
+			if (jobs.length > 0) {
+				try {
+					jobMgr.join(family, null);
+				} catch (InterruptedException ie) {
+				}
+				break;
+			}
+			try {
+				Thread.sleep(100);
+			} catch (InterruptedException ie) {
+			}
+		}
+	}
+
+	 /**
+     * Disables all validators (if this is not done, getting error deleting/renaming projects
+     * because one of the validators is holding onto web.xml)
+     */
+    public static void disableValidation() throws InvocationTargetException {
+    	disableValidation(true);
+    }
+    
+    public static void enableValidation() throws InvocationTargetException {
+    	disableValidation(false);
+    }
+    
+    private static void disableValidation(final boolean disabled) throws InvocationTargetException {
+    	final GlobalConfiguration config = new GlobalConfiguration(ConfigurationManager.getManager().getGlobalConfiguration());
+    	config.setDisableAllValidation(disabled);
+    	config.passivate();
+    	config.store();
+	}
+    
+    /**
+     * Adds a Java source path
+     * @param path project relative path.
+     * @throws CoreException
+     */
+    public static boolean addJavaSrcPath(final IProject project, final IPath path) throws CoreException {
+    	final IFolder folder = project.getFolder(path);
+    	if (!folder.exists()) {
+    		folder.create(true, true, null);
+    	}
+    	final IJavaProject jProject = JavaCore.create(project);
+    	final IPath absolutePath = project.getFullPath().append(path);
+    	final IClasspathEntry entry = JavaCore.newSourceEntry(absolutePath);
+    	IClasspathEntry[] cp = jProject.getRawClasspath();
+    	final List cpList = new ArrayList();
+    	boolean hasEntry = false;
+    	for (int i = 0; i < cp.length; i++) {
+    		final IClasspathEntry cpe = cp[i];
+    		if (cpe.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
+    			if (cpe.getPath().equals(absolutePath)) {
+    				hasEntry = true;
+    				break;
+    			}
+    		}
+    		cpList.add(cp[i]);
+    	}
+    	if (!hasEntry) {
+    		cpList.add(entry);
+        	cp = (IClasspathEntry[]) cpList.toArray(new IClasspathEntry[cpList.size()]);
+        	jProject.setRawClasspath(cp, null);
+        	waitForComponentRefactoringJobs();
+        	return true;
+    	}
+    	return false;
+    }
+    
+    /**
+     * Adds a Java source path
+     * @param path project relative path.
+     * @throws CoreException
+     */
+    public static boolean removeJavaSrcPath(final IProject project, final IPath path) throws CoreException {
+    	final IJavaProject jProject = JavaCore.create(project);
+    	final IPath absolutePath = project.getFullPath().append(path);
+    	IClasspathEntry[] cp = jProject.getRawClasspath();
+    	final List cpList = new ArrayList();
+    	boolean removedEntry = false;
+    	for (int i = 0; i < cp.length; i++) {
+    		final IClasspathEntry cpe = cp[i];
+    		if (cpe.getEntryKind() != IClasspathEntry.CPE_SOURCE 
+    				|| !cpe.getPath().equals(absolutePath)) {
+    			cpList.add(cp[i]);
+    		} else {
+    			removedEntry = true;
+    		}
+    	}
+    	if (removedEntry) {
+    		cp = (IClasspathEntry[]) cpList.toArray(new IClasspathEntry[cpList.size()]);
+    		jProject.setRawClasspath(cp, null);
+        	waitForComponentRefactoringJobs();
+        	return true;
+    	}
+    	return false;
+    }
+    
+    /**
+     * Verifies the existence (or absence) of the specified component path mapping.
+     * @param project
+     * @param projectPath
+     * @param runtimePath
+     * @param exists
+     * @throws CoreException
+     */
+    public static void verifyComponentMapping(final IProject project, final IPath projectPath, final boolean exists) throws CoreException {
+    	final IVirtualComponent c = ComponentCore.createComponent(project);
+    	c.create(0, null);
+    	IVirtualFolder dest = c.getRootFolder();
+    	if (J2EEProjectUtilities.isDynamicWebProject(project)) {
+    		// web projects map to WEB-INF/classes
+    		dest = dest.getFolder(new Path(J2EEConstants.WEB_INF_CLASSES));
+    	}
+    	IContainer[] mappedFolders = dest.getUnderlyingFolders();
+    	boolean hasMapping = false;
+    	for (int i = 0; i < mappedFolders.length; i++) {
+    		if (mappedFolders[i].getProjectRelativePath().equals(projectPath)) {
+    			hasMapping = true;
+    			break;
+    		}
+    	}
+    	if (exists) {
+    		Assert.assertTrue("Component mapping from " + projectPath + " to " + dest.toString() + " missing", hasMapping);
+    	} else { 
+    		Assert.assertFalse("Component mapping from " + projectPath + " to " + dest.toString() + " should not exist", hasMapping);
+    	}
+    }
+}
diff --git a/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/jst/j2ee/dependency/tests/util/DependencyVerificationUtil.java b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/jst/j2ee/dependency/tests/util/DependencyVerificationUtil.java
new file mode 100644
index 0000000..5be3f2c
--- /dev/null
+++ b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/jst/j2ee/dependency/tests/util/DependencyVerificationUtil.java
@@ -0,0 +1,287 @@
+package org.eclipse.jst.j2ee.dependency.tests.util;
+
+import java.io.IOException;
+
+import junit.framework.Assert;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jst.j2ee.application.Application;
+import org.eclipse.jst.j2ee.application.Module;
+import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveManifest;
+import org.eclipse.jst.j2ee.componentcore.util.EARArtifactEdit;
+import org.eclipse.jst.j2ee.internal.J2EEConstants;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.internal.builder.DependencyGraphManager;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.componentcore.resources.IVirtualFile;
+import org.eclipse.wst.common.componentcore.resources.IVirtualReference;
+
+/**
+ * Test utility class that programmatically verifies J2EE dependencies. 
+ */
+public class DependencyVerificationUtil {
+	
+	public static final IPath WEB_INF_LIB = new Path("/WEB-INF/lib"); //$NON-NLS-1$
+	public static final IPath ROOT = new Path("/"); //$NON-NLS-1$
+	
+	/**
+	 * Verifies the presence (or lack) of dependency between two projects as defined by the
+	 * DependencyManager.
+	 * @param source Source project
+	 * @param target Target project
+	 * @param hasDep True if a dependency should exist; false if not.
+	 * @throws Exception
+	 */
+	public static void verifyDependency(final IProject source, final IProject target, final boolean hasDep) {
+		IProject[] referencingProjects  = DependencyGraphManager.getInstance().getDependencyGraph().getReferencingComponents(target);
+		boolean dep = false;
+		for (int i = 0; i < referencingProjects.length; i++) {
+			if (referencingProjects[i].equals(source)) {
+				dep= true;
+				break;
+			}
+		}
+		if (hasDep) {
+			Assert.assertTrue("DependencyGraphManager does not report dependency between " + source + " and " + target, dep);
+		} else {
+			Assert.assertFalse("DependencyGraphManager incorrectly reporting dependency between " + source + " and " + target, dep);
+		}		
+	}
+	
+	/**
+	 * Verifies the presence (or lack) of a component reference between two projects.
+	 * @param source Source project
+	 * @param target Target project
+	 * @param runtimePath Runtime path of target project; null to not check path.
+	 * @param hasRef True if a component reference should exist; false if not.
+	 * @throws Exception
+	 */
+	public static void verifyComponentReference(final IProject source, final IProject target, final IPath runtimePath, final boolean hasRef) {
+		IVirtualComponent sourceComp = ComponentCore.createComponent(source);
+		IVirtualReference[] refs = sourceComp.getReferences();
+		boolean ref = false;
+		for (int i = 0; i < refs.length; i++) {
+			if (refs[i].getReferencedComponent().getProject().equals(target)) {
+				if (runtimePath == null || refs[i].getRuntimePath().equals(runtimePath)) {
+					ref = true;
+					break;
+				}
+			}
+		}
+		if (hasRef) {
+			Assert.assertTrue("Source project " + source + " missing component reference to " + target, ref);
+		} else {
+			Assert.assertFalse("Source project " + source + " still has component reference to " + target, ref);			
+		}
+	}
+	
+	/**
+	 * Verifies the presence (or lack) or a static project reference between two projects.
+	 * @param source Source project.
+	 * @param target Target project.
+	 * @param hasRef True if a project reference should exist; false if not.
+	 * @throws Exception
+	 */
+	public static void verifyProjectReference(final IProject source, final IProject target, final boolean hasRef) throws CoreException {
+		final IProjectDescription desc = source.getDescription();
+		IProject[] refs = desc.getReferencedProjects();
+		boolean ref = false;
+		for (int i = 0; i < refs.length; i++) {
+			if (refs[i].equals(target)) {
+				ref = true;
+				break;
+			}
+		}
+		if (hasRef) {
+			Assert.assertTrue("Source project " + source + " missing project reference to " + target, ref);
+		} else {
+			Assert.assertFalse("Source project " + source + " still has project reference to " + target, ref);			
+		}
+	}
+	
+	/**
+	 * Verifies the presence (or lack) of the specified MANIFEST.MF entry.
+	 * @param source Source project
+	 * @param entry Manifest entry.
+	 * @param hasEntry True if the entry should exist, false if not.
+	 * @throws Exception
+	 */
+	public static void verifyManifestReference(final IProject source, final String entry, final boolean hasEntry) throws CoreException, IOException {
+		final IVirtualComponent sourceComp = ComponentCore.createComponent(source);
+		final IVirtualFile vf = sourceComp.getRootFolder().getFile(new Path(J2EEConstants.MANIFEST_URI) );
+		final IFile manifestmf = vf.getUnderlyingFile();
+		final ArchiveManifest manifest = DependencyCreationUtil.getArchiveManifest(manifestmf);
+		String[] cp = manifest.getClassPathTokenized();
+		boolean hasManifestRef = false;
+		for (int i = 0; i < cp.length; i++) {
+			if (cp[i].equals(entry)) {
+				hasManifestRef = true;
+			}
+		}
+		if (hasEntry) {
+			Assert.assertTrue("Source project " + source + " missing MANIFEST.MF entry " + entry, hasManifestRef);
+		} else {
+			Assert.assertFalse("Source project " + source + " still has MANIFEST.MF entry " + entry, hasManifestRef);			
+		}
+	}
+	
+	/**
+	 * Verifies the presence of an application.xml reference in the specified EAR project for the
+	 * specified module project.
+	 * @param earProject The EAR project.
+	 * @param moduleProject The module project.
+	 * @param moduleURI Ignored unless hasRef is false.
+	 * @param hasRef True if there should be a ref, false if not
+	 * @return Computed module URI or null if one was passed in.
+	 * @throws Exception
+	 */
+	public static String verifyApplicationXMLReference(final IProject earProject, final IProject moduleProject, final String moduleURI, final boolean hasRef) throws CoreException {
+		EARArtifactEdit earEdit = null;
+		try {
+			earEdit = EARArtifactEdit.getEARArtifactEditForRead(earProject);
+			Assert.assertTrue(earEdit != null);
+			Application application = earEdit.getApplication();
+			if (hasRef) {
+				IVirtualComponent moduleComp = ComponentCore.createComponent(moduleProject);
+				String computedURI = earEdit.getModuleURI(moduleComp);
+				Assert.assertTrue("EAR's application.xml missing module element for " + moduleURI, 
+						application.getFirstModule(computedURI) != null);
+				return computedURI;
+			} else {
+				Module module = application.getFirstModule(moduleURI);
+				Assert.assertTrue("EAR's application.xml should not have a module element for " + moduleURI, 
+						module == null);
+			}
+		} finally {
+			if (earEdit != null)
+				earEdit.dispose();
+		}
+		return null;
+	}
+	
+	/**
+	 * Verifies that the specified target project is visible (or not visible) to the source project via the Java build path 
+	 * @param source Source project.
+	 * @param target Target project.
+	 * @param hasRef True if the target project should be on the resolved classpath, false if not.
+	 * @throws Exception
+	 */
+	public static void verifyClasspathReference(final IProject source, final IProject target, final boolean hasRef) throws CoreException {
+		IJavaProject javaProject = JavaCore.create(source);
+		IClasspathEntry[] cp = javaProject.getResolvedClasspath(true); // ignore unresolvable entries
+		boolean onClasspath = false;
+		for (int i = 0; i < cp.length; i++) {
+			if (cp[i].getEntryKind() == IClasspathEntry.CPE_PROJECT 
+					&& cp[i].getPath().equals(target.getFullPath())) {
+				onClasspath= true;
+				break;
+			}
+		}
+		if (hasRef) {
+			Assert.assertTrue("Project " + target + " missing from resolved classpath of project " + source, onClasspath);
+		} else {
+			Assert.assertFalse("Project " + target + " should not be on resolved classpath of project " + source, onClasspath);
+		}	
+	}
+	
+	public static String verifyEARDependency(final IProject earProject, final IProject childProject, final boolean moduleRef) throws CoreException {
+		// .project dep
+		verifyProjectReference(earProject, childProject, true);
+		// .component dep
+		verifyComponentReference(earProject, childProject, ROOT, true);
+		// application.xml ref
+		String moduleURI = null;
+		if (moduleRef) {
+			moduleURI = verifyApplicationXMLReference(earProject, childProject, null, true);
+		}
+		// DependencyGraphManager
+		verifyDependency(earProject, childProject, true);
+		
+		return moduleURI;
+	}
+
+	public static void verifyEARDependencyChanged(final IProject earProject, final IProject oldChildProject, final IProject newChildProject) throws CoreException {
+		verifyEARDependencyChanged(earProject, oldChildProject, null, newChildProject);
+	}
+	
+	public static void verifyEARDependencyChanged(final IProject earProject, final IProject oldChildProject, final String oldModuleURI, final IProject newChildProject) throws CoreException {
+		verifyEARDependency(earProject, newChildProject, oldModuleURI != null);
+		verifyEARDependencyRemoved(earProject, oldChildProject, oldModuleURI);
+	}
+	
+	public static void verifyEARDependencyRemoved(final IProject earProject, final IProject childProject) throws CoreException {
+		verifyEARDependencyRemoved(earProject, childProject, null);
+	}
+	
+	public static void verifyEARDependencyRemoved(final IProject earProject, final IProject childProject, final String oldModuleURI) throws CoreException {
+		// .component dep
+		verifyComponentReference(earProject, childProject, ROOT, false);
+		// application.xml ref
+		if (oldModuleURI != null) {
+			verifyApplicationXMLReference(earProject, childProject, oldModuleURI, false);			
+		}
+		// DependencyGraphManager
+		verifyDependency(earProject, childProject, false);
+		// .project dep
+		verifyProjectReference(earProject, childProject, false);
+	}
+	
+	public static void verifyModuleDependency(final IProject source, final IProject target) throws CoreException, IOException {
+		// verify MANIFEST.MF dep added
+		verifyManifestReference(source, target.getName() + ".jar", true); //$NON-NLS-1$
+		// verify classpath ref (will be via "EAR Libraries")
+		verifyClasspathReference(source, target, true);
+		// DependencyGraphManager
+		verifyDependency(source, target, true);
+	}
+	
+	public static void verifyModuleDependencyChanged(final IProject source, final IProject oldTarget, final IProject newTarget) throws CoreException, IOException {
+		verifyModuleDependency(source, newTarget);
+		verifyModuleDependencyRemoved(source, oldTarget);
+	}
+	
+	public static void verifyModuleDependencyRemoved(final IProject source, final IProject target) throws CoreException, IOException {
+		// verify MANIFEST.MF dep removed
+		verifyManifestReference(source, target.getName()+ ".jar", false);
+		// verify classpath ref removed 
+		verifyClasspathReference(source, target, false);
+		// DependencyGraphManager
+		verifyDependency(source, target, false);
+	}
+	
+	public static void verifyWebLibDependency(final IProject source, final IProject target) throws CoreException {
+		// .project dep
+		verifyProjectReference(source, target, true);
+		// .component dep
+		verifyComponentReference(source, target, WEB_INF_LIB, true);
+		// verify classpath ref (will be via "EAR Libraries")
+		verifyClasspathReference(source, target, true);
+		// DependencyGraphManager
+		verifyDependency(source, target, true);
+	}
+	
+	public static void verifyWebLibDependencyChanged(final IProject source, final IProject oldTarget, final IProject newTarget) throws CoreException {
+		verifyWebLibDependency(source, newTarget);
+		verifyWebLibDependencyRemoved(source, oldTarget);
+	}
+	
+	public static void verifyWebLibDependencyRemoved(final IProject source, final IProject target) throws CoreException {
+		// verify changed .project dep
+		verifyProjectReference(source, target, false);
+		// .component dep
+		verifyComponentReference(source, target, WEB_INF_LIB, false);
+		// verify classpath ref removed 
+		verifyClasspathReference(source, target, false);
+		// DependencyGraphManager
+		verifyDependency(source, target, false);
+	}
+	
+}
diff --git a/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/jst/j2ee/dependency/tests/util/ProjectUtil.java b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/jst/j2ee/dependency/tests/util/ProjectUtil.java
new file mode 100644
index 0000000..cc1d4c1
--- /dev/null
+++ b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/jst/j2ee/dependency/tests/util/ProjectUtil.java
@@ -0,0 +1,189 @@
+package org.eclipse.jst.j2ee.dependency.tests.util;
+
+import junit.framework.Assert;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+import org.eclipse.jst.j2ee.internal.ejb.project.operations.EjbFacetProjectCreationDataModelProvider;
+import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
+import org.eclipse.jst.j2ee.internal.web.archive.operations.WebFacetProjectCreationDataModelProvider;
+import org.eclipse.jst.j2ee.project.facet.EARFacetProjectCreationDataModelProvider;
+import org.eclipse.jst.j2ee.project.facet.IJ2EEModuleFacetInstallDataModelProperties;
+import org.eclipse.jst.j2ee.project.facet.UtilityProjectCreationDataModelProvider;
+
+import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties;
+import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties.FacetDataModelMap;
+import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.tests.OperationTestCase;
+
+/**
+ * Test utility class that contains code for manipulating projects.
+ * DO NOT verify dependencies between EAR and module projects.
+ */
+public class ProjectUtil {
+	
+	public static final IWorkspace ws = ResourcesPlugin.getWorkspace();
+
+	/**
+	 * Gets the project for the given name. Does not test for existence.
+	 * @param name
+	 * @return
+	 */
+	public static IProject getProject(final String name) {
+		return ws.getRoot().getProject(name);
+	}
+
+	/**
+	 * Deletes the specified project if it exists and waits for all refactoring
+	 * jobs.
+	 */
+	public static void deleteProject(final IProject project)
+	throws CoreException, InterruptedException {
+		if (!project.exists()) {
+			return;
+		}
+
+		IWorkspaceRunnable workspaceRunnable = new IWorkspaceRunnable() {
+			public void run(IProgressMonitor pm) throws CoreException {
+				project.delete(true, null);
+			}
+		};
+		
+		//waitForValidationJobs();
+		ResourcesPlugin.getWorkspace().run(workspaceRunnable, null);
+		DependencyUtil.waitForProjectRefactoringJobs();
+	}
+
+	/**
+	 * Renames the specified project if it exists and waits for all refactoring
+	 * jobs.
+	 * @param project
+	 * @param newName
+	 * @return Renamed project.
+	 */
+	public static IProject renameProject(final IProject project, final String newName) 
+	throws CoreException, InterruptedException {
+		final IProject newProject = getProject(newName);
+		Assert.assertFalse("Cannot rename project " + project + ", a project already exists with name " + newName, newProject.exists());
+		Assert.assertTrue("Project " + project + " does not exist, cannot rename.", project.exists());
+		
+		IWorkspaceRunnable workspaceRunnable = new IWorkspaceRunnable() {
+			public void run(IProgressMonitor pm) throws CoreException {
+				project.move(newProject.getFullPath(), true, null);
+			}
+		};
+		
+		//waitForValidationJobs();
+		ResourcesPlugin.getWorkspace().run(workspaceRunnable, null);
+		DependencyUtil.waitForProjectRefactoringJobs();
+
+		return newProject;
+	}
+	
+	/**
+	 * Creates an EAR project.
+	 * @param name EAR name.
+	 * @return The EAR project.
+	 * @throws Exception
+	 */
+	public static IProject createEARProject(final String name) throws Exception {
+		final IDataModel dataModel = getEARCreationDataModel(name);
+		return createAndVerify(dataModel, name, J2EEProjectUtilities.ENTERPRISE_APPLICATION, null);
+    }
+	
+	/**
+	 * Creates a web project with optional EAR association.
+	 * @param name Web name.
+	 * @param earName EAR name; null for no EAR association.
+	 * @return The Web project.
+	 * @throws Exception
+	 */
+	public static IProject createWebProject(final String name, final String earName) throws Exception {
+		final IDataModel dataModel = getWebCreationDataModel(name, earName);
+		return createAndVerify(dataModel, name, J2EEProjectUtilities.DYNAMIC_WEB, earName);
+    }
+	
+	/**
+	 * Creates a Utility project with optional EAR association.
+	 * @param name Util name.
+	 * @param earName EAR name; null for no EAR association.
+	 * @return The utility project.
+	 * @throws Exception
+	 */
+	public static IProject createUtilityProject(final String name, final String earName) throws Exception {
+		final IDataModel dataModel = getUtilityCreationDataModel(name, earName);
+		return createAndVerify(dataModel, name, J2EEProjectUtilities.UTILITY, earName);
+	}
+	
+	/**
+	 * Creates an EJB project with optional EAR association.
+	 * @param name EJB name.
+	 * @param earName EAR name; null for no EAR association.
+	 * @return The EJB project.
+	 * @throws Exception
+	 */
+	public static IProject createEJBProject(final String name, final String earName) throws Exception {
+		final IDataModel dataModel = getEJBCreationDataModel(name, earName);
+		return createAndVerify(dataModel, name, J2EEProjectUtilities.EJB, earName);
+	}
+
+	private static IDataModel getEARCreationDataModel(final String name) {
+		final IDataModel model =  DataModelFactory.createDataModel(new EARFacetProjectCreationDataModelProvider());
+		configure(model, name, J2EEProjectUtilities.ENTERPRISE_APPLICATION, null);
+		return model;
+	}
+
+	
+	private static IDataModel getWebCreationDataModel(final String name, final String earName) {
+		final IDataModel model =  DataModelFactory.createDataModel(new WebFacetProjectCreationDataModelProvider());
+		configure(model, name, J2EEProjectUtilities.DYNAMIC_WEB, earName);
+		return model;
+	}
+		
+	private static IDataModel getUtilityCreationDataModel(final String name, final String earName) {
+		final IDataModel model =  DataModelFactory.createDataModel(new UtilityProjectCreationDataModelProvider());
+		configure(model, name, J2EEProjectUtilities.UTILITY, earName);
+		return model;
+	}
+	
+	private static IDataModel getEJBCreationDataModel(final String name, final String earName) {
+		final IDataModel model =  DataModelFactory.createDataModel(new EjbFacetProjectCreationDataModelProvider());
+		configure(model, name, J2EEProjectUtilities.EJB, earName);
+		return model;
+	}
+	
+	private static void configure(final IDataModel model, final String name, final String facet, final String earName) {
+		model.setProperty(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME, name);		
+		if (earName != null) {
+			final FacetDataModelMap map = (FacetDataModelMap) model.getProperty(IFacetProjectCreationDataModelProperties.FACET_DM_MAP);
+			final IDataModel facetDM = map.getFacetDataModel(facet);
+			facetDM.setBooleanProperty(IJ2EEModuleFacetInstallDataModelProperties.ADD_TO_EAR, true);
+			facetDM.setProperty(IJ2EEModuleFacetInstallDataModelProperties.EAR_PROJECT_NAME, earName);
+		}
+	}
+
+	private static IProject createAndVerify(final IDataModel model, final String projectName, final String type, final String earName) throws Exception {
+		// run the data model operation to create the projects
+		OperationTestCase.runAndVerify(model,false,true, true);
+		// verify the EAR (if one was created)
+	    verifyProject(earName, J2EEProjectUtilities.ENTERPRISE_APPLICATION);
+	    // verify the module project
+	    return verifyProject(projectName, type);
+	}
+	
+	private static IProject verifyProject(final String projectName, final String type) {
+		if (projectName != null) {
+            final IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+            Assert.assertTrue("Failed to create project " + projectName, project.exists());
+            Assert.assertTrue("Project not is of type " + type, J2EEProjectUtilities.isProjectOfType(project, type));
+            return project;
+        }	
+		return null;
+	}
+}
diff --git a/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/wtp/j2ee/headless/tests/plugin/AllPluginTests.java b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/wtp/j2ee/headless/tests/plugin/AllPluginTests.java
index 41e935d..6135f4e 100644
--- a/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/wtp/j2ee/headless/tests/plugin/AllPluginTests.java
+++ b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/wtp/j2ee/headless/tests/plugin/AllPluginTests.java
@@ -42,6 +42,7 @@
 	      addTest(org.eclipse.jst.j2ee.tests.modulecore.AllTests.suite());
 	      addTest(ProjectMigrationTest.suite());
 	      addTest(AnnotationProviderTest.suite());
+	      addTest(org.eclipse.jst.j2ee.dependency.tests.AllTests.suite());
     }
     
     public static IRuntime createJONASRuntime()  {
diff --git a/tests/org.eclipse.jst.j2ee.tests/plugin.xml b/tests/org.eclipse.jst.j2ee.tests/plugin.xml
index 155109d..a0bdde3 100644
--- a/tests/org.eclipse.jst.j2ee.tests/plugin.xml
+++ b/tests/org.eclipse.jst.j2ee.tests/plugin.xml
@@ -39,6 +39,7 @@
       <import plugin="org.eclipse.wst.common.project.facet.core"/>
       <import plugin="org.eclipse.jst.server.core"/>
       <import plugin="org.eclipse.jst.common.annotations.core"/>
+      <import plugin="org.eclipse.wst.validation"/>
    </requires>
    <extension
          point="org.eclipse.wst.common.tests.collector.suites">