// Test integer attribute
Expression testAttribute1 = new LiteralExpressionImpl(new Integer(4));
Expression testAttribute2 = new LiteralExpressionImpl(new Integer(2));
// Test addition
MathExpressionImpl mathTest = new AddImpl(null, null);
mathTest.setExpression1(testAttribute1);
mathTest.setExpression2(testAttribute2);
LOGGER.fine("math test: " + testAttribute1.evaluate(testFeature)
+ " + " + testAttribute2.evaluate(testFeature) + " = "
+ mathTest.evaluate(testFeature));
assertEquals(new Integer(6), mathTest.evaluate(testFeature,
Integer.class));
// Test subtraction
mathTest = new SubtractImpl(null, null);
mathTest.setExpression1(testAttribute1);
mathTest.setExpression2(testAttribute2);
LOGGER.fine("math test: " + testAttribute1.evaluate(testFeature)
+ " - " + testAttribute2.evaluate(testFeature) + " = "
+ mathTest.evaluate(testFeature));
assertEquals(new Integer(2), mathTest.evaluate(testFeature,
Integer.class));
// Test multiplication
mathTest = new MultiplyImpl(null, null);
mathTest.setExpression1(testAttribute1);
mathTest.setExpression2(testAttribute2);
LOGGER.fine("math test: " + testAttribute1.evaluate(testFeature)
+ " * " + testAttribute2.evaluate(testFeature) + " = "
+ mathTest.evaluate(testFeature));
assertEquals(new Integer(8), mathTest.evaluate(testFeature,
Integer.class));
// Test division
mathTest = new DivideImpl(null, null);
mathTest.setExpression1(testAttribute1);
mathTest.setExpression2(testAttribute2);
LOGGER.fine("math test: " + testAttribute1.evaluate(testFeature)
+ " / " + testAttribute2.evaluate(testFeature) + " = "
+ mathTest.evaluate(testFeature));
assertEquals(new Double(2), mathTest.evaluate(testFeature));
}