Search in sources :

Example 1 with BinaryMetadataView

use of org.apache.ignite.spi.systemview.view.BinaryMetadataView in project ignite by apache.

the class SystemViewSelfTest method testBinaryMeta.

/**
 */
@Test
public void testBinaryMeta() throws Exception {
    try (IgniteEx g = startGrid(0)) {
        IgniteCache<Integer, TestObjectAllTypes> c1 = g.createCache("test-cache");
        IgniteCache<Integer, TestObjectEnum> c2 = g.createCache("test-enum-cache");
        c1.put(1, new TestObjectAllTypes());
        c2.put(1, TestObjectEnum.A);
        SystemView<BinaryMetadataView> view = g.context().systemView().view(BINARY_METADATA_VIEW);
        assertNotNull(view);
        assertEquals(2, view.size());
        for (BinaryMetadataView meta : view) {
            if (TestObjectEnum.class.getName().contains(meta.typeName())) {
                assertTrue(meta.isEnum());
                assertEquals(0, meta.fieldsCount());
            } else {
                assertFalse(meta.isEnum());
                Field[] fields = TestObjectAllTypes.class.getDeclaredFields();
                assertEquals(fields.length, meta.fieldsCount());
                for (Field field : fields) assertTrue(meta.fields().contains(field.getName()));
            }
        }
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Field(java.lang.reflect.Field) TestObjectEnum(org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses.TestObjectEnum) IgniteEx(org.apache.ignite.internal.IgniteEx) BinaryMetadataView(org.apache.ignite.spi.systemview.view.BinaryMetadataView) TestObjectAllTypes(org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses.TestObjectAllTypes) Test(org.junit.Test) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)

Aggregations

Field (java.lang.reflect.Field)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 IgniteEx (org.apache.ignite.internal.IgniteEx)1 TestObjectAllTypes (org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses.TestObjectAllTypes)1 TestObjectEnum (org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses.TestObjectEnum)1 BinaryMetadataView (org.apache.ignite.spi.systemview.view.BinaryMetadataView)1 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)1 Test (org.junit.Test)1