rm

上级 79ef4b5c
...@@ -212,12 +212,11 @@ public class MyBatisTestRunner { ...@@ -212,12 +212,11 @@ public class MyBatisTestRunner {
private static final Logger _logger = LoggerFactory.getLogger(MyBatisTestRunner.class); private static final Logger _logger = LoggerFactory.getLogger(MyBatisTestRunner.class);
public static ApplicationContext context; public static ApplicationContext context;
public static StudentsService service;
@Test @Test
public void insert() throws Exception{ public void insert() throws Exception{
_logger.info("insert..."); _logger.info("insert...");
WebContext.applicationContext=context;
StudentsService ss=(StudentsService)WebContext.getBean("studentsService");
Students student=new Students(); Students student=new Students();
student.setStdNo("10024"); student.setStdNo("10024");
student.setStdGender("M"); student.setStdGender("M");
...@@ -225,17 +224,15 @@ public class MyBatisTestRunner { ...@@ -225,17 +224,15 @@ public class MyBatisTestRunner {
student.setStdAge(20); student.setStdAge(20);
student.setStdMajor("政治"); student.setStdMajor("政治");
student.setStdClass("4"); student.setStdClass("4");
ss.insert(student); service.insert(student);
Thread.sleep(1000); Thread.sleep(1000);
ss.remove(student.getId()); service.remove(student.getId());
} }
@Test @Test
public void get() throws Exception{ public void get() throws Exception{
_logger.info("get..."); _logger.info("get...");
WebContext.applicationContext=context; Students student=service.get("921d3377-937a-4578-b1e2-92fb23b5e512");
StudentsService ss=(StudentsService)WebContext.getBean("studentsService");
Students student=ss.get("921d3377-937a-4578-b1e2-92fb23b5e512");
_logger.info("Students "+student); _logger.info("Students "+student);
} }
...@@ -243,33 +240,27 @@ public class MyBatisTestRunner { ...@@ -243,33 +240,27 @@ public class MyBatisTestRunner {
@Test @Test
public void remove() throws Exception{ public void remove() throws Exception{
_logger.info("remove..."); _logger.info("remove...");
WebContext.applicationContext=context;
StudentsService ss=(StudentsService)WebContext.getBean("studentsService");
Students student=new Students(); Students student=new Students();
student.setId("921d3377-937a-4578-b1e2-92fb23b5e512"); student.setId("921d3377-937a-4578-b1e2-92fb23b5e512");
ss.remove(student.getId()); service.remove(student.getId());
} }
@Test @Test
public void batchDelete() throws Exception{ public void batchDelete() throws Exception{
_logger.info("batchDelete..."); _logger.info("batchDelete...");
WebContext.applicationContext=context;
StudentsService ss=(StudentsService)WebContext.getBean("studentsService");
List<String> idList=new ArrayList<String>(); List<String> idList=new ArrayList<String>();
idList.add("8584804d-b5ac-45d2-9f91-4dd8e7a090a7"); idList.add("8584804d-b5ac-45d2-9f91-4dd8e7a090a7");
idList.add("ab7422e9-a91a-4840-9e59-9d911257c918"); idList.add("ab7422e9-a91a-4840-9e59-9d911257c918");
idList.add("12b6ceb8-573b-4f01-ad85-cfb24cfa007c"); idList.add("12b6ceb8-573b-4f01-ad85-cfb24cfa007c");
idList.add("dafd5ba4-d2e3-4656-bd42-178841e610fe"); idList.add("dafd5ba4-d2e3-4656-bd42-178841e610fe");
ss.batchDelete(idList); service.batchDelete(idList);
} }
@Test @Test
public void findAll() throws Exception{ public void findAll() throws Exception{
_logger.info("findAll..."); _logger.info("findAll...");
WebContext.applicationContext=context; _logger.info("findAll "+service.findAll());
StudentsService ss=(StudentsService)WebContext.getBean("studentsService");
_logger.info("findAll "+ss.findAll());
} }
@Before @Before
...@@ -293,21 +284,11 @@ public class MyBatisTestRunner { ...@@ -293,21 +284,11 @@ public class MyBatisTestRunner {
//Initialization ApplicationContext for Project //Initialization ApplicationContext for Project
public void init(){ public void init(){
_logger.info("init ..."); _logger.info("init ...");
String path_str=MyBatisTestRunner.class.getResource("ApplicationRunner.properties").getFile().toString();
String appRunnerClassPath=path_str.substring(0,path_str.indexOf("org"));
_logger.info("Application class "+appRunnerClassPath);
System.setProperty("APPRUNNER_CLASSPATH",appRunnerClassPath);
String appRunnerPath=path_str.substring(
path_str.startsWith("/")?1:0,
path_str.indexOf(appRunnerClassPath.split("/")[appRunnerClassPath.split("/").length-1]));
System.setProperty("APPRUNNER_PATH",appRunnerPath);
_logger.info("appRunner dir "+appRunnerPath);
_logger.info("Application dir "+System.getProperty("user.dir"));
context = new ClassPathXmlApplicationContext(new String[] {"spring/applicationContext.xml"}); context = new ClassPathXmlApplicationContext(new String[] {"spring/applicationContext.xml"});
WebContext.applicationContext=context;
service =(StudentsService)WebContext.getBean("studentsService");
} }
} }
...@@ -343,28 +324,24 @@ public class MyBatisTestRunner { ...@@ -343,28 +324,24 @@ public class MyBatisTestRunner {
@Test @Test
public void queryPageResults() throws Exception{ public void queryPageResults() throws Exception{
_logger.info("queryPageResults..."); _logger.info("queryPageResults...");
WebContext.applicationContext=context;
StudentsService ss=(StudentsService)WebContext.getBean("studentsService");
Students student=new Students(); Students student=new Students();
//student.setId("af04d610-6092-481e-9558-30bd63ef783c"); //student.setId("af04d610-6092-481e-9558-30bd63ef783c");
student.setStdGender("M"); student.setStdGender("M");
//student.setStdMajor(政治"); //student.setStdMajor(政治");
student.setPageResults(10); student.setPageResults(10);
student.setPage(2); student.setPage(2);
_logger.info("queryPageResults "+ss.queryPageResults(student)); _logger.info("queryPageResults "+service.queryPageResults(student));
} }
@Test @Test
public void queryPageResultsByMapperId() throws Exception{ public void queryPageResultsByMapperId() throws Exception{
_logger.info("queryPageResults by mapperId..."); _logger.info("queryPageResults by mapperId...");
WebContext.applicationContext=context;
StudentsService ss=(StudentsService)WebContext.getBean("studentsService");
Students student=new Students(); Students student=new Students();
student.setStdGender("M"); student.setStdGender("M");
//student.setStdMajor(政治"); //student.setStdMajor(政治");
student.setPageResults(10); student.setPageResults(10);
student.setPage(2); student.setPage(2);
_logger.info("queryPageResults by mapperId "+ss.queryPageResults("queryPageResults1",student)); _logger.info("queryPageResults by mapperId "+service.queryPageResults("queryPageResults1",student));
} }
...@@ -389,21 +366,9 @@ public class MyBatisTestRunner { ...@@ -389,21 +366,9 @@ public class MyBatisTestRunner {
//Initialization ApplicationContext for Project //Initialization ApplicationContext for Project
public void init(){ public void init(){
_logger.info("init ..."); _logger.info("init ...");
String path_str=MyBatisTestRunner.class.getResource("ApplicationRunner.properties").getFile().toString();
String appRunnerClassPath=path_str.substring(0,path_str.indexOf("org"));
_logger.info("Application class "+appRunnerClassPath);
System.setProperty("APPRUNNER_CLASSPATH",appRunnerClassPath);
String appRunnerPath=path_str.substring(
path_str.startsWith("/")?1:0,
path_str.indexOf(appRunnerClassPath.split("/")[appRunnerClassPath.split("/").length-1]));
System.setProperty("APPRUNNER_PATH",appRunnerPath);
_logger.info("appRunner dir "+appRunnerPath);
_logger.info("Application dir "+System.getProperty("user.dir"));
context = new ClassPathXmlApplicationContext(new String[] {"spring/applicationContext.xml"}); context = new ClassPathXmlApplicationContext(new String[] {"spring/applicationContext.xml"});
WebContext.applicationContext=context;
service =(StudentsService)WebContext.getBean("studentsService");
} }
} }
...@@ -456,7 +421,7 @@ public class MyBatisTestRunner { ...@@ -456,7 +421,7 @@ public class MyBatisTestRunner {
<include refid="sql_condition"/> <include refid="sql_condition"/>
</select> </select>
<select id="query" parameterType="Students" resultType="Students"> <select id="queryBy" parameterType="Students" resultType="Students">
SELECT SELECT
ID , ID ,
STDNO , STDNO ,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册