use of org.apache.geode.internal.cache.xmlcache.SerializerCreation in project geode by apache.
the class CacheXml66DUnitTest method testSerializationRegistration.
@Test
public void testSerializationRegistration() throws Exception {
CacheCreation cc = new CacheCreation();
SerializerCreation sc = new SerializerCreation();
cc.setSerializerCreation(sc);
sc.registerInstantiator(DS1.class, 15);
sc.registerInstantiator(DS2.class, 16);
sc.registerSerializer(GoodSerializer.class);
testXml(cc);
// Now make sure all of the classes were registered....
assertEquals(15, InternalInstantiator.getClassId(DS1.class));
assertEquals(16, InternalInstantiator.getClassId(DS2.class));
assertEquals(GoodSerializer.class, InternalDataSerializer.getSerializer(101).getClass());
sc = new SerializerCreation();
sc.registerInstantiator(NotDataSerializable.class, 15);
closeCache();
cc.setSerializerCreation(sc);
IgnoredException expectedException = IgnoredException.addIgnoredException("While reading Cache XML file");
try {
testXml(cc);
fail("Instantiator should not have registered due to bad class.");
} catch (Exception e) {
} finally {
expectedException.remove();
}
sc = new SerializerCreation();
sc.registerSerializer(BadSerializer.class);
closeCache();
cc.setSerializerCreation(sc);
IgnoredException expectedException1 = IgnoredException.addIgnoredException("While reading Cache XML file");
try {
testXml(cc);
fail("Serializer should not have registered due to bad class.");
} catch (Exception e) {
} finally {
expectedException1.remove();
}
}
Aggregations