Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: a400fc8d44
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 72 lines (57 sloc) 2.007 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
require "spec_helper"

describe "Connection" do

  describe "create" do
    before(:each) do
      @olap = Mondrian::OLAP::Connection.new(CONNECTION_PARAMS_WITH_CATALOG)
    end

    it "should not be connected before connection" do
      @olap.should_not be_connected
    end

    it "should be successful" do
      @olap.connect.should be_true
    end

  end

  describe "create with catalog content" do
    before(:all) do
      @schema_xml = File.read(CATALOG_FILE)
    end
    it "should be successful" do
      @olap = Mondrian::OLAP::Connection.new(CONNECTION_PARAMS.merge(
        :catalog_content => @schema_xml
      ))
      @olap.connect.should be_true
    end

  end

  describe "properties" do
    before(:all) do
      @olap = Mondrian::OLAP::Connection.create(CONNECTION_PARAMS_WITH_CATALOG)
    end

    it "should be connected" do
      @olap.should be_connected
    end

    # to check that correct database dialect is loaded by ServiceDiscovery detected class loader
    it "should use corresponding Mondrian dialect" do
      # read private "schema" field
      schema_field = @olap.raw_schema.getClass.getDeclaredField("schema")
      schema_field.setAccessible(true)
      private_schema = schema_field.get(@olap.raw_schema)
      private_schema.getDialect.java_class.name.should == case MONDRIAN_DRIVER
        when 'mysql' then 'mondrian.spi.impl.MySqlDialect'
        when 'postgresql' then 'mondrian.spi.impl.PostgreSqlDialect'
        when 'oracle' then 'mondrian.spi.impl.OracleDialect'
        when 'luciddb' then 'mondrian.spi.impl.LucidDbDialect'
        when 'mssql' then 'mondrian.spi.impl.MicrosoftSqlServerDialect'
        when 'sqlserver' then 'mondrian.spi.impl.MicrosoftSqlServerDialect'
        end
    end

  end

  describe "close" do
    before(:all) do
      @olap = Mondrian::OLAP::Connection.create(CONNECTION_PARAMS_WITH_CATALOG)
    end

    it "should not be connected after close" do
      @olap.close
      @olap.should_not be_connected
    end

  end

end
Something went wrong with that request. Please try again.