Search in sources :

Example 96 with RunnableX

use of org.apache.ignite.testframework.GridTestUtils.RunnableX in project gridgain by gridgain.

the class DynamicIndexAbstractBasicSelfTest method checkCreate.

/**
 * Check normal create operation.
 *
 * @param mode Mode.
 * @param atomicityMode Atomicity mode.
 * @param near Near flag.
 * @throws Exception If failed.
 */
private void checkCreate(CacheMode mode, CacheAtomicityMode atomicityMode, boolean near) throws Exception {
    initialize(mode, atomicityMode, near);
    final QueryIndex idx = index(IDX_NAME_1, field(FIELD_NAME_1_ESCAPED));
    dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx, false, 0);
    assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1, QueryIndex.DFLT_INLINE_SIZE, field(FIELD_NAME_1_ESCAPED));
    assertIgniteSqlException(new RunnableX() {

        @Override
        public void runx() throws Exception {
            dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx, false, 0);
        }
    }, IgniteQueryErrorCode.INDEX_ALREADY_EXISTS);
    dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx, true, 0);
    assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1, QueryIndex.DFLT_INLINE_SIZE, field(FIELD_NAME_1_ESCAPED));
    assertSimpleIndexOperations(SQL_SIMPLE_FIELD_1);
    assertIndexUsed(IDX_NAME_1, SQL_SIMPLE_FIELD_1, SQL_ARG_1);
}
Also used : RunnableX(org.apache.ignite.testframework.GridTestUtils.RunnableX) QueryIndex(org.apache.ignite.cache.QueryIndex) CacheException(javax.cache.CacheException) IgniteException(org.apache.ignite.IgniteException) IgniteSQLException(org.apache.ignite.internal.processors.query.IgniteSQLException) SchemaOperationException(org.apache.ignite.internal.processors.query.schema.SchemaOperationException)

Example 97 with RunnableX

use of org.apache.ignite.testframework.GridTestUtils.RunnableX in project gridgain by gridgain.

the class DynamicIndexAbstractBasicSelfTest method checkNoIndexIsCreatedForInlineSize.

/**
 * Verifies that no index is created and an exception is thrown.
 *
 * @param inlineSize Inline size value in the CREATE INDEX statement.
 * @param igniteQryErrorCode Expected error code in the thrown exception.
 * @throws Exception If failed for any other reason than the expected exception.
 */
private void checkNoIndexIsCreatedForInlineSize(final int inlineSize, int igniteQryErrorCode) throws Exception {
    assertIgniteSqlException(new RunnableX() {

        @Override
        public void runx() throws Exception {
            QueryIndex idx = index(IDX_NAME_1, field(FIELD_NAME_1_ESCAPED));
            idx.setInlineSize(inlineSize);
            dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx, false, 0);
        }
    }, igniteQryErrorCode);
    assertNoIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1);
}
Also used : RunnableX(org.apache.ignite.testframework.GridTestUtils.RunnableX) QueryIndex(org.apache.ignite.cache.QueryIndex) CacheException(javax.cache.CacheException) IgniteException(org.apache.ignite.IgniteException) IgniteSQLException(org.apache.ignite.internal.processors.query.IgniteSQLException) SchemaOperationException(org.apache.ignite.internal.processors.query.schema.SchemaOperationException)

Example 98 with RunnableX

use of org.apache.ignite.testframework.GridTestUtils.RunnableX in project gridgain by gridgain.

the class DynamicIndexAbstractBasicSelfTest method checkCreateNoTable.

/**
 * Check create when table doesn't exist.
 *
 * @param mode Mode.
 * @param atomicityMode Atomicity mode.
 * @param near Near flag.
 * @throws Exception If failed.
 */
private void checkCreateNoTable(CacheMode mode, CacheAtomicityMode atomicityMode, boolean near) throws Exception {
    initialize(mode, atomicityMode, near);
    final QueryIndex idx = index(IDX_NAME_1, field(FIELD_NAME_1_ESCAPED));
    assertIgniteSqlException(new RunnableX() {

        @Override
        public void runx() throws Exception {
            dynamicIndexCreate(CACHE_NAME, randomString(), idx, false, 0);
        }
    }, IgniteQueryErrorCode.TABLE_NOT_FOUND);
    assertNoIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1);
}
Also used : RunnableX(org.apache.ignite.testframework.GridTestUtils.RunnableX) QueryIndex(org.apache.ignite.cache.QueryIndex) CacheException(javax.cache.CacheException) IgniteException(org.apache.ignite.IgniteException) IgniteSQLException(org.apache.ignite.internal.processors.query.IgniteSQLException) SchemaOperationException(org.apache.ignite.internal.processors.query.schema.SchemaOperationException)

Example 99 with RunnableX

use of org.apache.ignite.testframework.GridTestUtils.RunnableX in project gridgain by gridgain.

the class DynamicIndexAbstractBasicSelfTest method checkCreateIndexOnColumnWithAlias.

/**
 * Check index creation on aliased column.
 *
 * @param mode Mode.
 * @param atomicityMode Atomicity mode.
 * @param near Near flag.
 * @throws Exception If failed.
 */
private void checkCreateIndexOnColumnWithAlias(CacheMode mode, CacheAtomicityMode atomicityMode, boolean near) throws Exception {
    initialize(mode, atomicityMode, near);
    assertIgniteSqlException(new RunnableX() {

        @Override
        public void runx() throws Exception {
            QueryIndex idx = index(IDX_NAME_1, field(FIELD_NAME_2_ESCAPED));
            dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx, false, 0);
        }
    }, IgniteQueryErrorCode.COLUMN_NOT_FOUND);
    assertNoIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1);
    QueryIndex idx = index(IDX_NAME_1, field(alias(FIELD_NAME_2_ESCAPED)));
    dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx, false, 0);
    assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1, QueryIndex.DFLT_INLINE_SIZE, field(alias(FIELD_NAME_2_ESCAPED)));
    assertSimpleIndexOperations(SQL_SIMPLE_FIELD_2);
    assertIndexUsed(IDX_NAME_1, SQL_SIMPLE_FIELD_2, SQL_ARG_1);
}
Also used : RunnableX(org.apache.ignite.testframework.GridTestUtils.RunnableX) QueryIndex(org.apache.ignite.cache.QueryIndex) CacheException(javax.cache.CacheException) IgniteException(org.apache.ignite.IgniteException) IgniteSQLException(org.apache.ignite.internal.processors.query.IgniteSQLException) SchemaOperationException(org.apache.ignite.internal.processors.query.schema.SchemaOperationException)

Example 100 with RunnableX

use of org.apache.ignite.testframework.GridTestUtils.RunnableX in project gridgain by gridgain.

the class JdbcThinStatementSelfTest method testGetMoreResultsKeepCurrent.

/**
 * @throws Exception If failed.
 */
@org.junit.Test
public void testGetMoreResultsKeepCurrent() throws Exception {
    assertFalse(stmt.getMoreResults(Statement.CLOSE_CURRENT_RESULT));
    assertFalse(stmt.getMoreResults(Statement.KEEP_CURRENT_RESULT));
    assertFalse(stmt.getMoreResults(Statement.CLOSE_ALL_RESULTS));
    stmt.execute("select 1; ");
    ResultSet rs = stmt.getResultSet();
    assertFalse(stmt.getMoreResults(Statement.KEEP_CURRENT_RESULT));
    assertFalse(rs.isClosed());
    stmt.close();
    checkStatementClosed(new RunnableX() {

        @Override
        public void runx() throws Exception {
            stmt.getMoreResults(Statement.KEEP_CURRENT_RESULT);
        }
    });
}
Also used : RunnableX(org.apache.ignite.testframework.GridTestUtils.RunnableX) ResultSet(java.sql.ResultSet) SQLFeatureNotSupportedException(java.sql.SQLFeatureNotSupportedException) SQLException(java.sql.SQLException)

Aggregations

RunnableX (org.apache.ignite.testframework.GridTestUtils.RunnableX)126 SQLException (java.sql.SQLException)104 SQLFeatureNotSupportedException (java.sql.SQLFeatureNotSupportedException)80 Test (org.junit.Test)78 Connection (java.sql.Connection)64 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)54 SQLClientInfoException (java.sql.SQLClientInfoException)50 JdbcThinConnection (org.apache.ignite.internal.jdbc.thin.JdbcThinConnection)50 IgniteException (org.apache.ignite.IgniteException)22 SchemaOperationException (org.apache.ignite.internal.processors.query.schema.SchemaOperationException)20 ResultSet (java.sql.ResultSet)18 Savepoint (java.sql.Savepoint)18 CacheException (javax.cache.CacheException)16 QueryIndex (org.apache.ignite.cache.QueryIndex)16 IgniteSQLException (org.apache.ignite.internal.processors.query.IgniteSQLException)16 DatabaseMetaData (java.sql.DatabaseMetaData)10 PreparedStatement (java.sql.PreparedStatement)10 MalformedURLException (java.net.MalformedURLException)6 Statement (java.sql.Statement)6 Ignite (org.apache.ignite.Ignite)6