polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From paulmer...@apache.org
Subject [50/50] [abbrv] polygene-java git commit: Fix json & xml loading of Configuration defaults
Date Sun, 26 Feb 2017 22:48:12 GMT
Fix json & xml loading of Configuration defaults

POLYGENE-191


Project: http://git-wip-us.apache.org/repos/asf/polygene-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/polygene-java/commit/9dcb18eb
Tree: http://git-wip-us.apache.org/repos/asf/polygene-java/tree/9dcb18eb
Diff: http://git-wip-us.apache.org/repos/asf/polygene-java/diff/9dcb18eb

Branch: refs/heads/serialization-3.0
Commit: 9dcb18ebb966ff2b738fe2ddad91f66639f78c0f
Parents: 0d1bb57
Author: Paul Merlin <paulmerlin@apache.org>
Authored: Sun Feb 26 23:44:06 2017 +0100
Committer: Paul Merlin <paulmerlin@apache.org>
Committed: Sun Feb 26 23:44:06 2017 +0100

----------------------------------------------------------------------
 .../api/configuration/Configuration.java        |  7 +++++--
 .../JavaxJsonSerializationAssembler.java        |  1 +
 .../JavaxXmlSerializationAssembler.java         |  1 +
 ...avaxXmlConfigurationDeserializationTest.java | 21 ++++++++++++++++++++
 .../src/test/resources/configtest.xml           |  1 +
 5 files changed, 29 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/polygene-java/blob/9dcb18eb/core/api/src/main/java/org/apache/polygene/api/configuration/Configuration.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/configuration/Configuration.java
b/core/api/src/main/java/org/apache/polygene/api/configuration/Configuration.java
index 21eb05f..1cd32cf 100644
--- a/core/api/src/main/java/org/apache/polygene/api/configuration/Configuration.java
+++ b/core/api/src/main/java/org/apache/polygene/api/configuration/Configuration.java
@@ -49,6 +49,8 @@ import org.apache.polygene.api.unitofwork.UnitOfWorkFactory;
 import org.apache.polygene.api.usecase.Usecase;
 import org.apache.polygene.api.usecase.UsecaseBuilder;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
+
 /**
  * Provide Configurations for Services. A Service that wants to be configurable
  * should inject a reference to Configuration with the Configuration type:
@@ -403,8 +405,9 @@ public interface Configuration<T>
                     {
                         if( asStream != null )
                         {
-                            V configObject = serializerRef.get().deserialize( uow.module(),
configType,
-                                                                              new InputStreamReader(
asStream ) );
+                            Deserializer deserializer = serializerRef.get();
+                            V configObject = deserializer.deserialize( uow.module(), configType,
+                                                                       new InputStreamReader(
asStream, UTF_8 ) );
                             return uow.toEntity( configType, configObject );
                         }
                     }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/9dcb18eb/extensions/serialization-javaxjson/src/main/java/org/apache/polygene/serialization/javaxjson/JavaxJsonSerializationAssembler.java
----------------------------------------------------------------------
diff --git a/extensions/serialization-javaxjson/src/main/java/org/apache/polygene/serialization/javaxjson/JavaxJsonSerializationAssembler.java
b/extensions/serialization-javaxjson/src/main/java/org/apache/polygene/serialization/javaxjson/JavaxJsonSerializationAssembler.java
index 36b84d6..84022e1 100644
--- a/extensions/serialization-javaxjson/src/main/java/org/apache/polygene/serialization/javaxjson/JavaxJsonSerializationAssembler.java
+++ b/extensions/serialization-javaxjson/src/main/java/org/apache/polygene/serialization/javaxjson/JavaxJsonSerializationAssembler.java
@@ -45,6 +45,7 @@ public class JavaxJsonSerializationAssembler extends Assemblers.VisibilityIdenti
                                                            Serializer.class, Deserializer.class,
                                                            JsonSerialization.class,
                                                            JsonSerializer.class, JsonDeserializer.class
)
+                                               .taggedWith( Serialization.Formats.JSON )
                                                .visibleIn( visibility() );
         if( hasIdentity() )
         {

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/9dcb18eb/extensions/serialization-javaxxml/src/main/java/org/apache/polygene/serialization/javaxxml/JavaxXmlSerializationAssembler.java
----------------------------------------------------------------------
diff --git a/extensions/serialization-javaxxml/src/main/java/org/apache/polygene/serialization/javaxxml/JavaxXmlSerializationAssembler.java
b/extensions/serialization-javaxxml/src/main/java/org/apache/polygene/serialization/javaxxml/JavaxXmlSerializationAssembler.java
index b97bf12..e402a9f 100644
--- a/extensions/serialization-javaxxml/src/main/java/org/apache/polygene/serialization/javaxxml/JavaxXmlSerializationAssembler.java
+++ b/extensions/serialization-javaxxml/src/main/java/org/apache/polygene/serialization/javaxxml/JavaxXmlSerializationAssembler.java
@@ -45,6 +45,7 @@ public class JavaxXmlSerializationAssembler extends Assemblers.VisibilityIdentit
                                                            Serializer.class, Deserializer.class,
                                                            XmlSerialization.class,
                                                            XmlSerializer.class, XmlDeserializer.class
)
+                                               .taggedWith( Serialization.Formats.XML )
                                                .visibleIn( visibility() );
         if( hasIdentity() )
         {

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/9dcb18eb/extensions/serialization-javaxxml/src/test/java/org/apache/polygene/serialization/javaxxml/JavaxXmlConfigurationDeserializationTest.java
----------------------------------------------------------------------
diff --git a/extensions/serialization-javaxxml/src/test/java/org/apache/polygene/serialization/javaxxml/JavaxXmlConfigurationDeserializationTest.java
b/extensions/serialization-javaxxml/src/test/java/org/apache/polygene/serialization/javaxxml/JavaxXmlConfigurationDeserializationTest.java
new file mode 100644
index 0000000..f87c396
--- /dev/null
+++ b/extensions/serialization-javaxxml/src/test/java/org/apache/polygene/serialization/javaxxml/JavaxXmlConfigurationDeserializationTest.java
@@ -0,0 +1,21 @@
+package org.apache.polygene.serialization.javaxxml;
+
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.test.entity.AbstractConfigurationDeserializationTest;
+import org.junit.Test;
+
+public class JavaxXmlConfigurationDeserializationTest extends AbstractConfigurationDeserializationTest
+{
+    @Override
+    public void assemble( ModuleAssembly module )
+    {
+        new JavaxXmlSerializationAssembler().assemble( module );
+        super.assemble( module );
+    }
+
+    @Test
+    public void givenServiceWhenInitializingExpectCorrectDeserialization()
+    {
+        super.givenServiceWhenInitializingExpectCorrectDeserialization();
+    }
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/9dcb18eb/extensions/serialization-javaxxml/src/test/resources/configtest.xml
----------------------------------------------------------------------
diff --git a/extensions/serialization-javaxxml/src/test/resources/configtest.xml b/extensions/serialization-javaxxml/src/test/resources/configtest.xml
new file mode 100644
index 0000000..0f6bc4c
--- /dev/null
+++ b/extensions/serialization-javaxxml/src/test/resources/configtest.xml
@@ -0,0 +1 @@
+<?xml version="1.1" encoding="UTF-8" standalone="yes"?><state><value><identity>configtest</identity><host><value
_type="org.apache.polygene.test.entity.AbstractConfigurationDeserializationTest$Host"><ip>12.23.34.45</ip><port>1234</port></value></host><name>main</name></value></state>


Mime
View raw message