发表于: 2017-11-19 21:28:16

2 668


今天学习的内容

今天按照任务要求重构了代码,代码太长就不上了,看下测试单元部分

package mapper;

import model.Student;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.context.ApplicationContext;

import org.apache.log4j.Logger;

import org.springframework.test.context.ContextConfiguration;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.List;

@RunWith(SpringJUnit4ClassRunner.class)

@ContextConfiguration(locations = {"classpath:applicationContext.xml"})

public class StudentTest {

    @Autowired

    ApplicationContext ctx;

    private static Logger logger = Logger.getLogger(StudentTest.class);

    @Test

    public void studentInsert() throws Exception{

        StudentMapper studentMapper = (StudentMapper) ctx.getBean("studentMapper");

        Student student = new Student();

        student.setId(0);

        student.setName("张三");

        student.setQq(123456789);

        student.setType("后端");

        student.setAdmission_date("2017.10.28");

        student.setUniversity("五道口职业技术学院");

        student.setHomework("www.baidu.com");

        student.setPledge("老大最帅");

        student.setSenior("王鹏举");

        student.setChannel("贴吧");

        studentMapper.studentInsert(student);

    }

    @Test

    public void studentDelete() throws Exception{

        StudentMapper studentMapper = (StudentMapper) ctx.getBean("studentMapper");

        studentMapper.studentDelete(10);

    }

    @Test

    public void studentUpdate() throws Exception{

        StudentMapper studentMapper = (StudentMapper) ctx.getBean("studentMapper");

        Student student1 = new Student();

        student1.setName("李四");

        student1.setId(9);

        studentMapper.studentUpdate(student1);

    }

    @Test

    public void studentSelect() throws Exception{

        StudentMapper studentMapper = (StudentMapper) ctx.getBean("studentMapper");

        Student student2 = new Student();

        student2.setId(5);

        studentMapper.studentSelect(student2);

    }

     @Test

    public void ListAll() throws Exception{

        StudentMapper studentMapper = (StudentMapper) ctx.getBean("studentMapper");

         List<Student> listAll = studentMapper.listAll();

     }

}

看下运行结果

然后是正式运行的结果

最终的表结果

遇到的问题

原因是Mapper配置文件中的insert语法中,在字段个字段中间用的.分隔的,正确应该是,号,结果自己半天没找到这个句号,最后还是师兄帮我找到的!可以面壁去了....

今天的收获

今天应该是正式结束任务一了,深度思考放到明天写.

明天的计划

开始任务2

任务进度:任务1步骤28

任务开始时间:10月28日
任务结束时间:11月19日



返回列表 返回列表
评论

    分享到