mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-03-10 00:13:40 +08:00
fix warnings
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
package me.chanjar.weixin.cp.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 com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
import me.chanjar.weixin.common.util.xml.XStreamInitializer;
|
||||
|
||||
import java.io.InputStream;
|
||||
import me.chanjar.weixin.common.util.xml.XStreamInitializer;
|
||||
|
||||
public class ApiTestModule implements Module {
|
||||
|
||||
@@ -19,13 +21,18 @@ public class ApiTestModule implements Module {
|
||||
|
||||
@Override
|
||||
public void configure(Binder binder) {
|
||||
InputStream is1 = ClassLoader.getSystemResourceAsStream("test-config.xml");
|
||||
WxXmlCpInMemoryConfigStorage config = fromXml(WxXmlCpInMemoryConfigStorage.class, is1);
|
||||
WxCpServiceImpl wxService = new WxCpServiceImpl();
|
||||
wxService.setWxCpConfigStorage(config);
|
||||
try (InputStream is1 = ClassLoader
|
||||
.getSystemResourceAsStream("test-config.xml")) {
|
||||
WxXmlCpInMemoryConfigStorage config = fromXml(
|
||||
WxXmlCpInMemoryConfigStorage.class, is1);
|
||||
WxCpServiceImpl wxService = new WxCpServiceImpl();
|
||||
wxService.setWxCpConfigStorage(config);
|
||||
|
||||
binder.bind(WxCpServiceImpl.class).toInstance(wxService);
|
||||
binder.bind(WxCpConfigStorage.class).toInstance(config);
|
||||
binder.bind(WxCpServiceImpl.class).toInstance(wxService);
|
||||
binder.bind(WxCpConfigStorage.class).toInstance(config);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@XStreamAlias("xml")
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
package me.chanjar.weixin.cp.api;
|
||||
|
||||
import me.chanjar.weixin.common.bean.result.WxError;
|
||||
import me.chanjar.weixin.common.exception.WxErrorException;
|
||||
import me.chanjar.weixin.common.util.http.RequestExecutor;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import me.chanjar.weixin.common.bean.result.WxError;
|
||||
import me.chanjar.weixin.common.exception.WxErrorException;
|
||||
import me.chanjar.weixin.common.util.http.RequestExecutor;
|
||||
|
||||
@Test
|
||||
public class WxCpBusyRetryTest {
|
||||
|
||||
@@ -19,7 +20,9 @@ public class WxCpBusyRetryTest {
|
||||
WxCpService service = new WxCpServiceImpl() {
|
||||
|
||||
@Override
|
||||
protected <T, E> T executeInternal(RequestExecutor<T, E> executor, String uri, E data) throws WxErrorException {
|
||||
protected synchronized <T, E> T executeInternal(
|
||||
RequestExecutor<T, E> executor, String uri, E data)
|
||||
throws WxErrorException {
|
||||
WxError error = new WxError();
|
||||
error.setErrorCode(-1);
|
||||
throw new WxErrorException(error);
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
package me.chanjar.weixin.cp.api;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import me.chanjar.weixin.common.exception.WxErrorException;
|
||||
import me.chanjar.weixin.cp.bean.WxCpDepart;
|
||||
import java.util.List;
|
||||
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Guice;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.List;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import me.chanjar.weixin.common.exception.WxErrorException;
|
||||
import me.chanjar.weixin.cp.bean.WxCpDepart;
|
||||
|
||||
/**
|
||||
* 测试部门接口
|
||||
@@ -24,11 +26,12 @@ public class WxCpDepartAPITest {
|
||||
protected WxCpDepart depart;
|
||||
|
||||
public void testDepartCreate() throws WxErrorException {
|
||||
WxCpDepart depart = new WxCpDepart();
|
||||
depart.setName("子部门" + System.currentTimeMillis());
|
||||
depart.setParentId(1);
|
||||
depart.setOrder(1);
|
||||
Integer departId = this.wxCpService.departCreate(depart);
|
||||
WxCpDepart cpDepart = new WxCpDepart();
|
||||
cpDepart.setName("子部门" + System.currentTimeMillis());
|
||||
cpDepart.setParentId(1);
|
||||
cpDepart.setOrder(1);
|
||||
Integer departId = this.wxCpService.departCreate(cpDepart);
|
||||
System.out.println(departId);
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "testDepartCreate")
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
package me.chanjar.weixin.cp.api;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import me.chanjar.weixin.common.api.WxConsts;
|
||||
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
|
||||
import me.chanjar.weixin.common.exception.WxErrorException;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Guice;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Guice;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import me.chanjar.weixin.common.api.WxConsts;
|
||||
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
|
||||
import me.chanjar.weixin.common.exception.WxErrorException;
|
||||
|
||||
/**
|
||||
* 测试多媒体文件上传下载
|
||||
*
|
||||
@@ -31,17 +33,21 @@ public class WxCpMediaAPITest {
|
||||
|
||||
@Test(dataProvider = "uploadMedia")
|
||||
public void testUploadMedia(String mediaType, String fileType, String fileName) throws WxErrorException, IOException {
|
||||
InputStream inputStream = ClassLoader.getSystemResourceAsStream(fileName);
|
||||
WxMediaUploadResult res = this.wxService.mediaUpload(mediaType, fileType, inputStream);
|
||||
Assert.assertNotNull(res.getType());
|
||||
Assert.assertNotNull(res.getCreatedAt());
|
||||
Assert.assertTrue(res.getMediaId() != null || res.getThumbMediaId() != null);
|
||||
try (InputStream inputStream = ClassLoader
|
||||
.getSystemResourceAsStream(fileName);) {
|
||||
WxMediaUploadResult res = this.wxService.mediaUpload(mediaType, fileType,
|
||||
inputStream);
|
||||
Assert.assertNotNull(res.getType());
|
||||
Assert.assertNotNull(res.getCreatedAt());
|
||||
Assert.assertTrue(
|
||||
res.getMediaId() != null || res.getThumbMediaId() != null);
|
||||
|
||||
if (res.getMediaId() != null) {
|
||||
this.media_ids.add(res.getMediaId());
|
||||
}
|
||||
if (res.getThumbMediaId() != null) {
|
||||
this.media_ids.add(res.getThumbMediaId());
|
||||
if (res.getMediaId() != null) {
|
||||
this.media_ids.add(res.getMediaId());
|
||||
}
|
||||
if (res.getThumbMediaId() != null) {
|
||||
this.media_ids.add(res.getThumbMediaId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user