pavlukhin commented on a change in pull request #7320: IGNITE-12468 Java thin
client: deserialization of arrays, collections and maps fixed
URL: https://github.com/apache/ignite/pull/7320#discussion_r375806713
##########
File path:
modules/core/src/test/java/org/apache/ignite/client/FunctionalTest.java
##########
@@ -278,6 +284,157 @@ public void testPutGet() throws Exception {
}
}
+ /**
+ * Test cache operations with different data types.
+ */
+ @Test
+ public void testDataTypes() throws Exception {
+ try (Ignite ignite = Ignition.start(Config.getServerConfiguration());
+ IgniteClient client =
Ignition.startClient(getClientConfiguration())
+ ) {
+ IgniteCache<Object, Object> thickCache =
ignite.getOrCreateCache(Config.DEFAULT_CACHE_NAME);
+ ClientCache<Object, Object> thinCache =
client.getOrCreateCache(Config.DEFAULT_CACHE_NAME);
+
+ Person person = new Person(1, "name");
+
+ // Primitive and built-in types.
+ checkDataType(thinCache, thickCache, (byte)1);
+ checkDataType(thinCache, thickCache, (short)1);
+ checkDataType(thinCache, thickCache, 1);
+ checkDataType(thinCache, thickCache, 1L);
+ checkDataType(thinCache, thickCache, 1.0f);
+ checkDataType(thinCache, thickCache, 1.0d);
+ checkDataType(thinCache, thickCache, 'c');
+ checkDataType(thinCache, thickCache, true);
+ checkDataType(thinCache, thickCache, "string");
+ checkDataType(thinCache, thickCache, UUID.randomUUID());
+ checkDataType(thinCache, thickCache, new Date());
+
+ // Enum.
+ checkDataType(thinCache, thickCache, CacheAtomicityMode.ATOMIC);
+
+ // Binary object.
+ checkDataType(thinCache, thickCache, person);
+
+ // Arrays.
+ checkDataType(thinCache, thickCache, new byte[] {(byte)1});
+ checkDataType(thinCache, thickCache, new short[] {(short)1});
+ checkDataType(thinCache, thickCache, new int[] {1});
+ checkDataType(thinCache, thickCache, new long[] {1L});
+ checkDataType(thinCache, thickCache, new float[] {1.0f});
+ checkDataType(thinCache, thickCache, new double[] {1.0d});
+ checkDataType(thinCache, thickCache, new char[] {'c'});
+ checkDataType(thinCache, thickCache, new boolean[] {true});
+ checkDataType(thinCache, thickCache, new String[] {"string"});
+ checkDataType(thinCache, thickCache, new UUID[]
{UUID.randomUUID()});
+ checkDataType(thinCache, thickCache, new Date[] {new Date()});
+ checkDataType(thinCache, thickCache, new int[][] {new int[] {1}});
+
+ checkDataType(thinCache, thickCache, new CacheAtomicityMode[]
{CacheAtomicityMode.ATOMIC});
+
+ checkDataType(thinCache, thickCache, new Person[] {person});
+ checkDataType(thinCache, thickCache, new Person[][] {new Person[]
{person}});
+ checkDataType(thinCache, thickCache, new Object[] {1, "string",
person, new Person[] {person}});
+
+ // Lists.
+ checkDataType(thinCache, thickCache, Collections.emptyList());
+ checkDataType(thinCache, thickCache,
Collections.singletonList(person));
+ checkDataType(thinCache, thickCache, Arrays.asList(person,
person));
+ checkDataType(thinCache, thickCache, new
ArrayList<>(Arrays.asList(person, person)));
+ checkDataType(thinCache, thickCache, new
LinkedList<>(Arrays.asList(person, person)));
+ checkDataType(thinCache, thickCache,
Arrays.asList(Arrays.asList(person, person), person));
+
+ // Sets.
+ checkDataType(thinCache, thickCache, Collections.emptySet());
+ checkDataType(thinCache, thickCache,
Collections.singleton(person));
+ checkDataType(thinCache, thickCache, new
HashSet<>(Arrays.asList(1, 2)));
+ checkDataType(thinCache, thickCache, new
HashSet<>(Arrays.asList(Arrays.asList(person, person), person)));
+ checkDataType(thinCache, thickCache, new HashSet<>(new
ArrayList<>(Arrays.asList(Arrays.asList(person,
+ person), person))));
+
+ // Maps.
+ checkDataType(thinCache, thickCache, Collections.emptyMap());
+ checkDataType(thinCache, thickCache, Collections.singletonMap(1,
person));
+ checkDataType(thinCache, thickCache, F.asMap(1, person));
+ checkDataType(thinCache, thickCache, new HashMap<>(F.asMap(1,
person)));
+ checkDataType(thinCache, thickCache, new HashMap<>(F.asMap(new
HashSet<>(Arrays.asList(1, 2)),
+ Arrays.asList(person, person))));
+ }
+ }
+
+ /**
+ * Check that we get the same value from the cache as we put before.
+ *
+ * @param thinCache Cache.
Review comment:
There is no `@param thickCache`. We might omit a parameters list here.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services