code clean up for common module
This commit is contained in:
@@ -14,5 +14,5 @@ public class WxAccessTokenTest {
|
||||
Assert.assertTrue(wxError.getExpiresIn() == 7200);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ public class WxErrorTest {
|
||||
Assert.assertEquals(wxError.getErrorMsg(), "invalid openid");
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void testFromBadJson1() {
|
||||
|
||||
String json = "{ \"errcode\": 40003, \"errmsg\": \"invalid openid\", \"media_id\": \"12323423dsfafsf232f\" }";
|
||||
@@ -24,7 +24,7 @@ public class WxErrorTest {
|
||||
Assert.assertEquals(wxError.getErrorMsg(), "invalid openid");
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void testFromBadJson2() {
|
||||
|
||||
String json = "{\"access_token\":\"ACCESS_TOKEN\",\"expires_in\":7200}";
|
||||
@@ -33,5 +33,5 @@ public class WxErrorTest {
|
||||
Assert.assertEquals(wxError.getErrorMsg(), null);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -8,51 +8,51 @@ import org.testng.annotations.Test;
|
||||
@Test
|
||||
public class WxMenuTest {
|
||||
|
||||
@Test(dataProvider="wxReturnMenu")
|
||||
@Test(dataProvider = "wxReturnMenu")
|
||||
public void testFromJson(String json) {
|
||||
WxMenu menu = WxMenu.fromJson(json);
|
||||
Assert.assertEquals(menu.getButtons().size(), 3);
|
||||
}
|
||||
|
||||
@Test(dataProvider="wxPushMenu")
|
||||
|
||||
@Test(dataProvider = "wxPushMenu")
|
||||
public void testToJson(String json) {
|
||||
WxMenu menu = new WxMenu();
|
||||
WxMenuButton button1 = new WxMenuButton();
|
||||
button1.setType("click");
|
||||
button1.setName("今日歌曲");
|
||||
button1.setKey("V1001_TODAY_MUSIC");
|
||||
|
||||
|
||||
WxMenuButton button2 = new WxMenuButton();
|
||||
button2.setType("click");
|
||||
button2.setName("歌手简介");
|
||||
button2.setKey("V1001_TODAY_SINGER");
|
||||
|
||||
|
||||
WxMenuButton button3 = new WxMenuButton();
|
||||
button3.setName("菜单");
|
||||
|
||||
|
||||
menu.getButtons().add(button1);
|
||||
menu.getButtons().add(button2);
|
||||
menu.getButtons().add(button3);
|
||||
|
||||
|
||||
WxMenuButton button31 = new WxMenuButton();
|
||||
button31.setType("view");
|
||||
button31.setName("搜索");
|
||||
button31.setUrl("http://www.soso.com/");
|
||||
|
||||
|
||||
WxMenuButton button32 = new WxMenuButton();
|
||||
button32.setType("view");
|
||||
button32.setName("视频");
|
||||
button32.setUrl("http://v.qq.com/");
|
||||
|
||||
|
||||
WxMenuButton button33 = new WxMenuButton();
|
||||
button33.setType("click");
|
||||
button33.setName("赞一下我们");
|
||||
button33.setKey("V1001_GOOD");
|
||||
|
||||
|
||||
button3.getSubButtons().add(button31);
|
||||
button3.getSubButtons().add(button32);
|
||||
button3.getSubButtons().add(button33);
|
||||
|
||||
|
||||
Assert.assertEquals(menu.toJson(), json);
|
||||
}
|
||||
|
||||
@@ -78,82 +78,82 @@ public class WxMenuTest {
|
||||
|
||||
Assert.assertEquals(menu.toJson(), json);
|
||||
}
|
||||
|
||||
|
||||
@DataProvider
|
||||
public Object[][] wxReturnMenu() {
|
||||
Object[][] res = menuJson();
|
||||
Object[][] res = menuJson();
|
||||
String json = "{ \"menu\" : " + res[0][0] + " }";
|
||||
return new Object[][] {
|
||||
new Object[] { json }
|
||||
return new Object[][]{
|
||||
new Object[]{json}
|
||||
};
|
||||
}
|
||||
|
||||
@DataProvider(name="wxPushMenu")
|
||||
|
||||
@DataProvider(name = "wxPushMenu")
|
||||
public Object[][] menuJson() {
|
||||
String json =
|
||||
"{"
|
||||
+"\"button\":["
|
||||
+"{"
|
||||
+"\"type\":\"click\","
|
||||
+"\"name\":\"今日歌曲\","
|
||||
+"\"key\":\"V1001_TODAY_MUSIC\""
|
||||
+"},"
|
||||
+"{"
|
||||
+"\"type\":\"click\","
|
||||
+"\"name\":\"歌手简介\","
|
||||
+"\"key\":\"V1001_TODAY_SINGER\""
|
||||
+"},"
|
||||
+"{"
|
||||
+"\"name\":\"菜单\","
|
||||
+"\"sub_button\":["
|
||||
+"{"
|
||||
+"\"type\":\"view\","
|
||||
+"\"name\":\"搜索\","
|
||||
+"\"url\":\"http://www.soso.com/\""
|
||||
+"},"
|
||||
+"{"
|
||||
+"\"type\":\"view\","
|
||||
+"\"name\":\"视频\","
|
||||
+"\"url\":\"http://v.qq.com/\""
|
||||
+"},"
|
||||
+"{"
|
||||
+"\"type\":\"click\","
|
||||
+"\"name\":\"赞一下我们\","
|
||||
+"\"key\":\"V1001_GOOD\""
|
||||
+"}"
|
||||
+"]"
|
||||
+"}"
|
||||
+"]"
|
||||
+"}";
|
||||
return new Object[][] {
|
||||
new Object[] { json }
|
||||
String json =
|
||||
"{"
|
||||
+ "\"button\":["
|
||||
+ "{"
|
||||
+ "\"type\":\"click\","
|
||||
+ "\"name\":\"今日歌曲\","
|
||||
+ "\"key\":\"V1001_TODAY_MUSIC\""
|
||||
+ "},"
|
||||
+ "{"
|
||||
+ "\"type\":\"click\","
|
||||
+ "\"name\":\"歌手简介\","
|
||||
+ "\"key\":\"V1001_TODAY_SINGER\""
|
||||
+ "},"
|
||||
+ "{"
|
||||
+ "\"name\":\"菜单\","
|
||||
+ "\"sub_button\":["
|
||||
+ "{"
|
||||
+ "\"type\":\"view\","
|
||||
+ "\"name\":\"搜索\","
|
||||
+ "\"url\":\"http://www.soso.com/\""
|
||||
+ "},"
|
||||
+ "{"
|
||||
+ "\"type\":\"view\","
|
||||
+ "\"name\":\"视频\","
|
||||
+ "\"url\":\"http://v.qq.com/\""
|
||||
+ "},"
|
||||
+ "{"
|
||||
+ "\"type\":\"click\","
|
||||
+ "\"name\":\"赞一下我们\","
|
||||
+ "\"key\":\"V1001_GOOD\""
|
||||
+ "}"
|
||||
+ "]"
|
||||
+ "}"
|
||||
+ "]"
|
||||
+ "}";
|
||||
return new Object[][]{
|
||||
new Object[]{json}
|
||||
};
|
||||
}
|
||||
|
||||
@DataProvider(name = "wxAddConditionalMenu")
|
||||
public Object[][] addConditionalMenuJson(){
|
||||
public Object[][] addConditionalMenuJson() {
|
||||
String json =
|
||||
"{"
|
||||
+"\"button\":["
|
||||
+"{"
|
||||
+"\"type\":\"click\","
|
||||
+"\"name\":\"今日歌曲\","
|
||||
+"\"key\":\"V1001_TODAY_MUSIC\""
|
||||
+"}"
|
||||
+"],"
|
||||
+"\"matchrule\":{"
|
||||
+"\"group_id\":\"2\","
|
||||
+"\"sex\":\"1\","
|
||||
+"\"country\":\"中国\","
|
||||
+"\"province\":\"广东\","
|
||||
+"\"city\":\"广州\","
|
||||
+"\"client_platform_type\":\"2\","
|
||||
+"\"language\":\"zh_CN\""
|
||||
+"}"
|
||||
+"}";
|
||||
"{"
|
||||
+ "\"button\":["
|
||||
+ "{"
|
||||
+ "\"type\":\"click\","
|
||||
+ "\"name\":\"今日歌曲\","
|
||||
+ "\"key\":\"V1001_TODAY_MUSIC\""
|
||||
+ "}"
|
||||
+ "],"
|
||||
+ "\"matchrule\":{"
|
||||
+ "\"group_id\":\"2\","
|
||||
+ "\"sex\":\"1\","
|
||||
+ "\"country\":\"中国\","
|
||||
+ "\"province\":\"广东\","
|
||||
+ "\"city\":\"广州\","
|
||||
+ "\"client_platform_type\":\"2\","
|
||||
+ "\"language\":\"zh_CN\""
|
||||
+ "}"
|
||||
+ "}";
|
||||
return new Object[][]{
|
||||
new Object[]{json}
|
||||
new Object[]{json}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@ public class SessionTest {
|
||||
@DataProvider
|
||||
public Object[][] getSessionManager() {
|
||||
|
||||
return new Object[][] {
|
||||
new Object[] { new StandardSessionManager() }
|
||||
return new Object[][]{
|
||||
new Object[]{new StandardSessionManager()}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import org.testng.annotations.Test;
|
||||
public class WxMessageInMemoryDuplicateCheckerTest {
|
||||
|
||||
public void test() throws InterruptedException {
|
||||
Long[] msgIds = new Long[] { 1l, 2l, 3l, 4l, 5l, 6l, 7l, 8l };
|
||||
Long[] msgIds = new Long[]{1l, 2l, 3l, 4l, 5l, 6l, 7l, 8l};
|
||||
WxMessageInMemoryDuplicateChecker checker = new WxMessageInMemoryDuplicateChecker(2000l, 1000l);
|
||||
|
||||
// 第一次检查
|
||||
|
||||
@@ -69,7 +69,7 @@ public class WxCryptUtilTest {
|
||||
}
|
||||
|
||||
public void testValidateSignatureError() throws ParserConfigurationException, SAXException,
|
||||
IOException {
|
||||
IOException {
|
||||
try {
|
||||
WxCryptUtil pc = new WxCryptUtil(token, encodingAesKey, appId);
|
||||
String afterEncrpt = pc.encrypt(replyMsg);
|
||||
|
||||
Reference in New Issue
Block a user