rtm 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. data/README +38 -3
  2. data/lib/rtm.rb +25 -47
  3. data/lib/rtm/axes.rb +7 -4
  4. data/lib/rtm/axes/association.rb +1 -1
  5. data/lib/rtm/axes/associations.rb +1 -1
  6. data/lib/rtm/axes/characteristic.rb +1 -1
  7. data/lib/rtm/axes/characteristics.rb +1 -1
  8. data/lib/rtm/axes/topic.rb +3 -3
  9. data/lib/rtm/axes/topics.rb +3 -3
  10. data/lib/rtm/engine.rb +48 -5
  11. data/lib/rtm/extensions.rb +58 -8
  12. data/lib/rtm/io.rb +2 -1
  13. data/lib/rtm/io/tmapix_from.rb +155 -0
  14. data/lib/rtm/io/tmapix_to.rb +223 -0
  15. data/lib/rtm/io/to_hash.rb +79 -41
  16. data/lib/rtm/io/to_jtm.rb +1 -1
  17. data/lib/rtm/io/to_rdf.rb +20 -5
  18. data/lib/rtm/io/to_string.rb +13 -2
  19. data/lib/rtm/io/to_yaml.rb +39 -11
  20. data/lib/rtm/navigation.rb +1 -15
  21. data/lib/rtm/navigation/association/players.rb +1 -1
  22. data/lib/rtm/navigation/name/characteristics.rb +1 -1
  23. data/lib/rtm/navigation/occurrence/characteristics.rb +1 -1
  24. data/lib/rtm/navigation/topic/characteristics.rb +1 -1
  25. data/lib/rtm/navigation/topic/players.rb +1 -1
  26. data/lib/rtm/navigation/topic/supertypes.rb +21 -17
  27. data/lib/rtm/navigation/topic/traverse.rb +1 -1
  28. data/lib/rtm/navigation/topic/types.rb +6 -4
  29. data/lib/rtm/psi.rb +6 -0
  30. data/lib/rtm/sugar.rb +42 -29
  31. data/lib/rtm/sugar/association/hash_access.rb +3 -3
  32. data/lib/rtm/sugar/occurrence/dynamic_value.rb +39 -56
  33. data/lib/rtm/sugar/occurrence/external.rb +53 -0
  34. data/lib/rtm/sugar/reifiable/reifier.rb +21 -0
  35. data/lib/rtm/sugar/role/counterparts.rb +12 -6
  36. data/lib/rtm/sugar/topic/best_name.rb +74 -0
  37. data/lib/rtm/sugar/topic/characteristics.rb +10 -10
  38. data/lib/rtm/sugar/topic/counterparts.rb +131 -119
  39. data/lib/rtm/sugar/topic/scoped.rb +102 -53
  40. data/lib/rtm/sugar/topic/topic_ref.rb +63 -12
  41. data/lib/rtm/sugar/topic/typed.rb +50 -2
  42. data/lib/rtm/sugar/topic_map/query_cache.rb +66 -0
  43. data/lib/rtm/sugar/topic_map/themes.rb +53 -0
  44. data/lib/rtm/sugar/typed/types.rb +1 -1
  45. data/lib/rtm/validation.rb +2 -2
  46. data/lib/rtm/version.rb +18 -6
  47. data/spec/rtm/axes/string_spec.rb +7 -7
  48. data/spec/rtm/axes/strings_spec.rb +10 -10
  49. data/spec/rtm/io/tmapix_from_spec.rb +76 -0
  50. data/spec/rtm/io/tmapix_to_spec.rb +159 -0
  51. data/spec/rtm/io/to_hash_spec.rb +90 -0
  52. data/spec/rtm/io/to_rdf_spec.rb +37 -0
  53. data/spec/rtm/io/to_string_spec.rb +122 -0
  54. data/spec/rtm/io/to_yaml_spec.rb +89 -0
  55. data/spec/rtm/sugar/occurrence/dynamic_value_spec.rb +156 -1
  56. data/spec/rtm/sugar/occurrence/external_spec.rb +129 -0
  57. data/spec/rtm/sugar/reifiable/reifier_spec.rb +41 -0
  58. data/spec/rtm/sugar/role/counterparts_spec.rb +174 -172
  59. data/spec/rtm/sugar/topic/best_name_spec.rb +25 -0
  60. data/spec/rtm/sugar/topic/characteristics_spec.rb +20 -5
  61. data/spec/rtm/sugar/topic/counterparts_spec.rb +41 -1
  62. data/spec/rtm/sugar/topic/hash_access_spec.rb +1 -1
  63. data/spec/rtm/sugar/topic/scoped_spec.rb +178 -114
  64. data/spec/rtm/sugar/topic/topic_ref_spec.rb +10 -10
  65. data/spec/rtm/sugar/topic/typed_spec.rb +196 -134
  66. data/spec/rtm/sugar/topic_map/themes_spec.rb +67 -0
  67. data/spec/rtm/sugar/typed/types_spec.rb +1 -1
  68. data/spec/rtm/tmapi/core/association_spec.rb +2 -2
  69. data/spec/rtm/tmapi/core/datatype_aware_spec.rb +236 -0
  70. data/spec/rtm/tmapi/core/name_spec.rb +186 -1
  71. data/spec/rtm/tmapi/core/occurrence_spec.rb +24 -67
  72. data/spec/rtm/tmapi/core/reifiable_spec.rb +2 -2
  73. data/spec/rtm/tmapi/core/scoped_spec.rb +40 -2
  74. data/spec/rtm/tmapi/core/topic_map_spec.rb +98 -30
  75. data/spec/rtm/tmapi/core/topic_spec.rb +558 -82
  76. data/spec/rtm/tmapi/core/variant_spec.rb +3 -3
  77. data/spec/rtm_spec.rb +0 -1
  78. data/spec/spec_helper.rb +7 -2
  79. data/test/javalibs/junit-4.5.jar +0 -0
  80. data/test/javalibs/tmapi-2.0-tests.jar +0 -0
  81. data/test/tmapi_tests.rb +25 -0
  82. metadata +66 -11
  83. data/lib/rtm/io/ontopia_io.rb +0 -25
  84. data/lib/rtm/io/tmapix.rb +0 -234
  85. data/lib/rtm/sugar/occurrence/externalize.rb +0 -31
  86. data/spec/rtm/io/tmapix_spec.rb +0 -85
  87. data/test/base_unit_test.rb +0 -161
  88. data/test/base_unit_test_tmapi.rb +0 -165
@@ -1,31 +0,0 @@
1
- # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
- # License: Apache License, Version 2.0
3
-
4
- module RTM
5
- # Some useful or maybe not so useful stuff which I don't know how to put else.
6
- module PimpMyApi
7
- module Occurrence
8
-
9
- # Create an association out of this occurrence
10
- # Norwegian isa: Language
11
- # - name: "Norwegian"
12
- # - iso639: "no"
13
- # iso639: "no"
14
- # webpage: http://example.org
15
- # to
16
- # webpage( subject: Norwegian, occ: =http://www.example.org )
17
- def externalize
18
- a = parent.create_association
19
- a.create_role parent, RTM::PSI[:subject]
20
- a.create_role self.type, self.value # TODO what should be exactly done with value? prepend something? dependend on param?
21
- a
22
- end
23
- end
24
- def externalize!(*args)
25
- a = externalize(*args)
26
- remove
27
- a
28
- end
29
- RTM.register_extension( self )
30
- end
31
- end
@@ -1,85 +0,0 @@
1
- # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
- # License: Apache License, Version 2.0
3
-
4
- require File.dirname(__FILE__) + '/../../spec_helper'
5
-
6
- module RTM::IO::TMAPIX::TopicMap
7
-
8
- describe self do
9
- before(:each) do
10
- @tm = get_used_tm_sys_tm
11
- end
12
- after(:each) do
13
- @tm.close
14
- end
15
-
16
- describe "#from_ltm" do
17
- it "should be tested"
18
- end
19
-
20
- describe "#from_ctm" do
21
- it "should be tested"
22
- end
23
-
24
- describe "#from_jtm" do
25
- it "should be tested"
26
- end
27
-
28
- describe "#from_tmxml" do
29
- it "should be tested"
30
- end
31
-
32
- describe "#from_xtm10" do
33
- it "should be tested"
34
- end
35
-
36
- describe "#from_xtm20" do
37
- it "should be tested"
38
- end
39
-
40
- describe "#from_xtm" do
41
- it "should be tested"
42
- end
43
-
44
- describe "#from_n3" do
45
- it "should be tested"
46
- end
47
-
48
- describe "#from_rdfxml" do
49
- it "should be tested"
50
- end
51
-
52
- describe "#to_xtm20" do
53
- it "should be tested"
54
- end
55
-
56
- describe "#to_xtm10" do
57
- it "should be tested"
58
- end
59
-
60
- describe "#to_jtm" do
61
- it "should be tested"
62
- end
63
-
64
- describe "#to_ltm" do
65
- it "should be tested"
66
- end
67
-
68
- describe "#to_tmxml" do
69
- it "should be tested"
70
- end
71
-
72
- describe "#to_ctm" do
73
- it "should export a topic map to ctm" do
74
- # filling ...
75
- @tm.from_xtm20(File.dirname(__FILE__) + "/../../resources/toyTM.xtm")
76
- @tm.to_ctm(File.dirname(__FILE__) + "/../../resources/toyTM_after_spec.ctm","http://www.example.org/toyTM_after_spec")
77
- end
78
- it "should read it afterwards" do
79
- emptyTM = get_used_tm_sys.create("http://blub.org/")
80
- emptyTM.from_ctm(File.dirname(__FILE__) + "/../../resources/toyTM_after_spec.ctm")
81
- end
82
- end
83
-
84
- end
85
- end
@@ -1,161 +0,0 @@
1
- # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
- # License: Apache License, Version 2.0
3
- #
4
- # Some basic tests for the Active Reckord Backend, more to be added into the RSpecs:)
5
-
6
- $: << File.join(File.dirname(__FILE__), "/../lib")
7
-
8
- require 'rubygems'
9
- require 'test/unit'
10
- require 'rtm'
11
-
12
- class BaseTest < Test::Unit::TestCase
13
- # There are a bunch of global assertions in here so it cannot be parallelized
14
- # with other tests, that's why it is all in one. What can we do about that?
15
- def test_connect
16
- base = RTM.connect(:implementation => :activerecord)
17
- assert base, "Connection to memory backend failed"
18
- assert_equal 0, base[].size, "There should be no topic maps in a newly created environment."
19
- base_locator = "http://rtm.rubyforge.org/tests/base_test"
20
- m = base.create base_locator
21
- assert_equal 1, base[].size, "After creation of a topic map, there should be one."
22
- assert_kind_of RTM::TopicMap, m, "RTM.create should create something which includes RTM::TopicMap"
23
- assert_equal base_locator, m.base_locator, "The base_locator should be initialized properly."
24
- assert m.respond_to?(:topics), "The topic map should respond to :topics"
25
- assert m.respond_to?(:associations), "The topic map should respond to :topics"
26
- assert_equal 0, m.topics.size, "A new topic map should have no topics."
27
- assert_equal 0, m.associations.size, "A new topic map should have no associations."
28
- assert m.reifier.nil?, "A new topic map should not be reified yet."
29
- assert_equal 0, m.item_identifiers.size, "A new topic map should "
30
- # assigning a reifier
31
- m.reifier = "a_topic_which_reifies_the_topic_map"
32
- assert_equal 1, m.topics.size, "A topic should have been created to reify the topic map."
33
- assert_kind_of RTM::Topic, m.reifier, "A reifier should be a Topic."
34
- assert_equal m, m.topics.first.reified, "The only topic out there should reify the map (not generally, but here)."
35
- assert_equal m.base_locator, m.topics.first.reified.base_locator, "The only topic out there should reify the map. Check base locator."
36
- assert_equal m.__getobj__, m.topics.first.reified.__getobj__, "The only topic out there should reify the map. Look inside."
37
- t = m.create_topic
38
- assert_equal 2, m.topics.size, "There should be 2 topics after creating the second one."
39
- assert_kind_of RTM::Topic, t, "The created topic should really be one."
40
- assert_kind_of RTM::TopicMap, m
41
- assert_equal m, t.parent, "The Topic Map should be the parent of our new topic."
42
- # The next tests may look a bit unneeded, but they at least also test the properties be available and initialized somehow.
43
- assert_equal 0, t.item_identifiers.size, "New topic has no item_identifiers."
44
-
45
- assert_equal 0, t.subject_identifiers.size, "New topic has no subject_identifiers."
46
- assert_equal 0, t.subject_locators.size, "New topic has no subject_locators."
47
- assert !t.valid?, "Without item identifiers nor subject identifiers the topic must not be valid."
48
- assert_equal 0, t.names.size, "New topic has no names."
49
- assert_equal 0, t.occurrences.size, "New topic has no occurrences."
50
- assert_equal 0, t.roles_played.size, "New topic plays no roles."
51
- assert_nil t.reified, "New topic does not reify a statement."
52
- n = t.create_name "bla"
53
- assert_equal 1, t.names.size, "The topic should have one name now."
54
- assert_kind_of RTM::Name, n
55
- assert_kind_of RTM::Topic, n.parent, "You won't believe but this should be a Topic and right now it not..."
56
- # TODO the following assertion does not work - it crashes pp... but why?
57
- # assert_equal t, n.parent, "The parent of the name should be the topic on which it was created."
58
- assert_equal 0, n.item_identifiers.size, "I wonder if someone will ever read that."
59
- assert_kind_of RTM::Name, n, "The topic name shoud be a TopicName... makes sence, he?"
60
- assert_equal 0, n.variants.size, "According to Lars Heuer and Robert Barta that should always be 0, not only now."
61
- #assert_nil n.value, "We haven't set a value yet, where should it come from."
62
- assert_equal "bla", n.value
63
- #assert_nil n.type, "I am really tired of writing this stuff."
64
- assert_equal m.get(RTM::PSI[:name_type]), n.type
65
- assert_equal 0, n.scope.size, "Should I really be more serious with this stuff?"
66
- assert_nil n.reifier, "No, I guess not... who could ever stand that."
67
- v = n.create_variant "v1", ["v1-scope"]
68
- assert_equal 1, n.variants.size, "The topic should have one name now."
69
- assert_kind_of RTM::Variant, v
70
- assert_kind_of RTM::Name, v.parent, "You won't believe but this should be a Topic and right now it not..."
71
- # TODO the following assertion does not work - it crashes pp... but why?
72
- # assert_equal t, v.parent, "The parent of the name should be the topic on which it was created."
73
- assert_equal 0, v.item_identifiers.size, "I wonder if someone will ever read that."
74
- assert_kind_of RTM::Variant, v, "The variant should be a Variant... makes sence, he?"
75
- #assert_nil v.value, "We haven't set a value yet, where should it come from."
76
- assert_equal "v1", v.value
77
-
78
- assert_nil v.datatype, "No datatype set, yet."
79
-
80
- assert_equal 1, v.scope.size, "Should I really be more serious with this stuff?"
81
- assert_nil v.reifier, "No, I guess not... who could ever stand that."
82
- #assert !v.valid?
83
- o = t.create_occurrence "otype", "val"
84
- assert_equal 1, t.occurrences.size, "The topic should have one name now."
85
- assert_kind_of RTM::Occurrence, o
86
- assert_kind_of RTM::Topic, o.parent, "You won't believe but this should be a Topic and right now it not..."
87
- # TODO the following assertion does not work - it crashes pp... but why?
88
- # assert_equal t, o.parent, "The parent of the name should be the topic on which it was created."
89
- assert_equal 0, o.item_identifiers.size, "I wonder if someone will ever read that."
90
- assert_kind_of RTM::Occurrence, o, "The occurrence shoud be a Occurrence... makes sence, he?"
91
- #assert_nil o.value, "We haven't set a value yet, where should it come from."
92
- #assert_nil o.type, "I am really tired of writing this stuff."
93
- assert_nil o.datatype
94
- assert_equal 0, n.scope.size, "Should I really be more serious with this stuff?"
95
- assert_nil n.reifier, "No, I guess not... who could ever stand that."
96
- a = m.create_association "atype"
97
- #assert_nil a.type
98
- assert_equal 0, a.roles.size
99
- assert_kind_of RTM::Association, a
100
- assert_kind_of RTM::TopicMap, a.parent
101
- assert_equal m, a.parent
102
- assert_equal 0, a.scope.size
103
- #assert !a.valid?
104
- #r1 = a.create_role
105
- #assert_nil r1.type
106
- #assert_nil r1.player
107
-
108
- #assert_kind_of RTM::Role, r1
109
- #assert_kind_of RTM::Association, r1.parent
110
- #assert_equal 1, a.roles.size
111
- t.item_identifiers << "nr1"
112
- assert_equal 1, t.item_identifiers.size
113
- fii = t.item_identifiers.first
114
- assert_equal "http://rtm.rubyforge.org/tests/base_test#nr1", fii.to_s
115
- assert_kind_of RTM::Locator, fii
116
- assert_kind_of RTM::ItemIdentifier, fii #needed?
117
- # TODO: invalidate cache/reload value somehow
118
- #assert_equal 1, m.item_identifiers.size, "If you see this, it is probably because TopicMap#item_identifiers.size is cached which is wrong in this case."
119
-
120
- t.subject_identifiers << "si1"
121
- fsi = t.subject_identifiers.first
122
- assert_equal "si1", fsi.to_s
123
- assert_kind_of RTM::Locator, fsi
124
- assert_kind_of RTM::SubjectIdentifier, fsi #needed?
125
-
126
- t.subject_locators << "sl1"
127
- fsl = t.subject_locators.first
128
- assert_equal "sl1", fsl.to_s
129
- assert_kind_of RTM::Locator, fsl
130
- assert_kind_of RTM::SubjectLocator, fsl #needed?
131
-
132
- # to be in associations_test later:
133
- tm = base.create "urn:/associations_test"
134
- a1 = tm.create_association "urn:/assoc_type_with_absolute_uri"
135
- assert_not_nil a1.type
136
- assert_equal a1.type, tm.get("urn:/assoc_type_with_absolute_uri")
137
- a2 = tm.create_association "urn:/assoc_type_with_absolute_uri_using_hash"
138
- assert_not_nil a2.type
139
- assert_equal a2.type, tm.get("urn:/assoc_type_with_absolute_uri_using_hash")
140
-
141
- a3 = tm.create_association "relative_type"
142
- assert_not_nil a3.type
143
- assert_equal a3.type, tm.get("relative_type")
144
-
145
- end
146
- def test_sugar_hash_access
147
- base = RTM.connect(:implementation => :activerecord)
148
- tm = base.create "a:b"
149
- bla = tm.get!("bla")
150
- bla["-name"] = "test"
151
- n = bla["-name"].first
152
- assert_equal "test", n.value
153
- blau = tm.get!("blau")
154
- blau["hex"] = "#0000ff"
155
- assert_equal "#0000ff", blau["hex"].first.value
156
- blau["hex @short"] = "#00f"
157
- assert_equal "#0000ff", blau["hex"].first.value
158
- assert_equal "#00f", blau["hex @short"].first.value
159
- end
160
-
161
- end
@@ -1,165 +0,0 @@
1
- # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
- # License: Apache License, Version 2.0
3
- #
4
- # Some basic tests for the Active Reckord Backend, applied to a TMAPI backend
5
- # Err
6
- # first is not supported for Java::GnuTrove::THashSet
7
- # tm.reifier not implemented
8
-
9
- $: << File.join(File.dirname(__FILE__), "/../lib")
10
-
11
- require 'rubygems'
12
- require 'test/unit'
13
- require 'rtm'
14
-
15
- class BaseTest < Test::Unit::TestCase
16
- # There are a bunch of global assertions in here so it cannot be parallelized
17
- # with other tests, that's why it is all in one. What can we do about that?
18
- def test_connect
19
- base = RTM.connect
20
- assert base, "Connection to memory backend failed"
21
- assert_equal 0, base[].size, "There should be no topic maps in a newly created environment."
22
- base_locator = "http://rtm.rubyforge.org/tests/base_test"
23
- m = base.create base_locator
24
- assert_equal 1, base[].size, "After creation of a topic map, there should be one."
25
- assert_kind_of RTM::TopicMap, m, "RTM.create should create something which includes RTM::TopicMap"
26
- assert_equal base_locator, m.base_locator, "The base_locator should be initialized properly."
27
- assert m.respond_to?(:topics), "The topic map should respond to :topics"
28
- assert m.respond_to?(:associations), "The topic map should respond to :topics"
29
- assert_equal 0, m.topics.size, "A new topic map should have no topics."
30
- assert_equal 0, m.associations.size, "A new topic map should have no associations."
31
- assert m.reifier.nil?, "A new topic map should not be reified yet."
32
- assert_equal 0, m.item_identifiers.size, "A new topic map should "
33
- # assigning a reifier
34
- m.reifier = "a_topic_which_reifies_the_topic_map"
35
- assert_equal 1, m.topics.size, "A topic should have been created to reify the topic map."
36
- assert_kind_of RTM::Topic, m.reifier, "A reifier should be a Topic."
37
- assert_equal m, m.topics.first.reified, "The only topic out there should reify the map (not generally, but here)."
38
- assert_equal m.base_locator, m.topics.first.reified.base_locator, "The only topic out there should reify the map. Check base locator."
39
- assert_equal m.__getobj__, m.topics.first.reified.__getobj__, "The only topic out there should reify the map. Look inside."
40
- t = m.create_topic
41
- assert_equal 2, m.topics.size, "There should be 2 topics after creating the second one."
42
- assert_kind_of RTM::Topic, t, "The created topic should really be one."
43
- assert_kind_of RTM::TopicMap, m
44
- assert_equal m, t.parent, "The Topic Map should be the parent of our new topic."
45
- # The next tests may look a bit unneeded, but they at least also test the properties be available and initialized somehow.
46
- assert_equal 0, t.item_identifiers.size, "New topic has no item_identifiers."
47
-
48
- assert_equal 0, t.subject_identifiers.size, "New topic has no subject_identifiers."
49
- assert_equal 0, t.subject_locators.size, "New topic has no subject_locators."
50
- assert !t.valid?, "Without item identifiers nor subject identifiers the topic must not be valid."
51
- assert_equal 0, t.names.size, "New topic has no names."
52
- assert_equal 0, t.occurrences.size, "New topic has no occurrences."
53
- assert_equal 0, t.roles_played.size, "New topic plays no roles."
54
- assert_nil t.reified, "New topic does not reify a statement."
55
- n = t.create_name
56
- assert_equal 1, t.names.size, "The topic should have one name now."
57
- assert_kind_of RTM::Name, n
58
- assert_kind_of RTM::Topic, n.parent, "You won't believe but this should be a Topic and right now it not..."
59
- # TODO the following assertion does not work - it crashes pp... but why?
60
- # assert_equal t, n.parent, "The parent of the name should be the topic on which it was created."
61
- assert_equal 0, n.item_identifiers.size, "I wonder if someone will ever read that."
62
- assert_kind_of RTM::Name, n, "The topic name shoud be a TopicName... makes sence, he?"
63
- assert_equal 0, n.variants.size, "According to Lars Heuer and Robert Barta that should always be 0, not only now."
64
- assert_nil n.value, "We haven't set a value yet, where should it come from."
65
- assert_nil n.type, "I am really tired of writing this stuff."
66
- assert_equal 0, n.scope.size, "Should I really be more serious with this stuff?"
67
- assert_nil n.reifier, "No, I guess not... who could ever stand that."
68
- v = n.create_variant
69
- assert_equal 1, n.variants.size, "The topic should have one name now."
70
- assert_kind_of RTM::Variant, v
71
- assert_kind_of RTM::Name, v.parent, "You won't believe but this should be a Topic and right now it not..."
72
- # TODO the following assertion does not work - it crashes pp... but why?
73
- # assert_equal t, v.parent, "The parent of the name should be the topic on which it was created."
74
- assert_equal 0, v.item_identifiers.size, "I wonder if someone will ever read that."
75
- assert_kind_of RTM::Variant, v, "The variant should be a Variant... makes sence, he?"
76
- assert_nil v.value, "We haven't set a value yet, where should it come from."
77
-
78
- assert_nil v.datatype, "No datatype set, yet."
79
-
80
- assert_equal 0, v.scope.size, "Should I really be more serious with this stuff?"
81
- assert_nil v.reifier, "No, I guess not... who could ever stand that."
82
- assert !v.valid?
83
- o = t.create_occurrence
84
- assert_equal 1, t.occurrences.size, "The topic should have one name now."
85
- assert_kind_of RTM::Occurrence, o
86
- assert_kind_of RTM::Topic, o.parent, "You won't believe but this should be a Topic and right now it not..."
87
- # TODO the following assertion does not work - it crashes pp... but why?
88
- # assert_equal t, o.parent, "The parent of the name should be the topic on which it was created."
89
- assert_equal 0, o.item_identifiers.size, "I wonder if someone will ever read that."
90
- assert_kind_of RTM::Occurrence, o, "The occurrence shoud be a Occurrence... makes sence, he?"
91
- assert_nil o.value, "We haven't set a value yet, where should it come from."
92
- assert_nil o.type, "I am really tired of writing this stuff."
93
- assert_nil o.datatype
94
- assert_equal 0, n.scope.size, "Should I really be more serious with this stuff?"
95
- assert_nil n.reifier, "No, I guess not... who could ever stand that."
96
- a = m.create_association
97
- assert_nil a.type
98
- assert_equal 0, a.roles.size
99
- assert_kind_of RTM::Association, a
100
- assert_kind_of RTM::TopicMap, a.parent
101
- assert_equal m, a.parent
102
- assert_equal 0, a.scope.size
103
- assert !a.valid?
104
- r1 = a.create_role
105
- assert_nil r1.type
106
- assert_nil r1.player
107
-
108
- assert_kind_of RTM::Role, r1
109
- assert_kind_of RTM::Association, r1.parent
110
- assert_equal 1, a.roles.size
111
- t.item_identifiers << "nr1"
112
- assert_equal 1, t.item_identifiers.size
113
- fii = t.item_identifiers.first
114
- assert_equal "http://rtm.rubyforge.org/tests/base_test#nr1", fii.to_s
115
- assert_kind_of RTM::Locator, fii
116
- assert_kind_of RTM::ItemIdentifier, fii #needed?
117
- # TODO: invalidate cache/reload value somehow
118
- # assert_equal 1, m.item_identifiers.size, "If you see this, it is probably because TopicMap#item_identifiers.size is cached which is wrong in this case."
119
-
120
- t.subject_identifiers << "si1"
121
- fsi = t.subject_identifiers.first
122
- assert_equal "si1", fsi.to_s
123
- assert_kind_of RTM::Locator, fsi
124
- assert_kind_of RTM::SubjectIdentifier, fsi #needed?
125
-
126
- t.subject_locators << "sl1"
127
- fsl = t.subject_locators.first
128
- assert_equal "sl1", fsl.to_s
129
- assert_kind_of RTM::Locator, fsl
130
- assert_kind_of RTM::SubjectLocator, fsl #needed?
131
-
132
- # to be in associations_test later:
133
- tm = base.create "urn:/associations_test"
134
- a1 = tm.create_association "urn:/assoc_type_with_absolute_uri"
135
- assert_not_nil a1.type
136
- assert_equal a1.type, tm.get("urn:/assoc_type_with_absolute_uri")
137
- a2 = tm.create_association :type => "urn:/assoc_type_with_absolute_uri_using_hash"
138
- assert_not_nil a2.type
139
- assert_equal a2.type, tm.get("urn:/assoc_type_with_absolute_uri_using_hash")
140
-
141
- a3 = tm.create_association "relative_type"
142
- assert_not_nil a3.type
143
- assert_equal a3.type, tm.get("relative_type")
144
-
145
- end
146
- def test_sugar_hash_access
147
- base = RTM.connect
148
- tm = base.create "a:b"
149
- bla = tm.get!("bla")
150
- bla["-name"] = "test"
151
- n = bla["-name"].first
152
- assert_equal "test", n.value
153
- end
154
- def test_names
155
- base = RTM.connect
156
- tm = base.create "a:c"
157
-
158
- # Create 2 more names, this time of type "foo".
159
- t4 = tm.create_topic
160
- n2 = t4.create_name "http://foo.foo/foo", "bar", []
161
- n2 = t4.create_name "http://foo.foo/foo", "bar", ["http://baz.baz/baz"]
162
- assert_equal 2, t4.names.size, "The topic should have 2 names now."
163
- end
164
-
165
- end