Search in sources :

Example 1 with PdxInstanceEnumInfo

use of org.apache.geode.pdx.internal.EnumInfo.PdxInstanceEnumInfo in project geode by apache.

the class PdxInstanceJUnitTest method testPdxComplexEnum.

public void testPdxComplexEnum() {
    PdxInstanceFactory c = PdxInstanceFactoryImpl.newCreator("testPdxEnum", false);
    c.writeObject("enumField", MyComplexEnum.ONE);
    PdxInstance pi = c.create();
    Object f = pi.getField("enumField");
    if (f instanceof PdxInstanceEnumInfo) {
        PdxInstanceEnumInfo e = (PdxInstanceEnumInfo) f;
        assertEquals("ONE", e.getName());
        GemFireCacheImpl theCache = GemFireCacheImpl.getForPdx("PDX registry is unavailable because the Cache has been closed.");
        theCache.getPdxRegistry().flushCache();
        assertEquals(MyComplexEnum.ONE, e.getObject());
    } else {
        fail("Expected enumField to be a PdxInstanceEnumInfo but it was a " + f.getClass());
    }
}
Also used : PdxInstanceEnumInfo(org.apache.geode.pdx.internal.EnumInfo.PdxInstanceEnumInfo) GemFireCacheImpl(org.apache.geode.internal.cache.GemFireCacheImpl)

Example 2 with PdxInstanceEnumInfo

use of org.apache.geode.pdx.internal.EnumInfo.PdxInstanceEnumInfo in project geode by apache.

the class PdxInstanceJUnitTest method testPdxSimpleEnum.

public void testPdxSimpleEnum() {
    PdxInstanceFactory c = PdxInstanceFactoryImpl.newCreator("testPdxEnum", false);
    c.writeObject("enumField", MyEnum.ONE);
    PdxInstance pi = c.create();
    Object f = pi.getField("enumField");
    if (f instanceof PdxInstanceEnumInfo) {
        PdxInstanceEnumInfo e = (PdxInstanceEnumInfo) f;
        assertEquals("ONE", e.getName());
        GemFireCacheImpl theCache = GemFireCacheImpl.getForPdx("PDX registry is unavailable because the Cache has been closed.");
        theCache.getPdxRegistry().flushCache();
        assertEquals(MyEnum.ONE, e.getObject());
    } else {
        fail("Expected enumField to be a PdxInstanceEnumInfo but it was a " + f.getClass());
    }
}
Also used : PdxInstanceEnumInfo(org.apache.geode.pdx.internal.EnumInfo.PdxInstanceEnumInfo) GemFireCacheImpl(org.apache.geode.internal.cache.GemFireCacheImpl)

Aggregations

GemFireCacheImpl (org.apache.geode.internal.cache.GemFireCacheImpl)2 PdxInstanceEnumInfo (org.apache.geode.pdx.internal.EnumInfo.PdxInstanceEnumInfo)2