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"));
}
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);
}
});
}
}
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();
}
});
}
}
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);
}
});
}
}
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);
}
});
}
}
Aggregations