/** * Asserts that {@link IOException} will be thrown. * * @param call Callable that cause allocation overflow. */ @SuppressWarnings("ThrowableNotThrown") private void allocationOverflowCheck(Callable<?> call) { GridTestUtils.assertThrowsAnyCause(log, call, IOException.class, "Failed to allocate required memory"); }
/** * Assert that provided URL is invalid. * * @param url URL. * @param errMsg Error message. */ @SuppressWarnings("ThrowableNotThrown") private void assertInvalid(final String url, String errMsg) { GridTestUtils.assertThrowsAnyCause(log, new Callable<Void>() { @Override public Void call() throws Exception { DriverManager.getConnection(url); return null; } }, SQLException.class, errMsg); }
@Override public void run() throws Exception { GridTestUtils.assertThrowsAnyCause(log, new Callable<Object>() { @Override public Object call() throws Exception { cache.getAndPut(key1, badValue); return null; } }, IgniteCheckedException.class, ERR_MSG); assertEquals(0, cache.size()); } });
@Override public void run() throws Exception { GridTestUtils.assertThrowsAnyCause(log, new Callable<Object>() { @Override public Object call() throws Exception { cache.putIfAbsent(key1, badValue); return null; } }, IgniteCheckedException.class, ERR_MSG); assertEquals(0, cache.size()); } });
/** * Verifies correctness of BaselineTopology checks when working in persistent mode. */ @Override protected void doFinalChecks() { for (int i = 0; i < 4; i++) { int j = i; assertThrowsAnyCause(log, () -> { startGrid(j); return null; }, IgniteSpiException.class, "not compatible"); } }
/** * @throws Exception If failed. */ @Test public void testObjectNotSupported() throws Exception { GridTestUtils.assertThrowsAnyCause(log, new Callable<Object>() { @Override public Object call() throws Exception { stmt.executeQuery("select f1 from TestObject where id = 1"); return null; } }, SQLException.class, "Custom objects are not supported"); }
@Override public void run() throws Exception { GridTestUtils.assertThrowsAnyCause(log, new Callable<Object>() { @Override public Object call() throws Exception { return cache.invoke(key1, new TestEntryProcessor(badValue)); } }, IgniteCheckedException.class, ERR_MSG); assertEquals(0, cache.size()); } });
/** Check create table fails with NOT NULL field and read-through. */ @Test public void testReadThroughRestrictionCreateTable() throws Exception { GridTestUtils.assertThrowsAnyCause(log, new Callable<Object>() { @Override public Object call() throws Exception { return executeSql("CREATE TABLE test(id INT PRIMARY KEY, name char NOT NULL) " + "WITH \"template=" + CACHE_READ_THROUGH+ "\""); } }, IgniteSQLException.class, READ_THROUGH_ERR_MSG); }
/** * Test that dropping a non-existent index yields an error. */ @Test public void testDropMissingIndex() { GridTestUtils.assertThrowsAnyCause(log, new Callable<Void>() { @Override public Void call() throws Exception { jdbcRun(DROP_INDEX); return null; } }, SQLException.class, "Index doesn't exist: IDX"); }
@Override public void run() throws Exception { cache.put(key1, okValue); GridTestUtils.assertThrowsAnyCause(log, new Callable<Object>() { @Override public Object call() throws Exception { cache.put(key2, badValue); return null; } }, IgniteCheckedException.class, ERR_MSG); } });
/** Check create table fails with NOT NULL field and cache interceptor. */ @Test public void testInterceptorRestrictionCreateTable() throws Exception { GridTestUtils.assertThrowsAnyCause(log, new Callable<Object>() { @Override public Object call() throws Exception { return executeSql("CREATE TABLE test(id INT PRIMARY KEY, name char NOT NULL) " + "WITH \"template=" + CACHE_INTERCEPTOR + "\""); } }, IgniteSQLException.class, INTERCEPTOR_ERR_MSG); }
@Override public void run() throws Exception { assertEquals(0, cache.size()); GridTestUtils.assertThrowsAnyCause(log, new Callable<Object>() { @Override public Object call() throws Exception { return cache.getAndPutIfAbsent(key1, badValue); } }, IgniteCheckedException.class, ERR_MSG); assertEquals(0, cache.size()); } });
@Override public void run() throws Exception { cache.put(key1, okValue); GridTestUtils.assertThrowsAnyCause(log, new Callable<Object>() { @Override public Object call() throws Exception { return cache.replace(key1, badValue); } }, IgniteCheckedException.class, ERR_MSG); assertEquals(1, cache.size()); assertEquals(okValue, cache.get(key1)); } });
@Override public void run() throws Exception { cache.put(key1, okValue); GridTestUtils.assertThrowsAnyCause(log, new Callable<Object>() { @Override public Object call() throws Exception { return cache.getAndReplace(key1, badValue); } }, IgniteCheckedException.class, ERR_MSG); assertEquals(1, cache.size()); assertEquals(okValue, cache.get(key1)); } });
/** Check alter table fails with NOT NULL field and read-through. */ @Test public void testReadThroughRestrictionAlterTable() throws Exception { executeSql("CREATE TABLE test(id INT PRIMARY KEY, age INT) " + "WITH \"template=" + CACHE_READ_THROUGH + "\""); GridTestUtils.assertThrowsAnyCause(log, new Callable<Object>() { @Override public Object call() throws Exception { return executeSql("ALTER TABLE test ADD COLUMN name char NOT NULL"); } }, IgniteSQLException.class, READ_THROUGH_ERR_MSG); }
/** Check alter table fails with NOT NULL field and cache interceptor. */ @Test public void testInterceptorRestrictionAlterTable() throws Exception { executeSql("CREATE TABLE test(id INT PRIMARY KEY, age INT) " + "WITH \"template=" + CACHE_INTERCEPTOR + "\""); GridTestUtils.assertThrowsAnyCause(log, new Callable<Object>() { @Override public Object call() throws Exception { return executeSql("ALTER TABLE test ADD COLUMN name char NOT NULL"); } }, IgniteSQLException.class, INTERCEPTOR_ERR_MSG); }
/** * Test that creating an index with duplicate name yields an error. * @throws SQLException If failed. */ @Test public void testCreateIndexWithDuplicateName() throws SQLException { jdbcRun(CREATE_INDEX); GridTestUtils.assertThrowsAnyCause(log, new Callable<Void>() { @Override public Void call() throws Exception { jdbcRun(CREATE_INDEX); return null; } }, SQLException.class, "Index already exists: IDX"); }
@Override public void run() throws Exception { final Map<Integer, EntryProcessorResult<Object>> r = cache.invokeAll(F.asMap( key1, new TestEntryProcessor(okValue), key2, new TestEntryProcessor(badValue))); assertNotNull(r); GridTestUtils.assertThrowsAnyCause(log, new Callable<Object>() { @Override public Object call() throws Exception { return r.get(key2).get(); } }, IgniteCheckedException.class, ERR_MSG); assertEquals(1, cache.size()); } });
/** * */ @Test public void testGroupConcatDistributedException() { final IgniteCache c = ignite(CLIENT).cache(CACHE_NAME); GridTestUtils.assertThrowsAnyCause(log, new Callable<Object>() { @Override public Object call() { c.query(new SqlFieldsQuery("select grp, GROUP_CONCAT(str0 ORDER BY str0) " + "from Value group by grp")).getAll(); return null; } }, IgniteSQLException.class, "Clauses DISTINCT and ORDER BY are unsupported for GROUP_CONCAT " + "for not collocated data"); }
/** * @throws Exception If failed. */ @Test @SuppressWarnings("ThrowableNotThrown") public void testInactiveClusterWrite() throws Exception { startGrid(0); GridTestUtils.assertThrowsAnyCause(log, () -> { metastorage(0).write("key", "value"); return null; }, IllegalStateException.class, "Ignite cluster is not active"); GridTestUtils.assertThrowsAnyCause(log, () -> { metastorage(0).remove("key"); return null; }, IllegalStateException.class, "Ignite cluster is not active"); }