use of org.apache.ignite.binary.BinaryType in project ignite by apache.
the class GridDefaultBinaryMappersBinaryMetaDataSelfTest method testBinaryMarshalAware.
/**
* @throws Exception If failed.
*/
public void testBinaryMarshalAware() throws Exception {
binaries().toBinary(new TestObject2());
BinaryType meta = binaries().type(TestObject2.class);
assertNotNull(meta);
assertEquals(expectedTypeName(TestObject2.class.getName()), 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"));
}
use of org.apache.ignite.binary.BinaryType in project ignite by apache.
the class BinaryObjectBuilderAdditionalSelfTest method testMetadataChangingDoublePut2.
/**
*
*/
public void testMetadataChangingDoublePut2() {
BinaryObjectBuilderImpl mutableObj = wrap(new GridBinaryTestClasses.TestObjectContainer());
mutableObj.setField("xx567", "a");
mutableObj.setField("xx567", "b");
mutableObj.build();
BinaryType metadata = binaries().type(GridBinaryTestClasses.TestObjectContainer.class);
assertEquals("String", metadata.fieldTypeName("xx567"));
}
use of org.apache.ignite.binary.BinaryType in project ignite by apache.
the class BinaryObjectBuilderAdditionalSelfTest method testMetadataChanging.
/**
*
*/
public void testMetadataChanging() {
GridBinaryTestClasses.TestObjectContainer c = new GridBinaryTestClasses.TestObjectContainer();
BinaryObjectBuilderImpl mutableObj = wrap(c);
mutableObj.setField("intField", 1);
mutableObj.setField("intArrField", new int[] { 1 });
mutableObj.setField("arrField", new String[] { "1" });
mutableObj.setField("strField", "1");
mutableObj.setField("colField", Lists.newArrayList("1"));
mutableObj.setField("mapField", Maps.newHashMap(ImmutableMap.of(1, "1")));
mutableObj.setField("enumField", GridBinaryTestClasses.TestObjectEnum.A);
mutableObj.setField("enumArrField", new Enum[] { GridBinaryTestClasses.TestObjectEnum.A });
mutableObj.build();
BinaryType metadata = binaries().type(c.getClass());
assertTrue(metadata.fieldNames().containsAll(Arrays.asList("intField", "intArrField", "arrField", "strField", "colField", "mapField", "enumField", "enumArrField")));
assertEquals("int", metadata.fieldTypeName("intField"));
assertEquals("int[]", metadata.fieldTypeName("intArrField"));
assertEquals("String[]", metadata.fieldTypeName("arrField"));
assertEquals("String", metadata.fieldTypeName("strField"));
assertEquals("Collection", metadata.fieldTypeName("colField"));
assertEquals("Map", metadata.fieldTypeName("mapField"));
assertEquals("Enum", metadata.fieldTypeName("enumField"));
assertEquals("Enum[]", metadata.fieldTypeName("enumArrField"));
}
use of org.apache.ignite.binary.BinaryType in project ignite by apache.
the class BinaryObjectBuilderDefaultMappersSelfTest method testMetaData2.
/**
* @throws Exception If failed.
*/
public void testMetaData2() throws Exception {
BinaryObjectBuilder builder = builder("org.test.MetaTest2");
builder.setField("objectField", "a", Object.class);
BinaryObject bo = builder.build();
BinaryType meta = bo.type();
assertEquals(expectedTypeName("org.test.MetaTest2"), meta.typeName());
assertEquals("Object", meta.fieldTypeName("objectField"));
}
use of org.apache.ignite.binary.BinaryType in project ignite by apache.
the class BinaryObjectBuilderAdditionalSelfTest method testMetadataChangingDoublePut.
/**
*
*/
public void testMetadataChangingDoublePut() {
BinaryObjectBuilderImpl mutableObj = wrap(new GridBinaryTestClasses.TestObjectContainer());
mutableObj.setField("xx567", "a");
mutableObj.setField("xx567", "b");
mutableObj.build();
BinaryType metadata = binaries().type(GridBinaryTestClasses.TestObjectContainer.class);
assertEquals("String", metadata.fieldTypeName("xx567"));
}
Aggregations