# Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig. # License: Apache License, Version 2.0 require File.dirname(__FILE__) + '/../spec_helper' module RTM::TopicMap describe self do before(:each) do @tm = get_used_tm_sys_tm @tm.should be_a_kind_of RTM::TopicMap end after(:each) do if implementation_for_spec == :majortom_db @tm.remove else @tm.close end end describe "#revision_index" do it "should give an open revision index for a majortom map" do index = @tm.revision_index index.should be_a_kind_of Java::DeTopicmapslabMajortomModelIndex::IRevisionIndex index.should be_open end end describe "#supertype_subtype_index" do it "should give an open supertype subtype index for a majortom map" do index = @tm.supertype_subtype_index index.should be_a_kind_of Java::DeTopicmapslabMajortomModelIndex::ISupertypeSubtypeIndex index.should be_open end end describe "#transitive_type_instance_index" do it "should give an open transitive type instance index for a majortom map" do index = @tm.transitive_type_instance_index index.should be_a_kind_of Java::DeTopicmapslabMajortomModelIndex::ITransitiveTypeInstanceIndex index.should be_open end end describe "#remove_duplicates" do it "should not raise an error" do store = @tm.store store.enable_revision_management(false) store.is_revision_management_enabled.should_not be_true if implementation_for_spec == :majortom_db @tm.clear end @tm.topics.should be_empty begin @tm.from_xtm(File.dirname(__FILE__) + "/../../../rtm/spec/resources/toyTM.xtm") rescue Exception => e print_stack_trace(e) raise(e.message) end @tm.topics.should_not be_empty @tm.remove_duplicates store.enable_revision_management(true) store.is_revision_management_enabled.should be_true end end describe "#store" do it "should give back the store" do store = @tm.store store.should_not be_nil store.should be_a_kind_of Java::DeTopicmapslabMajortomModelStore::ITopicMapStore if implementation_for_spec == :majortom_db store.should be_a_kind_of Java::DeTopicmapslabMajortomDatabaseStore::JdbcTopicMapStore elsif implementation_for_spec == :majortom store.should be_a_kind_of Java::DeTopicmapslabMajortomInmemoryStore::InMemoryTopicMapStore end end end describe "#clear" do it "should disable the history, remove the history and clear the topic map" do @tm.topics.should be_empty revision_index = @tm.revision_index revision_index.should_not be_nil first_revision = revision_index.first_revision first_revision.should be_nil store = @tm.store store.enable_revision_management(false) store.is_revision_management_enabled.should_not be_true begin @tm.from_xtm(File.dirname(__FILE__) + "/../../../rtm/spec/resources/toyTM.xtm") rescue Exception => e print_stack_trace(e) raise(e.message) end store.enable_revision_management(true) store.is_revision_management_enabled.should be_true first_revision = revision_index.first_revision first_revision.should be_nil @tm.get!("Topic") first_revision = revision_index.first_revision first_revision.should_not be_nil @tm.clear first_revision = revision_index.first_revision first_revision.should be_nil end end it "should not create type instance associations cause it is really slow" do @tm.clear @tm.should have(0).associations @tm.get!("topic_a").add_type("topic_b") @tm.should have(0).associations end end # of describe self end