http://git-wip-us.apache.org/repos/asf/ignite/blob/1dbf20e0/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 deleted file mode 100644 index f2bca9a..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataSelfTest.java +++ /dev/null @@ -1,371 +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 java.math.BigDecimal; -import java.util.Arrays; -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.binary.BinaryObjectException; -import org.apache.ignite.binary.Binarylizable; -import org.apache.ignite.binary.BinaryType; -import org.apache.ignite.binary.BinaryObject; -import org.apache.ignite.binary.BinaryRawWriter; -import org.apache.ignite.binary.BinaryReader; -import org.apache.ignite.binary.BinaryWriter; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; - -/** - * Portable meta data test. - */ -public class GridPortableMetaDataSelfTest extends GridCommonAbstractTest { - /** */ - private static int idx; - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - BinaryConfiguration bCfg = new BinaryConfiguration(); - - bCfg.setClassNames(Arrays.asList(TestObject1.class.getName(), TestObject2.class.getName())); - - cfg.setBinaryConfiguration(bCfg); - - cfg.setMarshaller(new BinaryMarshaller()); - - CacheConfiguration ccfg = new CacheConfiguration(); - - cfg.setCacheConfiguration(ccfg); - - return cfg; - } - - /** {@inheritDoc} */ - @Override protected void beforeTest() throws Exception { - idx = 0; - - startGrid(); - } - - /** {@inheritDoc} */ - @Override protected void afterTest() throws Exception { - stopGrid(); - } - - /** - * @return Portables API. - */ - protected IgniteBinary portables() { - return grid().binary(); - } - - /** - * @throws Exception If failed. - */ - public void testGetAll() throws Exception { - portables().toBinary(new TestObject2()); - - Collection<BinaryType> metas = portables().types(); - - assertEquals(2, metas.size()); - - for (BinaryType meta : metas) { - Collection<String> fields; - - switch (meta.typeName()) { - case "TestObject1": - fields = meta.fieldNames(); - - assertEquals(7, fields.size()); - - assertTrue(fields.contains("intVal")); - assertTrue(fields.contains("strVal")); - assertTrue(fields.contains("arrVal")); - assertTrue(fields.contains("obj1Val")); - assertTrue(fields.contains("obj2Val")); - assertTrue(fields.contains("decVal")); - assertTrue(fields.contains("decArrVal")); - - assertEquals("int", meta.fieldTypeName("intVal")); - assertEquals("String", meta.fieldTypeName("strVal")); - assertEquals("byte[]", meta.fieldTypeName("arrVal")); - assertEquals("Object", meta.fieldTypeName("obj1Val")); - assertEquals("Object", meta.fieldTypeName("obj2Val")); - assertEquals("decimal", meta.fieldTypeName("decVal")); - assertEquals("decimal[]", meta.fieldTypeName("decArrVal")); - - break; - - case "TestObject2": - fields = meta.fieldNames(); - - assertEquals(7, fields.size()); - - assertTrue(fields.contains("boolVal")); - assertTrue(fields.contains("dateVal")); - assertTrue(fields.contains("uuidArrVal")); - assertTrue(fields.contains("objVal")); - assertTrue(fields.contains("mapVal")); - assertTrue(fields.contains("decVal")); - assertTrue(fields.contains("decArrVal")); - - assertEquals("boolean", meta.fieldTypeName("boolVal")); - assertEquals("Date", meta.fieldTypeName("dateVal")); - assertEquals("UUID[]", meta.fieldTypeName("uuidArrVal")); - assertEquals("Object", meta.fieldTypeName("objVal")); - assertEquals("Map", meta.fieldTypeName("mapVal")); - assertEquals("decimal", meta.fieldTypeName("decVal")); - assertEquals("decimal[]", meta.fieldTypeName("decArrVal")); - - break; - - default: - assert false : meta.typeName(); - } - } - } - - /** - * @throws Exception If failed. - */ - public void testNoConfiguration() throws Exception { - portables().toBinary(new TestObject3()); - - assertNotNull(portables().type(TestObject3.class)); - } - - /** - * @throws Exception If failed. - */ - public void testReflection() throws Exception { - BinaryType meta = portables().type(TestObject1.class); - - assertNotNull(meta); - - assertEquals("TestObject1", meta.typeName()); - - Collection<String> fields = meta.fieldNames(); - - assertEquals(7, fields.size()); - - assertTrue(fields.contains("intVal")); - assertTrue(fields.contains("strVal")); - assertTrue(fields.contains("arrVal")); - assertTrue(fields.contains("obj1Val")); - assertTrue(fields.contains("obj2Val")); - assertTrue(fields.contains("decVal")); - assertTrue(fields.contains("decArrVal")); - - assertEquals("int", meta.fieldTypeName("intVal")); - assertEquals("String", meta.fieldTypeName("strVal")); - assertEquals("byte[]", meta.fieldTypeName("arrVal")); - assertEquals("Object", meta.fieldTypeName("obj1Val")); - assertEquals("Object", meta.fieldTypeName("obj2Val")); - assertEquals("decimal", meta.fieldTypeName("decVal")); - assertEquals("decimal[]", meta.fieldTypeName("decArrVal")); - } - - /** - * @throws Exception If failed. - */ - public void testPortableMarshalAware() throws Exception { - portables().toBinary(new TestObject2()); - - BinaryType meta = portables().type(TestObject2.class); - - assertNotNull(meta); - - assertEquals("TestObject2", meta.typeName()); - - Collection<String> fields = meta.fieldNames(); - - assertEquals(7, fields.size()); - - assertTrue(fields.contains("boolVal")); - assertTrue(fields.contains("dateVal")); - assertTrue(fields.contains("uuidArrVal")); - assertTrue(fields.contains("objVal")); - assertTrue(fields.contains("mapVal")); - assertTrue(fields.contains("decVal")); - assertTrue(fields.contains("decArrVal")); - - assertEquals("boolean", meta.fieldTypeName("boolVal")); - assertEquals("Date", meta.fieldTypeName("dateVal")); - assertEquals("UUID[]", meta.fieldTypeName("uuidArrVal")); - assertEquals("Object", meta.fieldTypeName("objVal")); - assertEquals("Map", meta.fieldTypeName("mapVal")); - assertEquals("decimal", meta.fieldTypeName("decVal")); - assertEquals("decimal[]", meta.fieldTypeName("decArrVal")); - } - - /** - * @throws Exception If failed. - */ - public void testMerge() throws Exception { - portables().toBinary(new TestObject2()); - - idx = 1; - - portables().toBinary(new TestObject2()); - - BinaryType meta = portables().type(TestObject2.class); - - assertNotNull(meta); - - assertEquals("TestObject2", meta.typeName()); - - Collection<String> fields = meta.fieldNames(); - - assertEquals(9, fields.size()); - - assertTrue(fields.contains("boolVal")); - assertTrue(fields.contains("dateVal")); - assertTrue(fields.contains("uuidArrVal")); - assertTrue(fields.contains("objVal")); - assertTrue(fields.contains("mapVal")); - assertTrue(fields.contains("charVal")); - assertTrue(fields.contains("colVal")); - assertTrue(fields.contains("decVal")); - assertTrue(fields.contains("decArrVal")); - - assertEquals("boolean", meta.fieldTypeName("boolVal")); - assertEquals("Date", meta.fieldTypeName("dateVal")); - assertEquals("UUID[]", meta.fieldTypeName("uuidArrVal")); - assertEquals("Object", meta.fieldTypeName("objVal")); - assertEquals("Map", meta.fieldTypeName("mapVal")); - assertEquals("char", meta.fieldTypeName("charVal")); - assertEquals("Collection", meta.fieldTypeName("colVal")); - assertEquals("decimal", meta.fieldTypeName("decVal")); - assertEquals("decimal[]", meta.fieldTypeName("decArrVal")); - } - - /** - * @throws Exception If failed. - */ - public void testSerializedObject() throws Exception { - TestObject1 obj = new TestObject1(); - - obj.intVal = 10; - obj.strVal = "str"; - obj.arrVal = new byte[] {2, 4, 6}; - obj.obj1Val = null; - obj.obj2Val = new TestObject2(); - obj.decVal = BigDecimal.ZERO; - obj.decArrVal = new BigDecimal[] { BigDecimal.ONE }; - - BinaryObject po = portables().toBinary(obj); - - info(po.toString()); - - BinaryType meta = po.type(); - - assertNotNull(meta); - - assertEquals("TestObject1", meta.typeName()); - - Collection<String> fields = meta.fieldNames(); - - assertEquals(7, fields.size()); - - assertTrue(fields.contains("intVal")); - assertTrue(fields.contains("strVal")); - assertTrue(fields.contains("arrVal")); - assertTrue(fields.contains("obj1Val")); - assertTrue(fields.contains("obj2Val")); - assertTrue(fields.contains("decVal")); - assertTrue(fields.contains("decArrVal")); - - assertEquals("int", meta.fieldTypeName("intVal")); - assertEquals("String", meta.fieldTypeName("strVal")); - assertEquals("byte[]", meta.fieldTypeName("arrVal")); - assertEquals("Object", meta.fieldTypeName("obj1Val")); - assertEquals("Object", meta.fieldTypeName("obj2Val")); - assertEquals("decimal", meta.fieldTypeName("decVal")); - assertEquals("decimal[]", meta.fieldTypeName("decArrVal")); - } - - /** - */ - @SuppressWarnings("UnusedDeclaration") - private static class TestObject1 { - /** */ - private int intVal; - - /** */ - private String strVal; - - /** */ - private byte[] arrVal; - - /** */ - private TestObject1 obj1Val; - - /** */ - private TestObject2 obj2Val; - - /** */ - private BigDecimal decVal; - - /** */ - private BigDecimal[] decArrVal; - } - - /** - */ - private static class TestObject2 implements Binarylizable { - /** {@inheritDoc} */ - @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException { - writer.writeBoolean("boolVal", false); - writer.writeDate("dateVal", new Date()); - writer.writeUuidArray("uuidArrVal", null); - writer.writeObject("objVal", null); - writer.writeMap("mapVal", new HashMap<>()); - writer.writeDecimal("decVal", BigDecimal.ZERO); - writer.writeDecimalArray("decArrVal", new BigDecimal[] { BigDecimal.ONE }); - - if (idx == 1) { - writer.writeChar("charVal", (char)0); - writer.writeCollection("colVal", null); - } - - BinaryRawWriter raw = writer.rawWriter(); - - raw.writeChar((char)0); - raw.writeCollection(null); - } - - /** {@inheritDoc} */ - @Override public void readBinary(BinaryReader reader) throws BinaryObjectException { - // No-op. - } - } - - /** - */ - @SuppressWarnings("UnusedDeclaration") - private static class TestObject3 { - /** */ - private int intVal; - } -} \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/1dbf20e0/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 deleted file mode 100644 index 0fb5381..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableWildcardsSelfTest.java +++ /dev/null @@ -1,464 +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 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.testframework.junits.common.GridCommonAbstractTest; - -import java.util.Arrays; -import java.util.Map; - -/** - * Wildcards test. - */ -public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest { - /** - * @throws Exception If failed. - */ - public void testClassNames() throws Exception { - BinaryMarshaller marsh = portableMarshaller(Arrays.asList( - new BinaryTypeConfiguration("org.apache.ignite.internal.portable.test.*"), - new BinaryTypeConfiguration("unknown.*") - )); - - PortableContext ctx = portableContext(marsh); - - Map<Integer, Class> typeIds = U.field(ctx, "userTypes"); - - assertEquals(3, typeIds.size()); - - assertTrue(typeIds.containsKey("gridportabletestclass1".hashCode())); - assertTrue(typeIds.containsKey("gridportabletestclass2".hashCode())); - assertTrue(typeIds.containsKey("innerclass".hashCode())); - } - - /** - * @throws Exception If failed. - */ - public void testClassNamesWithMapper() throws Exception { - BinaryMarshaller marsh = portableMarshaller(new BinaryIdMapper() { - @SuppressWarnings("IfMayBeConditional") - @Override public int typeId(String clsName) { - if (clsName.endsWith("1")) - return 300; - else if (clsName.endsWith("2")) - return 400; - else if (clsName.endsWith("InnerClass")) - return 500; - else - return -500; - } - - @Override public int fieldId(int typeId, String fieldName) { - return 0; - } - }, Arrays.asList( - new BinaryTypeConfiguration("org.apache.ignite.internal.portable.test.*"), - new BinaryTypeConfiguration("unknown.*") - )); - - PortableContext ctx = portableContext(marsh); - - Map<String, BinaryIdMapper> typeMappers = U.field(ctx, "typeMappers"); - - assertEquals(3, typeMappers.size()); - - assertEquals(300, typeMappers.get("GridPortableTestClass1").typeId("GridPortableTestClass1")); - assertEquals(400, typeMappers.get("GridPortableTestClass2").typeId("GridPortableTestClass2")); - assertEquals(500, typeMappers.get("InnerClass").typeId("InnerClass")); - } - - /** - * @throws Exception If failed. - */ - public void testTypeConfigurations() throws Exception { - BinaryMarshaller marsh = portableMarshaller(Arrays.asList( - new BinaryTypeConfiguration("org.apache.ignite.internal.portable.test.*"), - new BinaryTypeConfiguration("unknown.*") - )); - - PortableContext ctx = portableContext(marsh); - - Map<Integer, Class> typeIds = U.field(ctx, "userTypes"); - - assertEquals(3, typeIds.size()); - - assertTrue(typeIds.containsKey("gridportabletestclass1".hashCode())); - assertTrue(typeIds.containsKey("gridportabletestclass2".hashCode())); - assertTrue(typeIds.containsKey("innerclass".hashCode())); - } - - /** - * @throws Exception If failed. - */ - public void testTypeConfigurationsWithGlobalMapper() throws Exception { - BinaryMarshaller marsh = portableMarshaller(new BinaryIdMapper() { - @SuppressWarnings("IfMayBeConditional") - @Override public int typeId(String clsName) { - if (clsName.endsWith("1")) - return 300; - else if (clsName.endsWith("2")) - return 400; - else if (clsName.endsWith("InnerClass")) - return 500; - else - return -500; - } - - @Override public int fieldId(int typeId, String fieldName) { - return 0; - } - }, Arrays.asList( - new BinaryTypeConfiguration("org.apache.ignite.internal.portable.test.*"), - new BinaryTypeConfiguration("unknown.*") - )); - - PortableContext ctx = portableContext(marsh); - - Map<String, BinaryIdMapper> typeMappers = U.field(ctx, "typeMappers"); - - assertEquals(3, typeMappers.size()); - - assertEquals(300, typeMappers.get("GridPortableTestClass1").typeId("GridPortableTestClass1")); - assertEquals(400, typeMappers.get("GridPortableTestClass2").typeId("GridPortableTestClass2")); - assertEquals(500, typeMappers.get("InnerClass").typeId("InnerClass")); - } - - /** - * @throws Exception If failed. - */ - public void testTypeConfigurationsWithNonGlobalMapper() throws Exception { - BinaryMarshaller marsh = portableMarshaller(new BinaryIdMapper() { - @SuppressWarnings("IfMayBeConditional") - @Override public int typeId(String clsName) { - if (clsName.endsWith("1")) - return 300; - else if (clsName.endsWith("2")) - return 400; - else if (clsName.endsWith("InnerClass")) - return 500; - else - return -500; - } - - @Override public int fieldId(int typeId, String fieldName) { - return 0; - } - }, Arrays.asList( - new BinaryTypeConfiguration("org.apache.ignite.internal.portable.test.*"), - new BinaryTypeConfiguration("unknown.*") - )); - - PortableContext ctx = portableContext(marsh); - - Map<String, BinaryIdMapper> typeMappers = U.field(ctx, "typeMappers"); - - assertEquals(3, typeMappers.size()); - - assertEquals(300, typeMappers.get("GridPortableTestClass1").typeId("GridPortableTestClass1")); - assertEquals(400, typeMappers.get("GridPortableTestClass2").typeId("GridPortableTestClass2")); - assertEquals(500, typeMappers.get("InnerClass").typeId("InnerClass")); - } - - /** - * @throws Exception If failed. - */ - public void testOverride() throws Exception { - BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration(); - - typeCfg.setTypeName("org.apache.ignite.internal.portable.test.GridPortableTestClass2"); - typeCfg.setIdMapper(new BinaryIdMapper() { - @Override public int typeId(String clsName) { - return 100; - } - - @Override public int fieldId(int typeId, String fieldName) { - return 0; - } - }); - - BinaryMarshaller marsh = portableMarshaller(Arrays.asList( - new BinaryTypeConfiguration("org.apache.ignite.internal.portable.test.*"), - typeCfg)); - - PortableContext ctx = portableContext(marsh); - - Map<Integer, Class> typeIds = U.field(ctx, "userTypes"); - - assertEquals(3, typeIds.size()); - - assertTrue(typeIds.containsKey("gridportabletestclass1".hashCode())); - assertTrue(typeIds.containsKey("innerclass".hashCode())); - assertFalse(typeIds.containsKey("gridportabletestclass2".hashCode())); - - Map<String, BinaryIdMapper> typeMappers = U.field(ctx, "typeMappers"); - - assertEquals(100, typeMappers.get("GridPortableTestClass2").typeId("GridPortableTestClass2")); - } - - /** - * @throws Exception If failed. - */ - public void testClassNamesJar() throws Exception { - BinaryMarshaller marsh = portableMarshaller(Arrays.asList( - new BinaryTypeConfiguration("org.apache.ignite.portable.testjar.*"), - new BinaryTypeConfiguration("unknown.*") - )); - - PortableContext ctx = portableContext(marsh); - - Map<Integer, Class> typeIds = U.field(ctx, "userTypes"); - - assertEquals(3, typeIds.size()); - - assertTrue(typeIds.containsKey("gridportabletestclass1".hashCode())); - assertTrue(typeIds.containsKey("gridportabletestclass2".hashCode())); - } - - /** - * @throws Exception If failed. - */ - public void testClassNamesWithMapperJar() throws Exception { - BinaryMarshaller marsh = portableMarshaller(new BinaryIdMapper() { - @SuppressWarnings("IfMayBeConditional") - @Override public int typeId(String clsName) { - if (clsName.endsWith("1")) - return 300; - else if (clsName.endsWith("2")) - return 400; - else - return -500; - } - - @Override public int fieldId(int typeId, String fieldName) { - return 0; - } - }, Arrays.asList( - new BinaryTypeConfiguration("org.apache.ignite.portable.testjar.*"), - new BinaryTypeConfiguration("unknown.*") - )); - - PortableContext ctx = portableContext(marsh); - - Map<String, BinaryIdMapper> typeMappers = U.field(ctx, "typeMappers"); - - assertEquals(3, typeMappers.size()); - - assertEquals(300, typeMappers.get("GridPortableTestClass1").typeId("GridPortableTestClass1")); - assertEquals(400, typeMappers.get("GridPortableTestClass2").typeId("GridPortableTestClass2")); - } - - /** - * @throws Exception If failed. - */ - public void testTypeConfigurationsJar() throws Exception { - BinaryMarshaller marsh = portableMarshaller(Arrays.asList( - new BinaryTypeConfiguration("org.apache.ignite.portable.testjar.*"), - new BinaryTypeConfiguration("unknown.*") - )); - - PortableContext ctx = portableContext(marsh); - - Map<Integer, Class> typeIds = U.field(ctx, "userTypes"); - - assertEquals(3, typeIds.size()); - - assertTrue(typeIds.containsKey("gridportabletestclass1".hashCode())); - assertTrue(typeIds.containsKey("gridportabletestclass2".hashCode())); - } - - /** - * @throws Exception If failed. - */ - public void testTypeConfigurationsWithGlobalMapperJar() throws Exception { - BinaryMarshaller marsh = portableMarshaller(new BinaryIdMapper() { - @SuppressWarnings("IfMayBeConditional") - @Override public int typeId(String clsName) { - if (clsName.endsWith("1")) - return 300; - else if (clsName.endsWith("2")) - return 400; - else - return -500; - } - - @Override public int fieldId(int typeId, String fieldName) { - return 0; - } - }, Arrays.asList( - new BinaryTypeConfiguration("org.apache.ignite.portable.testjar.*"), - new BinaryTypeConfiguration("unknown.*") - )); - - PortableContext ctx = portableContext(marsh); - - Map<String, BinaryIdMapper> typeMappers = U.field(ctx, "typeMappers"); - - assertEquals(3, typeMappers.size()); - - assertEquals(300, typeMappers.get("GridPortableTestClass1").typeId("GridPortableTestClass1")); - assertEquals(400, typeMappers.get("GridPortableTestClass2").typeId("GridPortableTestClass2")); - } - - /** - * @throws Exception If failed. - */ - public void testTypeConfigurationsWithNonGlobalMapperJar() throws Exception { - BinaryMarshaller marsh = portableMarshaller(new BinaryIdMapper() { - @SuppressWarnings("IfMayBeConditional") - @Override public int typeId(String clsName) { - if (clsName.endsWith("1")) - return 300; - else if (clsName.endsWith("2")) - return 400; - else - return -500; - } - - @Override public int fieldId(int typeId, String fieldName) { - return 0; - } - }, Arrays.asList( - new BinaryTypeConfiguration("org.apache.ignite.portable.testjar.*"), - new BinaryTypeConfiguration("unknown.*") - )); - - PortableContext ctx = portableContext(marsh); - - Map<String, BinaryIdMapper> typeMappers = U.field(ctx, "typeMappers"); - - assertEquals(3, typeMappers.size()); - - assertEquals(300, typeMappers.get("GridPortableTestClass1").typeId("GridPortableTestClass1")); - assertEquals(400, typeMappers.get("GridPortableTestClass2").typeId("GridPortableTestClass2")); - } - - /** - * @throws Exception If failed. - */ - public void testOverrideJar() throws Exception { - BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration( - "org.apache.ignite.portable.testjar.GridPortableTestClass2"); - - typeCfg.setIdMapper(new BinaryIdMapper() { - @Override public int typeId(String clsName) { - return 100; - } - - @Override public int fieldId(int typeId, String fieldName) { - return 0; - } - }); - - BinaryMarshaller marsh = portableMarshaller(Arrays.asList( - new BinaryTypeConfiguration("org.apache.ignite.portable.testjar.*"), - typeCfg)); - - PortableContext ctx = portableContext(marsh); - - Map<Integer, Class> typeIds = U.field(ctx, "userTypes"); - - assertEquals(3, typeIds.size()); - - assertTrue(typeIds.containsKey("gridportabletestclass1".hashCode())); - - Map<String, BinaryIdMapper> typeMappers = U.field(ctx, "typeMappers"); - - assertEquals(3, typeMappers.size()); - - 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/1dbf20e0/modules/core/src/test/java/org/apache/ignite/internal/portable/TestCachingMetadataHandler.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/TestCachingMetadataHandler.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/TestCachingMetadataHandler.java deleted file mode 100644 index e49ebf3..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/portable/TestCachingMetadataHandler.java +++ /dev/null @@ -1,45 +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.binary.BinaryObjectException; -import org.apache.ignite.binary.BinaryType; - -import java.util.concurrent.ConcurrentHashMap; - -/** - * Test metadata handler. - */ -public class TestCachingMetadataHandler implements BinaryMetadataHandler { - /** Cached metadatas. */ - private final ConcurrentHashMap<Integer, BinaryType> metas = new ConcurrentHashMap<>(); - - /** {@inheritDoc} */ - @Override public void addMeta(int typeId, BinaryType meta) throws BinaryObjectException { - BinaryType otherType = metas.put(typeId, meta); - - if (otherType != null) - throw new IllegalStateException("Metadata replacement is not allowed in " + - TestCachingMetadataHandler.class.getSimpleName() + '.'); - } - - /** {@inheritDoc} */ - @Override public BinaryType metadata(int typeId) throws BinaryObjectException { - return metas.get(typeId); - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/1dbf20e0/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 deleted file mode 100644 index aad0e87..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/GridBinaryMarshalerAwareTestClass.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.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/1dbf20e0/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 deleted file mode 100644 index b568cb5..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/GridPortableTestClasses.java +++ /dev/null @@ -1,484 +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 com.google.common.base.Throwables; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.ObjectOutput; -import java.io.ObjectOutputStream; -import java.io.Serializable; -import java.math.BigDecimal; -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; -import java.util.UUID; - -import org.apache.ignite.binary.BinaryMapFactory; -import org.apache.ignite.binary.BinaryObjectException; -import org.apache.ignite.binary.BinaryReader; -import org.apache.ignite.binary.BinaryWriter; -import org.apache.ignite.binary.Binarylizable; -import org.apache.ignite.internal.util.lang.GridMapEntry; -import org.apache.ignite.binary.BinaryObject; - -/** - * - */ -@SuppressWarnings({"PublicInnerClass", "PublicField"}) -public class GridPortableTestClasses { - /** - * - */ - public static class TestObjectContainer { - /** */ - public Object foo; - - /** - * - */ - public TestObjectContainer() { - // No-op. - } - - /** - * @param foo Object. - */ - public TestObjectContainer(Object foo) { - this.foo = foo; - } - } - - /** - * - */ - public static class TestObjectOuter { - /** */ - public TestObjectInner inner; - - /** */ - public String foo; - - /** - * - */ - public TestObjectOuter() { - - } - - /** - * @param inner Inner object. - */ - public TestObjectOuter(TestObjectInner inner) { - this.inner = inner; - } - } - - /** */ - public static class TestObjectInner { - /** */ - public Object foo; - - /** */ - public TestObjectOuter outer; - } - - /** */ - public static class TestObjectArrayList { - /** */ - public List<String> list = new ArrayList<>(); - } - - /** - * - */ - public static class TestObjectPlainPortable { - /** */ - public BinaryObject plainPortable; - - /** - * - */ - public TestObjectPlainPortable() { - // No-op. - } - - /** - * @param plainPortable Object. - */ - public TestObjectPlainPortable(BinaryObject plainPortable) { - this.plainPortable = plainPortable; - } - } - - /** - * - */ - public static class TestObjectAllTypes implements Serializable { - /** */ - public Byte b_; - - /** */ - public Short s_; - - /** */ - public Integer i_; - - /** */ - public Long l_; - - /** */ - public Float f_; - - /** */ - public Double d_; - - /** */ - public Character c_; - - /** */ - public Boolean z_; - - /** */ - public byte b; - - /** */ - public short s; - - /** */ - public int i; - - /** */ - public long l; - - /** */ - public float f; - - /** */ - public double d; - - /** */ - public char c; - - /** */ - public boolean z; - - /** */ - public String str; - - /** */ - public UUID uuid; - - /** */ - public Date date; - - /** */ - public Timestamp ts; - - /** */ - public byte[] bArr; - - /** */ - public short[] sArr; - - /** */ - public int[] iArr; - - /** */ - public long[] lArr; - - /** */ - public float[] fArr; - - /** */ - public double[] dArr; - - /** */ - public char[] cArr; - - /** */ - public boolean[] zArr; - - /** */ - public BigDecimal[] bdArr; - - /** */ - public String[] strArr; - - /** */ - public UUID[] uuidArr; - - /** */ - public Date[] dateArr; - - /** */ - public Timestamp[] tsArr; - - /** */ - public TestObjectEnum anEnum; - - /** */ - public TestObjectEnum[] enumArr; - - /** */ - public Map.Entry entry; - - /** - * @return Array. - */ - private byte[] serialize() { - ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); - - try { - ObjectOutput out = new ObjectOutputStream(byteOut); - - out.writeObject(this); - - out.close(); - } - catch (IOException e) { - Throwables.propagate(e); - } - - return byteOut.toByteArray(); - } - - /** - * - */ - public void setDefaultData() { - b_ = 11; - s_ = 22; - i_ = 33; - l_ = 44L; - f_ = 55f; - d_ = 66d; - c_ = 'e'; - z_ = true; - - b = 1; - s = 2; - i = 3; - l = 4; - f = 5; - d = 6; - c = 7; - z = true; - - str = "abc"; - uuid = new UUID(1, 1); - date = new Date(1000000); - ts = new Timestamp(100020003); - - bArr = new byte[] {1, 2, 3}; - sArr = new short[] {1, 2, 3}; - iArr = new int[] {1, 2, 3}; - lArr = new long[] {1, 2, 3}; - fArr = new float[] {1, 2, 3}; - dArr = new double[] {1, 2, 3}; - cArr = new char[] {1, 2, 3}; - zArr = new boolean[] {true, false}; - - strArr = new String[] {"abc", "ab", "a"}; - uuidArr = new UUID[] {new UUID(1, 1), new UUID(2, 2)}; - bdArr = new BigDecimal[] {new BigDecimal(1000), BigDecimal.TEN}; - dateArr = new Date[] {new Date(1000000), new Date(200000)}; - tsArr = new Timestamp[] {new Timestamp(100020003), new Timestamp(200030004)}; - - anEnum = TestObjectEnum.A; - - enumArr = new TestObjectEnum[] {TestObjectEnum.B}; - - entry = new GridMapEntry<>(1, "a"); - } - } - - /** - * - */ - public enum TestObjectEnum { - A, B, C - } - - /** - * - */ - public static class Address implements Serializable { - /** SUID. */ - private static final long serialVersionUID = 0L; - - /** City. */ - public String city; - - /** Street. */ - public String street; - - /** Street number. */ - public int streetNumber; - - /** Flat number. */ - public int flatNumber; - - /** - * Default constructor. - */ - public Address() { - // No-op. - } - - /** - * Constructor. - * - * @param city City. - * @param street Street. - * @param streetNumber Street number. - * @param flatNumber Flat number. - */ - public Address(String city, String street, int streetNumber, int flatNumber) { - this.city = city; - this.street = street; - this.streetNumber = streetNumber; - this.flatNumber = flatNumber; - } - } - - /** - * - */ - public static class Company implements Serializable { - /** SUID. */ - private static final long serialVersionUID = 0L; - - /** ID. */ - public int id; - - /** Name. */ - public String name; - - /** Size. */ - public int size; - - /** Address. */ - public Address address; - - /** Occupation. */ - public String occupation; - - /** - * Default constructor. - */ - public Company() { - // No-op. - } - - /** - * Constructor. - * - * @param id ID. - * @param name Name. - * @param size Size. - * @param address Address. - * @param occupation Occupation. - */ - public Company(int id, String name, int size, Address address, String occupation) { - this.id = id; - this.name = name; - this.size = size; - this.address = address; - this.occupation = occupation; - } - } - - /** - * Companies. - */ - public static class Companies { - /** Companies. */ - private List<Company> companies = new ArrayList<>(); - - /** - * @param idx Index. - * @return Company. - */ - public Company get(int idx) { - return companies.get(idx); - } - - /** - * @param company Company. - */ - public void add(Company company) { - companies.add(company); - } - - /** - * @return Size. - */ - public int size() { - return companies.size(); - } - } - - /** - * - */ - public static class Addresses implements Binarylizable { - /** */ - private Map<String, Companies> companyByStreet = new TreeMap<>(); - - /** - * @param company Company. - */ - public void addCompany(Company company) { - Companies list = companyByStreet.get(company.address.street); - - if (list == null) { - list = new Companies(); - - companyByStreet.put(company.address.street, list); - } - - list.add(company); - } - - /** - * @return map - */ - public Map<String, Companies> getCompanyByStreet() { - return companyByStreet; - } - - /** {@inheritDoc} */ - @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException { - writer.writeMap("companyByStreet", companyByStreet); - } - - /** {@inheritDoc} */ - @SuppressWarnings("unchecked") - @Override public void readBinary(BinaryReader reader) throws BinaryObjectException { - companyByStreet = reader.readMap("companyByStreet", new BinaryMapFactory<String, Companies>() { - @Override public Map<String, Companies> create(int size) { - return new TreeMap<>(); - } - }); - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/1dbf20e0/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/package-info.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/package-info.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/package-info.java deleted file mode 100644 index daa13d5..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/package-info.java +++ /dev/null @@ -1,22 +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 description. --> - * Contains internal tests or test related classes and interfaces. - */ -package org.apache.ignite.internal.portable.mutabletest; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/1dbf20e0/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 deleted file mode 100644 index 6c11938..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryFieldsHeapNonCompactSelfTest.java +++ /dev/null @@ -1,30 +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.noncompact; - -import org.apache.ignite.internal.portable.BinaryFieldsHeapSelfTest; - -/** - * Field tests for heap-based portables with non-compact footer. - */ -public class BinaryFieldsHeapNonCompactSelfTest extends BinaryFieldsHeapSelfTest { - /** {@inheritDoc} */ - @Override protected boolean compactFooter() { - return false; - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/1dbf20e0/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryFieldsOffheapNonCompactSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryFieldsOffheapNonCompactSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryFieldsOffheapNonCompactSelfTest.java deleted file mode 100644 index 0bca601..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryFieldsOffheapNonCompactSelfTest.java +++ /dev/null @@ -1,30 +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.noncompact; - -import org.apache.ignite.internal.portable.BinaryFieldsOffheapSelfTest; - -/** - * Field tests for offheap-based portables with non-compact footer. - */ -public class BinaryFieldsOffheapNonCompactSelfTest extends BinaryFieldsOffheapSelfTest { - /** {@inheritDoc} */ - @Override protected boolean compactFooter() { - return false; - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/1dbf20e0/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryFooterOffsetsHeapNonCompactSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryFooterOffsetsHeapNonCompactSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryFooterOffsetsHeapNonCompactSelfTest.java deleted file mode 100644 index 8fba738..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryFooterOffsetsHeapNonCompactSelfTest.java +++ /dev/null @@ -1,30 +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.noncompact; - -import org.apache.ignite.internal.portable.BinaryFooterOffsetsHeapSelfTest; - -/** - * Compact offsets tests for heap portable objects with non-compact footer. - */ -public class BinaryFooterOffsetsHeapNonCompactSelfTest extends BinaryFooterOffsetsHeapSelfTest { - /** {@inheritDoc} */ - @Override protected boolean compactFooter() { - return false; - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/1dbf20e0/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryFooterOffsetsOffheapNonCompactSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryFooterOffsetsOffheapNonCompactSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryFooterOffsetsOffheapNonCompactSelfTest.java deleted file mode 100644 index b52bd83..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryFooterOffsetsOffheapNonCompactSelfTest.java +++ /dev/null @@ -1,30 +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.noncompact; - -import org.apache.ignite.internal.portable.BinaryFooterOffsetsOffheapSelfTest; - -/** - * Compact offsets tests for offheap portable objects with non-compact footer. - */ -public class BinaryFooterOffsetsOffheapNonCompactSelfTest extends BinaryFooterOffsetsOffheapSelfTest { - /** {@inheritDoc} */ - @Override protected boolean compactFooter() { - return false; - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/1dbf20e0/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryMarshallerNonCompactSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryMarshallerNonCompactSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryMarshallerNonCompactSelfTest.java deleted file mode 100644 index 0484dea..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryMarshallerNonCompactSelfTest.java +++ /dev/null @@ -1,30 +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.noncompact; - -import org.apache.ignite.internal.portable.BinaryMarshallerSelfTest; - -/** - * Basic marshaller test with non-compact footer. - */ -public class BinaryMarshallerNonCompactSelfTest extends BinaryMarshallerSelfTest { - /** {@inheritDoc} */ - @Override protected boolean compactFooter() { - return false; - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/1dbf20e0/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryObjectBuilderAdditionalNonCompactSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryObjectBuilderAdditionalNonCompactSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryObjectBuilderAdditionalNonCompactSelfTest.java deleted file mode 100644 index 8811029..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryObjectBuilderAdditionalNonCompactSelfTest.java +++ /dev/null @@ -1,30 +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.noncompact; - -import org.apache.ignite.internal.portable.BinaryObjectBuilderAdditionalSelfTest; - -/** - * - */ -public class BinaryObjectBuilderAdditionalNonCompactSelfTest extends BinaryObjectBuilderAdditionalSelfTest { - /** {@inheritDoc} */ - @Override protected boolean compactFooter() { - return false; - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/1dbf20e0/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryObjectBuilderNonCompactSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryObjectBuilderNonCompactSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryObjectBuilderNonCompactSelfTest.java deleted file mode 100644 index 0b0916d..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryObjectBuilderNonCompactSelfTest.java +++ /dev/null @@ -1,30 +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.noncompact; - -import org.apache.ignite.internal.portable.BinaryObjectBuilderSelfTest; - -/** - * Portable builder test for objects with non-compact footer. - */ -public class BinaryObjectBuilderNonCompactSelfTest extends BinaryObjectBuilderSelfTest { - /** {@inheritDoc} */ - @Override protected boolean compactFooter() { - return false; - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/1dbf20e0/modules/core/src/test/java/org/apache/ignite/internal/portable/package-info.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/package-info.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/package-info.java deleted file mode 100644 index 26897e6..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/portable/package-info.java +++ /dev/null @@ -1,22 +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 description. --> - * Contains internal tests or test related classes and interfaces. - */ -package org.apache.ignite.internal.portable; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/1dbf20e0/modules/core/src/test/java/org/apache/ignite/internal/portable/test/GridPortableTestClass1.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/test/GridPortableTestClass1.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/test/GridPortableTestClass1.java deleted file mode 100644 index 05a8c33..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/portable/test/GridPortableTestClass1.java +++ /dev/null @@ -1,28 +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.test; - -/** - */ -public class GridPortableTestClass1 { - /** - */ - private static class InnerClass { - // No-op. - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/1dbf20e0/modules/core/src/test/java/org/apache/ignite/internal/portable/test/GridPortableTestClass2.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/test/GridPortableTestClass2.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/test/GridPortableTestClass2.java deleted file mode 100644 index ba69991..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/portable/test/GridPortableTestClass2.java +++ /dev/null @@ -1,24 +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.test; - -/** - */ -public class GridPortableTestClass2 { - // No-op. -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/1dbf20e0/modules/core/src/test/java/org/apache/ignite/internal/portable/test/package-info.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/test/package-info.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/test/package-info.java deleted file mode 100644 index e63b814..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/portable/test/package-info.java +++ /dev/null @@ -1,22 +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 description. --> - * Contains internal tests or test related classes and interfaces. - */ -package org.apache.ignite.internal.portable.test; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/1dbf20e0/modules/core/src/test/java/org/apache/ignite/internal/portable/test/subpackage/GridPortableTestClass3.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/test/subpackage/GridPortableTestClass3.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/test/subpackage/GridPortableTestClass3.java deleted file mode 100644 index cf3aa2d..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/portable/test/subpackage/GridPortableTestClass3.java +++ /dev/null @@ -1,24 +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.test.subpackage; - -/** - */ -public class GridPortableTestClass3 { - // No-op. -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/1dbf20e0/modules/core/src/test/java/org/apache/ignite/internal/portable/test/subpackage/package-info.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/test/subpackage/package-info.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/test/subpackage/package-info.java deleted file mode 100644 index ae8ee73..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/portable/test/subpackage/package-info.java +++ /dev/null @@ -1,22 +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 description. --> - * Contains internal tests or test related classes and interfaces. - */ -package org.apache.ignite.internal.portable.test.subpackage; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/1dbf20e0/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConditionalDeploymentSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConditionalDeploymentSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConditionalDeploymentSelfTest.java index 4098225..ea16c1f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConditionalDeploymentSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConditionalDeploymentSelfTest.java @@ -22,7 +22,7 @@ import org.apache.ignite.Ignition; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.managers.communication.GridIoMessageFactory; -import org.apache.ignite.internal.portable.BinaryMarshaller; +import org.apache.ignite.internal.binary.BinaryMarshaller; import org.apache.ignite.internal.util.IgniteUtils; import org.apache.ignite.internal.util.typedef.CO; import org.apache.ignite.plugin.extensions.communication.Message; http://git-wip-us.apache.org/repos/asf/ignite/blob/1dbf20e0/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentSelfTest.java index bfa353b..22e8c36 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentSelfTest.java @@ -26,7 +26,7 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.DeploymentMode; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; -import org.apache.ignite.internal.portable.BinaryMarshaller; +import org.apache.ignite.internal.binary.BinaryMarshaller; import org.apache.ignite.internal.util.typedef.T2; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; http://git-wip-us.apache.org/repos/asf/ignite/blob/1dbf20e0/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStoreValueAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStoreValueAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStoreValueAbstractTest.java index 95527c3..70c5dc3 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStoreValueAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStoreValueAbstractTest.java @@ -39,8 +39,8 @@ import org.apache.ignite.cache.store.CacheStoreAdapter; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteEx; -import org.apache.ignite.internal.portable.BinaryMarshaller; -import org.apache.ignite.internal.portable.BinaryObjectImpl; +import org.apache.ignite.internal.binary.BinaryMarshaller; +import org.apache.ignite.internal.binary.BinaryObjectImpl; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheAdapter; import org.apache.ignite.internal.util.lang.GridAbsPredicate; import org.apache.ignite.lang.IgniteBiInClosure; @@ -519,4 +519,4 @@ public abstract class IgniteCacheStoreValueAbstractTest extends IgniteCacheAbstr static class TestInterceptor extends CacheInterceptorAdapter { // No-op. } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/ignite/blob/1dbf20e0/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryAtomicEntryProcessorDeploymentSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryAtomicEntryProcessorDeploymentSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryAtomicEntryProcessorDeploymentSelfTest.java new file mode 100644 index 0000000..2c55381 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryAtomicEntryProcessorDeploymentSelfTest.java @@ -0,0 +1,129 @@ +/* + * 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.binary; + +import org.apache.ignite.IgniteCache; +import org.apache.ignite.binary.BinaryInvalidTypeException; +import org.apache.ignite.binary.BinaryObject; +import org.apache.ignite.configuration.DeploymentMode; +import org.apache.ignite.internal.processors.cache.GridCacheAtomicEntryProcessorDeploymentSelfTest; + +/** + * Cache EntryProcessor + Deployment. + */ +public class GridCacheBinaryAtomicEntryProcessorDeploymentSelfTest + extends GridCacheAtomicEntryProcessorDeploymentSelfTest { + /** {@inheritDoc} */ + protected IgniteCache getCache() { + return grid(1).cache(null).withKeepBinary(); + } + + /** {@inheritDoc} */ + @Override protected String getEntryProcessor() { + return "org.apache.ignite.tests.p2p.CacheDeploymentBinaryObjectEntryProcessor"; + } + + /** + * @throws Exception In case of error. + */ + public void testGetDeployment() throws Exception { + depMode = DeploymentMode.CONTINUOUS; + + doTestGet(false); + } + + /** + * @throws Exception In case of error. + */ + public void testGetDeployment2() throws Exception { + depMode = DeploymentMode.SHARED; + + doTestGet(false); + } + + /** + * @throws Exception In case of error. + */ + public void testGetDeploymentWithKeepBinary() throws Exception { + depMode = DeploymentMode.CONTINUOUS; + + doTestGet(true); + } + + /** + * @throws Exception In case of error. + */ + public void testGetDeployment2WithKeepBinary() throws Exception { + depMode = DeploymentMode.SHARED; + + doTestGet(true); + } + + /** + * @throws Exception Exception. + */ + private void doTestGet(boolean withKeepBinary) throws Exception { + try { + clientMode = false; + startGrid(0); + + clientMode = true; + startGrid(1); + + Class valCls = grid(1).configuration().getClassLoader().loadClass(TEST_VALUE); + + assertTrue(grid(1).configuration().isClientMode()); + assertFalse(grid(0).configuration().isClientMode()); + + IgniteCache cache1 = grid(1).cache(null); + IgniteCache cache0 = grid(0).cache(null); + + if (withKeepBinary) { + cache1 = cache1.withKeepBinary(); + cache0 = cache0.withKeepBinary(); + } + + cache1.put("key", valCls.newInstance()); + + if (withKeepBinary) { + BinaryObject obj = (BinaryObject)(cache0.get("key")); + + try { + obj.deserialize(); + + fail("Exception did not happened."); + } + catch (BinaryInvalidTypeException e) { + // No-op. + } + } + else + try { + cache0.get("key"); + + fail("Exception did not happened."); + } + catch (BinaryInvalidTypeException e) { + // No-op. + } + } + finally { + stopAllGrids(); + } + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/1dbf20e0/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractDataStreamerSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractDataStreamerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractDataStreamerSelfTest.java new file mode 100644 index 0000000..5840149 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractDataStreamerSelfTest.java @@ -0,0 +1,192 @@ +/* + * 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.binary; + +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.BinaryConfiguration; +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.binary.BinaryMarshaller; +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); + + BinaryConfiguration bCfg = new BinaryConfiguration(); + + bCfg.setTypeConfigurations(Arrays.asList( + new BinaryTypeConfiguration(TestObject.class.getName()))); + + cfg.setBinaryConfiguration(bCfg); + cfg.setMarshaller(new BinaryMarshaller()); + + 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"); + } + } +}
