# Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig. # License: Apache License, Version 2.0 require File.dirname(__FILE__) + '/../../spec_helper' module RTM::IO::TmapiXTo::TopicMap describe self do before(:each) do @tm = get_used_tm_sys_tm end after(:each) do @tm.close end describe "#to_xtm20" do before(:each) do @tm.from_ctm(File.dirname(__FILE__) + "/../../resources/toyTM.ctm") end it "should serialize a topic map to String" do @tm.to_xtm20.should be_a_kind_of String end it "should serialize a topic map to a file" do @tm.to_xtm20(File.dirname(__FILE__) + "/../../resources/toyTM_after_spec.xtm20").should be_true end it "should serialize a topic map to a file given a base iri" do @tm.to_xtm20(File.dirname(__FILE__) + "/../../resources/toyTM_after_spec.xtm20", "http://www.example.org/testtm").should be_true end it "should serialize a topic map to a Java::JavaIo::Stream" do @tm.to_xtm20(Java::JavaIo::ByteArrayOutputStream.new).should be_true end it "should be the case that the xtm20 writer does not respond to :setProperty" do Java::OrgTmapixIo::XTM20TopicMapWriter.new(Java::JavaIo::ByteArrayOutputStream.new,"http://www.example.org/testtm").should_not respond_to(:setProperty) end it "should provide an alias for to_xtm" do @tm.method(:to_xtm).should == @tm.method(:to_xtm20) end it "should provide an alias for to_xtm2" do @tm.method(:to_xtm2).should == @tm.method(:to_xtm20) end end describe "#to_xtm10" do before(:each) do @tm.from_ctm(File.dirname(__FILE__) + "/../../resources/toyTM.ctm") end it "should serialize a topic map to String" do @tm.to_xtm10.should be_a_kind_of String end it "should serialize a topic map to a file" do @tm.to_xtm10(File.dirname(__FILE__) + "/../../resources/toyTM_after_spec.xtm10").should be_true end it "should serialize a topic map to a file given a base iri" do @tm.to_xtm10(File.dirname(__FILE__) + "/../../resources/toyTM_after_spec.xtm10", "http://www.example.org/testtm").should be_true end it "should serialize a topic map to a Java::JavaIo::Stream" do @tm.to_xtm10(Java::JavaIo::ByteArrayOutputStream.new).should be_true end it "should be the case that the xtm10 writer does not respond to :setProperty" do Java::OrgTmapixIo::XTM10TopicMapWriter.new(Java::JavaIo::ByteArrayOutputStream.new,"http://www.example.org/testtm").should_not respond_to(:setProperty) end it "should provide an alias for to_xtm1" do @tm.method(:to_xtm1).should == @tm.method(:to_xtm10) end end describe "#to_jtm" do before(:each) do @tm.from_ctm(File.dirname(__FILE__) + "/../../resources/toyTM.ctm") end it "should serialize a topic map to String" do @tm.to_jtm.should be_a_kind_of String end it "should serialize a topic map to a file" do @tm.to_jtm(File.dirname(__FILE__) + "/../../resources/toyTM_after_spec.jtm").should be_true end it "should serialize a topic map to a file given a base iri" do @tm.to_jtm(File.dirname(__FILE__) + "/../../resources/toyTM_after_spec.jtm", "http://www.example.org/testtm").should be_true end it "should serialize a topic map to a Java::JavaIo::Stream" do @tm.to_jtm(Java::JavaIo::ByteArrayOutputStream.new).should be_true end it "should be the case that the jtm writer does not respond to :setProperty" do Java::OrgTmapixIo::JTMTopicMapWriter.new(Java::JavaIo::ByteArrayOutputStream.new,"http://www.example.org/testtm").should_not respond_to(:setProperty) end it "should provide an alias for to_json" do @tm.method(:to_json).should == @tm.method(:to_jtm) end end describe "#to_ltm" do before(:each) do @tm.from_ctm(File.dirname(__FILE__) + "/../../resources/toyTM.ctm") end it "should serialize a topic map to String" do @tm.to_ltm.should be_a_kind_of String end it "should serialize a topic map to a file" do @tm.to_ltm(File.dirname(__FILE__) + "/../../resources/toyTM_after_spec.ltm").should be_true end it "should serialize a topic map to a file given a base iri" do @tm.to_ltm(File.dirname(__FILE__) + "/../../resources/toyTM_after_spec.ltm", "http://www.example.org/testtm").should be_true end it "should serialize a topic map to a Java::JavaIo::Stream" do @tm.to_ltm(Java::JavaIo::ByteArrayOutputStream.new).should be_true end it "should be the case that the ltm writer does not respond to :setProperty" do Java::OrgTmapixIo::LTMTopicMapWriter.new(Java::JavaIo::ByteArrayOutputStream.new,"http://www.example.org/testtm").should_not respond_to(:setProperty) end end # describe "#to_tmxml" do # before(:each) do # @tm.from_tmxml(File.dirname(__FILE__) + "/../../resources/toyTM.tmxml") # end # it "should serialize a topic map to String" do # @tm.to_tmxml.should be_a_kind_of String # end # it "should serialize a topic map to a file" do # @tm.to_tmxml(File.dirname(__FILE__) + "/../../resources/toyTM_after_spec.tmxml").should be_true # end # it "should serialize a topic map to a file given a base iri" do # @tm.to_tmxml(File.dirname(__FILE__) + "/../../resources/toyTM_after_spec.tmxml", "http://www.example.org/testtm").should be_true # end # it "should serialize a topic map to a Java::JavaIo::Stream" do # @tm.to_tmxml(Java::JavaIo::ByteArrayOutputStream.new).should be_true # end # it "should be the case that the tmxml writer does not respond to :setProperty" do # Java::OrgTmapixIo::TMXMLTopicMapWriter.new(Java::JavaIo::ByteArrayOutputStream.new,"http://www.example.org/testtm").should_not respond_to(:setProperty) # end # end describe "#to_ctm" do before(:each) do @tm.from_xtm(File.dirname(__FILE__) + "/../../resources/toyTM.xtm") end it "should serialize a topic map to String" do @tm.to_ctm.should be_a_kind_of String end it "should serialize a topic map to a file" do @tm.to_ctm(File.dirname(__FILE__) + "/../../resources/toyTM_after_spec.ctm").should be_true end it "should serialize a topic map to a file given a base iri" do @tm.to_ctm(File.dirname(__FILE__) + "/../../resources/toyTM_after_spec.ctm", "http://www.example.org/testtm").should be_true end it "should serialize a topic map to a Java::JavaIo::Stream" do @tm.to_ctm(Java::JavaIo::ByteArrayOutputStream.new).should be_true end it "should be the case that the xtm10 writer does respond to :setProperty" do Java::DeTopicmapslabCtmWriterCore::CTMTopicMapWriter.new(Java::JavaIo::ByteArrayOutputStream.new,"http://www.example.org/testtm").should respond_to(:setProperty) end it "should read it afterwards" do emptyTM = get_used_tm_sys.create("http://blub.org/") emptyTM.from_ctm(File.dirname(__FILE__) + "/../../resources/toyTM_after_spec.ctm") end end end end