This is an automated email from the ASF dual-hosted git repository.
nizhikov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push:
new d9e785f77fa [MINOR] Test to check USE_CACHE flag in BinaryArray added
(#13557)
d9e785f77fa is described below
commit d9e785f77faea6ca6701e675b4b4d7c7f8c33154
Author: Nikolay <[email protected]>
AuthorDate: Mon Sep 7 16:38:30 2026 +0300
[MINOR] Test to check USE_CACHE flag in BinaryArray added (#13557)
---
.../binary/BinaryClassLoaderMultiJvmTest.java | 49 ++++++++++++++++++++--
1 file changed, 45 insertions(+), 4 deletions(-)
diff --git
a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryClassLoaderMultiJvmTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryClassLoaderMultiJvmTest.java
index e00dc4530c4..3e62ed376ce 100644
---
a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryClassLoaderMultiJvmTest.java
+++
b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryClassLoaderMultiJvmTest.java
@@ -18,9 +18,11 @@
package org.apache.ignite.internal.binary;
import java.lang.ref.WeakReference;
+import java.lang.reflect.Array;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.net.URL;
+import java.util.List;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteException;
@@ -38,12 +40,16 @@ import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.lang.IgniteRunnable;
import org.apache.ignite.testframework.GridTestExternalClassLoader;
import org.apache.ignite.testframework.config.GridTestProperties;
+import org.apache.ignite.testframework.junits.WithSystemProperty;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.junit.Test;
+import static
org.apache.ignite.IgniteCommonsSystemProperties.IGNITE_USE_BINARY_ARRAYS;
+
/**
* Test class covering feature that allows to unmarshal binary object with
custom classloader.
*/
+@WithSystemProperty(key = IGNITE_USE_BINARY_ARRAYS, value = "true")
public class BinaryClassLoaderMultiJvmTest extends GridCommonAbstractTest {
/** Person class name. */
private static final String PERSON_CLASS_NAME =
"org.apache.ignite.tests.p2p.cache.Person";
@@ -68,6 +74,11 @@ public class BinaryClassLoaderMultiJvmTest extends
GridCommonAbstractTest {
return true;
}
+ /** {@inheritDoc} */
+ @Override protected List<String> additionalRemoteJvmArgs() {
+ return List.of("-D" + IGNITE_USE_BINARY_ARRAYS + "=true");
+ }
+
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String
igniteInstanceName) throws Exception {
return super.getConfiguration(igniteInstanceName)
@@ -77,6 +88,9 @@ public class BinaryClassLoaderMultiJvmTest extends
GridCommonAbstractTest {
new CacheConfiguration("SomeCache")
.setAtomicityMode(CacheAtomicityMode.ATOMIC)
.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC),
+ new CacheConfiguration("SomeCacheArray")
+ .setAtomicityMode(CacheAtomicityMode.ATOMIC)
+
.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC),
new CacheConfiguration("SomeCacheEnum")
.setAtomicityMode(CacheAtomicityMode.ATOMIC)
.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC),
@@ -126,6 +140,8 @@ public class BinaryClassLoaderMultiJvmTest extends
GridCommonAbstractTest {
checkItems(testClsLdr, "SomeCache", PERSON_CLASS_NAME, ign);
+ checkItems(testClsLdr, "SomeCacheArray", PERSON_CLASS_NAME, ign);
+
checkItems(testClsLdr, "SomeCacheEnum", ENUM_CLASS_NAME, ign);
checkItems(testClsLdr, "OrganizationCache",
ORGANIZATION_CLASS_NAME, ign);
@@ -179,6 +195,8 @@ public class BinaryClassLoaderMultiJvmTest extends
GridCommonAbstractTest {
checkItems(testClsLdr, "SomeCache", PERSON_CLASS_NAME, ign);
+ checkItems(testClsLdr, "SomeCacheArray", PERSON_CLASS_NAME, ign);
+
checkItems(testClsLdr, "SomeCacheEnum", ENUM_CLASS_NAME, ign);
checkItems(testClsLdr, "OrganizationCache",
ORGANIZATION_CLASS_NAME, ign);
@@ -213,8 +231,9 @@ public class BinaryClassLoaderMultiJvmTest extends
GridCommonAbstractTest {
IgniteCache<Integer, BinaryObject> binaryCache =
cache.withKeepBinary();
- for (int i = 0; i < 100; i++) {
+ boolean arrVals = cacheName.endsWith("Array");
+ for (int i = 0; i < 100; i++) {
BinaryObject binaryVal = binaryCache.get(i);
if (i % 50 == 0)
@@ -225,7 +244,8 @@ public class BinaryClassLoaderMultiJvmTest extends
GridCommonAbstractTest {
info("Can not execute toString() on class " +
binaryVal.type().typeName());
}
- assertEquals(binaryVal.type().typeName(), valClsName);
+ if (!arrVals)
+ assertEquals(binaryVal.type().typeName(), valClsName);
boolean catchEx = false;
@@ -245,7 +265,14 @@ public class BinaryClassLoaderMultiJvmTest extends
GridCommonAbstractTest {
Object personVal = binaryVal.deserialize(testClsLdr);
- assertTrue(personVal != null &&
personVal.getClass().getName().equals(valClsName));
+ assertNotNull(personVal);
+
+ if (!arrVals)
+ assertTrue(personVal.getClass().getName().equals(valClsName));
+ else {
+ assertTrue(personVal.getClass().isArray());
+
assertTrue(personVal.getClass().getComponentType().getName().equals(valClsName));
+ }
}
}
@@ -254,7 +281,9 @@ public class BinaryClassLoaderMultiJvmTest extends
GridCommonAbstractTest {
* @param ignite Ignite.
*/
private void loadItems(ClassLoader testClsLdr, Ignite ignite) throws
Exception {
- Constructor personConstructor =
testClsLdr.loadClass(PERSON_CLASS_NAME).getConstructor(String.class);
+ Class<?> personCls = testClsLdr.loadClass(PERSON_CLASS_NAME);
+
+ Constructor personConstructor = personCls.getConstructor(String.class);
IgniteCache<Integer, Object> cache = ignite.cache("SomeCache");
@@ -262,6 +291,18 @@ public class BinaryClassLoaderMultiJvmTest extends
GridCommonAbstractTest {
cache.put(i, personConstructor.newInstance("Persone name " + i));
assertEquals(cache.size(CachePeekMode.PRIMARY), 100);
+
+ cache = ignite.cache("SomeCacheArray");
+
+ for (int i = 0; i < 100; i++) {
+ Object arr = Array.newInstance(personCls, 1);
+
+ Array.set(arr, 0, personConstructor.newInstance("Persone name " +
i));
+
+ cache.put(i, arr);
+ }
+
+ assertEquals(cache.size(CachePeekMode.PRIMARY), 100);
}
/**