pull/1/MERGE
tanghc 5 years ago
parent 554520d4b8
commit 7b7ccf0e08
  1. 1
      sop-test/src/test/java/com/gitee/sop/test/AlipayClientPostTest.java
  2. 14
      sop-test/src/test/java/com/gitee/sop/test/TestBase.java

@ -56,6 +56,7 @@ public class AlipayClientPostTest extends TestBase {
System.out.println("----------- 请求信息 -----------");
System.out.println("请求参数:" + buildParamQuery(params));
System.out.println("URL参数:" + buildUrlQuery(params));
System.out.println("商户秘钥:" + privateKey);
String content = AlipaySignature.getSignContent(params);
System.out.println("待签名内容:" + content);

@ -5,6 +5,8 @@ import junit.framework.TestCase;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Collections;
import java.util.Map;
@ -73,4 +75,16 @@ public class TestBase extends TestCase {
return sb.toString().substring(1);
}
protected static String buildUrlQuery(Map<String, String> params) {
StringBuilder sb = new StringBuilder();
for (Map.Entry<String, String> entry : params.entrySet()) {
try {
sb.append("&").append(entry.getKey()).append("=").append(URLEncoder.encode(entry.getValue(), "UTF-8"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
return sb.toString().substring(1);
}
}

Loading…
Cancel
Save