Search in sources :

Example 1 with MondrianException

use of mondrian.olap.MondrianException in project mondrian by pentaho.

the class CodeSetTest method testSucces_CodeSetContainsOnlyCodeForPostgresDialect.

/**
 * ISSUE MONDRIAN-2335 If SqlQuery.CodeSet contains only sql code
 * for dialect="postgres", this code should be chosen.
 * No error should be thrown
 *
 * @throws Exception
 */
public void testSucces_CodeSetContainsOnlyCodeForPostgresDialect() throws Exception {
    PostgreSqlDialect postgreSqlDialect = new PostgreSqlDialect(mockConnection(POSTGRESQL_PRODUCT_NAME, POSTGRESQL_PRODUCT_VERSION));
    codeSet = new SqlQuery.CodeSet();
    codeSet.put(POSTGRES_DIALECT, SQL_CODE_FOR_POSTGRES_DIALECT);
    try {
        String chooseQuery = codeSet.chooseQuery(postgreSqlDialect);
        assertEquals(SQL_CODE_FOR_POSTGRES_DIALECT, chooseQuery);
    } catch (MondrianException mExc) {
        fail("Not expected any MondrianException but it occured: " + mExc.getLocalizedMessage());
    }
}
Also used : PostgreSqlDialect(mondrian.spi.impl.PostgreSqlDialect) MondrianException(mondrian.olap.MondrianException)

Example 2 with MondrianException

use of mondrian.olap.MondrianException in project mondrian by pentaho.

the class CodeSetTest method testMondrianExceptionThrown_WhenCodeSetContainsNOCodeForDialect.

/**
 * If SqlQuery.CodeSet contains no sql code with specified dialect at all
 * (even 'generic'), the MondrianException should be thrown.
 *
 * @throws Exception
 */
public void testMondrianExceptionThrown_WhenCodeSetContainsNOCodeForDialect() throws Exception {
    PostgreSqlDialect postgreSqlDialect = new PostgreSqlDialect(mockConnection(POSTGRESQL_PRODUCT_NAME, POSTGRESQL_PRODUCT_VERSION));
    codeSet = new SqlQuery.CodeSet();
    try {
        String chooseQuery = codeSet.chooseQuery(postgreSqlDialect);
        fail("Expected MondrianException but not occured");
        assertEquals(SQL_CODE_FOR_GENERIC_DIALECT, chooseQuery);
    } catch (MondrianException mExc) {
        assertEquals(MONDRIAN_ERROR_NO_GENERIC_VARIANT, mExc.getLocalizedMessage());
    }
}
Also used : PostgreSqlDialect(mondrian.spi.impl.PostgreSqlDialect) MondrianException(mondrian.olap.MondrianException)

Example 3 with MondrianException

use of mondrian.olap.MondrianException in project mondrian by pentaho.

the class CodeSetTest method testSucces_CodeSetContainsCodeForBothPostgresAndGenericDialects.

/**
 * ISSUE MONDRIAN-2335 If SqlQuery.CodeSet contains sql code
 * for both dialect="postgres" and dialect="generic",
 * the code for dialect="postgres"should be chosen. No error should be thrown
 *
 * @throws Exception
 */
public void testSucces_CodeSetContainsCodeForBothPostgresAndGenericDialects() throws Exception {
    PostgreSqlDialect postgreSqlDialect = new PostgreSqlDialect(mockConnection(POSTGRESQL_PRODUCT_NAME, POSTGRESQL_PRODUCT_VERSION));
    codeSet = new SqlQuery.CodeSet();
    codeSet.put(POSTGRES_DIALECT, SQL_CODE_FOR_POSTGRES_DIALECT);
    codeSet.put(GENERIC_DIALECT, SQL_CODE_FOR_GENERIC_DIALECT);
    try {
        String chooseQuery = codeSet.chooseQuery(postgreSqlDialect);
        assertEquals(SQL_CODE_FOR_POSTGRES_DIALECT, chooseQuery);
    } catch (MondrianException mExc) {
        fail("Not expected any MondrianException but it occured: " + mExc.getLocalizedMessage());
    }
}
Also used : PostgreSqlDialect(mondrian.spi.impl.PostgreSqlDialect) MondrianException(mondrian.olap.MondrianException)

Example 4 with MondrianException

use of mondrian.olap.MondrianException in project mondrian by pentaho.

the class CodeSetTest method testSucces_CodeSetContainsOnlyCodeForGenericlDialect.

/**
 * If SqlQuery.CodeSet contains sql code for dialect="generic" ,
 * the code for dialect="generic" should be chosen. No error should be thrown
 *
 * @throws Exception
 */
public void testSucces_CodeSetContainsOnlyCodeForGenericlDialect() throws Exception {
    PostgreSqlDialect postgreSqlDialect = new PostgreSqlDialect(mockConnection(POSTGRESQL_PRODUCT_NAME, POSTGRESQL_PRODUCT_VERSION));
    codeSet = new SqlQuery.CodeSet();
    codeSet.put(GENERIC_DIALECT, SQL_CODE_FOR_GENERIC_DIALECT);
    try {
        String chooseQuery = codeSet.chooseQuery(postgreSqlDialect);
        assertEquals(SQL_CODE_FOR_GENERIC_DIALECT, chooseQuery);
    } catch (MondrianException mExc) {
        fail("Not expected any MondrianException but it occured: " + mExc.getLocalizedMessage());
    }
}
Also used : PostgreSqlDialect(mondrian.spi.impl.PostgreSqlDialect) MondrianException(mondrian.olap.MondrianException)

Example 5 with MondrianException

use of mondrian.olap.MondrianException in project mondrian by pentaho.

the class SchemaVersionTest method testSchema4withVersion.

public void testSchema4withVersion() {
    TestContext testContext = TestContext.instance().withSchema(SCHEMA_4_HEADER + SCHEMA_4_BODY);
    Util.PropertyList connectInfo = testContext.getConnectionProperties();
    try {
        Connection conn = DriverManager.getConnection(connectInfo, null);
        conn.close();
        Assert.fail("No exception thrown for version 4 schema.");
    } catch (MondrianException e) {
        assertTrue(e.getMessage().contains("Schema version"));
    }
}
Also used : Connection(mondrian.olap.Connection) Util(mondrian.olap.Util) MondrianException(mondrian.olap.MondrianException)

Aggregations

MondrianException (mondrian.olap.MondrianException)23 Util (mondrian.olap.Util)5 PostgreSqlDialect (mondrian.spi.impl.PostgreSqlDialect)5 Connection (mondrian.olap.Connection)4 RolapConnection (mondrian.rolap.RolapConnection)4 SQLException (java.sql.SQLException)3 Test (org.junit.Test)3 IMondrianCatalogService (org.pentaho.platform.plugin.action.mondrian.catalog.IMondrianCatalogService)3 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 ArrayList (java.util.ArrayList)2 Properties (java.util.Properties)2 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)2 Query (mondrian.olap.Query)2 AbortException (mondrian.rolap.agg.SegmentCacheManager.AbortException)2 SegmentCacheIndex (mondrian.rolap.cache.SegmentCacheIndex)2 Locus (mondrian.server.Locus)2 FileSystemException (org.apache.commons.vfs2.FileSystemException)2 XOMException (org.eigenbase.xom.XOMException)2