private static void compareTabularType(TabularType t1, TabularType t2) {
if (t1.equals(t2)) {
System.out.println("same tabular type");
return;
}
if (t1.getClassName().equals(t2.getClassName()))
System.out.println("same class name");
if (t1.getDescription().equals(t2.getDescription()))
System.out.println("same description");
else {
System.out.println("t1 description: " + t1.getDescription());
System.out.println("t2 description: " + t2.getDescription());
}
if (t1.getIndexNames().equals(t2.getIndexNames()))
System.out.println("same index names");
if (t1.getRowType().equals(t2.getRowType()))
System.out.println("same row type");
}
java类javax.management.openmbean.TabularType的实例源码
MXBeanTest.java 文件源码
项目:OLD-OpenJDK8
阅读 78
收藏 0
点赞 0
评论 0
ExpressionTypeConverterUnitTestCase.java 文件源码
项目:wildfly-core
阅读 28
收藏 0
点赞 0
评论 0
@Test
public void testSimpleTypeObject() throws Exception {
ModelNode description = createDescription(ModelType.OBJECT, ModelType.LONG);
TypeConverter converter = getConverter(description);
assertMapType(assertCast(TabularType.class, converter.getOpenType()), SimpleType.STRING, SimpleType.STRING);
ModelNode node = new ModelNode();
node.get("one").set(1L);
node.get("two").set(2L);
TabularData tabularData = assertCast(TabularData.class, converter.fromModelNode(node));
Assert.assertEquals(2, tabularData.size());
Assert.assertEquals("1", tabularData.get(new Object[] {"one"}).get("value"));
Assert.assertEquals("2", tabularData.get(new Object[] {"two"}).get("value"));
Assert.assertEquals(node, converter.toModelNode(tabularData));
//Allow plain map as well? Yeah why not!
Map<String, String> map = new HashMap<String, String>();
map.put("one", "1");
map.put("two", "2");
Assert.assertEquals(node, converter.toModelNode(map));
}
ExpressionTypeConverterUnitTestCase.java 文件源码
项目:wildfly-core
阅读 27
收藏 0
点赞 0
评论 0
@Test
public void testByteArrayObject() throws Exception {
ModelNode description = createDescription(ModelType.OBJECT, ModelType.BYTES);
TypeConverter converter = getConverter(description);
assertMapType(assertCast(TabularType.class, converter.getOpenType()), SimpleType.STRING, ArrayType.getPrimitiveArrayType(byte[].class));
ModelNode node = new ModelNode();
node.get("one").set(new byte[] {1,2});
node.get("two").set(new byte[] {3,4});
TabularData tabularData = assertCast(TabularData.class, converter.fromModelNode(node));
Assert.assertEquals(2, tabularData.size());
Assert.assertTrue(Arrays.equals(new byte[] {1,2}, (byte[])tabularData.get(new Object[] {"one"}).get("value")));
Assert.assertTrue(Arrays.equals(new byte[] {3,4}, (byte[])tabularData.get(new Object[] {"two"}).get("value")));
//Allow plain map as well? Yeah why not!
Map<String, byte[]> map = new HashMap<String, byte[]>();
map.put("one", new byte[] {1,2});
map.put("two", new byte[] {3,4});
Assert.assertEquals(node, converter.toModelNode(map));
}
ExpressionTypeConverterUnitTestCase.java 文件源码
项目:wildfly-core
阅读 26
收藏 0
点赞 0
评论 0
@Test
public void testSimpleTypeObjectExpressions() throws Exception {
ModelNode description = createDescription(ModelType.OBJECT, ModelType.LONG);
description.get(EXPRESSIONS_ALLOWED).set(true);
TypeConverter converter = getConverter(description);
assertMapType(assertCast(TabularType.class, converter.getOpenType()), SimpleType.STRING, SimpleType.STRING);
ModelNode node = new ModelNode();
node.get("one").set(new ValueExpression("${this.should.not.exist.!!!!!:1}"));
node.get("two").set(new ValueExpression("${this.should.not.exist.!!!!!:2}"));
TabularData tabularData = assertCast(TabularData.class, converter.fromModelNode(node));
Assert.assertEquals(2, tabularData.size());
Assert.assertEquals("${this.should.not.exist.!!!!!:1}", tabularData.get(new Object[] {"one"}).get("value"));
Assert.assertEquals("${this.should.not.exist.!!!!!:2}", tabularData.get(new Object[] {"two"}).get("value"));
Assert.assertEquals(node, converter.toModelNode(tabularData));
}
ExpressionTypeConverterUnitTestCase.java 文件源码
项目:wildfly-core
阅读 24
收藏 0
点赞 0
评论 0
@Test
public void testSimpleTypeObjectEmpty() throws Exception {
ModelNode description = createDescription(ModelType.OBJECT, ModelType.LONG);
TypeConverter converter = getConverter(description);
assertMapType(assertCast(TabularType.class, converter.getOpenType()), SimpleType.STRING, SimpleType.STRING);
ModelNode node = new ModelNode();
node.get("one").set("");
node.get("two").set("");
TabularData tabularData = assertCast(TabularData.class, converter.fromModelNode(node));
Assert.assertEquals(2, tabularData.size());
Assert.assertNull(tabularData.get(new Object[] {"one"}).get("value"));
Assert.assertNull(tabularData.get(new Object[] {"two"}).get("value"));
ModelNode expected = new ModelNode();
expected.get("one");
expected.get("two");
Assert.assertEquals(expected, converter.toModelNode(tabularData));
}
LegacyTypeConverterUnitTestCase.java 文件源码
项目:wildfly-core
阅读 25
收藏 0
点赞 0
评论 0
@Test
public void testSimpleTypeObject() throws Exception {
ModelNode description = createDescription(ModelType.OBJECT, ModelType.LONG);
TypeConverter converter = getConverter(description);
assertMapType(assertCast(TabularType.class, converter.getOpenType()), SimpleType.STRING, SimpleType.LONG);
ModelNode node = new ModelNode();
node.get("one").set(1L);
node.get("two").set(2L);
TabularData tabularData = assertCast(TabularData.class, converter.fromModelNode(node));
Assert.assertEquals(2, tabularData.size());
Assert.assertEquals((long) 1, tabularData.get(new Object[] {"one"}).get("value"));
Assert.assertEquals((long) 2, tabularData.get(new Object[] {"two"}).get("value"));
Assert.assertEquals(node, converter.toModelNode(tabularData));
//Allow plain map as well? Yeah why not!
Map<String, Long> map = new HashMap<String, Long>();
map.put("one", 1L);
map.put("two", 2L);
Assert.assertEquals(node, converter.toModelNode(map));
}
LegacyTypeConverterUnitTestCase.java 文件源码
项目:wildfly-core
阅读 23
收藏 0
点赞 0
评论 0
@Test
public void testByteArrayObject() throws Exception {
ModelNode description = createDescription(ModelType.OBJECT, ModelType.BYTES);
TypeConverter converter = getConverter(description);
assertMapType(assertCast(TabularType.class, converter.getOpenType()), SimpleType.STRING, ArrayType.getPrimitiveArrayType(byte[].class));
ModelNode node = new ModelNode();
node.get("one").set(new byte[] {1,2});
node.get("two").set(new byte[] {3,4});
TabularData tabularData = assertCast(TabularData.class, converter.fromModelNode(node));
Assert.assertEquals(2, tabularData.size());
Assert.assertTrue(Arrays.equals(new byte[] {1,2}, (byte[])tabularData.get(new Object[] {"one"}).get("value")));
Assert.assertTrue(Arrays.equals(new byte[] {3,4}, (byte[])tabularData.get(new Object[] {"two"}).get("value")));
//Allow plain map as well? Yeah why not!
Map<String, byte[]> map = new HashMap<String, byte[]>();
map.put("one", new byte[] {1,2});
map.put("two", new byte[] {3,4});
Assert.assertEquals(node, converter.toModelNode(map));
}
LegacyTypeConverterUnitTestCase.java 文件源码
项目:wildfly-core
阅读 27
收藏 0
点赞 0
评论 0
@Test
public void testSimpleTypeObjectExpressions() throws Exception {
ModelNode description = createDescription(ModelType.OBJECT, ModelType.LONG);
description.get(EXPRESSIONS_ALLOWED).set(true);
TypeConverter converter = getConverter(description);
assertMapType(assertCast(TabularType.class, converter.getOpenType()), SimpleType.STRING, SimpleType.LONG);
ModelNode node = new ModelNode();
node.get("one").set(new ValueExpression("${this.should.not.exist.!!!!!:1}"));
node.get("two").set(new ValueExpression("${this.should.not.exist.!!!!!:2}"));
TabularData tabularData = assertCast(TabularData.class, converter.fromModelNode(node));
Assert.assertEquals(2, tabularData.size());
Assert.assertEquals((long) 1, tabularData.get(new Object[] {"one"}).get("value"));
Assert.assertEquals((long) 2, tabularData.get(new Object[] {"two"}).get("value"));
}
LegacyTypeConverterUnitTestCase.java 文件源码
项目:wildfly-core
阅读 23
收藏 0
点赞 0
评论 0
@Test
public void testSimpleTypeObjectEmpty() throws Exception {
ModelNode description = createDescription(ModelType.OBJECT, ModelType.LONG);
TypeConverter converter = getConverter(description);
assertMapType(assertCast(TabularType.class, converter.getOpenType()), SimpleType.STRING, SimpleType.LONG);
ModelNode node = new ModelNode();
node.get("one").set("");
node.get("two").set("");
TabularData tabularData = assertCast(TabularData.class, converter.fromModelNode(node));
Assert.assertEquals(2, tabularData.size());
Assert.assertNull(tabularData.get(new Object[] {"one"}).get("value"));
Assert.assertNull(tabularData.get(new Object[] {"two"}).get("value"));
ModelNode expected = new ModelNode();
expected.get("one");
expected.get("two");
Assert.assertEquals(expected, converter.toModelNode(tabularData));
}
MXBeanTest.java 文件源码
项目:JAVA_UNIT
阅读 28
收藏 0
点赞 0
评论 0
private static void compareTabularType(TabularType t1, TabularType t2) {
if (t1.equals(t2)) {
System.out.println("same tabular type");
return;
}
if (t1.getClassName().equals(t2.getClassName()))
System.out.println("same class name");
if (t1.getDescription().equals(t2.getDescription()))
System.out.println("same description");
else {
System.out.println("t1 description: " + t1.getDescription());
System.out.println("t2 description: " + t2.getDescription());
}
if (t1.getIndexNames().equals(t2.getIndexNames()))
System.out.println("same index names");
if (t1.getRowType().equals(t2.getRowType()))
System.out.println("same row type");
}