polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From paulmer...@apache.org
Subject zest-java git commit: ZEST-120 Add incomplete ignored test, demonstrating the issue
Date Sun, 20 Nov 2016 15:16:12 GMT
Repository: zest-java
Updated Branches:
  refs/heads/develop 64d6d81ce -> 8558d2d06


ZEST-120 Add incomplete ignored test, demonstrating the issue

Composites do not implement interface default methods.
Application bootstrap fails.


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

Branch: refs/heads/develop
Commit: 8558d2d064a6c2ef5c72ec27fe708c1e70e6ac54
Parents: 64d6d81
Author: Paul Merlin <paulmerlin@apache.org>
Authored: Sun Nov 20 16:15:35 2016 +0100
Committer: Paul Merlin <paulmerlin@apache.org>
Committed: Sun Nov 20 16:15:35 2016 +0100

----------------------------------------------------------------------
 .../composite/InterfaceDefaultMethodsTest.java  | 139 +++++++++++++++++++
 1 file changed, 139 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zest-java/blob/8558d2d0/core/runtime/src/test/java/org/apache/zest/runtime/composite/InterfaceDefaultMethodsTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/composite/InterfaceDefaultMethodsTest.java
b/core/runtime/src/test/java/org/apache/zest/runtime/composite/InterfaceDefaultMethodsTest.java
new file mode 100644
index 0000000..4e3c873
--- /dev/null
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/composite/InterfaceDefaultMethodsTest.java
@@ -0,0 +1,139 @@
+package org.apache.zest.runtime.composite;
+
+import org.apache.zest.api.constraint.ConstraintViolationException;
+import org.apache.zest.bootstrap.AssemblyException;
+import org.apache.zest.bootstrap.ModuleAssembly;
+import org.apache.zest.library.constraints.annotation.NotEmpty;
+import org.apache.zest.test.AbstractZestTest;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.equalTo;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
+
+/**
+ * Assert that interface default methods are mixed in composites.
+ */
+public class InterfaceDefaultMethodsTest extends AbstractZestTest
+{
+    public interface DefaultMethods
+    {
+        default String sayHello( String name )
+        {
+            return "Hello, " + name + '!';
+        }
+    }
+
+    public interface OverrideDefaultMethods extends DefaultMethods
+    {
+        @Override
+        default String sayHello( String name )
+        {
+            return "Hello, overridden in " + name + '!';
+        }
+    }
+
+    public static abstract class MixinDefaultMethods implements DefaultMethods
+    {
+        @Override
+        public String sayHello( String name )
+        {
+            return "Hello, mixed in " + name + '!';
+        }
+    }
+
+    public interface DefaultMethodsConstraints extends DefaultMethods
+    {
+        @Override
+        default String sayHello( @NotEmpty String name )
+        {
+            return "Hello, " + name + '!';
+        }
+    }
+
+    public interface DefaultMethodsConcerns extends DefaultMethods
+    {
+        // TODO Add concern
+        @Override
+        default String sayHello( String name )
+        {
+            return "Hello, " + name + '!';
+        }
+    }
+
+    public interface DefaultMethodsSideEffects extends DefaultMethods
+    {
+        // TODO Add side effect
+        @Override
+        default String sayHello( String name )
+        {
+            return "Hello, " + name + '!';
+        }
+    }
+
+    @Override
+    public void assemble( final ModuleAssembly module ) throws AssemblyException
+    {
+        module.transients( DefaultMethods.class,
+                           OverrideDefaultMethods.class,
+                           MixinDefaultMethods.class,
+                           DefaultMethodsConstraints.class,
+                           DefaultMethodsConcerns.class,
+                           DefaultMethodsSideEffects.class );
+    }
+
+    @Ignore( "ZEST-120" )
+    @Test
+    public void defaultMethods()
+    {
+        DefaultMethods composite = transientBuilderFactory.newTransient( DefaultMethods.class
);
+        assertThat( composite.sayHello( "John" ), equalTo( "Hello, John!" ) );
+    }
+
+    @Ignore( "ZEST-120" )
+    @Test
+    public void overrideDefaultMethods()
+    {
+        OverrideDefaultMethods composite = transientBuilderFactory.newTransient( OverrideDefaultMethods.class
);
+        assertThat( composite.sayHello( "John" ), equalTo( "Hello, overridden John!" ) );
+    }
+
+    @Ignore( "ZEST-120" )
+    @Test
+    public void mixinDefaultMethods()
+    {
+        MixinDefaultMethods composite = transientBuilderFactory.newTransient( MixinDefaultMethods.class
);
+        assertThat( composite.sayHello( "John" ), equalTo( "Hello, mixed in John!" ) );
+    }
+
+    @Ignore( "ZEST-120" )
+    @Test
+    public void defaultMethodsConstraints()
+    {
+        DefaultMethodsConstraints composite = transientBuilderFactory.newTransient( DefaultMethodsConstraints.class
);
+        try
+        {
+            composite.sayHello( "" );
+        }
+        catch( ConstraintViolationException ex )
+        {
+            assertThat( ex.getMessage(), containsString( "sayHello" ) );
+        }
+    }
+
+    @Ignore( "ZEST-120" )
+    @Test
+    public void defaultMethodsConcerns()
+    {
+        fail( "Test not implemented" );
+    }
+
+    @Ignore( "ZEST-120" )
+    @Test
+    public void defaultMethodsSideEffects()
+    {
+        fail( "Test not implemented" );
+    }
+}


Mime
View raw message