test/xml_test.rb in iq_rdf-0.0.14 vs test/xml_test.rb in iq_rdf-0.0.15

- old
+ new

@@ -1,6 +1,6 @@ -# Copyright 2011 Till Schulte-Coerne (innoQ Deutschland GmbH) +# Copyright 2011 innoQ Deutschland GmbH # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # @@ -10,12 +10,14 @@ # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -require 'test/test_helper' +$LOAD_PATH << File.dirname(__FILE__) +require 'test_helper' + class XmlTest < Test::Unit::TestCase def test_basic_xml_output document = IqRdf::Document.new('http://www.test.de/', :lang => :de) document.namespaces :foaf => 'http://xmlns.com/foaf/0.1/' @@ -44,19 +46,19 @@ assert_raise RuntimeError do IqRdf::build_full_uri_subject("bla") end document << IqRdf::build_full_uri_subject(URI.parse('http://www.xyz.de/#test'), IqRdf::build_uri('SomeType')) do |t| - t.test("testvalue") + t.sometest("testvalue") end assert_equal(<<rdf, document.to_xml) <?xml version="1.0" encoding="UTF-8"?> <rdf:RDF xmlns="http://www.test.de/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <rdf:Description rdf:about="http://www.xyz.de/#test"> <rdf:type rdf:resource="http://www.test.de/SomeType"/> - <test>testvalue</test> + <sometest>testvalue</sometest> </rdf:Description> </rdf:RDF> rdf end @@ -197,7 +199,37 @@ <some_literal xml:lang="de">text</some_literal> </rdf:Description> </rdf:RDF> rdf end + + def test_blank_nodes + document = IqRdf::Document.new('http://www.test.de/') + + document << IqRdf::testnode.test32 do |blank_node| # Blank nodes # :testnode :test32 [ + blank_node.title("dies ist ein test") # :title "dies ist ein test"; + blank_node.build_predicate(:test, "Another test") # :test "Another test"; + blank_node.sub do |subnode| # sub [ + subnode.title("blubb") # title "blubb" + end # ] + end # ] + assert_equal(<<rdf, document.to_xml) +<?xml version=\"1.0\" encoding=\"UTF-8\"?> +<rdf:RDF xmlns=\"http://www.test.de/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"> + <rdf:Description rdf:about=\"http://www.test.de/testnode\"> + <test32> + <rdf:Description> + <title>dies ist ein test</title> + <test>Another test</test> + <sub> + <rdf:Description> + <title>blubb</title> + </rdf:Description> + </sub> + </rdf:Description> + </test32> + </rdf:Description> +</rdf:RDF> +rdf + end end \ No newline at end of file