/**
 * Copyright 2008-2009. Chongqing Communications Industry Services Co.,Ltd Information Technology Branch. All rights reserved.
 * <a>http://www.crunii.com</a>
 */
package com.crunii.micro.core.test;

import org.springframework.expression.Expression;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.common.TemplateParserContext;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.mock.env.MockEnvironment;

/**
 * @author 田平 create 2023-01-05 09:28:28
 */
public class SpelTest {

	public static void main(String[] args) {
		MockEnvironment mockEnvironment = new MockEnvironment();
		mockEnvironment.setProperty("result", "true");
		String exp = "#{'${result}'=='true'}";
		String resolve = mockEnvironment.resolvePlaceholders(exp);
		ExpressionParser expressionParser = new SpelExpressionParser();
		TemplateParserContext context = new TemplateParserContext();
		Expression expression = expressionParser.parseExpression(resolve, context);
		System.out.println(expression.getValue());
	}
}
