01: /*
02: * Copyright (C) The MX4J Contributors.
03: * All rights reserved.
04: *
05: * This software is distributed under the terms of the MX4J License version 1.0.
06: * See the terms of the MX4J License in the documentation provided with this software.
07: */
08:
09: 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: /**
18: * @version $Revision: 1.4 $
19: */
20: public class BinaryOpValueExpTest extends TestCase {
21: /**
22: * Constructor requested by the JUnit framework
23: */
24: public BinaryOpValueExpTest(String name) {
25: super (name);
26: }
27:
28: public void testLongOperations() throws Exception {
29: ValueExp value1 = Query.value(new Integer(3));
30: ValueExp value2 = Query.value(new Integer(4));
31: ValueExp op = Query.plus(value1, value2);
32: QueryExp result = Query.eq(Query.value(7L), op);
33: assertTrue(result.apply(null));
34:
35: op = Query.minus(value1, value2);
36: result = Query.eq(Query.value(-1L), op);
37: assertTrue(result.apply(null));
38:
39: op = Query.times(value1, value2);
40: result = Query.eq(Query.value(12L), op);
41: assertTrue(result.apply(null));
42:
43: op = Query.div(value1, value2);
44: result = Query.eq(Query.value(0L), op);
45: assertTrue(result.apply(null));
46: }
47:
48: public void testDoubleOperations() throws Exception {
49: ValueExp value1 = Query.value(new Double(3.0D));
50: ValueExp value2 = Query.value(new Double(4.0D));
51: ValueExp op = Query.plus(value1, value2);
52: QueryExp result = Query.eq(Query.value(7.0D), op);
53: assertTrue(result.apply(null));
54:
55: op = Query.minus(value1, value2);
56: result = Query.eq(Query.value(-1.0D), op);
57: assertTrue(result.apply(null));
58:
59: op = Query.times(value1, value2);
60: result = Query.eq(Query.value(12.0D), op);
61: assertTrue(result.apply(null));
62:
63: op = Query.div(value1, value2);
64: result = Query.eq(Query.value(3.0D / 4.0D), op);
65: assertTrue(result.apply(null));
66: }
67: }
|