Skip to content

Commit b699eb0

Browse files
committed
GG-20594 GG-20593 GG-20592 GG-19428 [IGNITE-9560] Security Engine fixes and test coverage. Phase #1.
1 parent 21de580 commit b699eb0

File tree

78 files changed

+4896
-778
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+4896
-778
lines changed

modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcDynamicIndexAbstractSelfTest.java

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.apache.ignite.configuration.CacheConfiguration;
3232
import org.apache.ignite.configuration.NearCacheConfiguration;
3333
import org.apache.ignite.internal.util.typedef.F;
34+
import org.apache.ignite.testframework.GridTestUtils;
3435

3536
/**
3637
* Test that checks indexes handling with JDBC.
@@ -168,9 +169,9 @@ public void testCreateIndex() throws SQLException {
168169
public void testCreateIndexWithDuplicateName() throws SQLException {
169170
jdbcRun(CREATE_INDEX);
170171

171-
assertSqlException(new RunnableX() {
172+
assertSqlException(new GridTestUtils.RunnableX() {
172173
/** {@inheritDoc} */
173-
@Override public void run() throws Exception {
174+
@Override public void runx() throws Exception {
174175
jdbcRun(CREATE_INDEX);
175176
}
176177
});
@@ -219,9 +220,9 @@ public void testDropIndex() throws SQLException {
219220
* Test that dropping a non-existent index yields an error.
220221
*/
221222
public void testDropMissingIndex() {
222-
assertSqlException(new RunnableX() {
223+
assertSqlException(new GridTestUtils.RunnableX() {
223224
/** {@inheritDoc} */
224-
@Override public void run() throws Exception {
225+
@Override public void runx() throws Exception {
225226
jdbcRun(DROP_INDEX);
226227
}
227228
});
@@ -310,11 +311,11 @@ private IgniteCache<String, Person> cache() {
310311
*
311312
* @param r Runnable.
312313
*/
313-
private static void assertSqlException(RunnableX r) {
314+
private static void assertSqlException(GridTestUtils.RunnableX r) {
314315
// We expect IgniteSQLException with given code inside CacheException inside JDBC SQLException.
315316

316317
try {
317-
r.run();
318+
r.runx();
318319
}
319320
catch (SQLException e) {
320321
return;
@@ -325,16 +326,4 @@ private static void assertSqlException(RunnableX r) {
325326

326327
fail(SQLException.class.getSimpleName() + " is not thrown.");
327328
}
328-
329-
/**
330-
* Runnable which can throw checked exceptions.
331-
*/
332-
private interface RunnableX {
333-
/**
334-
* Do run.
335-
*
336-
* @throws Exception If failed.
337-
*/
338-
public void run() throws Exception;
339-
}
340329
}

modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinAbstractSelfTest.java

Lines changed: 14 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@
2828
import java.util.Collection;
2929
import java.util.Collections;
3030
import java.util.List;
31-
import java.util.concurrent.Callable;
3231
import org.apache.ignite.internal.IgniteEx;
3332
import org.apache.ignite.internal.processors.odbc.ClientListenerProcessor;
3433
import org.apache.ignite.internal.processors.port.GridPortRecord;
3534
import org.apache.ignite.internal.util.typedef.F;
3635
import org.apache.ignite.testframework.GridTestUtils;
36+
import org.apache.ignite.testframework.GridTestUtils.RunnableX;
3737
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
3838

3939
/**
@@ -45,68 +45,45 @@ public class JdbcThinAbstractSelfTest extends GridCommonAbstractTest {
4545
* @param r Runnable to check support.
4646
*/
4747
protected void checkNotSupported(final RunnableX r) {
48-
GridTestUtils.assertThrows(log,
49-
new Callable<Object>() {
50-
@Override public Object call() throws Exception {
51-
r.run();
52-
53-
return null;
54-
}
55-
}, SQLFeatureNotSupportedException.class, null);
48+
GridTestUtils.assertThrowsWithCause(r, SQLFeatureNotSupportedException.class);
5649
}
5750

5851
/**
5952
* @param r Runnable to check on closed connection.
6053
*/
6154
protected void checkConnectionClosed(final RunnableX r) {
62-
GridTestUtils.assertThrows(log,
63-
new Callable<Object>() {
64-
@Override public Object call() throws Exception {
65-
r.run();
55+
GridTestUtils.assertThrowsAnyCause(log,
56+
() -> {
57+
r.run();
6658

67-
return null;
68-
}
59+
return null;
6960
}, SQLException.class, "Connection is closed");
7061
}
7162

7263
/**
7364
* @param r Runnable to check on closed statement.
7465
*/
7566
protected void checkStatementClosed(final RunnableX r) {
76-
GridTestUtils.assertThrows(log,
77-
new Callable<Object>() {
78-
@Override public Object call() throws Exception {
79-
r.run();
67+
GridTestUtils.assertThrowsAnyCause(log,
68+
() -> {
69+
r.run();
8070

81-
return null;
82-
}
71+
return null;
8372
}, SQLException.class, "Statement is closed");
8473
}
8574

8675
/**
8776
* @param r Runnable to check on closed result set.
8877
*/
8978
protected void checkResultSetClosed(final RunnableX r) {
90-
GridTestUtils.assertThrows(log,
91-
new Callable<Object>() {
92-
@Override public Object call() throws Exception {
93-
r.run();
79+
GridTestUtils.assertThrowsAnyCause(log,
80+
() -> {
81+
r.run();
9482

95-
return null;
96-
}
83+
return null;
9784
}, SQLException.class, "Result set is closed");
9885
}
9986

100-
/**
101-
* Runnable that can throw an exception.
102-
*/
103-
interface RunnableX {
104-
/**
105-
* @throws Exception On error.
106-
*/
107-
void run() throws Exception;
108-
}
109-
11087
/**
11188
* @param node Node to connect to.
11289
* @param params Connection parameters.

0 commit comments

Comments
 (0)