public void test_Factory() { try { ExpressionEvaluator.Factory.createInstance(InvalidEvaluator.class.getName(), "blah"); fail("Expected SmooksConfigurationException"); } catch (SmooksConfigurationException e) { assertEquals( "Unsupported ExpressionEvaluator type 'org.milyn.delivery.condition.InvalidEvaluator'. Currently only support 'org.milyn.expression.ExecutionContextExpressionEvaluator' implementations.", e.getMessage()); } TestExecutionContextExpressionEvaluator evaluator = (TestExecutionContextExpressionEvaluator) ExpressionEvaluator.Factory.createInstance( TestExecutionContextExpressionEvaluator.class.getName(), "blah"); assertNotNull(evaluator.condition); }
public ExpressionEvaluator digestCondition(Element conditionElement) throws SmooksConfigurationException { String idRef = DomUtils.getAttributeValue(conditionElement, "idRef"); if (idRef != null) { return getConditionEvaluator(idRef); } else { String evaluatorClassName = DomUtils.getAttributeValue(conditionElement, "evaluator"); if (evaluatorClassName == null || evaluatorClassName.trim().equals("")) { evaluatorClassName = "org.milyn.javabean.expression.BeanMapExpressionEvaluator"; } String evaluatorConditionExpression = DomUtils.getAllText(conditionElement, true); if (evaluatorConditionExpression == null || evaluatorConditionExpression.trim().equals("")) { throw new SmooksConfigurationException( "smooks-resource/condition must specify a condition expression as child text e.g. <condition evaluator=\"....\">A + B > C</condition>."); } // And construct it... return ExpressionEvaluator.Factory.createInstance( evaluatorClassName, evaluatorConditionExpression); } }