You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@johnzon.apache.org by st...@apache.org on 2017/11/06 17:00:46 UTC
[1/2] johnzon git commit: JOHNZON-144 add a unit test to make the
problem clear
Repository: johnzon
Updated Branches:
refs/heads/master 2ffe0f697 -> 092848f20
JOHNZON-144 add a unit test to make the problem clear
Project: http://git-wip-us.apache.org/repos/asf/johnzon/repo
Commit: http://git-wip-us.apache.org/repos/asf/johnzon/commit/6b67b885
Tree: http://git-wip-us.apache.org/repos/asf/johnzon/tree/6b67b885
Diff: http://git-wip-us.apache.org/repos/asf/johnzon/diff/6b67b885
Branch: refs/heads/master
Commit: 6b67b8850cf8c9c7f25f9908faecf51f699f38b3
Parents: 2ffe0f6
Author: Mark Struberg <st...@apache.org>
Authored: Mon Nov 6 17:57:57 2017 +0100
Committer: Mark Struberg <st...@apache.org>
Committed: Mon Nov 6 17:57:57 2017 +0100
----------------------------------------------------------------------
.../jsonb/JohnzonConverterInJsonbTest.java | 79 ++++++++++++++++++++
1 file changed, 79 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/johnzon/blob/6b67b885/johnzon-jsonb/src/test/java/org/apache/johnzon/jsonb/JohnzonConverterInJsonbTest.java
----------------------------------------------------------------------
diff --git a/johnzon-jsonb/src/test/java/org/apache/johnzon/jsonb/JohnzonConverterInJsonbTest.java b/johnzon-jsonb/src/test/java/org/apache/johnzon/jsonb/JohnzonConverterInJsonbTest.java
new file mode 100644
index 0000000..75023d3
--- /dev/null
+++ b/johnzon-jsonb/src/test/java/org/apache/johnzon/jsonb/JohnzonConverterInJsonbTest.java
@@ -0,0 +1,79 @@
+/*
+ * 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.jsonb;
+
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
+
+import javax.json.bind.Jsonb;
+import javax.json.bind.spi.JsonbProvider;
+
+import org.apache.johnzon.mapper.Converter;
+import org.apache.johnzon.mapper.JohnzonConverter;
+import org.junit.Test;
+import static org.junit.Assert.assertNotNull;
+
+/**
+ * Test that a Johnzon Converter works even in JsonB mode
+ */
+public class JohnzonConverterInJsonbTest {
+
+ @Test
+ public void testJohnzonConverter() {
+ TestDTO dto = new TestDTO();
+ dto.setInstant(Instant.now());
+
+ Jsonb jsonb = JsonbProvider.provider().create().build();
+ String json = jsonb.toJson(dto);
+ assertNotNull(json);
+ }
+
+ public static class TestDTO {
+ @JohnzonConverter(TestInstantConverter.class)
+ private Instant instant;
+
+ public Instant getInstant() {
+ return instant;
+ }
+
+ public void setInstant(Instant instant) {
+ this.instant = instant;
+ }
+ }
+
+
+ public static class TestInstantConverter implements Converter<Instant> {
+ public static final DateTimeFormatter FORMAT = DateTimeFormatter.ofPattern(
+ "yyyy-MM-dd HH:mm:ss.SSS");
+
+ @Override
+ public String toString(Instant date) {
+ return FORMAT.withZone(ZoneId.of("UTC")).format(date);
+ }
+
+ @Override
+ public Instant fromString(String dateStr) {
+ return LocalDateTime.parse(dateStr, FORMAT)
+ .atZone(ZoneId.of("UTC"))
+ .toInstant();
+ }
+
+ }
+
+}
[2/2] johnzon git commit: JOHNZON-139 remove half baked work
Posted by st...@apache.org.
JOHNZON-139 remove half baked work
Project: http://git-wip-us.apache.org/repos/asf/johnzon/repo
Commit: http://git-wip-us.apache.org/repos/asf/johnzon/commit/092848f2
Tree: http://git-wip-us.apache.org/repos/asf/johnzon/tree/092848f2
Diff: http://git-wip-us.apache.org/repos/asf/johnzon/diff/092848f2
Branch: refs/heads/master
Commit: 092848f20e380d3ff88a446d342079559285f155
Parents: 6b67b88
Author: Mark Struberg <st...@apache.org>
Authored: Mon Nov 6 17:59:36 2017 +0100
Committer: Mark Struberg <st...@apache.org>
Committed: Mon Nov 6 17:59:36 2017 +0100
----------------------------------------------------------------------
.../java/org/apache/johnzon/core/JohnzonJsonParserImpl.java | 7 -------
1 file changed, 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/johnzon/blob/092848f2/johnzon-core/src/main/java/org/apache/johnzon/core/JohnzonJsonParserImpl.java
----------------------------------------------------------------------
diff --git a/johnzon-core/src/main/java/org/apache/johnzon/core/JohnzonJsonParserImpl.java b/johnzon-core/src/main/java/org/apache/johnzon/core/JohnzonJsonParserImpl.java
index b105e8b..5939119 100644
--- a/johnzon-core/src/main/java/org/apache/johnzon/core/JohnzonJsonParserImpl.java
+++ b/johnzon-core/src/main/java/org/apache/johnzon/core/JohnzonJsonParserImpl.java
@@ -16,8 +16,6 @@
*/
package org.apache.johnzon.core;
-import java.util.Map;
-import java.util.stream.Stream;
import javax.json.JsonArray;
import javax.json.JsonObject;
@@ -96,9 +94,4 @@ public abstract class JohnzonJsonParserImpl implements JohnzonJsonParser {
}
}
-
- @Override
- public Stream<Map.Entry<String, JsonValue>> getObjectStream() {
- return null;
- }
}