Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id D1B88200C4A for ; Sun, 2 Apr 2017 19:47:48 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id D084B160B79; Sun, 2 Apr 2017 17:47:48 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id A2452160BB5 for ; Sun, 2 Apr 2017 19:47:46 +0200 (CEST) Received: (qmail 19753 invoked by uid 500); 2 Apr 2017 17:47:45 -0000 Mailing-List: contact commits-help@polygene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@polygene.apache.org Delivered-To: mailing list commits@polygene.apache.org Received: (qmail 18561 invoked by uid 99); 2 Apr 2017 17:47:44 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 02 Apr 2017 17:47:44 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 10B8CE08AC; Sun, 2 Apr 2017 17:47:44 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: paulmerlin@apache.org To: commits@polygene.apache.org Date: Sun, 02 Apr 2017 17:48:33 -0000 Message-Id: <8dc1884d67ee40a5aef556b76f0bfc45@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [51/52] [abbrv] polygene-java git commit: Add HandCraftedJsonTest archived-at: Sun, 02 Apr 2017 17:47:49 -0000 Add HandCraftedJsonTest POLYGENE-231 Project: http://git-wip-us.apache.org/repos/asf/polygene-java/repo Commit: http://git-wip-us.apache.org/repos/asf/polygene-java/commit/14fe39ce Tree: http://git-wip-us.apache.org/repos/asf/polygene-java/tree/14fe39ce Diff: http://git-wip-us.apache.org/repos/asf/polygene-java/diff/14fe39ce Branch: refs/heads/develop Commit: 14fe39ce9c3946cf4351797a205d316e4629235a Parents: bd39297 Author: Paul Merlin Authored: Sun Mar 26 17:20:39 2017 +0200 Committer: Paul Merlin Committed: Sun Apr 2 19:16:24 2017 +0200 ---------------------------------------------------------------------- .../javaxjson/HandCraftedJsonTest.java | 74 ++++++++++++++++++++ 1 file changed, 74 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/polygene-java/blob/14fe39ce/extensions/serialization-javaxjson/src/test/java/org/apache/polygene/serialization/javaxjson/HandCraftedJsonTest.java ---------------------------------------------------------------------- diff --git a/extensions/serialization-javaxjson/src/test/java/org/apache/polygene/serialization/javaxjson/HandCraftedJsonTest.java b/extensions/serialization-javaxjson/src/test/java/org/apache/polygene/serialization/javaxjson/HandCraftedJsonTest.java new file mode 100644 index 0000000..2181b6b --- /dev/null +++ b/extensions/serialization-javaxjson/src/test/java/org/apache/polygene/serialization/javaxjson/HandCraftedJsonTest.java @@ -0,0 +1,74 @@ +/* + * 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.polygene.serialization.javaxjson; + +import org.apache.polygene.api.injection.scope.Service; +import org.apache.polygene.api.property.Property; +import org.apache.polygene.api.serialization.Deserializer; +import org.apache.polygene.bootstrap.ModuleAssembly; +import org.apache.polygene.serialization.javaxjson.assembly.JavaxJsonSerializationAssembler; +import org.apache.polygene.test.AbstractPolygeneTest; +import org.apache.polygene.test.util.NotYetImplemented; +import org.junit.Test; + +import static org.hamcrest.Matchers.equalTo; +import static org.junit.Assert.assertThat; + +public class HandCraftedJsonTest extends AbstractPolygeneTest +{ + @Override + public void assemble( ModuleAssembly module ) + { + new JavaxJsonSerializationAssembler().assemble( module ); + module.values( SomeValue.class ); + } + + public interface SomeValue + { + Property foo(); + } + + @Service + private Deserializer deserializer; + + @Test + public void canReadSingleLineJson() + { + String json = " { \"foo\" : \"bar\" } "; + assertThat( deserializer.deserialize( module, SomeValue.class, json ).foo().get(), + equalTo( "bar" ) ); + } + + @Test + public void canReadFormattedMultiLineJson() + { + String json = " \n { \n\t\"foo\" : \"bar\" \n }\n "; + assertThat( deserializer.deserialize( module, SomeValue.class, json ).foo().get(), + equalTo( "bar" ) ); + } + + @Test + @NotYetImplemented( reason = "need to manage javax.json providers and properties first, could work with Johnzon" ) + // See org.apache.johnzon.supports-comments + public void canReadCommentedJson() + { + String json = "// One comment\n { \n\t\"foo\" : \"bar\" \n/* Two comments */ }\n "; + assertThat( deserializer.deserialize( module, SomeValue.class, json ).foo().get(), + equalTo( "bar" ) ); + } +}