You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2015/08/21 08:48:27 UTC
[09/45] incubator-ignite git commit: ignite-1258: make
IgnitePortables available through Ignite interface,
adding tests and fixing bugs
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/96981338/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataDisabledSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataDisabledSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataDisabledSelfTest.java
new file mode 100644
index 0000000..47db42b
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataDisabledSelfTest.java
@@ -0,0 +1,218 @@
+/*
+ * 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.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.marshaller.portable.*;
+import org.apache.ignite.portable.*;
+import org.apache.ignite.testframework.junits.common.*;
+
+import java.util.*;
+
+/**
+ * Test for disabled meta data.
+ */
+public class GridPortableMetaDataDisabledSelfTest extends GridCommonAbstractTest {
+ /** */
+ private PortableMarshaller marsh;
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ cfg.setMarshaller(marsh);
+
+ return cfg;
+ }
+
+ /**
+ * @return Portables.
+ */
+ private IgnitePortables portables() {
+ return grid().portables();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDisableGlobal() throws Exception {
+ marsh = new PortableMarshaller();
+
+ marsh.setClassNames(Arrays.asList(
+ TestObject1.class.getName(),
+ TestObject2.class.getName()
+ ));
+
+ marsh.setMetaDataEnabled(false);
+
+ try {
+ startGrid();
+
+ portables().toPortable(new TestObject1());
+ portables().toPortable(new TestObject2());
+
+ assertEquals(0, portables().metadata(TestObject1.class).fields().size());
+ assertEquals(0, portables().metadata(TestObject2.class).fields().size());
+ }
+ finally {
+ stopGrid();
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDisableGlobalSimpleClass() throws Exception {
+ marsh = new PortableMarshaller();
+
+ PortableTypeConfiguration typeCfg = new PortableTypeConfiguration(TestObject2.class.getName());
+
+ typeCfg.setMetaDataEnabled(true);
+
+ marsh.setTypeConfigurations(Arrays.asList(
+ new PortableTypeConfiguration(TestObject1.class.getName()),
+ typeCfg
+ ));
+
+ marsh.setMetaDataEnabled(false);
+
+ try {
+ startGrid();
+
+ portables().toPortable(new TestObject1());
+ portables().toPortable(new TestObject2());
+
+ assertEquals(0, portables().metadata(TestObject1.class).fields().size());
+ assertEquals(1, portables().metadata(TestObject2.class).fields().size());
+ }
+ finally {
+ stopGrid();
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDisableGlobalMarshalAwareClass() throws Exception {
+ marsh = new PortableMarshaller();
+
+ PortableTypeConfiguration typeCfg = new PortableTypeConfiguration(TestObject1.class.getName());
+
+ typeCfg.setMetaDataEnabled(true);
+
+ marsh.setTypeConfigurations(Arrays.asList(
+ new PortableTypeConfiguration(TestObject2.class.getName()),
+ typeCfg
+ ));
+
+ marsh.setMetaDataEnabled(false);
+
+ try {
+ startGrid();
+
+ portables().toPortable(new TestObject1());
+ portables().toPortable(new TestObject2());
+
+ assertEquals(1, portables().metadata(TestObject1.class).fields().size());
+ assertEquals(0, portables().metadata(TestObject2.class).fields().size());
+ }
+ finally {
+ stopGrid();
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDisableSimpleClass() throws Exception {
+ marsh = new PortableMarshaller();
+
+ PortableTypeConfiguration typeCfg = new PortableTypeConfiguration(TestObject1.class.getName());
+
+ typeCfg.setMetaDataEnabled(false);
+
+ marsh.setTypeConfigurations(Arrays.asList(
+ new PortableTypeConfiguration(TestObject2.class.getName()),
+ typeCfg
+ ));
+
+ try {
+ startGrid();
+
+ portables().toPortable(new TestObject1());
+ portables().toPortable(new TestObject2());
+
+ assertEquals(0, portables().metadata(TestObject1.class).fields().size());
+ assertEquals(1, portables().metadata(TestObject2.class).fields().size());
+ }
+ finally {
+ stopGrid();
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDisableMarshalAwareClass() throws Exception {
+ marsh = new PortableMarshaller();
+
+ PortableTypeConfiguration typeCfg = new PortableTypeConfiguration(TestObject2.class.getName());
+
+ typeCfg.setMetaDataEnabled(false);
+
+ marsh.setTypeConfigurations(Arrays.asList(
+ new PortableTypeConfiguration(TestObject1.class.getName()),
+ typeCfg
+ ));
+
+ try {
+ startGrid();
+
+ portables().toPortable(new TestObject1());
+ portables().toPortable(new TestObject2());
+
+ assertEquals(1, portables().metadata(TestObject1.class).fields().size());
+ assertEquals(0, portables().metadata(TestObject2.class).fields().size());
+ }
+ finally {
+ stopGrid();
+ }
+ }
+
+ /**
+ */
+ @SuppressWarnings("UnusedDeclaration")
+ private static class TestObject1 {
+ /** */
+ private int field;
+ }
+
+ /**
+ */
+ private static class TestObject2 implements PortableMarshalAware {
+ /** {@inheritDoc} */
+ @Override public void writePortable(PortableWriter writer) throws PortableException {
+ writer.writeInt("field", 1);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readPortable(PortableReader reader) throws PortableException {
+ // No-op.
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/96981338/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
new file mode 100644
index 0000000..e5ca91e
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataSelfTest.java
@@ -0,0 +1,343 @@
+/*
+ * 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.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.marshaller.portable.*;
+import org.apache.ignite.portable.*;
+import org.apache.ignite.testframework.junits.common.*;
+
+import java.math.*;
+import java.util.*;
+
+/**
+ * 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);
+
+ PortableMarshaller marsh = new PortableMarshaller();
+
+ marsh.setClassNames(Arrays.asList(TestObject1.class.getName(), TestObject2.class.getName()));
+
+ cfg.setMarshaller(marsh);
+
+ 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 IgnitePortables portables() {
+ return grid().portables();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testGetAll() throws Exception {
+ portables().toPortable(new TestObject2());
+
+ Collection<PortableMetadata> metas = portables().metadata();
+
+ assertEquals(2, metas.size());
+
+ for (PortableMetadata meta : metas) {
+ Collection<String> fields;
+
+ switch (meta.typeName()) {
+ case "TestObject1":
+ fields = meta.fields();
+
+ 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.fields();
+
+ 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 testReflection() throws Exception {
+ PortableMetadata meta = portables().metadata(TestObject1.class);
+
+ assertNotNull(meta);
+
+ assertEquals("TestObject1", meta.typeName());
+
+ Collection<String> fields = meta.fields();
+
+ 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().toPortable(new TestObject2());
+
+ PortableMetadata meta = portables().metadata(TestObject2.class);
+
+ assertNotNull(meta);
+
+ assertEquals("TestObject2", meta.typeName());
+
+ Collection<String> fields = meta.fields();
+
+ 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().toPortable(new TestObject2());
+
+ idx = 1;
+
+ portables().toPortable(new TestObject2());
+
+ PortableMetadata meta = portables().metadata(TestObject2.class);
+
+ assertNotNull(meta);
+
+ assertEquals("TestObject2", meta.typeName());
+
+ Collection<String> fields = meta.fields();
+
+ 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 };
+
+ PortableObject po = portables().toPortable(obj);
+
+ info(po.toString());
+
+ PortableMetadata meta = po.metaData();
+
+ assertNotNull(meta);
+
+ assertEquals("TestObject1", meta.typeName());
+
+ Collection<String> fields = meta.fields();
+
+ 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 PortableMarshalAware {
+ /** {@inheritDoc} */
+ @Override public void writePortable(PortableWriter writer) throws PortableException {
+ 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);
+ }
+
+ PortableRawWriter raw = writer.rawWriter();
+
+ raw.writeChar((char)0);
+ raw.writeCollection(null);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readPortable(PortableReader reader) throws PortableException {
+ // No-op.
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/96981338/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableTestClasses.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableTestClasses.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableTestClasses.java
new file mode 100644
index 0000000..1917f59
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableTestClasses.java
@@ -0,0 +1,425 @@
+/*
+ * 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.lang.*;
+import org.apache.ignite.portable.*;
+
+import com.google.common.base.*;
+
+import java.io.*;
+import java.util.*;
+
+/**
+ *
+ */
+@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 PortableObject plainPortable;
+
+ /**
+ *
+ */
+ public TestObjectPlainPortable() {
+ // No-op.
+ }
+
+ /**
+ * @param plainPortable Object.
+ */
+ public TestObjectPlainPortable(PortableObject 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 byte[] bArr;
+
+ /** */
+ public short[] sArr;
+
+ /** */
+ public int[] iArr;
+
+ /** */
+ public long[] lArr;
+
+ /** */
+ public float[] fArr;
+
+ /** */
+ public double[] dArr;
+
+ /** */
+ public char[] cArr;
+
+ /** */
+ public boolean[] zArr;
+
+ /** */
+ public String[] strArr;
+
+ /** */
+ public UUID[] uuidArr;
+
+ /** */
+ public TestObjectEnum anEnum;
+
+ /** */
+ public TestObjectEnum[] enumArr;
+
+ /** */
+ public Map.Entry entry;
+
+ //public Date[] dateArr; // todo test date array.
+
+ /**
+ * @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);
+
+ 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)};
+
+ anEnum = TestObjectEnum.A;
+
+ enumArr = new TestObjectEnum[]{TestObjectEnum.B};
+
+ entry = new GridMapEntry<>(1, "a");
+ }
+ }
+
+ /**
+ *
+ */
+ public enum TestObjectEnum {
+ A, B, C
+ }
+
+ /**
+ *
+ */
+ public static class Address {
+ /** 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 {
+ /** 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;
+ }
+ }
+
+ /**
+ *
+ */
+ public static class AddressBook {
+ /** */
+ private Map<String, List<Company>> companyByStreet = new TreeMap<>();
+
+ /**
+ *
+ * @param street Street.
+ * @return Company.
+ */
+ public List<Company> findCompany(String street) {
+ return companyByStreet.get(street);
+ }
+
+ /**
+ *
+ * @param company Company.
+ */
+ public void addCompany(Company company) {
+ List<Company> list = companyByStreet.get(company.address.street);
+
+ if (list == null) {
+ list = new ArrayList<>();
+
+ companyByStreet.put(company.address.street, list);
+ }
+
+ list.add(company);
+ }
+
+ /**
+ *
+ * @return map
+ */
+ public Map<String, List<Company>> getCompanyByStreet() {
+ return companyByStreet;
+ }
+
+ /**
+ *
+ * @param companyByStreet map
+ */
+ public void setCompanyByStreet(Map<String, List<Company>> companyByStreet) {
+ this.companyByStreet = companyByStreet;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/96981338/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
new file mode 100644
index 0000000..4e62bb1
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableWildcardsSelfTest.java
@@ -0,0 +1,481 @@
+/*
+ * 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.typedef.internal.*;
+import org.apache.ignite.marshaller.*;
+import org.apache.ignite.marshaller.portable.*;
+import org.apache.ignite.plugin.*;
+import org.apache.ignite.portable.*;
+import org.apache.ignite.testframework.junits.common.*;
+
+import java.util.*;
+
+/**
+ * Wildcards test.
+ */
+public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
+ /** */
+ private static final GridPortableMetaDataHandler META_HND = new GridPortableMetaDataHandler() {
+ @Override public void addMeta(int typeId, GridPortableMetaDataImpl meta) {
+ // No-op.
+ }
+
+ @Override public PortableMetadata metadata(int typeId) {
+ return null;
+ }
+ };
+
+ /**
+ * @return Portable context.
+ */
+ private GridPortableContext portableContext() {
+ return new GridPortableContext(META_HND, null);
+ }
+
+ /**
+ * @return Portable marshaller.
+ */
+ private PortableMarshaller portableMarshaller() {
+ PortableMarshaller marsh = new PortableMarshaller();
+ marsh.setContext(new MarshallerContextTestImpl(null));
+
+ return marsh;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testClassNames() throws Exception {
+ GridPortableContext ctx = portableContext();
+
+ PortableMarshaller marsh = portableMarshaller();
+
+ marsh.setClassNames(Arrays.asList(
+ "org.apache.ignite.internal.portable.test.*",
+ "unknown.*"
+ ));
+
+ ctx.configure(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 {
+ GridPortableContext ctx = portableContext();
+
+ PortableMarshaller marsh = portableMarshaller();
+
+ marsh.setIdMapper(new PortableIdMapper() {
+ @SuppressWarnings("IfMayBeConditional")
+ @Override public int typeId(String clsName) {
+ if (clsName.endsWith("1"))
+ return 100;
+ else if (clsName.endsWith("2"))
+ return 200;
+ else if (clsName.endsWith("InnerClass"))
+ return 300;
+ else
+ return -500;
+ }
+
+ @Override public int fieldId(int typeId, String fieldName) {
+ return 0;
+ }
+ });
+
+ marsh.setClassNames(Arrays.asList(
+ "org.apache.ignite.internal.portable.test.*",
+ "unknown.*"
+ ));
+
+ ctx.configure(marsh);
+
+ Map<String, PortableIdMapper> typeMappers = U.field(ctx, "typeMappers");
+
+ assertEquals(3, typeMappers.size());
+
+ assertEquals(100, typeMappers.get("GridPortableTestClass1").typeId("GridPortableTestClass1"));
+ assertEquals(200, typeMappers.get("GridPortableTestClass2").typeId("GridPortableTestClass2"));
+ assertEquals(300, typeMappers.get("InnerClass").typeId("InnerClass"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTypeConfigurations() throws Exception {
+ GridPortableContext ctx = portableContext();
+
+ PortableMarshaller marsh = portableMarshaller();
+
+ marsh.setTypeConfigurations(Arrays.asList(
+ new PortableTypeConfiguration("org.apache.ignite.internal.portable.test.*"),
+ new PortableTypeConfiguration("unknown.*")
+ ));
+
+ ctx.configure(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 {
+ GridPortableContext ctx = portableContext();
+
+ PortableMarshaller marsh = portableMarshaller();
+
+ marsh.setIdMapper(new PortableIdMapper() {
+ @SuppressWarnings("IfMayBeConditional")
+ @Override public int typeId(String clsName) {
+ if (clsName.endsWith("1"))
+ return 100;
+ else if (clsName.endsWith("2"))
+ return 200;
+ else if (clsName.endsWith("InnerClass"))
+ return 300;
+ else
+ return -500;
+ }
+
+ @Override public int fieldId(int typeId, String fieldName) {
+ return 0;
+ }
+ });
+
+ marsh.setTypeConfigurations(Arrays.asList(
+ new PortableTypeConfiguration("org.apache.ignite.internal.portable.test.*"),
+ new PortableTypeConfiguration("unknown.*")
+ ));
+
+ ctx.configure(marsh);
+
+ Map<String, PortableIdMapper> typeMappers = U.field(ctx, "typeMappers");
+
+ assertEquals(3, typeMappers.size());
+
+ assertEquals(100, typeMappers.get("GridPortableTestClass1").typeId("GridPortableTestClass1"));
+ assertEquals(200, typeMappers.get("GridPortableTestClass2").typeId("GridPortableTestClass2"));
+ assertEquals(300, typeMappers.get("InnerClass").typeId("InnerClass"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTypeConfigurationsWithNonGlobalMapper() throws Exception {
+ GridPortableContext ctx = portableContext();
+
+ PortableMarshaller marsh = portableMarshaller();
+
+ marsh.setIdMapper(new PortableIdMapper() {
+ @SuppressWarnings("IfMayBeConditional")
+ @Override public int typeId(String clsName) {
+ if (clsName.endsWith("1"))
+ return 100;
+ else if (clsName.endsWith("2"))
+ return 200;
+ else if (clsName.endsWith("InnerClass"))
+ return 300;
+ else
+ return -500;
+ }
+
+ @Override public int fieldId(int typeId, String fieldName) {
+ return 0;
+ }
+ });
+
+ marsh.setTypeConfigurations(Arrays.asList(
+ new PortableTypeConfiguration("org.apache.ignite.internal.portable.test.*"),
+ new PortableTypeConfiguration("unknown.*")
+ ));
+
+ ctx.configure(marsh);
+
+ Map<String, PortableIdMapper> typeMappers = U.field(ctx, "typeMappers");
+
+ assertEquals(3, typeMappers.size());
+
+ assertEquals(100, typeMappers.get("GridPortableTestClass1").typeId("GridPortableTestClass1"));
+ assertEquals(200, typeMappers.get("GridPortableTestClass2").typeId("GridPortableTestClass2"));
+ assertEquals(300, typeMappers.get("InnerClass").typeId("InnerClass"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testOverride() throws Exception {
+ GridPortableContext ctx = portableContext();
+
+ PortableMarshaller marsh = portableMarshaller();
+
+ marsh.setClassNames(Arrays.asList(
+ "org.apache.ignite.internal.portable.test.*"
+ ));
+
+ PortableTypeConfiguration typeCfg = new PortableTypeConfiguration();
+
+ typeCfg.setClassName("org.gridgain.grid.internal.util.portable.test.GridPortableTestClass2");
+ typeCfg.setIdMapper(new PortableIdMapper() {
+ @Override public int typeId(String clsName) {
+ return 100;
+ }
+
+ @Override public int fieldId(int typeId, String fieldName) {
+ return 0;
+ }
+ });
+
+ marsh.setTypeConfigurations(Arrays.asList(typeCfg));
+
+ ctx.configure(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, PortableIdMapper> typeMappers = U.field(ctx, "typeMappers");
+
+ assertEquals(100, typeMappers.get("GridPortableTestClass2").typeId("GridPortableTestClass2"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testClassNamesJar() throws Exception {
+ GridPortableContext ctx = portableContext();
+
+ PortableMarshaller marsh = portableMarshaller();
+
+ marsh.setClassNames(Arrays.asList(
+ "org.gridgain.grid.util.portable.testjar.*",
+ "unknown.*"
+ ));
+
+ ctx.configure(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 {
+ GridPortableContext ctx = portableContext();
+
+ PortableMarshaller marsh = portableMarshaller();
+
+ marsh.setIdMapper(new PortableIdMapper() {
+ @SuppressWarnings("IfMayBeConditional")
+ @Override public int typeId(String clsName) {
+ if (clsName.endsWith("1"))
+ return 100;
+ else if (clsName.endsWith("2"))
+ return 200;
+ else
+ return -500;
+ }
+
+ @Override public int fieldId(int typeId, String fieldName) {
+ return 0;
+ }
+ });
+
+ marsh.setClassNames(Arrays.asList(
+ "org.gridgain.grid.util.portable.testjar.*",
+ "unknown.*"
+ ));
+
+ ctx.configure(marsh);
+
+ Map<String, PortableIdMapper> typeMappers = U.field(ctx, "typeMappers");
+
+ assertEquals(3, typeMappers.size());
+
+ assertEquals(100, typeMappers.get("GridPortableTestClass1").typeId("GridPortableTestClass1"));
+ assertEquals(200, typeMappers.get("GridPortableTestClass2").typeId("GridPortableTestClass2"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTypeConfigurationsJar() throws Exception {
+ GridPortableContext ctx = portableContext();
+
+ PortableMarshaller marsh = portableMarshaller();
+
+ marsh.setTypeConfigurations(Arrays.asList(
+ new PortableTypeConfiguration("org.gridgain.grid.util.portable.testjar.*"),
+ new PortableTypeConfiguration("unknown.*")
+ ));
+
+ ctx.configure(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 {
+ GridPortableContext ctx = portableContext();
+
+ PortableMarshaller marsh = portableMarshaller();
+
+ marsh.setIdMapper(new PortableIdMapper() {
+ @SuppressWarnings("IfMayBeConditional")
+ @Override public int typeId(String clsName) {
+ if (clsName.endsWith("1"))
+ return 100;
+ else if (clsName.endsWith("2"))
+ return 200;
+ else
+ return -500;
+ }
+
+ @Override public int fieldId(int typeId, String fieldName) {
+ return 0;
+ }
+ });
+
+ marsh.setTypeConfigurations(Arrays.asList(
+ new PortableTypeConfiguration("org.gridgain.grid.util.portable.testjar.*"),
+ new PortableTypeConfiguration("unknown.*")
+ ));
+
+ ctx.configure(marsh);
+
+ Map<String, PortableIdMapper> typeMappers = U.field(ctx, "typeMappers");
+
+ assertEquals(3, typeMappers.size());
+
+ assertEquals(100, typeMappers.get("GridPortableTestClass1").typeId("GridPortableTestClass1"));
+ assertEquals(200, typeMappers.get("GridPortableTestClass2").typeId("GridPortableTestClass2"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTypeConfigurationsWithNonGlobalMapperJar() throws Exception {
+ GridPortableContext ctx = portableContext();
+
+ PortableMarshaller marsh = portableMarshaller();
+
+ marsh.setIdMapper(new PortableIdMapper() {
+ @SuppressWarnings("IfMayBeConditional")
+ @Override public int typeId(String clsName) {
+ if (clsName.endsWith("1"))
+ return 100;
+ else if (clsName.endsWith("2"))
+ return 200;
+ else
+ return -500;
+ }
+
+ @Override public int fieldId(int typeId, String fieldName) {
+ return 0;
+ }
+ });
+
+ marsh.setTypeConfigurations(Arrays.asList(
+ new PortableTypeConfiguration("org.gridgain.grid.util.portable.testjar.*"),
+ new PortableTypeConfiguration("unknown.*")
+ ));
+
+ ctx.configure(marsh);
+
+ Map<String, PortableIdMapper> typeMappers = U.field(ctx, "typeMappers");
+
+ assertEquals(3, typeMappers.size());
+
+ assertEquals(100, typeMappers.get("GridPortableTestClass1").typeId("GridPortableTestClass1"));
+ assertEquals(200, typeMappers.get("GridPortableTestClass2").typeId("GridPortableTestClass2"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testOverrideJar() throws Exception {
+ GridPortableContext ctx = portableContext();
+
+ PortableMarshaller marsh = portableMarshaller();
+
+ marsh.setClassNames(Arrays.asList(
+ "org.gridgain.grid.util.portable.testjar.*"
+ ));
+
+ PortableTypeConfiguration typeCfg = new PortableTypeConfiguration(
+ "org.gridgain.grid.util.portable.testjar.GridPortableTestClass2");
+
+ typeCfg.setIdMapper(new PortableIdMapper() {
+ @Override public int typeId(String clsName) {
+ return 100;
+ }
+
+ @Override public int fieldId(int typeId, String fieldName) {
+ return 0;
+ }
+ });
+
+ marsh.setTypeConfigurations(Arrays.asList(typeCfg));
+
+ ctx.configure(marsh);
+
+ Map<Integer, Class> typeIds = U.field(ctx, "userTypes");
+
+ assertEquals(3, typeIds.size());
+
+ assertTrue(typeIds.containsKey("gridportabletestclass1".hashCode()));
+
+ Map<String, PortableIdMapper> typeMappers = U.field(ctx, "typeMappers");
+
+ assertEquals(3, typeMappers.size());
+
+ assertEquals(100, typeMappers.get("GridPortableTestClass2").typeId("GridPortableTestClass2"));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/96981338/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
new file mode 100644
index 0000000..26897e6
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * 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/incubator-ignite/blob/96981338/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
new file mode 100644
index 0000000..fa5b047
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/test/GridPortableTestClass1.java
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/96981338/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
new file mode 100644
index 0000000..52131a9
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/test/GridPortableTestClass2.java
@@ -0,0 +1,24 @@
+/*
+ * 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.
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/96981338/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
new file mode 100644
index 0000000..f620ea7
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/test/subpackage/GridPortableTestClass3.java
@@ -0,0 +1,24 @@
+/*
+ * 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.
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/96981338/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java
index 1471faa..c6645c7 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java
@@ -248,6 +248,11 @@ public class IgniteMock implements Ignite {
}
/** {@inheritDoc} */
+ @Override public IgnitePortables portables() {
+ return null;
+ }
+
+ /** {@inheritDoc} */
@Override public void close() {}
@Nullable @Override public IgniteAtomicSequence atomicSequence(String name, long initVal, boolean create) {
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/96981338/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java
index 220424a..e116e5ab 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java
@@ -509,6 +509,11 @@ public class IgniteProcessProxy implements IgniteEx {
}
/** {@inheritDoc} */
+ @Override public IgnitePortables portables() {
+ throw new UnsupportedOperationException("Operation isn't supported yet.");
+ }
+
+ /** {@inheritDoc} */
@Override public void close() throws IgniteException {
final CountDownLatch rmtNodeStoppedLatch = new CountDownLatch(1);
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/96981338/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePortableObjectsTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePortableObjectsTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePortableObjectsTestSuite.java
new file mode 100644
index 0000000..0adb7fe
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePortableObjectsTestSuite.java
@@ -0,0 +1,120 @@
+/*
+ * 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.testsuites;
+
+import org.apache.ignite.internal.portable.*;
+
+import junit.framework.*;
+
+/**
+ * Test for portable objects stored in cache.
+ */
+public class IgnitePortableObjectsTestSuite extends TestSuite {
+ /**
+ * @return Suite.
+ * @throws Exception If failed.
+ */
+ public static TestSuite suite() throws Exception {
+ TestSuite suite = new TestSuite("GridGain Portable Objects Test Suite");
+
+ suite.addTestSuite(GridPortableMarshallerSelfTest.class);
+ suite.addTestSuite(GridPortableMarshallerCtxDisabledSelfTest.class);
+ suite.addTestSuite(GridPortableBuilderSelfTest.class);
+ suite.addTestSuite(GridPortableBuilderStringAsCharsSelfTest.class);
+ suite.addTestSuite(GridPortableMetaDataSelfTest.class);
+ suite.addTestSuite(GridPortableMetaDataDisabledSelfTest.class);
+ suite.addTestSuite(GridPortableAffinityKeySelfTest.class);
+ suite.addTestSuite(GridPortableWildcardsSelfTest.class);
+ suite.addTestSuite(GridPortableBuilderAdditionalSelfTest.class);
+ suite.addTestSuite(GridPortableBuilderStringAsCharsAdditionalSelfTest.class);
+//
+// suite.addTestSuite(GridCachePortableObjectsLocalSelfTest.class);
+// suite.addTestSuite(GridCachePortableObjectsAtomicLocalSelfTest.class);
+// suite.addTestSuite(GridCachePortableObjectsReplicatedSelfTest.class);
+// suite.addTestSuite(GridCachePortableObjectsPartitionedSelfTest.class);
+// suite.addTestSuite(GridCachePortableObjectsPartitionedNearDisabledSelfTest.class);
+// suite.addTestSuite(GridCachePortableObjectsAtomicSelfTest.class);
+// suite.addTestSuite(GridCachePortableObjectsAtomicNearDisabledSelfTest.class);
+//
+// suite.addTestSuite(GridCachePortableObjectsLocalOffheapTieredSelfTest.class);
+// suite.addTestSuite(GridCachePortableObjectsAtomicOffheapTieredSelfTest.class);
+// suite.addTestSuite(GridCachePortableObjectsAtomicNearDisabledOffheapTieredSelfTest.class);
+// suite.addTestSuite(GridCachePortableObjectsPartitionedOffheapTieredSelfTest.class);
+// suite.addTestSuite(GridCachePortableObjectsPartitionedNearDisabledOffheapTieredSelfTest.class);
+//
+// suite.addTestSuite(GridCacheLocalPortableEnabledFullApiSelfTest.class);
+// suite.addTestSuite(GridCacheAtomicLocalPortableEnabledFullApiSelfTest.class);
+// suite.addTestSuite(GridCacheReplicatedPortableEnabledFullApiSelfTest.class);
+// suite.addTestSuite(GridCachePartitionedPortableEnabledFullApiSelfTest.class);
+// suite.addTestSuite(GridCachePartitionedNearDisabledPortableEnabledFullApiSelfTest.class);
+// suite.addTestSuite(GridCacheAtomicPortableEnabledFullApiSelfTest.class);
+// suite.addTestSuite(GridCacheAtomicNearEnabledPortableEnabledFullApiSelfTest.class);
+//
+// /** Off-heap tiered mode. */
+// suite.addTestSuite(GridCacheOffHeapTieredLocalPortableEnabledFullApiSelfTest.class);
+// suite.addTestSuite(GridCacheOffHeapTieredAtomicLocalPortableEnabledFullApiSelfTest.class);
+// suite.addTestSuite(GridCacheOffHeapTieredReplicatedPortableEnabledFullApiSelfTest.class);
+// suite.addTestSuite(GridCacheOffHeapTieredPartitionedPortableEnabledFullApiSelfTest.class);
+// suite.addTestSuite(GridCacheOffHeapTieredPartitionedNearDisabledPortableEnabledFullApiSelfTest.class);
+// suite.addTestSuite(GridCacheOffHeapTieredAtomicPortableEnabledFullApiSelfTest.class);
+// suite.addTestSuite(GridCacheOffHeapTieredAtomicNearEnabledPortableEnabledFullApiSelfTest.class);
+//
+// suite.addTestSuite(GridCachePartitionedPortableEnabledFullApiMultiNodeSelfTest.class);
+// suite.addTestSuite(GridCacheAtomicPortableEnabledFullApiMultiNodeSelfTest.class);
+//
+// suite.addTestSuite(GridCacheOffHeapTieredPartitionedPortableEnabledFullApiMultiNodeSelfTest.class);
+// suite.addTestSuite(GridCacheOffHeapTieredAtomicPortableEnabledFullApiMultiNodeSelfTest.class);
+//
+// suite.addTestSuite(GridCacheAtomicPortableEnabledRollingUpdatesFullApiMultiNodeSelfTest.class);
+// suite.addTestSuite(GridCachePartitionedPortableEnabledRollingUpdatesFullApiMultiNodeSelfTest.class);
+//
+// suite.addTestSuite(GridCacheOffHeapTieredAtomicPortableEnabledRollingUpdatesFullApiMultiNodeSelfTest.class);
+// suite.addTestSuite(GridCacheOffHeapTieredPartitionedPortableEnabledRollingUpdatesFullApiMultiNodeSelfTest.class);
+//
+// suite.addTestSuite(GridCacheAtomicPartitionedOnlyPortableMultiNodeSelfTest.class);
+// suite.addTestSuite(GridCacheAtomicPartitionedOnlyPortableMultithreadedSelfTest.class);
+//
+// suite.addTestSuite(GridCacheAtomicPartitionedOnlyPortableDataStreamerMultiNodeSelfTest.class);
+// suite.addTestSuite(GridCacheAtomicPartitionedOnlyPortableDataStreamerMultithreadedSelfTest.class);
+//
+// suite.addTestSuite(GridCachePortableDuplicateIndexObjectPartitionedAtomicSelfTest.class);
+// suite.addTestSuite(GridCachePortableDuplicateIndexObjectPartitionedTransactionalSelfTest.class);
+//
+// suite.addTestSuite(GridCacheMemoryModePortableSelfTest.class);
+// suite.addTestSuite(GridCacheOffHeapAtomicPortableMultiThreadedUpdateSelfTest.class);
+// suite.addTestSuite(GridCacheOffHeapTieredEvictionAtomicPortableSelfTest.class);
+// suite.addTestSuite(GridCacheOffHeapTieredEvictionPortableSelfTest.class);
+// suite.addTestSuite(GridCachePortablesPartitionedOnlyByteArrayValuesSelfTest.class);
+// suite.addTestSuite(GridCachePortablesNearPartitionedByteArrayValuesSelfTest.class);
+// suite.addTestSuite(GridCacheOffHeapTieredPortableSelfTest.class);
+// suite.addTestSuite(GridCacheOffHeapTieredAtomicPortableSelfTest.class);
+//
+// suite.addTestSuite(GridDataStreamerImplEntSelfTest.class);
+//
+// suite.addTestSuite(GridCachePortableStoreObjectsSelfTest.class);
+// suite.addTestSuite(GridCachePortableStorePortablesSelfTest.class);
+//
+// suite.addTestSuite(GridCacheClientNodePortableMetadataTest.class);
+// suite.addTestSuite(GridCacheClientNodePortableMetadataMultinodeTest.class);
+//
+// suite.addTestSuite(DrBasicSelfTest.class);
+
+ return suite;
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/96981338/modules/spring/src/main/java/org/apache/ignite/IgniteSpringBean.java
----------------------------------------------------------------------
diff --git a/modules/spring/src/main/java/org/apache/ignite/IgniteSpringBean.java b/modules/spring/src/main/java/org/apache/ignite/IgniteSpringBean.java
index 3228210..a1a1b46 100644
--- a/modules/spring/src/main/java/org/apache/ignite/IgniteSpringBean.java
+++ b/modules/spring/src/main/java/org/apache/ignite/IgniteSpringBean.java
@@ -339,6 +339,13 @@ public class IgniteSpringBean implements Ignite, DisposableBean, InitializingBea
}
/** {@inheritDoc} */
+ @Override public IgnitePortables portables() {
+ assert g != null;
+
+ return g.portables();
+ }
+
+ /** {@inheritDoc} */
@Override public void close() throws IgniteException {
g.close();
}