polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject [26/81] [abbrv] [partial] zest-java git commit: ZEST-195 ; Replace all "zest" with "polygene"
Date Sat, 17 Dec 2016 10:28:02 GMT
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/test/java/org/apache/polygene/api/injection/scope/StateFieldTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/polygene/api/injection/scope/StateFieldTest.java b/core/api/src/test/java/org/apache/polygene/api/injection/scope/StateFieldTest.java
new file mode 100644
index 0000000..13c6e60
--- /dev/null
+++ b/core/api/src/test/java/org/apache/polygene/api/injection/scope/StateFieldTest.java
@@ -0,0 +1,149 @@
+/*
+ *  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.api.injection.scope;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.apache.polygene.api.association.Association;
+import org.apache.polygene.api.association.ManyAssociation;
+import org.apache.polygene.api.common.Optional;
+import org.apache.polygene.api.common.UseDefaults;
+import org.apache.polygene.api.entity.EntityComposite;
+import org.apache.polygene.api.mixin.Mixins;
+import org.apache.polygene.api.property.Property;
+import org.apache.polygene.api.unitofwork.UnitOfWork;
+import org.apache.polygene.bootstrap.AssemblyException;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.test.AbstractPolygeneTest;
+import org.apache.polygene.test.EntityTestAssembler;
+
+/**
+ * Define a field to be a Property
+ */
+public class StateFieldTest
+    extends AbstractPolygeneTest
+{
+    public void assemble( ModuleAssembly module )
+        throws AssemblyException
+    {
+        new EntityTestAssembler().assemble( module );
+        module.entities( PersonEntity.class );
+    }
+
+    @Test
+    public void givenEntityWithFieldPropertiesWhenUpdatedThenReturnCorrect()
+        throws Exception
+    {
+        UnitOfWork unitOfWork = unitOfWorkFactory.newUnitOfWork();
+        try
+        {
+            PersonEntity charles = unitOfWork.newEntity( PersonEntity.class );
+            charles.changeName( "Charles" );
+            Assert.assertEquals( charles.getName(), "Charles" );
+
+            PersonEntity daniel = unitOfWork.newEntity( PersonEntity.class );
+            daniel.changeName( "Daniel" );
+            Assert.assertEquals( daniel.getName(), "Daniel" );
+
+            PersonEntity lisa = unitOfWork.newEntity( PersonEntity.class );
+            lisa.changeName( "Lisa" );
+            Assert.assertEquals( lisa.getName(), "Lisa" );
+
+            charles.befriend( daniel );
+            charles.befriend( lisa );
+            charles.marry( lisa );
+
+            unitOfWork.complete();
+
+            unitOfWork = unitOfWorkFactory.newUnitOfWork();
+
+            charles = unitOfWork.get( charles );
+            daniel = unitOfWork.get( daniel );
+            Assert.assertTrue( charles.isFriend( daniel ) );
+
+            unitOfWork.complete();
+        }
+        finally
+        {
+            unitOfWork.discard();
+        }
+    }
+
+    @Mixins( PersonEntity.Mixin.class )
+    public interface PersonEntity
+        extends EntityComposite
+    {
+        void changeName( String newName );
+
+        void marry( PersonEntity entity );
+
+        void befriend( PersonEntity entity );
+
+        boolean isFriend( PersonEntity entity );
+
+        String getName();
+
+        abstract class Mixin
+            implements PersonEntity
+        {
+            @State
+            @UseDefaults
+            public Property<String> name;
+
+            @State
+            @Optional
+            public Association<PersonEntity> spouse;
+
+            @State
+            public ManyAssociation<PersonEntity> friends;
+
+            @Override
+            public void changeName( String newName )
+            {
+                name.set( newName );
+            }
+
+            @Override
+            public void marry( PersonEntity entity )
+            {
+                spouse.set( entity );
+            }
+
+            @Override
+            public void befriend( PersonEntity entity )
+            {
+                friends.add( entity );
+            }
+
+            @Override
+            public String getName()
+            {
+                return name.get();
+            }
+
+            @Override
+            public boolean isFriend( PersonEntity entity )
+            {
+                return friends.contains( entity );
+            }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/test/java/org/apache/polygene/api/injection/scope/ThisTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/polygene/api/injection/scope/ThisTest.java b/core/api/src/test/java/org/apache/polygene/api/injection/scope/ThisTest.java
new file mode 100644
index 0000000..a26d434
--- /dev/null
+++ b/core/api/src/test/java/org/apache/polygene/api/injection/scope/ThisTest.java
@@ -0,0 +1,54 @@
+/*
+ *  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.api.injection.scope;
+
+import java.lang.annotation.Annotation;
+import org.junit.Test;
+import org.apache.polygene.api.common.Optional;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+/**
+ * Tests public api exposed by This annotation.
+ * This will ensure that the public api does not get changed by mistake.
+ */
+public class ThisTest
+{
+
+    @Test
+    public void retention()
+        throws NoSuchFieldException
+    {
+        Annotation[] annotations = Annotated.class.getDeclaredField( "uses" ).getDeclaredAnnotations();
+        assertNotNull( "annotations should not be null", annotations );
+        assertEquals( "number of annotations", 1, annotations.length );
+        assertEquals( "annotation type", This.class, annotations[ 0 ].annotationType() );
+    }
+
+    private static class Annotated
+    {
+        @This
+        String uses;
+        @Optional
+        @This
+        String usesOptional;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/test/java/org/apache/polygene/api/metrics/DocumentationSupport.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/polygene/api/metrics/DocumentationSupport.java b/core/api/src/test/java/org/apache/polygene/api/metrics/DocumentationSupport.java
new file mode 100644
index 0000000..654bd5d
--- /dev/null
+++ b/core/api/src/test/java/org/apache/polygene/api/metrics/DocumentationSupport.java
@@ -0,0 +1,114 @@
+/*
+ *  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.api.metrics;
+
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingQueue;
+import org.apache.polygene.api.injection.scope.Service;
+
+public class DocumentationSupport
+{
+    // START SNIPPET: common
+    @Service
+    private MetricsProvider provider;
+    // END SNIPPET: common
+
+    public void forDocumentationOnly()
+    {
+        // START SNIPPET: gauge
+        final BlockingQueue queue = new LinkedBlockingQueue( 20 );
+        // END SNIPPET: gauge
+        // START SNIPPET: gauge
+        MetricsGaugeFactory gaugeFactory = provider.createFactory( MetricsGaugeFactory.class );
+        MetricsGauge<Integer> gauge = gaugeFactory.registerGauge( "Sample Gauge", new MetricsGauge<Integer>()
+        {
+            @Override
+            public Integer value()
+            {
+                return queue.size();
+            }
+        } );
+        // END SNIPPET: gauge
+
+        // START SNIPPET: counter
+        MetricsCounterFactory counterFactory = provider.createFactory( MetricsCounterFactory.class );
+        MetricsCounter counter = counterFactory.createCounter( "Sample Counter" );
+        // END SNIPPET: counter
+
+        // START SNIPPET: histogram
+        MetricsHistogramFactory histoFactory = provider.createFactory( MetricsHistogramFactory.class );
+        MetricsHistogram histogram = histoFactory.createHistogram( "Sample Histogram" );
+        // END SNIPPET: histogram
+
+        // START SNIPPET: meter
+        MetricsMeterFactory meterFactory = provider.createFactory( MetricsMeterFactory.class );
+        MetricsMeter meter = meterFactory.createMeter( "Sample Meter" );
+        // END SNIPPET: meter
+
+        // START SNIPPET: timer
+        MetricsTimerFactory timerFactory = provider.createFactory( MetricsTimerFactory.class );
+        MetricsTimer timer = timerFactory.createTimer( "Sample Timer" );
+        // END SNIPPET: timer
+
+        // START SNIPPET: healthcheck
+        MetricsHealthCheckFactory healthFactory = provider.createFactory( MetricsHealthCheckFactory.class );
+        MetricsHealthCheck healthCheck = healthFactory.registerHealthCheck(
+            "Sample Healthcheck",
+            new MetricsHealthCheck()
+            {
+                @Override
+                public Result check()
+                    throws Exception
+                {
+                    ServiceStatus status = pingMyService();
+                    return new Result( status.isOk(), status.getErrorMessage(), status.getException() );
+                }
+            } );
+        // END SNIPPET: healthcheck
+
+    }
+
+    private ServiceStatus pingMyService()
+    {
+        return new ServiceStatus();
+    }
+
+    private static class ServiceStatus
+    {
+        String errorMessage;
+        Exception exception;
+
+        public String getErrorMessage()
+        {
+            return errorMessage;
+        }
+
+        public Exception getException()
+        {
+            return exception;
+        }
+
+        public boolean isOk()
+        {
+            return errorMessage.equals( "OK" );
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/test/java/org/apache/polygene/api/mixin/BankAccount.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/polygene/api/mixin/BankAccount.java b/core/api/src/test/java/org/apache/polygene/api/mixin/BankAccount.java
new file mode 100644
index 0000000..c0f6d6e
--- /dev/null
+++ b/core/api/src/test/java/org/apache/polygene/api/mixin/BankAccount.java
@@ -0,0 +1,31 @@
+/*
+ *  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.api.mixin;
+
+
+// START SNIPPET: mixinType
+public interface BankAccount
+{
+    Money checkBalance();
+}
+// END SNIPPET: mixinType
+
+class Money {}
+

http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/test/java/org/apache/polygene/api/mixin/Car.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/polygene/api/mixin/Car.java b/core/api/src/test/java/org/apache/polygene/api/mixin/Car.java
new file mode 100644
index 0000000..eb927a8
--- /dev/null
+++ b/core/api/src/test/java/org/apache/polygene/api/mixin/Car.java
@@ -0,0 +1,26 @@
+/*
+ *  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.api.mixin;
+
+// START SNIPPET: mixin
+@Mixins( { StartMixin.class, VehicleMixin.class } )
+public interface Car extends Startable, Vehicle
+{}
+// END SNIPPET: mixin

http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/test/java/org/apache/polygene/api/mixin/Something.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/polygene/api/mixin/Something.java b/core/api/src/test/java/org/apache/polygene/api/mixin/Something.java
new file mode 100644
index 0000000..df65eb1
--- /dev/null
+++ b/core/api/src/test/java/org/apache/polygene/api/mixin/Something.java
@@ -0,0 +1,28 @@
+/*
+ *  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.api.mixin;
+
+// START SNIPPET: something
+@Mixins( SomethingMixin.class )
+public interface Something
+{}
+// END SNIPPET: something
+
+

http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/test/java/org/apache/polygene/api/mixin/SomethingMixin.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/polygene/api/mixin/SomethingMixin.java b/core/api/src/test/java/org/apache/polygene/api/mixin/SomethingMixin.java
new file mode 100644
index 0000000..e5aa474
--- /dev/null
+++ b/core/api/src/test/java/org/apache/polygene/api/mixin/SomethingMixin.java
@@ -0,0 +1,33 @@
+/*
+ *  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.api.mixin;
+
+// START SNIPPET: something
+public class SomethingMixin
+        implements Something
+{
+    // State is allowed.
+
+    public void doSomething()
+    {
+        // do stuff...
+    }
+}
+// END SNIPPET: something

http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/test/java/org/apache/polygene/api/mixin/StartMixin.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/polygene/api/mixin/StartMixin.java b/core/api/src/test/java/org/apache/polygene/api/mixin/StartMixin.java
new file mode 100644
index 0000000..2f6fbeb
--- /dev/null
+++ b/core/api/src/test/java/org/apache/polygene/api/mixin/StartMixin.java
@@ -0,0 +1,23 @@
+/*
+ *  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.api.mixin;
+
+public abstract class StartMixin implements Startable
+{}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/test/java/org/apache/polygene/api/mixin/Startable.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/polygene/api/mixin/Startable.java b/core/api/src/test/java/org/apache/polygene/api/mixin/Startable.java
new file mode 100644
index 0000000..7230742
--- /dev/null
+++ b/core/api/src/test/java/org/apache/polygene/api/mixin/Startable.java
@@ -0,0 +1,29 @@
+/*
+ *  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.api.mixin;
+
+// START SNIPPET: mixin
+public interface Startable
+{
+    boolean start();
+    void stop();
+}
+
+// END SNIPPET: mixin

http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/test/java/org/apache/polygene/api/mixin/Vehicle.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/polygene/api/mixin/Vehicle.java b/core/api/src/test/java/org/apache/polygene/api/mixin/Vehicle.java
new file mode 100644
index 0000000..7545687
--- /dev/null
+++ b/core/api/src/test/java/org/apache/polygene/api/mixin/Vehicle.java
@@ -0,0 +1,32 @@
+/*
+ *  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.api.mixin;
+
+// START SNIPPET: mixin
+public interface Vehicle
+{
+    void turn(float angle);
+
+    void accelerate(float acceleration);
+
+    // more methods
+}
+
+// END SNIPPET: mixin

http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/test/java/org/apache/polygene/api/mixin/VehicleMixin.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/polygene/api/mixin/VehicleMixin.java b/core/api/src/test/java/org/apache/polygene/api/mixin/VehicleMixin.java
new file mode 100644
index 0000000..16d4cfd
--- /dev/null
+++ b/core/api/src/test/java/org/apache/polygene/api/mixin/VehicleMixin.java
@@ -0,0 +1,23 @@
+/*
+ *  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.api.mixin;
+
+public abstract class VehicleMixin
+{}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/test/java/org/apache/polygene/api/mixin/decoratorMixin/DecoratorMixinTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/polygene/api/mixin/decoratorMixin/DecoratorMixinTest.java b/core/api/src/test/java/org/apache/polygene/api/mixin/decoratorMixin/DecoratorMixinTest.java
new file mode 100644
index 0000000..4b658e5
--- /dev/null
+++ b/core/api/src/test/java/org/apache/polygene/api/mixin/decoratorMixin/DecoratorMixinTest.java
@@ -0,0 +1,92 @@
+/*
+ *  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.api.mixin.decoratorMixin;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Proxy;
+import org.junit.Test;
+import org.apache.polygene.api.composite.TransientBuilder;
+import org.apache.polygene.bootstrap.AssemblyException;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.test.AbstractPolygeneTest;
+
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.assertThat;
+
+public class DecoratorMixinTest extends AbstractPolygeneTest
+{
+    // START SNIPPET: assembly
+    @Override
+    public void assemble( ModuleAssembly module )
+        throws AssemblyException
+    {
+        module.transients( View1.class );
+        module.transients( View2.class );
+        module.transients( FooModel.class );
+    }
+// END SNIPPET: assembly
+
+// START SNIPPET: test
+
+    @Test
+    public void testDecoration()
+    {
+        FooModelImpl model = new FooModelImpl( "Init" );
+        View1 view1 = createView1( model );
+        View2 view2 = createView2( model );
+        assertThat( view1.bar(), equalTo( "Init" ) );
+        assertThat( view2.bar(), equalTo( "Init" ) );
+        model.setBar( "New Value" );
+        assertThat( view1.bar(), equalTo( "New Value" ) );
+        assertThat( view2.bar(), equalTo( "New Value" ) );
+    }
+// END SNIPPET: test
+
+    @Test
+    public void testDecorationWithGenericMixin()
+    {
+        InvocationHandler handler = new FooModelInvocationHandler("Init");
+        ClassLoader cl = getClass().getClassLoader();
+        FooModel model = (FooModel) Proxy.newProxyInstance( cl, new Class[]{ FooModel.class }, handler );
+        View1 view1 = createView1( model );
+        View2 view2 = createView2( model );
+        assertThat( view1.bar(), equalTo( "Init" ) );
+        assertThat( view2.bar(), equalTo( "Init" ) );
+        model.setBar( "New Value" );
+        assertThat( view1.bar(), equalTo( "New Value" ) );
+        assertThat( view2.bar(), equalTo( "New Value" ) );
+    }
+
+    // START SNIPPET: create
+    public View1 createView1( FooModel model )
+    {
+        TransientBuilder<View1> builder = transientBuilderFactory.newTransientBuilder( View1.class );
+        builder.use( model );
+        return builder.newInstance();
+    }
+// END SNIPPET: create
+
+    public View2 createView2( FooModel model )
+    {
+        TransientBuilder<View2> builder = transientBuilderFactory.newTransientBuilder( View2.class );
+        builder.use( model );
+        return builder.newInstance();
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/test/java/org/apache/polygene/api/mixin/decoratorMixin/FooModel.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/polygene/api/mixin/decoratorMixin/FooModel.java b/core/api/src/test/java/org/apache/polygene/api/mixin/decoratorMixin/FooModel.java
new file mode 100644
index 0000000..f777279
--- /dev/null
+++ b/core/api/src/test/java/org/apache/polygene/api/mixin/decoratorMixin/FooModel.java
@@ -0,0 +1,37 @@
+/*
+ *  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.api.mixin.decoratorMixin;
+
+import org.apache.polygene.api.composite.DecoratorMixin;
+import org.apache.polygene.api.mixin.Mixins;
+
+// START SNIPPET: decorator
+@Mixins(DecoratorMixin.class)
+// START SNIPPET: plain
+public interface FooModel
+// END SNIPPET: decorator
+{
+    String getBar();
+    void setBar(String value);
+// END SNIPPET: plain
+
+// START SNIPPET: plain
+}
+// END SNIPPET: plain

http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/test/java/org/apache/polygene/api/mixin/decoratorMixin/FooModelImpl.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/polygene/api/mixin/decoratorMixin/FooModelImpl.java b/core/api/src/test/java/org/apache/polygene/api/mixin/decoratorMixin/FooModelImpl.java
new file mode 100644
index 0000000..5da835e
--- /dev/null
+++ b/core/api/src/test/java/org/apache/polygene/api/mixin/decoratorMixin/FooModelImpl.java
@@ -0,0 +1,42 @@
+/*
+ *  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.api.mixin.decoratorMixin;
+
+public class FooModelImpl
+    implements FooModel
+{
+    private String bar;
+
+    public FooModelImpl( String bar )
+    {
+        this.bar = bar;
+    }
+
+    @Override
+    public String getBar()
+    {
+        return bar;
+    }
+
+    public void setBar( String bar )
+    {
+        this.bar = bar;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/test/java/org/apache/polygene/api/mixin/decoratorMixin/FooModelInvocationHandler.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/polygene/api/mixin/decoratorMixin/FooModelInvocationHandler.java b/core/api/src/test/java/org/apache/polygene/api/mixin/decoratorMixin/FooModelInvocationHandler.java
new file mode 100644
index 0000000..856799b
--- /dev/null
+++ b/core/api/src/test/java/org/apache/polygene/api/mixin/decoratorMixin/FooModelInvocationHandler.java
@@ -0,0 +1,48 @@
+/*
+ *  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.api.mixin.decoratorMixin;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+
+public class FooModelInvocationHandler
+    implements InvocationHandler
+{
+    private String value;
+
+    public FooModelInvocationHandler( String value )
+    {
+        this.value = value;
+    }
+
+    @Override
+    public Object invoke( Object proxy, Method method, Object[] args )
+        throws Throwable
+    {
+        if(method.getName().equals( "hashCode" ))
+            return hashCode();
+        if(method.getName().equals( "equals" ))
+            return equals(args[0]);
+        if(args==null || args.length==0)
+            return value;
+        value = (String) args[0];
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/test/java/org/apache/polygene/api/mixin/decoratorMixin/View1.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/polygene/api/mixin/decoratorMixin/View1.java b/core/api/src/test/java/org/apache/polygene/api/mixin/decoratorMixin/View1.java
new file mode 100644
index 0000000..5cb9293
--- /dev/null
+++ b/core/api/src/test/java/org/apache/polygene/api/mixin/decoratorMixin/View1.java
@@ -0,0 +1,44 @@
+/*
+ *  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.api.mixin.decoratorMixin;
+
+import org.apache.polygene.api.injection.scope.This;
+import org.apache.polygene.api.mixin.Mixins;
+
+// START SNIPPET: decorator
+@Mixins(View1.Mixin.class)
+public interface View1
+{
+    String bar();
+
+    public class Mixin
+        implements View1
+    {
+        @This
+        FooModel model;
+
+        @Override
+        public String bar()
+        {
+            return model.getBar();
+        }
+    }
+}
+// END SNIPPET: decorator

http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/test/java/org/apache/polygene/api/mixin/decoratorMixin/View2.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/polygene/api/mixin/decoratorMixin/View2.java b/core/api/src/test/java/org/apache/polygene/api/mixin/decoratorMixin/View2.java
new file mode 100644
index 0000000..517940f
--- /dev/null
+++ b/core/api/src/test/java/org/apache/polygene/api/mixin/decoratorMixin/View2.java
@@ -0,0 +1,41 @@
+/*
+ *  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.api.mixin.decoratorMixin;
+
+import org.apache.polygene.api.injection.scope.This;
+import org.apache.polygene.api.mixin.Mixins;
+
+@Mixins(View2.Mixin.class)
+public interface View2
+{
+    String bar();
+    public class Mixin
+        implements View2
+    {
+        @This
+        FooModel model;
+
+        @Override
+        public String bar()
+        {
+            return model.getBar();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/test/java/org/apache/polygene/api/mixin/partial/Car.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/polygene/api/mixin/partial/Car.java b/core/api/src/test/java/org/apache/polygene/api/mixin/partial/Car.java
new file mode 100644
index 0000000..ea1198e
--- /dev/null
+++ b/core/api/src/test/java/org/apache/polygene/api/mixin/partial/Car.java
@@ -0,0 +1,31 @@
+/*
+ *  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.api.mixin.partial;
+
+import org.apache.polygene.api.mixin.Mixins;
+import org.apache.polygene.api.mixin.StartMixin;
+import org.apache.polygene.api.mixin.Startable;
+
+// START SNIPPET: partial
+@Mixins( { StartMixin.class, SpeedMixin.class, CrashResultMixin.class } )
+public interface Car extends Startable, Vehicle
+{}
+
+// END SNIPPET: partial

http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/test/java/org/apache/polygene/api/mixin/partial/CrashResultMixin.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/polygene/api/mixin/partial/CrashResultMixin.java b/core/api/src/test/java/org/apache/polygene/api/mixin/partial/CrashResultMixin.java
new file mode 100644
index 0000000..9dbb130
--- /dev/null
+++ b/core/api/src/test/java/org/apache/polygene/api/mixin/partial/CrashResultMixin.java
@@ -0,0 +1,24 @@
+/*
+ *  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.api.mixin.partial;
+
+public class CrashResultMixin implements Crashable
+{
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/test/java/org/apache/polygene/api/mixin/partial/Crashable.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/polygene/api/mixin/partial/Crashable.java b/core/api/src/test/java/org/apache/polygene/api/mixin/partial/Crashable.java
new file mode 100644
index 0000000..e83c78a
--- /dev/null
+++ b/core/api/src/test/java/org/apache/polygene/api/mixin/partial/Crashable.java
@@ -0,0 +1,24 @@
+/*
+ *  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.api.mixin.partial;
+
+public interface Crashable
+{
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/test/java/org/apache/polygene/api/mixin/partial/SpeedLocation.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/polygene/api/mixin/partial/SpeedLocation.java b/core/api/src/test/java/org/apache/polygene/api/mixin/partial/SpeedLocation.java
new file mode 100644
index 0000000..21f3620
--- /dev/null
+++ b/core/api/src/test/java/org/apache/polygene/api/mixin/partial/SpeedLocation.java
@@ -0,0 +1,29 @@
+/*
+ *  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.api.mixin.partial;
+
+// START SNIPPET: partial
+public interface SpeedLocation
+{
+    void turn(float angle);
+
+    void accelerate(float acceleration);
+}
+// END SNIPPET: partial

http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/test/java/org/apache/polygene/api/mixin/partial/SpeedMixin.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/polygene/api/mixin/partial/SpeedMixin.java b/core/api/src/test/java/org/apache/polygene/api/mixin/partial/SpeedMixin.java
new file mode 100644
index 0000000..7273441
--- /dev/null
+++ b/core/api/src/test/java/org/apache/polygene/api/mixin/partial/SpeedMixin.java
@@ -0,0 +1,34 @@
+/*
+ *  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.api.mixin.partial;
+
+// START SNIPPET: partial
+public abstract class SpeedMixin
+        implements SpeedLocation
+{
+    // state for speed
+
+    public void accelerate( float acceleration )
+    {
+        // logic
+    }
+}
+
+// END SNIPPET: partial
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/test/java/org/apache/polygene/api/mixin/partial/Vehicle.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/polygene/api/mixin/partial/Vehicle.java b/core/api/src/test/java/org/apache/polygene/api/mixin/partial/Vehicle.java
new file mode 100644
index 0000000..4372398
--- /dev/null
+++ b/core/api/src/test/java/org/apache/polygene/api/mixin/partial/Vehicle.java
@@ -0,0 +1,27 @@
+/*
+ *  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.api.mixin.partial;
+
+// START SNIPPET: partial
+public interface Vehicle extends SpeedLocation, Crashable
+{
+}
+
+// END SNIPPET: partial
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/test/java/org/apache/polygene/api/mixin/privateMixin/Cargo.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/polygene/api/mixin/privateMixin/Cargo.java b/core/api/src/test/java/org/apache/polygene/api/mixin/privateMixin/Cargo.java
new file mode 100644
index 0000000..6c61ac2
--- /dev/null
+++ b/core/api/src/test/java/org/apache/polygene/api/mixin/privateMixin/Cargo.java
@@ -0,0 +1,37 @@
+/*
+ *  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.api.mixin.privateMixin;
+
+import org.apache.polygene.api.entity.EntityComposite;
+import org.apache.polygene.api.mixin.Mixins;
+
+// START SNIPPET: private
+@Mixins( CargoMixin.class )
+public interface Cargo extends EntityComposite
+{
+    String origin();
+
+    String destination();
+
+    void changeDestination( String newDestination );
+
+}
+
+// END SNIPPET: private

http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/test/java/org/apache/polygene/api/mixin/privateMixin/CargoMixin.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/polygene/api/mixin/privateMixin/CargoMixin.java b/core/api/src/test/java/org/apache/polygene/api/mixin/privateMixin/CargoMixin.java
new file mode 100644
index 0000000..9629161
--- /dev/null
+++ b/core/api/src/test/java/org/apache/polygene/api/mixin/privateMixin/CargoMixin.java
@@ -0,0 +1,47 @@
+/*
+ *  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.api.mixin.privateMixin;
+
+import org.apache.polygene.api.injection.scope.This;
+
+// START SNIPPET: private
+public abstract class CargoMixin
+        implements Cargo
+{
+    @This
+    private CargoState state;
+
+    public String origin()
+    {
+        return state.origin().get();
+    }
+
+    public String destination()
+    {
+        return state.destination().get();
+    }
+
+    public void changeDestination( String newDestination )
+    {
+        state.destination().set( newDestination );
+    }
+}
+
+// END SNIPPET: private
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/test/java/org/apache/polygene/api/mixin/privateMixin/CargoState.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/polygene/api/mixin/privateMixin/CargoState.java b/core/api/src/test/java/org/apache/polygene/api/mixin/privateMixin/CargoState.java
new file mode 100644
index 0000000..e93b561
--- /dev/null
+++ b/core/api/src/test/java/org/apache/polygene/api/mixin/privateMixin/CargoState.java
@@ -0,0 +1,31 @@
+/*
+ *  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.api.mixin.privateMixin;
+
+import org.apache.polygene.api.property.Property;
+
+// START SNIPPET: private
+public interface CargoState
+{
+    Property<String> origin();
+    Property<String> destination();
+}
+
+// END SNIPPET: private
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/test/java/org/apache/polygene/api/object/ObjectBuilderTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/polygene/api/object/ObjectBuilderTest.java b/core/api/src/test/java/org/apache/polygene/api/object/ObjectBuilderTest.java
new file mode 100644
index 0000000..265d086
--- /dev/null
+++ b/core/api/src/test/java/org/apache/polygene/api/object/ObjectBuilderTest.java
@@ -0,0 +1,75 @@
+/*
+ *  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.api.object;
+
+import org.junit.Test;
+import org.apache.polygene.api.injection.scope.Uses;
+import org.apache.polygene.bootstrap.AssemblyException;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.test.AbstractPolygeneTest;
+
+import static org.junit.Assert.assertNotNull;
+
+/**
+ * JAVADOC
+ */
+public class ObjectBuilderTest
+    extends AbstractPolygeneTest
+{
+    public void assemble( ModuleAssembly module )
+        throws AssemblyException
+    {
+        module.objects( A.class, B.class, C.class, D.class );
+    }
+
+    @Test
+    public void testNotProvidedUses()
+    {
+        A a = objectFactory.newObject( A.class );
+        assertNotNull( a );
+        assertNotNull( a.b );
+        assertNotNull( a.b.c );
+        assertNotNull( a.b.c.d );
+    }
+
+    public static class A
+    {
+        @Uses
+        B b;
+    }
+
+    public static class B
+    {
+        @Uses
+        C c;
+    }
+
+    public static class C
+    {
+        @Uses
+        D d;
+    }
+
+    public static class D
+    {
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/test/java/org/apache/polygene/api/property/PropertyErrorTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/polygene/api/property/PropertyErrorTest.java b/core/api/src/test/java/org/apache/polygene/api/property/PropertyErrorTest.java
new file mode 100644
index 0000000..f0fe7a1
--- /dev/null
+++ b/core/api/src/test/java/org/apache/polygene/api/property/PropertyErrorTest.java
@@ -0,0 +1,67 @@
+/*
+ *  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.api.property;
+
+import org.junit.Test;
+import org.apache.polygene.api.constraint.ConstraintViolationException;
+import org.apache.polygene.api.entity.EntityComposite;
+import org.apache.polygene.api.unitofwork.UnitOfWork;
+import org.apache.polygene.bootstrap.AssemblyException;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.test.AbstractPolygeneTest;
+import org.apache.polygene.test.EntityTestAssembler;
+
+/**
+ * Error messages for Properties
+ */
+public class PropertyErrorTest
+    extends AbstractPolygeneTest
+{
+    public void assemble( ModuleAssembly module )
+        throws AssemblyException
+    {
+        new EntityTestAssembler().assemble( module );
+        module.entities( PersonEntity.class );
+    }
+
+    @Test( expected = ConstraintViolationException.class )
+    public void givenEntityWithNonOptionPropertyWhenInstantiatedThenException()
+        throws Exception
+    {
+        UnitOfWork unitOfWork = unitOfWorkFactory.newUnitOfWork();
+        try
+        {
+            PersonEntity person = unitOfWork.newEntity( PersonEntity.class );
+
+            unitOfWork.complete();
+        }
+        finally
+        {
+            unitOfWork.discard();
+        }
+    }
+
+    interface PersonEntity
+        extends EntityComposite
+    {
+        Property<String> foo();
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/test/java/org/apache/polygene/api/service/DocumentationSupport.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/polygene/api/service/DocumentationSupport.java b/core/api/src/test/java/org/apache/polygene/api/service/DocumentationSupport.java
new file mode 100644
index 0000000..c612d0b
--- /dev/null
+++ b/core/api/src/test/java/org/apache/polygene/api/service/DocumentationSupport.java
@@ -0,0 +1,139 @@
+/*
+ *  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.api.service;
+
+import java.util.List;
+import org.apache.polygene.api.activation.Activators;
+import org.apache.polygene.api.injection.scope.Service;
+import org.apache.polygene.api.mixin.Mixins;
+import org.apache.polygene.api.service.qualifier.ServiceTags;
+import org.apache.polygene.bootstrap.Assembler;
+import org.apache.polygene.bootstrap.AssemblyException;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.bootstrap.ServiceDeclaration;
+
+public class DocumentationSupport
+    implements Assembler
+{
+    // START SNIPPET: tag
+    // START SNIPPET: instantiateOnStartup
+    @Override
+    public void assemble( ModuleAssembly module )
+        throws AssemblyException
+    {
+        ServiceDeclaration service = module.addServices( MyDemoService.class );
+        // END SNIPPET: tag
+        service.instantiateOnStartup();
+        // END SNIPPET: instantiateOnStartup
+        // START SNIPPET: tag
+        service.taggedWith( "Important", "Drain" );
+        // END SNIPPET: tag
+    }
+
+    private static class MyDemoService
+    {
+    }
+
+    private static class MyOtherDemoService
+    {
+        // START SNIPPET: UseTag
+        @Service
+        private List<ServiceReference<MyDemoService>> services;
+
+        public MyDemoService locateImportantService()
+        {
+            for( ServiceReference<MyDemoService> ref : services )
+            {
+                ServiceTags serviceTags = ref.metaInfo( ServiceTags.class );
+                if( serviceTags.hasTag( "Important" ) )
+                {
+                    return ref.get();
+                }
+            }
+            return null;
+        }
+        // END SNIPPET: UseTag
+    }
+
+    // START SNIPPET: activation1
+    @Mixins( MyActivationMixin.class )
+    public static interface MyActivationDemoService
+        extends ServiceComposite, ServiceActivation
+    {
+    }
+
+    public static class MyActivationMixin
+        implements ServiceActivation
+    {
+        @Override
+        public void activateService()
+            throws Exception
+        {
+            // Activation code
+        }
+
+        @Override
+        public void passivateService()
+            throws Exception
+        {
+            // Passivation code
+        }
+    }
+    // END SNIPPET: activation1
+
+    // START SNIPPET: activation2
+    @Activators( MyActivator.class )
+    public static interface MyOtherActivationDemoService
+        extends ServiceComposite
+    {
+    }
+
+    public static class MyActivator
+        extends ServiceActivatorAdapter<MyOtherActivationDemoService>
+    {
+        @Override
+        public void afterActivation( ServiceReference<MyOtherActivationDemoService> activated )
+            throws Exception
+        {
+            // Activation code
+        }
+
+        @Override
+        public void beforePassivation( ServiceReference<MyOtherActivationDemoService> passivating )
+            throws Exception
+        {
+            // Passivation code
+        }
+    }
+    // END SNIPPET: activation2
+
+    static class Activation3
+        implements Assembler
+    {
+        // START SNIPPET: activation3
+        @Override
+        public void assemble( ModuleAssembly module )
+        {
+            module.services( MyDemoService.class ).withActivators( MyActivator.class );
+        }
+        // END SNIPPET: activation3
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/test/java/org/apache/polygene/api/unitofwork/RemovalTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/polygene/api/unitofwork/RemovalTest.java b/core/api/src/test/java/org/apache/polygene/api/unitofwork/RemovalTest.java
new file mode 100644
index 0000000..87d609c
--- /dev/null
+++ b/core/api/src/test/java/org/apache/polygene/api/unitofwork/RemovalTest.java
@@ -0,0 +1,133 @@
+/*
+ *  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.api.unitofwork;
+
+import org.apache.polygene.api.identity.StringIdentity;
+import org.junit.Test;
+import org.apache.polygene.api.common.Optional;
+import org.apache.polygene.api.entity.EntityBuilder;
+import org.apache.polygene.api.entity.EntityComposite;
+import org.apache.polygene.api.property.Property;
+import org.apache.polygene.bootstrap.AssemblyException;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.test.AbstractPolygeneTest;
+import org.apache.polygene.test.EntityTestAssembler;
+
+public class RemovalTest
+    extends AbstractPolygeneTest
+{
+    public void assemble( ModuleAssembly module )
+        throws AssemblyException
+    {
+        module.entities( TestEntity.class );
+        module.entities( PidRegulator.class );
+        new EntityTestAssembler().assemble( module );
+    }
+
+    @Test
+    public void givenEntityIsCreatedAndUnitOfWorkIsNotCompletedWhenEntityIsRemoveThenSuccessfulRemoval()
+        throws Exception
+    {
+        UnitOfWork uow = unitOfWorkFactory.newUnitOfWork();
+        try
+        {
+            EntityBuilder<TestEntity> builder = uow.newEntityBuilder( TestEntity.class, new StringIdentity( "123" ) );
+            builder.instance().test().set( "habba" );
+            TestEntity test = builder.newInstance();
+            uow.remove( test );
+            uow.complete();
+        }
+        finally
+        {
+            uow.discard();
+        }
+    }
+
+    @Test
+    public void givenStandardPidRegulatorWhenNoChangeInInputExpectOutputToGoTowardsMinimum()
+        throws Exception
+    {
+        UnitOfWork uow = unitOfWorkFactory.newUnitOfWork();
+        PidRegulator regulator = null;
+        try
+        {
+            regulator = createPidRegulator( uow );
+        }
+        finally
+        {
+            if( regulator != null )
+            {
+                uow.remove( regulator );
+            }
+            // TODO: This problem is related to that uow.remove() has a bug.
+            // If the Entity is both created and removed in the same session, then the remove() should simply remove
+            // the entity from the internal UoW holding area, and not set the REMOVED status.
+
+            // Probably that UnitOfWorkInstance.remove() should also call instanceCache.remove(), but the question is
+            // then what is an InstanceKey vs EntityReference
+            uow.complete();
+        }
+    }
+
+    public interface TestEntity
+        extends EntityComposite
+    {
+        @Optional
+        Property<String> test();
+    }
+
+    private PidRegulator createPidRegulator( UnitOfWork uow )
+        throws UnitOfWorkCompletionException
+    {
+        EntityBuilder<PidRegulator> builder = uow.newEntityBuilder( PidRegulator.class );
+        PidRegulator prototype = builder.instance();
+        prototype.p().set( 1.0f );
+        prototype.i().set( 10f );
+        prototype.d().set( 0.1f );
+        prototype.maxD().set( 10f );
+        prototype.maximum().set( 100f );
+        prototype.minimum().set( 0f );
+        PidRegulator regulator = builder.newInstance();
+
+        return regulator;
+    }
+
+    //    @Mixins( { PidRegulatorAlgorithmMixin.class } )
+    public interface PidRegulator
+        extends PidParameters, EntityComposite
+    {
+    }
+
+    public interface PidParameters
+    {
+        Property<Float> p();
+
+        Property<Float> i();
+
+        Property<Float> d();
+
+        Property<Float> maxD();
+
+        Property<Float> minimum();
+
+        Property<Float> maximum();
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/test/java/org/apache/polygene/api/unitofwork/UnitOfWorkTemplateTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/polygene/api/unitofwork/UnitOfWorkTemplateTest.java b/core/api/src/test/java/org/apache/polygene/api/unitofwork/UnitOfWorkTemplateTest.java
new file mode 100644
index 0000000..5f4b2ae
--- /dev/null
+++ b/core/api/src/test/java/org/apache/polygene/api/unitofwork/UnitOfWorkTemplateTest.java
@@ -0,0 +1,74 @@
+/*
+ *  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.api.unitofwork;
+
+import org.junit.Test;
+import org.apache.polygene.api.entity.EntityBuilderTemplate;
+import org.apache.polygene.api.entity.EntityComposite;
+import org.apache.polygene.api.property.Property;
+import org.apache.polygene.bootstrap.AssemblyException;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.test.AbstractPolygeneTest;
+import org.apache.polygene.test.EntityTestAssembler;
+
+/**
+ * TODO
+ */
+public class UnitOfWorkTemplateTest
+    extends AbstractPolygeneTest
+{
+    @Override
+    public void assemble( ModuleAssembly module )
+        throws AssemblyException
+    {
+        new EntityTestAssembler().assemble( module );
+        module.entities( TestEntity.class );
+    }
+
+    @Test
+    public void testTemplate()
+        throws UnitOfWorkCompletionException
+    {
+        new UnitOfWorkTemplate<Void, RuntimeException>()
+        {
+            @Override
+            protected Void withUnitOfWork( UnitOfWork uow )
+                throws RuntimeException
+            {
+                new EntityBuilderTemplate<TestEntity>( TestEntity.class )
+                {
+                    @Override
+                    protected void build( TestEntity prototype )
+                    {
+                        prototype.name().set( "Rickard" );
+                    }
+                }.newInstance( module.instance() );
+
+                return null;
+            }
+        }.withModule( module.instance() );
+    }
+
+    interface TestEntity
+        extends EntityComposite
+    {
+        Property<String> name();
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/test/java/org/apache/polygene/api/util/ClassesTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/polygene/api/util/ClassesTest.java b/core/api/src/test/java/org/apache/polygene/api/util/ClassesTest.java
new file mode 100644
index 0000000..24acbb5
--- /dev/null
+++ b/core/api/src/test/java/org/apache/polygene/api/util/ClassesTest.java
@@ -0,0 +1,211 @@
+/*
+ *  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.api.util;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
+import java.util.HashSet;
+import java.util.Set;
+import org.junit.Test;
+
+import static org.apache.polygene.api.util.Classes.interfacesOf;
+import static org.apache.polygene.api.util.Classes.interfacesWithMethods;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Tests for Classes
+ */
+public class ClassesTest
+{
+
+    @Test
+    public void givenClassWithInterfacesWhenInterfacesOfThenGetCorrectSet()
+    {
+        assertThat( "one interface returned", interfacesOf( A.class ).count(), equalTo( 1L ) );
+        assertThat( "two interface returned", interfacesOf( B.class ).count(), equalTo( 2L ) );
+        assertThat( "tree interface returned", interfacesOf( C.class ).count(), equalTo( 4L ) );
+    }
+
+    @Test
+    public void givenClassWithInterfacesWhenGetInterfacesWithMethodsThenGetCorrectSet()
+    {
+        HashSet<Class<?>> interfaces = new HashSet<Class<?>>();
+        interfaces.add( B.class );
+        Set<Class<?>> types = interfacesWithMethods( interfaces );
+        assertThat( "one interface returned", types.size(), equalTo( 1 ) );
+        assertThat( "correct interface returned", types.contains( B.class ), is( true ) );
+    }
+
+    @Test
+    public void givenClassesWithInterfacesWhenGetInterfacesWithMethodsThenGetCorrectSet()
+    {
+        assertThat( "one interface returned", interfacesOf( C.class ).filter( Methods.HAS_METHODS )
+            .count(), equalTo( 1L ) );
+        boolean isIn = interfacesOf( C.class ).filter( Methods.HAS_METHODS )
+            .anyMatch( B.class::equals );
+        assertThat( "correct interface returned", isIn, is( true ) );
+    }
+
+    @Test
+    public void givenClassNameWhenToUriThenUriIsReturned()
+    {
+        assertThat( "URI is correct", Classes.toURI( A.class ), equalTo( "urn:polygene:type:org.apache.polygene.api.util.ClassesTest-A" ) );
+    }
+
+    @Test
+    public void givenUriWhenToClassNameThenClassNameIsReturned()
+    {
+        assertThat( "Class name is correct", Classes.toClassName( "urn:polygene:type:org.apache.polygene.api.util.ClassesTest-A" ), equalTo( "org.apache.polygene.api.util.ClassesTest$A" ) );
+    }
+
+    @Test
+    public void givenGenericTypeWithWildCardWhenGetRawClassThenCorrectTypeIsReturned()
+        throws NoSuchMethodException
+    {
+        Type returnType = Generics.class.getMethod( "wildcard" ).getGenericReturnType();
+        Type wildcardType = ( (ParameterizedType) returnType ).getActualTypeArguments()[ 0 ];
+        assertThat( "Return type is A", Classes.RAW_CLASS.apply( wildcardType ), equalTo( (Class) A.class ) );
+    }
+
+    @Test
+    public void givenTypeVariableWhenResolveThenResolved()
+    {
+        for( Method method : Type1.class.getMethods() )
+        {
+            Type type = method.getGenericReturnType();
+            TypeVariable typeVariable = (TypeVariable) type;
+            Type resolvedType = Classes.resolveTypeVariable( typeVariable, method.getDeclaringClass(), Type1.class );
+            System.out.println( type + "=" + resolvedType );
+            switch( method.getName() )
+            {
+            case "type":
+                assertThat( resolvedType, equalTo( (Type) String.class ) );
+                break;
+            case "type1":
+                assertThat( resolvedType, equalTo( (Type) String.class ) );
+                break;
+            case "type2":
+                assertThat( resolvedType, equalTo( (Type) Long.class ) );
+                break;
+            }
+        }
+    }
+
+    @Test
+    public void givenGenericTypeWhenGetSimpleGenericNameThenCorrectStringIsReturned()
+        throws NoSuchMethodException
+    {
+        assertThat( "Simple Generic Name is 'A'",
+                    Classes.simpleGenericNameOf( A.class ),
+                    equalTo( "A" ) );
+        assertThat( "Simple Generic Name is 'B'",
+                    Classes.simpleGenericNameOf( B.class ),
+                    equalTo( "B" ) );
+        assertThat( "Simple Generic Name is 'C'",
+                    Classes.simpleGenericNameOf( C.class ),
+                    equalTo( "C" ) );
+
+        assertThat( "Simple Generic Name is 'Generics'",
+                    Classes.simpleGenericNameOf( Generics.class ),
+                    equalTo( "Generics" ) );
+        assertThat( "Simple Generic Name is 'Iterable<? extends A>'",
+                    Classes.simpleGenericNameOf( Generics.class.getMethod( "wildcard" ).getGenericReturnType() ),
+                    equalTo( "Iterable<? extends A>" ) );
+
+        assertThat( "Simple Generic Name is 'Type1'",
+                    Classes.simpleGenericNameOf( Type1.class ),
+                    equalTo( "Type1" ) );
+        assertThat( "Simple Generic Name is 'TYPE'",
+                    Classes.simpleGenericNameOf( Type1.class.getMethod( "type" ).getGenericReturnType() ),
+                    equalTo( "TYPE" ) );
+        assertThat( "Simple Generic Name is 'TYPE1'",
+                    Classes.simpleGenericNameOf( Type1.class.getMethod( "type1" ).getGenericReturnType() ),
+                    equalTo( "TYPE1" ) );
+        assertThat( "Simple Generic Name is 'TYPE2'",
+                    Classes.simpleGenericNameOf( Type1.class.getMethod( "type2" ).getGenericReturnType() ),
+                    equalTo( "TYPE2" ) );
+
+        assertThat( "Simple Generic Name is 'Type2'",
+                    Classes.simpleGenericNameOf( Type2.class ),
+                    equalTo( "Type2" ) );
+        assertThat( "Simple Generic Name is 'TYPE'",
+                    Classes.simpleGenericNameOf( Type2.class.getMethod( "type" ).getGenericReturnType() ),
+                    equalTo( "TYPE" ) );
+        assertThat( "Simple Generic Name is 'TYPE1'",
+                    Classes.simpleGenericNameOf( Type2.class.getMethod( "type1" ).getGenericReturnType() ),
+                    equalTo( "TYPE1" ) );
+        assertThat( "Simple Generic Name is 'TYPE2'",
+                    Classes.simpleGenericNameOf( Type2.class.getMethod( "type2" ).getGenericReturnType() ),
+                    equalTo( "TYPE2" ) );
+
+        assertThat( "Simple Generic Name is 'Type3'",
+                    Classes.simpleGenericNameOf( Type3.class ),
+                    equalTo( "Type3" ) );
+        assertThat( "Simple Generic Name is 'TYPE'",
+                    Classes.simpleGenericNameOf( Type3.class.getMethod( "type" ).getGenericReturnType() ),
+                    equalTo( "TYPE" ) );
+    }
+
+    interface A
+    {
+    }
+
+    interface B
+        extends A
+    {
+
+        public void doStuff();
+    }
+
+    interface C
+        extends A, B
+    {
+    }
+
+    interface Generics
+    {
+
+        Iterable<? extends A> wildcard();
+    }
+
+    interface Type1
+        extends Type2<String, Long>
+    {
+    }
+
+    interface Type2<TYPE1, TYPE2>
+        extends Type3<TYPE1>
+    {
+
+        TYPE1 type1();
+
+        TYPE2 type2();
+    }
+
+    interface Type3<TYPE>
+    {
+
+        TYPE type();
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/test/java/org/apache/polygene/api/util/CollectorsTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/polygene/api/util/CollectorsTest.java b/core/api/src/test/java/org/apache/polygene/api/util/CollectorsTest.java
new file mode 100644
index 0000000..5521b93
--- /dev/null
+++ b/core/api/src/test/java/org/apache/polygene/api/util/CollectorsTest.java
@@ -0,0 +1,75 @@
+/*
+ *  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.api.util;
+
+import java.util.Optional;
+import java.util.stream.Stream;
+import org.junit.Test;
+
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
+
+public class CollectorsTest
+{
+    @Test
+    public void single()
+    {
+        assertThat( Stream.of( 1L ).collect( Collectors.single() ), is( 1L ) );
+
+        try
+        {
+            Stream.of().collect( Collectors.single() );
+            fail( "Should have failed" );
+        }
+        catch( IllegalArgumentException ex ) {}
+        try
+        {
+            Stream.of( 1, 1 ).collect( Collectors.single() );
+            fail( "Should have failed" );
+        }
+        catch( IllegalArgumentException ex ) {}
+        try
+        {
+            Stream.of( 1, 1, 1 ).collect( Collectors.single() );
+            fail( "Should have failed" );
+        }
+        catch( IllegalArgumentException ex ) {}
+    }
+
+    @Test
+    public void singleOrEmpty()
+    {
+        assertEquals( Optional.empty(), Stream.of().collect( Collectors.singleOrEmpty() ) );
+        assertEquals( Optional.of( 1 ), Stream.of( 1 ).collect( Collectors.singleOrEmpty() ) );
+
+        try
+        {
+            Stream.of( 1, 1 ).collect( Collectors.singleOrEmpty() );
+            fail( "Should have failed" );
+        }
+        catch( IllegalArgumentException ex ) {}
+        try
+        {
+            Stream.of( 1, 1, 1 ).collect( Collectors.singleOrEmpty() );
+            fail( "Should have failed" );
+        }
+        catch( IllegalArgumentException ex ) {}
+    }
+}


Mime
View raw message