Skip to content

Commit 33ef6eb

Browse files
committed
修复#82引入代码导致的单元测试失败的问题
1 parent 077f39c commit 33ef6eb

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceImpl.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -368,9 +368,7 @@ public <T, E> T execute(RequestExecutor<T, E> executor, String uri, E data) thro
368368
return result;
369369
} catch (WxErrorException e) {
370370
WxError error = e.getError();
371-
/**
372-
* -1 系统繁忙, 1000ms后重试
373-
*/
371+
// -1 系统繁忙, 1000ms后重试
374372
if (error.getErrorCode() == -1) {
375373
int sleepMillis = this.retrySleepMillis * (1 << retryTimes);
376374
try {

weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/ApiTestModule.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
package me.chanjar.weixin.mp.api;
22

3-
import java.io.IOException;
4-
import java.io.InputStream;
5-
63
import com.google.inject.Binder;
74
import com.google.inject.Module;
85
import com.thoughtworks.xstream.XStream;
9-
106
import me.chanjar.weixin.common.util.xml.XStreamInitializer;
117
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
128

9+
import java.io.IOException;
10+
import java.io.InputStream;
11+
import java.util.concurrent.locks.ReentrantLock;
12+
1313
public class ApiTestModule implements Module {
1414

1515
@Override
@@ -18,6 +18,7 @@ public void configure(Binder binder) {
1818
.getSystemResourceAsStream("test-config.xml")) {
1919
WxXmlMpInMemoryConfigStorage config = this
2020
.fromXml(WxXmlMpInMemoryConfigStorage.class, is1);
21+
config.setAccessTokenLock(new ReentrantLock());
2122
WxMpService wxService = new WxMpServiceImpl();
2223
wxService.setWxMpConfigStorage(config);
2324

weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxXmlMpInMemoryConfigStorage.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package me.chanjar.weixin.mp.api;
22

3+
import com.thoughtworks.xstream.annotations.XStreamAlias;
34
import org.apache.commons.lang3.builder.ToStringBuilder;
45

5-
import com.thoughtworks.xstream.annotations.XStreamAlias;
6+
import java.util.concurrent.locks.Lock;
67

78
@XStreamAlias("xml")
89
public class WxXmlMpInMemoryConfigStorage
@@ -50,4 +51,7 @@ public void setTemplateId(String templateId) {
5051
this.templateId = templateId;
5152
}
5253

53-
}
54+
public void setAccessTokenLock(Lock lock){
55+
super.accessTokenLock = lock;
56+
}
57+
}

0 commit comments

Comments
 (0)