use of org.apache.ignite.binary.BinaryObject in project ignite by apache.
the class BinaryMarshallerSelfTest method testThreadLocalArrayReleased.
/**
* @throws IgniteCheckedException If failed.
*/
public void testThreadLocalArrayReleased() throws Exception {
// Checking the writer directly.
assertEquals(false, INSTANCE.isAcquired());
BinaryMarshaller marsh = binaryMarshaller();
try (BinaryWriterExImpl writer = new BinaryWriterExImpl(binaryContext(marsh))) {
assertEquals(true, INSTANCE.isAcquired());
writer.writeString("Thread local test");
writer.array();
assertEquals(true, INSTANCE.isAcquired());
}
// Checking the binary marshaller.
assertEquals(false, INSTANCE.isAcquired());
marsh = binaryMarshaller();
marsh.marshal(new SimpleObject());
assertEquals(false, INSTANCE.isAcquired());
marsh = binaryMarshaller();
// Checking the builder.
BinaryObjectBuilder builder = new BinaryObjectBuilderImpl(binaryContext(marsh), "org.gridgain.foo.bar.TestClass");
builder.setField("a", "1");
BinaryObject binaryObj = builder.build();
assertEquals(false, INSTANCE.isAcquired());
}
use of org.apache.ignite.binary.BinaryObject in project ignite by apache.
the class BinaryMarshallerSelfTest method testBinaryCopyCharArray.
/**
* @throws Exception If failed.
*/
public void testBinaryCopyCharArray() throws Exception {
BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(new BinaryTypeConfiguration(SimpleObject.class.getName())));
SimpleObject obj = simpleObject();
BinaryObject po = marshal(obj, marsh);
BinaryObject copy = copy(po, F.<String, Object>asMap("cArr", new char[] { 1, 2, 3 }));
assertArrayEquals(new char[] { 1, 2, 3 }, copy.<char[]>field("cArr"));
SimpleObject obj0 = copy.deserialize();
assertArrayEquals(new char[] { 1, 2, 3 }, obj0.cArr);
}
use of org.apache.ignite.binary.BinaryObject in project ignite by apache.
the class BinaryMarshallerSelfTest method testBinaryCopyFloatArray.
/**
* @throws Exception If failed.
*/
public void testBinaryCopyFloatArray() throws Exception {
BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(new BinaryTypeConfiguration(SimpleObject.class.getName())));
SimpleObject obj = simpleObject();
BinaryObject po = marshal(obj, marsh);
BinaryObject copy = copy(po, F.<String, Object>asMap("fArr", new float[] { 1, 2, 3 }));
assertArrayEquals(new float[] { 1, 2, 3 }, copy.<float[]>field("fArr"), 0);
SimpleObject obj0 = copy.deserialize();
assertArrayEquals(new float[] { 1, 2, 3 }, obj0.fArr, 0);
}
use of org.apache.ignite.binary.BinaryObject in project ignite by apache.
the class BinaryObjectBuilderAdditionalSelfTest method testWrongMetadataNullField2.
/**
*
*/
public void testWrongMetadataNullField2() {
BinaryObjectBuilder builder = binaries().builder("SomeType1");
builder.setField("dateField", null);
builder.setField("objectField", null, Integer.class);
BinaryObject obj = builder.build();
try {
builder = binaries().builder(obj);
builder.setField("dateField", new Date());
builder.build();
} catch (BinaryObjectException ex) {
assertTrue(ex.getMessage().startsWith("Wrong value has been set"));
}
builder = binaries().builder(obj);
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.BinaryObject in project ignite by apache.
the class DynamicIndexAbstractSelfTest method put.
/**
* Put key to cache.
*
* @param node Node.
* @param id ID.
*/
protected static void put(Ignite node, long id) {
BinaryObject key = key(node, id);
BinaryObject val = value(node, id);
cache(node).put(key, val);
}
Aggregations