Return-Path: X-Original-To: apmail-zest-commits-archive@minotaur.apache.org Delivered-To: apmail-zest-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 44EA218A82 for ; Wed, 16 Dec 2015 06:17:39 +0000 (UTC) Received: (qmail 62830 invoked by uid 500); 16 Dec 2015 06:17:39 -0000 Delivered-To: apmail-zest-commits-archive@zest.apache.org Received: (qmail 62747 invoked by uid 500); 16 Dec 2015 06:17:39 -0000 Mailing-List: contact commits-help@zest.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@zest.apache.org Delivered-To: mailing list commits@zest.apache.org Received: (qmail 62639 invoked by uid 99); 16 Dec 2015 06:17:38 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Dec 2015 06:17:38 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id CDFC1E0B27; Wed, 16 Dec 2015 06:17:38 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: niclas@apache.org To: commits@zest.apache.org Date: Wed, 16 Dec 2015 06:17:42 -0000 Message-Id: In-Reply-To: <0b77afe66b1d4c059412da98c8184cce@git.apache.org> References: <0b77afe66b1d4c059412da98c8184cce@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [5/9] zest-java git commit: ZEST-132, ZEST-97 UnitOfWorkFactory as a customizable Service UnitOfWork as a customizable Transient Class can be a Transient directly, with itself as both the Composite Type and the Mixin. SideEffects declarations http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/runtime/src/test/java/org/apache/zest/runtime/visibility/VisibilityInUnitOfWorkTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/visibility/VisibilityInUnitOfWorkTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/visibility/VisibilityInUnitOfWorkTest.java index bae6c61..55662db 100644 --- a/core/runtime/src/test/java/org/apache/zest/runtime/visibility/VisibilityInUnitOfWorkTest.java +++ b/core/runtime/src/test/java/org/apache/zest/runtime/visibility/VisibilityInUnitOfWorkTest.java @@ -16,7 +16,6 @@ */ package org.apache.zest.runtime.visibility; -import org.junit.Test; import org.apache.zest.api.common.Visibility; import org.apache.zest.api.injection.scope.Service; import org.apache.zest.api.injection.scope.Structure; @@ -25,17 +24,18 @@ import org.apache.zest.api.service.ServiceReference; import org.apache.zest.api.structure.Application; import org.apache.zest.api.structure.Module; import org.apache.zest.api.unitofwork.UnitOfWork; +import org.apache.zest.api.unitofwork.UnitOfWorkFactory; import org.apache.zest.api.value.ValueSerialization; -import org.apache.zest.bootstrap.ApplicationAssembler; import org.apache.zest.bootstrap.ApplicationAssembly; -import org.apache.zest.bootstrap.ApplicationAssemblyFactory; import org.apache.zest.bootstrap.AssemblyException; import org.apache.zest.bootstrap.Energy4Java; import org.apache.zest.bootstrap.LayerAssembly; import org.apache.zest.bootstrap.ModuleAssembly; +import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler; import org.apache.zest.entitystore.memory.MemoryEntityStoreService; import org.apache.zest.spi.uuid.UuidIdentityGeneratorService; import org.apache.zest.valueserialization.orgjson.OrgJsonValueSerializationService; +import org.junit.Test; public class VisibilityInUnitOfWorkTest { @@ -60,19 +60,19 @@ public class VisibilityInUnitOfWorkTest implements YourService { @Structure - private Module module; + private UnitOfWorkFactory uowf; @Override public void create() { - UnitOfWork uow = module.currentUnitOfWork(); + UnitOfWork uow = uowf.currentUnitOfWork(); YourEntity entity = uow.newEntity( YourEntity.class, "345" ); } @Override public YourEntity get() { - UnitOfWork uow = module.currentUnitOfWork(); + UnitOfWork uow = uowf.currentUnitOfWork(); return uow.get( YourEntity.class, "345" ); } } @@ -114,12 +114,12 @@ public class VisibilityInUnitOfWorkTest private YourService service; @Structure - private Module module; + private UnitOfWorkFactory uowf; @Override public void create() { - try (UnitOfWork uow = module.newUnitOfWork()) + try (UnitOfWork uow = uowf.newUnitOfWork()) { uow.newEntity( MyEntity.class, "123" ); MyEntity entity1 = uow.get( MyEntity.class, "123" ); @@ -134,26 +134,25 @@ public class VisibilityInUnitOfWorkTest throws AssemblyException { Energy4Java zest = new Energy4Java(); - return zest.newApplication( new ApplicationAssembler() - { - @Override - public ApplicationAssembly assemble( ApplicationAssemblyFactory appFactory ) - throws AssemblyException - { - ApplicationAssembly appAssembly = appFactory.newApplicationAssembly(); - LayerAssembly layer1 = appAssembly.layer( "layer1" ); - ModuleAssembly myModule = layer1.module( "My Module" ); - ModuleAssembly yourModule = layer1.module( "Your Module" ); - ModuleAssembly infraModule = layer1.module( "Infra Module" ); - myModule.services( MyService.class ); - myModule.entities( MyEntity.class ); - yourModule.entities( YourEntity.class ); - yourModule.services( YourService.class ).visibleIn( Visibility.layer ); - infraModule.services( MemoryEntityStoreService.class ).visibleIn( Visibility.layer ); - infraModule.services( UuidIdentityGeneratorService.class ).visibleIn( Visibility.layer ); - infraModule.services( OrgJsonValueSerializationService.class ).visibleIn( Visibility.layer).taggedWith( ValueSerialization.Formats.JSON ); - return appAssembly; - } + return zest.newApplication( appFactory -> { + ApplicationAssembly appAssembly = appFactory.newApplicationAssembly(); + LayerAssembly layer1 = appAssembly.layer( "layer1" ); + ModuleAssembly myModule = layer1.module( "My Module" ); + ModuleAssembly yourModule = layer1.module( "Your Module" ); + ModuleAssembly infraModule = layer1.module( "Infra Module" ); + myModule.services( MyService.class ); + myModule.entities( MyEntity.class ); + new DefaultUnitOfWorkAssembler().assemble( myModule ); + yourModule.entities( YourEntity.class ); + yourModule.services( YourService.class ).visibleIn( Visibility.layer ); + new DefaultUnitOfWorkAssembler().assemble( yourModule ); + infraModule.services( MemoryEntityStoreService.class ).visibleIn( Visibility.layer ); + infraModule.services( UuidIdentityGeneratorService.class ).visibleIn( Visibility.layer ); + infraModule.services( OrgJsonValueSerializationService.class ) + .visibleIn( Visibility.layer ) + .taggedWith( ValueSerialization.Formats.JSON ); + new DefaultUnitOfWorkAssembler().assemble( infraModule ); + return appAssembly; } ); } } http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONMapEntityStoreMixin.java ---------------------------------------------------------------------- diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONMapEntityStoreMixin.java b/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONMapEntityStoreMixin.java index ef78cce..8dedcfd 100755 --- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONMapEntityStoreMixin.java +++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONMapEntityStoreMixin.java @@ -58,7 +58,7 @@ import org.apache.zest.spi.entitystore.EntityStoreException; import org.apache.zest.spi.entitystore.EntityStoreSPI; import org.apache.zest.spi.entitystore.EntityStoreUnitOfWork; import org.apache.zest.spi.entitystore.StateCommitter; -import org.apache.zest.spi.module.ModelModule; +import org.apache.zest.spi.structure.ModelModule; import org.apache.zest.spi.module.ModuleSpi; import org.json.JSONException; import org.json.JSONObject; http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/MapEntityStoreMixin.java ---------------------------------------------------------------------- diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/MapEntityStoreMixin.java b/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/MapEntityStoreMixin.java index ec001b1..d553437 100755 --- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/MapEntityStoreMixin.java +++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/MapEntityStoreMixin.java @@ -55,7 +55,7 @@ import org.apache.zest.spi.entitystore.EntityStoreException; import org.apache.zest.spi.entitystore.EntityStoreSPI; import org.apache.zest.spi.entitystore.EntityStoreUnitOfWork; import org.apache.zest.spi.entitystore.StateCommitter; -import org.apache.zest.spi.module.ModelModule; +import org.apache.zest.spi.structure.ModelModule; import org.apache.zest.spi.module.ModuleSpi; import org.json.JSONArray; import org.json.JSONException; http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/spi/src/main/java/org/apache/zest/spi/module/ModelModule.java ---------------------------------------------------------------------- diff --git a/core/spi/src/main/java/org/apache/zest/spi/module/ModelModule.java b/core/spi/src/main/java/org/apache/zest/spi/module/ModelModule.java deleted file mode 100644 index 4445697..0000000 --- a/core/spi/src/main/java/org/apache/zest/spi/module/ModelModule.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * 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.zest.spi.module; - -import java.util.function.Function; -import org.apache.zest.api.composite.ModelDescriptor; - -/** - * TODO - */ -public class ModelModule -{ - - public static Function, String> toStringFunction = item -> item.model() - .types() - .iterator() - .next() - .getName() + "[" + item.module().name() + "]"; - - public static Function> modelModuleFunction( final ModuleSpi module ) - { - return model1 -> new ModelModule<>( module, model1 ); - } - - public static Function, ModelDescriptor> modelFunction() - { - return new Function, ModelDescriptor>() - { - @Override - public ModelDescriptor apply( ModelModule modelModule ) - { - return modelModule.model(); - } - }; - } - - private final ModuleSpi module; - private final T model; - - public ModelModule( ModuleSpi module, T model ) - { - this.module = module; - this.model = model; - } - - public ModuleSpi module() - { - return module; - } - - public T model() - { - return model; - } - - @Override - public boolean equals( Object o ) - { - if( this == o ) - { - return true; - } - if( o == null || getClass() != o.getClass() ) - { - return false; - } - - ModelModule that = (ModelModule) o; - - if( model != null ? !model.equals( that.model ) : that.model != null ) - { - return false; - } - - return !( module != null ? !module.equals( that.module ) : that.module != null ); - } - - @Override - public int hashCode() - { - int result = module != null ? module.hashCode() : 0; - result = 31 * result + ( model != null ? model.hashCode() : 0 ); - return result; - } - - @Override - public String toString() - { - return module.name() + ":" + model; - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/spi/src/main/java/org/apache/zest/spi/module/ModuleSpi.java ---------------------------------------------------------------------- diff --git a/core/spi/src/main/java/org/apache/zest/spi/module/ModuleSpi.java b/core/spi/src/main/java/org/apache/zest/spi/module/ModuleSpi.java index 3057b05..cb5208c 100644 --- a/core/spi/src/main/java/org/apache/zest/spi/module/ModuleSpi.java +++ b/core/spi/src/main/java/org/apache/zest/spi/module/ModuleSpi.java @@ -19,7 +19,10 @@ package org.apache.zest.spi.module; import java.util.stream.Stream; import org.apache.zest.api.composite.ModelDescriptor; import org.apache.zest.api.entity.IdentityGenerator; +import org.apache.zest.api.metrics.MetricsProvider; import org.apache.zest.api.service.ServiceReference; +import org.apache.zest.spi.structure.TypeLookup; +import org.apache.zest.spi.structure.ModelModule; import org.apache.zest.api.structure.Module; import org.apache.zest.api.value.ValueSerialization; import org.apache.zest.spi.entitystore.EntityStore; @@ -41,4 +44,8 @@ public interface ModuleSpi extends Module Stream> findVisibleObjectTypes(); Stream> findVisibleServiceTypes(); + + TypeLookup typeLookup(); + + MetricsProvider metricsProvider(); } http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/spi/src/main/java/org/apache/zest/spi/structure/ModelModule.java ---------------------------------------------------------------------- diff --git a/core/spi/src/main/java/org/apache/zest/spi/structure/ModelModule.java b/core/spi/src/main/java/org/apache/zest/spi/structure/ModelModule.java new file mode 100644 index 0000000..6b584ae --- /dev/null +++ b/core/spi/src/main/java/org/apache/zest/spi/structure/ModelModule.java @@ -0,0 +1,107 @@ +/* + * 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.zest.spi.structure; + +import java.util.function.Function; +import org.apache.zest.api.composite.ModelDescriptor; +import org.apache.zest.spi.module.ModuleSpi; + +/** + * TODO + */ +public class ModelModule +{ + + public static Function, String> toStringFunction = item -> item.model() + .types() + .iterator() + .next() + .getName() + "[" + item.module() + .name() + "]"; + + public static Function> modelModuleFunction( final ModuleSpi module ) + { + return model1 -> new ModelModule<>( module, model1 ); + } + + public static Function, ModelDescriptor> modelFunction() + { + return modelModule -> { + return modelModule.model(); + }; + } + + private final ModuleSpi module; + private final T model; + + public ModelModule( ModuleSpi module, T model ) + { + this.module = module; + this.model = model; + } + + public ModuleSpi module() + { + return module; + } + + public T model() + { + return model; + } + + @Override + public boolean equals( Object o ) + { + if( this == o ) + { + return true; + } + if( o == null || getClass() != o.getClass() ) + { + return false; + } + + ModelModule that = (ModelModule) o; + + //noinspection SimplifiableIfStatement + if( model != null ? !model.equals( that.model ) : that.model != null ) + { + return false; + } + + return !( module != null ? !module.equals( that.module ) : that.module != null ); + } + + @Override + public int hashCode() + { + int result = module != null ? module.hashCode() : 0; + result = 31 * result + ( model != null ? model.hashCode() : 0 ); + return result; + } + + @Override + public String toString() + { + return module.name() + ":" + model; + } +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/spi/src/main/java/org/apache/zest/spi/structure/TypeLookup.java ---------------------------------------------------------------------- diff --git a/core/spi/src/main/java/org/apache/zest/spi/structure/TypeLookup.java b/core/spi/src/main/java/org/apache/zest/spi/structure/TypeLookup.java new file mode 100644 index 0000000..94e0473 --- /dev/null +++ b/core/spi/src/main/java/org/apache/zest/spi/structure/TypeLookup.java @@ -0,0 +1,125 @@ +/* + * 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.zest.spi.structure; + +import java.lang.reflect.Type; +import java.util.List; +import java.util.stream.Stream; +import org.apache.zest.api.composite.TransientDescriptor; +import org.apache.zest.api.entity.EntityDescriptor; +import org.apache.zest.api.object.ObjectDescriptor; +import org.apache.zest.api.service.ServiceReference; +import org.apache.zest.api.value.ValueDescriptor; + +public interface TypeLookup +{ + /** + * Lookup first Entity Model matching the given Type. + * + *

First, if Entity Models exactly match the given type, the closest one (Visibility then Assembly order) is returned. + * Multiple exact matches with the same Visibility are forbidden and result in an AmbiguousTypeException.

+ * + *

Second, if Entity Models match a type assignable to the given type, the closest one (Visibility then Assembly order) is returned. + * Multiple assignable matches with the same Visibility are forbidden and result in an AmbiguousTypeException.

+ * + *

Type lookup is done lazily and cached.

+ * + *

Should be used for creational use cases only. For non-creational use cases see + * {@link #lookupEntityModels(Class)}.

+ * + * @param type Looked up Type + * + * @return First matching Entity Model + */ + ModelModule lookupEntityModel( Class type ); + + /** + * Lookup all Entity Models matching the given Type. + * + *

Returned Iterable contains, in order, Entity Models that:

+ * + *
    + *
  • exactly match the given type, in Visibility then Assembly order ;
  • + *
  • match a type assignable to the given type, in Visibility then Assembly order.
  • + *
+ * + *

Multiple exact matches with the same Visibility are forbidden and result in an AmbiguousTypeException.

+ *

Multiple assignable matches are allowed to enable polymorphic fetches and queries.

+ * + *

Type lookup is done lazily and cached.

+ * + *

Should be used for non-creational use cases only. For creational use cases see + * {@link #lookupEntityModel(Class)}.

+ * + * @param type Looked up Type + * + * @return All matching Entity Models + */ + Iterable> lookupEntityModels( Class type ); + + /** + * Lookup first ServiceReference matching the given Type. + * + *

Type lookup is done lazily and cached.

+ * + *

See {@link #lookupServiceReferences(Type)}.

+ * + * @param Service Type + * @param serviceType Looked up Type + * + * @return First matching ServiceReference + */ + ServiceReference lookupServiceReference( Type serviceType ); + + /** + * Lookup all ServiceReferences matching the given Type. + * + *

Returned Iterable contains, in order, ServiceReferences that:

+ * + *
    + *
  • exactly match the given type, in Visibility then Assembly order ;
  • + *
  • match a type assignable to the given type, in Visibility then Assembly order.
  • + *
+ * + *

Multiple exact matches with the same Visibility are allowed to enable polymorphic lookup/injection.

+ *

Multiple assignable matches with the same Visibility are allowed for the very same reason.

+ * + *

Type lookup is done lazily and cached.

+ * + * @param Service Type + * @param type Looked up Type + * + * @return All matching ServiceReferences + */ + List> lookupServiceReferences( Type type ); + + Stream> allVisibleObjects(); + + Stream> allObjects(); + + Stream> allTransients(); + + Stream> allValues(); + + Stream> allEntities(); + + Stream> allServices(); +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/testsupport/src/main/java/org/apache/zest/test/AbstractZestScenarioTest.java ---------------------------------------------------------------------- diff --git a/core/testsupport/src/main/java/org/apache/zest/test/AbstractZestScenarioTest.java b/core/testsupport/src/main/java/org/apache/zest/test/AbstractZestScenarioTest.java index a035345..456c616 100644 --- a/core/testsupport/src/main/java/org/apache/zest/test/AbstractZestScenarioTest.java +++ b/core/testsupport/src/main/java/org/apache/zest/test/AbstractZestScenarioTest.java @@ -14,20 +14,19 @@ package org.apache.zest.test; -import org.junit.AfterClass; -import org.junit.BeforeClass; import org.apache.zest.api.ZestAPI; import org.apache.zest.api.structure.Application; import org.apache.zest.api.structure.ApplicationDescriptor; import org.apache.zest.api.structure.Module; import org.apache.zest.api.unitofwork.UnitOfWork; +import org.apache.zest.api.unitofwork.UnitOfWorkFactory; import org.apache.zest.bootstrap.ApplicationAssembler; -import org.apache.zest.bootstrap.ApplicationAssembly; -import org.apache.zest.bootstrap.ApplicationAssemblyFactory; import org.apache.zest.bootstrap.Assembler; import org.apache.zest.bootstrap.AssemblyException; import org.apache.zest.bootstrap.Energy4Java; import org.apache.zest.spi.ZestSPI; +import org.junit.AfterClass; +import org.junit.BeforeClass; /** * Base class for Zest scenario tests. This will create one Zest application per class instead of per test. @@ -45,6 +44,7 @@ public abstract class AbstractZestScenarioTest static protected Module module; static protected Assembler assembler; // Initialize this in static block of subclass + private static UnitOfWorkFactory uowf; @BeforeClass public static void setUp() @@ -64,6 +64,7 @@ public abstract class AbstractZestScenarioTest // Assume only one module module = application.findModule( "Layer 1", "Module 1" ); + uowf = module.unitOfWorkFactory(); } static protected ApplicationDescriptor newApplication() @@ -71,15 +72,7 @@ public abstract class AbstractZestScenarioTest { final Assembler asm = assembler; - ApplicationAssembler assembler = new ApplicationAssembler() - { - @Override - public ApplicationAssembly assemble( ApplicationAssemblyFactory applicationFactory ) - throws AssemblyException - { - return applicationFactory.newApplicationAssembly( asm ); - } - }; + ApplicationAssembler assembler = applicationFactory -> applicationFactory.newApplicationAssembly( asm ); try { return zest.newApplicationModel( assembler ); @@ -116,11 +109,11 @@ public abstract class AbstractZestScenarioTest public void tearDown() throws Exception { - if( module != null && module.isUnitOfWorkActive() ) + if( uowf != null && uowf.isUnitOfWorkActive() ) { - while( module.isUnitOfWorkActive() ) + while( uowf.isUnitOfWorkActive() ) { - UnitOfWork uow = module.currentUnitOfWork(); + UnitOfWork uow = uowf.currentUnitOfWork(); if( uow.isOpen() ) { uow.discard(); http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/testsupport/src/main/java/org/apache/zest/test/AbstractZestTest.java ---------------------------------------------------------------------- diff --git a/core/testsupport/src/main/java/org/apache/zest/test/AbstractZestTest.java b/core/testsupport/src/main/java/org/apache/zest/test/AbstractZestTest.java index 8f2fb96..29c27aa 100644 --- a/core/testsupport/src/main/java/org/apache/zest/test/AbstractZestTest.java +++ b/core/testsupport/src/main/java/org/apache/zest/test/AbstractZestTest.java @@ -14,6 +14,9 @@ package org.apache.zest.test; +import org.apache.zest.api.injection.scope.Structure; +import org.apache.zest.api.unitofwork.UnitOfWorkFactory; +import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler; import org.junit.After; import org.junit.Before; import org.apache.zest.api.unitofwork.UnitOfWork; @@ -30,6 +33,9 @@ import org.apache.zest.spi.module.ModuleSpi; public abstract class AbstractZestTest extends AbstractZestBaseTest implements Assembler { + @Structure + protected UnitOfWorkFactory uowf; + protected ModuleSpi module; @Before @@ -52,6 +58,7 @@ public abstract class AbstractZestTest extends AbstractZestBaseTest { LayerAssembly layer = applicationAssembly.layer( "Layer 1" ); ModuleAssembly module = layer.module( "Module 1" ); + new DefaultUnitOfWorkAssembler().assemble( module ); module.objects( AbstractZestTest.this.getClass() ); assemble( module ); } @@ -61,11 +68,11 @@ public abstract class AbstractZestTest extends AbstractZestBaseTest public void tearDown() throws Exception { - if( module != null && module.isUnitOfWorkActive() ) + if( uowf != null && uowf.isUnitOfWorkActive() ) { - while( module.isUnitOfWorkActive() ) + while( uowf.isUnitOfWorkActive() ) { - UnitOfWork uow = module.currentUnitOfWork(); + UnitOfWork uow = uowf.currentUnitOfWork(); if( uow.isOpen() ) { System.err.println( "UnitOfWork not cleaned up:" + uow.usecase().name() ); http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/testsupport/src/main/java/org/apache/zest/test/cache/AbstractCachePoolTest.java ---------------------------------------------------------------------- diff --git a/core/testsupport/src/main/java/org/apache/zest/test/cache/AbstractCachePoolTest.java b/core/testsupport/src/main/java/org/apache/zest/test/cache/AbstractCachePoolTest.java index ab05212..e697375 100644 --- a/core/testsupport/src/main/java/org/apache/zest/test/cache/AbstractCachePoolTest.java +++ b/core/testsupport/src/main/java/org/apache/zest/test/cache/AbstractCachePoolTest.java @@ -121,5 +121,4 @@ public abstract class AbstractCachePoolTest cache = cachePool.fetchCache( "1", String.class ); assertNull( "Value not missing", cache.get( "Habba" ) ); } - } http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractEntityStoreTest.java ---------------------------------------------------------------------- diff --git a/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractEntityStoreTest.java b/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractEntityStoreTest.java index af74176..de6956d 100644 --- a/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractEntityStoreTest.java +++ b/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractEntityStoreTest.java @@ -155,14 +155,14 @@ public abstract class AbstractEntityStoreTest public void whenNewEntityThenCanFindEntityAndCorrectValues() throws Exception { - UnitOfWork unitOfWork = module.newUnitOfWork(); + UnitOfWork unitOfWork = uowf.newUnitOfWork(); try { TestEntity instance = createEntity( unitOfWork ); unitOfWork.complete(); // Find entity - unitOfWork = module.newUnitOfWork(); + unitOfWork = uowf.newUnitOfWork(); instance = unitOfWork.get( instance ); // Check state @@ -276,19 +276,19 @@ public abstract class AbstractEntityStoreTest public void whenRemovedEntityThenCannotFindEntity() throws Exception { - UnitOfWork unitOfWork = module.newUnitOfWork(); + UnitOfWork unitOfWork = uowf.newUnitOfWork(); TestEntity newInstance = createEntity( unitOfWork ); String identity = newInstance.identity().get(); unitOfWork.complete(); // Remove entity - unitOfWork = module.newUnitOfWork(); + unitOfWork = uowf.newUnitOfWork(); TestEntity instance = unitOfWork.get( newInstance ); unitOfWork.remove( instance ); unitOfWork.complete(); // Find entity - unitOfWork = module.newUnitOfWork(); + unitOfWork = uowf.newUnitOfWork(); try { unitOfWork.get( TestEntity.class, identity ); @@ -311,21 +311,21 @@ public abstract class AbstractEntityStoreTest TestEntity testEntity; String version; { - UnitOfWork unitOfWork = module.newUnitOfWork(); + UnitOfWork unitOfWork = uowf.newUnitOfWork(); EntityBuilder builder = unitOfWork.newEntityBuilder( TestEntity.class ); testEntity = builder.newInstance(); unitOfWork.complete(); } { - UnitOfWork unitOfWork = module.newUnitOfWork(); + UnitOfWork unitOfWork = uowf.newUnitOfWork(); testEntity = unitOfWork.get( testEntity ); version = spi.entityStateOf( testEntity ).version(); unitOfWork.complete(); } { - UnitOfWork unitOfWork = module.newUnitOfWork(); + UnitOfWork unitOfWork = uowf.newUnitOfWork(); testEntity = unitOfWork.get( testEntity ); String newVersion = spi.entityStateOf( testEntity ).version(); assertThat( "version has not changed", newVersion, equalTo( version ) ); @@ -341,14 +341,14 @@ public abstract class AbstractEntityStoreTest TestEntity testEntity; String version; { - UnitOfWork unitOfWork = module.newUnitOfWork(); + UnitOfWork unitOfWork = uowf.newUnitOfWork(); EntityBuilder builder = unitOfWork.newEntityBuilder( TestEntity.class ); testEntity = builder.newInstance(); unitOfWork.complete(); } { - UnitOfWork unitOfWork = module.newUnitOfWork(); + UnitOfWork unitOfWork = uowf.newUnitOfWork(); testEntity = unitOfWork.get( testEntity ); testEntity.name().set( "Rickard" ); version = spi.entityStateOf( testEntity ).version(); @@ -356,7 +356,7 @@ public abstract class AbstractEntityStoreTest unitOfWork.complete(); } { - UnitOfWork unitOfWork = module.newUnitOfWork(); + UnitOfWork unitOfWork = uowf.newUnitOfWork(); testEntity = unitOfWork.get( testEntity ); String newVersion = spi.entityStateOf( testEntity ).version(); assertThat( "version has changed", newVersion, not( equalTo( version ) ) ); @@ -372,14 +372,14 @@ public abstract class AbstractEntityStoreTest TestEntity testEntity; String version; { - UnitOfWork unitOfWork = module.newUnitOfWork(); + UnitOfWork unitOfWork = uowf.newUnitOfWork(); EntityBuilder builder = unitOfWork.newEntityBuilder( TestEntity.class ); testEntity = builder.newInstance(); unitOfWork.complete(); } { - UnitOfWork unitOfWork = module.newUnitOfWork(); + UnitOfWork unitOfWork = uowf.newUnitOfWork(); testEntity = unitOfWork.get( testEntity ); testEntity.manyAssociation().add( 0, testEntity ); version = spi.entityStateOf( testEntity ).version(); @@ -387,7 +387,7 @@ public abstract class AbstractEntityStoreTest unitOfWork.complete(); } { - UnitOfWork unitOfWork = module.newUnitOfWork(); + UnitOfWork unitOfWork = uowf.newUnitOfWork(); testEntity = unitOfWork.get( testEntity ); String newVersion = spi.entityStateOf( testEntity ).version(); assertThat( "version has changed", newVersion, not( equalTo( version ) ) ); @@ -402,7 +402,7 @@ public abstract class AbstractEntityStoreTest { TestEntity testEntity; { - UnitOfWork unitOfWork = module.newUnitOfWork(); + UnitOfWork unitOfWork = uowf.newUnitOfWork(); EntityBuilder builder = unitOfWork.newEntityBuilder( TestEntity.class ); testEntity = builder.newInstance(); @@ -414,7 +414,7 @@ public abstract class AbstractEntityStoreTest String version; { // Start working with Entity in one UoW - unitOfWork1 = module.newUnitOfWork(); + unitOfWork1 = uowf.newUnitOfWork(); testEntity1 = unitOfWork1.get( testEntity ); version = spi.entityStateOf( testEntity1 ).version(); if( version.isEmpty() ) @@ -427,7 +427,7 @@ public abstract class AbstractEntityStoreTest } { // Start working with same Entity in another UoW, and complete it - UnitOfWork unitOfWork = module.newUnitOfWork(); + UnitOfWork unitOfWork = uowf.newUnitOfWork(); TestEntity testEntity2 = unitOfWork.get( testEntity ); assertThat( "version is correct", spi.entityStateOf( testEntity1 ).version(), equalTo( version ) ); testEntity2.name().set( "B" ); @@ -447,7 +447,7 @@ public abstract class AbstractEntityStoreTest } { // Check values - unitOfWork1 = module.newUnitOfWork(); + unitOfWork1 = uowf.newUnitOfWork(); testEntity1 = unitOfWork1.get( testEntity ); assertThat( "property name has not been set", testEntity1.name().get(), equalTo( "B" ) ); assertThat( "version is incorrect", spi.entityStateOf( testEntity1 ).version(), @@ -460,19 +460,19 @@ public abstract class AbstractEntityStoreTest public void givenEntityStoredLoadedChangedWhenUnitOfWorkDiscardsThenDontStoreState() throws UnitOfWorkCompletionException { - UnitOfWork unitOfWork = module.newUnitOfWork(); + UnitOfWork unitOfWork = uowf.newUnitOfWork(); try { String identity = createEntity( unitOfWork ).identity().get(); unitOfWork.complete(); - unitOfWork = module.newUnitOfWork(); + unitOfWork = uowf.newUnitOfWork(); TestEntity entity = unitOfWork.get( TestEntity.class, identity ); assertThat( entity.intValue().get(), is( 42 ) ); entity.intValue().set( 23 ); unitOfWork.discard(); - unitOfWork = module.newUnitOfWork(); + unitOfWork = uowf.newUnitOfWork(); entity = unitOfWork.get( TestEntity.class, identity ); assertThat( entity.intValue().get(), is( 42 ) ); } http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractAnyQueryTest.java ---------------------------------------------------------------------- diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractAnyQueryTest.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractAnyQueryTest.java index de7676e..e9c18b5 100755 --- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractAnyQueryTest.java +++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractAnyQueryTest.java @@ -82,7 +82,7 @@ public class AbstractAnyQueryTest super.setUp(); TestData.populate( module ); - this.unitOfWork = this.module.newUnitOfWork(); + this.unitOfWork = this.module.unitOfWorkFactory().newUnitOfWork(); } http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/testsupport/src/main/java/org/apache/zest/test/indexing/TestData.java ---------------------------------------------------------------------- diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/TestData.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/TestData.java index b07055e..48cd6b5 100644 --- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/TestData.java +++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/TestData.java @@ -22,10 +22,6 @@ import java.math.BigDecimal; import java.math.BigInteger; import java.util.ArrayList; import java.util.List; -import org.apache.zest.test.indexing.model.Dog; -import org.joda.time.DateTime; -import org.joda.time.LocalDate; -import org.joda.time.LocalDateTime; import org.apache.zest.api.entity.EntityBuilder; import org.apache.zest.api.structure.Module; import org.apache.zest.api.unitofwork.UnitOfWork; @@ -42,6 +38,9 @@ import org.apache.zest.test.indexing.model.Person; import org.apache.zest.test.indexing.model.Protocol; import org.apache.zest.test.indexing.model.QueryParam; import org.apache.zest.test.indexing.model.URL; +import org.joda.time.DateTime; +import org.joda.time.LocalDate; +import org.joda.time.LocalDateTime; import static org.joda.time.DateTimeZone.UTC; @@ -53,7 +52,7 @@ public class TestData public static void populate( Module module ) throws UnitOfWorkCompletionException { - try( UnitOfWork unitOfWork = module.newUnitOfWork() ) + try (UnitOfWork unitOfWork = module.unitOfWorkFactory().newUnitOfWork()) { NameableAssert.clear(); Domain gaming; @@ -240,12 +239,6 @@ public class TestData felix.name().set( "Felix" ); catBuilder.newInstance(); } - { - EntityBuilder builder = unitOfWork.newEntityBuilder( Dog.class ); - Dog snoopy = builder.instance(); - snoopy.name().set( "Snoopy" ); - builder.newInstance(); - } unitOfWork.complete(); } } http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/AccountModule.java ---------------------------------------------------------------------- diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/AccountModule.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/AccountModule.java index d398e6f..567056a 100644 --- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/AccountModule.java +++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/AccountModule.java @@ -43,6 +43,7 @@ class AccountModule public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module ) throws AssemblyException { + module.withDefaultUnitOfWorkFactory(); module.entities( Account.class, Domain.class ).visibleIn( Visibility.layer ); module.values( File.class, Host.class, Port.class, Protocol.class, QueryParam.class, URL.class ) .visibleIn( Visibility.layer ); http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/ConfigModule.java ---------------------------------------------------------------------- diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/ConfigModule.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/ConfigModule.java index ecd4939..66cc1c2 100644 --- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/ConfigModule.java +++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/ConfigModule.java @@ -35,6 +35,7 @@ class ConfigModule public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module ) throws AssemblyException { + module.withDefaultUnitOfWorkFactory(); module.services( MemoryEntityStoreService.class ).visibleIn( Visibility.application ); return module; } http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/FamilyModule.java ---------------------------------------------------------------------- diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/FamilyModule.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/FamilyModule.java index 9e24b3f..74562bf 100644 --- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/FamilyModule.java +++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/FamilyModule.java @@ -41,6 +41,7 @@ class FamilyModule public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module ) throws AssemblyException { + module.withDefaultUnitOfWorkFactory(); module.entities( Male.class, Female.class, City.class, http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/PersistenceModule.java ---------------------------------------------------------------------- diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/PersistenceModule.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/PersistenceModule.java index b6ae1e7..b6f785a 100644 --- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/PersistenceModule.java +++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/PersistenceModule.java @@ -37,6 +37,7 @@ class PersistenceModule public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module ) throws AssemblyException { + module.withDefaultUnitOfWorkFactory(); module.services( OrgJsonValueSerializationService.class ).taggedWith( ValueSerialization.Formats.JSON ); module.services( MemoryEntityStoreService.class ).visibleIn( Visibility.application ); return module; http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestExecutionModule.java ---------------------------------------------------------------------- diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestExecutionModule.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestExecutionModule.java index bf3fe2b..a21b168 100644 --- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestExecutionModule.java +++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestExecutionModule.java @@ -40,6 +40,7 @@ public class TestExecutionModule public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module ) throws AssemblyException { + module.withDefaultUnitOfWorkFactory(); module.objects( testClass ).visibleIn( Visibility.layer ); return module; } http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite1Module.java ---------------------------------------------------------------------- diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite1Module.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite1Module.java index efcb64b..bd7b015 100644 --- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite1Module.java +++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite1Module.java @@ -37,6 +37,7 @@ class TestSuite1Module public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module ) throws AssemblyException { + module.withDefaultUnitOfWorkFactory(); declareTestCase( module, Suite1Case1.class ); declareTestCase( module, Suite1Case2.class ); return module; http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite2Module.java ---------------------------------------------------------------------- diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite2Module.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite2Module.java index ac3f655..b7560b6 100644 --- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite2Module.java +++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite2Module.java @@ -33,6 +33,7 @@ class TestSuite2Module public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module ) throws AssemblyException { + module.withDefaultUnitOfWorkFactory(); return module; } } http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite3Module.java ---------------------------------------------------------------------- diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite3Module.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite3Module.java index f93ddf7..163cbbb 100644 --- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite3Module.java +++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/layered/assembly/TestSuite3Module.java @@ -33,6 +33,7 @@ class TestSuite3Module public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module ) throws AssemblyException { + module.withDefaultUnitOfWorkFactory(); return module; } } http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractValueCompositeSerializationTest.java ---------------------------------------------------------------------- diff --git a/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractValueCompositeSerializationTest.java b/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractValueCompositeSerializationTest.java index 4920ebd..7ff7406 100644 --- a/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractValueCompositeSerializationTest.java +++ b/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractValueCompositeSerializationTest.java @@ -92,7 +92,7 @@ public abstract class AbstractValueCompositeSerializationTest public void givenValueCompositeWhenSerializingAndDeserializingExpectEquals() throws Exception { - UnitOfWork uow = module.newUnitOfWork(); + UnitOfWork uow = uowf.newUnitOfWork(); try { SomeValue some = buildSomeValue(); @@ -214,7 +214,7 @@ public abstract class AbstractValueCompositeSerializationTest private BarEntity buildBarEntity( String cathedral ) { - EntityBuilder barBuilder = module.currentUnitOfWork().newEntityBuilder( BarEntity.class ); + EntityBuilder barBuilder = uowf.currentUnitOfWork().newEntityBuilder( BarEntity.class ); barBuilder.instance().cathedral().set( cathedral ); return barBuilder.newInstance(); } http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/entitystore-preferences/src/main/java/org/apache/zest/entitystore/prefs/PreferencesEntityStoreMixin.java ---------------------------------------------------------------------- diff --git a/extensions/entitystore-preferences/src/main/java/org/apache/zest/entitystore/prefs/PreferencesEntityStoreMixin.java b/extensions/entitystore-preferences/src/main/java/org/apache/zest/entitystore/prefs/PreferencesEntityStoreMixin.java index 2c833e0..f34fdd4 100755 --- a/extensions/entitystore-preferences/src/main/java/org/apache/zest/entitystore/prefs/PreferencesEntityStoreMixin.java +++ b/extensions/entitystore-preferences/src/main/java/org/apache/zest/entitystore/prefs/PreferencesEntityStoreMixin.java @@ -67,7 +67,7 @@ import org.apache.zest.spi.entitystore.EntityStoreSPI; import org.apache.zest.spi.entitystore.EntityStoreUnitOfWork; import org.apache.zest.spi.entitystore.StateCommitter; import org.apache.zest.spi.entitystore.helpers.DefaultEntityState; -import org.apache.zest.spi.module.ModelModule; +import org.apache.zest.spi.structure.ModelModule; import org.apache.zest.spi.module.ModuleSpi; import org.slf4j.Logger; import org.slf4j.LoggerFactory; http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/SQLEntityStoreMixin.java ---------------------------------------------------------------------- diff --git a/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/SQLEntityStoreMixin.java b/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/SQLEntityStoreMixin.java index cd8faec..95ce3fe 100755 --- a/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/SQLEntityStoreMixin.java +++ b/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/SQLEntityStoreMixin.java @@ -68,7 +68,7 @@ import org.apache.zest.spi.entitystore.helpers.DefaultEntityState; import org.apache.zest.spi.entitystore.helpers.JSONKeys; import org.apache.zest.spi.entitystore.helpers.Migration; import org.apache.zest.spi.entitystore.helpers.StateStore; -import org.apache.zest.spi.module.ModelModule; +import org.apache.zest.spi.structure.ModelModule; import org.apache.zest.spi.module.ModuleSpi; import org.json.JSONArray; import org.json.JSONException; http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/DerbySQLEntityStoreTest.java ---------------------------------------------------------------------- diff --git a/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/DerbySQLEntityStoreTest.java b/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/DerbySQLEntityStoreTest.java index c47bb9e..c33ddd0 100644 --- a/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/DerbySQLEntityStoreTest.java +++ b/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/DerbySQLEntityStoreTest.java @@ -75,7 +75,7 @@ public class DerbySQLEntityStoreTest public void tearDown() throws Exception { - UnitOfWork uow = this.module.newUnitOfWork( UsecaseBuilder.newUsecase( + UnitOfWork uow = this.uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Delete " + getClass().getSimpleName() + " test data" ) ); try { http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/MySQLEntityStoreTest.java ---------------------------------------------------------------------- diff --git a/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/MySQLEntityStoreTest.java b/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/MySQLEntityStoreTest.java index 7788b71..cb263ec 100644 --- a/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/MySQLEntityStoreTest.java +++ b/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/MySQLEntityStoreTest.java @@ -86,7 +86,7 @@ public class MySQLEntityStoreTest { return; } - UnitOfWork uow = this.module.newUnitOfWork( + UnitOfWork uow = this.uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Delete " + getClass().getSimpleName() + " test data" ) ); try http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/PostgreSQLEntityStoreTest.java ---------------------------------------------------------------------- diff --git a/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/PostgreSQLEntityStoreTest.java b/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/PostgreSQLEntityStoreTest.java index 27e93f5..5504e36 100644 --- a/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/PostgreSQLEntityStoreTest.java +++ b/extensions/entitystore-sql/src/test/java/org/apache/zest/entitystore/sql/PostgreSQLEntityStoreTest.java @@ -112,7 +112,7 @@ public class PostgreSQLEntityStoreTest public void tearDown() throws Exception { - UnitOfWork uow = module.newUnitOfWork( + UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Delete " + getClass().getSimpleName() + " test data" ) ); try http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchQueryMultimoduleTest.java ---------------------------------------------------------------------- diff --git a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchQueryMultimoduleTest.java b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchQueryMultimoduleTest.java index 6e50400..edd2652 100755 --- a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchQueryMultimoduleTest.java +++ b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchQueryMultimoduleTest.java @@ -25,6 +25,7 @@ import org.apache.zest.api.common.Visibility; import org.apache.zest.bootstrap.AssemblyException; import org.apache.zest.bootstrap.LayerAssembly; import org.apache.zest.bootstrap.ModuleAssembly; +import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler; import org.apache.zest.index.elasticsearch.assembly.ESFilesystemIndexQueryAssembler; import org.apache.zest.library.fileconfig.FileConfigurationOverride; import org.apache.zest.library.fileconfig.FileConfigurationService; @@ -46,6 +47,7 @@ public class ElasticSearchQueryMultimoduleTest extends ElasticSearchQueryTest module = module.layer().module( "module2" ); new EntityTestAssembler().visibleIn( Visibility.layer ).assemble( module ); + new DefaultUnitOfWorkAssembler().assemble( module ); // Config module LayerAssembly configLayer = module.layer().application().layer( "config" ); http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchTest.java ---------------------------------------------------------------------- diff --git a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchTest.java b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchTest.java index f5efe83..6bf8c83 100644 --- a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchTest.java +++ b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchTest.java @@ -159,7 +159,7 @@ public class ElasticSearchTest { String title = "Foo Bar Bazar!"; - UnitOfWork uow = module.newUnitOfWork(); + UnitOfWork uow = uowf.newUnitOfWork(); EntityBuilder authorBuilder = uow.newEntityBuilder( Author.class ); Author author = authorBuilder.instance(); @@ -199,7 +199,7 @@ public class ElasticSearchTest uow.complete(); - uow = module.newUnitOfWork(); + uow = uowf.newUnitOfWork(); QueryBuilder queryBuilder = module.newQueryBuilder( Post.class ); Query query = uow.newQuery( queryBuilder ); http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ImmenseTermTest.java ---------------------------------------------------------------------- diff --git a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ImmenseTermTest.java b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ImmenseTermTest.java index 9947de2..b6b41f1 100644 --- a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ImmenseTermTest.java +++ b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ImmenseTermTest.java @@ -117,18 +117,18 @@ public class ImmenseTermTest { long count = 10_000L; TestEntity testEntity; - try( UnitOfWork uow = module.newUnitOfWork() ) + try( UnitOfWork uow = uowf.newUnitOfWork() ) { testEntity = uow.newEntity( TestEntity.class ); for( long i = 0; i < count; i++ ) { - TestEntity2 testEntity2 = module.currentUnitOfWork().newEntity( TestEntity2.class ); + TestEntity2 testEntity2 = uowf.currentUnitOfWork().newEntity( TestEntity2.class ); testEntity2.property().set( "test" ); testEntity.manyAssociation().add( testEntity2 ); } uow.complete(); } - try( UnitOfWork uow = module.newUnitOfWork() ) + try( UnitOfWork uow = uowf.newUnitOfWork() ) { testEntity = uow.get( testEntity ); Query query = uow.newQuery( http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/ContainsAllTest.java ---------------------------------------------------------------------- diff --git a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/ContainsAllTest.java b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/ContainsAllTest.java index 5a166c8..c0092a1 100644 --- a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/ContainsAllTest.java +++ b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/ContainsAllTest.java @@ -312,7 +312,7 @@ public class ContainsAllTest builder = builder.where( QueryExpressions.containsAll( QueryExpressions.templateFor( ExampleEntity.class ).strings(), Iterables.iterable( strings ) ) ); - return this.module.currentUnitOfWork().newQuery( builder ).find(); + return this.uowf.currentUnitOfWork().newQuery( builder ).find(); } private ExampleEntity findEntityBasedOnValueStrings( String... valueStrings ) @@ -340,18 +340,18 @@ public class ContainsAllTest ) ); - return this.module.currentUnitOfWork().newQuery( builder ); + return this.uowf.currentUnitOfWork().newQuery( builder ); } private ExampleEntity performContainsAllStringsTest( Set entityStrings, Set queryableStrings ) throws Exception { - UnitOfWork creatingUOW = this.module.newUnitOfWork(); + UnitOfWork creatingUOW = this.uowf.newUnitOfWork(); String[] entityStringsArray = new String[entityStrings.size()]; createEntityWithStrings( creatingUOW, this.module, entityStrings.toArray( entityStringsArray ) ); creatingUOW.complete(); - UnitOfWork queryingUOW = this.module.newUnitOfWork(); + UnitOfWork queryingUOW = this.uowf.newUnitOfWork(); try { String[] queryableStringsArray = new String[queryableStrings.size()]; @@ -367,12 +367,12 @@ public class ContainsAllTest private ExampleEntity performContainsAllStringValueTest( Set entityStrings, Set queryableStrings ) throws Exception { - UnitOfWork creatingUOW = this.module.newUnitOfWork(); + UnitOfWork creatingUOW = this.uowf.newUnitOfWork(); String[] entityStringsArray = new String[entityStrings.size()]; createEntityWithComplexValues( creatingUOW, this.module, entityStrings.toArray( entityStringsArray ) ); creatingUOW.complete(); - UnitOfWork queryingUOW = this.module.newUnitOfWork(); + UnitOfWork queryingUOW = this.uowf.newUnitOfWork(); try { String[] queryableStringsArray = new String[queryableStrings.size()]; http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/ContainsTest.java ---------------------------------------------------------------------- diff --git a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/ContainsTest.java b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/ContainsTest.java index 3d0ab4a..9fd4e54 100644 --- a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/ContainsTest.java +++ b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/ContainsTest.java @@ -143,7 +143,7 @@ public class ContainsTest extends AbstractZestTest string ) ); - return this.module.currentUnitOfWork().newQuery( builder ).find(); + return this.uowf.currentUnitOfWork().newQuery( builder ).find(); } @@ -167,17 +167,17 @@ public class ContainsTest extends AbstractZestTest ) ); - return this.module.currentUnitOfWork().newQuery( builder); + return this.uowf.currentUnitOfWork().newQuery( builder); } private ExampleEntity performContainsStringTest(Set entityStrings, String queryableString) throws Exception { - UnitOfWork creatingUOW = this.module.newUnitOfWork(); + UnitOfWork creatingUOW = this.uowf.newUnitOfWork(); String[] entityStringsArray = new String[entityStrings.size()]; ContainsAllTest.createEntityWithStrings(creatingUOW, this.module, entityStrings.toArray(entityStringsArray)); creatingUOW.complete(); - UnitOfWork queryingUOW = this.module.newUnitOfWork(); + UnitOfWork queryingUOW = this.uowf.newUnitOfWork(); try { ExampleEntity entity = this.findEntity(queryableString); @@ -191,12 +191,12 @@ public class ContainsTest extends AbstractZestTest private ExampleEntity performContainsStringValueTest(Set entityStrings, String queryableString) throws Exception { - UnitOfWork creatingUOW = this.module.newUnitOfWork(); + UnitOfWork creatingUOW = this.uowf.newUnitOfWork(); String[] entityStringsArray = new String[entityStrings.size()]; ContainsAllTest.createEntityWithComplexValues(creatingUOW, this.module, entityStrings.toArray(entityStringsArray)); creatingUOW.complete(); - UnitOfWork queryingUOW = this.module.newUnitOfWork(); + UnitOfWork queryingUOW = this.uowf.newUnitOfWork(); try { ExampleEntity entity = this.findEntityBasedOnValueString(queryableString); http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/MultiLayeredTest.java ---------------------------------------------------------------------- diff --git a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/MultiLayeredTest.java b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/MultiLayeredTest.java index 7923b75..cd8aeae 100644 --- a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/MultiLayeredTest.java +++ b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/MultiLayeredTest.java @@ -42,7 +42,8 @@ public class MultiLayeredTest extends AbstractMultiLayeredIndexingTest public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module ) throws AssemblyException { - new RdfMemoryStoreAssembler( Visibility.layer, Visibility.module ).assemble( module ); + module.withDefaultUnitOfWorkFactory(); + new RdfMemoryStoreAssembler( Visibility.application, Visibility.module ).assemble( module ); return module; } } http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RDFPerformanceTest.java ---------------------------------------------------------------------- diff --git a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RDFPerformanceTest.java b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RDFPerformanceTest.java index f051935..c005360 100644 --- a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RDFPerformanceTest.java +++ b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RDFPerformanceTest.java @@ -89,7 +89,7 @@ public class RDFPerformanceTest extends AbstractZestTest List entities = new ArrayList(); for (Integer x = 0; x < howMany; ++x) { - ExampleEntity exampleEntity = this.module.currentUnitOfWork().newEntity( ExampleEntity.class, "entity" + x ); + ExampleEntity exampleEntity = this.uowf.currentUnitOfWork().newEntity( ExampleEntity.class, "entity" + x ); for (ExampleEntity entity : entities) { @@ -110,14 +110,14 @@ public class RDFPerformanceTest extends AbstractZestTest { for (ExampleEntity entity : entities) { - this.module.currentUnitOfWork().remove( this.module.currentUnitOfWork().get( entity ) ); + this.uowf.currentUnitOfWork().remove( this.uowf.currentUnitOfWork().get( entity ) ); } } private List doList( int howMany ) { List list = new ArrayList(); - UnitOfWork uow = this.module.newUnitOfWork(); + UnitOfWork uow = this.uowf.newUnitOfWork(); Iterator iter = uow.newQuery( this.module.newQueryBuilder( ExampleEntity.class ) ).iterator(); int found = 0; while (iter.hasNext()) @@ -141,11 +141,11 @@ public class RDFPerformanceTest extends AbstractZestTest private void doRemove( int howMany ) { - Iterator iter = this.module.currentUnitOfWork().newQuery( this.module.newQueryBuilder( ExampleEntity.class )).maxResults( howMany ).iterator(); + Iterator iter = this.uowf.currentUnitOfWork().newQuery( this.module.newQueryBuilder( ExampleEntity.class )).maxResults( howMany ).iterator(); Integer removed = 0; while (iter.hasNext()) { - this.module.currentUnitOfWork().remove( iter.next() ); + this.uowf.currentUnitOfWork().remove( iter.next() ); ++removed; } @@ -159,7 +159,7 @@ public class RDFPerformanceTest extends AbstractZestTest { long startTest = System.currentTimeMillis(); - UnitOfWork creatingUOW = this.module.newUnitOfWork(); + UnitOfWork creatingUOW = this.uowf.newUnitOfWork(); Long startingTime = System.currentTimeMillis(); List entities = this.doCreate( howMany ); LOG.info( "Time to create " + howMany + " entities (ms): " + (System.currentTimeMillis() - startingTime) ); @@ -172,7 +172,7 @@ public class RDFPerformanceTest extends AbstractZestTest List entityList = this.doList( howMany ); startingTime = System.currentTimeMillis(); - UnitOfWork uow = this.module.newUnitOfWork(); + UnitOfWork uow = this.uowf.newUnitOfWork(); for (int i = 0; i < 1000; i++) { Query query = uow.newQuery( this.module.newQueryBuilder( ExampleEntity.class ). @@ -183,7 +183,7 @@ public class RDFPerformanceTest extends AbstractZestTest long endTest = System.currentTimeMillis(); LOG.info( "Time to query " + howMany + " entities (ms): " + (endTest - startingTime) ); - UnitOfWork deletingUOW = this.module.newUnitOfWork(); + UnitOfWork deletingUOW = this.uowf.newUnitOfWork(); startingTime = System.currentTimeMillis(); this.doRemoveAll( entityList ); // this.doRemove(200); http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RdfNamedQueryMultimoduleTest.java ---------------------------------------------------------------------- diff --git a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RdfNamedQueryMultimoduleTest.java b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RdfNamedQueryMultimoduleTest.java index d0b1d19..e1434f9 100755 --- a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RdfNamedQueryMultimoduleTest.java +++ b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RdfNamedQueryMultimoduleTest.java @@ -24,6 +24,7 @@ import org.apache.zest.api.common.Visibility; import org.apache.zest.bootstrap.AssemblyException; import org.apache.zest.bootstrap.LayerAssembly; import org.apache.zest.bootstrap.ModuleAssembly; +import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler; import org.apache.zest.index.rdf.assembly.RdfMemoryStoreAssembler; import org.apache.zest.test.EntityTestAssembler; @@ -39,10 +40,12 @@ public class RdfNamedQueryMultimoduleTest assembleValues( module, Visibility.module ); ModuleAssembly storeModule = layer.module( "store" ); + new DefaultUnitOfWorkAssembler().assemble( storeModule ); new EntityTestAssembler().visibleIn( Visibility.layer ).assemble( storeModule ); assembleValues( storeModule, Visibility.module ); ModuleAssembly indexModule = layer.module( "index" ); + new DefaultUnitOfWorkAssembler().assemble( indexModule ); new RdfMemoryStoreAssembler( Visibility.layer, Visibility.module ).assemble( indexModule ); } http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RdfQueryMultimoduleTest.java ---------------------------------------------------------------------- diff --git a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RdfQueryMultimoduleTest.java b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RdfQueryMultimoduleTest.java index d25f79a..390818e 100755 --- a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RdfQueryMultimoduleTest.java +++ b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RdfQueryMultimoduleTest.java @@ -25,6 +25,7 @@ import org.apache.zest.api.common.Visibility; import org.apache.zest.bootstrap.AssemblyException; import org.apache.zest.bootstrap.LayerAssembly; import org.apache.zest.bootstrap.ModuleAssembly; +import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler; import org.apache.zest.index.rdf.assembly.RdfNativeSesameStoreAssembler; import org.apache.zest.library.rdf.repository.NativeConfiguration; import org.apache.zest.test.EntityTestAssembler; @@ -49,9 +50,11 @@ public class RdfQueryMultimoduleTest ModuleAssembly storeModule = layer.module( "store" ); new EntityTestAssembler().visibleIn( Visibility.layer ).assemble( storeModule ); assembleValues( storeModule, Visibility.module ); + new DefaultUnitOfWorkAssembler().assemble( storeModule ); ModuleAssembly indexModule = layer.module( "index" ); new RdfNativeSesameStoreAssembler( Visibility.layer, Visibility.module ).assemble( indexModule ); + new DefaultUnitOfWorkAssembler().assemble( indexModule ); LayerAssembly configLayer = module.layer().application().layer( "config" ); module.layer().uses( configLayer ); @@ -59,6 +62,7 @@ public class RdfQueryMultimoduleTest config.entities( NativeConfiguration.class ).visibleIn( Visibility.application ); config.forMixin( NativeConfiguration.class ).declareDefaults().dataDirectory().set( DATA_DIR.getAbsolutePath() ); new EntityTestAssembler().assemble( config ); + new DefaultUnitOfWorkAssembler().assemble( config ); } } http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RdfQueryTest.java ---------------------------------------------------------------------- diff --git a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RdfQueryTest.java b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RdfQueryTest.java index 867a3a4..4469b75 100755 --- a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RdfQueryTest.java +++ b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RdfQueryTest.java @@ -22,6 +22,7 @@ import java.io.File; import org.apache.zest.api.common.Visibility; import org.apache.zest.bootstrap.AssemblyException; import org.apache.zest.bootstrap.ModuleAssembly; +import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler; import org.apache.zest.index.rdf.assembly.RdfNativeSesameStoreAssembler; import org.apache.zest.library.rdf.repository.NativeConfiguration; import org.apache.zest.spi.query.EntityFinderException; @@ -51,6 +52,7 @@ public class RdfQueryTest config.entities( NativeConfiguration.class ).visibleIn( Visibility.layer ); config.forMixin( NativeConfiguration.class ).declareDefaults().dataDirectory().set( DATA_DIR.getAbsolutePath() ); new EntityTestAssembler().assemble( config ); + new DefaultUnitOfWorkAssembler().assemble( config ); } @Test http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi173/Qi173IssueTest.java ---------------------------------------------------------------------- diff --git a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi173/Qi173IssueTest.java b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi173/Qi173IssueTest.java index 009a5cd..1d83240 100644 --- a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi173/Qi173IssueTest.java +++ b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi173/Qi173IssueTest.java @@ -52,7 +52,7 @@ public class Qi173IssueTest @Test public void testPersistence() { - UnitOfWork uow = module.newUnitOfWork(); + UnitOfWork uow = uowf.newUnitOfWork(); try { createCar( "Volvo", "S80", 2007 ); @@ -73,7 +73,7 @@ public class Qi173IssueTest e.printStackTrace(); } - uow = module.newUnitOfWork(); + uow = uowf.newUnitOfWork(); QueryBuilder qb = module.newQueryBuilder( Car.class ); Car template = QueryExpressions.templateFor( Car.class ); qb = qb.where( QueryExpressions.eq( template.year(), 2007 ) ); @@ -104,7 +104,7 @@ public class Qi173IssueTest private String createCar( String manufacturer, String model, int year ) { - UnitOfWork uow = module.currentUnitOfWork(); + UnitOfWork uow = uowf.currentUnitOfWork(); EntityBuilder builder = uow.newEntityBuilder( Car.class ); Car prototype = builder.instanceFor( Car.class ); prototype.manufacturer().set( manufacturer ); http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/AbstractIssueTest.java ---------------------------------------------------------------------- diff --git a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/AbstractIssueTest.java b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/AbstractIssueTest.java index f09d95c..b9402ec 100644 --- a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/AbstractIssueTest.java +++ b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/AbstractIssueTest.java @@ -41,7 +41,7 @@ public abstract class AbstractIssueTest protected final String newZestAccount() throws UnitOfWorkCompletionException { - UnitOfWork work = module.newUnitOfWork(); + UnitOfWork work = uowf.newUnitOfWork(); EntityBuilder entityBuilder = work.newEntityBuilder( AccountComposite.class ); AccountComposite accountComposite = entityBuilder.instance(); accountComposite.name().set( DEFAULT_ACCOUNT_NAME ); http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationMandatory/IssueTest.java ---------------------------------------------------------------------- diff --git a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationMandatory/IssueTest.java b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationMandatory/IssueTest.java index f39421d..ed7c460 100644 --- a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationMandatory/IssueTest.java +++ b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationMandatory/IssueTest.java @@ -53,7 +53,7 @@ public final class IssueTest String id = newZestAccount(); // Make sure there's no unit of work - assertNull( module.currentUnitOfWork() ); + assertNull( uowf.currentUnitOfWork() ); accountService.getAccountById( id ); } @@ -66,14 +66,14 @@ public final class IssueTest String id = newZestAccount(); // Make sure there's no unit of work - assertFalse( module.isUnitOfWorkActive() ); + assertFalse( uowf.isUnitOfWorkActive() ); - UnitOfWork parentUnitOfWork = module.newUnitOfWork(); + UnitOfWork parentUnitOfWork = uowf.newUnitOfWork(); AccountComposite account = accountService.getAccountById( id ); assertNotNull( account ); - UnitOfWork currentUnitOfWork = module.currentUnitOfWork(); + UnitOfWork currentUnitOfWork = uowf.currentUnitOfWork(); assertEquals( parentUnitOfWork, currentUnitOfWork ); assertTrue( currentUnitOfWork.isOpen() ); http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationRequired/IssueTest.java ---------------------------------------------------------------------- diff --git a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationRequired/IssueTest.java b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationRequired/IssueTest.java index 40f692a..23a1d8b 100644 --- a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationRequired/IssueTest.java +++ b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationRequired/IssueTest.java @@ -49,12 +49,12 @@ public final class IssueTest String id = newZestAccount(); // Make sure there's no unit of work - assertFalse( module.isUnitOfWorkActive() ); + assertFalse( uowf.isUnitOfWorkActive() ); AccountComposite account = accountService.getAccountById( id ); assertNotNull( account ); - assertFalse( module.isUnitOfWorkActive() ); + assertFalse( uowf.isUnitOfWorkActive() ); } @Test @@ -65,14 +65,14 @@ public final class IssueTest String id = newZestAccount(); // Make sure there's no unit of work - assertFalse( module.isUnitOfWorkActive() ); + assertFalse( uowf.isUnitOfWorkActive() ); - UnitOfWork parentUnitOfWork = module.newUnitOfWork(); + UnitOfWork parentUnitOfWork = uowf.newUnitOfWork(); AccountComposite account = accountService.getAccountById( id ); assertNotNull( account ); - UnitOfWork currentUnitOfWork = module.currentUnitOfWork(); + UnitOfWork currentUnitOfWork = uowf.currentUnitOfWork(); assertEquals( parentUnitOfWork, currentUnitOfWork ); assertTrue( currentUnitOfWork.isOpen() ); http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationRequiresNew/IssueTest.java ---------------------------------------------------------------------- diff --git a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationRequiresNew/IssueTest.java b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationRequiresNew/IssueTest.java index 18dc869..1675973 100644 --- a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationRequiresNew/IssueTest.java +++ b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi64/withPropagationRequiresNew/IssueTest.java @@ -49,12 +49,12 @@ public class IssueTest String id = newZestAccount(); // Make sure there's no unit of work - assertFalse( module.isUnitOfWorkActive() ); + assertFalse( uowf.isUnitOfWorkActive() ); AccountComposite account = accountService.getAccountById( id ); assertNotNull( account ); - assertFalse( module.isUnitOfWorkActive() ); + assertFalse( uowf.isUnitOfWorkActive() ); } @Test @@ -65,14 +65,14 @@ public class IssueTest String id = newZestAccount(); // Make sure there's no unit of work - assertFalse( module.isUnitOfWorkActive() ); + assertFalse( uowf.isUnitOfWorkActive() ); - UnitOfWork parentUnitOfWork = module.newUnitOfWork(); + UnitOfWork parentUnitOfWork = uowf.newUnitOfWork(); AccountComposite account = accountService.getAccountById( id ); assertNotNull( account ); - UnitOfWork currentUnitOfWork = module.currentUnitOfWork(); + UnitOfWork currentUnitOfWork = uowf.currentUnitOfWork(); assertEquals( parentUnitOfWork, currentUnitOfWork ); assertTrue( currentUnitOfWork.isOpen() ); http://git-wip-us.apache.org/repos/asf/zest-java/blob/a5be013f/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi66/Qi66IssueTest.java ---------------------------------------------------------------------- diff --git a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi66/Qi66IssueTest.java b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi66/Qi66IssueTest.java index f655b32..6904c24 100644 --- a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi66/Qi66IssueTest.java +++ b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/qi66/Qi66IssueTest.java @@ -49,7 +49,7 @@ public class Qi66IssueTest { String accountIdentity = newZestAccount(); - UnitOfWork work = module.newUnitOfWork(); + UnitOfWork work = uowf.newUnitOfWork(); AccountComposite account = work.get( AccountComposite.class, accountIdentity ); assertNotNull( account ); @@ -74,7 +74,7 @@ public class Qi66IssueTest private String newZestAccount() throws UnitOfWorkCompletionException { - UnitOfWork work = module.newUnitOfWork(); + UnitOfWork work = uowf.newUnitOfWork(); EntityBuilder entityBuilder = work.newEntityBuilder( AccountComposite.class ); AccountComposite accountComposite = entityBuilder.instance(); accountComposite.name().set( ACCOUNT_NAME );