Skip to content

Instantly share code, notes, and snippets.

@yongchun
yongchun / ClassProperty2KeyUtil.java
Created January 8, 2014 02:00
自动化测试原型
package com.snda.sysdev.util;
import com.snda.sysdev.template.bean.InterfaceFuncParam;
import org.springframework.beans.BeanUtils;
import sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl;
import java.beans.PropertyDescriptor;
import java.lang.reflect.*;
import java.util.ArrayList;
import java.util.Collection;
@yongchun
yongchun / pom.xml
Created December 27, 2013 13:20
testng+jmock单元测试pom配置
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8.5</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.5</version>
@yongchun
yongchun / IdcServiceTest.java
Last active January 1, 2016 12:49
service层
import com.XXX.sysdev.virtualsys.BaseTest;
import com.XXX.sysdev.virtualsys.dao.IdcDao;
import com.XXX.sysdev.virtualsys.model.Idc;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@yongchun
yongchun / BaseTest.java
Last active January 1, 2016 12:49
tentng+jmock的单元测试
import org.mockito.MockitoAnnotations;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.springframework.test.context.transaction.TransactionConfiguration;
import org.springframework.transaction.annotation.Transactional;
import org.testng.annotations.BeforeClass;
@ContextConfiguration({
@yongchun
yongchun / cankaowendang.txt
Created December 26, 2013 07:03
git和gerrit push配置
http://qt-project.org/wiki/Gerrit-Introduction
@yongchun
yongchun / DetachedCriteria.java
Created December 26, 2013 05:42
使用DetachedCriteria和Restrictions构建hibernate的动态sql语句(1)
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
@yongchun
yongchun / Restrictions.java
Created December 26, 2013 05:41
使用DetachedCriteria和Restrictions构建hibernate的动态sql语句(2)
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
@yongchun
yongchun / delete_remove.sh
Created December 26, 2013 04:55
shell脚本,删除和移动文件
#!/bin/bash
#可以修改为工程所在的目录
user=yourhome
apphome=virtualinterface
appdir=/root/${user}/${apphome}
appdir_back=/root/${user}/${apphome}_back
@yongchun
yongchun / HttpMethodRetryHandler.java
Created November 28, 2013 09:14
HttpClient处理失败的时候重试
HttpClient client = new HttpClient();
HttpMethodRetryHandler myretryhandler = new HttpMethodRetryHandler() {
public boolean retryMethod(
final HttpMethod method,
final IOException exception,
int executionCount) {
if (executionCount >= 5) {
// Do not retry if over max retry count
return false;
@yongchun
yongchun / IDCViewAction.java
Created November 28, 2013 08:23
JSP页面到处excel解决中文名乱码
HSSFWorkbook wb = getExcelData(ippes);
response.setContentType("application/octet-stream");
if(StringUtils.isNotEmpty(timeSession)){
startTimeStr = new Date(new Date().getTime()-24*60*60*1000);
endTimeStr = new Date();
}
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("IP端口流量-from-" + sdf.format(startTimeStr) + "-to-" + sdf.format(endTimeStr) + ".xls","UTF-8") );
wb.write(response.getOutputStream());
response.getOutputStream().flush();
response.getOutputStream().close();