activerdf_net7 1.6.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (190) hide show
  1. data/CHANGELOG +79 -0
  2. data/LICENSE +504 -0
  3. data/README.rdoc +34 -0
  4. data/activerdf-jena/CHANGELOG +14 -0
  5. data/activerdf-jena/LICENSE +504 -0
  6. data/activerdf-jena/README +57 -0
  7. data/activerdf-jena/Rakefile +87 -0
  8. data/activerdf-jena/TODO +18 -0
  9. data/activerdf-jena/VERSION +1 -0
  10. data/activerdf-jena/ext/antlr-2.7.5.jar +0 -0
  11. data/activerdf-jena/ext/arq-extra.jar +0 -0
  12. data/activerdf-jena/ext/arq.jar +0 -0
  13. data/activerdf-jena/ext/aterm-java-1.6.jar +0 -0
  14. data/activerdf-jena/ext/commons-logging-1.1.jar +0 -0
  15. data/activerdf-jena/ext/concurrent.jar +0 -0
  16. data/activerdf-jena/ext/icu4j_3_4.jar +0 -0
  17. data/activerdf-jena/ext/iri.jar +0 -0
  18. data/activerdf-jena/ext/jena.jar +0 -0
  19. data/activerdf-jena/ext/jenatest.jar +0 -0
  20. data/activerdf-jena/ext/json.jar +0 -0
  21. data/activerdf-jena/ext/junit.jar +0 -0
  22. data/activerdf-jena/ext/log4j-1.2.12.jar +0 -0
  23. data/activerdf-jena/ext/lucene-core-2.0.0.jar +0 -0
  24. data/activerdf-jena/ext/ng4j.jar +0 -0
  25. data/activerdf-jena/ext/pellet.jar +0 -0
  26. data/activerdf-jena/ext/relaxngDatatype.jar +0 -0
  27. data/activerdf-jena/ext/stax-api-1.0.jar +0 -0
  28. data/activerdf-jena/ext/wstx-asl-3.0.0.jar +0 -0
  29. data/activerdf-jena/ext/xercesImpl.jar +0 -0
  30. data/activerdf-jena/ext/xml-apis.jar +0 -0
  31. data/activerdf-jena/ext/xsdlib.jar +0 -0
  32. data/activerdf-jena/lib/activerdf_jena/init.rb +26 -0
  33. data/activerdf-jena/lib/activerdf_jena/jena.rb +59 -0
  34. data/activerdf-jena/lib/activerdf_jena/jena_adapter.rb +515 -0
  35. data/activerdf-jena/lib/activerdf_jena/lucene.rb +22 -0
  36. data/activerdf-jena/lib/activerdf_jena/ng4j.rb +50 -0
  37. data/activerdf-jena/lib/activerdf_jena/ng4j_adapter.rb +379 -0
  38. data/activerdf-jena/lib/activerdf_jena/pellet.rb +25 -0
  39. data/activerdf-jena/test/bnode_org_rss.rdf +793 -0
  40. data/activerdf-jena/test/eyal-foaf.nt +39 -0
  41. data/activerdf-jena/test/fun_with_bnodes.nt +2 -0
  42. data/activerdf-jena/test/s1.n3 +18 -0
  43. data/activerdf-jena/test/test_data.nt +32 -0
  44. data/activerdf-jena/test/test_jena_adapter.rb +451 -0
  45. data/activerdf-jena/test/test_ng4j_adapter.rb +354 -0
  46. data/activerdf-rdflite/CHANGELOG +31 -0
  47. data/activerdf-rdflite/LICENSE +504 -0
  48. data/activerdf-rdflite/README +16 -0
  49. data/activerdf-rdflite/Rakefile +73 -0
  50. data/activerdf-rdflite/VERSION +1 -0
  51. data/activerdf-rdflite/lib/activerdf_rdflite/fetching.rb +34 -0
  52. data/activerdf-rdflite/lib/activerdf_rdflite/init.rb +13 -0
  53. data/activerdf-rdflite/lib/activerdf_rdflite/rdflite.rb +582 -0
  54. data/activerdf-rdflite/lib/activerdf_rdflite/suggesting.rb +87 -0
  55. data/activerdf-rdflite/test/test_bnode_data.nt +5 -0
  56. data/activerdf-rdflite/test/test_data.nt +32 -0
  57. data/activerdf-rdflite/test/test_escaped_data.nt +2 -0
  58. data/activerdf-rdflite/test/test_fetching.rb +33 -0
  59. data/activerdf-rdflite/test/test_rdflite.rb +277 -0
  60. data/activerdf-redland/CHANGELOG +12 -0
  61. data/activerdf-redland/LICENSE +504 -0
  62. data/activerdf-redland/README +9 -0
  63. data/activerdf-redland/Rakefile +72 -0
  64. data/activerdf-redland/VERSION +1 -0
  65. data/activerdf-redland/lib/activerdf_redland/init.rb +10 -0
  66. data/activerdf-redland/lib/activerdf_redland/redland.rb +362 -0
  67. data/activerdf-redland/test/test_person_data.nt +42 -0
  68. data/activerdf-redland/test/test_redland_adapter.rb +242 -0
  69. data/activerdf-sesame/CHANGELOG +6 -0
  70. data/activerdf-sesame/LICENSE +10 -0
  71. data/activerdf-sesame/LICENSE-aduna +10 -0
  72. data/activerdf-sesame/LICENSE-lgpl +504 -0
  73. data/activerdf-sesame/README +33 -0
  74. data/activerdf-sesame/Rakefile +77 -0
  75. data/activerdf-sesame/VERSION +1 -0
  76. data/activerdf-sesame/ext/commons-codec-1.3.jar +0 -0
  77. data/activerdf-sesame/ext/commons-dbcp-1.2.2.jar +0 -0
  78. data/activerdf-sesame/ext/commons-httpclient-3.1.jar +0 -0
  79. data/activerdf-sesame/ext/commons-logging-1.1.1.jar +0 -0
  80. data/activerdf-sesame/ext/commons-pool-1.3.jar +0 -0
  81. data/activerdf-sesame/ext/commons-pool-1.5.2.jar +0 -0
  82. data/activerdf-sesame/ext/junit-3.8.2.jar +0 -0
  83. data/activerdf-sesame/ext/openrdf-sesame-2.0-onejar.jar +0 -0
  84. data/activerdf-sesame/ext/openrdf-sesame-2.3-pr1-onejar.jar +0 -0
  85. data/activerdf-sesame/ext/slf4j-api-1.4.3.jar +0 -0
  86. data/activerdf-sesame/ext/slf4j-nop-1.4.3.jar +0 -0
  87. data/activerdf-sesame/ext/wrapper-sesame2.jar +0 -0
  88. data/activerdf-sesame/java/build.number +3 -0
  89. data/activerdf-sesame/java/build.xml +313 -0
  90. data/activerdf-sesame/java/javadoc/allclasses-frame.html +31 -0
  91. data/activerdf-sesame/java/javadoc/allclasses-noframe.html +31 -0
  92. data/activerdf-sesame/java/javadoc/constant-values.html +146 -0
  93. data/activerdf-sesame/java/javadoc/deprecated-list.html +146 -0
  94. data/activerdf-sesame/java/javadoc/help-doc.html +223 -0
  95. data/activerdf-sesame/java/javadoc/index-files/index-1.html +150 -0
  96. data/activerdf-sesame/java/javadoc/index-files/index-10.html +145 -0
  97. data/activerdf-sesame/java/javadoc/index-files/index-2.html +157 -0
  98. data/activerdf-sesame/java/javadoc/index-files/index-3.html +146 -0
  99. data/activerdf-sesame/java/javadoc/index-files/index-4.html +145 -0
  100. data/activerdf-sesame/java/javadoc/index-files/index-5.html +145 -0
  101. data/activerdf-sesame/java/javadoc/index-files/index-6.html +142 -0
  102. data/activerdf-sesame/java/javadoc/index-files/index-7.html +145 -0
  103. data/activerdf-sesame/java/javadoc/index-files/index-8.html +152 -0
  104. data/activerdf-sesame/java/javadoc/index-files/index-9.html +146 -0
  105. data/activerdf-sesame/java/javadoc/index.html +36 -0
  106. data/activerdf-sesame/java/javadoc/org/activerdf/wrapper/sesame2/WrapperForSesame2.html +665 -0
  107. data/activerdf-sesame/java/javadoc/org/activerdf/wrapper/sesame2/class-use/WrapperForSesame2.html +144 -0
  108. data/activerdf-sesame/java/javadoc/org/activerdf/wrapper/sesame2/package-frame.html +32 -0
  109. data/activerdf-sesame/java/javadoc/org/activerdf/wrapper/sesame2/package-summary.html +157 -0
  110. data/activerdf-sesame/java/javadoc/org/activerdf/wrapper/sesame2/package-tree.html +150 -0
  111. data/activerdf-sesame/java/javadoc/org/activerdf/wrapper/sesame2/package-use.html +144 -0
  112. data/activerdf-sesame/java/javadoc/overview-summary.html +156 -0
  113. data/activerdf-sesame/java/javadoc/overview-tree.html +152 -0
  114. data/activerdf-sesame/java/javadoc/package-list +1 -0
  115. data/activerdf-sesame/java/javadoc/resources/inherit.gif +0 -0
  116. data/activerdf-sesame/java/javadoc/stylesheet.css +29 -0
  117. data/activerdf-sesame/java/lib/commons-codec-1.3.jar +0 -0
  118. data/activerdf-sesame/java/lib/commons-dbcp-1.2.2.jar +0 -0
  119. data/activerdf-sesame/java/lib/commons-httpclient-3.1.jar +0 -0
  120. data/activerdf-sesame/java/lib/commons-logging-1.1.1.jar +0 -0
  121. data/activerdf-sesame/java/lib/commons-pool-1.3.jar +0 -0
  122. data/activerdf-sesame/java/lib/commons-pool-1.5.2.jar +0 -0
  123. data/activerdf-sesame/java/lib/junit-3.8.2.jar +0 -0
  124. data/activerdf-sesame/java/lib/openrdf-sesame-2.0-onejar.jar +0 -0
  125. data/activerdf-sesame/java/lib/openrdf-sesame-2.3-pr1-onejar.jar +0 -0
  126. data/activerdf-sesame/java/lib/slf4j-api-1.4.3.jar +0 -0
  127. data/activerdf-sesame/java/lib/slf4j-nop-1.4.3.jar +0 -0
  128. data/activerdf-sesame/java/manifest.mf +3 -0
  129. data/activerdf-sesame/java/settings.xml +135 -0
  130. data/activerdf-sesame/java/src/org/activerdf/wrapper/sesame2/WrapperForSesame2.java +145 -0
  131. data/activerdf-sesame/java/test-src/org/activerdf/wrapper/sesame2/TestWrapperForSesame2.java +41 -0
  132. data/activerdf-sesame/lib/activerdf_sesame/init.rb +11 -0
  133. data/activerdf-sesame/lib/activerdf_sesame/sesame.rb +400 -0
  134. data/activerdf-sesame/test/eyal-foaf.nt +39 -0
  135. data/activerdf-sesame/test/eyal-foaf.rdf +65 -0
  136. data/activerdf-sesame/test/test_sesame_adapter.rb +341 -0
  137. data/activerdf-sparql/CHANGELOG +35 -0
  138. data/activerdf-sparql/LICENSE +504 -0
  139. data/activerdf-sparql/README +10 -0
  140. data/activerdf-sparql/Rakefile +78 -0
  141. data/activerdf-sparql/VERSION +1 -0
  142. data/activerdf-sparql/lib/activerdf_sparql/init.rb +10 -0
  143. data/activerdf-sparql/lib/activerdf_sparql/sparql.rb +212 -0
  144. data/activerdf-sparql/lib/activerdf_sparql/sparql_result_parser.rb +55 -0
  145. data/activerdf-sparql/test/test_sparql_adapter.rb +108 -0
  146. data/activerdf-yars/LICENSE +504 -0
  147. data/activerdf-yars/README +10 -0
  148. data/activerdf-yars/Rakefile +38 -0
  149. data/activerdf-yars/lib/activerdf_yars/init.rb +10 -0
  150. data/activerdf-yars/lib/activerdf_yars/jars2.rb +119 -0
  151. data/lib/active_rdf.rb +85 -0
  152. data/lib/active_rdf/directaccess/direct_access.rb +49 -0
  153. data/lib/active_rdf/federation/active_rdf_adapter.rb +47 -0
  154. data/lib/active_rdf/federation/connection_pool.rb +156 -0
  155. data/lib/active_rdf/federation/federation_manager.rb +112 -0
  156. data/lib/active_rdf/instance_exec.rb +13 -0
  157. data/lib/active_rdf/objectmanager/bnode.rb +7 -0
  158. data/lib/active_rdf/objectmanager/literal.rb +71 -0
  159. data/lib/active_rdf/objectmanager/namespace.rb +106 -0
  160. data/lib/active_rdf/objectmanager/object_manager.rb +119 -0
  161. data/lib/active_rdf/objectmanager/ordered_set.rb +116 -0
  162. data/lib/active_rdf/objectmanager/property_list.rb +76 -0
  163. data/lib/active_rdf/objectmanager/resource.rb +609 -0
  164. data/lib/active_rdf/objectmanager/resource_like.rb +28 -0
  165. data/lib/active_rdf/queryengine/ntriples_parser.rb +90 -0
  166. data/lib/active_rdf/queryengine/query.rb +245 -0
  167. data/lib/active_rdf/queryengine/query2jars2.rb +22 -0
  168. data/lib/active_rdf/queryengine/query2sparql.rb +139 -0
  169. data/lib/active_rdf_helpers.rb +30 -0
  170. data/lib/active_rdf_log.rb +100 -0
  171. data/test/common.rb +119 -0
  172. data/test/directaccess/test_direct_access.rb +64 -0
  173. data/test/federation/test_connection_pool.rb +86 -0
  174. data/test/federation/test_federation_manager.rb +145 -0
  175. data/test/objectmanager/test_literal.rb +52 -0
  176. data/test/objectmanager/test_namespace.rb +83 -0
  177. data/test/objectmanager/test_object_manager.rb +96 -0
  178. data/test/objectmanager/test_ordered_set.rb +110 -0
  179. data/test/objectmanager/test_resource_reading.rb +150 -0
  180. data/test/objectmanager/test_resource_writing.rb +39 -0
  181. data/test/objectmanager/test_talia_syntax.rb +68 -0
  182. data/test/queryengine/my_external_resource.rb +24 -0
  183. data/test/queryengine/test_external_resource_class.rb +49 -0
  184. data/test/queryengine/test_ntriples_parser.rb +71 -0
  185. data/test/queryengine/test_query.rb +55 -0
  186. data/test/queryengine/test_query2jars2.rb +51 -0
  187. data/test/queryengine/test_query2sparql.rb +76 -0
  188. data/test/queryengine/test_query_engine.rb +52 -0
  189. data/test/test_adapters.rb +58 -0
  190. metadata +266 -0
@@ -0,0 +1,39 @@
1
+ # Author:: Eyal Oren
2
+ # Copyright:: (c) 2005-2006
3
+ # License:: LGPL
4
+
5
+ require 'test/unit'
6
+ require 'active_rdf'
7
+ require 'federation/connection_pool'
8
+ require "#{File.dirname(__FILE__)}/../common"
9
+
10
+ class TestResourceWriting < Test::Unit::TestCase
11
+ def setup
12
+ ConnectionPool.clear
13
+ end
14
+
15
+ def test_update_value
16
+ Namespace.register(:ar, 'http://activerdf.org/test/')
17
+ adapter = get_write_adapter
18
+
19
+ eyal = RDFS::Resource.new 'http://activerdf.org/test/eyal'
20
+ assert_raises(ActiveRdfError) { eyal.age = 18 }
21
+
22
+ eyal.ar::age = 100
23
+ assert_equal 100, eyal.ar::age
24
+ assert_equal [100], eyal.all_ar::age
25
+
26
+ # << fails on Fixnums , because Ruby doesn't allow us to change behaviour of
27
+ # << on Fixnums
28
+ eyal.age << 18
29
+ assert_equal 100, eyal.age
30
+
31
+ # << same for Strings (TODO)
32
+ eyal.ar::name = "first"
33
+ eyal.ar::name << "second"
34
+ assert_equal "first", eyal.ar::name
35
+
36
+ eyal.ar::age = [100, 80]
37
+ assert_equal [100, 80], eyal.ar::age
38
+ end
39
+ end
@@ -0,0 +1,68 @@
1
+ # Author: Michele Nucci
2
+ # License: LGPL
3
+ #
4
+ # Test for new syntax in ActiveRDF for Talia
5
+
6
+ require 'test/unit'
7
+ require 'active_rdf'
8
+ require 'federation/connection_pool'
9
+ require "#{File.dirname(__FILE__)}/../common"
10
+
11
+ class TestTaliaSyntax < Test::Unit::TestCase
12
+ def setup
13
+ ConnectionPool.clear
14
+ end
15
+
16
+ def test_syntax
17
+ adapter = get_write_adapter
18
+ adapter.load "#{File.dirname(__FILE__)}/../test_person_data.nt"
19
+
20
+ Namespace.register(:test, 'http://activerdf.org/test/')
21
+
22
+ eyal = RDFS::Resource.new 'http://activerdf.org/test/eyal'
23
+ michele = RDFS::Resource.new 'http://activerdf.org/test/michele'
24
+
25
+ # Adding some triples
26
+ adapter.add(michele, RDFS::subClassOf, RDF::Resource)
27
+ adapter.add(michele, RDF::type, Namespace.lookup(:rdfs, 'Class') )
28
+ adapter.add(michele, RDF::type, Namespace.lookup(:test, 'Person') )
29
+ adapter.add(eyal, Namespace.lookup(:test, 'friendOf'), michele)
30
+
31
+ assert_nothing_raised(ActiveRdfError) {
32
+ michele.car = 'car1'
33
+ michele.car = 'car2'
34
+ }
35
+
36
+ # new syntax (shortcut) to get all properties values about TEST::car
37
+ x = michele[TEST::car]
38
+ assert_not_equal [], x
39
+
40
+ # Adding new property (new triple) with the new syntax
41
+ x << 'car3'
42
+ assert_equal ['car2', 'car3'], x
43
+
44
+ # test inverse ===========================================================
45
+ y = michele.inverse
46
+ assert_equal '<http://activerdf.org/test/eyal>', y[Namespace.lookup(:test, 'friendOf')].to_s
47
+ # ========================================================================
48
+
49
+ # test deletion triple with new syntax ===================================
50
+
51
+ # remove a triple whose value is specified relater to TEST::car
52
+ x.remove('car3')
53
+ assert_equal ['car2'], x
54
+
55
+ # remove every triples related to TEST::car
56
+ x.remove
57
+ assert_equal [], x
58
+
59
+ # remove EVERY triples related to a specified resource
60
+ FederationManager.delete_all(michele)
61
+ result = Query.new.select(:p, :o).where(michele, :p, :o).execute
62
+ assert_equal [], result
63
+ # ========================================================================
64
+
65
+
66
+ end
67
+
68
+ end
@@ -0,0 +1,24 @@
1
+ module RDFS
2
+ # External resource class
3
+ class MyExternalResource
4
+
5
+ include ResourceLike
6
+
7
+ # uri of the resource
8
+ attr_reader :uri
9
+ # adding accessor to the class uri:
10
+ # the uri of the rdf resource being represented by this class
11
+ class << self
12
+ attr_accessor :class_uri
13
+ end
14
+
15
+ # creates new resource representing an RDF resource
16
+ def initialize uri
17
+ @uri = uri
18
+ end
19
+
20
+ def to_s
21
+ "<#{uri}>"
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,49 @@
1
+ require File.join("test","unit")
2
+ require 'active_rdf'
3
+ require File.join("queryengine","query")
4
+ require File.join(File.dirname(__FILE__),"..","common")
5
+ require File.join(File.dirname(__FILE__),"my_external_resource")
6
+
7
+
8
+ class TestExternalResourceClass < Test::Unit::TestCase
9
+ def setup
10
+ ConnectionPool.clear
11
+ end
12
+
13
+ def teardown
14
+ ConnectionPool.clear
15
+ end
16
+
17
+ @@eyal = RDFS::MyExternalResource.new("http://activerdf.org/test/eyal")
18
+ @@age = RDFS::MyExternalResource.new("http://activerdf.org/test/age")
19
+
20
+ def test_query_external_resource
21
+ adapters = get_talia_adapters
22
+ adapters.each do |adapter|
23
+
24
+ # load test data
25
+ adapter.load(File.join(File.dirname(__FILE__),"..","test_person_data.nt"))
26
+
27
+ # execute query and check the result classes
28
+ #require "ruby-debug/debugger"
29
+ result = Query.new(RDFS::MyExternalResource).select(:p,:o).where(@@eyal, :p, :o).execute
30
+ assert result.size > 0, "No Results for #{adapter.class}"
31
+ assert_kind_of RDFS::MyExternalResource, result[0][0]
32
+
33
+ # add data
34
+ pl = PropertyList.new(@@age, Query.new(RDFS::MyExternalResource).select(:o).where(@@eyal, @@age, :o).execute, @@eyal)
35
+ assert(pl.size > 0, "PropertyList empty")
36
+ assert_nothing_raised {pl << "18"}
37
+ result = Query.new.select(:o).where(@@eyal, @@age, :o).execute
38
+ assert result.include?("18")
39
+ end
40
+ end
41
+
42
+ def test_namespace_external_resource
43
+ # namespace
44
+ Namespace.register(:test, 'http://activerdf.org/test/')
45
+ assert_kind_of(RDFS::MyExternalResource, Namespace.lookup(:test, "eyal", RDFS::MyExternalResource))
46
+ assert_equal(:test, Namespace.prefix(@@eyal))
47
+ assert_equal("eyal",Namespace.localname(@@eyal))
48
+ end
49
+ end
@@ -0,0 +1,71 @@
1
+ # Author:: Eyal Oren
2
+ # Copyright:: (c) 2005-2006
3
+ # License:: LGPL
4
+
5
+ require 'test/unit'
6
+ require 'active_rdf'
7
+ require 'queryengine/ntriples_parser'
8
+ require "#{File.dirname(__FILE__)}/../common"
9
+
10
+ class TestNTriplesParser < Test::Unit::TestCase
11
+ def setup
12
+ end
13
+
14
+ def teardown
15
+ end
16
+
17
+ def test_simple_triples
18
+ str = <<EOF
19
+ <http://www.johnbreslin.com/blog/author/cloud/#foaf> <http://xmlns.com/foaf/0.1/surname> "Breslin" .
20
+ <http://www.johnbreslin.com/blog/author/cloud/#foaf> <http://xmlns.com/foaf/0.1/firstName> "John" .
21
+ <http://www.johnbreslin.com/blog/author/cloud/> <http://purl.org/dc/terms/created> "1999-11-30T00:00:00" .
22
+ EOF
23
+
24
+ triples = NTriplesParser.parse(str)
25
+ assert_equal 9, triples.flatten.size
26
+ assert_equal 3, triples[0].size
27
+
28
+ assert_equal RDFS::Resource.new('http://www.johnbreslin.com/blog/author/cloud/#foaf'), triples[0][0]
29
+ assert_equal RDFS::Resource.new('http://xmlns.com/foaf/0.1/surname'), triples[0][1]
30
+ assert_equal 'Breslin', triples[0][2]
31
+ end
32
+
33
+ def test_encoded_content
34
+ str = <<'EOF'
35
+ <http://b4mad.net/datenbrei/archives/2004/07/15/brainstream-his-own-foafing-in-wordpress/#comment-10> <http://purl.org/rss/1.0/modules/content/encoded> "<p>Heh - excellent. Are we leaving Morten in the dust? :) I know he had some bu gs to fix in his version.</p>\n<p>Also, I think we should really add the foaf: in front of the foaf properties to ma ke it easier to read. </p>\n<p>Other hack ideas:</p>\n<p>* Birthdate in month/date/year (seperate fields) to add bio :Event/ bio:Birth and then say who can see the birth year, birth day/mo and full birth date.<br />\n* Add trust leve ls to friends<br />\n* Storing ones PGP key/key fingerprint in Wordpress and referencing it as user_pubkey/user_pubk eyprint respectively<br />\n* Add gender, depiction picture for profile, myers-brigs, astrological sign fields to Pr ofile.<br />\n* Add the option to create Projects/Groups user is involved with re: their Profile.<br />\n* Maybe add phone numbers/address/geo location? Essentially make it a VCard that can be foafified.\n</p>\n" .
36
+ EOF
37
+ literal = '<p>Heh - excellent. Are we leaving Morten in the dust? :) I know he had some bu gs to fix in his version.</p>\n<p>Also, I think we should really add the foaf: in front of the foaf properties to ma ke it easier to read. </p>\n<p>Other hack ideas:</p>\n<p>* Birthdate in month/date/year (seperate fields) to add bio :Event/ bio:Birth and then say who can see the birth year, birth day/mo and full birth date.<br />\n* Add trust leve ls to friends<br />\n* Storing ones PGP key/key fingerprint in Wordpress and referencing it as user_pubkey/user_pubk eyprint respectively<br />\n* Add gender, depiction picture for profile, myers-brigs, astrological sign fields to Pr ofile.<br />\n* Add the option to create Projects/Groups user is involved with re: their Profile.<br />\n* Maybe add phone numbers/address/geo location? Essentially make it a VCard that can be foafified.\n</p>\n'
38
+
39
+ triples = NTriplesParser.parse(str)
40
+ assert_equal 1, triples.size
41
+
42
+ encoded_content = triples.first[2]
43
+ assert_equal literal, encoded_content
44
+ assert_equal String, encoded_content.class
45
+ assert encoded_content.include?('PGP')
46
+ end
47
+
48
+ def test_escaped_quotes
49
+ string = '<subject> <predicate> "test string with \n breaks and \" escaped quotes" .'
50
+ literal = 'test string with \n breaks and \" escaped quotes'
51
+ triples = NTriplesParser.parse(string)
52
+
53
+ assert_equal 1, triples.size
54
+ assert_equal literal, triples.first[2]
55
+ end
56
+
57
+ def test_datatypes
58
+ string =<<EOF
59
+ <s> <p> "blue" .
60
+ <s> <p> "29"^^<http://www.w3.org/2001/XMLSchema#integer> .
61
+ <s> <p> "false"^^<http://www.w3.org/2001/XMLSchema#boolean> .
62
+ <s> <p> "2002-10-10T00:00:00+13"^^<http://www.w3.org/2001/XMLSchema#date> .
63
+ EOF
64
+ triples = NTriplesParser.parse(string)
65
+ assert_equal 4, triples.size
66
+ assert_equal 'blue', triples[0][2]
67
+ assert_equal 29, triples[1][2]
68
+ assert_equal triples[2][2], false
69
+ assert_equal triples[3][2], DateTime.parse('2002-10-10T00:00:00+13')
70
+ end
71
+ end
@@ -0,0 +1,55 @@
1
+ # Author:: Eyal Oren
2
+ # Copyright:: (c) 2005-2006
3
+ # License:: LGPL
4
+
5
+ require 'test/unit'
6
+ require 'active_rdf'
7
+ require 'queryengine/query'
8
+ require "#{File.dirname(__FILE__)}/../common"
9
+
10
+ class TestQuery < Test::Unit::TestCase
11
+ def setup
12
+ end
13
+
14
+ def teardown
15
+ end
16
+
17
+ def test_sparql_generation
18
+ query = Query.new
19
+ query.select(:s)
20
+ query.where(:s, RDFS::Resource.new('predicate'), '30')
21
+ generated = Query2SPARQL.translate(query)
22
+ expected = "SELECT ?s WHERE { ?s <predicate> \"30\" . }"
23
+ assert_equal expected, generated
24
+
25
+ query = Query.new
26
+ query.select(:s)
27
+ query.where(:s, RDFS::Resource.new('foaf:age'), :a)
28
+ query.where(:a, RDFS::Resource.new('rdf:type'), RDFS::Resource.new('xsd:int'))
29
+ generated = Query2SPARQL.translate(query)
30
+ expected = "SELECT ?s WHERE { ?s <foaf:age> ?a. ?a <rdf:type> <xsd:int> . }"
31
+ assert_equal expected, generated
32
+ end
33
+
34
+ def test_sparql_distinct
35
+ query = Query.new
36
+ query.distinct(:s)
37
+ query.where(:s, RDFS::Resource.new('foaf:age'), :a)
38
+ generated = Query2SPARQL.translate(query)
39
+ expected = "SELECT DISTINCT ?s WHERE { ?s <foaf:age> ?a . }"
40
+ assert_equal expected, generated
41
+ end
42
+
43
+ def test_query_omnipotent
44
+ # can define multiple select clauses at once or separately
45
+ q1 = Query.new.select(:s,:a)
46
+ q2 = Query.new.select(:s).select(:a)
47
+ assert_equal Query2SPARQL.translate(q1),Query2SPARQL.translate(q2)
48
+ end
49
+
50
+ def test_query_refuses_string_in_where_clause_subject_or_predicate
51
+ assert_raises(ActiveRdfError)do
52
+ Query.new.select(:s).where("http://test.org/uri",:p, :o).execute
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,51 @@
1
+ # Author:: Eyal Oren
2
+ # Copyright:: (c) 2005-2006
3
+ # License:: LGPL
4
+
5
+ require 'test/unit'
6
+ require 'active_rdf'
7
+ require 'queryengine/query2jars2'
8
+ require "#{File.dirname(__FILE__)}/../common"
9
+
10
+ class TestQuery2Jars2 < Test::Unit::TestCase
11
+ def setup
12
+ end
13
+
14
+ def teardown
15
+ end
16
+
17
+ def test_sparql_generation
18
+
19
+ # TODO: write tests for distinct, ask
20
+
21
+ query = Query.new
22
+ query.select(:s)
23
+ query.where(:s, RDFS::Resource.new('predicate'), '30')
24
+
25
+ generated = Query2SPARQL.translate(query)
26
+ expected = "SELECT ?s WHERE { ?s <predicate> \"30\" . }"
27
+ assert_equal expected, generated
28
+
29
+ query = Query.new
30
+ query.select(:s)
31
+ query.where(:s, RDFS::Resource.new('foaf:age'), :a)
32
+ query.where(:a, RDFS::Resource.new('rdf:type'), RDFS::Resource.new('xsd:int'))
33
+ generated = Query2SPARQL.translate(query)
34
+ expected = "SELECT ?s WHERE { ?s <foaf:age> ?a. ?a <rdf:type> <xsd:int> . }"
35
+ assert_equal expected, generated
36
+
37
+ # query = Query.new
38
+ # query.select(:s).select(:a)
39
+ # query.where(:s, 'foaf:age', :a)
40
+ # generated = Query2SPARQL.translate(query)
41
+ # expected = "SELECT DISTINCT ?s ?a WHERE { ?s foaf:age ?a .}"
42
+ # assert_equal expected, generated
43
+ end
44
+
45
+ def test_query_omnipotent
46
+ # can define multiple select clauses at once or separately
47
+ q1 = Query.new.select(:s,:a)
48
+ q2 = Query.new.select(:s).select(:a)
49
+ assert_equal Query2SPARQL.translate(q1),Query2SPARQL.translate(q2)
50
+ end
51
+ end
@@ -0,0 +1,76 @@
1
+ # Author:: Eyal Oren
2
+ # Copyright:: (c) 2005-2006
3
+ # License:: LGPL
4
+
5
+ require 'test/unit'
6
+ require 'active_rdf'
7
+ require "#{File.dirname(__FILE__)}/../common"
8
+
9
+ class TestQuery2Sparql < Test::Unit::TestCase
10
+
11
+ def test_sparql_generation
12
+ # TODO: write tests for distinct, ask
13
+
14
+ query = Query.new
15
+ query.select(:s)
16
+ query.where(:s, RDFS::Resource.new('predicate'), 30)
17
+
18
+ generated = Query2SPARQL.translate(query)
19
+ expected = "SELECT ?s WHERE { ?s <predicate> \"30\"^^<http://www.w3.org/2001/XMLSchema#integer> . } "
20
+ assert_equal expected, generated
21
+
22
+ query = Query.new
23
+ query.select(:s)
24
+ query.where(:s, RDFS::Resource.new('foaf:age'), :a)
25
+ query.where(:a, RDFS::Resource.new('rdf:type'), RDFS::Resource.new('xsd:int'))
26
+ generated = Query2SPARQL.translate(query)
27
+ expected = "SELECT ?s WHERE { ?s <foaf:age> ?a . ?a <rdf:type> <xsd:int> . } "
28
+ assert_equal expected, generated
29
+ end
30
+
31
+ def test_sparql_distinct
32
+ query = Query.new
33
+ query.distinct(:s)
34
+ query.where(:s, RDFS::Resource.new('foaf:age'), :a)
35
+ generated = Query2SPARQL.translate(query)
36
+ expected = "SELECT DISTINCT ?s WHERE { ?s <foaf:age> ?a . } "
37
+ assert_equal expected, generated
38
+ end
39
+
40
+ def test_query_omnipotent
41
+ # can define multiple select clauses at once or separately
42
+ q1 = Query.new.select(:s,:a)
43
+ q2 = Query.new.select(:s).select(:a)
44
+ assert_equal Query2SPARQL.translate(q1),Query2SPARQL.translate(q2)
45
+ end
46
+
47
+ def test_sort
48
+ q1 = Query.new.select(:s).sort(:s)
49
+ q2 = Query.new.select(:s).sort(:s, :p, :o)
50
+ q3 = Query.new.select(:s).reverse_sort(:s)
51
+ q4 = Query.new.select(:s).reverse_sort(:s, :p, :o)
52
+ q5 = Query.new.select(:s).sort(:s).reverse_sort(:p)
53
+ assert_equal "SELECT ?s WHERE { . } ORDER BY ASC(?s) ", Query2SPARQL.translate(q1)
54
+ assert_equal "SELECT ?s WHERE { . } ORDER BY ASC(?s) ASC(?p) ASC(?o) ", Query2SPARQL.translate(q2)
55
+ assert_equal "SELECT ?s WHERE { . } ORDER BY DESC(?s) ", Query2SPARQL.translate(q3)
56
+ assert_equal "SELECT ?s WHERE { . } ORDER BY DESC(?s) DESC(?p) DESC(?o) ", Query2SPARQL.translate(q4)
57
+ assert_equal "SELECT ?s WHERE { . } ORDER BY ASC(?s) DESC(?p) ", Query2SPARQL.translate(q5)
58
+ end
59
+
60
+ def test_execute_sort_query
61
+ ConnectionPool.clear
62
+ file_one = "#{File.dirname(__FILE__)}/../small-one.nt"
63
+ adapter = get_adapter
64
+
65
+ if (adapter.class.to_s != "SesameAdapter")
66
+ adapter.load file_one
67
+ else
68
+ adapter.load(file_one, 'ntriples')
69
+ end
70
+ @eyal = RDFS::Resource.new 'http://activerdf.org/test/eyal'
71
+ @eye = RDFS::Resource.new 'http://activerdf.org/test/eye'
72
+ @eyal[@eye] << 'green'
73
+ assert_equal ["blue", "green"], Query.new.select(:o).where(@eyal, @eye, :o).limit(100).sort(:o).execute
74
+ assert_equal ["green", "blue"], Query.new.select(:o).where(@eyal, @eye, :o).limit(100).reverse_sort(:o).execute
75
+ end
76
+ end
@@ -0,0 +1,52 @@
1
+ # Author:: Eyal Oren
2
+ # Copyright:: (c) 2005-2006
3
+ # License:: LGPL
4
+
5
+ require 'test/unit'
6
+ require 'active_rdf'
7
+ require 'queryengine/query'
8
+ require 'queryengine/query2sparql'
9
+ require "#{File.dirname(__FILE__)}/../common"
10
+
11
+ class TestQueryEngine < Test::Unit::TestCase
12
+ def setup
13
+ end
14
+
15
+ def teardown
16
+ end
17
+
18
+ def test_sparql_generation
19
+
20
+ # TODO: write tests for distinct, ask
21
+
22
+ query = Query.new
23
+ query.select(:s)
24
+ query.where(:s, RDFS::Resource.new('predicate'), 30)
25
+
26
+ generated = Query2SPARQL.translate(query)
27
+ expected = "SELECT ?s WHERE { ?s <predicate> \"30\"^^<http://www.w3.org/2001/XMLSchema#integer> . } "
28
+ assert_equal expected, generated
29
+
30
+ query = Query.new
31
+ query.select(:s)
32
+ query.where(:s, RDFS::Resource.new('foaf:age'), :a)
33
+ query.where(:a, RDFS::Resource.new('rdf:type'), RDFS::Resource.new('xsd:int'))
34
+ generated = Query2SPARQL.translate(query)
35
+ expected = "SELECT ?s WHERE { ?s <foaf:age> ?a . ?a <rdf:type> <xsd:int> . } "
36
+ assert_equal expected, generated
37
+
38
+ # query = Query.new
39
+ # query.select(:s).select(:a)
40
+ # query.where(:s, 'foaf:age', :a)
41
+ # generated = Query2SPARQL.translate(query)
42
+ # expected = "SELECT DISTINCT ?s ?a WHERE { ?s foaf:age ?a .}"
43
+ # assert_equal expected, generated
44
+ end
45
+
46
+ def test_query_omnipotent
47
+ # can define multiple select clauses at once or separately
48
+ q1 = Query.new.select(:s,:a)
49
+ q2 = Query.new.select(:s).select(:a)
50
+ assert_equal Query2SPARQL.translate(q1),Query2SPARQL.translate(q2)
51
+ end
52
+ end