dev --- 3.8.0.A版本, openProject引用 ; formao-live --- 3.7.0.B 版本, formallProject引用
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 line
2.4 KiB

  1. package chanjarster.weixin.api;
  2. import javax.xml.bind.JAXBException;
  3. import org.testng.Assert;
  4. import org.testng.annotations.DataProvider;
  5. import org.testng.annotations.Guice;
  6. import org.testng.annotations.Test;
  7. import com.google.inject.Inject;
  8. import chanjarster.weixin.bean.WxMenu;
  9. import chanjarster.weixin.bean.WxMenu.WxMenuButton;
  10. import chanjarster.weixin.exception.WxErrorException;
  11. /**
  12. * 测试菜单
  13. * @author chanjarster
  14. *
  15. */
  16. @Test(groups="menuAPI", dependsOnGroups="baseAPI")
  17. @Guice(modules = ApiTestModule.class)
  18. public class WxMenuAPITest {
  19. @Inject
  20. protected WxServiceImpl wxService;
  21. @Test(dataProvider = "menu", enabled = true)
  22. public void testCreateMenu(WxMenu wxMenu) throws WxErrorException {
  23. wxService.menuCreate(wxMenu);
  24. }
  25. @Test(dependsOnMethods = { "testCreateMenu"}, enabled = true)
  26. public void testGetMenu() throws WxErrorException {
  27. Assert.assertNotNull(wxService.menuGet());
  28. }
  29. @Test(dependsOnMethods = { "testGetMenu"}, enabled = true)
  30. public void testDeleteMenu() throws WxErrorException {
  31. wxService.menuDelete();
  32. }
  33. @DataProvider(name="menu")
  34. public Object[][] getMenu() throws JAXBException {
  35. WxMenu menu = new WxMenu();
  36. WxMenuButton button1 = new WxMenuButton();
  37. button1.setType("click");
  38. button1.setName("今日歌曲");
  39. button1.setKey("V1001_TODAY_MUSIC");
  40. WxMenuButton button2 = new WxMenuButton();
  41. button2.setType("click");
  42. button2.setName("歌手简介");
  43. button2.setKey("V1001_TODAY_SINGER");
  44. WxMenuButton button3 = new WxMenuButton();
  45. button3.setName("菜单");
  46. menu.getButton().add(button1);
  47. menu.getButton().add(button2);
  48. menu.getButton().add(button3);
  49. WxMenuButton button31 = new WxMenuButton();
  50. button31.setType("view");
  51. button31.setName("搜索");
  52. button31.setUrl("http://www.soso.com/");
  53. WxMenuButton button32 = new WxMenuButton();
  54. button32.setType("view");
  55. button32.setName("视频");
  56. button32.setUrl("http://v.qq.com/");
  57. WxMenuButton button33 = new WxMenuButton();
  58. button33.setType("click");
  59. button33.setName("赞一下我们");
  60. button33.setKey("V1001_GOOD");
  61. button3.getSub_button().add(button31);
  62. button3.getSub_button().add(button32);
  63. button3.getSub_button().add(button33);
  64. return new Object[][] {
  65. new Object[] {
  66. menu
  67. }
  68. };
  69. }
  70. }