Search in sources :

Example 41 with BinaryObjectException

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"));
    }
}
Also used : BinaryObjectBuilder(org.apache.ignite.binary.BinaryObjectBuilder) GridBinaryTestClasses(org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses) Date(java.util.Date) BinaryObjectException(org.apache.ignite.binary.BinaryObjectException)

Example 42 with BinaryObjectException

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;
}
Also used : BinaryConfiguration(org.apache.ignite.configuration.BinaryConfiguration) BinaryBasicIdMapper(org.apache.ignite.binary.BinaryBasicIdMapper) BinaryWriter(org.apache.ignite.binary.BinaryWriter) BinaryTypeConfiguration(org.apache.ignite.binary.BinaryTypeConfiguration) BinaryReader(org.apache.ignite.binary.BinaryReader) BinarySerializer(org.apache.ignite.binary.BinarySerializer) BinaryObjectException(org.apache.ignite.binary.BinaryObjectException)

Aggregations

BinaryObjectException (org.apache.ignite.binary.BinaryObjectException)42 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)9 BinaryObject (org.apache.ignite.binary.BinaryObject)8 Date (java.util.Date)4 HashMap (java.util.HashMap)4 LinkedHashMap (java.util.LinkedHashMap)4 Map (java.util.Map)4 TreeMap (java.util.TreeMap)4 BinarySerializer (org.apache.ignite.binary.BinarySerializer)4 BinaryType (org.apache.ignite.binary.BinaryType)4 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 BigInteger (java.math.BigInteger)2 Time (java.sql.Time)2 Timestamp (java.sql.Timestamp)2 ConcurrentMap (java.util.concurrent.ConcurrentMap)2 BinaryBasicIdMapper (org.apache.ignite.binary.BinaryBasicIdMapper)2 BinaryInvalidTypeException (org.apache.ignite.binary.BinaryInvalidTypeException)2 BinaryObjectBuilder (org.apache.ignite.binary.BinaryObjectBuilder)2 BinaryTypeConfiguration (org.apache.ignite.binary.BinaryTypeConfiguration)2 BinaryEnumObjectImpl (org.apache.ignite.internal.binary.BinaryEnumObjectImpl)2