use of org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses.TestObjectAllTypes 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()));
}
}
}
}
use of org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses.TestObjectAllTypes 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"));
}
}
}
use of org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses.TestObjectAllTypes 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"));
}
}
}
use of org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses.TestObjectAllTypes 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()));
}
}
}
Aggregations