use of org.apache.ignite.binary.BinaryObjectException in project ignite by apache.
the class BinaryObjectBuilderAdditionalSelfTest method testWrongMetadataNullField.
/**
*
*/
public void testWrongMetadataNullField() {
BinaryObjectBuilder builder = binaries().builder("SomeType");
builder.setField("dateField", null);
builder.setField("objectField", null, Integer.class);
builder.build();
try {
builder = binaries().builder("SomeType");
builder.setField("dateField", new Date());
builder.build();
} catch (BinaryObjectException ex) {
assertTrue(ex.getMessage().startsWith("Wrong value has been set"));
}
builder = binaries().builder("SomeType");
try {
builder.setField("objectField", new GridBinaryTestClasses.Company());
builder.build();
fail("BinaryObjectBuilder accepted wrong metadata");
} catch (BinaryObjectException ex) {
assertTrue(ex.getMessage().startsWith("Wrong value has been set"));
}
}
use of org.apache.ignite.binary.BinaryObjectException in project ignite by apache.
the class BinaryConfigurationConsistencySelfTest method customConfig.
/**
* @return Custom BinaryConfiguration.
* @param compactFooter Compact footer.
*/
private BinaryConfiguration customConfig(boolean compactFooter) {
BinaryConfiguration c = new BinaryConfiguration();
c.setIdMapper(new BinaryBasicIdMapper(true));
c.setSerializer(new BinarySerializer() {
@Override
public void writeBinary(Object obj, BinaryWriter writer) throws BinaryObjectException {
// No-op.
}
@Override
public void readBinary(Object obj, BinaryReader reader) throws BinaryObjectException {
// No-op.
}
});
c.setCompactFooter(compactFooter);
BinaryTypeConfiguration btc = new BinaryTypeConfiguration("org.MyClass");
btc.setIdMapper(BinaryContext.defaultIdMapper());
btc.setEnum(false);
btc.setSerializer(new BinarySerializer() {
@Override
public void writeBinary(Object obj, BinaryWriter writer) throws BinaryObjectException {
// No-op.
}
@Override
public void readBinary(Object obj, BinaryReader reader) throws BinaryObjectException {
// No-op.
}
});
c.setTypeConfigurations(Arrays.asList(btc));
return c;
}
Aggregations