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 17:28:46 UTC
[26/50] [abbrv] ignite git commit: Merged IGNITE-950-new into
IGNITE-1282
http://git-wip-us.apache.org/repos/asf/ignite/blob/b783d2b7/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 349f152..22125af 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
@@ -19,12 +19,13 @@ package org.apache.ignite.internal.portable;
import java.util.Arrays;
import java.util.Map;
+import org.apache.ignite.configuration.IgniteConfiguration;
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.portable.PortableIdMapper;
-import org.apache.ignite.portable.PortableMetadata;
-import org.apache.ignite.portable.PortableTypeConfiguration;
+import org.apache.ignite.binary.BinaryTypeIdMapper;
+import org.apache.ignite.binary.BinaryType;
+import org.apache.ignite.binary.BinaryTypeConfiguration;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
/**
@@ -33,11 +34,11 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
/** */
private static final PortableMetaDataHandler META_HND = new PortableMetaDataHandler() {
- @Override public void addMeta(int typeId, PortableMetadata meta) {
+ @Override public void addMeta(int typeId, BinaryType meta) {
// No-op.
}
- @Override public PortableMetadata metadata(int typeId) {
+ @Override public BinaryType metadata(int typeId) {
return null;
}
};
@@ -46,7 +47,7 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
* @return Portable context.
*/
private PortableContext portableContext() {
- return new PortableContext(META_HND, null);
+ return new PortableContext(META_HND, new IgniteConfiguration());
}
/**
@@ -91,7 +92,7 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
PortableMarshaller marsh = portableMarshaller();
- marsh.setIdMapper(new PortableIdMapper() {
+ marsh.setIdMapper(new BinaryTypeIdMapper() {
@SuppressWarnings("IfMayBeConditional")
@Override public int typeId(String clsName) {
if (clsName.endsWith("1"))
@@ -116,7 +117,7 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
ctx.configure(marsh);
- Map<String, PortableIdMapper> typeMappers = U.field(ctx, "typeMappers");
+ Map<String, BinaryTypeIdMapper> typeMappers = U.field(ctx, "typeMappers");
assertEquals(3, typeMappers.size());
@@ -134,8 +135,8 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
PortableMarshaller marsh = portableMarshaller();
marsh.setTypeConfigurations(Arrays.asList(
- new PortableTypeConfiguration("org.apache.ignite.internal.portable.test.*"),
- new PortableTypeConfiguration("unknown.*")
+ new BinaryTypeConfiguration("org.apache.ignite.internal.portable.test.*"),
+ new BinaryTypeConfiguration("unknown.*")
));
ctx.configure(marsh);
@@ -157,7 +158,7 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
PortableMarshaller marsh = portableMarshaller();
- marsh.setIdMapper(new PortableIdMapper() {
+ marsh.setIdMapper(new BinaryTypeIdMapper() {
@SuppressWarnings("IfMayBeConditional")
@Override public int typeId(String clsName) {
if (clsName.endsWith("1"))
@@ -176,13 +177,13 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
});
marsh.setTypeConfigurations(Arrays.asList(
- new PortableTypeConfiguration("org.apache.ignite.internal.portable.test.*"),
- new PortableTypeConfiguration("unknown.*")
+ new BinaryTypeConfiguration("org.apache.ignite.internal.portable.test.*"),
+ new BinaryTypeConfiguration("unknown.*")
));
ctx.configure(marsh);
- Map<String, PortableIdMapper> typeMappers = U.field(ctx, "typeMappers");
+ Map<String, BinaryTypeIdMapper> typeMappers = U.field(ctx, "typeMappers");
assertEquals(3, typeMappers.size());
@@ -199,7 +200,7 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
PortableMarshaller marsh = portableMarshaller();
- marsh.setIdMapper(new PortableIdMapper() {
+ marsh.setIdMapper(new BinaryTypeIdMapper() {
@SuppressWarnings("IfMayBeConditional")
@Override public int typeId(String clsName) {
if (clsName.endsWith("1"))
@@ -218,13 +219,13 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
});
marsh.setTypeConfigurations(Arrays.asList(
- new PortableTypeConfiguration("org.apache.ignite.internal.portable.test.*"),
- new PortableTypeConfiguration("unknown.*")
+ new BinaryTypeConfiguration("org.apache.ignite.internal.portable.test.*"),
+ new BinaryTypeConfiguration("unknown.*")
));
ctx.configure(marsh);
- Map<String, PortableIdMapper> typeMappers = U.field(ctx, "typeMappers");
+ Map<String, BinaryTypeIdMapper> typeMappers = U.field(ctx, "typeMappers");
assertEquals(3, typeMappers.size());
@@ -245,10 +246,10 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
"org.apache.ignite.internal.portable.test.*"
));
- PortableTypeConfiguration typeCfg = new PortableTypeConfiguration();
+ BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration();
typeCfg.setClassName("org.apache.ignite.internal.portable.test.GridPortableTestClass2");
- typeCfg.setIdMapper(new PortableIdMapper() {
+ typeCfg.setIdMapper(new BinaryTypeIdMapper() {
@Override public int typeId(String clsName) {
return 100;
}
@@ -270,7 +271,7 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
assertTrue(typeIds.containsKey("innerclass".hashCode()));
assertFalse(typeIds.containsKey("gridportabletestclass2".hashCode()));
- Map<String, PortableIdMapper> typeMappers = U.field(ctx, "typeMappers");
+ Map<String, BinaryTypeIdMapper> typeMappers = U.field(ctx, "typeMappers");
assertEquals(100, typeMappers.get("GridPortableTestClass2").typeId("GridPortableTestClass2"));
}
@@ -306,7 +307,7 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
PortableMarshaller marsh = portableMarshaller();
- marsh.setIdMapper(new PortableIdMapper() {
+ marsh.setIdMapper(new BinaryTypeIdMapper() {
@SuppressWarnings("IfMayBeConditional")
@Override public int typeId(String clsName) {
if (clsName.endsWith("1"))
@@ -329,7 +330,7 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
ctx.configure(marsh);
- Map<String, PortableIdMapper> typeMappers = U.field(ctx, "typeMappers");
+ Map<String, BinaryTypeIdMapper> typeMappers = U.field(ctx, "typeMappers");
assertEquals(3, typeMappers.size());
@@ -346,8 +347,8 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
PortableMarshaller marsh = portableMarshaller();
marsh.setTypeConfigurations(Arrays.asList(
- new PortableTypeConfiguration("org.apache.ignite.portable.testjar.*"),
- new PortableTypeConfiguration("unknown.*")
+ new BinaryTypeConfiguration("org.apache.ignite.portable.testjar.*"),
+ new BinaryTypeConfiguration("unknown.*")
));
ctx.configure(marsh);
@@ -368,7 +369,7 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
PortableMarshaller marsh = portableMarshaller();
- marsh.setIdMapper(new PortableIdMapper() {
+ marsh.setIdMapper(new BinaryTypeIdMapper() {
@SuppressWarnings("IfMayBeConditional")
@Override public int typeId(String clsName) {
if (clsName.endsWith("1"))
@@ -385,13 +386,13 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
});
marsh.setTypeConfigurations(Arrays.asList(
- new PortableTypeConfiguration("org.apache.ignite.portable.testjar.*"),
- new PortableTypeConfiguration("unknown.*")
+ new BinaryTypeConfiguration("org.apache.ignite.portable.testjar.*"),
+ new BinaryTypeConfiguration("unknown.*")
));
ctx.configure(marsh);
- Map<String, PortableIdMapper> typeMappers = U.field(ctx, "typeMappers");
+ Map<String, BinaryTypeIdMapper> typeMappers = U.field(ctx, "typeMappers");
assertEquals(3, typeMappers.size());
@@ -407,7 +408,7 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
PortableMarshaller marsh = portableMarshaller();
- marsh.setIdMapper(new PortableIdMapper() {
+ marsh.setIdMapper(new BinaryTypeIdMapper() {
@SuppressWarnings("IfMayBeConditional")
@Override public int typeId(String clsName) {
if (clsName.endsWith("1"))
@@ -424,13 +425,13 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
});
marsh.setTypeConfigurations(Arrays.asList(
- new PortableTypeConfiguration("org.apache.ignite.portable.testjar.*"),
- new PortableTypeConfiguration("unknown.*")
+ new BinaryTypeConfiguration("org.apache.ignite.portable.testjar.*"),
+ new BinaryTypeConfiguration("unknown.*")
));
ctx.configure(marsh);
- Map<String, PortableIdMapper> typeMappers = U.field(ctx, "typeMappers");
+ Map<String, BinaryTypeIdMapper> typeMappers = U.field(ctx, "typeMappers");
assertEquals(3, typeMappers.size());
@@ -450,10 +451,10 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
"org.apache.ignite.portable.testjar.*"
));
- PortableTypeConfiguration typeCfg = new PortableTypeConfiguration(
+ BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration(
"org.apache.ignite.portable.testjar.GridPortableTestClass2");
- typeCfg.setIdMapper(new PortableIdMapper() {
+ typeCfg.setIdMapper(new BinaryTypeIdMapper() {
@Override public int typeId(String clsName) {
return 100;
}
@@ -473,7 +474,7 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
assertTrue(typeIds.containsKey("gridportabletestclass1".hashCode()));
- Map<String, PortableIdMapper> typeMappers = U.field(ctx, "typeMappers");
+ Map<String, BinaryTypeIdMapper> typeMappers = U.field(ctx, "typeMappers");
assertEquals(3, typeMappers.size());
http://git-wip-us.apache.org/repos/asf/ignite/blob/b783d2b7/modules/core/src/test/java/org/apache/ignite/internal/portable/PortableCompactOffsetsAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/PortableCompactOffsetsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/PortableCompactOffsetsAbstractSelfTest.java
index 28058de..db3c821 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/PortableCompactOffsetsAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/PortableCompactOffsetsAbstractSelfTest.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.BinaryType;
+import org.apache.ignite.binary.BinaryTypeConfiguration;
+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.portable.PortableField;
-import org.apache.ignite.portable.PortableMetadata;
-import org.apache.ignite.portable.PortableTypeConfiguration;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-import java.util.Arrays;
-
/**
* Contains tests for compact offsets.
*/
@@ -39,11 +39,11 @@ public abstract class PortableCompactOffsetsAbstractSelfTest extends GridCommonA
/** Dummy metadata handler. */
protected static final PortableMetaDataHandler META_HND = new PortableMetaDataHandler() {
- @Override public void addMeta(int typeId, PortableMetadata meta) {
+ @Override public void addMeta(int typeId, BinaryType meta) {
// No-op.
}
- @Override public PortableMetadata metadata(int typeId) {
+ @Override public BinaryType metadata(int typeId) {
return null;
}
};
@@ -58,11 +58,11 @@ public abstract class PortableCompactOffsetsAbstractSelfTest extends GridCommonA
@Override protected void beforeTest() throws Exception {
super.beforeTest();
- ctx = new PortableContext(META_HND, null);
+ ctx = new PortableContext(META_HND, new IgniteConfiguration());
marsh = new PortableMarshaller();
- marsh.setTypeConfigurations(Arrays.asList(new PortableTypeConfiguration(TestObject.class.getName())));
+ marsh.setTypeConfigurations(Arrays.asList(new BinaryTypeConfiguration(TestObject.class.getName())));
marsh.setContext(new MarshallerContextTestImpl(null));
IgniteUtils.invoke(PortableMarshaller.class, marsh, "setPortableContext", ctx);
@@ -123,7 +123,7 @@ public abstract class PortableCompactOffsetsAbstractSelfTest extends GridCommonA
private void check(int len) throws Exception {
TestObject obj = new TestObject(len);
- PortableObjectEx portObj = toPortable(marsh, obj);
+ BinaryObjectEx portObj = toPortable(marsh, obj);
// 1. Test portable object content.
assert portObj.hasField("field1");
@@ -139,8 +139,8 @@ public abstract class PortableCompactOffsetsAbstractSelfTest extends GridCommonA
assert obj.field2 == field2;
// 2. Test fields API.
- PortableField field1Desc = portObj.fieldDescriptor("field1");
- PortableField field2Desc = portObj.fieldDescriptor("field2");
+ BinaryField field1Desc = portObj.fieldDescriptor("field1");
+ BinaryField field2Desc = portObj.fieldDescriptor("field2");
assert field1Desc.exists(portObj);
assert field2Desc.exists(portObj);
@@ -165,7 +165,7 @@ public abstract class PortableCompactOffsetsAbstractSelfTest extends GridCommonA
* @return Portable object.
* @throws Exception If failed.
*/
- protected abstract PortableObjectEx toPortable(PortableMarshaller marsh, Object obj) throws Exception;
+ protected abstract BinaryObjectEx toPortable(PortableMarshaller marsh, Object obj) throws Exception;
/**
* Test object.
http://git-wip-us.apache.org/repos/asf/ignite/blob/b783d2b7/modules/core/src/test/java/org/apache/ignite/internal/portable/PortableCompactOffsetsHeapSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/PortableCompactOffsetsHeapSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/PortableCompactOffsetsHeapSelfTest.java
index 826f972..ebdef38 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/PortableCompactOffsetsHeapSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/PortableCompactOffsetsHeapSelfTest.java
@@ -24,9 +24,9 @@ import org.apache.ignite.marshaller.portable.PortableMarshaller;
*/
public class PortableCompactOffsetsHeapSelfTest extends PortableCompactOffsetsAbstractSelfTest {
/** {@inheritDoc} */
- @Override protected PortableObjectEx toPortable(PortableMarshaller marsh, Object obj) throws Exception {
+ @Override protected BinaryObjectEx toPortable(PortableMarshaller marsh, Object obj) throws Exception {
byte[] bytes = marsh.marshal(obj);
- return new PortableObjectImpl(ctx, bytes, 0);
+ return new BinaryObjectImpl(ctx, bytes, 0);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/b783d2b7/modules/core/src/test/java/org/apache/ignite/internal/portable/PortableCompactOffsetsOffheapSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/PortableCompactOffsetsOffheapSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/PortableCompactOffsetsOffheapSelfTest.java
index 9ad1c67..e3b6bda 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/PortableCompactOffsetsOffheapSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/PortableCompactOffsetsOffheapSelfTest.java
@@ -47,7 +47,7 @@ public class PortableCompactOffsetsOffheapSelfTest extends PortableCompactOffset
}
/** {@inheritDoc} */
- @Override protected PortableObjectEx toPortable(PortableMarshaller marsh, Object obj) throws Exception {
+ @Override protected BinaryObjectEx toPortable(PortableMarshaller marsh, Object obj) throws Exception {
byte[] arr = marsh.marshal(obj);
long ptr = UNSAFE.allocateMemory(arr.length);
@@ -56,6 +56,6 @@ public class PortableCompactOffsetsOffheapSelfTest extends PortableCompactOffset
UNSAFE.copyMemory(arr, BYTE_ARR_OFF, null, ptr, arr.length);
- return new PortableObjectOffheapImpl(ctx, ptr, 0, arr.length);
+ return new BinaryObjectOffheapImpl(ctx, ptr, 0, arr.length);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/b783d2b7/modules/core/src/test/java/org/apache/ignite/internal/portable/PortableFieldsAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/PortableFieldsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/PortableFieldsAbstractSelfTest.java
deleted file mode 100644
index 0d712dc..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/PortableFieldsAbstractSelfTest.java
+++ /dev/null
@@ -1,729 +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.internal.portable;
-
-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.portable.PortableField;
-import org.apache.ignite.portable.PortableMetadata;
-import org.apache.ignite.portable.PortableObject;
-import org.apache.ignite.portable.PortableTypeConfiguration;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-
-import java.math.BigDecimal;
-import java.sql.Timestamp;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.UUID;
-
-/**
- * Contains tests for portable object fields.
- */
-public abstract class PortableFieldsAbstractSelfTest extends GridCommonAbstractTest {
- /** Dummy metadata handler. */
- protected static final PortableMetaDataHandler META_HND = new PortableMetaDataHandler() {
- @Override public void addMeta(int typeId, PortableMetadata meta) {
- // No-op.
- }
-
- @Override public PortableMetadata metadata(int typeId) {
- return null;
- }
- };
-
- /** Marshaller. */
- protected PortableMarshaller dfltMarsh;
-
- /**
- * Create marshaller.
- *
- * @param stringAsBytes Whether to marshal strings as bytes (UTF8).
- * @return Portable marshaller.
- * @throws Exception If failed.
- */
- protected static PortableMarshaller createMarshaller(boolean stringAsBytes) throws Exception {
- PortableContext ctx = new PortableContext(META_HND, null);
-
- PortableMarshaller marsh = new PortableMarshaller();
-
- marsh.setConvertStringToBytes(stringAsBytes);
-
- marsh.setTypeConfigurations(Arrays.asList(
- new PortableTypeConfiguration(TestObject.class.getName()),
- new PortableTypeConfiguration(TestOuterObject.class.getName()),
- new PortableTypeConfiguration(TestInnerObject.class.getName())
- ));
-
- marsh.setContext(new MarshallerContextTestImpl(null));
-
- IgniteUtils.invoke(PortableMarshaller.class, marsh, "setPortableContext", ctx);
-
- return marsh;
- }
-
- /**
- * Get portable context for the current marshaller.
- *
- * @param marsh Marshaller.
- * @return Portable context.
- */
- protected static PortableContext portableContext(PortableMarshaller marsh) {
- GridPortableMarshaller impl = U.field(marsh, "impl");
-
- return impl.context();
- }
-
- /** {@inheritDoc} */
- @Override protected void beforeTest() throws Exception {
- super.beforeTest();
-
- dfltMarsh = createMarshaller(true);
- }
-
- /**
- * Test byte field.
- *
- * @throws Exception If failed.
- */
- public void testByte() throws Exception {
- check("fByte");
- }
-
- /**
- * Test byte array field.
- *
- * @throws Exception If failed.
- */
- public void testByteArray() throws Exception {
- check("fByteArr");
- }
-
- /**
- * Test boolean field.
- *
- * @throws Exception If failed.
- */
- public void testBoolean() throws Exception {
- check("fBool");
- }
-
- /**
- * Test boolean array field.
- *
- * @throws Exception If failed.
- */
- public void testBooleanArray() throws Exception {
- check("fBoolArr");
- }
-
- /**
- * Test short field.
- *
- * @throws Exception If failed.
- */
- public void testShort() throws Exception {
- check("fShort");
- }
-
- /**
- * Test short array field.
- *
- * @throws Exception If failed.
- */
- public void testShortArray() throws Exception {
- check("fShortArr");
- }
-
- /**
- * Test char field.
- *
- * @throws Exception If failed.
- */
- public void testChar() throws Exception {
- check("fChar");
- }
-
- /**
- * Test char array field.
- *
- * @throws Exception If failed.
- */
- public void testCharArray() throws Exception {
- check("fCharArr");
- }
-
- /**
- * Test int field.
- *
- * @throws Exception If failed.
- */
- public void testInt() throws Exception {
- check("fInt");
- }
-
- /**
- * Test int array field.
- *
- * @throws Exception If failed.
- */
- public void testIntArray() throws Exception {
- check("fIntArr");
- }
-
- /**
- * Test long field.
- *
- * @throws Exception If failed.
- */
- public void testLong() throws Exception {
- check("fLong");
- }
-
- /**
- * Test long array field.
- *
- * @throws Exception If failed.
- */
- public void testLongArray() throws Exception {
- check("fLongArr");
- }
-
- /**
- * Test float field.
- *
- * @throws Exception If failed.
- */
- public void testFloat() throws Exception {
- check("fFloat");
- }
-
- /**
- * Test float array field.
- *
- * @throws Exception If failed.
- */
- public void testFloatArray() throws Exception {
- check("fFloatArr");
- }
-
- /**
- * Test double field.
- *
- * @throws Exception If failed.
- */
- public void testDouble() throws Exception {
- check("fDouble");
- }
-
- /**
- * Test double array field.
- *
- * @throws Exception If failed.
- */
- public void testDoubleArray() throws Exception {
- check("fDoubleArr");
- }
-
- /**
- * Test string field.
- *
- * @throws Exception If failed.
- */
- public void testString() throws Exception {
- check("fString");
- }
-
- /**
- * Test string field.
- *
- * @throws Exception If failed.
- */
- public void testStringAsChars() throws Exception {
- PortableMarshaller marsh = createMarshaller(false);
-
- checkNormal(marsh, "fString", true);
- checkNested(marsh, "fString", true);
- }
-
- /**
- * Test string array field.
- *
- * @throws Exception If failed.
- */
- public void testStringArray() throws Exception {
- check("fStringArr");
- }
-
- /**
- * Test date field.
- *
- * @throws Exception If failed.
- */
- public void testDate() throws Exception {
- check("fDate");
- }
-
- /**
- * Test date array field.
- *
- * @throws Exception If failed.
- */
- public void testDateArray() throws Exception {
- check("fDateArr");
- }
-
- /**
- * Test timestamp field.
- *
- * @throws Exception If failed.
- */
- public void testTimestamp() throws Exception {
- check("fTimestamp");
- }
-
- /**
- * Test timestamp array field.
- *
- * @throws Exception If failed.
- */
- public void testTimestampArray() throws Exception {
- check("fTimestampArr");
- }
-
- /**
- * Test UUID field.
- *
- * @throws Exception If failed.
- */
- public void testUuid() throws Exception {
- check("fUuid");
- }
-
- /**
- * Test UUID array field.
- *
- * @throws Exception If failed.
- */
- public void testUuidArray() throws Exception {
- check("fUuidArr");
- }
-
- /**
- * Test decimal field.
- *
- * @throws Exception If failed.
- */
- public void testDecimal() throws Exception {
- check("fDecimal");
- }
-
- /**
- * Test decimal array field.
- *
- * @throws Exception If failed.
- */
- public void testDecimalArray() throws Exception {
- check("fDecimalArr");
- }
-
- /**
- * Test object field.
- *
- * @throws Exception If failed.
- */
- public void testObject() throws Exception {
- check("fObj");
- }
-
- /**
- * Test object array field.
- *
- * @throws Exception If failed.
- */
- public void testObjectArray() throws Exception {
- check("fObjArr");
- }
-
- /**
- * Test null field.
- *
- * @throws Exception If failed.
- */
- public void testNull() throws Exception {
- check("fNull");
- }
-
- /**
- * Test missing field.
- *
- * @throws Exception If failed.
- */
- public void testMissing() throws Exception {
- String fieldName = "fMissing";
-
- checkNormal(dfltMarsh, fieldName, false);
- checkNested(dfltMarsh, fieldName, false);
- }
-
- /**
- * Check field resolution in both normal and nested modes.
- *
- * @param fieldName Field name.
- * @throws Exception If failed.
- */
- public void check(String fieldName) throws Exception {
- checkNormal(dfltMarsh, fieldName, true);
- checkNested(dfltMarsh, fieldName, true);
- }
-
- /**
- * Check field.
- *
- * @param marsh Marshaller.
- * @param fieldName Field name.
- * @param exists Whether field should exist.
- * @throws Exception If failed.
- */
- private void checkNormal(PortableMarshaller marsh, String fieldName, boolean exists) throws Exception {
- TestContext testCtx = context(marsh, fieldName);
-
- check0(fieldName, testCtx, exists);
- }
-
- /**
- * Check nested field.
- *
- * @param marsh Marshaller.
- * @param fieldName Field name.
- * @param exists Whether field should exist.
- * @throws Exception If failed.
- */
- private void checkNested(PortableMarshaller marsh, String fieldName, boolean exists) throws Exception {
- TestContext testCtx = nestedContext(marsh, fieldName);
-
- check0(fieldName, testCtx, exists);
- }
-
- /**
- * Internal check routine.
- *
- * @param fieldName Field name.
- * @param ctx Context.
- * @param exists Whether field should exist.
- * @throws Exception If failed.
- */
- private void check0(String fieldName, TestContext ctx, boolean exists) throws Exception {
- Object val = ctx.field.value(ctx.portObj);
-
- if (exists) {
- assertTrue(ctx.field.exists(ctx.portObj));
-
- Object expVal = U.field(ctx.obj, fieldName);
-
- if (val instanceof PortableObject)
- val = ((PortableObject) val).deserialize();
-
- if (val != null && val.getClass().isArray()) {
- assertNotNull(expVal);
-
- if (val instanceof byte[])
- assertTrue(Arrays.equals((byte[]) expVal, (byte[]) val));
- else if (val instanceof boolean[])
- assertTrue(Arrays.equals((boolean[]) expVal, (boolean[]) val));
- else if (val instanceof short[])
- assertTrue(Arrays.equals((short[]) expVal, (short[]) val));
- else if (val instanceof char[])
- assertTrue(Arrays.equals((char[]) expVal, (char[]) val));
- else if (val instanceof int[])
- assertTrue(Arrays.equals((int[]) expVal, (int[]) val));
- else if (val instanceof long[])
- assertTrue(Arrays.equals((long[]) expVal, (long[]) val));
- else if (val instanceof float[])
- assertTrue(Arrays.equals((float[]) expVal, (float[]) val));
- else if (val instanceof double[])
- assertTrue(Arrays.equals((double[]) expVal, (double[]) val));
- else {
- Object[] expVal0 = (Object[])expVal;
- Object[] val0 = (Object[])val;
-
- assertEquals(expVal0.length, val0.length);
-
- for (int i = 0; i < expVal0.length; i++) {
- Object expItem = expVal0[i];
- Object item = val0[i];
-
- if (item instanceof PortableObject)
- item = ((PortableObject)item).deserialize();
-
- assertEquals(expItem, item);
- }
- }
- }
- else
- assertEquals(expVal, val);
- }
- else {
- assertFalse(ctx.field.exists(ctx.portObj));
-
- assert val == null;
- }
- }
-
- /**
- * Get test context.
- *
- * @param marsh Portable marshaller.
- * @param fieldName Field name.
- * @return Test context.
- * @throws Exception If failed.
- */
- private TestContext context(PortableMarshaller marsh, String fieldName) throws Exception {
- TestObject obj = createObject();
-
- PortableObjectEx portObj = toPortable(marsh, obj);
-
- PortableField field = portObj.fieldDescriptor(fieldName);
-
- return new TestContext(obj, portObj, field);
- }
-
- /**
- * Get test context with nested test object.
- *
- * @param marsh Portable marshaller.
- * @param fieldName Field name.
- * @return Test context.
- * @throws Exception If failed.
- */
- private TestContext nestedContext(PortableMarshaller marsh, String fieldName)
- throws Exception {
- TestObject obj = createObject();
- TestOuterObject outObj = new TestOuterObject(obj);
-
- PortableObjectEx portOutObj = toPortable(marsh, outObj);
- PortableObjectEx portObj = portOutObj.field("fInner");
-
- assert portObj != null;
-
- PortableField field = portObj.fieldDescriptor(fieldName);
-
- return new TestContext(obj, portObj, field);
- }
-
- /**
- * Create test object.
- *
- * @return Test object.
- */
- private TestObject createObject() {
- return new TestObject(0);
- }
-
- /**
- * Convert object to portable object.
- *
- * @param marsh Marshaller.
- * @param obj Object.
- * @return Portable object.
- * @throws Exception If failed.
- */
- protected abstract PortableObjectEx toPortable(PortableMarshaller marsh, Object obj) throws Exception;
-
- /**
- * Outer test object.
- */
- @SuppressWarnings("UnusedDeclaration")
- public static class TestOuterObject {
- /** Inner object. */
- public TestObject fInner;
-
- /**
- * Default constructor.
- */
- public TestOuterObject() {
- // No-op.
- }
-
- /**
- * Constructor.
- *
- * @param fInner Inner object.
- */
- public TestOuterObject(TestObject fInner) {
- this.fInner = fInner;
- }
- }
-
- /**
- * Test object class, c
- */
- @SuppressWarnings("UnusedDeclaration")
- public static class TestObject {
- /** Primitive fields. */
- public byte fByte;
- public boolean fBool;
- public short fShort;
- public char fChar;
- public int fInt;
- public long fLong;
- public float fFloat;
- public double fDouble;
-
- public byte[] fByteArr;
- public boolean[] fBoolArr;
- public short[] fShortArr;
- public char[] fCharArr;
- public int[] fIntArr;
- public long[] fLongArr;
- public float[] fFloatArr;
- public double[] fDoubleArr;
-
- /** Special fields. */
- public String fString;
- public Date fDate;
- public Timestamp fTimestamp;
- public UUID fUuid;
- public BigDecimal fDecimal;
-
- public String[] fStringArr;
- public Date[] fDateArr;
- public Timestamp[] fTimestampArr;
- public UUID[] fUuidArr;
- public BigDecimal[] fDecimalArr;
-
- /** Nested object. */
- public TestInnerObject fObj;
-
- public TestInnerObject[] fObjArr;
-
- /** Field which is always set to null. */
- public Object fNull;
-
- /**
- * Default constructor.
- */
- public TestObject() {
- // No-op.
- }
-
- /**
- * Non-default constructor.
- *
- * @param ignore Ignored.
- */
- public TestObject(int ignore) {
- fByte = 1;
- fBool = true;
- fShort = 2;
- fChar = 3;
- fInt = 4;
- fLong = 5;
- fFloat = 6.6f;
- fDouble = 7.7;
-
- fByteArr = new byte[] { 1, 2 };
- fBoolArr = new boolean[] { true, false };
- fShortArr = new short[] { 2, 3 };
- fCharArr = new char[] { 3, 4 };
- fIntArr = new int[] { 4, 5 };
- fLongArr = new long[] { 5, 6 };
- fFloatArr = new float[] { 6.6f, 7.7f };
- fDoubleArr = new double[] { 7.7, 8.8 };
-
- fString = "8";
- fDate = new Date();
- fTimestamp = new Timestamp(new Date().getTime() + 1);
- fUuid = UUID.randomUUID();
- fDecimal = new BigDecimal(9);
-
- fStringArr = new String[] { "8", "9" };
- fDateArr = new Date[] { new Date(), new Date(new Date().getTime() + 1) };
- fTimestampArr =
- new Timestamp[] { new Timestamp(new Date().getTime() + 1), new Timestamp(new Date().getTime() + 2) };
- fUuidArr = new UUID[] { UUID.randomUUID(), UUID.randomUUID() };
- fDecimalArr = new BigDecimal[] { new BigDecimal(9), new BigDecimal(10) };
-
- fObj = new TestInnerObject(10);
- fObjArr = new TestInnerObject[] { new TestInnerObject(10), new TestInnerObject(11) };
- }
- }
-
- /**
- * Inner test object.
- */
- @SuppressWarnings("UnusedDeclaration")
- public static class TestInnerObject {
- /** Value. */
- private int val;
-
- /**
- * Default constructor.
- */
- public TestInnerObject() {
- // No-op.
- }
-
- /**
- * Constructor.
- *
- * @param val Value.
- */
- public TestInnerObject(int val) {
- this.val = val;
- }
-
- /** {@inheritDoc} */
- @Override public int hashCode() {
- return val;
- }
-
- /** {@inheritDoc} */
- @Override public boolean equals(Object other) {
- return other != null && other instanceof TestInnerObject && val == ((TestInnerObject)(other)).val;
- }
- }
-
- /**
- * Test context.
- */
- public static class TestContext {
- /** Object. */
- public final TestObject obj;
-
- /** Portable object. */
- public final PortableObjectEx portObj;
-
- /** Field. */
- public final PortableField field;
-
- /**
- * Constructor.
- *
- * @param obj Object.
- * @param portObj Portable object.
- * @param field Field.
- */
- public TestContext(TestObject obj, PortableObjectEx portObj, PortableField field) {
- this.obj = obj;
- this.portObj = portObj;
- this.field = field;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/b783d2b7/modules/core/src/test/java/org/apache/ignite/internal/portable/PortableFieldsHeapSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/PortableFieldsHeapSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/PortableFieldsHeapSelfTest.java
deleted file mode 100644
index c7feeab..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/PortableFieldsHeapSelfTest.java
+++ /dev/null
@@ -1,32 +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.internal.portable;
-
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
-
-/**
- * Field tests for heap-based portables.
- */
-public class PortableFieldsHeapSelfTest extends PortableFieldsAbstractSelfTest {
- /** {@inheritDoc} */
- @Override protected PortableObjectEx toPortable(PortableMarshaller marsh, Object obj) throws Exception {
- byte[] bytes = marsh.marshal(obj);
-
- return new PortableObjectImpl(portableContext(marsh), bytes, 0);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/b783d2b7/modules/core/src/test/java/org/apache/ignite/internal/portable/PortableFieldsOffheapSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/PortableFieldsOffheapSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/PortableFieldsOffheapSelfTest.java
deleted file mode 100644
index 44bb8a1..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/PortableFieldsOffheapSelfTest.java
+++ /dev/null
@@ -1,61 +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.internal.portable;
-
-import org.apache.ignite.internal.util.GridUnsafe;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
-import org.eclipse.jetty.util.ConcurrentHashSet;
-import sun.misc.Unsafe;
-
-/**
- * Field tests for heap-based portables.
- */
-public class PortableFieldsOffheapSelfTest extends PortableFieldsAbstractSelfTest {
- /** Unsafe instance. */
- private static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
- /** Byte array offset for unsafe mechanics. */
- protected static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class);
-
- /** Allocated unsafe pointer. */
- private final ConcurrentHashSet<Long> ptrs = new ConcurrentHashSet<>();
-
- /** {@inheritDoc} */
- @Override protected void afterTest() throws Exception {
- super.afterTest();
-
- // Cleanup allocated objects.
- for (Long ptr : ptrs)
- UNSAFE.freeMemory(ptr);
-
- ptrs.clear();
- }
-
- /** {@inheritDoc} */
- @Override protected PortableObjectEx toPortable(PortableMarshaller marsh, Object obj) throws Exception {
- byte[] arr = marsh.marshal(obj);
-
- long ptr = UNSAFE.allocateMemory(arr.length);
-
- ptrs.add(ptr);
-
- UNSAFE.copyMemory(arr, BYTE_ARR_OFF, null, ptr, arr.length);
-
- return new PortableObjectOffheapImpl(portableContext(marsh), ptr, 0, arr.length);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/b783d2b7/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/GridBinaryMarshalerAwareTestClass.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/GridBinaryMarshalerAwareTestClass.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/GridBinaryMarshalerAwareTestClass.java
new file mode 100644
index 0000000..aad0e87
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/GridBinaryMarshalerAwareTestClass.java
@@ -0,0 +1,67 @@
+/*
+ * 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.mutabletest;
+
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.Binarylizable;
+import org.apache.ignite.binary.BinaryRawReader;
+import org.apache.ignite.binary.BinaryRawWriter;
+import org.apache.ignite.binary.BinaryReader;
+import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.testframework.GridTestUtils;
+
+/**
+ *
+ */
+public class GridBinaryMarshalerAwareTestClass implements Binarylizable {
+ /** */
+ public String s;
+
+ /** */
+ public String sRaw;
+
+ /** {@inheritDoc} */
+ @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
+ writer.writeString("s", s);
+
+ BinaryRawWriter raw = writer.rawWriter();
+
+ raw.writeString(sRaw);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readBinary(BinaryReader reader) throws BinaryObjectException {
+ s = reader.readString("s");
+
+ BinaryRawReader raw = reader.rawReader();
+
+ sRaw = raw.readString();
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("FloatingPointEquality")
+ @Override public boolean equals(Object other) {
+ return this == other || GridTestUtils.deepEquals(this, other);
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(GridBinaryMarshalerAwareTestClass.class, this);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/b783d2b7/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/GridPortableMarshalerAwareTestClass.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/GridPortableMarshalerAwareTestClass.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/GridPortableMarshalerAwareTestClass.java
deleted file mode 100644
index 3244331..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/GridPortableMarshalerAwareTestClass.java
+++ /dev/null
@@ -1,67 +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.internal.portable.mutabletest;
-
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.portable.PortableException;
-import org.apache.ignite.portable.PortableMarshalAware;
-import org.apache.ignite.portable.PortableRawReader;
-import org.apache.ignite.portable.PortableRawWriter;
-import org.apache.ignite.portable.PortableReader;
-import org.apache.ignite.portable.PortableWriter;
-import org.apache.ignite.testframework.GridTestUtils;
-
-/**
- *
- */
-public class GridPortableMarshalerAwareTestClass implements PortableMarshalAware {
- /** */
- public String s;
-
- /** */
- public String sRaw;
-
- /** {@inheritDoc} */
- @Override public void writePortable(PortableWriter writer) throws PortableException {
- writer.writeString("s", s);
-
- PortableRawWriter raw = writer.rawWriter();
-
- raw.writeString(sRaw);
- }
-
- /** {@inheritDoc} */
- @Override public void readPortable(PortableReader reader) throws PortableException {
- s = reader.readString("s");
-
- PortableRawReader raw = reader.rawReader();
-
- sRaw = raw.readString();
- }
-
- /** {@inheritDoc} */
- @SuppressWarnings("FloatingPointEquality")
- @Override public boolean equals(Object other) {
- return this == other || GridTestUtils.deepEquals(this, other);
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(GridPortableMarshalerAwareTestClass.class, this);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/b783d2b7/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/GridPortableTestClasses.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/GridPortableTestClasses.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/GridPortableTestClasses.java
index a2ae71f..69687ab 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/GridPortableTestClasses.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/GridPortableTestClasses.java
@@ -32,7 +32,7 @@ import java.util.Map;
import java.util.TreeMap;
import java.util.UUID;
import org.apache.ignite.internal.util.lang.GridMapEntry;
-import org.apache.ignite.portable.PortableObject;
+import org.apache.ignite.binary.BinaryObject;
/**
*
@@ -106,7 +106,7 @@ public class GridPortableTestClasses {
*/
public static class TestObjectPlainPortable {
/** */
- public PortableObject plainPortable;
+ public BinaryObject plainPortable;
/**
*
@@ -118,7 +118,7 @@ public class GridPortableTestClasses {
/**
* @param plainPortable Object.
*/
- public TestObjectPlainPortable(PortableObject plainPortable) {
+ public TestObjectPlainPortable(BinaryObject plainPortable) {
this.plainPortable = plainPortable;
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/b783d2b7/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNearReaderUpdateTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNearReaderUpdateTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNearReaderUpdateTest.java
index e267620..50a622f 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNearReaderUpdateTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNearReaderUpdateTest.java
@@ -121,24 +121,46 @@ public class CacheNearReaderUpdateTest extends GridCommonAbstractTest {
/**
* @throws Exception If failed.
*/
- public void testGetUpdateMultithreaded() throws Exception {
- fail("https://issues.apache.org/jira/browse/IGNITE-627");
+ public void testNoBackups() throws Exception {
+ testGetUpdateMultithreaded(cacheConfiguration(PARTITIONED, FULL_SYNC, 0, false, false));
+ }
- List<CacheConfiguration<Integer, Integer>> cfgs = new ArrayList<>();
+ /**
+ * @throws Exception If failed.
+ */
+ public void testOneBackup() throws Exception {
+ testGetUpdateMultithreaded(cacheConfiguration(PARTITIONED, FULL_SYNC, 1, false, false));
+ }
- cfgs.add(cacheConfiguration(PARTITIONED, FULL_SYNC, 0, false, false));
- cfgs.add(cacheConfiguration(PARTITIONED, FULL_SYNC, 1, false, false));
- cfgs.add(cacheConfiguration(PARTITIONED, FULL_SYNC, 1, false, true));
- cfgs.add(cacheConfiguration(PARTITIONED, FULL_SYNC, 1, true, false));
+ /**
+ * @throws Exception If failed.
+ */
+ public void testOneBackupNearEnabled() throws Exception {
+ testGetUpdateMultithreaded(cacheConfiguration(PARTITIONED, FULL_SYNC, 1, false, true));
+ }
- {
- CacheConfiguration<Integer, Integer> ccfg = cacheConfiguration(PARTITIONED, FULL_SYNC, 1, false, false);
+ /**
+ * @throws Exception If failed.
+ */
+ public void testOneBackupStoreEnabled() throws Exception {
+ testGetUpdateMultithreaded(cacheConfiguration(PARTITIONED, FULL_SYNC, 1, true, false));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testOneBackupOffheap() throws Exception {
+ CacheConfiguration<Integer, Integer> ccfg = cacheConfiguration(PARTITIONED, FULL_SYNC, 1, false, false);
- GridTestUtils.setMemoryMode(null, ccfg, GridTestUtils.TestMemoryMode.OFFHEAP_TIERED, 0, 0);
+ GridTestUtils.setMemoryMode(null, ccfg, GridTestUtils.TestMemoryMode.OFFHEAP_TIERED, 0, 0);
- cfgs.add(ccfg);
- }
+ testGetUpdateMultithreaded(ccfg);
+ }
+ /**
+ * @throws Exception If failed.
+ */
+ public void testGetUpdateMultithreaded(CacheConfiguration<Integer, Integer> ccfg) throws Exception {
final List<Ignite> putNodes = new ArrayList<>();
for (int i = 0; i < SRVS + CLIENTS - 1; i++)
@@ -149,18 +171,16 @@ public class CacheNearReaderUpdateTest extends GridCommonAbstractTest {
getNodes.add(ignite(SRVS + CLIENTS - 1));
getNodes.add(ignite(0));
- for (CacheConfiguration<Integer, Integer> ccfg : cfgs) {
- logCacheInfo(ccfg);
+ logCacheInfo(ccfg);
- getUpdateMultithreaded(ccfg, putNodes, getNodes, null, null);
+ getUpdateMultithreaded(ccfg, putNodes, getNodes, null, null);
- if (ccfg.getAtomicityMode() == TRANSACTIONAL) {
- getUpdateMultithreaded(ccfg, putNodes, getNodes, PESSIMISTIC, REPEATABLE_READ);
+ if (ccfg.getAtomicityMode() == TRANSACTIONAL) {
+ getUpdateMultithreaded(ccfg, putNodes, getNodes, PESSIMISTIC, REPEATABLE_READ);
- getUpdateMultithreaded(ccfg, putNodes, getNodes, OPTIMISTIC, REPEATABLE_READ);
+ getUpdateMultithreaded(ccfg, putNodes, getNodes, OPTIMISTIC, REPEATABLE_READ);
- getUpdateMultithreaded(ccfg, putNodes, getNodes, OPTIMISTIC, SERIALIZABLE);
- }
+ getUpdateMultithreaded(ccfg, putNodes, getNodes, OPTIMISTIC, SERIALIZABLE);
}
}
@@ -177,6 +197,8 @@ public class CacheNearReaderUpdateTest extends GridCommonAbstractTest {
final List<Ignite> getNodes,
final TransactionConcurrency concurrency,
final TransactionIsolation isolation) throws Exception {
+ fail("https://issues.apache.org/jira/browse/IGNITE-627");
+
log.info("Execute updates [concurrency=" + concurrency + ", isolation=" + isolation + ']');
final Ignite ignite0 = ignite(0);
http://git-wip-us.apache.org/repos/asf/ignite/blob/b783d2b7/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java
index f8fc3ae..52fbf4c 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java
@@ -38,6 +38,7 @@ import org.apache.ignite.internal.IgniteKernal;
import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
import org.apache.ignite.internal.util.lang.GridAbsPredicateX;
import org.apache.ignite.internal.util.typedef.CI1;
+import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.P1;
import org.apache.ignite.internal.util.typedef.R1;
import org.apache.ignite.internal.util.typedef.X;
@@ -241,7 +242,11 @@ public abstract class GridCacheAbstractSelfTest extends GridCommonAbstractTest {
cfg.setAtomicityMode(atomicityMode());
cfg.setWriteSynchronizationMode(writeSynchronization());
cfg.setNearConfiguration(nearConfiguration());
- cfg.setIndexedTypes(indexedTypes());
+
+ Class<?>[] idxTypes = indexedTypes();
+
+ if (!F.isEmpty(idxTypes))
+ cfg.setIndexedTypes(idxTypes);
if (cacheMode() == PARTITIONED)
cfg.setBackups(1);
@@ -560,4 +565,4 @@ public abstract class GridCacheAbstractSelfTest extends GridCommonAbstractTest {
return cacheStore();
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/b783d2b7/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapTieredEvictionAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapTieredEvictionAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapTieredEvictionAbstractSelfTest.java
index 33c2b53..cd82739 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapTieredEvictionAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapTieredEvictionAbstractSelfTest.java
@@ -169,7 +169,7 @@ public abstract class GridCacheOffHeapTieredEvictionAbstractSelfTest extends Gri
* @throws Exception If failed.
*/
public void testTransform() throws Exception {
- final IgniteCache<Integer, Object> cache = grid(0).cache(null);
+ final IgniteCache<Integer, Object> cache = grid(0).cache(null).withKeepBinary();
GridTestUtils.runMultiThreaded(new Callable<Void>() {
@Override public Void call() throws Exception {
http://git-wip-us.apache.org/repos/asf/ignite/blob/b783d2b7/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
index abb2767..4820f54 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
@@ -437,7 +437,8 @@ public class GridCacheTestEntryEx extends GridMetadataAwareAdapter implements Gr
UUID subjId,
Object transformClo,
String taskName,
- @Nullable IgniteCacheExpiryPolicy expiryPlc) {
+ @Nullable IgniteCacheExpiryPolicy expiryPlc,
+ boolean keepBinary) {
return val;
}
@@ -451,7 +452,8 @@ public class GridCacheTestEntryEx extends GridMetadataAwareAdapter implements Gr
UUID subjId,
Object transformClo,
String taskName,
- @Nullable IgniteCacheExpiryPolicy expiryPlc) {
+ @Nullable IgniteCacheExpiryPolicy expiryPlc,
+ boolean keepBinary) {
assert false;
return null;
@@ -472,6 +474,7 @@ public class GridCacheTestEntryEx extends GridMetadataAwareAdapter implements Gr
long ttl,
boolean evt,
boolean metrics,
+ boolean keepPortable,
AffinityTopologyVersion topVer,
CacheEntryPredicate[] filter,
GridDrType drType,
@@ -493,6 +496,7 @@ public class GridCacheTestEntryEx extends GridMetadataAwareAdapter implements Gr
boolean writeThrough,
boolean readThrough,
boolean retval,
+ boolean keepPortable,
@Nullable ExpiryPolicy expiryPlc,
boolean evt,
boolean metrics,
@@ -515,6 +519,7 @@ public class GridCacheTestEntryEx extends GridMetadataAwareAdapter implements Gr
boolean writeThrough,
boolean readThrough,
boolean retval,
+ boolean keepPortable,
@Nullable IgniteCacheExpiryPolicy expiryPlc,
boolean evt,
boolean metrics,
@@ -545,6 +550,7 @@ public class GridCacheTestEntryEx extends GridMetadataAwareAdapter implements Gr
boolean retval,
boolean evt,
boolean metrics,
+ boolean keepPortable,
AffinityTopologyVersion topVer,
CacheEntryPredicate[] filter,
GridDrType drType,
@@ -578,7 +584,8 @@ public class GridCacheTestEntryEx extends GridMetadataAwareAdapter implements Gr
@Override public boolean tmLock(IgniteInternalTx tx,
long timeout,
@Nullable GridCacheVersion serOrder,
- GridCacheVersion serReadVer) {
+ GridCacheVersion serReadVer,
+ boolean keepBinary) {
assert false; return false;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/b783d2b7/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePeekModesAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePeekModesAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePeekModesAbstractTest.java
index 89610e7..056affc 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePeekModesAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePeekModesAbstractTest.java
@@ -26,6 +26,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.cache.Cache;
+import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.cache.CacheMemoryMode;
import org.apache.ignite.cache.CachePeekMode;
@@ -35,6 +36,7 @@ import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.configuration.NearCacheConfiguration;
+import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.internal.IgniteKernal;
import org.apache.ignite.internal.util.typedef.T2;
import org.apache.ignite.spi.IgniteSpiCloseableIterator;
@@ -260,16 +262,26 @@ public abstract class IgniteCachePeekModesAbstractTest extends IgniteCacheAbstra
for (Integer key : keys)
cache0.put(key, val);
- SwapSpaceSpi swap = ignite(nodeIdx).configuration().getSwapSpaceSpi();
+ Ignite ignite = ignite(nodeIdx);
+
+ SwapSpaceSpi swap = ignite.configuration().getSwapSpaceSpi();
+
+ GridCacheAdapter<Integer, String> internalCache =
+ ((IgniteKernal)ignite).context().cache().internalCache();
+
+ CacheObjectContext coctx = internalCache.context().cacheObjectContext();
Set<Integer> swapKeys = new HashSet<>();
- IgniteSpiCloseableIterator<Integer> it = swap.keyIterator(SPACE_NAME, null);
+ IgniteSpiCloseableIterator<KeyCacheObject> it = swap.keyIterator(SPACE_NAME, null);
assertNotNull(it);
- while (it.hasNext())
- assertTrue(swapKeys.add(it.next()));
+ while (it.hasNext()) {
+ KeyCacheObject next = it.next();
+
+ assertTrue(swapKeys.add((Integer)next.value(coctx, false)));
+ }
assertFalse(swapKeys.isEmpty());
@@ -277,9 +289,6 @@ public abstract class IgniteCachePeekModesAbstractTest extends IgniteCacheAbstra
Set<Integer> offheapKeys = new HashSet<>();
- GridCacheAdapter<Integer, String> internalCache =
- ((IgniteKernal)ignite(nodeIdx)).context().cache().internalCache();
-
Iterator<Map.Entry<Integer, String>> offheapIt;
if (internalCache.context().isNear())
@@ -645,7 +654,7 @@ public abstract class IgniteCachePeekModesAbstractTest extends IgniteCacheAbstra
private T2<List<Integer>, List<Integer>> swapKeys(int nodeIdx) {
SwapSpaceSpi swap = ignite(nodeIdx).configuration().getSwapSpaceSpi();
- IgniteSpiCloseableIterator<Integer> it = swap.keyIterator(SPACE_NAME, null);
+ IgniteSpiCloseableIterator<KeyCacheObject> it = swap.keyIterator(SPACE_NAME, null);
assertNotNull(it);
@@ -656,8 +665,11 @@ public abstract class IgniteCachePeekModesAbstractTest extends IgniteCacheAbstra
List<Integer> primary = new ArrayList<>();
List<Integer> backups = new ArrayList<>();
+ CacheObjectContext coctx = ((IgniteEx)ignite(nodeIdx)).context().cache().internalCache()
+ .context().cacheObjectContext();
+
while (it.hasNext()) {
- Integer key = it.next();
+ Integer key = it.next().value(coctx, false);
if (aff.isPrimary(node, key))
primary.add(key);
http://git-wip-us.apache.org/repos/asf/ignite/blob/b783d2b7/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 c04c934..80c339c 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
@@ -23,6 +23,8 @@ import org.apache.ignite.IgniteCache;
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.testframework.GridTestExternalClassLoader;
import org.apache.ignite.testframework.config.GridTestProperties;
@@ -63,6 +65,9 @@ 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()))
+ fail("https://issues.apache.org/jira/browse/IGNITE-1272");
+
UsersClassLoader testClassLdr = (UsersClassLoader)grid(0).configuration().getClassLoader();
Object val = testClassLdr.loadClass(TEST_VALUE).newInstance();
http://git-wip-us.apache.org/repos/asf/ignite/blob/b783d2b7/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCacheTxExecutionContextTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCacheTxExecutionContextTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCacheTxExecutionContextTest.java
index 1cde3f8..aaefc90 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCacheTxExecutionContextTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCacheTxExecutionContextTest.java
@@ -21,6 +21,8 @@ import org.apache.ignite.cache.CacheAtomicWriteOrderMode;
import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.configuration.NearCacheConfiguration;
+import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.testframework.config.GridTestProperties;
import static org.apache.ignite.cache.CacheAtomicWriteOrderMode.CLOCK;
import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
http://git-wip-us.apache.org/repos/asf/ignite/blob/b783d2b7/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractDistributedByteArrayValuesSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractDistributedByteArrayValuesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractDistributedByteArrayValuesSelfTest.java
index 29d9387..fde16ec 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractDistributedByteArrayValuesSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractDistributedByteArrayValuesSelfTest.java
@@ -336,6 +336,8 @@ public abstract class GridCacheAbstractDistributedByteArrayValuesSelfTest extend
private void testTransactionMixed0(IgniteCache<Integer, Object>[] caches, TransactionConcurrency concurrency,
Integer key1, byte[] val1, @Nullable Integer key2, @Nullable Object val2) throws Exception {
for (IgniteCache<Integer, Object> cache : caches) {
+ info("Checking cache: " + cache.getName());
+
Transaction tx = cache.unwrap(Ignite.class).transactions().txStart(concurrency, REPEATABLE_READ);
try {
@@ -351,6 +353,8 @@ public abstract class GridCacheAbstractDistributedByteArrayValuesSelfTest extend
}
for (IgniteCache<Integer, Object> cacheInner : caches) {
+ info("Getting value from cache: " + cacheInner.getName());
+
tx = cacheInner.unwrap(Ignite.class).transactions().txStart(concurrency, REPEATABLE_READ);
try {
http://git-wip-us.apache.org/repos/asf/ignite/blob/b783d2b7/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheBinaryObjectsAbstractDataStreamerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheBinaryObjectsAbstractDataStreamerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheBinaryObjectsAbstractDataStreamerSelfTest.java
new file mode 100644
index 0000000..c1144b6
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheBinaryObjectsAbstractDataStreamerSelfTest.java
@@ -0,0 +1,190 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.portable;
+
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ThreadLocalRandom;
+import java.util.concurrent.atomic.AtomicBoolean;
+import org.apache.ignite.IgniteDataStreamer;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.CacheWriteSynchronizationMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.NearCacheConfiguration;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.Binarylizable;
+import org.apache.ignite.binary.BinaryReader;
+import org.apache.ignite.binary.BinaryTypeConfiguration;
+import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.jsr166.LongAdder8;
+
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.PRIMARY_SYNC;
+
+/**
+ * Test for portable objects stored in cache.
+ */
+public abstract class GridCacheBinaryObjectsAbstractDataStreamerSelfTest extends GridCommonAbstractTest {
+ /** */
+ private static final int THREAD_CNT = 64;
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ CacheConfiguration cacheCfg = new CacheConfiguration();
+
+ cacheCfg.setCacheMode(cacheMode());
+ cacheCfg.setAtomicityMode(atomicityMode());
+ cacheCfg.setNearConfiguration(nearConfiguration());
+ cacheCfg.setWriteSynchronizationMode(writeSynchronizationMode());
+
+ cfg.setCacheConfiguration(cacheCfg);
+
+ PortableMarshaller marsh = new PortableMarshaller();
+
+ marsh.setTypeConfigurations(Arrays.asList(
+ new BinaryTypeConfiguration(TestObject.class.getName())));
+
+ cfg.setMarshaller(marsh);
+
+ return cfg;
+ }
+
+ /**
+ * @return Sync mode.
+ */
+ protected CacheWriteSynchronizationMode writeSynchronizationMode() {
+ return PRIMARY_SYNC;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ startGridsMultiThreaded(gridCount());
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ stopAllGrids();
+ }
+
+ /**
+ * @return Cache mode.
+ */
+ protected abstract CacheMode cacheMode();
+
+ /**
+ * @return Atomicity mode.
+ */
+ protected abstract CacheAtomicityMode atomicityMode();
+
+ /**
+ * @return Near configuration.
+ */
+ protected abstract NearCacheConfiguration nearConfiguration();
+
+ /**
+ * @return Grid count.
+ */
+ protected int gridCount() {
+ return 1;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ @SuppressWarnings("BusyWait")
+ public void testGetPut() throws Exception {
+ final AtomicBoolean flag = new AtomicBoolean();
+
+ final LongAdder8 cnt = new LongAdder8();
+
+ try (IgniteDataStreamer<Object, Object> ldr = grid(0).dataStreamer(null)) {
+ IgniteInternalFuture<?> f = multithreadedAsync(
+ new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ ThreadLocalRandom rnd = ThreadLocalRandom.current();
+
+ while (!flag.get()) {
+ ldr.addData(rnd.nextInt(10000), new TestObject(rnd.nextInt(10000)));
+
+ cnt.add(1);
+ }
+
+ return null;
+ }
+ },
+ THREAD_CNT
+ );
+
+ for (int i = 0; i < 30 && !f.isDone(); i++)
+ Thread.sleep(1000);
+
+ flag.set(true);
+
+ f.get();
+ }
+
+ info("Operations in 30 sec: " + cnt.sum());
+ }
+
+ /**
+ */
+ private static class TestObject implements Binarylizable, Serializable {
+ /** */
+ private int val;
+
+ /**
+ */
+ private TestObject() {
+ // No-op.
+ }
+
+ /**
+ * @param val Value.
+ */
+ private TestObject(int val) {
+ this.val = val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ return val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object obj) {
+ return obj instanceof TestObject && ((TestObject)obj).val == val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
+ writer.writeInt("val", val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readBinary(BinaryReader reader) throws BinaryObjectException {
+ val = reader.readInt("val");
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/b783d2b7/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheBinaryObjectsAbstractMultiThreadedSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheBinaryObjectsAbstractMultiThreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheBinaryObjectsAbstractMultiThreadedSelfTest.java
new file mode 100644
index 0000000..b626093
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheBinaryObjectsAbstractMultiThreadedSelfTest.java
@@ -0,0 +1,231 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.portable;
+
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ThreadLocalRandom;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.CacheWriteSynchronizationMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.NearCacheConfiguration;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.processors.cache.IgniteCacheProxy;
+import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.Binarylizable;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.binary.BinaryReader;
+import org.apache.ignite.binary.BinaryTypeConfiguration;
+import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.jsr166.LongAdder8;
+
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.PRIMARY_SYNC;
+
+/**
+ * Test for portable objects stored in cache.
+ */
+public abstract class GridCacheBinaryObjectsAbstractMultiThreadedSelfTest extends GridCommonAbstractTest {
+ /** */
+ private static final int THREAD_CNT = 64;
+
+ /** */
+ private static final AtomicInteger idxGen = new AtomicInteger();
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ CacheConfiguration cacheCfg = new CacheConfiguration();
+
+ cacheCfg.setCacheMode(cacheMode());
+ cacheCfg.setAtomicityMode(atomicityMode());
+ cacheCfg.setNearConfiguration(nearConfiguration());
+ cacheCfg.setWriteSynchronizationMode(writeSynchronizationMode());
+
+ cfg.setCacheConfiguration(cacheCfg);
+
+ PortableMarshaller marsh = new PortableMarshaller();
+
+ marsh.setTypeConfigurations(Arrays.asList(
+ new BinaryTypeConfiguration(TestObject.class.getName())));
+
+ cfg.setMarshaller(marsh);
+
+ return cfg;
+ }
+
+ /**
+ * @return Sync mode.
+ */
+ protected CacheWriteSynchronizationMode writeSynchronizationMode() {
+ return PRIMARY_SYNC;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ startGridsMultiThreaded(gridCount());
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ stopAllGrids();
+ }
+
+ /**
+ * @return Cache mode.
+ */
+ protected abstract CacheMode cacheMode();
+
+ /**
+ * @return Atomicity mode.
+ */
+ protected abstract CacheAtomicityMode atomicityMode();
+
+ /**
+ * @return Distribution mode.
+ */
+ protected abstract NearCacheConfiguration nearConfiguration();
+
+ /**
+ * @return Grid count.
+ */
+ protected int gridCount() {
+ return 1;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ @SuppressWarnings("BusyWait") public void testGetPut() throws Exception {
+ final AtomicBoolean flag = new AtomicBoolean();
+
+ final LongAdder8 cnt = new LongAdder8();
+
+ IgniteInternalFuture<?> f = multithreadedAsync(
+ new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ int threadId = idxGen.getAndIncrement() % 2;
+
+ ThreadLocalRandom rnd = ThreadLocalRandom.current();
+
+ while (!flag.get()) {
+ IgniteCache<Object, Object> c = jcache(rnd.nextInt(gridCount()));
+
+ switch (threadId) {
+ case 0:
+ // Put/get/remove portable -> portable.
+
+ c.put(new TestObject(rnd.nextInt(10000)), new TestObject(rnd.nextInt(10000)));
+
+ IgniteCache<Object, Object> p2 = ((IgniteCacheProxy<Object, Object>)c).keepPortable();
+
+ BinaryObject v = (BinaryObject)p2.get(new TestObject(rnd.nextInt(10000)));
+
+ if (v != null)
+ v.deserialize();
+
+ c.remove(new TestObject(rnd.nextInt(10000)));
+
+ break;
+
+ case 1:
+ // Put/get int -> portable.
+ c.put(rnd.nextInt(10000), new TestObject(rnd.nextInt(10000)));
+
+ IgniteCache<Integer, BinaryObject> p4 = ((IgniteCacheProxy<Object, Object>)c).keepPortable();
+
+ BinaryObject v1 = p4.get(rnd.nextInt(10000));
+
+ if (v1 != null)
+ v1.deserialize();
+
+ p4.remove(rnd.nextInt(10000));
+
+ break;
+
+ default:
+ assert false;
+ }
+
+ cnt.add(3);
+ }
+
+ return null;
+ }
+ },
+ THREAD_CNT
+ );
+
+ for (int i = 0; i < 30 && !f.isDone(); i++)
+ Thread.sleep(1000);
+
+ flag.set(true);
+
+ f.get();
+
+ info("Operations in 30 sec: " + cnt.sum());
+ }
+
+ /**
+ */
+ private static class TestObject implements Binarylizable, Serializable {
+ /** */
+ private int val;
+
+ /**
+ */
+ private TestObject() {
+ // No-op.
+ }
+
+ /**
+ * @param val Value.
+ */
+ private TestObject(int val) {
+ this.val = val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ return val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object obj) {
+ return obj instanceof TestObject && ((TestObject)obj).val == val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
+ writer.writeInt("val", val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readBinary(BinaryReader reader) throws BinaryObjectException {
+ val = reader.readInt("val");
+ }
+ }
+}
\ No newline at end of file