http://git-wip-us.apache.org/repos/asf/polygene-java/blob/cfd38626/extensions/indexing-rdf/src/test/java/org/apache/polygene/index/rdf/RdfNamedQueryTest.java ---------------------------------------------------------------------- diff --git a/extensions/indexing-rdf/src/test/java/org/apache/polygene/index/rdf/RdfNamedQueryTest.java b/extensions/indexing-rdf/src/test/java/org/apache/polygene/index/rdf/RdfNamedQueryTest.java index 6ebbee8..18cc678 100644 --- a/extensions/indexing-rdf/src/test/java/org/apache/polygene/index/rdf/RdfNamedQueryTest.java +++ b/extensions/indexing-rdf/src/test/java/org/apache/polygene/index/rdf/RdfNamedQueryTest.java @@ -58,16 +58,16 @@ public class RdfNamedQueryTest extends AbstractNamedQueryTest "PREFIX ns0: <urn:polygene:type:org.apache.polygene.api.identity.HasIdentity#> \n" + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "SELECT DISTINCT ?reference\n" - + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.indexing.model.Person>. \n" + + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.model.Person>. \n" + "?entity rdf:type ?entityType. \n" + "?entity ns0:identity ?reference. \n" + "\n" + "}", // script01 // END SNIPPET: query1 // START SNIPPET: query2 - "PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.indexing.model.Nameable#> \n" + "PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.model.Nameable#> \n" + "PREFIX ns0: <urn:polygene:type:org.apache.polygene.api.identity.HasIdentity#> \n" + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "SELECT DISTINCT ?reference\n" - + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.indexing.model.Domain>. \n" + + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.model.Domain>. \n" + "?entity rdf:type ?entityType. \n" + "?entity ns0:identity ?reference. \n" + "?entity ns1:name ?v0. \n" + "FILTER (?v0 = \"Gaming\")\n" + "}", // script02 // END SNIPPET: query2 @@ -76,100 +76,100 @@ public class RdfNamedQueryTest extends AbstractNamedQueryTest "PREFIX ns0: <urn:polygene:type:org.apache.polygene.api.identity.HasIdentity#> \n" + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "SELECT DISTINCT ?reference\n" - + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.indexing.model.Nameable>. \n" + + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.model.Nameable>. \n" + "?entity rdf:type ?entityType. \n" + "?entity ns0:identity ?reference. \n" + "\n" + "}", // script03 // END SNIPPET: query3 // START SNIPPET: query4 - "PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.indexing.model.Person#> \n" - + "PREFIX ns2: <urn:polygene:type:org.apache.polygene.test.indexing.model.Nameable#> \n" + "PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.model.Person#> \n" + + "PREFIX ns2: <urn:polygene:type:org.apache.polygene.test.model.Nameable#> \n" + "PREFIX ns0: <urn:polygene:type:org.apache.polygene.api.identity.HasIdentity#> \n" + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "SELECT DISTINCT ?reference\n" - + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.indexing.model.Person>. \n" + + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.model.Person>. \n" + "?entity rdf:type ?entityType. \n" + "?entity ns0:identity ?reference. \n" + "?entity ns1:placeOfBirth ?v0. \n" + "?v0 ns2:name ?v1. \n" + "FILTER (?v1 = \"Kuala Lumpur\")\n" + "}", // script04 // END SNIPPET: query4 // START SNIPPET: query5 - "PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.indexing.model.Person#> \n" - + "PREFIX ns2: <urn:polygene:type:org.apache.polygene.test.indexing.model.Nameable#> \n" + "PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.model.Person#> \n" + + "PREFIX ns2: <urn:polygene:type:org.apache.polygene.test.model.Nameable#> \n" + "PREFIX ns0: <urn:polygene:type:org.apache.polygene.api.identity.HasIdentity#> \n" + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "SELECT DISTINCT ?reference\n" - + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.indexing.model.Person>. \n" + + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.model.Person>. \n" + "?entity rdf:type ?entityType. \n" + "?entity ns0:identity ?reference. \n" + "?entity ns1:mother ?v0. \n" + "?v0 ns1:placeOfBirth ?v1. \n" + "?v1 ns2:name ?v2. \n" + "FILTER (?v2 = \"Kuala Lumpur\")\n" + "}", // script05 // END SNIPPET: query5 // START SNIPPET: query6 - "PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.indexing.model.Person#> \n" + "PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.model.Person#> \n" + "PREFIX ns0: <urn:polygene:type:org.apache.polygene.api.identity.HasIdentity#> \n" + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "SELECT DISTINCT ?reference\n" - + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.indexing.model.Person>. \n" + + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.model.Person>. \n" + "?entity rdf:type ?entityType. \n" + "?entity ns0:identity ?reference. \n" + "?entity ns1:yearOfBirth ?v0. \n" + "FILTER (?v0 >= \"1973\")\n" + "}", // script06 // END SNIPPET: query6 // START SNIPPET: query7 - "PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.indexing.model.Person#> \n" - + "PREFIX ns2: <urn:polygene:type:org.apache.polygene.test.indexing.model.Nameable#> \n" + "PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.model.Person#> \n" + + "PREFIX ns2: <urn:polygene:type:org.apache.polygene.test.model.Nameable#> \n" + "PREFIX ns0: <urn:polygene:type:org.apache.polygene.api.identity.HasIdentity#> \n" + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "SELECT DISTINCT ?reference\n" - + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.indexing.model.Nameable>. \n" + + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.model.Nameable>. \n" + "?entity rdf:type ?entityType. \n" + "?entity ns0:identity ?reference. \n" + "?entity ns1:yearOfBirth ?v0. \n" + "?entity ns1:placeOfBirth ?v1. \n" + "?v1 ns2:name ?v2. \n" + "FILTER ((?v0 >= \"1900\") && (?v2 = \"Penang\"))\n" + "}", // script07 // END SNIPPET: query7 // START SNIPPET: query8 - "PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.indexing.model.Person#> \n" + "PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.model.Person#> \n" + "PREFIX ns0: <urn:polygene:type:org.apache.polygene.api.identity.HasIdentity#> \n" + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "SELECT DISTINCT ?reference\n" - + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.indexing.model.Person>. \n" + + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.model.Person>. \n" + "?entity rdf:type ?entityType. \n" + "?entity ns0:identity ?reference. \n" + "?entity ns1:yearOfBirth ?v0. \n" + "FILTER ((?v0 = \"1970\") || (?v0 = \"1975\"))\n" + "}", // script08 // END SNIPPET: query8 // START SNIPPET: query9 - "PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.indexing.model.Person#> \n" + "PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.model.Person#> \n" + "PREFIX ns0: <urn:polygene:type:org.apache.polygene.api.identity.HasIdentity#> \n" + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "SELECT DISTINCT ?reference\n" - + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.indexing.model.Female>. \n" + + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.model.Female>. \n" + "?entity rdf:type ?entityType. \n" + "?entity ns0:identity ?reference. \n" + "?entity ns1:yearOfBirth ?v0. \n" + "FILTER ((?v0 = \"1970\") || (?v0 = \"1975\"))\n" + "}", // script09 // END SNIPPET: query9 // START SNIPPET: query10 - "PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.indexing.model.Person#> \n" + "PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.model.Person#> \n" + "PREFIX ns0: <urn:polygene:type:org.apache.polygene.api.identity.HasIdentity#> \n" + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "SELECT DISTINCT ?reference\n" - + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.indexing.model.Person>. \n" + + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.model.Person>. \n" + "?entity rdf:type ?entityType. \n" + "?entity ns0:identity ?reference. \n" + "?entity ns1:yearOfBirth ?v0. \n" + "FILTER (!(?v0 = \"1975\"))\n" + "}", // script10 // END SNIPPET: query10 // START SNIPPET: query11 - "PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.indexing.model.Person#> \n" + "PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.model.Person#> \n" + "PREFIX ns0: <urn:polygene:type:org.apache.polygene.api.identity.HasIdentity#> \n" + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "SELECT DISTINCT ?reference\n" - + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.indexing.model.Person>. \n" + + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.model.Person>. \n" + "?entity rdf:type ?entityType. \n" + "?entity ns0:identity ?reference. \n" + "OPTIONAL {?entity ns1:email ?v0}. \n" + "FILTER (bound(?v0))\n" + "}", // script11 // END SNIPPET: query11 // START SNIPPET: query12 - "PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.indexing.model.Person#> \n" + "PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.model.Person#> \n" + "PREFIX ns0: <urn:polygene:type:org.apache.polygene.api.identity.HasIdentity#> \n" + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "SELECT DISTINCT ?reference\n" - + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.indexing.model.Person>. \n" + + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.model.Person>. \n" + "?entity rdf:type ?entityType. \n" + "?entity ns0:identity ?reference. \n" + "OPTIONAL {?entity ns1:email ?v0}. \n" + "FILTER (! bound(?v0))\n" + "}", // script12 // END SNIPPET: query12 @@ -177,9 +177,9 @@ public class RdfNamedQueryTest extends AbstractNamedQueryTest // START SNIPPET: query13 "PREFIX ns0: <urn:polygene:type:org.apache.polygene.api.identity.HasIdentity#> \n" + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" - + "PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.indexing.model.Male#> \n" + + "PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.model.Male#> \n" + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "SELECT DISTINCT ?reference\n" - + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.indexing.model.Person>. \n" + + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.model.Person>. \n" + "?entity rdf:type ?entityType. \n" + "?entity ns0:identity ?reference. \n" + "OPTIONAL {?entity ns1:wife ?v0}. \n" + "FILTER (bound(?v0))\n" + "}", // script13 // END SNIPPET: query13 @@ -187,9 +187,9 @@ public class RdfNamedQueryTest extends AbstractNamedQueryTest // START SNIPPET: query14 "PREFIX ns0: <urn:polygene:type:org.apache.polygene.api.identity.HasIdentity#> \n" + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" - + "PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.indexing.model.Male#> \n" + + "PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.model.Male#> \n" + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "SELECT DISTINCT ?reference\n" - + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.indexing.model.Male>. \n" + + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.model.Male>. \n" + "?entity rdf:type ?entityType. \n" + "?entity ns0:identity ?reference. \n" + "OPTIONAL {?entity ns1:wife ?v0}. \n" + "FILTER (! bound(?v0))\n" + "}", // script14 // END SNIPPET: query14 @@ -197,83 +197,83 @@ public class RdfNamedQueryTest extends AbstractNamedQueryTest // START SNIPPET: query15 "PREFIX ns0: <urn:polygene:type:org.apache.polygene.api.identity.HasIdentity#> \n" + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" - + "PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.indexing.model.Male#> \n" + + "PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.model.Male#> \n" + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "SELECT DISTINCT ?reference\n" - + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.indexing.model.Person>. \n" + + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.model.Person>. \n" + "?entity rdf:type ?entityType. \n" + "?entity ns0:identity ?reference. \n" + "OPTIONAL {?entity ns1:wife ?v0}. \n" + "FILTER (! bound(?v0))\n" + "}", // script15 // END SNIPPET: query15 // START SNIPPET: query16 - "PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.indexing.model.Nameable#> \n" + "PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.model.Nameable#> \n" + "PREFIX ns0: <urn:polygene:type:org.apache.polygene.api.identity.HasIdentity#> \n" + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "SELECT DISTINCT ?reference\n" - + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.indexing.model.Nameable>. \n" + + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.model.Nameable>. \n" + "?entity rdf:type ?entityType. \n" + "?entity ns0:identity ?reference. \n" + "?entity ns1:name ?v0. \n" + "\n" + "}", // script16 // END SNIPPET: query16 // START SNIPPET: query17 - "PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.indexing.model.Nameable#> \n" + "PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.model.Nameable#> \n" + "PREFIX ns0: <urn:polygene:type:org.apache.polygene.api.identity.HasIdentity#> \n" + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "SELECT DISTINCT ?reference\n" - + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.indexing.model.Nameable>. \n" + + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.model.Nameable>. \n" + "?entity rdf:type ?entityType. \n" + "?entity ns0:identity ?reference. \n" + "?entity ns1:name ?v0. \n" + "\n" + "} ", // script17 // END SNIPPET: query17 // START SNIPPET: query18 - "PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.indexing.model.Nameable#> \n" + "PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.model.Nameable#> \n" + "PREFIX ns0: <urn:polygene:type:org.apache.polygene.api.identity.HasIdentity#> \n" + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "SELECT DISTINCT ?reference\n" - + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.indexing.model.Nameable>. \n" + + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.model.Nameable>. \n" + "?entity rdf:type ?entityType. \n" + "?entity ns0:identity ?reference. \n" + "?entity ns1:name ?v0. \n" + "\n" + "}\n", // script18 // END SNIPPET: query18 // START SNIPPET: query19 - "PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.indexing.model.Nameable#> \n" + "PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.model.Nameable#> \n" + "PREFIX ns0: <urn:polygene:type:org.apache.polygene.api.identity.HasIdentity#> \n" + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "SELECT DISTINCT ?reference\n" - + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.indexing.model.Nameable>. \n" + + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.model.Nameable>. \n" + "?entity rdf:type ?entityType. \n" + "?entity ns0:identity ?reference. \n" + "?entity ns1:name ?v0. \n" + "FILTER (?v0 > \"D\")\n" + "} ", // script19 // END SNIPPET: query19 // START SNIPPET: query20 - "PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.indexing.model.Person#> \n" - + "PREFIX ns2: <urn:polygene:type:org.apache.polygene.test.indexing.model.Nameable#> \n" + "PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.model.Person#> \n" + + "PREFIX ns2: <urn:polygene:type:org.apache.polygene.test.model.Nameable#> \n" + "PREFIX ns0: <urn:polygene:type:org.apache.polygene.api.identity.HasIdentity#> \n" + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "SELECT DISTINCT ?reference\n" - + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.indexing.model.Person>. \n" + + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.model.Person>. \n" + "?entity rdf:type ?entityType. \n" + "?entity ns0:identity ?reference. \n" + "?entity ns1:yearOfBirth ?v0. \n" + "?entity ns2:name ?v1. \n" + "FILTER (?v0 > \"1973\")\n" + "}\n" , // script20 // END SNIPPET: query20 // START SNIPPET: query21 - "PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.indexing.model.Person#> \n" - + "PREFIX ns2: <urn:polygene:type:org.apache.polygene.test.indexing.model.Nameable#> \n" + "PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.model.Person#> \n" + + "PREFIX ns2: <urn:polygene:type:org.apache.polygene.test.model.Nameable#> \n" + "PREFIX ns0: <urn:polygene:type:org.apache.polygene.api.identity.HasIdentity#> \n" + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "SELECT DISTINCT ?reference\n" - + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.indexing.model.Person>. \n" + + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.model.Person>. \n" + "?entity rdf:type ?entityType. \n" + "?entity ns0:identity ?reference. \n" + "?entity ns1:placeOfBirth ?v0. \n" + "?v0 ns2:name ?v1. \n" + "?entity ns1:yearOfBirth ?v2. \n" + "\n" + "}", // script21 // END SNIPPET: query21 // START SNIPPET: query22 - "PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.indexing.model.Nameable#> \n" + "PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.model.Nameable#> \n" + "PREFIX ns0: <urn:polygene:type:org.apache.polygene.api.identity.HasIdentity#> \n" + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "SELECT DISTINCT ?reference\n" - + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.indexing.model.Nameable>. \n" + + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.model.Nameable>. \n" + "?entity rdf:type ?entityType. \n" + "?entity ns0:identity ?reference. \n" + "?entity ns1:name ?v0. \n" + "FILTER regex(?v0,\"J.*Doe\")\n" + "}", // script22 // END SNIPPET: query22 @@ -283,11 +283,11 @@ public class RdfNamedQueryTest extends AbstractNamedQueryTest // END SNIPPET: query23 // START SNIPPET: query24 - "PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.indexing.model.Nameable#> \n" + "PREFIX ns1: <urn:polygene:type:org.apache.polygene.test.model.Nameable#> \n" + "PREFIX ns0: <urn:polygene:type:org.apache.polygene.api.identity.HasIdentity#> \n" + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "SELECT DISTINCT ?reference\n" - + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.indexing.model.Domain>. \n" + + "WHERE {\n" + "?entityType rdfs:subClassOf <urn:polygene:type:org.apache.polygene.test.model.Domain>. \n" + "?entity rdf:type ?entityType. \n" + "?entity ns0:identity ?reference. \n" + "?entity ns1:name ?v0. \n" + "FILTER (?v0 = ?domain)\n" + "}" // script24 // END SNIPPET: query24
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/cfd38626/extensions/indexing-sql/src/test/java/org/apache/polygene/index/sql/postgresql/PostgreSQLComplexQueryTest.java ---------------------------------------------------------------------- diff --git a/extensions/indexing-sql/src/test/java/org/apache/polygene/index/sql/postgresql/PostgreSQLComplexQueryTest.java b/extensions/indexing-sql/src/test/java/org/apache/polygene/index/sql/postgresql/PostgreSQLComplexQueryTest.java index 74d8e63..da9e217 100644 --- a/extensions/indexing-sql/src/test/java/org/apache/polygene/index/sql/postgresql/PostgreSQLComplexQueryTest.java +++ b/extensions/indexing-sql/src/test/java/org/apache/polygene/index/sql/postgresql/PostgreSQLComplexQueryTest.java @@ -29,7 +29,7 @@ public class PostgreSQLComplexQueryTest extends AbstractComplexQueryTest { @ClassRule - public static final DockerRule DOCKER = new DockerRule( "postgres", 5432 ); + public static final DockerRule DOCKER = new DockerRule( "postgres", 3000L, "PostgreSQL init process complete; ready for start up." ); @Override public void assemble( ModuleAssembly mainModule ) http://git-wip-us.apache.org/repos/asf/polygene-java/blob/cfd38626/extensions/indexing-sql/src/test/java/org/apache/polygene/index/sql/postgresql/PostgreSQLDBIntegrityTest.java ---------------------------------------------------------------------- diff --git a/extensions/indexing-sql/src/test/java/org/apache/polygene/index/sql/postgresql/PostgreSQLDBIntegrityTest.java b/extensions/indexing-sql/src/test/java/org/apache/polygene/index/sql/postgresql/PostgreSQLDBIntegrityTest.java index 627c8df..7906b61 100644 --- a/extensions/indexing-sql/src/test/java/org/apache/polygene/index/sql/postgresql/PostgreSQLDBIntegrityTest.java +++ b/extensions/indexing-sql/src/test/java/org/apache/polygene/index/sql/postgresql/PostgreSQLDBIntegrityTest.java @@ -46,7 +46,7 @@ public class PostgreSQLDBIntegrityTest extends AbstractPolygeneTest { @ClassRule - public static final DockerRule DOCKER = new DockerRule( "postgres", 5432 ); + public static final DockerRule DOCKER = new DockerRule( "postgres", 3000L, "PostgreSQL init process complete; ready for start up." ); public static interface TestEntity extends EntityComposite http://git-wip-us.apache.org/repos/asf/polygene-java/blob/cfd38626/extensions/indexing-sql/src/test/java/org/apache/polygene/index/sql/postgresql/PostgreSQLEntityFinderTest.java ---------------------------------------------------------------------- diff --git a/extensions/indexing-sql/src/test/java/org/apache/polygene/index/sql/postgresql/PostgreSQLEntityFinderTest.java b/extensions/indexing-sql/src/test/java/org/apache/polygene/index/sql/postgresql/PostgreSQLEntityFinderTest.java index 8a0c3f2..e909827 100644 --- a/extensions/indexing-sql/src/test/java/org/apache/polygene/index/sql/postgresql/PostgreSQLEntityFinderTest.java +++ b/extensions/indexing-sql/src/test/java/org/apache/polygene/index/sql/postgresql/PostgreSQLEntityFinderTest.java @@ -29,7 +29,7 @@ public class PostgreSQLEntityFinderTest extends AbstractEntityFinderTest { @ClassRule - public static final DockerRule DOCKER = new DockerRule( "postgres", 5432 ); + public static final DockerRule DOCKER = new DockerRule( "postgres", 3000L, "PostgreSQL init process complete; ready for start up." ); @Override public void assemble( ModuleAssembly mainModule ) http://git-wip-us.apache.org/repos/asf/polygene-java/blob/cfd38626/extensions/indexing-sql/src/test/java/org/apache/polygene/index/sql/postgresql/PostgreSQLQueryTest.java ---------------------------------------------------------------------- diff --git a/extensions/indexing-sql/src/test/java/org/apache/polygene/index/sql/postgresql/PostgreSQLQueryTest.java b/extensions/indexing-sql/src/test/java/org/apache/polygene/index/sql/postgresql/PostgreSQLQueryTest.java index 3a4caa6..ab8b923 100644 --- a/extensions/indexing-sql/src/test/java/org/apache/polygene/index/sql/postgresql/PostgreSQLQueryTest.java +++ b/extensions/indexing-sql/src/test/java/org/apache/polygene/index/sql/postgresql/PostgreSQLQueryTest.java @@ -36,7 +36,7 @@ public class PostgreSQLQueryTest extends AbstractQueryTest { @ClassRule - public static final DockerRule DOCKER = new DockerRule( "postgres", 5432 ); + public static final DockerRule DOCKER = new DockerRule( "postgres", 3000L, "PostgreSQL init process complete; ready for start up." ); @Override public void assemble( ModuleAssembly mainModule ) http://git-wip-us.apache.org/repos/asf/polygene-java/blob/cfd38626/internals/testsupport-internal/src/main/java/org/apache/polygene/test/internal/DelayChecker.java ---------------------------------------------------------------------- diff --git a/internals/testsupport-internal/src/main/java/org/apache/polygene/test/internal/DelayChecker.java b/internals/testsupport-internal/src/main/java/org/apache/polygene/test/internal/DelayChecker.java new file mode 100644 index 0000000..574381d --- /dev/null +++ b/internals/testsupport-internal/src/main/java/org/apache/polygene/test/internal/DelayChecker.java @@ -0,0 +1,60 @@ +/* + * 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.test.internal; + +import pl.domzal.junit.docker.rule.wait.StartCondition; +import pl.domzal.junit.docker.rule.wait.StartConditionCheck; + +class DelayChecker + implements StartCondition +{ + + private final long millis; + private final long doneAt; + + DelayChecker( long millis ) + { + this.millis = millis; + this.doneAt = System.currentTimeMillis() + millis; + } + + @Override + public StartConditionCheck build( pl.domzal.junit.docker.rule.DockerRule currentRule ) + { + return new StartConditionCheck() + { + + @Override + public boolean check() + { + return System.currentTimeMillis() > doneAt; + } + + @Override + public String describe() + { + return String.format( "delay check %d ms", millis ); + } + + @Override + public void after() + { + } + }; + } +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/cfd38626/internals/testsupport-internal/src/main/java/org/apache/polygene/test/internal/DockerRule.java ---------------------------------------------------------------------- diff --git a/internals/testsupport-internal/src/main/java/org/apache/polygene/test/internal/DockerRule.java b/internals/testsupport-internal/src/main/java/org/apache/polygene/test/internal/DockerRule.java index 1e228a5..f8059bd 100644 --- a/internals/testsupport-internal/src/main/java/org/apache/polygene/test/internal/DockerRule.java +++ b/internals/testsupport-internal/src/main/java/org/apache/polygene/test/internal/DockerRule.java @@ -17,14 +17,21 @@ */ package org.apache.polygene.test.internal; +import java.util.Arrays; import java.util.Collections; +import java.util.List; import java.util.Map; +import java.util.stream.Collectors; import org.junit.rules.TestRule; import org.junit.runner.Description; import org.junit.runners.model.Statement; import pl.domzal.junit.docker.rule.DockerRuleBuilder; import pl.domzal.junit.docker.rule.WaitFor; +import pl.domzal.junit.docker.rule.wait.LineListener; +import pl.domzal.junit.docker.rule.wait.StartCondition; +import pl.domzal.junit.docker.rule.wait.StartConditionCheck; +import static java.util.stream.Collectors.joining; import static org.junit.Assume.assumeFalse; public class DockerRule @@ -35,11 +42,40 @@ public class DockerRule public DockerRule( String image, int... portsToWaitFor ) { - this( image, Collections.emptyMap(), portsToWaitFor ); + this( image, null, WaitFor.tcpPort( portsToWaitFor ) ); } - public DockerRule( String image, Map<String, String> environment, int... portsToWaitFor ) + public DockerRule( String image, String... logMessageSequenceToWaitFor ) { + this( image, null, WaitFor.logMessageSequence( logMessageSequenceToWaitFor ) ); + } + + public DockerRule( String image, Map<String, String> environment, String... logMessageSequnceToWaitFor ) + { + this( image, environment, WaitFor.logMessageSequence( logMessageSequnceToWaitFor ) ); + } + + public DockerRule( String image, Long delay, int... portsToWaitFor ) + { + this( image, null, new DelayChecker( delay ), WaitFor.tcpPort( portsToWaitFor ), new DelayChecker( delay ) ); + } + + public DockerRule( String image, Long delay, String... logMessageSequenceToWaitFor ) + { + this( image, null, WaitFor.logMessageSequence( logMessageSequenceToWaitFor ), new DelayChecker( delay ) ); + } + + public DockerRule( String image, Map<String, String> environment, Long delay, String... logMessageSequnceToWaitFor ) + { + this( image, environment, WaitFor.logMessageSequence( logMessageSequnceToWaitFor ), new DelayChecker( delay ) ); + } + + public DockerRule( String image, Map<String, String> environment, StartCondition... waitFor ) + { + if( environment == null ) + { + environment = Collections.emptyMap(); + } if( dockerDisabled ) { dockerRule = null; @@ -50,7 +86,8 @@ public class DockerRule .builder() .imageName( "org.apache.polygene:org.apache.polygene.internal.docker-" + image ) .publishAllPorts( true ) - .waitFor( WaitFor.tcpPort( portsToWaitFor ) ); + .waitForTimeout( 60000 ) + .waitFor( rule -> new AndChecker( rule, waitFor ) ); environment.entrySet().forEach( entry -> builder.env( entry.getKey(), entry.getValue() ) ); dockerRule = builder.build(); } @@ -72,4 +109,48 @@ public class DockerRule { return Integer.valueOf( dockerRule.getExposedContainerPort( containerPort ) ); } + + public class AndChecker + implements StartConditionCheck, LineListener + { + private List<StartConditionCheck> allOf; + + public AndChecker( pl.domzal.junit.docker.rule.DockerRule rule, StartCondition... allOf ) + { + this.allOf = Arrays.stream( allOf ).map( cond -> cond.build( rule ) ).collect( Collectors.toList() ); + } + + @Override + public boolean check() + { + return allOf.stream() + .allMatch( StartConditionCheck::check ); + } + + @Override + public String describe() + { + return allOf.stream() + .map( StartConditionCheck::describe ) + .collect( joining( ",", "and(", ")" ) ); + } + + @Override + public void after() + { + allOf.forEach( StartConditionCheck::after ); + } + + @Override + public void nextLine( String line ) + { + allOf.forEach( listener -> + { + if( listener instanceof LineListener ) + { + ( (LineListener) listener ).nextLine( line ); + } + } ); + } + } } http://git-wip-us.apache.org/repos/asf/polygene-java/blob/cfd38626/libraries/http/build.gradle ---------------------------------------------------------------------- diff --git a/libraries/http/build.gradle b/libraries/http/build.gradle index 19c89dc..6002d53 100644 --- a/libraries/http/build.gradle +++ b/libraries/http/build.gradle @@ -38,6 +38,7 @@ dependencies { testImplementation polygene.core.testsupport testImplementation libraries.http_client + testImplementation libraries.junit testRuntimeOnly libraries.logback }
