Message<String> message = MessageBuilder.withPayload("jee").copyHeaders(headers).build();
String nowYYYYMM = new SimpleDateFormat("yyyy/MM").format(new Date());
String nowYYYY = new SimpleDateFormat("yyyy").format(new Date());
ExpressionParser parser = new SpelExpressionParser();
StandardEvaluationContext context = new StandardEvaluationContext();
MessagePartitionKeyMethodResolver resolver = new MessagePartitionKeyMethodResolver();
MessagePartitionKeyPropertyAccessor accessor = new MessagePartitionKeyPropertyAccessor();
context.addMethodResolver(resolver);
context.addPropertyAccessor(accessor);
assertThat(parser.parseExpression("dateFormat('yyyy/MM')").getValue(context, message, String.class), is(nowYYYYMM));
assertThat(parser.parseExpression("dateFormat('yyyy/MM', headers[timestamp])").getValue(context, message, String.class), is(nowYYYYMM));
assertThat(parser.parseExpression("dateFormat('yyyy/MM', timestamp)").getValue(context, message, String.class), is(nowYYYYMM));
assertThat(parser.parseExpression("dateFormat('yyyy/MM', T(java.lang.System).currentTimeMillis())").getValue(context, message, String.class), is(nowYYYYMM));