UT4断言
在一个测试中,往往需要满足某种条件才能断定测试成功,而不仅仅是测试方法执行完毕.
org.junit.Assert对象提供了各种断言方法,用于判定程序的执行结果是否符合预期,从而通过测试。
1.import static org.junit.Assert.*;静态导入
2.assertEquals(sb.replace(" ",""),result);
org.junit.ComparisonFailure:
断言报错
反射 带有dubboservice注解的类
1.
@Reference注解只能引用接口,不能引用类
1.
动态获取dubbo接口
1.以上方案为2.5.3版本中的方案Reference注解已经在dubbo新版本中标记为废弃
cannot resolve import
1.clean project重新编译
使用注解通过方法映射类名
1.参考CreatBeanUtil_Resp
选择版本revert
1.通过showlog查看版本,选择需要的进行回退
revert to xxx revision
前言中不允许有内容
1.使用notepa另存为不带bom格式
挡板测试
1.即mock,如果你测试A系统,但是A系统还依赖B系统,B系统环境不好搭建或者性能可能是瓶颈,这时候,可以改一下
2.A系统调用B系统的代码,不再真正去调用了,而是直接返回一个模拟的值,最好是考虑到一般情况下调用B系统,所用的响应时间,在返回模拟值的时候,sleep一下,这样就比较真实了。
mybatis if判断
<where>
<if test="bznsTpId!=null and bznsTpId!=''">BZNS_TP_ID =#{bznsTpId}</if>
<if test="bznsTpName!=null and bznsTpName!=''"> and BZNS_TP_NAME like '%${bznsTpName}%'</if>
</where>
Error:(1, 1) java: illegal character: '\ufeff',如下
将文本转成utf-8无BOM格式
1.使用notepad++,点击编码,使用utf-8编码
mybatis的mapper.xml中参数中包含引用类型变量
1
Oracle不支持Top n查询
Mybatis中Collection集合标签的使用
1.对应的xml
<resultMap id="queryVisitHistoryResultMap" type="pojo.resp.QueryPolicyBasicInfoResp" >
<collection property="basicInfos" ofType="pojo.resp.BasicInfo">
<result column="POLICY_STATE" property="policySt" jdbcType="VARCHAR" />
2.对应的实体类
public class QueryPolicyBasicInfoResp {
@XmlElementWrapper(name="basicInfoList")
@XmlElement(name="basicInfos")
private List<BasicInfo> basicInfos ;
3.对应的报文
<TX>
<TX_HEADER/>
<TX_BODY>
<ENTITY>
<basicInfoList>
<basicInfos>
<contNo>666</contNo>
MyBatis的association和extends
1.
将文件Base64编码
resultMap Constructor???
1.必须依据resultMap特定的顺序
id -- > result --> collection
XML表头声明standalone和String index out of range: -1
1.值 no 表示这个 XML 文档不是独立的而是依赖于外部所定义的一个 DTD. 值 yes 表示这个 XML 文档是自包含的(self-contained);
2.如果是yes,则表示这个XML文档时独立的,不能引用外部的DTD规范文件.
Mybatis-oracle时间范围查询
1.数据库类型date,传入是string
<![CDATA[ and g.create_time >= to_date(#{minCreateTime,jdbcType=DATE},'yyyyMMdd')]]>
或者
AND CREATE_DT <![CDATA[>=]]> to_date(#{createBeginDt}, 'yyyyMMdd')
2.jdbcType为date,bean为String
3.同为字符串
HTTPClient/mq/fel/定时/触发
unable to marshal type "java.util.ArrayList" as an element because it is missing an @XmlRootElement annotation
1.尝试不直接使用List返回
2.使用list转xml字符串的工具类
#unable to parse template class
1.原class template配置
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
#parse("File Header.java")
public class ${NAME} {
}
Cause: java.lang.IllegalArgumentException: invalid comparison: java.util.ArrayList and java.lang.String
在动态sql语句中如果出现了list!=‘ ’这样的判断,就会把传进来的list当做string处理,因此在循环中就会出错;
Spring声明式事务管理方式
1.在基于tx和aop名字空间的xml配置文件中做相关的事务规则声明
2.通过基于@Transactional注解的方式
--@Transactional 注解只能应用到 public 方法才有效;
--在默认的代理模式下,只有目标方法由外部调用,才能被 Spring 的事务拦截器拦截。在同一个类中的两个方法直接调用,是不会被 Spring 的事务拦截器拦截的;
HttpClient测试
1.工具类使用
使用多if test判断时, where 和 and 的尴尬位置
where 1 = 1 ,现在知道是做什么的了吧
MyBatis List<HashMap<String, Object>>
1.首先xml没有配置resultMap
<select id="selectappointTms" parameterType="com.ccblife.cccp.co.business.pojo.req.QueryAppointmentListReq" resultType="java.util.HashMap">
SELECT
a1.POLICY_NO as contNo,
COUNT(a1.POLICY_NO) as times
FROM
T_APPOINTMENT a1
WHERE a1.POLICY_NO in
(
......
)
GROUP BY
a1.POLICY_NO
2.mapper.java中,map的value泛型为Object
@Repository
public interface TAppoinTmentMapper extends BaseMapper<TAppoinTment> {
List<HashMap<String, Object>> selectappointTms (QueryAppointmentListReq req);
}
3.在java类中,转换成map代码如
List<HashMap<String, Object>> hashMapList = mapper.selectappointTms(req);
HashMap<String, Object> resultMap = new HashMap<String, Object>();
for (Map<String, Object> map : hashMapList) {
String contNo = null;
Integer times = null;
for (Map.Entry<String, Object> entry : map.entrySet()) {
if ("CONTNO".equals(entry.getKey())) {
contNo = entry.getValue() + "";
}else if ("TIMES".equals(entry.getKey())) {
//没有配置resultMap,默认的数字类型是BigDecimal,不知直接用Integer强转
times = ((java.math.BigDecimal) entry.getValue()).intValue();
}
}
resultMap.put(contNo, times);
}
for(QueryAppointmentListResp resp : resps){
resp.setAppointTms(resultMap.get(resp.getContNo()) + "");
}
网友评论