Rename entitystore-sql to entitystore-sqlkv
Project: http://git-wip-us.apache.org/repos/asf/polygene-java/repo Commit: http://git-wip-us.apache.org/repos/asf/polygene-java/commit/3168fdb4 Tree: http://git-wip-us.apache.org/repos/asf/polygene-java/tree/3168fdb4 Diff: http://git-wip-us.apache.org/repos/asf/polygene-java/diff/3168fdb4 Branch: refs/heads/develop Commit: 3168fdb4803adda7cb3f93a4b11c99ea97225e58 Parents: c8b40a2 Author: Paul Merlin <[email protected]> Authored: Mon Jul 17 15:02:40 2017 +0200 Committer: Paul Merlin <[email protected]> Committed: Mon Jul 17 15:14:28 2017 +0200 ---------------------------------------------------------------------- extensions/entitystore-sql/build.gradle | 46 ---- extensions/entitystore-sql/dev-status.xml | 38 --- extensions/entitystore-sql/src/docs/es-sql.txt | 167 ------------- .../sql/SQLEntityStoreConfiguration.java | 47 ---- .../entitystore/sql/SQLEntityStoreMixin.java | 244 ------------------- .../entitystore/sql/SQLEntityStoreService.java | 43 ---- .../AbstractSQLEntityStoreAssembler.java | 98 -------- .../assembly/DerbySQLEntityStoreAssembler.java | 35 --- .../sql/assembly/H2SQLEntityStoreAssembler.java | 35 --- .../sql/assembly/MySQLEntityStoreAssembler.java | 35 --- .../PostgreSQLEntityStoreAssembler.java | 35 --- .../sql/assembly/SQLEntityStoreAssembler.java | 28 --- .../assembly/SQLiteEntityStoreAssembler.java | 35 --- .../entitystore/sql/assembly/package.html | 24 -- .../polygene/entitystore/sql/package.html | 24 -- .../polygene/entitystore/sql/changelog.xml | 37 --- .../sql/DerbySQLEntityStoreTest.java | 101 -------- .../sql/DerbySQLEntityStoreTestSuite.java | 94 ------- .../entitystore/sql/H2SQLEntityStoreTest.java | 67 ----- .../sql/H2SQLEntityStoreTestSuite.java | 56 ----- .../entitystore/sql/MySQLEntityStoreTest.java | 127 ---------- .../sql/MySQLEntityStoreTestSuite.java | 122 ---------- .../sql/PostgreSQLEntityStoreTest.java | 115 --------- .../sql/PostgreSQLEntityStoreTestSuite.java | 111 --------- .../entitystore/sql/SQLiteEntityStoreTest.java | 75 ------ .../sql/SQLiteEntityStoreTestSuite.java | 65 ----- .../test/resources/derby-datasource.properties | 25 -- .../src/test/resources/h2-datasource.properties | 25 -- .../src/test/resources/logback.xml | 35 --- .../test/resources/mysql-datasource.properties | 25 -- .../resources/postgresql-datasource.properties | 24 -- .../test/resources/sqlite-datasource.properties | 25 -- extensions/entitystore-sqlkv/build.gradle | 46 ++++ extensions/entitystore-sqlkv/dev-status.xml | 38 +++ .../entitystore-sqlkv/src/docs/es-sqlkv.txt | 166 +++++++++++++ .../sql/SQLEntityStoreConfiguration.java | 47 ++++ .../entitystore/sql/SQLEntityStoreMixin.java | 244 +++++++++++++++++++ .../entitystore/sql/SQLEntityStoreService.java | 43 ++++ .../AbstractSQLEntityStoreAssembler.java | 98 ++++++++ .../assembly/DerbySQLEntityStoreAssembler.java | 35 +++ .../sql/assembly/H2SQLEntityStoreAssembler.java | 35 +++ .../sql/assembly/MySQLEntityStoreAssembler.java | 35 +++ .../PostgreSQLEntityStoreAssembler.java | 35 +++ .../sql/assembly/SQLEntityStoreAssembler.java | 28 +++ .../assembly/SQLiteEntityStoreAssembler.java | 35 +++ .../entitystore/sql/assembly/package.html | 24 ++ .../polygene/entitystore/sql/package.html | 24 ++ .../polygene/entitystore/sql/changelog.xml | 37 +++ .../sql/DerbySQLEntityStoreTest.java | 101 ++++++++ .../sql/DerbySQLEntityStoreTestSuite.java | 94 +++++++ .../entitystore/sql/H2SQLEntityStoreTest.java | 67 +++++ .../sql/H2SQLEntityStoreTestSuite.java | 56 +++++ .../entitystore/sql/MySQLEntityStoreTest.java | 127 ++++++++++ .../sql/MySQLEntityStoreTestSuite.java | 122 ++++++++++ .../sql/PostgreSQLEntityStoreTest.java | 115 +++++++++ .../sql/PostgreSQLEntityStoreTestSuite.java | 111 +++++++++ .../entitystore/sql/SQLiteEntityStoreTest.java | 75 ++++++ .../sql/SQLiteEntityStoreTestSuite.java | 65 +++++ .../test/resources/derby-datasource.properties | 25 ++ .../src/test/resources/h2-datasource.properties | 25 ++ .../src/test/resources/logback.xml | 35 +++ .../test/resources/mysql-datasource.properties | 25 ++ .../resources/postgresql-datasource.properties | 24 ++ .../test/resources/sqlite-datasource.properties | 25 ++ extensions/indexing-sql/src/docs/index-sql.txt | 2 +- libraries/sql/src/docs/sql.txt | 2 +- manual/src/docs/userguide/extensions.txt | 2 +- manual/src/docs/website/samples.txt | 2 +- samples/sql-support/build.gradle | 2 +- settings.gradle | 2 +- tests/performance/build.gradle | 2 +- 71 files changed, 2069 insertions(+), 2070 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/polygene-java/blob/3168fdb4/extensions/entitystore-sql/build.gradle ---------------------------------------------------------------------- diff --git a/extensions/entitystore-sql/build.gradle b/extensions/entitystore-sql/build.gradle deleted file mode 100644 index 223e85b..0000000 --- a/extensions/entitystore-sql/build.gradle +++ /dev/null @@ -1,46 +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. - * - * - */ - -apply plugin: 'polygene-extension' - -description = "Apache Polygene⢠SQL EntityStore Extension" - -jar { manifest { name = "Apache Polygene⢠Extension - EntityStore - SQL" } } - -dependencies { - api polygene.core.bootstrap - api polygene.library( 'sql' ) - api libraries.jooq - - implementation polygene.library( 'sql-liquibase' ) - - runtimeOnly polygene.core.runtime - - testImplementation polygene.internals.testsupport - testImplementation polygene.library( 'sql-dbcp' ) - testImplementation libraries.docker_junit - - testRuntimeOnly libraries.logback - testRuntimeOnly libraries.derby - testRuntimeOnly libraries.h2 - testRuntimeOnly libraries.mysql_connector - testRuntimeOnly libraries.postgres - testRuntimeOnly libraries.sqlite -} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/3168fdb4/extensions/entitystore-sql/dev-status.xml ---------------------------------------------------------------------- diff --git a/extensions/entitystore-sql/dev-status.xml b/extensions/entitystore-sql/dev-status.xml deleted file mode 100644 index 8d582e2..0000000 --- a/extensions/entitystore-sql/dev-status.xml +++ /dev/null @@ -1,38 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<!-- - ~ 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. - ~ - ~ - --> -<module xmlns="http://polygene.apache.org/schemas/2008/dev-status/1" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://polygene.apache.org/schemas/2008/dev-status/1 - http://polygene.apache.org/schemas/2008/dev-status/1/dev-status.xsd"> - <status> - <!--none,early,beta,stable,mature--> - <codebase>stable</codebase> - - <!-- none, brief, good, complete --> - <documentation>good</documentation> - - <!-- none, some, good, complete --> - <unittests>good</unittests> - </status> - <licenses> - <license>ALv2</license> - </licenses> -</module> http://git-wip-us.apache.org/repos/asf/polygene-java/blob/3168fdb4/extensions/entitystore-sql/src/docs/es-sql.txt ---------------------------------------------------------------------- diff --git a/extensions/entitystore-sql/src/docs/es-sql.txt b/extensions/entitystore-sql/src/docs/es-sql.txt deleted file mode 100644 index e0328a1..0000000 --- a/extensions/entitystore-sql/src/docs/es-sql.txt +++ /dev/null @@ -1,167 +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. -/////////////////////////////////////////////////////////////// - -[[extension-es-sql, SQL EntityStore]] -= SQL EntityStore = - -[devstatus] --------------- -source=extensions/entitystore-sql/dev-status.xml --------------- - -EntityStore service backed by a SQL database. - -This extension fully leverage the <<library-sql>> meaning that you must use it to assemble your DataSource and that you -get <<library-circuitbreaker,Circuit Breaker>> and <<library-jmx, JMX>> integration for free. - -The database schema is managed using <<library-sql-liquibase>>. - -TIP: See the <<sample-sql-support>> that demonstrate combined use of <<library-sql>>, <<extension-es-sql>> and -<<extension-indexing-sql>>. - -The following SQL databases are supported: - -- http://www.postgresql.org/[PostgreSQL] -- http://www.mysql.com/[MySQL] and http://mariadb.org/[MariaDB] -- http://www.sqlite.org/[SQLite] -- http://www.h2database.com/[H2 Database Engine] -- http://db.apache.org/derby/[Apache Derby] and http://www.oracle.com/technetwork/java/javadb/overview/index.htm[Oracle JavaDB] - -Each entity state is stored as a single row so maximum number of entities is the maximum number of rows per table -supported by the underlying SQL database. - -include::../../build/docs/buildinfo/artifact.txt[] - -== Configuration == - -Here are the available configuration properties: - -[snippet,java] ----- -source=extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/SQLMapEntityStoreConfiguration.java -tag=config ----- - -The assembly snippets below show the DataSource assembly alongside the SQL EntityStore assembly. Remember to configure -the DataSource properly, see <<library-sql>> and <<howto-configure-service>>. - - -== PostgreSQL == - -Maximum number of entities is unlimited. - -Assembly is done using the provided Assembler: - -[snippet,java] ----- -source=extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/PostgreSQLEntityStoreTest.java -tag=assembly ----- - -Sample DataSource configuration defaults: - -[source,java] ----- -include::../test/resources/postgresql-datasource.properties[] ----- - - -== MySQL and MariaDB == - -Maximum number of entities depends on the choosen storage engine. - -Assembly is done using the provided Assembler: - -[snippet,java] ----- -source=extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/MySQLEntityStoreTest.java -tag=assembly ----- - -Sample DataSource configuration defaults: - -[source,java] ----- -include::../test/resources/mysql-datasource.properties[] ----- - - -== SQLite == - -Maximum number of entities is unlimited. - -The http://www.xerial.org/trac/Xerial/wiki/SQLiteJDBC[Xerial SQLite JDBC] driver is recommended. -It provides native support on Linux, Windows and MaxOSX, pure Java on other OSes. - -Assembly is done using the provided Assembler: - -[snippet,java] ----- -source=extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/SQLiteEntityStoreTest.java -tag=assembly ----- - -Sample DataSource configuration defaults: - -[source,java] ----- -include::../test/resources/sqlite-datasource.properties[] ----- - - -== H2 Database Engine == - -Maximum number of entities is 2^64. - -Assembly is done using the provided Assembler: - -[snippet,java] ----- -source=extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/H2SQLEntityStoreTest.java -tag=assembly ----- - -Sample DataSource configuration defaults: - -[source,java] ----- -include::../test/resources/h2-datasource.properties[] ----- - - - -== Apache Derby and Oracle JavaDB == - -Maximum number of entities is unlimited. - -Assembly is done using the provided Assembler: - -[snippet,java] ----- -source=extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/DerbySQLEntityStoreTest.java -tag=assembly ----- - -Sample DataSource configuration defaults: - -[source,java] ----- -include::../test/resources/derby-datasource.properties[] ----- - http://git-wip-us.apache.org/repos/asf/polygene-java/blob/3168fdb4/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/SQLEntityStoreConfiguration.java ---------------------------------------------------------------------- diff --git a/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/SQLEntityStoreConfiguration.java b/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/SQLEntityStoreConfiguration.java deleted file mode 100644 index 19658ea..0000000 --- a/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/SQLEntityStoreConfiguration.java +++ /dev/null @@ -1,47 +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.UseDefaults; -import org.apache.polygene.api.property.Property; -import org.apache.polygene.library.sql.common.SQLConfiguration; - -// START SNIPPET: config -public interface SQLEntityStoreConfiguration extends SQLConfiguration -{ - /** - * Name of the database schema to use. - * Ignored on SQL databases that don't support schemas. - */ - @UseDefaults( "POLYGENE_ES" ) - @Override - Property<String> schemaName(); - - /** - * Name of the entities table. - */ - @UseDefaults( "POLYGENE_ENTITIES" ) - Property<String> entityTableName(); - - /** - * Defines whether the database schema and table should be created if not already present. - */ - @UseDefaults( "true" ) - Property<Boolean> createIfMissing(); -} -// END SNIPPET: config http://git-wip-us.apache.org/repos/asf/polygene-java/blob/3168fdb4/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 deleted file mode 100644 index 293ce58..0000000 --- a/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/SQLEntityStoreMixin.java +++ /dev/null @@ -1,244 +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.io.IOException; -import java.io.Reader; -import java.io.StringReader; -import java.io.StringWriter; -import java.io.Writer; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Stream; -import javax.sql.DataSource; -import liquibase.Contexts; -import liquibase.Liquibase; -import liquibase.database.Database; -import liquibase.database.ObjectQuotingStrategy; -import liquibase.exception.LiquibaseException; -import org.apache.polygene.api.configuration.Configuration; -import org.apache.polygene.api.entity.EntityDescriptor; -import org.apache.polygene.api.entity.EntityReference; -import org.apache.polygene.api.injection.scope.Service; -import org.apache.polygene.api.injection.scope.This; -import org.apache.polygene.api.injection.scope.Uses; -import org.apache.polygene.api.service.ServiceActivation; -import org.apache.polygene.api.service.ServiceDescriptor; -import org.apache.polygene.library.sql.liquibase.LiquibaseService; -import org.apache.polygene.serialization.javaxjson.JavaxJsonFactories; -import org.apache.polygene.spi.entitystore.EntityNotFoundException; -import org.apache.polygene.spi.entitystore.helpers.JSONKeys; -import org.apache.polygene.spi.entitystore.helpers.MapEntityStore; -import org.jooq.DSLContext; -import org.jooq.Field; -import org.jooq.Query; -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; - -public class SQLEntityStoreMixin - implements ServiceActivation, MapEntityStore -{ - private static final String TABLE_NAME_LIQUIBASE_PARAMETER = "es-sql.table"; - private static final String IDENTITY_COLUMN_NAME = "ENTITY_IDENTITY"; - private static final String VERSION_COLUMN_NAME = "ENTITY_VERSION"; - private static final String STATE_COLUMN_NAME = "ENTITY_STATE"; - - @Service - private DataSource dataSource; - - @Service - private LiquibaseService liquibaseService; - - @Service - private JavaxJsonFactories jsonFactories; - - @Uses - private ServiceDescriptor descriptor; - - @This - private Configuration<SQLEntityStoreConfiguration> configuration; - - private Schema schema; - private Table<Record> table; - private Field<String> identityColumn; - private Field<String> versionColumn; - private Field<String> stateColumn; - private DSLContext dsl; - - @Override - public void activateService() throws Exception - { - configuration.refresh(); - SQLEntityStoreConfiguration config = configuration.get(); - - // Prepare jooq DSL - SQLDialect dialect = descriptor.metaInfo( SQLDialect.class ); - Settings settings = descriptor.metaInfo( Settings.class ); - String schemaName = config.schemaName().get(); - String tableName = config.entityTableName().get(); - schema = DSL.schema( DSL.name( schemaName ) ); - table = DSL.table( - dialect.equals( SQLDialect.SQLITE ) - ? DSL.name( tableName ) - : DSL.name( schema.getName(), tableName ) - ); - identityColumn = DSL.field( DSL.name( IDENTITY_COLUMN_NAME ), String.class ); - versionColumn = DSL.field( DSL.name( VERSION_COLUMN_NAME ), String.class ); - stateColumn = DSL.field( DSL.name( STATE_COLUMN_NAME ), String.class ); - dsl = DSL.using( dataSource, dialect, settings ); - - // Eventually create schema and apply Liquibase changelog - if( config.createIfMissing().get() ) - { - if( !dialect.equals( SQLDialect.SQLITE ) - && dsl.meta().getSchemas().stream().noneMatch( s -> schema.getName().equalsIgnoreCase( s.getName() ) ) ) - { - dsl.createSchema( schema ).execute(); - } - - applyLiquibaseChangelog( dialect ); - } - } - - private void applyLiquibaseChangelog( SQLDialect dialect ) throws SQLException, LiquibaseException - { - Liquibase liquibase = liquibaseService.newConnectedLiquibase(); - Database db = liquibase.getDatabase(); - db.setObjectQuotingStrategy( ObjectQuotingStrategy.QUOTE_ALL_OBJECTS ); - try - { - if( !dialect.equals( SQLDialect.SQLITE ) ) - { - if( db.supportsSchemas() ) - { - db.setDefaultSchemaName( schema.getName() ); - db.setLiquibaseSchemaName( schema.getName() ); - } - if( db.supportsCatalogs() ) - { - db.setDefaultCatalogName( schema.getName() ); - db.setLiquibaseCatalogName( schema.getName() ); - } - } - liquibase.getChangeLogParameters().set( TABLE_NAME_LIQUIBASE_PARAMETER, table.getName() ); - liquibase.update( new Contexts() ); - } - finally - { - db.close(); - } - } - - @Override - public void passivateService() throws Exception - { - dsl = null; - schema = null; - table = null; - identityColumn = null; - versionColumn = null; - stateColumn = null; - } - - @Override - public Reader get( EntityReference entityReference ) - { - String state = dsl.select( stateColumn ) - .from( table ) - .where( identityColumn.equal( entityReference.identity().toString() ) ) - .fetchOptional( stateColumn ) - .orElseThrow( () -> new EntityNotFoundException( entityReference ) ); - return new StringReader( state ); - } - - @Override - public Stream<Reader> entityStates() - { - return dsl.select( stateColumn ) - .from( table ) - .fetch( stateColumn ) - .stream() - .map( StringReader::new ); - } - - @Override - public void applyChanges( MapChanges changes ) throws Exception - { - List<Query> operations = new ArrayList<>(); - changes.visitMap( new MapChanger() - { - @Override - public Writer newEntity( EntityReference ref, EntityDescriptor entityDescriptor ) - { - return new StringWriter( 1000 ) - { - @Override - public void close() throws IOException - { - super.close(); - String state = toString(); - String version = jsonFactories.readerFactory().createReader( new StringReader( state ) ) - .readObject() - .getString( JSONKeys.VERSION ); - operations.add( - dsl.insertInto( table ) - .columns( identityColumn, versionColumn, stateColumn ) - .values( ref.identity().toString(), version, state ) - ); - } - }; - } - - @Override - public Writer updateEntity( MapChange mapChange ) - { - return new StringWriter( 1000 ) - { - @Override - public void close() throws IOException - { - super.close(); - String state = toString(); - operations.add( - dsl.update( table ) - .set( versionColumn, mapChange.newVersion() ) - .set( stateColumn, state ) - .where( identityColumn.equal( mapChange.reference().identity().toString() ) ) - .and( versionColumn.equal( mapChange.previousVersion() ) ) - ); - } - }; - } - - @Override - public void removeEntity( EntityReference ref, EntityDescriptor entityDescriptor ) - { - operations.add( - dsl.deleteFrom( table ) - .where( identityColumn.equal( ref.identity().toString() ) ) - ); - } - } ); - dsl.batch( operations ).execute(); - } -} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/3168fdb4/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/SQLEntityStoreService.java ---------------------------------------------------------------------- diff --git a/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/SQLEntityStoreService.java b/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/SQLEntityStoreService.java deleted file mode 100644 index 9e4e0e7..0000000 --- a/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/SQLEntityStoreService.java +++ /dev/null @@ -1,43 +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.concern.Concerns; -import org.apache.polygene.api.configuration.Configuration; -import org.apache.polygene.api.mixin.Mixins; -import org.apache.polygene.api.service.ServiceActivation; -import org.apache.polygene.spi.entitystore.ConcurrentModificationCheckConcern; -import org.apache.polygene.spi.entitystore.EntityStateVersions; -import org.apache.polygene.spi.entitystore.EntityStore; -import org.apache.polygene.spi.entitystore.StateChangeNotificationConcern; -import org.apache.polygene.spi.entitystore.helpers.JSONMapEntityStoreActivation; -import org.apache.polygene.spi.entitystore.helpers.JSONMapEntityStoreMixin; - -/** - * SQL EntityStore service. - */ -@Concerns( { StateChangeNotificationConcern.class, ConcurrentModificationCheckConcern.class } ) -@Mixins( { JSONMapEntityStoreMixin.class, SQLEntityStoreMixin.class } ) -public interface SQLEntityStoreService - extends ServiceActivation, - JSONMapEntityStoreActivation, - EntityStore, - EntityStateVersions, - Configuration -{ -} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/3168fdb4/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 deleted file mode 100644 index 0f86490..0000000 --- a/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/assembly/AbstractSQLEntityStoreAssembler.java +++ /dev/null @@ -1,98 +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.assembly; - -import org.apache.polygene.api.identity.Identity; -import org.apache.polygene.api.identity.StringIdentity; -import org.apache.polygene.bootstrap.Assemblers; -import org.apache.polygene.bootstrap.AssemblyException; -import org.apache.polygene.bootstrap.ModuleAssembly; -import org.apache.polygene.entitystore.sql.SQLEntityStoreConfiguration; -import org.apache.polygene.entitystore.sql.SQLEntityStoreService; -import org.apache.polygene.library.sql.liquibase.LiquibaseAssembler; -import org.apache.polygene.library.sql.liquibase.LiquibaseConfiguration; -import org.jooq.SQLDialect; -import org.jooq.conf.RenderNameStyle; -import org.jooq.conf.Settings; - -/** - * Base SQL EntityStore assembly. - */ -public abstract class AbstractSQLEntityStoreAssembler<AssemblerType> - extends Assemblers.VisibilityIdentityConfig<AssemblerType> -{ - public static final Identity DEFAULT_ENTITYSTORE_IDENTITY = StringIdentity.identityOf( "entitystore-sql" ); - private static final String DEFAULT_CHANGELOG_PATH = "org/apache/polygene/entitystore/sql/changelog.xml"; - - private String changelogPath = DEFAULT_CHANGELOG_PATH; - - @Override - public void assemble( ModuleAssembly module ) - { - super.assemble( module ); - SQLDialect dialect = getSQLDialect(); - if( dialect == null ) - { - throw new AssemblyException( "SQLDialect must not be null" ); - } - Settings settings = getSettings(); - if( settings == null ) - { - throw new AssemblyException( "Settings must not be null" ); - } - - String identity = ( hasIdentity() ? identity() : DEFAULT_ENTITYSTORE_IDENTITY ).toString(); - - LiquibaseAssembler liquibase = new LiquibaseAssembler().identifiedBy( identity + "-liquibase" ); - if( hasConfig() ) - { - liquibase.withConfig( configModule(), configVisibility() ); - LiquibaseConfiguration liquibaseconfig = configModule().forMixin( LiquibaseConfiguration.class ) - .declareDefaults(); - liquibaseconfig.changeLog().set( changelogPath ); - } - liquibase.assemble( module ); - - module.services( SQLEntityStoreService.class ) - .identifiedBy( identity ) - .visibleIn( visibility() ) - .setMetaInfo( dialect ) - .setMetaInfo( settings ); - - if( hasConfig() ) - { - configModule().entities( SQLEntityStoreConfiguration.class ).visibleIn( configVisibility() ); - } - } - - public AssemblerType withLiquibaseChangelog( String changelogPath ) - { - this.changelogPath = changelogPath; - return (AssemblerType) this; - } - - protected Settings getSettings() - { - return new Settings().withRenderNameStyle( RenderNameStyle.QUOTED ); - } - - protected SQLDialect getSQLDialect() - { - return SQLDialect.DEFAULT; - } -} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/3168fdb4/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/assembly/DerbySQLEntityStoreAssembler.java ---------------------------------------------------------------------- diff --git a/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/assembly/DerbySQLEntityStoreAssembler.java b/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/assembly/DerbySQLEntityStoreAssembler.java deleted file mode 100644 index 4e88d01..0000000 --- a/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/assembly/DerbySQLEntityStoreAssembler.java +++ /dev/null @@ -1,35 +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.assembly; - -import org.jooq.SQLDialect; - -/** - * Derby EntityStore assembly. - */ -public class DerbySQLEntityStoreAssembler - extends AbstractSQLEntityStoreAssembler<DerbySQLEntityStoreAssembler> -{ - @Override - protected SQLDialect getSQLDialect() - { - return SQLDialect.DERBY; - } -} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/3168fdb4/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/assembly/H2SQLEntityStoreAssembler.java ---------------------------------------------------------------------- diff --git a/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/assembly/H2SQLEntityStoreAssembler.java b/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/assembly/H2SQLEntityStoreAssembler.java deleted file mode 100644 index 928e660..0000000 --- a/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/assembly/H2SQLEntityStoreAssembler.java +++ /dev/null @@ -1,35 +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.assembly; - -import org.jooq.SQLDialect; - -/** - * H2 EntityStore assembly. - */ -public class H2SQLEntityStoreAssembler - extends AbstractSQLEntityStoreAssembler<H2SQLEntityStoreAssembler> -{ - @Override - protected SQLDialect getSQLDialect() - { - return SQLDialect.H2; - } -} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/3168fdb4/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/assembly/MySQLEntityStoreAssembler.java ---------------------------------------------------------------------- diff --git a/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/assembly/MySQLEntityStoreAssembler.java b/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/assembly/MySQLEntityStoreAssembler.java deleted file mode 100644 index dec7be5..0000000 --- a/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/assembly/MySQLEntityStoreAssembler.java +++ /dev/null @@ -1,35 +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.assembly; - -import org.jooq.SQLDialect; - -/** - * MySQL EntityStore assembly. - */ -public class MySQLEntityStoreAssembler - extends AbstractSQLEntityStoreAssembler<MySQLEntityStoreAssembler> -{ - @Override - protected SQLDialect getSQLDialect() - { - return SQLDialect.MYSQL; - } -} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/3168fdb4/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/assembly/PostgreSQLEntityStoreAssembler.java ---------------------------------------------------------------------- diff --git a/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/assembly/PostgreSQLEntityStoreAssembler.java b/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/assembly/PostgreSQLEntityStoreAssembler.java deleted file mode 100644 index 8e3e31f..0000000 --- a/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/assembly/PostgreSQLEntityStoreAssembler.java +++ /dev/null @@ -1,35 +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.assembly; - -import org.jooq.SQLDialect; - -/** - * PostgreSQL EntityStore assembly. - */ -public class PostgreSQLEntityStoreAssembler - extends AbstractSQLEntityStoreAssembler<PostgreSQLEntityStoreAssembler> -{ - @Override - protected SQLDialect getSQLDialect() - { - return SQLDialect.POSTGRES; - } -} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/3168fdb4/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/assembly/SQLEntityStoreAssembler.java ---------------------------------------------------------------------- diff --git a/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/assembly/SQLEntityStoreAssembler.java b/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/assembly/SQLEntityStoreAssembler.java deleted file mode 100644 index 1477c6b..0000000 --- a/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/assembly/SQLEntityStoreAssembler.java +++ /dev/null @@ -1,28 +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.assembly; - -/** - * This is a dummy Assembler to support the Yeoman Polygene Generator, which require naming conventions for - * the systems that it supports. - */ -public class SQLEntityStoreAssembler extends H2SQLEntityStoreAssembler -{} - http://git-wip-us.apache.org/repos/asf/polygene-java/blob/3168fdb4/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/assembly/SQLiteEntityStoreAssembler.java ---------------------------------------------------------------------- diff --git a/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/assembly/SQLiteEntityStoreAssembler.java b/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/assembly/SQLiteEntityStoreAssembler.java deleted file mode 100644 index 2615316..0000000 --- a/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/assembly/SQLiteEntityStoreAssembler.java +++ /dev/null @@ -1,35 +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.assembly; - -import org.jooq.SQLDialect; - -/** - * SQLite EntityStore assembly. - */ -public class SQLiteEntityStoreAssembler - extends AbstractSQLEntityStoreAssembler<SQLiteEntityStoreAssembler> -{ - @Override - protected SQLDialect getSQLDialect() - { - return SQLDialect.SQLITE; - } -} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/3168fdb4/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/assembly/package.html ---------------------------------------------------------------------- diff --git a/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/assembly/package.html b/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/assembly/package.html deleted file mode 100644 index a93cf6f..0000000 --- a/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/assembly/package.html +++ /dev/null @@ -1,24 +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. - ~ - ~ - --> -<html> - <body> - <h2>SQL EntityStore Assembly.</h2> - </body> -</html> http://git-wip-us.apache.org/repos/asf/polygene-java/blob/3168fdb4/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/package.html ---------------------------------------------------------------------- diff --git a/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/package.html b/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/package.html deleted file mode 100644 index a90af3e..0000000 --- a/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/package.html +++ /dev/null @@ -1,24 +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. - ~ - ~ - --> -<html> - <body> - <h2>SQL EntityStore.</h2> - </body> -</html> http://git-wip-us.apache.org/repos/asf/polygene-java/blob/3168fdb4/extensions/entitystore-sql/src/main/resources/org/apache/polygene/entitystore/sql/changelog.xml ---------------------------------------------------------------------- diff --git a/extensions/entitystore-sql/src/main/resources/org/apache/polygene/entitystore/sql/changelog.xml b/extensions/entitystore-sql/src/main/resources/org/apache/polygene/entitystore/sql/changelog.xml deleted file mode 100644 index 47ef554..0000000 --- a/extensions/entitystore-sql/src/main/resources/org/apache/polygene/entitystore/sql/changelog.xml +++ /dev/null @@ -1,37 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ~ 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. - --> -<databaseChangeLog - xmlns="http://www.liquibase.org/xml/ns/dbchangelog" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd" - objectQuotingStrategy="QUOTE_ALL_OBJECTS"> - <changeSet id="0" author="paul"> - <createTable tableName="${es-sql.table}"> - <column name="ENTITY_IDENTITY" type="varchar(64)"> - <constraints primaryKey="true" nullable="false"/> - </column> - <column name="ENTITY_VERSION" type="varchar(64)"> - <constraints nullable="false"/> - </column> - <column name="ENTITY_STATE" type="varchar(10240)"> - <constraints nullable="false"/> - </column> - </createTable> - </changeSet> -</databaseChangeLog> http://git-wip-us.apache.org/repos/asf/polygene-java/blob/3168fdb4/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 deleted file mode 100644 index 4bd1578..0000000 --- a/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/DerbySQLEntityStoreTest.java +++ /dev/null @@ -1,101 +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.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.sql.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/3168fdb4/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 deleted file mode 100644 index 7fbfb2a..0000000 --- a/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/DerbySQLEntityStoreTestSuite.java +++ /dev/null @@ -1,94 +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.structure.Module; -import org.apache.polygene.api.unitofwork.UnitOfWork; -import org.apache.polygene.api.unitofwork.UnitOfWorkFactory; -import org.apache.polygene.api.usecase.UsecaseBuilder; -import org.apache.polygene.bootstrap.ModuleAssembly; -import org.apache.polygene.entitystore.sql.assembly.DerbySQLEntityStoreAssembler; -import org.apache.polygene.library.sql.assembly.DataSourceAssembler; -import org.apache.polygene.library.sql.dbcp.DBCPDataSourceServiceAssembler; -import org.apache.polygene.test.entity.model.EntityStoreTestSuite; - -import static org.apache.polygene.entitystore.sql.assembly.DerbySQLEntityStoreAssembler.DEFAULT_ENTITYSTORE_IDENTITY; - -public class DerbySQLEntityStoreTestSuite extends EntityStoreTestSuite -{ - @Override - protected void defineStorageModule( ModuleAssembly module ) - { - module.defaultServices(); - // DataSourceService - new DBCPDataSourceServiceAssembler() - .identifiedBy( "derby-datasource-service" ) - .visibleIn( Visibility.module ) - .withConfig( configModule, Visibility.application ) - .assemble( module ); - - // DataSource - new DataSourceAssembler() - .withDataSourceServiceIdentity( "derby-datasource-service" ) - .identifiedBy( "derby-datasource" ) - .visibleIn( Visibility.module ) - .withCircuitBreaker() - .assemble( module ); - - // SQL EntityStore - new DerbySQLEntityStoreAssembler() - .visibleIn( Visibility.application ) - .withConfig( configModule, Visibility.application ) - .assemble( module ); - } - - @Override - public void tearDown() - throws Exception - { - Module storageModule = application.findModule( "Infrastructure Layer","Storage Module" ); - UnitOfWorkFactory uowf = storageModule.unitOfWorkFactory(); - UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( - "Delete " + getClass().getSimpleName() + " test data" ) ); - try - { - SQLEntityStoreConfiguration config = uow.get( SQLEntityStoreConfiguration.class, - DEFAULT_ENTITYSTORE_IDENTITY ); - Connection connection = storageModule.serviceFinder().findService( DataSource.class ).get().getConnection(); - connection.setAutoCommit( false ); - try( Statement stmt = connection.createStatement() ) - { - stmt.execute( String.format( "DELETE FROM %s.%s", - config.schemaName().get(), - config.entityTableName().get() ) ); - connection.commit(); - } - } - finally - { - uow.discard(); - super.tearDown(); - } - } -} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/3168fdb4/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 deleted file mode 100644 index 4b4b759..0000000 --- a/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/H2SQLEntityStoreTest.java +++ /dev/null @@ -1,67 +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.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/3168fdb4/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 deleted file mode 100644 index f763238..0000000 --- a/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/H2SQLEntityStoreTestSuite.java +++ /dev/null @@ -1,56 +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.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/3168fdb4/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 deleted file mode 100644 index a940e95..0000000 --- a/extensions/entitystore-sql/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/3168fdb4/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 deleted file mode 100644 index e2b0564..0000000 --- a/extensions/entitystore-sql/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/3168fdb4/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 deleted file mode 100644 index daa9949..0000000 --- a/extensions/entitystore-sql/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/3168fdb4/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 deleted file mode 100644 index d1dd952..0000000 --- a/extensions/entitystore-sql/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(); - } - } -}
