james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r1076126 - in /james/mailbox-integration-tester/trunk: ./ src/main/java/org/apache/james/imap/tester/ src/test/java/org/apache/james/mailbox/jcr/host/ src/test/java/org/apache/james/mailbox/jpa/host/
Date Wed, 02 Mar 2011 07:14:07 GMT
Author: norman
Date: Wed Mar  2 07:14:06 2011
New Revision: 1076126

URL: http://svn.apache.org/viewvc?rev=1076126&view=rev
Log:
Replace commons-logging with slf4j. Thanks to Felix Knecht for the patch. See MAILBOX-41

Modified:
    james/mailbox-integration-tester/trunk/pom.xml
    james/mailbox-integration-tester/trunk/src/main/java/org/apache/james/imap/tester/ImapSessionImpl.java
    james/mailbox-integration-tester/trunk/src/main/java/org/apache/james/imap/tester/SilentLog.java
    james/mailbox-integration-tester/trunk/src/main/java/org/apache/james/imap/tester/VerboseConsoleLog.java
    james/mailbox-integration-tester/trunk/src/test/java/org/apache/james/mailbox/jcr/host/JCRHostSystem.java
    james/mailbox-integration-tester/trunk/src/test/java/org/apache/james/mailbox/jpa/host/JPAHostSystem.java

Modified: james/mailbox-integration-tester/trunk/pom.xml
URL: http://svn.apache.org/viewvc/james/mailbox-integration-tester/trunk/pom.xml?rev=1076126&r1=1076125&r2=1076126&view=diff
==============================================================================
--- james/mailbox-integration-tester/trunk/pom.xml (original)
+++ james/mailbox-integration-tester/trunk/pom.xml Wed Mar  2 07:14:06 2011
@@ -19,7 +19,7 @@
 -->
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <parent>
-    <artifactId>apache-james-mailbox-parent</artifactId>
+    <artifactId>apache-james-mailbox</artifactId>
     <groupId>org.apache.james</groupId>
     <version>0.2-M2-SNAPSHOT</version>
   </parent>
@@ -62,14 +62,22 @@
       <artifactId>${javax.mail.artifactId}</artifactId>
     </dependency>
     <dependency>
-      <groupId>commons-logging</groupId>
-      <artifactId>commons-logging</artifactId>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-api</artifactId>
+      <version>1.6.1</version>
     </dependency>
     <dependency>
       <groupId>org.apache.james</groupId>
       <artifactId>apache-james-mailbox-jcr</artifactId>
       <scope>test</scope>
     </dependency>
+    <!-- As mime4j use commons-logging we need to specify the binding here -->
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>jcl-over-slf4j</artifactId>
+      <version>1.6.1</version>
+      <scope>test</scope>
+    </dependency>
     
     <!-- Use lucene 2.4.1 for now to let jcr tests pass -->
     <dependency>
@@ -131,6 +139,7 @@
     <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-log4j12</artifactId>
+      <version>1.6.1</version>
       <scope>test</scope>
     </dependency>
   </dependencies>

Modified: james/mailbox-integration-tester/trunk/src/main/java/org/apache/james/imap/tester/ImapSessionImpl.java
URL: http://svn.apache.org/viewvc/james/mailbox-integration-tester/trunk/src/main/java/org/apache/james/imap/tester/ImapSessionImpl.java?rev=1076126&r1=1076125&r2=1076126&view=diff
==============================================================================
--- james/mailbox-integration-tester/trunk/src/main/java/org/apache/james/imap/tester/ImapSessionImpl.java
(original)
+++ james/mailbox-integration-tester/trunk/src/main/java/org/apache/james/imap/tester/ImapSessionImpl.java
Wed Mar  2 07:14:06 2011
@@ -21,11 +21,11 @@ package org.apache.james.imap.tester;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
-import org.apache.commons.logging.Log;
 import org.apache.james.imap.api.ImapSessionState;
 import org.apache.james.imap.api.process.ImapLineHandler;
 import org.apache.james.imap.api.process.ImapSession;
 import org.apache.james.imap.api.process.SelectedMailbox;
+import org.slf4j.Logger;
 
 public class ImapSessionImpl implements ImapSession{
 
@@ -36,9 +36,9 @@ public class ImapSessionImpl implements 
 
     private final Map<String, Object> attributesByKey;
 
-	private Log log;
+	private Logger log;
 
-    public ImapSessionImpl(Log log) {
+    public ImapSessionImpl(Logger log) {
         this.attributesByKey = new ConcurrentHashMap<String, Object>();
         this.log = log;
     }
@@ -91,7 +91,7 @@ public class ImapSessionImpl implements 
         }
     }
 
-    public Log getLog() {
+    public Logger getLog() {
         return log;
     }
 

Modified: james/mailbox-integration-tester/trunk/src/main/java/org/apache/james/imap/tester/SilentLog.java
URL: http://svn.apache.org/viewvc/james/mailbox-integration-tester/trunk/src/main/java/org/apache/james/imap/tester/SilentLog.java?rev=1076126&r1=1076125&r2=1076126&view=diff
==============================================================================
--- james/mailbox-integration-tester/trunk/src/main/java/org/apache/james/imap/tester/SilentLog.java
(original)
+++ james/mailbox-integration-tester/trunk/src/main/java/org/apache/james/imap/tester/SilentLog.java
Wed Mar  2 07:14:06 2011
@@ -19,9 +19,10 @@
 
 package org.apache.james.imap.tester;
 
-import org.apache.commons.logging.Log;
+import org.slf4j.Logger;
+import org.slf4j.Marker;
 
-final class SilentLog implements Log {
+final class SilentLog implements Logger {
     public void debug(Object arg0) {
     }
 
@@ -93,4 +94,179 @@ final class SilentLog implements Log {
 
     public void trace(Object arg0, Throwable arg1) {
     }
+
+    public String getName() {
+	return "SilentLog";
+    }
+
+    public void trace(String msg) {
+    }
+
+    public void trace(String format, Object arg) {
+    }
+
+    public void trace(String format, Object arg1, Object arg2) {
+    }
+
+    public void trace(String format, Object[] argArray) {
+    }
+
+    public void trace(String msg, Throwable t) {
+    }
+
+    public boolean isTraceEnabled(Marker marker) {
+	return false;
+    }
+
+    public void trace(Marker marker, String msg) {
+    }
+
+    public void trace(Marker marker, String format, Object arg) {
+    }
+
+    public void trace(Marker marker, String format, Object arg1, Object arg2) {
+    }
+
+    public void trace(Marker marker, String format, Object[] argArray) {
+    }
+
+    public void trace(Marker marker, String msg, Throwable t) {
+    }
+
+    public void debug(String msg) {
+    }
+
+    public void debug(String format, Object arg) {
+    }
+
+    public void debug(String format, Object arg1, Object arg2) {
+    }
+
+    public void debug(String format, Object[] argArray) {
+    }
+
+    public void debug(String msg, Throwable t) {
+    }
+
+    public boolean isDebugEnabled(Marker marker) {
+	return false;
+    }
+
+    public void debug(Marker marker, String msg) {
+    }
+
+    public void debug(Marker marker, String format, Object arg) {
+    }
+
+    public void debug(Marker marker, String format, Object arg1, Object arg2) {
+    }
+
+    public void debug(Marker marker, String format, Object[] argArray) {
+    }
+
+    public void debug(Marker marker, String msg, Throwable t) {
+    }
+
+    public void info(String msg) {
+    }
+
+    public void info(String format, Object arg) {
+    }
+
+    public void info(String format, Object arg1, Object arg2) {
+    }
+
+    public void info(String format, Object[] argArray) {
+    }
+
+    public void info(String msg, Throwable t) {
+    }
+
+    public boolean isInfoEnabled(Marker marker) {
+	return false;
+    }
+
+    public void info(Marker marker, String msg) {
+    }
+
+    public void info(Marker marker, String format, Object arg) {
+    }
+
+    public void info(Marker marker, String format, Object arg1, Object arg2) {
+    }
+
+    public void info(Marker marker, String format, Object[] argArray) {
+    }
+
+    public void info(Marker marker, String msg, Throwable t) {
+    }
+
+    public void warn(String msg) {
+    }
+
+    public void warn(String format, Object arg) {
+    }
+
+    public void warn(String format, Object[] argArray) {
+    }
+
+    public void warn(String format, Object arg1, Object arg2) {
+    }
+
+    public void warn(String msg, Throwable t) {
+    }
+
+    public boolean isWarnEnabled(Marker marker) {
+	return false;
+    }
+
+    public void warn(Marker marker, String msg) {
+    }
+
+    public void warn(Marker marker, String format, Object arg) {
+    }
+
+    public void warn(Marker marker, String format, Object arg1, Object arg2) {
+    }
+
+    public void warn(Marker marker, String format, Object[] argArray) {
+    }
+
+    public void warn(Marker marker, String msg, Throwable t) {
+    }
+
+    public void error(String msg) {
+    }
+
+    public void error(String format, Object arg) {
+    }
+
+    public void error(String format, Object arg1, Object arg2) {
+    }
+
+    public void error(String format, Object[] argArray) {
+    }
+
+    public void error(String msg, Throwable t) {
+    }
+
+    public boolean isErrorEnabled(Marker marker) {
+	return false;
+    }
+
+    public void error(Marker marker, String msg) {
+    }
+
+    public void error(Marker marker, String format, Object arg) {
+    }
+
+    public void error(Marker marker, String format, Object arg1, Object arg2) {
+    }
+
+    public void error(Marker marker, String format, Object[] argArray) {
+    }
+
+    public void error(Marker marker, String msg, Throwable t) {
+    }
+
 }
\ No newline at end of file

Modified: james/mailbox-integration-tester/trunk/src/main/java/org/apache/james/imap/tester/VerboseConsoleLog.java
URL: http://svn.apache.org/viewvc/james/mailbox-integration-tester/trunk/src/main/java/org/apache/james/imap/tester/VerboseConsoleLog.java?rev=1076126&r1=1076125&r2=1076126&view=diff
==============================================================================
--- james/mailbox-integration-tester/trunk/src/main/java/org/apache/james/imap/tester/VerboseConsoleLog.java
(original)
+++ james/mailbox-integration-tester/trunk/src/main/java/org/apache/james/imap/tester/VerboseConsoleLog.java
Wed Mar  2 07:14:06 2011
@@ -18,91 +18,307 @@
  ****************************************************************/
 package org.apache.james.imap.tester;
 
-import org.apache.commons.logging.Log;
+import org.slf4j.Logger;
+import org.slf4j.Marker;
 
-public class VerboseConsoleLog implements Log {
+public class VerboseConsoleLog implements Logger {
 
-    public void debug(Object message) {
-        System.out.println(message);
+    public String getName() {
+        return "MockLogger to System out";
     }
 
-    public void debug(Object message, Throwable t) {
-        System.out.println(message);
-        t.printStackTrace();
+    public boolean isTraceEnabled() {
+        return true;
+    }
+
+    public void trace(String msg) {
+        SysPrint(msg);
+    }
+
+    public void trace(String format, Object arg) {
+        SysPrint(format, arg);
     }
 
-    public void error(Object message) {
-        System.out.println(message);
-        
+    public void trace(String format, Object arg1, Object arg2) {
+        SysPrint(format, arg1, arg2);
     }
 
-    public void error(Object message, Throwable t) {
-        System.out.println(message);
-        t.printStackTrace();
+    public void trace(String format, Object[] argArray) {
+        SysPrint(format, argArray);
     }
 
-    public void fatal(Object message) {
-        System.out.println(message);
-        
+    public void trace(String msg, Throwable t) {
+        SysPrint(msg, t);
     }
 
-    public void fatal(Object message, Throwable t) {
-        System.out.println(message);
-        t.printStackTrace();
+    public boolean isTraceEnabled(Marker marker) {
+        return true;
+    }
+
+    public void trace(Marker marker, String msg) {
+        SysPrint(marker, msg);
     }
 
-    public void info(Object message) {
-        System.out.println(message);
-        
+    public void trace(Marker marker, String format, Object arg) {
+        SysPrint(marker, format, arg);
     }
 
-    public void info(Object message, Throwable t) {
-        System.out.println(message);
-        t.printStackTrace();
+    public void trace(Marker marker, String format, Object arg1, Object arg2) {
+        SysPrint(marker, format, arg1, arg2);
+    }
+
+    public void trace(Marker marker, String format, Object[] argArray) {
+        SysPrint(marker, format, argArray);
+    }
+
+    public void trace(Marker marker, String msg, Throwable t) {
+        SysPrint(marker, msg, t);
     }
 
     public boolean isDebugEnabled() {
         return true;
     }
 
-    public boolean isErrorEnabled() {
-        return true;
+    public void debug(String msg) {
+        SysPrint(msg);
+    }
+
+    public void debug(String format, Object arg) {
+        SysPrint(format, arg);
+    }
+
+    public void debug(String format, Object arg1, Object arg2) {
+        SysPrint(format, arg1, arg2);
+    }
+
+    public void debug(String format, Object[] argArray) {
+        SysPrint(format, argArray);
+    }
+
+    public void debug(String msg, Throwable t) {
+        SysPrint(msg, t);
     }
 
-    public boolean isFatalEnabled() {
+    public boolean isDebugEnabled(Marker marker) {
         return true;
     }
 
+    public void debug(Marker marker, String msg) {
+        SysPrint(marker, msg);
+    }
+
+    public void debug(Marker marker, String format, Object arg) {
+        SysPrint(marker, format, arg);
+    }
+
+    public void debug(Marker marker, String format, Object arg1, Object arg2) {
+        SysPrint(marker, format, arg1, arg2);
+    }
+
+    public void debug(Marker marker, String format, Object[] argArray) {
+        SysPrint(marker, format, argArray);
+    }
+
+    public void debug(Marker marker, String msg, Throwable t) {
+        SysPrint(marker, msg, t);
+    }
+
     public boolean isInfoEnabled() {
         return true;
     }
 
-    public boolean isTraceEnabled() {
+    public void info(String msg) {
+        SysPrint(msg);
+    }
+
+    public void info(String format, Object arg) {
+        SysPrint(format, arg);
+    }
+
+    public void info(String format, Object arg1, Object arg2) {
+        SysPrint(format, arg1, arg2);
+    }
+
+    public void info(String format, Object[] argArray) {
+        SysPrint(format, argArray);
+    }
+
+    public void info(String msg, Throwable t) {
+        SysPrint(msg, t);
+    }
+
+    public boolean isInfoEnabled(Marker marker) {
         return true;
     }
 
+    public void info(Marker marker, String msg) {
+        SysPrint(marker, msg);
+    }
+
+    public void info(Marker marker, String format, Object arg) {
+        SysPrint(marker, format, arg);
+    }
+
+    public void info(Marker marker, String format, Object arg1, Object arg2) {
+        SysPrint(marker, format, arg1, arg2);
+    }
+
+    public void info(Marker marker, String format, Object[] argArray) {
+        SysPrint(marker, format, argArray);
+    }
+
+    public void info(Marker marker, String msg, Throwable t) {
+        SysPrint(marker, msg, t);
+    }
+
     public boolean isWarnEnabled() {
         return true;
     }
 
-    public void trace(Object message) {
-        System.out.println(message);
-        
+    public void warn(String msg) {
+        SysPrint(msg);
+    }
+
+    public void warn(String format, Object arg) {
+        SysPrint(format, arg);
+    }
+
+    public void warn(String format, Object[] argArray) {
+        SysPrint(format, argArray);
+    }
+
+    public void warn(String format, Object arg1, Object arg2) {
+        SysPrint(format, arg1, arg2);
+    }
+
+    public void warn(String msg, Throwable t) {
+        SysPrint(msg, t);
+    }
+
+    public boolean isWarnEnabled(Marker marker) {
+        return true;
+    }
+
+    public void warn(Marker marker, String msg) {
+    }
+
+    public void warn(Marker marker, String format, Object arg) {
+        SysPrint(marker, format, arg);
+    }
+
+    public void warn(Marker marker, String format, Object arg1, Object arg2) {
+        SysPrint(marker, format, arg1, arg2);
+    }
+
+    public void warn(Marker marker, String format, Object[] argArray) {
+        SysPrint(marker, format, argArray);
+    }
+
+    public void warn(Marker marker, String msg, Throwable t) {
+        SysPrint(marker, msg, t);
+    }
+
+    public boolean isErrorEnabled() {
+        return true;
+    }
+
+    public void error(String msg) {
+        SysPrint(msg);
+    }
+
+    public void error(String format, Object arg) {
+        SysPrint(format, arg);
+    }
+
+    public void error(String format, Object arg1, Object arg2) {
+        SysPrint(format, arg1, arg2);
+    }
+
+    public void error(String format, Object[] argArray) {
+        SysPrint(format, argArray);
+    }
+
+    public void error(String msg, Throwable t) {
+        SysPrint(msg, t);
+    }
+
+    public boolean isErrorEnabled(Marker marker) {
+        return true;
     }
 
-    public void trace(Object message, Throwable t) {
-        System.out.println(message);
-        t.printStackTrace();
+    public void error(Marker marker, String msg) {
+        SysPrint(marker, msg);
     }
 
-    public void warn(Object message) {
-        System.out.println(message);
-        
+    public void error(Marker marker, String format, Object arg) {
+        SysPrint(marker, format, arg);
     }
 
-    public void warn(Object message, Throwable t) {
-        System.out.println(message);
-        t.printStackTrace();
+    public void error(Marker marker, String format, Object arg1, Object arg2) {
+        SysPrint(marker, format, arg1, arg2);
+    }
+
+    public void error(Marker marker, String format, Object[] argArray) {
+        SysPrint(marker, format, argArray);
+    }
+
+    public void error(Marker marker, String msg, Throwable t) {
+        SysPrint(marker, msg, t);
+    }
+
+    private void SysPrint(Marker marker, String msg, Object... obj) {
+        if (obj != null) {
+            Throwable t = null;
+            StringBuffer s = new StringBuffer("[");
+            s.append(marker.toString()).append("] ").append(msg);
+            s.append(" args=[");
+            boolean first = true;
+            for (Object o : obj) {
+                if (o instanceof Throwable) {
+                    t = (Throwable) o;
+                } else {
+                    if (first) {
+                        s.append(o.toString());
+                        first = false;
+                    } else {
+                        s.append(", ").append(o.toString());
+                    }
+                }
+            }
+            System.out.println(s.toString());
+            if (t != null) {
+                t.printStackTrace();
+            }
+        } else {
+            System.out.println(msg);
+        }
+    }
+
+    private void SysPrint(String msg, Object... obj) {
+        if (obj != null) {
+            Throwable t = null;
+            StringBuffer s = new StringBuffer(msg);
+            s.append(" args=[");
+            boolean first = true;
+            for (Object o : obj) {
+                if (o instanceof Throwable) {
+                    t = (Throwable) o;
+                } else {
+                    if (first) {
+                        s.append(o.toString());
+                        first = false;
+                    } else {
+                        s.append(", ").append(o.toString());
+                    }
+                }
+            }
+            System.out.println(s.toString());
+            if (t != null) {
+                t.printStackTrace();
+            }
+        } else {
+            System.out.println(msg);
+        }
     }
 
 }

Modified: james/mailbox-integration-tester/trunk/src/test/java/org/apache/james/mailbox/jcr/host/JCRHostSystem.java
URL: http://svn.apache.org/viewvc/james/mailbox-integration-tester/trunk/src/test/java/org/apache/james/mailbox/jcr/host/JCRHostSystem.java?rev=1076126&r1=1076125&r2=1076126&view=diff
==============================================================================
--- james/mailbox-integration-tester/trunk/src/test/java/org/apache/james/mailbox/jcr/host/JCRHostSystem.java
(original)
+++ james/mailbox-integration-tester/trunk/src/test/java/org/apache/james/mailbox/jcr/host/JCRHostSystem.java
Wed Mar  2 07:14:06 2011
@@ -21,7 +21,6 @@ package org.apache.james.mailbox.jcr.hos
 import java.io.File;
 
 import org.apache.commons.io.FileUtils;
-import org.apache.commons.logging.impl.SimpleLog;
 import org.apache.jackrabbit.core.RepositoryImpl;
 import org.apache.jackrabbit.core.config.RepositoryConfig;
 import org.apache.james.imap.api.process.ImapProcessor;
@@ -38,6 +37,7 @@ import org.apache.james.mailbox.jcr.JCRS
 import org.apache.james.mailbox.jcr.JCRUtils;
 import org.apache.james.mailbox.jcr.mail.JCRCachingUidProvider;
 import org.apache.james.mailbox.store.MockAuthenticator;
+import org.slf4j.LoggerFactory;
 import org.xml.sax.InputSource;
 
 public class JCRHostSystem extends ImapHostSystem{
@@ -78,7 +78,7 @@ public class JCRHostSystem extends ImapH
 
             final ImapProcessor defaultImapProcessorFactory = DefaultImapProcessorFactory.createDefaultProcessor(mailboxManager,
new JCRSubscriptionManager(mf));
             resetUserMetaData();
-            MailboxSession session = mailboxManager.createSystemSession("test", new SimpleLog("TestLog"));
+            MailboxSession session = mailboxManager.createSystemSession("test", LoggerFactory.getLogger("TestLog"));
             mailboxManager.startProcessingRequest(session);
             //mailboxManager.deleteEverything(session);
             mailboxManager.endProcessingRequest(session);

Modified: james/mailbox-integration-tester/trunk/src/test/java/org/apache/james/mailbox/jpa/host/JPAHostSystem.java
URL: http://svn.apache.org/viewvc/james/mailbox-integration-tester/trunk/src/test/java/org/apache/james/mailbox/jpa/host/JPAHostSystem.java?rev=1076126&r1=1076125&r2=1076126&view=diff
==============================================================================
--- james/mailbox-integration-tester/trunk/src/test/java/org/apache/james/mailbox/jpa/host/JPAHostSystem.java
(original)
+++ james/mailbox-integration-tester/trunk/src/test/java/org/apache/james/mailbox/jpa/host/JPAHostSystem.java
Wed Mar  2 07:14:06 2011
@@ -25,7 +25,6 @@ import java.util.HashMap;
 import javax.persistence.EntityManagerFactory;
 
 import org.apache.commons.io.FileUtils;
-import org.apache.commons.logging.impl.SimpleLog;
 import org.apache.james.imap.api.process.ImapProcessor;
 import org.apache.james.imap.encode.main.DefaultImapEncoderFactory;
 import org.apache.james.imap.main.DefaultImapDecoderFactory;
@@ -49,6 +48,7 @@ import org.apache.james.mailbox.jpa.open
 import org.apache.james.mailbox.jpa.user.model.JPASubscription;
 import org.apache.james.mailbox.store.MockAuthenticator;
 import org.apache.openjpa.persistence.OpenJPAPersistence;
+import org.slf4j.LoggerFactory;
 
 public class JPAHostSystem extends ImapHostSystem {
 
@@ -132,7 +132,7 @@ public class JPAHostSystem extends ImapH
 
     public void resetData() throws Exception {
         resetUserMetaData();
-        MailboxSession session = mailboxManager.createSystemSession("test", new SimpleLog("TestLog"));
+        MailboxSession session = mailboxManager.createSystemSession("test", LoggerFactory.getLogger("TestLog"));
         mailboxManager.startProcessingRequest(session);
         mailboxManager.deleteEverything(session);
         mailboxManager.endProcessingRequest(session);



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message