This is an automated email from the ASF dual-hosted git repository.
rmannibucau pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/johnzon.git
The following commit(s) were added to refs/heads/master by this push:
new 8cb5377 simplifying some mappe dependencies, no main code change
8cb5377 is described below
commit 8cb53770e58cc2bdd26c26bdade4eae9cb995544
Author: Romain Manni-Bucau
AuthorDate: Mon Apr 25 09:02:24 2022 +0200
simplifying some mappe dependencies, no main code change
---
johnzon-mapper/pom.xml | 22 +--
.../org/apache/johnzon/mapper/NoWarningTest.java | 73 +-
johnzon-mapper/src/test/resources/JPATest.xml | 2 +-
3 files changed, 61 insertions(+), 36 deletions(-)
diff --git a/johnzon-mapper/pom.xml b/johnzon-mapper/pom.xml
index acaa20f..f4e3427 100644
--- a/johnzon-mapper/pom.xml
+++ b/johnzon-mapper/pom.xml
@@ -35,34 +35,16 @@
${project.version}
-
- com.github.stefanbirkner
- system-rules
- 1.8.0
- test
-
-
- commons-io
- commons-io
-
-
-
-
- commons-io
- commons-io
- 2.4
- test
-
org.apache.openjpa
openjpa
- 2.4.0
+ 3.2.2
test
com.h2database
h2
- 1.3.166
+ 2.1.210
test
diff --git
a/johnzon-mapper/src/test/java/org/apache/johnzon/mapper/NoWarningTest.java
b/johnzon-mapper/src/test/java/org/apache/johnzon/mapper/NoWarningTest.java
index fcb3656..3ffb94e 100644
--- a/johnzon-mapper/src/test/java/org/apache/johnzon/mapper/NoWarningTest.java
+++ b/johnzon-mapper/src/test/java/org/apache/johnzon/mapper/NoWarningTest.java
@@ -19,29 +19,68 @@
package org.apache.johnzon.mapper;
import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;
+import java.util.logging.Handler;
+import java.util.logging.LogRecord;
+import java.util.logging.Logger;
import javax.json.Json;
-import org.junit.Rule;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
-import org.junit.contrib.java.lang.system.StandardErrorStreamLog;
-import org.junit.contrib.java.lang.system.StandardOutputStreamLog;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertFalse;
public class NoWarningTest {
-
-@Rule
-public final StandardOutputStreamLog out = new StandardOutputStreamLog();
+public ByteArrayOutputStream out;
+public ByteArrayOutputStream err;
+private PrintStream oldOut;
+private PrintStream oldErr;
+private Handler handler;
+
+@Before
+public void capture() {
+out = new ByteArrayOutputStream();
+err = new ByteArrayOutputStream();
+oldOut = System.out;
+oldErr = System.err;
+System.setOut(new PrintStream(out));
+final PrintStream stderr = new PrintStream(err);
+System.setErr(stderr);
+handler = new Handler() {
+@Override
+public void publish(final LogRecord record) {
+stderr.println(record.getMessage());
+oldErr.println(record.getMessage());
+}
+
+@Override
+public void flush() {
+// no-op
+}
-@Rule
-public final StandardErrorStreamLog err = new StandardErrorStreamLog();
+@Override
+public void close() throws SecurityException {
+flush();
+}
+};
+Logger.getLogger("").addHandler(handler);
+}
+
+@After
+public void reset() {
+System.setOut(oldOut);
+System.setErr(oldErr);
+Logger.getLogger("").removeHandler(handler);
+}
@Test
-public void noWarn() {
+public void noWarn() throws UnsupportedEncodingException {
new MapperBuilder()
.setEncoding("UTF-8")
.setSupportConstructors(true)
@@ -52,19 +91,23 @@ public class NoWarningTest {
.setMaxSize(789465)
.setSkipNull(true)
.setSupportsComments(true)
-.build();
+.build()
+.close();
// no warn log
-assertTrue(out.getLog().isEmpty());
-assertTrue(err.getLog().isEmpty());
+assertTrue(out.toString("UTF-8").isEmpty());
+assertTrue(err.toString("UTF-8").isEmpty());
}
@Test
-public void warn() {
+public void warn() throws UnsupportedEncodingException {
Map unsupportedConfig = new HashMap();
unsupportedConfig.put("xxx.yyy.zzz", "");
-Json.createGeneratorFactory(unsupportedConfig).createGenerator(new
ByteArrayOutputStream());
+Json.createGeneratorFactory(unsupportedConfig)
+.createGenerator(new ByteArrayOutputStream())
+