[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mina-commits
Subject:    [mina-sshd] 03/15: [SSHD-1109] Route tests JUL logging via SLF4JBridgeHandler
From:       lgoldstein () apache ! org
Date:       2020-12-11 8:51:28
Message-ID: 20201211085125.B4A6581AF3 () gitbox ! apache ! org
[Download RAW message or body]

This is an automated email from the ASF dual-hosted git repository.

lgoldstein pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mina-sshd.git

commit 5e933062675970408eee6d9bc41ef51c3f86ab92
Author: Lyor Goldstein <lgoldstein@apache.org>
AuthorDate: Thu Dec 10 06:51:45 2020 +0200

    [SSHD-1109] Route tests JUL logging via SLF4JBridgeHandler
---
 CHANGES.md                                         |   2 +-
 assembly/pom.xml                                   |   4 -
 pom.xml                                            |  40 ++++++
 sshd-cli/pom.xml                                   |  20 ---
 .../main/java/org/apache/sshd/cli/CliLogger.java   |  97 ++-------------
 .../org/apache/sshd/cli/client/SshKeyScanMain.java |  43 ++++---
 sshd-common/pom.xml                                |  25 ----
 .../sshd/common/util/buffer/BufferUtils.java       |   2 +-
 .../sshd/common/util/logging/LoggingUtils.java     |  56 +--------
 .../sshd/common/util/logging/SimplifiedLog.java    | 135 ++++++++++++++++++++-
 .../apache/sshd/util/test/JUnitTestSupport.java    |  16 ++-
 sshd-contrib/pom.xml                               |  20 ---
 sshd-core/pom.xml                                  |  20 ---
 sshd-git/pom.xml                                   |  15 ---
 sshd-ldap/pom.xml                                  |  20 ---
 sshd-mina/pom.xml                                  |  20 ---
 sshd-netty/pom.xml                                 |  20 ---
 sshd-openpgp/pom.xml                               |  20 ---
 sshd-putty/pom.xml                                 |  20 ---
 sshd-scp/pom.xml                                   |  20 ---
 sshd-sftp/pom.xml                                  |  20 ---
 sshd-spring-sftp/pom.xml                           |  21 ----
 22 files changed, 222 insertions(+), 434 deletions(-)

diff --git a/CHANGES.md b/CHANGES.md
index 6a8b852..054fcf4 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -17,7 +17,7 @@
 ## Minor code helpers
 
 * [SSHD-1085](https://issues.apache.org/jira/browse/SSHD-1085) Added `CliLogger` + \
                more verbosity on `SshClientMain`
-
+* [SSHD-1109](https://issues.apache.org/jira/browse/SSHD-1109) Route tests JUL \
logging via SLF4JBridgeHandler  
 ## Behavioral changes and enhancements
 
diff --git a/assembly/pom.xml b/assembly/pom.xml
index 7d28953..f1ded23 100644
--- a/assembly/pom.xml
+++ b/assembly/pom.xml
@@ -126,10 +126,6 @@
             <artifactId>eddsa</artifactId>
         </dependency>
             <!-- Replacement of commons-logging for Spring parts that still use it \
                -->
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>jcl-over-slf4j</artifactId>
-        </dependency>
             <!-- Used for Unix sockets proxy -->
         <dependency>
             <groupId>tomcat</groupId>
diff --git a/pom.xml b/pom.xml
index 7256aba..c3fb369 100644
--- a/pom.xml
+++ b/pom.xml
@@ -444,6 +444,11 @@
             </dependency>
             <dependency>
                 <groupId>org.slf4j</groupId>
+                <artifactId>jul-to-slf4j</artifactId>
+                <version>${slf4j.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.slf4j</groupId>
                 <artifactId>slf4j-log4j12</artifactId>
                 <version>${slf4j.version}</version>
             </dependency>
@@ -632,6 +637,41 @@
         </dependencies>
     </dependencyManagement>
 
+        <!-- Common dependencies for all projects -->
+    <dependencies>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+            <!-- Just in case any of our dependencies uses JCL -->
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>jcl-over-slf4j</artifactId>
+        </dependency>
+
+            <!-- Test dependencies -->
+       <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>jul-to-slf4j</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-core</artifactId>
+            <scope>test</scope>
+        </dependency>
+     </dependencies>
+
     <build>
         <pluginManagement>
             <plugins>
diff --git a/sshd-cli/pom.xml b/sshd-cli/pom.xml
index 61fbf82..c5b890c 100644
--- a/sshd-cli/pom.xml
+++ b/sshd-cli/pom.xml
@@ -86,26 +86,6 @@
         </dependency>
 
         <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.mockito</groupId>
-            <artifactId>mockito-core</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>jcl-over-slf4j</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-log4j12</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>com.jcraft</groupId>
             <artifactId>jsch</artifactId>
             <scope>test</scope>
diff --git a/sshd-cli/src/main/java/org/apache/sshd/cli/CliLogger.java \
b/sshd-cli/src/main/java/org/apache/sshd/cli/CliLogger.java index e6094fd..904bde8 \
                100644
--- a/sshd-cli/src/main/java/org/apache/sshd/cli/CliLogger.java
+++ b/sshd-cli/src/main/java/org/apache/sshd/cli/CliLogger.java
@@ -23,12 +23,15 @@ import java.io.PrintStream;
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.Date;
+import java.util.Objects;
 import java.util.logging.Level;
 
+import org.apache.sshd.common.util.logging.SimplifiedLog;
+
 /**
  * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
  */
-public class CliLogger {
+public class CliLogger implements SimplifiedLog {
     public static final DateFormat LOG_TIME_FORMATTER = new \
SimpleDateFormat("yyyy-MM-dd HH:mm:ss,SSS");  
     protected final Level threshold;
@@ -39,71 +42,13 @@ public class CliLogger {
         this.logStream = logStream;
     }
 
-    public boolean isErrorEnabled() {
-        return isEnabledLevel(Level.SEVERE);
-    }
-
-    public void error(String msg) {
-        error(msg, null);
-    }
-
-    public void error(String msg, Throwable err) {
-        log(Level.SEVERE, msg, err);
-    }
-
-    public boolean isWarnEnabled() {
-        return isEnabledLevel(Level.WARNING);
-    }
-
-    public void warn(String msg) {
-        warn(msg, null);
-    }
-
-    public void warn(String msg, Throwable err) {
-        log(Level.WARNING, msg, err);
-    }
-
-    public boolean isInfoEnabled() {
-        return isEnabledLevel(Level.INFO);
-    }
-
-    public void info(String msg) {
-        info(msg, null);
-    }
-
-    public void info(String msg, Throwable err) {
-        log(Level.INFO, msg, err);
-    }
-
-    public boolean isDebugEnabled() {
-        return isEnabledLevel(Level.FINE);
-    }
-
-    public void debug(String msg) {
-        debug(msg, null);
-    }
-
-    public void debug(String msg, Throwable err) {
-        log(Level.FINE, msg, err);
-    }
-
-    public boolean isTraceEnabled() {
-        return isEnabledLevel(Level.FINER);
-    }
-
-    public void trace(String msg) {
-        trace(msg, null);
-    }
-
-    public void trace(String msg, Throwable err) {
-        log(Level.FINER, msg, err);
-    }
-
+    @Override
     public boolean isEnabledLevel(Level level) {
-        return isLevelEnabled(level, threshold);
+        return SimplifiedLog.isLoggable(level, threshold);
     }
 
-    public void log(Level level, String msg, Throwable err) {
+    @Override
+    public void log(Level level, Object msg, Throwable err) {
         if (!isEnabledLevel(level)) {
             return;
         }
@@ -116,34 +61,10 @@ public class CliLogger {
         logStream.append(time)
                 .append(' ').append(level.getName())
                 .append(' ').append(Thread.currentThread().getName())
-                .append(' ').append(msg)
+                .append(' ').append(Objects.toString(msg))
                 .println();
         if (err != null) {
             err.printStackTrace(logStream);
         }
     }
-
-    public static boolean isErrorEnabled(Level level) {
-        return isLevelEnabled(level, Level.SEVERE);
-    }
-
-    public static boolean isWarnEnabled(Level level) {
-        return isLevelEnabled(level, Level.WARNING);
-    }
-
-    public static boolean isInfoEnabled(Level level) {
-        return isLevelEnabled(level, Level.INFO);
-    }
-
-    public static boolean isDebugEnabled(Level level) {
-        return isLevelEnabled(level, Level.FINE);
-    }
-
-    public static boolean isTraceEnabled(Level level) {
-        return isLevelEnabled(level, Level.FINER);
-    }
-
-    public static boolean isLevelEnabled(Level level, Level threshold) {
-        return (level != null) && (threshold != null) && (level.intValue() <= \
                threshold.intValue());
-    }
 }
diff --git a/sshd-cli/src/main/java/org/apache/sshd/cli/client/SshKeyScanMain.java \
b/sshd-cli/src/main/java/org/apache/sshd/cli/client/SshKeyScanMain.java index \
                4e9513d..d9f7f45 100644
--- a/sshd-cli/src/main/java/org/apache/sshd/cli/client/SshKeyScanMain.java
+++ b/sshd-cli/src/main/java/org/apache/sshd/cli/client/SshKeyScanMain.java
@@ -81,7 +81,6 @@ import org.apache.sshd.common.util.GenericUtils;
 import org.apache.sshd.common.util.ValidateUtils;
 import org.apache.sshd.common.util.io.IoUtils;
 import org.apache.sshd.common.util.io.NoCloseInputStream;
-import org.apache.sshd.common.util.logging.LoggingUtils;
 import org.apache.sshd.common.util.logging.SimplifiedLog;
 import org.apache.sshd.common.util.net.SshdSocketAddress;
 import org.apache.sshd.common.util.security.SecurityUtils;
@@ -158,7 +157,7 @@ public class SshKeyScanMain implements Channel, Callable<Void>, \
ServerKeyVerifie  
     @Override
     public void log(Level level, Object message, Throwable t) {
-        if (isEnabled(level)) {
+        if (isEnabledLevel(level)) {
             PrintStream ps = System.out;
             if ((t != null) || Level.SEVERE.equals(level) || \
Level.WARNING.equals(level)) {  ps = System.err;
@@ -172,8 +171,8 @@ public class SshKeyScanMain implements Channel, Callable<Void>, \
ServerKeyVerifie  }
 
     @Override
-    public boolean isEnabled(Level level) {
-        return LoggingUtils.isLoggable(level, getLogLevel());
+    public boolean isEnabledLevel(Level level) {
+        return SimplifiedLog.isLoggable(level, getLogLevel());
     }
 
     @Override
@@ -191,7 +190,7 @@ public class SshKeyScanMain implements Channel, Callable<Void>, \
ServerKeyVerifie  for (String kt : sigTypes) {
             List<NamedFactory<Signature>> factories = resolveSignatureFactories(kt);
             if (GenericUtils.isEmpty(factories)) {
-                if (isEnabled(Level.FINEST)) {
+                if (isEnabledLevel(Level.FINEST)) {
                     log(Level.FINEST, "Skip empty signature factories for " + kt);
                 }
                 pairsMap.remove(kt);
@@ -230,7 +229,7 @@ public class SshKeyScanMain implements Channel, Callable<Void>, \
ServerKeyVerifie  
                     @Override
                     public void serverVersionInfo(ClientSession session, \
                List<String> lines) {
-                        if (isEnabled(Level.FINE) && GenericUtils.isNotEmpty(lines)) \
{ +                        if (isEnabledLevel(Level.FINE) && \
GenericUtils.isNotEmpty(lines)) {  for (String l : lines) {
                                 log(Level.FINE, "Server Info: " + l);
                             }
@@ -239,7 +238,7 @@ public class SshKeyScanMain implements Channel, Callable<Void>, \
ServerKeyVerifie  
                     @Override
                     public void welcome(ClientSession session, String banner, String \
                lang) {
-                        if (isEnabled(Level.FINE) && \
GenericUtils.isNotEmpty(banner)) { +                        if \
                (isEnabledLevel(Level.FINE) && GenericUtils.isNotEmpty(banner)) {
                             String[] lines = GenericUtils.split(banner, '\n');
                             for (String l : lines) {
                                 log(Level.FINE, "Welcome[" + lang + "]: " + l);
@@ -270,7 +269,7 @@ public class SshKeyScanMain implements Channel, Callable<Void>, \
ServerKeyVerifie  throw e;
                             }
 
-                            if (isEnabled(Level.FINE)) {
+                            if (isEnabledLevel(Level.FINE)) {
                                 log(Level.FINE, "Failed to retrieve keys from " + h, \
e);  }
                             err = GenericUtils.accumulateException(err, e);
@@ -316,7 +315,7 @@ public class SshKeyScanMain implements Channel, Callable<Void>, \
ServerKeyVerifie  client.setSignatureFactories(forced);
                 resolveServerKeys(client, host, kt, pe.getValue());
             } catch (Exception e) {
-                if (isEnabled(Level.FINE)) {
+                if (isEnabledLevel(Level.FINE)) {
                     log(Level.FINE, "Failed to resolve key=" + kt + " for " + host);
                 }
 
@@ -331,7 +330,7 @@ public class SshKeyScanMain implements Channel, Callable<Void>, \
ServerKeyVerifie  
     protected void resolveServerKeys(SshClient client, String host, String kt, \
List<KeyPair> ids) throws Exception {  int connectPort = getPort();
-        if (isEnabled(Level.FINE)) {
+        if (isEnabledLevel(Level.FINE)) {
             log(Level.FINE, "Connecting to " + host + ":" + connectPort + " to \
retrieve key type=" + kt);  }
 
@@ -348,13 +347,13 @@ public class SshKeyScanMain implements Channel, Callable<Void>, \
ServerKeyVerifie  IoSession ioSession = session.getIoSession();
             SocketAddress remoteAddress = ioSession.getRemoteAddress();
             String remoteLocation = toString(remoteAddress);
-            if (isEnabled(Level.FINE)) {
+            if (isEnabledLevel(Level.FINE)) {
                 log(Level.FINE, "Connected to " + remoteLocation + " to retrieve key \
type=" + kt);  }
 
             try {
                 session.addSessionListener(this);
-                if (isEnabled(Level.FINER)) {
+                if (isEnabledLevel(Level.FINER)) {
                     log(Level.FINER, "Authenticating with key type=" + kt + " to " + \
remoteLocation);  }
 
@@ -365,7 +364,7 @@ public class SshKeyScanMain implements Channel, Callable<Void>, \
ServerKeyVerifie  session.auth().verify(waitTime);
                     log(Level.WARNING, "Unexpected authentication success using key \
type=" + kt + " with " + remoteLocation);  } catch (Exception e) {
-                    if (isEnabled(Level.FINER)) {
+                    if (isEnabledLevel(Level.FINER)) {
                         log(Level.FINER, "Failed to authenticate using key type=" + \
kt + " with " + remoteLocation);  }
                 } finally {
@@ -385,7 +384,7 @@ public class SshKeyScanMain implements Channel, Callable<Void>, \
ServerKeyVerifie  @Override
     public void sessionEvent(Session session, Event event) {
         logSessionEvent(session, event);
-        if (isEnabled(Level.FINEST) && Event.KexCompleted.equals(event)) {
+        if (isEnabledLevel(Level.FINEST) && Event.KexCompleted.equals(event)) {
             IoSession ioSession = session.getIoSession();
             SocketAddress remoteAddress = ioSession.getRemoteAddress();
             String remoteLocation = toString(remoteAddress);
@@ -415,7 +414,7 @@ public class SshKeyScanMain implements Channel, Callable<Void>, \
ServerKeyVerifie  }
 
     protected void logNegotiationProposal(String type, Map<KexProposalOption, \
                String> proposal) {
-        if (!isEnabled(Level.FINEST)) {
+        if (!isEnabledLevel(Level.FINEST)) {
             return;
         }
 
@@ -435,7 +434,7 @@ public class SshKeyScanMain implements Channel, Callable<Void>, \
ServerKeyVerifie  }
 
     protected void logSessionEvent(Session session, Object event) {
-        if (isEnabled(Level.FINEST)) {
+        if (isEnabledLevel(Level.FINEST)) {
             IoSession ioSession = session.getIoSession();
             SocketAddress remoteAddress = ioSession.getRemoteAddress();
             log(Level.FINEST, "Session " + toString(remoteAddress) + " event: " + \
event); @@ -450,11 +449,11 @@ public class SshKeyScanMain implements Channel, \
Callable<Void>, ServerKeyVerifie  String keyType = KeyUtils.getKeyType(serverKey);
             String current = GenericUtils.isEmpty(keyType) ? null : \
currentHostFingerprints.get(keyType);  if (Objects.equals(current, extra)) {
-                if (isEnabled(Level.FINER)) {
+                if (isEnabledLevel(Level.FINER)) {
                     log(Level.FINER, "verifyServerKey(" + remoteLocation + ")[" + \
keyType + "] skip existing key: " + extra);  }
             } else {
-                if (isEnabled(Level.FINE)) {
+                if (isEnabledLevel(Level.FINE)) {
                     log(Level.FINE, "verifyServerKey(" + remoteLocation + ")[" + \
keyType + "] found new key: " + extra);  }
 
@@ -490,7 +489,7 @@ public class SshKeyScanMain implements Channel, Callable<Void>, \
ServerKeyVerifie  }
 
     protected List<NamedFactory<Signature>> resolveSignatureFactories(String \
                keyType) throws GeneralSecurityException {
-        if (isEnabled(Level.FINE)) {
+        if (isEnabledLevel(Level.FINE)) {
             log(Level.FINE, "Resolve signature factories for " + keyType);
         }
 
@@ -501,7 +500,7 @@ public class SshKeyScanMain implements Channel, Callable<Void>, \
                ServerKeyVerifie
         } else if (BuiltinIdentities.Constants.ECDSA.equalsIgnoreCase(keyType)) {
             List<NamedFactory<Signature>> factories = new \
ArrayList<>(ECCurves.NAMES.size());  for (String n : ECCurves.NAMES) {
-                if (isEnabled(Level.FINER)) {
+                if (isEnabledLevel(Level.FINER)) {
                     log(Level.FINER, "Resolve signature factory for curve=" + n);
                 }
 
@@ -549,7 +548,7 @@ public class SshKeyScanMain implements Channel, Callable<Void>, \
ServerKeyVerifie  }
 
     protected List<KeyPair> createKeyPairs(String keyType) throws \
                GeneralSecurityException {
-        if (isEnabled(Level.FINE)) {
+        if (isEnabledLevel(Level.FINE)) {
             log(Level.FINE, "Generate key pairs for " + keyType);
         }
 
@@ -565,7 +564,7 @@ public class SshKeyScanMain implements Channel, Callable<Void>, \
ServerKeyVerifie  List<KeyPair> kps = new ArrayList<>(ECCurves.NAMES.size());
             for (ECCurves curve : ECCurves.VALUES) {
                 String curveName = curve.getName();
-                if (isEnabled(Level.FINER)) {
+                if (isEnabledLevel(Level.FINER)) {
                     log(Level.FINER, "Generate key pair for curve=" + curveName);
                 }
 
diff --git a/sshd-common/pom.xml b/sshd-common/pom.xml
index 42e46af..a1a110b 100644
--- a/sshd-common/pom.xml
+++ b/sshd-common/pom.xml
@@ -37,11 +37,6 @@
 
     <dependencies>
         <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-api</artifactId>
-        </dependency>
-
-        <dependency>
             <groupId>org.bouncycastle</groupId>
             <artifactId>bcpg-jdk15on</artifactId>
             <optional>true</optional>
@@ -61,26 +56,6 @@
 
             <!-- test dependencies -->
         <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>jcl-over-slf4j</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-log4j12</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.mockito</groupId>
-            <artifactId>mockito-core</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>org.apache.servicemix.bundles</groupId>
             <artifactId>org.apache.servicemix.bundles.not-yet-commons-ssl</artifactId>
  <scope>test</scope>
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/util/buffer/BufferUtils.java \
b/sshd-common/src/main/java/org/apache/sshd/common/util/buffer/BufferUtils.java index \
                ad67a5f..8c935d1 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/util/buffer/BufferUtils.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/util/buffer/BufferUtils.java
@@ -86,7 +86,7 @@ public final class BufferUtils {
     public static void dumpHex(
             SimplifiedLog logger, Level level, String prefix, char sep,
             int chunkSize, byte[] data, int offset, int len) {
-        if ((logger == null) || (level == null) || (!logger.isEnabled(level))) {
+        if ((logger == null) || (level == null) || (!logger.isEnabledLevel(level))) \
{  return;
         }
 
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/util/logging/LoggingUtils.java \
b/sshd-common/src/main/java/org/apache/sshd/common/util/logging/LoggingUtils.java \
                index 19aa8e9..3d592b5 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/util/logging/LoggingUtils.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/util/logging/LoggingUtils.java
@@ -190,71 +190,21 @@ public final class LoggingUtils {
         });
     }
 
-    /**
-     * Verifies if the given level is above the required threshold for logging.
-     *
-     * @param  level     The {@link Level} to evaluate
-     * @param  threshold The threshold {@link Level}
-     * @return           {@code true} if the evaluated level is above the required \
                threshold.
-     *                   <P>
-     *                   <B>Note(s):</B>
-     *                   </P>
-     *                   <UL>
-     *                   <LI>
-     *                   <P>
-     *                   If either argument is {@code null} then result is {@code \
                false}.
-     *                   </P>
-     *                   </LI>
-     *
-     *                   <LI>
-     *                   <P>
-     *                   If the evaluated level is {@link Level#OFF} then result is \
                {@code false} regardless of the
-     *                   threshold.
-     *                   </P>
-     *                   </LI>
-     *
-     *                   <LI>
-     *                   <P>
-     *                   If the threshold is {@link Level#ALL} and the evaluated \
                level is <U>not</U> {@link Level#OFF}
-     *                   the result is {@code true}.
-     *                   </P>
-     *                   </LI>
-     *
-     *                   <LI>
-     *                   <P>
-     *                   Otherwise, the evaluated level {@link Level#intValue()} \
                must be greater or equal to the
-     *                   threshold.
-     *                   </P>
-     *                   </LI>
-     *                   </UL>
-     */
-    public static boolean isLoggable(Level level, Level threshold) {
-        if ((level == null) || (threshold == null)) {
-            return false;
-        } else if (Level.OFF.equals(level) || Level.OFF.equals(threshold)) {
-            return false;
-        } else if (Level.ALL.equals(threshold)) {
-            return true;
-        } else {
-            return level.intValue() >= threshold.intValue();
-        }
-    }
-
-    public static SimplifiedLog wrap(final Logger logger) {
+    public static SimplifiedLog wrap(Logger logger) {
         if (logger == null) {
             return SimplifiedLog.EMPTY;
         } else {
             return new SimplifiedLog() {
                 @Override
                 public void log(Level level, Object message, Throwable t) {
-                    if (isEnabled(level)) {
+                    if (isEnabledLevel(level)) {
                         logMessage(logger, level, message, t);
                     }
 
                 }
 
                 @Override
-                public boolean isEnabled(Level level) {
+                public boolean isEnabledLevel(Level level) {
                     return isLoggable(logger, level);
                 }
             };
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/util/logging/SimplifiedLog.java \
b/sshd-common/src/main/java/org/apache/sshd/common/util/logging/SimplifiedLog.java \
                index 58d58ee..0b5a39d 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/util/logging/SimplifiedLog.java
                
+++ b/sshd-common/src/main/java/org/apache/sshd/common/util/logging/SimplifiedLog.java
 @@ -24,13 +24,12 @@ import java.util.logging.Level;
  * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
  */
 public interface SimplifiedLog {
-
     /**
      * An &quot;empty&quot; {@link SimplifiedLog} that does nothing
      */
     SimplifiedLog EMPTY = new SimplifiedLog() {
         @Override
-        public boolean isEnabled(Level level) {
+        public boolean isEnabledLevel(Level level) {
             return false;
         }
 
@@ -45,11 +44,141 @@ public interface SimplifiedLog {
         }
     };
 
-    boolean isEnabled(Level level);
+    default boolean isErrorEnabled() {
+        return isEnabledLevel(Level.SEVERE);
+    }
+
+    default void error(String msg) {
+        error(msg, null);
+    }
+
+    default void error(String msg, Throwable err) {
+        log(Level.SEVERE, msg, err);
+    }
+
+    default boolean isWarnEnabled() {
+        return isEnabledLevel(Level.WARNING);
+    }
+
+    default void warn(String msg) {
+        warn(msg, null);
+    }
+
+    default void warn(String msg, Throwable err) {
+        log(Level.WARNING, msg, err);
+    }
+
+    default boolean isInfoEnabled() {
+        return isEnabledLevel(Level.INFO);
+    }
+
+    default void info(String msg) {
+        info(msg, null);
+    }
+
+    default void info(String msg, Throwable err) {
+        log(Level.INFO, msg, err);
+    }
+
+    default boolean isDebugEnabled() {
+        return isEnabledLevel(Level.FINE);
+    }
+
+    default void debug(String msg) {
+        debug(msg, null);
+    }
+
+    default void debug(String msg, Throwable err) {
+        log(Level.FINE, msg, err);
+    }
+
+    default boolean isTraceEnabled() {
+        return isEnabledLevel(Level.FINER);
+    }
+
+    default void trace(String msg) {
+        trace(msg, null);
+    }
+
+    default void trace(String msg, Throwable err) {
+        log(Level.FINER, msg, err);
+    }
+
+    boolean isEnabledLevel(Level level);
 
     default void log(Level level, Object message) {
         log(level, message, null);
     }
 
     void log(Level level, Object message, Throwable t);
+
+    static boolean isErrorEnabled(Level level) {
+        return isLoggable(level, Level.SEVERE);
+    }
+
+    static boolean isWarnEnabled(Level level) {
+        return isLoggable(level, Level.WARNING);
+    }
+
+    static boolean isInfoEnabled(Level level) {
+        return isLoggable(level, Level.INFO);
+    }
+
+    static boolean isDebugEnabled(Level level) {
+        return isLoggable(level, Level.FINE);
+    }
+
+    static boolean isTraceEnabled(Level level) {
+        return isLoggable(level, Level.FINER);
+    }
+
+    /**
+     * Verifies if the given level is above the required threshold for logging.
+     *
+     * @param  level     The {@link Level} to evaluate
+     * @param  threshold The threshold {@link Level}
+     * @return           {@code true} if the evaluated level is above the required \
threshold. +     *                   <P>
+     *                   <B>Note(s):</B>
+     *                   </P>
+     *                   <UL>
+     *                   <LI>
+     *                   <P>
+     *                   If either argument is {@code null} then result is {@code \
false}. +     *                   </P>
+     *                   </LI>
+     *
+     *                   <LI>
+     *                   <P>
+     *                   If the evaluated level is {@link Level#OFF} then result is \
{@code false} regardless of the +     *                   threshold.
+     *                   </P>
+     *                   </LI>
+     *
+     *                   <LI>
+     *                   <P>
+     *                   If the threshold is {@link Level#ALL} and the evaluated \
level is <U>not</U> {@link Level#OFF} +     *                   the result is {@code \
true}. +     *                   </P>
+     *                   </LI>
+     *
+     *                   <LI>
+     *                   <P>
+     *                   Otherwise, the evaluated level {@link Level#intValue()} \
must be greater or equal to the +     *                   threshold.
+     *                   </P>
+     *                   </LI>
+     *                   </UL>
+     */
+    static boolean isLoggable(Level level, Level threshold) {
+        if ((level == null) || (threshold == null)) {
+            return false;
+        } else if (Level.OFF.equals(level) || Level.OFF.equals(threshold)) {
+            return false;
+        } else if (Level.ALL.equals(threshold)) {
+            return true;
+        } else {
+            return level.intValue() >= threshold.intValue();
+        }
+    }
 }
diff --git a/sshd-common/src/test/java/org/apache/sshd/util/test/JUnitTestSupport.java \
b/sshd-common/src/test/java/org/apache/sshd/util/test/JUnitTestSupport.java index \
                a635fc9..a5211f0 100644
--- a/sshd-common/src/test/java/org/apache/sshd/util/test/JUnitTestSupport.java
+++ b/sshd-common/src/test/java/org/apache/sshd/util/test/JUnitTestSupport.java
@@ -62,6 +62,7 @@ import org.junit.Assert;
 import org.junit.Rule;
 import org.junit.rules.TestName;
 import org.junit.runner.RunWith;
+import org.slf4j.bridge.SLF4JBridgeHandler;
 
 /**
  * TODO Add javadoc
@@ -89,7 +90,7 @@ public abstract class JUnitTestSupport extends Assert {
     private Path tempFolder;
 
     protected JUnitTestSupport() {
-        super();
+        replaceJULLoggers();
     }
 
     public final String getCurrentTestName() {
@@ -637,4 +638,17 @@ public abstract class JUnitTestSupport extends Assert {
             System.out.append("===[DEBUG]=== ").println(message);
         }
     }
+
+    /* ---------------------------------------------------------------------------- \
*/ +
+    public static void replaceJULLoggers() {
+        if (!SLF4JBridgeHandler.isInstalled()) {
+            // Optionally remove existing handlers attached to j.u.l root logger
+            SLF4JBridgeHandler.removeHandlersForRootLogger();  // (since SLF4J \
1.6.5) +
+            // add SLF4JBridgeHandler to j.u.l's root logger, should be done once \
during +            // the initialization phase of your application
+            SLF4JBridgeHandler.install();
+        }
+    }
 }
diff --git a/sshd-contrib/pom.xml b/sshd-contrib/pom.xml
index 6563c53..bb37464 100644
--- a/sshd-contrib/pom.xml
+++ b/sshd-contrib/pom.xml
@@ -80,26 +80,6 @@
             <type>test-jar</type>
             <scope>test</scope>
         </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>jcl-over-slf4j</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-log4j12</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.mockito</groupId>
-            <artifactId>mockito-core</artifactId>
-            <scope>test</scope>
-        </dependency>
     </dependencies>
 
     <build>
diff --git a/sshd-core/pom.xml b/sshd-core/pom.xml
index f42c2c9..d589cef 100644
--- a/sshd-core/pom.xml
+++ b/sshd-core/pom.xml
@@ -81,16 +81,6 @@
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>jcl-over-slf4j</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-log4j12</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>com.jcraft</groupId>
             <artifactId>jsch</artifactId>
             <scope>test</scope>
@@ -106,16 +96,6 @@
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.mockito</groupId>
-            <artifactId>mockito-core</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>commons-httpclient</groupId>
             <artifactId>commons-httpclient</artifactId>
             <scope>test</scope>
diff --git a/sshd-git/pom.xml b/sshd-git/pom.xml
index a675d64..6774c82 100644
--- a/sshd-git/pom.xml
+++ b/sshd-git/pom.xml
@@ -72,21 +72,6 @@
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>jcl-over-slf4j</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-log4j12</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>com.jcraft</groupId>
             <artifactId>jsch</artifactId>
             <scope>test</scope>
diff --git a/sshd-ldap/pom.xml b/sshd-ldap/pom.xml
index d47cc31..760ee8b 100644
--- a/sshd-ldap/pom.xml
+++ b/sshd-ldap/pom.xml
@@ -114,26 +114,6 @@
             <type>test-jar</type>
             <scope>test</scope>
         </dependency>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.mockito</groupId>
-            <artifactId>mockito-core</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>jcl-over-slf4j</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-log4j12</artifactId>
-            <scope>test</scope>
-        </dependency>
     </dependencies>
 
     <build>
diff --git a/sshd-mina/pom.xml b/sshd-mina/pom.xml
index e4d28dc..d2f0db8 100644
--- a/sshd-mina/pom.xml
+++ b/sshd-mina/pom.xml
@@ -75,16 +75,6 @@
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>jcl-over-slf4j</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-log4j12</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>com.jcraft</groupId>
             <artifactId>jsch</artifactId>
             <scope>test</scope>
@@ -100,16 +90,6 @@
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.mockito</groupId>
-            <artifactId>mockito-core</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>commons-httpclient</groupId>
             <artifactId>commons-httpclient</artifactId>
             <scope>test</scope>
diff --git a/sshd-netty/pom.xml b/sshd-netty/pom.xml
index 6d9f59b..ba83aed 100644
--- a/sshd-netty/pom.xml
+++ b/sshd-netty/pom.xml
@@ -83,16 +83,6 @@
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>jcl-over-slf4j</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-log4j12</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>com.jcraft</groupId>
             <artifactId>jsch</artifactId>
             <scope>test</scope>
@@ -108,16 +98,6 @@
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.mockito</groupId>
-            <artifactId>mockito-core</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>commons-httpclient</groupId>
             <artifactId>commons-httpclient</artifactId>
             <scope>test</scope>
diff --git a/sshd-openpgp/pom.xml b/sshd-openpgp/pom.xml
index ef37af9..60c838d 100644
--- a/sshd-openpgp/pom.xml
+++ b/sshd-openpgp/pom.xml
@@ -65,26 +65,6 @@
             <type>test-jar</type>
             <scope>test</scope>
         </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>jcl-over-slf4j</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-log4j12</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.mockito</groupId>
-            <artifactId>mockito-core</artifactId>
-            <scope>test</scope>
-        </dependency>
     </dependencies>
 
     <build>
diff --git a/sshd-putty/pom.xml b/sshd-putty/pom.xml
index bd39b58..d0af818 100644
--- a/sshd-putty/pom.xml
+++ b/sshd-putty/pom.xml
@@ -68,26 +68,6 @@
             <type>test-jar</type>
             <scope>test</scope>
         </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>jcl-over-slf4j</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-log4j12</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.mockito</groupId>
-            <artifactId>mockito-core</artifactId>
-            <scope>test</scope>
-        </dependency>
     </dependencies>
 
     <build>
diff --git a/sshd-scp/pom.xml b/sshd-scp/pom.xml
index ba4a22d..1632415 100644
--- a/sshd-scp/pom.xml
+++ b/sshd-scp/pom.xml
@@ -56,26 +56,6 @@
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.mockito</groupId>
-            <artifactId>mockito-core</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>jcl-over-slf4j</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-log4j12</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>com.jcraft</groupId>
             <artifactId>jsch</artifactId>
             <scope>test</scope>
diff --git a/sshd-sftp/pom.xml b/sshd-sftp/pom.xml
index f05786c..a331962 100644
--- a/sshd-sftp/pom.xml
+++ b/sshd-sftp/pom.xml
@@ -56,26 +56,6 @@
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.mockito</groupId>
-            <artifactId>mockito-core</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>jcl-over-slf4j</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-log4j12</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>com.jcraft</groupId>
             <artifactId>jsch</artifactId>
             <scope>test</scope>
diff --git a/sshd-spring-sftp/pom.xml b/sshd-spring-sftp/pom.xml
index 9a92374..eb37c5c 100644
--- a/sshd-spring-sftp/pom.xml
+++ b/sshd-spring-sftp/pom.xml
@@ -58,12 +58,6 @@
             <artifactId>sshd-sftp</artifactId>
             <version>${project.version}</version>
         </dependency>
-        <!-- Replacement of commons-logging for Spring parts that still use it -->
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>jcl-over-slf4j</artifactId>
-            <optional>true</optional>
-        </dependency>
 
         <dependency>
             <groupId>org.springframework.integration</groupId>
@@ -104,21 +98,6 @@
             <type>test-jar</type>
             <scope>test</scope>
         </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-log4j12</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.mockito</groupId>
-            <artifactId>mockito-core</artifactId>
-            <scope>test</scope>
-        </dependency>
     </dependencies>
 
     <build>


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic