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.

43 lines
1.1 KiB

  1. package me.chanjar.weixin.api;
  2. import org.apache.commons.lang3.StringUtils;
  3. import org.testng.Assert;
  4. import org.testng.annotations.Guice;
  5. import org.testng.annotations.Test;
  6. import me.chanjar.weixin.exception.WxErrorException;
  7. import com.google.inject.Inject;
  8. /**
  9. * 基础API测试
  10. * @author chanjarster
  11. *
  12. */
  13. @Test(groups = "baseAPI")
  14. @Guice(modules = ApiTestModule.class)
  15. public class WxBaseAPITest {
  16. @Inject
  17. protected WxServiceImpl wxService;
  18. public void testRefreshAccessToken() throws WxErrorException {
  19. WxConfigStorage configStorage = wxService.wxConfigStorage;
  20. String before = configStorage.getAccessToken();
  21. wxService.accessTokenRefresh();
  22. String after = configStorage.getAccessToken();
  23. Assert.assertNotEquals(before, after);
  24. Assert.assertTrue(StringUtils.isNotBlank(after));
  25. }
  26. public void testCheckSignature() throws WxErrorException {
  27. String timestamp = "1413729506";
  28. String nonce = "1753282854";
  29. String signature = "af210121811dce2d6f306612cb133cba490e818b";
  30. Assert.assertTrue(wxService.checkSignature(timestamp, nonce, signature));
  31. }
  32. }