polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject [3/3] polygene-java git commit: More fixing due to the autoCommit OFF that I think I enabled earlier. OR that we have a new JOOQ version and the default transaction/connection handler isn't good enough.
Date Fri, 27 Oct 2017 07:37:28 GMT
More fixing due to the autoCommit OFF that I think I enabled earlier. OR that we have a new
JOOQ version and the default transaction/connection handler isn't good enough.


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

Branch: refs/heads/develop
Commit: db90b19ca9d0984fd399175dc9cf04619aed6c12
Parents: 27dc60c
Author: niclas <niclas@hedhman.org>
Authored: Fri Oct 27 15:36:42 2017 +0800
Committer: niclas <niclas@hedhman.org>
Committed: Fri Oct 27 15:36:42 2017 +0800

----------------------------------------------------------------------
 .../sql/PostgreSQLEntityStoreTest.java          | 15 +++-
 .../sql/PostgreSQLEntityStoreTestSuite.java     |  3 +-
 .../sqlkv/PostgreSQLEntityStoreTest.java        | 15 +++-
 .../sqlkv/PostgreSQLEntityStoreTestSuite.java   |  3 +-
 .../sql/liquibase/LiquibaseServiceTest.java     | 75 ++++++++++++--------
 5 files changed, 78 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/polygene-java/blob/db90b19c/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/PostgreSQLEntityStoreTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/PostgreSQLEntityStoreTest.java
b/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/PostgreSQLEntityStoreTest.java
index 3813220..f790a69 100644
--- a/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/PostgreSQLEntityStoreTest.java
+++ b/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/PostgreSQLEntityStoreTest.java
@@ -49,7 +49,7 @@ public class PostgreSQLEntityStoreTest
 
         DOCKER = new DockerRule( "postgres",
                                  environment,
-                                 3000L,
+                                 5000L,
                                  "PostgreSQL init process complete; ready for start up."
);
     }
 
@@ -59,6 +59,7 @@ public class PostgreSQLEntityStoreTest
         throws AssemblyException
     {
         // END SNIPPET: assembly
+        delay();
         super.assemble( module );
         ModuleAssembly config = module.layer().module( "config" );
         new EntityTestAssembler().defaultServicesVisibleIn( Visibility.layer ).assemble(
config );
@@ -97,6 +98,18 @@ public class PostgreSQLEntityStoreTest
 
         // START SNIPPET: assembly
     }
+
+    static void delay()
+    {
+        try
+        {
+            Thread.sleep( 5000L );
+        }
+        catch( InterruptedException e )
+        {
+            // ignore.
+        }
+    }
     // END SNIPPET: assembly
 
     @Override

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/db90b19c/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/PostgreSQLEntityStoreTestSuite.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/PostgreSQLEntityStoreTestSuite.java
b/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/PostgreSQLEntityStoreTestSuite.java
index 6c7dcd4..7a10131 100644
--- a/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/PostgreSQLEntityStoreTestSuite.java
+++ b/extensions/entitystore-sql/src/test/java/org/apache/polygene/entitystore/sql/PostgreSQLEntityStoreTestSuite.java
@@ -46,13 +46,14 @@ public class PostgreSQLEntityStoreTestSuite extends EntityStoreTestSuite
 
         DOCKER = new DockerRule( "postgres",
                                  environment,
-                                 3000L,
+                                 5000L,
                                  "PostgreSQL init process complete; ready for start up."
);
     }
 
     @Override
     protected void defineStorageModule( ModuleAssembly module )
     {
+        PostgreSQLEntityStoreTest.delay();
         module.defaultServices();
         // DataSourceService
         new DBCPDataSourceServiceAssembler()

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/db90b19c/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
index 1abfa3f..b4552de 100644
--- 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
@@ -37,7 +37,7 @@ public class PostgreSQLEntityStoreTest extends AbstractEntityStoreTest
 {
     @ClassRule
     public static final DockerRule DOCKER = new DockerRule( "postgres",
-                                                            3000L,
+                                                            5000L,
                                                             "PostgreSQL init process complete;
ready for start up." );
 
     @Override
@@ -46,6 +46,7 @@ public class PostgreSQLEntityStoreTest extends AbstractEntityStoreTest
         throws AssemblyException
     {
         // END SNIPPET: assembly
+        delay();
         super.assemble( module );
         ModuleAssembly config = module.layer().module( "config" );
         new EntityTestAssembler().defaultServicesVisibleIn( Visibility.layer ).assemble(
config );
@@ -78,6 +79,18 @@ public class PostgreSQLEntityStoreTest extends AbstractEntityStoreTest
         defaults.url().set( "jdbc:postgresql://" + host + ":" + port + "/jdbc_test_db" );
         // START SNIPPET: assembly
     }
+
+    static void delay()
+    {
+        try
+        {
+            Thread.sleep( 5000L );
+        }
+        catch( InterruptedException e )
+        {
+            // ignore;
+        }
+    }
     // END SNIPPET: assembly
 
     @Override

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/db90b19c/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
index 5e975b7..ee45f23 100644
--- 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
@@ -35,12 +35,13 @@ public class PostgreSQLEntityStoreTestSuite extends EntityStoreTestSuite
 {
     @ClassRule
     public static final DockerRule DOCKER = new DockerRule( "postgres",
-                                                            3000L,
+                                                            5000L,
                                                             "PostgreSQL init process complete;
ready for start up." );
 
     @Override
     protected void defineStorageModule( ModuleAssembly module )
     {
+        PostgreSQLEntityStoreTest.delay();
         module.defaultServices();
         // DataSourceService
         new DBCPDataSourceServiceAssembler()

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/db90b19c/libraries/sql-liquibase/src/test/java/org/apache/polygene/library/sql/liquibase/LiquibaseServiceTest.java
----------------------------------------------------------------------
diff --git a/libraries/sql-liquibase/src/test/java/org/apache/polygene/library/sql/liquibase/LiquibaseServiceTest.java
b/libraries/sql-liquibase/src/test/java/org/apache/polygene/library/sql/liquibase/LiquibaseServiceTest.java
index fd39fb3..dd9ff28 100644
--- a/libraries/sql-liquibase/src/test/java/org/apache/polygene/library/sql/liquibase/LiquibaseServiceTest.java
+++ b/libraries/sql-liquibase/src/test/java/org/apache/polygene/library/sql/liquibase/LiquibaseServiceTest.java
@@ -35,13 +35,18 @@ import org.apache.polygene.bootstrap.SingletonAssembler;
 import org.apache.polygene.library.sql.assembly.DataSourceAssembler;
 import org.apache.polygene.library.sql.dbcp.DBCPDataSourceServiceAssembler;
 import org.apache.polygene.test.EntityTestAssembler;
+import org.jooq.ConnectionProvider;
 import org.jooq.DSLContext;
 import org.jooq.Field;
 import org.jooq.InsertValuesStep2;
 import org.jooq.Record;
 import org.jooq.SQLDialect;
 import org.jooq.Table;
+import org.jooq.TransactionProvider;
 import org.jooq.impl.DSL;
+import org.jooq.impl.DataSourceConnectionProvider;
+import org.jooq.impl.DefaultConfiguration;
+import org.jooq.impl.ThreadLocalTransactionProvider;
 import org.junit.Test;
 
 import static java.util.stream.Collectors.toList;
@@ -58,7 +63,8 @@ import static org.junit.Assert.assertTrue;
 public class LiquibaseServiceTest
 {
     @Test
-    public void testLiquibase() throws ActivationException
+    public void testLiquibase()
+        throws ActivationException
     {
         final SingletonAssembler assembler = new SingletonAssembler()
         {
@@ -105,38 +111,49 @@ public class LiquibaseServiceTest
         DataSource ds = module.findService( DataSource.class ).get();
 
         // Prepare jOOQ and the schema model
-        DSLContext jooq = DSL.using( ds, SQLDialect.DERBY );
+        SQLDialect dialect = SQLDialect.DERBY;
+        ConnectionProvider connectionProvider = new DataSourceConnectionProvider( ds );
+        TransactionProvider transactionProvider = new ThreadLocalTransactionProvider( connectionProvider,
false );
+        org.jooq.Configuration configuration = new DefaultConfiguration()
+            .set( dialect )
+            .set( connectionProvider )
+            .set( transactionProvider );
+        DSLContext jooq = DSL.using( configuration );
+
         Table<Record> testTable = table( "TEST" );
         Field<String> idColumn = field( "ID", String.class );
         Field<String> fooColumn = field( "FOO", String.class );
 
-        // Assert that insertion works
-        InsertValuesStep2 insert = jooq.insertInto( testTable )
-                                       .columns( idColumn, fooColumn )
-                                       .values( "someid", "bar" );
-        assertTrue( insert.execute() == 1 );
-
-        List<Record> records = jooq.selectFrom( testTable ).stream().collect( toList()
);
-        assertThat( records.size(), is( 1 ) );
-        assertThat( records.get( 0 ).get( idColumn ), equalTo( "someid" ) );
-        assertThat( records.get( 0 ).get( fooColumn ), equalTo( "bar" ) );
-
-        Function<Record, SomeValue> toValue = record ->
-        {
-            ValueBuilder<SomeValue> builder = assembler.module().newValueBuilder( SomeValue.class
);
-            builder.prototype().id().set( record.get( idColumn ) );
-            builder.prototype().foo().set( record.get( fooColumn ) );
-            return builder.newInstance();
-        };
-
-        List<SomeValue> values = jooq.selectFrom( testTable ).stream()
-                                     .map( toValue )
-                                     .peek( System.out::println )
-                                     .collect( toList() );
-
-        assertThat( values.size(), is( 1 ) );
-        assertThat( values.get( 0 ).id().get(), equalTo( "someid" ) );
-        assertThat( values.get( 0 ).foo().get(), equalTo( "bar" ) );
+        jooq.transaction( conf -> {
+            // Assert that insertion works
+            InsertValuesStep2 insert = jooq.insertInto( testTable )
+                                           .columns( idColumn, fooColumn )
+                                           .values( "someid", "bar" );
+            assertTrue( insert.execute() == 1 );
+        } );
+        jooq.transaction( conf -> {
+            List<Record> records = jooq.selectFrom( testTable ).stream().collect( toList()
);
+            assertThat( records.size(), is( 1 ) );
+            assertThat( records.get( 0 ).get( idColumn ), equalTo( "someid" ) );
+            assertThat( records.get( 0 ).get( fooColumn ), equalTo( "bar" ) );
+
+            Function<Record, SomeValue> toValue = record ->
+            {
+                ValueBuilder<SomeValue> builder = assembler.module().newValueBuilder(
SomeValue.class );
+                builder.prototype().id().set( record.get( idColumn ) );
+                builder.prototype().foo().set( record.get( fooColumn ) );
+                return builder.newInstance();
+            };
+
+            List<SomeValue> values = jooq.selectFrom( testTable ).stream()
+                                         .map( toValue )
+                                         .peek( System.out::println )
+                                         .collect( toList() );
+
+            assertThat( values.size(), is( 1 ) );
+            assertThat( values.get( 0 ).id().get(), equalTo( "someid" ) );
+            assertThat( values.get( 0 ).foo().get(), equalTo( "bar" ) );
+        } );
     }
 
     interface SomeValue


Mime
View raw message