| 1 |
require 'test/unit' |
| 2 |
require 'rdf/redland' |
| 3 |
require 'rdf/redland/constants' |
| 4 |
require 'rdf/redland/schemas/rdfs' |
| 5 |
|
| 6 |
class TestRDFResource < Test::Unit::TestCase |
| 7 |
include Redland::RDFS |
| 8 |
|
| 9 |
def setup |
| 10 |
@rdfsns = Namespace.new("http://www.w3.org/2000/01/rdf-schema#") |
| 11 |
end |
| 12 |
|
| 13 |
def test_comment() |
| 14 |
model = Model.new() |
| 15 |
resource = model.create_resource("http://www.faa.gov/DominicSisneros") |
| 16 |
resource.extend RDFS |
| 17 |
resource.comment = "This is a new comment" |
| 18 |
assert_equal("This is a new comment",resource.get_property(RDFS_COMMENT).value) |
| 19 |
assert_equal("This is a new comment",resource.comment) |
| 20 |
resource.comment ="change comment" |
| 21 |
assert_equal("change comment",resource.model.object(resource,RDFS_COMMENT).value) |
| 22 |
end |
| 23 |
|
| 24 |
def test_label() |
| 25 |
model = Model.new() |
| 26 |
resource = model.create_resource("http://class") |
| 27 |
resource.extend RDFS |
| 28 |
resource.add_label('First label') |
| 29 |
assert_equal('First label',resource.label.value) |
| 30 |
resource.add_label('A new label') |
| 31 |
assert_equal('A new label', resource.label.value) |
| 32 |
assert_equal(1, resource.get_properties(RDFS_LABEL).size) |
| 33 |
resource.add_label('A new label','en') |
| 34 |
assert_equal(2, resource.get_properties(RDFS_LABEL).size) |
| 35 |
end |
| 36 |
|
| 37 |
def test_get_label_language() |
| 38 |
model = Model.new() |
| 39 |
resource = model.create_resource('http://class') |
| 40 |
resource.extend RDFS |
| 41 |
resource.add_label('Hello','en') |
| 42 |
resource.add_label('Hola','sp') |
| 43 |
assert_equal('Hello',resource.label('en').value) |
| 44 |
assert_equal('Hola',resource.label('sp').value) |
| 45 |
assert_nil(resource.label('fr')) |
| 46 |
end |
| 47 |
|
| 48 |
def test_type |
| 49 |
model = Model.new() |
| 50 |
resource = model.create_resource('http://class') |
| 51 |
resource.extend RDFS |
| 52 |
resource.type = Resource.new('http://faa.gov/#Project') |
| 53 |
assert(resource.type?( Resource.new('http://faa.gov/#Project') )) |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
end |
| 58 |
|
| 59 |
end |
| 60 |
|