新增数据统计接口&支付单元测试

This commit is contained in:
jy.hu
2015-01-31 00:32:06 +08:00
parent 1df0978564
commit b07033dff3
10 changed files with 43 additions and 22 deletions
@@ -24,15 +24,15 @@ import com.thoughtworks.xstream.XStream;
public class FileTokenHolder implements TokenHolder {
private final XStream xstream;
private final String tokenPath;
private final TokenCreator tokenCretor;
private final TokenCreator tokenCreator;
public FileTokenHolder(TokenCreator tokenCretor) {
this(ConfigUtil.getValue("token_path"), tokenCretor);
public FileTokenHolder(TokenCreator tokenCreator) {
this(ConfigUtil.getValue("token_path"), tokenCreator);
}
public FileTokenHolder(String tokenPath, TokenCreator tokenCretor) {
public FileTokenHolder(String tokenPath, TokenCreator tokenCreator) {
this.tokenPath = tokenPath;
this.tokenCretor = tokenCretor;
this.tokenCreator = tokenCreator;
xstream = new XStream();
xstream.ignoreUnknownElements();
xstream.autodetectAnnotations(true);
@@ -43,7 +43,7 @@ public class FileTokenHolder implements TokenHolder {
@Override
public Token getToken() throws WeixinException {
File token_file = new File(String.format("%s/%s.xml", tokenPath,
tokenCretor.getCacheKey()));
tokenCreator.getCacheKey()));
Token token = null;
Calendar ca = Calendar.getInstance();
long now_time = ca.getTimeInMillis();
@@ -57,7 +57,7 @@ public class FileTokenHolder implements TokenHolder {
return token;
}
}
token = tokenCretor.createToken();
token = tokenCreator.createToken();
xstream.toXML(token, new FileOutputStream(token_file));
} catch (IOException e) {
throw new WeixinException(e.getMessage());
@@ -7,6 +7,7 @@ import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.Consts;
import com.alibaba.fastjson.JSON;
@@ -49,6 +50,9 @@ public class MapUtil {
try {
if (encoder && lowerCase) {
for (Map.Entry<String, String> entry : set) {
if (StringUtils.isBlank(entry.getValue())) {
continue;
}
sb.append(entry.getKey().toLowerCase())
.append("=")
.append(URLEncoder.encode(entry.getValue(),
@@ -56,6 +60,9 @@ public class MapUtil {
}
} else if (encoder) {
for (Map.Entry<String, String> entry : set) {
if (StringUtils.isBlank(entry.getValue())) {
continue;
}
sb.append(entry.getKey())
.append("=")
.append(URLEncoder.encode(entry.getValue(),
@@ -63,11 +70,17 @@ public class MapUtil {
}
} else if (lowerCase) {
for (Map.Entry<String, String> entry : set) {
if (StringUtils.isBlank(entry.getValue())) {
continue;
}
sb.append(entry.getKey().toLowerCase()).append("=")
.append(entry.getValue()).append("&");
}
} else {
for (Map.Entry<String, String> entry : set) {
if (StringUtils.isBlank(entry.getValue())) {
continue;
}
sb.append(entry.getKey()).append("=")
.append(entry.getValue()).append("&");
}