You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ag...@apache.org on 2015/11/21 23:46:03 UTC
[35/55] [abbrv] ignite git commit: Merged ignite-1945 into ignite-1282
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsAbstractSelfTest.java
index 8f79db1..dd08390 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsAbstractSelfTest.java
@@ -20,11 +20,12 @@ package org.apache.ignite.internal.portable;
import org.apache.ignite.binary.BinaryField;
import org.apache.ignite.binary.BinaryObject;
import org.apache.ignite.binary.BinaryTypeConfiguration;
+import org.apache.ignite.configuration.BinaryConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.util.IgniteUtils;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.marshaller.MarshallerContextTestImpl;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import java.math.BigDecimal;
@@ -38,7 +39,7 @@ import java.util.UUID;
*/
public abstract class BinaryFieldsAbstractSelfTest extends GridCommonAbstractTest {
/** Marshaller. */
- protected PortableMarshaller dfltMarsh;
+ protected BinaryMarshaller dfltMarsh;
/**
* Create marshaller.
@@ -46,22 +47,28 @@ public abstract class BinaryFieldsAbstractSelfTest extends GridCommonAbstractTes
* @return Portable marshaller.
* @throws Exception If failed.
*/
- protected PortableMarshaller createMarshaller() throws Exception {
+ protected BinaryMarshaller createMarshaller() throws Exception {
PortableContext ctx = new PortableContext(BinaryCachingMetadataHandler.create(), new IgniteConfiguration());
- PortableMarshaller marsh = new PortableMarshaller();
+ BinaryMarshaller marsh = new BinaryMarshaller();
- marsh.setCompactFooter(compactFooter());
+ BinaryConfiguration bCfg = new BinaryConfiguration();
+
+ bCfg.setCompactFooter(compactFooter());
- marsh.setTypeConfigurations(Arrays.asList(
+ bCfg.setTypeConfigurations(Arrays.asList(
new BinaryTypeConfiguration(TestObject.class.getName()),
new BinaryTypeConfiguration(TestOuterObject.class.getName()),
new BinaryTypeConfiguration(TestInnerObject.class.getName())
));
+ IgniteConfiguration iCfg = new IgniteConfiguration();
+
+ iCfg.setBinaryConfiguration(bCfg);
+
marsh.setContext(new MarshallerContextTestImpl(null));
- IgniteUtils.invoke(PortableMarshaller.class, marsh, "setPortableContext", ctx);
+ IgniteUtils.invoke(BinaryMarshaller.class, marsh, "setPortableContext", ctx, iCfg);
return marsh;
}
@@ -79,7 +86,7 @@ public abstract class BinaryFieldsAbstractSelfTest extends GridCommonAbstractTes
* @param marsh Marshaller.
* @return Portable context.
*/
- protected static PortableContext portableContext(PortableMarshaller marsh) {
+ protected static PortableContext portableContext(BinaryMarshaller marsh) {
GridPortableMarshaller impl = U.field(marsh, "impl");
return impl.context();
@@ -384,7 +391,7 @@ public abstract class BinaryFieldsAbstractSelfTest extends GridCommonAbstractTes
* @param exists Whether field should exist.
* @throws Exception If failed.
*/
- private void checkNormal(PortableMarshaller marsh, String fieldName, boolean exists) throws Exception {
+ private void checkNormal(BinaryMarshaller marsh, String fieldName, boolean exists) throws Exception {
TestContext testCtx = context(marsh, fieldName);
check0(fieldName, testCtx, exists);
@@ -398,7 +405,7 @@ public abstract class BinaryFieldsAbstractSelfTest extends GridCommonAbstractTes
* @param exists Whether field should exist.
* @throws Exception If failed.
*/
- private void checkNested(PortableMarshaller marsh, String fieldName, boolean exists) throws Exception {
+ private void checkNested(BinaryMarshaller marsh, String fieldName, boolean exists) throws Exception {
TestContext testCtx = nestedContext(marsh, fieldName);
check0(fieldName, testCtx, exists);
@@ -477,7 +484,7 @@ public abstract class BinaryFieldsAbstractSelfTest extends GridCommonAbstractTes
* @return Test context.
* @throws Exception If failed.
*/
- private TestContext context(PortableMarshaller marsh, String fieldName) throws Exception {
+ private TestContext context(BinaryMarshaller marsh, String fieldName) throws Exception {
TestObject obj = createObject();
BinaryObjectEx portObj = toPortable(marsh, obj);
@@ -495,7 +502,7 @@ public abstract class BinaryFieldsAbstractSelfTest extends GridCommonAbstractTes
* @return Test context.
* @throws Exception If failed.
*/
- private TestContext nestedContext(PortableMarshaller marsh, String fieldName)
+ private TestContext nestedContext(BinaryMarshaller marsh, String fieldName)
throws Exception {
TestObject obj = createObject();
TestOuterObject outObj = new TestOuterObject(obj);
@@ -527,7 +534,7 @@ public abstract class BinaryFieldsAbstractSelfTest extends GridCommonAbstractTes
* @return Portable object.
* @throws Exception If failed.
*/
- protected abstract BinaryObjectEx toPortable(PortableMarshaller marsh, Object obj) throws Exception;
+ protected abstract BinaryObjectEx toPortable(BinaryMarshaller marsh, Object obj) throws Exception;
/**
* Outer test object.
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsHeapSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsHeapSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsHeapSelfTest.java
index 0140c53..53ba212 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsHeapSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsHeapSelfTest.java
@@ -17,14 +17,14 @@
package org.apache.ignite.internal.portable;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
/**
* Field tests for heap-based portables.
*/
public class BinaryFieldsHeapSelfTest extends BinaryFieldsAbstractSelfTest {
/** {@inheritDoc} */
- @Override protected BinaryObjectEx toPortable(PortableMarshaller marsh, Object obj) throws Exception {
+ @Override protected BinaryObjectEx toPortable(BinaryMarshaller marsh, Object obj) throws Exception {
byte[] bytes = marsh.marshal(obj);
return new BinaryObjectImpl(portableContext(marsh), bytes, 0);
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsOffheapSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsOffheapSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsOffheapSelfTest.java
index 1bd0f72..68bfb30 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsOffheapSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsOffheapSelfTest.java
@@ -18,7 +18,7 @@
package org.apache.ignite.internal.portable;
import org.apache.ignite.internal.util.GridUnsafe;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
import org.eclipse.jetty.util.ConcurrentHashSet;
import sun.misc.Unsafe;
@@ -47,7 +47,7 @@ public class BinaryFieldsOffheapSelfTest extends BinaryFieldsAbstractSelfTest {
}
/** {@inheritDoc} */
- @Override protected BinaryObjectEx toPortable(PortableMarshaller marsh, Object obj) throws Exception {
+ @Override protected BinaryObjectEx toPortable(BinaryMarshaller marsh, Object obj) throws Exception {
byte[] arr = marsh.marshal(obj);
long ptr = UNSAFE.allocateMemory(arr.length);
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsAbstractSelfTest.java
index 3ec0b83..7267b16 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsAbstractSelfTest.java
@@ -17,16 +17,16 @@
package org.apache.ignite.internal.portable;
+import java.util.Arrays;
import org.apache.ignite.binary.BinaryField;
import org.apache.ignite.binary.BinaryTypeConfiguration;
+import org.apache.ignite.configuration.BinaryConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.util.IgniteUtils;
import org.apache.ignite.marshaller.MarshallerContextTestImpl;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-import java.util.Arrays;
-
/**
* Contains tests for compact offsets.
*/
@@ -38,7 +38,7 @@ public abstract class BinaryFooterOffsetsAbstractSelfTest extends GridCommonAbst
private static int POW_16 = 1 << 16;
/** Marshaller. */
- protected PortableMarshaller marsh;
+ protected BinaryMarshaller marsh;
/** Portable context. */
protected PortableContext ctx;
@@ -49,14 +49,21 @@ public abstract class BinaryFooterOffsetsAbstractSelfTest extends GridCommonAbst
ctx = new PortableContext(BinaryCachingMetadataHandler.create(), new IgniteConfiguration());
- marsh = new PortableMarshaller();
+ marsh = new BinaryMarshaller();
+
+ IgniteConfiguration iCfg = new IgniteConfiguration();
- marsh.setCompactFooter(compactFooter());
+ BinaryConfiguration bCfg = new BinaryConfiguration();
+
+ bCfg.setTypeConfigurations(Arrays.asList(new BinaryTypeConfiguration(TestObject.class.getName())));
+
+ bCfg.setCompactFooter(compactFooter());
+
+ iCfg.setBinaryConfiguration(bCfg);
- marsh.setTypeConfigurations(Arrays.asList(new BinaryTypeConfiguration(TestObject.class.getName())));
marsh.setContext(new MarshallerContextTestImpl(null));
- IgniteUtils.invoke(PortableMarshaller.class, marsh, "setPortableContext", ctx);
+ IgniteUtils.invoke(BinaryMarshaller.class, marsh, "setPortableContext", ctx, iCfg);
}
/**
@@ -65,7 +72,7 @@ public abstract class BinaryFooterOffsetsAbstractSelfTest extends GridCommonAbst
protected boolean compactFooter() {
return true;
}
-
+
/**
* Test 1 byte.
*
@@ -163,7 +170,7 @@ public abstract class BinaryFooterOffsetsAbstractSelfTest extends GridCommonAbst
* @return Portable object.
* @throws Exception If failed.
*/
- protected abstract BinaryObjectEx toPortable(PortableMarshaller marsh, Object obj) throws Exception;
+ protected abstract BinaryObjectEx toPortable(BinaryMarshaller marsh, Object obj) throws Exception;
/**
* Test object.
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsHeapSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsHeapSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsHeapSelfTest.java
index b23f012..471bd44 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsHeapSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsHeapSelfTest.java
@@ -17,14 +17,14 @@
package org.apache.ignite.internal.portable;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
/**
* Compact offsets tests for heap portable objects.
*/
public class BinaryFooterOffsetsHeapSelfTest extends BinaryFooterOffsetsAbstractSelfTest {
/** {@inheritDoc} */
- @Override protected BinaryObjectEx toPortable(PortableMarshaller marsh, Object obj) throws Exception {
+ @Override protected BinaryObjectEx toPortable(BinaryMarshaller marsh, Object obj) throws Exception {
byte[] bytes = marsh.marshal(obj);
return new BinaryObjectImpl(ctx, bytes, 0);
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsOffheapSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsOffheapSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsOffheapSelfTest.java
index e52ebe7..7b44b80 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsOffheapSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsOffheapSelfTest.java
@@ -18,7 +18,7 @@
package org.apache.ignite.internal.portable;
import org.apache.ignite.internal.util.GridUnsafe;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
import org.eclipse.jetty.util.ConcurrentHashSet;
import sun.misc.Unsafe;
@@ -47,7 +47,7 @@ public class BinaryFooterOffsetsOffheapSelfTest extends BinaryFooterOffsetsAbstr
}
/** {@inheritDoc} */
- @Override protected BinaryObjectEx toPortable(PortableMarshaller marsh, Object obj) throws Exception {
+ @Override protected BinaryObjectEx toPortable(BinaryMarshaller marsh, Object obj) throws Exception {
byte[] arr = marsh.marshal(obj);
long ptr = UNSAFE.allocateMemory(arr.length);
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryMarshallerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryMarshallerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryMarshallerSelfTest.java
index dfc8109..4584575 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryMarshallerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryMarshallerSelfTest.java
@@ -30,8 +30,10 @@ import org.apache.ignite.binary.BinarySerializer;
import org.apache.ignite.binary.BinaryTypeConfiguration;
import org.apache.ignite.binary.BinaryWriter;
import org.apache.ignite.binary.Binarylizable;
+import org.apache.ignite.configuration.BinaryConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.portable.builder.BinaryObjectBuilderImpl;
+import org.apache.ignite.internal.processors.cache.CacheObjectContext;
import org.apache.ignite.internal.util.GridUnsafe;
import org.apache.ignite.internal.util.IgniteUtils;
import org.apache.ignite.internal.util.lang.GridMapEntry;
@@ -39,7 +41,7 @@ import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.marshaller.MarshallerContextTestImpl;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
import org.apache.ignite.testframework.GridTestUtils;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.jsr166.ConcurrentHashMap8;
@@ -384,9 +386,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testBinaryObject() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(new BinaryTypeConfiguration(SimpleObject.class.getName())));
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(new BinaryTypeConfiguration(SimpleObject.class.getName())));
SimpleObject obj = simpleObject();
@@ -413,9 +413,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testEnum() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setClassNames(Arrays.asList(TestEnum.class.getName()));
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(new BinaryTypeConfiguration(TestEnum.class.getName())));
assertEquals(TestEnum.B, marshalUnmarshal(TestEnum.B, marsh));
}
@@ -426,9 +424,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
public void testDateAndTimestampInSingleObject() throws Exception {
BinaryTypeConfiguration cfg1 = new BinaryTypeConfiguration(DateClass1.class.getName());
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(cfg1));
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(cfg1));
Date date = new Date();
Timestamp ts = new Timestamp(System.currentTimeMillis());
@@ -453,9 +449,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testSimpleObject() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
new BinaryTypeConfiguration(SimpleObject.class.getName())
));
@@ -540,9 +534,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testPortable() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
new BinaryTypeConfiguration(SimpleObject.class.getName()),
new BinaryTypeConfiguration(TestBinary.class.getName())
));
@@ -704,9 +696,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testClassWithoutPublicConstructor() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
new BinaryTypeConfiguration(NoPublicConstructor.class.getName()),
new BinaryTypeConfiguration(NoPublicDefaultConstructor.class.getName()),
new BinaryTypeConfiguration(ProtectedConstructor.class.getName()))
@@ -732,14 +722,12 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testCustomSerializer() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
BinaryTypeConfiguration type =
new BinaryTypeConfiguration(CustomSerializedObject1.class.getName());
type.setSerializer(new CustomSerializer1());
- marsh.setTypeConfigurations(Arrays.asList(type));
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(type));
CustomSerializedObject1 obj1 = new CustomSerializedObject1(10);
@@ -752,10 +740,6 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testCustomSerializerWithGlobal() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setSerializer(new CustomSerializer1());
-
BinaryTypeConfiguration type1 =
new BinaryTypeConfiguration(CustomSerializedObject1.class.getName());
BinaryTypeConfiguration type2 =
@@ -763,7 +747,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
type2.setSerializer(new CustomSerializer2());
- marsh.setTypeConfigurations(Arrays.asList(type1, type2));
+ BinaryMarshaller marsh = binaryMarshaller(new CustomSerializer1(), Arrays.asList(type1, type2));
CustomSerializedObject1 obj1 = new CustomSerializedObject1(10);
@@ -782,8 +766,6 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testCustomIdMapper() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
BinaryTypeConfiguration type =
new BinaryTypeConfiguration(CustomMappedObject1.class.getName());
@@ -806,7 +788,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
}
});
- marsh.setTypeConfigurations(Arrays.asList(type));
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(type));
CustomMappedObject1 obj1 = new CustomMappedObject1(10, "str");
@@ -824,18 +806,21 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testCustomIdMapperWithGlobal() throws Exception {
- PortableMarshaller marsh = createMarshaller();
+ BinaryTypeConfiguration type1 =
+ new BinaryTypeConfiguration(CustomMappedObject1.class.getName());
+ BinaryTypeConfiguration type2 =
+ new BinaryTypeConfiguration(CustomMappedObject2.class.getName());
- marsh.setIdMapper(new BinaryIdMapper() {
+ type2.setIdMapper(new BinaryIdMapper() {
@Override public int typeId(String clsName) {
- return 11111;
+ return 44444;
}
@Override public int fieldId(int typeId, String fieldName) {
- assert typeId == 11111;
+ assert typeId == 44444;
- if ("val1".equals(fieldName)) return 22222;
- else if ("val2".equals(fieldName)) return 33333;
+ if ("val1".equals(fieldName)) return 55555;
+ else if ("val2".equals(fieldName)) return 66666;
assert false : "Unknown field: " + fieldName;
@@ -843,29 +828,24 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
}
});
- BinaryTypeConfiguration type1 =
- new BinaryTypeConfiguration(CustomMappedObject1.class.getName());
- BinaryTypeConfiguration type2 =
- new BinaryTypeConfiguration(CustomMappedObject2.class.getName());
-
- type2.setIdMapper(new BinaryIdMapper() {
+ BinaryMarshaller marsh = binaryMarshaller(new BinaryIdMapper() {
@Override public int typeId(String clsName) {
- return 44444;
+ return 11111;
}
@Override public int fieldId(int typeId, String fieldName) {
- assert typeId == 44444;
+ assert typeId == 11111;
- if ("val1".equals(fieldName)) return 55555;
- else if ("val2".equals(fieldName)) return 66666;
+ if ("val1".equals(fieldName))
+ return 22222;
+ else if ("val2".equals(fieldName))
+ return 33333;
assert false : "Unknown field: " + fieldName;
return 0;
}
- });
-
- marsh.setTypeConfigurations(Arrays.asList(type1, type2));
+ }, Arrays.asList(type1, type2));
CustomMappedObject1 obj1 = new CustomMappedObject1(10, "str1");
@@ -894,14 +874,10 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testDynamicObject() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
new BinaryTypeConfiguration(DynamicObject.class.getName())
));
- initializePortableContext(marsh);
-
BinaryObject po1 = marshal(new DynamicObject(0, 10, 20, 30), marsh);
assertEquals(new Integer(10), po1.field("val1"));
@@ -943,9 +919,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testCycleLink() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
new BinaryTypeConfiguration(CycleLinkObject.class.getName())
));
@@ -964,9 +938,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testDetached() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
new BinaryTypeConfiguration(DetachedTestObject.class.getName()),
new BinaryTypeConfiguration(DetachedInnerTestObject.class.getName())
));
@@ -1020,9 +992,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testCollectionFields() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
new BinaryTypeConfiguration(CollectionFieldsObject.class.getName()),
new BinaryTypeConfiguration(Key.class.getName()),
new BinaryTypeConfiguration(Value.class.getName())
@@ -1061,10 +1031,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
/**
* @throws Exception If failed.
*/
- // TODO: Only with full headers.
public void _testDefaultMapping() throws Exception {
- PortableMarshaller marsh1 = createMarshaller();
-
BinaryTypeConfiguration customMappingType =
new BinaryTypeConfiguration(TestBinary.class.getName());
@@ -1091,7 +1058,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
}
});
- marsh1.setTypeConfigurations(Arrays.asList(
+ BinaryMarshaller marsh1 = binaryMarshaller(Arrays.asList(
new BinaryTypeConfiguration(SimpleObject.class.getName()),
customMappingType
));
@@ -1100,16 +1067,12 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
BinaryObjectImpl po = marshal(obj, marsh1);
- PortableMarshaller marsh2 = createMarshaller();
-
- marsh2.setTypeConfigurations(Arrays.asList(
+ BinaryMarshaller marsh2 = binaryMarshaller(Arrays.asList(
new BinaryTypeConfiguration(SimpleObject.class.getName()),
new BinaryTypeConfiguration(TestBinary.class.getName())
));
- PortableContext ctx = initializePortableContext(marsh2);
-
- po.context(ctx);
+ po = marshal(obj, marsh2);
assertEquals(obj, po.deserialize());
}
@@ -1118,8 +1081,6 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testTypeNames() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
BinaryTypeConfiguration customType1 = new BinaryTypeConfiguration(Value.class.getName());
customType1.setIdMapper(new BinaryIdMapper() {
@@ -1168,7 +1129,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
}
});
- marsh.setTypeConfigurations(Arrays.asList(
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
new BinaryTypeConfiguration(Key.class.getName()),
new BinaryTypeConfiguration("org.gridgain.NonExistentClass3"),
new BinaryTypeConfiguration("NonExistentClass4"),
@@ -1178,7 +1139,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
customType4
));
- PortableContext ctx = initializePortableContext(marsh);
+ PortableContext ctx = portableContext(marsh);
assertEquals("notconfiguredclass".hashCode(), ctx.typeId("NotConfiguredClass"));
assertEquals("key".hashCode(), ctx.typeId("Key"));
@@ -1194,8 +1155,6 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testFieldIdMapping() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
BinaryTypeConfiguration customType1 = new BinaryTypeConfiguration(Value.class.getName());
customType1.setIdMapper(new BinaryIdMapper() {
@@ -1238,12 +1197,12 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
}
});
- marsh.setTypeConfigurations(Arrays.asList(new BinaryTypeConfiguration(Key.class.getName()),
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(new BinaryTypeConfiguration(Key.class.getName()),
new BinaryTypeConfiguration("NonExistentClass2"),
customType1,
customType2));
- PortableContext ctx = initializePortableContext(marsh);
+ PortableContext ctx = portableContext(marsh);
assertEquals("val".hashCode(), ctx.fieldId("key".hashCode(), "val"));
assertEquals("val".hashCode(), ctx.fieldId("nonexistentclass2".hashCode(), "val"));
@@ -1260,8 +1219,6 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testDuplicateTypeId() throws Exception {
- final PortableMarshaller marsh = createMarshaller();
-
BinaryTypeConfiguration customType1 = new BinaryTypeConfiguration("org.gridgain.Class1");
customType1.setIdMapper(new BinaryIdMapper() {
@@ -1286,13 +1243,11 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
}
});
- marsh.setTypeConfigurations(Arrays.asList(customType1, customType2));
-
try {
- initializePortableContext(marsh);
+ binaryMarshaller(Arrays.asList(customType1, customType2));
}
catch (IgniteCheckedException e) {
- assertEquals("Duplicate type ID [clsName=org.gridgain.Class1, id=100]",
+ assertEquals("Duplicate type ID [clsName=org.gridgain.Class2, id=100]",
e.getCause().getCause().getMessage());
return;
@@ -1305,14 +1260,10 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testPortableCopy() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
new BinaryTypeConfiguration(SimpleObject.class.getName())
));
- initializePortableContext(marsh);
-
SimpleObject obj = simpleObject();
final BinaryObject po = marshal(obj, marsh);
@@ -1432,9 +1383,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testPortableCopyString() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
new BinaryTypeConfiguration(SimpleObject.class.getName())
));
@@ -1455,9 +1404,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testPortableCopyUuid() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
new BinaryTypeConfiguration(SimpleObject.class.getName())
));
@@ -1480,9 +1427,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testPortableCopyByteArray() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
new BinaryTypeConfiguration(SimpleObject.class.getName())
));
@@ -1519,9 +1464,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testPortableCopyShortArray() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
new BinaryTypeConfiguration(SimpleObject.class.getName())
));
@@ -1542,9 +1485,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testPortableCopyIntArray() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
new BinaryTypeConfiguration(SimpleObject.class.getName())
));
@@ -1565,9 +1506,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testPortableCopyLongArray() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
new BinaryTypeConfiguration(SimpleObject.class.getName())
));
@@ -1588,9 +1527,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testPortableCopyFloatArray() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
new BinaryTypeConfiguration(SimpleObject.class.getName())
));
@@ -1611,9 +1548,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testPortableCopyDoubleArray() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
new BinaryTypeConfiguration(SimpleObject.class.getName())
));
@@ -1634,9 +1569,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testPortableCopyCharArray() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
new BinaryTypeConfiguration(SimpleObject.class.getName())
));
@@ -1657,9 +1590,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testPortableCopyStringArray() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
new BinaryTypeConfiguration(SimpleObject.class.getName())
));
@@ -1680,9 +1611,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testPortableCopyObject() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
new BinaryTypeConfiguration(SimpleObject.class.getName())
));
@@ -1709,9 +1638,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testPortableCopyNonPrimitives() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
new BinaryTypeConfiguration(SimpleObject.class.getName())
));
@@ -1748,9 +1675,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testPortableCopyMixed() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(new BinaryTypeConfiguration(SimpleObject.class.getName())));
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(new BinaryTypeConfiguration(SimpleObject.class.getName())));
SimpleObject obj = simpleObject();
@@ -1794,82 +1719,26 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testKeepDeserialized() throws Exception {
- PortableMarshaller marsh = createMarshaller();
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(new BinaryTypeConfiguration(SimpleObject.class.getName())));
- marsh.setClassNames(Arrays.asList(SimpleObject.class.getName()));
- marsh.setKeepDeserialized(true);
+ BinaryObjectImpl po = marshal(simpleObject(), marsh);
- BinaryObject po = marshal(simpleObject(), marsh);
+ CacheObjectContext coCtx = new CacheObjectContext(newContext(), null, false, true, false);
- assert po.deserialize() == po.deserialize();
-
- marsh = createMarshaller();
-
- marsh.setClassNames(Arrays.asList(SimpleObject.class.getName()));
- marsh.setKeepDeserialized(false);
+ assert po.value(coCtx, false) == po.value(coCtx, false);
po = marshal(simpleObject(), marsh);
assert po.deserialize() != po.deserialize();
-
- marsh = createMarshaller();
-
- marsh.setKeepDeserialized(true);
- marsh.setTypeConfigurations(Arrays.asList(
- new BinaryTypeConfiguration(SimpleObject.class.getName())));
-
- po = marshal(simpleObject(), marsh);
-
- assert po.deserialize() == po.deserialize();
-
- marsh = createMarshaller();
-
- marsh.setKeepDeserialized(false);
- marsh.setTypeConfigurations(Arrays.asList(
- new BinaryTypeConfiguration(SimpleObject.class.getName())));
-
- po = marshal(simpleObject(), marsh);
-
- assert po.deserialize() != po.deserialize();
-
- marsh = createMarshaller();
-
- marsh.setKeepDeserialized(true);
-
- BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration(SimpleObject.class.getName());
-
- typeCfg.setKeepDeserialized(false);
-
- marsh.setTypeConfigurations(Arrays.asList(typeCfg));
-
- po = marshal(simpleObject(), marsh);
-
- assert po.deserialize() != po.deserialize();
-
- marsh = createMarshaller();
-
- marsh.setKeepDeserialized(false);
-
- typeCfg = new BinaryTypeConfiguration(SimpleObject.class.getName());
-
- typeCfg.setKeepDeserialized(true);
-
- marsh.setTypeConfigurations(Arrays.asList(typeCfg));
-
- po = marshal(simpleObject(), marsh);
-
- assert po.deserialize() == po.deserialize();
}
/**
* @throws Exception If failed.
*/
public void testOffheapPortable() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(new BinaryTypeConfiguration(SimpleObject.class.getName())));
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(new BinaryTypeConfiguration(SimpleObject.class.getName())));
- PortableContext ctx = initializePortableContext(marsh);
+ PortableContext ctx = portableContext(marsh);
SimpleObject simpleObj = simpleObject();
@@ -1961,10 +1830,9 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
*
*/
public void testReadResolve() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setClassNames(
- Arrays.asList(MySingleton.class.getName(), SingletonMarker.class.getName()));
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
+ new BinaryTypeConfiguration(MySingleton.class.getName()),
+ new BinaryTypeConfiguration(SingletonMarker.class.getName())));
BinaryObjectImpl portableObj = marshal(MySingleton.INSTANCE, marsh);
@@ -1979,9 +1847,8 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
*
*/
public void testReadResolveOnPortableAware() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setClassNames(Collections.singletonList(MyTestClass.class.getName()));
+ BinaryMarshaller marsh = binaryMarshaller(Collections.singletonList(
+ new BinaryTypeConfiguration(MyTestClass.class.getName())));
BinaryObjectImpl portableObj = marshal(new MyTestClass(), marsh);
@@ -1994,9 +1861,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If ecxeption thrown.
*/
public void testDeclareReadResolveInParent() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setClassNames(Arrays.asList(ChildPortable.class.getName()));
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(new BinaryTypeConfiguration(ChildPortable.class.getName())));
BinaryObjectImpl portableObj = marshal(new ChildPortable(), marsh);
@@ -2009,14 +1874,12 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
*
*/
public void testDecimalFields() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- Collection<String> clsNames = new ArrayList<>();
+ Collection<BinaryTypeConfiguration> clsNames = new ArrayList<>();
- clsNames.add(DecimalReflective.class.getName());
- clsNames.add(DecimalMarshalAware.class.getName());
+ clsNames.add(new BinaryTypeConfiguration(DecimalReflective.class.getName()));
+ clsNames.add(new BinaryTypeConfiguration(DecimalMarshalAware.class.getName()));
- marsh.setClassNames(clsNames);
+ BinaryMarshaller marsh = binaryMarshaller(clsNames);
// 1. Test reflective stuff.
DecimalReflective obj1 = new DecimalReflective();
@@ -2054,8 +1917,8 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
/**
* @throws IgniteCheckedException If failed.
*/
- public void testFinalField() throws Exception {
- PortableMarshaller marsh = createMarshaller();
+ public void testFinalField() throws IgniteCheckedException {
+ BinaryMarshaller marsh = binaryMarshaller();
SimpleObjectWithFinal obj = new SimpleObjectWithFinal();
@@ -2071,9 +1934,9 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
// Checking the writer directly.
assertEquals(false, INSTANCE.isAcquired());
- PortableMarshaller marsh0 = createMarshaller();
-
- try (BinaryWriterExImpl writer = new BinaryWriterExImpl(portableContext(marsh0))) {
+ BinaryMarshaller marsh = binaryMarshaller();
+
+ try (BinaryWriterExImpl writer = new BinaryWriterExImpl(portableContext(marsh))) {
assertEquals(true, INSTANCE.isAcquired());
writer.writeString("Thread local test");
@@ -2086,16 +1949,16 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
// Checking the portable marshaller.
assertEquals(false, INSTANCE.isAcquired());
- PortableMarshaller marsh = createMarshaller();
+ marsh = binaryMarshaller();
marsh.marshal(new SimpleObject());
assertEquals(false, INSTANCE.isAcquired());
- // Checking the builder.
- PortableMarshaller marsh2 = createMarshaller();
+ marsh = binaryMarshaller();
- BinaryObjectBuilder builder = new BinaryObjectBuilderImpl(portableContext(marsh2),
+ // Checking the builder.
+ BinaryObjectBuilder builder = new BinaryObjectBuilderImpl(portableContext(marsh),
"org.gridgain.foo.bar.TestClass");
builder.setField("a", "1");
@@ -2109,7 +1972,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testDuplicateName() throws Exception {
- PortableMarshaller marsh = createMarshaller();
+ BinaryMarshaller marsh = binaryMarshaller();
Test1.Job job1 = new Test1().new Job();
Test2.Job job2 = new Test2().new Job();
@@ -2132,7 +1995,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testClass() throws Exception {
- PortableMarshaller marsh = createMarshaller();
+ BinaryMarshaller marsh = binaryMarshaller();
Class cls = BinaryMarshallerSelfTest.class;
@@ -2145,7 +2008,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testClassFieldsMarshalling() throws Exception {
- PortableMarshaller marsh = createMarshaller();
+ BinaryMarshaller marsh = binaryMarshaller();
ObjectWithClassFields obj = new ObjectWithClassFields();
obj.cls1 = BinaryMarshallerSelfTest.class;
@@ -2168,7 +2031,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testMarshallingThroughJdk() throws Exception {
- PortableMarshaller marsh = createMarshaller();
+ BinaryMarshaller marsh = binaryMarshaller();
InetSocketAddress addr = new InetSocketAddress("192.168.0.2", 4545);
@@ -2204,9 +2067,9 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testPredefinedTypeIds() throws Exception {
- PortableMarshaller marsh = createMarshaller();
+ BinaryMarshaller marsh = binaryMarshaller();
- PortableContext pCtx = initializePortableContext(marsh);
+ PortableContext pCtx = portableContext(marsh);
Field field = pCtx.getClass().getDeclaredField("predefinedTypeNames");
@@ -2233,7 +2096,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testCyclicReferencesMarshalling() throws Exception {
- PortableMarshaller marsh = createMarshaller();
+ BinaryMarshaller marsh = binaryMarshaller();
SimpleObject obj = simpleObject();
@@ -2355,8 +2218,8 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @param obj Original object.
* @return Result object.
*/
- private <T> T marshalUnmarshal(T obj) throws Exception {
- return marshalUnmarshal(obj, createMarshaller());
+ private <T> T marshalUnmarshal(T obj) throws IgniteCheckedException {
+ return marshalUnmarshal(obj, binaryMarshaller());
}
/**
@@ -2364,9 +2227,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @param marsh Marshaller.
* @return Result object.
*/
- private <T> T marshalUnmarshal(Object obj, PortableMarshaller marsh) throws IgniteCheckedException {
- initializePortableContext(marsh);
-
+ private <T> T marshalUnmarshal(Object obj, BinaryMarshaller marsh) throws IgniteCheckedException {
byte[] bytes = marsh.marshal(obj);
return marsh.unmarshal(bytes, null);
@@ -2377,9 +2238,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @param marsh Marshaller.
* @return Portable object.
*/
- private <T> BinaryObjectImpl marshal(T obj, PortableMarshaller marsh) throws IgniteCheckedException {
- initializePortableContext(marsh);
-
+ private <T> BinaryObjectImpl marshal(T obj, BinaryMarshaller marsh) throws IgniteCheckedException {
byte[] bytes = marsh.marshal(obj);
return new BinaryObjectImpl(U.<GridPortableMarshaller>field(marsh, "impl").context(),
@@ -2387,54 +2246,83 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
}
/**
- * Create portable marshaller.
- *
- * @return Portable marshaller.
- * @throws Exception If failed.
+ * @return Whether to use compact footers or not.
*/
- private PortableMarshaller createMarshaller() throws Exception {
- PortableMarshaller marsh = new PortableMarshaller();
-
- marsh.setCompactFooter(compactFooter());
+ protected boolean compactFooter() {
+ return true;
+ }
+
+ /**
+ * @param marsh Marshaller.
+ * @return Portable context.
+ */
+ protected PortableContext portableContext(BinaryMarshaller marsh) {
+ GridPortableMarshaller impl = U.field(marsh, "impl");
- initializePortableContext(marsh);
+ return impl.context();
+ }
- return marsh;
+ /**
+ *
+ */
+ protected BinaryMarshaller binaryMarshaller()
+ throws IgniteCheckedException {
+ return binaryMarshaller(null, null, null);
}
/**
- * @return Whether to use compact footers or not.
+ *
*/
- protected boolean compactFooter() {
- return true;
+ protected BinaryMarshaller binaryMarshaller(Collection<BinaryTypeConfiguration> cfgs)
+ throws IgniteCheckedException {
+ return binaryMarshaller(null, null, cfgs);
}
/**
- * Get portable context of the given marshaller.
*
- * @param marsh Marshaller.
- * @return Context.
- * @throws Exception If failed.
*/
- private PortableContext portableContext(PortableMarshaller marsh) throws Exception {
- GridPortableMarshaller marsh0 = IgniteUtils.field(marsh, "impl");
+ protected BinaryMarshaller binaryMarshaller(BinaryIdMapper mapper, Collection<BinaryTypeConfiguration> cfgs)
+ throws IgniteCheckedException {
+ return binaryMarshaller(mapper, null, cfgs);
+ }
- return marsh0.context();
+ /**
+ *
+ */
+ protected BinaryMarshaller binaryMarshaller(BinarySerializer serializer, Collection<BinaryTypeConfiguration> cfgs)
+ throws IgniteCheckedException {
+ return binaryMarshaller(null, serializer, cfgs);
}
/**
- * @return Portable context.
+ * @return Binary marshaller.
*/
- private PortableContext initializePortableContext(PortableMarshaller marsh) throws IgniteCheckedException {
+ protected BinaryMarshaller binaryMarshaller(
+ BinaryIdMapper mapper,
+ BinarySerializer serializer,
+ Collection<BinaryTypeConfiguration> cfgs
+ ) throws IgniteCheckedException {
IgniteConfiguration iCfg = new IgniteConfiguration();
+ BinaryConfiguration bCfg = new BinaryConfiguration();
+
+ bCfg.setIdMapper(mapper);
+ bCfg.setSerializer(serializer);
+ bCfg.setCompactFooter(compactFooter());
+
+ bCfg.setTypeConfigurations(cfgs);
+
+ iCfg.setBinaryConfiguration(bCfg);
+
PortableContext ctx = new PortableContext(BinaryCachingMetadataHandler.create(), iCfg);
+ BinaryMarshaller marsh = new BinaryMarshaller();
+
marsh.setContext(new MarshallerContextTestImpl(null));
- IgniteUtils.invoke(PortableMarshaller.class, marsh, "setPortableContext", ctx);
+ IgniteUtils.invoke(BinaryMarshaller.class, marsh, "setPortableContext", ctx, iCfg);
- return ctx;
+ return marsh;
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryObjectBuilderAdditionalSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryObjectBuilderAdditionalSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryObjectBuilderAdditionalSelfTest.java
index 0e31451..356a25b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryObjectBuilderAdditionalSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryObjectBuilderAdditionalSelfTest.java
@@ -37,6 +37,7 @@ import java.util.Set;
import java.util.UUID;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteBinary;
+import org.apache.ignite.configuration.BinaryConfiguration;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.portable.builder.PortableBuilderEnum;
@@ -45,7 +46,7 @@ import org.apache.ignite.internal.portable.mutabletest.GridBinaryMarshalerAwareT
import org.apache.ignite.internal.processors.cache.portable.CacheObjectBinaryProcessorImpl;
import org.apache.ignite.internal.processors.cache.portable.IgniteBinaryImpl;
import org.apache.ignite.internal.util.lang.GridMapEntry;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
import org.apache.ignite.binary.BinaryObjectBuilder;
import org.apache.ignite.binary.BinaryType;
import org.apache.ignite.binary.BinaryObject;
@@ -78,13 +79,13 @@ public class BinaryObjectBuilderAdditionalSelfTest extends GridCommonAbstractTes
cfg.setCacheConfiguration(cacheCfg);
- PortableMarshaller marsh = new PortableMarshaller();
+ BinaryConfiguration bCfg = new BinaryConfiguration();
- marsh.setCompactFooter(compactFooter());
+ bCfg.setCompactFooter(compactFooter());
+
+ bCfg.setClassNames(Arrays.asList("org.apache.ignite.internal.portable.mutabletest.*"));
- marsh.setClassNames(Arrays.asList("org.apache.ignite.internal.portable.mutabletest.*"));
-
- cfg.setMarshaller(marsh);
+ cfg.setMarshaller(new BinaryMarshaller());
return cfg;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryObjectBuilderSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryObjectBuilderSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryObjectBuilderSelfTest.java
index 2dfa6d0..7f023f3 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryObjectBuilderSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryObjectBuilderSelfTest.java
@@ -22,13 +22,18 @@ import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;
-import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteBinary;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.binary.BinaryIdMapper;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.binary.BinaryObjectBuilder;
+import org.apache.ignite.binary.BinaryType;
+import org.apache.ignite.binary.BinaryTypeConfiguration;
+import org.apache.ignite.configuration.BinaryConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.portable.builder.BinaryObjectBuilderImpl;
import org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.TestObjectAllTypes;
@@ -39,12 +44,7 @@ import org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.T
import org.apache.ignite.internal.processors.cache.portable.CacheObjectBinaryProcessorImpl;
import org.apache.ignite.internal.util.GridUnsafe;
import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
-import org.apache.ignite.binary.BinaryObjectBuilder;
-import org.apache.ignite.binary.BinaryIdMapper;
-import org.apache.ignite.binary.BinaryType;
-import org.apache.ignite.binary.BinaryObject;
-import org.apache.ignite.binary.BinaryTypeConfiguration;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
import org.apache.ignite.testframework.GridTestUtils;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import sun.misc.Unsafe;
@@ -63,17 +63,10 @@ public class BinaryObjectBuilderSelfTest extends GridCommonAbstractTest {
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(gridName);
- PortableMarshaller marsh = new PortableMarshaller();
-
- marsh.setCompactFooter(compactFooter());
+ BinaryTypeConfiguration customTypeCfg = new BinaryTypeConfiguration();
- marsh.setClassNames(Arrays.asList(Key.class.getName(), Value.class.getName(),
- "org.gridgain.grid.internal.util.portable.mutabletest.*"));
-
- BinaryTypeConfiguration customIdMapper = new BinaryTypeConfiguration();
-
- customIdMapper.setClassName(CustomIdMapper.class.getName());
- customIdMapper.setIdMapper(new BinaryIdMapper() {
+ customTypeCfg.setTypeName(CustomIdMapper.class.getName());
+ customTypeCfg.setIdMapper(new BinaryIdMapper() {
@Override public int typeId(String clsName) {
return ~BinaryInternalIdMapper.defaultInstance().typeId(clsName);
}
@@ -83,9 +76,19 @@ public class BinaryObjectBuilderSelfTest extends GridCommonAbstractTest {
}
});
- marsh.setTypeConfigurations(Collections.singleton(customIdMapper));
+ BinaryConfiguration bCfg = new BinaryConfiguration();
+
+ bCfg.setCompactFooter(compactFooter());
+
+ bCfg.setTypeConfigurations(Arrays.asList(
+ new BinaryTypeConfiguration(Key.class.getName()),
+ new BinaryTypeConfiguration(Value.class.getName()),
+ new BinaryTypeConfiguration("org.gridgain.grid.internal.util.portable.mutabletest.*"),
+ customTypeCfg));
+
+ cfg.setBinaryConfiguration(bCfg);
- cfg.setMarshaller(marsh);
+ cfg.setMarshaller(new BinaryMarshaller());
return cfg;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableAffinityKeySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableAffinityKeySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableAffinityKeySelfTest.java
index 748c423..9fb3a6f 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableAffinityKeySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableAffinityKeySelfTest.java
@@ -23,6 +23,7 @@ import java.util.concurrent.atomic.AtomicReference;
import org.apache.ignite.Ignite;
import org.apache.ignite.cache.CacheKeyConfiguration;
import org.apache.ignite.cache.affinity.Affinity;
+import org.apache.ignite.configuration.BinaryConfiguration;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.IgniteKernal;
@@ -32,7 +33,7 @@ import org.apache.ignite.internal.processors.cache.CacheObjectContext;
import org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor;
import org.apache.ignite.lang.IgniteCallable;
import org.apache.ignite.lang.IgniteRunnable;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
import org.apache.ignite.binary.BinaryTypeConfiguration;
import org.apache.ignite.resources.IgniteInstanceResource;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
@@ -61,17 +62,19 @@ public class GridPortableAffinityKeySelfTest extends GridCommonAbstractTest {
BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration();
- typeCfg.setClassName(TestObject.class.getName());
+ typeCfg.setTypeName(TestObject.class.getName());
- PortableMarshaller marsh = new PortableMarshaller();
+ BinaryConfiguration bCfg = new BinaryConfiguration();
- marsh.setTypeConfigurations(Collections.singleton(typeCfg));
+ bCfg.setTypeConfigurations(Collections.singleton(typeCfg));
+
+ cfg.setBinaryConfiguration(bCfg);
CacheKeyConfiguration keyCfg = new CacheKeyConfiguration(TestObject.class.getName(), "affKey");
cfg.setCacheKeyCfg(keyCfg);
- cfg.setMarshaller(marsh);
+ cfg.setMarshaller(new BinaryMarshaller());
if (!gridName.equals(getTestGridName(GRID_CNT))) {
CacheConfiguration cacheCfg = new CacheConfiguration();
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerCtxDisabledSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerCtxDisabledSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerCtxDisabledSelfTest.java
index 9c0824e..917298a 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerCtxDisabledSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerCtxDisabledSelfTest.java
@@ -25,7 +25,7 @@ import org.apache.ignite.binary.Binarylizable;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.MarshallerContextAdapter;
import org.apache.ignite.internal.util.IgniteUtils;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import java.io.Externalizable;
@@ -42,12 +42,14 @@ public class GridPortableMarshallerCtxDisabledSelfTest extends GridCommonAbstrac
* @throws Exception If failed.
*/
public void testObjectExchange() throws Exception {
- PortableMarshaller marsh = new PortableMarshaller();
+ BinaryMarshaller marsh = new BinaryMarshaller();
marsh.setContext(new MarshallerContextWithNoStorage());
- PortableContext context = new PortableContext(BinaryCachingMetadataHandler.create(), new IgniteConfiguration());
+ IgniteConfiguration cfg = new IgniteConfiguration();
- IgniteUtils.invoke(PortableMarshaller.class, marsh, "setPortableContext", context);
+ PortableContext context = new PortableContext(BinaryCachingMetadataHandler.create(), cfg);
+
+ IgniteUtils.invoke(BinaryMarshaller.class, marsh, "setPortableContext", context, cfg);
SimpleObject simpleObj = new SimpleObject();
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataSelfTest.java
index 2a367a8..5c25d3b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataSelfTest.java
@@ -23,9 +23,10 @@ import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import org.apache.ignite.IgniteBinary;
+import org.apache.ignite.configuration.BinaryConfiguration;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
import org.apache.ignite.binary.BinaryObjectException;
import org.apache.ignite.binary.Binarylizable;
import org.apache.ignite.binary.BinaryType;
@@ -46,11 +47,13 @@ public class GridPortableMetaDataSelfTest extends GridCommonAbstractTest {
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(gridName);
- PortableMarshaller marsh = new PortableMarshaller();
+ BinaryConfiguration bCfg = new BinaryConfiguration();
- marsh.setClassNames(Arrays.asList(TestObject1.class.getName(), TestObject2.class.getName()));
+ bCfg.setClassNames(Arrays.asList(TestObject1.class.getName(), TestObject2.class.getName()));
- cfg.setMarshaller(marsh);
+ cfg.setBinaryConfiguration(bCfg);
+
+ cfg.setMarshaller(new BinaryMarshaller());
CacheConfiguration ccfg = new CacheConfiguration();
@@ -148,8 +151,6 @@ public class GridPortableMetaDataSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testNoConfiguration() throws Exception {
- fail("https://issues.apache.org/jira/browse/IGNITE-1377");
-
portables().toBinary(new TestObject3());
assertNotNull(portables().metadata(TestObject3.class));
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableWildcardsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableWildcardsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableWildcardsSelfTest.java
index 52af867..a00ad75 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableWildcardsSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableWildcardsSelfTest.java
@@ -17,12 +17,17 @@
package org.apache.ignite.internal.portable;
+import java.util.Collection;
+import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.binary.BinaryIdMapper;
+import org.apache.ignite.binary.BinarySerializer;
import org.apache.ignite.binary.BinaryTypeConfiguration;
+import org.apache.ignite.configuration.BinaryConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.util.IgniteUtils;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.marshaller.MarshallerContextTestImpl;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import java.util.Arrays;
@@ -33,36 +38,15 @@ import java.util.Map;
*/
public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
/**
- * @return Portable context.
- */
- private PortableContext portableContext() {
- return new PortableContext(BinaryNoopMetadataHandler.instance(), new IgniteConfiguration());
- }
-
- /**
- * @return Portable marshaller.
- */
- private PortableMarshaller portableMarshaller() {
- PortableMarshaller marsh = new PortableMarshaller();
- marsh.setContext(new MarshallerContextTestImpl(null));
-
- return marsh;
- }
-
- /**
* @throws Exception If failed.
*/
public void testClassNames() throws Exception {
- PortableContext ctx = portableContext();
-
- PortableMarshaller marsh = portableMarshaller();
-
- marsh.setClassNames(Arrays.asList(
- "org.apache.ignite.internal.portable.test.*",
- "unknown.*"
+ BinaryMarshaller marsh = portableMarshaller(Arrays.asList(
+ new BinaryTypeConfiguration("org.apache.ignite.internal.portable.test.*"),
+ new BinaryTypeConfiguration("unknown.*")
));
- ctx.configure(marsh);
+ PortableContext ctx = portableContext(marsh);
Map<Integer, Class> typeIds = U.field(ctx, "userTypes");
@@ -77,11 +61,7 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testClassNamesWithMapper() throws Exception {
- PortableContext ctx = portableContext();
-
- PortableMarshaller marsh = portableMarshaller();
-
- marsh.setIdMapper(new BinaryIdMapper() {
+ BinaryMarshaller marsh = portableMarshaller(new BinaryIdMapper() {
@SuppressWarnings("IfMayBeConditional")
@Override public int typeId(String clsName) {
if (clsName.endsWith("1"))
@@ -97,14 +77,12 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
@Override public int fieldId(int typeId, String fieldName) {
return 0;
}
- });
-
- marsh.setClassNames(Arrays.asList(
- "org.apache.ignite.internal.portable.test.*",
- "unknown.*"
+ }, Arrays.asList(
+ new BinaryTypeConfiguration("org.apache.ignite.internal.portable.test.*"),
+ new BinaryTypeConfiguration("unknown.*")
));
- ctx.configure(marsh);
+ PortableContext ctx = portableContext(marsh);
Map<String, BinaryIdMapper> typeMappers = U.field(ctx, "typeMappers");
@@ -119,16 +97,12 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testTypeConfigurations() throws Exception {
- PortableContext ctx = portableContext();
-
- PortableMarshaller marsh = portableMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
+ BinaryMarshaller marsh = portableMarshaller(Arrays.asList(
new BinaryTypeConfiguration("org.apache.ignite.internal.portable.test.*"),
new BinaryTypeConfiguration("unknown.*")
));
- ctx.configure(marsh);
+ PortableContext ctx = portableContext(marsh);
Map<Integer, Class> typeIds = U.field(ctx, "userTypes");
@@ -143,11 +117,7 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testTypeConfigurationsWithGlobalMapper() throws Exception {
- PortableContext ctx = portableContext();
-
- PortableMarshaller marsh = portableMarshaller();
-
- marsh.setIdMapper(new BinaryIdMapper() {
+ BinaryMarshaller marsh = portableMarshaller(new BinaryIdMapper() {
@SuppressWarnings("IfMayBeConditional")
@Override public int typeId(String clsName) {
if (clsName.endsWith("1"))
@@ -163,14 +133,12 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
@Override public int fieldId(int typeId, String fieldName) {
return 0;
}
- });
-
- marsh.setTypeConfigurations(Arrays.asList(
+ }, Arrays.asList(
new BinaryTypeConfiguration("org.apache.ignite.internal.portable.test.*"),
new BinaryTypeConfiguration("unknown.*")
));
- ctx.configure(marsh);
+ PortableContext ctx = portableContext(marsh);
Map<String, BinaryIdMapper> typeMappers = U.field(ctx, "typeMappers");
@@ -185,11 +153,7 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testTypeConfigurationsWithNonGlobalMapper() throws Exception {
- PortableContext ctx = portableContext();
-
- PortableMarshaller marsh = portableMarshaller();
-
- marsh.setIdMapper(new BinaryIdMapper() {
+ BinaryMarshaller marsh = portableMarshaller(new BinaryIdMapper() {
@SuppressWarnings("IfMayBeConditional")
@Override public int typeId(String clsName) {
if (clsName.endsWith("1"))
@@ -205,14 +169,12 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
@Override public int fieldId(int typeId, String fieldName) {
return 0;
}
- });
-
- marsh.setTypeConfigurations(Arrays.asList(
+ }, Arrays.asList(
new BinaryTypeConfiguration("org.apache.ignite.internal.portable.test.*"),
new BinaryTypeConfiguration("unknown.*")
));
- ctx.configure(marsh);
+ PortableContext ctx = portableContext(marsh);
Map<String, BinaryIdMapper> typeMappers = U.field(ctx, "typeMappers");
@@ -227,17 +189,9 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testOverride() throws Exception {
- PortableContext ctx = portableContext();
-
- PortableMarshaller marsh = portableMarshaller();
-
- marsh.setClassNames(Arrays.asList(
- "org.apache.ignite.internal.portable.test.*"
- ));
-
BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration();
- typeCfg.setClassName("org.apache.ignite.internal.portable.test.GridPortableTestClass2");
+ typeCfg.setTypeName("org.apache.ignite.internal.portable.test.GridPortableTestClass2");
typeCfg.setIdMapper(new BinaryIdMapper() {
@Override public int typeId(String clsName) {
return 100;
@@ -248,9 +202,11 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
}
});
- marsh.setTypeConfigurations(Arrays.asList(typeCfg));
+ BinaryMarshaller marsh = portableMarshaller(Arrays.asList(
+ new BinaryTypeConfiguration("org.apache.ignite.internal.portable.test.*"),
+ typeCfg));
- ctx.configure(marsh);
+ PortableContext ctx = portableContext(marsh);
Map<Integer, Class> typeIds = U.field(ctx, "userTypes");
@@ -269,16 +225,12 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testClassNamesJar() throws Exception {
- PortableContext ctx = portableContext();
-
- PortableMarshaller marsh = portableMarshaller();
-
- marsh.setClassNames(Arrays.asList(
- "org.apache.ignite.portable.testjar.*",
- "unknown.*"
+ BinaryMarshaller marsh = portableMarshaller(Arrays.asList(
+ new BinaryTypeConfiguration("org.apache.ignite.portable.testjar.*"),
+ new BinaryTypeConfiguration("unknown.*")
));
- ctx.configure(marsh);
+ PortableContext ctx = portableContext(marsh);
Map<Integer, Class> typeIds = U.field(ctx, "userTypes");
@@ -292,11 +244,7 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testClassNamesWithMapperJar() throws Exception {
- PortableContext ctx = portableContext();
-
- PortableMarshaller marsh = portableMarshaller();
-
- marsh.setIdMapper(new BinaryIdMapper() {
+ BinaryMarshaller marsh = portableMarshaller(new BinaryIdMapper() {
@SuppressWarnings("IfMayBeConditional")
@Override public int typeId(String clsName) {
if (clsName.endsWith("1"))
@@ -310,14 +258,12 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
@Override public int fieldId(int typeId, String fieldName) {
return 0;
}
- });
-
- marsh.setClassNames(Arrays.asList(
- "org.apache.ignite.portable.testjar.*",
- "unknown.*"
+ }, Arrays.asList(
+ new BinaryTypeConfiguration("org.apache.ignite.portable.testjar.*"),
+ new BinaryTypeConfiguration("unknown.*")
));
- ctx.configure(marsh);
+ PortableContext ctx = portableContext(marsh);
Map<String, BinaryIdMapper> typeMappers = U.field(ctx, "typeMappers");
@@ -331,16 +277,12 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testTypeConfigurationsJar() throws Exception {
- PortableContext ctx = portableContext();
-
- PortableMarshaller marsh = portableMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
+ BinaryMarshaller marsh = portableMarshaller(Arrays.asList(
new BinaryTypeConfiguration("org.apache.ignite.portable.testjar.*"),
new BinaryTypeConfiguration("unknown.*")
));
- ctx.configure(marsh);
+ PortableContext ctx = portableContext(marsh);
Map<Integer, Class> typeIds = U.field(ctx, "userTypes");
@@ -354,11 +296,7 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testTypeConfigurationsWithGlobalMapperJar() throws Exception {
- PortableContext ctx = portableContext();
-
- PortableMarshaller marsh = portableMarshaller();
-
- marsh.setIdMapper(new BinaryIdMapper() {
+ BinaryMarshaller marsh = portableMarshaller(new BinaryIdMapper() {
@SuppressWarnings("IfMayBeConditional")
@Override public int typeId(String clsName) {
if (clsName.endsWith("1"))
@@ -372,14 +310,12 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
@Override public int fieldId(int typeId, String fieldName) {
return 0;
}
- });
-
- marsh.setTypeConfigurations(Arrays.asList(
+ }, Arrays.asList(
new BinaryTypeConfiguration("org.apache.ignite.portable.testjar.*"),
new BinaryTypeConfiguration("unknown.*")
));
- ctx.configure(marsh);
+ PortableContext ctx = portableContext(marsh);
Map<String, BinaryIdMapper> typeMappers = U.field(ctx, "typeMappers");
@@ -393,11 +329,7 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testTypeConfigurationsWithNonGlobalMapperJar() throws Exception {
- PortableContext ctx = portableContext();
-
- PortableMarshaller marsh = portableMarshaller();
-
- marsh.setIdMapper(new BinaryIdMapper() {
+ BinaryMarshaller marsh = portableMarshaller(new BinaryIdMapper() {
@SuppressWarnings("IfMayBeConditional")
@Override public int typeId(String clsName) {
if (clsName.endsWith("1"))
@@ -411,14 +343,12 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
@Override public int fieldId(int typeId, String fieldName) {
return 0;
}
- });
-
- marsh.setTypeConfigurations(Arrays.asList(
+ }, Arrays.asList(
new BinaryTypeConfiguration("org.apache.ignite.portable.testjar.*"),
new BinaryTypeConfiguration("unknown.*")
));
- ctx.configure(marsh);
+ PortableContext ctx = portableContext(marsh);
Map<String, BinaryIdMapper> typeMappers = U.field(ctx, "typeMappers");
@@ -432,14 +362,6 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testOverrideJar() throws Exception {
- PortableContext ctx = portableContext();
-
- PortableMarshaller marsh = portableMarshaller();
-
- marsh.setClassNames(Arrays.asList(
- "org.apache.ignite.portable.testjar.*"
- ));
-
BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration(
"org.apache.ignite.portable.testjar.GridPortableTestClass2");
@@ -453,9 +375,11 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
}
});
- marsh.setTypeConfigurations(Arrays.asList(typeCfg));
+ BinaryMarshaller marsh = portableMarshaller(Arrays.asList(
+ new BinaryTypeConfiguration("org.apache.ignite.portable.testjar.*"),
+ typeCfg));
- ctx.configure(marsh);
+ PortableContext ctx = portableContext(marsh);
Map<Integer, Class> typeIds = U.field(ctx, "userTypes");
@@ -469,4 +393,73 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
assertEquals(100, typeMappers.get("GridPortableTestClass2").typeId("GridPortableTestClass2"));
}
+
+ /**
+ * @param marsh Marshaller.
+ * @return Portable context.
+ */
+ protected PortableContext portableContext(BinaryMarshaller marsh) {
+ GridPortableMarshaller impl = U.field(marsh, "impl");
+
+ return impl.context();
+ }
+
+ /**
+ *
+ */
+ protected BinaryMarshaller portableMarshaller()
+ throws IgniteCheckedException {
+ return portableMarshaller(null, null, null);
+ }
+
+ /**
+ *
+ */
+ protected BinaryMarshaller portableMarshaller(Collection<BinaryTypeConfiguration> cfgs)
+ throws IgniteCheckedException {
+ return portableMarshaller(null, null, cfgs);
+ }
+
+ /**
+ *
+ */
+ protected BinaryMarshaller portableMarshaller(BinaryIdMapper mapper, Collection<BinaryTypeConfiguration> cfgs)
+ throws IgniteCheckedException {
+ return portableMarshaller(mapper, null, cfgs);
+ }
+
+ /**
+ *
+ */
+ protected BinaryMarshaller portableMarshaller(BinarySerializer serializer, Collection<BinaryTypeConfiguration> cfgs)
+ throws IgniteCheckedException {
+ return portableMarshaller(null, serializer, cfgs);
+ }
+
+ protected BinaryMarshaller portableMarshaller(
+ BinaryIdMapper mapper,
+ BinarySerializer serializer,
+ Collection<BinaryTypeConfiguration> cfgs
+ ) throws IgniteCheckedException {
+ IgniteConfiguration iCfg = new IgniteConfiguration();
+
+ BinaryConfiguration bCfg = new BinaryConfiguration();
+
+ bCfg.setIdMapper(mapper);
+ bCfg.setSerializer(serializer);
+
+ bCfg.setTypeConfigurations(cfgs);
+
+ iCfg.setBinaryConfiguration(bCfg);
+
+ PortableContext ctx = new PortableContext(BinaryNoopMetadataHandler.instance(), iCfg);
+
+ BinaryMarshaller marsh = new BinaryMarshaller();
+
+ marsh.setContext(new MarshallerContextTestImpl(null));
+
+ IgniteUtils.invoke(BinaryMarshaller.class, marsh, "setPortableContext", ctx, iCfg);
+
+ return marsh;
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryFieldsHeapNonCompactSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryFieldsHeapNonCompactSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryFieldsHeapNonCompactSelfTest.java
index 9e7619f..6c11938 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryFieldsHeapNonCompactSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryFieldsHeapNonCompactSelfTest.java
@@ -17,11 +17,7 @@
package org.apache.ignite.internal.portable.noncompact;
-import org.apache.ignite.internal.portable.BinaryFieldsAbstractSelfTest;
import org.apache.ignite.internal.portable.BinaryFieldsHeapSelfTest;
-import org.apache.ignite.internal.portable.BinaryObjectEx;
-import org.apache.ignite.internal.portable.BinaryObjectImpl;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
/**
* Field tests for heap-based portables with non-compact footer.
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCacheAbstractExecutionContextTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCacheAbstractExecutionContextTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCacheAbstractExecutionContextTest.java
index 80c339c..c855c9d 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCacheAbstractExecutionContextTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCacheAbstractExecutionContextTest.java
@@ -24,7 +24,7 @@ import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.processors.cache.IgniteCacheAbstractTest;
import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
import org.apache.ignite.testframework.GridTestExternalClassLoader;
import org.apache.ignite.testframework.config.GridTestProperties;
@@ -65,7 +65,7 @@ public abstract class IgniteCacheAbstractExecutionContextTest extends IgniteCach
* @throws Exception If failed.
*/
public void testUsersClassLoader() throws Exception {
- if (F.eq(GridTestProperties.getProperty(GridTestProperties.MARSH_CLASS_NAME), PortableMarshaller.class.getName()))
+ if (F.eq(GridTestProperties.getProperty(GridTestProperties.MARSH_CLASS_NAME), BinaryMarshaller.class.getName()))
fail("https://issues.apache.org/jira/browse/IGNITE-1272");
UsersClassLoader testClassLdr = (UsersClassLoader)grid(0).configuration().getClassLoader();