Search in sources :

Example 26 with RunnableX

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

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)

Example 27 with RunnableX

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

the class JdbcThinStatementSelfTest method testCursorName.

/**
 * @throws Exception If failed.
 */
@org.junit.Test
public void testCursorName() throws Exception {
    checkNotSupported(new RunnableX() {

        @Override
        public void runx() throws Exception {
            stmt.setCursorName("test");
        }
    });
    stmt.close();
    checkStatementClosed(new RunnableX() {

        @Override
        public void runx() throws Exception {
            stmt.setCursorName("test");
        }
    });
}
Also used : RunnableX(org.apache.ignite.testframework.GridTestUtils.RunnableX) SQLFeatureNotSupportedException(java.sql.SQLFeatureNotSupportedException) SQLException(java.sql.SQLException)

Example 28 with RunnableX

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

the class JdbcThinResultSetSelfTest method testNotSupportedTypes.

/**
 * @throws Exception If failed.
 */
@Test
public void testNotSupportedTypes() throws Exception {
    final ResultSet rs = stmt.executeQuery(SQL);
    assert rs.next();
    checkNotSupported(new RunnableX() {

        @Override
        public void runx() throws Exception {
            rs.getArray(1);
        }
    });
    checkNotSupported(new RunnableX() {

        @Override
        public void runx() throws Exception {
            rs.getArray("id");
        }
    });
    checkNotSupported(new RunnableX() {

        @Override
        public void runx() throws Exception {
            rs.getAsciiStream(1);
        }
    });
    checkNotSupported(new RunnableX() {

        @Override
        public void runx() throws Exception {
            rs.getAsciiStream("id");
        }
    });
    checkNotSupported(new RunnableX() {

        @Override
        public void runx() throws Exception {
            rs.getBinaryStream(1);
        }
    });
    checkNotSupported(new RunnableX() {

        @Override
        public void runx() throws Exception {
            rs.getBinaryStream("id");
        }
    });
    checkNotSupported(new RunnableX() {

        @Override
        public void runx() throws Exception {
            rs.getBlob(1);
        }
    });
    checkNotSupported(new RunnableX() {

        @Override
        public void runx() throws Exception {
            rs.getBlob("id");
        }
    });
    checkNotSupported(new RunnableX() {

        @Override
        public void runx() throws Exception {
            rs.getClob(1);
        }
    });
    checkNotSupported(new RunnableX() {

        @Override
        public void runx() throws Exception {
            rs.getClob("id");
        }
    });
    checkNotSupported(new RunnableX() {

        @Override
        public void runx() throws Exception {
            rs.getCharacterStream(1);
        }
    });
    checkNotSupported(new RunnableX() {

        @Override
        public void runx() throws Exception {
            rs.getCharacterStream("id");
        }
    });
    checkNotSupported(new RunnableX() {

        @Override
        public void runx() throws Exception {
            rs.getNCharacterStream(1);
        }
    });
    checkNotSupported(new RunnableX() {

        @Override
        public void runx() throws Exception {
            rs.getNCharacterStream("id");
        }
    });
    checkNotSupported(new RunnableX() {

        @Override
        public void runx() throws Exception {
            rs.getNClob(1);
        }
    });
    checkNotSupported(new RunnableX() {

        @Override
        public void runx() throws Exception {
            rs.getNClob("id");
        }
    });
    checkNotSupported(new RunnableX() {

        @Override
        public void runx() throws Exception {
            rs.getRef(1);
        }
    });
    checkNotSupported(new RunnableX() {

        @Override
        public void runx() throws Exception {
            rs.getRef("id");
        }
    });
    checkNotSupported(new RunnableX() {

        @Override
        public void runx() throws Exception {
            rs.getRowId(1);
        }
    });
    checkNotSupported(new RunnableX() {

        @Override
        public void runx() throws Exception {
            rs.getRowId("id");
        }
    });
    checkNotSupported(new RunnableX() {

        @Override
        public void runx() throws Exception {
            rs.getSQLXML(1);
        }
    });
    checkNotSupported(new RunnableX() {

        @Override
        public void runx() throws Exception {
            rs.getSQLXML("id");
        }
    });
}
Also used : RunnableX(org.apache.ignite.testframework.GridTestUtils.RunnableX) ResultSet(java.sql.ResultSet) SQLException(java.sql.SQLException) MalformedURLException(java.net.MalformedURLException) Test(org.junit.Test)

Example 29 with RunnableX

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

the class DynamicIndexAbstractConcurrentSelfTest method checkClientReconnect.

/**
 * Make sure that client receives schema changes made while it was disconnected, optionally with cache restart
 * in the interim.
 *
 * @param restartCache Whether cache needs to be recreated during client's absence.
 * @throws Exception If failed.
 */
private void checkClientReconnect(final boolean restartCache) throws Exception {
    // Start complex topology.
    final Ignite srv = ignitionStart(serverConfiguration(1));
    ignitionStart(serverConfiguration(2));
    ignitionStart(serverConfiguration(3, true));
    final Ignite cli = ignitionStart(clientConfiguration(4));
    createSqlCache(cli);
    // Check index create.
    reconnectClientNode(srv, cli, restartCache, new RunnableX() {

        @Override
        public void runx() throws Exception {
            final QueryIndex idx = index(IDX_NAME_1, field(FIELD_NAME_1));
            queryProcessor(srv).dynamicIndexCreate(CACHE_NAME, CACHE_NAME, TBL_NAME, idx, false, 0).get();
        }
    });
    assertIndex(cli, CACHE_NAME, TBL_NAME, IDX_NAME_1, QueryIndex.DFLT_INLINE_SIZE, field(FIELD_NAME_1));
    assertIndexUsed(IDX_NAME_1, SQL_SIMPLE_FIELD_1, SQL_ARG_1);
    // Check index drop.
    reconnectClientNode(srv, cli, restartCache, new RunnableX() {

        @Override
        public void runx() throws Exception {
            if (!restartCache)
                queryProcessor(srv).dynamicIndexDrop(CACHE_NAME, CACHE_NAME, IDX_NAME_1, false).get();
        }
    });
    assertNoIndex(cli, CACHE_NAME, TBL_NAME, IDX_NAME_1);
    assertIndexNotUsed(IDX_NAME_1, SQL_SIMPLE_FIELD_1, SQL_ARG_1);
    // Update existing index.
    QueryIndex idx = index(IDX_NAME_2, field(aliasUnescaped(FIELD_NAME_2)));
    queryProcessor(srv).dynamicIndexCreate(CACHE_NAME, CACHE_NAME, TBL_NAME, idx, false, 0).get();
    assertIndex(cli, CACHE_NAME, TBL_NAME, IDX_NAME_2, QueryIndex.DFLT_INLINE_SIZE, field(aliasUnescaped(FIELD_NAME_2)));
    assertIndexUsed(IDX_NAME_2, SQL_SIMPLE_FIELD_2, SQL_ARG_2);
    reconnectClientNode(srv, cli, restartCache, new RunnableX() {

        @Override
        public void runx() throws Exception {
            if (!restartCache)
                queryProcessor(srv).dynamicIndexDrop(CACHE_NAME, CACHE_NAME, IDX_NAME_2, false).get();
            final QueryIndex idx = index(IDX_NAME_2, field(FIELD_NAME_1), field(aliasUnescaped(FIELD_NAME_2)));
            queryProcessor(srv).dynamicIndexCreate(CACHE_NAME, CACHE_NAME, TBL_NAME, idx, false, 0).get();
        }
    });
    assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_2, QueryIndex.DFLT_INLINE_SIZE, field(FIELD_NAME_1), field(aliasUnescaped(FIELD_NAME_2)));
    assertIndexUsed(IDX_NAME_2, SQL_COMPOSITE, SQL_ARG_1, SQL_ARG_2);
}
Also used : RunnableX(org.apache.ignite.testframework.GridTestUtils.RunnableX) QueryIndex(org.apache.ignite.cache.QueryIndex) Ignite(org.apache.ignite.Ignite) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) SchemaOperationException(org.apache.ignite.internal.processors.query.schema.SchemaOperationException)

Example 30 with RunnableX

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

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)

Aggregations

RunnableX (org.apache.ignite.testframework.GridTestUtils.RunnableX)63 SQLException (java.sql.SQLException)52 SQLFeatureNotSupportedException (java.sql.SQLFeatureNotSupportedException)40 Test (org.junit.Test)39 Connection (java.sql.Connection)32 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)27 SQLClientInfoException (java.sql.SQLClientInfoException)25 JdbcThinConnection (org.apache.ignite.internal.jdbc.thin.JdbcThinConnection)25 IgniteException (org.apache.ignite.IgniteException)11 SchemaOperationException (org.apache.ignite.internal.processors.query.schema.SchemaOperationException)10 ResultSet (java.sql.ResultSet)9 Savepoint (java.sql.Savepoint)9 CacheException (javax.cache.CacheException)8 QueryIndex (org.apache.ignite.cache.QueryIndex)8 IgniteSQLException (org.apache.ignite.internal.processors.query.IgniteSQLException)8 DatabaseMetaData (java.sql.DatabaseMetaData)5 PreparedStatement (java.sql.PreparedStatement)5 MalformedURLException (java.net.MalformedURLException)3 Statement (java.sql.Statement)3 Ignite (org.apache.ignite.Ignite)3