You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildr.apache.org by to...@apache.org on 2017/08/01 06:36:03 UTC

buildr git commit: Add support for jetty9, keep support for jetty6. Add integration tests for both.

Repository: buildr
Updated Branches:
  refs/heads/master a5340ee0d -> 63120eeec


Add support for jetty9, keep support for jetty6. Add integration tests for both.


Project: http://git-wip-us.apache.org/repos/asf/buildr/repo
Commit: http://git-wip-us.apache.org/repos/asf/buildr/commit/63120eee
Tree: http://git-wip-us.apache.org/repos/asf/buildr/tree/63120eee
Diff: http://git-wip-us.apache.org/repos/asf/buildr/diff/63120eee

Branch: refs/heads/master
Commit: 63120eeecec39442965e9630bb39749efa7b080e
Parents: a5340ee
Author: Antoine Toulme <an...@lunar-ocean.com>
Authored: Mon Jul 31 23:35:53 2017 -0700
Committer: Antoine Toulme <an...@lunar-ocean.com>
Committed: Mon Jul 31 23:35:53 2017 -0700

----------------------------------------------------------------------
 CHANGELOG                                       |   1 +
 addon/buildr/jetty.rb                           |  19 +-
 addon/buildr/jetty6.rb                          | 243 +++++++++++++++++++
 .../buildr/org/apache/buildr/Jetty6Wrapper.java | 144 +++++++++++
 .../buildr/org/apache/buildr/JettyWrapper.java  |  26 +-
 buildr.buildfile                                |   3 +-
 tests/integration_testing.rb                    |  67 +++--
 tests/run_jetty6/Buildfile                      |  13 +
 tests/run_jetty6/src/main/java/MainServlet.java |  12 +
 .../run_jetty6/src/main/webapp/WEB-INF/web.xml  |  17 ++
 tests/run_jetty9/Buildfile                      |  13 +
 tests/run_jetty9/src/main/java/MainServlet.java |  12 +
 .../run_jetty9/src/main/webapp/WEB-INF/web.xml  |  17 ++
 13 files changed, 554 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/buildr/blob/63120eee/CHANGELOG
----------------------------------------------------------------------
diff --git a/CHANGELOG b/CHANGELOG
index 076a2de..0a80ac3 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -4,6 +4,7 @@
 * Added: New way to concatenate file contents when merging several archives together.
 * Added: New way to transform file contents when merging several archives together.
 * Fixed: Removed .class files from being checked in.
+* Added: Support both Jetty 6 and Jetty 9 as addons. Added integration tests to cover their use.
 
 1.5.3 (2017-05-17)
 * Change: Add support for gwt 2.8.1 to gwt addon.

http://git-wip-us.apache.org/repos/asf/buildr/blob/63120eee/addon/buildr/jetty.rb
----------------------------------------------------------------------
diff --git a/addon/buildr/jetty.rb b/addon/buildr/jetty.rb
index 609174d..9e0395b 100644
--- a/addon/buildr/jetty.rb
+++ b/addon/buildr/jetty.rb
@@ -39,13 +39,22 @@ module Buildr
   class Jetty
 
     # Which version of Jetty we're using by default (change with options.jetty.version).
-    VERSION = "6.1.3"
-    SLF4J_VERSION = "1.4.3"
+    VERSION = '9.4.6.v20170531'
+    SLF4J_VERSION = '1.7.25'
 
     # Libraries used by Jetty.
-    REQUIRES = [ "org.mortbay.jetty:jetty:jar:#{VERSION}", "org.mortbay.jetty:jetty-util:jar:#{VERSION}",
-      "org.mortbay.jetty:servlet-api-2.5:jar:#{VERSION}", "org.slf4j:slf4j-api:jar:#{SLF4J_VERSION}",
-      "org.slf4j:slf4j-simple:jar:#{SLF4J_VERSION}", "org.slf4j:jcl104-over-slf4j:jar:#{SLF4J_VERSION}" ]
+    REQUIRES = [ "org.eclipse.jetty:jetty-server:jar:#{VERSION}",
+      "org.eclipse.jetty:jetty-webapp:jar:#{VERSION}",
+      "org.eclipse.jetty:jetty-http:jar:#{VERSION}",
+      "org.eclipse.jetty:jetty-util:jar:#{VERSION}",
+      "org.eclipse.jetty:jetty-io:jar:#{VERSION}",
+      "org.eclipse.jetty:jetty-servlet:jar:#{VERSION}",
+      "org.eclipse.jetty:jetty-security:jar:#{VERSION}",
+      "org.eclipse.jetty:jetty-xml:jar:#{VERSION}",
+      "org.slf4j:slf4j-api:jar:#{SLF4J_VERSION}",
+      "org.slf4j:slf4j-simple:jar:#{SLF4J_VERSION}", 
+      "org.slf4j:jcl-over-slf4j:jar:#{SLF4J_VERSION}",
+      'javax.servlet:javax.servlet-api:jar:3.1.0' ]
 
     Java.classpath <<  REQUIRES
     Java.classpath << File.dirname(__FILE__)

http://git-wip-us.apache.org/repos/asf/buildr/blob/63120eee/addon/buildr/jetty6.rb
----------------------------------------------------------------------
diff --git a/addon/buildr/jetty6.rb b/addon/buildr/jetty6.rb
new file mode 100644
index 0000000..1ac5458
--- /dev/null
+++ b/addon/buildr/jetty6.rb
@@ -0,0 +1,243 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with this
+# work for additional information regarding copyright ownership.  The ASF
+# licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+require 'uri'
+require 'net/http'
+require 'thread'
+
+module Buildr
+
+  # Provides a collection of tasks and methods for using Jetty, specifically as a server
+  # for testing your application.
+  #
+  # Build files should always start Jetty by invoking the #use task, typically as
+  # a prerequisite. This task will start Jetty once during the build, and shut it down
+  # when the build completes.
+  #
+  # If you want to keep Jetty running across builds, and look at error messages, you can
+  # start Jetty in a separate console with:
+  #   buildr jetty:start
+  # To stop this instance of Jetty, simply kill the process (Ctrl-C) or run:
+  #   buildr jetty:stop
+  #
+  # If you start Jetty separately from the build, the #use task will connect to that
+  # existing server. Since you are using Jetty across several builds, you will want to
+  # cleanup any mess created by each build. You can use the #setup and #teardown tasks,
+  # which are called when Jetty is first used in the build, and when the build ends.
+  class Jetty6
+
+    # Which version of Jetty we're using by default (change with options.jetty.version).
+    VERSION = "6.1.3"
+    SLF4J_VERSION = "1.4.3"
+
+    # Libraries used by Jetty.
+    REQUIRES = [ "org.mortbay.jetty:jetty:jar:#{VERSION}", "org.mortbay.jetty:jetty-util:jar:#{VERSION}",
+      "org.mortbay.jetty:servlet-api-2.5:jar:#{VERSION}", "org.slf4j:slf4j-api:jar:#{SLF4J_VERSION}",
+      "org.slf4j:slf4j-simple:jar:#{SLF4J_VERSION}", "org.slf4j:jcl104-over-slf4j:jar:#{SLF4J_VERSION}" ]
+
+    Java.classpath <<  REQUIRES
+    Java.classpath << File.dirname(__FILE__)
+
+    # Default URL for Jetty (change with options.jetty.url).
+    URL = "http://localhost:8080"
+
+    class << self
+
+      # :call-seq:
+      #   instance() => Jetty
+      #
+      # Returns an instance of Jetty.
+      def instance()
+        @instance ||= Jetty6.new("jetty", URL)
+      end
+
+    end
+
+    def initialize(name, url) #:nodoc:
+      @url = url
+      namespace name do
+        @setup = task("setup")
+        @teardown = task("teardown")
+        @use = task("use") { fire }
+      end
+    end
+
+    # The URL for the Jetty server. Leave as is if you want to use the default server
+    # (http://localhost:8080).
+    attr_accessor :url
+
+    # :call-seq:
+    #    start(pipe?)
+    #
+    # Starts Jetty. This method does not return, it keeps the thread running until
+    # Jetty is stopped. If you want to run Jetty parallel with other tasks in the build,
+    # invoke the #use task instead.
+    def start(sync = nil)
+      begin
+        puts "classpath #{Java.classpath.inspect}"
+        port = URI.parse(url).port
+        puts "Starting Jetty at http://localhost:#{port}" if verbose
+        Java.load
+        jetty = Java.org.apache.buildr.Jetty6Wrapper.new(port)
+        sync << "Started" if sync
+        sleep # Forever
+      rescue Interrupt # Stopped from console
+      rescue Exception=>error
+        puts "#{error.class}: #{error.message}"
+      end
+      exit! # No at_exit
+    end
+
+    # :call-seq:
+    #    stop()
+    #
+    # Stops Jetty. Stops a server running in a separate process.
+    def stop()
+      uri = URI.parse(url)
+      begin
+        Net::HTTP.start(uri.host, uri.port) do |http|
+          http.request_post "/buildr/stop", ""
+        end
+      rescue Errno::ECONNREFUSED
+        # Expected if Jetty server not running.
+      rescue EOFError
+        # We get EOFError because Jetty is brutally killed.
+      end
+      puts "Jetty server stopped"
+    end
+
+    # :call-seq:
+    #   running?() => boolean
+    #
+    # Returns true if it finds a running Jetty server that supports the Buildr
+    # requests for deploying, stopping, etc.
+    def running?()
+      uri = URI.parse(url)
+      begin
+        Net::HTTP.start(uri.host, uri.port) do |http|
+          response = http.request_get("/buildr/")
+          response.is_a?(Net::HTTPSuccess) && response.body =~ /Alive/
+        end
+      rescue Errno::ECONNREFUSED, Errno::EBADF
+        false
+      end
+    end
+
+    # :call-seq:
+    #   deploy(url, webapp) => path
+    #
+    # Deploy a WAR in the specified URL.
+    def deploy(url, webapp)
+      use.invoke
+      uri = URI.parse(url)
+      Net::HTTP.start(uri.host, uri.port) do |http|
+        response = http.request_post("/buildr/deploy", "webapp=#{webapp}&path=#{uri.path}")
+        if Net::HTTPOK === response && response.body =~ /Deployed/
+          path = response.body.split[1]
+          puts "Deployed #{webapp}, context path #{uri.path}" if trace?
+          path
+        else
+          fail "Deployment failed: #{response}"
+        end
+      end
+    end
+
+    # :call-seq:
+    #   undeploy(url) => boolean
+    #
+    # Undeploys a WAR from the specified URL.
+    def undeploy(url)
+      use.invoke
+      uri = URI.parse(url)
+      Net::HTTP.start(uri.host, uri.port) do |http|
+        response = http.request_post("/buildr/undeploy", "path=#{uri.path}")
+        if Net::HTTPOK === response && response.body =~ /Undeployed/
+          true
+        else
+          fail "Deployment failed: #{response}"
+        end
+      end
+    end
+
+    # :call-seq:
+    #   setup(*prereqs) => task
+    #   setup(*prereqs) { |task| .. } => task
+    #
+    # This task executes when Jetty is first used in the build. You can use it to
+    # deploy artifacts into Jetty.
+    def setup(*prereqs, &block)
+      @setup.enhance prereqs, &block
+    end
+
+    # :call-seq:
+    #   teardown(*prereqs) => task
+    #   teardown(*prereqs) { |task| .. } => task
+    #
+    # This task executes when the build is done. You can use it to undeploy artifacts
+    # previously deployed into Jetty.
+    def teardown(*prereqs, &block)
+      @teardown.enhance prereqs, &block
+    end
+
+    # :call-seq:
+    #   use(*prereqs) => task
+    #   use(*prereqs) { |task| .. } => task
+    #
+    # If you intend to use Jetty, invoke this task. It will start a new instance of
+    # Jetty and close it when the build is done. However, if you already have a server
+    # running in the background (e.g. jetty:start), it will use that server and will
+    # not close it down.
+    def use(*prereqs, &block)
+      @use.enhance prereqs, &block
+    end
+
+  protected
+
+    # If you want to start Jetty inside the build, call this method instead of #start.
+    # It will spawn a separate process that will run Jetty, and will stop Jetty when
+    # the build ends. However, if you already started Jetty from the console (with
+    # take jetty:start), it will use the existing instance without shutting it down.
+    def fire()
+      unless running?
+        sync = Queue.new
+        Thread.new { start sync }
+        # Wait for Jetty to fire up before doing anything else.
+        sync.pop == "Started" or fail "Jetty not started"
+        puts "Jetty started" if verbose
+        at_exit { stop }
+      end
+      @setup.invoke
+      at_exit { @teardown.invoke }
+    end
+
+  end
+
+  namespace "jetty" do
+    desc "Start an instance of Jetty running in the background"
+    task("start") { Jetty6.instance.start }
+    desc "Stop an instance of Jetty running in the background"
+    task("stop") { Jetty6.instance.stop }
+  end
+
+  # :call-seq:
+  #   jetty() => Jetty
+  #
+  # Returns a Jetty object. You can use this to discover the Jetty#use task,
+  # configure the Jetty#setup and Jetty#teardown tasks, deploy and undeploy to Jetty.
+  def jetty()
+    @jetty ||= Jetty6.instance
+  end
+
+end

http://git-wip-us.apache.org/repos/asf/buildr/blob/63120eee/addon/buildr/org/apache/buildr/Jetty6Wrapper.java
----------------------------------------------------------------------
diff --git a/addon/buildr/org/apache/buildr/Jetty6Wrapper.java b/addon/buildr/org/apache/buildr/Jetty6Wrapper.java
new file mode 100644
index 0000000..0423e3d
--- /dev/null
+++ b/addon/buildr/org/apache/buildr/Jetty6Wrapper.java
@@ -0,0 +1,144 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+package org.apache.buildr;
+
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.Request;
+import org.mortbay.jetty.Handler;
+import org.mortbay.jetty.handler.AbstractHandler;
+import org.mortbay.jetty.handler.ContextHandler;
+import org.mortbay.jetty.handler.ContextHandlerCollection;
+import org.mortbay.jetty.webapp.WebAppContext;
+import org.mortbay.jetty.webapp.WebAppClassLoader;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.ServletException;
+import java.io.IOException;
+import java.util.HashMap;
+
+/**
+ * @author Matthieu Riou <mriou at apache dot org>
+ */
+public class Jetty6Wrapper {
+
+    private Server _server;
+    private ContextHandlerCollection _handlerColl;
+
+    public Jetty6Wrapper(int port) throws Exception {
+        _server = new Server(port);
+        // Adding the buildr handler to control our server lifecycle
+        ContextHandler context = new ContextHandler();
+        context.setContextPath("/buildr");
+        Handler handler = new BuildrHandler();
+        context.setHandler(handler);
+
+        _handlerColl = new ContextHandlerCollection();
+        _handlerColl.setHandlers(new Handler[] {context});
+
+        _server.addHandler(_handlerColl);
+        _server.start();
+    }
+
+/*
+    public void join() {
+        try {
+            _server.join();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+*/
+
+    private class BuildrHandler extends AbstractHandler {
+
+        private HashMap _apps = new HashMap();
+
+        public void handle(String string, HttpServletRequest request,
+                           HttpServletResponse response, int i) throws IOException, ServletException {
+            response.setContentType("text/html");
+            if (request.getPathInfo().equals("/")) {
+                response.getWriter().println("Alive");
+                ((Request)request).setHandled(true);
+                return;
+            } else if (request.getPathInfo().equals("/deploy")) {
+                try {
+                    String webapp = request.getParameter("webapp");
+                    String path = request.getParameter("path");
+                    System.out.println("Deploying " + webapp + " in " + path);
+                    WebAppContext context;
+
+                    context = (WebAppContext) _apps.get(path);
+                    if (context != null) {
+                        context.stop();
+                        _handlerColl.removeHandler(context);
+                        _apps.remove(path);
+                    }
+
+                    context = new WebAppContext(webapp, path);
+                    context.setConfigurationClasses(new String[] {
+                        "org.mortbay.jetty.webapp.WebInfConfiguration",
+                        "org.mortbay.jetty.webapp.WebXmlConfiguration"});
+                    context.setClassLoader(new WebAppClassLoader(context));
+
+                    _handlerColl.addHandler(context);
+                    context.start();
+                    _apps.put(path, context);
+                    response.getWriter().println("Deployed");
+                    response.getWriter().println(context.getTempDirectory());
+                    ((Request)request).setHandled(true);
+                } catch (Throwable e) {
+                    e.printStackTrace();
+                    response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+                    ((Request)request).setHandled(true);
+                    return;
+                }
+            } else if (request.getPathInfo().equals("/undeploy")) {
+                try {
+                    String path = request.getParameter("path");
+                    WebAppContext context = (WebAppContext) _apps.get(path);
+                    if (context != null) {
+                        System.out.println("Undeploying app at " + path);
+                        context.stop();
+                        _handlerColl.removeHandler(context);
+                        _apps.remove(path);
+                    }
+                    response.getWriter().println("Undeployed");
+                    ((Request)request).setHandled(true);
+                } catch (Throwable e) {
+                    e.printStackTrace();
+                    response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+                    ((Request)request).setHandled(true);
+                    return;
+                }
+            } else if (request.getPathInfo().equals("/stop")) {
+                try {
+                    _server.stop();
+                    _server.destroy();
+                    // Brute force
+                    System.exit(0);
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+            response.getWriter().println("OK " + request.getPathInfo());
+            ((Request)request).setHandled(true);
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/buildr/blob/63120eee/addon/buildr/org/apache/buildr/JettyWrapper.java
----------------------------------------------------------------------
diff --git a/addon/buildr/org/apache/buildr/JettyWrapper.java b/addon/buildr/org/apache/buildr/JettyWrapper.java
index 769b339..84f456f 100644
--- a/addon/buildr/org/apache/buildr/JettyWrapper.java
+++ b/addon/buildr/org/apache/buildr/JettyWrapper.java
@@ -17,14 +17,14 @@
 
 package org.apache.buildr;
 
-import org.mortbay.jetty.Server;
-import org.mortbay.jetty.Request;
-import org.mortbay.jetty.Handler;
-import org.mortbay.jetty.handler.AbstractHandler;
-import org.mortbay.jetty.handler.ContextHandler;
-import org.mortbay.jetty.handler.ContextHandlerCollection;
-import org.mortbay.jetty.webapp.WebAppContext;
-import org.mortbay.jetty.webapp.WebAppClassLoader;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.Request;
+import org.eclipse.jetty.server.Handler;
+import org.eclipse.jetty.server.handler.AbstractHandler;
+import org.eclipse.jetty.server.handler.ContextHandler;
+import org.eclipse.jetty.server.handler.ContextHandlerCollection;
+import org.eclipse.jetty.webapp.WebAppContext;
+import org.eclipse.jetty.webapp.WebAppClassLoader;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -51,7 +51,7 @@ public class JettyWrapper {
         _handlerColl = new ContextHandlerCollection();
         _handlerColl.setHandlers(new Handler[] {context});
 
-        _server.addHandler(_handlerColl);
+        _server.setHandler(_handlerColl);
         _server.start();
     }
 
@@ -69,8 +69,8 @@ public class JettyWrapper {
 
         private HashMap _apps = new HashMap();
 
-        public void handle(String string, HttpServletRequest request,
-                           HttpServletResponse response, int i) throws IOException, ServletException {
+        public void handle(String string, Request req, HttpServletRequest request,
+                           HttpServletResponse response) throws IOException, ServletException {
             response.setContentType("text/html");
             if (request.getPathInfo().equals("/")) {
                 response.getWriter().println("Alive");
@@ -92,8 +92,8 @@ public class JettyWrapper {
 
                     context = new WebAppContext(webapp, path);
                     context.setConfigurationClasses(new String[] {
-                        "org.mortbay.jetty.webapp.WebInfConfiguration",
-                        "org.mortbay.jetty.webapp.WebXmlConfiguration"});
+                        "org.eclipse.jetty.webapp.WebInfConfiguration",
+                        "org.eclipse.jetty.webapp.WebXmlConfiguration"});
                     context.setClassLoader(new WebAppClassLoader(context));
 
                     _handlerColl.addHandler(context);

http://git-wip-us.apache.org/repos/asf/buildr/blob/63120eee/buildr.buildfile
----------------------------------------------------------------------
diff --git a/buildr.buildfile b/buildr.buildfile
index 3d34d2d..5f86e2b 100644
--- a/buildr.buildfile
+++ b/buildr.buildfile
@@ -15,6 +15,7 @@
 
 $LOADED_FEATURES << 'jruby' unless RUBY_PLATFORM =~ /java/ # Pretend to have JRuby, keeps Nailgun happy.
 require 'buildr/jetty'
+require 'buildr/jetty6'
 require 'buildr/nailgun'
 require 'buildr/scala'
 require 'buildr/kotlin'
@@ -39,7 +40,7 @@ define 'buildr' do
 
   desc 'Buildr extra packages (Antlr, Cobertura, Hibernate, Javacc, JDepend, Jetty, OpenJPA, XmlBeans)'
   define 'extra', :version=>'1.0' do
-    compile.using(:javac).from(FileList['addon/buildr/**/*.java']).into('addon/buildr').with(Buildr::Jetty::REQUIRES, Buildr::Nailgun::ARTIFACT_SPEC)
+    compile.using(:javac).from(FileList['addon/buildr/**/*.java']).into('addon/buildr').with(Buildr::Jetty::REQUIRES, Buildr::Jetty6::REQUIRES, Buildr::Nailgun::ARTIFACT_SPEC)
     # Legals included in source code and show in RDoc.
     legal = 'LICENSE', 'NOTICE'
     package(:gem).include(legal).path('lib').include('addon/buildr')

http://git-wip-us.apache.org/repos/asf/buildr/blob/63120eee/tests/integration_testing.rb
----------------------------------------------------------------------
diff --git a/tests/integration_testing.rb b/tests/integration_testing.rb
index 7fa62d5..3144c95 100644
--- a/tests/integration_testing.rb
+++ b/tests/integration_testing.rb
@@ -18,11 +18,12 @@ BUILDR = ENV['BUILDR'] || File.expand_path("#{TEST_DIR}/../_buildr")
 
 require 'test/unit'
 require 'zip'
+require 'open-uri'
 
 module Buildr
   module IntegrationTests
 
-    def self.test(folder, cmd, after_block = nil)
+    def self.test(folder, cmd, after_block = nil, cleanup = "#{BUILDR} clean")
 
       eval <<-TEST
       class #{folder.sub("-", "").capitalize} < Test::Unit::TestCase
@@ -30,11 +31,10 @@ module Buildr
         def test_#{folder.sub("-", "")}
           begin
             result = `cd #{TEST_DIR}/#{folder} ; #{BUILDR} #{cmd}`
-p result
             assert($?.success?, 'Command success?')
             #{ after_block || "" }
           ensure
-            %x[cd #{TEST_DIR}/#{folder} ; #{BUILDR} clean]
+            %x[cd #{TEST_DIR}/#{folder} ; #{cleanup}]
           end
 
         end
@@ -50,46 +50,85 @@ p result
 
     test "helloWorld", "package"
 
-    test "helloWorldEcj", "package", <<-CHECK
+    test "helloWorldEcj", "package", %Q(
 p result
 #assert(::Buildr::Java.classpath.include?(artifact("org.eclipse.jdt.core.compiler:ecj:jar:3.5.1").to_s))
-    CHECK
+    )
 
     test "compile_with_parent", "compile"
 
     test "junit3", "test"
 
-    test "include_path", "package", <<-CHECK
+    test "include_path", "package", %Q(
 path = File.expand_path("#{TEST_DIR}/include_path/target/proj-1.0.zip")
 assert(File.exist?(path), "File exists?")
 ::Zip::File.open(path) {|zip|
 assert(!zip.get_entry("distrib/doc/index.html").nil?)
 assert(!zip.get_entry("distrib/lib/slf4j-api-1.6.1.jar").nil?)
 }
-    CHECK
+    )
 
-    test "include_as", "package", <<-CHECK
+    test "include_as", "package", %Q(
 path = File.expand_path("#{TEST_DIR}/include_as/target/proj-1.0.zip")
 assert(File.exist? path)
 ::Zip::File.open(path) {|zip|
 assert(!zip.get_entry("docu/index.html").nil?)
 assert(!zip.get_entry("lib/logging.jar").nil?)
 }
-    CHECK
+    )
 
-    test "package_war_as_jar", "package", <<-CHECK
+    test "package_war_as_jar", "package", %Q(
     assert(File.exist? "#{TEST_DIR}/package_war_as_jar/target/webapp-1.0.jar")
     %x[cd #{TEST_DIR}/package_war_as_jar ; #{BUILDR} clean]
     assert($?.success?)
-    CHECK
+    )
 
-    test "generateFromPom", "--generate pom.xml", <<-CHECK
+    test "generateFromPom", "--generate pom.xml", %Q(
     assert(File.exist? "#{TEST_DIR}/generateFromPom/buildfile")
     assert(File.read("#{TEST_DIR}/generateFromPom/buildfile") !~ /slf4j.version/)
-    CHECK
+    ), 'rm Buildfile'
+
+    test "generateFromPom2", "--generate pom.xml", '', 'rm Buildfile' # For BUILDR-623
+
+    class RunJetty6 < Test::Unit::TestCase
+
+      def test_RunJetty6
+        begin
+          result = `cd #{TEST_DIR}/run_jetty6 ; #{BUILDR} clean package`
+          assert($?.success?, 'Command success?')
+          system "cd #{TEST_DIR}/run_jetty6 ; #{BUILDR} jetty:start &"
+          sleep 5
+          system "cd #{TEST_DIR}/run_jetty6 ; #{BUILDR} webapp:deploy-app"
+          sleep 5
+          http_resp = open('http://localhost:8080/hello/').read
+          assert("Hello!\n" == http_resp)
+        ensure
+          %x[cd #{TEST_DIR}/run_jetty6 ; #{BUILDR} jetty:stop clean]
+          system "ps aux | grep jetty:start | awk '{print $2}' | xargs kill -9"
+        end
 
-    test "generateFromPom2", "--generate pom.xml" # For BUILDR-623
+      end
+    end
+    
+    class RunJetty9 < Test::Unit::TestCase
+
+      def test_RunJetty9
+        begin
+          result = `cd #{TEST_DIR}/run_jetty9 ; #{BUILDR} clean package`
+          assert($?.success?, 'Command success?')
+          system "cd #{TEST_DIR}/run_jetty9 ; #{BUILDR} jetty:start &"
+          sleep 5
+          system "cd #{TEST_DIR}/run_jetty9 ; #{BUILDR} webapp:deploy-app"
+          sleep 5
+          http_resp = open('http://localhost:8080/hello/').read
+          assert("Hello!\n" == http_resp)
+        ensure
+          %x[cd #{TEST_DIR}/run_jetty9 ; #{BUILDR} jetty:stop clean]
+          system "ps aux | grep jetty:start | awk '{print $2}' | xargs kill -9"
+        end
 
+      end
+    end
   end
 
 end

http://git-wip-us.apache.org/repos/asf/buildr/blob/63120eee/tests/run_jetty6/Buildfile
----------------------------------------------------------------------
diff --git a/tests/run_jetty6/Buildfile b/tests/run_jetty6/Buildfile
new file mode 100644
index 0000000..e049e05
--- /dev/null
+++ b/tests/run_jetty6/Buildfile
@@ -0,0 +1,13 @@
+require 'buildr/jetty6'
+require 'readline'
+ 
+define "webapp", :group => 'com.example', :version => '1.0' do
+  compile.with(Buildr::Jetty6::REQUIRES, 'javax.servlet:javax.servlet-api:jar:3.1.0')
+  
+  task("deploy-app"=>[package(:war), jetty.use]) do |task|
+    class << task ; attr_accessor :url, :path ; end
+    task.url = "http://localhost:8080/hello"
+    task.path = jetty.deploy(task.url, task.prerequisites.first)
+  end
+ 
+end
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/buildr/blob/63120eee/tests/run_jetty6/src/main/java/MainServlet.java
----------------------------------------------------------------------
diff --git a/tests/run_jetty6/src/main/java/MainServlet.java b/tests/run_jetty6/src/main/java/MainServlet.java
new file mode 100644
index 0000000..f94d354
--- /dev/null
+++ b/tests/run_jetty6/src/main/java/MainServlet.java
@@ -0,0 +1,12 @@
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+public class MainServlet extends HttpServlet {
+    
+    public void service(HttpServletRequest request, HttpServletResponse response) throws IOException {
+        response.getWriter().println("Hello!");
+        response.setStatus(200);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/buildr/blob/63120eee/tests/run_jetty6/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/tests/run_jetty6/src/main/webapp/WEB-INF/web.xml b/tests/run_jetty6/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..9e71b89
--- /dev/null
+++ b/tests/run_jetty6/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns="http://java.sun.com/xml/ns/javaee"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+         version="3.0">
+
+    <servlet>
+        <servlet-name>MainServlet</servlet-name>
+        <servlet-class>MainServlet</servlet-class>
+        <load-on-startup>1</load-on-startup>
+    </servlet>
+    
+    <servlet-mapping>
+        <servlet-name>MainServlet</servlet-name>
+        <url-pattern>/</url-pattern>
+    </servlet-mapping>
+</web-app>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/buildr/blob/63120eee/tests/run_jetty9/Buildfile
----------------------------------------------------------------------
diff --git a/tests/run_jetty9/Buildfile b/tests/run_jetty9/Buildfile
new file mode 100644
index 0000000..78def3d
--- /dev/null
+++ b/tests/run_jetty9/Buildfile
@@ -0,0 +1,13 @@
+require 'buildr/jetty'
+require 'readline'
+ 
+define "webapp", :group => 'com.example', :version => '1.0' do
+  compile.with(Buildr::Jetty::REQUIRES)
+  
+  task("deploy-app"=>[package(:war), jetty.use]) do |task|
+    class << task ; attr_accessor :url, :path ; end
+    task.url = "http://localhost:8080/hello"
+    task.path = jetty.deploy(task.url, task.prerequisites.first)
+  end
+ 
+end
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/buildr/blob/63120eee/tests/run_jetty9/src/main/java/MainServlet.java
----------------------------------------------------------------------
diff --git a/tests/run_jetty9/src/main/java/MainServlet.java b/tests/run_jetty9/src/main/java/MainServlet.java
new file mode 100644
index 0000000..f94d354
--- /dev/null
+++ b/tests/run_jetty9/src/main/java/MainServlet.java
@@ -0,0 +1,12 @@
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+public class MainServlet extends HttpServlet {
+    
+    public void service(HttpServletRequest request, HttpServletResponse response) throws IOException {
+        response.getWriter().println("Hello!");
+        response.setStatus(200);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/buildr/blob/63120eee/tests/run_jetty9/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/tests/run_jetty9/src/main/webapp/WEB-INF/web.xml b/tests/run_jetty9/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..9e71b89
--- /dev/null
+++ b/tests/run_jetty9/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns="http://java.sun.com/xml/ns/javaee"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+         version="3.0">
+
+    <servlet>
+        <servlet-name>MainServlet</servlet-name>
+        <servlet-class>MainServlet</servlet-class>
+        <load-on-startup>1</load-on-startup>
+    </servlet>
+    
+    <servlet-mapping>
+        <servlet-name>MainServlet</servlet-name>
+        <url-pattern>/</url-pattern>
+    </servlet-mapping>
+</web-app>
\ No newline at end of file