Browse Source

修复#82引入代码导致的单元测试失败的问题

master
Binary Wang 8 years ago
parent
commit
33ef6ebbe9
3 changed files with 12 additions and 9 deletions
  1. +1
    -3
      weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceImpl.java
  2. +5
    -4
      weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/ApiTestModule.java
  3. +6
    -2
      weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxXmlMpInMemoryConfigStorage.java

+ 1
- 3
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceImpl.java View File

@@ -368,9 +368,7 @@ public class WxMpServiceImpl implements WxMpService {
return result;
} catch (WxErrorException e) {
WxError error = e.getError();
/**
* -1 系统繁忙, 1000ms后重试
*/
// -1 系统繁忙, 1000ms后重试
if (error.getErrorCode() == -1) {
int sleepMillis = this.retrySleepMillis * (1 << retryTimes);
try {


+ 5
- 4
weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/ApiTestModule.java View File

@@ -1,15 +1,15 @@
package me.chanjar.weixin.mp.api;

import java.io.IOException;
import java.io.InputStream;

import com.google.inject.Binder;
import com.google.inject.Module;
import com.thoughtworks.xstream.XStream;

import me.chanjar.weixin.common.util.xml.XStreamInitializer;
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;

import java.io.IOException;
import java.io.InputStream;
import java.util.concurrent.locks.ReentrantLock;

public class ApiTestModule implements Module {

@Override
@@ -18,6 +18,7 @@ public class ApiTestModule implements Module {
.getSystemResourceAsStream("test-config.xml")) {
WxXmlMpInMemoryConfigStorage config = this
.fromXml(WxXmlMpInMemoryConfigStorage.class, is1);
config.setAccessTokenLock(new ReentrantLock());
WxMpService wxService = new WxMpServiceImpl();
wxService.setWxMpConfigStorage(config);



+ 6
- 2
weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxXmlMpInMemoryConfigStorage.java View File

@@ -1,8 +1,9 @@
package me.chanjar.weixin.mp.api;

import com.thoughtworks.xstream.annotations.XStreamAlias;
import org.apache.commons.lang3.builder.ToStringBuilder;

import com.thoughtworks.xstream.annotations.XStreamAlias;
import java.util.concurrent.locks.Lock;

@XStreamAlias("xml")
public class WxXmlMpInMemoryConfigStorage
@@ -50,4 +51,7 @@ public class WxXmlMpInMemoryConfigStorage
this.templateId = templateId;
}

}
public void setAccessTokenLock(Lock lock){
super.accessTokenLock = lock;
}
}

Loading…
Cancel
Save