use of org.apache.ignite.binary.BinaryNameMapper in project ignite by apache.
the class GridBinaryWildcardsSelfTest method checkOverrideNameMapper.
/**
*
* @param nameMapper Name mapper.
* @param mapper Mapper.
* @throws IgniteCheckedException If failed.
*/
private void checkOverrideNameMapper(BinaryNameMapper nameMapper, BinaryIdMapper mapper) throws IgniteCheckedException {
BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration();
typeCfg.setTypeName(CLASS2_FULL_NAME);
typeCfg.setNameMapper(new BinaryNameMapper() {
@Override
public String typeName(String clsName) {
return "type2";
}
@Override
public String fieldName(String fieldName) {
return "field2";
}
});
BinaryMarshaller marsh = binaryMarshaller(nameMapper, mapper, Arrays.asList(new BinaryTypeConfiguration("org.apache.ignite.internal.binary.test.*"), typeCfg));
BinaryContext ctx = binaryContext(marsh);
ConcurrentMap<Integer, BinaryInternalMapper> types = U.field(ctx, "typeId2Mapper");
assertEquals(3, types.size());
assertTrue(types.containsKey(typeId(CLASS1_FULL_NAME, nameMapper, mapper)));
assertTrue(types.containsKey(typeId(INNER_CLASS_FULL_NAME, nameMapper, mapper)));
assertTrue(types.containsKey("type2".hashCode()));
Map<String, org.apache.ignite.internal.binary.BinaryInternalMapper> typeMappers = U.field(ctx, "cls2Mappers");
assertEquals("type2", typeMappers.get(CLASS2_FULL_NAME).nameMapper().typeName(CLASS2_FULL_NAME));
}
Aggregations