更新测试方法
This commit is contained in:
parent
dd6bd72c84
commit
72d82df2bd
|
|
@ -4,6 +4,7 @@ import java.io.BufferedReader;
|
|||
import java.io.InputStreamReader;
|
||||
|
||||
public class BaseTest {
|
||||
|
||||
public String getType() {
|
||||
try {
|
||||
BufferedReader strin = new BufferedReader(new InputStreamReader(System.in));
|
||||
|
|
@ -15,4 +16,5 @@ public class BaseTest {
|
|||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
package com.smallchill.test.beetlsql;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.beetl.sql.core.ClasspathLoader;
|
||||
import org.beetl.sql.core.DefaultNameConversion;
|
||||
|
|
@ -10,6 +13,7 @@ import org.beetl.sql.core.SQLLoader;
|
|||
import org.beetl.sql.core.SQLManager;
|
||||
import org.beetl.sql.core.db.PostgresStyle;
|
||||
import org.junit.Test;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
import com.smallchill.core.beetl.ReportInterceptor;
|
||||
import com.smallchill.core.toolbox.Paras;
|
||||
|
|
@ -20,19 +24,31 @@ public class BeetlTest {
|
|||
|
||||
@Test
|
||||
public void test() {
|
||||
|
||||
List<Map> list = getSqlManager().execute("select * from tb_yw_tzgg where f_vc_bt = #f_vc_bt#", Map.class, Paras.create().set("f_vc_bt", '1'), 1, 10);
|
||||
List<Map> list = getSqlManager().execute("select * from blade_notice where id = #{id}", Map.class, Paras.create().set("id", 1), 1, 10);
|
||||
System.out.println(list);
|
||||
|
||||
}
|
||||
|
||||
public SQLManager getSqlManager() {
|
||||
PostgresStyle style = new PostgresStyle();
|
||||
PostgreSqlConnection cs = new PostgreSqlConnection();
|
||||
SQLLoader loader = new ClasspathLoader("/beetlsql");
|
||||
SQLManager sql = new SQLManager(style, loader, cs, new DefaultNameConversion(), new Interceptor[] { new ReportInterceptor() });
|
||||
sql.getSqlLoader().setCharset(CharsetKit.UTF_8);
|
||||
sql.getSqlLoader().setAutoCheck(true);
|
||||
loader.setCharset(CharsetKit.UTF_8);
|
||||
loader.setAutoCheck(true);
|
||||
ClassPathResource cpr = new ClassPathResource("config/beetlsql.properties");
|
||||
Properties properties = new Properties();
|
||||
InputStream in = null;
|
||||
try {
|
||||
in = cpr.getInputStream();
|
||||
properties.load(in);
|
||||
} catch (IOException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
} finally {
|
||||
if (in != null) {
|
||||
try { in.close(); } catch (IOException e) {}
|
||||
in = null;
|
||||
}
|
||||
}
|
||||
SQLManager sql = new SQLManager(style, loader, cs, new DefaultNameConversion(), new Interceptor[] {new ReportInterceptor()}, null, properties);
|
||||
return sql;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package com.smallchill.test;
|
||||
package com.smallchill.test.excel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
|
@ -13,17 +13,29 @@ import com.smallchill.core.toolbox.kit.ClassKit;
|
|||
|
||||
public class ProxyTest {
|
||||
|
||||
/**
|
||||
* 基于jdk代理
|
||||
*/
|
||||
@Test
|
||||
public void test() {
|
||||
TestProxyBean testBean = new TestProxyBean();
|
||||
|
||||
IProxy test = (IProxy) Proxy.newProxyInstance(testBean.getClass()
|
||||
.getClassLoader(), testBean.getClass().getInterfaces(),
|
||||
new TestProxyHander(testBean));
|
||||
|
||||
IProxy test = (IProxy) Proxy.newProxyInstance(testBean.getClass().getClassLoader(), testBean.getClass().getInterfaces(), new TestProxyHander(testBean));
|
||||
test.test();
|
||||
}
|
||||
|
||||
/**
|
||||
* 基于jdk代理工具类
|
||||
*/
|
||||
@Test
|
||||
public void testKit() {
|
||||
TestProxyBean testBean = new TestProxyBean();
|
||||
IProxyKit test = ClassKit.newProxyInstance(IProxyKit.class, new TestProxyHander(testBean));
|
||||
test.testKit();
|
||||
}
|
||||
|
||||
/**
|
||||
* 基于cglib代理
|
||||
*/
|
||||
@Test
|
||||
public void testCglib(){
|
||||
try {
|
||||
|
|
@ -34,6 +46,9 @@ public class ProxyTest {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 基于cglib代理工具类
|
||||
*/
|
||||
@Test
|
||||
public void testCglibKit(){
|
||||
TestProxyMethodCglib test = ClassKit.newProxyCglibFactory(TestProxyMethodCglib.class, new TestProxyMethodInterceptor());
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user