Search in sources :

Example 1 with RunnableX

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

the class JmxExporterSpiTest method testFilterAndExport.

/**
 */
@Test
public void testFilterAndExport() throws Exception {
    createAdditionalMetrics(ignite);
    assertThrowsWithCause(new RunnableX() {

        @Override
        public void runx() throws Exception {
            metricRegistry(ignite.name(), "filtered", "metric");
        }
    }, IgniteException.class);
    DynamicMBean bean1 = metricRegistry(ignite.name(), "other", "prefix");
    assertEquals(42L, bean1.getAttribute("test"));
    assertEquals(43L, bean1.getAttribute("test2"));
    DynamicMBean bean2 = metricRegistry(ignite.name(), "other", "prefix2");
    assertEquals(44L, bean2.getAttribute("test3"));
}
Also used : DynamicMBean(javax.management.DynamicMBean) RunnableX(org.apache.ignite.testframework.GridTestUtils.RunnableX) BrokenBarrierException(java.util.concurrent.BrokenBarrierException) IgniteException(org.apache.ignite.IgniteException) Test(org.junit.Test)

Example 2 with RunnableX

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

the class JdbcThinConnectionSelfTest method testCreateStruct.

/**
 * @throws Exception If failed.
 */
@Test
public void testCreateStruct() throws Exception {
    try (Connection conn = DriverManager.getConnection(urlWithPartitionAwarenessProp)) {
        // Invalid typename
        assertThrows(log, new Callable<Object>() {

            @Override
            public Object call() throws Exception {
                return conn.createStruct(null, null);
            }
        }, SQLException.class, "Type name cannot be null");
        final String typeName = "employee";
        final Object[] attrs = new Object[] { 100, "Tom" };
        checkNotSupported(new RunnableX() {

            @Override
            public void runx() throws Exception {
                conn.createStruct(typeName, attrs);
            }
        });
        conn.close();
        checkConnectionClosed(new RunnableX() {

            @Override
            public void runx() throws Exception {
                conn.createStruct(typeName, attrs);
            }
        });
    }
}
Also used : RunnableX(org.apache.ignite.testframework.GridTestUtils.RunnableX) Connection(java.sql.Connection) JdbcThinConnection(org.apache.ignite.internal.jdbc.thin.JdbcThinConnection) SQLFeatureNotSupportedException(java.sql.SQLFeatureNotSupportedException) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) SQLClientInfoException(java.sql.SQLClientInfoException) SQLException(java.sql.SQLException) Test(org.junit.Test)

Example 3 with RunnableX

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

the class JdbcThinConnectionSelfTest method testGetSetSchema.

/**
 * @throws Exception If failed.
 */
@Test
public void testGetSetSchema() throws Exception {
    try (Connection conn = DriverManager.getConnection(urlWithPartitionAwarenessProp)) {
        assertEquals("PUBLIC", conn.getSchema());
        final String schema = "test";
        conn.setSchema(schema);
        assertEquals(schema.toUpperCase(), conn.getSchema());
        conn.setSchema('"' + schema + '"');
        assertEquals(schema, conn.getSchema());
        conn.close();
        checkConnectionClosed(new RunnableX() {

            @Override
            public void runx() throws Exception {
                conn.setSchema(schema);
            }
        });
        checkConnectionClosed(new RunnableX() {

            @Override
            public void runx() throws Exception {
                conn.getSchema();
            }
        });
    }
}
Also used : RunnableX(org.apache.ignite.testframework.GridTestUtils.RunnableX) Connection(java.sql.Connection) JdbcThinConnection(org.apache.ignite.internal.jdbc.thin.JdbcThinConnection) SQLFeatureNotSupportedException(java.sql.SQLFeatureNotSupportedException) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) SQLClientInfoException(java.sql.SQLClientInfoException) SQLException(java.sql.SQLException) Test(org.junit.Test)

Example 4 with RunnableX

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

the class JdbcThinConnectionSelfTest method testRollbackSavePoint.

/**
 * @throws Exception If failed.
 */
@Test
public void testRollbackSavePoint() throws Exception {
    try (Connection conn = DriverManager.getConnection(urlWithPartitionAwarenessProp)) {
        assert !conn.getMetaData().supportsSavepoints();
        // Invalid arg
        assertThrows(log, new Callable<Object>() {

            @Override
            public Object call() throws Exception {
                conn.rollback(null);
                return null;
            }
        }, SQLException.class, "Invalid savepoint");
        final Savepoint savepoint = getFakeSavepoint();
        // Disallowed in auto-commit mode
        assertThrows(log, new Callable<Object>() {

            @Override
            public Object call() throws Exception {
                conn.rollback(savepoint);
                return null;
            }
        }, SQLException.class, "Auto-commit mode");
        conn.close();
        checkConnectionClosed(new RunnableX() {

            @Override
            public void runx() throws Exception {
                conn.rollback(savepoint);
            }
        });
    }
}
Also used : RunnableX(org.apache.ignite.testframework.GridTestUtils.RunnableX) Connection(java.sql.Connection) JdbcThinConnection(org.apache.ignite.internal.jdbc.thin.JdbcThinConnection) Savepoint(java.sql.Savepoint) SQLFeatureNotSupportedException(java.sql.SQLFeatureNotSupportedException) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) SQLClientInfoException(java.sql.SQLClientInfoException) SQLException(java.sql.SQLException) Test(org.junit.Test)

Example 5 with RunnableX

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

the class JdbcThinConnectionSelfTest method testSetSavepointName.

/**
 * @throws Exception If failed.
 */
@Test
public void testSetSavepointName() throws Exception {
    try (Connection conn = DriverManager.getConnection(urlWithPartitionAwarenessProp)) {
        assert !conn.getMetaData().supportsSavepoints();
        // Invalid arg
        assertThrows(log, new Callable<Object>() {

            @Override
            public Object call() throws Exception {
                conn.setSavepoint(null);
                return null;
            }
        }, SQLException.class, "Savepoint name cannot be null");
        final String name = "savepoint";
        // Disallowed in auto-commit mode
        assertThrows(log, new Callable<Object>() {

            @Override
            public Object call() throws Exception {
                conn.setSavepoint(name);
                return null;
            }
        }, SQLException.class, "Savepoint cannot be set in auto-commit mode");
        conn.close();
        checkConnectionClosed(new RunnableX() {

            @Override
            public void runx() throws Exception {
                conn.setSavepoint(name);
            }
        });
    }
}
Also used : RunnableX(org.apache.ignite.testframework.GridTestUtils.RunnableX) Connection(java.sql.Connection) JdbcThinConnection(org.apache.ignite.internal.jdbc.thin.JdbcThinConnection) SQLFeatureNotSupportedException(java.sql.SQLFeatureNotSupportedException) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) SQLClientInfoException(java.sql.SQLClientInfoException) SQLException(java.sql.SQLException) Test(org.junit.Test)

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