POLYGENE-260 - Fixed the "duplicate should be allowed" for ManyAssociations.
POLYGENE-261 - Documentation of "No order is defined" for NamedAssociation
Changed StringIdentity creation to use static factory method, and changing the name from "fromString" to "identityOf"
Signed-off-by: niclas <niclas@hedhman.org>
diff --git a/core/api/src/main/java/org/apache/polygene/api/association/ManyAssociation.java b/core/api/src/main/java/org/apache/polygene/api/association/ManyAssociation.java
index 2471b94..98f7fcf 100644
--- a/core/api/src/main/java/org/apache/polygene/api/association/ManyAssociation.java
+++ b/core/api/src/main/java/org/apache/polygene/api/association/ManyAssociation.java
@@ -28,6 +28,11 @@
/**
* Association to a collection of entities.
+ *
+ * <p>
+ * Duplication of entities (defined as Identity equality) is allowed and for each add, there will be
+ * an additional item in the collection/iterator. If de-duplication is requested, see {@link #toSet()} method.
+ * </p>
*/
public interface ManyAssociation<T> extends Iterable<T>, AbstractAssociation
{
diff --git a/core/api/src/main/java/org/apache/polygene/api/association/NamedAssociation.java b/core/api/src/main/java/org/apache/polygene/api/association/NamedAssociation.java
index b8a62da..8597ba0 100644
--- a/core/api/src/main/java/org/apache/polygene/api/association/NamedAssociation.java
+++ b/core/api/src/main/java/org/apache/polygene/api/association/NamedAssociation.java
@@ -24,8 +24,15 @@
import org.apache.polygene.api.entity.EntityReference;
/**
- * Association to named Entities.
- * The Iterable<String> returns the names in the association set.
+ * Named Association to Entities.
+ * <p>
+ * This works similar to a Map with a String key.
+ * </p>
+ * <p>
+ * The Iterable<String> returns the names in the association set. The order during iteration is random by
+ * definition, even if other behaviors can possibly be observed. The depends on the underlying entity store
+ * implementation.
+ * </p>
* @param <T> Parameterized associatee type
*/
public interface NamedAssociation<T>
@@ -47,7 +54,7 @@
* Adds a named association.
* @param name The name of the association.
* @param entity The entity for this named association.
- * @return true if putted, false otherwise
+ * @return true if value has been updated to a new value.
*/
boolean put( String name, T entity );
diff --git a/core/api/src/main/java/org/apache/polygene/api/entity/EntityReference.java b/core/api/src/main/java/org/apache/polygene/api/entity/EntityReference.java
index 68e2232..c2a7327 100644
--- a/core/api/src/main/java/org/apache/polygene/api/entity/EntityReference.java
+++ b/core/api/src/main/java/org/apache/polygene/api/entity/EntityReference.java
@@ -41,7 +41,7 @@
public static EntityReference parseEntityReference(String identityString)
{
Objects.requireNonNull( identityString, "identityString must not be null" );
- return new EntityReference( StringIdentity.identity( identityString ) );
+ return new EntityReference( StringIdentity.identityOf( identityString ) );
}
/**
diff --git a/core/api/src/main/java/org/apache/polygene/api/identity/StringIdentity.java b/core/api/src/main/java/org/apache/polygene/api/identity/StringIdentity.java
index 3eba611..faacf25 100644
--- a/core/api/src/main/java/org/apache/polygene/api/identity/StringIdentity.java
+++ b/core/api/src/main/java/org/apache/polygene/api/identity/StringIdentity.java
@@ -55,7 +55,7 @@
return value;
}
- public static Identity identity( String serializedState )
+ public static Identity identityOf( String serializedState )
{
return new StringIdentity( serializedState );
}
diff --git a/core/api/src/main/java/org/apache/polygene/api/identity/UuidGeneratorMixin.java b/core/api/src/main/java/org/apache/polygene/api/identity/UuidGeneratorMixin.java
index 6f85ca7..6e71bac 100644
--- a/core/api/src/main/java/org/apache/polygene/api/identity/UuidGeneratorMixin.java
+++ b/core/api/src/main/java/org/apache/polygene/api/identity/UuidGeneratorMixin.java
@@ -27,6 +27,6 @@
@Override
public Identity generate(Class<?> compositeType)
{
- return StringIdentity.identity( UUID.randomUUID().toString() );
+ return StringIdentity.identityOf( UUID.randomUUID().toString() );
}
}
diff --git a/core/api/src/test/java/org/apache/polygene/api/OperatorsTest.java b/core/api/src/test/java/org/apache/polygene/api/OperatorsTest.java
index f018907..9f3be8e 100644
--- a/core/api/src/test/java/org/apache/polygene/api/OperatorsTest.java
+++ b/core/api/src/test/java/org/apache/polygene/api/OperatorsTest.java
@@ -63,7 +63,7 @@
try
{
- EntityBuilder<TestEntity> entityBuilder = uow.newEntityBuilder( TestEntity.class, StringIdentity.identity( "123" ) );
+ EntityBuilder<TestEntity> entityBuilder = uow.newEntityBuilder( TestEntity.class, StringIdentity.identityOf( "123" ) );
entityBuilder.instance().value().set( assembler.module().newValue( TestValue.class ) );
TestEntity testEntity = entityBuilder.newInstance();
diff --git a/core/api/src/test/java/org/apache/polygene/api/type/ValueTypeFactoryTest.java b/core/api/src/test/java/org/apache/polygene/api/type/ValueTypeFactoryTest.java
index 48ac6a5..95d328a 100644
--- a/core/api/src/test/java/org/apache/polygene/api/type/ValueTypeFactoryTest.java
+++ b/core/api/src/test/java/org/apache/polygene/api/type/ValueTypeFactoryTest.java
@@ -125,7 +125,7 @@
try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork() )
{
assertThat(
- valueTypeFactory.valueTypeOf( module, uow.newEntity( SomeState.class, StringIdentity.identity( "abc" ) ) ),
+ valueTypeFactory.valueTypeOf( module, uow.newEntity( SomeState.class, StringIdentity.identityOf( "abc" ) ) ),
instanceOf( EntityCompositeType.class ) );
}
}
diff --git a/core/api/src/test/java/org/apache/polygene/api/unitofwork/RemovalTest.java b/core/api/src/test/java/org/apache/polygene/api/unitofwork/RemovalTest.java
index f3a01d9..c401167 100644
--- a/core/api/src/test/java/org/apache/polygene/api/unitofwork/RemovalTest.java
+++ b/core/api/src/test/java/org/apache/polygene/api/unitofwork/RemovalTest.java
@@ -49,7 +49,7 @@
UnitOfWork uow = unitOfWorkFactory.newUnitOfWork();
try
{
- EntityBuilder<TestEntity> builder = uow.newEntityBuilder( TestEntity.class, StringIdentity.identity( "123" ) );
+ EntityBuilder<TestEntity> builder = uow.newEntityBuilder( TestEntity.class, StringIdentity.identityOf( "123" ) );
builder.instance().test().set( "habba" );
TestEntity test = builder.newInstance();
uow.remove( test );
diff --git a/core/api/src/test/java/org/apache/polygene/api/unitofwork/ToEntityConversionTest.java b/core/api/src/test/java/org/apache/polygene/api/unitofwork/ToEntityConversionTest.java
index 86ac547..52d4901 100644
--- a/core/api/src/test/java/org/apache/polygene/api/unitofwork/ToEntityConversionTest.java
+++ b/core/api/src/test/java/org/apache/polygene/api/unitofwork/ToEntityConversionTest.java
@@ -65,7 +65,7 @@
public void testPropertyConversionToEntity()
throws Exception
{
- Identity identity = StringIdentity.identity( "Niclas" );
+ Identity identity = StringIdentity.identityOf( "Niclas" );
ValueBuilder<SomeType> vb = valueBuilderFactory.newValueBuilder( SomeType.class );
SomeType prototype = vb.prototype();
prototype.identity().set( identity );
diff --git a/core/api/src/test/java/org/apache/polygene/api/unitofwork/ToValueConversionTest.java b/core/api/src/test/java/org/apache/polygene/api/unitofwork/ToValueConversionTest.java
index 910cf72..3b768bb 100644
--- a/core/api/src/test/java/org/apache/polygene/api/unitofwork/ToValueConversionTest.java
+++ b/core/api/src/test/java/org/apache/polygene/api/unitofwork/ToValueConversionTest.java
@@ -73,11 +73,11 @@
SomeType value;
try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork(usecase) )
{
- SomeType entity1 = createEntity( uow, StringIdentity.identity( "Niclas" ) );
- SomeType entity2 = createEntity( uow, StringIdentity.identity( "Paul" ) );
- SomeType entity3 = createEntity( uow, StringIdentity.identity( "Jiri" ) );
- SomeType entity4 = createEntity( uow, StringIdentity.identity( "Kent" ) );
- SomeType entity5 = createEntity( uow, StringIdentity.identity( "Stan" ) );
+ SomeType entity1 = createEntity( uow, StringIdentity.identityOf( "Niclas" ) );
+ SomeType entity2 = createEntity( uow, StringIdentity.identityOf( "Paul" ) );
+ SomeType entity3 = createEntity( uow, StringIdentity.identityOf( "Jiri" ) );
+ SomeType entity4 = createEntity( uow, StringIdentity.identityOf( "Kent" ) );
+ SomeType entity5 = createEntity( uow, StringIdentity.identityOf( "Stan" ) );
entity1.assoc().set( entity2 );
entity1.many().add( entity3 );
entity1.named().put( "kent", entity4 );
@@ -89,7 +89,7 @@
}
try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork(usecase) )
{
- assertThat( value.identity().get(), equalTo( StringIdentity.identity( "Niclas" ) ) );
+ assertThat( value.identity().get(), equalTo( StringIdentity.identityOf( "Niclas" ) ) );
assertThat( value.name().get(), equalTo( "[Niclas]" ) );
assertThat( uow.toValue( SomeType.class, value.assoc().get()).name().get(), equalTo( "[Paul]" ));
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/ImportedServiceAssemblyImpl.java b/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/ImportedServiceAssemblyImpl.java
index 614df0b..8319f32 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/ImportedServiceAssemblyImpl.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/ImportedServiceAssemblyImpl.java
@@ -78,7 +78,7 @@
}
else
{
- id = StringIdentity.identity( identity );
+ id = StringIdentity.identityOf( identity );
}
ImportedServiceModel serviceModel = new ImportedServiceModel( module,
@@ -103,7 +103,7 @@
{
// Find reference that is not yet used
int idx = 0;
- Identity id = StringIdentity.identity( serviceType.getSimpleName() );
+ Identity id = StringIdentity.identityOf( serviceType.getSimpleName() );
boolean invalid;
do
{
@@ -113,7 +113,7 @@
if( serviceModel.identity().equals( id ) )
{
idx++;
- id = StringIdentity.identity( serviceType.getSimpleName() + "_" + idx );
+ id = StringIdentity.identityOf( serviceType.getSimpleName() + "_" + idx );
invalid = true;
break;
}
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/ModuleAssemblyImpl.java b/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/ModuleAssemblyImpl.java
index 225857d..5c30117 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/ModuleAssemblyImpl.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/ModuleAssemblyImpl.java
@@ -708,7 +708,7 @@
Class<?> serviceType = serviceTypes.findFirst()
.orElse(null); // Use the first, which *SHOULD* be the main serviceType
int idx = 0;
- Identity id = StringIdentity.identity( serviceType.getSimpleName() );
+ Identity id = StringIdentity.identityOf( serviceType.getSimpleName() );
boolean invalid;
do
{
@@ -718,7 +718,7 @@
if (serviceAssembly.identity() != null && serviceAssembly.identity().equals(id))
{
idx++;
- id = StringIdentity.identity( serviceType.getSimpleName() + "_" + idx );
+ id = StringIdentity.identityOf( serviceType.getSimpleName() + "_" + idx );
invalid = true;
break;
}
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/ServiceDeclarationImpl.java b/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/ServiceDeclarationImpl.java
index 92db867..beb3480 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/ServiceDeclarationImpl.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/ServiceDeclarationImpl.java
@@ -59,7 +59,7 @@
for( ServiceAssemblyImpl serviceAssembly : serviceAssemblies )
{
if( identity != null ) {
- serviceAssembly.identity = StringIdentity.identity( identity );
+ serviceAssembly.identity = StringIdentity.identityOf( identity );
}
}
return this;
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/unitofwork/ModuleUnitOfWork.java b/core/runtime/src/main/java/org/apache/polygene/runtime/unitofwork/ModuleUnitOfWork.java
index 071d2c3..a863364 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/unitofwork/ModuleUnitOfWork.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/unitofwork/ModuleUnitOfWork.java
@@ -264,7 +264,7 @@
}
else
{
- identity = StringIdentity.identity( propertyState );
+ identity = StringIdentity.identityOf( propertyState );
}
}
diff --git a/core/runtime/src/test/java/org/apache/polygene/api/common/RemovalTest.java b/core/runtime/src/test/java/org/apache/polygene/api/common/RemovalTest.java
index 6c514c9..b58c6c9 100644
--- a/core/runtime/src/test/java/org/apache/polygene/api/common/RemovalTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/api/common/RemovalTest.java
@@ -48,7 +48,7 @@
throws Exception
{
UnitOfWork uow = unitOfWorkFactory.newUnitOfWork();
- EntityBuilder<TestEntity> builder = uow.newEntityBuilder( TestEntity.class, StringIdentity.identity( "123" ) );
+ EntityBuilder<TestEntity> builder = uow.newEntityBuilder( TestEntity.class, StringIdentity.identityOf( "123" ) );
builder.instance().test().set( "habba" );
TestEntity test = builder.newInstance();
uow.remove( test );
diff --git a/core/runtime/src/test/java/org/apache/polygene/regression/qi377/SetAssociationInSideEffectTest.java b/core/runtime/src/test/java/org/apache/polygene/regression/qi377/SetAssociationInSideEffectTest.java
index 84b6aed..1a73631 100644
--- a/core/runtime/src/test/java/org/apache/polygene/regression/qi377/SetAssociationInSideEffectTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/regression/qi377/SetAssociationInSideEffectTest.java
@@ -61,8 +61,8 @@
{
try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( UsecaseBuilder.newUsecase( "Purchase Steinway" ) ) )
{
- Pianist chris = uow.newEntity( Pianist.class, StringIdentity.identity( "Chris" ) );
- Steinway modelD = uow.newEntity( Steinway.class, StringIdentity.identity( "ModelD-274" ) );
+ Pianist chris = uow.newEntity( Pianist.class, StringIdentity.identityOf( "Chris" ) );
+ Steinway modelD = uow.newEntity( Steinway.class, StringIdentity.identityOf( "ModelD-274" ) );
assertThat( modelD.owner().get(), is( nullValue() ) );
diff --git a/core/runtime/src/test/java/org/apache/polygene/regression/qi377/ValueCollisionWithRelatedReturnTypesTest.java b/core/runtime/src/test/java/org/apache/polygene/regression/qi377/ValueCollisionWithRelatedReturnTypesTest.java
index 45e8658..6b6bb0a 100644
--- a/core/runtime/src/test/java/org/apache/polygene/regression/qi377/ValueCollisionWithRelatedReturnTypesTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/regression/qi377/ValueCollisionWithRelatedReturnTypesTest.java
@@ -36,7 +36,7 @@
extends AbstractPolygeneTest
{
- public static final Identity NICLAS = StringIdentity.identity( "niclas" );
+ public static final Identity NICLAS = StringIdentity.identityOf( "niclas" );
@Override
public void assemble( ModuleAssembly module )
diff --git a/core/runtime/src/test/java/org/apache/polygene/regression/qi382/Qi382Test.java b/core/runtime/src/test/java/org/apache/polygene/regression/qi382/Qi382Test.java
index 140fd9d..d645308 100644
--- a/core/runtime/src/test/java/org/apache/polygene/regression/qi382/Qi382Test.java
+++ b/core/runtime/src/test/java/org/apache/polygene/regression/qi382/Qi382Test.java
@@ -44,8 +44,8 @@
public class Qi382Test extends AbstractPolygeneTest
{
- public static final Identity FERRARI = StringIdentity.identity( "Ferrari" );
- public static final Identity NICLAS = StringIdentity.identity( "Niclas" );
+ public static final Identity FERRARI = StringIdentity.identityOf( "Ferrari" );
+ public static final Identity NICLAS = StringIdentity.identityOf( "Niclas" );
@Override
public void assemble( ModuleAssembly module )
diff --git a/core/runtime/src/test/java/org/apache/polygene/regression/qi383/Qi383Test.java b/core/runtime/src/test/java/org/apache/polygene/regression/qi383/Qi383Test.java
index 96f0cad..efa6bc0 100644
--- a/core/runtime/src/test/java/org/apache/polygene/regression/qi383/Qi383Test.java
+++ b/core/runtime/src/test/java/org/apache/polygene/regression/qi383/Qi383Test.java
@@ -47,9 +47,9 @@
{
try( UnitOfWork unitOfWork = unitOfWorkFactory.newUnitOfWork() )
{
- unitOfWork.newEntity( Car.class, StringIdentity.identity( "Ferrari" ) );
- unitOfWork.newEntity( Car.class, StringIdentity.identity( "Ford" ) );
- unitOfWork.newEntity( Car.class, StringIdentity.identity( "Ferrari" ) );
+ unitOfWork.newEntity( Car.class, StringIdentity.identityOf( "Ferrari" ) );
+ unitOfWork.newEntity( Car.class, StringIdentity.identityOf( "Ford" ) );
+ unitOfWork.newEntity( Car.class, StringIdentity.identityOf( "Ferrari" ) );
unitOfWork.complete();
}
}
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/activation/ImportedServiceActivationTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/activation/ImportedServiceActivationTest.java
index 07674f0..c13d019 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/activation/ImportedServiceActivationTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/activation/ImportedServiceActivationTest.java
@@ -179,7 +179,7 @@
module -> {
module.importedServices( TestedService.class ).
importedBy( ImportedServiceDeclaration.SERVICE_IMPORTER ).
- setMetaInfo( StringIdentity.identity( "testimporter" ) ).
+ setMetaInfo( StringIdentity.identityOf( "testimporter" ) ).
withActivators( TestedActivator.class ).
importOnStartup();
module.services( TestedServiceImporterService.class ).identifiedBy( "testimporter" );
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/entity/EntityTypeTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/entity/EntityTypeTest.java
index 1c63573..d814e50 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/entity/EntityTypeTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/entity/EntityTypeTest.java
@@ -40,9 +40,9 @@
UnitOfWork uow = unitOfWorkFactory.newUnitOfWork();
try
{
- EntityBuilder<Rst> builder3 = uow.newEntityBuilder( Rst.class, StringIdentity.identity( "123" ) );
- EntityBuilder<Def> builder2 = uow.newEntityBuilder( Def.class, StringIdentity.identity( "456" ) );
- EntityBuilder<Abc> builder1 = uow.newEntityBuilder( Abc.class, StringIdentity.identity( "789" ) );
+ EntityBuilder<Rst> builder3 = uow.newEntityBuilder( Rst.class, StringIdentity.identityOf( "123" ) );
+ EntityBuilder<Def> builder2 = uow.newEntityBuilder( Def.class, StringIdentity.identityOf( "456" ) );
+ EntityBuilder<Abc> builder1 = uow.newEntityBuilder( Abc.class, StringIdentity.identityOf( "789" ) );
}
finally
{
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/entity/EntityVisibilityTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/entity/EntityVisibilityTest.java
index 519d2a7..d1d510b 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/entity/EntityVisibilityTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/entity/EntityVisibilityTest.java
@@ -47,7 +47,7 @@
public class EntityVisibilityTest
{
- public static final Identity TEST_IDENTITY = StringIdentity.identity( "123" );
+ public static final Identity TEST_IDENTITY = StringIdentity.identityOf( "123" );
private Energy4Java polygene;
private Module module;
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/injection/ServiceInjectionTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/injection/ServiceInjectionTest.java
index 637a141..c9cdd4e 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/injection/ServiceInjectionTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/injection/ServiceInjectionTest.java
@@ -82,7 +82,7 @@
ServiceUser user = factory.newObject( ServiceUser.class );
assertEquals( "X", user.testSingle() );
- assertThat( user.testIdentity(), equalTo( StringIdentity.identity( "Foo" ) ) );
+ assertThat( user.testIdentity(), equalTo( StringIdentity.identityOf( "Foo" ) ) );
assertEquals( "FooX", user.testServiceReference() );
assertEquals( "Bar", user.testQualifier() );
assertEquals( "A", user.testStringIterable() );
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/injection/UnitOfWorkInjectionTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/injection/UnitOfWorkInjectionTest.java
index cd61437..4dd7111 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/injection/UnitOfWorkInjectionTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/injection/UnitOfWorkInjectionTest.java
@@ -53,7 +53,7 @@
UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( usecase );
try
{
- Trial trial = uow.newEntity( Trial.class, StringIdentity.identity( "123" ) );
+ Trial trial = uow.newEntity( Trial.class, StringIdentity.identityOf( "123" ) );
trial.doSomething();
uow.complete();
uow = unitOfWorkFactory.newUnitOfWork( usecase );
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/AssemblyMixinTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/AssemblyMixinTest.java
index 2b3b6af..9e67af3 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/AssemblyMixinTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/AssemblyMixinTest.java
@@ -62,11 +62,11 @@
throws UnitOfWorkCompletionException
{
UnitOfWork uow = unitOfWorkFactory.newUnitOfWork();
- FooEntity entity = uow.newEntity( FooEntity.class, StringIdentity.identity( "123" ) );
+ FooEntity entity = uow.newEntity( FooEntity.class, StringIdentity.identityOf( "123" ) );
uow.complete();
uow = unitOfWorkFactory.newUnitOfWork();
- Foo foo = uow.get( Foo.class, StringIdentity.identity( "123" ) );
+ Foo foo = uow.get( Foo.class, StringIdentity.identityOf( "123" ) );
try
{
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/AssemblyRoleTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/AssemblyRoleTest.java
index f051aec..ca15bc4 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/AssemblyRoleTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/AssemblyRoleTest.java
@@ -71,11 +71,11 @@
throws UnitOfWorkCompletionException
{
UnitOfWork uow = unitOfWorkFactory.newUnitOfWork();
- uow.newEntity( FooEntity.class, StringIdentity.identity( "123" ) );
+ uow.newEntity( FooEntity.class, StringIdentity.identityOf( "123" ) );
uow.complete();
uow = unitOfWorkFactory.newUnitOfWork();
- Foo foo = uow.get( Foo.class, StringIdentity.identity( "123" ) );
+ Foo foo = uow.get( Foo.class, StringIdentity.identityOf( "123" ) );
try
{
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/JDKMixinTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/JDKMixinTest.java
index 831babd..47e1203 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/JDKMixinTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/mixin/JDKMixinTest.java
@@ -98,8 +98,8 @@
}
}
- private static final Identity EXTENDS_IDENTITY = StringIdentity.identity( ExtendsJDKMixin.class.getName() );
- private static final Identity COMPOSE_IDENTITY = StringIdentity.identity( ComposeWithJDKMixin.class.getName() );
+ private static final Identity EXTENDS_IDENTITY = StringIdentity.identityOf( ExtendsJDKMixin.class.getName() );
+ private static final Identity COMPOSE_IDENTITY = StringIdentity.identityOf( ComposeWithJDKMixin.class.getName() );
private static final Predicate<ServiceReference<?>> EXTENDS_IDENTITY_SPEC = new ServiceIdentitySpec(
EXTENDS_IDENTITY );
private static final Predicate<ServiceReference<?>> COMPOSE_IDENTITY_SPEC = new ServiceIdentitySpec(
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/objects/ObjectVisibilityTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/objects/ObjectVisibilityTest.java
index d80d4e5..59c5a98 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/objects/ObjectVisibilityTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/objects/ObjectVisibilityTest.java
@@ -47,7 +47,7 @@
public class ObjectVisibilityTest
{
- public static final Identity TEST_IDENTITY = StringIdentity.identity( "123" );
+ public static final Identity TEST_IDENTITY = StringIdentity.identityOf( "123" );
private Energy4Java polygene;
private Module module;
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/query/IterableQuerySourceTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/query/IterableQuerySourceTest.java
index 9dbf52f..810eab2 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/query/IterableQuerySourceTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/query/IterableQuerySourceTest.java
@@ -214,7 +214,7 @@
{
QueryBuilder<Person> qb = qbf.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
- City kl = uow.get( City.class, StringIdentity.identity( "kualalumpur" ) );
+ City kl = uow.get( City.class, StringIdentity.identityOf( "kualalumpur" ) );
Query<Person> query = qb.where(
eq( person.mother().get().placeOfBirth(), kl )
).newQuery( Network.persons() );
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/query/Network.java b/core/runtime/src/test/java/org/apache/polygene/runtime/query/Network.java
index 727d168..dfd3253 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/query/Network.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/query/Network.java
@@ -44,8 +44,8 @@
*/
class Network
{
- public static final Identity KUALALUMPUR = StringIdentity.identity( "kualalumpur" );
- public static final Identity PENANG = StringIdentity.identity( "penang" );
+ public static final Identity KUALALUMPUR = StringIdentity.identityOf( "kualalumpur" );
+ public static final Identity PENANG = StringIdentity.identityOf( "penang" );
private static List<Domain> domains;
private static List<Person> persons;
private static List<Male> males;
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/service/ServiceVisibilityTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/service/ServiceVisibilityTest.java
index 289be4b..e82a092 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/service/ServiceVisibilityTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/service/ServiceVisibilityTest.java
@@ -46,7 +46,7 @@
public class ServiceVisibilityTest
{
- public static final Identity TEST_IDENTITY = StringIdentity.identity( "123" );
+ public static final Identity TEST_IDENTITY = StringIdentity.identityOf( "123" );
private Energy4Java polygene;
private Module module;
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/transients/TransientVisibilityTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/transients/TransientVisibilityTest.java
index 6e6abab..ba92bf1 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/transients/TransientVisibilityTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/transients/TransientVisibilityTest.java
@@ -47,7 +47,7 @@
public class TransientVisibilityTest
{
- public static final Identity TEST_IDENTITY = StringIdentity.identity( "123" );
+ public static final Identity TEST_IDENTITY = StringIdentity.identityOf( "123" );
private Energy4Java polygene;
private Module module;
private Application app;
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/unitofwork/PrivateEntityUnitOfWorkTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/unitofwork/PrivateEntityUnitOfWorkTest.java
index 425ae18..c1a04f0 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/unitofwork/PrivateEntityUnitOfWorkTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/unitofwork/PrivateEntityUnitOfWorkTest.java
@@ -52,7 +52,7 @@
*/
public class PrivateEntityUnitOfWorkTest
{
- private static final Identity TEST_IDENTITY = StringIdentity.identity( "1" );
+ private static final Identity TEST_IDENTITY = StringIdentity.identityOf( "1" );
@Structure
private UnitOfWorkFactory uowf;
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/unitofwork/RemovalTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/unitofwork/RemovalTest.java
index 1a95f2f..617914a 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/unitofwork/RemovalTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/unitofwork/RemovalTest.java
@@ -40,7 +40,7 @@
extends AbstractPolygeneTest
{
- private static final Identity TEST_IDENTITY = StringIdentity.identity( "123" );
+ private static final Identity TEST_IDENTITY = StringIdentity.identityOf( "123" );
public void assemble(ModuleAssembly module )
throws AssemblyException
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/value/AssociationToValueTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/value/AssociationToValueTest.java
index ffbe234..d43cfc9 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/value/AssociationToValueTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/value/AssociationToValueTest.java
@@ -151,7 +151,7 @@
public Person findPersonByName( String name )
{
UnitOfWork uow = unitOfWorkFactory.currentUnitOfWork();
- return uow.toValue( Person.class, uow.get( Person.class, StringIdentity.identity( name ) ) );
+ return uow.toValue( Person.class, uow.get( Person.class, StringIdentity.identityOf( name ) ) );
}
}
@@ -206,7 +206,7 @@
private Person createPerson( String name )
{
UnitOfWork uow = uowf.currentUnitOfWork();
- return uow.newEntity( Person.class, StringIdentity.identity( name ) );
+ return uow.newEntity( Person.class, StringIdentity.identityOf( name ) );
}
}
}
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/value/ValueSerializationRegressionTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/value/ValueSerializationRegressionTest.java
index f48bfe3..2bb600a 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/value/ValueSerializationRegressionTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/value/ValueSerializationRegressionTest.java
@@ -50,7 +50,7 @@
throws UnitOfWorkCompletionException
{
ValueBuilder<DualFaced> builder = valueBuilderFactory.newValueBuilder( DualFaced.class );
- builder.prototype().identity().set( StringIdentity.identity( "1234" ) );
+ builder.prototype().identity().set( StringIdentity.identityOf( "1234" ) );
builder.prototype().name().set( "Hedhman" );
DualFaced value = builder.newInstance();
}
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/value/ValueVisibilityTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/value/ValueVisibilityTest.java
index 191808b..500d255 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/value/ValueVisibilityTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/value/ValueVisibilityTest.java
@@ -48,7 +48,7 @@
public class ValueVisibilityTest
{
- public static final Identity TEST_IDENTIY = StringIdentity.identity( "123" );
+ public static final Identity TEST_IDENTIY = StringIdentity.identityOf( "123" );
private Energy4Java polygene;
private Module module;
private Application app;
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/value/ValueWithAssociationTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/value/ValueWithAssociationTest.java
index 655505c..c53a1a5 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/value/ValueWithAssociationTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/value/ValueWithAssociationTest.java
@@ -113,7 +113,7 @@
throws UnitOfWorkCompletionException
{
ValueBuilder<DualFaced> builder = valueBuilderFactory.newValueBuilder( DualFaced.class );
- builder.prototype().identity().set( StringIdentity.identity( "1234" ) );
+ builder.prototype().identity().set( StringIdentity.identityOf( "1234" ) );
builder.prototype().name().set( "Hedhman" );
DualFaced value = builder.newInstance();
@@ -125,8 +125,8 @@
try (UnitOfWork uow = unitOfWorkFactory.newUnitOfWork())
{
- DualFaced entity = uow.get( DualFaced.class, StringIdentity.identity( "1234" ) );
- assertThat( entity.identity().get(), equalTo( StringIdentity.identity( "1234" ) ) );
+ DualFaced entity = uow.get( DualFaced.class, StringIdentity.identityOf( "1234" ) );
+ assertThat( entity.identity().get(), equalTo( StringIdentity.identityOf( "1234" ) ) );
assertThat( entity.name().get(), equalTo( "Hedhman" ) );
uow.complete();
}
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/visibility/VisibilityInUnitOfWorkTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/visibility/VisibilityInUnitOfWorkTest.java
index ec9d072..239e7fe 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/visibility/VisibilityInUnitOfWorkTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/visibility/VisibilityInUnitOfWorkTest.java
@@ -41,8 +41,8 @@
public class VisibilityInUnitOfWorkTest
{
- public static final Identity TEST_IDENTITY1 = StringIdentity.identity( "123" );
- public static final Identity TEST_IDENTITY2 = StringIdentity.identity( "345" );
+ public static final Identity TEST_IDENTITY1 = StringIdentity.identityOf( "123" );
+ public static final Identity TEST_IDENTITY2 = StringIdentity.identityOf( "345" );
@Test
public void givenTwoModulesWithServiceAndEntityInOneAndEntityInOtherWhenOtherEntityAccessServiceWhichUsesItsEntityExpectServiceToHaveVisibility()
diff --git a/core/runtime/src/test/java/org/apache/polygene/spi/service/importer/ServiceInstanceImporterTest.java b/core/runtime/src/test/java/org/apache/polygene/spi/service/importer/ServiceInstanceImporterTest.java
index 237e8ab..b5f79a7 100644
--- a/core/runtime/src/test/java/org/apache/polygene/spi/service/importer/ServiceInstanceImporterTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/spi/service/importer/ServiceInstanceImporterTest.java
@@ -46,7 +46,7 @@
{
module.importedServices( TestService.class ).
identifiedBy( "test" ).
- setMetaInfo( StringIdentity.identity( "testimporter" ) ).
+ setMetaInfo( StringIdentity.identityOf( "testimporter" ) ).
importedBy( ImportedServiceDeclaration.SERVICE_IMPORTER );
module.services( TestImporterService.class ).identifiedBy( "testimporter" );
diff --git a/core/spi/src/main/java/org/apache/polygene/spi/entitystore/helpers/DefaultNamedAssociationState.java b/core/spi/src/main/java/org/apache/polygene/spi/entitystore/helpers/DefaultNamedAssociationState.java
index 94f30ca..c182180 100644
--- a/core/spi/src/main/java/org/apache/polygene/spi/entitystore/helpers/DefaultNamedAssociationState.java
+++ b/core/spi/src/main/java/org/apache/polygene/spi/entitystore/helpers/DefaultNamedAssociationState.java
@@ -21,6 +21,7 @@
import java.util.Iterator;
import java.util.Map;
+import java.util.Objects;
import org.apache.polygene.api.entity.EntityReference;
import org.apache.polygene.spi.entity.NamedAssociationState;
@@ -55,7 +56,10 @@
@Override
public boolean put( String name, EntityReference entityReference )
{
- if( references.put( name, entityReference ) == null )
+ Objects.requireNonNull(name, "name");
+ Objects.requireNonNull(entityReference, "entityReference");
+ EntityReference oldReference = references.put( name, entityReference );
+ if( entityReference.equals( oldReference ) )
{
return false;
}
diff --git a/core/spi/src/main/java/org/apache/polygene/spi/entitystore/helpers/JSONMapEntityStoreMixin.java b/core/spi/src/main/java/org/apache/polygene/spi/entitystore/helpers/JSONMapEntityStoreMixin.java
index cedcedc..aa0bdc4 100644
--- a/core/spi/src/main/java/org/apache/polygene/spi/entitystore/helpers/JSONMapEntityStoreMixin.java
+++ b/core/spi/src/main/java/org/apache/polygene/spi/entitystore/helpers/JSONMapEntityStoreMixin.java
@@ -419,7 +419,7 @@
String version = parsedState.getString( JSONKeys.VERSION );
Instant modified = Instant.ofEpochMilli( parsedState.getJsonNumber( JSONKeys.MODIFIED ).longValueExact() );
- Identity identity = StringIdentity.identity( parsedState.getString( JSONKeys.IDENTITY ) );
+ Identity identity = StringIdentity.identityOf( parsedState.getString( JSONKeys.IDENTITY ) );
// Check if version is correct
JsonObject state;
diff --git a/core/spi/src/main/java/org/apache/polygene/spi/entitystore/helpers/MapEntityStoreMixin.java b/core/spi/src/main/java/org/apache/polygene/spi/entitystore/helpers/MapEntityStoreMixin.java
index 2c98677..2dde5dc 100644
--- a/core/spi/src/main/java/org/apache/polygene/spi/entitystore/helpers/MapEntityStoreMixin.java
+++ b/core/spi/src/main/java/org/apache/polygene/spi/entitystore/helpers/MapEntityStoreMixin.java
@@ -382,7 +382,7 @@
String version = parsedState.getString( JSONKeys.VERSION );
Instant modified = Instant.ofEpochMilli( parsedState.getJsonNumber( JSONKeys.MODIFIED ).longValueExact() );
- Identity identity = StringIdentity.identity( parsedState.getString( JSONKeys.IDENTITY ) );
+ Identity identity = StringIdentity.identityOf( parsedState.getString( JSONKeys.IDENTITY ) );
// Check if version is correct
JsonObject state;
diff --git a/core/spi/src/main/java/org/apache/polygene/spi/serialization/BuiltInConverters.java b/core/spi/src/main/java/org/apache/polygene/spi/serialization/BuiltInConverters.java
index d86b81d..ab7448e 100644
--- a/core/spi/src/main/java/org/apache/polygene/spi/serialization/BuiltInConverters.java
+++ b/core/spi/src/main/java/org/apache/polygene/spi/serialization/BuiltInConverters.java
@@ -108,7 +108,7 @@
@Override
public Identity fromString( String string )
{
- return StringIdentity.identity( string );
+ return StringIdentity.identityOf( string );
}
}
diff --git a/core/spi/src/test/java/org/apache/polygene/spi/entitystore/Polygene142Test.java b/core/spi/src/test/java/org/apache/polygene/spi/entitystore/Polygene142Test.java
index b9030bd..b8af6ca 100644
--- a/core/spi/src/test/java/org/apache/polygene/spi/entitystore/Polygene142Test.java
+++ b/core/spi/src/test/java/org/apache/polygene/spi/entitystore/Polygene142Test.java
@@ -61,7 +61,7 @@
value = serialization.deserialize( module, Regression142Type.class, serialized ); // ok
}
{
- Identity valueId = StringIdentity.identity( "abcdefg" );
+ Identity valueId = StringIdentity.identityOf( "abcdefg" );
{
try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( UsecaseBuilder.newUsecase( "create" ) ) )
{
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/EntityStoreTestSuite.java b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/EntityStoreTestSuite.java
index 507526d..8a004a7 100644
--- a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/EntityStoreTestSuite.java
+++ b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/EntityStoreTestSuite.java
@@ -19,7 +19,6 @@
*/
package org.apache.polygene.test.entity.model;
-import java.util.Iterator;
import org.apache.polygene.api.association.NamedAssociation;
import org.apache.polygene.api.common.Visibility;
import org.apache.polygene.api.constraint.ConstraintViolationException;
@@ -56,7 +55,7 @@
import org.junit.Before;
import org.junit.Test;
-import static org.hamcrest.core.Is.is;
+import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertThat;
@@ -65,6 +64,8 @@
private static final String FRIEND = "Friend";
private static final String COLLEAGUE = "Colleague";
+ protected ModuleAssembly configModule;
+
@Structure
private ObjectFactory obf;
@@ -80,14 +81,14 @@
private Identity montpellierId;
private Identity hannoverId;
private Identity malmoId;
- private Identity cherasId;
+ private Identity cherasId;
private Identity unknown3Id;
private Identity unknown2Id;
private Identity unknown1Id;
private Identity varnhemId;
- private Identity canaryId;
+ private Identity canaryId;
private Identity switzerlandId;
private Identity franceId;
private Identity denmarkId;
@@ -240,15 +241,7 @@
try( UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Test - whenIteratingNamedAssociationExpectIterationToSucceed" ) ) )
{
Person niclas = peopleRepository.findPersonByName( "Niclas" );
- Iterator<String> numbers = niclas.phoneNumbers().iterator();
- assertThat( numbers.hasNext(), is( true ) );
- assertThat( numbers.next(), equalTo( "Home" ) );
- assertThat( numbers.hasNext(), is( true ) );
- assertThat( numbers.next(), equalTo( "Chinese" ) );
- assertThat( numbers.hasNext(), is( true ) );
- assertThat( numbers.next(), equalTo( "Swedish" ) );
- assertThat( numbers.hasNext(), is( true ) );
- assertThat( numbers.next(), equalTo( "German" ) );
+ assertThat( niclas.phoneNumbers(), containsInAnyOrder("Home", "Chinese", "Swedish", "German"));
}
}
@@ -542,5 +535,6 @@
{
module.defaultServices();
module.services( MemoryEntityStoreService.class ).visibleIn( Visibility.module );
+ configModule = module;
}
}
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/LegalService.java b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/LegalService.java
index 925e500..c90a64c 100644
--- a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/LegalService.java
+++ b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/legal/LegalService.java
@@ -52,7 +52,7 @@
public Identity createWill( Person principal, Map<Person, BigDecimal> amounts, Map<Person, Float> percentages, Map<Person, String> specificItems )
{
UnitOfWork uow = uowf.currentUnitOfWork();
- Identity identity = StringIdentity.identity( "will-" + principal.name().get() );
+ Identity identity = StringIdentity.identityOf( "will-" + principal.name().get() );
EntityBuilder<Will> builder = uow.newEntityBuilder( Will.class, identity );
Will instance = builder.instance();
for( Map.Entry<Person, BigDecimal> entry : amounts.entrySet() )
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/PeopleRepository.java b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/PeopleRepository.java
index 0aeb8ea..7e31aab9 100644
--- a/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/PeopleRepository.java
+++ b/core/testsupport/src/main/java/org/apache/polygene/test/entity/model/people/PeopleRepository.java
@@ -27,7 +27,7 @@
import org.apache.polygene.api.unitofwork.UnitOfWork;
import org.apache.polygene.api.unitofwork.UnitOfWorkFactory;
-import static org.apache.polygene.api.identity.StringIdentity.identity;
+import static org.apache.polygene.api.identity.StringIdentity.identityOf;
@Mixins( PeopleRepository.Mixin.class )
public interface PeopleRepository
@@ -66,7 +66,7 @@
public Person createPerson( String name, Country nationality, Address address, Person spouse, PhoneNumber homeNumber )
{
UnitOfWork uow = uowf.currentUnitOfWork();
- EntityBuilder<Person> builder = uow.newEntityBuilder( Person.class, identity( "person-" + name ) );
+ EntityBuilder<Person> builder = uow.newEntityBuilder( Person.class, identityOf( "person-" + name ) );
Person instance = builder.instance();
instance.name().set( name );
instance.nationality().set( nationality );
@@ -89,14 +89,14 @@
public Person findPersonByName( String name )
{
UnitOfWork uow = uowf.currentUnitOfWork();
- return uow.get( Person.class, identity( "person-" + name ) );
+ return uow.get( Person.class, identityOf( "person-" + name ) );
}
@Override
public Country createCountry( String countryCode, String countryName )
{
UnitOfWork uow = uowf.currentUnitOfWork();
- EntityBuilder<Country> builder = uow.newEntityBuilder( Country.class, identity( "country-" + countryCode ) );
+ EntityBuilder<Country> builder = uow.newEntityBuilder( Country.class, identityOf( "country-" + countryCode ) );
builder.instance().name().set( countryName );
return builder.newInstance();
}
@@ -105,7 +105,7 @@
public Country findCountryByCountryCode( String countryCode )
{
- return findCountryByIdentity( identity( "country-" + countryCode ) );
+ return findCountryByIdentity( identityOf( "country-" + countryCode ) );
}
@Override
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/indexing/AbstractQueryTest.java b/core/testsupport/src/main/java/org/apache/polygene/test/indexing/AbstractQueryTest.java
index 0592b1d..c5d1d99 100644
--- a/core/testsupport/src/main/java/org/apache/polygene/test/indexing/AbstractQueryTest.java
+++ b/core/testsupport/src/main/java/org/apache/polygene/test/indexing/AbstractQueryTest.java
@@ -465,7 +465,7 @@
{
QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
- Domain gaming = unitOfWork.get( Domain.class, StringIdentity.identity( "Gaming" ) );
+ Domain gaming = unitOfWork.get( Domain.class, StringIdentity.identityOf( "Gaming" ) );
Query<Person> query = unitOfWork.newQuery( qb.where( contains( person.interests(), gaming ) ) );
System.out.println( "*** script33: " + query );
@@ -477,7 +477,7 @@
{
QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
- Female annDoe = unitOfWork.get( Female.class, StringIdentity.identity( "anndoe" ) );
+ Female annDoe = unitOfWork.get( Female.class, StringIdentity.identityOf( "anndoe" ) );
Query<Person> query = unitOfWork.newQuery( qb.where( eq( person.mother(), annDoe ) ) );
System.out.println( "*** script34: " + query );
@@ -500,7 +500,7 @@
{
QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
- Account anns = unitOfWork.get( Account.class, StringIdentity.identity( "accountOfAnnDoe" ) );
+ Account anns = unitOfWork.get( Account.class, StringIdentity.identityOf( "accountOfAnnDoe" ) );
Query<Person> query = unitOfWork.newQuery( qb.where( contains( person.accounts(), anns ) ) );
System.out.println( "*** script36: " + query );
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/indexing/TestData.java b/core/testsupport/src/main/java/org/apache/polygene/test/indexing/TestData.java
index 40df6ba..5434005 100644
--- a/core/testsupport/src/main/java/org/apache/polygene/test/indexing/TestData.java
+++ b/core/testsupport/src/main/java/org/apache/polygene/test/indexing/TestData.java
@@ -59,7 +59,7 @@
NameableAssert.clear();
Domain gaming;
{
- EntityBuilder<Domain> domainBuilder = unitOfWork.newEntityBuilder( Domain.class, StringIdentity.identity( "Gaming" ) );
+ EntityBuilder<Domain> domainBuilder = unitOfWork.newEntityBuilder( Domain.class, StringIdentity.identityOf( "Gaming" ) );
gaming = domainBuilder.instance();
gaming.name().set( "Gaming" );
gaming.description().set( "Gaming domain" );
@@ -121,7 +121,7 @@
Account annsAccount;
{
- EntityBuilder<Account> accountBuilder = unitOfWork.newEntityBuilder( Account.class, StringIdentity.identity( "accountOfAnnDoe" ) );
+ EntityBuilder<Account> accountBuilder = unitOfWork.newEntityBuilder( Account.class, StringIdentity.identityOf( "accountOfAnnDoe" ) );
annsAccount = accountBuilder.instance();
annsAccount.number().set( "accountOfAnnDoe" );
annsAccount = accountBuilder.newInstance();
@@ -129,7 +129,7 @@
Account jacksAccount;
{
- EntityBuilder<Account> accountBuilder = unitOfWork.newEntityBuilder( Account.class, StringIdentity.identity( "accountOfJackDoe" ) );
+ EntityBuilder<Account> accountBuilder = unitOfWork.newEntityBuilder( Account.class, StringIdentity.identityOf( "accountOfJackDoe" ) );
jacksAccount = accountBuilder.instance();
jacksAccount.number().set( "accountOfJackDoe" );
jacksAccount = accountBuilder.newInstance();
@@ -143,7 +143,7 @@
Female annDoe;
{
- EntityBuilder<Female> femaleBuilder = unitOfWork.newEntityBuilder( Female.class, StringIdentity.identity( "anndoe" ) );
+ EntityBuilder<Female> femaleBuilder = unitOfWork.newEntityBuilder( Female.class, StringIdentity.identityOf( "anndoe" ) );
annDoe = femaleBuilder.instance();
annDoe.name().set( "Ann Doe" );
annDoe.title().set( Person.Title.MRS );
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/metrics/AbstractPolygeneMetricsTest.java b/core/testsupport/src/main/java/org/apache/polygene/test/metrics/AbstractPolygeneMetricsTest.java
index f07a202..e9e0c1c 100644
--- a/core/testsupport/src/main/java/org/apache/polygene/test/metrics/AbstractPolygeneMetricsTest.java
+++ b/core/testsupport/src/main/java/org/apache/polygene/test/metrics/AbstractPolygeneMetricsTest.java
@@ -71,7 +71,7 @@
public interface PersonList
{
- Identity LIST_ID = StringIdentity.identity( "person-list" );
+ Identity LIST_ID = StringIdentity.identityOf( "person-list" );
ManyAssociation<Person> all();
}
@@ -274,7 +274,7 @@
Commands commands = services.findService( Commands.class ).get();
Queries queries = services.findService( Queries.class ).get();
- Identity identity = StringIdentity.identity( "1" );
+ Identity identity = StringIdentity.identityOf( "1" );
try (UnitOfWork uow = services.unitOfWorkFactory().newUnitOfWork( newUsecase( "Step 1" ) ) )
{
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/serialization/AbstractValueCompositeSerializationTest.java b/core/testsupport/src/main/java/org/apache/polygene/test/serialization/AbstractValueCompositeSerializationTest.java
index ddea6d2..9f0d87c 100644
--- a/core/testsupport/src/main/java/org/apache/polygene/test/serialization/AbstractValueCompositeSerializationTest.java
+++ b/core/testsupport/src/main/java/org/apache/polygene/test/serialization/AbstractValueCompositeSerializationTest.java
@@ -253,7 +253,7 @@
// JSONEntityState does not allow for polymorphic serialization
public void valueAndEntityTypeEquality()
{
- Identity identity = StringIdentity.identity( "42" );
+ Identity identity = StringIdentity.identityOf( "42" );
Some createdValue, loadedValue;
try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( newUsecase( "create" ) ) )
@@ -301,7 +301,7 @@
{
EntityBuilder<Some> builder = uow.newEntityBuilder( Some.class );
Some proto = builder.instance();
- proto.identity().set( StringIdentity.identity( identity ) );
+ proto.identity().set( StringIdentity.identityOf( identity ) );
setSomeValueState( module, uow, proto );
return builder.newInstance();
}
@@ -313,7 +313,7 @@
{
ValueBuilder<Some> builder = module.newValueBuilder( Some.class );
Some proto = builder.prototype();
- proto.identity().set( StringIdentity.identity( identity ) );
+ proto.identity().set( StringIdentity.identityOf( identity ) );
setSomeValueState( module, uow, proto );
return builder.newInstance();
}
@@ -322,7 +322,7 @@
{
ValueBuilder<SomeExtended> builder = module.newValueBuilder( SomeExtended.class );
SomeExtended proto = builder.prototype();
- proto.identity().set( StringIdentity.identity( identity ) );
+ proto.identity().set( StringIdentity.identityOf( identity ) );
setSomeValueState( module, uow, proto );
proto.extraProperty().set( "extra property" );
proto.extraAssociation().set( buildBarEntity( module, uow, "extra association" ) );
diff --git a/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreMixin.java b/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreMixin.java
index 2895d53..549e0dc 100644
--- a/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreMixin.java
+++ b/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreMixin.java
@@ -427,7 +427,7 @@
Identity newIdentity;
if( idGenerator == null )
{
- newIdentity = StringIdentity.identity( UUID.randomUUID().toString() );
+ newIdentity = StringIdentity.identityOf( UUID.randomUUID().toString() );
}
else
{
diff --git a/extensions/entitystore-cassandra/src/test/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreTestSuite.java b/extensions/entitystore-cassandra/src/test/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreTestSuite.java
new file mode 100644
index 0000000..3908a73
--- /dev/null
+++ b/extensions/entitystore-cassandra/src/test/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreTestSuite.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.entitystore.cassandra;
+
+import org.apache.polygene.api.common.Visibility;
+import org.apache.polygene.api.service.ServiceReference;
+import org.apache.polygene.api.structure.Module;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.entitystore.cassandra.assembly.CassandraEntityStoreAssembler;
+import org.apache.polygene.test.docker.DockerRule;
+import org.apache.polygene.test.entity.CanRemoveAll;
+import org.apache.polygene.test.entity.model.EntityStoreTestSuite;
+import org.junit.ClassRule;
+
+/**
+ * Test the CassandraEntityStoreService.
+ * <p>Installing Cassandra and starting it should suffice as the test use Cassandra defaults: 127.0.0.1:3000</p>
+ */
+public class CassandraEntityStoreTestSuite extends EntityStoreTestSuite
+{
+ @ClassRule
+ public static final DockerRule DOCKER = new DockerRule( "cassandra", "Starting listening for CQL clients" );
+
+ @Override
+ protected void defineStorageModule( ModuleAssembly module )
+ {
+ module.defaultServices();
+ new CassandraEntityStoreAssembler()
+ .visibleIn( Visibility.application )
+ .withConfig( configModule, Visibility.application )
+ .assemble( module );
+
+ module.services( CassandraEntityStoreService.class )
+ .withTypes( CanRemoveAll.class )
+ .withMixins( EmptyCassandraTableMixin.class )
+ .visibleIn( Visibility.application );
+
+
+ CassandraEntityStoreConfiguration cassandraDefaults = configModule.forMixin( CassandraEntityStoreConfiguration.class ).declareDefaults();
+ String host = DOCKER.getDockerHost();
+ int port = DOCKER.getExposedContainerPort( "9042/tcp" );
+ System.out.println("Cassandra: " + host + ":" + port);
+ cassandraDefaults.hostnames().set( host + ':' + port );
+ cassandraDefaults.createIfMissing().set( true );
+ }
+
+ @Override
+ public void tearDown()
+ throws Exception
+ {
+ Module module = application.findModule( "Infrastructure Layer", "Storage Module" );
+ ServiceReference<CanRemoveAll> cleaner = module.serviceFinder().findService( CanRemoveAll.class );
+ if( cleaner.isActive() && cleaner.isAvailable() )
+ {
+ cleaner.get().removeAll();
+ }
+ else
+ {
+ throw new IllegalStateException( "Clean up operation of Cassandra database was not availeble." );
+ }
+ super.tearDown();
+ }
+}
diff --git a/extensions/entitystore-file/src/test/java/org/apache/polygene/entitystore/file/FileEntityStoreTestSuite.java b/extensions/entitystore-file/src/test/java/org/apache/polygene/entitystore/file/FileEntityStoreTestSuite.java
new file mode 100644
index 0000000..b28afff
--- /dev/null
+++ b/extensions/entitystore-file/src/test/java/org/apache/polygene/entitystore/file/FileEntityStoreTestSuite.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.entitystore.file;
+
+import org.apache.polygene.api.common.Visibility;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.entitystore.file.assembly.FileEntityStoreAssembler;
+import org.apache.polygene.library.fileconfig.FileConfigurationAssembler;
+import org.apache.polygene.library.fileconfig.FileConfigurationOverride;
+import org.apache.polygene.test.entity.model.EntityStoreTestSuite;
+import org.junit.Rule;
+import org.junit.rules.TemporaryFolder;
+
+public class FileEntityStoreTestSuite
+ extends EntityStoreTestSuite
+{
+ @Rule
+ public final TemporaryFolder tmpDir = new TemporaryFolder();
+
+ @Override
+ protected void defineStorageModule( ModuleAssembly module )
+ {
+ module.defaultServices();
+ new FileConfigurationAssembler()
+ .withOverride( new FileConfigurationOverride().withConventionalRoot( tmpDir.getRoot() ) )
+ .visibleIn( Visibility.application )
+ .assemble( module );
+ new FileEntityStoreAssembler()
+ .withConfig( configModule, Visibility.application )
+ .visibleIn( Visibility.application )
+ .assemble( module );
+ }
+}
diff --git a/extensions/entitystore-geode/src/test/java/org/apache/polygene/entitystore/geode/GeodeEntityStoreTestSuite.java b/extensions/entitystore-geode/src/test/java/org/apache/polygene/entitystore/geode/GeodeEntityStoreTestSuite.java
new file mode 100644
index 0000000..73dc13c
--- /dev/null
+++ b/extensions/entitystore-geode/src/test/java/org/apache/polygene/entitystore/geode/GeodeEntityStoreTestSuite.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.entitystore.geode;
+
+import org.apache.polygene.api.common.Visibility;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.entitystore.geode.assembly.GeodeEntityStoreAssembler;
+import org.apache.polygene.test.entity.model.EntityStoreTestSuite;
+
+public class GeodeEntityStoreTestSuite extends EntityStoreTestSuite
+{
+ @Override
+ protected void defineStorageModule( ModuleAssembly module )
+ {
+ module.defaultServices();
+ new GeodeEntityStoreAssembler()
+ .visibleIn( Visibility.application )
+ .withConfig( configModule, Visibility.application )
+ .assemble( module );
+ }
+}
diff --git a/extensions/entitystore-hazelcast/src/test/java/org/apache/polygene/entitystore/hazelcast/HazelcastEntityStoreTestSuite.java b/extensions/entitystore-hazelcast/src/test/java/org/apache/polygene/entitystore/hazelcast/HazelcastEntityStoreTestSuite.java
new file mode 100644
index 0000000..346f0ea
--- /dev/null
+++ b/extensions/entitystore-hazelcast/src/test/java/org/apache/polygene/entitystore/hazelcast/HazelcastEntityStoreTestSuite.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.entitystore.hazelcast;
+
+import org.apache.polygene.api.common.Visibility;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.entitystore.hazelcast.assembly.HazelcastEntityStoreAssembler;
+import org.apache.polygene.test.entity.model.EntityStoreTestSuite;
+import org.junit.After;
+
+public class HazelcastEntityStoreTestSuite extends EntityStoreTestSuite
+{
+ @Override
+ protected void defineStorageModule( ModuleAssembly module )
+ {
+ module.defaultServices();
+ new HazelcastEntityStoreAssembler()
+ .visibleIn( Visibility.application )
+ .withConfig( configModule, Visibility.application )
+ .assemble( module );
+ }
+
+ @After
+ @Override
+ public void tearDown()
+ throws Exception
+ {
+ super.tearDown();
+ // TODO : delete test data
+ }
+}
diff --git a/extensions/entitystore-jclouds/src/test/java/org/apache/polygene/entitystore/jclouds/JCloudsFilesystemTestSuite.java b/extensions/entitystore-jclouds/src/test/java/org/apache/polygene/entitystore/jclouds/JCloudsFilesystemTestSuite.java
new file mode 100644
index 0000000..d1eeb88
--- /dev/null
+++ b/extensions/entitystore-jclouds/src/test/java/org/apache/polygene/entitystore/jclouds/JCloudsFilesystemTestSuite.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+
+package org.apache.polygene.entitystore.jclouds;
+
+import java.util.Collections;
+import org.apache.polygene.api.common.Visibility;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.entitystore.jclouds.assembly.JCloudsEntityStoreAssembler;
+import org.apache.polygene.test.entity.model.EntityStoreTestSuite;
+import org.jclouds.filesystem.reference.FilesystemConstants;
+import org.junit.Rule;
+import org.junit.rules.TemporaryFolder;
+
+public class JCloudsFilesystemTestSuite extends EntityStoreTestSuite
+{
+ @Rule
+ public TemporaryFolder tmpDir = new TemporaryFolder();
+
+ @Override
+ protected void defineStorageModule( ModuleAssembly module )
+ {
+ module.defaultServices();
+ new JCloudsEntityStoreAssembler()
+ .visibleIn( Visibility.application )
+ .withConfig( configModule, Visibility.application )
+ .assemble( module );
+
+ JCloudsEntityStoreConfiguration defaults = configModule.forMixin( JCloudsEntityStoreConfiguration.class )
+ .declareDefaults();
+ defaults.provider().set( "filesystem" );
+ defaults.properties().set( Collections.singletonMap( FilesystemConstants.PROPERTY_BASEDIR,
+ tmpDir.getRoot().getAbsolutePath() ) );
+ }
+}
diff --git a/extensions/entitystore-jclouds/src/test/java/org/apache/polygene/entitystore/jclouds/JCloudsS3TestSuite.java b/extensions/entitystore-jclouds/src/test/java/org/apache/polygene/entitystore/jclouds/JCloudsS3TestSuite.java
new file mode 100644
index 0000000..1b43c7d
--- /dev/null
+++ b/extensions/entitystore-jclouds/src/test/java/org/apache/polygene/entitystore/jclouds/JCloudsS3TestSuite.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.entitystore.jclouds;
+
+import org.apache.polygene.api.common.Visibility;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.entitystore.jclouds.assembly.JCloudsEntityStoreAssembler;
+import org.apache.polygene.test.docker.DockerRule;
+import org.apache.polygene.test.entity.model.EntityStoreTestSuite;
+import org.junit.ClassRule;
+
+public class JCloudsS3TestSuite extends EntityStoreTestSuite
+{
+ @ClassRule
+ public static final DockerRule DOCKER = new DockerRule( "s3server", "server started" );
+
+ @Override
+ protected void defineStorageModule( ModuleAssembly module )
+ {
+ module.defaultServices();
+ new JCloudsEntityStoreAssembler()
+ .visibleIn( Visibility.application )
+ .withConfig( configModule, Visibility.application )
+ .assemble( module );
+
+ JCloudsEntityStoreConfiguration defaults =
+ configModule.forMixin( JCloudsEntityStoreConfiguration.class ).declareDefaults();
+
+ String host = DOCKER.getDockerHost();
+ int port = DOCKER.getExposedContainerPort( "8000/tcp" );
+ defaults.provider().set( "s3" );
+ defaults.endpoint().set( "http://" + host + ':' + port );
+ defaults.identifier().set( "dummyIdentifier" );
+ defaults.credential().set( "dummyCredential" );
+ }
+}
diff --git a/extensions/entitystore-jclouds/src/test/java/org/apache/polygene/entitystore/jclouds/JCloudsTransientTestSuite.java b/extensions/entitystore-jclouds/src/test/java/org/apache/polygene/entitystore/jclouds/JCloudsTransientTestSuite.java
new file mode 100644
index 0000000..186d7f0
--- /dev/null
+++ b/extensions/entitystore-jclouds/src/test/java/org/apache/polygene/entitystore/jclouds/JCloudsTransientTestSuite.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+
+package org.apache.polygene.entitystore.jclouds;
+
+import org.apache.polygene.api.common.Visibility;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.entitystore.jclouds.assembly.JCloudsEntityStoreAssembler;
+import org.apache.polygene.test.entity.model.EntityStoreTestSuite;
+
+public class JCloudsTransientTestSuite extends EntityStoreTestSuite
+{
+ @Override
+ protected void defineStorageModule( ModuleAssembly module )
+ {
+ module.defaultServices();
+ new JCloudsEntityStoreAssembler()
+ .visibleIn( Visibility.application )
+ .withConfig( configModule, Visibility.application )
+ .assemble( module );
+ }
+}
diff --git a/extensions/entitystore-jdbm/src/test/java/org/apache/polygene/entitystore/jdbm/JdbmEntityStoreTestSuite.java b/extensions/entitystore-jdbm/src/test/java/org/apache/polygene/entitystore/jdbm/JdbmEntityStoreTestSuite.java
index 597bfe3..959c83f 100644
--- a/extensions/entitystore-jdbm/src/test/java/org/apache/polygene/entitystore/jdbm/JdbmEntityStoreTestSuite.java
+++ b/extensions/entitystore-jdbm/src/test/java/org/apache/polygene/entitystore/jdbm/JdbmEntityStoreTestSuite.java
@@ -32,7 +32,6 @@
{
@Rule
public final TemporaryFolder tmpDir = new TemporaryFolder();
- private ModuleAssembly configModule;
@Override
protected void defineStorageModule( ModuleAssembly module )
@@ -45,11 +44,4 @@
.withConfig( configModule, Visibility.application )
.assemble( module );
}
-
- @Override
- protected void defineConfigModule( ModuleAssembly module )
- {
- configModule = module;
- super.defineConfigModule( module );
- }
}
diff --git a/extensions/entitystore-leveldb/src/test/java/org/apache/polygene/entitystore/leveldb/JavaLevelDBEntityStoreTestSuite.java b/extensions/entitystore-leveldb/src/test/java/org/apache/polygene/entitystore/leveldb/JavaLevelDBEntityStoreTestSuite.java
new file mode 100644
index 0000000..70c8929
--- /dev/null
+++ b/extensions/entitystore-leveldb/src/test/java/org/apache/polygene/entitystore/leveldb/JavaLevelDBEntityStoreTestSuite.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.entitystore.leveldb;
+
+import org.apache.polygene.api.common.Visibility;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.entitystore.leveldb.assembly.LevelDBEntityStoreAssembler;
+import org.apache.polygene.library.fileconfig.FileConfigurationAssembler;
+import org.apache.polygene.library.fileconfig.FileConfigurationOverride;
+import org.apache.polygene.test.entity.model.EntityStoreTestSuite;
+import org.junit.Rule;
+import org.junit.rules.TemporaryFolder;
+
+public class JavaLevelDBEntityStoreTestSuite extends EntityStoreTestSuite
+{
+ @Rule
+ public final TemporaryFolder tmpDir = new TemporaryFolder();
+
+ @Override
+ protected void defineStorageModule( ModuleAssembly module )
+ {
+ module.defaultServices();
+ new FileConfigurationAssembler()
+ .withOverride( new FileConfigurationOverride().withConventionalRoot( tmpDir.getRoot() ) )
+ .assemble( module );
+
+ new LevelDBEntityStoreAssembler()
+ .visibleIn( Visibility.application )
+ .withConfig( configModule, Visibility.application )
+ .identifiedBy( "java-leveldb-entitystore" )
+ .assemble( module );
+
+ configModule.forMixin( LevelDBEntityStoreConfiguration.class ).declareDefaults().flavour().set( "java" );
+ }
+}
diff --git a/extensions/entitystore-leveldb/src/test/java/org/apache/polygene/entitystore/leveldb/JniLevelDBEntityStoreTest.java b/extensions/entitystore-leveldb/src/test/java/org/apache/polygene/entitystore/leveldb/JniLevelDBEntityStoreTest.java
index 08177e1..c072f4d 100644
--- a/extensions/entitystore-leveldb/src/test/java/org/apache/polygene/entitystore/leveldb/JniLevelDBEntityStoreTest.java
+++ b/extensions/entitystore-leveldb/src/test/java/org/apache/polygene/entitystore/leveldb/JniLevelDBEntityStoreTest.java
@@ -20,40 +20,33 @@
package org.apache.polygene.entitystore.leveldb;
import org.apache.polygene.api.common.Visibility;
-import org.apache.polygene.bootstrap.AssemblyException;
import org.apache.polygene.bootstrap.ModuleAssembly;
import org.apache.polygene.entitystore.leveldb.assembly.LevelDBEntityStoreAssembler;
import org.apache.polygene.library.fileconfig.FileConfigurationAssembler;
import org.apache.polygene.library.fileconfig.FileConfigurationOverride;
-import org.apache.polygene.test.EntityTestAssembler;
-import org.apache.polygene.test.entity.AbstractEntityStoreTest;
+import org.apache.polygene.test.entity.model.EntityStoreTestSuite;
import org.junit.Rule;
import org.junit.rules.TemporaryFolder;
-public class JniLevelDBEntityStoreTest
- extends AbstractEntityStoreTest
+public class JniLevelDBEntityStoreTest extends EntityStoreTestSuite
{
@Rule
public final TemporaryFolder tmpDir = new TemporaryFolder();
@Override
- public void assemble( ModuleAssembly module )
- throws AssemblyException
+ protected void defineStorageModule( ModuleAssembly module )
{
- super.assemble( module );
-
- ModuleAssembly config = module.layer().module( "config" );
- new EntityTestAssembler().defaultServicesVisibleIn( Visibility.layer ).assemble( config );
-
+ module.defaultServices();
new FileConfigurationAssembler()
.withOverride( new FileConfigurationOverride().withConventionalRoot( tmpDir.getRoot() ) )
.assemble( module );
new LevelDBEntityStoreAssembler()
- .withConfig( config, Visibility.layer )
+ .visibleIn( Visibility.application )
+ .withConfig( configModule, Visibility.application )
.identifiedBy( "jni-leveldb-entitystore" )
.assemble( module );
- config.forMixin( LevelDBEntityStoreConfiguration.class ).declareDefaults().flavour().set( "jni" );
+ configModule.forMixin( LevelDBEntityStoreConfiguration.class ).declareDefaults().flavour().set( "jni" );
}
}
diff --git a/extensions/entitystore-memory/src/test/java/org/apache/polygene/entitystore/memory/MemoryEntityStoreTestSuite.java b/extensions/entitystore-memory/src/test/java/org/apache/polygene/entitystore/memory/MemoryEntityStoreTestSuite.java
new file mode 100644
index 0000000..01d4b33
--- /dev/null
+++ b/extensions/entitystore-memory/src/test/java/org/apache/polygene/entitystore/memory/MemoryEntityStoreTestSuite.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.entitystore.memory;
+
+import org.apache.polygene.api.common.Visibility;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.entitystore.memory.assembly.MemoryEntityStoreAssembler;
+import org.apache.polygene.test.entity.model.EntityStoreTestSuite;
+
+public class MemoryEntityStoreTestSuite extends EntityStoreTestSuite
+{
+ @Override
+ protected void defineStorageModule( ModuleAssembly module )
+ {
+ module.defaultServices();
+ new MemoryEntityStoreAssembler()
+ .visibleIn( Visibility.application )
+ .assemble( module );
+ }
+}
diff --git a/extensions/entitystore-mongodb/src/test/java/org/apache/polygene/entitystore/mongodb/EmbedMongoDBMapEntityStoreTestSuite.java b/extensions/entitystore-mongodb/src/test/java/org/apache/polygene/entitystore/mongodb/EmbedMongoDBMapEntityStoreTestSuite.java
new file mode 100644
index 0000000..57c1e16
--- /dev/null
+++ b/extensions/entitystore-mongodb/src/test/java/org/apache/polygene/entitystore/mongodb/EmbedMongoDBMapEntityStoreTestSuite.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.polygene.entitystore.mongodb;
+
+import de.flapdoodle.embed.mongo.MongodExecutable;
+import de.flapdoodle.embed.mongo.MongodStarter;
+import de.flapdoodle.embed.mongo.config.MongodConfigBuilder;
+import de.flapdoodle.embed.mongo.config.Net;
+import de.flapdoodle.embed.mongo.distribution.Version;
+import de.flapdoodle.embed.process.runtime.Network;
+import java.io.IOException;
+import java.util.Collections;
+import org.apache.polygene.api.common.Visibility;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.entitystore.mongodb.assembly.MongoDBEntityStoreAssembler;
+import org.apache.polygene.test.entity.model.EntityStoreTestSuite;
+import org.apache.polygene.test.util.FreePortFinder;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.rules.TestName;
+
+public class EmbedMongoDBMapEntityStoreTestSuite extends EntityStoreTestSuite
+{
+ private static final MongodStarter MONGO_STARTER = MongodStarter.getDefaultInstance();
+
+ @Rule
+ public TestName testName = new TestName();
+ private static int port;
+ private static MongodExecutable mongod;
+
+ @BeforeClass
+ public static void startEmbedMongo()
+ throws IOException
+ {
+ port = FreePortFinder.findFreePortOnLoopback();
+ mongod = MONGO_STARTER.prepare( new MongodConfigBuilder()
+ .version( Version.Main.PRODUCTION )
+ .net( new Net( "localhost", port, Network.localhostIsIPv6() ) )
+ .build() );
+ mongod.start();
+ }
+
+ @AfterClass
+ public static void stopEmbedMongo()
+ {
+ if( mongod != null )
+ {
+ mongod.stop();
+ }
+ }
+
+ @Override
+ protected void defineStorageModule( ModuleAssembly module )
+ {
+ module.defaultServices();
+ new MongoDBEntityStoreAssembler()
+ .visibleIn( Visibility.application )
+ .withConfig( configModule, Visibility.application )
+ .assemble( module );
+
+ MongoDBEntityStoreConfiguration mongoConfig = configModule.forMixin( MongoDBEntityStoreConfiguration.class )
+ .declareDefaults();
+ mongoConfig.writeConcern().set( MongoDBEntityStoreConfiguration.WriteConcern.MAJORITY );
+ mongoConfig.database().set( "polygene-test" );
+ mongoConfig.collection().set( testName.getMethodName() );
+ mongoConfig.nodes().set( Collections.singletonList( "localhost:" + port ) );
+ }
+}
diff --git a/extensions/entitystore-mongodb/src/test/java/org/apache/polygene/entitystore/mongodb/MongoDBEntityStoreTestSuite.java b/extensions/entitystore-mongodb/src/test/java/org/apache/polygene/entitystore/mongodb/MongoDBEntityStoreTestSuite.java
new file mode 100644
index 0000000..109ff43
--- /dev/null
+++ b/extensions/entitystore-mongodb/src/test/java/org/apache/polygene/entitystore/mongodb/MongoDBEntityStoreTestSuite.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.entitystore.mongodb;
+
+import com.mongodb.Mongo;
+import org.apache.polygene.api.common.Visibility;
+import org.apache.polygene.api.structure.Module;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.entitystore.mongodb.assembly.MongoDBEntityStoreAssembler;
+import org.apache.polygene.test.docker.DockerRule;
+import org.apache.polygene.test.entity.model.EntityStoreTestSuite;
+import org.junit.ClassRule;
+
+/**
+ * Test the MongoDBEntityStoreService.
+ */
+public class MongoDBEntityStoreTestSuite extends EntityStoreTestSuite
+{
+ @ClassRule
+ public static final DockerRule DOCKER = new DockerRule( "mongo", 27017 );
+
+ @Override
+ protected void defineStorageModule( ModuleAssembly module )
+ {
+ module.defaultServices();
+ new MongoDBEntityStoreAssembler()
+ .visibleIn( Visibility.application )
+ .withConfig( configModule, Visibility.application )
+ .assemble( module );
+
+ MongoDBEntityStoreConfiguration mongoConfig = configModule.forMixin( MongoDBEntityStoreConfiguration.class ).declareDefaults();
+ mongoConfig.writeConcern().set( MongoDBEntityStoreConfiguration.WriteConcern.MAJORITY );
+ mongoConfig.database().set( "polygene:test" );
+ mongoConfig.collection().set( "polygene:test:entities" );
+ mongoConfig.hostname().set( DOCKER.getDockerHost() );
+ mongoConfig.port().set( DOCKER.getExposedContainerPort( "27017/tcp" ) );
+ }
+
+ private Mongo mongo;
+ private String dbName;
+
+ @Override
+ public void setUp()
+ throws Exception
+ {
+ super.setUp();
+ Module storageModule = application.findModule( "Infrastructure Layer", "Storage Module" );
+ MongoDBEntityStoreService es = storageModule.serviceFinder().findService( MongoDBEntityStoreService.class ).get();
+ mongo = es.mongoInstanceUsed();
+ dbName = es.dbInstanceUsed().getName();
+ }
+
+ @Override
+ public void tearDown()
+ throws Exception
+ {
+ mongo.dropDatabase( dbName );
+ super.tearDown();
+ }
+}
diff --git a/extensions/entitystore-preferences/src/main/java/org/apache/polygene/entitystore/preferences/assembly/PreferencesEntityStoreAssembler.java b/extensions/entitystore-preferences/src/main/java/org/apache/polygene/entitystore/preferences/assembly/PreferencesEntityStoreAssembler.java
index 1020216..f3b0de5 100644
--- a/extensions/entitystore-preferences/src/main/java/org/apache/polygene/entitystore/preferences/assembly/PreferencesEntityStoreAssembler.java
+++ b/extensions/entitystore-preferences/src/main/java/org/apache/polygene/entitystore/preferences/assembly/PreferencesEntityStoreAssembler.java
@@ -26,8 +26,7 @@
import org.apache.polygene.entitystore.preferences.PreferencesEntityStoreInfo;
import org.apache.polygene.entitystore.preferences.PreferencesEntityStoreService;
-public class PreferencesEntityStoreAssembler
- extends Assemblers.VisibilityIdentityConfig<PreferencesEntityStoreAssembler>
+public class PreferencesEntityStoreAssembler extends Assemblers.VisibilityIdentityConfig<PreferencesEntityStoreAssembler>
{
@Override
public void assemble( ModuleAssembly module )
@@ -38,9 +37,9 @@
Preferences node = root.node( applicationName );
PreferencesEntityStoreInfo info = new PreferencesEntityStoreInfo( node );
ServiceDeclaration service = module.services( PreferencesEntityStoreService.class )
- .setMetaInfo( info )
- .visibleIn( visibility() )
- .instantiateOnStartup();
+ .setMetaInfo( info )
+ .visibleIn( visibility() )
+ .instantiateOnStartup();
if( hasIdentity() )
{
service.identifiedBy( identity() );
diff --git a/extensions/entitystore-preferences/src/test/java/org/apache/polygene/entitystore/preferences/PreferencesEntityStoreTestSuite.java b/extensions/entitystore-preferences/src/test/java/org/apache/polygene/entitystore/preferences/PreferencesEntityStoreTestSuite.java
new file mode 100644
index 0000000..4ca18b4
--- /dev/null
+++ b/extensions/entitystore-preferences/src/test/java/org/apache/polygene/entitystore/preferences/PreferencesEntityStoreTestSuite.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.entitystore.preferences;
+
+import java.util.prefs.BackingStoreException;
+import java.util.prefs.Preferences;
+import org.apache.polygene.api.common.Visibility;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.entitystore.preferences.assembly.PreferencesEntityStoreAssembler;
+import org.apache.polygene.test.entity.model.EntityStoreTestSuite;
+import org.junit.After;
+import org.junit.Rule;
+import org.junit.rules.TemporaryFolder;
+
+public class PreferencesEntityStoreTestSuite extends EntityStoreTestSuite
+{
+ @Rule
+ public TemporaryFolder tmpDir = new TemporaryFolder();
+ private Preferences rootNode;
+
+ @Override
+ protected void defineStorageModule( ModuleAssembly module )
+ {
+ module.defaultServices();
+ String applicationName = module.layer().application().name();
+ rootNode = Preferences.userRoot().node( applicationName );
+
+ new PreferencesEntityStoreAssembler()
+ .visibleIn( Visibility.application )
+ .assemble( module );
+ }
+
+ @After
+ public void tearDown()
+ throws BackingStoreException
+ {
+ rootNode.removeNode();
+ }
+}
diff --git a/extensions/entitystore-redis/src/test/java/org/apache/polygene/entitystore/redis/RedisEntityStoreTestSuite.java b/extensions/entitystore-redis/src/test/java/org/apache/polygene/entitystore/redis/RedisEntityStoreTestSuite.java
new file mode 100644
index 0000000..6ae99a1
--- /dev/null
+++ b/extensions/entitystore-redis/src/test/java/org/apache/polygene/entitystore/redis/RedisEntityStoreTestSuite.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.entitystore.redis;
+
+import org.apache.polygene.api.common.Visibility;
+import org.apache.polygene.api.structure.Module;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.entitystore.redis.assembly.RedisEntityStoreAssembler;
+import org.apache.polygene.test.docker.DockerRule;
+import org.apache.polygene.test.entity.model.EntityStoreTestSuite;
+import org.junit.ClassRule;
+import redis.clients.jedis.Jedis;
+import redis.clients.jedis.JedisPool;
+
+public class RedisEntityStoreTestSuite extends EntityStoreTestSuite
+{
+ @ClassRule
+ public static final DockerRule DOCKER = new DockerRule( "redis", 6379 );
+
+ @Override
+ protected void defineStorageModule( ModuleAssembly module )
+ {
+ module.defaultServices();
+ new RedisEntityStoreAssembler()
+ .visibleIn( Visibility.application )
+ .withConfig( configModule, Visibility.application )
+ .assemble( module );
+
+ RedisEntityStoreConfiguration redisConfig = configModule.forMixin( RedisEntityStoreConfiguration.class )
+ .declareDefaults();
+ redisConfig.host().set( DOCKER.getDockerHost() );
+ redisConfig.port().set( DOCKER.getExposedContainerPort( "6379/tcp" ) );
+ }
+
+ private JedisPool jedisPool;
+
+ @Override
+ public void setUp()
+ throws Exception
+ {
+ super.setUp();
+ Module storageModule = application.findModule( "Infrastructure Layer", "Storage Module" );
+ RedisEntityStoreService es = storageModule.findService( RedisEntityStoreService.class ).get();
+ jedisPool = es.jedisPool();
+ }
+
+ @Override
+ public void tearDown()
+ throws Exception
+ {
+ try( Jedis jedis = jedisPool.getResource() )
+ {
+ jedis.flushDB();
+ }
+ super.tearDown();
+ }
+}
diff --git a/extensions/entitystore-riak/src/test/java/org/apache/polygene/entitystore/riak/RiakEntityStoreTestSuite.java b/extensions/entitystore-riak/src/test/java/org/apache/polygene/entitystore/riak/RiakEntityStoreTestSuite.java
new file mode 100644
index 0000000..14828ff
--- /dev/null
+++ b/extensions/entitystore-riak/src/test/java/org/apache/polygene/entitystore/riak/RiakEntityStoreTestSuite.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.polygene.entitystore.riak;
+
+import java.util.Collections;
+import org.apache.polygene.api.common.Visibility;
+import org.apache.polygene.api.structure.Module;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.entitystore.riak.assembly.RiakEntityStoreAssembler;
+import org.apache.polygene.test.docker.DockerRule;
+import org.apache.polygene.test.entity.model.EntityStoreTestSuite;
+import org.junit.ClassRule;
+
+public class RiakEntityStoreTestSuite extends EntityStoreTestSuite
+{
+ @ClassRule
+ public static final DockerRule DOCKER = new DockerRule( "riak", "riak_auth_mods started on node" );
+
+ private RiakFixture riakFixture;
+
+ @Override
+ protected void defineStorageModule( ModuleAssembly module )
+ {
+ module.defaultServices();
+ new RiakEntityStoreAssembler()
+ .visibleIn( Visibility.application )
+ .withConfig( configModule, Visibility.application )
+ .assemble( module );
+
+ RiakEntityStoreConfiguration riakConfig = configModule.forMixin( RiakEntityStoreConfiguration.class )
+ .declareDefaults();
+ String host = DOCKER.getDockerHost();
+ int port = DOCKER.getExposedContainerPort( "8087/tcp" );
+ riakConfig.hosts().set( Collections.singletonList( host + ':' + port ) );
+ }
+
+ @Override
+ public void tearDown()
+ throws Exception
+ {
+ riakFixture.deleteTestData();
+ super.tearDown();
+ }
+
+ @Override
+ public void setUp()
+ throws Exception
+ {
+ super.setUp();
+ Module storageModule = application.findModule( "Infrastructure Layer", "Storage Module" );
+ RiakEntityStoreService es = storageModule.findService( RiakEntityStoreService.class ).get();
+ riakFixture = new RiakFixture( es.riakClient(), es.riakNamespace() );
+ riakFixture.waitUntilReady();
+ }
+}
diff --git a/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/assembly/AbstractSQLEntityStoreAssembler.java b/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/assembly/AbstractSQLEntityStoreAssembler.java
index 6a41cea..c25a3cd 100644
--- a/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/assembly/AbstractSQLEntityStoreAssembler.java
+++ b/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/assembly/AbstractSQLEntityStoreAssembler.java
@@ -36,7 +36,7 @@
public abstract class AbstractSQLEntityStoreAssembler<AssemblerType>
extends Assemblers.VisibilityIdentityConfig<AssemblerType>
{
- public static final Identity DEFAULT_ENTITYSTORE_IDENTITY = StringIdentity.identity( "entitystore-sql" );
+ public static final Identity DEFAULT_ENTITYSTORE_IDENTITY = StringIdentity.identityOf( "entitystore-sql" );
private static final String DEFAULT_CHANGELOG_PATH = "org/apache/polygene/entitystore/sql/changelog.xml";
private String changelogPath = DEFAULT_CHANGELOG_PATH;
diff --git a/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/DerbySQLEntityStoreTestSuite.java b/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/DerbySQLEntityStoreTestSuite.java
new file mode 100644
index 0000000..7fbfb2a
--- /dev/null
+++ b/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/DerbySQLEntityStoreTestSuite.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.entitystore.sql;
+
+import java.sql.Connection;
+import java.sql.Statement;
+import javax.sql.DataSource;
+import org.apache.polygene.api.common.Visibility;
+import org.apache.polygene.api.structure.Module;
+import org.apache.polygene.api.unitofwork.UnitOfWork;
+import org.apache.polygene.api.unitofwork.UnitOfWorkFactory;
+import org.apache.polygene.api.usecase.UsecaseBuilder;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.entitystore.sql.assembly.DerbySQLEntityStoreAssembler;
+import org.apache.polygene.library.sql.assembly.DataSourceAssembler;
+import org.apache.polygene.library.sql.dbcp.DBCPDataSourceServiceAssembler;
+import org.apache.polygene.test.entity.model.EntityStoreTestSuite;
+
+import static org.apache.polygene.entitystore.sql.assembly.DerbySQLEntityStoreAssembler.DEFAULT_ENTITYSTORE_IDENTITY;
+
+public class DerbySQLEntityStoreTestSuite extends EntityStoreTestSuite
+{
+ @Override
+ protected void defineStorageModule( ModuleAssembly module )
+ {
+ module.defaultServices();
+ // DataSourceService
+ new DBCPDataSourceServiceAssembler()
+ .identifiedBy( "derby-datasource-service" )
+ .visibleIn( Visibility.module )
+ .withConfig( configModule, Visibility.application )
+ .assemble( module );
+
+ // DataSource
+ new DataSourceAssembler()
+ .withDataSourceServiceIdentity( "derby-datasource-service" )
+ .identifiedBy( "derby-datasource" )
+ .visibleIn( Visibility.module )
+ .withCircuitBreaker()
+ .assemble( module );
+
+ // SQL EntityStore
+ new DerbySQLEntityStoreAssembler()
+ .visibleIn( Visibility.application )
+ .withConfig( configModule, Visibility.application )
+ .assemble( module );
+ }
+
+ @Override
+ public void tearDown()
+ throws Exception
+ {
+ Module storageModule = application.findModule( "Infrastructure Layer","Storage Module" );
+ UnitOfWorkFactory uowf = storageModule.unitOfWorkFactory();
+ UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase(
+ "Delete " + getClass().getSimpleName() + " test data" ) );
+ try
+ {
+ SQLEntityStoreConfiguration config = uow.get( SQLEntityStoreConfiguration.class,
+ DEFAULT_ENTITYSTORE_IDENTITY );
+ Connection connection = storageModule.serviceFinder().findService( DataSource.class ).get().getConnection();
+ connection.setAutoCommit( false );
+ try( Statement stmt = connection.createStatement() )
+ {
+ stmt.execute( String.format( "DELETE FROM %s.%s",
+ config.schemaName().get(),
+ config.entityTableName().get() ) );
+ connection.commit();
+ }
+ }
+ finally
+ {
+ uow.discard();
+ super.tearDown();
+ }
+ }
+}
diff --git a/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/H2SQLEntityStoreTestSuite.java b/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/H2SQLEntityStoreTestSuite.java
new file mode 100644
index 0000000..f763238
--- /dev/null
+++ b/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/H2SQLEntityStoreTestSuite.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.entitystore.sql;
+
+import org.apache.polygene.api.common.Visibility;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.entitystore.sql.assembly.H2SQLEntityStoreAssembler;
+import org.apache.polygene.library.sql.assembly.DataSourceAssembler;
+import org.apache.polygene.library.sql.dbcp.DBCPDataSourceServiceAssembler;
+import org.apache.polygene.test.entity.model.EntityStoreTestSuite;
+
+public class H2SQLEntityStoreTestSuite extends EntityStoreTestSuite
+{
+ @Override
+ protected void defineStorageModule( ModuleAssembly module )
+ {
+ module.defaultServices();
+ // DataSourceService
+ new DBCPDataSourceServiceAssembler()
+ .identifiedBy( "h2-datasource-service" )
+ .visibleIn( Visibility.module )
+ .withConfig( configModule, Visibility.application )
+ .assemble( module );
+
+ // DataSource
+ new DataSourceAssembler()
+ .withDataSourceServiceIdentity( "h2-datasource-service" )
+ .identifiedBy( "h2-datasource" )
+ .visibleIn( Visibility.module )
+ .withCircuitBreaker()
+ .assemble( module );
+
+ // SQL EntityStore
+ new H2SQLEntityStoreAssembler()
+ .visibleIn( Visibility.application )
+ .withConfig( configModule, Visibility.application )
+ .assemble( module );
+ }
+}
diff --git a/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/MySQLEntityStoreTestSuite.java b/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/MySQLEntityStoreTestSuite.java
new file mode 100644
index 0000000..e2b0564
--- /dev/null
+++ b/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/MySQLEntityStoreTestSuite.java
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.entitystore.sql;
+
+import java.sql.Connection;
+import java.sql.Statement;
+import java.util.HashMap;
+import javax.sql.DataSource;
+import org.apache.polygene.api.common.Visibility;
+import org.apache.polygene.api.service.ServiceFinder;
+import org.apache.polygene.api.structure.Module;
+import org.apache.polygene.api.unitofwork.UnitOfWork;
+import org.apache.polygene.api.unitofwork.UnitOfWorkFactory;
+import org.apache.polygene.api.usecase.UsecaseBuilder;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.entitystore.sql.assembly.MySQLEntityStoreAssembler;
+import org.apache.polygene.library.sql.assembly.DataSourceAssembler;
+import org.apache.polygene.library.sql.datasource.DataSourceConfiguration;
+import org.apache.polygene.library.sql.dbcp.DBCPDataSourceServiceAssembler;
+import org.apache.polygene.test.docker.DockerRule;
+import org.apache.polygene.test.entity.model.EntityStoreTestSuite;
+import org.junit.ClassRule;
+
+import static org.apache.polygene.entitystore.sql.assembly.MySQLEntityStoreAssembler.DEFAULT_ENTITYSTORE_IDENTITY;
+
+public class MySQLEntityStoreTestSuite extends EntityStoreTestSuite
+{
+ @ClassRule
+ public static final DockerRule DOCKER = new DockerRule(
+ "mysql",
+ new HashMap<String, String>()
+ {{
+ put( "MYSQL_ROOT_PASSWORD", "" );
+ put( "MYSQL_ALLOW_EMPTY_PASSWORD", "yes" );
+ put( "MYSQL_DATABASE", "jdbc_test_db" );
+ put( "MYSQL_ROOT_HOST", "172.17.0.1" );
+ }},
+ 30000L
+// , "mysqld: ready for connections" TODO: add this after next release of tdomzal/junit-docker-rule
+ );
+
+ @Override
+ protected void defineStorageModule( ModuleAssembly module )
+ {
+ module.defaultServices();
+ // DataSourceService
+ new DBCPDataSourceServiceAssembler()
+ .identifiedBy( "mysql-datasource-service" )
+ .visibleIn( Visibility.module )
+ .withConfig( configModule, Visibility.application )
+ .assemble( module );
+
+ // DataSource
+ new DataSourceAssembler()
+ .withDataSourceServiceIdentity( "mysql-datasource-service" )
+ .identifiedBy( "mysql-datasource" )
+ .visibleIn( Visibility.module )
+ .withCircuitBreaker()
+ .assemble( module );
+
+ // SQL EntityStore
+ new MySQLEntityStoreAssembler()
+ .visibleIn( Visibility.application )
+ .withConfig( configModule, Visibility.application )
+ .assemble( module );
+
+ String mysqlHost = DOCKER.getDockerHost();
+ int mysqlPort = DOCKER.getExposedContainerPort( "3306/tcp" );
+ configModule.forMixin( DataSourceConfiguration.class ).declareDefaults()
+ .url().set( "jdbc:mysql://" + mysqlHost + ":" + mysqlPort
+ + "/jdbc_test_db?profileSQL=false&useLegacyDatetimeCode=false&serverTimezone=UTC"
+ + "&nullCatalogMeansCurrent=true&nullNamePatternMatchesAll=true" );
+ }
+
+ @Override
+ public void tearDown()
+ throws Exception
+ {
+ Module storageModule = application.findModule( "Infrastructure Layer", "Storage Module" );
+ UnitOfWorkFactory uowf = storageModule.unitOfWorkFactory();
+ ServiceFinder serviceFinder = storageModule.serviceFinder();
+ UnitOfWork uow = uowf.newUnitOfWork(
+ UsecaseBuilder.newUsecase( "Delete " + getClass().getSimpleName() + " test data" )
+ );
+ try
+ {
+ Connection connection = serviceFinder.findService( DataSource.class ).get().getConnection();
+ SQLEntityStoreConfiguration configuration = uow.get( SQLEntityStoreConfiguration.class,
+ DEFAULT_ENTITYSTORE_IDENTITY );
+ connection.setAutoCommit( false );
+ try( Statement stmt = connection.createStatement() )
+ {
+ stmt.execute( String.format( "TRUNCATE %s.%s",
+ configuration.schemaName().get(),
+ configuration.entityTableName().get() ) );
+ connection.commit();
+ }
+ }
+ finally
+ {
+ uow.discard();
+ super.tearDown();
+ }
+ }
+}
diff --git a/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/PostgreSQLEntityStoreTest.java b/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/PostgreSQLEntityStoreTest.java
index d3342b8..daa9949 100644
--- a/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/PostgreSQLEntityStoreTest.java
+++ b/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/PostgreSQLEntityStoreTest.java
@@ -39,40 +39,6 @@
import static org.apache.polygene.entitystore.sql.assembly.PostgreSQLEntityStoreAssembler.DEFAULT_ENTITYSTORE_IDENTITY;
-/**
- * WARN This test run only if localhost:5432 is listening.
- *
- * To run it you need to have a user & database set up in postgresql. Here are two snippets to create and drop the
- * needed test environment.
- *
- * Use 'password' as password for the jdbc_test_login user.
- *
- * Eventually create a database cluster:
- *
- * <pre>
- * initdb -D /usr/local/pgsql/data
- * </pre>
- *
- * Start PostgreSQL. Then, create test user and database:
- *
- * <pre>
- * createuser -A -D -P -E -W jdbc_test_login
- * createdb -O jdbc_test_login -W jdbc_test_db
- * </pre>
- *
- * To clear the data:
- *
- * <pre>
- * dropdb -W jdbc_test_db
- * createdb -O jdbc_test_login -W jdbc_test_db
- * </pre>
- *
- * To remove the test user:
- *
- * <pre>
- * dropuser -W jdbc_test_login
- * </pre>
- */
public class PostgreSQLEntityStoreTest
extends AbstractEntityStoreTest
{
diff --git a/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/PostgreSQLEntityStoreTestSuite.java b/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/PostgreSQLEntityStoreTestSuite.java
new file mode 100644
index 0000000..d1dd952
--- /dev/null
+++ b/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/PostgreSQLEntityStoreTestSuite.java
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.entitystore.sql;
+
+import java.sql.Connection;
+import java.sql.Statement;
+import javax.sql.DataSource;
+import org.apache.polygene.api.common.Visibility;
+import org.apache.polygene.api.service.ServiceFinder;
+import org.apache.polygene.api.structure.Module;
+import org.apache.polygene.api.unitofwork.UnitOfWork;
+import org.apache.polygene.api.unitofwork.UnitOfWorkFactory;
+import org.apache.polygene.api.usecase.UsecaseBuilder;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.entitystore.sql.assembly.PostgreSQLEntityStoreAssembler;
+import org.apache.polygene.library.sql.assembly.DataSourceAssembler;
+import org.apache.polygene.library.sql.common.SQLConfiguration;
+import org.apache.polygene.library.sql.datasource.DataSourceConfiguration;
+import org.apache.polygene.library.sql.dbcp.DBCPDataSourceServiceAssembler;
+import org.apache.polygene.test.docker.DockerRule;
+import org.apache.polygene.test.entity.model.EntityStoreTestSuite;
+import org.junit.ClassRule;
+
+import static org.apache.polygene.entitystore.sql.assembly.PostgreSQLEntityStoreAssembler.DEFAULT_ENTITYSTORE_IDENTITY;
+
+public class PostgreSQLEntityStoreTestSuite extends EntityStoreTestSuite
+{
+ @ClassRule
+ public static final DockerRule DOCKER = new DockerRule( "postgres",
+ 3000L,
+ "PostgreSQL init process complete; ready for start up." );
+
+ @Override
+ protected void defineStorageModule( ModuleAssembly module )
+ {
+ module.defaultServices();
+ // DataSourceService
+ new DBCPDataSourceServiceAssembler()
+ .identifiedBy( "postgresql-datasource-service" )
+ .visibleIn( Visibility.module )
+ .withConfig( configModule, Visibility.application )
+ .assemble( module );
+
+ // DataSource
+ new DataSourceAssembler()
+ .withDataSourceServiceIdentity( "postgresql-datasource-service" )
+ .identifiedBy( "postgresql-datasource" )
+ .visibleIn( Visibility.module )
+ .withCircuitBreaker()
+ .assemble( module );
+
+ // SQL EntityStore
+ new PostgreSQLEntityStoreAssembler()
+ .visibleIn( Visibility.application )
+ .withConfig( configModule, Visibility.application )
+ .assemble( module );
+
+ String host = DOCKER.getDockerHost();
+ int port = DOCKER.getExposedContainerPort( "5432/tcp" );
+ configModule.forMixin( DataSourceConfiguration.class ).declareDefaults()
+ .url().set( "jdbc:postgresql://" + host + ":" + port + "/jdbc_test_db" );
+ // START SNIPPET: assembly
+ }
+ // END SNIPPET: assembly
+
+ @Override
+ public void tearDown()
+ throws Exception
+ {
+ Module storageModule = application.findModule( "Infrastructure Layer", "Storage Module" );
+ UnitOfWorkFactory uowf = storageModule.unitOfWorkFactory();
+ ServiceFinder serviceFinder = storageModule.serviceFinder();
+ UnitOfWork uow = uowf.newUnitOfWork(
+ UsecaseBuilder.newUsecase( "Delete " + getClass().getSimpleName() + " test data" )
+ );
+ try
+ {
+ SQLConfiguration config = uow.get( SQLConfiguration.class, DEFAULT_ENTITYSTORE_IDENTITY );
+ Connection connection = serviceFinder.findService( DataSource.class ).get().getConnection();
+ connection.setAutoCommit( false );
+ String schemaName = config.schemaName().get();
+ try( Statement stmt = connection.createStatement() )
+ {
+ stmt.execute( String.format( "DROP SCHEMA \"%s\" CASCADE", schemaName ) );
+ connection.commit();
+ }
+ }
+ finally
+ {
+ uow.discard();
+ super.tearDown();
+ }
+ }
+}
diff --git a/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/SQLiteEntityStoreTestSuite.java b/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/SQLiteEntityStoreTestSuite.java
new file mode 100644
index 0000000..6dc5fbe
--- /dev/null
+++ b/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/SQLiteEntityStoreTestSuite.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.entitystore.sql;
+
+import org.apache.polygene.api.common.Visibility;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.entitystore.sql.assembly.SQLiteEntityStoreAssembler;
+import org.apache.polygene.library.sql.assembly.DataSourceAssembler;
+import org.apache.polygene.library.sql.dbcp.DBCPDataSourceServiceAssembler;
+import org.apache.polygene.test.entity.model.EntityStoreTestSuite;
+import org.junit.BeforeClass;
+
+import static org.apache.polygene.test.util.Assume.assumeNoIbmJdk;
+
+public class SQLiteEntityStoreTestSuite extends EntityStoreTestSuite
+{
+ @BeforeClass
+ public static void beforeClass_IBMJDK()
+ {
+ assumeNoIbmJdk();
+ }
+
+ @Override
+ protected void defineStorageModule( ModuleAssembly module )
+ {
+ module.defaultServices();
+ // DataSourceService
+ new DBCPDataSourceServiceAssembler()
+ .identifiedBy( "sqlite-datasource-service" )
+ .visibleIn( Visibility.module )
+ .withConfig( configModule, Visibility.application )
+ .assemble( module );
+
+ // DataSource
+ new DataSourceAssembler()
+ .withDataSourceServiceIdentity( "sqlite-datasource-service" )
+ .identifiedBy( "sqlite-datasource" )
+ .visibleIn( Visibility.module )
+ .withCircuitBreaker()
+ .assemble( module );
+
+ // SQL EntityStore
+ new SQLiteEntityStoreAssembler()
+ .visibleIn( Visibility.application )
+ .withConfig( configModule, Visibility.application )
+ .assemble( module );
+ }
+}
diff --git a/extensions/indexing-rdf/src/test/java/org/apache/polygene/index/rdf/RDFPerformanceTest.java b/extensions/indexing-rdf/src/test/java/org/apache/polygene/index/rdf/RDFPerformanceTest.java
index 08e1db4..86bd8e3 100644
--- a/extensions/indexing-rdf/src/test/java/org/apache/polygene/index/rdf/RDFPerformanceTest.java
+++ b/extensions/indexing-rdf/src/test/java/org/apache/polygene/index/rdf/RDFPerformanceTest.java
@@ -102,7 +102,7 @@
List<ExampleEntity> entities = new ArrayList<ExampleEntity>();
for (Integer x = 0; x < howMany; ++x)
{
- ExampleEntity exampleEntity = this.unitOfWorkFactory.currentUnitOfWork().newEntity( ExampleEntity.class, StringIdentity.identity( "entity" + x ) );
+ ExampleEntity exampleEntity = this.unitOfWorkFactory.currentUnitOfWork().newEntity( ExampleEntity.class, StringIdentity.identityOf( "entity" + x ) );
for (ExampleEntity entity : entities)
{
@@ -188,7 +188,7 @@
UnitOfWork uow = this.unitOfWorkFactory.newUnitOfWork();
for (int i = 0; i < 1000; i++)
{
- ExampleEntity entity50 = uow.get(ExampleEntity.class, StringIdentity.identity( "entity50" ) );
+ ExampleEntity entity50 = uow.get(ExampleEntity.class, StringIdentity.identityOf( "entity50" ) );
Query<ExampleEntity> query = uow.newQuery( this.queryBuilderFactory.newQueryBuilder( ExampleEntity.class ).
where( QueryExpressions.contains( QueryExpressions.templateFor( ExampleEntity.class ).manyAssoc(), entity50) ));
System.out.println(query.count());
diff --git a/extensions/indexing-sql/src/main/java/org/apache/polygene/index/sql/assembly/AbstractSQLIndexQueryAssembler.java b/extensions/indexing-sql/src/main/java/org/apache/polygene/index/sql/assembly/AbstractSQLIndexQueryAssembler.java
index 86790c9..b5e861c 100644
--- a/extensions/indexing-sql/src/main/java/org/apache/polygene/index/sql/assembly/AbstractSQLIndexQueryAssembler.java
+++ b/extensions/indexing-sql/src/main/java/org/apache/polygene/index/sql/assembly/AbstractSQLIndexQueryAssembler.java
@@ -35,7 +35,7 @@
public abstract class AbstractSQLIndexQueryAssembler<AssemblerType> extends Assemblers.VisibilityIdentityConfig<AssemblerType>
{
- public static final Identity DEFAULT_IDENTITY = StringIdentity.identity( "indexing-sql" );
+ public static final Identity DEFAULT_IDENTITY = StringIdentity.identityOf( "indexing-sql" );
private Class<? extends ReindexingStrategy> reindexingStrategy = ReindexingStrategy.NeverNeed.class;
diff --git a/libraries/alarm/src/main/java/org/apache/polygene/library/alarm/AlarmSystem.java b/libraries/alarm/src/main/java/org/apache/polygene/library/alarm/AlarmSystem.java
index 1b42452..0b90143 100644
--- a/libraries/alarm/src/main/java/org/apache/polygene/library/alarm/AlarmSystem.java
+++ b/libraries/alarm/src/main/java/org/apache/polygene/library/alarm/AlarmSystem.java
@@ -214,7 +214,7 @@
public AlarmPoint createAlarm( String name, AlarmCategory category )
{
UnitOfWork uow = uowf.currentUnitOfWork();
- EntityBuilder<AlarmPoint> builder = uow.newEntityBuilder( AlarmPoint.class, StringIdentity.identity( name ) );
+ EntityBuilder<AlarmPoint> builder = uow.newEntityBuilder( AlarmPoint.class, StringIdentity.identityOf( name ) );
builder.instance().category().set( category );
AlarmPoint.AlarmState state = builder.instanceFor( AlarmPoint.AlarmState.class );
state.systemName().set( name );
diff --git a/libraries/alarm/src/test/java/org/apache/polygene/library/alarm/AlarmProxyTest.java b/libraries/alarm/src/test/java/org/apache/polygene/library/alarm/AlarmProxyTest.java
index 5ec2236..cd6c292 100644
--- a/libraries/alarm/src/test/java/org/apache/polygene/library/alarm/AlarmProxyTest.java
+++ b/libraries/alarm/src/test/java/org/apache/polygene/library/alarm/AlarmProxyTest.java
@@ -60,7 +60,7 @@
try
{
// START SNIPPET: documentation
- myAlarmPoint = factory.create( StringIdentity.identity( "This Alarm Identity" ), "ProActiveCRM", "Sales", AlarmClass.B );
+ myAlarmPoint = factory.create( StringIdentity.identityOf( "This Alarm Identity" ), "ProActiveCRM", "Sales", AlarmClass.B );
myAlarmPoint.history().maxSize().set( 20 );
// END SNIPPET: documentation
@@ -71,7 +71,7 @@
assertThat( myAlarmPoint.history().activateCounter(), equalTo( 1 ) );
AlarmEvent event = myAlarmPoint.history().firstEvent();
assertThat( event, notNullValue() );
- assertThat( event.identity().get(), equalTo( StringIdentity.identity( "This Alarm Identity" ) ) );
+ assertThat( event.identity().get(), equalTo( StringIdentity.identityOf( "This Alarm Identity" ) ) );
assertThat( event.newStatus().get().name( null ), equalTo( "Activated" ) );
assertThat( event.oldStatus().get().name( null ), equalTo( "Normal" ) );
}
diff --git a/libraries/jmx/src/main/java/org/apache/polygene/library/jmx/ConfigurationManagerService.java b/libraries/jmx/src/main/java/org/apache/polygene/library/jmx/ConfigurationManagerService.java
index 91025f0..ed5964d 100644
--- a/libraries/jmx/src/main/java/org/apache/polygene/library/jmx/ConfigurationManagerService.java
+++ b/libraries/jmx/src/main/java/org/apache/polygene/library/jmx/ConfigurationManagerService.java
@@ -243,7 +243,7 @@
EditableConfiguration( MBeanInfo info, String identity, Map<String, AccessibleObject> propertyNames )
{
this.info = info;
- this.identity = StringIdentity.identity( identity );
+ this.identity = StringIdentity.identityOf( identity );
this.propertyNames = propertyNames;
}
diff --git a/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/entity/EntitySerializerTest.java b/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/entity/EntitySerializerTest.java
index a48e272..64512cb 100644
--- a/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/entity/EntitySerializerTest.java
+++ b/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/entity/EntitySerializerTest.java
@@ -109,14 +109,14 @@
valueBuilder.prototype().test3().set( valueBuilder2.newInstance() );
TestValue testValue = valueBuilder.newInstance();
- EntityBuilder<TestEntity> builder = unitOfWork.newEntityBuilder( TestEntity.class, StringIdentity.identity( "test1" ) );
+ EntityBuilder<TestEntity> builder = unitOfWork.newEntityBuilder( TestEntity.class, StringIdentity.identityOf( "test1" ) );
TestEntity rickardTemplate = builder.instance();
rickardTemplate.name().set( "Rickard" );
rickardTemplate.title().set( "Mr" );
rickardTemplate.value().set( testValue );
TestEntity testEntity = builder.newInstance();
- EntityBuilder<TestEntity> builder2 = unitOfWork.newEntityBuilder( TestEntity.class, StringIdentity.identity( "test2" ) );
+ EntityBuilder<TestEntity> builder2 = unitOfWork.newEntityBuilder( TestEntity.class, StringIdentity.identityOf( "test2" ) );
TestEntity niclasTemplate = builder2.instance();
niclasTemplate.name().set( "Niclas" );
niclasTemplate.title().set( "Mr" );
diff --git a/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/entity/EntityTypeSerializerTest.java b/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/entity/EntityTypeSerializerTest.java
index ae4c56e..8e8d8d7 100644
--- a/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/entity/EntityTypeSerializerTest.java
+++ b/libraries/rdf/src/test/java/org/apache/polygene/library/rdf/entity/EntityTypeSerializerTest.java
@@ -95,14 +95,14 @@
valueBuilder.prototype().test3().set( vb2.newInstance() );
TestValue testValue = valueBuilder.newInstance();
- EntityBuilder<TestEntity> builder = unitOfWork.newEntityBuilder(TestEntity.class, StringIdentity.identity( "test1" ) );
+ EntityBuilder<TestEntity> builder = unitOfWork.newEntityBuilder(TestEntity.class, StringIdentity.identityOf( "test1" ) );
TestEntity rickardTemplate = builder.instance();
rickardTemplate.name().set( "Rickard" );
rickardTemplate.title().set( "Mr" );
rickardTemplate.value().set( testValue );
TestEntity testEntity = builder.newInstance();
- EntityBuilder<TestEntity> builder2 = unitOfWork.newEntityBuilder(TestEntity.class, StringIdentity.identity( "test2" ) );
+ EntityBuilder<TestEntity> builder2 = unitOfWork.newEntityBuilder(TestEntity.class, StringIdentity.identityOf( "test2" ) );
TestEntity niclasTemplate = builder2.instance();
niclasTemplate.name().set( "Niclas" );
niclasTemplate.title().set( "Mr" );
diff --git a/libraries/rest-server/src/main/java/org/apache/polygene/library/rest/server/restlet/RequestReaderDelegator.java b/libraries/rest-server/src/main/java/org/apache/polygene/library/rest/server/restlet/RequestReaderDelegator.java
index 50db549..33b69b8 100644
--- a/libraries/rest-server/src/main/java/org/apache/polygene/library/rest/server/restlet/RequestReaderDelegator.java
+++ b/libraries/rest-server/src/main/java/org/apache/polygene/library/rest/server/restlet/RequestReaderDelegator.java
@@ -51,7 +51,7 @@
public void init( @Service Iterable<ServiceReference<RequestReader>> requestReaderReferences )
{
Logger logger = LoggerFactory.getLogger( getClass() );
- Identity requestreaderdelegator = StringIdentity.identity( "requestreaderdelegator" );
+ Identity requestreaderdelegator = StringIdentity.identityOf( "requestreaderdelegator" );
// Add custom readers first
for( ServiceReference<RequestReader> requestReader : requestReaderReferences )
diff --git a/libraries/rest-server/src/main/java/org/apache/polygene/library/rest/server/restlet/ResponseWriterDelegator.java b/libraries/rest-server/src/main/java/org/apache/polygene/library/rest/server/restlet/ResponseWriterDelegator.java
index 5809f66..29da261 100644
--- a/libraries/rest-server/src/main/java/org/apache/polygene/library/rest/server/restlet/ResponseWriterDelegator.java
+++ b/libraries/rest-server/src/main/java/org/apache/polygene/library/rest/server/restlet/ResponseWriterDelegator.java
@@ -48,7 +48,7 @@
public void init( @Service Iterable<ServiceReference<ResponseWriter>> resultWriters )
{
Logger logger = LoggerFactory.getLogger( getClass() );
- Identity responsewriterdelegator = StringIdentity.identity( "responsewriterdelegator" );
+ Identity responsewriterdelegator = StringIdentity.identityOf( "responsewriterdelegator" );
// Add custom writers first
for( ServiceReference<ResponseWriter> resultWriter : resultWriters )
diff --git a/libraries/rest-server/src/main/java/org/apache/polygene/library/rest/server/restlet/requestreader/DefaultRequestReader.java b/libraries/rest-server/src/main/java/org/apache/polygene/library/rest/server/restlet/requestreader/DefaultRequestReader.java
index 65b31af..60f26c8 100644
--- a/libraries/rest-server/src/main/java/org/apache/polygene/library/rest/server/restlet/requestreader/DefaultRequestReader.java
+++ b/libraries/rest-server/src/main/java/org/apache/polygene/library/rest/server/restlet/requestreader/DefaultRequestReader.java
@@ -251,7 +251,7 @@
entityAsForm = new Form();
}
- Identity entityIdentity = StringIdentity.identity( getValue( "entity", queryAsForm, entityAsForm ) );
+ Identity entityIdentity = StringIdentity.identityOf( getValue( "entity", queryAsForm, entityAsForm ) );
args[0] = uowf.currentUnitOfWork().get( method.getParameterTypes()[0], entityIdentity );
return args;
@@ -480,7 +480,7 @@
}
else if( parameterType.isInterface() )
{
- arg = uowf.currentUnitOfWork().get( parameterType, StringIdentity.identity( argString ) );
+ arg = uowf.currentUnitOfWork().get( parameterType, StringIdentity.identityOf( argString ) );
}
else
{
diff --git a/libraries/rest/src/main/java/org/apache/polygene/library/rest/admin/EntityResource.java b/libraries/rest/src/main/java/org/apache/polygene/library/rest/admin/EntityResource.java
index a81e682..17d4ae1 100644
--- a/libraries/rest/src/main/java/org/apache/polygene/library/rest/admin/EntityResource.java
+++ b/libraries/rest/src/main/java/org/apache/polygene/library/rest/admin/EntityResource.java
@@ -106,7 +106,7 @@
{
// /entity/{reference}
Map<String, Object> attributes = getRequest().getAttributes();
- identity = StringIdentity.identity( (String) attributes.get( "reference" ) );
+ identity = StringIdentity.identityOf( (String) attributes.get( "reference" ) );
}
@Override
@@ -474,7 +474,6 @@
try
{
unitOfWork.entityStateOf( module, reference );
-
namedAssociation.remove( name );
namedAssociation.put( name, reference );
diff --git a/libraries/rest/src/test/java/org/apache/polygene/library/rest/admin/DummyDataService.java b/libraries/rest/src/test/java/org/apache/polygene/library/rest/admin/DummyDataService.java
index 56004c4..1d5a2ad 100644
--- a/libraries/rest/src/test/java/org/apache/polygene/library/rest/admin/DummyDataService.java
+++ b/libraries/rest/src/test/java/org/apache/polygene/library/rest/admin/DummyDataService.java
@@ -77,13 +77,13 @@
valueBuilder.prototype().string().set( "Foo bar value" );
valueBuilder.prototype().map().set( new HashMap() );
- EntityBuilder<TestEntity> builder = unitOfWork.newEntityBuilder( TestEntity.class, StringIdentity.identity( "test1" ) );
+ EntityBuilder<TestEntity> builder = unitOfWork.newEntityBuilder( TestEntity.class, StringIdentity.identityOf( "test1" ) );
builder.instance().name().set( "Foo bar" );
builder.instance().age().set( 42 );
builder.instance().value().set( valueBuilder.newInstance() );
TestEntity testEntity = builder.newInstance();
- EntityBuilder<TestEntity> builder2 = unitOfWork.newEntityBuilder( TestEntity.class, StringIdentity.identity( "test2" ) );
+ EntityBuilder<TestEntity> builder2 = unitOfWork.newEntityBuilder( TestEntity.class, StringIdentity.identityOf( "test2" ) );
builder2.instance().name().set( "Xyzzy" );
builder2.instance().age().set( 12 );
builder2.instance().association().set( testEntity );
@@ -98,7 +98,7 @@
}
{
- EntityBuilder<TestEntity2> builder = unitOfWork.newEntityBuilder( TestEntity2.class, StringIdentity.identity( "test3" ) );
+ EntityBuilder<TestEntity2> builder = unitOfWork.newEntityBuilder( TestEntity2.class, StringIdentity.identityOf( "test3" ) );
builder.instance().name().set( "Test3" );
builder.newInstance();
}
diff --git a/libraries/rest/src/test/java/org/apache/polygene/library/rest/admin/RestTest.java b/libraries/rest/src/test/java/org/apache/polygene/library/rest/admin/RestTest.java
index 206c0ef..db6db80 100644
--- a/libraries/rest/src/test/java/org/apache/polygene/library/rest/admin/RestTest.java
+++ b/libraries/rest/src/test/java/org/apache/polygene/library/rest/admin/RestTest.java
@@ -111,13 +111,13 @@
UnitOfWork uow = unitOfWorkFactory.newUnitOfWork();
try
{
- EntityBuilder<PersonEntity> builder1 = uow.newEntityBuilder( PersonEntity.class, StringIdentity.identity( "P2" ) );
+ EntityBuilder<PersonEntity> builder1 = uow.newEntityBuilder( PersonEntity.class, StringIdentity.identityOf( "P2" ) );
PersonEntity maryDoe = builder1.instance();
maryDoe.firstname().set( "Mary" );
maryDoe.lastname().set( "Doe" );
maryDoe = builder1.newInstance();
- EntityBuilder<PersonEntity> builder2 = uow.newEntityBuilder( PersonEntity.class, StringIdentity.identity( "P1" ) );
+ EntityBuilder<PersonEntity> builder2 = uow.newEntityBuilder( PersonEntity.class, StringIdentity.identityOf( "P1" ) );
PersonEntity joeDoe = builder2.instance();
joeDoe.firstname().set( "Joe" );
joeDoe.lastname().set( "Doe" );
@@ -162,7 +162,7 @@
UnitOfWork work = unitOfWorkFactory.newUnitOfWork();
try
{
- PersonEntity entity = work.get( PersonEntity.class, StringIdentity.identity( "P1" ) );
+ PersonEntity entity = work.get( PersonEntity.class, StringIdentity.identityOf( "P1" ) );
assertEquals( "FirstName not changed.", "Jack", entity.firstname().get() );
assertEquals( "LastName not changed.", "Doe", entity.lastname().get() );
work.complete();
@@ -185,7 +185,7 @@
PersonEntity entity = null;
try
{
- entity = work.get( PersonEntity.class, StringIdentity.identity( "P1" ) );
+ entity = work.get( PersonEntity.class, StringIdentity.identityOf( "P1" ) );
}
catch( NoSuchEntityException expected )
{
diff --git a/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/crud/EntityResource.java b/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/crud/EntityResource.java
index c822892..965a33a 100644
--- a/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/crud/EntityResource.java
+++ b/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/crud/EntityResource.java
@@ -97,7 +97,7 @@
{
Class entityType = parameters.entityType().get();
String idOfEntity = parameters.id().get();
- locator.find( entityType ).delete( StringIdentity.identity( idOfEntity ) );
+ locator.find( entityType ).delete( StringIdentity.identityOf( idOfEntity ) );
}
@Override
@@ -137,7 +137,7 @@
throw new RuntimeException( message, e );
}
Reference base = parameters.request().get().getResourceRef();
- return resourceBuilder.createRestLink( StringIdentity.identity( "" ), base, org.restlet.data.Method.GET );
+ return resourceBuilder.createRestLink( StringIdentity.identityOf( "" ), base, org.restlet.data.Method.GET );
}
private Object createParametersComposite( RestForm form, Class argType )
diff --git a/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/identity/IdentityManager.java b/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/identity/IdentityManager.java
index ec2a6c0..e7b66fa 100644
--- a/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/identity/IdentityManager.java
+++ b/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/identity/IdentityManager.java
@@ -80,10 +80,10 @@
if( isIdentity( canonicalName ) )
{
// This is already an ID, and we simply return it.
- return StringIdentity.identity( canonicalName );
+ return StringIdentity.identityOf( canonicalName );
}
String prefix = findPrefix( type );
- return StringIdentity.identity( prefix + SEPARATOR + canonicalName );
+ return StringIdentity.identityOf( prefix + SEPARATOR + canonicalName );
}
@Override
diff --git a/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/resource/EntryPointResource.java b/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/resource/EntryPointResource.java
index 2204980..b497ebd 100644
--- a/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/resource/EntryPointResource.java
+++ b/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/resource/EntryPointResource.java
@@ -80,18 +80,18 @@
RestLink link;
if( route.getDescription() == null )
{
- link = resourceBuilder.createRestLink( StringIdentity.identity( template.getPattern() ), hostRef, Method.GET );
+ link = resourceBuilder.createRestLink( StringIdentity.identityOf( template.getPattern() ), hostRef, Method.GET );
}
else
{
- link = resourceBuilder.createRestLink( StringIdentity.identity( template.getPattern() ), hostRef, Method.GET, route.getDescription() );
+ link = resourceBuilder.createRestLink( StringIdentity.identityOf( template.getPattern() ), hostRef, Method.GET, route.getDescription() );
}
entryPoints.put( route.getName(), link );
}
}
}
ValueBuilder<EntryPoint> builder = vbf.newValueBuilder( EntryPoint.class );
- builder.prototype().identity().set( StringIdentity.identity( "/" ) );
+ builder.prototype().identity().set( StringIdentity.identityOf( "/" ) );
builder.prototype().api().set( entryPoints );
return builder.newInstance();
}
diff --git a/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/resource/ResourceBuilder.java b/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/resource/ResourceBuilder.java
index b59aac8..be851a6 100644
--- a/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/resource/ResourceBuilder.java
+++ b/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/resource/ResourceBuilder.java
@@ -143,7 +143,7 @@
public RestForm createNameForm( Reference base )
{
ValueBuilder<RestForm> builder = vbf.newValueBuilder( RestForm.class );
- builder.prototype().link().set( createRestLink( StringIdentity.identity( "form" ), base, Method.POST ) );
+ builder.prototype().link().set( createRestLink( StringIdentity.identityOf( "form" ), base, Method.POST ) );
builder.prototype().fields().set( Collections.singletonList( createFormField( "name", FormField.TEXT ) ) );
return builder.newInstance();
}
diff --git a/libraries/sql/src/main/java/org/apache/polygene/library/sql/assembly/DataSourceAssembler.java b/libraries/sql/src/main/java/org/apache/polygene/library/sql/assembly/DataSourceAssembler.java
index e3d8e73..1618cc0 100644
--- a/libraries/sql/src/main/java/org/apache/polygene/library/sql/assembly/DataSourceAssembler.java
+++ b/libraries/sql/src/main/java/org/apache/polygene/library/sql/assembly/DataSourceAssembler.java
@@ -70,7 +70,7 @@
{
module.importedServices( DataSource.class ).
importedBy( ServiceInstanceImporter.class ).
- setMetaInfo( StringIdentity.identity( dataSourceServiceId ) ).
+ setMetaInfo( StringIdentity.identityOf( dataSourceServiceId ) ).
identifiedBy( identity() ).
visibleIn( visibility() );
if( circuitBreaker != null )
diff --git a/libraries/sql/src/main/java/org/apache/polygene/library/sql/assembly/ExternalDataSourceAssembler.java b/libraries/sql/src/main/java/org/apache/polygene/library/sql/assembly/ExternalDataSourceAssembler.java
index 78cf765..2e833bb 100644
--- a/libraries/sql/src/main/java/org/apache/polygene/library/sql/assembly/ExternalDataSourceAssembler.java
+++ b/libraries/sql/src/main/java/org/apache/polygene/library/sql/assembly/ExternalDataSourceAssembler.java
@@ -65,7 +65,7 @@
{
if( circuitBreaker != null )
{
- externalDataSource = DataSources.wrapWithCircuitBreaker( StringIdentity.identity( identity() ), externalDataSource, circuitBreaker );
+ externalDataSource = DataSources.wrapWithCircuitBreaker( StringIdentity.identityOf( identity() ), externalDataSource, circuitBreaker );
}
module.importedServices( DataSource.class ).
identifiedBy( identity() ).
diff --git a/libraries/sql/src/main/java/org/apache/polygene/library/sql/jmx/DataSourceConfigurationManagerService.java b/libraries/sql/src/main/java/org/apache/polygene/library/sql/jmx/DataSourceConfigurationManagerService.java
index ec49c23..fb279e1 100644
--- a/libraries/sql/src/main/java/org/apache/polygene/library/sql/jmx/DataSourceConfigurationManagerService.java
+++ b/libraries/sql/src/main/java/org/apache/polygene/library/sql/jmx/DataSourceConfigurationManagerService.java
@@ -175,7 +175,7 @@
EditableConfiguration( MBeanInfo info, String identity, Map<String, AccessibleObject> propertyNames )
{
this.info = info;
- this.identity = StringIdentity.identity( identity );
+ this.identity = StringIdentity.identityOf( identity );
this.propertyNames = propertyNames;
}
diff --git a/samples/dci/src/main/java/org/apache/polygene/dci/moneytransfer/context/PayBillsContext.java b/samples/dci/src/main/java/org/apache/polygene/dci/moneytransfer/context/PayBillsContext.java
index 9bd5878..1ae3c2b 100644
--- a/samples/dci/src/main/java/org/apache/polygene/dci/moneytransfer/context/PayBillsContext.java
+++ b/samples/dci/src/main/java/org/apache/polygene/dci/moneytransfer/context/PayBillsContext.java
@@ -133,8 +133,8 @@
{
// Creditor retrieval could be a use case in itself...
List<BalanceData> creditors = new ArrayList<BalanceData>();
- creditors.add( uowf.currentUnitOfWork().get( CreditorRolemap.class, StringIdentity.identity( "BakerAccount" ) ) );
- creditors.add( uowf.currentUnitOfWork().get( CreditorRolemap.class, StringIdentity.identity( "ButcherAccount" ) ) );
+ creditors.add( uowf.currentUnitOfWork().get( CreditorRolemap.class, StringIdentity.identityOf( "BakerAccount" ) ) );
+ creditors.add( uowf.currentUnitOfWork().get( CreditorRolemap.class, StringIdentity.identityOf( "ButcherAccount" ) ) );
return creditors;
}
diff --git a/samples/dci/src/main/java/org/apache/polygene/dci/moneytransfer/context/PayBillsContext2.java b/samples/dci/src/main/java/org/apache/polygene/dci/moneytransfer/context/PayBillsContext2.java
index ba5a40d..3606713 100644
--- a/samples/dci/src/main/java/org/apache/polygene/dci/moneytransfer/context/PayBillsContext2.java
+++ b/samples/dci/src/main/java/org/apache/polygene/dci/moneytransfer/context/PayBillsContext2.java
@@ -126,8 +126,8 @@
{
// Creditor retrieval could be a use case in itself...
List<BalanceData> creditors = new ArrayList<>();
- creditors.add( uowf.currentUnitOfWork().get( BalanceData.class, StringIdentity.identity( "BakerAccount" ) ) );
- creditors.add( uowf.currentUnitOfWork().get( BalanceData.class, StringIdentity.identity( "ButcherAccount" ) ) );
+ creditors.add( uowf.currentUnitOfWork().get( BalanceData.class, StringIdentity.identityOf( "BakerAccount" ) ) );
+ creditors.add( uowf.currentUnitOfWork().get( BalanceData.class, StringIdentity.identityOf( "ButcherAccount" ) ) );
return creditors;
}
diff --git a/samples/dci/src/test/java/org/apache/polygene/dci/moneytransfer/test/AccountIds.java b/samples/dci/src/test/java/org/apache/polygene/dci/moneytransfer/test/AccountIds.java
index 4456660..323335b 100644
--- a/samples/dci/src/test/java/org/apache/polygene/dci/moneytransfer/test/AccountIds.java
+++ b/samples/dci/src/test/java/org/apache/polygene/dci/moneytransfer/test/AccountIds.java
@@ -24,9 +24,9 @@
public interface AccountIds
{
- Identity SAVINGS_ACCOUNT_ID = StringIdentity.identity( "SavingsAccountId" );
- Identity CHECKING_ACCOUNT_ID = StringIdentity.identity( "CheckingAccountId" );
- Identity CREDITOR_ID1 = StringIdentity.identity( "BakerAccount" );
- Identity CREDITOR_ID2 = StringIdentity.identity( "ButcherAccount" );
+ Identity SAVINGS_ACCOUNT_ID = StringIdentity.identityOf( "SavingsAccountId" );
+ Identity CHECKING_ACCOUNT_ID = StringIdentity.identityOf( "CheckingAccountId" );
+ Identity CREDITOR_ID1 = StringIdentity.identityOf( "BakerAccount" );
+ Identity CREDITOR_ID2 = StringIdentity.identityOf( "ButcherAccount" );
}
diff --git a/samples/forum/src/main/java/org/apache/polygene/sample/forum/data/entity/Forums.java b/samples/forum/src/main/java/org/apache/polygene/sample/forum/data/entity/Forums.java
index cc70100..3dea65a 100644
--- a/samples/forum/src/main/java/org/apache/polygene/sample/forum/data/entity/Forums.java
+++ b/samples/forum/src/main/java/org/apache/polygene/sample/forum/data/entity/Forums.java
@@ -38,7 +38,7 @@
public interface Forums
extends Administrators, EntityComposite
{
- Identity FORUMS_ID = StringIdentity.identity( "forums" );
+ Identity FORUMS_ID = StringIdentity.identityOf( "forums" );
Query<Forum> forums();
diff --git a/samples/forum/src/main/java/org/apache/polygene/sample/forum/data/entity/Users.java b/samples/forum/src/main/java/org/apache/polygene/sample/forum/data/entity/Users.java
index aa16c40..41b9434 100644
--- a/samples/forum/src/main/java/org/apache/polygene/sample/forum/data/entity/Users.java
+++ b/samples/forum/src/main/java/org/apache/polygene/sample/forum/data/entity/Users.java
@@ -41,7 +41,7 @@
public interface Users
extends EntityComposite, Events
{
- Identity USERS_ID = StringIdentity.identity( "users" );
+ Identity USERS_ID = StringIdentity.identityOf( "users" );
Query<User> users();
diff --git a/samples/forum/src/main/java/org/apache/polygene/sample/forum/rest/resource/forum/BoardResource.java b/samples/forum/src/main/java/org/apache/polygene/sample/forum/rest/resource/forum/BoardResource.java
index f748192..eac4823 100644
--- a/samples/forum/src/main/java/org/apache/polygene/sample/forum/rest/resource/forum/BoardResource.java
+++ b/samples/forum/src/main/java/org/apache/polygene/sample/forum/rest/resource/forum/BoardResource.java
@@ -37,7 +37,7 @@
public void resource( String segment )
throws ResourceException
{
- selectFromManyAssociation( ObjectSelection.current().get( Forum.class ).boards(), StringIdentity.identity( segment ) );
+ selectFromManyAssociation( ObjectSelection.current().get( Forum.class ).boards(), StringIdentity.identityOf( segment ) );
subResource( BoardResource.class );
}
}
diff --git a/samples/forum/src/main/java/org/apache/polygene/sample/forum/rest/resource/forum/ForumResource.java b/samples/forum/src/main/java/org/apache/polygene/sample/forum/rest/resource/forum/ForumResource.java
index abf7c18..3e1fac4 100644
--- a/samples/forum/src/main/java/org/apache/polygene/sample/forum/rest/resource/forum/ForumResource.java
+++ b/samples/forum/src/main/java/org/apache/polygene/sample/forum/rest/resource/forum/ForumResource.java
@@ -37,7 +37,7 @@
public void resource( String segment )
throws ResourceException
{
- selectFromManyAssociation( ObjectSelection.current().get( Forum.class ).boards(), StringIdentity.identity( segment ) );
+ selectFromManyAssociation( ObjectSelection.current().get( Forum.class ).boards(), StringIdentity.identityOf( segment ) );
subResource( BoardResource.class );
}
}
diff --git a/samples/forum/src/main/java/org/apache/polygene/sample/forum/rest/resource/forum/ForumsResource.java b/samples/forum/src/main/java/org/apache/polygene/sample/forum/rest/resource/forum/ForumsResource.java
index 5c14ec2..1c1c60c 100644
--- a/samples/forum/src/main/java/org/apache/polygene/sample/forum/rest/resource/forum/ForumsResource.java
+++ b/samples/forum/src/main/java/org/apache/polygene/sample/forum/rest/resource/forum/ForumsResource.java
@@ -36,7 +36,7 @@
public void resource( String segment )
throws ResourceException
{
- select( Forum.class, StringIdentity.identity( segment ) );
+ select( Forum.class, StringIdentity.identityOf( segment ) );
subResource( ForumResource.class );
}
}
diff --git a/samples/rental/src/main/java/org/apache/polygene/sample/rental/domain/dev/InitialData.java b/samples/rental/src/main/java/org/apache/polygene/sample/rental/domain/dev/InitialData.java
index 0ac3450..db70f40 100644
--- a/samples/rental/src/main/java/org/apache/polygene/sample/rental/domain/dev/InitialData.java
+++ b/samples/rental/src/main/java/org/apache/polygene/sample/rental/domain/dev/InitialData.java
@@ -198,7 +198,7 @@
private RentalShop createShop( UnitOfWork uow )
throws UnitOfWorkCompletionException
{
- return uow.newEntity( RentalShop.class, StringIdentity.identity( "SHOP" ) );
+ return uow.newEntity( RentalShop.class, StringIdentity.identityOf( "SHOP" ) );
}
private void createCustomers( RentalShop shop )
diff --git a/samples/rental/src/main/java/org/apache/polygene/sample/rental/web/BookingPage.java b/samples/rental/src/main/java/org/apache/polygene/sample/rental/web/BookingPage.java
index 4c39f73..2aa0c98 100644
--- a/samples/rental/src/main/java/org/apache/polygene/sample/rental/web/BookingPage.java
+++ b/samples/rental/src/main/java/org/apache/polygene/sample/rental/web/BookingPage.java
@@ -52,7 +52,7 @@
Element result = dom.createElementNS( Page.XHTML, "div" );
String bookingId = context.path();
UnitOfWork uow = uowf.currentUnitOfWork();
- Booking booking = uow.get( Booking.class, StringIdentity.identity( bookingId ) );
+ Booking booking = uow.get( Booking.class, StringIdentity.identityOf( bookingId ) );
Car car = booking.car().get();
createChildNode( dom, result, car.model().get() );
createChildNode( dom, result, car.licensePlate().get() );
@@ -73,7 +73,7 @@
Element result = dom.createElementNS( Page.XHTML, "div" );
String bookingId = context.path();
UnitOfWork uow = uowf.currentUnitOfWork();
- Booking booking = uow.get( Booking.class, StringIdentity.identity( bookingId ) );
+ Booking booking = uow.get( Booking.class, StringIdentity.identityOf( bookingId ) );
Customer customer = booking.customer().get();
createChildNode( dom, result, customer.name().get() );
createChildNode( dom, result, customer.address().get().line1().get() );
diff --git a/samples/rental/src/main/java/org/apache/polygene/sample/rental/web/MainPage.java b/samples/rental/src/main/java/org/apache/polygene/sample/rental/web/MainPage.java
index 328c41b..884f702 100644
--- a/samples/rental/src/main/java/org/apache/polygene/sample/rental/web/MainPage.java
+++ b/samples/rental/src/main/java/org/apache/polygene/sample/rental/web/MainPage.java
@@ -59,7 +59,7 @@
ArrayList<Node> nodes = new ArrayList<Node>();
Document dom = context.dom();
UnitOfWork uow = uowf.currentUnitOfWork();
- RentalShop shop = uow.get( RentalShop.class, StringIdentity.identity( "SHOP" ) );
+ RentalShop shop = uow.get( RentalShop.class, StringIdentity.identityOf( "SHOP" ) );
for( Booking booking : shop.findAllBookings() )
{
String plate = booking.car().get().licensePlate().get();
diff --git a/tests/performance/src/main/java/org/apache/polygene/test/performance/entitystore/AbstractEntityStorePerformanceTest.java b/tests/performance/src/main/java/org/apache/polygene/test/performance/entitystore/AbstractEntityStorePerformanceTest.java
index 61de7ed..43be59d 100644
--- a/tests/performance/src/main/java/org/apache/polygene/test/performance/entitystore/AbstractEntityStorePerformanceTest.java
+++ b/tests/performance/src/main/java/org/apache/polygene/test/performance/entitystore/AbstractEntityStorePerformanceTest.java
@@ -243,7 +243,7 @@
UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "readEntityWithComplexType PREPARE " + bulk ) );
for( int i = 0; i < ITERATIONS; i++ )
{
- ComplexProduct product = uow.newEntity( ComplexProduct.class, StringIdentity.identity( "product" + i ) );
+ ComplexProduct product = uow.newEntity( ComplexProduct.class, StringIdentity.identityOf( "product" + i ) );
product.name().set( "Product " + i );
if( i % 1000 == 0 )
@@ -265,7 +265,7 @@
String id = rnd.nextInt( ITERATIONS ) + "";
for( int i = 0; i < ITERATIONS; i++ )
{
- ComplexProduct product = uow.get( ComplexProduct.class, StringIdentity.identity( "product" + id ) );
+ ComplexProduct product = uow.get( ComplexProduct.class, StringIdentity.identityOf( "product" + id ) );
product.name().get();
if( i % 100 == 0 )
{
diff --git a/tools/envisage/src/test/java/org/apache/polygene/envisage/school/domain/person/initialdata/SamplePersonInitialData.java b/tools/envisage/src/test/java/org/apache/polygene/envisage/school/domain/person/initialdata/SamplePersonInitialData.java
index 626415e..10fa526 100644
--- a/tools/envisage/src/test/java/org/apache/polygene/envisage/school/domain/person/initialdata/SamplePersonInitialData.java
+++ b/tools/envisage/src/test/java/org/apache/polygene/envisage/school/domain/person/initialdata/SamplePersonInitialData.java
@@ -94,7 +94,7 @@
private void createPerson( UnitOfWork uow, String personId, String firstName, String lastName )
{
- EntityBuilder<Person> person = uow.newEntityBuilder( Person.class, StringIdentity.identity( personId ) );
+ EntityBuilder<Person> person = uow.newEntityBuilder( Person.class, StringIdentity.identityOf( personId ) );
PersonEntity.PersonState state = person.instanceFor( PersonEntity.PersonState.class );
state.firstName().set( firstName );
diff --git a/tutorials/hello/src/test/java/org/apache/polygene/tutorials/hello/HelloTest4.java b/tutorials/hello/src/test/java/org/apache/polygene/tutorials/hello/HelloTest4.java
index dd103d8..908030f 100644
--- a/tutorials/hello/src/test/java/org/apache/polygene/tutorials/hello/HelloTest4.java
+++ b/tutorials/hello/src/test/java/org/apache/polygene/tutorials/hello/HelloTest4.java
@@ -35,7 +35,7 @@
public class HelloTest4 extends AbstractPolygeneTest
{
- public static final Identity TEST_IDENTITY = StringIdentity.identity( "123" );
+ public static final Identity TEST_IDENTITY = StringIdentity.identityOf( "123" );
@Override
public void assemble( ModuleAssembly module )