diff options
Diffstat (limited to 'tests')
14 files changed, 691 insertions, 139 deletions
diff --git a/tests/org.eclipse.jst.ws.tests/META-INF/MANIFEST.MF b/tests/org.eclipse.jst.ws.tests/META-INF/MANIFEST.MF new file mode 100644 index 000000000..0c5c25da6 --- /dev/null +++ b/tests/org.eclipse.jst.ws.tests/META-INF/MANIFEST.MF @@ -0,0 +1,38 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Java Web Services Tools Tests +Bundle-SymbolicName: org.eclipse.jst.ws.tests +Bundle-Version: 1.0.0 +Bundle-ClassPath: tests.jar +Bundle-Activator: org.eclipse.jst.ws.tests.plugin.TestsPlugin +Bundle-Vendor: IBM +Bundle-Localization: plugin +Export-Package: org.eclipse.jst.ws.tests, + org.eclipse.jst.ws.tests.axis.tomcat.v50, + org.eclipse.jst.ws.tests.plugin, + org.eclipse.jst.ws.tests.unittest, + org.eclipse.jst.ws.tests.util +Require-Bundle: org.eclipse.jst.ws.consumption.ui, + org.eclipse.jst.ws.consumption, + org.eclipse.jst.ws.ui, + org.eclipse.jst.ws, + org.eclipse.wst.command.env.core, + org.eclipse.wst.command.env.ui, + org.eclipse.wst.command.env, + org.eclipse.jst.server.tomcat.core, + org.eclipse.jst.j2ee.core, + org.eclipse.jst.j2ee, + org.eclipse.jst.j2ee.web, + org.eclipse.wst.common.emfworkbench.integration, + org.eclipse.wst.common.emf, + org.eclipse.wst.common.frameworks, + org.eclipse.core.runtime, + org.eclipse.core.resources, + org.eclipse.jdt.launching, + org.eclipse.jdt.core, + org.junit, + org.eclipse.wst.ws.ui, + org.eclipse.ui, + org.eclipse.debug.core, + org.eclipse.wst.server.core +Eclipse-AutoStart: true diff --git a/tests/org.eclipse.jst.ws.tests/build.properties b/tests/org.eclipse.jst.ws.tests/build.properties index b2eac8cba..b1d6c6892 100644 --- a/tests/org.eclipse.jst.ws.tests/build.properties +++ b/tests/org.eclipse.jst.ws.tests/build.properties @@ -2,7 +2,9 @@ bin.includes = build.xml,\ data/,\ plugin.xml,\ readme.txt,\ - tests.jar + tests.jar,\ + META-INF/,\ + test.xml jars.compile.order = tests.jar source.tests.jar = tests/ output.tests.jar = bin/ diff --git a/tests/org.eclipse.jst.ws.tests/plugin.xml b/tests/org.eclipse.jst.ws.tests/plugin.xml index 283a2d8d5..7bf65fb5f 100644 --- a/tests/org.eclipse.jst.ws.tests/plugin.xml +++ b/tests/org.eclipse.jst.ws.tests/plugin.xml @@ -1,42 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <?eclipse version="3.0"?> -<plugin - id="org.eclipse.jst.ws.tests" - name="Java Web Services Tools Tests" - version="1.0.0" - provider-name="IBM" - class="org.eclipse.jst.ws.tests.plugin.TestsPlugin"> - - <runtime> - <library name="tests.jar"> - <export name="*"/> - </library> - </runtime> - - <requires> - <import plugin="org.eclipse.jst.ws.consumption.ui"/> - <import plugin="org.eclipse.jst.ws.consumption"/> - <import plugin="org.eclipse.jst.ws.ui"/> - <import plugin="org.eclipse.jst.ws"/> - <import plugin="org.eclipse.wst.command.env.core"/> - <import plugin="org.eclipse.wst.command.env.ui"/> - <import plugin="org.eclipse.wst.command.env"/> - <import plugin="org.eclipse.jst.server.tomcat.core"/> - <import plugin="org.eclipse.jst.j2ee.core"/> - <import plugin="org.eclipse.jst.j2ee"/> - <import plugin="org.eclipse.jst.j2ee.web"/> - <import plugin="org.eclipse.wst.common.emfworkbench.integration"/> - <import plugin="org.eclipse.wst.common.emf"/> - <import plugin="org.eclipse.wst.common.frameworks"/> - <import plugin="org.eclipse.core.runtime"/> - <import plugin="org.eclipse.core.resources"/> - <import plugin="org.eclipse.jdt.launching"/> - <import plugin="org.eclipse.jdt.core"/> - <import plugin="org.junit"/> - <import plugin="org.eclipse.wst.ws.ui"/> - <import plugin="org.eclipse.ui"/> - <import plugin="org.eclipse.debug.core"/> - <import plugin="org.eclipse.wst.server.core"/> - </requires> +<plugin> + </plugin> diff --git a/tests/org.eclipse.jst.ws.tests/test.xml b/tests/org.eclipse.jst.ws.tests/test.xml new file mode 100644 index 000000000..74162bfa1 --- /dev/null +++ b/tests/org.eclipse.jst.ws.tests/test.xml @@ -0,0 +1,51 @@ +<?xml version="1.0"?> + +<project name="testsuite" default="run" basedir="."> + <!-- The property ${eclipse-home} should be passed into this script --> + <!-- Set a meaningful default value for when it is not. --> + <!-- <property name="eclipse-home" value="${basedir}\..\.."/> --> + <echo message="basedir ${basedir}" /> + <echo message="eclipse place ${eclipse-home}" /> + <!-- sets the properties plugin-name, and library-file --> + <property name="plugin-name" value="org.eclipse.jst.ws.tests"/> + <property name="library-file" value="${eclipse-home}/plugins/org.eclipse.test_3.1.0/library.xml"/> + <property name="extraVMargs" value="-Dorg.eclipse.jst.server.tomcat.50=${testDir}/${tomcat50Dir}"/> + + <!-- This target holds all initialization code that needs to be done for --> + <!-- all tests that are to be run. Initialization for individual tests --> + <!-- should be done within the body of the suite target. --> + <target name="init"> + <tstamp/> + <delete> + <fileset dir="${eclipse-home}" includes="org*.xml"/> + </delete> + </target> + + <!-- This target defines the tests that need to be run. --> + <target name="suite"> + <property name="jst-ws-folder" value="${eclipse-home}/jst_ws_folder"/> + <delete dir="${jst-folder}" quiet="true"/> + <ant target="core-test" antfile="${library-file}" dir="${eclipse-home}"> + <property name="data-dir" value="${jst-ws-folder}"/> + <property name="plugin-name" value="${plugin-name}"/> + <property name="classname" value="org.eclipse.jst.ws.tests.unittest.AllWSJUnitTests" /> + <property name="plugin-path" value="${eclipse-home}/plugins/${plugin-name}"/> + <property name="extraVMargs" value="${extraVMargs}"/> + </ant> + </target> + + <!-- This target holds code to cleanup the testing environment after --> + <!-- after all of the tests have been run. You can use this target to --> + <!-- delete temporary files that have been created. --> + <target name="cleanup"> + </target> + + <!-- This target runs the test suite. Any actions that need to happen --> + <!-- after all the tests have been run should go here. --> + <target name="run" depends="init,suite,cleanup"> + <ant target="collect" antfile="${library-file}" dir="${eclipse-home}"> + <property name="includes" value="org*.xml"/> + <property name="output-file" value="${plugin-name}.xml"/> + </ant> + </target> +</project> diff --git a/tests/org.eclipse.jst.ws.tests/tests/org/eclipse/jst/ws/tests/WSWizardTest.java b/tests/org.eclipse.jst.ws.tests/tests/org/eclipse/jst/ws/tests/WSWizardTest.java index 815a3ed3a..e79a5048d 100644 --- a/tests/org.eclipse.jst.ws.tests/tests/org/eclipse/jst/ws/tests/WSWizardTest.java +++ b/tests/org.eclipse.jst.ws.tests/tests/org/eclipse/jst/ws/tests/WSWizardTest.java @@ -123,9 +123,9 @@ public abstract class WSWizardTest extends TestCase protected void tearDown() throws Exception { stopServer(); - deleteServer(); - deleteInputData(); - deleteServerRuntime(); +// deleteServer(); +// deleteInputData(); +// deleteServerRuntime(); } /** @@ -141,7 +141,7 @@ public abstract class WSWizardTest extends TestCase protected void stopServer() throws Exception { if (server_ != null && server_.getServerState() == IServer.STATE_STARTED) - server_.synchronousStop(true); + server_.stop(true); assertTrue(server_.getServerState() == IServer.STATE_STOPPED); } @@ -151,10 +151,8 @@ public abstract class WSWizardTest extends TestCase */ protected void deleteServer() throws Exception { - if (server_ != null) { - server_.getServerConfiguration().delete(true, null); + if (server_ != null) server_.delete(); - } } /** @@ -164,7 +162,7 @@ public abstract class WSWizardTest extends TestCase protected void deleteServerRuntime() throws Exception { if (serverRuntime_ != null) - serverRuntime_.delete(); + serverRuntime_.delete(); } /** diff --git a/tests/org.eclipse.jst.ws.tests/tests/org/eclipse/jst/ws/tests/unittest/AllWSJUnitTests.java b/tests/org.eclipse.jst.ws.tests/tests/org/eclipse/jst/ws/tests/unittest/AllWSJUnitTests.java new file mode 100644 index 000000000..d1ffc2c9e --- /dev/null +++ b/tests/org.eclipse.jst.ws.tests/tests/org/eclipse/jst/ws/tests/unittest/AllWSJUnitTests.java @@ -0,0 +1,91 @@ +package org.eclipse.jst.ws.tests.unittest; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestResult; +import junit.framework.TestSuite; +import junit.textui.TestRunner; + +/** + * This class is to run all the unittest tests. + */ +public class AllWSJUnitTests extends TestCase +{ + /** + * Method parseArgs. + * + * @param args + */ + private void parseArgs(Object args) + { + // typicially args is an array of strings, + // not sure when it wouldn't be. + } + + public static void main(String[] args) + { + new AllWSJUnitTests().runMain(args); + } + + public Object runMain(Object args) + { + Object result = null; + try + { + TestRunner testRunner = null; + + parseArgs(args); + + testRunner = new TestRunner(System.out); + + + Test suite = suite(); + TestResult testResult = testRunner.doRun(suite, false); + printHeader(testResult); + } + catch (Exception e) + { + result = e; + } + + return result; + } + + public static Test suite() + { + TestSuite testSuite = new TestSuite(); + testSuite.addTest( ComponentCreationTests.suite() ); + testSuite.addTest( J2EEUtilsTests.suite() ); + testSuite.addTest( ServerCreationTests.suite()); + // testSuite.addTest( ResourceUtilsTests.suite() ); + + + return testSuite; + } + + /** + * Prints the header of the report + */ + protected void printHeader(TestResult result) + { + if (result.wasSuccessful()) + { + System.out.println(); + System.out.print("OK"); + System.out.println(" (" + result.runCount() + " tests)"); + + } + else + { + System.out.println(); + System.out.println("FAILURES!!!"); + System.out.println( + "Tests run: " + + result.runCount() + + ", Failures: " + + result.failureCount() + + ", Errors: " + + result.errorCount()); + } + } +} diff --git a/tests/org.eclipse.jst.ws.tests/tests/org/eclipse/jst/ws/tests/unittest/ComponentCreationTests.java b/tests/org.eclipse.jst.ws.tests/tests/org/eclipse/jst/ws/tests/unittest/ComponentCreationTests.java new file mode 100644 index 000000000..5e2ebe456 --- /dev/null +++ b/tests/org.eclipse.jst.ws.tests/tests/org/eclipse/jst/ws/tests/unittest/ComponentCreationTests.java @@ -0,0 +1,112 @@ +/** + * + */ +package org.eclipse.jst.ws.tests.unittest; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +import org.eclipse.core.resources.IProject; +import org.eclipse.jst.j2ee.internal.J2EEVersionConstants; +import org.eclipse.jst.ws.internal.common.ResourceUtils; +import org.eclipse.jst.ws.internal.consumption.command.common.CreateModuleCommand; +import org.eclipse.jst.ws.tests.util.JUnitUtils; +import org.eclipse.wst.common.componentcore.ComponentCore; +import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; + +/** + * Tests the various Component creation commands + */ +public class ComponentCreationTests extends TestCase implements WSJUnitConstants { + + public static Test suite(){ + return new TestSuite(ComponentCreationTests.class); + } + + public void testWebComponentCreation(){ + + createServerRuntime(); + createWebModule(webProjectName, webComponentName, J2EEVersionConstants.J2EE_1_4_ID); + createWebModule(webProjectName, webComponent2Name, J2EEVersionConstants.J2EE_1_3_ID); + + createWebModule(webProject2Name, webComp3Name, J2EEVersionConstants.J2EE_1_3_ID); + createWebModule(webProject2Name, webComp4Name, J2EEVersionConstants.J2EE_1_3_ID); + + } + + + public void createServerRuntime(){ + + try { + JUnitUtils.createServerRuntime(RUNTIMETYPEID_TC50, SERVER_INSTALL_PATH); + } + catch(Exception e){ + e.printStackTrace(); + } + + } + + private void createWebModule(String projectName, String componentName, int j2eeVersion){ + + CreateModuleCommand cmc = new CreateModuleCommand(); + cmc.setJ2eeLevel(new Integer(j2eeVersion).toString()); + cmc.setModuleName(componentName); + cmc.setModuleType(CreateModuleCommand.WEB); + cmc.setProjectName(projectName); + cmc.setServerFactoryId(SERVERTYPEID_TC50); + cmc.execute(null); + + System.out.println("Done creating Web component..."); + IProject p = ResourceUtils.getWorkspaceRoot().getProject(projectName); + IVirtualComponent vc = ComponentCore.createComponent(p, componentName); + assertTrue(vc.exists()); + + } + + public void testCreateEJBModule(){ + + CreateModuleCommand cmc = new CreateModuleCommand(); + cmc.setJ2eeLevel(new Integer(J2EEVersionConstants.J2EE_1_3_ID).toString()); + cmc.setModuleName(ejbComponentName); + cmc.setModuleType(CreateModuleCommand.EJB); + cmc.setProjectName(ejbProjectName); + cmc.setServerFactoryId(SERVERTYPEID_TC50); + cmc.execute(null); + + System.out.println("Done creating EJB component."); + IProject p = ResourceUtils.getWorkspaceRoot().getProject(ejbProjectName); + IVirtualComponent vc = ComponentCore.createComponent(p, ejbComponentName); + assertTrue(vc.exists()); + } + + public void testCreateAppClientModule(){ + CreateModuleCommand cmc = new CreateModuleCommand(); + cmc.setJ2eeLevel(new Integer(J2EEVersionConstants.J2EE_1_3_ID).toString()); + cmc.setModuleName(appClientCompName); + cmc.setModuleType(CreateModuleCommand.APPCLIENT); + cmc.setProjectName(appClientProjectName); + cmc.setServerFactoryId(SERVERTYPEID_TC50); + cmc.execute(null); + + System.out.println("Done creating App client component."); + IProject p = ResourceUtils.getWorkspaceRoot().getProject(appClientProjectName); + IVirtualComponent vc = ComponentCore.createComponent(p, appClientCompName); + assertTrue(vc.exists()); + } + + public void testCreateEARModule(){ + CreateModuleCommand cmc = new CreateModuleCommand(); + cmc.setJ2eeLevel(new Integer(J2EEVersionConstants.J2EE_1_3_ID).toString()); + cmc.setModuleName(earCompName); + cmc.setModuleType(CreateModuleCommand.EAR); + cmc.setProjectName(webProjectName); + cmc.setServerFactoryId(SERVERTYPEID_TC50); + cmc.execute(null); + + System.out.println("Done creating EAR component."); + IProject p = ResourceUtils.getWorkspaceRoot().getProject(webProjectName); + IVirtualComponent vc = ComponentCore.createComponent(p, earCompName); + assertTrue(vc.exists()); + } +} diff --git a/tests/org.eclipse.jst.ws.tests/tests/org/eclipse/jst/ws/tests/unittest/J2EEUtilsTests.java b/tests/org.eclipse.jst.ws.tests/tests/org/eclipse/jst/ws/tests/unittest/J2EEUtilsTests.java new file mode 100644 index 000000000..cd44d1b5b --- /dev/null +++ b/tests/org.eclipse.jst.ws.tests/tests/org/eclipse/jst/ws/tests/unittest/J2EEUtilsTests.java @@ -0,0 +1,214 @@ +/** + * + */ +package org.eclipse.jst.ws.tests.unittest; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IPath; +import org.eclipse.jem.util.emf.workbench.ProjectUtilities; +import org.eclipse.jst.j2ee.internal.J2EEVersionConstants; +import org.eclipse.jst.ws.internal.common.J2EEUtils; +import org.eclipse.jst.ws.internal.common.ResourceUtils; +import org.eclipse.jst.ws.internal.consumption.command.common.AssociateModuleWithEARCommand; +import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; + +/** + * @author sengpl + * + */ +public class J2EEUtilsTests extends TestCase implements WSJUnitConstants{ + + private IProject project1 = null; + private IProject project2 = null; + private IProject ejbProject = null; + + private String comp1 = webComponentName; + private String comp2 = webComponent2Name; + private String comp3 = webComp3Name; + private String comp4 = webComp4Name; + + protected void setUp() throws Exception { + super.setUp(); + + // Project and component names initialized here! + project1 = ProjectUtilities.getProject(webProjectName); + assertNotNull(project1); + + project2 = ProjectUtilities.getProject(webProject2Name); + assertNotNull(project2); + + ejbProject = ProjectUtilities.getProject(ejbProjectName); + assertNotNull(ejbProject); + + } + + protected void tearDown() throws Exception { + super.tearDown(); + // TODO Clear the workspace + + } + + public static Test suite() + { + return new TestSuite(J2EEUtilsTests.class); + } + + public void testComponentsExist(){ + System.out.println("< BEGIN: testComponentExists ..."); + IVirtualComponent vc1 = J2EEUtils.getVirtualComponent(project1, comp1); + IVirtualComponent vc2 = J2EEUtils.getVirtualComponent(project2.getName(), comp3); + + assertTrue(vc1.exists()); + assertTrue(J2EEUtils.exists(project1, comp1)); + assertTrue(vc2.exists()); + assertTrue(J2EEUtils.exists(project2.getName(), comp3)); + System.out.println("< END: testComponentExists ..."); + } + + public void testLocationGetterMethods(){ + + System.out.println("< BEGIN: testLocationGetterMethods ..."); + IPath loc1 = J2EEUtils.getWebContentPath(project1,comp1); + System.out.println("WebContentPath of comp1 = "+loc1); + IResource res = ResourceUtils.getWorkspaceRoot().findMember(loc1); + assertTrue(res.exists()); + assertTrue(res.toString().endsWith("WebContent")); + + IPath loc2 = J2EEUtils.getWebContentPath(project2,comp3); + System.out.println("WebContentPath of comp1 = "+loc2); + IResource res2 = ResourceUtils.getWorkspaceRoot().findMember(loc2); + assertTrue(res2.exists()); + assertTrue(res2.toString().endsWith("WebContent")); + + IPath loc3 = J2EEUtils.getWebInfPath(project1, comp2); + System.out.println("Web-INF path = "+loc3); + IResource res3 = ResourceUtils.getWorkspaceRoot().findMember(loc3); + assertTrue(res3.exists()); + assertTrue(res3.toString().endsWith("WEB-INF")); + + IContainer container = J2EEUtils.getWebContentContainer(project2, comp3); + IResource res4 = ResourceUtils.getWorkspaceRoot().findMember(container.getFullPath()); + assertEquals(res2, res4); + + System.out.println("< END: testLocationGetterMethods ..."); + + } + + public void testJ2EEVersionMethods(){ + + System.out.println("< BEGIN: testJ2EEVersionMethods ..."); + + int j1 = J2EEUtils.getJ2EEVersion(project2, comp4); + + IVirtualComponent vc2 = J2EEUtils.getVirtualComponent(project1, comp2); + int j2 = J2EEUtils.getJ2EEVersion(vc2); + System.out.println("J2EEVersions p1: "+j2); + System.out.println("J2EEVersions p2: "+j1); + assertEquals(j1, j2); + + String j3 = J2EEUtils.getJ2EEVersionAsString(project1, comp1); + System.out.println("J2EEVersion p1 as String: "+j3); + assertEquals(j3, J2EEVersionConstants.VERSION_1_4_TEXT); + + System.out.println("< ENG: testJ2EEVersionMethods ..."); + } + + public void testComponentGetterMethods(){ + + System.out.println("< BEGIN: testComponentGetterMethods ..."); + + IVirtualComponent[] vcs = J2EEUtils.getAllComponents(); + checkVirtualComponentsExists(vcs); + + IVirtualComponent[] vcs2 = J2EEUtils.getAllEARComponents(); + checkVirtualComponentsExists(vcs2); + + IVirtualComponent[] vcs3 = J2EEUtils.getAllWebComponents(); + checkVirtualComponentsExists(vcs3); + + IVirtualComponent[] vcs4 = J2EEUtils.getWebComponents(project1); + checkVirtualComponentsExists(vcs4); + + String[] names = J2EEUtils.getWebComponentNames(project2); + printNameStrings(names); + + String[] names2 = J2EEUtils.toComponentNamesArray(J2EEUtils.getComponentsByType(project1, J2EEUtils.WEB | J2EEUtils.EJB)); + printNameStrings(names2); + + IProject[] projects = J2EEUtils.getAllFlexibleProjects(); + for (int i=0;i<projects.length;i++){ + System.out.println("Flex project "+i+" = "+projects[i]); + } + + System.out.println("< END: testComponentGetterMethods ..."); + } + + private void checkVirtualComponentsExists(IVirtualComponent[] vcs){ + if (vcs.length == 0) + System.out.println("Empty...."); + + for (int i=0; i<vcs.length;i++){ + IVirtualComponent vc = vcs[i]; + System.out.println("VC: Project = "+vc.getProject()+" Name = "+vc.getName()); + assertTrue(vc.exists()); + + } + } + + private void printNameStrings(String[] names){ + for (int i=0;i<names.length;i++){ + System.out.println("Name"+i+" = "+names[i]); + } + } + + public void testAssociateComponentCommand(){ + + System.out.println("< BEGIN: testAssociateComponentCommand ..."); + + AssociateModuleWithEARCommand amwe = new AssociateModuleWithEARCommand(); + amwe.setEar(earCompName); + amwe.setEARProject(webProjectName); + amwe.setModule(comp1); + amwe.setProject(webProjectName); + amwe.execute(null); + + System.out.println("< END: testAssociateComponentCommand ..."); + } + + public void testReferencingGetterMethods(){ + + System.out.println("< BEGIN: testReferencingGetterMethods ..."); + + System.out.println("isComponentAssociated .."); + J2EEUtils.isComponentAssociated(project1, earCompName, project1, comp1); + + String[] names = J2EEUtils.toComponentNamesArray(J2EEUtils.getReferencingEARComponents(project1, comp1)); + printNameStrings(names); + String[] names2 = J2EEUtils.toComponentNamesArray(J2EEUtils.getReferencingEARComponents(project2, comp3)); + printNameStrings(names2); + + String[] names3 = J2EEUtils.toComponentNamesArray(J2EEUtils.getReferencingWebComponentsFromEAR(project1, earCompName)); + printNameStrings(names3); + + System.out.println("< END: testReferencingGetterMethods ..."); + } + + public void testIsComponentMethods(){ + + System.out.println("< BEGIN: testIsComponentMethods ..."); + + //assertFalse(J2EEUtils.isEJB20Component(ejbProject, ejbComponentName)); + assertTrue(J2EEUtils.isEJB20Component(ejbProject, ejbComponentName)); + + System.out.println("< END: testIsComponentMethods ..."); + } + + + +} diff --git a/tests/org.eclipse.jst.ws.tests/tests/org/eclipse/jst/ws/tests/unittest/LaunchTest.java b/tests/org.eclipse.jst.ws.tests/tests/org/eclipse/jst/ws/tests/unittest/LaunchTest.java new file mode 100644 index 000000000..ec2f6aa5b --- /dev/null +++ b/tests/org.eclipse.jst.ws.tests/tests/org/eclipse/jst/ws/tests/unittest/LaunchTest.java @@ -0,0 +1,33 @@ +package org.eclipse.jst.ws.tests.unittest; + +import org.eclipse.core.runtime.IPlatformRunnable; + +/** + * Minimal app to run as Eclipse "application" + */ +public class LaunchTest implements IPlatformRunnable +{ + /** + * @see org.eclipse.core.runtime.IPlatformRunnable#run(Object) + */ + public Object run(Object args) throws Exception + { + + Object result = new AllWSJUnitTests().runMain(args); + + if (result != null) + { + if (result instanceof Throwable) + { + ((Throwable) result).printStackTrace(); + } + else + { + System.out.println("tests didn't return 'ok'"); + } + return result; + } + else + return IPlatformRunnable.EXIT_OK; + } +} diff --git a/tests/org.eclipse.jst.ws.tests/tests/org/eclipse/jst/ws/tests/unittest/ResourceUtilsTests.java b/tests/org.eclipse.jst.ws.tests/tests/org/eclipse/jst/ws/tests/unittest/ResourceUtilsTests.java new file mode 100644 index 000000000..0b09c6e4c --- /dev/null +++ b/tests/org.eclipse.jst.ws.tests/tests/org/eclipse/jst/ws/tests/unittest/ResourceUtilsTests.java @@ -0,0 +1,23 @@ +/** + * + */ +package org.eclipse.jst.ws.tests.unittest; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * @author sengpl + * + */ +public class ResourceUtilsTests extends TestCase implements WSJUnitConstants{ + + + public static Test suite(){ + return new TestSuite(ResourceUtilsTests.class); + } + + + +} diff --git a/tests/org.eclipse.jst.ws.tests/tests/org/eclipse/jst/ws/tests/unittest/ServerCreationTests.java b/tests/org.eclipse.jst.ws.tests/tests/org/eclipse/jst/ws/tests/unittest/ServerCreationTests.java new file mode 100644 index 000000000..8fe016c8f --- /dev/null +++ b/tests/org.eclipse.jst.ws.tests/tests/org/eclipse/jst/ws/tests/unittest/ServerCreationTests.java @@ -0,0 +1,40 @@ +/** + * + */ +package org.eclipse.jst.ws.tests.unittest; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +import org.eclipse.jst.ws.internal.consumption.command.common.CreateServerCommand; + +/** + * @author sengpl + * + */ +public class ServerCreationTests extends TestCase implements WSJUnitConstants{ + + + public static Test suite(){ + return new TestSuite(ServerCreationTests.class); + } + + public void testCreateTomcatv5Server(){ + System.out.println("Creating Tomcat v5 server."); + CreateServerCommand csc = new CreateServerCommand(); + csc.setServerFactoryid(SERVERTYPEID_TC50); + csc.execute(null); + + System.out.println("Done creating Tomcat v5 server."); + } + + public void testReattemptCreateTomcatv5Server(){ + System.out.println("Attempting to create 2nd Tomcat v5 server."); + CreateServerCommand csc = new CreateServerCommand(); + csc.setServerFactoryid(SERVERTYPEID_TC50); + csc.execute(null); + + System.out.println("Done attempting 2nd Tomcat v5 server creation."); + } +} diff --git a/tests/org.eclipse.jst.ws.tests/tests/org/eclipse/jst/ws/tests/unittest/WSJUnitConstants.java b/tests/org.eclipse.jst.ws.tests/tests/org/eclipse/jst/ws/tests/unittest/WSJUnitConstants.java new file mode 100644 index 000000000..ce8a8fb6a --- /dev/null +++ b/tests/org.eclipse.jst.ws.tests/tests/org/eclipse/jst/ws/tests/unittest/WSJUnitConstants.java @@ -0,0 +1,29 @@ +package org.eclipse.jst.ws.tests.unittest; + + +public interface WSJUnitConstants { + + public final String SERVER_INSTALL_PATH = System.getProperty("org.eclipse.jst.server.tomcat.50"); + public final String RUNTIMETYPEID_TC50 = "org.eclipse.jst.server.tomcat.runtime.50"; + + public final String WS_RUNTIMEID_AXIS = "org.eclipse.jst.ws.runtime.axis11"; + + public final String SERVERTYPEID_TC50 = "org.eclipse.jst.server.tomcat.50"; + + public final String webProjectName = "WP"; + public final String webProject2Name = "WP2"; + public final String webComponentName = "webComponent"; + public final String webComponent2Name = "webComp2"; + public final String webComp3Name = "webComp3"; + public final String webComp4Name = "webComp4"; + + + public final String ejbProjectName = "EJBProject"; + public final String ejbComponentName = "ejbComponent"; + + public final String appClientProjectName = "AppClientProject"; + public final String appClientCompName = "appClientComponent"; + + public final String earCompName = "EARComponent"; + +} diff --git a/tests/org.eclipse.jst.ws.tests/tests/org/eclipse/jst/ws/tests/util/DynamicPopupJUnitWizard.java b/tests/org.eclipse.jst.ws.tests/tests/org/eclipse/jst/ws/tests/util/DynamicPopupJUnitWizard.java index dc4483da9..9963ff8f4 100644 --- a/tests/org.eclipse.jst.ws.tests/tests/org/eclipse/jst/ws/tests/util/DynamicPopupJUnitWizard.java +++ b/tests/org.eclipse.jst.ws.tests/tests/org/eclipse/jst/ws/tests/util/DynamicPopupJUnitWizard.java @@ -36,7 +36,7 @@ public class DynamicPopupJUnitWizard extends DynamicPopupWizard { DataMappingRegistryImpl dataRegistry_ = new DataMappingRegistryImpl(); DataFlowManager dataManager = new DataFlowManager( dataRegistry_, environment ); - SimpleCommandEngineManager manager = new SimpleCommandEngineManager(environment, dataManager ); + SimpleCommandEngineManager manager = new SimpleCommandEngineManager(environment, dataManager); commandWidgetBinding_.registerDataMappings( dataRegistry_ ); manager.setRootFragment( rootFragment ); diff --git a/tests/org.eclipse.jst.ws.tests/tests/org/eclipse/jst/ws/tests/util/JUnitUtils.java b/tests/org.eclipse.jst.ws.tests/tests/org/eclipse/jst/ws/tests/util/JUnitUtils.java index fb9b16409..ae10f0425 100644 --- a/tests/org.eclipse.jst.ws.tests/tests/org/eclipse/jst/ws/tests/util/JUnitUtils.java +++ b/tests/org.eclipse.jst.ws.tests/tests/org/eclipse/jst/ws/tests/util/JUnitUtils.java @@ -30,7 +30,6 @@ import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jst.j2ee.internal.web.operations.WebNatureRuntimeUtilities; import org.eclipse.jst.ws.internal.common.EnvironmentUtils; import org.eclipse.jst.ws.internal.common.ServerUtils; -import org.eclipse.jst.ws.internal.consumption.command.common.CreateEARProjectCommand; import org.eclipse.jst.ws.internal.consumption.command.common.CreateModuleCommand; import org.eclipse.jst.ws.internal.consumption.ui.plugin.WebServiceConsumptionUIPlugin; import org.eclipse.jst.ws.internal.consumption.ui.preferences.PersistentServerRuntimeContext; @@ -72,22 +71,19 @@ public class JUnitUtils { public static IServer createServer(String name,String serverTypeId,IRuntime runtime,Environment env) throws Exception { - IServerType serverType = ServerCore.findServerType(serverTypeId); - IServer[] servers = ServerCore.getServers(); - for (int i=0;i<servers.length;i++){ - if(servers[i].getServerType().getId().equals(serverType.getId())){ - return servers[i]; + IServerType serverType = ServerCore.findServerType(serverTypeId); + IServer[] servers = ServerCore.getServers(); + for (int i=0;i<servers.length;i++){ + if(servers[i].getServerType().getId().equals(serverType.getId())){ + return servers[i]; + } } - } - - IServerWorkingCopy serverWc = serverType.createServer(serverTypeId,null,EnvironmentUtils.getIProgressMonitor(env)); - serverWc.setName(name); - serverWc.setRuntime(runtime); - - IServer server = serverWc.saveAll(true, EnvironmentUtils.getIProgressMonitor(env)); - - return server; + IServerWorkingCopy serverWc = serverType.createServer(serverTypeId,null,EnvironmentUtils.getIProgressMonitor(env)); + serverWc.setName(name); + serverWc.setRuntime(runtime); + IServer server = serverWc.saveAll(true, EnvironmentUtils.getIProgressMonitor(env)); + return server; } /** @@ -100,6 +96,8 @@ public class JUnitUtils { * @param env Environment * @return server IServer * @throws Exception + * + * @deprecated */ public static IServer createServer(String javaRuntimePath, String jreID, String name,String serverTypeId,IRuntime runtime,Environment env) throws Exception { @@ -130,7 +128,7 @@ public class JUnitUtils { { try { - currentServer.synchronousStart(ILaunchManager.RUN_MODE,EnvironmentUtils.getIProgressMonitor(currentEnv)); + currentServer.start(ILaunchManager.RUN_MODE,EnvironmentUtils.getIProgressMonitor(currentEnv)); } catch (CoreException e) { @@ -143,55 +141,6 @@ public class JUnitUtils { PlatformUI.getWorkbench().getProgressService().run(true,false,runnable); } - public static IServer getDefaultServer() - { - IServer[] serverList = ServerCore.getServers(); - if (serverList.length > 0){ - return serverList[0]; - } - return null; - } - - public static boolean addEARToDefaultServer(IProject earProject,Environment env) throws Exception - { - return addEARToServer(getDefaultServer(),earProject,env); - } - - public static boolean addEARToServer(IServer server,IProject earProject,Environment env) throws Exception - { - int numberOfModules = server.getModules().length; - if (server != null) - { - final IModule[] modules = ServerUtil.getModules(earProject); - final IModule earProjectModule = modules[0]; - new ServerUtils().modifyModules(env,server,earProjectModule,true,EnvironmentUtils.getIProgressMonitor(env)); - final IServer currentServer = server; - IRunnableWithProgress runnable = new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - for (int i=0;i<1000;i++) - { - if (currentServer.getModuleState(modules) != IServer.STATE_STARTED) { - try { - Thread.sleep(300); - } - catch (InterruptedException e){ - } - } else - break; - } - } - }; - PlatformUI.getWorkbench().getProgressService().run(true,false,runnable); - return (server.getModules().length == (numberOfModules+1)); - } - return false; - } - - public static boolean removeEARFromDefaultServer(IProject earProject,Environment env) throws Exception - { - return removeEARFromServer(getDefaultServer(),earProject,env); - } - public static boolean removeEARFromServer(IServer server,IProject earProject,Environment env) throws Exception { int numberOfModules = server.getModules().length; @@ -231,7 +180,8 @@ public class JUnitUtils { } public static boolean removeModuleFromServer(IServer server, IProject webProject, Environment env) throws Exception { - + + int numberOfModules = server.getModules().length; if (server != null) { final IModule[] modules = ServerUtil.getModules(webProject); @@ -262,24 +212,13 @@ public class JUnitUtils { } } }; - int numberOfModules = server.getModules().length; PlatformUI.getWorkbench().getProgressService().run(true,false,runnable); - Thread.sleep(6000); + //Thread.sleep(6000); return (server.getModules().length == (numberOfModules-1)); } return false; } - public static void stopDefaultServer() throws Exception - { - getDefaultServer().synchronousStop(true); - } - - public static void deleteDefaultServer() throws Exception - { - getDefaultServer().delete(); - } - // Begin: General Eclipse Utilities public static void syncBuildProject(IProject project,Environment env) throws Exception @@ -398,24 +337,14 @@ public class JUnitUtils { return launchWizard("org.eclipse.jst.ws.internal.consumption.ui",wizardId,objectClassId,initialSelection); } - // Begin: EAR Utilities - public static Status createEARProject(String earProjectName,String serverTypeId,String j2eeVersion,Environment env) - { - CreateEARProjectCommand t = new CreateEARProjectCommand(); - t.setEarProjectName(earProjectName); - t.setServerFactoryId(serverTypeId); - t.setJ2EEVersion(j2eeVersion); - return t.execute(env); - } - - public static Status createWebProject(String webProjectName, String moduleName, String serverFactoryId, String j2eeVersion, Environment env){ + public static Status createWebModule(String webProjectName, String moduleName, String serverFactoryId, String j2eeVersion, Environment env){ Status status = new SimpleStatus(""); try{ CreateModuleCommand createWeb = new CreateModuleCommand(); createWeb.setProjectName(webProjectName); - createWeb.setModuleName(moduleName); - createWeb.setModuleType(CreateModuleCommand.WEB); + createWeb.setModuleName(moduleName); + createWeb.setModuleType(CreateModuleCommand.WEB); createWeb.setJ2eeLevel(j2eeVersion); createWeb.setServerFactoryId(serverFactoryId); return createWeb.execute(env); @@ -427,6 +356,13 @@ public class JUnitUtils { } + /** + * + * @param projectName + * @return + * + * @deprecated + */ public static IFolder getSourceFolderForWebProject(String projectName) { IProject project = ProjectUtilities.getProject(projectName); @@ -435,6 +371,13 @@ public class JUnitUtils { return srcFolder; } + /** + * + * @param projectName + * @return + * + * @deprecated + */ public static IFolder getWebContentFolder(String projectName) { IProject project = ProjectUtilities.getProject(projectName); @@ -442,12 +385,26 @@ public class JUnitUtils { return webContentFolder; } + /** + * + * @param projectName + * @return + * + * @deprecated + */ public static IFolder getWebInfFolderForWebProject(String projectName) { IProject project = ProjectUtilities.getProject(projectName); return project.getFolder(WebNatureRuntimeUtilities.getDefaultWEBINFPath()); } + /** + * + * @param projectName + * @return + * + * @deprecated + */ public static IFolder getClassesFolderForWebProject(String projectName) { IProject project = ProjectUtilities.getProject(projectName); |