Repository: incubator-tamaya-extensions Updated Branches: refs/heads/master 299b67712 -> 839b50f36
TAMAYA-291: Add basic JSONVisitor test Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/839b50f3 Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/839b50f3 Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/839b50f3 Branch: refs/heads/master Commit: 839b50f36c7429c7fc5ecf4e1f68db0fa592bc1b Parents: 299b677 Author: Phil Ottlinger <[email protected]> Authored: Sun Oct 22 22:49:38 2017 +0200 Committer: Phil Ottlinger <[email protected]> Committed: Sun Oct 22 22:49:38 2017 +0200 ---------------------------------------------------------------------- modules/formats/json/pom.xml | 4 ++ .../org/apache/tamaya/json/JSONVisitorTest.java | 63 ++++++++++++++++++++ modules/formats/pom.xml | 1 - pom.xml | 1 - 4 files changed, 67 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/839b50f3/modules/formats/json/pom.xml ---------------------------------------------------------------------- diff --git a/modules/formats/json/pom.xml b/modules/formats/json/pom.xml index 1bf8345..49360ca 100644 --- a/modules/formats/json/pom.xml +++ b/modules/formats/json/pom.xml @@ -98,6 +98,10 @@ under the License. <groupId>org.hamcrest</groupId> <artifactId>java-hamcrest</artifactId> </dependency> + <dependency> + <groupId>org.assertj</groupId> + <artifactId>assertj-core</artifactId> + </dependency> </dependencies> <build> http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/839b50f3/modules/formats/json/src/test/java/org/apache/tamaya/json/JSONVisitorTest.java ---------------------------------------------------------------------- diff --git a/modules/formats/json/src/test/java/org/apache/tamaya/json/JSONVisitorTest.java b/modules/formats/json/src/test/java/org/apache/tamaya/json/JSONVisitorTest.java new file mode 100644 index 0000000..6a51f0a --- /dev/null +++ b/modules/formats/json/src/test/java/org/apache/tamaya/json/JSONVisitorTest.java @@ -0,0 +1,63 @@ +/* + * 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.tamaya.json; + +import java.util.HashMap; +import java.util.Map; + +import static org.assertj.core.api.Assertions.*; +import javax.json.Json; +import javax.json.JsonObject; +import javax.json.JsonValue; + +import org.junit.Test; + +public class JSONVisitorTest { + + @Test + public void ensureJSONisParsedProperlyWithDifferentValueTypes() { + JsonObject startNode = Json.createObjectBuilder().// + add("key.sub", "value").// + add("anotherKey", true).// + add("notAnotherKey", false).// + add("number", 4711).// + add("null", JsonValue.NULL).// + build(); + Map<String, String> targetStore = new HashMap<>(); + JSONVisitor visitor = new JSONVisitor(startNode, targetStore); + assertThat(visitor).isNotNull(); + + visitor.run(); + + assertThat(targetStore).hasSize(5); + } + + @Test + public void parsingWorksOnEmptyObject() { + JsonObject startNode = Json.createObjectBuilder().build(); + + Map<String, String> targetStore = new HashMap<>(); + JSONVisitor visitor = new JSONVisitor(startNode, targetStore); + assertThat(visitor).isNotNull(); + + visitor.run(); + assertThat(targetStore).isEmpty(); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/839b50f3/modules/formats/pom.xml ---------------------------------------------------------------------- diff --git a/modules/formats/pom.xml b/modules/formats/pom.xml index 9853c55..5a6d96e 100644 --- a/modules/formats/pom.xml +++ b/modules/formats/pom.xml @@ -35,5 +35,4 @@ <module>json</module> <module>yaml</module> </modules> - </project> http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/839b50f3/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 382a487..4774607 100644 --- a/pom.xml +++ b/pom.xml @@ -332,7 +332,6 @@ under the License. <artifactId>johnzon-core</artifactId> <version>${johnzon.version}</version> </dependency> - </dependencies> </dependencyManagement>
