From 14b0b20dfe2fe74c71a86b231f257494fb586377 Mon Sep 17 00:00:00 2001 From: Arne Augenstein Date: Sun, 17 Sep 2017 22:20:03 +0200 Subject: [PATCH 1/3] Reproduce error in logging framework --- .gitignore | 1 + .../io/kamax/matrix/LoggingErrorTest.java | 32 +++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 src/test/java/io/kamax/matrix/LoggingErrorTest.java diff --git a/.gitignore b/.gitignore index b1ead11..6b686f6 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ build/ # Intellij IDEA .idea/ +out/ \ No newline at end of file diff --git a/src/test/java/io/kamax/matrix/LoggingErrorTest.java b/src/test/java/io/kamax/matrix/LoggingErrorTest.java new file mode 100644 index 0000000..1d8864a --- /dev/null +++ b/src/test/java/io/kamax/matrix/LoggingErrorTest.java @@ -0,0 +1,32 @@ +/* + * matrix-java-sdk - Matrix Client SDK for Java + * Copyright (C) 2017 Arne Augenstein + * + * https://max.kamax.io/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package io.kamax.matrix; + +import io.kamax.matrix.client.regular.MatrixHttpClient; +import org.junit.Test; + +import java.net.URISyntaxException; + +public class LoggingErrorTest { + @Test + public void login() throws URISyntaxException { + MatrixHttpClient client = new MatrixHttpClient(null); + } +} From b0cfa99a9f187049a9bdcc2bdc77c1985921de3e Mon Sep 17 00:00:00 2001 From: Arne Augenstein Date: Mon, 18 Sep 2017 21:15:15 +0200 Subject: [PATCH 2/3] Add logging implementation for test cases --- build.gradle | 1 + ...rrorTest.java => LoggingDependencyTest.java} | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) rename src/test/java/io/kamax/matrix/{LoggingErrorTest.java => LoggingDependencyTest.java} (61%) diff --git a/build.gradle b/build.gradle index cab3ba7..c8e117e 100644 --- a/build.gradle +++ b/build.gradle @@ -38,6 +38,7 @@ dependencies { compile 'commons-io:commons-io:2.5' compile 'org.apache.httpcomponents:fluent-hc:4.5.3' compile 'com.google.code.gson:gson:2.8.0' + testRuntimeOnly 'org.slf4j:slf4j-simple:1.7.25' testCompile 'junit:junit:4.12' diff --git a/src/test/java/io/kamax/matrix/LoggingErrorTest.java b/src/test/java/io/kamax/matrix/LoggingDependencyTest.java similarity index 61% rename from src/test/java/io/kamax/matrix/LoggingErrorTest.java rename to src/test/java/io/kamax/matrix/LoggingDependencyTest.java index 1d8864a..1e6bd73 100644 --- a/src/test/java/io/kamax/matrix/LoggingErrorTest.java +++ b/src/test/java/io/kamax/matrix/LoggingDependencyTest.java @@ -19,14 +19,25 @@ */ package io.kamax.matrix; -import io.kamax.matrix.client.regular.MatrixHttpClient; +import org.junit.Assert; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.helpers.NOPLoggerFactory; import java.net.URISyntaxException; -public class LoggingErrorTest { +/** + * A small test class, intended to verify that the logging framework has + * a suitable logging implementation. + */ +public class LoggingDependencyTest { @Test public void login() throws URISyntaxException { - MatrixHttpClient client = new MatrixHttpClient(null); + if (LoggerFactory.getILoggerFactory() instanceof NOPLoggerFactory) { + Assert.fail("No logging implementation found, using fallback NOP logger"); + } + Logger logger = LoggerFactory.getLogger(""); + logger.info("If you see this info in the logger, everything is alright"); } } From 3c106138947573f5a1d6ebdb54e4f405a6da6082 Mon Sep 17 00:00:00 2001 From: Arne Augenstein Date: Mon, 18 Sep 2017 21:16:00 +0200 Subject: [PATCH 3/3] Change dependency line order --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index c8e117e..3e50de5 100644 --- a/build.gradle +++ b/build.gradle @@ -38,9 +38,9 @@ dependencies { compile 'commons-io:commons-io:2.5' compile 'org.apache.httpcomponents:fluent-hc:4.5.3' compile 'com.google.code.gson:gson:2.8.0' - testRuntimeOnly 'org.slf4j:slf4j-simple:1.7.25' testCompile 'junit:junit:4.12' + testRuntimeOnly 'org.slf4j:slf4j-simple:1.7.25' deployerJars "org.apache.maven.wagon:wagon-ssh:2.2" }