diff --git a/pom.xml b/pom.xml
index 8090f488..f138de6a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -33,7 +33,7 @@ OF THE POSSIBILITY OF SUCH DAMAGE.
com.jcabi
jcabi
- 1.24
+ 1.26.0
jcabi-log
1.0-SNAPSHOT
@@ -79,13 +79,24 @@ OF THE POSSIBILITY OF SUCH DAMAGE.
-->
org.slf4j
slf4j-api
- 1.7.21
+ 1.8.0-beta1
+
+
+ org.junit.jupiter
+ junit-jupiter-params
+ 5.6.2
+ test
org.apache.commons
commons-lang3
test
+
+ org.apache.commons
+ commons-text
+ test
+
@@ -104,21 +115,6 @@ OF THE POSSIBILITY OF SUCH DAMAGE.
true
-
-
-
- maven-compiler-plugin
-
-
- 1.8
-
-
-
- maven-invoker-plugin
- 2.0.0
-
-
-
diff --git a/src/it/it-decoloring/pom.xml b/src/it/it-decoloring/pom.xml
index d26a2bea..9fb60287 100644
--- a/src/it/it-decoloring/pom.xml
+++ b/src/it/it-decoloring/pom.xml
@@ -33,7 +33,7 @@ OF THE POSSIBILITY OF SUCH DAMAGE.
com.jcabi
jcabi
- 1.20.1
+ 1.26.0
com.jcabi
jcabi-log-test
@@ -46,7 +46,7 @@ OF THE POSSIBILITY OF SUCH DAMAGE.
org.apache.commons
- commons-lang3
+ commons-text
test
diff --git a/src/it/it-decoloring/src/test/java/com/jcabi/log/MulticolorLayoutIntegrationTest.java b/src/it/it-decoloring/src/test/java/com/jcabi/log/MulticolorLayoutIntegrationTest.java
index ca412890..06172b00 100644
--- a/src/it/it-decoloring/src/test/java/com/jcabi/log/MulticolorLayoutIntegrationTest.java
+++ b/src/it/it-decoloring/src/test/java/com/jcabi/log/MulticolorLayoutIntegrationTest.java
@@ -1,4 +1,4 @@
-/**
+/*
* Copyright (c) 2012-2017, jcabi.com
* All rights reserved.
*
@@ -29,12 +29,12 @@
*/
package com.jcabi.log;
-import org.apache.commons.lang3.StringEscapeUtils;
+import org.apache.commons.text.StringEscapeUtils;
import org.apache.log4j.Level;
import org.apache.log4j.spi.LoggingEvent;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
/**
diff --git a/src/main/java/com/jcabi/log/MsDecor.java b/src/main/java/com/jcabi/log/MsDecor.java
index 78f3921f..97199562 100644
--- a/src/main/java/com/jcabi/log/MsDecor.java
+++ b/src/main/java/com/jcabi/log/MsDecor.java
@@ -112,23 +112,23 @@ public void formatTo(final Formatter formatter, final int flags,
private String toText(final int precision) {
final double number;
final String title;
- if (this.millis < 1000L) {
+ if (this.millis < 1000.0) {
number = this.millis;
title = "ms";
- } else if (this.millis < 1000L * 60) {
- number = this.millis / 1000L;
+ } else if (this.millis < (double) (1000L * 60L)) {
+ number = this.millis / 1000.0;
title = "s";
- } else if (this.millis < 1000L * 60 * 60) {
- number = this.millis / (1000L * 60);
+ } else if (this.millis < (double) (1000L * 60L * 60L)) {
+ number = this.millis / (double) (1000L * 60L);
title = "min";
- } else if (this.millis < 1000L * 60 * 60 * 24) {
- number = this.millis / (1000L * 60 * 60);
+ } else if (this.millis < (double) (1000L * 60L * 60L * 24L)) {
+ number = this.millis / (double) (1000L * 60L * 60L);
title = "hr";
- } else if (this.millis < 1000L * 60 * 60 * 24 * 30) {
- number = this.millis / (1000L * 60 * 60 * 24);
+ } else if (this.millis < (double) (1000L * 60L * 60L * 24L * 30L)) {
+ number = this.millis / (double) (1000L * 60L * 60L * 24L);
title = "days";
} else {
- number = this.millis / (1000L * 60 * 60 * 24 * 30);
+ number = this.millis / (double) (1000L * 60L * 60L * 24L * 30L);
title = "mon";
}
final String format;
diff --git a/src/test/java/com/jcabi/log/ConversionPatternTest.java b/src/test/java/com/jcabi/log/ConversionPatternTest.java
index 9fb5ea73..f7ddd491 100644
--- a/src/test/java/com/jcabi/log/ConversionPatternTest.java
+++ b/src/test/java/com/jcabi/log/ConversionPatternTest.java
@@ -31,7 +31,7 @@
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Test case for {@link ConversionPattern}.
@@ -51,9 +51,6 @@ public final class ConversionPatternTest {
*/
private static final Colors COLORS = new Colors();
- /**
- * Test some edge cases: these shouldn't result in replacement.
- */
@Test
public void testGenerateNoReplacement() {
MatcherAssert.assertThat(
@@ -78,10 +75,6 @@ public void testGenerateNoReplacement() {
);
}
- /**
- * Test the empty edge case: should be replaced with the wrapped empty
- * string.
- */
@Test
public void testGenerateEmpty() {
MatcherAssert.assertThat(
@@ -90,9 +83,6 @@ public void testGenerateEmpty() {
);
}
- /**
- * Normal test cases.
- */
@Test
public void testGenerateSimple() {
MatcherAssert.assertThat(
@@ -111,27 +101,32 @@ public void testGenerateSimple() {
);
}
- /**
- * Test cases where the body includes curly braces. The correct (balanced)
- * curly brace pair should be replaced.
- */
@Test
public void testGenerateCurlyBraces() {
MatcherAssert.assertThat(
- convert("%color{%c{1}}"),
- Matchers.equalTo(colorWrap("%c{1}"))
+ ConversionPatternTest.convert("%color{%c{1}}"),
+ Matchers.equalTo(ConversionPatternTest.colorWrap("%c{1}"))
);
MatcherAssert.assertThat(
- convert("%color{%c{1}}foo"),
- Matchers.equalTo(String.format("%sfoo", colorWrap("%c{1}")))
+ ConversionPatternTest.convert("%color{%c{1}}foo"),
+ Matchers.equalTo(
+ String.format("%sfoo", ConversionPatternTest.colorWrap("%c{1}"))
+ )
);
MatcherAssert.assertThat(
- convert("%color{%c1}}foo"),
- Matchers.equalTo(String.format("%s}foo", colorWrap("%c1")))
+ ConversionPatternTest.convert("%color{%c1}}foo"),
+ Matchers.equalTo(
+ String.format("%s}foo", ConversionPatternTest.colorWrap("%c1"))
+ )
);
MatcherAssert.assertThat(
- convert("%color{%c{{{1}{2}}}}foo"),
- Matchers.equalTo(String.format("%sfoo", colorWrap("%c{{{1}{2}}}")))
+ ConversionPatternTest.convert("%color{%c{{{1}{2}}}}foo"),
+ Matchers.equalTo(
+ String.format(
+ "%sfoo",
+ ConversionPatternTest.colorWrap("%c{{{1}{2}}}")
+ )
+ )
);
}
diff --git a/src/test/java/com/jcabi/log/DecorsManagerTest.java b/src/test/java/com/jcabi/log/DecorsManagerTest.java
index 5d9327b3..192da827 100644
--- a/src/test/java/com/jcabi/log/DecorsManagerTest.java
+++ b/src/test/java/com/jcabi/log/DecorsManagerTest.java
@@ -31,7 +31,8 @@
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
/**
* Test case for {@link DecorsManager}.
@@ -42,10 +43,6 @@
*/
public final class DecorsManagerTest {
- /**
- * DecorsManager can return one of built-in decors.
- * @throws Exception If some problem
- */
@Test
public void hasBuiltInDecors() throws Exception {
MatcherAssert.assertThat(
@@ -54,13 +51,15 @@ public void hasBuiltInDecors() throws Exception {
);
}
- /**
- * DecorsManager can throw exception if a decor is missed.
- * @throws Exception If some problem
- */
- @Test(expected = DecorException.class)
- public void throwsExceptionForAbsentDecor() throws Exception {
- DecorsManager.decor("non-existing-formatter", null);
+ @Test
+ public void throwsExceptionForAbsentDecor() {
+ Assertions.assertThrows(
+ DecorException.class,
+ () -> {
+ DecorsManager.decor("non-existing-formatter", null);
+ }
+ );
+
}
}
diff --git a/src/test/java/com/jcabi/log/DomDecorTest.java b/src/test/java/com/jcabi/log/DomDecorTest.java
index e92deccd..ad98c47c 100644
--- a/src/test/java/com/jcabi/log/DomDecorTest.java
+++ b/src/test/java/com/jcabi/log/DomDecorTest.java
@@ -33,7 +33,7 @@
import java.util.Formatter;
import javax.xml.parsers.DocumentBuilderFactory;
import org.hamcrest.Matchers;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.mockito.hamcrest.MockitoHamcrest;
import org.w3c.dom.Document;
@@ -46,10 +46,6 @@
*/
public final class DomDecorTest {
- /**
- * DocumentDecor can transform Document to text.
- * @throws Exception If some problem
- */
@Test
public void convertsDocumentToText() throws Exception {
final Document doc = DocumentBuilderFactory.newInstance()
@@ -64,10 +60,6 @@ public void convertsDocumentToText() throws Exception {
);
}
- /**
- * DocumentDecor can handle NULL properly.
- * @throws Exception If some problem
- */
@Test
public void convertsNullToText() throws Exception {
final Formattable decor = new DomDecor(null);
diff --git a/src/test/java/com/jcabi/log/ExceptionDecorTest.java b/src/test/java/com/jcabi/log/ExceptionDecorTest.java
index f3b40e12..22593820 100644
--- a/src/test/java/com/jcabi/log/ExceptionDecorTest.java
+++ b/src/test/java/com/jcabi/log/ExceptionDecorTest.java
@@ -33,7 +33,7 @@
import java.util.Formattable;
import java.util.Formatter;
import org.hamcrest.Matchers;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.mockito.hamcrest.MockitoHamcrest;
@@ -45,10 +45,6 @@
*/
public final class ExceptionDecorTest {
- /**
- * ExceptionDecor can transform exception to text.
- * @throws Exception If some problem
- */
@Test
public void convertsExceptionToText() throws Exception {
final Formattable decor = new ExceptionDecor(new IOException("ouch!"));
@@ -69,10 +65,6 @@ public void convertsExceptionToText() throws Exception {
);
}
- /**
- * ExceptionDecor can handle NULL properly.
- * @throws Exception If some problem
- */
@Test
public void convertsNullToText() throws Exception {
final Formattable decor = new ExceptionDecor(null);
diff --git a/src/test/java/com/jcabi/log/LineNumberTest.java b/src/test/java/com/jcabi/log/LineNumberTest.java
index 2b8bcb96..575e8a01 100644
--- a/src/test/java/com/jcabi/log/LineNumberTest.java
+++ b/src/test/java/com/jcabi/log/LineNumberTest.java
@@ -38,7 +38,7 @@
import org.apache.log4j.WriterAppender;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Test case for %L pattern.
@@ -55,10 +55,6 @@ public final class LineNumberTest {
*/
private static final String CONV_PATTERN = "%c:%L";
- /**
- * PaternLayout can use %L properly.
- * @throws Exception If something goes wrong
- */
@Test
public void testLineNumber() throws Exception {
final PatternLayout layout = new PatternLayout();
@@ -75,7 +71,7 @@ public void testLineNumber() throws Exception {
MatcherAssert.assertThat(
writer.toString(),
Matchers.containsString(
- "com.jcabi.log.LineNumberTest:73"
+ "com.jcabi.log.LineNumberTest:247"
)
);
} finally {
diff --git a/src/test/java/com/jcabi/log/ListDecorTest.java b/src/test/java/com/jcabi/log/ListDecorTest.java
index 22b76d0f..1e5f64e5 100644
--- a/src/test/java/com/jcabi/log/ListDecorTest.java
+++ b/src/test/java/com/jcabi/log/ListDecorTest.java
@@ -32,10 +32,11 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Formattable;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
+import java.util.Locale;
+import org.hamcrest.MatcherAssert;
+import org.hamcrest.Matchers;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
/**
* Test case for {@link ListDecor}.
@@ -43,31 +44,35 @@
* @version $Id$
* @since 0.1
*/
-@RunWith(Parameterized.class)
-@SuppressWarnings("PMD.TestClassWithoutTestCases")
-public final class ListDecorTest extends AbstractDecorTest {
+public final class ListDecorTest {
- /**
- * Public ctor.
- * @param list The list to test
- * @param text Expected text
- * @param flags Flags
- * @param width Width
- * @param precision Precission
- * @checkstyle ParameterNumber (3 lines)
- */
- public ListDecorTest(final Object list, final String text,
- final int flags, final int width, final int precision) {
- super(list, text, flags, width, precision);
+ @ParameterizedTest
+ @MethodSource("params")
+ public void testPrintsRight(final Object list, final String text,
+ final int flags, final int width, final int precision) throws DecorException {
+ Locale.setDefault(Locale.US);
+ MatcherAssert.assertThat(
+ new Printed(new ListDecor(list), flags, width, precision),
+ Matchers.hasToString(text)
+ );
+ }
+
+ @ParameterizedTest
+ @MethodSource("params")
+ public void testLogsRight(final Object list, final String text,
+ final int flags, final int width, final int precision) throws DecorException {
+ Locale.setDefault(Locale.US);
+ MatcherAssert.assertThat(
+ new Logged(new ListDecor(list), flags, width, precision),
+ Matchers.hasToString(text)
+ );
}
/**
* Params for this parametrized test.
* @return Array of arrays of params for ctor
*/
- @Parameters
- @SuppressWarnings("PMD.ProhibitPublicStaticMethods")
- public static Collection