polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From paulmer...@apache.org
Subject polygene-java git commit: Extract POLYGENE-142 regression test from AbstractPlainValueSerializationTest
Date Sun, 15 Jan 2017 18:24:59 GMT
Repository: polygene-java
Updated Branches:
  refs/heads/develop 8f534efe2 -> b61d0254f


Extract POLYGENE-142 regression test from AbstractPlainValueSerializationTest


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

Branch: refs/heads/develop
Commit: b61d0254fe3dbecafc0bdb1d5692a75babe266df
Parents: 8f534ef
Author: Paul Merlin <paulmerlin@apache.org>
Authored: Sun Jan 15 19:24:44 2017 +0100
Committer: Paul Merlin <paulmerlin@apache.org>
Committed: Sun Jan 15 19:24:44 2017 +0100

----------------------------------------------------------------------
 .../spi/entitystore/Polygene142Test.java        | 112 +++++++++++++++++++
 .../AbstractPlainValueSerializationTest.java    |  84 --------------
 .../JacksonPlainValueSerializationTest.java     |   6 -
 .../OrgJsonPlainValueSerializationTest.java     |   6 -
 .../stax/StaxPlainValueSerializationTest.java   |   8 +-
 5 files changed, 113 insertions(+), 103 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/polygene-java/blob/b61d0254/core/spi/src/test/java/org/apache/polygene/spi/entitystore/Polygene142Test.java
----------------------------------------------------------------------
diff --git a/core/spi/src/test/java/org/apache/polygene/spi/entitystore/Polygene142Test.java
b/core/spi/src/test/java/org/apache/polygene/spi/entitystore/Polygene142Test.java
new file mode 100644
index 0000000..718e3b7
--- /dev/null
+++ b/core/spi/src/test/java/org/apache/polygene/spi/entitystore/Polygene142Test.java
@@ -0,0 +1,112 @@
+/*
+ *  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.spi.entitystore;
+
+import org.apache.polygene.api.entity.EntityBuilder;
+import org.apache.polygene.api.identity.Identity;
+import org.apache.polygene.api.identity.StringIdentity;
+import org.apache.polygene.api.injection.scope.Service;
+import org.apache.polygene.api.property.Property;
+import org.apache.polygene.api.service.qualifier.Tagged;
+import org.apache.polygene.api.unitofwork.UnitOfWork;
+import org.apache.polygene.api.usecase.UsecaseBuilder;
+import org.apache.polygene.api.value.ValueBuilder;
+import org.apache.polygene.api.value.ValueSerialization;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.test.AbstractPolygeneTest;
+import org.apache.polygene.test.EntityTestAssembler;
+import org.junit.Test;
+
+public class Polygene142Test extends AbstractPolygeneTest
+{
+    @Override
+    public void assemble( ModuleAssembly module )
+    {
+        module.values( Regression142Type.class );
+        module.entities( Regression142Type.class );
+        new EntityTestAssembler().assemble( module );
+    }
+
+    @Service
+    @Tagged( ValueSerialization.Formats.JSON )
+    private ValueSerialization serialization;
+
+    @Test
+    public void polygene142RegressionTest()
+        throws Exception
+    {
+        if( getClass().getName().equals(
+            "org.apache.polygene.valueserialization.stax.StaxPlainValueSerializationTest"
) )
+        {
+            // This test is disabled, as this test expect a JSON capable serializer as it
uses
+            // the JSONMapEntityStoreMixin in MemoryEntityStore.
+            return;
+        }
+        Regression142Type value;
+        {
+            ValueBuilder<Regression142Type> builder = valueBuilderFactory.newValueBuilder(
Regression142Type.class );
+            builder.prototype().price().set( 23.45 );
+            builder.prototype().testenum().set( Regression142Enum.B );
+            value = builder.newInstance();
+            String serialized = serialization.serialize( value );
+            System.out.println( serialized ); // ok
+            value = serialization.deserialize( module, Regression142Type.class, serialized
); // ok
+        }
+        {
+            Identity valueId = new StringIdentity( "abcdefg" );
+            {
+                try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( UsecaseBuilder.newUsecase(
"create" ) ) )
+                {
+                    EntityBuilder<Regression142Type> builder = uow.newEntityBuilder(
Regression142Type.class, valueId );
+                    builder.instance().price().set( 45.67 );
+                    builder.instance().testenum().set( Regression142Enum.A );
+                    value = builder.newInstance();
+                    System.out.println( value.testenum().get() );
+                    uow.complete();
+                }
+                catch( Exception e_ )
+                {
+                    e_.printStackTrace();
+                }
+            }
+            {
+                try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( UsecaseBuilder.newUsecase(
"create" ) ) )
+                {
+                    value = uow.get( Regression142Type.class, valueId );
+                    System.out.println( value.price().get() );
+                    System.out.println( value.testenum().get() ); // FAIL
+                }
+            }
+        }
+    }
+
+    private enum Regression142Enum
+    {
+        A,
+        B,
+        C,
+        D
+    }
+
+    interface Regression142Type
+    {
+        Property<Double> price();
+
+        Property<Regression142Enum> testenum();
+    }
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/b61d0254/core/testsupport/src/main/java/org/apache/polygene/test/value/AbstractPlainValueSerializationTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/value/AbstractPlainValueSerializationTest.java
b/core/testsupport/src/main/java/org/apache/polygene/test/value/AbstractPlainValueSerializationTest.java
index 29d17ef..c001b6f 100644
--- a/core/testsupport/src/main/java/org/apache/polygene/test/value/AbstractPlainValueSerializationTest.java
+++ b/core/testsupport/src/main/java/org/apache/polygene/test/value/AbstractPlainValueSerializationTest.java
@@ -26,19 +26,9 @@ import java.time.LocalDateTime;
 import java.time.OffsetDateTime;
 import java.time.ZoneOffset;
 import java.time.ZonedDateTime;
-import org.apache.polygene.api.entity.EntityBuilder;
 import org.apache.polygene.api.entity.EntityReference;
-import org.apache.polygene.api.identity.Identity;
-import org.apache.polygene.api.identity.StringIdentity;
 import org.apache.polygene.api.injection.scope.Service;
-import org.apache.polygene.api.property.Property;
-import org.apache.polygene.api.unitofwork.UnitOfWork;
-import org.apache.polygene.api.usecase.UsecaseBuilder;
-import org.apache.polygene.api.value.ValueBuilder;
 import org.apache.polygene.api.value.ValueSerialization;
-import org.apache.polygene.bootstrap.AssemblyException;
-import org.apache.polygene.bootstrap.ModuleAssembly;
-import org.apache.polygene.entitystore.memory.MemoryEntityStoreService;
 import org.apache.polygene.test.AbstractPolygeneTest;
 import org.junit.Test;
 
@@ -52,21 +42,9 @@ import static org.junit.Assert.assertThat;
 public abstract class AbstractPlainValueSerializationTest
     extends AbstractPolygeneTest
 {
-
     @Service
-    @SuppressWarnings( "ProtectedField" )
     protected ValueSerialization valueSerialization;
 
-    @Override
-    public void assemble( ModuleAssembly module )
-        throws AssemblyException
-    {
-        module.values( Regression142Type.class );
-        module.entities( Regression142Type.class );
-
-        module.services( MemoryEntityStoreService.class );
-    }
-
     @Test
     public void givenCharacterValueWhenSerializingAndDeserializingExpectEquals()
     {
@@ -230,66 +208,4 @@ public abstract class AbstractPlainValueSerializationTest
         EntityReference deserialized = valueSerialization.deserialize( module, EntityReference.class,
serialized );
         assertThat( deserialized, equalTo( EntityReference.parseEntityReference( "ABCD-1234"
) ) );
     }
-
-    @Test
-    public void polygene142RegressionTest()
-        throws Exception
-    {
-        if( getClass().getName().equals( "org.apache.polygene.valueserialization.stax.StaxPlainValueSerializationTest"
) )
-        {
-            // This test is disabled, as this test expect a JSON capable serializer as it
uses
-            // the JSONMapEntityStoreMixin in MemoryEntityStore.
-            return;
-        }
-        ValueSerialization serialization = serviceFinder.findService( ValueSerialization.class
).get();
-
-        Regression142Type value;
-        {
-            ValueBuilder<Regression142Type> builder = valueBuilderFactory.newValueBuilder(
Regression142Type.class );
-            builder.prototype().price().set( 23.45 );
-            builder.prototype().testenum().set( Regression142Enum.B );
-            value = builder.newInstance();
-            String serialized = serialization.serialize( value );
-            System.out.println( serialized ); // ok
-            value = serialization.deserialize( module, Regression142Type.class, serialized
); // ok
-        }
-        {
-            Identity valueId = new StringIdentity( "abcdefg" );
-            {
-                try (UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( UsecaseBuilder.newUsecase(
"create" ) ))
-                {
-                    EntityBuilder<Regression142Type> builder = uow.newEntityBuilder(
Regression142Type.class, valueId );
-                    builder.instance().price().set( 45.67 );
-                    builder.instance().testenum().set( Regression142Enum.A );
-                    value = builder.newInstance();
-                    System.out.println( value.testenum().get() );
-                    uow.complete();
-                }
-                catch( Exception e_ )
-                {
-                    e_.printStackTrace();
-                }
-            }
-            {
-                try (UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( UsecaseBuilder.newUsecase(
"create" ) ))
-                {
-                    value = uow.get( Regression142Type.class, valueId );
-                    System.out.println( value.price().get() );
-                    System.out.println( value.testenum().get() ); // FAIL
-                }
-            }
-        }
-    }
-
-    private enum Regression142Enum
-    {
-        A, B, C, D
-    }
-
-    interface Regression142Type
-    {
-        Property<Double> price();
-
-        Property<Regression142Enum> testenum();
-    }
 }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/b61d0254/extensions/valueserialization-jackson/src/test/java/org/apache/polygene/valueserialization/jackson/JacksonPlainValueSerializationTest.java
----------------------------------------------------------------------
diff --git a/extensions/valueserialization-jackson/src/test/java/org/apache/polygene/valueserialization/jackson/JacksonPlainValueSerializationTest.java
b/extensions/valueserialization-jackson/src/test/java/org/apache/polygene/valueserialization/jackson/JacksonPlainValueSerializationTest.java
index f8c59ed..b4ad6a4 100644
--- a/extensions/valueserialization-jackson/src/test/java/org/apache/polygene/valueserialization/jackson/JacksonPlainValueSerializationTest.java
+++ b/extensions/valueserialization-jackson/src/test/java/org/apache/polygene/valueserialization/jackson/JacksonPlainValueSerializationTest.java
@@ -19,23 +19,17 @@
  */
 package org.apache.polygene.valueserialization.jackson;
 
-import org.apache.polygene.bootstrap.AssemblyException;
 import org.apache.polygene.bootstrap.ModuleAssembly;
 import org.apache.polygene.test.value.AbstractPlainValueSerializationTest;
 
 public class JacksonPlainValueSerializationTest
     extends AbstractPlainValueSerializationTest
 {
-
     // START SNIPPET: assembly
     @Override
     public void assemble( ModuleAssembly module )
-        throws AssemblyException
     {
         new JacksonValueSerializationAssembler().assemble( module );
-        // END SNIPPET: assembly
-        // START SNIPPET: assembly
-        super.assemble( module );
     }
     // END SNIPPET: assembly
 }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/b61d0254/extensions/valueserialization-orgjson/src/test/java/org/apache/polygene/valueserialization/orgjson/OrgJsonPlainValueSerializationTest.java
----------------------------------------------------------------------
diff --git a/extensions/valueserialization-orgjson/src/test/java/org/apache/polygene/valueserialization/orgjson/OrgJsonPlainValueSerializationTest.java
b/extensions/valueserialization-orgjson/src/test/java/org/apache/polygene/valueserialization/orgjson/OrgJsonPlainValueSerializationTest.java
index fafb434..ef1f928 100644
--- a/extensions/valueserialization-orgjson/src/test/java/org/apache/polygene/valueserialization/orgjson/OrgJsonPlainValueSerializationTest.java
+++ b/extensions/valueserialization-orgjson/src/test/java/org/apache/polygene/valueserialization/orgjson/OrgJsonPlainValueSerializationTest.java
@@ -19,23 +19,17 @@
  */
 package org.apache.polygene.valueserialization.orgjson;
 
-import org.apache.polygene.bootstrap.AssemblyException;
 import org.apache.polygene.bootstrap.ModuleAssembly;
 import org.apache.polygene.test.value.AbstractPlainValueSerializationTest;
 
 public class OrgJsonPlainValueSerializationTest
     extends AbstractPlainValueSerializationTest
 {
-
     // START SNIPPET: assembly
     @Override
     public void assemble( ModuleAssembly module )
-        throws AssemblyException
     {
         new OrgJsonValueSerializationAssembler().assemble( module );
-        // END SNIPPET: assembly
-        super.assemble( module );
-        // START SNIPPET: assembly
     }
     // END SNIPPET: assembly
 }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/b61d0254/extensions/valueserialization-stax/src/test/java/org/apache/polygene/valueserialization/stax/StaxPlainValueSerializationTest.java
----------------------------------------------------------------------
diff --git a/extensions/valueserialization-stax/src/test/java/org/apache/polygene/valueserialization/stax/StaxPlainValueSerializationTest.java
b/extensions/valueserialization-stax/src/test/java/org/apache/polygene/valueserialization/stax/StaxPlainValueSerializationTest.java
index a9d4b47..1d1c456 100644
--- a/extensions/valueserialization-stax/src/test/java/org/apache/polygene/valueserialization/stax/StaxPlainValueSerializationTest.java
+++ b/extensions/valueserialization-stax/src/test/java/org/apache/polygene/valueserialization/stax/StaxPlainValueSerializationTest.java
@@ -19,17 +19,15 @@
  */
 package org.apache.polygene.valueserialization.stax;
 
-import org.junit.BeforeClass;
-import org.apache.polygene.bootstrap.AssemblyException;
 import org.apache.polygene.bootstrap.ModuleAssembly;
 import org.apache.polygene.test.value.AbstractPlainValueSerializationTest;
+import org.junit.BeforeClass;
 
 import static org.apache.polygene.test.util.Assume.assumeNoIbmJdk;
 
 public class StaxPlainValueSerializationTest
     extends AbstractPlainValueSerializationTest
 {
-
     @BeforeClass
     public static void beforeClass_IBMJDK()
     {
@@ -39,12 +37,8 @@ public class StaxPlainValueSerializationTest
     // START SNIPPET: assembly
     @Override
     public void assemble( ModuleAssembly module )
-        throws AssemblyException
     {
         new StaxValueSerializationAssembler().assemble( module );
-        // END SNIPPET: assembly
-        super.assemble( module );
-        // START SNIPPET: assembly
     }
     // END SNIPPET: assembly
 }


Mime
View raw message