polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject [10/10] polygene-java git commit: POLYGENE-120 - Testcase for default interface methods.
Date Sun, 14 May 2017 04:08:15 GMT
POLYGENE-120 - Testcase for default interface methods.

Signed-off-by: niclas <niclas@hedhman.org>


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

Branch: refs/heads/develop
Commit: 07f65e0a4dba3f36466da5740b1a4151e1052a28
Parents: ee79f22
Author: niclas <niclas@hedhman.org>
Authored: Sat May 13 16:43:03 2017 +0800
Committer: niclas <niclas@hedhman.org>
Committed: Sun May 14 12:07:56 2017 +0800

----------------------------------------------------------------------
 .../runtime/mixin/DefaultMethodsTest.java       | 31 +++++++++++++++++---
 1 file changed, 27 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/polygene-java/blob/07f65e0a/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/DefaultMethodsTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/DefaultMethodsTest.java
b/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/DefaultMethodsTest.java
index 5beb98f..7795329 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/DefaultMethodsTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/DefaultMethodsTest.java
@@ -17,6 +17,7 @@
  */
 package org.apache.polygene.runtime.mixin;
 
+import org.apache.polygene.api.composite.TransientBuilder;
 import org.apache.polygene.api.property.Property;
 import org.apache.polygene.api.value.ValueBuilder;
 import org.apache.polygene.bootstrap.AssemblyException;
@@ -38,6 +39,7 @@ public class DefaultMethodsTest extends AbstractPolygeneTest
         throws AssemblyException
     {
         module.values( Hello.class );
+        module.transients( Hello.class ).withMixins( SpeakMixin.class );
     }
 
     @Test
@@ -46,13 +48,23 @@ public class DefaultMethodsTest extends AbstractPolygeneTest
         ValueBuilder<Hello> builder = valueBuilderFactory.newValueBuilder( Hello.class
);
         Hello prototype = builder.prototype();
         Property<String> phrase = prototype.phrase();
-        phrase.set( "Hello!" );
+        phrase.set( "Hello" );
         Hello hello = builder.newInstance();
-        assertThat( hello.phrase().get(), equalTo( "Hello!" ) );
+        assertThat( hello.speak(), equalTo( "Hello" ) );
     }
 
-    //    @Mixins( { PropertyMixin.class, NoopMixin.class } )
-    interface Hello
+    @Test
+    public void givenInterfaceWithDefaultMethodAndMixinImplementationWhenCallingExpectMixinValueReturned()
+    {
+        TransientBuilder<Hello> builder = transientBuilderFactory.newTransientBuilder(
Hello.class );
+        Hello prototype = builder.prototype();
+        Property<String> phrase = prototype.phrase();
+        phrase.set( "Hello" );
+        Hello hello = builder.newInstance();
+        assertThat( hello.speak(), equalTo( "Hello, Mixin!" ) );
+    }
+
+    public interface Hello
     {
         Property<String> phrase();
 
@@ -61,4 +73,15 @@ public class DefaultMethodsTest extends AbstractPolygeneTest
             return phrase().get();
         }
     }
+
+    public static abstract class SpeakMixin
+        implements Hello
+    {
+        @Override
+        public String speak()
+        {
+            return phrase().get() + ", Mixin!";
+        }
+    }
+
 }


Mime
View raw message