Java 类javax.management.ValueExp 实例源码

项目:freeVM    文件:QueryTest.java   
/**
 * Test for the method in(javax.management.ValueExp,
 * javax.management.ValueExp[])
 * 
 * @see javax.management.Query#in(javax.management.ValueExp,
 *      javax.management.ValueExp[])
 */
public final void testIn() throws Exception {
    String[] attrs = new String[] { "IntNumber1", "IntNumber2",
        "LongNumber1", "LongNumber2", "DoubleNumber1", "DoubleNumber2",
        "FloatNumber1", "FloatNumber2", "Number1", "Number2" };

    ValueExp[] v1 = new ValueExp[] { Query.value(10), Query.value(20),
        Query.value(30) };
    ValueExp[] v2 = new ValueExp[] { Query.value(20), Query.value(30),
        Query.value(40) };

    for (int i = 0; i < attrs.length; i += 2) {
        assertTrue(attrs[i] + " in [10, 20, 30]", Query.in(
            Query.attr(attrs[i]), v1).apply(names[2]));
        assertFalse(attrs[i] + " in [20, 30, 40]", Query.in(
            Query.attr(attrs[i]), v2).apply(names[2]));
    }
}
项目:freeVM    文件:QueryTest.java   
/**
 * Test for the method plus(javax.management.ValueExp,
 * javax.management.ValueExp)
 * 
 * @see javax.management.Query#plus(javax.management.ValueExp,
 *      javax.management.ValueExp)
 */
public final void testPlus() throws Exception {
    String[] attrs = new String[] { "IntNumber1", "IntNumber2",
        "LongNumber1", "LongNumber2", "DoubleNumber1", "DoubleNumber2",
        "FloatNumber1", "FloatNumber2", "Number1", "Number2" };

    for (int i = 0; i < attrs.length; i += 2) {
        ValueExp v1 = Query.attr(attrs[i]).apply(names[2]);
        ValueExp v2 = Query.attr(attrs[i + 1]).apply(names[2]);
        ValueExp res = Query.plus(v1, v2).apply(names[2]);
        assertTrue(v1 + " + " + v2 + " = " + res, Query.eq(
            Query.plus(Query.attr(attrs[i + 1]), Query.attr(attrs[i])),
            Query.value(110)).apply(names[2]));
        assertFalse(v1 + " + " + v2 + " = " + res, Query.eq(
            Query.plus(Query.attr(attrs[i + 1]), Query.attr(attrs[i])),
            Query.value(111)).apply(names[2]));
    }
}
项目:freeVM    文件:QueryTest.java   
/**
 * Test for the method times(javax.management.ValueExp,
 * javax.management.ValueExp)
 * 
 * @see javax.management.Query#times(javax.management.ValueExp,
 *      javax.management.ValueExp)
 */
public final void testTimes() throws Exception {
    String[] attrs = new String[] { "IntNumber1", "IntNumber2",
        "LongNumber1", "LongNumber2", "DoubleNumber1", "DoubleNumber2",
        "FloatNumber1", "FloatNumber2", "Number1", "Number2" };

    for (int i = 0; i < attrs.length; i += 2) {
        ValueExp v1 = Query.attr(attrs[i]).apply(names[2]);
        ValueExp v2 = Query.attr(attrs[i + 1]).apply(names[2]);
        ValueExp res = Query.times(v1, v2).apply(names[2]);
        assertTrue(v1 + " * " + v2 + " = " + res, Query.eq(
            Query.times(Query.attr(attrs[i + 1]), Query.attr(attrs[i])),
            Query.value(1000)).apply(names[2]));
        assertFalse(v1 + " * " + v2 + " = " + res, Query.eq(
            Query.times(Query.attr(attrs[i + 1]), Query.attr(attrs[i])),
            Query.value(10001)).apply(names[2]));
    }
}