1
0
mirror of synced 2026-02-16 10:07:54 +08:00

#985 修复多WxApp场景下initHttp方法执行时的空指针异常错误

This commit is contained in:
liaochuntao
2019-03-26 22:09:49 +08:00
committed by Binary Wang
parent 28c03d71db
commit 0937ac85b1
6 changed files with 122 additions and 23 deletions

View File

@@ -85,6 +85,53 @@ public class WxMpMenuServiceImplTest {
"}";
this.menuId = this.wxService.getMenuService().menuCreate(json);
if (this.wxService.switchover("test-1")) {
this.menuId = this.wxService.getMenuService().menuCreate(json);
}
System.out.println(this.menuId);
}
@Test
public void testMultiCreateConditionalMenu() throws WxErrorException {
String json = "{\n" +
" \"button\":[\n" +
" { \n" +
" \"type\":\"click\",\n" +
" \"name\":\"今日歌曲\",\n" +
" \"key\":\"V1001_TODAY_MUSIC\" \n" +
" },\n" +
" { \n" +
" \"name\":\"菜单\",\n" +
" \"sub_button\":[\n" +
" { \n" +
" \"type\":\"view\",\n" +
" \"name\":\"搜索\",\n" +
" \"url\":\"http://www.soso.com/\"\n" +
" },\n" +
" {\n" +
" \"type\":\"view\",\n" +
" \"name\":\"视频\",\n" +
" \"url\":\"http://v.qq.com/\"\n" +
" },\n" +
" {\n" +
" \"type\":\"click\",\n" +
" \"name\":\"赞一下我们\",\n" +
" \"key\":\"V1001_GOOD\"\n" +
" }]\n" +
" }],\n" +
"\"matchrule\":{\n" +
" \"tag_id\":\"2\",\n" +
" \"sex\":\"1\",\n" +
" \"country\":\"中国\",\n" +
" \"province\":\"广东\",\n" +
" \"city\":\"广州\",\n" +
" \"client_platform_type\":\"2\",\n" +
" \"language\":\"zh_CN\"\n" +
" }\n" +
"}";
if (this.wxService.switchover("test-1")) {
this.menuId = this.wxService.getMenuService().menuCreate(json);
}
System.out.println(this.menuId);
}

View File

@@ -2,6 +2,8 @@ package me.chanjar.weixin.mp.api.test;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.locks.ReentrantLock;
import me.chanjar.weixin.mp.api.impl.WxMpServiceHttpClientImpl;
@@ -29,11 +31,14 @@ public class ApiTestModule implements Module {
TestConfigStorage config = this.fromXml(TestConfigStorage.class, inputStream);
config.setAccessTokenLock(new ReentrantLock());
WxMpService wxService = new WxMpServiceHttpClientImpl();
wxService.setWxMpConfigStorage(config);
WxMpService wxMpServiceMulti = new WxMpServiceHttpClientImpl();
// TODO 多WxAppId
wxMpServiceMulti.setWxMpConfigStorage(config);
wxMpServiceMulti.addWxMpConfigStorage("test-1", config);
binder.bind(WxMpService.class).toInstance(wxService);
binder.bind(WxMpConfigStorage.class).toInstance(config);
binder.bind(WxMpService.class).toInstance(wxMpServiceMulti);
} catch (IOException e) {
this.log.error(e.getMessage(), e);
}