polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject [46/50] [abbrv] zest-qi4j git commit: JDK8: compilation fixes for b84
Date Fri, 17 Apr 2015 16:06:06 GMT
JDK8: compilation fixes for b84


Project: http://git-wip-us.apache.org/repos/asf/zest-qi4j/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-qi4j/commit/68c662c9
Tree: http://git-wip-us.apache.org/repos/asf/zest-qi4j/tree/68c662c9
Diff: http://git-wip-us.apache.org/repos/asf/zest-qi4j/diff/68c662c9

Branch: refs/heads/master
Commit: 68c662c94fd6cb832e10eabf759724d954e2cb68
Parents: 42b9b39
Author: Paul Merlin <paul@nosphere.org>
Authored: Wed Apr 17 16:16:39 2013 +0200
Committer: Paul Merlin <paul@nosphere.org>
Committed: Wed Apr 17 16:16:39 2013 +0200

----------------------------------------------------------------------
 .../api/service/importer/NewObjectImporter.java |   2 +-
 .../dataset/iterable/IterableDataSetTest.java   |   2 +
 .../runtime/composite/CompositeMethodModel.java |   4 +-
 .../qi4j/runtime/property/PropertyModel.java    |   2 +-
 .../jmx/CircuitBreakerManagementSample.java     | 113 +++++++++++
 .../jmx/CircuitBreakerManagementTest.java       | 113 -----------
 .../server/DomainEventSourceResourceSample.java | 186 +++++++++++++++++++
 .../server/DomainEventSourceResourceTest.java   | 186 -------------------
 .../trace/service/TraceServiceMixin.java        |   4 +-
 .../org/qi4j/library/rest/admin/RestTest.java   |   1 +
 .../uid/sequence/PersistingSequencingTest.java  |   5 +-
 .../uid/sequence/TransientSequencingTest.java   |   3 +-
 12 files changed, 313 insertions(+), 308 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/68c662c9/core/api/src/main/java/org/qi4j/api/service/importer/NewObjectImporter.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/service/importer/NewObjectImporter.java b/core/api/src/main/java/org/qi4j/api/service/importer/NewObjectImporter.java
index 22507c7..47e1365 100644
--- a/core/api/src/main/java/org/qi4j/api/service/importer/NewObjectImporter.java
+++ b/core/api/src/main/java/org/qi4j/api/service/importer/NewObjectImporter.java
@@ -34,7 +34,7 @@ public final class NewObjectImporter<T>
     public T importService( ImportedServiceDescriptor serviceDescriptor )
         throws ServiceImporterException
     {
-        return (T) obf.newObject( Iterables.first( serviceDescriptor.types() ) );
+        return obf.newObject( (Class<T>) Iterables.first( serviceDescriptor.types()
) );
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/68c662c9/core/api/src/test/java/org/qi4j/api/dataset/iterable/IterableDataSetTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/dataset/iterable/IterableDataSetTest.java
b/core/api/src/test/java/org/qi4j/api/dataset/iterable/IterableDataSetTest.java
index de8263a..3830f1e 100644
--- a/core/api/src/test/java/org/qi4j/api/dataset/iterable/IterableDataSetTest.java
+++ b/core/api/src/test/java/org/qi4j/api/dataset/iterable/IterableDataSetTest.java
@@ -1,6 +1,7 @@
 package org.qi4j.api.dataset.iterable;
 
 import org.junit.Before;
+import org.junit.Ignore;
 import org.qi4j.api.dataset.DataSet;
 import org.qi4j.api.property.Property;
 import org.qi4j.bootstrap.AssemblyException;
@@ -11,6 +12,7 @@ import org.qi4j.test.AbstractQi4jTest;
 /**
  * TODO
  */
+@Ignore( "Not implemented yet" )
 public class IterableDataSetTest
     extends AbstractQi4jTest
 {

http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/68c662c9/core/runtime/src/main/java/org/qi4j/runtime/composite/CompositeMethodModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/composite/CompositeMethodModel.java
b/core/runtime/src/main/java/org/qi4j/runtime/composite/CompositeMethodModel.java
index 32c5202..8fecf91 100644
--- a/core/runtime/src/main/java/org/qi4j/runtime/composite/CompositeMethodModel.java
+++ b/core/runtime/src/main/java/org/qi4j/runtime/composite/CompositeMethodModel.java
@@ -296,7 +296,7 @@ public final class CompositeMethodModel
 
         // @Override (Since JDK 8)
         @SuppressWarnings( "unchecked" )
-        public <T extends Annotation> T[] getAnnotations( Class<T> annotationClass
)
+        public <T extends Annotation> T[] getAnnotationsByType( Class<T> annotationClass
)
         {
             NullArgumentException.validateNotNull( "annotationClass", annotationClass );
             return (T[]) Array.newInstance( annotationClass, 0 );
@@ -311,7 +311,7 @@ public final class CompositeMethodModel
 
         // @Override (Since JDK 8)
         @SuppressWarnings( "unchecked" )
-        public <T extends Annotation> T[] getDeclaredAnnotations( Class<T> annotationClass
)
+        public <T extends Annotation> T[] getDeclaredAnnotationsByType( Class<T>
annotationClass )
         {
             NullArgumentException.validateNotNull( "annotationClass", annotationClass );
             return (T[]) Array.newInstance( annotationClass, 0 );

http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/68c662c9/core/runtime/src/main/java/org/qi4j/runtime/property/PropertyModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/property/PropertyModel.java b/core/runtime/src/main/java/org/qi4j/runtime/property/PropertyModel.java
index e547d8a..235a86a 100644
--- a/core/runtime/src/main/java/org/qi4j/runtime/property/PropertyModel.java
+++ b/core/runtime/src/main/java/org/qi4j/runtime/property/PropertyModel.java
@@ -171,7 +171,7 @@ public class PropertyModel
         {
             if( valueType instanceof ValueCompositeType )
             {
-                return module.newValue( first( valueType().types() ) );
+                return module.newValue( (Class<?>) first( valueType().types() ) );
             }
             else
             {

http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/68c662c9/libraries/circuitbreaker/src/test/java/org/qi4j/library/circuitbreaker/jmx/CircuitBreakerManagementSample.java
----------------------------------------------------------------------
diff --git a/libraries/circuitbreaker/src/test/java/org/qi4j/library/circuitbreaker/jmx/CircuitBreakerManagementSample.java
b/libraries/circuitbreaker/src/test/java/org/qi4j/library/circuitbreaker/jmx/CircuitBreakerManagementSample.java
new file mode 100644
index 0000000..ec71938
--- /dev/null
+++ b/libraries/circuitbreaker/src/test/java/org/qi4j/library/circuitbreaker/jmx/CircuitBreakerManagementSample.java
@@ -0,0 +1,113 @@
+/*
+ * Copyright 2009-2010 Rickard Öberg AB
+ *
+ * Licensed 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.qi4j.library.circuitbreaker.jmx;
+
+import java.util.Random;
+import javax.management.MBeanServer;
+import org.qi4j.api.activation.ActivationException;
+import org.qi4j.bootstrap.AssemblyException;
+import org.qi4j.bootstrap.ModuleAssembly;
+import org.qi4j.bootstrap.SingletonAssembler;
+import org.qi4j.library.circuitbreaker.CircuitBreaker;
+import org.qi4j.library.circuitbreaker.CircuitBreakers;
+import org.qi4j.library.circuitbreaker.service.ServiceCircuitBreaker;
+import org.qi4j.library.jmx.MBeanServerImporter;
+
+/**
+ * Run this as a program and connect with VisualVM. That way you can monitor changes in attributes,
notifications, and
+ * execute operations on the CircuitBreaker through JMX.
+ */
+public class CircuitBreakerManagementSample
+{
+
+    public static void main( String[] args )
+        throws ActivationException, AssemblyException
+    {
+        SingletonAssembler assembler = new SingletonAssembler()
+        {
+
+            @Override
+            // START SNIPPET: jmx
+            public void assemble( ModuleAssembly module )
+                    throws AssemblyException
+            {
+                // END SNIPPET: jmx
+                CircuitBreaker cb = new CircuitBreaker( 3, 250, CircuitBreakers.in( IllegalArgumentException.class
) );
+
+                module.importedServices( TestService.class ).setMetaInfo( new TestService(
cb ) );
+
+                // START SNIPPET: jmx
+                module.importedServices( MBeanServer.class ).importedBy( MBeanServerImporter.class
); // JMX Library
+                module.services( CircuitBreakerManagement.class ).instantiateOnStartup();
// CircuitBreakers in JMX
+            }
+            // END SNIPPET: jmx
+
+        };
+
+        TestService service = assembler.module().<TestService>findService( TestService.class
).get();
+
+        int interval = 1; // Seconds
+        System.out.println( "CircuitBreaker JMX Support sample is now started." );
+        System.out.println();
+        System.out.println( "A Service that randomly output some text or fail is called through
a CircuitBreaker every " + interval + " seconds." );
+        System.out.println( "In a few interval the CircuitBreaker will be turned off." );
+        System.out.println( "Connect with a MBean browser (eg. VisualVM + MBean plugin) to
use the turnOn operation on the CircuitBreakers." );
+        System.out.println();
+        System.out.println( "Hit Ctrl-C to stop." );
+        System.out.println();
+
+        while ( true ) {
+            try {
+                Thread.sleep( interval * 1000 );
+            } catch ( InterruptedException e ) {
+                e.printStackTrace();
+            }
+
+            service.helloWorld();
+        }
+    }
+
+    public static class TestService
+            implements ServiceCircuitBreaker
+    {
+
+        CircuitBreaker cb;
+
+        Random random = new Random();
+
+        public TestService( CircuitBreaker cb )
+        {
+            this.cb = cb;
+        }
+
+        @Override
+        public CircuitBreaker circuitBreaker()
+        {
+            return cb;
+        }
+
+        public void helloWorld()
+        {
+            if ( random.nextDouble() > 0.3 ) {
+                cb.throwable( new Throwable( "Failed" ) );
+            } else {
+                cb.success();
+            }
+        }
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/68c662c9/libraries/circuitbreaker/src/test/java/org/qi4j/library/circuitbreaker/jmx/CircuitBreakerManagementTest.java
----------------------------------------------------------------------
diff --git a/libraries/circuitbreaker/src/test/java/org/qi4j/library/circuitbreaker/jmx/CircuitBreakerManagementTest.java
b/libraries/circuitbreaker/src/test/java/org/qi4j/library/circuitbreaker/jmx/CircuitBreakerManagementTest.java
deleted file mode 100644
index 6150012..0000000
--- a/libraries/circuitbreaker/src/test/java/org/qi4j/library/circuitbreaker/jmx/CircuitBreakerManagementTest.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright 2009-2010 Rickard Öberg AB
- *
- * Licensed 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.qi4j.library.circuitbreaker.jmx;
-
-import java.util.Random;
-import javax.management.MBeanServer;
-import org.qi4j.api.activation.ActivationException;
-import org.qi4j.bootstrap.AssemblyException;
-import org.qi4j.bootstrap.ModuleAssembly;
-import org.qi4j.bootstrap.SingletonAssembler;
-import org.qi4j.library.circuitbreaker.CircuitBreaker;
-import org.qi4j.library.circuitbreaker.CircuitBreakers;
-import org.qi4j.library.circuitbreaker.service.ServiceCircuitBreaker;
-import org.qi4j.library.jmx.MBeanServerImporter;
-
-/**
- * Run this as a program and connect with VisualVM. That way you can monitor changes in attributes,
notifications, and
- * execute operations on the CircuitBreaker through JMX.
- */
-public class CircuitBreakerManagementTest
-{
-
-    public static void main( String[] args )
-        throws ActivationException, AssemblyException
-    {
-        SingletonAssembler assembler = new SingletonAssembler()
-        {
-
-            @Override
-            // START SNIPPET: jmx
-            public void assemble( ModuleAssembly module )
-                    throws AssemblyException
-            {
-                // END SNIPPET: jmx
-                CircuitBreaker cb = new CircuitBreaker( 3, 250, CircuitBreakers.in( IllegalArgumentException.class
) );
-
-                module.importedServices( TestService.class ).setMetaInfo( new TestService(
cb ) );
-
-                // START SNIPPET: jmx
-                module.importedServices( MBeanServer.class ).importedBy( MBeanServerImporter.class
); // JMX Library
-                module.services( CircuitBreakerManagement.class ).instantiateOnStartup();
// CircuitBreakers in JMX
-            }
-            // END SNIPPET: jmx
-
-        };
-
-        TestService service = assembler.module().<TestService>findService( TestService.class
).get();
-
-        int interval = 1; // Seconds
-        System.out.println( "CircuitBreaker JMX Support sample is now started." );
-        System.out.println();
-        System.out.println( "A Service that randomly output some text or fail is called through
a CircuitBreaker every " + interval + " seconds." );
-        System.out.println( "In a few interval the CircuitBreaker will be turned off." );
-        System.out.println( "Connect with a MBean browser (eg. VisualVM + MBean plugin) to
use the turnOn operation on the CircuitBreakers." );
-        System.out.println();
-        System.out.println( "Hit Ctrl-C to stop." );
-        System.out.println();
-
-        while ( true ) {
-            try {
-                Thread.sleep( interval * 1000 );
-            } catch ( InterruptedException e ) {
-                e.printStackTrace();
-            }
-
-            service.helloWorld();
-        }
-    }
-
-    public static class TestService
-            implements ServiceCircuitBreaker
-    {
-
-        CircuitBreaker cb;
-
-        Random random = new Random();
-
-        public TestService( CircuitBreaker cb )
-        {
-            this.cb = cb;
-        }
-
-        @Override
-        public CircuitBreaker circuitBreaker()
-        {
-            return cb;
-        }
-
-        public void helloWorld()
-        {
-            if ( random.nextDouble() > 0.3 ) {
-                cb.throwable( new Throwable( "Failed" ) );
-            } else {
-                cb.success();
-            }
-        }
-
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/68c662c9/libraries/eventsourcing-rest/src/test/java/org/qi4j/library/eventsourcing/domain/rest/server/DomainEventSourceResourceSample.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing-rest/src/test/java/org/qi4j/library/eventsourcing/domain/rest/server/DomainEventSourceResourceSample.java
b/libraries/eventsourcing-rest/src/test/java/org/qi4j/library/eventsourcing/domain/rest/server/DomainEventSourceResourceSample.java
new file mode 100644
index 0000000..d74c295
--- /dev/null
+++ b/libraries/eventsourcing-rest/src/test/java/org/qi4j/library/eventsourcing/domain/rest/server/DomainEventSourceResourceSample.java
@@ -0,0 +1,186 @@
+/*
+ * Copyright (c) 2011, Rickard Öberg. All Rights Reserved.
+ *
+ * Licensed 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.qi4j.library.eventsourcing.domain.rest.server;
+
+import org.junit.Ignore;
+import org.qi4j.api.common.UseDefaults;
+import org.qi4j.api.entity.EntityComposite;
+import org.qi4j.api.injection.scope.Service;
+import org.qi4j.api.injection.scope.Structure;
+import org.qi4j.api.mixin.Mixins;
+import org.qi4j.api.property.Property;
+import org.qi4j.api.unitofwork.UnitOfWork;
+import org.qi4j.api.unitofwork.UnitOfWorkCompletionException;
+import org.qi4j.api.unitofwork.UnitOfWorkFactory;
+import org.qi4j.api.usecase.UsecaseBuilder;
+import org.qi4j.bootstrap.AssemblyException;
+import org.qi4j.bootstrap.ImportedServiceDeclaration;
+import org.qi4j.bootstrap.ModuleAssembly;
+import org.qi4j.bootstrap.SingletonAssembler;
+import org.qi4j.library.eventsourcing.domain.api.DomainEvent;
+import org.qi4j.library.eventsourcing.domain.api.DomainEventValue;
+import org.qi4j.library.eventsourcing.domain.api.UnitOfWorkDomainEventsValue;
+import org.qi4j.library.eventsourcing.domain.factory.CurrentUserUoWPrincipal;
+import org.qi4j.library.eventsourcing.domain.factory.DomainEventCreationConcern;
+import org.qi4j.library.eventsourcing.domain.factory.DomainEventFactoryService;
+import org.qi4j.library.eventsourcing.domain.source.EventSource;
+import org.qi4j.library.eventsourcing.domain.source.memory.MemoryEventStoreService;
+import org.qi4j.test.EntityTestAssembler;
+import org.restlet.*;
+import org.restlet.data.Protocol;
+import org.restlet.data.Status;
+import org.restlet.representation.StringRepresentation;
+import org.restlet.resource.ResourceException;
+
+import java.security.Principal;
+
+/**
+ * Start simple web server that exposes the Restlet resource. Test through browser.
+ */
+public class DomainEventSourceResourceSample
+{
+    public static void main( String[] args ) throws Exception
+    {
+        Component component = new Component();
+        component.getServers().add( Protocol.HTTP, 8080 );
+
+        SingletonAssembler assembler = new SingletonAssembler()
+        {
+            public void assemble( ModuleAssembly module ) throws AssemblyException
+            {
+                new EntityTestAssembler().assemble( module );
+
+                module.values( DomainEventValue.class, UnitOfWorkDomainEventsValue.class
);
+                module.services( MemoryEventStoreService.class ).taggedWith( "domain" );
+                module.services( DomainEventFactoryService.class );
+                module.importedServices( CurrentUserUoWPrincipal.class ).importedBy( ImportedServiceDeclaration.NEW_OBJECT
);
+                module.objects( CurrentUserUoWPrincipal.class );
+
+                module.objects( DomainEventSourceResource.class, PingResource.class );
+
+                module.entities( TestEntity.class ).withConcerns( DomainEventCreationConcern.class
);
+            }
+        };
+
+        component.getDefaultHost().attach( "/events", new TestApplication( assembler ) );
+        component.getDefaultHost().attach( "/ping", assembler.module().newObject( PingResource.class
) );
+        component.start();
+
+        generateTestData(assembler.module());
+    }
+
+    private static void generateTestData(UnitOfWorkFactory unitOfWorkFactory) throws UnitOfWorkCompletionException
+    {
+        // Set principal for the UoW
+        Principal administratorPrincipal = new Principal()
+        {
+            public String getName()
+            {
+                return "administrator";
+            }
+        };
+
+        // Perform UoW with usecase defined
+        for (int i = 0; i < 43; i++)
+        {
+            UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( UsecaseBuilder.newUsecase(
"Change description "+(i+1) ));
+            uow.setMetaInfo( administratorPrincipal );
+
+            TestEntity entity = uow.newEntity( TestEntity.class );
+            entity.changedDescription( "New description" );
+            uow.complete();
+        }
+    }
+
+    static class TestApplication
+        extends Application
+    {
+        private final SingletonAssembler assembler;
+
+        TestApplication(SingletonAssembler assembler)
+        {
+            this.assembler = assembler;
+        }
+
+        @Override
+        public Restlet createInboundRoot()
+        {
+            getTunnelService().setExtensionsTunnel( true );
+            return assembler.module().newObject(DomainEventSourceResource.class  );
+        }
+    }
+
+
+    @Mixins(TestEntity.Mixin.class)
+    public interface TestEntity
+            extends EntityComposite
+    {
+        @UseDefaults
+        Property<String> description();
+
+        @DomainEvent
+        void changedDescription( String newName );
+
+        abstract class Mixin
+                implements TestEntity
+        {
+            public void changedDescription( String newName )
+            {
+                description().set( newName );
+            }
+        }
+    }
+
+    // Used to create more events
+    public static class PingResource
+        extends Restlet
+    {
+        @Structure
+        UnitOfWorkFactory unitOfWorkFactory;
+
+        @Service
+        EventSource eventSource;
+
+        @Override
+        public void handle( Request request, Response response )
+        {
+            // Set principal for the UoW
+            Principal administratorPrincipal = new Principal()
+            {
+                public String getName()
+                {
+                    return "administrator";
+                }
+            };
+
+            // Perform UoW with usecase defined
+            try
+            {
+                UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( UsecaseBuilder.newUsecase(
"Change description "+(eventSource.count()) ));
+                uow.setMetaInfo( administratorPrincipal );
+
+                TestEntity entity = uow.newEntity( TestEntity.class );
+                entity.changedDescription( "New description" );
+                uow.complete();
+
+                response.setEntity( new StringRepresentation( "Event created" ) );
+                response.setStatus( Status.SUCCESS_OK );
+            } catch (UnitOfWorkCompletionException e)
+            {
+                throw new ResourceException(e);
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/68c662c9/libraries/eventsourcing-rest/src/test/java/org/qi4j/library/eventsourcing/domain/rest/server/DomainEventSourceResourceTest.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing-rest/src/test/java/org/qi4j/library/eventsourcing/domain/rest/server/DomainEventSourceResourceTest.java
b/libraries/eventsourcing-rest/src/test/java/org/qi4j/library/eventsourcing/domain/rest/server/DomainEventSourceResourceTest.java
deleted file mode 100644
index 2f1a2cd..0000000
--- a/libraries/eventsourcing-rest/src/test/java/org/qi4j/library/eventsourcing/domain/rest/server/DomainEventSourceResourceTest.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Copyright (c) 2011, Rickard Öberg. All Rights Reserved.
- *
- * Licensed 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.qi4j.library.eventsourcing.domain.rest.server;
-
-import org.junit.Ignore;
-import org.qi4j.api.common.UseDefaults;
-import org.qi4j.api.entity.EntityComposite;
-import org.qi4j.api.injection.scope.Service;
-import org.qi4j.api.injection.scope.Structure;
-import org.qi4j.api.mixin.Mixins;
-import org.qi4j.api.property.Property;
-import org.qi4j.api.unitofwork.UnitOfWork;
-import org.qi4j.api.unitofwork.UnitOfWorkCompletionException;
-import org.qi4j.api.unitofwork.UnitOfWorkFactory;
-import org.qi4j.api.usecase.UsecaseBuilder;
-import org.qi4j.bootstrap.AssemblyException;
-import org.qi4j.bootstrap.ImportedServiceDeclaration;
-import org.qi4j.bootstrap.ModuleAssembly;
-import org.qi4j.bootstrap.SingletonAssembler;
-import org.qi4j.library.eventsourcing.domain.api.DomainEvent;
-import org.qi4j.library.eventsourcing.domain.api.DomainEventValue;
-import org.qi4j.library.eventsourcing.domain.api.UnitOfWorkDomainEventsValue;
-import org.qi4j.library.eventsourcing.domain.factory.CurrentUserUoWPrincipal;
-import org.qi4j.library.eventsourcing.domain.factory.DomainEventCreationConcern;
-import org.qi4j.library.eventsourcing.domain.factory.DomainEventFactoryService;
-import org.qi4j.library.eventsourcing.domain.source.EventSource;
-import org.qi4j.library.eventsourcing.domain.source.memory.MemoryEventStoreService;
-import org.qi4j.test.EntityTestAssembler;
-import org.restlet.*;
-import org.restlet.data.Protocol;
-import org.restlet.data.Status;
-import org.restlet.representation.StringRepresentation;
-import org.restlet.resource.ResourceException;
-
-import java.security.Principal;
-
-/**
- * Start simple web server that exposes the Restlet resource. Test through browser.
- */
-public class DomainEventSourceResourceTest
-{
-    public static void main( String[] args ) throws Exception
-    {
-        Component component = new Component();
-        component.getServers().add( Protocol.HTTP, 8080 );
-
-        SingletonAssembler assembler = new SingletonAssembler()
-        {
-            public void assemble( ModuleAssembly module ) throws AssemblyException
-            {
-                new EntityTestAssembler().assemble( module );
-
-                module.values( DomainEventValue.class, UnitOfWorkDomainEventsValue.class
);
-                module.services( MemoryEventStoreService.class ).taggedWith( "domain" );
-                module.services( DomainEventFactoryService.class );
-                module.importedServices( CurrentUserUoWPrincipal.class ).importedBy( ImportedServiceDeclaration.NEW_OBJECT
);
-                module.objects( CurrentUserUoWPrincipal.class );
-
-                module.objects( DomainEventSourceResource.class, PingResource.class );
-
-                module.entities( TestEntity.class ).withConcerns( DomainEventCreationConcern.class
);
-            }
-        };
-
-        component.getDefaultHost().attach( "/events", new TestApplication( assembler ) );
-        component.getDefaultHost().attach( "/ping", assembler.module().newObject( PingResource.class
) );
-        component.start();
-
-        generateTestData(assembler.module());
-    }
-
-    private static void generateTestData(UnitOfWorkFactory unitOfWorkFactory) throws UnitOfWorkCompletionException
-    {
-        // Set principal for the UoW
-        Principal administratorPrincipal = new Principal()
-        {
-            public String getName()
-            {
-                return "administrator";
-            }
-        };
-
-        // Perform UoW with usecase defined
-        for (int i = 0; i < 43; i++)
-        {
-            UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( UsecaseBuilder.newUsecase(
"Change description "+(i+1) ));
-            uow.setMetaInfo( administratorPrincipal );
-
-            TestEntity entity = uow.newEntity( TestEntity.class );
-            entity.changedDescription( "New description" );
-            uow.complete();
-        }
-    }
-
-    static class TestApplication
-        extends Application
-    {
-        private final SingletonAssembler assembler;
-
-        TestApplication(SingletonAssembler assembler)
-        {
-            this.assembler = assembler;
-        }
-
-        @Override
-        public Restlet createInboundRoot()
-        {
-            getTunnelService().setExtensionsTunnel( true );
-            return assembler.module().newObject(DomainEventSourceResource.class  );
-        }
-    }
-
-
-    @Mixins(TestEntity.Mixin.class)
-    public interface TestEntity
-            extends EntityComposite
-    {
-        @UseDefaults
-        Property<String> description();
-
-        @DomainEvent
-        void changedDescription( String newName );
-
-        abstract class Mixin
-                implements TestEntity
-        {
-            public void changedDescription( String newName )
-            {
-                description().set( newName );
-            }
-        }
-    }
-
-    // Used to create more events
-    public static class PingResource
-        extends Restlet
-    {
-        @Structure
-        UnitOfWorkFactory unitOfWorkFactory;
-
-        @Service
-        EventSource eventSource;
-
-        @Override
-        public void handle( Request request, Response response )
-        {
-            // Set principal for the UoW
-            Principal administratorPrincipal = new Principal()
-            {
-                public String getName()
-                {
-                    return "administrator";
-                }
-            };
-
-            // Perform UoW with usecase defined
-            try
-            {
-                UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( UsecaseBuilder.newUsecase(
"Change description "+(eventSource.count()) ));
-                uow.setMetaInfo( administratorPrincipal );
-
-                TestEntity entity = uow.newEntity( TestEntity.class );
-                entity.changedDescription( "New description" );
-                uow.complete();
-
-                response.setEntity( new StringRepresentation( "Event created" ) );
-                response.setStatus( Status.SUCCESS_OK );
-            } catch (UnitOfWorkCompletionException e)
-            {
-                throw new ResourceException(e);
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/68c662c9/libraries/logging/src/main/java/org/qi4j/logging/trace/service/TraceServiceMixin.java
----------------------------------------------------------------------
diff --git a/libraries/logging/src/main/java/org/qi4j/logging/trace/service/TraceServiceMixin.java
b/libraries/logging/src/main/java/org/qi4j/logging/trace/service/TraceServiceMixin.java
index 7590eef..8f20625 100644
--- a/libraries/logging/src/main/java/org/qi4j/logging/trace/service/TraceServiceMixin.java
+++ b/libraries/logging/src/main/java/org/qi4j/logging/trace/service/TraceServiceMixin.java
@@ -103,8 +103,8 @@ public class TraceServiceMixin
         {
             EntityComposite entity = (EntityComposite) object;
             String identity = entity.identity().get();
-            EntityComposite source = (EntityComposite) uow.get( first( Qi4j.FUNCTION_DESCRIPTOR_FOR
-                                                                           .map( entity ).types()
), identity);
+            EntityComposite source = (EntityComposite) uow.get( (Class<?>) first(
+                Qi4j.FUNCTION_DESCRIPTOR_FOR.map( entity ).types() ), identity );
             EntityBuilder<EntityTraceRecordEntity> builder = uow.newEntityBuilder(
EntityTraceRecordEntity.class );
             EntityTraceRecordEntity state = builder.instance();
             setStandardStuff( compositeType, method, args, entryTime, durationNano, state,
exception );

http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/68c662c9/libraries/rest/src/test/java/org/qi4j/library/rest/admin/RestTest.java
----------------------------------------------------------------------
diff --git a/libraries/rest/src/test/java/org/qi4j/library/rest/admin/RestTest.java b/libraries/rest/src/test/java/org/qi4j/library/rest/admin/RestTest.java
index 3dfdbf9..046746d 100644
--- a/libraries/rest/src/test/java/org/qi4j/library/rest/admin/RestTest.java
+++ b/libraries/rest/src/test/java/org/qi4j/library/rest/admin/RestTest.java
@@ -124,6 +124,7 @@ public class RestTest
         assertThat( "Incorrect RDF produced", rdf, anyOf(
             // Open JDK 8 & Valid
             equalTo( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<rdf:RDF\n	xmlns:qi4j=\"http://www.qi4j.org/rdf/model/1.0/\"\n
xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n	xmlns:rdfs=\"http://www.w3.org/2000/01/rdf-schema#\">\n<org.qi4j.library.rest.admin.RestTest-PersonEntity
xmlns=\"urn:qi4j:type:\" rdf:about=\"urn:qi4j:entity:P1\">\n	<lastname xmlns=\"urn:qi4j:type:org.qi4j.library.rest.admin.RestTest-Person#\">Doe</lastname>\n
<firstname xmlns=\"urn:qi4j:type:org.qi4j.library.rest.admin.RestTest-Person#\">Joe</firstname>\n
<identity xmlns=\"urn:qi4j:type:org.qi4j.api.entity.Identity#\">P1</identity>\n
<mother xmlns=\"urn:qi4j:type:org.qi4j.library.rest.admin.RestTest-Person#\" rdf:resource=\"urn:qi4j:entity:P2\"/>\n</org.qi4j.library.rest.admin.RestTest-PersonEntity>\n\n</rdf:RDF>"
),
+            equalTo( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<rdf:RDF\n	xmlns:qi4j=\"http://www.qi4j.org/rdf/model/1.0/\"\n
xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n	xmlns:rdfs=\"http://www.w3.org/2000/01/rdf-schema#\">\n<org.qi4j.library.rest.admin.RestTest-PersonEntity
xmlns=\"urn:qi4j:type:\" rdf:about=\"urn:qi4j:entity:P1\">\n	<identity xmlns=\"urn:qi4j:type:org.qi4j.api.entity.Identity#\">P1</identity>\n
<firstname xmlns=\"urn:qi4j:type:org.qi4j.library.rest.admin.RestTest-Person#\">Joe</firstname>\n
<lastname xmlns=\"urn:qi4j:type:org.qi4j.library.rest.admin.RestTest-Person#\">Doe</lastname>\n
<mother xmlns=\"urn:qi4j:type:org.qi4j.library.rest.admin.RestTest-Person#\" rdf:resource=\"urn:qi4j:entity:P2\"/>\n</org.qi4j.library.rest.admin.RestTest-PersonEntity>\n\n</rdf:RDF>"
),
             // Sun JDK 6 / Oracle JDK 7 & Valid
             equalTo( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<rdf:RDF\n	xmlns:qi4j=\"http://www.qi4j.org/rdf/model/1.0/\"\n
xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n	xmlns:rdfs=\"http://www.w3.org/2000/01/rdf-schema#\">\n<org.qi4j.library.rest.admin.RestTest-PersonEntity
xmlns=\"urn:qi4j:type:\" rdf:about=\"urn:qi4j:entity:P1\">\n	<firstname xmlns=\"urn:qi4j:type:org.qi4j.library.rest.admin.RestTest-Person#\">Joe</firstname>\n
<lastname xmlns=\"urn:qi4j:type:org.qi4j.library.rest.admin.RestTest-Person#\">Doe</lastname>\n
<identity xmlns=\"urn:qi4j:type:org.qi4j.api.entity.Identity#\">P1</identity>\n
<mother xmlns=\"urn:qi4j:type:org.qi4j.library.rest.admin.RestTest-Person#\" rdf:resource=\"urn:qi4j:entity:P2\"/>\n</org.qi4j.library.rest.admin.RestTest-PersonEntity>\n\n</rdf:RDF>"
),
             // IBM JDK 6 & Valid

http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/68c662c9/libraries/uid/src/test/java/org/qi4j/library/uid/sequence/PersistingSequencingTest.java
----------------------------------------------------------------------
diff --git a/libraries/uid/src/test/java/org/qi4j/library/uid/sequence/PersistingSequencingTest.java
b/libraries/uid/src/test/java/org/qi4j/library/uid/sequence/PersistingSequencingTest.java
index 04e55c3..3a33c9e 100644
--- a/libraries/uid/src/test/java/org/qi4j/library/uid/sequence/PersistingSequencingTest.java
+++ b/libraries/uid/src/test/java/org/qi4j/library/uid/sequence/PersistingSequencingTest.java
@@ -27,10 +27,11 @@ import org.qi4j.library.uid.sequence.assembly.PersistingSequencingAssembler;
 import org.qi4j.test.AbstractQi4jTest;
 import org.qi4j.test.EntityTestAssembler;
 
-import static junit.framework.Assert.assertEquals;
-
+import static org.junit.Assert.*;
+    
 public class PersistingSequencingTest extends AbstractQi4jTest
 {
+    @Override
     public void assemble( ModuleAssembly module ) throws AssemblyException
     {
         new PersistingSequencingAssembler().assemble( module );

http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/68c662c9/libraries/uid/src/test/java/org/qi4j/library/uid/sequence/TransientSequencingTest.java
----------------------------------------------------------------------
diff --git a/libraries/uid/src/test/java/org/qi4j/library/uid/sequence/TransientSequencingTest.java
b/libraries/uid/src/test/java/org/qi4j/library/uid/sequence/TransientSequencingTest.java
index fef14ea..5ad7e5b 100644
--- a/libraries/uid/src/test/java/org/qi4j/library/uid/sequence/TransientSequencingTest.java
+++ b/libraries/uid/src/test/java/org/qi4j/library/uid/sequence/TransientSequencingTest.java
@@ -26,10 +26,11 @@ import org.qi4j.bootstrap.ModuleAssembly;
 import org.qi4j.library.uid.sequence.assembly.TransientSequencingAssembler;
 import org.qi4j.test.AbstractQi4jTest;
 
-import static junit.framework.Assert.assertEquals;
+import static org.junit.Assert.assertEquals;
 
 public class TransientSequencingTest extends AbstractQi4jTest
 {
+    @Override
     public void assemble( ModuleAssembly module ) throws AssemblyException
     {
         new TransientSequencingAssembler().assemble( module );


Mime
View raw message