@Test(expected = org.modeshape.jcr.value.ValueFormatException.class)
@FixFor( "MODE-2166" )
public void shouldFailWhenAttemptingToCastToInvalidType() throws Exception {

    String sql = "SELECT car.[jcr:path] FROM [car:Car] as car WHERE CAST(car.[car:maker] AS DATE) = 'Toyota'";
    Query query = session.getWorkspace().getQueryManager().createQuery(sql, Query.JCR_SQL2);
    QueryResult result = query.execute();
    validateQuery().validate(query, result);                            
}