java类javax.management.openmbean.SimpleType的实例源码

ExpressionTypeConverterUnitTestCase.java 文件源码 项目:wildfly-core 阅读 21 收藏 0 点赞 0 评论 0
@Test
public void testJsonObjectInComplexValue() throws Exception {
    ModelNode description = createDescription(ModelType.OBJECT);
    ModelNode complexValueType = new ModelNode();
    complexValueType.get("value", DESCRIPTION).set("A  value");
    complexValueType.get("value", TYPE).set(ModelType.OBJECT);
    description.get(VALUE_TYPE).set(complexValueType);

    TypeConverter converter = getConverter(description);

    CompositeType type = assertCast(CompositeType.class, converter.getOpenType());
    Set<String> keys = type.keySet();
    Assert.assertEquals(1, keys.size());

    Assert.assertEquals(SimpleType.STRING, type.getType("value"));

    ModelNode node = new ModelNode();
    node.get("value", "long").set(1L);
    node.get("value", "string").set("test");

    CompositeData data = assertCast(CompositeData.class, converter.fromModelNode(node));
    Assert.assertEquals(type, data.getCompositeType());
    Assert.assertEquals(ModelNode.fromJSONString(node.toJSONString(false)), converter.toModelNode(data));

}
MemoryNotificationInfoTest.java 文件源码 项目:cn1 阅读 21 收藏 0 点赞 0 评论 0
public void test_from_scenario13() throws Exception {
    String[] names = { "poolName", "usage", "count", "extention" };
    Object[] values = { "TestPoolName", memoryCompositeData, new Long(42),
            "Extention" };
    OpenType[] types = { SimpleType.STRING, memoryUsageCompositeType,
            SimpleType.LONG, SimpleType.STRING };

    CompositeType compositeType = getCompositeType(names, types);
    CompositeData data = new CompositeDataSupport(compositeType, names,
            values);
    MemoryNotificationInfo info = MemoryNotificationInfo.from(data);
    assertEquals(values[0], info.getPoolName());
    assertEquals(values[2], info.getCount());
    MemoryUsage usage = info.getUsage();
    assertEquals(1, usage.getInit());
    assertEquals(2, usage.getUsed());
    assertEquals(3, usage.getCommitted());
    assertEquals(4, usage.getMax());
}
ThreadInfoTest.java 文件源码 项目:cn1 阅读 18 收藏 0 点赞 0 评论 0
private static CompositeType createGoodStackTraceElementCompositeType() {
    CompositeType result = null;
    String[] typeNames = { "className", "methodName", "fileName",
            "lineNumber", "nativeMethod" };
    String[] typeDescs = { "className", "methodName", "fileName",
            "lineNumber", "nativeMethod" };
    OpenType[] typeTypes = { SimpleType.STRING, SimpleType.STRING,
            SimpleType.STRING, SimpleType.INTEGER, SimpleType.BOOLEAN };
    try {
        result = new CompositeType(StackTraceElement.class.getName(),
                StackTraceElement.class.getName(), typeNames, typeDescs,
                typeTypes);
    } catch (OpenDataException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return result;
}
ThreadInfoTest.java 文件源码 项目:cn1 阅读 18 收藏 0 点赞 0 评论 0
public void test_from_scenario2() throws Exception {
    initialValues[0] = "1";
    ArrayType stackTraceArray = new ArrayType(1, stackTraceElementType);
    OpenType[] types = { SimpleType.STRING, SimpleType.STRING,
            SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN,
            SimpleType.LONG, SimpleType.LONG, SimpleType.LONG,
            SimpleType.LONG, SimpleType.STRING, SimpleType.LONG,
            SimpleType.STRING, stackTraceArray, SimpleType.STRING };
    CompositeType compositeType = getCompositeType(initialNames, types);
    CompositeData data = new CompositeDataSupport(compositeType,
            initialNames, initialValues);
    try {
        ThreadInfo.from(data);
        fail("should throw IllegalArgumentException");
    } catch (IllegalArgumentException e) {
        // Expected
    }
}
ThreadInfoTest.java 文件源码 项目:cn1 阅读 15 收藏 0 点赞 0 评论 0
public void test_from_scenario4() throws Exception {
    initialValues[0] = null;
    ArrayType stackTraceArray = new ArrayType(1, stackTraceElementType);
    OpenType[] types = { SimpleType.LONG, SimpleType.STRING,
            SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN,
            SimpleType.LONG, SimpleType.LONG, SimpleType.LONG,
            SimpleType.LONG, SimpleType.STRING, SimpleType.LONG,
            SimpleType.STRING, stackTraceArray, SimpleType.STRING };
    CompositeType compositeType = getCompositeType(initialNames, types);
    CompositeData data = new CompositeDataSupport(compositeType,
            initialNames, initialValues);
    try {
        ThreadInfo.from(data);
        fail("should throw NullPointerException");
    } catch (NullPointerException e) {
        // Expected
    }
}
ThreadInfoTest.java 文件源码 项目:cn1 阅读 57 收藏 0 点赞 0 评论 0
public void test_from_scenario5() throws Exception {
    initialValues[1] = null;
    ArrayType stackTraceArray = new ArrayType(1, stackTraceElementType);
    OpenType[] types = { SimpleType.LONG, SimpleType.STRING,
            SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN,
            SimpleType.LONG, SimpleType.LONG, SimpleType.LONG,
            SimpleType.LONG, SimpleType.STRING, SimpleType.LONG,
            SimpleType.STRING, stackTraceArray, SimpleType.STRING };
    CompositeType compositeType = getCompositeType(initialNames, types);
    CompositeData data = new CompositeDataSupport(compositeType,
            initialNames, initialValues);
    try {
        ThreadInfo.from(data);
        fail("should throw IllegalArgumentException");
    } catch (IllegalArgumentException e) {
        // Expected
    }
}
ThreadInfoTest.java 文件源码 项目:cn1 阅读 18 收藏 0 点赞 0 评论 0
public void test_from_scenario6() throws Exception {
    initialValues[2] = null;
    ArrayType stackTraceArray = new ArrayType(1, stackTraceElementType);
    OpenType[] types = { SimpleType.LONG, SimpleType.STRING,
            SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN,
            SimpleType.LONG, SimpleType.LONG, SimpleType.LONG,
            SimpleType.LONG, SimpleType.STRING, SimpleType.LONG,
            SimpleType.STRING, stackTraceArray, SimpleType.STRING };
    CompositeType compositeType = getCompositeType(initialNames, types);
    CompositeData data = new CompositeDataSupport(compositeType,
            initialNames, initialValues);
    try {
        ThreadInfo.from(data);
        fail("should throw NullPointerException");
    } catch (NullPointerException e) {
        // Expected
    }
}
ThreadInfoTest.java 文件源码 项目:cn1 阅读 21 收藏 0 点赞 0 评论 0
public void test_from_scenario8() throws Exception {
    initialValues[4] = null;
    ArrayType stackTraceArray = new ArrayType(1, stackTraceElementType);
    OpenType[] types = { SimpleType.LONG, SimpleType.STRING,
            SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN,
            SimpleType.LONG, SimpleType.LONG, SimpleType.LONG,
            SimpleType.LONG, SimpleType.STRING, SimpleType.LONG,
            SimpleType.STRING, stackTraceArray, SimpleType.STRING };
    CompositeType compositeType = getCompositeType(initialNames, types);
    CompositeData data = new CompositeDataSupport(compositeType,
            initialNames, initialValues);
    try {
        ThreadInfo.from(data);
        fail("should throw NullPointerException");
    } catch (NullPointerException e) {
        // Expected
    }
}
ThreadInfoTest.java 文件源码 项目:cn1 阅读 23 收藏 0 点赞 0 评论 0
public void test_from_scenario9() throws Exception {
    initialValues[5] = null;
    ArrayType stackTraceArray = new ArrayType(1, stackTraceElementType);
    OpenType[] types = { SimpleType.LONG, SimpleType.STRING,
            SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN,
            SimpleType.LONG, SimpleType.LONG, SimpleType.LONG,
            SimpleType.LONG, SimpleType.STRING, SimpleType.LONG,
            SimpleType.STRING, stackTraceArray, SimpleType.STRING };
    CompositeType compositeType = getCompositeType(initialNames, types);
    CompositeData data = new CompositeDataSupport(compositeType,
            initialNames, initialValues);
    try {
        ThreadInfo.from(data);
        fail("should throw NullPointerException");
    } catch (NullPointerException e) {
        // Expected
    }
}
ThreadInfoTest.java 文件源码 项目:cn1 阅读 21 收藏 0 点赞 0 评论 0
public void test_from_scenario10() throws Exception {
    initialValues[6] = null;
    ArrayType stackTraceArray = new ArrayType(1, stackTraceElementType);
    OpenType[] types = { SimpleType.LONG, SimpleType.STRING,
            SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN,
            SimpleType.LONG, SimpleType.LONG, SimpleType.LONG,
            SimpleType.LONG, SimpleType.STRING, SimpleType.LONG,
            SimpleType.STRING, stackTraceArray, SimpleType.STRING };
    CompositeType compositeType = getCompositeType(initialNames, types);
    CompositeData data = new CompositeDataSupport(compositeType,
            initialNames, initialValues);
    try {
        ThreadInfo.from(data);
        fail("should throw NullPointerException");
    } catch (NullPointerException e) {
        // Expected
    }
}


问题


面经


文章

微信
公众号

扫码关注公众号