jruaux      2002/10/29 09:11:58

  Modified:    Eclipse-Plugin/src/java/org/apache/cactus/eclipse/launcher
                        CactusLaunchShortcut.java
  Log:
  Added support for generic ant provider
  
  Revision  Changes    Path
  1.8       +60 -39    
jakarta-cactus/Eclipse-Plugin/src/java/org/apache/cactus/eclipse/launcher/CactusLaunchShortcut.java
  
  Index: CactusLaunchShortcut.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-cactus/Eclipse-Plugin/src/java/org/apache/cactus/eclipse/launcher/CactusLaunchShortcut.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- CactusLaunchShortcut.java 25 Oct 2002 10:50:18 -0000      1.7
  +++ CactusLaunchShortcut.java 29 Oct 2002 17:11:58 -0000      1.8
  @@ -56,9 +56,13 @@
    */
   package org.apache.cactus.eclipse.launcher;
   
  +import java.io.File;
   import java.lang.reflect.InvocationTargetException;
   
  -import org.apache.cactus.eclipse.containers.Tomcat40AntContainerProvider;
  +import org.apache.cactus.eclipse.containers.GenericAntProvider;
  +import org.apache.cactus.eclipse.containers.IContainerProvider;
  +import org.apache.cactus.eclipse.ui.CactusPlugin;
  +import org.apache.cactus.eclipse.ui.CactusPreferences;
   import org.eclipse.core.runtime.CoreException;
   import org.eclipse.debug.core.DebugPlugin;
   import org.eclipse.debug.core.ILaunchConfiguration;
  @@ -88,12 +92,15 @@
       extends JUnitLaunchShortcut
       implements ITestRunListener
   {
  +
  +    /**
  +     * Reference to the War file so that we can delete it on tearDown()
  +     */
  +    private File war;
       /**
        * The provider to use for container setup.
        */
  -    private Tomcat40AntContainerProvider tomcat =
  -        new Tomcat40AntContainerProvider();
  -
  +    private IContainerProvider provider;
       /**
        * @return the Cactus launch configuration type. This method overrides
        *         the one in {@link JUnitLaunchShortcut} so that we can return
  @@ -133,9 +140,9 @@
           if (types.length == 0)
           {
               MessageDialog.openInformation(
  -            getShell(),
  -            JUnitMessages.getString("LaunchTestAction.dialog.title"),
  -            JUnitMessages.getString("LaunchTestAction.message.notests"));
  +                getShell(),
  +                JUnitMessages.getString("LaunchTestAction.dialog.title"),
  +                JUnitMessages.getString("LaunchTestAction.message.notests"));
           }
           else if (types.length > 1)
           {
  @@ -156,23 +163,8 @@
        */
       private void launch(IType type, String mode)
       {
  +        prepareCactusTests(type);
           ILaunchConfiguration config = findLaunchConfiguration(type, mode);
  -        try
  -        {
  -            tomcat.deploy();
  -        }
  -        catch (CoreException e)
  -        {
  -            e.printStackTrace();
  -        }
  -        try
  -        {
  -            tomcat.start();
  -        }
  -        catch (CoreException e)
  -        {
  -            e.printStackTrace();
  -        }
           launchConfiguration(mode, config);
           IWorkbenchPage wbPage = JUnitPlugin.getDefault().getActivePage();
           JUnitViewFinder finder = new JUnitViewFinder(wbPage, this);
  @@ -195,41 +187,70 @@
           }
           catch (CoreException e)
           {
  -            ErrorDialog.openError(getShell(),
  -            JUnitMessages.getString("LaunchTestAction.message.launchFailed"),
  -            e.getMessage(),
  -            e.getStatus());
  +            ErrorDialog.openError(
  +                getShell(),
  +                JUnitMessages.getString(
  +                    "LaunchTestAction.message.launchFailed"),
  +                e.getMessage(),
  +                e.getStatus());
           }
       }
   
       /**
  -     * @see 
org.eclipse.jdt.internal.junit.runner.ITestRunListener#testRunStarted(int)
  -     */
  -    public void testRunStarted(int testCount)
  -    {
  -    }
  -
  -    /**
  -     * @see 
org.eclipse.jdt.internal.junit.runner.ITestRunListener#testRunEnded(long)
  +     * creates the war file, deploys and launches the container.
  +     * @param theType the Java file     
        */
  -    public void testRunEnded(long elapsedTime)
  +    private void prepareCactusTests(IType theType)
       {
           try
           {
  -            tomcat.stop();
  +            provider = CactusPlugin.getContainerProvider();
  +            WarBuilder newWar =
  +                new WarBuilder(
  +                    theType.getJavaProject(),
  +                    new File(CactusPreferences.getJarsDir()));
  +            war = newWar.createWar();
  +            provider.deploy(
  +                CactusPreferences.getContextURLPath(),
  +                war.toURL(),
  +                null);
  +            provider.start(null);
           }
  -        catch (CoreException e)
  +        catch (Exception e)
           {
               e.printStackTrace();
           }
  +    }
  +
  +    /**
  +     * Stops the container and undeploys (cleans) it.
  +     */
  +    private void teardownCactusTests()
  +    {
           try
           {
  -            tomcat.undeploy();
  +            provider.stop(null);
  +            provider.undeploy(null, null);
  +            war.delete();
           }
           catch (CoreException e)
           {
               e.printStackTrace();
           }
  +    }
  +    /**
  +     * @see 
org.eclipse.jdt.internal.junit.runner.ITestRunListener#testRunStarted(int)
  +     */
  +    public void testRunStarted(int testCount)
  +    {
  +    }
  +
  +    /**
  +     * @see 
org.eclipse.jdt.internal.junit.runner.ITestRunListener#testRunEnded(long)
  +     */
  +    public void testRunEnded(long elapsedTime)
  +    {
  +        teardownCactusTests();
       }
   
       /**
  
  
  

--
To unsubscribe, e-mail:   <mailto:cactus-dev-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:cactus-dev-help@;jakarta.apache.org>

Reply via email to