Java 类javax.management.openmbean.SimpleType 实例源码

项目:openjdk-jdk10    文件:TypeVersionMapper.java   
private ArrayType<?> getVersionedArrayType(ArrayType<?> type, String version)
    throws OpenDataException
{
    if (type.isPrimitiveArray()) {
        return type;
    }
    OpenType<?> ot = getVersionedType(
        type.getElementOpenType(),
        version
    );
    if (ot instanceof SimpleType) {
        return new ArrayType<>((SimpleType<?>)ot, type.isPrimitiveArray());
    } else {
        return new ArrayType<>(type.getDimension(), ot);
    }
}
项目:tqdev-metrics    文件:JmxReporter.java   
@Override
public MBeanInfo getMBeanInfo() {

    ArrayList<OpenMBeanAttributeInfoSupport> attributes = new ArrayList<>();

    attributes.add(new OpenMBeanAttributeInfoSupport("enabled", "enabled", SimpleType.BOOLEAN, true, true, true));
    for (String type : registry.getTypes()) {
        attributes.add(new OpenMBeanAttributeInfoSupport(type, type, getCompositeType(type), true, false, false));
    }

    OpenMBeanParameterInfo[] params = new OpenMBeanParameterInfoSupport[0];
    OpenMBeanOperationInfoSupport reset = new OpenMBeanOperationInfoSupport("reset", "Reset all Metrics", params,
            SimpleType.VOID, MBeanOperationInfo.ACTION);

    OpenMBeanInfoSupport PSOMBInfo = new OpenMBeanInfoSupport(this.getClass().getName(), description,
            attributes.toArray(new OpenMBeanAttributeInfoSupport[0]), new OpenMBeanConstructorInfoSupport[0],
            new OpenMBeanOperationInfoSupport[] { reset }, new MBeanNotificationInfo[0]);

    return PSOMBInfo;
}
项目:hashsdn-controller    文件:JavaAttribute.java   
private OpenType<?> getCompositeType(final Type baseType, final TypeDefinition<?> baseTypeDefinition) {

        final SimpleType<?> innerItemType = SimpleTypeResolver.getSimpleType(baseType);
        final String innerItemName = this.typeProviderWrapper.getJMXParamForBaseType(baseTypeDefinition);

        final String[] itemNames = new String[]{innerItemName};
        final String description = getNullableDescription() == null ? getAttributeYangName() : getNullableDescription();

        final OpenType<?>[] itemTypes = new OpenType[]{innerItemType};
        try {
            return new CompositeType(getUpperCaseCammelCase(), description, itemNames, itemNames, itemTypes);
        } catch (final OpenDataException e) {
            throw new RuntimeException("Unable to create " + CompositeType.class + " with inner element of type "
                    + itemTypes, e);
        }
    }
项目:openjdk9    文件:GarbageCollectionNotifInfoCompositeData.java   
private static synchronized CompositeType getBaseGcNotifInfoCompositeType() {
    if (baseGcNotifInfoCompositeType == null) {
        try {
            OpenType<?>[] baseGcNotifInfoItemTypes = new OpenType<?>[] {
                SimpleType.STRING,
                SimpleType.STRING,
                SimpleType.STRING,
                GcInfoCompositeData.getBaseGcInfoCompositeType()
            };
            baseGcNotifInfoCompositeType =
                new CompositeType("sun.management.BaseGarbageCollectionNotifInfoCompositeType",
                                  "CompositeType for Base GarbageCollectionNotificationInfo",
                                  gcNotifInfoItemNames,
                                  gcNotifInfoItemNames,
                                  baseGcNotifInfoItemTypes);
        } catch (OpenDataException e) {
            // shouldn't reach here
            throw new RuntimeException(e);
        }
    }
    return baseGcNotifInfoCompositeType;
}
项目:openjdk9    文件:TypeVersionMapper.java   
private ArrayType<?> getVersionedArrayType(ArrayType<?> type, String version)
    throws OpenDataException
{
    if (type.isPrimitiveArray()) {
        return type;
    }
    OpenType<?> ot = getVersionedType(
        type.getElementOpenType(),
        version
    );
    if (ot instanceof SimpleType) {
        return new ArrayType<>((SimpleType<?>)ot, type.isPrimitiveArray());
    } else {
        return new ArrayType<>(type.getDimension(), ot);
    }
}
项目:jdk8u_jdk    文件:GarbageCollectionNotifInfoCompositeData.java   
private static synchronized CompositeType getBaseGcNotifInfoCompositeType() {
    if (baseGcNotifInfoCompositeType == null) {
        try {
            OpenType<?>[] baseGcNotifInfoItemTypes = new OpenType<?>[] {
                SimpleType.STRING,
                SimpleType.STRING,
                SimpleType.STRING,
                GcInfoCompositeData.getBaseGcInfoCompositeType()
            };
            baseGcNotifInfoCompositeType =
                new CompositeType("sun.management.BaseGarbageCollectionNotifInfoCompositeType",
                                  "CompositeType for Base GarbageCollectionNotificationInfo",
                                  gcNotifInfoItemNames,
                                  gcNotifInfoItemNames,
                                  baseGcNotifInfoItemTypes);
        } catch (OpenDataException e) {
            // shouldn't reach here
            throw Util.newException(e);
        }
    }
    return baseGcNotifInfoCompositeType;
}
项目:lookaside_java-1.8.0-openjdk    文件:GarbageCollectionNotifInfoCompositeData.java   
private static synchronized CompositeType getBaseGcNotifInfoCompositeType() {
    if (baseGcNotifInfoCompositeType == null) {
        try {
            OpenType<?>[] baseGcNotifInfoItemTypes = new OpenType<?>[] {
                SimpleType.STRING,
                SimpleType.STRING,
                SimpleType.STRING,
                GcInfoCompositeData.getBaseGcInfoCompositeType()
            };
            baseGcNotifInfoCompositeType =
                new CompositeType("sun.management.BaseGarbageCollectionNotifInfoCompositeType",
                                  "CompositeType for Base GarbageCollectionNotificationInfo",
                                  gcNotifInfoItemNames,
                                  gcNotifInfoItemNames,
                                  baseGcNotifInfoItemTypes);
        } catch (OpenDataException e) {
            // shouldn't reach here
            throw Util.newException(e);
        }
    }
    return baseGcNotifInfoCompositeType;
}
项目:scylla-jmx    文件:FailureDetector.java   
@Override
public TabularData getPhiValues() throws OpenDataException {
    final CompositeType ct = new CompositeType("Node", "Node", new String[] { "Endpoint", "PHI" },
            new String[] { "IP of the endpoint", "PHI value" },
            new OpenType[] { SimpleType.STRING, SimpleType.DOUBLE });
    final TabularDataSupport results = new TabularDataSupport(
            new TabularType("PhiList", "PhiList", ct, new String[] { "Endpoint" }));
    final JsonArray arr = client.getJsonArray("/failure_detector/endpoint_phi_values");

    for (JsonValue v : arr) {
        JsonObject o = (JsonObject) v;
        String endpoint = o.getString("endpoint");
        double phi = Double.parseDouble(o.getString("phi"));

        if (phi != Double.MIN_VALUE) {
            // returned values are scaled by PHI_FACTOR so that the are on
            // the same scale as PhiConvictThreshold
            final CompositeData data = new CompositeDataSupport(ct, new String[] { "Endpoint", "PHI" },
                    new Object[] { endpoint, phi * PHI_FACTOR });
            results.put(data);
        }
    }

    return results;
}
项目:cacheonix-core    文件:HttpAdaptor.java   
public TestClass(String str, URL url)
{
   this.str = str;
   this.url = url;
   list.add("a");
   list.add("b");
   list.add("c");
   map.put("1", "a");
   map.put("2", "b");
   map.put("3", "c");
   try
   {
      CompositeType type = new CompositeType("My type",
                                             "My type",
                                             new String[]{"item1", "item2"},
                                             new String[]{"item1", "item2"},
                                             new OpenType[]{SimpleType.STRING, SimpleType.STRING});
      compositeData = new CompositeDataSupport(type, new String[]{"item1", "item2"}, new Object[]{"item value 1", "item value 2"});
   }
   catch (OpenDataException e)
   {
      e.printStackTrace();
   }

}
项目:parfait    文件:JmxView.java   
private OpenType<?> getJmxType(Class<?> type) {
    if (type == Boolean.class) {
        return SimpleType.BOOLEAN;
    } else if (type == Integer.class || type == AtomicInteger.class) {
        return SimpleType.INTEGER;
    } else if (type == Long.class || type == AtomicLong.class) {
        return SimpleType.LONG;
    } else if (type == Double.class) {
        return SimpleType.DOUBLE;
    } else if (type == String.class) {
        return SimpleType.STRING;
    } else {
        throw new UnsupportedOperationException(
                "Don't know how to process Monitorable of type [" + type + "]");
    }
}
项目:acs-aem-samples    文件:SampleContentReplicationHarnessImpl.java   
@Override
// MBean method
// @Description is set at the interface level
public final CompositeDataSupport getThrottleConfig() throws OpenDataException {

    final CompositeType throttleConfigurationType = new CompositeType(
            "Throttle Configuration",
            "Throttle Configuration",
            new String[]{"Throttle (in ms)", "Batch size"},
            new String[]{"Throttle (in ms)", "Batch size"},
            new OpenType[]{SimpleType.INTEGER, SimpleType.INTEGER}
    );

    final Map<String, Object> data = new HashMap<String, Object>();
    data.put("Throttle (in ms)", this.throttle.get());
    data.put("Batch size", this.batchSize.get());
    return new CompositeDataSupport(throttleConfigurationType, data);
}
项目:infobip-open-jdk-8    文件:GarbageCollectionNotifInfoCompositeData.java   
private static synchronized CompositeType getBaseGcNotifInfoCompositeType() {
    if (baseGcNotifInfoCompositeType == null) {
        try {
            OpenType<?>[] baseGcNotifInfoItemTypes = new OpenType<?>[] {
                SimpleType.STRING,
                SimpleType.STRING,
                SimpleType.STRING,
                GcInfoCompositeData.getBaseGcInfoCompositeType()
            };
            baseGcNotifInfoCompositeType =
                new CompositeType("sun.management.BaseGarbageCollectionNotifInfoCompositeType",
                                  "CompositeType for Base GarbageCollectionNotificationInfo",
                                  gcNotifInfoItemNames,
                                  gcNotifInfoItemNames,
                                  baseGcNotifInfoItemTypes);
        } catch (OpenDataException e) {
            // shouldn't reach here
            throw Util.newException(e);
        }
    }
    return baseGcNotifInfoCompositeType;
}
项目:jdk8u-dev-jdk    文件:GarbageCollectionNotifInfoCompositeData.java   
private static synchronized CompositeType getBaseGcNotifInfoCompositeType() {
    if (baseGcNotifInfoCompositeType == null) {
        try {
            OpenType<?>[] baseGcNotifInfoItemTypes = new OpenType<?>[] {
                SimpleType.STRING,
                SimpleType.STRING,
                SimpleType.STRING,
                GcInfoCompositeData.getBaseGcInfoCompositeType()
            };
            baseGcNotifInfoCompositeType =
                new CompositeType("sun.management.BaseGarbageCollectionNotifInfoCompositeType",
                                  "CompositeType for Base GarbageCollectionNotificationInfo",
                                  gcNotifInfoItemNames,
                                  gcNotifInfoItemNames,
                                  baseGcNotifInfoItemTypes);
        } catch (OpenDataException e) {
            // shouldn't reach here
            throw Util.newException(e);
        }
    }
    return baseGcNotifInfoCompositeType;
}
项目:datakernel    文件:AttributeNodeForSimpleType.java   
private static SimpleType<?> simpleTypeOf(Class<?> clazz) throws IllegalArgumentException {
    if (clazz == boolean.class || clazz == Boolean.class) {
        return SimpleType.BOOLEAN;
    } else if (clazz == byte.class || clazz == Byte.class) {
        return SimpleType.BYTE;
    } else if (clazz == short.class || clazz == Short.class) {
        return SimpleType.SHORT;
    } else if (clazz == char.class || clazz == Character.class) {
        return SimpleType.CHARACTER;
    } else if (clazz == int.class || clazz == Integer.class) {
        return SimpleType.INTEGER;
    } else if (clazz == long.class || clazz == Long.class) {
        return SimpleType.LONG;
    } else if (clazz == float.class || clazz == Float.class) {
        return SimpleType.FLOAT;
    } else if (clazz == double.class || clazz == Double.class) {
        return SimpleType.DOUBLE;
    } else if (clazz == String.class) {
        return SimpleType.STRING;
    } else {
        throw new IllegalArgumentException("There is no SimpleType for " + clazz.getName());
    }
}
项目:datakernel    文件:ExceptionStatsTest.java   
@Before
public void before() throws OpenDataException {
    exceptionDetailsItemNames = new String[]{
            "lastException",
            "lastExceptionCausedObject",
            "lastExceptionStackTrace",
            "lastExceptionTimestamp",
            "totalExceptions"
    };

    exceptionDetailsItemTypes = new OpenType<?>[]{
            SimpleType.STRING,
            SimpleType.STRING,
            new ArrayType<>(1, SimpleType.STRING),
            SimpleType.LONG,
            SimpleType.INTEGER
    };
}
项目:wildfly-core    文件:LegacyTypeConverterUnitTestCase.java   
@Test
public void testJsonObject() throws Exception {
    ModelNode description = createDescription(ModelType.OBJECT);

    TypeConverter converter = getConverter(description);

    Assert.assertEquals(SimpleType.STRING, converter.getOpenType());

    ModelNode node = new ModelNode();
    node.get("long").set(5L);
    node.get("string").set("Value");
    node.get("a", "b").set(true);
    node.get("c", "d").set(40);

    String json = node.toJSONString(false);
    String data = assertCast(String.class, converter.fromModelNode(node));
    Assert.assertEquals(json, data);

    Assert.assertEquals(ModelNode.fromJSONString(json), converter.toModelNode(data));
}
项目:olat    文件:ClusterEventBus.java   
private CompositeDataSupport propertiesToCompositeData(final Map<String, ?> properties) {
    // try {
    try {
        final String[] keys = properties.keySet().toArray(new String[0]);
        final OpenType[] itemTypes = new OpenType[keys.length];
        for (int i = 0; i < itemTypes.length; i++) {
            itemTypes[i] = SimpleType.STRING;
        }
        CompositeType propsType;
        propsType = new CompositeType("Properties type", "properties", keys, keys, itemTypes);
        final CompositeDataSupport propsData = new CompositeDataSupport(propsType, properties);
        return propsData;
    } catch (final OpenDataException e) {
        throw new AssertException("problem with jmx data generation", e);
    }
}
项目:olat    文件:ClusterEventBus.java   
private CompositeDataSupport propertiesToCompositeData(final Map<String, ?> properties) {
    // try {
    try {
        final String[] keys = properties.keySet().toArray(new String[0]);
        final OpenType[] itemTypes = new OpenType[keys.length];
        for (int i = 0; i < itemTypes.length; i++) {
            itemTypes[i] = SimpleType.STRING;
        }
        CompositeType propsType;
        propsType = new CompositeType("Properties type", "properties", keys, keys, itemTypes);
        final CompositeDataSupport propsData = new CompositeDataSupport(propsType, properties);
        return propsData;
    } catch (final OpenDataException e) {
        throw new AssertException("problem with jmx data generation", e);
    }
}
项目:bagri    文件:JMXUtils.java   
private static OpenType getOpenType(Object value) throws OpenDataException {
    if (value == null) {
        return SimpleType.VOID;
    }

    //if (OpenType.ALLOWED_CLASSNAMES_LIST.contains(name)) {
    int dim = 0;
    Class<?> cls = value.getClass();
    while (cls.isArray()) {
        cls = value.getClass().getComponentType();
        dim++;
    }
    SimpleType<?> type = getTypeForName(cls.getName());
    if (type != null && dim > 0) {
        if (cls.isPrimitive() && dim == 1) {
            return new ArrayType<>(type, true);
        }
        return new ArrayType<>(dim, type);
    }
    return type;
}
项目:openjdk-source-code-learn    文件:GarbageCollectionNotifInfoCompositeData.java   
private static synchronized CompositeType getBaseGcNotifInfoCompositeType() {
    if (baseGcNotifInfoCompositeType == null) {
        try {
            OpenType[] baseGcNotifInfoItemTypes = new OpenType[] {
                SimpleType.STRING,
                SimpleType.STRING,
                SimpleType.STRING,
                GcInfoCompositeData.getBaseGcInfoCompositeType()
            };
            baseGcNotifInfoCompositeType =
                new CompositeType("sun.management.BaseGarbageCollectionNotifInfoCompositeType",
                                  "CompositeType for Base GarbageCollectionNotificationInfo",
                                  gcNotifInfoItemNames,
                                  gcNotifInfoItemNames,
                                  baseGcNotifInfoItemTypes);
        } catch (OpenDataException e) {
            // shouldn't reach here
            throw Util.newException(e);
        }
    }
    return baseGcNotifInfoCompositeType;
}
项目:wildfly-core    文件:LegacyTypeConverterUnitTestCase.java   
@Test
public void testUndefinedTypeConverter() {
    TypeConverter converter = getConverter(new ModelNode());
    Assert.assertEquals(SimpleType.STRING, converter.getOpenType());

    ModelNode node = new ModelNode();
    // BES 2013/01/10 This uses BigInteger; I'm not sure why. But use a value > Long.MAX_VALUE
    // so the json parser won't convert it down to a long or int resulting in a different value
    // See AS7-4913
    // Likely BigInteger was used *because of* the problem discussed in AS7-4913
    node.get("abc").set(new BigInteger(String.valueOf(Long.MAX_VALUE) + "0"));
    node.get("def").set(false);
    node.protect();

    String json = assertCast(String.class, converter.fromModelNode(node));
    Assert.assertEquals(node, ModelNode.fromJSONString(json));
    Assert.assertEquals(json, assertCast(String.class, converter.fromModelNode(node)));
    assertToArray(converter, json);
}
项目:wildfly-core    文件:ExpressionTypeConverterUnitTestCase.java   
@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));
}
项目:OLD-OpenJDK8    文件:GarbageCollectionNotifInfoCompositeData.java   
private static synchronized CompositeType getBaseGcNotifInfoCompositeType() {
    if (baseGcNotifInfoCompositeType == null) {
        try {
            OpenType<?>[] baseGcNotifInfoItemTypes = new OpenType<?>[] {
                SimpleType.STRING,
                SimpleType.STRING,
                SimpleType.STRING,
                GcInfoCompositeData.getBaseGcInfoCompositeType()
            };
            baseGcNotifInfoCompositeType =
                new CompositeType("sun.management.BaseGarbageCollectionNotifInfoCompositeType",
                                  "CompositeType for Base GarbageCollectionNotificationInfo",
                                  gcNotifInfoItemNames,
                                  gcNotifInfoItemNames,
                                  baseGcNotifInfoItemTypes);
        } catch (OpenDataException e) {
            // shouldn't reach here
            throw Util.newException(e);
        }
    }
    return baseGcNotifInfoCompositeType;
}
项目:cn1    文件:ManagementUtils.java   
/**
 * @return an instance of {@link CompositeType}for the
 *         {@link MemoryNotificationInfo}class.
 */
private static CompositeType getMemoryNotificationInfoCompositeType() {
    if (MEMORYNOTIFICATIONINFO_COMPOSITETYPE == null) {
        String[] typeNames = { "poolName", "usage", "count" };
        String[] typeDescs = { "poolName", "usage", "count" };
        OpenType[] typeTypes = { SimpleType.STRING,
                getMemoryUsageCompositeType(), SimpleType.LONG };
        try {
            MEMORYNOTIFICATIONINFO_COMPOSITETYPE = new CompositeType(
                    MemoryNotificationInfo.class.getName(),
                    MemoryNotificationInfo.class.getName(), typeNames,
                    typeDescs, typeTypes);
        } catch (OpenDataException e) {
            if (ManagementUtils.VERBOSE_MODE) {
                e.printStackTrace(System.err);
            }// end if
        }
    }
    return MEMORYNOTIFICATIONINFO_COMPOSITETYPE;
}
项目:cn1    文件:ManagementUtils.java   
/**
 * @return an instance of {@link CompositeType}for the
 *         {@link StackTraceElement}class.
 */
private static CompositeType getStackTraceElementCompositeType() {
    if (STACKTRACEELEMENT_COMPOSITETYPE == 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 {
            STACKTRACEELEMENT_COMPOSITETYPE = new CompositeType(
                    StackTraceElement.class.getName(),
                    StackTraceElement.class.getName(), typeNames,
                    typeDescs, typeTypes);
        } catch (OpenDataException e) {
            if (ManagementUtils.VERBOSE_MODE) {
                e.printStackTrace(System.err);
            }// end if
        }
    }
    return STACKTRACEELEMENT_COMPOSITETYPE;
}
项目:wildfly-core    文件:LegacyTypeConverterUnitTestCase.java   
@Test
public void testPropertyTypeExpressionConverter() throws OperationFailedException {
    ModelNode description = createDescription(ModelType.PROPERTY);
    TypeConverter converter = getConverter(description);

    ModelNode node = new ModelNode();
    node.set("name", "${this.should.not.exist.!!!!!:value}");
    node.protect();

    ModelNode expected = ExpressionResolver.TEST_RESOLVER.resolveExpressions(node.clone());

    Assert.assertEquals(SimpleType.STRING, converter.getOpenType());
    String dmr = assertCast(String.class, converter.fromModelNode(node));
    Assert.assertEquals(expected, ModelNode.fromString(dmr));
    Assert.assertEquals(dmr, assertCast(String.class, converter.fromModelNode(expected)));
    assertToArray(converter, dmr);
}
项目:cn1    文件:MemoryNotificationInfoTest.java   
public void test_from_scenario6() throws Exception {
    String[] names = { "poolName", "usage", "count" };
    Object[] values = { "TestPoolName", new Long(1), new Long(42) };
    OpenType[] types = { SimpleType.STRING, SimpleType.LONG,
            SimpleType.LONG };

    CompositeType compositeType = getCompositeType(names, types);
    CompositeData data = new CompositeDataSupport(compositeType, names,
            values);
    try {
        MemoryNotificationInfo.from(data);
        fail("should throw IllegalArgumentException");
    } catch (IllegalArgumentException e) {
        // Expected
    }
}
项目:cn1    文件:MemoryNotificationInfoTest.java   
public void test_from_scenario7() throws Exception {
    String[] names = { "poolName", "usage", "count" };
    Object[] values = { "TestPoolName", memoryCompositeData, "42" };
    OpenType[] types = { SimpleType.STRING, memoryUsageCompositeType,
            SimpleType.STRING };

    CompositeType compositeType = getCompositeType(names, types);
    CompositeData data = new CompositeDataSupport(compositeType, names,
            values);
    try {
        MemoryNotificationInfo.from(data);
        fail("should throw IllegalArgumentException");
    } catch (IllegalArgumentException e) {
        // Expected
    }
}
项目:wildfly-core    文件:ExpressionTypeConverterUnitTestCase.java   
@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));
}
项目:cn1    文件:MemoryNotificationInfoTest.java   
public void test_from_scenario11() throws Exception {
    String[] names = { "notPoolName", "usage", "count" };
    Object[] values = { "TestNotPoolName", memoryCompositeData,
            new Long(42) };
    OpenType[] types = { SimpleType.STRING, memoryUsageCompositeType,
            SimpleType.LONG };

    CompositeType compositeType = getCompositeType(names, types);
    CompositeData data = new CompositeDataSupport(compositeType, names,
            values);
    try {
        MemoryNotificationInfo.from(data);
        fail("should throw IllegalArgumentException");
    } catch (IllegalArgumentException e) {
        // Expected
    }
}
项目:wildfly-core    文件:ExpressionTypeConverterUnitTestCase.java   
@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));

}
项目:cn1    文件:MemoryNotificationInfoTest.java   
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());
}
项目:cn1    文件:ThreadInfoTest.java   
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;
}
项目:cn1    文件:ThreadInfoTest.java   
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
    }
}
项目:cn1    文件:ThreadInfoTest.java   
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
    }
}
项目:cn1    文件:ThreadInfoTest.java   
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
    }
}
项目:cn1    文件:ThreadInfoTest.java   
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
    }
}
项目:cn1    文件:ThreadInfoTest.java   
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
    }
}
项目:cn1    文件:ThreadInfoTest.java   
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
    }
}
项目:cn1    文件:ThreadInfoTest.java   
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
    }
}