polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject [29/33] polygene-java git commit: There seems to be permission problems.
Date Thu, 26 Oct 2017 07:34:59 GMT
There seems to be permission problems.


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

Branch: refs/heads/develop
Commit: 58d19ab46fff7d710ac12ade0a17da97f3af5d2b
Parents: 0f8f0b8
Author: niclas <niclas@hedhman.org>
Authored: Sun Sep 10 21:00:43 2017 +0800
Committer: niclas <niclas@hedhman.org>
Committed: Sun Sep 10 21:00:43 2017 +0800

----------------------------------------------------------------------
 .../polygene/entitystore/sql/SqlTable.java      | 52 ++++++++++----------
 .../sql/PostgreSQLEntityStoreTest.java          | 24 +++++++--
 .../resources/postgresql-datasource.properties  |  2 -
 3 files changed, 46 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/polygene-java/blob/58d19ab4/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/SqlTable.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/SqlTable.java
b/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/SqlTable.java
index a2fc658..c553532 100644
--- a/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/SqlTable.java
+++ b/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/SqlTable.java
@@ -211,31 +211,33 @@ public interface SqlTable extends ServiceActivation
             // Eventually create schema
             if( config.createIfMissing().get() )
             {
-                if( !dialect.equals( SQLDialect.SQLITE )
-                    && dsl.meta().getSchemas().stream().noneMatch( s -> schema.getName().equalsIgnoreCase(
s.getName() ) ) )
-                {
-                    dsl.createSchema( schemaName ).execute();
-                    datasource.getConnection().commit();
-                }
-
-                dsl.createTableIfNotExists( DSL.name( schemaName, typesTableName ) )
-                   .column( identityColumn )
-                   .column( tableNameColumn )
-                   .column( createdColumn )
-                   .column( modifiedColumn )
-                   .execute();
-                datasource.getConnection().commit();
-
-                dsl.createTableIfNotExists( DSL.name( schemaName, entitiesTableName ) )
-                   .column( identityColumn )
-                   .column( applicationVersionColumn )
-                   .column( valueIdentityColumn )
-                   .column( versionColumn )
-                   .column( typeNameColumn )
-                   .column( modifiedColumn )
-                   .column( createdColumn )
-                   .execute();
-                datasource.getConnection().commit();
+                dsl.transaction( t -> {
+                    if( !dialect.equals( SQLDialect.SQLITE )
+                        && dsl.meta().getSchemas().stream().noneMatch( s -> schema.getName().equalsIgnoreCase(
s.getName() ) ) )
+                    {
+                        dsl.createSchema( schemaName ).execute();
+                    }
+                } );
+
+                dsl.transaction( t -> {
+
+                    dsl.createTableIfNotExists( DSL.name( schemaName, typesTableName ) )
+                       .column( identityColumn )
+                       .column( tableNameColumn )
+                       .column( createdColumn )
+                       .column( modifiedColumn )
+                       .execute();
+
+                    dsl.createTableIfNotExists( DSL.name( schemaName, entitiesTableName )
)
+                       .column( identityColumn )
+                       .column( applicationVersionColumn )
+                       .column( valueIdentityColumn )
+                       .column( versionColumn )
+                       .column( typeNameColumn )
+                       .column( modifiedColumn )
+                       .column( createdColumn )
+                       .execute();
+                } );
             }
         }
 

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/58d19ab4/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 d193728..1122c71 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
@@ -21,6 +21,8 @@ package org.apache.polygene.entitystore.sql;
 
 import java.sql.Connection;
 import java.sql.Statement;
+import java.util.HashMap;
+import java.util.Map;
 import javax.sql.DataSource;
 import org.apache.polygene.api.common.Visibility;
 import org.apache.polygene.api.unitofwork.UnitOfWork;
@@ -43,9 +45,19 @@ public class PostgreSQLEntityStoreTest
     extends AbstractEntityStoreTest
 {
     @ClassRule
-    public static final DockerRule DOCKER = new DockerRule( "postgres",
-                                                            3000L,
-                                                            "PostgreSQL init process complete;
ready for start up." );
+    public static final DockerRule DOCKER;
+
+    static
+    {
+        Map<String,String> environment = new HashMap<>();
+        environment.put( "POSTGRES_USER", System.getProperty( "user.name" ));
+        environment.put( "POSTGRES_PASSWORD", "ThisIsGreat!");
+
+        DOCKER = new DockerRule( "postgres",
+                                 environment,
+                                 3000L,
+                                 "PostgreSQL init process complete; ready for start up."
);
+    }
 
     @Override
     // START SNIPPET: assembly
@@ -81,8 +93,10 @@ public class PostgreSQLEntityStoreTest
         // 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" );
+        DataSourceConfiguration defaults = config.forMixin( DataSourceConfiguration.class
).declareDefaults();
+        defaults.url().set( "jdbc:postgresql://" + host + ":" + port + "/jdbc_test_db" );
+        defaults.username().set( System.getProperty( "user.name" ) );
+        defaults.password().set( "ThisIsGreat!" );
         // START SNIPPET: assembly
     }
     // END SNIPPET: assembly

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/58d19ab4/extensions/entitystore-sql/src/test/resources/postgresql-datasource.properties
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sql/src/test/resources/postgresql-datasource.properties
b/extensions/entitystore-sql/src/test/resources/postgresql-datasource.properties
index bdda284..f47d5d3 100644
--- a/extensions/entitystore-sql/src/test/resources/postgresql-datasource.properties
+++ b/extensions/entitystore-sql/src/test/resources/postgresql-datasource.properties
@@ -20,5 +20,3 @@
 
 enabled=true
 driver=org.postgresql.Driver
-username=jdbc_test_login
-password=password


Mime
View raw message