You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polygene.apache.org by pa...@apache.org on 2017/03/26 15:40:09 UTC
polygene-java git commit: Add HandCraftedJsonTest
Repository: polygene-java
Updated Branches:
refs/heads/serialization-3.0 324be8faf -> 8953566e1
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/8953566e
Tree: http://git-wip-us.apache.org/repos/asf/polygene-java/tree/8953566e
Diff: http://git-wip-us.apache.org/repos/asf/polygene-java/diff/8953566e
Branch: refs/heads/serialization-3.0
Commit: 8953566e1ea42f62a03d67e8006e47066d28e035
Parents: 324be8f
Author: Paul Merlin <pa...@apache.org>
Authored: Sun Mar 26 17:20:39 2017 +0200
Committer: Paul Merlin <pa...@apache.org>
Committed: Sun Mar 26 17:20:39 2017 +0200
----------------------------------------------------------------------
.../javaxjson/HandCraftedJsonTest.java | 74 ++++++++++++++++++++
1 file changed, 74 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/8953566e/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<String> 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" ) );
+ }
+}