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/13 15:28:28 UTC

[05/48] polygene-java git commit: Trigger UoW completion in AbstractValueCompositeSerializationTest

Trigger UoW completion in AbstractValueCompositeSerializationTest

Add complex value composite in entity under test.
Exercise entity state serialization in test.

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/65b53d9b
Tree: http://git-wip-us.apache.org/repos/asf/polygene-java/tree/65b53d9b
Diff: http://git-wip-us.apache.org/repos/asf/polygene-java/diff/65b53d9b

Branch: refs/heads/serialization-3.0
Commit: 65b53d9b129d81c3c2a8e0375cb57e23d30ee382
Parents: dfc1493
Author: Paul Merlin <pa...@apache.org>
Authored: Mon Mar 13 09:10:29 2017 +0100
Committer: Paul Merlin <pa...@apache.org>
Committed: Mon Mar 13 16:27:47 2017 +0100

----------------------------------------------------------------------
 ...AbstractValueCompositeSerializationTest.java | 50 ++++++++++++--------
 1 file changed, 30 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/polygene-java/blob/65b53d9b/core/testsupport/src/main/java/org/apache/polygene/test/serialization/AbstractValueCompositeSerializationTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/serialization/AbstractValueCompositeSerializationTest.java b/core/testsupport/src/main/java/org/apache/polygene/test/serialization/AbstractValueCompositeSerializationTest.java
index a0975ee..2642198 100644
--- a/core/testsupport/src/main/java/org/apache/polygene/test/serialization/AbstractValueCompositeSerializationTest.java
+++ b/core/testsupport/src/main/java/org/apache/polygene/test/serialization/AbstractValueCompositeSerializationTest.java
@@ -50,7 +50,6 @@ import org.apache.polygene.api.structure.Module;
 import org.apache.polygene.api.unitofwork.UnitOfWork;
 import org.apache.polygene.api.value.ValueBuilder;
 import org.apache.polygene.api.value.ValueComposite;
-import org.apache.polygene.bootstrap.AssemblyException;
 import org.apache.polygene.bootstrap.ModuleAssembly;
 import org.apache.polygene.test.AbstractPolygeneTest;
 import org.apache.polygene.test.EntityTestAssembler;
@@ -89,12 +88,8 @@ public abstract class AbstractValueCompositeSerializationTest
         System.out.println( "# END " + testName.getMethodName() );
     }
 
-    @Structure
-    protected Module moduleInstance;
-
     @Override
     public void assemble( ModuleAssembly module )
-        throws AssemblyException
     {
         module.values( Some.class, SomeExtended.class, SomeShuffled.class,
                        AnotherValue.class, FooValue.class, CustomFooValue.class,
@@ -104,6 +99,9 @@ public abstract class AbstractValueCompositeSerializationTest
         module.entities( Some.class, BarEntity.class );
     }
 
+    @Structure
+    protected Module moduleInstance;
+
     @Service
     protected Serialization serialization;
 
@@ -141,6 +139,8 @@ public abstract class AbstractValueCompositeSerializationTest
                         is( true ) );
 
             assertThat( "Value equality", some, equalTo( some2 ) );
+
+            uow.complete();
         }
     }
 
@@ -156,6 +156,8 @@ public abstract class AbstractValueCompositeSerializationTest
 
             Some deserialized = serialization.deserialize( module, Some.class, serialized );
             System.out.println( deserialized );
+
+            uow.complete();
         }
     }
 
@@ -171,6 +173,8 @@ public abstract class AbstractValueCompositeSerializationTest
 
             SomeExtended deserialized = serialization.deserialize( module, SomeExtended.class, serialized );
             System.out.println( deserialized );
+
+            uow.complete();
         }
     }
 
@@ -196,6 +200,8 @@ public abstract class AbstractValueCompositeSerializationTest
 
             serialization.deserialize( module, SomeExtended.class, serialized );
             System.out.println( deserialized );
+
+            uow.complete();
         }
     }
 
@@ -268,9 +274,9 @@ public abstract class AbstractValueCompositeSerializationTest
         proto.identity().set( StringIdentity.fromString( identity ) );
         setSomeValueState( module, uow, proto );
         proto.extraProperty().set( "extra property" );
-        proto.extraAssociation().set( buildBarEntity( uow, "extra association" ) );
-        proto.extraManyAssociation().add( buildBarEntity( uow, "extra many association" ) );
-        proto.extraNamedAssociation().put( "extra", buildBarEntity( uow, "extra named association" ) );
+        proto.extraAssociation().set( buildBarEntity( module, uow, "extra association" ) );
+        proto.extraManyAssociation().add( buildBarEntity( module, uow, "extra many association" ) );
+        proto.extraNamedAssociation().put( "extra", buildBarEntity( module, uow, "extra named association" ) );
         return builder.newInstance();
     }
 
@@ -314,7 +320,7 @@ public abstract class AbstractValueCompositeSerializationTest
         // maintain a certain order but it's not the case on some JVMs. On OpenJDK 8 they are reversed for example.
         // This should not be enforced tough as both the Map API and the JSON specification state that name-value pairs
         // are unordered.
-        // As a consequence this test should be enhanced to be Map order independant.
+        // As a consequence this test should be enhanced to be Map order independent.
         //
         // proto.stringIntMap().get().put( "bar", 67 );
 
@@ -330,18 +336,19 @@ public abstract class AbstractValueCompositeSerializationTest
         some.customFooValue().set( module.newValue( CustomFooValue.class ) );
 
         // NestedEntities
-        some.barAssociation().set( buildBarEntity( uow, "bazar in barAssociation" ) );
-        some.barEntityAssociation().set( buildBarEntity( uow, "bazar in barEntityAssociation" ) );
-        some.barManyAssociation().add( buildBarEntity( uow, "bazar ONE in barManyAssociation" ) );
-        some.barManyAssociation().add( buildBarEntity( uow, "bazar TWO in barManyAssociation" ) );
-        some.barEntityManyAssociation().add( buildBarEntity( uow, "bazar ONE in barEntityManyAssociation" ) );
-        some.barEntityManyAssociation().add( buildBarEntity( uow, "bazar TWO in barEntityManyAssociation" ) );
-        some.barNamedAssociation().put( "bazar", buildBarEntity( uow, "bazar in barNamedAssociation" ) );
-        some.barNamedAssociation().put( "cathedral", buildBarEntity( uow, "cathedral in barNamedAssociation" ) );
+        some.barAssociation().set( buildBarEntity( module, uow, "bazar in barAssociation" ) );
+        some.barEntityAssociation().set( buildBarEntity( module, uow, "bazar in barEntityAssociation" ) );
+        some.barManyAssociation().add( buildBarEntity( module, uow, "bazar ONE in barManyAssociation" ) );
+        some.barManyAssociation().add( buildBarEntity( module, uow, "bazar TWO in barManyAssociation" ) );
+        some.barEntityManyAssociation().add( buildBarEntity( module, uow, "bazar ONE in barEntityManyAssociation" ) );
+        some.barEntityManyAssociation().add( buildBarEntity( module, uow, "bazar TWO in barEntityManyAssociation" ) );
+        some.barNamedAssociation().put( "bazar", buildBarEntity( module, uow, "bazar in barNamedAssociation" ) );
+        some.barNamedAssociation().put( "cathedral",
+                                        buildBarEntity( module, uow, "cathedral in barNamedAssociation" ) );
         some.barEntityNamedAssociation().put( "bazar",
-                                              buildBarEntity( uow, "bazar in barEntityNamedAssociation" ) );
+                                              buildBarEntity( module, uow, "bazar in barEntityNamedAssociation" ) );
         some.barEntityNamedAssociation().put( "cathedral",
-                                              buildBarEntity( uow, "cathedral in barEntityNamedAssociation" ) );
+                                              buildBarEntity( module, uow, "cathedral in barEntityNamedAssociation" ) );
     }
 
     private static AnotherValue createAnotherValue( Module module, String val1, String val2 )
@@ -352,10 +359,11 @@ public abstract class AbstractValueCompositeSerializationTest
         return valueBuilder.newInstance();
     }
 
-    private static BarEntity buildBarEntity( UnitOfWork uow, String cathedral )
+    private static BarEntity buildBarEntity( Module module, UnitOfWork uow, String cathedral )
     {
         EntityBuilder<BarEntity> barBuilder = uow.newEntityBuilder( BarEntity.class );
         barBuilder.instance().cathedral().set( cathedral );
+        barBuilder.instance().another().set( createAnotherValue( module, "nested", "value" ) );
         return barBuilder.newInstance();
     }
 
@@ -574,6 +582,8 @@ public abstract class AbstractValueCompositeSerializationTest
     {
         @UseDefaults
         Property<String> cathedral();
+
+        Property<AnotherValue> another();
     }
 
     public interface BarEntity