You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polygene.apache.org by ni...@apache.org on 2017/10/26 07:34:56 UTC
[26/33] polygene-java git commit: Introducing the whole test suite
from entitystore-sqlkv and starting to solidify the implementation against
all these SQL systems.
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/0f8f0b8d/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sql/MySQLEntityStoreTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sql/MySQLEntityStoreTest.java b/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sql/MySQLEntityStoreTest.java
deleted file mode 100644
index a940e95..0000000
--- a/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sql/MySQLEntityStoreTest.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.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.unitofwork.UnitOfWork;
-import org.apache.polygene.api.usecase.UsecaseBuilder;
-import org.apache.polygene.bootstrap.AssemblyException;
-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.EntityTestAssembler;
-import org.apache.polygene.test.docker.DockerRule;
-import org.apache.polygene.test.entity.AbstractEntityStoreTest;
-import org.junit.ClassRule;
-
-import static org.apache.polygene.entitystore.sql.assembly.MySQLEntityStoreAssembler.DEFAULT_ENTITYSTORE_IDENTITY;
-
-public class MySQLEntityStoreTest
- extends AbstractEntityStoreTest
-{
- @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
- // START SNIPPET: assembly
- public void assemble( ModuleAssembly module )
- throws AssemblyException
- {
- // END SNIPPET: assembly
- super.assemble( module );
- ModuleAssembly config = module.layer().module( "config" );
- new EntityTestAssembler().defaultServicesVisibleIn( Visibility.layer ).assemble( config );
-
- // START SNIPPET: assembly
- // DataSourceService
- new DBCPDataSourceServiceAssembler()
- .identifiedBy( "mysql-datasource-service" )
- .visibleIn( Visibility.module )
- .withConfig( config, Visibility.layer )
- .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( config, Visibility.layer )
- .assemble( module );
- // END SNIPPET: assembly
- String mysqlHost = DOCKER.getDockerHost();
- int mysqlPort = DOCKER.getExposedContainerPort( "3306/tcp" );
- config.forMixin( DataSourceConfiguration.class ).declareDefaults()
- .url().set( "jdbc:mysql://" + mysqlHost + ":" + mysqlPort
- + "/jdbc_test_db?profileSQL=false&useLegacyDatetimeCode=false&serverTimezone=UTC"
- + "&nullCatalogMeansCurrent=true&nullNamePatternMatchesAll=true" );
- // START SNIPPET: assembly
- }
- // END SNIPPET: assembly
-
- @Override
- 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 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();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/0f8f0b8d/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sql/MySQLEntityStoreTestSuite.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sql/MySQLEntityStoreTestSuite.java b/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sql/MySQLEntityStoreTestSuite.java
deleted file mode 100644
index e2b0564..0000000
--- a/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sql/MySQLEntityStoreTestSuite.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.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();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/0f8f0b8d/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sql/PostgreSQLEntityStoreTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sql/PostgreSQLEntityStoreTest.java b/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sql/PostgreSQLEntityStoreTest.java
deleted file mode 100644
index daa9949..0000000
--- a/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sql/PostgreSQLEntityStoreTest.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.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.unitofwork.UnitOfWork;
-import org.apache.polygene.api.usecase.UsecaseBuilder;
-import org.apache.polygene.bootstrap.AssemblyException;
-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.EntityTestAssembler;
-import org.apache.polygene.test.docker.DockerRule;
-import org.apache.polygene.test.entity.AbstractEntityStoreTest;
-import org.junit.ClassRule;
-
-import static org.apache.polygene.entitystore.sql.assembly.PostgreSQLEntityStoreAssembler.DEFAULT_ENTITYSTORE_IDENTITY;
-
-public class PostgreSQLEntityStoreTest
- extends AbstractEntityStoreTest
-{
- @ClassRule
- public static final DockerRule DOCKER = new DockerRule( "postgres",
- 3000L,
- "PostgreSQL init process complete; ready for start up." );
-
- @Override
- // START SNIPPET: assembly
- public void assemble( ModuleAssembly module )
- throws AssemblyException
- {
- // END SNIPPET: assembly
- super.assemble( module );
- ModuleAssembly config = module.layer().module( "config" );
- new EntityTestAssembler().defaultServicesVisibleIn( Visibility.layer ).assemble( config );
-
- // START SNIPPET: assembly
- // DataSourceService
- new DBCPDataSourceServiceAssembler()
- .identifiedBy( "postgresql-datasource-service" )
- .visibleIn( Visibility.module )
- .withConfig( config, Visibility.layer )
- .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( config, Visibility.layer )
- .assemble( module );
- // END SNIPPET: assembly
- String host = DOCKER.getDockerHost();
- int port = DOCKER.getExposedContainerPort( "5432/tcp" );
- config.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
- {
- UnitOfWork uow = unitOfWorkFactory.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();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/0f8f0b8d/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sql/PostgreSQLEntityStoreTestSuite.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sql/PostgreSQLEntityStoreTestSuite.java b/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sql/PostgreSQLEntityStoreTestSuite.java
deleted file mode 100644
index d1dd952..0000000
--- a/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sql/PostgreSQLEntityStoreTestSuite.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.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();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/0f8f0b8d/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sql/SQLiteEntityStoreTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sql/SQLiteEntityStoreTest.java b/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sql/SQLiteEntityStoreTest.java
deleted file mode 100644
index 83e8a21..0000000
--- a/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sql/SQLiteEntityStoreTest.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.polygene.entitystore.sql;
-
-import org.apache.polygene.api.common.Visibility;
-import org.apache.polygene.bootstrap.AssemblyException;
-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.EntityTestAssembler;
-import org.apache.polygene.test.entity.AbstractEntityStoreTest;
-import org.junit.BeforeClass;
-
-import static org.apache.polygene.test.util.Assume.assumeNoIbmJdk;
-
-public class SQLiteEntityStoreTest extends AbstractEntityStoreTest
-{
- @BeforeClass
- public static void beforeClass_IBMJDK()
- {
- assumeNoIbmJdk();
- }
-
- @Override
- // START SNIPPET: assembly
- public void assemble( ModuleAssembly module )
- throws AssemblyException
- {
- // END SNIPPET: assembly
- super.assemble( module );
- ModuleAssembly config = module.layer().module( "config" );
- new EntityTestAssembler().defaultServicesVisibleIn( Visibility.layer ).assemble( config );
-
- // START SNIPPET: assembly
- // DataSourceService
- new DBCPDataSourceServiceAssembler()
- .identifiedBy( "sqlite-datasource-service" )
- .visibleIn( Visibility.module )
- .withConfig( config, Visibility.layer )
- .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( config, Visibility.layer )
- .assemble( module );
- }
- // END SNIPPET: assembly
-}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/0f8f0b8d/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sql/SQLiteEntityStoreTestSuite.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sql/SQLiteEntityStoreTestSuite.java b/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sql/SQLiteEntityStoreTestSuite.java
deleted file mode 100644
index 6dc5fbe..0000000
--- a/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sql/SQLiteEntityStoreTestSuite.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.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 );
- }
-}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/0f8f0b8d/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sqlkv/DerbySQLEntityStoreTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sqlkv/DerbySQLEntityStoreTest.java b/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sqlkv/DerbySQLEntityStoreTest.java
new file mode 100644
index 0000000..627699f
--- /dev/null
+++ b/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sqlkv/DerbySQLEntityStoreTest.java
@@ -0,0 +1,102 @@
+/*
+ * 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.sqlkv;
+
+import java.sql.Connection;
+import java.sql.Statement;
+import javax.sql.DataSource;
+import org.apache.polygene.api.common.Visibility;
+import org.apache.polygene.api.unitofwork.UnitOfWork;
+import org.apache.polygene.api.usecase.UsecaseBuilder;
+import org.apache.polygene.bootstrap.AssemblyException;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.entitystore.sqlkv.SQLEntityStoreConfiguration;
+import org.apache.polygene.entitystore.sqlkv.assembly.DerbySQLEntityStoreAssembler;
+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 static org.apache.polygene.entitystore.sqlkv.assembly.DerbySQLEntityStoreAssembler.DEFAULT_ENTITYSTORE_IDENTITY;
+
+public class DerbySQLEntityStoreTest
+ extends AbstractEntityStoreTest
+{
+ @Override
+ // START SNIPPET: assembly
+ public void assemble( ModuleAssembly module )
+ throws AssemblyException
+ {
+ // END SNIPPET: assembly
+ super.assemble( module );
+ ModuleAssembly config = module.layer().module( "config" );
+ new EntityTestAssembler().defaultServicesVisibleIn( Visibility.layer ).assemble( config );
+
+ // START SNIPPET: assembly
+ // DataSourceService
+ new DBCPDataSourceServiceAssembler()
+ .identifiedBy( "derby-datasource-service" )
+ .visibleIn( Visibility.module )
+ .withConfig( config, Visibility.layer )
+ .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( config, Visibility.layer )
+ .assemble( module );
+ }
+ // END SNIPPET: assembly
+
+ @Override
+ public void tearDown()
+ throws Exception
+ {
+ UnitOfWork uow = this.unitOfWorkFactory.newUnitOfWork( UsecaseBuilder.newUsecase(
+ "Delete " + getClass().getSimpleName() + " test data" ) );
+ try
+ {
+ SQLEntityStoreConfiguration config = uow.get( SQLEntityStoreConfiguration.class,
+ DEFAULT_ENTITYSTORE_IDENTITY );
+ Connection connection = 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();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/0f8f0b8d/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sqlkv/DerbySQLEntityStoreTestSuite.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sqlkv/DerbySQLEntityStoreTestSuite.java b/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sqlkv/DerbySQLEntityStoreTestSuite.java
new file mode 100644
index 0000000..b5d3949
--- /dev/null
+++ b/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sqlkv/DerbySQLEntityStoreTestSuite.java
@@ -0,0 +1,95 @@
+/*
+ * 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.sqlkv;
+
+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.sqlkv.SQLEntityStoreConfiguration;
+import org.apache.polygene.entitystore.sqlkv.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.sqlkv.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();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/0f8f0b8d/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sqlkv/H2SQLEntityStoreTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sqlkv/H2SQLEntityStoreTest.java b/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sqlkv/H2SQLEntityStoreTest.java
new file mode 100644
index 0000000..1303106
--- /dev/null
+++ b/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sqlkv/H2SQLEntityStoreTest.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.entitystore.sqlkv;
+
+import org.apache.polygene.api.common.Visibility;
+import org.apache.polygene.bootstrap.AssemblyException;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.entitystore.sqlkv.assembly.H2SQLEntityStoreAssembler;
+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;
+
+public class H2SQLEntityStoreTest
+ extends AbstractEntityStoreTest
+{
+ @Override
+ // START SNIPPET: assembly
+ public void assemble( ModuleAssembly module )
+ throws AssemblyException
+ {
+ // END SNIPPET: assembly
+ super.assemble( module );
+ ModuleAssembly config = module.layer().module( "config" );
+ new EntityTestAssembler().defaultServicesVisibleIn( Visibility.layer ).assemble( config );
+
+ // START SNIPPET: assembly
+ // DataSourceService
+ new DBCPDataSourceServiceAssembler()
+ .identifiedBy( "h2-datasource-service" )
+ .visibleIn( Visibility.module )
+ .withConfig( config, Visibility.layer )
+ .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( config, Visibility.layer )
+ .assemble( module );
+ }
+ // END SNIPPET: assembly
+}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/0f8f0b8d/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sqlkv/H2SQLEntityStoreTestSuite.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sqlkv/H2SQLEntityStoreTestSuite.java b/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sqlkv/H2SQLEntityStoreTestSuite.java
new file mode 100644
index 0000000..daa3030
--- /dev/null
+++ b/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sqlkv/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.sqlkv;
+
+import org.apache.polygene.api.common.Visibility;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.entitystore.sqlkv.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 );
+ }
+}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/0f8f0b8d/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sqlkv/MySQLEntityStoreTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sqlkv/MySQLEntityStoreTest.java b/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sqlkv/MySQLEntityStoreTest.java
new file mode 100644
index 0000000..3c9f689
--- /dev/null
+++ b/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sqlkv/MySQLEntityStoreTest.java
@@ -0,0 +1,128 @@
+/*
+ * 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.sqlkv;
+
+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.unitofwork.UnitOfWork;
+import org.apache.polygene.api.usecase.UsecaseBuilder;
+import org.apache.polygene.bootstrap.AssemblyException;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.entitystore.sqlkv.SQLEntityStoreConfiguration;
+import org.apache.polygene.entitystore.sqlkv.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.EntityTestAssembler;
+import org.apache.polygene.test.docker.DockerRule;
+import org.apache.polygene.test.entity.AbstractEntityStoreTest;
+import org.junit.ClassRule;
+
+import static org.apache.polygene.entitystore.sqlkv.assembly.MySQLEntityStoreAssembler.DEFAULT_ENTITYSTORE_IDENTITY;
+
+public class MySQLEntityStoreTest
+ extends AbstractEntityStoreTest
+{
+ @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
+ // START SNIPPET: assembly
+ public void assemble( ModuleAssembly module )
+ throws AssemblyException
+ {
+ // END SNIPPET: assembly
+ super.assemble( module );
+ ModuleAssembly config = module.layer().module( "config" );
+ new EntityTestAssembler().defaultServicesVisibleIn( Visibility.layer ).assemble( config );
+
+ // START SNIPPET: assembly
+ // DataSourceService
+ new DBCPDataSourceServiceAssembler()
+ .identifiedBy( "mysql-datasource-service" )
+ .visibleIn( Visibility.module )
+ .withConfig( config, Visibility.layer )
+ .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( config, Visibility.layer )
+ .assemble( module );
+ // END SNIPPET: assembly
+ String mysqlHost = DOCKER.getDockerHost();
+ int mysqlPort = DOCKER.getExposedContainerPort( "3306/tcp" );
+ config.forMixin( DataSourceConfiguration.class ).declareDefaults()
+ .url().set( "jdbc:mysql://" + mysqlHost + ":" + mysqlPort
+ + "/jdbc_test_db?profileSQL=false&useLegacyDatetimeCode=false&serverTimezone=UTC"
+ + "&nullCatalogMeansCurrent=true&nullNamePatternMatchesAll=true" );
+ // START SNIPPET: assembly
+ }
+ // END SNIPPET: assembly
+
+ @Override
+ 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 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();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/0f8f0b8d/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sqlkv/MySQLEntityStoreTestSuite.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sqlkv/MySQLEntityStoreTestSuite.java b/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sqlkv/MySQLEntityStoreTestSuite.java
new file mode 100644
index 0000000..65f6b72
--- /dev/null
+++ b/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sqlkv/MySQLEntityStoreTestSuite.java
@@ -0,0 +1,123 @@
+/*
+ * 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.sqlkv;
+
+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.sqlkv.SQLEntityStoreConfiguration;
+import org.apache.polygene.entitystore.sqlkv.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.sqlkv.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();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/0f8f0b8d/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sqlkv/PostgreSQLEntityStoreTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sqlkv/PostgreSQLEntityStoreTest.java b/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sqlkv/PostgreSQLEntityStoreTest.java
new file mode 100644
index 0000000..2525265
--- /dev/null
+++ b/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sqlkv/PostgreSQLEntityStoreTest.java
@@ -0,0 +1,115 @@
+/*
+ * 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.sqlkv;
+
+import java.sql.Connection;
+import java.sql.Statement;
+import javax.sql.DataSource;
+import org.apache.polygene.api.common.Visibility;
+import org.apache.polygene.api.unitofwork.UnitOfWork;
+import org.apache.polygene.api.usecase.UsecaseBuilder;
+import org.apache.polygene.bootstrap.AssemblyException;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.entitystore.sqlkv.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.EntityTestAssembler;
+import org.apache.polygene.test.docker.DockerRule;
+import org.apache.polygene.test.entity.AbstractEntityStoreTest;
+import org.junit.ClassRule;
+
+import static org.apache.polygene.entitystore.sqlkv.assembly.PostgreSQLEntityStoreAssembler.DEFAULT_ENTITYSTORE_IDENTITY;
+
+public class PostgreSQLEntityStoreTest
+ extends AbstractEntityStoreTest
+{
+ @ClassRule
+ public static final DockerRule DOCKER = new DockerRule( "postgres",
+ 3000L,
+ "PostgreSQL init process complete; ready for start up." );
+
+ @Override
+ // START SNIPPET: assembly
+ public void assemble( ModuleAssembly module )
+ throws AssemblyException
+ {
+ // END SNIPPET: assembly
+ super.assemble( module );
+ ModuleAssembly config = module.layer().module( "config" );
+ new EntityTestAssembler().defaultServicesVisibleIn( Visibility.layer ).assemble( config );
+
+ // START SNIPPET: assembly
+ // DataSourceService
+ new DBCPDataSourceServiceAssembler()
+ .identifiedBy( "postgresql-datasource-service" )
+ .visibleIn( Visibility.module )
+ .withConfig( config, Visibility.layer )
+ .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( 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" );
+ // START SNIPPET: assembly
+ }
+ // END SNIPPET: assembly
+
+ @Override
+ public void tearDown()
+ throws Exception
+ {
+ UnitOfWork uow = unitOfWorkFactory.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();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/0f8f0b8d/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sqlkv/PostgreSQLEntityStoreTestSuite.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sqlkv/PostgreSQLEntityStoreTestSuite.java b/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sqlkv/PostgreSQLEntityStoreTestSuite.java
new file mode 100644
index 0000000..93e73e8
--- /dev/null
+++ b/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sqlkv/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.sqlkv;
+
+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.sqlkv.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.sqlkv.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();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/0f8f0b8d/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sqlkv/SQLiteEntityStoreTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sqlkv/SQLiteEntityStoreTest.java b/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sqlkv/SQLiteEntityStoreTest.java
new file mode 100644
index 0000000..d554cd6
--- /dev/null
+++ b/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sqlkv/SQLiteEntityStoreTest.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.entitystore.sqlkv;
+
+import org.apache.polygene.api.common.Visibility;
+import org.apache.polygene.bootstrap.AssemblyException;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.entitystore.sqlkv.assembly.SQLiteEntityStoreAssembler;
+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.BeforeClass;
+
+import static org.apache.polygene.test.util.Assume.assumeNoIbmJdk;
+
+public class SQLiteEntityStoreTest extends AbstractEntityStoreTest
+{
+ @BeforeClass
+ public static void beforeClass_IBMJDK()
+ {
+ assumeNoIbmJdk();
+ }
+
+ @Override
+ // START SNIPPET: assembly
+ public void assemble( ModuleAssembly module )
+ throws AssemblyException
+ {
+ // END SNIPPET: assembly
+ super.assemble( module );
+ ModuleAssembly config = module.layer().module( "config" );
+ new EntityTestAssembler().defaultServicesVisibleIn( Visibility.layer ).assemble( config );
+
+ // START SNIPPET: assembly
+ // DataSourceService
+ new DBCPDataSourceServiceAssembler()
+ .identifiedBy( "sqlite-datasource-service" )
+ .visibleIn( Visibility.module )
+ .withConfig( config, Visibility.layer )
+ .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( config, Visibility.layer )
+ .assemble( module );
+ }
+ // END SNIPPET: assembly
+}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/0f8f0b8d/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sqlkv/SQLiteEntityStoreTestSuite.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sqlkv/SQLiteEntityStoreTestSuite.java b/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sqlkv/SQLiteEntityStoreTestSuite.java
new file mode 100644
index 0000000..5ae254f
--- /dev/null
+++ b/extensions/entitystore-sqlkv/src/test/java/org/apache/polygene/entitystore/sqlkv/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.sqlkv;
+
+import org.apache.polygene.api.common.Visibility;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.entitystore.sqlkv.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 );
+ }
+}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/0f8f0b8d/libraries/sql-dbcp/src/main/java/org/apache/polygene/library/sql/dbcp/DBCPDataSourceServiceImporter.java
----------------------------------------------------------------------
diff --git a/libraries/sql-dbcp/src/main/java/org/apache/polygene/library/sql/dbcp/DBCPDataSourceServiceImporter.java b/libraries/sql-dbcp/src/main/java/org/apache/polygene/library/sql/dbcp/DBCPDataSourceServiceImporter.java
index 6e89f1f..31be482 100644
--- a/libraries/sql-dbcp/src/main/java/org/apache/polygene/library/sql/dbcp/DBCPDataSourceServiceImporter.java
+++ b/libraries/sql-dbcp/src/main/java/org/apache/polygene/library/sql/dbcp/DBCPDataSourceServiceImporter.java
@@ -19,10 +19,13 @@
*/
package org.apache.polygene.library.sql.dbcp;
+import java.sql.Connection;
+import java.util.function.Consumer;
import javax.sql.DataSource;
import org.apache.commons.dbcp2.BasicDataSource;
import org.apache.polygene.api.activation.Activators;
import org.apache.polygene.api.mixin.Mixins;
+import org.apache.polygene.api.property.Property;
import org.apache.polygene.api.service.ServiceComposite;
import org.apache.polygene.api.service.ServiceImporter;
import org.apache.polygene.library.sql.datasource.AbstractDataSourceServiceImporterMixin;
@@ -32,7 +35,7 @@ import org.apache.polygene.library.sql.datasource.DataSourceServiceImporterActiv
@Mixins( DBCPDataSourceServiceImporter.Mixin.class )
@Activators( DataSourceServiceImporterActivation.Activator.class )
public interface DBCPDataSourceServiceImporter
- extends ServiceImporter<DataSource>, DataSourceServiceImporterActivation, ServiceComposite
+ extends ServiceImporter<DataSource>, DataSourceServiceImporterActivation, ServiceComposite
{
class Mixin extends AbstractDataSourceServiceImporterMixin<BasicDataSource>
@@ -40,7 +43,7 @@ public interface DBCPDataSourceServiceImporter
@Override
protected BasicDataSource setupDataSourcePool( DataSourceConfiguration config )
- throws Exception
+ throws Exception
{
BasicDataSource pool = new BasicDataSource();
@@ -48,37 +51,41 @@ public interface DBCPDataSourceServiceImporter
pool.setDriverClassName( config.driver().get() );
pool.setUrl( config.url().get() );
- if ( !config.username().get().equals( "" ) ) {
- pool.setUsername( config.username().get() );
- pool.setPassword( config.password().get() );
- }
+ setConfig( config.username(), pool::setUsername, null );
+ setConfig( config.password(), pool::setPassword, null );
+ setConfig( config.minPoolSize(), pool::setMinIdle, null );
+ setConfig( config.maxPoolSize(), pool::setMaxTotal, null );
+ setConfig( config.maxConnectionAgeSeconds(), v -> pool.setMinEvictableIdleTimeMillis( v * 1000 ), null );
+ setConfig( config.validationQuery(), pool::setValidationQuery, null );
+ setConfig( config.autoCommit(), pool::setDefaultAutoCommit, null );
+ setConfig( config.isolationLevel(), pool::setDefaultTransactionIsolation, Connection.TRANSACTION_SERIALIZABLE );
- if ( config.minPoolSize().get() != null ) {
- pool.setMinIdle( config.minPoolSize().get() );
- }
- if ( config.maxPoolSize().get() != null ) {
- pool.setMaxTotal( config.maxPoolSize().get() );
- }
- if ( config.loginTimeoutSeconds().get() != null ) {
+ // Throws checked exception and can't be neatly handled
+ if( config.loginTimeoutSeconds().get() != null )
+ {
pool.setLoginTimeout( config.loginTimeoutSeconds().get() );
}
- if ( config.maxConnectionAgeSeconds().get() != null ) {
- pool.setMinEvictableIdleTimeMillis( config.maxConnectionAgeSeconds().get() * 1000 );
+ return pool;
+ }
+
+ private <T> void setConfig( Property<T> property, Consumer<T> setter, T defaultValue )
+ {
+ T value = property.get();
+ if( value != null )
+ {
+ setter.accept( value );
}
- if ( config.validationQuery().get() != null ) {
- pool.setValidationQuery( config.validationQuery().get() );
+ else if( defaultValue != null )
+ {
+ setter.accept( defaultValue );
}
-
- return pool;
}
@Override
protected void passivateDataSourcePool( BasicDataSource dataSourcePool )
- throws Exception
+ throws Exception
{
dataSourcePool.close();
}
-
}
-
}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/0f8f0b8d/libraries/sql/src/main/java/org/apache/polygene/library/sql/datasource/DataSourceConfigurationState.java
----------------------------------------------------------------------
diff --git a/libraries/sql/src/main/java/org/apache/polygene/library/sql/datasource/DataSourceConfigurationState.java b/libraries/sql/src/main/java/org/apache/polygene/library/sql/datasource/DataSourceConfigurationState.java
index 9243fa5..bf5aaa2 100644
--- a/libraries/sql/src/main/java/org/apache/polygene/library/sql/datasource/DataSourceConfigurationState.java
+++ b/libraries/sql/src/main/java/org/apache/polygene/library/sql/datasource/DataSourceConfigurationState.java
@@ -40,5 +40,7 @@ public interface DataSourceConfigurationState extends Enabled
@Optional Property<Integer> maxConnectionAgeSeconds();
@Optional Property<String> validationQuery();
@UseDefaults Property<String> properties();
+ @UseDefaults Property<Boolean> autoCommit();
+ @Optional Property<Integer> isolationLevel();
}
// END SNIPPET: config
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/0f8f0b8d/libraries/sql/src/main/java/org/apache/polygene/library/sql/datasource/DataSourceServiceImporterActivation.java
----------------------------------------------------------------------
diff --git a/libraries/sql/src/main/java/org/apache/polygene/library/sql/datasource/DataSourceServiceImporterActivation.java b/libraries/sql/src/main/java/org/apache/polygene/library/sql/datasource/DataSourceServiceImporterActivation.java
index c28c357..82cbb32 100644
--- a/libraries/sql/src/main/java/org/apache/polygene/library/sql/datasource/DataSourceServiceImporterActivation.java
+++ b/libraries/sql/src/main/java/org/apache/polygene/library/sql/datasource/DataSourceServiceImporterActivation.java
@@ -31,14 +31,11 @@ public interface DataSourceServiceImporterActivation
class Activator
extends ActivatorAdapter<ServiceReference<DataSourceServiceImporterActivation>>
{
-
@Override
public void beforePassivation( ServiceReference<DataSourceServiceImporterActivation> passivating )
throws Exception
{
passivating.get().passivateDataSourceService();
}
-
}
-
}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/0f8f0b8d/samples/sql-support/src/main/java/org/apache/polygene/sample/sqlsupport/AppAssembler.java
----------------------------------------------------------------------
diff --git a/samples/sql-support/src/main/java/org/apache/polygene/sample/sqlsupport/AppAssembler.java b/samples/sql-support/src/main/java/org/apache/polygene/sample/sqlsupport/AppAssembler.java
index 716c954..e748106 100644
--- a/samples/sql-support/src/main/java/org/apache/polygene/sample/sqlsupport/AppAssembler.java
+++ b/samples/sql-support/src/main/java/org/apache/polygene/sample/sqlsupport/AppAssembler.java
@@ -26,7 +26,7 @@ import org.apache.polygene.bootstrap.ApplicationAssemblyFactory;
import org.apache.polygene.bootstrap.LayerAssembly;
import org.apache.polygene.bootstrap.ModuleAssembly;
import org.apache.polygene.entitystore.memory.MemoryEntityStoreService;
-import org.apache.polygene.entitystore.sql.assembly.PostgreSQLEntityStoreAssembler;
+import org.apache.polygene.entitystore.sqlkv.assembly.PostgreSQLEntityStoreAssembler;
import org.apache.polygene.index.sql.assembly.PostgreSQLIndexQueryAssembler;
import org.apache.polygene.library.sql.assembly.DataSourceAssembler;
import org.apache.polygene.library.sql.datasource.DataSources;
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/0f8f0b8d/samples/sql-support/src/main/java/org/apache/polygene/sample/sqlsupport/Main.java
----------------------------------------------------------------------
diff --git a/samples/sql-support/src/main/java/org/apache/polygene/sample/sqlsupport/Main.java b/samples/sql-support/src/main/java/org/apache/polygene/sample/sqlsupport/Main.java
index 5a96f31..66a0918 100644
--- a/samples/sql-support/src/main/java/org/apache/polygene/sample/sqlsupport/Main.java
+++ b/samples/sql-support/src/main/java/org/apache/polygene/sample/sqlsupport/Main.java
@@ -30,7 +30,7 @@ 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.bootstrap.Energy4Java;
-import org.apache.polygene.entitystore.sql.assembly.PostgreSQLEntityStoreAssembler;
+import org.apache.polygene.entitystore.sqlkv.assembly.PostgreSQLEntityStoreAssembler;
import org.apache.polygene.index.sql.assembly.PostgreSQLIndexQueryAssembler;
import org.apache.polygene.library.sql.common.SQLConfiguration;
import org.apache.polygene.library.sql.common.SQLUtil;
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/0f8f0b8d/tests/performance/src/perf/java/org/apache/polygene/test/performance/entitystore/sql/DerbySQLEntityStorePerformanceTest.java
----------------------------------------------------------------------
diff --git a/tests/performance/src/perf/java/org/apache/polygene/test/performance/entitystore/sql/DerbySQLEntityStorePerformanceTest.java b/tests/performance/src/perf/java/org/apache/polygene/test/performance/entitystore/sql/DerbySQLEntityStorePerformanceTest.java
index 42305a2..e034c38 100644
--- a/tests/performance/src/perf/java/org/apache/polygene/test/performance/entitystore/sql/DerbySQLEntityStorePerformanceTest.java
+++ b/tests/performance/src/perf/java/org/apache/polygene/test/performance/entitystore/sql/DerbySQLEntityStorePerformanceTest.java
@@ -25,14 +25,14 @@ import org.apache.polygene.api.unitofwork.UnitOfWork;
import org.apache.polygene.api.usecase.UsecaseBuilder;
import org.apache.polygene.bootstrap.Assembler;
import org.apache.polygene.bootstrap.ModuleAssembly;
-import org.apache.polygene.entitystore.sql.SQLEntityStoreConfiguration;
-import org.apache.polygene.entitystore.sql.assembly.DerbySQLEntityStoreAssembler;
+import org.apache.polygene.entitystore.sqlkv.SQLEntityStoreConfiguration;
+import org.apache.polygene.entitystore.sqlkv.assembly.DerbySQLEntityStoreAssembler;
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.performance.entitystore.AbstractEntityStorePerformanceTest;
-import static org.apache.polygene.entitystore.sql.assembly.DerbySQLEntityStoreAssembler.DEFAULT_ENTITYSTORE_IDENTITY;
+import static org.apache.polygene.entitystore.sqlkv.assembly.DerbySQLEntityStoreAssembler.DEFAULT_ENTITYSTORE_IDENTITY;
/**
* Performance test for DerbySQLEntityStore.
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/0f8f0b8d/tests/performance/src/perf/java/org/apache/polygene/test/performance/entitystore/sql/PostgreSQLEntityStorePerformanceTest.java
----------------------------------------------------------------------
diff --git a/tests/performance/src/perf/java/org/apache/polygene/test/performance/entitystore/sql/PostgreSQLEntityStorePerformanceTest.java b/tests/performance/src/perf/java/org/apache/polygene/test/performance/entitystore/sql/PostgreSQLEntityStorePerformanceTest.java
index eac294b..6f91b12 100644
--- a/tests/performance/src/perf/java/org/apache/polygene/test/performance/entitystore/sql/PostgreSQLEntityStorePerformanceTest.java
+++ b/tests/performance/src/perf/java/org/apache/polygene/test/performance/entitystore/sql/PostgreSQLEntityStorePerformanceTest.java
@@ -30,7 +30,7 @@ import org.apache.polygene.bootstrap.ApplicationAssemblerAdapter;
import org.apache.polygene.bootstrap.Assembler;
import org.apache.polygene.bootstrap.Energy4Java;
import org.apache.polygene.bootstrap.ModuleAssembly;
-import org.apache.polygene.entitystore.sql.assembly.PostgreSQLEntityStoreAssembler;
+import org.apache.polygene.entitystore.sqlkv.assembly.PostgreSQLEntityStoreAssembler;
import org.apache.polygene.library.sql.assembly.DataSourceAssembler;
import org.apache.polygene.library.sql.common.SQLConfiguration;
import org.apache.polygene.library.sql.dbcp.DBCPDataSourceServiceAssembler;
@@ -38,7 +38,7 @@ import org.apache.polygene.test.EntityTestAssembler;
import org.apache.polygene.test.performance.entitystore.AbstractEntityStorePerformanceTest;
import org.junit.Ignore;
-import static org.apache.polygene.entitystore.sql.assembly.PostgreSQLEntityStoreAssembler.DEFAULT_ENTITYSTORE_IDENTITY;
+import static org.apache.polygene.entitystore.sqlkv.assembly.PostgreSQLEntityStoreAssembler.DEFAULT_ENTITYSTORE_IDENTITY;
/**
* Performance test for PostgreSQLEntityStore.