Search in sources :

Example 1 with SerializerCreation

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();
    }
}
Also used : IgnoredException(org.apache.geode.test.dunit.IgnoredException) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation) ClientCacheCreation(org.apache.geode.internal.cache.xmlcache.ClientCacheCreation) SerializerCreation(org.apache.geode.internal.cache.xmlcache.SerializerCreation) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) CacheException(org.apache.geode.cache.CacheException) RegionExistsException(org.apache.geode.cache.RegionExistsException) CacheXmlException(org.apache.geode.cache.CacheXmlException) SAXException(org.xml.sax.SAXException) IgnoredException(org.apache.geode.test.dunit.IgnoredException) CacheLoaderException(org.apache.geode.cache.CacheLoaderException) Test(org.junit.Test)

Aggregations

IOException (java.io.IOException)1 UnknownHostException (java.net.UnknownHostException)1 CacheException (org.apache.geode.cache.CacheException)1 CacheLoaderException (org.apache.geode.cache.CacheLoaderException)1 CacheXmlException (org.apache.geode.cache.CacheXmlException)1 RegionExistsException (org.apache.geode.cache.RegionExistsException)1 CacheCreation (org.apache.geode.internal.cache.xmlcache.CacheCreation)1 ClientCacheCreation (org.apache.geode.internal.cache.xmlcache.ClientCacheCreation)1 SerializerCreation (org.apache.geode.internal.cache.xmlcache.SerializerCreation)1 IgnoredException (org.apache.geode.test.dunit.IgnoredException)1 Test (org.junit.Test)1 SAXException (org.xml.sax.SAXException)1