You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ak...@apache.org on 2015/11/05 04:27:59 UTC
[07/66] [abbrv] ignite git commit: IGNITE-950 - Renaming.
http://git-wip-us.apache.org/repos/asf/ignite/blob/20f5b9cd/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/transactions/PlatformTransactions.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/transactions/PlatformTransactions.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/transactions/PlatformTransactions.java
index 3fdfddf..5f5f5c3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/transactions/PlatformTransactions.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/transactions/PlatformTransactions.java
@@ -23,7 +23,7 @@ import java.util.concurrent.atomic.AtomicLong;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteTransactions;
import org.apache.ignite.configuration.TransactionConfiguration;
-import org.apache.ignite.internal.portable.IgniteObjectRawWriterEx;
+import org.apache.ignite.internal.portable.BinaryRawWriterEx;
import org.apache.ignite.internal.processors.platform.PlatformAbstractTarget;
import org.apache.ignite.internal.processors.platform.PlatformContext;
import org.apache.ignite.internal.processors.platform.utils.PlatformFutureUtils;
@@ -231,7 +231,7 @@ public class PlatformTransactions extends PlatformAbstractTarget {
}
/** {@inheritDoc} */
- @Override protected void processOutStream(int type, IgniteObjectRawWriterEx writer) throws IgniteCheckedException {
+ @Override protected void processOutStream(int type, BinaryRawWriterEx writer) throws IgniteCheckedException {
switch (type) {
case OP_CACHE_CONFIG_PARAMETERS:
TransactionConfiguration txCfg = platformCtx.kernalContext().config().getTransactionConfiguration();
http://git-wip-us.apache.org/repos/asf/ignite/blob/20f5b9cd/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformFutureUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformFutureUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformFutureUtils.java
index 7cf8adb..335be4d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformFutureUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformFutureUtils.java
@@ -18,7 +18,7 @@
package org.apache.ignite.internal.processors.platform.utils;
import org.apache.ignite.internal.IgniteInternalFuture;
-import org.apache.ignite.internal.portable.IgniteObjectRawWriterEx;
+import org.apache.ignite.internal.portable.BinaryRawWriterEx;
import org.apache.ignite.internal.processors.platform.PlatformAbstractTarget;
import org.apache.ignite.internal.processors.platform.PlatformContext;
import org.apache.ignite.internal.processors.platform.callback.PlatformCallbackGateway;
@@ -164,7 +164,7 @@ public class PlatformFutureUtils {
try (PlatformMemory mem = ctx.memory().allocate()) {
PlatformOutputStream out = mem.output();
- IgniteObjectRawWriterEx outWriter = ctx.writer(out);
+ BinaryRawWriterEx outWriter = ctx.writer(out);
outWriter.writeObjectDetached(res);
@@ -244,7 +244,7 @@ public class PlatformFutureUtils {
try (PlatformMemory mem = ctx.memory().allocate()) {
PlatformOutputStream out = mem.output();
- IgniteObjectRawWriterEx outWriter = ctx.writer(out);
+ BinaryRawWriterEx outWriter = ctx.writer(out);
outWriter.writeString(err.getClass().getName());
outWriter.writeString(err.getMessage());
@@ -276,7 +276,7 @@ public class PlatformFutureUtils {
try (PlatformMemory mem = ctx.memory().allocate()) {
PlatformOutputStream out = mem.output();
- IgniteObjectRawWriterEx outWriter = ctx.writer(out);
+ BinaryRawWriterEx outWriter = ctx.writer(out);
writer.write(outWriter, obj, err);
@@ -299,7 +299,7 @@ public class PlatformFutureUtils {
* @param obj Object.
* @param err Error.
*/
- public void write(IgniteObjectRawWriterEx writer, Object obj, Throwable err);
+ public void write(BinaryRawWriterEx writer, Object obj, Throwable err);
/**
* Determines whether this writer can write given data.
http://git-wip-us.apache.org/repos/asf/ignite/blob/20f5b9cd/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformReaderBiClosure.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformReaderBiClosure.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformReaderBiClosure.java
index 4bda62a..199cf72 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformReaderBiClosure.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformReaderBiClosure.java
@@ -17,7 +17,7 @@
package org.apache.ignite.internal.processors.platform.utils;
-import org.apache.ignite.internal.portable.IgniteObjectRawReaderEx;
+import org.apache.ignite.internal.portable.BinaryRawReaderEx;
import org.apache.ignite.lang.IgniteBiTuple;
/**
@@ -30,5 +30,5 @@ public interface PlatformReaderBiClosure<T1, T2> {
* @param reader Reader.
* @return Object.
*/
- IgniteBiTuple<T1, T2> read(IgniteObjectRawReaderEx reader);
+ IgniteBiTuple<T1, T2> read(BinaryRawReaderEx reader);
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/20f5b9cd/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformReaderClosure.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformReaderClosure.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformReaderClosure.java
index 3bec262..9330606 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformReaderClosure.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformReaderClosure.java
@@ -17,7 +17,7 @@
package org.apache.ignite.internal.processors.platform.utils;
-import org.apache.ignite.internal.portable.IgniteObjectRawReaderEx;
+import org.apache.ignite.internal.portable.BinaryRawReaderEx;
/**
* Reader closure.
@@ -30,5 +30,5 @@ public interface PlatformReaderClosure<T> {
* @param reader Reader.
* @return Object.
*/
- T read(IgniteObjectRawReaderEx reader);
+ T read(BinaryRawReaderEx reader);
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/20f5b9cd/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
index c847a61..8f74b66 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
@@ -24,8 +24,8 @@ import org.apache.ignite.IgniteLogger;
import org.apache.ignite.cache.CachePeekMode;
import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.IgniteKernal;
-import org.apache.ignite.internal.portable.IgniteObjectRawReaderEx;
-import org.apache.ignite.internal.portable.IgniteObjectRawWriterEx;
+import org.apache.ignite.internal.portable.BinaryRawReaderEx;
+import org.apache.ignite.internal.portable.BinaryRawWriterEx;
import org.apache.ignite.internal.processors.platform.PlatformContext;
import org.apache.ignite.internal.processors.platform.PlatformExtendedException;
import org.apache.ignite.internal.processors.platform.PlatformNativeException;
@@ -96,7 +96,7 @@ public class PlatformUtils {
* @param writer Writer.
* @param col Collection to write.
*/
- public static <T> void writeNullableCollection(IgniteObjectRawWriterEx writer, @Nullable Collection<T> col) {
+ public static <T> void writeNullableCollection(BinaryRawWriterEx writer, @Nullable Collection<T> col) {
writeNullableCollection(writer, col, null, null);
}
@@ -107,7 +107,7 @@ public class PlatformUtils {
* @param col Collection to write.
* @param writeClo Writer closure.
*/
- public static <T> void writeNullableCollection(IgniteObjectRawWriterEx writer, @Nullable Collection<T> col,
+ public static <T> void writeNullableCollection(BinaryRawWriterEx writer, @Nullable Collection<T> col,
@Nullable PlatformWriterClosure<T> writeClo) {
writeNullableCollection(writer, col, writeClo, null);
}
@@ -120,7 +120,7 @@ public class PlatformUtils {
* @param writeClo Optional writer closure.
* @param filter Optional filter.
*/
- public static <T> void writeNullableCollection(IgniteObjectRawWriterEx writer, @Nullable Collection<T> col,
+ public static <T> void writeNullableCollection(BinaryRawWriterEx writer, @Nullable Collection<T> col,
@Nullable PlatformWriterClosure<T> writeClo, @Nullable IgnitePredicate<T> filter) {
if (col != null) {
writer.writeBoolean(true);
@@ -137,7 +137,7 @@ public class PlatformUtils {
* @param writer Writer.
* @param col Collection to write.
*/
- public static <T> void writeCollection(IgniteObjectRawWriterEx writer, Collection<T> col) {
+ public static <T> void writeCollection(BinaryRawWriterEx writer, Collection<T> col) {
writeCollection(writer, col, null, null);
}
@@ -148,7 +148,7 @@ public class PlatformUtils {
* @param col Collection to write.
* @param writeClo Writer closure.
*/
- public static <T> void writeCollection(IgniteObjectRawWriterEx writer, Collection<T> col,
+ public static <T> void writeCollection(BinaryRawWriterEx writer, Collection<T> col,
@Nullable PlatformWriterClosure<T> writeClo) {
writeCollection(writer, col, writeClo, null);
}
@@ -161,7 +161,7 @@ public class PlatformUtils {
* @param writeClo Optional writer closure.
* @param filter Optional filter.
*/
- public static <T> void writeCollection(IgniteObjectRawWriterEx writer, Collection<T> col,
+ public static <T> void writeCollection(BinaryRawWriterEx writer, Collection<T> col,
@Nullable PlatformWriterClosure<T> writeClo, @Nullable IgnitePredicate<T> filter) {
assert col != null;
@@ -202,7 +202,7 @@ public class PlatformUtils {
* @param writer Writer.
* @param map Map to write.
*/
- public static <K, V> void writeNullableMap(IgniteObjectRawWriterEx writer, @Nullable Map<K, V> map) {
+ public static <K, V> void writeNullableMap(BinaryRawWriterEx writer, @Nullable Map<K, V> map) {
if (map != null) {
writer.writeBoolean(true);
@@ -218,7 +218,7 @@ public class PlatformUtils {
* @param writer Writer.
* @param map Map to write.
*/
- public static <K, V> void writeMap(IgniteObjectRawWriterEx writer, Map<K, V> map) {
+ public static <K, V> void writeMap(BinaryRawWriterEx writer, Map<K, V> map) {
assert map != null;
writeMap(writer, map, null);
@@ -231,7 +231,7 @@ public class PlatformUtils {
* @param map Map to write.
* @param writeClo Writer closure.
*/
- public static <K, V> void writeMap(IgniteObjectRawWriterEx writer, Map<K, V> map,
+ public static <K, V> void writeMap(BinaryRawWriterEx writer, Map<K, V> map,
@Nullable PlatformWriterBiClosure<K, V> writeClo) {
assert map != null;
@@ -255,7 +255,7 @@ public class PlatformUtils {
* @param reader Reader.
* @return List.
*/
- public static <T> List<T> readCollection(IgniteObjectRawReaderEx reader) {
+ public static <T> List<T> readCollection(BinaryRawReaderEx reader) {
return readCollection(reader, null);
}
@@ -266,7 +266,7 @@ public class PlatformUtils {
* @param readClo Optional reader closure.
* @return List.
*/
- public static <T> List<T> readCollection(IgniteObjectRawReaderEx reader, @Nullable PlatformReaderClosure<T> readClo) {
+ public static <T> List<T> readCollection(BinaryRawReaderEx reader, @Nullable PlatformReaderClosure<T> readClo) {
int cnt = reader.readInt();
List<T> res = new ArrayList<>(cnt);
@@ -289,7 +289,7 @@ public class PlatformUtils {
* @param reader Reader.
* @return List.
*/
- public static <T> List<T> readNullableCollection(IgniteObjectRawReaderEx reader) {
+ public static <T> List<T> readNullableCollection(BinaryRawReaderEx reader) {
return readNullableCollection(reader, null);
}
@@ -299,7 +299,7 @@ public class PlatformUtils {
* @param reader Reader.
* @return List.
*/
- public static <T> List<T> readNullableCollection(IgniteObjectRawReaderEx reader,
+ public static <T> List<T> readNullableCollection(BinaryRawReaderEx reader,
@Nullable PlatformReaderClosure<T> readClo) {
if (!reader.readBoolean())
return null;
@@ -311,7 +311,7 @@ public class PlatformUtils {
* @param reader Reader.
* @return Set.
*/
- public static <T> Set<T> readSet(IgniteObjectRawReaderEx reader) {
+ public static <T> Set<T> readSet(BinaryRawReaderEx reader) {
int cnt = reader.readInt();
Set<T> res = U.newHashSet(cnt);
@@ -326,7 +326,7 @@ public class PlatformUtils {
* @param reader Reader.
* @return Set.
*/
- public static <T> Set<T> readNullableSet(IgniteObjectRawReaderEx reader) {
+ public static <T> Set<T> readNullableSet(BinaryRawReaderEx reader) {
if (!reader.readBoolean())
return null;
@@ -339,7 +339,7 @@ public class PlatformUtils {
* @param reader Reader.
* @return Map.
*/
- public static <K, V> Map<K, V> readMap(IgniteObjectRawReaderEx reader) {
+ public static <K, V> Map<K, V> readMap(BinaryRawReaderEx reader) {
return readMap(reader, null);
}
@@ -350,7 +350,7 @@ public class PlatformUtils {
* @param readClo Reader closure.
* @return Map.
*/
- public static <K, V> Map<K, V> readMap(IgniteObjectRawReaderEx reader,
+ public static <K, V> Map<K, V> readMap(BinaryRawReaderEx reader,
@Nullable PlatformReaderBiClosure<K, V> readClo) {
int cnt = reader.readInt();
@@ -377,7 +377,7 @@ public class PlatformUtils {
* @param reader Reader.
* @return Map.
*/
- public static <K, V> Map<K, V> readNullableMap(IgniteObjectRawReaderEx reader) {
+ public static <K, V> Map<K, V> readNullableMap(BinaryRawReaderEx reader) {
if (!reader.readBoolean())
return null;
@@ -390,7 +390,7 @@ public class PlatformUtils {
* @param writer Writer.
* @param val Values.
*/
- public static void writeIgniteUuid(IgniteObjectRawWriterEx writer, IgniteUuid val) {
+ public static void writeIgniteUuid(BinaryRawWriterEx writer, IgniteUuid val) {
if (val == null)
writer.writeUuid(null);
else {
@@ -483,7 +483,7 @@ public class PlatformUtils {
try (PlatformMemory mem = ctx.memory().allocate()) {
PlatformOutputStream out = mem.output();
- IgniteObjectRawWriterEx writer = ctx.writer(out);
+ BinaryRawWriterEx writer = ctx.writer(out);
int cntPos = writer.reserveInt();
@@ -552,7 +552,7 @@ public class PlatformUtils {
* @param writer Writer.
* @param evt Event.
*/
- private static void writeCacheEntryEvent(IgniteObjectRawWriterEx writer, CacheEntryEvent evt) {
+ private static void writeCacheEntryEvent(BinaryRawWriterEx writer, CacheEntryEvent evt) {
writer.writeObjectDetached(evt.getKey());
writer.writeObjectDetached(evt.getOldValue());
writer.writeObjectDetached(evt.getValue());
@@ -564,7 +564,7 @@ public class PlatformUtils {
* @param err Error.
* @param writer Writer.
*/
- public static void writeErrorData(Throwable err, IgniteObjectRawWriterEx writer) {
+ public static void writeErrorData(Throwable err, BinaryRawWriterEx writer) {
writeErrorData(err, writer, null);
}
@@ -574,7 +574,7 @@ public class PlatformUtils {
* @param writer Writer.
* @param log Optional logger.
*/
- public static void writeErrorData(Throwable err, IgniteObjectRawWriterEx writer, @Nullable IgniteLogger log) {
+ public static void writeErrorData(Throwable err, BinaryRawWriterEx writer, @Nullable IgniteLogger log) {
// Write additional data if needed.
if (err instanceof PlatformExtendedException) {
PlatformExtendedException err0 = (PlatformExtendedException)err;
@@ -659,7 +659,7 @@ public class PlatformUtils {
// Write error data.
PlatformOutputStream out = mem.output();
- IgniteObjectRawWriterEx writer = ctx.writer(out);
+ BinaryRawWriterEx writer = ctx.writer(out);
try {
PlatformUtils.writeErrorData(err, writer, ctx.kernalContext().log(PlatformContext.class));
@@ -696,7 +696,7 @@ public class PlatformUtils {
* @param resObj Result.
* @param err Error.
*/
- public static void writeInvocationResult(IgniteObjectRawWriterEx writer, Object resObj, Exception err)
+ public static void writeInvocationResult(BinaryRawWriterEx writer, Object resObj, Exception err)
{
if (err == null) {
writer.writeBoolean(true);
@@ -732,7 +732,7 @@ public class PlatformUtils {
* @return Result.
* @throws IgniteCheckedException When invocation result is an error.
*/
- public static Object readInvocationResult(PlatformContext ctx, IgniteObjectRawReaderEx reader)
+ public static Object readInvocationResult(PlatformContext ctx, BinaryRawReaderEx reader)
throws IgniteCheckedException {
// 1. Read success flag.
boolean success = reader.readBoolean();
@@ -769,7 +769,7 @@ public class PlatformUtils {
* @param writer Writer.
* @param cfg Configuration.
*/
- public static void writeDotNetConfiguration(IgniteObjectRawWriterEx writer, PlatformDotNetConfiguration cfg) {
+ public static void writeDotNetConfiguration(BinaryRawWriterEx writer, PlatformDotNetConfiguration cfg) {
// 1. Write assemblies.
writeNullableCollection(writer, cfg.getAssemblies());
@@ -780,7 +780,7 @@ public class PlatformUtils {
writeNullableCollection(writer, portableCfg.getTypesConfiguration(),
new PlatformWriterClosure<PlatformDotNetPortableTypeConfiguration>() {
- @Override public void write(IgniteObjectRawWriterEx writer, PlatformDotNetPortableTypeConfiguration typ) {
+ @Override public void write(BinaryRawWriterEx writer, PlatformDotNetPortableTypeConfiguration typ) {
writer.writeString(typ.getTypeName());
writer.writeString(typ.getNameMapper());
writer.writeString(typ.getIdMapper());
http://git-wip-us.apache.org/repos/asf/ignite/blob/20f5b9cd/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformWriterBiClosure.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformWriterBiClosure.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformWriterBiClosure.java
index c944345..b0e6a65 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformWriterBiClosure.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformWriterBiClosure.java
@@ -17,7 +17,7 @@
package org.apache.ignite.internal.processors.platform.utils;
-import org.apache.ignite.internal.portable.IgniteObjectRawWriterEx;
+import org.apache.ignite.internal.portable.BinaryRawWriterEx;
/**
* Interop writer bi-closure.
@@ -30,5 +30,5 @@ public interface PlatformWriterBiClosure<T1, T2> {
* @param val1 Value 1.
* @param val2 Value 2.
*/
- public void write(IgniteObjectRawWriterEx writer, T1 val1, T2 val2);
+ public void write(BinaryRawWriterEx writer, T1 val1, T2 val2);
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/20f5b9cd/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformWriterClosure.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformWriterClosure.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformWriterClosure.java
index 2c9ab07..c55c209 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformWriterClosure.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformWriterClosure.java
@@ -17,7 +17,7 @@
package org.apache.ignite.internal.processors.platform.utils;
-import org.apache.ignite.internal.portable.IgniteObjectRawWriterEx;
+import org.apache.ignite.internal.portable.BinaryRawWriterEx;
/**
* Interop writer closure.
@@ -29,5 +29,5 @@ public interface PlatformWriterClosure<T> {
* @param writer Writer.
* @param val Value.
*/
- public void write(IgniteObjectRawWriterEx writer, T val);
+ public void write(BinaryRawWriterEx writer, T val);
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/20f5b9cd/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
index a9d6243..d1f9869 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
@@ -53,7 +53,7 @@ import org.apache.ignite.cache.query.SqlFieldsQuery;
import org.apache.ignite.cache.query.SqlQuery;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.events.CacheQueryExecutedEvent;
-import org.apache.ignite.igniteobject.IgniteObject;
+import org.apache.ignite.binary.BinaryObject;
import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.processors.GridProcessorAdapter;
@@ -1838,9 +1838,9 @@ public class GridQueryProcessor extends GridProcessorAdapter {
if (isKeyProp0 == 0) {
// Key is allowed to be a non-portable object here.
// We check key before value consistently with ClassProperty.
- if (key instanceof IgniteObject && ((IgniteObject)key).hasField(propName))
+ if (key instanceof BinaryObject && ((BinaryObject)key).hasField(propName))
isKeyProp = isKeyProp0 = 1;
- else if (val instanceof IgniteObject && ((IgniteObject)val).hasField(propName))
+ else if (val instanceof BinaryObject && ((BinaryObject)val).hasField(propName))
isKeyProp = isKeyProp0 = -1;
else {
U.warn(log, "Neither key nor value have property " +
http://git-wip-us.apache.org/repos/asf/ignite/blob/20f5b9cd/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java b/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java
index fa20e8d..94622f5 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java
@@ -28,11 +28,10 @@ import org.apache.ignite.internal.portable.GridPortableMarshaller;
import org.apache.ignite.internal.portable.PortableContext;
import org.apache.ignite.marshaller.AbstractMarshaller;
import org.apache.ignite.marshaller.MarshallerContext;
-import org.apache.ignite.igniteobject.IgniteObject;
-import org.apache.ignite.igniteobject.IgniteObjectConfiguration;
-import org.apache.ignite.igniteobject.IgniteObjectException;
-import org.apache.ignite.igniteobject.IgniteObjectIdMapper;
-import org.apache.ignite.igniteobject.IgniteObjectSerializer;
+import org.apache.ignite.binary.BinaryTypeConfiguration;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryTypeIdMapper;
+import org.apache.ignite.binary.BinarySerializer;
import org.jetbrains.annotations.Nullable;
/**
@@ -79,13 +78,13 @@ public class PortableMarshaller extends AbstractMarshaller {
private Collection<String> clsNames;
/** ID mapper. */
- private IgniteObjectIdMapper idMapper;
+ private BinaryTypeIdMapper idMapper;
/** Serializer. */
- private IgniteObjectSerializer serializer;
+ private BinarySerializer serializer;
/** Types. */
- private Collection<IgniteObjectConfiguration> typeCfgs;
+ private Collection<BinaryTypeConfiguration> typeCfgs;
/** Whether to convert string to bytes using UTF-8 encoding. */
private boolean convertString = true;
@@ -125,7 +124,7 @@ public class PortableMarshaller extends AbstractMarshaller {
*
* @return ID mapper.
*/
- public IgniteObjectIdMapper getIdMapper() {
+ public BinaryTypeIdMapper getIdMapper() {
return idMapper;
}
@@ -134,7 +133,7 @@ public class PortableMarshaller extends AbstractMarshaller {
*
* @param idMapper ID mapper.
*/
- public void setIdMapper(IgniteObjectIdMapper idMapper) {
+ public void setIdMapper(BinaryTypeIdMapper idMapper) {
this.idMapper = idMapper;
}
@@ -143,7 +142,7 @@ public class PortableMarshaller extends AbstractMarshaller {
*
* @return Serializer.
*/
- public IgniteObjectSerializer getSerializer() {
+ public BinarySerializer getSerializer() {
return serializer;
}
@@ -152,7 +151,7 @@ public class PortableMarshaller extends AbstractMarshaller {
*
* @param serializer Serializer.
*/
- public void setSerializer(IgniteObjectSerializer serializer) {
+ public void setSerializer(BinarySerializer serializer) {
this.serializer = serializer;
}
@@ -161,7 +160,7 @@ public class PortableMarshaller extends AbstractMarshaller {
*
* @return Types configuration.
*/
- public Collection<IgniteObjectConfiguration> getTypeConfigurations() {
+ public Collection<BinaryTypeConfiguration> getTypeConfigurations() {
return typeCfgs;
}
@@ -170,7 +169,7 @@ public class PortableMarshaller extends AbstractMarshaller {
*
* @param typeCfgs Type configurations.
*/
- public void setTypeConfigurations(Collection<IgniteObjectConfiguration> typeCfgs) {
+ public void setTypeConfigurations(Collection<BinaryTypeConfiguration> typeCfgs) {
this.typeCfgs = typeCfgs;
}
@@ -198,7 +197,7 @@ public class PortableMarshaller extends AbstractMarshaller {
/**
* If {@code true}, meta data will be collected or all types. If you need to override this behaviour for
- * some specific type, use {@link IgniteObjectConfiguration#setMetaDataEnabled(Boolean)} method.
+ * some specific type, use {@link org.apache.ignite.binary.BinaryTypeConfiguration#setMetaDataEnabled(Boolean)} method.
* <p>
* Default value if {@code true}.
*
@@ -216,11 +215,11 @@ public class PortableMarshaller extends AbstractMarshaller {
}
/**
- * If {@code true}, {@link IgniteObject} will cache deserialized instance after
- * {@link IgniteObject#deserialize()} is called. All consequent calls of this
- * method on the same instance of {@link IgniteObject} will return that cached
+ * If {@code true}, {@link org.apache.ignite.binary.BinaryObject} will cache deserialized instance after
+ * {@link org.apache.ignite.binary.BinaryObject#deserialize()} is called. All consequent calls of this
+ * method on the same instance of {@link org.apache.ignite.binary.BinaryObject} will return that cached
* value without actually deserializing portable object. If you need to override this
- * behaviour for some specific type, use {@link IgniteObjectConfiguration#setKeepDeserialized(Boolean)}
+ * behaviour for some specific type, use {@link org.apache.ignite.binary.BinaryTypeConfiguration#setKeepDeserialized(Boolean)}
* method.
* <p>
* Default value if {@code true}.
@@ -271,7 +270,7 @@ public class PortableMarshaller extends AbstractMarshaller {
out.write(arr);
}
catch (IOException e) {
- throw new IgniteObjectException("Failed to marshal the object: " + obj, e);
+ throw new BinaryObjectException("Failed to marshal the object: " + obj, e);
}
}
@@ -298,7 +297,7 @@ public class PortableMarshaller extends AbstractMarshaller {
return impl.deserialize(buf.toByteArray(), clsLdr);
}
catch (IOException e) {
- throw new IgniteObjectException("Failed to unmarshal the object from InputStream", e);
+ throw new BinaryObjectException("Failed to unmarshal the object from InputStream", e);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/20f5b9cd/modules/core/src/main/java/org/apache/ignite/portable/PortableField.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/portable/PortableField.java b/modules/core/src/main/java/org/apache/ignite/portable/PortableField.java
deleted file mode 100644
index 62475fb..0000000
--- a/modules/core/src/main/java/org/apache/ignite/portable/PortableField.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.portable;
-
-import org.apache.ignite.igniteobject.IgniteObject;
-
-/**
- * Portable object field. Can be used to speed object field lookup.
- */
-public interface PortableField {
- /**
- * Check whether field exists in the object.
- *
- * @param obj Object.
- * @return {@code True} if exists.
- */
- public boolean exists(IgniteObject obj);
-
- /**
- * Get field's value from the given object.
- *
- * @param obj Object.
- * @return Value.
- */
- public <T> T value(IgniteObject obj);
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/20f5b9cd/modules/core/src/test/java/org/apache/ignite/internal/portable/GridBinaryObjectBuilderAdditionalSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridBinaryObjectBuilderAdditionalSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridBinaryObjectBuilderAdditionalSelfTest.java
new file mode 100644
index 0000000..54e61f3
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridBinaryObjectBuilderAdditionalSelfTest.java
@@ -0,0 +1,1289 @@
+/*
+ * 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.portable;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+import java.lang.reflect.Field;
+import java.math.BigDecimal;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.UUID;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteObjects;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.portable.builder.PortableBuilderEnum;
+import org.apache.ignite.internal.portable.builder.BinaryObjectBuilderImpl;
+import org.apache.ignite.internal.portable.mutabletest.GridBinaryMarshalerAwareTestClass;
+import org.apache.ignite.internal.processors.cache.portable.CacheObjectPortableProcessorImpl;
+import org.apache.ignite.internal.processors.cache.portable.IgniteObjectsImpl;
+import org.apache.ignite.internal.util.lang.GridMapEntry;
+import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.binary.BinaryObjectBuilder;
+import org.apache.ignite.binary.BinaryTypeMetadata;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Assert;
+
+import static org.apache.ignite.cache.CacheMode.REPLICATED;
+import static org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.Address;
+import static org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.AddressBook;
+import static org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.Company;
+import static org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.TestObjectAllTypes;
+import static org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.TestObjectArrayList;
+import static org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.TestObjectContainer;
+import static org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.TestObjectEnum;
+import static org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.TestObjectInner;
+import static org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.TestObjectOuter;
+
+/**
+ *
+ */
+public class GridBinaryObjectBuilderAdditionalSelfTest extends GridCommonAbstractTest {
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ CacheConfiguration cacheCfg = new CacheConfiguration();
+
+ cacheCfg.setCacheMode(REPLICATED);
+
+ cfg.setCacheConfiguration(cacheCfg);
+
+ PortableMarshaller marsh = new PortableMarshaller();
+
+ marsh.setClassNames(Arrays.asList("org.apache.ignite.internal.portable.mutabletest.*"));
+
+ marsh.setConvertStringToBytes(useUtf8());
+
+ cfg.setMarshaller(marsh);
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ startGrids(1);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ stopAllGrids();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ jcache(0).clear();
+ }
+
+ /**
+ * @return Whether to use UTF8 strings.
+ */
+ protected boolean useUtf8() {
+ return true;
+ }
+
+ /**
+ * @return Portables API.
+ */
+ protected IgniteObjects portables() {
+ return grid(0).portables();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testSimpleTypeFieldRead() throws Exception {
+ TestObjectAllTypes exp = new TestObjectAllTypes();
+
+ exp.setDefaultData();
+
+ BinaryObjectBuilder mutPo = wrap(exp);
+
+ for (Field field : TestObjectAllTypes.class.getDeclaredFields()) {
+ Object expVal = field.get(exp);
+ Object actVal = mutPo.getField(field.getName());
+
+ switch (field.getName()) {
+ case "anEnum":
+ assertEquals(((PortableBuilderEnum)actVal).getOrdinal(), ((Enum)expVal).ordinal());
+ break;
+
+ case "enumArr": {
+ PortableBuilderEnum[] actArr = (PortableBuilderEnum[])actVal;
+ Enum[] expArr = (Enum[])expVal;
+
+ assertEquals(expArr.length, actArr.length);
+
+ for (int i = 0; i < actArr.length; i++)
+ assertEquals(expArr[i].ordinal(), actArr[i].getOrdinal());
+
+ break;
+ }
+
+ case "entry":
+ assertEquals(((Map.Entry)expVal).getKey(), ((Map.Entry)actVal).getKey());
+ assertEquals(((Map.Entry)expVal).getValue(), ((Map.Entry)actVal).getValue());
+ break;
+
+ default:
+ assertTrue(field.getName(), Objects.deepEquals(expVal, actVal));
+ break;
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ public void testSimpleTypeFieldSerialize() {
+ TestObjectAllTypes exp = new TestObjectAllTypes();
+
+ exp.setDefaultData();
+
+ BinaryObjectBuilderImpl mutPo = wrap(exp);
+
+ TestObjectAllTypes res = mutPo.build().deserialize();
+
+ GridTestUtils.deepEquals(exp, res);
+ }
+
+ /**
+ * @throws Exception If any error occurs.
+ */
+ public void testSimpleTypeFieldOverride() throws Exception {
+ TestObjectAllTypes exp = new TestObjectAllTypes();
+
+ exp.setDefaultData();
+
+ BinaryObjectBuilderImpl mutPo = wrap(new TestObjectAllTypes());
+
+ for (Field field : TestObjectAllTypes.class.getDeclaredFields())
+ mutPo.setField(field.getName(), field.get(exp));
+
+ TestObjectAllTypes res = mutPo.build().deserialize();
+
+ GridTestUtils.deepEquals(exp, res);
+ }
+
+ /**
+ * @throws Exception If any error occurs.
+ */
+ public void testSimpleTypeFieldSetNull() throws Exception {
+ TestObjectAllTypes exp = new TestObjectAllTypes();
+
+ exp.setDefaultData();
+
+ BinaryObjectBuilderImpl mutPo = wrap(exp);
+
+ for (Field field : TestObjectAllTypes.class.getDeclaredFields()) {
+ if (!field.getType().isPrimitive())
+ mutPo.setField(field.getName(), null);
+ }
+
+ TestObjectAllTypes res = mutPo.build().deserialize();
+
+ for (Field field : TestObjectAllTypes.class.getDeclaredFields()) {
+ if (!field.getType().isPrimitive())
+ assertNull(field.getName(), field.get(res));
+ }
+ }
+
+ /**
+ * @throws IgniteCheckedException If any error occurs.
+ */
+ public void testMakeCyclicDependency() throws IgniteCheckedException {
+ TestObjectOuter outer = new TestObjectOuter();
+ outer.inner = new TestObjectInner();
+
+ BinaryObjectBuilderImpl mutOuter = wrap(outer);
+
+ BinaryObjectBuilderImpl mutInner = mutOuter.getField("inner");
+
+ mutInner.setField("outer", mutOuter);
+ mutInner.setField("foo", mutInner);
+
+ TestObjectOuter res = mutOuter.build().deserialize();
+
+ assertEquals(res, res.inner.outer);
+ assertEquals(res.inner, res.inner.foo);
+ }
+
+ /**
+ *
+ */
+ public void testDateArrayModification() {
+ TestObjectAllTypes obj = new TestObjectAllTypes();
+
+ obj.dateArr = new Date[] {new Date(11111), new Date(11111), new Date(11111)};
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ Date[] arr = mutObj.getField("dateArr");
+ arr[0] = new Date(22222);
+
+ TestObjectAllTypes res = mutObj.build().deserialize();
+
+ Assert.assertArrayEquals(new Date[] {new Date(22222), new Date(11111), new Date(11111)}, res.dateArr);
+ }
+
+ /**
+ *
+ */
+ public void testTimestampArrayModification() {
+ TestObjectAllTypes obj = new TestObjectAllTypes();
+
+ obj.tsArr = new Timestamp[] {new Timestamp(111222333), new Timestamp(222333444)};
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ Timestamp[] arr = mutObj.getField("tsArr");
+ arr[0] = new Timestamp(333444555);
+
+ TestObjectAllTypes res = mutObj.build().deserialize();
+
+ Assert.assertArrayEquals(new Timestamp[] {new Timestamp(333444555), new Timestamp(222333444)}, res.tsArr);
+ }
+
+ /**
+ *
+ */
+ public void testUUIDArrayModification() {
+ TestObjectAllTypes obj = new TestObjectAllTypes();
+
+ obj.uuidArr = new UUID[] {new UUID(1, 1), new UUID(1, 1), new UUID(1, 1)};
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ UUID[] arr = mutObj.getField("uuidArr");
+ arr[0] = new UUID(2, 2);
+
+ TestObjectAllTypes res = mutObj.build().deserialize();
+
+ Assert.assertArrayEquals(new UUID[] {new UUID(2, 2), new UUID(1, 1), new UUID(1, 1)}, res.uuidArr);
+ }
+
+ /**
+ *
+ */
+ public void testDecimalArrayModification() {
+ TestObjectAllTypes obj = new TestObjectAllTypes();
+
+ obj.bdArr = new BigDecimal[] {new BigDecimal(1000), new BigDecimal(1000), new BigDecimal(1000)};
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ BigDecimal[] arr = mutObj.getField("bdArr");
+ arr[0] = new BigDecimal(2000);
+
+ TestObjectAllTypes res = mutObj.build().deserialize();
+
+ Assert.assertArrayEquals(new BigDecimal[] {new BigDecimal(1000), new BigDecimal(1000), new BigDecimal(1000)},
+ res.bdArr);
+ }
+
+ /**
+ *
+ */
+ public void testBooleanArrayModification() {
+ TestObjectAllTypes obj = new TestObjectAllTypes();
+
+ obj.zArr = new boolean[] {false, false, false};
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ boolean[] arr = mutObj.getField("zArr");
+ arr[0] = true;
+
+ TestObjectAllTypes res = mutObj.build().deserialize();
+
+ boolean[] expected = new boolean[] {true, false, false};
+
+ assertEquals(expected.length, res.zArr.length);
+
+ for (int i = 0; i < expected.length; i++)
+ assertEquals(expected[i], res.zArr[i]);
+ }
+
+ /**
+ *
+ */
+ public void testCharArrayModification() {
+ TestObjectAllTypes obj = new TestObjectAllTypes();
+
+ obj.cArr = new char[] {'a', 'a', 'a'};
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ char[] arr = mutObj.getField("cArr");
+ arr[0] = 'b';
+
+ TestObjectAllTypes res = mutObj.build().deserialize();
+
+ Assert.assertArrayEquals(new char[] {'b', 'a', 'a'}, res.cArr);
+ }
+
+ /**
+ *
+ */
+ public void testDoubleArrayModification() {
+ TestObjectAllTypes obj = new TestObjectAllTypes();
+
+ obj.dArr = new double[] {1.0, 1.0, 1.0};
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ double[] arr = mutObj.getField("dArr");
+ arr[0] = 2.0;
+
+ TestObjectAllTypes res = mutObj.build().deserialize();
+
+ Assert.assertArrayEquals(new double[] {2.0, 1.0, 1.0}, res.dArr, 0);
+ }
+
+ /**
+ *
+ */
+ public void testFloatArrayModification() {
+ TestObjectAllTypes obj = new TestObjectAllTypes();
+
+ obj.fArr = new float[] {1.0f, 1.0f, 1.0f};
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ float[] arr = mutObj.getField("fArr");
+ arr[0] = 2.0f;
+
+ TestObjectAllTypes res = mutObj.build().deserialize();
+
+ Assert.assertArrayEquals(new float[] {2.0f, 1.0f, 1.0f}, res.fArr, 0);
+ }
+
+ /**
+ *
+ */
+ public void testLongArrayModification() {
+ TestObjectAllTypes obj = new TestObjectAllTypes();
+
+ obj.lArr = new long[] {1, 1, 1};
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ long[] arr = mutObj.getField("lArr");
+ arr[0] = 2;
+
+ TestObjectAllTypes res = mutObj.build().deserialize();
+
+ Assert.assertArrayEquals(new long[] {2, 1, 1}, res.lArr);
+ }
+
+ /**
+ *
+ */
+ public void testIntArrayModification() {
+ TestObjectAllTypes obj = new TestObjectAllTypes();
+
+ obj.iArr = new int[] {1, 1, 1};
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ int[] arr = mutObj.getField("iArr");
+ arr[0] = 2;
+
+ TestObjectAllTypes res = mutObj.build().deserialize();
+
+ Assert.assertArrayEquals(new int[] {2, 1, 1}, res.iArr);
+ }
+
+ /**
+ *
+ */
+ public void testShortArrayModification() {
+ TestObjectAllTypes obj = new TestObjectAllTypes();
+
+ obj.sArr = new short[] {1, 1, 1};
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ short[] arr = mutObj.getField("sArr");
+ arr[0] = 2;
+
+ TestObjectAllTypes res = mutObj.build().deserialize();
+
+ Assert.assertArrayEquals(new short[] {2, 1, 1}, res.sArr);
+ }
+
+ /**
+ *
+ */
+ public void testByteArrayModification() {
+ TestObjectAllTypes obj = new TestObjectAllTypes();
+
+ obj.bArr = new byte[] {1, 1, 1};
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ byte[] arr = mutObj.getField("bArr");
+ arr[0] = 2;
+
+ TestObjectAllTypes res = mutObj.build().deserialize();
+
+ Assert.assertArrayEquals(new byte[] {2, 1, 1}, res.bArr);
+ }
+
+ /**
+ *
+ */
+ public void testStringArrayModification() {
+ TestObjectAllTypes obj = new TestObjectAllTypes();
+
+ obj.strArr = new String[] {"a", "a", "a"};
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ String[] arr = mutObj.getField("strArr");
+ arr[0] = "b";
+
+ TestObjectAllTypes res = mutObj.build().deserialize();
+
+ Assert.assertArrayEquals(new String[] {"b", "a", "a"}, res.strArr);
+ }
+
+ /**
+ *
+ */
+ public void testModifyObjectArray() {
+ TestObjectContainer obj = new TestObjectContainer();
+ obj.foo = new Object[] {"a"};
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ Object[] arr = mutObj.getField("foo");
+
+ Assert.assertArrayEquals(new Object[] {"a"}, arr);
+
+ arr[0] = "b";
+
+ TestObjectContainer res = mutObj.build().deserialize();
+
+ Assert.assertArrayEquals(new Object[] {"b"}, (Object[])res.foo);
+ }
+
+ /**
+ *
+ */
+ public void testOverrideObjectArrayField() {
+ BinaryObjectBuilderImpl mutObj = wrap(new TestObjectContainer());
+
+ Object[] createdArr = {mutObj, "a", 1, new String[] {"s", "s"}, new byte[] {1, 2}, new UUID(3, 0)};
+
+ mutObj.setField("foo", createdArr.clone());
+
+ TestObjectContainer res = mutObj.build().deserialize();
+
+ createdArr[0] = res;
+
+ assertTrue(Objects.deepEquals(createdArr, res.foo));
+ }
+
+ /**
+ *
+ */
+ public void testDeepArray() {
+ TestObjectContainer obj = new TestObjectContainer();
+ obj.foo = new Object[] {new Object[] {"a", obj}};
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ Object[] arr = (Object[])mutObj.<Object[]>getField("foo")[0];
+
+ assertEquals("a", arr[0]);
+ assertSame(mutObj, arr[1]);
+
+ arr[0] = mutObj;
+
+ TestObjectContainer res = mutObj.build().deserialize();
+
+ arr = (Object[])((Object[])res.foo)[0];
+
+ assertSame(arr[0], res);
+ assertSame(arr[0], arr[1]);
+ }
+
+ /**
+ *
+ */
+ public void testArrayListRead() {
+ TestObjectContainer obj = new TestObjectContainer();
+ obj.foo = Lists.newArrayList(obj, "a");
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ List<Object> list = mutObj.getField("foo");
+
+ assert list.equals(Lists.newArrayList(mutObj, "a"));
+ }
+
+ /**
+ *
+ */
+ public void testArrayListOverride() {
+ TestObjectContainer obj = new TestObjectContainer();
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ ArrayList<Object> list = Lists.newArrayList(mutObj, "a", Lists.newArrayList(1, 2));
+
+ mutObj.setField("foo", list);
+
+ TestObjectContainer res = mutObj.build().deserialize();
+
+ list.set(0, res);
+
+ assertNotSame(list, res.foo);
+ assertEquals(list, res.foo);
+ }
+
+ /**
+ *
+ */
+ public void testArrayListModification() {
+ TestObjectContainer obj = new TestObjectContainer();
+ obj.foo = Lists.newArrayList("a", "b", "c");
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ List<String> list = mutObj.getField("foo");
+
+ list.add("!"); // "a", "b", "c", "!"
+ list.add(0, "_"); // "_", "a", "b", "c", "!"
+
+ String s = list.remove(1); // "_", "b", "c", "!"
+ assertEquals("a", s);
+
+ assertEquals(Arrays.asList("c", "!"), list.subList(2, 4));
+ assertEquals(1, list.indexOf("b"));
+ assertEquals(1, list.lastIndexOf("b"));
+
+ TestObjectContainer res = mutObj.build().deserialize();
+
+ assertTrue(res.foo instanceof ArrayList);
+ assertEquals(Arrays.asList("_", "b", "c", "!"), res.foo);
+ }
+
+ /**
+ *
+ */
+ public void testArrayListClear() {
+ TestObjectContainer obj = new TestObjectContainer();
+ obj.foo = Lists.newArrayList("a", "b", "c");
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ List<String> list = mutObj.getField("foo");
+
+ list.clear();
+
+ assertEquals(Collections.emptyList(), mutObj.build().<TestObjectContainer>deserialize().foo);
+ }
+
+ /**
+ *
+ */
+ public void testArrayListWriteUnmodifiable() {
+ TestObjectContainer obj = new TestObjectContainer();
+
+ ArrayList<Object> src = Lists.newArrayList(obj, "a", "b", "c");
+
+ obj.foo = src;
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ TestObjectContainer deserialized = mutObj.build().deserialize();
+
+ List<Object> res = (List<Object>)deserialized.foo;
+
+ src.set(0, deserialized);
+
+ assertEquals(src, res);
+ }
+
+ /**
+ *
+ */
+ public void testLinkedListRead() {
+ TestObjectContainer obj = new TestObjectContainer();
+ obj.foo = Lists.newLinkedList(Arrays.asList(obj, "a"));
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ List<Object> list = mutObj.getField("foo");
+
+ assert list.equals(Lists.newLinkedList(Arrays.asList(mutObj, "a")));
+ }
+
+ /**
+ *
+ */
+ public void testLinkedListOverride() {
+ TestObjectContainer obj = new TestObjectContainer();
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ List<Object> list = Lists.newLinkedList(Arrays.asList(mutObj, "a", Lists.newLinkedList(Arrays.asList(1, 2))));
+
+ mutObj.setField("foo", list);
+
+ TestObjectContainer res = mutObj.build().deserialize();
+
+ list.set(0, res);
+
+ assertNotSame(list, res.foo);
+ assertEquals(list, res.foo);
+ }
+
+ /**
+ *
+ */
+ public void testLinkedListModification() {
+ TestObjectContainer obj = new TestObjectContainer();
+
+ obj.foo = Lists.newLinkedList(Arrays.asList("a", "b", "c"));
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ List<String> list = mutObj.getField("foo");
+
+ list.add("!"); // "a", "b", "c", "!"
+ list.add(0, "_"); // "_", "a", "b", "c", "!"
+
+ String s = list.remove(1); // "_", "b", "c", "!"
+ assertEquals("a", s);
+
+ assertEquals(Arrays.asList("c", "!"), list.subList(2, 4));
+ assertEquals(1, list.indexOf("b"));
+ assertEquals(1, list.lastIndexOf("b"));
+
+ TestObjectContainer res = mutObj.build().deserialize();
+
+ assertTrue(res.foo instanceof LinkedList);
+ assertEquals(Arrays.asList("_", "b", "c", "!"), res.foo);
+ }
+
+ /**
+ *
+ */
+ public void testLinkedListWriteUnmodifiable() {
+ TestObjectContainer obj = new TestObjectContainer();
+
+ LinkedList<Object> src = Lists.newLinkedList(Arrays.asList(obj, "a", "b", "c"));
+
+ obj.foo = src;
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ TestObjectContainer deserialized = mutObj.build().deserialize();
+
+ List<Object> res = (List<Object>)deserialized.foo;
+
+ src.set(0, deserialized);
+
+ assertEquals(src, res);
+ }
+
+ /**
+ *
+ */
+ public void testHashSetRead() {
+ TestObjectContainer obj = new TestObjectContainer();
+ obj.foo = Sets.newHashSet(obj, "a");
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ Set<Object> set = mutObj.getField("foo");
+
+ assert set.equals(Sets.newHashSet(mutObj, "a"));
+ }
+
+ /**
+ *
+ */
+ public void testHashSetOverride() {
+ TestObjectContainer obj = new TestObjectContainer();
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ Set<Object> c = Sets.newHashSet(mutObj, "a", Sets.newHashSet(1, 2));
+
+ mutObj.setField("foo", c);
+
+ TestObjectContainer res = mutObj.build().deserialize();
+
+ c.remove(mutObj);
+ c.add(res);
+
+ assertNotSame(c, res.foo);
+ assertEquals(c, res.foo);
+ }
+
+ /**
+ *
+ */
+ public void testHashSetModification() {
+ TestObjectContainer obj = new TestObjectContainer();
+ obj.foo = Sets.newHashSet("a", "b", "c");
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ Set<String> set = mutObj.getField("foo");
+
+ set.remove("b");
+ set.add("!");
+
+ assertEquals(Sets.newHashSet("a", "!", "c"), set);
+ assertTrue(set.contains("a"));
+ assertTrue(set.contains("!"));
+
+ TestObjectContainer res = mutObj.build().deserialize();
+
+ assertTrue(res.foo instanceof HashSet);
+ assertEquals(Sets.newHashSet("a", "!", "c"), res.foo);
+ }
+
+ /**
+ *
+ */
+ public void testHashSetWriteUnmodifiable() {
+ TestObjectContainer obj = new TestObjectContainer();
+
+ Set<Object> src = Sets.newHashSet(obj, "a", "b", "c");
+
+ obj.foo = src;
+
+ TestObjectContainer deserialized = wrap(obj).build().deserialize();
+
+ Set<Object> res = (Set<Object>)deserialized.foo;
+
+ src.remove(obj);
+ src.add(deserialized);
+
+ assertEquals(src, res);
+ }
+
+ /**
+ *
+ */
+ public void testMapRead() {
+ TestObjectContainer obj = new TestObjectContainer();
+ obj.foo = Maps.newHashMap(ImmutableMap.of(obj, "a", "b", obj));
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ Map<Object, Object> map = mutObj.getField("foo");
+
+ assert map.equals(ImmutableMap.of(mutObj, "a", "b", mutObj));
+ }
+
+ /**
+ *
+ */
+ public void testMapOverride() {
+ TestObjectContainer obj = new TestObjectContainer();
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ Map<Object, Object> map = Maps.newHashMap(ImmutableMap.of(mutObj, "a", "b", mutObj));
+
+ mutObj.setField("foo", map);
+
+ TestObjectContainer res = mutObj.build().deserialize();
+
+ assertEquals(ImmutableMap.of(res, "a", "b", res), res.foo);
+ }
+
+ /**
+ *
+ */
+ public void testMapModification() {
+ TestObjectContainer obj = new TestObjectContainer();
+ obj.foo = Maps.newHashMap(ImmutableMap.of(1, "a", 2, "b"));
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ Map<Object, Object> map = mutObj.getField("foo");
+
+ map.put(3, mutObj);
+ Object rmv = map.remove(1);
+
+ assertEquals("a", rmv);
+
+ TestObjectContainer res = mutObj.build().deserialize();
+
+ assertEquals(ImmutableMap.of(2, "b", 3, res), res.foo);
+ }
+
+ /**
+ *
+ */
+ public void testEnumArrayModification() {
+ TestObjectAllTypes obj = new TestObjectAllTypes();
+
+ obj.enumArr = new TestObjectEnum[] {TestObjectEnum.A, TestObjectEnum.B};
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ PortableBuilderEnum[] arr = mutObj.getField("enumArr");
+ arr[0] = new PortableBuilderEnum(mutObj.typeId(), TestObjectEnum.B);
+
+ TestObjectAllTypes res = mutObj.build().deserialize();
+
+ Assert.assertArrayEquals(new TestObjectEnum[] {TestObjectEnum.A, TestObjectEnum.B}, res.enumArr);
+ }
+
+ /**
+ *
+ */
+ public void testEditObjectWithRawData() {
+ GridBinaryMarshalerAwareTestClass obj = new GridBinaryMarshalerAwareTestClass();
+
+ obj.s = "a";
+ obj.sRaw = "aa";
+
+ BinaryObjectBuilderImpl mutableObj = wrap(obj);
+
+ mutableObj.setField("s", "z");
+
+ GridBinaryMarshalerAwareTestClass res = mutableObj.build().deserialize();
+ assertEquals("z", res.s);
+ assertEquals("aa", res.sRaw);
+ }
+
+ /**
+ *
+ */
+ public void testHashCode() {
+ TestObjectContainer obj = new TestObjectContainer();
+
+ BinaryObjectBuilderImpl mutableObj = wrap(obj);
+
+ assertEquals(obj.hashCode(), mutableObj.build().hashCode());
+
+ mutableObj.hashCode(25);
+
+ assertEquals(25, mutableObj.build().hashCode());
+ }
+
+ /**
+ *
+ */
+ public void testCollectionsInCollection() {
+ TestObjectContainer obj = new TestObjectContainer();
+ obj.foo = Lists.newArrayList(
+ Lists.newArrayList(1, 2),
+ Lists.newLinkedList(Arrays.asList(1, 2)),
+ Sets.newHashSet("a", "b"),
+ Sets.newLinkedHashSet(Arrays.asList("a", "b")),
+ Maps.newHashMap(ImmutableMap.of(1, "a", 2, "b")));
+
+ TestObjectContainer deserialized = wrap(obj).build().deserialize();
+
+ assertEquals(obj.foo, deserialized.foo);
+ }
+
+ /**
+ *
+ */
+ public void testMapEntryModification() {
+ TestObjectContainer obj = new TestObjectContainer();
+ obj.foo = ImmutableMap.of(1, "a").entrySet().iterator().next();
+
+ BinaryObjectBuilderImpl mutableObj = wrap(obj);
+
+ Map.Entry<Object, Object> entry = mutableObj.getField("foo");
+
+ assertEquals(1, entry.getKey());
+ assertEquals("a", entry.getValue());
+
+ entry.setValue("b");
+
+ TestObjectContainer res = mutableObj.build().deserialize();
+
+ assertEquals(new GridMapEntry<>(1, "b"), res.foo);
+ }
+
+ /**
+ *
+ */
+ public void testMapEntryOverride() {
+ TestObjectContainer obj = new TestObjectContainer();
+
+ BinaryObjectBuilderImpl mutableObj = wrap(obj);
+
+ mutableObj.setField("foo", new GridMapEntry<>(1, "a"));
+
+ TestObjectContainer res = mutableObj.build().deserialize();
+
+ assertEquals(new GridMapEntry<>(1, "a"), res.foo);
+ }
+
+ /**
+ *
+ */
+ public void testMetadataChangingDoublePut() {
+ BinaryObjectBuilderImpl mutableObj = wrap(new TestObjectContainer());
+
+ mutableObj.setField("xx567", "a");
+ mutableObj.setField("xx567", "b");
+
+ mutableObj.build();
+
+ BinaryTypeMetadata metadata = portables().metadata(TestObjectContainer.class);
+
+ assertEquals("String", metadata.fieldTypeName("xx567"));
+ }
+
+ /**
+ *
+ */
+ public void testMetadataChangingDoublePut2() {
+ BinaryObjectBuilderImpl mutableObj = wrap(new TestObjectContainer());
+
+ mutableObj.setField("xx567", "a");
+ mutableObj.setField("xx567", "b");
+
+ mutableObj.build();
+
+ BinaryTypeMetadata metadata = portables().metadata(TestObjectContainer.class);
+
+ assertEquals("String", metadata.fieldTypeName("xx567"));
+ }
+
+ /**
+ *
+ */
+ public void testMetadataChanging() {
+ TestObjectContainer c = new TestObjectContainer();
+
+ BinaryObjectBuilderImpl mutableObj = wrap(c);
+
+ mutableObj.setField("intField", 1);
+ mutableObj.setField("intArrField", new int[] {1});
+ mutableObj.setField("arrField", new String[] {"1"});
+ mutableObj.setField("strField", "1");
+ mutableObj.setField("colField", Lists.newArrayList("1"));
+ mutableObj.setField("mapField", Maps.newHashMap(ImmutableMap.of(1, "1")));
+ mutableObj.setField("enumField", TestObjectEnum.A);
+ mutableObj.setField("enumArrField", new Enum[] {TestObjectEnum.A});
+
+ mutableObj.build();
+
+ BinaryTypeMetadata metadata = portables().metadata(c.getClass());
+
+ assertTrue(metadata.fields().containsAll(Arrays.asList("intField", "intArrField", "arrField", "strField",
+ "colField", "mapField", "enumField", "enumArrField")));
+
+ assertEquals("int", metadata.fieldTypeName("intField"));
+ assertEquals("int[]", metadata.fieldTypeName("intArrField"));
+ assertEquals("String[]", metadata.fieldTypeName("arrField"));
+ assertEquals("String", metadata.fieldTypeName("strField"));
+ assertEquals("Collection", metadata.fieldTypeName("colField"));
+ assertEquals("Map", metadata.fieldTypeName("mapField"));
+ assertEquals("Enum", metadata.fieldTypeName("enumField"));
+ assertEquals("Enum[]", metadata.fieldTypeName("enumArrField"));
+ }
+
+ /**
+ *
+ */
+ public void testDateInObjectField() {
+ TestObjectContainer obj = new TestObjectContainer();
+
+ obj.foo = new Date();
+
+ BinaryObjectBuilderImpl mutableObj = wrap(obj);
+
+ assertEquals(Date.class, mutableObj.getField("foo").getClass());
+ }
+
+ /**
+ *
+ */
+ public void testTimestampInObjectField() {
+ TestObjectContainer obj = new TestObjectContainer();
+
+ obj.foo = new Timestamp(100020003);
+
+ BinaryObjectBuilderImpl mutableObj = wrap(obj);
+
+ assertEquals(Timestamp.class, mutableObj.getField("foo").getClass());
+ }
+
+ /**
+ *
+ */
+ public void testDateInCollection() {
+ TestObjectContainer obj = new TestObjectContainer();
+
+ obj.foo = Lists.newArrayList(new Date());
+
+ BinaryObjectBuilderImpl mutableObj = wrap(obj);
+
+ assertEquals(Date.class, ((List<?>)mutableObj.getField("foo")).get(0).getClass());
+ }
+
+ /**
+ *
+ */
+ public void testTimestampInCollection() {
+ TestObjectContainer obj = new TestObjectContainer();
+
+ obj.foo = Lists.newArrayList(new Timestamp(100020003));
+
+ BinaryObjectBuilderImpl mutableObj = wrap(obj);
+
+ assertEquals(Timestamp.class, ((List<?>)mutableObj.getField("foo")).get(0).getClass());
+ }
+
+ /**
+ *
+ */
+ @SuppressWarnings("AssertEqualsBetweenInconvertibleTypes")
+ public void testDateArrayOverride() {
+ TestObjectContainer obj = new TestObjectContainer();
+
+ BinaryObjectBuilderImpl mutableObj = wrap(obj);
+
+ Date[] arr = { new Date() };
+
+ mutableObj.setField("foo", arr);
+
+ TestObjectContainer res = mutableObj.build().deserialize();
+
+ assertEquals(Date[].class, res.foo.getClass());
+ assertTrue(Objects.deepEquals(arr, res.foo));
+ }
+
+ /**
+ *
+ */
+ @SuppressWarnings("AssertEqualsBetweenInconvertibleTypes")
+ public void testTimestampArrayOverride() {
+ TestObjectContainer obj = new TestObjectContainer();
+
+ BinaryObjectBuilderImpl mutableObj = wrap(obj);
+
+ Timestamp[] arr = { new Timestamp(100020003) };
+
+ mutableObj.setField("foo", arr);
+
+ TestObjectContainer res = mutableObj.build().deserialize();
+
+ assertEquals(Timestamp[].class, res.foo.getClass());
+ assertTrue(Objects.deepEquals(arr, res.foo));
+ }
+
+ /**
+ *
+ */
+ public void testChangeMap() {
+ AddressBook addrBook = new AddressBook();
+
+ addrBook.addCompany(new Company(1, "Google inc", 100, new Address("Saint-Petersburg", "Torzhkovskya", 1, 53), "occupation"));
+ addrBook.addCompany(new Company(2, "Apple inc", 100, new Address("Saint-Petersburg", "Torzhkovskya", 1, 54), "occupation"));
+ addrBook.addCompany(new Company(3, "Microsoft", 100, new Address("Saint-Petersburg", "Torzhkovskya", 1, 55), "occupation"));
+ addrBook.addCompany(new Company(4, "Oracle", 100, new Address("Saint-Petersburg", "Nevskiy", 1, 1), "occupation"));
+
+ BinaryObjectBuilderImpl mutableObj = wrap(addrBook);
+
+ Map<String, List<BinaryObjectBuilderImpl>> map = mutableObj.getField("companyByStreet");
+
+ List<BinaryObjectBuilderImpl> list = map.get("Torzhkovskya");
+
+ BinaryObjectBuilderImpl company = list.get(0);
+
+ assert "Google inc".equals(company.<String>getField("name"));
+
+ list.remove(0);
+
+ AddressBook res = mutableObj.build().deserialize();
+
+ assertEquals(Arrays.asList("Nevskiy", "Torzhkovskya"), new ArrayList<>(res.getCompanyByStreet().keySet()));
+
+ List<Company> torzhkovskyaCompanies = res.getCompanyByStreet().get("Torzhkovskya");
+
+ assertEquals(2, torzhkovskyaCompanies.size());
+ assertEquals("Apple inc", torzhkovskyaCompanies.get(0).name);
+ }
+
+ /**
+ *
+ */
+ public void testSavingObjectWithNotZeroStart() {
+ TestObjectOuter out = new TestObjectOuter();
+ TestObjectInner inner = new TestObjectInner();
+
+ out.inner = inner;
+ inner.outer = out;
+
+ BinaryObjectBuilderImpl builder = wrap(out);
+
+ BinaryObjectBuilderImpl innerBuilder = builder.getField("inner");
+
+ TestObjectInner res = innerBuilder.build().deserialize();
+
+ assertSame(res, res.outer.inner);
+ }
+
+ /**
+ *
+ */
+ public void testPortableObjectField() {
+ TestObjectContainer container = new TestObjectContainer(toPortable(new TestObjectArrayList()));
+
+ BinaryObjectBuilderImpl wrapper = wrap(container);
+
+ assertTrue(wrapper.getField("foo") instanceof BinaryObject);
+
+ TestObjectContainer deserialized = wrapper.build().deserialize();
+ assertTrue(deserialized.foo instanceof BinaryObject);
+ }
+
+ /**
+ *
+ */
+ public void testAssignPortableObject() {
+ TestObjectContainer container = new TestObjectContainer();
+
+ BinaryObjectBuilderImpl wrapper = wrap(container);
+
+ wrapper.setField("foo", toPortable(new TestObjectArrayList()));
+
+ TestObjectContainer deserialized = wrapper.build().deserialize();
+ assertTrue(deserialized.foo instanceof TestObjectArrayList);
+ }
+
+ /**
+ *
+ */
+ public void testRemoveFromNewObject() {
+ BinaryObjectBuilderImpl wrapper = newWrapper(TestObjectAllTypes.class);
+
+ wrapper.setField("str", "a");
+
+ wrapper.removeField("str");
+
+ assertNull(wrapper.build().<TestObjectAllTypes>deserialize().str);
+ }
+
+ /**
+ *
+ */
+ public void testRemoveFromExistingObject() {
+ TestObjectAllTypes obj = new TestObjectAllTypes();
+ obj.setDefaultData();
+
+ BinaryObjectBuilderImpl wrapper = wrap(toPortable(obj));
+
+ wrapper.removeField("str");
+
+ assertNull(wrapper.build().<TestObjectAllTypes>deserialize().str);
+ }
+
+ /**
+ *
+ */
+ public void testCyclicArrays() {
+ TestObjectContainer obj = new TestObjectContainer();
+
+ Object[] arr1 = new Object[1];
+ Object[] arr2 = new Object[] {arr1};
+
+ arr1[0] = arr2;
+
+ obj.foo = arr1;
+
+ TestObjectContainer res = toPortable(obj).deserialize();
+
+ Object[] resArr = (Object[])res.foo;
+
+ assertSame(((Object[])resArr[0])[0], resArr);
+ }
+
+ /**
+ *
+ */
+ @SuppressWarnings("TypeMayBeWeakened")
+ public void testCyclicArrayList() {
+ TestObjectContainer obj = new TestObjectContainer();
+
+ List<Object> arr1 = new ArrayList<>();
+ List<Object> arr2 = new ArrayList<>();
+
+ arr1.add(arr2);
+ arr2.add(arr1);
+
+ obj.foo = arr1;
+
+ TestObjectContainer res = toPortable(obj).deserialize();
+
+ List<?> resArr = (List<?>)res.foo;
+
+ assertSame(((List<Object>)resArr.get(0)).get(0), resArr);
+ }
+
+ /**
+ * @param obj Object.
+ * @return Object in portable format.
+ */
+ private BinaryObject toPortable(Object obj) {
+ return portables().toPortable(obj);
+ }
+
+ /**
+ * @param obj Object.
+ * @return GridMutablePortableObject.
+ */
+ private BinaryObjectBuilderImpl wrap(Object obj) {
+ return BinaryObjectBuilderImpl.wrap(toPortable(obj));
+ }
+
+ /**
+ * @param aCls Class.
+ * @return Wrapper.
+ */
+ private BinaryObjectBuilderImpl newWrapper(Class<?> aCls) {
+ CacheObjectPortableProcessorImpl processor = (CacheObjectPortableProcessorImpl)(
+ (IgniteObjectsImpl)portables()).processor();
+
+ return new BinaryObjectBuilderImpl(processor.portableContext(), processor.typeId(aCls.getName()),
+ aCls.getSimpleName());
+ }
+}
\ No newline at end of file