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

TypeVersionMapper.java 文件源码 项目:openjdk-jdk10 阅读 43 收藏 0 点赞 0 评论 0
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);
    }
}
JmxReporter.java 文件源码 项目:tqdev-metrics 阅读 32 收藏 0 点赞 0 评论 0
@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;
}
JavaAttribute.java 文件源码 项目:hashsdn-controller 阅读 24 收藏 0 点赞 0 评论 0
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);
        }
    }
GarbageCollectionNotifInfoCompositeData.java 文件源码 项目:openjdk9 阅读 27 收藏 0 点赞 0 评论 0
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;
}
TypeVersionMapper.java 文件源码 项目:openjdk9 阅读 27 收藏 0 点赞 0 评论 0
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);
    }
}
GarbageCollectionNotifInfoCompositeData.java 文件源码 项目:jdk8u_jdk 阅读 29 收藏 0 点赞 0 评论 0
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;
}
GarbageCollectionNotifInfoCompositeData.java 文件源码 项目:lookaside_java-1.8.0-openjdk 阅读 24 收藏 0 点赞 0 评论 0
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;
}
FailureDetector.java 文件源码 项目:scylla-jmx 阅读 25 收藏 0 点赞 0 评论 0
@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;
}
HttpAdaptor.java 文件源码 项目:cacheonix-core 阅读 20 收藏 0 点赞 0 评论 0
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();
   }

}
JmxView.java 文件源码 项目:parfait 阅读 20 收藏 0 点赞 0 评论 0
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 + "]");
    }
}
SampleContentReplicationHarnessImpl.java 文件源码 项目:acs-aem-samples 阅读 20 收藏 0 点赞 0 评论 0
@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);
}
GarbageCollectionNotifInfoCompositeData.java 文件源码 项目:infobip-open-jdk-8 阅读 26 收藏 0 点赞 0 评论 0
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;
}
GarbageCollectionNotifInfoCompositeData.java 文件源码 项目:jdk8u-dev-jdk 阅读 26 收藏 0 点赞 0 评论 0
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;
}
AttributeNodeForSimpleType.java 文件源码 项目:datakernel 阅读 22 收藏 0 点赞 0 评论 0
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());
    }
}
ExceptionStatsTest.java 文件源码 项目:datakernel 阅读 23 收藏 0 点赞 0 评论 0
@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
    };
}
LegacyTypeConverterUnitTestCase.java 文件源码 项目:wildfly-core 阅读 22 收藏 0 点赞 0 评论 0
@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));
}
ClusterEventBus.java 文件源码 项目:olat 阅读 21 收藏 0 点赞 0 评论 0
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);
    }
}
ClusterEventBus.java 文件源码 项目:olat 阅读 22 收藏 0 点赞 0 评论 0
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);
    }
}
JMXUtils.java 文件源码 项目:bagri 阅读 30 收藏 0 点赞 0 评论 0
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;
}
GarbageCollectionNotifInfoCompositeData.java 文件源码 项目:openjdk-source-code-learn 阅读 25 收藏 0 点赞 0 评论 0
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;
}
LegacyTypeConverterUnitTestCase.java 文件源码 项目:wildfly-core 阅读 24 收藏 0 点赞 0 评论 0
@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);
}
ExpressionTypeConverterUnitTestCase.java 文件源码 项目:wildfly-core 阅读 24 收藏 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));
}
GarbageCollectionNotifInfoCompositeData.java 文件源码 项目:OLD-OpenJDK8 阅读 23 收藏 0 点赞 0 评论 0
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;
}
ManagementUtils.java 文件源码 项目:cn1 阅读 25 收藏 0 点赞 0 评论 0
/**
 * @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;
}
ManagementUtils.java 文件源码 项目:cn1 阅读 23 收藏 0 点赞 0 评论 0
/**
 * @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;
}
LegacyTypeConverterUnitTestCase.java 文件源码 项目:wildfly-core 阅读 24 收藏 0 点赞 0 评论 0
@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);
}
MemoryNotificationInfoTest.java 文件源码 项目:cn1 阅读 23 收藏 0 点赞 0 评论 0
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
    }
}
MemoryNotificationInfoTest.java 文件源码 项目:cn1 阅读 20 收藏 0 点赞 0 评论 0
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
    }
}
ExpressionTypeConverterUnitTestCase.java 文件源码 项目:wildfly-core 阅读 24 收藏 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));
}
MemoryNotificationInfoTest.java 文件源码 项目:cn1 阅读 22 收藏 0 点赞 0 评论 0
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
    }
}


问题


面经


文章

微信
公众号

扫码关注公众号