1 8 9 package test.javax.management; 10 11 import javax.management.Query ; 12 import javax.management.QueryExp ; 13 import javax.management.ValueExp ; 14 15 import junit.framework.TestCase; 16 17 20 public class BinaryOpValueExpTest extends TestCase 21 { 22 25 public BinaryOpValueExpTest(String name) 26 { 27 super(name); 28 } 29 30 public void testLongOperations() throws Exception 31 { 32 ValueExp value1 = Query.value(new Integer (3)); 33 ValueExp value2 = Query.value(new Integer (4)); 34 ValueExp op = Query.plus(value1, value2); 35 QueryExp result = Query.eq(Query.value(7L), op); 36 assertTrue(result.apply(null)); 37 38 op = Query.minus(value1, value2); 39 result = Query.eq(Query.value(-1L), op); 40 assertTrue(result.apply(null)); 41 42 op = Query.times(value1, value2); 43 result = Query.eq(Query.value(12L), op); 44 assertTrue(result.apply(null)); 45 46 op = Query.div(value1, value2); 47 result = Query.eq(Query.value(0L), op); 48 assertTrue(result.apply(null)); 49 } 50 51 public void testDoubleOperations() throws Exception 52 { 53 ValueExp value1 = Query.value(new Double (3.0D)); 54 ValueExp value2 = Query.value(new Double (4.0D)); 55 ValueExp op = Query.plus(value1, value2); 56 QueryExp result = Query.eq(Query.value(7.0D), op); 57 assertTrue(result.apply(null)); 58 59 op = Query.minus(value1, value2); 60 result = Query.eq(Query.value(-1.0D), op); 61 assertTrue(result.apply(null)); 62 63 op = Query.times(value1, value2); 64 result = Query.eq(Query.value(12.0D), op); 65 assertTrue(result.apply(null)); 66 67 op = Query.div(value1, value2); 68 result = Query.eq(Query.value(3.0D / 4.0D), op); 69 assertTrue(result.apply(null)); 70 } 71 } 72 73 | Popular Tags |