mirror of https://github.com/alibaba/arthas.git
add OgnlTest. #2954
parent
aa23a4acc9
commit
4e931cbe83
@ -0,0 +1,9 @@
|
||||
package com.taobao.arthas.core.command.express;
|
||||
|
||||
public class FlowAttribute {
|
||||
private String bxApp = "aaa";
|
||||
|
||||
public String getBxApp() {
|
||||
return this.bxApp ;
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package com.taobao.arthas.core.command.express;
|
||||
|
||||
public class FlowContext {
|
||||
private FlowAttribute flowAttribute = new FlowAttribute();
|
||||
|
||||
public FlowAttribute getFlowAttribute() {
|
||||
return this.flowAttribute ;
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package com.taobao.arthas.core.command.express;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import com.taobao.arthas.core.advisor.Advice;
|
||||
import ognl.OgnlException;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* https://github.com/alibaba/arthas/issues/2954
|
||||
*/
|
||||
public class OgnlTest {
|
||||
|
||||
private Express express;
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() throws OgnlException, ExpressException {
|
||||
FlowContext context = new FlowContext();
|
||||
Object[] params = new Object[4];
|
||||
params[0] = context;
|
||||
Advice advice = Advice.newForAfterReturning(null, getClass(), null, null, params, null);
|
||||
express = ExpressFactory.unpooledExpress(null).bind(advice).bind("cost", 123);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStringEquals() throws OgnlException, ExpressException {
|
||||
String conditionExpress = "\"aaa\".equals(params[0].flowAttribute.getBxApp())";
|
||||
boolean result = express.is(conditionExpress);
|
||||
assertTrue(result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testObjectEquals() throws OgnlException, ExpressException {
|
||||
String conditionExpress = "params[0].flowAttribute.getBxApp().equals(\"aaa\")";
|
||||
boolean result = express.is(conditionExpress);
|
||||
assertTrue(result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEqualSign() throws OgnlException, ExpressException {
|
||||
String conditionExpress = "\"aaa\" == params[0].flowAttribute.getBxApp()";
|
||||
boolean result = express.is(conditionExpress);
|
||||
assertTrue(result);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue