mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-09-19 10:08:23 +08:00
优化单元测试提示信息
This commit is contained in:
@@ -1,22 +1,30 @@
|
||||
package cn.binarywang.wx.miniapp.test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||
import cn.binarywang.wx.miniapp.config.WxMaConfig;
|
||||
import com.google.inject.Binder;
|
||||
import com.google.inject.Module;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
/**
|
||||
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||
*/
|
||||
public class ApiTestModule implements Module {
|
||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
private static final String TEST_CONFIG_XML = "test-config.xml";
|
||||
|
||||
@Override
|
||||
public void configure(Binder binder) {
|
||||
try (InputStream inputStream = ClassLoader.getSystemResourceAsStream("test-config.xml")) {
|
||||
try (InputStream inputStream = ClassLoader.getSystemResourceAsStream(TEST_CONFIG_XML)) {
|
||||
if (inputStream == null) {
|
||||
throw new RuntimeException("测试配置文件【" + TEST_CONFIG_XML + "】未找到,请参照test-config-sample.xml文件生成");
|
||||
}
|
||||
TestConfig config = TestConfig.fromXml(inputStream);
|
||||
config.setAccessTokenLock(new ReentrantLock());
|
||||
|
||||
@@ -26,7 +34,7 @@ public class ApiTestModule implements Module {
|
||||
binder.bind(WxMaService.class).toInstance(wxService);
|
||||
binder.bind(WxMaConfig.class).toInstance(config);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
this.log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user