polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject [15/15] polygene-java git commit: Pushing for Tibor to assist.
Date Mon, 18 Sep 2017 15:21:11 GMT
Pushing for Tibor to assist.


Project: http://git-wip-us.apache.org/repos/asf/polygene-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/polygene-java/commit/3cca3c60
Tree: http://git-wip-us.apache.org/repos/asf/polygene-java/tree/3cca3c60
Diff: http://git-wip-us.apache.org/repos/asf/polygene-java/diff/3cca3c60

Branch: refs/heads/es-sql
Commit: 3cca3c6054cd2b3749f3a5830c9b8f58b5a42741
Parents: 58d19ab
Author: niclas <niclas@hedhman.org>
Authored: Mon Sep 18 23:19:02 2017 +0800
Committer: niclas <niclas@hedhman.org>
Committed: Mon Sep 18 23:19:02 2017 +0800

----------------------------------------------------------------------
 .../test/entity/AbstractEntityStoreTest.java    |  1 +
 .../polygene/entitystore/sql/EntitiesTable.java | 11 ++---
 .../entitystore/sql/JooqDslContext.java         | 38 +++++++++++++++--
 .../polygene/entitystore/sql/MixinTable.java    | 12 ++----
 .../entitystore/sql/SqlEntityStoreMixin.java    |  1 +
 .../polygene/entitystore/sql/SqlTable.java      | 16 +++----
 .../polygene/entitystore/sql/TypesTable.java    | 22 +++-------
 .../AbstractSQLEntityStoreAssembler.java        |  9 +++-
 .../sql/DerbySQLEntityStoreTest.java            | 23 +++-------
 .../sql/DerbySQLEntityStoreTestSuite.java       | 25 ++---------
 .../entitystore/sql/H2SQLEntityStoreTest.java   | 12 ++++++
 .../sql/H2SQLEntityStoreTestSuite.java          | 13 ++++++
 .../entitystore/sql/MySQLEntityStoreTest.java   | 25 +++--------
 .../sql/MySQLEntityStoreTestSuite.java          | 23 ++--------
 .../sql/PostgreSQLEntityStoreTest.java          | 27 ++++--------
 .../sql/PostgreSQLEntityStoreTestSuite.java     | 27 ++----------
 .../entitystore/sql/SQLiteEntityStoreTest.java  | 11 +++++
 .../sql/SQLiteEntityStoreTestSuite.java         | 12 ++++++
 .../polygene/entitystore/sql/TearDownUtil.java  | 44 ++++++++++++++++++++
 .../src/test/resources/logback.xml              |  1 +
 20 files changed, 186 insertions(+), 167 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/polygene-java/blob/3cca3c60/core/testsupport/src/main/java/org/apache/polygene/test/entity/AbstractEntityStoreTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/entity/AbstractEntityStoreTest.java
b/core/testsupport/src/main/java/org/apache/polygene/test/entity/AbstractEntityStoreTest.java
index 2812c4e..a349309 100644
--- a/core/testsupport/src/main/java/org/apache/polygene/test/entity/AbstractEntityStoreTest.java
+++ b/core/testsupport/src/main/java/org/apache/polygene/test/entity/AbstractEntityStoreTest.java
@@ -55,6 +55,7 @@ import org.apache.polygene.spi.entity.EntityState;
 import org.apache.polygene.spi.entitystore.EntityStore;
 import org.apache.polygene.test.AbstractPolygeneTest;
 import org.junit.After;
+import org.junit.Ignore;
 import org.junit.Test;
 
 import static java.time.ZoneOffset.UTC;

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/3cca3c60/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/EntitiesTable.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/EntitiesTable.java
b/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/EntitiesTable.java
index 257ca02..0bd9227 100644
--- a/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/EntitiesTable.java
+++ b/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/EntitiesTable.java
@@ -52,7 +52,6 @@ import org.jooq.Field;
 import org.jooq.Record;
 import org.jooq.RecordType;
 import org.jooq.Result;
-import org.jooq.Schema;
 import org.jooq.SelectJoinStep;
 import org.jooq.SelectQuery;
 import org.jooq.Table;
@@ -70,17 +69,15 @@ public class EntitiesTable
     private final Table<Record> entitiesTable;
     private JooqDslContext dsl;
     private final TypesTable types;
-    private final Schema schema;
     private String applicationVersion;
     private boolean replacementStrategy = false;  // Figure out later if we should support
both and if so, how.
 
-    EntitiesTable( JooqDslContext dsl, Schema schema, TypesTable types, String applicationVersion,
String entitiesTableName )
+    EntitiesTable( JooqDslContext dsl, TypesTable types, String applicationVersion, String
entitiesTableName )
     {
         this.dsl = dsl;
         this.types = types;
-        this.schema = schema;
         this.applicationVersion = applicationVersion;
-        entitiesTable = types.tableOf( entitiesTableName );
+        entitiesTable = dsl.tableOf( entitiesTableName );
     }
 
     public BaseEntity fetchEntity( EntityReference reference, ModuleDescriptor module )
@@ -165,7 +162,7 @@ public class EntitiesTable
 
     private MixinTable findMixinTable( Class<?> type, EntityDescriptor entityDescriptor
)
     {
-        return mixinTablesCache.computeIfAbsent( type, t -> new MixinTable( dsl, schema,
types, type, entityDescriptor ) );
+        return mixinTablesCache.computeIfAbsent( type, t -> new MixinTable( dsl, types,
type, entityDescriptor ) );
     }
 
     private Set<Class<?>> mixinsOf( Stream<? extends AssociationDescriptor>
stream )
@@ -222,7 +219,7 @@ public class EntitiesTable
         baseEntity.version = "1";
         baseEntity.applicationVersion = applicationVersion;
         baseEntity.identity = reference.identity();
-        baseEntity.currentValueIdentity = null;
+        baseEntity.currentValueIdentity = StringIdentity.identityOf( UUID.randomUUID().toString()
);
         baseEntity.modifedAt = currentTime;
         baseEntity.createdAt = currentTime;
         return baseEntity;

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/3cca3c60/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/JooqDslContext.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/JooqDslContext.java
b/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/JooqDslContext.java
index d89c058..be2f66b 100644
--- a/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/JooqDslContext.java
+++ b/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/JooqDslContext.java
@@ -25,7 +25,11 @@ import org.apache.polygene.api.injection.scope.Uses;
 import org.apache.polygene.api.mixin.Mixins;
 import org.jooq.Configuration;
 import org.jooq.DSLContext;
+import org.jooq.Name;
+import org.jooq.Record;
 import org.jooq.SQLDialect;
+import org.jooq.Schema;
+import org.jooq.Table;
 import org.jooq.conf.Settings;
 import org.jooq.impl.DSL;
 import org.jooq.impl.DefaultConfiguration;
@@ -33,14 +37,19 @@ import org.jooq.impl.DefaultConfiguration;
 @Mixins( JooqDslContext.Mixin.class )
 public interface JooqDslContext extends DSLContext
 {
+    boolean isSchemaCapable();
+    Name tableNameOf( String tableName );
+    Table<Record> tableOf( String tableName );
 
     class Mixin
         implements InvocationHandler
     {
-        private DSLContext dsl;
+        private final Schema schema;
+        private final DSLContext dsl;
 
-        public Mixin( @Service DataSource dataSource, @Uses Settings settings, @Uses SQLDialect
dialect )
+        public Mixin( @Service DataSource dataSource, @Uses Settings settings, @Uses SQLDialect
dialect, @Uses Schema schema )
         {
+            this.schema = schema;
             Configuration configuration = new DefaultConfiguration()
                 .set( dataSource )
                 .set( dialect )
@@ -49,10 +58,31 @@ public interface JooqDslContext extends DSLContext
         }
 
         @Override
-        public Object invoke( Object o, Method method, Object[] objects )
+        public Object invoke( Object o, Method method, Object[] args )
             throws Throwable
         {
-            return method.invoke( dsl, objects );       // delegate all
+            if(method.getName().equals( "tableOf" )){
+                return DSL.table(tableNameOf( (String) args[0] ) );
+            }
+            if(method.getName().equals( "tableNameOf" )){
+                return tableNameOf( (String) args[ 0 ] );
+            }
+
+            if(method.getName().equals( "isSchemaCapable" ))
+            {
+                return isSchemaCapable();
+            }
+            return method.invoke( dsl, args );       // delegate all
+        }
+
+        private Name tableNameOf( String name )
+        {
+            return this.isSchemaCapable() ? DSL.name( schema.getName(), name ) : DSL.name(
name );
+        }
+
+        private boolean isSchemaCapable()
+        {
+            return !dsl.dialect().equals( SQLDialect.SQLITE ) && !dsl.dialect().equals(
SQLDialect.MYSQL );
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/3cca3c60/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/MixinTable.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/MixinTable.java
b/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/MixinTable.java
index 80c26a2..9ddfe0e 100644
--- a/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/MixinTable.java
+++ b/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/MixinTable.java
@@ -36,12 +36,9 @@ import org.apache.polygene.spi.entitystore.helpers.DefaultEntityState;
 import org.jooq.Field;
 import org.jooq.InsertSetMoreStep;
 import org.jooq.InsertSetStep;
-import org.jooq.Name;
 import org.jooq.Record;
-import org.jooq.Schema;
 import org.jooq.Table;
 import org.jooq.UpdateSetMoreStep;
-import org.jooq.impl.DSL;
 
 class MixinTable
     implements TableFields
@@ -59,14 +56,14 @@ class MixinTable
     private TypesTable types;
     private final Class<?> mixinType;
 
-    MixinTable( JooqDslContext dsl, Schema schema, TypesTable types, Class<?> mixinType,
+    MixinTable( JooqDslContext dsl, TypesTable types, Class<?> mixinType,
                 EntityDescriptor descriptor )
     {
         this.dsl = dsl;
         this.types = types;
         this.mixinType = mixinType;
         mixinTable = types.tableFor( mixinType, descriptor );
-        mixinAssocsTable = getAssocsTable( descriptor, schema );
+        mixinAssocsTable = getAssocsTable( descriptor );
 
         descriptor.valueType().properties()
                   .filter( this::isThisMixin )
@@ -233,13 +230,12 @@ class MixinTable
         }
     }
 
-    private Table<Record> getAssocsTable( EntityDescriptor descriptor, Schema schema
)
+    private Table<Record> getAssocsTable( EntityDescriptor descriptor )
     {
         if( descriptor.state().manyAssociations().count() > 0
             || descriptor.state().namedAssociations().count() > 0 )
         {
-            Name tableName = DSL.name( schema.getName(), mixinTable.getName() + ASSOCS_TABLE_POSTFIX
);
-            Table<Record> table = DSL.table( tableName );
+            Table<Record> table = dsl.tableOf( mixinTable.getName() + ASSOCS_TABLE_POSTFIX
);
             int result2 = dsl.createTableIfNotExists( table )
                              .column( identityColumn )
                              .column( nameColumn )

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/3cca3c60/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/SqlEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/SqlEntityStoreMixin.java
b/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/SqlEntityStoreMixin.java
index 4fd7d3c..e881636 100644
--- a/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/SqlEntityStoreMixin.java
+++ b/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/SqlEntityStoreMixin.java
@@ -356,6 +356,7 @@ public class SqlEntityStoreMixin
                                                 removeState( state );
                                             }
                                         }
+
                                     } );
         }
 

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/3cca3c60/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/SqlTable.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/SqlTable.java
b/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/SqlTable.java
index c553532..9b2f7c6 100644
--- a/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/SqlTable.java
+++ b/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/SqlTable.java
@@ -195,24 +195,24 @@ public interface SqlTable extends ServiceActivation
         {
             SqlEntityStoreConfiguration config = this.configuration.get();
             SQLDialect dialect = getSqlDialect( config );
-
             Settings settings = serviceDescriptor
                 .metaInfo( Settings.class )
                 .withRenderNameStyle( RenderNameStyle.QUOTED );
-            dsl = tbf.newTransient( JooqDslContext.class, settings, dialect );
 
             String schemaName = config.schemaName().get();
             String typesTableName = config.typesTableName().get();
             String entitiesTableName = config.entitiesTableName().get();
             Schema schema = DSL.schema( DSL.name( schemaName ) );
-            types = new TypesTable( dsl, schema, dialect, typesTableName );
-            entitiesTable = new EntitiesTable( dsl, schema, types, application.version(),
entitiesTableName );
 
-            // Eventually create schema
+            dsl = tbf.newTransient( JooqDslContext.class, settings, dialect, schema );
+
+            types = new TypesTable( dsl, dialect, typesTableName );
+            entitiesTable = new EntitiesTable( dsl, types, application.version(), entitiesTableName
);
+
             if( config.createIfMissing().get() )
             {
                 dsl.transaction( t -> {
-                    if( !dialect.equals( SQLDialect.SQLITE )
+                    if( dsl.isSchemaCapable()
                         && dsl.meta().getSchemas().stream().noneMatch( s -> schema.getName().equalsIgnoreCase(
s.getName() ) ) )
                     {
                         dsl.createSchema( schemaName ).execute();
@@ -221,14 +221,14 @@ public interface SqlTable extends ServiceActivation
 
                 dsl.transaction( t -> {
 
-                    dsl.createTableIfNotExists( DSL.name( schemaName, typesTableName ) )
+                    dsl.createTableIfNotExists( dsl.tableNameOf( typesTableName ) )
                        .column( identityColumn )
                        .column( tableNameColumn )
                        .column( createdColumn )
                        .column( modifiedColumn )
                        .execute();
 
-                    dsl.createTableIfNotExists( DSL.name( schemaName, entitiesTableName )
)
+                    dsl.createTableIfNotExists( dsl.tableNameOf( entitiesTableName ) )
                        .column( identityColumn )
                        .column( applicationVersionColumn )
                        .column( valueIdentityColumn )

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/3cca3c60/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/TypesTable.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/TypesTable.java
b/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/TypesTable.java
index d04bc95..4c4b6ea 100644
--- a/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/TypesTable.java
+++ b/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/TypesTable.java
@@ -34,9 +34,9 @@ import org.jooq.Field;
 import org.jooq.Record;
 import org.jooq.Result;
 import org.jooq.SQLDialect;
-import org.jooq.Schema;
 import org.jooq.Table;
 import org.jooq.impl.DSL;
+import org.jooq.impl.DefaultDataType;
 
 public class TypesTable
     implements TableFields
@@ -46,18 +46,16 @@ public class TypesTable
 
     private final Table<Record> typesTable;
     private final SQLDialect dialect;
-    private final Schema schema;
 
     private final JooqDslContext dsl;
 
-    TypesTable( JooqDslContext dsl, Schema schema,
+    TypesTable( JooqDslContext dsl,
                 SQLDialect dialect,
                 String typesTablesName
               )
     {
-        this.schema = schema;
         this.dialect = dialect;
-        typesTable = tableOf( typesTablesName );
+        typesTable = dsl.tableOf( typesTablesName );
         this.dsl = dsl;
     }
 
@@ -66,14 +64,6 @@ public class TypesTable
         return DSL.field( DSL.name( columnName ), type );
     }
 
-    Table<Record> tableOf( String tableName )
-    {
-        return DSL.table(
-            dialect.equals( SQLDialect.SQLITE )
-            ? DSL.name( tableName )
-            : DSL.name( schema.getName(), tableName ) );
-    }
-
     String tableNameOf( Class<?> mixinType )
     {
         Result<Record> typeInfo = fetchTypeInfoFromTable( mixinType );
@@ -92,9 +82,9 @@ public class TypesTable
             if( tableName == null )
             {
                 Result<Record> newMixinTable = createNewMixinTable( type, descriptor
);
-                return tableOf( newMixinTable.getValue( 0, tableNameColumn ) );
+                return dsl.tableOf( newMixinTable.getValue( 0, tableNameColumn ) );
             }
-            return tableOf( tableName );
+            return dsl.tableOf( tableName );
         } );
     }
 
@@ -110,7 +100,7 @@ public class TypesTable
     {
         String mixinTypeName = mixinType.getName();
         String tableName = createNewTableName( mixinType );
-        CreateTableColumnStep primaryTable = dsl.createTable( DSL.name( schema.getName(),
tableName ) )
+        CreateTableColumnStep primaryTable = dsl.createTable( dsl.tableOf( tableName ) )
                                                 .column( identityColumn )
                                                 .column( createdColumn );
         descriptor.state().properties().forEach(

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/3cca3c60/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/assembly/AbstractSQLEntityStoreAssembler.java
----------------------------------------------------------------------
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 c9258ec..8e9273a 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
@@ -28,6 +28,7 @@ import org.apache.polygene.bootstrap.ModuleAssembly;
 import org.apache.polygene.entitystore.sql.JooqDslContext;
 import org.apache.polygene.entitystore.sql.SqlEntityStoreConfiguration;
 import org.apache.polygene.entitystore.sql.SqlEntityStoreService;
+import org.jooq.SQLDialect;
 import org.jooq.conf.RenderNameStyle;
 import org.jooq.conf.Settings;
 
@@ -60,14 +61,18 @@ public abstract class AbstractSQLEntityStoreAssembler<T extends AbstractSQLEntit
 
         if( hasConfig() )
         {
-            configModule().entities( SqlEntityStoreConfiguration.class ).visibleIn( configVisibility()
);
+            configModule().configurations( SqlEntityStoreConfiguration.class ).visibleIn(
configVisibility() );
+            SqlEntityStoreConfiguration defaults = configModule().forMixin( SqlEntityStoreConfiguration.class
)
+                                                                 .declareDefaults();
+            defaults.dialect().set( getSQLDialect().toString() );
         }
         super.assemble( module );
     }
 
+    protected abstract SQLDialect getSQLDialect();
+
     protected Settings getSettings()
     {
         return new Settings().withRenderNameStyle( RenderNameStyle.QUOTED );
     }
-
 }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/3cca3c60/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/DerbySQLEntityStoreTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/DerbySQLEntityStoreTest.java
b/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/DerbySQLEntityStoreTest.java
index 512c43e..5d7fc3d 100644
--- a/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/DerbySQLEntityStoreTest.java
+++ b/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/DerbySQLEntityStoreTest.java
@@ -23,6 +23,7 @@ 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.usecase.UsecaseBuilder;
 import org.apache.polygene.bootstrap.AssemblyException;
@@ -33,6 +34,7 @@ import org.apache.polygene.library.sql.assembly.DataSourceAssembler;
 import org.apache.polygene.library.sql.dbcp.DBCPDataSourceServiceAssembler;
 import org.apache.polygene.test.EntityTestAssembler;
 import org.apache.polygene.test.entity.AbstractEntityStoreTest;
+import org.junit.Ignore;
 
 import static org.apache.polygene.api.usecase.UsecaseBuilder.newUsecase;
 
@@ -77,23 +79,8 @@ public class DerbySQLEntityStoreTest
     public void tearDown()
         throws Exception
     {
-        UnitOfWork uow = this.unitOfWorkFactory.newUnitOfWork( newUsecase("Delete " + getClass().getSimpleName()
+ " test data" ) );
-        try
-        {
-            SqlEntityStoreConfiguration config = uow.get( SqlEntityStoreConfiguration.class,
-                                                          AbstractSQLEntityStoreAssembler.DEFAULT_ENTITYSTORE_IDENTITY
);
-            Connection connection = serviceFinder.findService( DataSource.class ).get().getConnection();
-            connection.setAutoCommit( false );
-            try( Statement stmt = connection.createStatement() )
-            {
-                stmt.execute( String.format( "DROP DATABASE FROM %s", config.schemaName().get()
) );
-                connection.commit();
-            }
-        }
-        finally
-        {
-            uow.discard();
-            super.tearDown();
-        }
+        Module storageModule = application.findModule( "Infrastructure Layer", "Storage Module"
);
+        TearDownUtil.cleanupSQL( storageModule, getClass().getSimpleName() );
+        super.tearDown();
     }
 }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/3cca3c60/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/DerbySQLEntityStoreTestSuite.java
----------------------------------------------------------------------
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
index cdfcd54..a6fa218 100644
--- 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
@@ -34,6 +34,7 @@ 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 org.junit.Ignore;
 
 import static org.apache.polygene.entitystore.sql.assembly.DerbySQLEntityStoreAssembler.DEFAULT_ENTITYSTORE_IDENTITY;
 
@@ -69,26 +70,8 @@ public class DerbySQLEntityStoreTestSuite extends EntityStoreTestSuite
     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,
-                                                          AbstractSQLEntityStoreAssembler.DEFAULT_ENTITYSTORE_IDENTITY
);
-            Connection connection = storageModule.serviceFinder().findService( DataSource.class
).get().getConnection();
-            connection.setAutoCommit( false );
-            try( Statement stmt = connection.createStatement() )
-            {
-                stmt.execute( String.format( "DROP DATABASE FROM %s", config.schemaName().get()
) );
-                connection.commit();
-            }
-        }
-        finally
-        {
-            uow.discard();
-            super.tearDown();
-        }
+        Module storageModule = application.findModule( "Infrastructure Layer", "Storage Module"
);
+        TearDownUtil.cleanupSQL( storageModule, getClass().getSimpleName() );
+        super.tearDown();
     }
 }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/3cca3c60/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/H2SQLEntityStoreTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/H2SQLEntityStoreTest.java
b/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/H2SQLEntityStoreTest.java
index 4b4b759..2b997c8 100644
--- a/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/H2SQLEntityStoreTest.java
+++ b/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/H2SQLEntityStoreTest.java
@@ -20,6 +20,7 @@
 package org.apache.polygene.entitystore.sql;
 
 import org.apache.polygene.api.common.Visibility;
+import org.apache.polygene.api.structure.Module;
 import org.apache.polygene.bootstrap.AssemblyException;
 import org.apache.polygene.bootstrap.ModuleAssembly;
 import org.apache.polygene.entitystore.sql.assembly.H2SQLEntityStoreAssembler;
@@ -27,6 +28,8 @@ import org.apache.polygene.library.sql.assembly.DataSourceAssembler;
 import org.apache.polygene.library.sql.dbcp.DBCPDataSourceServiceAssembler;
 import org.apache.polygene.test.EntityTestAssembler;
 import org.apache.polygene.test.entity.AbstractEntityStoreTest;
+import org.junit.After;
+import org.junit.Ignore;
 
 public class H2SQLEntityStoreTest
     extends AbstractEntityStoreTest
@@ -64,4 +67,13 @@ public class H2SQLEntityStoreTest
             .assemble( module );
     }
     // END SNIPPET: assembly
+
+    @After
+    public void tearDown()
+        throws Exception
+    {
+        Module storageModule = application.findModule( "Infrastructure Layer", "Storage Module"
);
+        TearDownUtil.cleanupSQL( storageModule, getClass().getSimpleName() );
+        super.tearDown();
+    }
 }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/3cca3c60/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/H2SQLEntityStoreTestSuite.java
----------------------------------------------------------------------
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
index f763238..32dfcb2 100644
--- 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
@@ -20,11 +20,14 @@
 package org.apache.polygene.entitystore.sql;
 
 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.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;
+import org.junit.After;
+import org.junit.Ignore;
 
 public class H2SQLEntityStoreTestSuite extends EntityStoreTestSuite
 {
@@ -53,4 +56,14 @@ public class H2SQLEntityStoreTestSuite extends EntityStoreTestSuite
             .withConfig( configModule, Visibility.application )
             .assemble( module );
     }
+
+    @After
+    public void tearDown()
+        throws Exception
+    {
+        Module storageModule = application.findModule( "Infrastructure Layer", "Storage Module"
);
+        TearDownUtil.cleanupSQL( storageModule, getClass().getSimpleName() );
+        super.tearDown();
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/3cca3c60/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/MySQLEntityStoreTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/MySQLEntityStoreTest.java
b/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/MySQLEntityStoreTest.java
index fe8da9c..dd9759b 100644
--- a/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/MySQLEntityStoreTest.java
+++ b/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/MySQLEntityStoreTest.java
@@ -24,6 +24,7 @@ import java.sql.Statement;
 import java.util.HashMap;
 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.usecase.UsecaseBuilder;
 import org.apache.polygene.bootstrap.AssemblyException;
@@ -37,6 +38,7 @@ import org.apache.polygene.test.EntityTestAssembler;
 import org.apache.polygene.test.docker.DockerRule;
 import org.apache.polygene.test.entity.AbstractEntityStoreTest;
 import org.junit.ClassRule;
+import org.junit.Ignore;
 
 public class MySQLEntityStoreTest
     extends AbstractEntityStoreTest
@@ -101,25 +103,8 @@ public class MySQLEntityStoreTest
     public void tearDown()
         throws Exception
     {
-        UnitOfWork uow = this.unitOfWorkFactory.newUnitOfWork(
-            UsecaseBuilder.newUsecase( "Delete " + getClass().getSimpleName() + " test data"
)
-                                                             );
-        try
-        {
-            Connection connection = serviceFinder.findService( DataSource.class ).get().getConnection();
-            SqlEntityStoreConfiguration config = uow.get( SqlEntityStoreConfiguration.class,
-                                                          AbstractSQLEntityStoreAssembler.DEFAULT_ENTITYSTORE_IDENTITY
);
-            connection.setAutoCommit( false );
-            try( Statement stmt = connection.createStatement() )
-            {
-                stmt.execute( String.format( "DROP DATABASE FROM %s", config.schemaName().get()
) );
-                connection.commit();
-            }
-        }
-        finally
-        {
-            uow.discard();
-            super.tearDown();
-        }
+        Module storageModule = application.findModule( "Infrastructure Layer", "Storage Module"
);
+        TearDownUtil.cleanupSQL( storageModule, getClass().getSimpleName() );
+        super.tearDown();
     }
 }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/3cca3c60/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/MySQLEntityStoreTestSuite.java
----------------------------------------------------------------------
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
index f625317..c3d2919 100644
--- 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
@@ -37,6 +37,7 @@ 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 org.junit.Ignore;
 
 import static org.apache.polygene.api.usecase.UsecaseBuilder.newUsecase;
 
@@ -94,25 +95,7 @@ public class MySQLEntityStoreTestSuite extends EntityStoreTestSuite
         throws Exception
     {
         Module storageModule = application.findModule( "Infrastructure Layer", "Storage Module"
);
-        UnitOfWorkFactory uowf = storageModule.unitOfWorkFactory();
-        ServiceFinder serviceFinder = storageModule.serviceFinder();
-        UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "Delete " + getClass().getSimpleName()
+ " test data" ) );
-        try
-        {
-            Connection connection = serviceFinder.findService( DataSource.class ).get().getConnection();
-            SqlEntityStoreConfiguration config = uow.get( SqlEntityStoreConfiguration.class,
-                                                          AbstractSQLEntityStoreAssembler.DEFAULT_ENTITYSTORE_IDENTITY
);
-            connection.setAutoCommit( false );
-            try( Statement stmt = connection.createStatement() )
-            {
-                stmt.execute( String.format( "DROP DATABASE FROM %s", config.schemaName().get()
) );
-                connection.commit();
-            }
-        }
-        finally
-        {
-            uow.discard();
-            super.tearDown();
-        }
+        TearDownUtil.cleanupSQL( storageModule, getClass().getSimpleName() );
+        super.tearDown();
     }
 }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/3cca3c60/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/PostgreSQLEntityStoreTest.java
----------------------------------------------------------------------
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 1122c71..d7ef07c 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
@@ -25,6 +25,7 @@ import java.util.HashMap;
 import java.util.Map;
 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.bootstrap.AssemblyException;
 import org.apache.polygene.bootstrap.ModuleAssembly;
@@ -91,12 +92,16 @@ public class PostgreSQLEntityStoreTest
             .withConfig( config, Visibility.layer )
             .assemble( module );
         // END SNIPPET: assembly
+
+
         String host = DOCKER.getDockerHost();
         int port = DOCKER.getExposedContainerPort( "5432/tcp" );
+
         DataSourceConfiguration defaults = config.forMixin( DataSourceConfiguration.class
).declareDefaults();
         defaults.url().set( "jdbc:postgresql://" + host + ":" + port + "/jdbc_test_db" );
         defaults.username().set( System.getProperty( "user.name" ) );
         defaults.password().set( "ThisIsGreat!" );
+
         // START SNIPPET: assembly
     }
     // END SNIPPET: assembly
@@ -105,24 +110,8 @@ public class PostgreSQLEntityStoreTest
     public void tearDown()
         throws Exception
     {
-        String usecaseName = "Delete " + getClass().getSimpleName() + " test data";
-        UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( newUsecase( usecaseName ) );
-        try
-        {
-            SQLConfiguration config = uow.get( SQLConfiguration.class, AbstractSQLEntityStoreAssembler.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();
-        }
+        Module storageModule = application.findModule( "Infrastructure Layer", "Storage Module"
);
+        TearDownUtil.cleanupSQL( storageModule, getClass().getSimpleName() );
+        super.tearDown();
     }
 }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/3cca3c60/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/PostgreSQLEntityStoreTestSuite.java
----------------------------------------------------------------------
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
index d53c7d1..d35fce0 100644
--- 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
@@ -27,7 +27,6 @@ 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.AbstractSQLEntityStoreAssembler;
 import org.apache.polygene.entitystore.sql.assembly.PostgreSQLEntityStoreAssembler;
@@ -39,7 +38,7 @@ 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;
+import static org.apache.polygene.api.usecase.UsecaseBuilder.newUsecase;
 
 public class PostgreSQLEntityStoreTestSuite extends EntityStoreTestSuite
 {
@@ -86,27 +85,7 @@ public class PostgreSQLEntityStoreTestSuite extends EntityStoreTestSuite
         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, AbstractSQLEntityStoreAssembler.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();
-        }
+        TearDownUtil.cleanupSQL(storageModule, getClass().getSimpleName());
+        super.tearDown();
     }
 }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/3cca3c60/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/SQLiteEntityStoreTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/SQLiteEntityStoreTest.java
b/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/SQLiteEntityStoreTest.java
index 83e8a21..14a52a0 100644
--- a/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/SQLiteEntityStoreTest.java
+++ b/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/SQLiteEntityStoreTest.java
@@ -20,6 +20,7 @@
 package org.apache.polygene.entitystore.sql;
 
 import org.apache.polygene.api.common.Visibility;
+import org.apache.polygene.api.structure.Module;
 import org.apache.polygene.bootstrap.AssemblyException;
 import org.apache.polygene.bootstrap.ModuleAssembly;
 import org.apache.polygene.entitystore.sql.assembly.SQLiteEntityStoreAssembler;
@@ -27,6 +28,7 @@ import org.apache.polygene.library.sql.assembly.DataSourceAssembler;
 import org.apache.polygene.library.sql.dbcp.DBCPDataSourceServiceAssembler;
 import org.apache.polygene.test.EntityTestAssembler;
 import org.apache.polygene.test.entity.AbstractEntityStoreTest;
+import org.junit.After;
 import org.junit.BeforeClass;
 
 import static org.apache.polygene.test.util.Assume.assumeNoIbmJdk;
@@ -72,4 +74,13 @@ public class SQLiteEntityStoreTest extends AbstractEntityStoreTest
             .assemble( module );
     }
     // END SNIPPET: assembly
+
+    @After
+    public void tearDown()
+        throws Exception
+    {
+        Module storageModule = application.findModule( "Infrastructure Layer", "Storage Module"
);
+        TearDownUtil.cleanupSQL( storageModule, getClass().getSimpleName() );
+        super.tearDown();
+    }
 }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/3cca3c60/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/SQLiteEntityStoreTestSuite.java
----------------------------------------------------------------------
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
index 6dc5fbe..678309b 100644
--- 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
@@ -20,11 +20,13 @@
 package org.apache.polygene.entitystore.sql;
 
 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.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.After;
 import org.junit.BeforeClass;
 
 import static org.apache.polygene.test.util.Assume.assumeNoIbmJdk;
@@ -62,4 +64,14 @@ public class SQLiteEntityStoreTestSuite extends EntityStoreTestSuite
             .withConfig( configModule, Visibility.application )
             .assemble( module );
     }
+
+    @After
+    public void tearDown()
+        throws Exception
+    {
+        Module storageModule = application.findModule( "Infrastructure Layer", "Storage Module"
);
+        TearDownUtil.cleanupSQL( storageModule, getClass().getSimpleName() );
+        super.tearDown();
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/3cca3c60/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/TearDownUtil.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/TearDownUtil.java
b/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/TearDownUtil.java
new file mode 100644
index 0000000..31a15d5
--- /dev/null
+++ b/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/TearDownUtil.java
@@ -0,0 +1,44 @@
+package org.apache.polygene.entitystore.sql;
+
+import java.sql.Connection;
+import java.sql.Statement;
+import javax.sql.DataSource;
+import org.apache.polygene.api.service.ServiceFinder;
+import org.apache.polygene.api.structure.Application;
+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.entitystore.sql.assembly.AbstractSQLEntityStoreAssembler;
+import org.apache.polygene.library.sql.common.SQLConfiguration;
+
+import static org.apache.polygene.api.usecase.UsecaseBuilder.newUsecase;
+
+public class TearDownUtil
+{
+
+    public static void cleanupSQL( Module storageModule, String testName )
+        throws Exception
+    {
+        String usecaseName = "Delete " + testName + " test data";
+        UnitOfWorkFactory uowf = storageModule.unitOfWorkFactory();
+        ServiceFinder serviceFinder = storageModule.serviceFinder();
+        UnitOfWork uow = uowf.newUnitOfWork( newUsecase( usecaseName ) );
+        try
+        {
+            SQLConfiguration config = uow.get( SQLConfiguration.class, AbstractSQLEntityStoreAssembler.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();
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/3cca3c60/extensions/entitystore-sql/src/test/resources/logback.xml
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sql/src/test/resources/logback.xml b/extensions/entitystore-sql/src/test/resources/logback.xml
index 03fb4dd..0ca004d 100644
--- a/extensions/entitystore-sql/src/test/resources/logback.xml
+++ b/extensions/entitystore-sql/src/test/resources/logback.xml
@@ -30,6 +30,7 @@
         <appender-ref ref="stdout" />
     </root>
 
+    <logger name="org.jooq" level="debug"/>
     <logger name="org.apache.polygene.entitystore.sql" level="debug"/>
 
 </configuration>
\ No newline at end of file


Mime
View raw message