http://git-wip-us.apache.org/repos/asf/ignite/blob/c5197e0a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalRecoveryTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalRecoveryTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalRecoveryTest.java index b29a679..7bf5675 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalRecoveryTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalRecoveryTest.java @@ -109,6 +109,9 @@ import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.configuration.DataStorageConfiguration.DFLT_CHECKPOINT_FREQ; import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_IGNITE_INSTANCE_NAME; @@ -118,6 +121,7 @@ import static org.apache.ignite.internal.processors.cache.persistence.file.FileP /** * */ +@RunWith(JUnit4.class) public class IgniteWalRecoveryTest extends GridCommonAbstractTest { /** */ private static final String HAS_CACHE = "HAS_CACHE"; @@ -250,6 +254,7 @@ public class IgniteWalRecoveryTest extends GridCommonAbstractTest { /** * @throws Exception if failed. */ + @Test public void testWalBig() throws Exception { IgniteEx ignite = startGrid(1); @@ -292,6 +297,7 @@ public class IgniteWalRecoveryTest extends GridCommonAbstractTest { /** * @throws Exception if failed. */ + @Test public void testWalBigObjectNodeCancel() throws Exception { final int MAX_SIZE_POWER = 21; @@ -330,6 +336,7 @@ public class IgniteWalRecoveryTest extends GridCommonAbstractTest { /** * @throws Exception If fail. */ + @Test public void testSwitchClassLoader() throws Exception { final IgniteEx igniteEx = startGrid(1); @@ -366,6 +373,7 @@ public class IgniteWalRecoveryTest extends GridCommonAbstractTest { /** * @throws Exception if failed. */ + @Test public void testWalSimple() throws Exception { IgniteEx ignite = startGrid(1); @@ -438,6 +446,7 @@ public class IgniteWalRecoveryTest extends GridCommonAbstractTest { /** * @throws Exception If fail. */ + @Test public void testWalLargeValue() throws Exception { IgniteEx ignite = startGrid(1); @@ -487,6 +496,7 @@ public class IgniteWalRecoveryTest extends GridCommonAbstractTest { * * @throws Exception if failed. */ + @Test public void testBinaryRecoverBeforePMEWhenMiddleCheckpoint() throws Exception { startGrids(3); @@ -587,6 +597,7 @@ public class IgniteWalRecoveryTest extends GridCommonAbstractTest { /** * @throws Exception if failed. */ + @Test public void testWalRolloverMultithreadedDefault() throws Exception { logOnly = false; @@ -596,6 +607,7 @@ public class IgniteWalRecoveryTest extends GridCommonAbstractTest { /** * @throws Exception if failed. */ + @Test public void testWalRolloverMultithreadedLogOnly() throws Exception { logOnly = true; @@ -605,6 +617,7 @@ public class IgniteWalRecoveryTest extends GridCommonAbstractTest { /** * @throws Exception if failed. */ + @Test public void testHugeCheckpointRecord() throws Exception { long prevFDTimeout = customFailureDetectionTimeout; @@ -684,6 +697,7 @@ public class IgniteWalRecoveryTest extends GridCommonAbstractTest { /** * @throws Exception If fail. */ + @Test public void testWalRenameDirSimple() throws Exception { IgniteEx ignite = startGrid(1); @@ -742,6 +756,7 @@ public class IgniteWalRecoveryTest extends GridCommonAbstractTest { /** * @throws Exception if failed. */ + @Test public void testRecoveryNoCheckpoint() throws Exception { IgniteEx ctrlGrid = startGrid(0); @@ -790,6 +805,7 @@ public class IgniteWalRecoveryTest extends GridCommonAbstractTest { /** * @throws Exception if failed. */ + @Test public void testRecoveryLargeNoCheckpoint() throws Exception { IgniteEx ctrlGrid = startGrid(0); @@ -840,6 +856,7 @@ public class IgniteWalRecoveryTest extends GridCommonAbstractTest { /** * @throws Exception if failed. */ + @Test public void testRandomCrash() throws Exception { checkpointFrequency = 2_000 + new Random().nextInt(4_000); @@ -875,6 +892,7 @@ public class IgniteWalRecoveryTest extends GridCommonAbstractTest { /** * @throws Exception if failed. */ + @Test public void testLargeRandomCrash() throws Exception { checkpointFrequency = 2_000 + new Random().nextInt(4_000); @@ -920,6 +938,7 @@ public class IgniteWalRecoveryTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testDestroyCache() throws Exception { IgniteEx ignite = startGrid(1); @@ -940,6 +959,7 @@ public class IgniteWalRecoveryTest extends GridCommonAbstractTest { /** * @throws Exception If fail. */ + @Test public void testEvictPartition() throws Exception { Ignite ignite1 = startGrid("node1"); @@ -979,6 +999,7 @@ public class IgniteWalRecoveryTest extends GridCommonAbstractTest { /** * @throws Exception If fail. */ + @Test public void testMetastorage() throws Exception { int cnt = 5000; @@ -1038,6 +1059,7 @@ public class IgniteWalRecoveryTest extends GridCommonAbstractTest { /** * @throws Exception If fail. */ + @Test public void testMetastorageLargeArray() throws Exception { int cnt = 5000; int arraySize = 32_768; @@ -1079,6 +1101,7 @@ public class IgniteWalRecoveryTest extends GridCommonAbstractTest { /** * @throws Exception If fail. */ + @Test public void testMetastorageRemove() throws Exception { int cnt = 400; @@ -1126,6 +1149,7 @@ public class IgniteWalRecoveryTest extends GridCommonAbstractTest { /** * @throws Exception If fail. */ + @Test public void testMetastorageUpdate() throws Exception { try { int cnt = 2000; @@ -1178,6 +1202,7 @@ public class IgniteWalRecoveryTest extends GridCommonAbstractTest { /** * @throws Exception If fail. */ + @Test public void testMetastorageWalRestore() throws Exception { int cnt = 2000; @@ -1229,6 +1254,7 @@ public class IgniteWalRecoveryTest extends GridCommonAbstractTest { /** * @throws Exception if failed. */ + @Test public void testAbsentDeadlock_Iterator_RollOver_Archivation() throws Exception { walSegments = 2; @@ -1292,6 +1318,7 @@ public class IgniteWalRecoveryTest extends GridCommonAbstractTest { /** * @throws Exception if failed. */ + @Test public void testApplyDeltaRecords() throws Exception { IgniteEx ignite0 = (IgniteEx)startGrid("node0"); @@ -1425,6 +1452,7 @@ public class IgniteWalRecoveryTest extends GridCommonAbstractTest { * * @throws Exception If fail. */ + @Test public void testRecoveryOnTransactionalAndPartitionedCache() throws Exception { IgniteEx ignite = (IgniteEx)startGrids(3); ignite.cluster().active(true); @@ -1496,6 +1524,7 @@ public class IgniteWalRecoveryTest extends GridCommonAbstractTest { * * @throws Exception If any fail. */ + @Test public void testTxRecordsConsistency() throws Exception { System.setProperty(IgniteSystemProperties.IGNITE_WAL_LOG_TX_RECORDS, "true");
http://git-wip-us.apache.org/repos/asf/ignite/blob/c5197e0a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/transaction/DmlInsideTransactionTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/transaction/DmlInsideTransactionTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/transaction/DmlInsideTransactionTest.java index 633bb6f..ee8c899 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/transaction/DmlInsideTransactionTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/transaction/DmlInsideTransactionTest.java @@ -30,12 +30,16 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.testframework.GridTestUtils.SystemProperty; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.testframework.GridTestUtils.assertThrows; /** * Tests DML allow/disallow operation inside transaction. */ +@RunWith(JUnit4.class) public class DmlInsideTransactionTest extends GridCommonAbstractTest { /** Person cache name. */ private static final String CACHE_PERSON = "PersonCache"; @@ -61,6 +65,7 @@ public class DmlInsideTransactionTest extends GridCommonAbstractTest { * * @throws Exception In case failure. */ + @Test public void testDmlInTransactionByDefault() throws Exception { prepareIgnite(); @@ -76,6 +81,7 @@ public class DmlInsideTransactionTest extends GridCommonAbstractTest { * * @throws Exception In case failure. */ + @Test public void testDmlInTransactionInDisabledCompatibilityMode() throws Exception { try (SystemProperty ignored = new SystemProperty(IgniteSystemProperties.IGNITE_ALLOW_DML_INSIDE_TRANSACTION, "false")) { prepareIgnite(); @@ -93,6 +99,7 @@ public class DmlInsideTransactionTest extends GridCommonAbstractTest { * * @throws Exception In case failure. */ + @Test public void testDmlInTransactionInCompatibilityMode() throws Exception { try (SystemProperty ignored = new SystemProperty(IgniteSystemProperties.IGNITE_ALLOW_DML_INSIDE_TRANSACTION, "true")) { prepareIgnite(); @@ -110,6 +117,7 @@ public class DmlInsideTransactionTest extends GridCommonAbstractTest { * * @throws Exception In case failure. */ + @Test public void testDmlNotInTransaction() throws Exception { prepareIgnite(); http://git-wip-us.apache.org/repos/asf/ignite/blob/c5197e0a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/ttl/CacheTtlAbstractSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/ttl/CacheTtlAbstractSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/ttl/CacheTtlAbstractSelfTest.java index c9a5bf6..0573756 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/ttl/CacheTtlAbstractSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/ttl/CacheTtlAbstractSelfTest.java @@ -42,6 +42,9 @@ import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static org.apache.ignite.cache.CacheMode.LOCAL; @@ -56,6 +59,7 @@ import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; /** * TTL test. */ +@RunWith(JUnit4.class) public abstract class CacheTtlAbstractSelfTest extends GridCommonAbstractTest { /** */ private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); @@ -145,6 +149,7 @@ public abstract class CacheTtlAbstractSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testDefaultTimeToLiveLoadCache() throws Exception { IgniteCache<Integer, Integer> cache = jcache(0); @@ -160,6 +165,7 @@ public abstract class CacheTtlAbstractSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testDefaultTimeToLiveLoadAll() throws Exception { defaultTimeToLiveLoadAll(false); @@ -194,6 +200,7 @@ public abstract class CacheTtlAbstractSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testDefaultTimeToLiveStreamerAdd() throws Exception { try (IgniteDataStreamer<Integer, Integer> streamer = ignite(0).dataStreamer(DEFAULT_CACHE_NAME)) { for (int i = 0; i < SIZE; i++) @@ -223,6 +230,7 @@ public abstract class CacheTtlAbstractSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testDefaultTimeToLivePut() throws Exception { IgniteCache<Integer, Integer> cache = jcache(0); @@ -240,6 +248,7 @@ public abstract class CacheTtlAbstractSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testDefaultTimeToLivePutAll() throws Exception { IgniteCache<Integer, Integer> cache = jcache(0); @@ -260,6 +269,7 @@ public abstract class CacheTtlAbstractSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testDefaultTimeToLivePreload() throws Exception { if (cacheMode() == LOCAL) return; @@ -285,6 +295,7 @@ public abstract class CacheTtlAbstractSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testTimeToLiveTtl() throws Exception { long time = DEFAULT_TIME_TO_LIVE + 2000; @@ -360,4 +371,4 @@ public abstract class CacheTtlAbstractSelfTest extends GridCommonAbstractTest { assertNull(cache.localPeek(key)); } } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/ignite/blob/c5197e0a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/client/ClientConnectorConfigurationValidationSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/client/ClientConnectorConfigurationValidationSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/client/ClientConnectorConfigurationValidationSelfTest.java index 6ca3030..593952f 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/client/ClientConnectorConfigurationValidationSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/client/ClientConnectorConfigurationValidationSelfTest.java @@ -40,11 +40,15 @@ import java.sql.SQLException; import java.sql.Statement; import java.util.concurrent.Callable; import java.util.concurrent.atomic.AtomicInteger; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Client connector configuration validation tests. */ @SuppressWarnings("deprecation") +@RunWith(JUnit4.class) public class ClientConnectorConfigurationValidationSelfTest extends GridCommonAbstractTest { /** Node index generator. */ private static final AtomicInteger NODE_IDX_GEN = new AtomicInteger(); @@ -62,6 +66,7 @@ public class ClientConnectorConfigurationValidationSelfTest extends GridCommonAb * * @throws Exception If failed. */ + @Test public void testDefault() throws Exception { check(new ClientConnectorConfiguration(), true); checkJdbc(null, ClientConnectorConfiguration.DFLT_PORT); @@ -72,6 +77,7 @@ public class ClientConnectorConfigurationValidationSelfTest extends GridCommonAb * * @throws Exception If failed. */ + @Test public void testHost() throws Exception { check(new ClientConnectorConfiguration().setHost("126.0.0.1"), false); @@ -88,6 +94,7 @@ public class ClientConnectorConfigurationValidationSelfTest extends GridCommonAb * * @throws Exception If failed. */ + @Test public void testPort() throws Exception { check(new ClientConnectorConfiguration().setPort(-1), false); check(new ClientConnectorConfiguration().setPort(0), false); @@ -107,6 +114,7 @@ public class ClientConnectorConfigurationValidationSelfTest extends GridCommonAb * * @throws Exception If failed. */ + @Test public void testPortRange() throws Exception { check(new ClientConnectorConfiguration().setPortRange(-1), false); @@ -122,6 +130,7 @@ public class ClientConnectorConfigurationValidationSelfTest extends GridCommonAb * * @throws Exception If failed. */ + @Test public void testSocketBuffers() throws Exception { check(new ClientConnectorConfiguration().setSocketSendBufferSize(-4 * 1024), false); check(new ClientConnectorConfiguration().setSocketReceiveBufferSize(-4 * 1024), false); @@ -138,6 +147,7 @@ public class ClientConnectorConfigurationValidationSelfTest extends GridCommonAb * * @throws Exception If failed. */ + @Test public void testMaxOpenCusrorsPerConnection() throws Exception { check(new ClientConnectorConfiguration().setMaxOpenCursorsPerConnection(-1), false); @@ -153,6 +163,7 @@ public class ClientConnectorConfigurationValidationSelfTest extends GridCommonAb * * @throws Exception If failed. */ + @Test public void testThreadPoolSize() throws Exception { check(new ClientConnectorConfiguration().setThreadPoolSize(0), false); check(new ClientConnectorConfiguration().setThreadPoolSize(-1), false); @@ -166,6 +177,7 @@ public class ClientConnectorConfigurationValidationSelfTest extends GridCommonAb * * @throws Exception If failed. */ + @Test public void testOdbcConnectorConversion() throws Exception { int port = ClientConnectorConfiguration.DFLT_PORT - 1; @@ -183,6 +195,7 @@ public class ClientConnectorConfigurationValidationSelfTest extends GridCommonAb * * @throws Exception If failed. */ + @Test public void testSqlConnectorConversion() throws Exception { int port = ClientConnectorConfiguration.DFLT_PORT - 1; @@ -200,6 +213,7 @@ public class ClientConnectorConfigurationValidationSelfTest extends GridCommonAb * * @throws Exception If failed. */ + @Test public void testIgnoreOdbcWhenSqlSet() throws Exception { int port = ClientConnectorConfiguration.DFLT_PORT - 1; @@ -218,6 +232,7 @@ public class ClientConnectorConfigurationValidationSelfTest extends GridCommonAb * * @throws Exception If failed. */ + @Test public void testIgnoreOdbcAndSqlWhenClientSet() throws Exception { int cliPort = ClientConnectorConfiguration.DFLT_PORT - 1; int sqlPort = ClientConnectorConfiguration.DFLT_PORT - 2; @@ -239,6 +254,7 @@ public class ClientConnectorConfigurationValidationSelfTest extends GridCommonAb * * @throws Exception If failed. */ + @Test public void testIgnoreOdbcWhenClientSet() throws Exception { int cliPort = ClientConnectorConfiguration.DFLT_PORT - 1; int odbcPort = ClientConnectorConfiguration.DFLT_PORT - 2; @@ -258,6 +274,7 @@ public class ClientConnectorConfigurationValidationSelfTest extends GridCommonAb * * @throws Exception If failed. */ + @Test public void testIgnoreSqlWhenClientSet() throws Exception { int cliPort = ClientConnectorConfiguration.DFLT_PORT - 1; int sqlPort = ClientConnectorConfiguration.DFLT_PORT - 2; @@ -277,6 +294,7 @@ public class ClientConnectorConfigurationValidationSelfTest extends GridCommonAb * * @throws Exception If failed. */ + @Test public void testDisabled() throws Exception { IgniteConfiguration cfg = baseConfiguration(); @@ -298,6 +316,7 @@ public class ClientConnectorConfigurationValidationSelfTest extends GridCommonAb * * @throws Exception If failed. */ + @Test public void testJdbcConnectionEnabled() throws Exception { IgniteConfiguration cfg = baseConfiguration(); @@ -316,6 +335,7 @@ public class ClientConnectorConfigurationValidationSelfTest extends GridCommonAb * * @throws Exception If failed. */ + @Test public void testJdbcConnectionDisabled() throws Exception { IgniteConfiguration cfg = baseConfiguration(); @@ -340,6 +360,7 @@ public class ClientConnectorConfigurationValidationSelfTest extends GridCommonAb * * @throws Exception If failed. */ + @Test public void testJdbcConnectionDisabledForDaemon() throws Exception { final IgniteConfiguration cfg = baseConfiguration().setDaemon(true); http://git-wip-us.apache.org/repos/asf/ignite/blob/c5197e0a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/client/IgniteDataStreamerTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/client/IgniteDataStreamerTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/client/IgniteDataStreamerTest.java index 1bfb02e..415c05b 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/client/IgniteDataStreamerTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/client/IgniteDataStreamerTest.java @@ -28,11 +28,15 @@ import org.apache.ignite.internal.processors.datastreamer.DataStreamerImpl; import org.apache.ignite.lang.IgniteFuture; import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CachePeekMode.ALL; /** */ +@RunWith(JUnit4.class) public class IgniteDataStreamerTest extends GridCommonAbstractTest { public static final String CACHE_NAME = "UUID_CACHE"; @@ -83,6 +87,7 @@ public class IgniteDataStreamerTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testStreamerIgniteUuid() throws Exception { Ignite client = grid("client"); http://git-wip-us.apache.org/repos/asf/ignite/blob/c5197e0a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbSingleNodeWithIndexingPutGetTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbSingleNodeWithIndexingPutGetTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbSingleNodeWithIndexingPutGetTest.java index 2971fff..0fd9ff1 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbSingleNodeWithIndexingPutGetTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbSingleNodeWithIndexingPutGetTest.java @@ -34,10 +34,14 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.S; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgniteDbSingleNodeWithIndexingPutGetTest extends IgniteDbSingleNodePutGetTest { /** {@inheritDoc} */ @Override protected boolean indexingEnabled() { @@ -46,6 +50,7 @@ public class IgniteDbSingleNodeWithIndexingPutGetTest extends IgniteDbSingleNode /** */ + @Test public void testGroupIndexes() { IgniteEx ig = grid(0); @@ -74,6 +79,7 @@ public class IgniteDbSingleNodeWithIndexingPutGetTest extends IgniteDbSingleNode /** */ + @Test public void testGroupIndexes2() { IgniteEx ig = grid(0); http://git-wip-us.apache.org/repos/asf/ignite/blob/c5197e0a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbSingleNodeWithIndexingWalRestoreTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbSingleNodeWithIndexingWalRestoreTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbSingleNodeWithIndexingWalRestoreTest.java index 6d80219..c9e20f5 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbSingleNodeWithIndexingWalRestoreTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbSingleNodeWithIndexingWalRestoreTest.java @@ -35,11 +35,15 @@ import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test verifies that binary metadata of values stored in cache and indexes upon these values * is handled correctly on cluster restart when persistent store is enabled and compact footer is turned on. */ +@RunWith(JUnit4.class) public class IgniteDbSingleNodeWithIndexingWalRestoreTest extends GridCommonAbstractTest { /** */ private static final String BINARY_TYPE_NAME = "BinaryPerson"; @@ -125,6 +129,7 @@ public class IgniteDbSingleNodeWithIndexingWalRestoreTest extends GridCommonAbst /** * Test for values without class created with BinaryObjectBuilder. */ + @Test public void testClasslessBinaryValuesRestored() throws Exception { IgniteEx ig = startGrid(0); @@ -162,6 +167,7 @@ public class IgniteDbSingleNodeWithIndexingWalRestoreTest extends GridCommonAbst * Test for regular objects stored in cache with compactFooter=true setting * (no metainformation to deserialize values is stored with values themselves). */ + @Test public void testRegularClassesRestored() throws Exception { IgniteEx ig = startGrid(0); http://git-wip-us.apache.org/repos/asf/ignite/blob/c5197e0a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgnitePersistentStoreQueryWithMultipleClassesPerCacheTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgnitePersistentStoreQueryWithMultipleClassesPerCacheTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgnitePersistentStoreQueryWithMultipleClassesPerCacheTest.java index b0bcff0..493edbf 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgnitePersistentStoreQueryWithMultipleClassesPerCacheTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgnitePersistentStoreQueryWithMultipleClassesPerCacheTest.java @@ -32,12 +32,16 @@ import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteSystemProperties.IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK; /** * */ +@RunWith(JUnit4.class) public class IgnitePersistentStoreQueryWithMultipleClassesPerCacheTest extends GridCommonAbstractTest { /** */ private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); @@ -104,6 +108,7 @@ public class IgnitePersistentStoreQueryWithMultipleClassesPerCacheTest extends G /** * @throws Exception If failed. */ + @Test public void testSimple() throws Exception { IgniteEx ig0 = startGrid(0); @@ -173,4 +178,4 @@ public class IgnitePersistentStoreQueryWithMultipleClassesPerCacheTest extends G @QuerySqlField private UUID uuid = UUID.randomUUID(); } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/ignite/blob/c5197e0a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgnitePersistentStoreSchemaLoadTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgnitePersistentStoreSchemaLoadTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgnitePersistentStoreSchemaLoadTest.java index 4671698..53c3dd9 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgnitePersistentStoreSchemaLoadTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgnitePersistentStoreSchemaLoadTest.java @@ -39,12 +39,16 @@ import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteSystemProperties.IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK; /** * */ +@RunWith(JUnit4.class) public class IgnitePersistentStoreSchemaLoadTest extends GridCommonAbstractTest { /** */ private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); @@ -134,16 +138,19 @@ public class IgnitePersistentStoreSchemaLoadTest extends GridCommonAbstractTest } /** */ + @Test public void testDynamicSchemaChangesPersistence() throws Exception { checkSchemaStateAfterNodeRestart(false); } /** */ + @Test public void testDynamicSchemaChangesPersistenceWithAliveCluster() throws Exception { checkSchemaStateAfterNodeRestart(true); } /** */ + @Test public void testDynamicSchemaChangesPersistenceWithStaticCache() throws Exception { IgniteEx node = startGrid(getConfigurationWithStaticCache(getTestIgniteInstanceName(0))); http://git-wip-us.apache.org/repos/asf/ignite/blob/c5197e0a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgniteTwoRegionsRebuildIndexTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgniteTwoRegionsRebuildIndexTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgniteTwoRegionsRebuildIndexTest.java index 7d5b296..293ad09 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgniteTwoRegionsRebuildIndexTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgniteTwoRegionsRebuildIndexTest.java @@ -24,10 +24,14 @@ import org.apache.ignite.configuration.DataRegionConfiguration; import org.apache.ignite.configuration.DataStorageConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests the case when preformed index rebuild for created by client in-memory cache. */ +@RunWith(JUnit4.class) public class IgniteTwoRegionsRebuildIndexTest extends GridCommonAbstractTest { /** */ private static final String PERSISTED_CACHE = "persisted"; @@ -93,6 +97,7 @@ public class IgniteTwoRegionsRebuildIndexTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testRebuildIndexes() throws Exception { startGrid("server"); Ignite client = startGrid("client"); http://git-wip-us.apache.org/repos/asf/ignite/blob/c5197e0a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteCacheGroupsSqlSegmentedIndexSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteCacheGroupsSqlSegmentedIndexSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteCacheGroupsSqlSegmentedIndexSelfTest.java index c0a4fb2..161cfd0 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteCacheGroupsSqlSegmentedIndexSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteCacheGroupsSqlSegmentedIndexSelfTest.java @@ -18,10 +18,14 @@ package org.apache.ignite.internal.processors.query; import org.apache.ignite.configuration.CacheConfiguration; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgniteCacheGroupsSqlSegmentedIndexSelfTest extends IgniteSqlSegmentedIndexSelfTest { /** {@inheritDoc} */ @Override protected <K, V> CacheConfiguration<K, V> cacheConfig(String name, boolean partitioned, Class<?>... idxTypes) { @@ -31,6 +35,7 @@ public class IgniteCacheGroupsSqlSegmentedIndexSelfTest extends IgniteSqlSegment /** * @throws Exception If failed. */ + @Test @Override public void testSegmentedPartitionedWithReplicated() throws Exception { log.info("Test is ignored"); } http://git-wip-us.apache.org/repos/asf/ignite/blob/c5197e0a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteCachelessQueriesSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteCachelessQueriesSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteCachelessQueriesSelfTest.java index 47ec1dd..001d6cf 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteCachelessQueriesSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteCachelessQueriesSelfTest.java @@ -35,10 +35,14 @@ import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for behavior in various cases of local and distributed queries. */ +@RunWith(JUnit4.class) public class IgniteCachelessQueriesSelfTest extends GridCommonAbstractTest { /** */ private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); @@ -109,6 +113,7 @@ public class IgniteCachelessQueriesSelfTest extends GridCommonAbstractTest { /** * */ + @Test public void testDistributedQueryOnPartitionedCaches() { createCachesAndExecuteQuery(TestCacheMode.PARTITIONED, TestCacheMode.PARTITIONED, false, false); @@ -118,6 +123,7 @@ public class IgniteCachelessQueriesSelfTest extends GridCommonAbstractTest { /** * */ + @Test public void testDistributedQueryOnPartitionedAndReplicatedCache() { createCachesAndExecuteQuery(TestCacheMode.PARTITIONED, TestCacheMode.REPLICATED, false, false); @@ -127,6 +133,7 @@ public class IgniteCachelessQueriesSelfTest extends GridCommonAbstractTest { /** * */ + @Test public void testDistributedQueryOnReplicatedCaches() { createCachesAndExecuteQuery(TestCacheMode.REPLICATED, TestCacheMode.REPLICATED, false, false); @@ -136,6 +143,7 @@ public class IgniteCachelessQueriesSelfTest extends GridCommonAbstractTest { /** * */ + @Test public void testDistributedQueryOnSegmentedCaches() { createCachesAndExecuteQuery(TestCacheMode.SEGMENTED, TestCacheMode.SEGMENTED, false, false); @@ -145,6 +153,7 @@ public class IgniteCachelessQueriesSelfTest extends GridCommonAbstractTest { /** * */ + @Test public void testDistributedQueryOnReplicatedAndSegmentedCache() { createCachesAndExecuteQuery(TestCacheMode.REPLICATED, TestCacheMode.SEGMENTED, false, false); @@ -154,6 +163,7 @@ public class IgniteCachelessQueriesSelfTest extends GridCommonAbstractTest { /** * */ + @Test public void testDistributedQueryOnPartitionedCachesWithReplicatedFlag() { createCachesAndExecuteQuery(TestCacheMode.PARTITIONED, TestCacheMode.PARTITIONED, true, false); @@ -163,6 +173,7 @@ public class IgniteCachelessQueriesSelfTest extends GridCommonAbstractTest { /** * */ + @Test public void testDistributedQueryOnPartitionedAndReplicatedCacheWithReplicatedFlag() { createCachesAndExecuteQuery(TestCacheMode.PARTITIONED, TestCacheMode.REPLICATED, true, false); @@ -172,6 +183,7 @@ public class IgniteCachelessQueriesSelfTest extends GridCommonAbstractTest { /** * */ + @Test public void testLocalQueryOnReplicatedCachesWithReplicatedFlag() { createCachesAndExecuteQuery(TestCacheMode.REPLICATED, TestCacheMode.REPLICATED, true, false); @@ -181,6 +193,7 @@ public class IgniteCachelessQueriesSelfTest extends GridCommonAbstractTest { /** * */ + @Test public void testDistributedQueryOnSegmentedCachesWithReplicatedFlag() { createCachesAndExecuteQuery(TestCacheMode.SEGMENTED, TestCacheMode.SEGMENTED, true, false); @@ -190,6 +203,7 @@ public class IgniteCachelessQueriesSelfTest extends GridCommonAbstractTest { /** * */ + @Test public void testDistributedQueryOnReplicatedAndSegmentedCacheWithReplicatedFlag() { createCachesAndExecuteQuery(TestCacheMode.REPLICATED, TestCacheMode.SEGMENTED, true, false); @@ -199,6 +213,7 @@ public class IgniteCachelessQueriesSelfTest extends GridCommonAbstractTest { /** * */ + @Test public void testLocalQueryOnPartitionedCachesWithLocalFlag() { createCachesAndExecuteQuery(TestCacheMode.PARTITIONED, TestCacheMode.PARTITIONED, false, true); @@ -208,6 +223,7 @@ public class IgniteCachelessQueriesSelfTest extends GridCommonAbstractTest { /** * */ + @Test public void testLocalQueryOnPartitionedAndReplicatedCacheWithLocalFlag() { createCachesAndExecuteQuery(TestCacheMode.PARTITIONED, TestCacheMode.REPLICATED, false, true); @@ -217,6 +233,7 @@ public class IgniteCachelessQueriesSelfTest extends GridCommonAbstractTest { /** * */ + @Test public void testLocalQueryOnReplicatedCachesWithLocalFlag() { createCachesAndExecuteQuery(TestCacheMode.REPLICATED, TestCacheMode.REPLICATED, false, true); @@ -226,6 +243,7 @@ public class IgniteCachelessQueriesSelfTest extends GridCommonAbstractTest { /** * */ + @Test public void testLocalTwoStepQueryOnSegmentedCachesWithLocalFlag() { createCachesAndExecuteQuery(TestCacheMode.SEGMENTED, TestCacheMode.SEGMENTED, false, true); @@ -235,6 +253,7 @@ public class IgniteCachelessQueriesSelfTest extends GridCommonAbstractTest { /** * */ + @Test public void testLocalTwoStepQueryOnReplicatedAndSegmentedCacheWithLocalFlag() { createCachesAndExecuteQuery(TestCacheMode.REPLICATED, TestCacheMode.SEGMENTED, false, true); @@ -244,6 +263,7 @@ public class IgniteCachelessQueriesSelfTest extends GridCommonAbstractTest { /** * */ + @Test public void testLocalQueryOnPartitionedCachesWithReplicatedAndLocalFlag() { createCachesAndExecuteQuery(TestCacheMode.PARTITIONED, TestCacheMode.PARTITIONED, false, true); @@ -253,6 +273,7 @@ public class IgniteCachelessQueriesSelfTest extends GridCommonAbstractTest { /** * */ + @Test public void testLocalQueryOnPartitionedAndReplicatedCacheWithReplicatedAndLocalFlag() { createCachesAndExecuteQuery(TestCacheMode.PARTITIONED, TestCacheMode.REPLICATED, true, true); @@ -262,6 +283,7 @@ public class IgniteCachelessQueriesSelfTest extends GridCommonAbstractTest { /** * */ + @Test public void testLocalQueryOnReplicatedCachesWithReplicatedAndLocalFlag() { createCachesAndExecuteQuery(TestCacheMode.REPLICATED, TestCacheMode.REPLICATED, true, true); @@ -271,6 +293,7 @@ public class IgniteCachelessQueriesSelfTest extends GridCommonAbstractTest { /** * */ + @Test public void testLocalTwoStepQueryOnSegmentedCachesWithReplicatedAndLocalFlag() { createCachesAndExecuteQuery(TestCacheMode.SEGMENTED, TestCacheMode.SEGMENTED, true, true); @@ -280,6 +303,7 @@ public class IgniteCachelessQueriesSelfTest extends GridCommonAbstractTest { /** * */ + @Test public void testLocalTwoStepQueryOnReplicatedAndSegmentedCacheWithReplicatedAndLocalFlag() { createCachesAndExecuteQuery(TestCacheMode.REPLICATED, TestCacheMode.SEGMENTED, true, true); http://git-wip-us.apache.org/repos/asf/ignite/blob/c5197e0a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteQueryDedicatedPoolTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteQueryDedicatedPoolTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteQueryDedicatedPoolTest.java index b2f4e47..c4ed9bd 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteQueryDedicatedPoolTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteQueryDedicatedPoolTest.java @@ -46,10 +46,14 @@ import org.apache.ignite.spi.indexing.IndexingQueryFilter; import org.apache.ignite.spi.indexing.IndexingSpi; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Ensures that SQL queries are executed in a dedicated thread pool. */ +@RunWith(JUnit4.class) public class IgniteQueryDedicatedPoolTest extends GridCommonAbstractTest { /** IP finder. */ private static final TcpDiscoveryVmIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); @@ -101,6 +105,7 @@ public class IgniteQueryDedicatedPoolTest extends GridCommonAbstractTest { * @throws Exception If failed. * @see GridCacheTwoStepQuery#isLocal() */ + @Test public void testSqlQueryUsesDedicatedThreadPool() throws Exception { try (Ignite client = startGrid("client")) { IgniteCache<Integer, Integer> cache = client.cache(CACHE_NAME); @@ -129,6 +134,7 @@ public class IgniteQueryDedicatedPoolTest extends GridCommonAbstractTest { * Tests that Scan queries are executed in dedicated pool * @throws Exception If failed. */ + @Test public void testScanQueryUsesDedicatedThreadPool() throws Exception { try (Ignite client = startGrid("client")) { IgniteCache<Integer, Integer> cache = client.cache(CACHE_NAME); @@ -152,6 +158,7 @@ public class IgniteQueryDedicatedPoolTest extends GridCommonAbstractTest { * Tests that SPI queries are executed in dedicated pool * @throws Exception If failed. */ + @Test public void testSpiQueryUsesDedicatedThreadPool() throws Exception { try (Ignite client = startGrid("client")) { IgniteCache<Byte, Byte> cache = client.cache(CACHE_NAME); http://git-wip-us.apache.org/repos/asf/ignite/blob/c5197e0a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlDefaultValueTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlDefaultValueTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlDefaultValueTest.java index f4c0539..24cb13f 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlDefaultValueTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlDefaultValueTest.java @@ -32,9 +32,13 @@ import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** */ @SuppressWarnings("ThrowableNotThrown") +@RunWith(JUnit4.class) public class IgniteSqlDefaultValueTest extends GridCommonAbstractTest { /** IP finder. */ private static final TcpDiscoveryVmIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); @@ -88,6 +92,7 @@ public class IgniteSqlDefaultValueTest extends GridCommonAbstractTest { /** */ + @Test public void testDefaultValueColumn() { sql("CREATE TABLE TEST (id int, val0 varchar DEFAULT 'default-val', primary key (id))"); sql("INSERT INTO TEST (id) VALUES (?)", 1); @@ -107,6 +112,7 @@ public class IgniteSqlDefaultValueTest extends GridCommonAbstractTest { /** */ + @Test public void testDefaultValueColumnAfterUpdate() { sql("CREATE TABLE TEST (id int, val0 varchar DEFAULT 'default-val', val1 varchar, primary key (id))"); sql("INSERT INTO TEST (id, val1) VALUES (?, ?)", 1, "val-10"); @@ -138,6 +144,7 @@ public class IgniteSqlDefaultValueTest extends GridCommonAbstractTest { /** */ + @Test public void testEmptyValueNullDefaults() { sql("CREATE TABLE TEST (id int, val0 varchar, primary key (id))"); sql("INSERT INTO TEST (id) VALUES (?)", 1); @@ -155,6 +162,7 @@ public class IgniteSqlDefaultValueTest extends GridCommonAbstractTest { /** */ + @Test public void testAddColumnWithDefaults() { sql("CREATE TABLE TEST (id int, val0 varchar, primary key (id))"); @@ -169,6 +177,7 @@ public class IgniteSqlDefaultValueTest extends GridCommonAbstractTest { /** */ + @Test public void testDefaultTypes() { assertEquals("Check tinyint", (byte)28, getDefaultObject("TINYINT", "28")); assertEquals("Check smallint", (short)28, getDefaultObject("SMALLINT", "28")); http://git-wip-us.apache.org/repos/asf/ignite/blob/c5197e0a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlDistributedJoinSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlDistributedJoinSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlDistributedJoinSelfTest.java index 4b993ec..d22c67a 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlDistributedJoinSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlDistributedJoinSelfTest.java @@ -29,10 +29,14 @@ import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for correct distributed sql joins. */ +@RunWith(JUnit4.class) public class IgniteSqlDistributedJoinSelfTest extends GridCommonAbstractTest { /** */ private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); @@ -84,6 +88,7 @@ public class IgniteSqlDistributedJoinSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testNonCollocatedDistributedJoin() throws Exception { CacheConfiguration ccfg1 = cacheConfig("pers", true, String.class, Person.class); CacheConfiguration ccfg2 = cacheConfig("org", true, String.class, Organization.class); http://git-wip-us.apache.org/repos/asf/ignite/blob/c5197e0a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlEntryCacheModeAgnosticTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlEntryCacheModeAgnosticTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlEntryCacheModeAgnosticTest.java index db7ca39..2b196d3 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlEntryCacheModeAgnosticTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlEntryCacheModeAgnosticTest.java @@ -29,6 +29,9 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import java.util.List; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.LOCAL; @@ -38,6 +41,7 @@ import static org.apache.ignite.cache.CacheMode.REPLICATED; /** * Test different cache modes for query entry */ +@RunWith(JUnit4.class) public class IgniteSqlEntryCacheModeAgnosticTest extends GridCommonAbstractTest { /** IP finder. */ private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); @@ -116,6 +120,7 @@ public class IgniteSqlEntryCacheModeAgnosticTest extends GridCommonAbstractTest /** * It should not matter what cache mode does entry cache use, if there is no join */ + @Test public void testCrossCacheModeQuery() throws Exception { Ignite ignite = startGrid(); http://git-wip-us.apache.org/repos/asf/ignite/blob/c5197e0a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlGroupConcatCollocatedTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlGroupConcatCollocatedTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlGroupConcatCollocatedTest.java index 05d29bf..e290009 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlGroupConcatCollocatedTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlGroupConcatCollocatedTest.java @@ -34,11 +34,15 @@ import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for GROUP_CONCAT aggregate function in collocated mode. */ @SuppressWarnings("unchecked") +@RunWith(JUnit4.class) public class IgniteSqlGroupConcatCollocatedTest extends GridCommonAbstractTest { /** */ private static final int CLIENT = 7; @@ -115,6 +119,7 @@ public class IgniteSqlGroupConcatCollocatedTest extends GridCommonAbstractTest { /** * */ + @Test public void testGroupConcatSimple() { IgniteCache c = ignite(CLIENT).cache(CACHE_NAME); @@ -139,6 +144,7 @@ public class IgniteSqlGroupConcatCollocatedTest extends GridCommonAbstractTest { /** * */ + @Test public void testGroupConcatOrderBy() { IgniteCache c = ignite(CLIENT).cache(CACHE_NAME); @@ -164,6 +170,7 @@ public class IgniteSqlGroupConcatCollocatedTest extends GridCommonAbstractTest { /** * */ + @Test public void testGroupConcatWithDistinct() { IgniteCache c = ignite(CLIENT).cache(CACHE_NAME); http://git-wip-us.apache.org/repos/asf/ignite/blob/c5197e0a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlGroupConcatNotCollocatedTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlGroupConcatNotCollocatedTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlGroupConcatNotCollocatedTest.java index fbd38f7..d9603e3 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlGroupConcatNotCollocatedTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlGroupConcatNotCollocatedTest.java @@ -33,11 +33,15 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for GROUP_CONCAT aggregate function in not collocated mode. */ @SuppressWarnings("unchecked") +@RunWith(JUnit4.class) public class IgniteSqlGroupConcatNotCollocatedTest extends GridCommonAbstractTest { /** */ private static final int CLIENT = 7; @@ -99,6 +103,7 @@ public class IgniteSqlGroupConcatNotCollocatedTest extends GridCommonAbstractTes /** * */ + @Test public void testGroupConcatSimple() { IgniteCache c = ignite(CLIENT).cache(CACHE_NAME); @@ -122,6 +127,7 @@ public class IgniteSqlGroupConcatNotCollocatedTest extends GridCommonAbstractTes /** * */ + @Test public void testGroupConcatCountDistinct() { IgniteCache c = ignite(CLIENT).cache(CACHE_NAME); @@ -145,6 +151,7 @@ public class IgniteSqlGroupConcatNotCollocatedTest extends GridCommonAbstractTes /** * */ + @Test public void testGroupConcatDistributedException() { final IgniteCache c = ignite(CLIENT).cache(CACHE_NAME); http://git-wip-us.apache.org/repos/asf/ignite/blob/c5197e0a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlKeyValueFieldsTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlKeyValueFieldsTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlKeyValueFieldsTest.java index 268104e..fabe862 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlKeyValueFieldsTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlKeyValueFieldsTest.java @@ -1,391 +1,404 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.processors.query; - -import org.apache.ignite.IgniteCache; -import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.cache.QueryEntity; -import org.apache.ignite.cache.query.QueryCursor; -import org.apache.ignite.cache.query.SqlFieldsQuery; -import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.internal.IgniteEx; -import org.apache.ignite.internal.binary.BinaryMarshaller; -import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; -import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; -import org.apache.ignite.testframework.GridTestUtils; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.concurrent.Callable; - -/** - * Test hidden _key, _val, _ver columns - */ -public class IgniteSqlKeyValueFieldsTest extends GridCommonAbstractTest { - - /** IP finder. */ - private static final TcpDiscoveryVmIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - - /** */ - private static String NODE_BAD_CONF_MISS_KEY_FIELD = "badConf1"; - /** */ - private static String NODE_BAD_CONF_MISS_VAL_FIELD = "badConf2"; - /** */ - private static String NODE_CLIENT = "client"; - - /** */ - private static String CACHE_PERSON_NO_KV = "PersonNoKV"; - /** */ - private static String CACHE_INT_NO_KV_TYPE = "IntNoKVType"; - /** */ - private static String CACHE_PERSON = "Person"; - /** */ - private static String CACHE_JOB = "Job"; - - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration c = super.getConfiguration(gridName); - - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - c.setDiscoverySpi(disco); - - c.setMarshaller(new BinaryMarshaller()); - - List<CacheConfiguration> ccfgs = new ArrayList<>(); - CacheConfiguration ccfg = buildCacheConfiguration(gridName); - if (ccfg != null) - ccfgs.add(ccfg); - - ccfgs.add(buildCacheConfiguration(CACHE_PERSON_NO_KV)); - ccfgs.add(buildCacheConfiguration(CACHE_INT_NO_KV_TYPE)); - ccfgs.add(buildCacheConfiguration(CACHE_PERSON)); - ccfgs.add(buildCacheConfiguration(CACHE_JOB)); - - c.setCacheConfiguration(ccfgs.toArray(new CacheConfiguration[ccfgs.size()])); - if (gridName.equals(NODE_CLIENT)) - c.setClientMode(true); - - return c; - } - - /** {@inheritDoc} */ - @Override protected void beforeTest() throws Exception { - super.beforeTest(); - - startGrid(0); - startGrid(NODE_CLIENT); - } - - /** {@inheritDoc} */ - @Override protected void afterTest() throws Exception { - super.afterTest(); - - stopAllGrids(); - } - - private CacheConfiguration buildCacheConfiguration(String name) { - if (name.equals(NODE_BAD_CONF_MISS_KEY_FIELD)) { - CacheConfiguration ccfg = new CacheConfiguration(NODE_BAD_CONF_MISS_KEY_FIELD); - QueryEntity qe = new QueryEntity(Object.class.getName(), Object.class.getName()); - qe.setKeyFieldName("k"); - qe.addQueryField("a", Integer.class.getName(), null); - ccfg.setQueryEntities(F.asList(qe)); - return ccfg; - } - else if (name.equals(NODE_BAD_CONF_MISS_VAL_FIELD)) { - CacheConfiguration ccfg = new CacheConfiguration(NODE_BAD_CONF_MISS_VAL_FIELD); - QueryEntity qe = new QueryEntity(Object.class.getName(), Object.class.getName()); - qe.setValueFieldName("v"); - qe.addQueryField("a", Integer.class.getName(), null); - ccfg.setQueryEntities(F.asList(qe)); - return ccfg; - } - else if (name.equals(CACHE_PERSON_NO_KV)) { - CacheConfiguration ccfg = new CacheConfiguration(CACHE_PERSON_NO_KV); - - QueryEntity entity = new QueryEntity(); - - entity.setKeyType(Integer.class.getName()); - entity.setValueType(Person.class.getName()); - - LinkedHashMap<String, String> fields = new LinkedHashMap<>(); - fields.put("name", String.class.getName()); - fields.put("age", Integer.class.getName()); - - entity.setFields(fields); - - ccfg.setQueryEntities(Arrays.asList(entity)); - return ccfg; - } - else if (name.equals(CACHE_INT_NO_KV_TYPE)) { - CacheConfiguration ccfg = new CacheConfiguration(CACHE_INT_NO_KV_TYPE); - QueryEntity entity = new QueryEntity(); - - entity.setKeyType(null); - entity.setValueType(null); - - entity.setKeyFieldName("id"); - entity.setValueFieldName("v"); - - LinkedHashMap<String, String> fields = new LinkedHashMap<>(); - fields.put("id", Integer.class.getName()); - fields.put("v", Integer.class.getName()); - - entity.setFields(fields); - - ccfg.setQueryEntities(Arrays.asList(entity)); - return ccfg; - } - else if (name.equals(CACHE_PERSON)) { - CacheConfiguration ccfg = new CacheConfiguration(CACHE_PERSON); - - QueryEntity entity = new QueryEntity(); - - entity.setKeyType(Integer.class.getName()); - entity.setValueType(Person.class.getName()); - - entity.setKeyFieldName("id"); - entity.setValueFieldName("v"); - - LinkedHashMap<String, String> fields = new LinkedHashMap<>(); - fields.put("name", String.class.getName()); - fields.put("age", Integer.class.getName()); - - fields.put(entity.getKeyFieldName(), entity.getKeyType()); - fields.put(entity.getValueFieldName(), entity.getValueType()); - - entity.setFields(fields); - - ccfg.setQueryEntities(Arrays.asList(entity)); - return ccfg; - } - else if (name.equals(CACHE_JOB)) { - CacheConfiguration ccfg = new CacheConfiguration(CACHE_JOB); - ccfg.setIndexedTypes(Integer.class, Integer.class); - return ccfg; - } - return null; - } - - /** Test for setIndexedTypes() primitive types */ - public void testSetIndexTypesPrimitive() throws Exception { - IgniteCache<Integer, Integer> cache = grid(NODE_CLIENT).cache(CACHE_JOB); - - checkInsert(cache, "insert into Integer (_key, _val) values (?,?)", 1, 100); - - checkSelect(cache, "select * from Integer", 1, 100); - checkSelect(cache, "select _key, _val from Integer", 1, 100); - } - - /** Test configuration error : keyFieldName is missing from fields */ - public void testErrorKeyFieldMissingFromFields() throws Exception { - checkCacheStartupError(NODE_BAD_CONF_MISS_KEY_FIELD); - } - - /** Test configuration error : valueFieldName is missing from fields */ - public void testErrorValueFieldMissingFromFields() throws Exception { - checkCacheStartupError(NODE_BAD_CONF_MISS_VAL_FIELD); - } - - /** */ - private void checkCacheStartupError(final String name) { - GridTestUtils.assertThrows(log, new Callable<Void>() { - @Override public Void call() throws Exception { - startGrid(name); - - return null; - } - }, IgniteCheckedException.class, null); - } - - /** - * Check that it is allowed to leave QE.keyType and QE.valueType unset - * in case keyFieldName and valueFieldName are set and present in fields - */ - public void testQueryEntityAutoKeyValTypes() throws Exception { - IgniteCache<Integer, Integer> cache = grid(NODE_CLIENT).cache(CACHE_INT_NO_KV_TYPE); - - checkInsert(cache, "insert into Integer (_key, _val) values (?,?)", 1, 100); - - checkSelect(cache, "select * from Integer where id = 1", 1, 100); - - checkSelect(cache, "select * from Integer", 1, 100); - checkSelect(cache, "select _key, _val from Integer", 1, 100); - checkSelect(cache, "select id, v from Integer", 1, 100); - } - - /** Check that it is possible to not have keyFieldName and valueFieldName */ - public void testNoKeyValueAliases() throws Exception { - IgniteCache<Integer, Person> cache = grid(NODE_CLIENT).cache(CACHE_PERSON_NO_KV); - - Person alice = new Person("Alice", 1); - checkInsert(cache, "insert into Person (_key, _val) values (?,?)", 1, alice); - - checkSelect(cache, "select * from Person", alice.name, alice.age); - checkSelect(cache, "select _key, _val from Person", 1, alice); - } - - /** Check keyFieldName and valueFieldName columns access */ - public void testKeyValueAlias() throws Exception { - //_key, _val, _ver | name, age, id, v - Person alice = new Person("Alice", 1); - Person bob = new Person("Bob", 2); - - IgniteCache<Integer, Person> cache = grid(NODE_CLIENT).cache(CACHE_PERSON); - - checkInsert(cache, "insert into Person (_key, _val) values (?,?)", 1, alice); - checkInsert(cache, "insert into Person (id, v) values (?,?)", 2, bob); - - checkSelect(cache, "select * from Person where _key=1", alice.name, alice.age, 1, alice); - checkSelect(cache, "select _key, _val from Person where id=1", 1, alice); - - checkSelect(cache, "select * from Person where _key=2", bob.name, bob.age, 2, bob); - checkSelect(cache, "select _key, _val from Person where id=2", 2, bob); - - checkInsert(cache, "update Person set age = ? where id = ?", 3, 1); - checkSelect(cache, "select _key, age from Person where id=1", 1, 3); - - checkInsert(cache, "update Person set v = ? where id = ?", alice, 1); - checkSelect(cache, "select _key, _val from Person where id=1", 1, alice); - } - - /** Check _ver version field is accessible */ - public void testVersionField() throws Exception { - Person alice = new Person("Alice", 1); - Person bob = new Person("Bob", 2); - - IgniteCache<Integer, Person> cache = grid(NODE_CLIENT).cache(CACHE_PERSON); - - checkInsert(cache, "insert into Person (id, v) values (?,?)", 1, alice); - assertNotNull(getVersion(cache, 1)); - - checkInsert(cache, "insert into Person (id, v) values (?,?)", 2, bob); - assertNotNull(getVersion(cache, 2)); - - GridCacheVersion v1 = getVersion(cache, 1); - - checkInsert(cache, "update Person set age = ? where id = ?", 3, 1); - - GridCacheVersion v2 = getVersion(cache, 1); - - assertFalse( v1.equals(v2) ); - } - - /** Check that joins are working on keyFieldName, valueFieldName columns */ - public void testJoinKeyValFields() throws Exception { - IgniteEx client = grid(NODE_CLIENT); - IgniteCache<Integer, Person> cache = client.cache(CACHE_PERSON); - IgniteCache<Integer, Integer> cache2 = client.cache(CACHE_JOB); - - checkInsert(cache, "insert into Person (id, v) values (?, ?)", 1, new Person("Bob", 30)); - checkInsert(cache, "insert into Person (id, v) values (?, ?)", 2, new Person("David", 35)); - checkInsert(cache2, "insert into Integer (_key, _val) values (?, ?)", 100, 1); - checkInsert(cache2, "insert into Integer (_key, _val) values (?, ?)", 200, 2); - - QueryCursor<List<?>> cursor = cache.query(new SqlFieldsQuery("select p.id, j._key from Person p, \""+ CACHE_JOB +"\".Integer j where p.id = j._val")); - List<List<?>> results = cursor.getAll(); - assertEquals(2, results.size()); - assertEquals(1, results.get(0).get(0)); - assertEquals(100, results.get(0).get(1)); - assertEquals(2, results.get(1).get(0)); - assertEquals(200, results.get(1).get(1)); - } - - /** Check automatic addition of index for keyFieldName column */ - public void testAutoKeyFieldIndex() throws Exception { - IgniteEx client = grid(NODE_CLIENT); - IgniteCache<Integer, Person> cache = client.cache(CACHE_PERSON); - - QueryCursor<List<?>> cursor = cache.query(new SqlFieldsQuery("explain select * from Person where id = 1")); - List<List<?>> results = cursor.getAll(); - assertEquals(2, results.size()); - assertTrue(((String)results.get(0).get(0)).contains("\"_key_PK_proxy\"")); - - cursor = cache.query(new SqlFieldsQuery("explain select * from Person where _key = 1")); - results = cursor.getAll(); - assertEquals(2, results.size()); - assertTrue(((String)results.get(0).get(0)).contains("\"_key_PK\"")); - } - - /** */ - private GridCacheVersion getVersion(IgniteCache<?, ?> cache, int key) { - QueryCursor<List<?>> cursor = cache.query(new SqlFieldsQuery("select _ver from Person where id = ?").setArgs(key)); - List<List<?>> results = cursor.getAll(); - assertEquals(1, results.size()); - return ((GridCacheVersion) results.get(0).get(0)); - } - - /** */ - private void checkInsert(IgniteCache<?, ?> cache, String qry, Object ... args) throws Exception { - QueryCursor<List<?>> cursor = cache.query(new SqlFieldsQuery(qry).setArgs(args)); - assertEquals(1, ((Number) cursor.getAll().get(0).get(0)).intValue()); - } - - /** */ - private void checkSelect(IgniteCache<?, ?> cache, String selectQry, Object ... expected) { - QueryCursor<List<?>> cursor = cache.query(new SqlFieldsQuery(selectQry)); - - List<List<?>> results = cursor.getAll(); - - assertEquals(1, results.size()); - - List<?> row0 = results.get(0); - for(int col = 0; col < expected.length; ++col) - assertEquals(expected[col], row0.get(col)); - } - - /** */ - private static class Person { - /** */ - private String name; - - /** */ - private int age; - - /** */ - public Person(String name, int age) { - this.name = name; - this.age = age; - } - - /** */ - @Override public int hashCode() { - return name.hashCode() ^ age; - } - - /** */ - @Override public boolean equals(Object o) { - if (this == o) - return true; - if (!(o instanceof Person)) - return false; - Person other = (Person)o; - return name.equals(other.name) && age == other.age; - } - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.query; + +import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.cache.QueryEntity; +import org.apache.ignite.cache.query.QueryCursor; +import org.apache.ignite.cache.query.SqlFieldsQuery; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.binary.BinaryMarshaller; +import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; +import org.apache.ignite.internal.util.typedef.F; +import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; +import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.concurrent.Callable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** + * Test hidden _key, _val, _ver columns + */ +@RunWith(JUnit4.class) +public class IgniteSqlKeyValueFieldsTest extends GridCommonAbstractTest { + + /** IP finder. */ + private static final TcpDiscoveryVmIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); + + /** */ + private static String NODE_BAD_CONF_MISS_KEY_FIELD = "badConf1"; + /** */ + private static String NODE_BAD_CONF_MISS_VAL_FIELD = "badConf2"; + /** */ + private static String NODE_CLIENT = "client"; + + /** */ + private static String CACHE_PERSON_NO_KV = "PersonNoKV"; + /** */ + private static String CACHE_INT_NO_KV_TYPE = "IntNoKVType"; + /** */ + private static String CACHE_PERSON = "Person"; + /** */ + private static String CACHE_JOB = "Job"; + + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { + IgniteConfiguration c = super.getConfiguration(gridName); + + TcpDiscoverySpi disco = new TcpDiscoverySpi(); + + disco.setIpFinder(IP_FINDER); + + c.setDiscoverySpi(disco); + + c.setMarshaller(new BinaryMarshaller()); + + List<CacheConfiguration> ccfgs = new ArrayList<>(); + CacheConfiguration ccfg = buildCacheConfiguration(gridName); + if (ccfg != null) + ccfgs.add(ccfg); + + ccfgs.add(buildCacheConfiguration(CACHE_PERSON_NO_KV)); + ccfgs.add(buildCacheConfiguration(CACHE_INT_NO_KV_TYPE)); + ccfgs.add(buildCacheConfiguration(CACHE_PERSON)); + ccfgs.add(buildCacheConfiguration(CACHE_JOB)); + + c.setCacheConfiguration(ccfgs.toArray(new CacheConfiguration[ccfgs.size()])); + if (gridName.equals(NODE_CLIENT)) + c.setClientMode(true); + + return c; + } + + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + super.beforeTest(); + + startGrid(0); + startGrid(NODE_CLIENT); + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + super.afterTest(); + + stopAllGrids(); + } + + private CacheConfiguration buildCacheConfiguration(String name) { + if (name.equals(NODE_BAD_CONF_MISS_KEY_FIELD)) { + CacheConfiguration ccfg = new CacheConfiguration(NODE_BAD_CONF_MISS_KEY_FIELD); + QueryEntity qe = new QueryEntity(Object.class.getName(), Object.class.getName()); + qe.setKeyFieldName("k"); + qe.addQueryField("a", Integer.class.getName(), null); + ccfg.setQueryEntities(F.asList(qe)); + return ccfg; + } + else if (name.equals(NODE_BAD_CONF_MISS_VAL_FIELD)) { + CacheConfiguration ccfg = new CacheConfiguration(NODE_BAD_CONF_MISS_VAL_FIELD); + QueryEntity qe = new QueryEntity(Object.class.getName(), Object.class.getName()); + qe.setValueFieldName("v"); + qe.addQueryField("a", Integer.class.getName(), null); + ccfg.setQueryEntities(F.asList(qe)); + return ccfg; + } + else if (name.equals(CACHE_PERSON_NO_KV)) { + CacheConfiguration ccfg = new CacheConfiguration(CACHE_PERSON_NO_KV); + + QueryEntity entity = new QueryEntity(); + + entity.setKeyType(Integer.class.getName()); + entity.setValueType(Person.class.getName()); + + LinkedHashMap<String, String> fields = new LinkedHashMap<>(); + fields.put("name", String.class.getName()); + fields.put("age", Integer.class.getName()); + + entity.setFields(fields); + + ccfg.setQueryEntities(Arrays.asList(entity)); + return ccfg; + } + else if (name.equals(CACHE_INT_NO_KV_TYPE)) { + CacheConfiguration ccfg = new CacheConfiguration(CACHE_INT_NO_KV_TYPE); + QueryEntity entity = new QueryEntity(); + + entity.setKeyType(null); + entity.setValueType(null); + + entity.setKeyFieldName("id"); + entity.setValueFieldName("v"); + + LinkedHashMap<String, String> fields = new LinkedHashMap<>(); + fields.put("id", Integer.class.getName()); + fields.put("v", Integer.class.getName()); + + entity.setFields(fields); + + ccfg.setQueryEntities(Arrays.asList(entity)); + return ccfg; + } + else if (name.equals(CACHE_PERSON)) { + CacheConfiguration ccfg = new CacheConfiguration(CACHE_PERSON); + + QueryEntity entity = new QueryEntity(); + + entity.setKeyType(Integer.class.getName()); + entity.setValueType(Person.class.getName()); + + entity.setKeyFieldName("id"); + entity.setValueFieldName("v"); + + LinkedHashMap<String, String> fields = new LinkedHashMap<>(); + fields.put("name", String.class.getName()); + fields.put("age", Integer.class.getName()); + + fields.put(entity.getKeyFieldName(), entity.getKeyType()); + fields.put(entity.getValueFieldName(), entity.getValueType()); + + entity.setFields(fields); + + ccfg.setQueryEntities(Arrays.asList(entity)); + return ccfg; + } + else if (name.equals(CACHE_JOB)) { + CacheConfiguration ccfg = new CacheConfiguration(CACHE_JOB); + ccfg.setIndexedTypes(Integer.class, Integer.class); + return ccfg; + } + return null; + } + + /** Test for setIndexedTypes() primitive types */ + @Test + public void testSetIndexTypesPrimitive() throws Exception { + IgniteCache<Integer, Integer> cache = grid(NODE_CLIENT).cache(CACHE_JOB); + + checkInsert(cache, "insert into Integer (_key, _val) values (?,?)", 1, 100); + + checkSelect(cache, "select * from Integer", 1, 100); + checkSelect(cache, "select _key, _val from Integer", 1, 100); + } + + /** Test configuration error : keyFieldName is missing from fields */ + @Test + public void testErrorKeyFieldMissingFromFields() throws Exception { + checkCacheStartupError(NODE_BAD_CONF_MISS_KEY_FIELD); + } + + /** Test configuration error : valueFieldName is missing from fields */ + @Test + public void testErrorValueFieldMissingFromFields() throws Exception { + checkCacheStartupError(NODE_BAD_CONF_MISS_VAL_FIELD); + } + + /** */ + private void checkCacheStartupError(final String name) { + GridTestUtils.assertThrows(log, new Callable<Void>() { + @Override public Void call() throws Exception { + startGrid(name); + + return null; + } + }, IgniteCheckedException.class, null); + } + + /** + * Check that it is allowed to leave QE.keyType and QE.valueType unset + * in case keyFieldName and valueFieldName are set and present in fields + */ + @Test + public void testQueryEntityAutoKeyValTypes() throws Exception { + IgniteCache<Integer, Integer> cache = grid(NODE_CLIENT).cache(CACHE_INT_NO_KV_TYPE); + + checkInsert(cache, "insert into Integer (_key, _val) values (?,?)", 1, 100); + + checkSelect(cache, "select * from Integer where id = 1", 1, 100); + + checkSelect(cache, "select * from Integer", 1, 100); + checkSelect(cache, "select _key, _val from Integer", 1, 100); + checkSelect(cache, "select id, v from Integer", 1, 100); + } + + /** Check that it is possible to not have keyFieldName and valueFieldName */ + @Test + public void testNoKeyValueAliases() throws Exception { + IgniteCache<Integer, Person> cache = grid(NODE_CLIENT).cache(CACHE_PERSON_NO_KV); + + Person alice = new Person("Alice", 1); + checkInsert(cache, "insert into Person (_key, _val) values (?,?)", 1, alice); + + checkSelect(cache, "select * from Person", alice.name, alice.age); + checkSelect(cache, "select _key, _val from Person", 1, alice); + } + + /** Check keyFieldName and valueFieldName columns access */ + @Test + public void testKeyValueAlias() throws Exception { + //_key, _val, _ver | name, age, id, v + Person alice = new Person("Alice", 1); + Person bob = new Person("Bob", 2); + + IgniteCache<Integer, Person> cache = grid(NODE_CLIENT).cache(CACHE_PERSON); + + checkInsert(cache, "insert into Person (_key, _val) values (?,?)", 1, alice); + checkInsert(cache, "insert into Person (id, v) values (?,?)", 2, bob); + + checkSelect(cache, "select * from Person where _key=1", alice.name, alice.age, 1, alice); + checkSelect(cache, "select _key, _val from Person where id=1", 1, alice); + + checkSelect(cache, "select * from Person where _key=2", bob.name, bob.age, 2, bob); + checkSelect(cache, "select _key, _val from Person where id=2", 2, bob); + + checkInsert(cache, "update Person set age = ? where id = ?", 3, 1); + checkSelect(cache, "select _key, age from Person where id=1", 1, 3); + + checkInsert(cache, "update Person set v = ? where id = ?", alice, 1); + checkSelect(cache, "select _key, _val from Person where id=1", 1, alice); + } + + /** Check _ver version field is accessible */ + @Test + public void testVersionField() throws Exception { + Person alice = new Person("Alice", 1); + Person bob = new Person("Bob", 2); + + IgniteCache<Integer, Person> cache = grid(NODE_CLIENT).cache(CACHE_PERSON); + + checkInsert(cache, "insert into Person (id, v) values (?,?)", 1, alice); + assertNotNull(getVersion(cache, 1)); + + checkInsert(cache, "insert into Person (id, v) values (?,?)", 2, bob); + assertNotNull(getVersion(cache, 2)); + + GridCacheVersion v1 = getVersion(cache, 1); + + checkInsert(cache, "update Person set age = ? where id = ?", 3, 1); + + GridCacheVersion v2 = getVersion(cache, 1); + + assertFalse( v1.equals(v2) ); + } + + /** Check that joins are working on keyFieldName, valueFieldName columns */ + @Test + public void testJoinKeyValFields() throws Exception { + IgniteEx client = grid(NODE_CLIENT); + IgniteCache<Integer, Person> cache = client.cache(CACHE_PERSON); + IgniteCache<Integer, Integer> cache2 = client.cache(CACHE_JOB); + + checkInsert(cache, "insert into Person (id, v) values (?, ?)", 1, new Person("Bob", 30)); + checkInsert(cache, "insert into Person (id, v) values (?, ?)", 2, new Person("David", 35)); + checkInsert(cache2, "insert into Integer (_key, _val) values (?, ?)", 100, 1); + checkInsert(cache2, "insert into Integer (_key, _val) values (?, ?)", 200, 2); + + QueryCursor<List<?>> cursor = cache.query(new SqlFieldsQuery("select p.id, j._key from Person p, \""+ CACHE_JOB +"\".Integer j where p.id = j._val")); + List<List<?>> results = cursor.getAll(); + assertEquals(2, results.size()); + assertEquals(1, results.get(0).get(0)); + assertEquals(100, results.get(0).get(1)); + assertEquals(2, results.get(1).get(0)); + assertEquals(200, results.get(1).get(1)); + } + + /** Check automatic addition of index for keyFieldName column */ + @Test + public void testAutoKeyFieldIndex() throws Exception { + IgniteEx client = grid(NODE_CLIENT); + IgniteCache<Integer, Person> cache = client.cache(CACHE_PERSON); + + QueryCursor<List<?>> cursor = cache.query(new SqlFieldsQuery("explain select * from Person where id = 1")); + List<List<?>> results = cursor.getAll(); + assertEquals(2, results.size()); + assertTrue(((String)results.get(0).get(0)).contains("\"_key_PK_proxy\"")); + + cursor = cache.query(new SqlFieldsQuery("explain select * from Person where _key = 1")); + results = cursor.getAll(); + assertEquals(2, results.size()); + assertTrue(((String)results.get(0).get(0)).contains("\"_key_PK\"")); + } + + /** */ + private GridCacheVersion getVersion(IgniteCache<?, ?> cache, int key) { + QueryCursor<List<?>> cursor = cache.query(new SqlFieldsQuery("select _ver from Person where id = ?").setArgs(key)); + List<List<?>> results = cursor.getAll(); + assertEquals(1, results.size()); + return ((GridCacheVersion) results.get(0).get(0)); + } + + /** */ + private void checkInsert(IgniteCache<?, ?> cache, String qry, Object ... args) throws Exception { + QueryCursor<List<?>> cursor = cache.query(new SqlFieldsQuery(qry).setArgs(args)); + assertEquals(1, ((Number) cursor.getAll().get(0).get(0)).intValue()); + } + + /** */ + private void checkSelect(IgniteCache<?, ?> cache, String selectQry, Object ... expected) { + QueryCursor<List<?>> cursor = cache.query(new SqlFieldsQuery(selectQry)); + + List<List<?>> results = cursor.getAll(); + + assertEquals(1, results.size()); + + List<?> row0 = results.get(0); + for(int col = 0; col < expected.length; ++col) + assertEquals(expected[col], row0.get(col)); + } + + /** */ + private static class Person { + /** */ + private String name; + + /** */ + private int age; + + /** */ + public Person(String name, int age) { + this.name = name; + this.age = age; + } + + /** */ + @Override public int hashCode() { + return name.hashCode() ^ age; + } + + /** */ + @Override public boolean equals(Object o) { + if (this == o) + return true; + if (!(o instanceof Person)) + return false; + Person other = (Person)o; + return name.equals(other.name) && age == other.age; + } + } +}
