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.
- data/CHANGELOG +63 -0
- data/activerdf-jena/lib/activerdf_jena/jena.rb +4 -4
- data/activerdf-jena/lib/activerdf_jena/jena_adapter.rb +55 -55
- data/activerdf-jena/lib/activerdf_jena/lucene.rb +1 -1
- data/activerdf-jena/lib/activerdf_jena/ng4j.rb +7 -7
- data/activerdf-jena/lib/activerdf_jena/ng4j_adapter.rb +47 -47
- data/activerdf-jena/lib/activerdf_jena/pellet.rb +1 -1
- data/activerdf-jena/test/test_jena_adapter.rb +121 -120
- data/activerdf-jena/test/test_ng4j_adapter.rb +111 -110
- data/activerdf-rdflite/lib/activerdf_rdflite/fetching.rb +23 -19
- data/activerdf-rdflite/lib/activerdf_rdflite/rdflite.rb +153 -277
- data/activerdf-rdflite/lib/activerdf_rdflite/suggesting.rb +2 -2
- data/activerdf-rdflite/test/test_fetching.rb +7 -22
- data/activerdf-rdflite/test/test_rdflite.rb +44 -257
- data/activerdf-redland/lib/activerdf_redland/redland.rb +246 -282
- data/activerdf-redland/test/test_redland_adapter.rb +62 -224
- data/activerdf-sesame/ext/wrapper-sesame2.jar +0 -0
- data/activerdf-sesame/java/build.number +2 -2
- data/activerdf-sesame/java/build.xml +0 -0
- data/activerdf-sesame/java/lib/junit-3.8.2.jar +0 -0
- data/activerdf-sesame/java/settings.xml +0 -0
- data/activerdf-sesame/java/src/org/activerdf/wrapper/sesame2/WrapperForSesame2.java +0 -0
- data/activerdf-sesame/java/temp/build/org/activerdf/wrapper/sesame2/WrapperForSesame2.class +0 -0
- data/activerdf-sesame/java/temp/manifest/MANIFEST.MF +2 -2
- data/activerdf-sesame/java/test-src/org/activerdf/wrapper/sesame2/TestWrapperForSesame2.java +0 -0
- data/activerdf-sesame/lib/activerdf_sesame/sesame.rb +360 -364
- data/activerdf-sesame/test/test_sesame_adapter.rb +85 -83
- data/activerdf-sparql/lib/activerdf_sparql/sparql.rb +147 -148
- data/activerdf-sparql/lib/activerdf_sparql/sparql_result_parser.rb +5 -5
- data/activerdf-sparql/test/test_sparql_adapter.rb +2 -0
- data/activerdf-yars/lib/activerdf_yars/jars2.rb +85 -83
- data/lib/active_rdf/federation/active_rdf_adapter.rb +26 -39
- data/lib/active_rdf/federation/connection_pool.rb +119 -110
- data/lib/active_rdf/federation/federation_manager.rb +51 -51
- data/lib/active_rdf/objectmanager/bnode.rb +8 -2
- data/lib/active_rdf/objectmanager/literal.rb +81 -50
- data/lib/active_rdf/objectmanager/namespace.rb +117 -84
- data/lib/active_rdf/objectmanager/object_manager.rb +101 -96
- data/lib/active_rdf/objectmanager/ordered_set.rb +1 -1
- data/lib/active_rdf/objectmanager/property.rb +345 -0
- data/lib/active_rdf/objectmanager/property_list.rb +4 -4
- data/lib/active_rdf/objectmanager/property_lookup.rb +57 -0
- data/lib/active_rdf/objectmanager/resource.rb +293 -501
- data/lib/active_rdf/objectmanager/resource_like.rb +2 -2
- data/lib/active_rdf/objectmanager/resource_query.rb +85 -0
- data/lib/active_rdf/queryengine/ntriples_parser.rb +75 -68
- data/lib/active_rdf/queryengine/query.rb +237 -183
- data/lib/active_rdf/queryengine/query2jars2.rb +17 -15
- data/lib/active_rdf/queryengine/query2sparql.rb +107 -101
- data/lib/active_rdf.rb +28 -17
- data/lib/active_rdf_helpers.rb +37 -5
- data/lib/active_rdf_log.rb +11 -11
- data/test/adapters/test_activerdf_adapter.rb +138 -0
- data/test/{test_adapters.rb → adapters/test_adapters.rb} +6 -24
- data/test/adapters/test_bnode_capable_adapter.rb +31 -0
- data/test/adapters/test_context_aware_adapter.rb +31 -0
- data/test/adapters/test_network_aware_adapter.rb +29 -0
- data/test/adapters/test_persistent_adapter.rb +21 -0
- data/test/adapters/test_read_only_adapter.rb +15 -0
- data/test/adapters/test_reasoning_adapter.rb +11 -0
- data/test/adapters/test_writable_adapter.rb +163 -0
- data/test/common.rb +78 -96
- data/test/federation/test_connection_pool.rb +25 -44
- data/test/federation/test_federation_manager.rb +45 -45
- data/test/objectmanager/test_literal.rb +47 -26
- data/test/objectmanager/test_namespace.rb +3 -1
- data/test/objectmanager/test_object_manager.rb +35 -45
- data/test/objectmanager/test_ordered_set.rb +1 -1
- data/test/objectmanager/test_property.rb +261 -0
- data/test/objectmanager/test_resource_reading.rb +196 -104
- data/test/objectmanager/test_resource_reasoning.rb +26 -0
- data/test/objectmanager/test_resource_writing.rb +34 -25
- data/test/queryengine/my_external_resource.rb +5 -1
- data/test/queryengine/test_external_resource_class.rb +1 -8
- data/test/queryengine/test_ntriples_parser.rb +5 -3
- data/test/queryengine/test_query.rb +3 -3
- data/test/queryengine/test_query2jars2.rb +2 -2
- data/test/queryengine/test_query2sparql.rb +2 -2
- data/test/queryengine/test_query_engine.rb +46 -28
- metadata +16 -8
- data/activerdf-rdflite/test/test_bnode_data.nt +0 -5
- data/activerdf-rdflite/test/test_data.nt +0 -32
- data/activerdf-rdflite/test/test_escaped_data.nt +0 -2
- data/activerdf-redland/test/test_person_data.nt +0 -42
- 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
|
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 =
|
21
|
+
@@age_number = 27
|
21
22
|
@@eye = RDFS::Resource.new("http://activerdf.org/test/eye")
|
22
|
-
@@eye_value =
|
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 =
|
30
|
-
a2 =
|
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
|
36
|
-
|
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
|
-
|
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
|
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
|
51
|
+
def test_add_one_write_one_read
|
51
52
|
# one write, one read
|
52
53
|
|
53
|
-
write1 =
|
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
|
-
|
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 =
|
66
|
-
r2 =
|
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 =
|
71
|
-
w2 =
|
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
|
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
|
-
|
82
|
-
|
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
|
-
|
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
|
91
|
+
def test_add_two_write_switching
|
93
92
|
# two write, one read, with switching
|
94
93
|
|
95
|
-
write1 =
|
96
|
-
write2 =
|
94
|
+
write1 = get_primary_write_adapter
|
95
|
+
write2 = get_secondary_write_adapter
|
96
|
+
get_read_only_adapter
|
97
97
|
|
98
|
-
|
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
|
-
|
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
|
-
|
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.
|
111
|
-
|
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
|
-
|
117
|
-
first_adapter
|
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 =
|
126
|
-
second_adapter.load(
|
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 =
|
132
|
-
first_adapter.load(
|
133
|
-
second_adapter =
|
134
|
-
second_adapter.load(
|
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.
|
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.
|
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.
|
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.
|
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.
|
47
|
-
assert_not_equal cat.
|
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
|
-
|
50
|
-
assert_equal '"
|
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://
|
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
|
-
|
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
|
-
|
41
|
-
|
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
|
-
|
47
|
-
|
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
|
51
|
-
|
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
|
-
|
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
|
-
|
77
|
-
'<rdf:Description rdf:about="#eyal">
|
78
|
-
<test:
|
79
|
-
<test:
|
80
|
-
<
|
81
|
-
<rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Resource"/>
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
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
|
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 =
|
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
|