You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by wi...@apache.org on 2016/05/02 11:50:27 UTC

[50/50] [abbrv] marmotta git commit: MARMOTTA-584: cosmetics

MARMOTTA-584: cosmetics


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

Branch: refs/heads/MARMOTTA-584
Commit: cde06ca13b1f3a42955b84706e0575d662551a8b
Parents: 653706d
Author: Sergio Fern�ndez <wi...@apache.org>
Authored: Mon May 2 11:48:22 2016 +0200
Committer: Sergio Fern�ndez <wi...@apache.org>
Committed: Mon May 2 11:49:10 2016 +0200

----------------------------------------------------------------------
 .../persistence/pgsql/upgrade_base_004_005.sql  | 15 ++--
 .../marmotta/kiwi/test/PersistenceTest.java     | 73 ++++----------------
 2 files changed, 21 insertions(+), 67 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/cde06ca1/libraries/kiwi/kiwi-triplestore/src/main/resources/org/apache/marmotta/kiwi/persistence/pgsql/upgrade_base_004_005.sql
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/src/main/resources/org/apache/marmotta/kiwi/persistence/pgsql/upgrade_base_004_005.sql b/libraries/kiwi/kiwi-triplestore/src/main/resources/org/apache/marmotta/kiwi/persistence/pgsql/upgrade_base_004_005.sql
index 75cc875..b1de974 100644
--- a/libraries/kiwi/kiwi-triplestore/src/main/resources/org/apache/marmotta/kiwi/persistence/pgsql/upgrade_base_004_005.sql
+++ b/libraries/kiwi/kiwi-triplestore/src/main/resources/org/apache/marmotta/kiwi/persistence/pgsql/upgrade_base_004_005.sql
@@ -16,26 +16,25 @@
 
 --creating new type 'geom'
 -- 1. rename the enum type 
-alter type nodetype rename to nodetype_old;
+ALTER TYPE nodetype RENAME TO nodetype_old;
 -- 2. create new type
 CREATE TYPE nodetype AS ENUM ('uri','bnode','string','int','double','date','boolean','geom');
 -- 3. rename column(s) which uses our enum type
-alter table nodes rename column ntype to ntype_old;
+ALTER TABLE nodes RENAME COLUMN ntype TO ntype_old;
 -- 4. add new column of new type
-alter table nodes add ntype nodetype;
+ALTER TABLE nodes ADD ntype nodetype;
 -- 5. copy values to the new column
-update nodes set ntype = ntype_old::text::nodetype;
+UPDATE nodes SET ntype = ntype_old::text::nodetype;
 -- 6. remove old column and type
-alter table nodes drop column ntype_old;
-
+ALTER TABLE nodes DROP COLUMN ntype_old;
 -- 7. delete old enum type
-drop type nodetype_old;
+DROP TYPE nodetype_old;
 
 --necessary for use spatial queries
 CREATE EXTENSION IF NOT EXISTS POSTGIS;
 
 --adding geometry colum
-ALTER TABLE nodes ADD COLUMN gvalue geometry;
+ALTER TABLE nodes ADD COLUMN gvalue GEOMETRY;
 
 UPDATE METADATA SET mvalue = '5' WHERE mkey = 'version';
 INSERT INTO metadata(mkey,mvalue) VALUES ('updated',to_char(now(),'yyyy-MM-DD HH:mm:ss TZ') );

http://git-wip-us.apache.org/repos/asf/marmotta/blob/cde06ca1/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/PersistenceTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/PersistenceTest.java b/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/PersistenceTest.java
index 3aa3842..22b9736 100644
--- a/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/PersistenceTest.java
+++ b/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/PersistenceTest.java
@@ -52,7 +52,6 @@ import static org.hamcrest.Matchers.hasItems;
 @RunWith(KiWiDatabaseRunner.class)
 public class PersistenceTest {
 
-
     private KiWiPersistence persistence;
 
     private final KiWiConfiguration kiwiConfig;
@@ -61,7 +60,6 @@ public class PersistenceTest {
         this.kiwiConfig = kiwiConfig;
     }
 
-
     @Before
     public void initDatabase() throws SQLException {
         persistence = new KiWiPersistence(kiwiConfig);
@@ -75,20 +73,18 @@ public class PersistenceTest {
         persistence.shutdown();
     }
 
-
     @Test
     public void testCreateDropDatabase() throws SQLException {
         // test if database exists and has a version
-        KiWiConnection connection = persistence.getConnection();
+        final KiWiConnection connection = persistence.getConnection();
         try {
-            Assert.assertThat(connection.getDatabaseTables(),hasItems("nodes","triples","namespaces"));
+            Assert.assertThat(connection.getDatabaseTables(), hasItems("nodes", "triples", "namespaces"));
             Assert.assertEquals(KiWiDialect.VERSION, connection.getDatabaseVersion());
 
             connection.commit();
         } finally {
             connection.close();
         }
-
     }
 
     /**
@@ -121,19 +117,16 @@ public class PersistenceTest {
             Assert.assertEquals(uri,testUri2);
             Assert.assertEquals(uri.getId(), testUri2.getId());
 
-
             KiWiNode testUri3 = connection.loadUriResource(uri.stringValue());
 
             // needs to be equal, and should also be the identical object!
             Assert.assertEquals(uri,testUri3);
             Assert.assertEquals(uri.getId(), testUri3.getId());
 
-
             connection.commit();
 
             Assert.assertEquals(1,Iterations.asList(connection.listResources()).size());
 
-
             // clear cache and test again
             persistence.clearCache();
             KiWiNode testUri4 = connection.loadNodeById(uri.getId());
@@ -167,7 +160,6 @@ public class PersistenceTest {
 
     }
 
-
     /**
      * Test storing and loading blank nodes.
      *
@@ -198,14 +190,12 @@ public class PersistenceTest {
             Assert.assertEquals(bnode,testBNode2);
             Assert.assertEquals(bnode.getId(), testBNode2.getId());
 
-
             KiWiNode testBNode3 = connection.loadAnonResource(bnode.stringValue());
 
             // needs to be equal, and should also be the identical object!
             Assert.assertEquals(bnode,testBNode3);
             Assert.assertEquals(bnode.getId(), testBNode3.getId());
 
-
             connection.commit();
 
             Assert.assertEquals(1,Iterations.asList(connection.listResources()).size());
@@ -240,7 +230,6 @@ public class PersistenceTest {
         } finally {
             connection.close();
         }
-
     }
 
 
@@ -285,7 +274,6 @@ public class PersistenceTest {
 
             connection.commit();
 
-
             // clear cache and test again
             persistence.clearCache();
             KiWiNode testLiteral4 = connection.loadNodeById(literal.getId());
@@ -319,7 +307,6 @@ public class PersistenceTest {
         } finally {
             connection.close();
         }
-
     }
 
 
@@ -364,7 +351,6 @@ public class PersistenceTest {
 
             connection.commit();
 
-
             // clear cache and test again
             persistence.clearCache();
             KiWiNode testLiteral4 = connection.loadNodeById(literal.getId());
@@ -398,7 +384,6 @@ public class PersistenceTest {
         } finally {
             connection.close();
         }
-
     }
 
 
@@ -445,7 +430,6 @@ public class PersistenceTest {
 
             connection.commit();
 
-
             // clear cache and test again
             persistence.clearCache();
             KiWiNode testLiteral4 = connection.loadNodeById(literal.getId());
@@ -480,7 +464,6 @@ public class PersistenceTest {
         } finally {
             connection.close();
         }
-
     }
 
 
@@ -527,7 +510,6 @@ public class PersistenceTest {
 
             connection.commit();
 
-
             // clear cache and test again
             persistence.clearCache();
             KiWiNode testLiteral4 = connection.loadNodeById(literal.getId());
@@ -562,7 +544,6 @@ public class PersistenceTest {
         } finally {
             connection.close();
         }
-
     }
 
 
@@ -578,11 +559,10 @@ public class PersistenceTest {
         try {
             KiWiUriResource uri = new KiWiUriResource(Namespaces.NS_XSD + "integer");
 
-
             Random rnd = new Random();
             long value = rnd.nextLong();
 
-                    // add a new URI to the triple store and check if it exists afterwards, before and after commit
+            // add a new URI to the triple store and check if it exists afterwards, before and after commit
             KiWiIntLiteral literal = new KiWiIntLiteral(value, uri);
             connection.storeNode(literal);
 
@@ -612,7 +592,6 @@ public class PersistenceTest {
             Assert.assertEquals(uri,((KiWiLiteral)testLiteral3).getType());
             //Assert.assertTrue(literal == testLiteral3);
 
-
             // load by integer value
             KiWiNode testLiteral6 = connection.loadLiteral(value);
 
@@ -621,10 +600,8 @@ public class PersistenceTest {
             Assert.assertEquals(uri,((KiWiLiteral)testLiteral6).getType());
             //Assert.assertTrue(literal == testLiteral6);
 
-
             connection.commit();
 
-
             // clear cache and test again
             persistence.clearCache();
             KiWiNode testLiteral4 = connection.loadNodeById(literal.getId());
@@ -641,7 +618,6 @@ public class PersistenceTest {
             Assert.assertEquals(uri,((KiWiLiteral)testLiteral5).getType());
             //Assert.assertTrue(literal != testLiteral5);
 
-
             // load by integer value
             KiWiNode testLiteral7 = connection.loadLiteral(value);
 
@@ -669,7 +645,6 @@ public class PersistenceTest {
         } finally {
             connection.close();
         }
-
     }
 
     /**
@@ -683,7 +658,6 @@ public class PersistenceTest {
         try {
             KiWiUriResource uri = new KiWiUriResource(Namespaces.NS_XSD + "double");
 
-
             Random rnd = new Random();
             double value = rnd.nextDouble();
 
@@ -717,7 +691,6 @@ public class PersistenceTest {
             Assert.assertEquals(uri,((KiWiLiteral)testLiteral3).getType());
             //Assert.assertTrue(literal == testLiteral3);
 
-
             // load by integer value
             KiWiNode testLiteral6 = connection.loadLiteral(value);
 
@@ -726,10 +699,8 @@ public class PersistenceTest {
             Assert.assertEquals(uri,((KiWiLiteral)testLiteral6).getType());
             //Assert.assertTrue(literal == testLiteral6);
 
-
             connection.commit();
 
-
             // clear cache and test again
             persistence.clearCache();
             KiWiNode testLiteral4 = connection.loadNodeById(literal.getId());
@@ -746,7 +717,6 @@ public class PersistenceTest {
             Assert.assertEquals(uri,((KiWiLiteral)testLiteral5).getType());
             //Assert.assertTrue(literal != testLiteral5);
 
-
             // load by integer value
             KiWiNode testLiteral7 = connection.loadLiteral(value);
 
@@ -774,7 +744,6 @@ public class PersistenceTest {
         } finally {
             connection.close();
         }
-
     }
 
     /**
@@ -821,7 +790,6 @@ public class PersistenceTest {
             Assert.assertEquals(uri,((KiWiLiteral)testLiteral3).getType());
             //Assert.assertTrue(literal == testLiteral3);
 
-
             // load by integer value
             KiWiNode testLiteral6 = connection.loadLiteral(value);
 
@@ -830,10 +798,8 @@ public class PersistenceTest {
             Assert.assertEquals(uri,((KiWiLiteral)testLiteral6).getType());
             //Assert.assertTrue(literal == testLiteral6);
 
-
             connection.commit();
 
-
             // clear cache and test again
             persistence.clearCache();
             KiWiNode testLiteral4 = connection.loadNodeById(literal.getId());
@@ -850,7 +816,6 @@ public class PersistenceTest {
             Assert.assertEquals(uri,((KiWiLiteral)testLiteral5).getType());
             //Assert.assertTrue(literal != testLiteral5);
 
-
             // load by integer value
             KiWiNode testLiteral7 = connection.loadLiteral(value);
 
@@ -878,7 +843,6 @@ public class PersistenceTest {
         } finally {
             connection.close();
         }
-
     }
 
     /**
@@ -892,7 +856,6 @@ public class PersistenceTest {
         try {
             KiWiUriResource uri = new KiWiUriResource(Namespaces.NS_XSD + "dateTime");
 
-
             DateTime value = DateTime.now().withMillisOfSecond(0);
             // add a new URI to the triple store and check if it exists afterwards, before and after commit
             KiWiDateLiteral literal = new KiWiDateLiteral(value, uri);
@@ -924,7 +887,6 @@ public class PersistenceTest {
             Assert.assertEquals(uri,((KiWiLiteral)testLiteral3).getType());
             //Assert.assertTrue(literal == testLiteral3);
 
-
             // load by integer value
             KiWiNode testLiteral6 = connection.loadLiteral(value);
 
@@ -933,10 +895,8 @@ public class PersistenceTest {
             Assert.assertEquals(uri,((KiWiLiteral)testLiteral6).getType());
             //Assert.assertTrue(literal == testLiteral6);
 
-
             connection.commit();
 
-
             // clear cache and test again
             persistence.clearCache();
             KiWiNode testLiteral4 = connection.loadNodeById(literal.getId());
@@ -953,7 +913,6 @@ public class PersistenceTest {
             Assert.assertEquals(uri,((KiWiLiteral)testLiteral5).getType());
             //Assert.assertTrue(literal != testLiteral5);
 
-
             // load by integer value
             KiWiNode testLiteral7 = connection.loadLiteral(value);
 
@@ -981,11 +940,8 @@ public class PersistenceTest {
         } finally {
             connection.close();
         }
-
     }
 
-
-
     /**
      * Test storing, querying and deleting triples
      */
@@ -1037,9 +993,8 @@ public class PersistenceTest {
                 // clear cache and test again
                 persistence.clearCache();
 
-                List<Statement> result3 = Iterations.asList(connection.listTriples(subject,null,null,null,false, true));
-                Assert.assertThat(result3,hasItems((Statement)triple1,(Statement)triple2));
-
+                List<Statement> result3 = Iterations.asList(connection.listTriples(subject, null, null, null, false, true));
+                Assert.assertThat(result3,hasItems((Statement)triple1, triple2));
 
                 Assert.assertEquals(2, connection.getSize());
                 Assert.assertEquals(2, connection.getSize(context));
@@ -1050,16 +1005,16 @@ public class PersistenceTest {
                 ResultSet dbResult1 = stmt.executeQuery();
 
                 Assert.assertTrue(dbResult1.next());
-                Assert.assertEquals((long) triple1.getId(), dbResult1.getLong("id"));
-                Assert.assertEquals((long) triple1.getSubject().getId(), dbResult1.getLong("subject"));
-                Assert.assertEquals((long) triple1.getPredicate().getId(), dbResult1.getLong("predicate"));
-                Assert.assertEquals((long)triple1.getObject().getId(),dbResult1.getLong("object"));
+                Assert.assertEquals(triple1.getId(), dbResult1.getLong("id"));
+                Assert.assertEquals( triple1.getSubject().getId(), dbResult1.getLong("subject"));
+                Assert.assertEquals(triple1.getPredicate().getId(), dbResult1.getLong("predicate"));
+                Assert.assertEquals(triple1.getObject().getId(),dbResult1.getLong("object"));
 
                 Assert.assertTrue(dbResult1.next());
-                Assert.assertEquals((long)triple2.getId(),dbResult1.getLong("id"));
-                Assert.assertEquals((long)triple2.getSubject().getId(),dbResult1.getLong("subject"));
-                Assert.assertEquals((long)triple2.getPredicate().getId(),dbResult1.getLong("predicate"));
-                Assert.assertEquals((long)triple2.getObject().getId(),dbResult1.getLong("object"));
+                Assert.assertEquals(triple2.getId(),dbResult1.getLong("id"));
+                Assert.assertEquals(triple2.getSubject().getId(),dbResult1.getLong("subject"));
+                Assert.assertEquals(triple2.getPredicate().getId(),dbResult1.getLong("predicate"));
+                Assert.assertEquals(triple2.getObject().getId(),dbResult1.getLong("object"));
 
                 dbResult1.close();
 
@@ -1067,7 +1022,6 @@ public class PersistenceTest {
             } finally {
                 connection.close();
             }
-
     }
 
     // TODO: test namespaces
@@ -1122,4 +1076,5 @@ public class PersistenceTest {
             connection.close();
         }
     }
+
 }