junit-JUnit不知道怎么写,求大神来一篇,然后我仿照着做啊~~~跪谢

问题描述

JUnit不知道怎么写,求大神来一篇,然后我仿照着做啊~~~跪谢
@Controller
@RequestMapping(""/feeBillClosedController"")
public class FeeBillClosedController extends BaseController {
/**
* Logger for this class
*/
private static final Logger logger = Logger.getLogger(FeeBillClosedController.class);

@Autowiredprivate FeeBillClosedServiceI feeBillClosedService;@Autowiredprivate SystemService systemService;private String message;public String getMessage() {    return message;}public void setMessage(String message) {    this.message = message;}/** * 已结账单列表 页面跳转 *  * @return */@RequestMapping(params = ""feeBillClosed"")public ModelAndView feeBillClosed(HttpServletRequest request) {    return new ModelAndView(""com/ygjt/oms/zj/feebillclosed/feeBillClosedList"");}/** * easyui AJAX请求数据 *  * @param request * @param response * @param dataGrid * @param user */@RequestMapping(params = ""datagrid"")public void datagrid(FeeBillClosedEntity feeBillClosedHttpServletRequest request HttpServletResponse response DataGrid dataGrid) {    CriteriaQuery cq = new CriteriaQuery(FeeBillClosedEntity.class dataGrid);    //查询条件组装器    cq.like(""comName"" feeBillClosed.getComName());    feeBillClosed.setComName(null);    cq.eq(""stat"" EnumUtils.PAY_STAT.CKECK.getValue());    org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq feeBillClosed request.getParameterMap());    try{        String query_addTime_begin = request.getParameter(""addTime_begin"");        String query_addTime_end = request.getParameter(""addTime_end"");        if (StringUtil.isNotEmpty(query_addTime_begin)) {            cq.ge(""addTime"" query_addTime_begin);        }        if (StringUtil.isNotEmpty(query_addTime_end)) {            cq.le(""addTime"" query_addTime_end);        }        String query_closedTime_begin = request.getParameter(""closedTime_begin"");        String query_closedTime_end = request.getParameter(""closedTime_end"");        if (StringUtil.isNotEmpty(query_closedTime_begin)) {            cq.ge(""closedTime"" query_closedTime_begin);        }        if (StringUtil.isNotEmpty(query_closedTime_end)) {            cq.le(""closedTime"" query_closedTime_end);        }    }catch (Exception e) {        throw new BusinessException(e.getMessage());    }    cq.add();    this.feeBillClosedService.getDataGridReturn(cq true);    List<FeeBillClosedEntity> feeBillClosedEntities = dataGrid.getResults();    for (FeeBillClosedEntity feeBillClosedEntity : feeBillClosedEntities) {        if (feeBillClosedEntity != null) {            FeeComEntity feeComEntity = systemService                    .singleResult(""from FeeComEntity where 1=1 AND ID='""                            + feeBillClosedEntity.getComFkid() + ""'"");            if (feeComEntity != null) {                EcommerceRecordEntity ecommerceRecordEntity = systemService                        .singleResult(""from EcommerceRecordEntity where 1=1 AND ID='""                                + feeComEntity.getComFkid() + ""'"");                if (ecommerceRecordEntity != null) {                    feeBillClosedEntity.setComName(ecommerceRecordEntity                            .getEcommerceName());                }                feeBillClosedEntity.setContacts(feeComEntity.getContacts());                feeBillClosedEntity.setPhone(feeComEntity.getPhone());                systemService.saveOrUpdate(feeBillClosedEntity);            }        }    }    TagUtil.datagrid(response dataGrid);}/** * 删除已结账单 *  * @return */@RequestMapping(params = ""doDel"")@ResponseBodypublic AjaxJson doDel(FeeBillClosedEntity feeBillClosed HttpServletRequest request) {    AjaxJson j = new AjaxJson();    feeBillClosed = systemService.getEntity(FeeBillClosedEntity.class feeBillClosed.getId());    message = ""已结账单删除成功"";    try{        feeBillClosedService.delete(feeBillClosed);        systemService.addLog(message Globals.Log_Type_DEL Globals.Log_Leavel_INFO);    }catch(Exception e){        e.printStackTrace();        message = ""已结账单删除失败"";        throw new BusinessException(e.getMessage());    }    j.setMsg(message);    return j;}/** * 批量删除已结账单 *  * @return */ @RequestMapping(params = ""doBatchDel"")@ResponseBodypublic AjaxJson doBatchDel(String idsHttpServletRequest request){    AjaxJson j = new AjaxJson();    message = ""已结账单删除成功"";    try{        for(String id:ids.split("")){            FeeBillClosedEntity feeBillClosed = systemService.getEntity(FeeBillClosedEntity.class             id            );            feeBillClosedService.delete(feeBillClosed);            systemService.addLog(message Globals.Log_Type_DEL Globals.Log_Leavel_INFO);        }    }catch(Exception e){        e.printStackTrace();        message = ""已结账单删除失败"";        throw new BusinessException(e.getMessage());    }    j.setMsg(message);    return j;}/** * 添加已结账单 *  * @param ids * @return */@RequestMapping(params = ""doAdd"")@ResponseBodypublic AjaxJson doAdd(FeeBillClosedEntity feeBillClosed HttpServletRequest request) {    AjaxJson j = new AjaxJson();    message = ""已结账单添加成功"";    try{        feeBillClosedService.save(feeBillClosed);        systemService.addLog(message Globals.Log_Type_INSERT Globals.Log_Leavel_INFO);    }catch(Exception e){        e.printStackTrace();        message = ""已结账单添加失败"";        throw new BusinessException(e.getMessage());    }    j.setMsg(message);    return j;}/** * 更新已结账单 *  * @param ids * @return */@RequestMapping(params = ""doUpdate"")@ResponseBodypublic AjaxJson doUpdate(FeeBillClosedEntity feeBillClosed HttpServletRequest request) {    AjaxJson j = new AjaxJson();    message = ""已结账单更新成功"";    FeeBillClosedEntity t = feeBillClosedService.get(FeeBillClosedEntity.class feeBillClosed.getId());    try {        MyBeanUtils.copyBeanNotNull2Bean(feeBillClosed t);        feeBillClosedService.saveOrUpdate(t);        systemService.addLog(message Globals.Log_Type_UPDATE Globals.Log_Leavel_INFO);    } catch (Exception e) {        e.printStackTrace();        message = ""已结账单更新失败"";        throw new BusinessException(e.getMessage());    }    j.setMsg(message);    return j;}/** * 已结账单新增页面跳转 *  * @return */@RequestMapping(params = ""goAdd"")public ModelAndView goAdd(FeeBillClosedEntity feeBillClosed HttpServletRequest req) {    if (StringUtil.isNotEmpty(feeBillClosed.getId())) {        feeBillClosed = feeBillClosedService.getEntity(FeeBillClosedEntity.class feeBillClosed.getId());        if(feeBillClosed!=null)        {             FeeComEntity feeComEntity = systemService.singleResult(""from FeeComEntity where 1=1 AND ID='""                            + feeBillClosed.getComFkid() + ""'"");             req.setAttribute(""FeeComEntityPage"" feeComEntity);//企业            if (feeComEntity != null)            {                EcommerceRecordEntity recordEntity = systemService.singleResult(""from EcommerceRecordEntity where 1=1 AND ID='""                                + feeComEntity.getComFkid() + ""'"");                req.setAttribute(""EcommerceRecordEntityPage"" recordEntity);//企业属性            }            FeeInvoiceEntity feeInvoiceEntity=systemService.singleResult(""from FeeInvoiceEntity where 1=1 AND BILL_FKID='""                        + feeBillClosed.getId() + ""'"");            if(feeInvoiceEntity!=null)            {            req.setAttribute(""FeeInvoiceEntityPage"" feeInvoiceEntity);//发票            }        }        req.setAttribute(""feeBillClosedPage"" feeBillClosed);    }    return new ModelAndView(""com/ygjt/oms/zj/feebillclosed/feeBillClosed-update"");}/** * 已结账单编辑页面跳转 *  * @return */@RequestMapping(params = ""goUpdate"")public ModelAndView goUpdate(FeeBillClosedEntity feeBillClosed HttpServletRequest req) {    if (StringUtil.isNotEmpty(feeBillClosed.getId())) {        feeBillClosed = feeBillClosedService.getEntity(FeeBillClosedEntity.class feeBillClosed.getId());        req.setAttribute(""feeBillClosedPage"" feeBillClosed);    }    return new ModelAndView(""com/ygjt/oms/zj/feebillclosed/feeBillClosed-update"");}

}

解决方案

一般junit也不会去测controller层的,spring mvc可以直接跑在tomcat这样的容器里面,然后通过浏览器测试

junit一般是测service层的

解决方案二:
谢谢大神指导!。。。可以跑去和开发说,这个不需要测了

解决方案三:
一般junit也不会去测controller层的,spring mvc可以直接跑在tomcat这样的容器里面,然后通过浏览器测试

junit一般是测service层的

时间: 2024-10-29 19:20:32

junit-JUnit不知道怎么写,求大神来一篇,然后我仿照着做啊~~~跪谢的相关文章

junit测试报错,求大神救命,控制台输出如下,

问题描述 junit测试报错,求大神救命,控制台输出如下, 0 2015-07-09 09:04:52182 [main] INFO org.springframework.beans.factory.xml.XmlBeanDefinitionReader - #org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:316)# -

编程-安卓,我写的在2个Activity间传递信息的代码,求大神来看看哪里出错了

问题描述 安卓,我写的在2个Activity间传递信息的代码,求大神来看看哪里出错了 先上一张logcat的截图: 下面开始是我的代码: 第一个activity 大概的布局如上图所示 一下activity_main.xml xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent

图片-Junit测试出问题,求大神解答

问题描述 Junit测试出问题,求大神解答 程序截图 报错:

mfc- MFC读取24位bmp图像出问题了,求大神来解决

问题描述 MFC读取24位bmp图像出问题了,求大神来解决 我要实现的是将24位bmp文件读入并在用户区显示,但是显示结果都不对的,谁能来帮忙看下? 注:因为对bmp文件还要做后续的处理(比如RGB转CMYK这样的),所以我现在写的代码只是一个测试是否正确读取bmp的程序.用其它控件去读取图片对我来说是毫无用处的. 这是我的代码: void CMy3View::OnLoad() { // TODO: 在此添加命令处理程序代码 CString strFilter,strFilename,info;

在Android开发中使用java代码的一些问题,求大神来看看。

问题描述 在Android开发中使用java代码的一些问题,求大神来看看. 1.我在MainActivity中定义一个单击事件监听器OnClickListener,这时要导入类,但是import android.view.*; 这样自己定义的OnClickListener会报错.但是 import android.view.View.*和import android.view.View.OnClickListener均不会报错.请问这是怎么回事?import android.view.*不是代表

c#-求大神来帮助C#,一个简单学生类

问题描述 求大神来帮助C#,一个简单学生类 定义枚举类型 Public enum SexType {男, 女, 未知}: Public enum ProTitle (助教,讲师,副教授.教授.未知) Public enum StuTitle {班长,副班长,学委,学员} 定义下面类 Person类(抽象类) 包含的字段:姓名Name(字符串型).身高Height(单精度型,单位:米).体重Weight(单精度,单位:kg).性别Sex(枚举类型SexType) 包含的属性:身份证号ID(字符串型

php嵌套循环分类怎么写---求大神帮帮忙呀!

问题描述 php嵌套循环分类怎么写---求大神帮帮忙呀! 鼠标悬停的时候,自动显示大分类下的小分类.(JS已经写出来了,就是php部分不会嵌套) <li class="nav-sub" data-tips="sub-school"> <a href="<{:U('Product/products')}>" class="tit">销售与支持</a> <div class=&

c语言-求大神来看看我的算法有没有可行性,最好能给点建议

问题描述 求大神来看看我的算法有没有可行性,最好能给点建议 读入一个自然数n,计算其各位数字之和,用汉语拼音写出和的每一位数字. 输入格式:每个测试输入包含1个测试用例,即给出自然数n的值.这里保证n小于10^100. 输出格式:在一行内输出n的各位数字之和的每一位,拼音数字间有1 空格,但一行中最后一个拼音数字后没有空格. 输入样例: 1234567890987654321123456789 输出样例:yi san w 我的代码如下: #include<stdio.h> #include&l

hibernate全外连接-hibernate中在一对多关系中全外连接语句怎么写,求大神

问题描述 hibernate中在一对多关系中全外连接语句怎么写,求大神 Employee 类与 Department类是多对一关系,分别对应于表s_emp 和 s_dept表 其中s_emp表中外键 dept_id, Employee中有dept成员,Department中有Set集合 hibernate.hbm.xml都配置好了,不知道怎么写 全外连接语句 String hql="select E.id,D.id from Employee E full join Department D&q