activerdf_net7 1.6.16 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. data/CHANGELOG +63 -0
  2. data/activerdf-jena/lib/activerdf_jena/jena.rb +4 -4
  3. data/activerdf-jena/lib/activerdf_jena/jena_adapter.rb +55 -55
  4. data/activerdf-jena/lib/activerdf_jena/lucene.rb +1 -1
  5. data/activerdf-jena/lib/activerdf_jena/ng4j.rb +7 -7
  6. data/activerdf-jena/lib/activerdf_jena/ng4j_adapter.rb +47 -47
  7. data/activerdf-jena/lib/activerdf_jena/pellet.rb +1 -1
  8. data/activerdf-jena/test/test_jena_adapter.rb +121 -120
  9. data/activerdf-jena/test/test_ng4j_adapter.rb +111 -110
  10. data/activerdf-rdflite/lib/activerdf_rdflite/fetching.rb +23 -19
  11. data/activerdf-rdflite/lib/activerdf_rdflite/rdflite.rb +153 -277
  12. data/activerdf-rdflite/lib/activerdf_rdflite/suggesting.rb +2 -2
  13. data/activerdf-rdflite/test/test_fetching.rb +7 -22
  14. data/activerdf-rdflite/test/test_rdflite.rb +44 -257
  15. data/activerdf-redland/lib/activerdf_redland/redland.rb +246 -282
  16. data/activerdf-redland/test/test_redland_adapter.rb +62 -224
  17. data/activerdf-sesame/ext/wrapper-sesame2.jar +0 -0
  18. data/activerdf-sesame/java/build.number +2 -2
  19. data/activerdf-sesame/java/build.xml +0 -0
  20. data/activerdf-sesame/java/lib/junit-3.8.2.jar +0 -0
  21. data/activerdf-sesame/java/settings.xml +0 -0
  22. data/activerdf-sesame/java/src/org/activerdf/wrapper/sesame2/WrapperForSesame2.java +0 -0
  23. data/activerdf-sesame/java/temp/build/org/activerdf/wrapper/sesame2/WrapperForSesame2.class +0 -0
  24. data/activerdf-sesame/java/temp/manifest/MANIFEST.MF +2 -2
  25. data/activerdf-sesame/java/test-src/org/activerdf/wrapper/sesame2/TestWrapperForSesame2.java +0 -0
  26. data/activerdf-sesame/lib/activerdf_sesame/sesame.rb +360 -364
  27. data/activerdf-sesame/test/test_sesame_adapter.rb +85 -83
  28. data/activerdf-sparql/lib/activerdf_sparql/sparql.rb +147 -148
  29. data/activerdf-sparql/lib/activerdf_sparql/sparql_result_parser.rb +5 -5
  30. data/activerdf-sparql/test/test_sparql_adapter.rb +2 -0
  31. data/activerdf-yars/lib/activerdf_yars/jars2.rb +85 -83
  32. data/lib/active_rdf/federation/active_rdf_adapter.rb +26 -39
  33. data/lib/active_rdf/federation/connection_pool.rb +119 -110
  34. data/lib/active_rdf/federation/federation_manager.rb +51 -51
  35. data/lib/active_rdf/objectmanager/bnode.rb +8 -2
  36. data/lib/active_rdf/objectmanager/literal.rb +81 -50
  37. data/lib/active_rdf/objectmanager/namespace.rb +117 -84
  38. data/lib/active_rdf/objectmanager/object_manager.rb +101 -96
  39. data/lib/active_rdf/objectmanager/ordered_set.rb +1 -1
  40. data/lib/active_rdf/objectmanager/property.rb +345 -0
  41. data/lib/active_rdf/objectmanager/property_list.rb +4 -4
  42. data/lib/active_rdf/objectmanager/property_lookup.rb +57 -0
  43. data/lib/active_rdf/objectmanager/resource.rb +293 -501
  44. data/lib/active_rdf/objectmanager/resource_like.rb +2 -2
  45. data/lib/active_rdf/objectmanager/resource_query.rb +85 -0
  46. data/lib/active_rdf/queryengine/ntriples_parser.rb +75 -68
  47. data/lib/active_rdf/queryengine/query.rb +237 -183
  48. data/lib/active_rdf/queryengine/query2jars2.rb +17 -15
  49. data/lib/active_rdf/queryengine/query2sparql.rb +107 -101
  50. data/lib/active_rdf.rb +28 -17
  51. data/lib/active_rdf_helpers.rb +37 -5
  52. data/lib/active_rdf_log.rb +11 -11
  53. data/test/adapters/test_activerdf_adapter.rb +138 -0
  54. data/test/{test_adapters.rb → adapters/test_adapters.rb} +6 -24
  55. data/test/adapters/test_bnode_capable_adapter.rb +31 -0
  56. data/test/adapters/test_context_aware_adapter.rb +31 -0
  57. data/test/adapters/test_network_aware_adapter.rb +29 -0
  58. data/test/adapters/test_persistent_adapter.rb +21 -0
  59. data/test/adapters/test_read_only_adapter.rb +15 -0
  60. data/test/adapters/test_reasoning_adapter.rb +11 -0
  61. data/test/adapters/test_writable_adapter.rb +163 -0
  62. data/test/common.rb +78 -96
  63. data/test/federation/test_connection_pool.rb +25 -44
  64. data/test/federation/test_federation_manager.rb +45 -45
  65. data/test/objectmanager/test_literal.rb +47 -26
  66. data/test/objectmanager/test_namespace.rb +3 -1
  67. data/test/objectmanager/test_object_manager.rb +35 -45
  68. data/test/objectmanager/test_ordered_set.rb +1 -1
  69. data/test/objectmanager/test_property.rb +261 -0
  70. data/test/objectmanager/test_resource_reading.rb +196 -104
  71. data/test/objectmanager/test_resource_reasoning.rb +26 -0
  72. data/test/objectmanager/test_resource_writing.rb +34 -25
  73. data/test/queryengine/my_external_resource.rb +5 -1
  74. data/test/queryengine/test_external_resource_class.rb +1 -8
  75. data/test/queryengine/test_ntriples_parser.rb +5 -3
  76. data/test/queryengine/test_query.rb +3 -3
  77. data/test/queryengine/test_query2jars2.rb +2 -2
  78. data/test/queryengine/test_query2sparql.rb +2 -2
  79. data/test/queryengine/test_query_engine.rb +46 -28
  80. metadata +16 -8
  81. data/activerdf-rdflite/test/test_bnode_data.nt +0 -5
  82. data/activerdf-rdflite/test/test_data.nt +0 -32
  83. data/activerdf-rdflite/test/test_escaped_data.nt +0 -2
  84. data/activerdf-redland/test/test_person_data.nt +0 -42
  85. data/test/objectmanager/test_talia_syntax.rb +0 -68
@@ -3,240 +3,78 @@
3
3
  # License:: LGPL
4
4
 
5
5
  require 'test/unit'
6
- require 'rubygems'
7
- # require 'active_rdf'
8
- require 'federation/federation_manager'
9
- require 'queryengine/query'
6
+ require 'tmpdir'
7
+ require 'fileutils'
8
+ common_test_dir = File.dirname(File.expand_path(__FILE__)) + '/../../test'
9
+ require "#{common_test_dir}/adapters/test_writable_adapter"
10
+ require "#{common_test_dir}/adapters/test_persistent_adapter"
11
+ require "#{common_test_dir}/adapters/test_network_aware_adapter"
10
12
 
11
- class TestRedlandAdapter < Test::Unit::TestCase
12
- def setup
13
- ConnectionPool.clear
14
- end
15
-
16
- def teardown
17
- end
18
-
19
- def test_registration
20
- adapter = ConnectionPool.add_data_source(:type => :redland)
21
- assert_instance_of RedlandAdapter, adapter
22
- end
23
-
24
- #def test_redland_postgres
25
- # adapter = ConnectionPool.add(:type => :redland, :name => 'db1', :location => :postgresql,
26
- # :host => 'localhost', :database => 'redland_test',
27
- # :user => 'eyal', :password => 'lief1234')
28
- #end
29
-
30
- def test_redland_connections
31
- adapter = RedlandAdapter.new({})
32
- assert_instance_of RedlandAdapter, adapter
33
- end
34
-
35
- def test_simple_query
36
- adapter = ConnectionPool.add_data_source(:type => :redland)
37
-
38
- eyal = RDFS::Resource.new 'eyaloren.org'
39
- age = RDFS::Resource.new 'foaf:age'
40
- test = RDFS::Resource.new 'test'
41
-
42
- adapter.add(eyal, age, test)
43
- result = Query.new.distinct(:s).where(:s, :p, :o).execute(:flatten)
44
-
45
- assert_instance_of RDFS::Resource, result
46
- assert_equal 'eyaloren.org', result.uri
47
- end
48
-
49
- def test_federated_query
50
- adapter1 = ConnectionPool.add_data_source(:type => :redland)
51
- adapter2 = ConnectionPool.add_data_source(:type => :redland, :fake_symbol_to_get_unique_adapter => true)
52
-
53
- eyal = RDFS::Resource.new 'eyaloren.org'
54
- age = RDFS::Resource.new 'foaf:age'
55
- test = RDFS::Resource.new 'test'
56
- test2 = RDFS::Resource.new 'test2'
57
-
58
- adapter1.add(eyal, age, test)
59
- adapter2.add(eyal, age, test2)
60
-
61
- # assert only one distinct subject is found (same one in both adapters)
62
- assert_equal 1, Query.new.distinct(:s).where(:s, :p, :o).execute.size
63
-
64
- # assert two distinct objects are found
65
- results = Query.new.distinct(:o).where(:s, :p, :o).execute
66
- assert_equal 2, results.size
67
-
68
- results.all? {|result| assert result.instance_of?(RDFS::Resource) }
69
- end
70
-
71
- def test_query_with_block
72
- adapter = ConnectionPool.add_data_source(:type => :redland)
73
-
74
- eyal = RDFS::Resource.new 'eyaloren.org'
75
- age = RDFS::Resource.new 'foaf:age'
76
- test = RDFS::Resource.new 'test'
77
-
78
- adapter.add(eyal, age, test)
79
- Query.new.select(:s,:p).where(:s,:p,:o).execute do |s,p|
80
- assert_equal 'eyaloren.org', s.uri
81
- assert_equal 'foaf:age', p.uri
82
- end
83
- end
84
-
85
- def test_load_from_file
86
- adapter = ConnectionPool.add_data_source :type => :redland
87
- adapter.load("#{File.dirname(__FILE__)}/test_person_data.nt", "turtle")
88
- assert_equal 28, adapter.size
89
- end
90
-
91
- def test_remote_load
92
- adapter = ConnectionPool.add_data_source :type => :redland
93
- adapter.load('http://www.eyaloren.org/foaf.rdf', 'rdfxml')
94
- assert_equal 9, adapter.size
95
- end
96
-
97
- def test_load_and_clear
98
- adapter = ConnectionPool.add_data_source :type => :redland
99
- adapter.load('http://www.eyaloren.org/foaf.rdf', 'rdfxml')
100
- assert_equal 9, adapter.size
101
- adapter.clear
102
- assert_equal 0, adapter.size
103
- end
13
+ module TestRedlandAdapter
14
+ include TestWritableAdapter
15
+ include TestNetworkAwareAdapter
104
16
 
105
- def test_close
106
- adapter = ConnectionPool.add_data_source :type => :redland, :location => '/tmp/test.db'
107
- adapter.load('http://www.eyaloren.org/foaf.rdf', 'rdfxml')
108
- assert_equal 9, adapter.size
109
- adapter.close
110
- assert_equal 0, ConnectionPool.adapters.size
111
- end
112
-
113
- def test_person_data
114
- ConnectionPool.add_data_source :type => :redland, :location => 'test/test-person'
115
- Namespace.register(:test, 'http://activerdf.org/test/')
116
-
117
- eyal = Namespace.lookup(:test, :eyal)
118
- eye = Namespace.lookup(:test, :eye)
119
- person = Namespace.lookup(:test, :Person)
120
- type = Namespace.lookup(:rdf, :type)
121
- resource = Namespace.lookup(:rdfs,:resource)
122
-
123
- color = Query.new.select(:o).where(eyal, eye,:o).execute
124
- assert 'blue', color
125
- assert_instance_of String, color
126
-
127
- ObjectManager.construct_classes
128
- assert eyal.instance_of?(TEST::Person)
129
- assert eyal.instance_of?(RDFS::Resource)
130
- end
131
-
132
- def test_federated_query
133
- adapter1 = ConnectionPool.add_data_source(:type => :redland)
134
- adapter2 = ConnectionPool.add_data_source(:type => :redland, :fake_symbol_to_get_unique_adapter => true)
135
-
136
- eyal = RDFS::Resource.new 'eyaloren.org'
137
- age = RDFS::Resource.new 'foaf:age'
138
- test = RDFS::Resource.new 'test'
139
- test2 = RDFS::Resource.new 'test2'
140
-
141
- adapter1.add(eyal, age, test)
142
- adapter2.add(eyal, age, test2)
143
-
144
- # assert only one distinct subject is found (same one in both adapters)
145
- assert_equal 1, Query.new.distinct(:s).where(:s, :p, :o).execute.size
146
-
147
- # assert two distinct objects are found
148
- results = Query.new.distinct(:o).where(:s, :p, :o).execute
149
- assert_equal 2, results.size
150
-
151
- results.all? {|result| assert result.instance_of?(RDFS::Resource) }
152
- end
153
-
154
- def test_query_with_block
155
- adapter = ConnectionPool.add_data_source(:type => :redland)
156
-
157
- eyal = RDFS::Resource.new 'eyaloren.org'
158
- age = RDFS::Resource.new 'foaf:age'
159
- test = RDFS::Resource.new 'test'
17
+ def test_sparql_query
18
+ @adapter.add(@@eyal, @@age, @@ageval)
160
19
 
161
- adapter.add(eyal, age, test)
162
- Query.new.select(:s,:p).where(:s,:p,:o).execute do |s,p|
163
- assert_equal 'eyaloren.org', s.uri
164
- assert_equal 'foaf:age', p.uri
165
- end
166
- end
167
-
168
- def test_person_data
169
- adapter = ConnectionPool.add_data_source :type => :redland
170
- adapter.load("#{File.dirname(__FILE__)}/test_person_data.nt", "turtle")
171
-
172
- Namespace.register(:test, 'http://activerdf.org/test/')
173
-
174
- eyal = Namespace.lookup(:test, :eyal)
175
- eye = Namespace.lookup(:test, :eye)
176
- person = Namespace.lookup(:test, :Person)
177
- type = Namespace.lookup(:rdf, :type)
178
- resource = Namespace.lookup(:rdfs,:resource)
20
+ @adapter.flush
179
21
 
180
- assert_equal 'blue', eyal.test::eye
181
-
182
- ObjectManager.construct_classes
183
- assert eyal.instance_of?(TEST::Person)
184
- assert eyal.instance_of?(RDFS::Resource)
22
+ query = Query.new.distinct(:s).where(:s,:p,:o)
23
+ sparql_query = @adapter.get_query_results(query)
24
+ assert sparql_query.include?(TEST::eyal.uri)
185
25
  end
186
-
187
- def test_write_to_file_and_reload
188
- require 'tmpdir'
189
- location = "#{Dir.tmpdir}/redland-temp"
190
- adapter = ConnectionPool.add_data_source(:type => :redland, :location => location)
191
-
192
- eyal = RDFS::Resource.new 'eyaloren.org'
193
- age = RDFS::Resource.new 'foaf:age'
194
- test = RDFS::Resource.new 'test'
26
+ end
195
27
 
196
- adapter.add(eyal, age, test)
197
- adapter.save
198
-
199
- # flush the pool and freshly load the file we just wrote into
200
- ConnectionPool.clear
201
- adapter2 = ConnectionPool.add_data_source(:type => :redland, :location => location)
28
+ class TestRedlandAdapterMemory < Test::Unit::TestCase
29
+ include TestRedlandAdapter
30
+ # not persistent
202
31
 
203
- assert adapter2.object_id != adapter.object_id
204
- assert_equal 1, adapter2.size
32
+ def setup
33
+ super(:type => :redland, :location => "memory")
205
34
  end
35
+ end
206
36
 
207
- def test_predicate_set
208
- adapter = ConnectionPool.add_data_source(:type => :redland)
209
- adapter.load("#{File.dirname(__FILE__)}/test_person_data.nt", "turtle")
210
- Namespace.register(:test, 'http://activerdf.org/test/')
211
- assert_equal 27, TEST::eyal.age.to_i
212
- assert_equal ['27'], TEST::eyal.get_predicate(TEST::age)
213
-
214
- TEST::eyal.set_predicate(TEST::age, [30])
215
- assert_equal 30, TEST::eyal.age.to_i
216
- assert_equal ['30'], TEST::eyal.get_predicate(TEST::age)
37
+ #class TestRedlandAdapterFile < Test::Unit::TestCase
38
+ # include TestRedlandAdapter
39
+ # include TestPersistentAdapter
40
+ #
41
+ # def setup
42
+ # super(:type => :redland, :location => @location)
43
+ # @location = File.join(Dir.tmpdir,"redland-temp")
44
+ # end
45
+ # def teardown
46
+ # FileUtils.rm Dir.glob(@location + '-*')
47
+ # end
48
+ #end
49
+
50
+ class TestRedlandAdapterSqlite < Test::Unit::TestCase
51
+ include TestRedlandAdapter
52
+ # not persistent
217
53
 
218
- ConnectionPool.clear
219
- adapter = ConnectionPool.add_data_source(:type => :redland)
220
- adapter.load("#{File.dirname(__FILE__)}/test_person_data.nt", "turtle")
221
- assert_equal 27, TEST::eyal.age.to_i
222
- TEST::eyal.age = 30
223
- assert_equal 30, TEST::eyal.age.to_i
54
+ def setup
55
+ super(:type => :redland, :location => 'sqlite')
224
56
  end
57
+ end
225
58
 
226
- def test_sparql_query
227
- adapter = ConnectionPool.add_data_source :type => :redland
228
-
229
- eyal = RDFS::Resource.new 'eyaloren.org'
230
- age = RDFS::Resource.new 'foaf:age'
231
- test = RDFS::Resource.new 'test'
232
- adapter.add(eyal, age, test)
233
-
234
- adapter.save
235
- query = Query.new.distinct(:s).where(:s,:p,:o)
236
- results = adapter.get_query_results(query)
59
+ #class TestRedlandAdapterMySQL < Test::Unit::TestCase
60
+ # include TestRedlandAdapter
61
+ # include TestPersistentAdapter
62
+ #
63
+ # def setup
64
+ # super(:type => :redland, :name => 'db1', :location => 'mysql',
65
+ # :host => 'localhost', :database => 'redland_test',
66
+ # :user => '', :password => '', :new => 'yes')
67
+ # end
68
+ #end
69
+
70
+ #class TestRedlandAdapterPostgres < Test::Unit::TestCase
71
+ # include TestPersistentAdapter
72
+ # include TestRedlandAdapter
73
+ #
74
+ # def setup
75
+ # super(:type => :redland, :name => 'db1', :location => 'postgresql',
76
+ # :host => 'localhost', :database => 'redland_test',
77
+ # :user => '', :password => '', :new => 'yes')
78
+ # end
79
+ #end
237
80
 
238
- # TODO: test if results are correct; but we do this only when redland
239
- # supports this method in release
240
- assert results.include?('eyaloren.org')
241
- end
242
- end
@@ -1,3 +1,3 @@
1
1
  #Build Number for ANT. Do not edit!
2
- #Wed Dec 02 17:17:16 CET 2009
3
- build.number=137
2
+ #Thu Feb 11 14:15:40 CET 2010
3
+ build.number=138
File without changes
File without changes
File without changes
@@ -1,8 +1,8 @@
1
1
  Manifest-Version: 1.0
2
2
  Ant-Version: Apache Ant 1.7.1
3
- Created-By: 1.5.0_20-141 (Apple Inc.)
3
+ Created-By: 14.3-b01-101 (Apple Inc.)
4
4
  Built-By: daniel
5
- Built-Number: 136
5
+ Built-Number: 137
6
6
 
7
7
  Name: common
8
8
  Specification-Title: Example