You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@johnzon.apache.org by rm...@apache.org on 2015/04/13 16:48:32 UTC

incubator-johnzon git commit: JOHNZON-46 ensuring we dont geenrate warning in our mapper cause of not supported properties

Repository: incubator-johnzon
Updated Branches:
  refs/heads/master 9ad17dc81 -> b90d1a67e


JOHNZON-46 ensuring we dont geenrate warning in our mapper cause of not supported properties


Project: http://git-wip-us.apache.org/repos/asf/incubator-johnzon/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-johnzon/commit/b90d1a67
Tree: http://git-wip-us.apache.org/repos/asf/incubator-johnzon/tree/b90d1a67
Diff: http://git-wip-us.apache.org/repos/asf/incubator-johnzon/diff/b90d1a67

Branch: refs/heads/master
Commit: b90d1a67e652acc4dbad94a35eb1fcf71b25ad87
Parents: 9ad17dc
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Mon Apr 13 16:48:13 2015 +0200
Committer: Romain Manni-Bucau <rm...@apache.org>
Committed: Mon Apr 13 16:48:24 2015 +0200

----------------------------------------------------------------------
 johnzon-mapper/pom.xml                          |  7 +++
 .../apache/johnzon/mapper/MapperBuilder.java    | 12 ++---
 .../apache/johnzon/mapper/NoWarningTest.java    | 52 ++++++++++++++++++++
 3 files changed, 65 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-johnzon/blob/b90d1a67/johnzon-mapper/pom.xml
----------------------------------------------------------------------
diff --git a/johnzon-mapper/pom.xml b/johnzon-mapper/pom.xml
index c28ec27..a8bc042 100644
--- a/johnzon-mapper/pom.xml
+++ b/johnzon-mapper/pom.xml
@@ -34,6 +34,13 @@
       <artifactId>johnzon-core</artifactId>
       <version>${project.version}</version>
     </dependency>
+
+    <dependency>
+      <groupId>com.github.stefanbirkner</groupId>
+      <artifactId>system-rules</artifactId>
+      <version>1.8.0</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
   <properties>

http://git-wip-us.apache.org/repos/asf/incubator-johnzon/blob/b90d1a67/johnzon-mapper/src/main/java/org/apache/johnzon/mapper/MapperBuilder.java
----------------------------------------------------------------------
diff --git a/johnzon-mapper/src/main/java/org/apache/johnzon/mapper/MapperBuilder.java b/johnzon-mapper/src/main/java/org/apache/johnzon/mapper/MapperBuilder.java
index 9ad7838..90afc74 100644
--- a/johnzon-mapper/src/main/java/org/apache/johnzon/mapper/MapperBuilder.java
+++ b/johnzon-mapper/src/main/java/org/apache/johnzon/mapper/MapperBuilder.java
@@ -101,12 +101,6 @@ public class MapperBuilder {
         if (readerFactory == null || generatorFactory == null) {
             final JsonProvider provider = JsonProvider.provider();
             final Map<String, Object> config = new HashMap<String, Object>();
-            if (maxSize > 0) {
-                config.put("org.apache.johnzon.max-string-length", maxSize);
-            }
-            if (bufferSize > 0) {
-                config.put("org.apache.johnzon.default-char-buffer", bufferSize);
-            }
             if (bufferStrategy != null) {
                 config.put("org.apache.johnzon.buffer-strategy", bufferStrategy);
             }
@@ -122,6 +116,12 @@ public class MapperBuilder {
             if (supportsComments) {
                 config.put("org.apache.johnzon.supports-comments", "true");
             }
+            if (maxSize > 0) {
+                config.put("org.apache.johnzon.max-string-length", maxSize);
+            }
+            if (bufferSize > 0) {
+                config.put("org.apache.johnzon.default-char-buffer", bufferSize);
+            }
             if (readerFactory == null) {
                 readerFactory = provider.createReaderFactory(config);
             }

http://git-wip-us.apache.org/repos/asf/incubator-johnzon/blob/b90d1a67/johnzon-mapper/src/test/java/org/apache/johnzon/mapper/NoWarningTest.java
----------------------------------------------------------------------
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
new file mode 100644
index 0000000..b1350cb
--- /dev/null
+++ b/johnzon-mapper/src/test/java/org/apache/johnzon/mapper/NoWarningTest.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.johnzon.mapper;
+
+import org.junit.Rule;
+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;
+
+public class NoWarningTest {
+    @Rule
+    public final StandardOutputStreamLog out = new StandardOutputStreamLog();
+
+    @Rule
+    public final StandardErrorStreamLog err = new StandardErrorStreamLog();
+
+    @Test
+    public void noWarn() {
+        new MapperBuilder()
+                .setEncoding("UTF-8")
+                .setSupportConstructors(true)
+                .setAccessModeName("field")
+                .setBufferStrategy("queue")
+                .setDoCloseOnStreams(true)
+                .setBufferSize(45678)
+                .setMaxSize(789465)
+                .setSkipNull(true)
+                .setSupportsComments(true)
+                .build();
+        // no warn log
+        assertTrue(out.getLog().isEmpty());
+        assertTrue(err.getLog().isEmpty());
+    }
+}