[logback-dev] [GIT] Logback: the generic, reliable, fast and flexible logging framework. branch, master, updated. v_0.9.30-3-g6534cfc

added by portage for gitosis-gentoo git-noreply at pixie.qos.ch
Sun Sep 25 23:34:46 CEST 2011


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Logback: the generic, reliable, fast and flexible logging framework.".

The branch, master has been updated
       via  6534cfcc93d86c742aec1bdbe5f1b8844e6bd988 (commit)
      from  cdca3a24519d66a09e86b0dda5913e07b30d8031 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=6534cfcc93d86c742aec1bdbe5f1b8844e6bd988
http://github.com/ceki/logback/commit/6534cfcc93d86c742aec1bdbe5f1b8844e6bd988

commit 6534cfcc93d86c742aec1bdbe5f1b8844e6bd988
Author: Ceki Gulcu <ceki at qos.ch>
Date:   Sun Sep 25 23:31:35 2011 +0200

    - upgrade to Jetty 7 and Tomcat 7
    - refactoring of Jetty related test cases

diff --git a/logback-access/pom.xml b/logback-access/pom.xml
index 0850d03..c5d59ad 100644
--- a/logback-access/pom.xml
+++ b/logback-access/pom.xml
@@ -48,17 +48,18 @@
 
     <dependency>
       <groupId>org.apache.tomcat</groupId>
-      <artifactId>catalina</artifactId>
+      <artifactId>tomcat-catalina</artifactId>
       <scope>compile</scope>
       <optional>true</optional>
     </dependency>
 
-    <dependency>
-      <groupId>org.mortbay.jetty</groupId>
-      <artifactId>jetty</artifactId>
-      <scope>compile</scope>
-      <optional>true</optional>
-    </dependency>
+    <!--<dependency>-->
+      <!--<groupId>org.mortbay.jetty</groupId>-->
+      <!--<artifactId>jetty</artifactId>-->
+      <!--<scope>compile</scope>-->
+      <!--<optional>true</optional>-->
+    <!--</dependency>-->
+
 
     <dependency>
       <groupId>org.eclipse.jetty</groupId>
@@ -67,12 +68,12 @@
       <optional>true</optional>
     </dependency>
 
-    <dependency>
-      <groupId>org.mortbay.jetty</groupId>
-      <artifactId>servlet-api-2.5</artifactId>
-      <scope>compile</scope>
-      <optional>true</optional>
-    </dependency>
+    <!--<dependency>-->
+      <!--<groupId>org.mortbay.jetty</groupId>-->
+      <!--<artifactId>servlet-api-2.5</artifactId>-->
+      <!--<scope>compile</scope>-->
+      <!--<optional>true</optional>-->
+    <!--</dependency>-->
 
     <dependency>
       <groupId>janino</groupId>
diff --git a/logback-access/src/main/java/ch/qos/logback/access/jetty/JettyServerAdapter.java b/logback-access/src/main/java/ch/qos/logback/access/jetty/JettyServerAdapter.java
index 951d9dc..bdb2fbe 100644
--- a/logback-access/src/main/java/ch/qos/logback/access/jetty/JettyServerAdapter.java
+++ b/logback-access/src/main/java/ch/qos/logback/access/jetty/JettyServerAdapter.java
@@ -17,11 +17,12 @@ import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.mortbay.jetty.HttpFields;
-import org.mortbay.jetty.Request;
-import org.mortbay.jetty.Response;
+import org.eclipse.jetty.http.HttpFields;
+import org.eclipse.jetty.server.Request;
+import org.eclipse.jetty.server.Response;
 
 import ch.qos.logback.access.spi.ServerAdapter;
+import org.eclipse.jetty.server.Request;
 
 /**
  * A jetty specific implementation of the {@link ServerAdapter} interface.
diff --git a/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogImpl.java b/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogImpl.java
index c8a7298..2c0a06a 100644
--- a/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogImpl.java
+++ b/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogImpl.java
@@ -17,10 +17,13 @@ import java.io.File;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Properties;
+
+import ch.qos.logback.core.util.StatusPrinter;
+import org.eclipse.jetty.server.Request;
+import org.eclipse.jetty.server.RequestLog;
+import org.eclipse.jetty.server.Response;
 
-import org.mortbay.jetty.Request;
-import org.mortbay.jetty.RequestLog;
-import org.mortbay.jetty.Response;
 
 import ch.qos.logback.access.joran.JoranConfigurator;
 import ch.qos.logback.access.spi.AccessEvent;
@@ -39,6 +42,7 @@ import ch.qos.logback.core.status.ErrorStatus;
 import ch.qos.logback.core.status.InfoStatus;
 import ch.qos.logback.core.status.WarnStatus;
 import ch.qos.logback.core.util.OptionHelper;
+import org.eclipse.jetty.util.component.LifeCycle;
 
 /**
  * This class is logback's implementation of jetty's RequestLog interface. <p>
@@ -135,6 +139,8 @@ public class RequestLogImpl extends ContextBase implements RequestLog,
   }
 
   public void start() {
+    Properties p = System.getProperties();
+    System.out.println(p);
     if (filename == null) {
       String jettyHomeProperty = OptionHelper.getSystemProperty("jetty.home");
 
@@ -150,7 +156,6 @@ public class RequestLogImpl extends ContextBase implements RequestLog,
         JoranConfigurator jc = new JoranConfigurator();
         jc.setContext(this);
         jc.doConfigure(filename);
-
       } else {
         getStatusManager().add(
             new ErrorStatus("[" + filename + "] does not exist", this));
@@ -165,7 +170,6 @@ public class RequestLogImpl extends ContextBase implements RequestLog,
               + getName(), this));
 
       started = true;
-
     } catch (JoranException e) {
       // errors have been registered as status messages
     }
@@ -204,6 +208,7 @@ public class RequestLogImpl extends ContextBase implements RequestLog,
     return false;
   }
 
+
   public void addAppender(Appender<IAccessEvent> newAppender) {
     aai.addAppender(newAppender);
   }
@@ -249,4 +254,11 @@ public class RequestLogImpl extends ContextBase implements RequestLog,
     return fai.getFilterChainDecision(event);
   }
 
+  public void addLifeCycleListener(Listener listener) {
+    // we'll implement this when asked
+  }
+  public void removeLifeCycleListener(Listener listener) {
+    // we'll implement this when asked
+  }
+
 }
diff --git a/logback-access/src/main/java/ch/qos/logback/access/jetty/package.html b/logback-access/src/main/java/ch/qos/logback/access/jetty/package.html
index 20a34c3..bc2c3dc 100644
--- a/logback-access/src/main/java/ch/qos/logback/access/jetty/package.html
+++ b/logback-access/src/main/java/ch/qos/logback/access/jetty/package.html
@@ -7,7 +7,7 @@
   
   <body>
     
-    <p>This is logback access' implementation for Jetty.</p>
+    <p>This is logback access' implementation for Jetty 8.</p>
 
   </body> 
 </html>
\ No newline at end of file
diff --git a/logback-access/src/main/java/ch/qos/logback/access/tomcat/LogbackValve.java b/logback-access/src/main/java/ch/qos/logback/access/tomcat/LogbackValve.java
index 21fe551..ede5b77 100644
--- a/logback-access/src/main/java/ch/qos/logback/access/tomcat/LogbackValve.java
+++ b/logback-access/src/main/java/ch/qos/logback/access/tomcat/LogbackValve.java
@@ -24,6 +24,8 @@ import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
 
 import ch.qos.logback.access.spi.IAccessEvent;
+//import org.apache.catalina.Lifecycle;
+import ch.qos.logback.core.spi.*;
 import org.apache.catalina.Lifecycle;
 import org.apache.catalina.LifecycleListener;
 import org.apache.catalina.connector.Request;
@@ -39,11 +41,6 @@ import ch.qos.logback.core.Context;
 import ch.qos.logback.core.CoreConstants;
 import ch.qos.logback.core.filter.Filter;
 import ch.qos.logback.core.joran.spi.JoranException;
-import ch.qos.logback.core.spi.AppenderAttachable;
-import ch.qos.logback.core.spi.AppenderAttachableImpl;
-import ch.qos.logback.core.spi.FilterAttachable;
-import ch.qos.logback.core.spi.FilterAttachableImpl;
-import ch.qos.logback.core.spi.FilterReply;
 import ch.qos.logback.core.status.InfoStatus;
 import ch.qos.logback.core.status.StatusManager;
 import ch.qos.logback.core.status.WarnStatus;
@@ -91,7 +88,11 @@ public class LogbackValve extends ValveBase implements Lifecycle, Context,
     putObject(CoreConstants.EVALUATOR_MAP, new HashMap());
   }
 
-  public void start() {
+  public boolean isStarted() {
+    return started;
+  }
+
+  public void startInternal() {
     if (filename == null) {
       String tomcatHomeProperty = OptionHelper
           .getSystemProperty("catalina.home");
@@ -172,7 +173,7 @@ public class LogbackValve extends ValveBase implements Lifecycle, Context,
     }
   }
 
-  public void stop() {
+  public void stopInternal() {
     started = false;
   }
 
diff --git a/logback-access/src/test/java/ch/qos/logback/access/dummy/DummyRequest.java b/logback-access/src/test/java/ch/qos/logback/access/dummy/DummyRequest.java
index f9de7d4..db3d9f2 100644
--- a/logback-access/src/test/java/ch/qos/logback/access/dummy/DummyRequest.java
+++ b/logback-access/src/test/java/ch/qos/logback/access/dummy/DummyRequest.java
@@ -17,16 +17,10 @@ import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.security.Principal;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Locale;
-import java.util.Map;
+import java.util.*;
 
-import javax.servlet.RequestDispatcher;
-import javax.servlet.ServletInputStream;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
+import javax.servlet.*;
+import javax.servlet.http.*;
 
 import ch.qos.logback.access.AccessConstants;
 
@@ -141,6 +135,26 @@ public class DummyRequest implements HttpServletRequest {
     return false;
   }
 
+  public boolean authenticate(HttpServletResponse response) throws IOException, ServletException {
+    return false;  //To change body of implemented methods use File | Settings | File Templates.
+  }
+
+  public void login(String username, String password) throws ServletException {
+    //To change body of implemented methods use File | Settings | File Templates.
+  }
+
+  public void logout() throws ServletException {
+    //To change body of implemented methods use File | Settings | File Templates.
+  }
+
+  public Collection<Part> getParts() throws IOException, IllegalStateException, ServletException {
+    return null;  //To change body of implemented methods use File | Settings | File Templates.
+  }
+
+  public Part getPart(String name) throws IOException, IllegalStateException, ServletException {
+    return null;  //To change body of implemented methods use File | Settings | File Templates.
+  }
+
   public boolean isRequestedSessionIdValid() {
     return false;
   }
@@ -193,6 +207,34 @@ public class DummyRequest implements HttpServletRequest {
     return 11;
   }
 
+  public ServletContext getServletContext() {
+    return null;  //To change body of implemented methods use File | Settings | File Templates.
+  }
+
+  public AsyncContext startAsync() {
+    return null;  //To change body of implemented methods use File | Settings | File Templates.
+  }
+
+  public AsyncContext startAsync(ServletRequest servletRequest, ServletResponse servletResponse) {
+    return null;  //To change body of implemented methods use File | Settings | File Templates.
+  }
+
+  public boolean isAsyncStarted() {
+    return false;  //To change body of implemented methods use File | Settings | File Templates.
+  }
+
+  public boolean isAsyncSupported() {
+    return false;  //To change body of implemented methods use File | Settings | File Templates.
+  }
+
+  public AsyncContext getAsyncContext() {
+    return null;  //To change body of implemented methods use File | Settings | File Templates.
+  }
+
+  public DispatcherType getDispatcherType() {
+    return null;  //To change body of implemented methods use File | Settings | File Templates.
+  }
+
   public Locale getLocale() {
     return null;
   }
diff --git a/logback-access/src/test/java/ch/qos/logback/access/dummy/DummyResponse.java b/logback-access/src/test/java/ch/qos/logback/access/dummy/DummyResponse.java
index 3fd3691..2281eec 100644
--- a/logback-access/src/test/java/ch/qos/logback/access/dummy/DummyResponse.java
+++ b/logback-access/src/test/java/ch/qos/logback/access/dummy/DummyResponse.java
@@ -15,9 +15,7 @@ package ch.qos.logback.access.dummy;
 
 import java.io.IOException;
 import java.io.PrintWriter;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
+import java.util.*;
 
 import javax.servlet.ServletOutputStream;
 import javax.servlet.http.Cookie;
@@ -27,16 +25,17 @@ public class DummyResponse implements HttpServletResponse {
 
   public static final int DUMMY_DEFAULT_STATUS = 200;
   public static final int DUMMY_DEFAULT_CONTENT_COUNT = 1000;
-  public static final Map<String, String> DUMMY_DEFAULT_HDEADER_MAP = new HashMap<String, String>();;
-  
+  public static final Map<String, String> DUMMY_DEFAULT_HDEADER_MAP = new HashMap<String, String>();
+  ;
+
   static {
     DUMMY_DEFAULT_HDEADER_MAP.put("headerName1", "headerValue1");
     DUMMY_DEFAULT_HDEADER_MAP.put("headerName2", "headerValue2");
   }
-  
-  int status = DUMMY_DEFAULT_STATUS ;
+
+  int status = DUMMY_DEFAULT_STATUS;
   public Map<String, String> headerMap;
-  
+
   public DummyResponse() {
     headerMap = DUMMY_DEFAULT_HDEADER_MAP;
   }
@@ -145,15 +144,27 @@ public class DummyResponse implements HttpServletResponse {
 
   public void setLocale(Locale arg0) {
   }
-  
+
   public String getHeader(String key) {
     return headerMap.get(key);
   }
-  
+
+  public Collection<String> getHeaders(String name) {
+    String val = headerMap.get(name);
+    List list = new ArrayList();
+    if (val != null)
+      list.add(val);
+    return list;
+  }
+
+  public Collection<String> getHeaderNames() {
+    return headerMap.keySet();
+  }
+
   public long getContentCount() {
     return DUMMY_DEFAULT_CONTENT_COUNT;
   }
-  
+
   public int getStatus() {
     return status;
   }
@@ -161,5 +172,5 @@ public class DummyResponse implements HttpServletResponse {
   public void setStatus(int status) {
     this.status = status;
   }
-  
+
 }
diff --git a/logback-access/src/test/java/ch/qos/logback/access/jetty/JettyBasicTest.java b/logback-access/src/test/java/ch/qos/logback/access/jetty/JettyBasicTest.java
index ec43ab4..b6a9d58 100644
--- a/logback-access/src/test/java/ch/qos/logback/access/jetty/JettyBasicTest.java
+++ b/logback-access/src/test/java/ch/qos/logback/access/jetty/JettyBasicTest.java
@@ -33,21 +33,19 @@ import ch.qos.logback.core.testUtil.RandomUtil;
 public class JettyBasicTest {
 
   static RequestLogImpl REQYEST_LOG_IMPL;
-  static JettyFixture JETTY_FIXTURE;
+  static JettyFixtureWithListAndConsoleAppenders JETTY_FIXTURE;
 
   static int RANDOM_SERVER_PORT = RandomUtil.getRandomServerPort();
   
   @BeforeClass
   static public void startServer() throws Exception {
-    // System.out.println("*** JettyBasicTest.startServer called");
     REQYEST_LOG_IMPL = new RequestLogImpl();
-    JETTY_FIXTURE = new JettyFixture(REQYEST_LOG_IMPL, RANDOM_SERVER_PORT);
+    JETTY_FIXTURE = new JettyFixtureWithListAndConsoleAppenders(REQYEST_LOG_IMPL, RANDOM_SERVER_PORT);
     JETTY_FIXTURE.start();
   }
 
   @AfterClass
   static public void stopServer() throws Exception {
-    // System.out.println("*** JettyBasicTest.stopServer called");
     if (JETTY_FIXTURE != null) {
       JETTY_FIXTURE.stop();
     }
diff --git a/logback-access/src/test/java/ch/qos/logback/access/jetty/JettyFixture.java b/logback-access/src/test/java/ch/qos/logback/access/jetty/JettyFixture.java
deleted file mode 100644
index a6efecd..0000000
--- a/logback-access/src/test/java/ch/qos/logback/access/jetty/JettyFixture.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/**
- * Logback: the reliable, generic, fast and flexible logging framework.
- * Copyright (C) 1999-2011, QOS.ch. All rights reserved.
- *
- * This program and the accompanying materials are dual-licensed under
- * either the terms of the Eclipse Public License v1.0 as published by
- * the Eclipse Foundation
- *
- *   or (per the licensee's choosing)
- *
- * under the terms of the GNU Lesser General Public License version 2.1
- * as published by the Free Software Foundation.
- */
-package ch.qos.logback.access.jetty;
-
-import java.io.IOException;
-import java.io.OutputStream;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import ch.qos.logback.access.spi.IAccessEvent;
-import org.mortbay.jetty.Handler;
-import org.mortbay.jetty.HttpConnection;
-import org.mortbay.jetty.Request;
-import org.mortbay.jetty.handler.AbstractHandler;
-import org.mortbay.util.ByteArrayISO8859Writer;
-
-import ch.qos.logback.access.PatternLayoutEncoder;
-import ch.qos.logback.access.testUtil.NotifyingListAppender;
-import ch.qos.logback.core.ConsoleAppender;
-
-public class JettyFixture extends JettyFixtureBase {
-  
-  Handler handler = new BasicHandler();
-  
-  public JettyFixture(RequestLogImpl impl, int port) {
-    super(impl, port);
-    url = "http://localhost:" + port + "/";
-  }
-
-  public void start() throws Exception {
-    super.start();
-    Thread.yield();
-  }
-
-  public void stop() throws Exception {
-    super.stop();
-    Thread.sleep(500);
-  }
-
-  protected void buildContext() {
-    NotifyingListAppender appender = new NotifyingListAppender();
-    appender.setContext(requestLogImpl);
-    appender.setName("list");
-    appender.start();
-
-    ConsoleAppender<IAccessEvent> console = new ConsoleAppender<IAccessEvent>();
-    console.setContext(requestLogImpl);
-    console.setName("console");
-    PatternLayoutEncoder layout = new PatternLayoutEncoder();
-    layout.setContext(requestLogImpl);
-    layout.setPattern("%date %server %clientHost");
-    console.setEncoder(layout);
-    layout.start();
-    console.start();
-
-    requestLogImpl.addAppender(appender);
-    requestLogImpl.addAppender(console);
-  }
-
-  @Override
-  protected Handler getHandler() {
-    return handler;
-  }
-
-}
-
-class BasicHandler extends AbstractHandler {
-  public void handle(String target, HttpServletRequest request,
-      HttpServletResponse response, int dispatch) throws IOException,
-      ServletException {
-
-    // String requestContent = Util.readToString(request.getInputStream());
-    // System.out.println("request content: " + requestContent);
-
-    OutputStream out = response.getOutputStream();
-    ByteArrayISO8859Writer writer = new ByteArrayISO8859Writer();
-    writer.write("hello world");
-    writer.flush();
-    response.setContentLength(writer.size());
-    writer.writeTo(out);
-    out.flush();
-
-    Request base_request = (request instanceof Request) ? (Request) request
-        : HttpConnection.getCurrentConnection().getRequest();
-    base_request.setHandled(true);
-
-  }
-}
diff --git a/logback-access/src/test/java/ch/qos/logback/access/jetty/JettyFixtureBase.java b/logback-access/src/test/java/ch/qos/logback/access/jetty/JettyFixtureBase.java
index bc0b4df..e4279cb 100644
--- a/logback-access/src/test/java/ch/qos/logback/access/jetty/JettyFixtureBase.java
+++ b/logback-access/src/test/java/ch/qos/logback/access/jetty/JettyFixtureBase.java
@@ -13,20 +13,29 @@
  */
 package ch.qos.logback.access.jetty;
 
-import org.mortbay.jetty.Connector;
-import org.mortbay.jetty.Handler;
-import org.mortbay.jetty.Server;
-import org.mortbay.jetty.handler.ContextHandler;
-import org.mortbay.jetty.handler.RequestLogHandler;
-import org.mortbay.jetty.nio.SelectChannelConnector;
+import org.eclipse.jetty.server.Connector;
+import org.eclipse.jetty.server.Request;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.Handler;
+import org.eclipse.jetty.server.handler.AbstractHandler;
+import org.eclipse.jetty.server.handler.HandlerList;
+import org.eclipse.jetty.server.handler.RequestLogHandler;
+import org.eclipse.jetty.server.nio.SelectChannelConnector;
+import org.eclipse.jetty.util.ByteArrayISO8859Writer;
 
-abstract public class JettyFixtureBase {
-  protected RequestLogImpl requestLogImpl;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.OutputStream;
 
+public class JettyFixtureBase {
+  final protected RequestLogImpl requestLogImpl;
+  protected Handler handler = new BasicHandler();
   private final int port;
   Server server;
-  String url;
-  
+  protected String url;
+
   public JettyFixtureBase(RequestLogImpl impl, int port) {
     requestLogImpl = impl;
     this.port = port;
@@ -45,32 +54,48 @@ abstract public class JettyFixtureBase {
     server = new Server();
     Connector connector = new SelectChannelConnector();
     connector.setPort(port);
-    server.setConnectors(new Connector[] { connector });
-
-    ContextHandler context = new ContextHandler();
-    context.setContextPath("/");
-    context.setResourceBase(".");
-    context.setClassLoader(Thread.currentThread().getContextClassLoader());
-    server.addHandler(context);
+    server.setConnectors(new Connector[]{connector});
 
     RequestLogHandler requestLogHandler = new RequestLogHandler();
-    buildContext();
+    configureRequestLogImpl();
     requestLogHandler.setRequestLog(requestLogImpl);
-    server.addHandler(requestLogHandler);
 
-    Handler handler = getHandler();
-    context.addHandler(handler);
+    HandlerList handlers = new HandlerList();
+    handlers.addHandler(requestLogHandler);
+    handlers.addHandler(getRequestHandler());
 
+    server.setHandler(handlers);
     server.start();
   }
 
   public void stop() throws Exception {
-    // System.out.println("into tearDown");
     server.stop();
     server = null;
-    requestLogImpl = null;
   }
 
-  abstract protected void buildContext();
-  abstract protected Handler getHandler();
+  protected void configureRequestLogImpl() {
+    requestLogImpl.start();
+  }
+
+  protected Handler getRequestHandler() {
+    return handler;
+  }
+
+
+  class BasicHandler extends AbstractHandler {
+    public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
+      OutputStream out = response.getOutputStream();
+      ByteArrayISO8859Writer writer = new ByteArrayISO8859Writer();
+      writer.write("hello world");
+      writer.flush();
+      response.setContentLength(writer.size());
+      writer.writeTo(out);
+      out.flush();
+
+      baseRequest.setHandled(true);
+
+    }
+  }
 }
+
+
diff --git a/logback-access/src/test/java/ch/qos/logback/access/jetty/JettyFixtureWithListAndConsoleAppenders.java b/logback-access/src/test/java/ch/qos/logback/access/jetty/JettyFixtureWithListAndConsoleAppenders.java
new file mode 100644
index 0000000..9f40a10
--- /dev/null
+++ b/logback-access/src/test/java/ch/qos/logback/access/jetty/JettyFixtureWithListAndConsoleAppenders.java
@@ -0,0 +1,59 @@
+/**
+ * Logback: the reliable, generic, fast and flexible logging framework.
+ * Copyright (C) 1999-2011, QOS.ch. All rights reserved.
+ *
+ * This program and the accompanying materials are dual-licensed under
+ * either the terms of the Eclipse Public License v1.0 as published by
+ * the Eclipse Foundation
+ *
+ *   or (per the licensee's choosing)
+ *
+ * under the terms of the GNU Lesser General Public License version 2.1
+ * as published by the Free Software Foundation.
+ */
+package ch.qos.logback.access.jetty;
+
+import ch.qos.logback.access.spi.IAccessEvent;
+import ch.qos.logback.access.PatternLayoutEncoder;
+import ch.qos.logback.access.testUtil.NotifyingListAppender;
+import ch.qos.logback.core.ConsoleAppender;
+
+public class JettyFixtureWithListAndConsoleAppenders extends JettyFixtureBase {
+
+  public JettyFixtureWithListAndConsoleAppenders(RequestLogImpl impl, int port) {
+    super(impl, port);
+    url = "http://localhost:" + port + "/";
+  }
+
+  public void start() throws Exception {
+    super.start();
+    Thread.yield();
+  }
+
+  public void stop() throws Exception {
+    super.stop();
+    Thread.sleep(500);
+  }
+
+  @Override
+  protected void configureRequestLogImpl() {
+    NotifyingListAppender appender = new NotifyingListAppender();
+    appender.setContext(requestLogImpl);
+    appender.setName("list");
+    appender.start();
+
+    ConsoleAppender<IAccessEvent> console = new ConsoleAppender<IAccessEvent>();
+    console.setContext(requestLogImpl);
+    console.setName("console");
+    PatternLayoutEncoder layout = new PatternLayoutEncoder();
+    layout.setContext(requestLogImpl);
+    layout.setPattern("%date %server %clientHost");
+    console.setEncoder(layout);
+    layout.start();
+    console.start();
+
+    requestLogImpl.addAppender(appender);
+    requestLogImpl.addAppender(console);
+  }
+}
+
diff --git a/logback-access/src/test/java/ch/qos/logback/access/sift/JettyFixture.java b/logback-access/src/test/java/ch/qos/logback/access/sift/JettyFixture.java
deleted file mode 100644
index 470e791..0000000
--- a/logback-access/src/test/java/ch/qos/logback/access/sift/JettyFixture.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/**
- * Logback: the reliable, generic, fast and flexible logging framework.
- * Copyright (C) 1999-2011, QOS.ch. All rights reserved.
- *
- * This program and the accompanying materials are dual-licensed under
- * either the terms of the Eclipse Public License v1.0 as published by
- * the Eclipse Foundation
- *
- *   or (per the licensee's choosing)
- *
- * under the terms of the GNU Lesser General Public License version 2.1
- * as published by the Free Software Foundation.
- */
-package ch.qos.logback.access.sift;
-
-import java.io.IOException;
-import java.io.OutputStream;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.mortbay.jetty.Handler;
-import org.mortbay.jetty.HttpConnection;
-import org.mortbay.jetty.Request;
-import org.mortbay.jetty.handler.AbstractHandler;
-import org.mortbay.util.ByteArrayISO8859Writer;
-
-import ch.qos.logback.access.jetty.JettyFixtureBase;
-import ch.qos.logback.access.jetty.RequestLogImpl;
-
-public class JettyFixture extends JettyFixtureBase {
-
-  Handler handler = new BasicHandler();
-
-  public JettyFixture(RequestLogImpl impl, int port) {
-    super(impl, port);
-  }
-
-  @Override
-  protected void buildContext() {
-    requestLogImpl.start();
-  }
-
-  @Override
-  protected Handler getHandler() {
-    return handler;
-  }
-
-  class BasicHandler extends AbstractHandler {
-    public void handle(String target, HttpServletRequest request,
-        HttpServletResponse response, int dispatch) throws IOException,
-        ServletException {
-
-      // String requestContent = Util.readToString(request.getInputStream());
-      // System.out.println("request content: " + requestContent);
-
-      OutputStream out = response.getOutputStream();
-      ByteArrayISO8859Writer writer = new ByteArrayISO8859Writer();
-      writer.write("hello world");
-      writer.flush();
-      response.setContentLength(writer.size());
-      writer.writeTo(out);
-      out.flush();
-
-      Request base_request = (request instanceof Request) ? (Request) request
-          : HttpConnection.getCurrentConnection().getRequest();
-      base_request.setHandled(true);
-
-    }
-  }
-}
diff --git a/logback-access/src/test/java/ch/qos/logback/access/sift/SiftingAppenderTest.java b/logback-access/src/test/java/ch/qos/logback/access/sift/SiftingAppenderTest.java
index 8168aaa..7e7231d 100644
--- a/logback-access/src/test/java/ch/qos/logback/access/sift/SiftingAppenderTest.java
+++ b/logback-access/src/test/java/ch/qos/logback/access/sift/SiftingAppenderTest.java
@@ -20,6 +20,7 @@ import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
 
+import ch.qos.logback.access.jetty.JettyFixtureBase;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -35,13 +36,12 @@ public class SiftingAppenderTest {
   static final String PREFIX = "src/test/input/jetty/";
   static int RANDOM_SERVER_PORT = RandomUtil.getRandomServerPort();
 
-  JettyFixture jettyFixture;
+  JettyFixtureBase jettyFixture;
   RequestLogImpl rli = new RequestLogImpl();
 
   @Before
   public void startServer() throws Exception {
-    jettyFixture = new JettyFixture(rli, RANDOM_SERVER_PORT);
-
+    jettyFixture = new JettyFixtureBase(rli, RANDOM_SERVER_PORT);
   }
 
   @After
@@ -52,18 +52,15 @@ public class SiftingAppenderTest {
   }
 
   @Test
-  public void test() throws Exception {
+  public void invokingDifferentPathShouldBeSiftedAccordingly() throws Exception {
     rli.setFileName(PREFIX + "sifting.xml");
     jettyFixture.start();
-
-
     StatusPrinter.print(rli);
     invokeServer("/");
     invokeServer("/x");
     invokeServer("/x");
     invokeServer("/y");
 
-    
     SiftingAppender siftingAppender = (SiftingAppender) rli
         .getAppender("SIFTING");
     List<String> keyList = siftingAppender.getAppenderTracker().keyList();
@@ -76,22 +73,16 @@ public class SiftingAppenderTest {
     assertEquals(witnessList, keyList);
 
     long now = System.currentTimeMillis();
-    {
-      ListAppender<IAccessEvent> listAppender = (ListAppender<IAccessEvent>) siftingAppender
-          .getAppenderTracker().get("NA", now);
-      assertEquals(1, listAppender.list.size());
-    }
-    
-    {
-      ListAppender<IAccessEvent> listAppender = (ListAppender<IAccessEvent>) siftingAppender
-          .getAppenderTracker().get("x", now);
-      assertEquals(2, listAppender.list.size());
-    }
-    {
-      ListAppender<IAccessEvent> listAppender = (ListAppender<IAccessEvent>) siftingAppender
-          .getAppenderTracker().get("y", now);
-      assertEquals(1, listAppender.list.size());
-    }
+    check(siftingAppender, "NA", 1, now);
+    check(siftingAppender, "x", 2, now);
+    check(siftingAppender, "y", 1, now);
+
+  }
+
+  private void check(SiftingAppender siftingAppender, String key, int expectedCount, long now) {
+    ListAppender<IAccessEvent> listAppender = (ListAppender<IAccessEvent>) siftingAppender
+      .getAppenderTracker().get(key, now);
+    assertEquals(expectedCount, listAppender.list.size());
   }
 
   void invokeServer(String uri) throws Exception {
@@ -99,6 +90,6 @@ public class SiftingAppenderTest {
     HttpURLConnection connection = (HttpURLConnection) url.openConnection();
     connection.setDoInput(true);
     Util.readToString(connection.getInputStream());
-    Thread.sleep(30);
+    Thread.sleep(10);
   }
 }
diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/SMTPAppenderBase.java b/logback-core/src/main/java/ch/qos/logback/core/net/SMTPAppenderBase.java
index a0d72d0..97a7258 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/net/SMTPAppenderBase.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/net/SMTPAppenderBase.java
@@ -128,7 +128,7 @@ public abstract class SMTPAppenderBase<E> extends AppenderBase<E> {
       addError("Both SSL and StartTLS cannot be enabled simultaneously");
     } else {
       if (isSTARTTLS()) {
-        props.setProperty("mail.smtp.auth", "true");
+        //props.setProperty("mail.smtp.auth", "true");
         props.put("mail.smtp.starttls.enable", "true");
       }
       if (isSSL()) {
diff --git a/logback-site/src/site/pages/access.html b/logback-site/src/site/pages/access.html
index eba8f76..2fe4f94 100644
--- a/logback-site/src/site/pages/access.html
+++ b/logback-site/src/site/pages/access.html
@@ -164,18 +164,19 @@
 		<em>logback-core-VERSION.jar</em> and
 		<em>logback-access-VERSION.jar</em> under $JETTY_HOME/lib
 		directory, where $JETTY_HOME is the folder where you have
-		installed Jetty. We have tested logback-access module with Jetty
-		version 6.0 as well as 6.1.
+		installed Jetty. Versions of logback-access 0.9.31 and later taget
+		Jetty version 7.x as well as 8.x. Logback-access versions 0.9.30
+		and earlier target Jetty version 6.x.
 		</p>
 
 		<h3>Logback's implementation of
-		<code>org.mortbay.jetty.RequestLog</code> interface</h3>
+		<code>org.eclipse.jetty.server.RequestLog</code> interface</h3>
 
 		<p>The <a
 		href="xref/ch/qos/logback/access/jetty/RequestLogImpl.html">
 		<code>ch.qos.logback.access.jetty.RequestLogImpl</code></a> class
 		implements Jetty's <code><a
-		href="http://jetty.mortbay.org/apidocs/org/mortbay/jetty/RequestLog.html">RequestLog</a></code>
+		href="http://download.eclipse.org/jetty/stable-7/apidocs/org/eclipse/jetty/server/RequestLog.html">RequestLog</a></code>
 		interface. Jetty delegates the management of access logging
 		functionality to implementations of this interface.
 		</p>
@@ -202,15 +203,14 @@
 		<p>By default, <code>RequestLogImpl</code> looks for a logback
 		configuration file called <em>logback-access.xml</em>, in the same
 		folder where <em>jetty.xml</em> is located. This configuration
-		file contains directives for configuring logback components. Among
-		others, you can specify the appenders where the logging requests
-		will be sent, and their format.
+		file contains directives for configuring logback components such
+		as appenders and layouts.
     </p>
 	
 		<p>As long the path is specified, you can place the logback
 		configuration file in any location. Here is another example of a
-		Jetty configuration file, including the path to the
-		<em>logback-access.xml</em> configuration file.
+		Jetty configuration file, including the path to the logback-access
+		configuration file here named <em>myaccess.xml</em>.
 		</p>
 		
     <pre class="prettyprint source">&lt;Ref id="requestLog"&gt;
diff --git a/pom.xml b/pom.xml
index 33e54a8..2fc2208 100755
--- a/pom.xml
+++ b/pom.xml
@@ -37,6 +37,9 @@
     <groovy.version>1.7.6</groovy.version>
     <surefire.version>2.6</surefire.version>
     <consolePlugin.version>1.1.0</consolePlugin.version>
+    <tomcat.version>7.0.21</tomcat.version>
+    <jetty.version>7.5.1.v20110908</jetty.version>
+    <!--<jetty.version>8.0.1.v20110908</jetty.version>-->
   </properties>
 
   <dependencies>
@@ -131,8 +134,8 @@
 
       <dependency>
         <groupId>org.apache.tomcat</groupId>
-        <artifactId>catalina</artifactId>
-        <version>6.0.20</version>
+        <artifactId>tomcat-catalina</artifactId>
+        <version>${tomcat.version}</version>
       </dependency>
       <dependency>
         <groupId>org.mortbay.jetty</groupId>
@@ -142,13 +145,15 @@
       <dependency>
         <groupId>org.eclipse.jetty</groupId>
         <artifactId>jetty-server</artifactId>
-        <version>7.0.1.v20091125</version>
+        <version>${jetty.version}</version>
       </dependency>
+      <!--
       <dependency>
         <groupId>org.mortbay.jetty</groupId>
         <artifactId>servlet-api-2.5</artifactId>
         <version>6.1.1</version>
       </dependency>
+      -->
       <dependency>
         <groupId>org.apache.geronimo.specs</groupId>
         <artifactId>geronimo-jms_1.1_spec</artifactId>

-----------------------------------------------------------------------

Summary of changes:
 logback-access/pom.xml                             |   27 +++---
 .../logback/access/jetty/JettyServerAdapter.java   |    7 +-
 .../qos/logback/access/jetty/RequestLogImpl.java   |   22 ++++-
 .../java/ch/qos/logback/access/jetty/package.html  |    2 +-
 .../ch/qos/logback/access/tomcat/LogbackValve.java |   15 ++--
 .../ch/qos/logback/access/dummy/DummyRequest.java  |   60 ++++++++++--
 .../ch/qos/logback/access/dummy/DummyResponse.java |   35 +++++---
 .../qos/logback/access/jetty/JettyBasicTest.java   |    6 +-
 .../ch/qos/logback/access/jetty/JettyFixture.java  |  101 --------------------
 .../qos/logback/access/jetty/JettyFixtureBase.java |   75 ++++++++++-----
 .../JettyFixtureWithListAndConsoleAppenders.java   |   59 ++++++++++++
 .../ch/qos/logback/access/sift/JettyFixture.java   |   72 --------------
 .../logback/access/sift/SiftingAppenderTest.java   |   39 +++-----
 .../ch/qos/logback/core/net/SMTPAppenderBase.java  |    2 +-
 logback-site/src/site/pages/access.html            |   18 ++--
 pom.xml                                            |   11 ++-
 16 files changed, 262 insertions(+), 289 deletions(-)
 delete mode 100644 logback-access/src/test/java/ch/qos/logback/access/jetty/JettyFixture.java
 create mode 100644 logback-access/src/test/java/ch/qos/logback/access/jetty/JettyFixtureWithListAndConsoleAppenders.java
 delete mode 100644 logback-access/src/test/java/ch/qos/logback/access/sift/JettyFixture.java


hooks/post-receive
-- 
Logback: the generic, reliable, fast and flexible logging framework.


More information about the logback-dev mailing list