use of org.apache.ignite.internal.MarshallerContextImpl in project ignite by apache.
the class MarshallerContextSelfTest method testOnUpdated.
/**
* @throws Exception If failed.
*/
public void testOnUpdated() throws Exception {
File workDir = U.resolveWorkDirectory(U.defaultWorkDirectory(), "marshaller", false);
MarshallerContextImpl ctx = new MarshallerContextImpl(null);
ctx.onMarshallerProcessorStarted(this.ctx, null);
MarshallerMappingItem item1 = new MarshallerMappingItem(JAVA_ID, 1, String.class.getName());
ctx.onMappingAccepted(item1);
// Wait until marshaller context write class to file.
U.sleep(2_000);
checkFileName("java.lang.String", Paths.get(workDir + "/1.classname0"));
MarshallerMappingItem item2 = new MarshallerMappingItem((byte) 2, 2, "Random.Class.Name");
ctx.onMappingProposed(item2);
ctx.onMappingAccepted(item2);
execSvc.shutdown();
if (execSvc.awaitTermination(1000, TimeUnit.MILLISECONDS))
checkFileName("Random.Class.Name", Paths.get(workDir + "/2.classname2"));
else
fail("Failed to wait for executor service to shutdown");
}
use of org.apache.ignite.internal.MarshallerContextImpl in project ignite by apache.
the class MarshallerContextSelfTest method testMultiplatformMappingsCollecting.
/**
* Test for adding non-java mappings (with platformId > 0) to MarshallerContext and collecting them
* for discovery.
*
* @throws Exception If failed.
*/
public void testMultiplatformMappingsCollecting() throws Exception {
String nonJavaClassName = "random.platform.Mapping";
MarshallerContextImpl marshCtx = new MarshallerContextImpl(null);
marshCtx.onMarshallerProcessorStarted(ctx, null);
MarshallerMappingItem item = new MarshallerMappingItem((byte) 2, 101, nonJavaClassName);
marshCtx.onMappingProposed(item);
marshCtx.onMappingAccepted(item);
ArrayList<Map<Integer, MappedName>> allMappings = marshCtx.getCachedMappings();
assertEquals(allMappings.size(), 3);
assertTrue(allMappings.get(0).isEmpty());
assertTrue(allMappings.get(1).isEmpty());
Map<Integer, MappedName> nonJavaMappings = allMappings.get(2);
assertNotNull(nonJavaMappings);
assertNotNull(nonJavaMappings.get(101));
assertEquals(nonJavaClassName, nonJavaMappings.get(101).className());
}
Aggregations