wuxw
2019-09-05 79006c218f912ffdc2552d2a075797c883e091e5
调试 javassist
2个文件已修改
66 ■■■■ 已修改文件
java110-core/src/test/java/com/java110/AppTest.java 47 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
java110-service/src/test/java/com/java110/service/smo/impl/QueryServiceSMOImplTest.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
java110-core/src/test/java/com/java110/AppTest.java
@@ -3,36 +3,59 @@
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.apache.ibatis.ognl.Ognl;
import org.apache.ibatis.ognl.OgnlContext;
import java.util.HashMap;
import java.util.Map;
/**
 * Unit test for simple App.
 */
public class AppTest
    extends TestCase
{
public class AppTest
        extends TestCase {
    /**
     * Create the test case
     *
     * @param testName name of the test case
     */
    public AppTest( String testName )
    {
        super( testName );
    public AppTest(String testName) {
        super(testName);
    }
    /**
     * @return the suite of tests being tested
     */
    public static Test suite()
    {
        return new TestSuite( AppTest.class );
    public static Test suite() {
        return new TestSuite(AppTest.class);
    }
    /**
     * Rigourous Test :-)
     */
    public void testApp()
    {
        assertTrue( true );
    public void testApp() {
        assertTrue(true);
    }
    public void testOgnl() throws Exception{
        //创建一个Ognl上下文对象
        OgnlContext context = new OgnlContext();
        Map user = new HashMap();
        user.put("id", "123213");
        user.put("name", "张三");
        context.putAll(user);
        Object node = Ognl.parseExpression("id != null and name != null");
        Object value = Ognl.getValue(node,context);
        System.out.printf("value : " + value);
    }
}
java110-service/src/test/java/com/java110/service/smo/impl/QueryServiceSMOImplTest.java
@@ -33,4 +33,23 @@
        move.invoke(con);
    }
    public void testExistsJavaClass() throws Exception{
        ClassPool classPool = ClassPool.getDefault();
        CtClass ctClass = classPool.get("com.java110.core.javassist.Java110CoreTemplateJavassist");
        String javaCode = "public static void testJava2() {        System.out.println(\"123213\");\n}\n";
        String    javaCode2 ="public static void testJava1() {     testJava2();   System.out.println(\"223213\");\n}";
        CtMethod helloM = CtNewMethod.make(javaCode, ctClass);
        ctClass.addMethod(helloM);
        CtMethod helloM1 = CtNewMethod.make(javaCode2, ctClass);
        ctClass.addMethod(helloM1);
        //ctClass
        ctClass.writeFile("E:\\project\\HC\\MicroCommunity\\11");
    }
}