Search in sources :

Example 1 with TestObjectEnum

use of org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses.TestObjectEnum 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)

Example 2 with TestObjectEnum

use of org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses.TestObjectEnum in project ignite by apache.

the class SystemViewCommandTest method testBinaryMeta.

/**
 */
@Test
public void testBinaryMeta() {
    IgniteCache<Integer, TestObjectAllTypes> c1 = ignite0.createCache("test-cache");
    IgniteCache<Integer, TestObjectEnum> c2 = ignite0.createCache("test-enum-cache");
    executeSql(ignite0, "CREATE TABLE T1(ID LONG PRIMARY KEY, NAME VARCHAR(40), ACCOUNT BIGINT)");
    executeSql(ignite0, "INSERT INTO T1(ID, NAME, ACCOUNT) VALUES(1, 'test', 1)");
    c1.put(1, new TestObjectAllTypes());
    c2.put(1, TestObjectEnum.A);
    List<List<String>> binaryMetaView = systemView(ignite0, BINARY_METADATA_VIEW);
    assertEquals(3, binaryMetaView.size());
    for (List<String> row : binaryMetaView) {
        if (Objects.equals(TestObjectEnum.class.getName(), row.get(1))) {
            assertTrue(Boolean.parseBoolean(row.get(6)));
            assertEquals("0", row.get(3));
        } else if (Objects.equals(TestObjectAllTypes.class.getName(), row.get(1))) {
            assertFalse(Boolean.parseBoolean(row.get(6)));
            Field[] fields = TestObjectAllTypes.class.getDeclaredFields();
            assertEquals(Integer.toString(fields.length), row.get(3));
            for (Field field : fields) assertTrue(row.get(4).contains(field.getName()));
        } else {
            assertFalse(Boolean.parseBoolean(row.get(6)));
            assertEquals("2", row.get(3));
            assertTrue(row.get(4).contains("NAME"));
            assertTrue(row.get(4).contains("ACCOUNT"));
        }
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Field(java.lang.reflect.Field) TestObjectEnum(org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses.TestObjectEnum) Arrays.asList(java.util.Arrays.asList) ArrayList(java.util.ArrayList) CommandList(org.apache.ignite.internal.commandline.CommandList) List(java.util.List) TestObjectAllTypes(org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses.TestObjectAllTypes) Test(org.junit.Test)

Example 3 with TestObjectEnum

use of org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses.TestObjectEnum in project ignite by apache.

the class SqlViewExporterSpiTest method testBinaryMeta.

/**
 */
@Test
public void testBinaryMeta() {
    IgniteCache<Integer, TestObjectAllTypes> c1 = ignite0.createCache("test-cache");
    IgniteCache<Integer, TestObjectEnum> c2 = ignite0.createCache("test-enum-cache");
    execute(ignite0, "CREATE TABLE T1(ID LONG PRIMARY KEY, NAME VARCHAR(40), ACCOUNT BIGINT)");
    execute(ignite0, "INSERT INTO T1(ID, NAME, ACCOUNT) VALUES(1, 'test', 1)");
    c1.put(1, new TestObjectAllTypes());
    c2.put(1, TestObjectEnum.A);
    List<List<?>> view = execute(ignite0, "SELECT TYPE_NAME, FIELDS_COUNT, FIELDS, IS_ENUM FROM SYS.BINARY_METADATA");
    assertNotNull(view);
    assertEquals(3, view.size());
    for (List<?> meta : view) {
        if (TestObjectEnum.class.getName().contains(meta.get(0).toString())) {
            assertTrue((Boolean) meta.get(3));
            assertEquals(0, meta.get(1));
        } else if (TestObjectAllTypes.class.getName().contains(meta.get(0).toString())) {
            assertFalse((Boolean) meta.get(3));
            Field[] fields = TestObjectAllTypes.class.getDeclaredFields();
            assertEquals(fields.length, meta.get(1));
            for (Field field : fields) assertTrue(meta.get(2).toString().contains(field.getName()));
        } else {
            assertFalse((Boolean) meta.get(3));
            assertEquals(2, meta.get(1));
            assertTrue(meta.get(2).toString().contains("NAME"));
            assertTrue(meta.get(2).toString().contains("ACCOUNT"));
        }
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Field(java.lang.reflect.Field) TestObjectEnum(org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses.TestObjectEnum) Arrays.asList(java.util.Arrays.asList) List(java.util.List) ArrayList(java.util.ArrayList) TestObjectAllTypes(org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses.TestObjectAllTypes) AbstractExporterSpiTest(org.apache.ignite.internal.metric.AbstractExporterSpiTest) Test(org.junit.Test)

Example 4 with TestObjectEnum

use of org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses.TestObjectEnum in project ignite by apache.

the class JmxExporterSpiTest method testBinaryMeta.

/**
 */
@Test
public void testBinaryMeta() {
    IgniteCache<Integer, TestObjectAllTypes> c1 = ignite.createCache("test-all-types-cache");
    IgniteCache<Integer, TestObjectEnum> c2 = ignite.createCache("test-enum-cache");
    c1.put(1, new TestObjectAllTypes());
    c2.put(1, TestObjectEnum.A);
    TabularDataSupport view = systemView(BINARY_METADATA_VIEW);
    assertNotNull(view);
    assertEquals(2, view.size());
    for (int i = 0; i < 2; i++) {
        CompositeData meta = view.get(new Object[] { i });
        if (Objects.equals(TestObjectEnum.class.getName(), meta.get("typeName"))) {
            assertTrue((Boolean) meta.get("isEnum"));
            assertEquals(0, meta.get("fieldsCount"));
        } else {
            assertFalse((Boolean) meta.get("isEnum"));
            Field[] fields = TestObjectAllTypes.class.getDeclaredFields();
            assertEquals(fields.length, meta.get("fieldsCount"));
            for (Field field : fields) assertTrue(meta.get("fields").toString().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) TabularDataSupport(javax.management.openmbean.TabularDataSupport) CompositeData(javax.management.openmbean.CompositeData) TestObjectAllTypes(org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses.TestObjectAllTypes) Test(org.junit.Test)

Aggregations

Field (java.lang.reflect.Field)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 TestObjectAllTypes (org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses.TestObjectAllTypes)4 TestObjectEnum (org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses.TestObjectEnum)4 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)2 Arrays.asList (java.util.Arrays.asList)2 List (java.util.List)2 CompositeData (javax.management.openmbean.CompositeData)1 TabularDataSupport (javax.management.openmbean.TabularDataSupport)1 IgniteEx (org.apache.ignite.internal.IgniteEx)1 CommandList (org.apache.ignite.internal.commandline.CommandList)1 AbstractExporterSpiTest (org.apache.ignite.internal.metric.AbstractExporterSpiTest)1 BinaryMetadataView (org.apache.ignite.spi.systemview.view.BinaryMetadataView)1 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)1