WxCpService添加getWxMpConfigStorage方法,同时修改相关位置

This commit is contained in:
ecoolper 2017-04-27 20:24:42 +08:00
parent d01d372b65
commit f42b22f5c1
5 changed files with 25 additions and 1 deletions

View File

@ -556,4 +556,11 @@ public interface WxCpService {
* 初始化http请求对象
*/
void initHttp();
/**
* 获取WxMpConfigStorage 对象
*
* @return WxMpConfigStorage
*/
WxCpConfigStorage getWxMpConfigStorage();
}

View File

@ -6,6 +6,7 @@ import me.chanjar.weixin.common.bean.result.WxError;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder;
import me.chanjar.weixin.common.util.http.apache.DefaultApacheHttpClientBuilder;
import me.chanjar.weixin.cp.api.WxCpConfigStorage;
import me.chanjar.weixin.cp.api.impl.AbstractWxCpService;
import org.apache.http.HttpHost;
@ -91,4 +92,9 @@ public class WxCpServiceImpl extends AbstractWxCpService<CloseableHttpClient, Ht
this.httpClient = apacheHttpClientBuilder.build();
}
@Override
public WxCpConfigStorage getWxMpConfigStorage() {
return this.configStorage;
}
}

View File

@ -4,6 +4,7 @@ import jodd.http.*;
import me.chanjar.weixin.common.bean.WxAccessToken;
import me.chanjar.weixin.common.bean.result.WxError;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.cp.api.WxCpConfigStorage;
import me.chanjar.weixin.cp.api.impl.AbstractWxCpService;
public class WxCpServiceImpl extends AbstractWxCpService<HttpConnectionProvider, ProxyInfo> {
@ -62,4 +63,9 @@ public class WxCpServiceImpl extends AbstractWxCpService<HttpConnectionProvider,
httpClient = JoddHttp.httpConnectionProvider;
}
@Override
public WxCpConfigStorage getWxMpConfigStorage() {
return this.configStorage;
}
}

View File

@ -87,4 +87,9 @@ public class WxCpServiceImpl extends AbstractWxCpService<ConnectionPool, OkhttpP
httpClient = new ConnectionPool();
}
@Override
public WxCpConfigStorage getWxMpConfigStorage() {
return this.configStorage;
}
}

View File

@ -21,7 +21,7 @@ public class WxCpMessageAPITest {
protected WxCpServiceImpl wxService;
public void testSendCustomMessage() throws WxErrorException {
ApiTestModule.WxXmlCpInMemoryConfigStorage configStorage = (ApiTestModule.WxXmlCpInMemoryConfigStorage) this.wxService.configStorage;
ApiTestModule.WxXmlCpInMemoryConfigStorage configStorage = (ApiTestModule.WxXmlCpInMemoryConfigStorage) this.wxService.getWxMpConfigStorage();
WxCpMessage message1 = new WxCpMessage();
message1.setAgentId(configStorage.getAgentId());
message1.setMsgType(WxConsts.CUSTOM_MSG_TEXT);