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
@@ -4,10 +4,11 @@
4
4
 
5
5
  require 'test/unit'
6
6
  require 'active_rdf'
7
- require 'federation/federation_manager'
8
- require "#{File.dirname(__FILE__)}/../common"
7
+ require "#{File.dirname(File.expand_path(__FILE__))}/../common"
9
8
 
10
9
  class TestFederationManager < Test::Unit::TestCase
10
+ include ActiveRDF
11
+
11
12
  def setup
12
13
  ConnectionPool.clear
13
14
  end
@@ -17,104 +18,103 @@ class TestFederationManager < Test::Unit::TestCase
17
18
 
18
19
  @@eyal = RDFS::Resource.new("http://activerdf.org/test/eyal")
19
20
  @@age = RDFS::Resource.new("http://activerdf.org/test/age")
20
- @@age_number = RDFS::Resource.new("27")
21
+ @@age_number = 27
21
22
  @@eye = RDFS::Resource.new("http://activerdf.org/test/eye")
22
- @@eye_value = RDFS::Resource.new("blue")
23
+ @@eye_value = "blue"
23
24
  @@type = RDFS::Resource.new("http://www.w3.org/1999/02/22-rdf-syntax-ns#type")
24
25
  @@person = RDFS::Resource.new("http://www.w3.org/2000/01/rdf-schema#Resource")
25
26
  @@resource = RDFS::Resource.new("http://activerdf.org/test/Person")
26
27
 
27
28
 
28
29
  def test_single_pool
29
- a1 = get_adapter
30
- a2 = get_adapter
30
+ a1 = get_primary_adapter
31
+ a2 = get_primary_adapter
31
32
  assert_equal a1, a2
32
33
  assert_equal a1.object_id, a2.object_id
33
34
  end
34
35
 
35
- def test_class_add
36
- write1 = get_write_adapter
36
+ def test_add
37
+ get_primary_write_adapter
37
38
  FederationManager.add(@@eyal, @@age, @@age_number)
38
39
 
39
- age_result = Query.new.select(:o).where(@@eyal, @@age, :o).execute
40
- assert "27", age_result
40
+ age_result = Query.new.select(:o).where(@@eyal, @@age, :o).execute(:flatten=>true)
41
+ assert_equal 27, age_result
41
42
  end
42
43
 
43
- def test_class_add_no_write_adapter
44
+ def test_add_no_write_adapter
44
45
  # zero write, one read -> must raise error
45
46
  adapter = get_read_only_adapter
46
47
  assert (not adapter.writes?)
47
48
  assert_raises(ActiveRdfError) { FederationManager.add(@@eyal, @@age, @@age_number) }
48
49
  end
49
50
 
50
- def test_class_add_one_write_one_read
51
+ def test_add_one_write_one_read
51
52
  # one write, one read
52
53
 
53
- write1 = get_write_adapter
54
+ write1 = get_primary_write_adapter
54
55
  read1 = get_read_only_adapter
55
56
  assert_not_equal write1,read1
56
57
  assert_not_equal write1.object_id, read1.object_id
57
58
 
58
59
  FederationManager.add(@@eyal, @@age, @@age_number)
59
60
 
60
- age_result = Query.new.select(:o).where(@@eyal, @@age, :o).execute
61
- assert "27", age_result
61
+ age_result = Query.new.select(:o).where(@@eyal, @@age, :o).execute(:flatten=>true)
62
+ assert_equal 27, age_result
62
63
  end
63
64
 
64
65
  def test_get_different_read_and_write_adapters
65
- r1 = get_adapter
66
- r2 = get_different_adapter(r1)
66
+ r1 = get_primary_adapter
67
+ r2 = get_secondary_adapter
67
68
  assert_not_equal r1,r2
68
69
  assert_not_equal r1.object_id, r2.object_id
69
70
 
70
- w1 = get_write_adapter
71
- w2 = get_different_write_adapter(w1)
71
+ w1 = get_primary_write_adapter
72
+ w2 = get_secondary_write_adapter
72
73
  assert_not_equal w1,w2
73
74
  assert_not_equal w1.object_id, w2.object_id
74
75
  end
75
76
 
76
- def test_class_add_two_write
77
+ def test_add_two_write
77
78
  # two write, one read, no switching
78
79
  # we need to different write adapters for this
79
80
  #
80
81
 
81
- write1 = get_write_adapter
82
- write2 = get_different_write_adapter(write1)
83
-
84
- read1 = get_read_only_adapter
82
+ get_secondary_write_adapter
83
+ get_primary_write_adapter
85
84
 
86
85
  FederationManager.add(@@eyal, @@age, @@age_number)
87
86
 
88
- age_result = Query.new.select(:o).where(@@eyal, @@age, :o).execute
89
- assert "27", age_result
87
+ age_result = Query.new.select(:o).where(@@eyal, @@age, :o).execute(:flatten=>true)
88
+ assert_equal 27, age_result
90
89
  end
91
90
 
92
- def test_class_add_two_write_switching
91
+ def test_add_two_write_switching
93
92
  # two write, one read, with switching
94
93
 
95
- write1 = get_write_adapter
96
- write2 = get_different_write_adapter(write1)
94
+ write1 = get_primary_write_adapter
95
+ write2 = get_secondary_write_adapter
96
+ get_read_only_adapter
97
97
 
98
- read1 = get_read_only_adapter
98
+ ConnectionPool.write_adapter = write1
99
99
 
100
100
  FederationManager.add(@@eyal, @@age, @@age_number)
101
- age_result = Query.new.select(:o).where(@@eyal, @@age, :o).execute
102
- assert "27", age_result
101
+ age_result = Query.new.select(:o).where(@@eyal, @@age, :o).execute(:flatten=>true)
102
+ assert_equal 27, age_result
103
103
 
104
104
  ConnectionPool.write_adapter = write2
105
105
 
106
106
  FederationManager.add(@@eyal, @@eye, @@eye_value)
107
- age_result = Query.new.select(:o).where(@@eyal, @@eye, :o).execute
108
- assert "blue", age_result
107
+ age_result = Query.new.select(:o).where(@@eyal, @@eye, :o).execute(:flatten=>true)
108
+ assert_equal "blue", age_result
109
109
 
110
- second_result = write2.query(Query.new.select(:o).where(@@eyal, @@eye, :o))
111
- assert "blue", second_result
110
+ second_result = write2.execute(Query.new.select(:o).where(@@eyal, @@eye, :o))
111
+ assert_equal [["blue"]], second_result # results returned as array of arrays directly from adapter
112
112
  end
113
113
 
114
- # this test makes no sense without two different data sources
115
114
  def test_federated_query
116
- first_adapter = get_write_adapter
117
- first_adapter.load("#{File.dirname(__FILE__)}/../test_person_data.nt")
115
+ test_person_data = "#{File.dirname(__FILE__)}/../test_person_data.nt"
116
+ first_adapter = get_primary_write_adapter
117
+ first_adapter.load(test_person_data)
118
118
  first = Query.new.select(:s,:p,:o).where(:s,:p,:o).execute
119
119
 
120
120
  # results should not be empty, because then the test succeeds trivially
@@ -122,16 +122,16 @@ class TestFederationManager < Test::Unit::TestCase
122
122
  assert first != []
123
123
 
124
124
  ConnectionPool.clear
125
- second_adapter = get_different_write_adapter(first_adapter)
126
- second_adapter.load("#{File.dirname(__FILE__)}/../test_person_data.nt")
125
+ second_adapter = get_secondary_write_adapter
126
+ second_adapter.load(test_person_data)
127
127
  second = Query.new.select(:s,:p,:o).where(:s,:p,:o).execute
128
128
 
129
129
  # now we query both adapters in parallel
130
130
  ConnectionPool.clear
131
- first_adapter = get_write_adapter
132
- first_adapter.load("#{File.dirname(__FILE__)}/../test_person_data.nt")
133
- second_adapter = get_different_write_adapter(first_adapter)
134
- second_adapter.load("#{File.dirname(__FILE__)}/../test_person_data.nt")
131
+ first_adapter = get_primary_write_adapter
132
+ first_adapter.load(test_person_data)
133
+ second_adapter = get_secondary_write_adapter
134
+ second_adapter.load(test_person_data)
135
135
  both = Query.new.select(:s,:p,:o).where(:s,:p,:o).execute
136
136
  # assert both together contain twice the sum of the separate sources
137
137
  assert_equal first + second, both
@@ -4,49 +4,70 @@
4
4
 
5
5
  require 'test/unit'
6
6
  require 'active_rdf'
7
- require "#{File.dirname(__FILE__)}/../common"
8
7
 
9
8
  class TestLiteral < Test::Unit::TestCase
10
- def setup
11
- ConnectionPool.clear
12
- @adapter = get_adapter
13
- end
14
-
15
- def teardown
16
- end
17
-
18
- def test_xsd_string
19
- test = Literal.typed('test', XSD::string)
20
- assert_equal '"test"^^<http://www.w3.org/2001/XMLSchema#string>', test.to_ntriple
21
- end
22
-
23
9
  def test_automatic_conversion
24
- # infer string
25
10
  test = 'test'
26
- assert_equal '"test"^^<http://www.w3.org/2001/XMLSchema#string>', test.to_ntriple
11
+ assert_equal '"test"^^<http://www.w3.org/2001/XMLSchema#string>', test.to_literal_s
27
12
 
28
13
  # infer integer
29
14
  test = 18
30
- assert_equal '"18"^^<http://www.w3.org/2001/XMLSchema#integer>', test.to_ntriple
15
+ assert_equal '"18"^^<http://www.w3.org/2001/XMLSchema#integer>', test.to_literal_s
16
+
17
+ # infer float
18
+ test = 3.1415
19
+ assert_equal '"3.1415"^^<http://www.w3.org/2001/XMLSchema#double>', test.to_literal_s
31
20
 
32
21
  # infer boolean
33
22
  test = true
34
- assert_equal '"true"^^<http://www.w3.org/2001/XMLSchema#boolean>', test.to_ntriple
23
+ assert_equal '"true"^^<http://www.w3.org/2001/XMLSchema#boolean>', test.to_literal_s
24
+
25
+ # infer Time
26
+ test = Time.parse("Sat Nov 22 00:33:23 Z 2008").utc
27
+ assert_equal '"2008-11-22T00:33:23Z"^^<http://www.w3.org/2001/XMLSchema#time>', test.to_literal_s
28
+
29
+ $activerdf_without_datatype = true
30
+ assert_equal '"2008-11-22T00:33:23Z"', test.to_literal_s
31
+ $activerdf_without_datatype = false
35
32
  end
36
-
33
+
37
34
  def test_equality
38
35
  test1 = 'test'
39
- test2 = Literal.typed('test', XSD::string)
40
- assert_equal test2.to_ntriple, test1.to_ntriple
36
+ test2 = RDFS::Literal.typed('test', XSD::string)
37
+ assert_equal test2.to_literal_s, test1.to_literal_s
41
38
  end
42
-
39
+
43
40
  def test_language_tag
44
41
  cat = 'cat'
45
42
  cat_en = LocalizedString.new('cat', '@en')
46
- assert_equal '"cat"@en', cat_en.to_ntriple
47
- assert_not_equal cat.to_ntriple, cat_en.to_ntriple
43
+ assert_equal '"cat"@en', cat_en.to_literal_s
44
+ assert_not_equal cat.to_literal_s, cat_en.to_literal_s
45
+
46
+ assert_equal '"dog"@en-GB', LocalizedString.new('dog', '@en-GB').to_literal_s
47
+ assert_equal '"dog"@en@test', LocalizedString.new('dog', '@en@test').to_literal_s
48
+ end
49
+ end
50
+
51
+ class TestLocalizedString < Test::Unit::TestCase
52
+ def setup
53
+ @ls_en = LocalizedString.new('localized string','@en')
54
+ end
55
+
56
+ def test_lang
57
+ assert_equal 'en', @ls_en.lang
58
+ assert_equal @ls_en, LocalizedString.new('localized string','en')
59
+ end
60
+
61
+ def test_equality
62
+ assert @ls_en == "localized string"
63
+ assert @ls_en == LocalizedString.new('localized string','en')
64
+ assert @ls_en != LocalizedString.new('localized string','@gb')
65
+ end
48
66
 
49
- assert_equal '"dog"@en-GB', LocalizedString.new('dog', '@en-GB').to_ntriple
50
- assert_equal '"dog"@en@test', LocalizedString.new('dog', '@en@test').to_ntriple
67
+ def test_to_literal_s
68
+ assert_equal '"localized string"@en', @ls_en.to_literal_s
69
+ $activerdf_without_datatype = true
70
+ assert_equal '"localized string"', @ls_en.to_literal_s
71
+ $activerdf_without_datatype = false
51
72
  end
52
73
  end
@@ -8,6 +8,8 @@ require 'objectmanager/namespace'
8
8
  require "#{File.dirname(__FILE__)}/../common"
9
9
 
10
10
  class TestNamespace < Test::Unit::TestCase
11
+ include ActiveRDF
12
+
11
13
  Rdf = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
12
14
  Rdfs = 'http://www.w3.org/2000/01/rdf-schema#'
13
15
  RdfType = RDFS::Resource.new('http://www.w3.org/1999/02/22-rdf-syntax-ns#type')
@@ -61,7 +63,7 @@ class TestNamespace < Test::Unit::TestCase
61
63
  end
62
64
 
63
65
  def test_class_register
64
- test = 'http://test.org/'
66
+ test = 'http://activerdf.org/test/'
65
67
  abc = RDFS::Resource.new("#{test}abc")
66
68
  Namespace.register :test, test
67
69
 
@@ -7,12 +7,7 @@ require 'active_rdf'
7
7
  require "#{File.dirname(__FILE__)}/../common"
8
8
 
9
9
  class TestObjectManager < Test::Unit::TestCase
10
- def setup
11
- ConnectionPool.clear
12
- end
13
-
14
- def teardown
15
- end
10
+ include SetupAdapter
16
11
 
17
12
  def test_resource_creation
18
13
  assert_nothing_raised { RDFS::Resource.new('abc') }
@@ -29,68 +24,63 @@ class TestObjectManager < Test::Unit::TestCase
29
24
  end
30
25
 
31
26
  def test_class_construct_classes
32
- adapter = get_write_adapter
33
- adapter.load "#{File.dirname(__FILE__)}/../test_person_data.nt"
34
-
35
- Namespace.register(:test, 'http://activerdf.org/test/')
36
-
37
27
  assert_equal RDFS::Resource.new('http://activerdf.org/test/Person'), TEST::Person
38
28
  assert_kind_of Class, TEST::Person
39
29
  assert TEST::Person.ancestors.include?(RDFS::Resource)
40
- assert_instance_of TEST::Person, TEST::Person.new('')
41
- assert TEST::Person.new('').respond_to?(:uri)
30
+ new_person = TEST::Person.new(TEST::michael)
31
+ assert_instance_of TEST::Person, new_person
32
+ assert new_person.respond_to?(:uri)
42
33
 
43
34
  assert_equal RDFS::Resource.new('http://www.w3.org/2000/01/rdf-schema#Class'), RDFS::Class
44
- assert RDFS::Class.ancestors.include?(RDFS::Resource)
45
35
  assert_kind_of Class, RDFS::Class
46
- assert_instance_of RDFS::Resource, RDFS::Class.new('')
47
- assert RDFS::Class.new('').respond_to?(:uri)
36
+ assert RDFS::Class.ancestors.include?(RDFS::Resource)
37
+ new_class = RDFS::Class.new(TEST::klass)
38
+ assert_instance_of RDFS::Resource, new_class
39
+ assert new_class.respond_to?(:uri)
48
40
  end
49
41
 
50
- def test_custom_code
51
- Namespace.register(:test, 'http://activerdf.org/test/')
42
+ def test_invalid_resource
43
+ assert_raise ActiveRdfError do
44
+ Query.new.distinct(:o).where(TEST::Person.new(''),TEST::age,:o).execute
45
+ end
46
+ end
52
47
 
48
+ def test_custom_code
53
49
  TEST::Person.module_eval{ def hello; 'world'; end }
54
50
  assert_respond_to TEST::Person.new(''), :hello
55
51
  assert_equal 'world', TEST::Person.new('').hello
56
52
  end
57
53
 
58
54
  def test_class_uri
59
- adapter = get_write_adapter
60
- adapter.load "#{File.dirname(__FILE__)}/../test_person_data.nt"
61
- Namespace.register(:test, 'http://activerdf.org/test/')
62
-
63
55
  assert_equal RDFS::Resource.new('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), RDF::type
64
56
  assert_equal RDF::type, RDFS::Resource.new('http://www.w3.org/1999/02/22-rdf-syntax-ns#type')
65
57
  assert_equal TEST::Person, RDFS::Resource.new('http://activerdf.org/test/Person')
66
58
  assert_equal RDFS::Resource.new('http://activerdf.org/test/Person'), TEST::Person
67
59
  end
68
60
 
69
- def test_to_xml
70
- get_adapter.load "#{File.dirname(__FILE__)}/../test_person_data.nt"
71
- Namespace.register(:test, 'http://activerdf.org/test/')
72
-
61
+ def test_to_xml#
62
+ @adapter.load "#{File.dirname(__FILE__)}/../test_person_data.nt"
73
63
  eyal = RDFS::Resource.new 'http://activerdf.org/test/eyal'
74
64
  eyal.age = 29
75
65
  assert_equal 29, eyal.age
76
- snippet =
77
- '<rdf:Description rdf:about="#eyal">
78
- <test:age rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">29</test:age>
79
- <test:eye rdf:datatype="http://www.w3.org/2001/XMLSchema#string">blue</test:eye>
80
- <rdf:type rdf:resource="http://activerdf.org/test/Person"/>
81
- <rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Resource"/>
82
- </rdf:Description>
83
- </rdf:RDF>'
84
- # Ignore whitespaces in comparison
85
- assert eyal.to_xml.gsub!(/\s+/, '').include?(snippet.gsub!(/\s+/, ''))
86
-
87
- require 'net/http'
88
- url = 'http://librdf.org/parse'
89
- uri = URI.parse(url)
90
- req = Net::HTTP::Post.new(url)
91
- req.set_form_data('content'=>eyal.to_xml, 'language'=>'rdfxml')
92
- res = Net::HTTP.new(uri.host,uri.port).start {|http| http.request(req) }
93
- result = res.body.match(/Found.*triples/)[0]
94
- assert_equal "Found 4 triples", result, 'invalid XML generated (according to online parser at librdf.org'
66
+ xml = eyal.to_xml
67
+ ['<rdf:Description rdf:about="#eyal">',
68
+ '<test:eye xml:lang="en">blue</test:eye>',
69
+ '<test:email rdf:datatype="http://www.w3.org/2001/XMLSchema#string">eyal@cs.vu.nl</test:email>',
70
+ '<test:email rdf:datatype="http://www.w3.org/2001/XMLSchema#string">eyal.oren@deri.org</test:email>',
71
+ '<rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Resource"/>',
72
+ '<rdf:type rdf:resource="http://activerdf.org/test/Person"/>',
73
+ '<test:age rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">29</test:age>'].each do |str|
74
+ assert xml.include?(str), "xml does not contain #{str}"
75
+ end
76
+
77
+ require 'net/http'
78
+ url = 'http://librdf.org/parse'
79
+ uri = URI.parse(url)
80
+ req = Net::HTTP::Post.new(url)
81
+ req.set_form_data('content'=>eyal.to_xml, 'language'=>'rdfxml')
82
+ res = Net::HTTP.new(uri.host,uri.port).start {|http| http.request(req) }
83
+ result = res.body.match(/Found.*triples/)[0]
84
+ assert_equal "Found 6 triples", result, 'invalid XML generated (according to online parser at librdf.org)'
95
85
  end
96
86
  end
@@ -13,7 +13,7 @@ class TestOrderedSet < Test::Unit::TestCase
13
13
  def setup
14
14
  ConnectionPool.clear
15
15
 
16
- adapter = get_write_adapter
16
+ adapter = get_primary_write_adapter
17
17
  adapter.load "#{File.dirname(__FILE__)}/../test_person_data.nt"
18
18
  adapter.load "#{File.dirname(__FILE__)}/../test_rdf_data.nt"
19
19
  ObjectManager.construct_classes