[153301] updated test for web deployables
diff --git a/tests/org.eclipse.jst.j2ee.tests/TestData/WebDeployTests/WebDeployTest.zip b/tests/org.eclipse.jst.j2ee.tests/TestData/WebDeployTests/WebDeployTest.zip new file mode 100644 index 0000000..2504ebc --- /dev/null +++ b/tests/org.eclipse.jst.j2ee.tests/TestData/WebDeployTests/WebDeployTest.zip Binary files differ
diff --git a/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/jst/j2ee/flexible/project/fvtests/WebDeployTest.java b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/jst/j2ee/flexible/project/fvtests/WebDeployTest.java new file mode 100644 index 0000000..e9779fa --- /dev/null +++ b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/jst/j2ee/flexible/project/fvtests/WebDeployTest.java
@@ -0,0 +1,99 @@ +package org.eclipse.jst.j2ee.flexible.project.fvtests; + +import java.io.IOException; +import java.net.URL; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +import org.eclipse.core.resources.IProject; +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.etools.common.test.apitools.ProjectUnzipUtil; +import org.eclipse.jem.util.emf.workbench.ProjectUtilities; +import org.eclipse.jst.j2ee.internal.deployables.J2EEFlexProjDeployable; +import org.eclipse.wst.common.componentcore.ComponentCore; +import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; +import org.eclipse.wst.server.core.IModule; +import org.eclipse.wst.server.core.internal.ModuleFolder; +import org.eclipse.wst.server.core.model.IModuleResource; +import org.eclipse.wtp.j2ee.headless.tests.plugin.HeadlessTestsPlugin; + +public class WebDeployTest extends TestCase { + + private static String[] projectNames = new String[]{"TestDeploy","TestDeployUtil","TestDeployWeb","TestWebLibProject"}; //$NON-NLS-1$; + private static Path zipFilePath = new Path("/TestData/WebDeployTests/WebDeployTest.zip"); //$NON-NLS-1$ + + public static Test suite() { + return new TestSuite(WebDeployTest.class); + } + public void testMembersDeployment() { + ProjectUnzipUtil util = new ProjectUnzipUtil(getLocalPath(), projectNames); + util.createProjects(); + //hari: we're getting the web project here + IProject project = ProjectUtilities.getProject(projectNames[2]); + IVirtualComponent component = ComponentCore.createComponent(project); + J2EEFlexProjDeployable deployable = new J2EEFlexProjDeployable(project, component); + try { + IModuleResource[] members = deployable.members(); + assertTrue(members.length==2); + + for (int i=0; i<members.length; i++) { + String name = members[i].getName(); + if (name.equals("META-INF")) { + IModuleResource manifest = ((ModuleFolder)members[i]).members()[0]; + assertTrue(manifest.getModuleRelativePath().toString().equals("META-INF")); + assertTrue(manifest.getName().equals("MANIFEST.MF")); + + } else if (name.equals("WEB-INF")) { + IModuleResource[] webInf = ((ModuleFolder)members[i]).members(); + assertTrue(webInf.length==3); + for (int j=0; j<webInf.length; j++) { + IModuleResource webResource = webInf[j]; + assertTrue(webResource.getModuleRelativePath().toString().equals("WEB-INF")); + if (webResource.getName().equals("lib")){ + IModuleResource[] webresMembers = ((ModuleFolder)webResource).members(); + {//finds only smokeEJB.jar here... + assertTrue(webresMembers.length==1); + //Check that the names match the 3 names we expect + for (int k = 0; k < webresMembers.length; k++) + assertTrue (webresMembers[k].getName().equals("SmokeEJB.jar") ); + } + } + } + } + } + //assertTrue(verified==3); + +// get child modules on the deployable - that should return the utility module that was in the ear - it should have only testdeployutil jar + //Hari: need to make sure we need to be looking for the ear project + + IModule[] childModules = deployable.getChildModules(); + assertTrue(childModules.length==3); + for (int l = 0; l < childModules.length; l++){ + //Hari: need to check to see these are the right modules to check for + assertTrue(childModules[l].getName().equals("TestDeployUtil") || childModules[l].getName().equals("lib/TestDeploy/customerEjb.jar") || childModules[l].getName().equals("TestWebLibProject")); + } + + } catch (CoreException e) { + e.printStackTrace(); + fail(e.getMessage()); + } + + + + } + + private static IPath getLocalPath() { + URL url = HeadlessTestsPlugin.getDefault().find(zipFilePath); + try { + url = Platform.asLocalURL(url); + } catch (IOException e) { + e.printStackTrace(); + } + return new Path(url.getPath()); + } +}
diff --git a/tests/org.eclipse.jst.j2ee.tests/webmodule-tests/org/eclipse/wtp/j2ee/headless/tests/web/operations/AllTests.java b/tests/org.eclipse.jst.j2ee.tests/webmodule-tests/org/eclipse/wtp/j2ee/headless/tests/web/operations/AllTests.java index 7c724c0..54c4974 100644 --- a/tests/org.eclipse.jst.j2ee.tests/webmodule-tests/org/eclipse/wtp/j2ee/headless/tests/web/operations/AllTests.java +++ b/tests/org.eclipse.jst.j2ee.tests/webmodule-tests/org/eclipse/wtp/j2ee/headless/tests/web/operations/AllTests.java
@@ -10,7 +10,7 @@ import junit.framework.TestSuite; import org.eclipse.core.runtime.Path; -import org.eclipse.jst.j2ee.flexible.project.fvtests.J2EEFlexProjDeployablePerfTest; +import org.eclipse.jst.j2ee.flexible.project.fvtests.WebDeployTest; import org.eclipse.wst.server.core.IRuntime; import org.eclipse.wst.server.core.IRuntimeType; import org.eclipse.wst.server.core.IRuntimeWorkingCopy; @@ -38,7 +38,7 @@ addTest(WebImportOperationTest.suite()); addTest(WebExportOperationTest.suite()); addTest(WebProjectCreationOperationTest.suite()); - addTest(J2EEFlexProjDeployablePerfTest.suite()); + addTest(WebDeployTest.suite()); //addTest(StaticWebProjectCreationOperationTest.suite()); addTest(AddServletOperationTest.suite()); // addTest(WebComponentCreationTest.suite());