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