@Override
    public <T> T evaluate(Exchange exchange, Class<T> type) {
        Map<String, Object> globalVariables = new HashMap<>();
        Script script = instantiateScript(exchange, globalVariables);
        script.setBinding(createBinding(exchange, globalVariables));
        Object value = script.run();

        return exchange.getContext().getTypeConverter().convertTo(type, value);
    }
@Test
    public void testInvalidExpressionFailsWithMeaningfulException() {
        try {
            GroovyLanguage.groovy("exchange.doesNotExist").evaluate(exchange);
            fail("This test case should have thrown an exception!");
        } catch (Exception e) {
            LOG.debug("Caught expected exception: {}", e.getMessage(), e);
            String message = e.getMessage();
            assertTrue(message.contains("doesNotExist"), "The message should include 'doesNotExist' but was: " + message);
        }
    }