use of org.apache.ignite.marshaller.MarshallerContextTestImpl in project ignite by apache.
the class GridSessionCheckpointSelfTest method testCacheCheckpoint.
/**
* @throws Exception If failed.
*/
public void testCacheCheckpoint() throws Exception {
IgniteConfiguration cfg = getConfiguration();
String cacheName = "test-checkpoints";
CacheConfiguration cacheCfg = defaultCacheConfiguration();
cacheCfg.setName(cacheName);
CacheCheckpointSpi spi = new CacheCheckpointSpi();
spi.setCacheName(cacheName);
cfg.setCacheConfiguration(cacheCfg);
cfg.setCheckpointSpi(spi);
if (cfg.getMarshaller() instanceof BinaryMarshaller) {
BinaryContext ctx = new BinaryContext(BinaryCachingMetadataHandler.create(), cfg, new NullLogger());
Marshaller marsh = cfg.getMarshaller();
marsh.setContext(new MarshallerContextTestImpl(null));
IgniteUtils.invoke(BinaryMarshaller.class, marsh, "setBinaryContext", ctx, cfg);
}
GridSessionCheckpointSelfTest.spi = spi;
checkCheckpoints(cfg);
}
use of org.apache.ignite.marshaller.MarshallerContextTestImpl in project ignite by apache.
the class OptimizedMarshallerEnumSelfTest method testEnumSerialisation.
/**
* @throws Exception If failed.
*/
public void testEnumSerialisation() throws Exception {
OptimizedMarshaller marsh = new OptimizedMarshaller();
MarshallerContextTestImpl context = new MarshallerContextTestImpl();
context.onMarshallerProcessorStarted(newContext(), null);
marsh.setContext(context);
byte[] bytes = marsh.marshal(TestEnum.Bond);
TestEnum unmarshalled = marsh.unmarshal(bytes, Thread.currentThread().getContextClassLoader());
assertEquals(TestEnum.Bond, unmarshalled);
assertEquals(TestEnum.Bond.desc, unmarshalled.desc);
}
use of org.apache.ignite.marshaller.MarshallerContextTestImpl in project ignite by apache.
the class BinaryFieldExtractionSelfTest method createMarshaller.
/**
* Create marshaller.
*
* @return Binary marshaller.
* @throws Exception If failed.
*/
protected BinaryMarshaller createMarshaller() throws Exception {
BinaryContext ctx = new BinaryContext(BinaryCachingMetadataHandler.create(), new IgniteConfiguration(), log());
BinaryMarshaller marsh = new BinaryMarshaller();
BinaryConfiguration bCfg = new BinaryConfiguration();
IgniteConfiguration iCfg = new IgniteConfiguration();
iCfg.setBinaryConfiguration(bCfg);
marsh.setContext(new MarshallerContextTestImpl(null));
IgniteUtils.invoke(BinaryMarshaller.class, marsh, "setBinaryContext", ctx, iCfg);
return marsh;
}
use of org.apache.ignite.marshaller.MarshallerContextTestImpl in project ignite by apache.
the class BinaryFieldsAbstractSelfTest method createMarshaller.
/**
* Create marshaller.
*
* @return Binary marshaller.
* @throws Exception If failed.
*/
protected BinaryMarshaller createMarshaller() throws Exception {
BinaryContext ctx = new BinaryContext(BinaryCachingMetadataHandler.create(), new IgniteConfiguration(), new NullLogger());
BinaryMarshaller marsh = new BinaryMarshaller();
BinaryConfiguration bCfg = new BinaryConfiguration();
bCfg.setCompactFooter(compactFooter());
bCfg.setTypeConfigurations(Arrays.asList(new BinaryTypeConfiguration(TestObject.class.getName()), new BinaryTypeConfiguration(TestOuterObject.class.getName()), new BinaryTypeConfiguration(TestInnerObject.class.getName())));
IgniteConfiguration iCfg = new IgniteConfiguration();
iCfg.setBinaryConfiguration(bCfg);
marsh.setContext(new MarshallerContextTestImpl(null));
IgniteUtils.invoke(BinaryMarshaller.class, marsh, "setBinaryContext", ctx, iCfg);
return marsh;
}
use of org.apache.ignite.marshaller.MarshallerContextTestImpl in project ignite by apache.
the class BinaryMarshallerSelfTest method testDeclaredBodyEnum.
/**
* @throws Exception If failed.
*/
public void testDeclaredBodyEnum() throws Exception {
final MarshallerContextTestImpl ctx = new MarshallerContextTestImpl();
ctx.registerClassName((byte) 0, 1, EnumObject.class.getName());
ctx.registerClassName((byte) 0, 2, DeclaredBodyEnum.class.getName());
BinaryMarshaller marsh = binaryMarshaller();
marsh.setContext(ctx);
EnumObject obj = new EnumObject(1L, "test 1", DeclaredBodyEnum.TWO);
final byte[] marshal = marsh.marshal(obj);
final Object restored = marsh.unmarshal(marshal, null);
assertTrue(restored instanceof EnumObject);
obj = (EnumObject) restored;
assertEquals(1, obj.id);
assertEquals(DeclaredBodyEnum.TWO.ordinal(), obj.type.ordinal());
assertEquals(DeclaredBodyEnum.TWO, obj.type);
assertTrue(obj.type == DeclaredBodyEnum.TWO);
}
Aggregations