You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
webcrawler/web/src/test/java/thrift/ThriftTest.java

54 lines
1.7 KiB

6 years ago
package thrift;
6 years ago
import core.thrift.MyAsyncMethodCallback;
import core.thrift.ThriftClientPool;
6 years ago
import core.thrift.comment.QueryComment;
import core.thrift.task.TSDM;
6 years ago
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.Test;
import org.junit.runner.RunWith;
6 years ago
import org.springframework.context.annotation.ComponentScan;
6 years ago
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.web.SpringJUnitWebConfig;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.ArrayList;
//让测试运行于Spring环境
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitWebConfig
6 years ago
@ContextConfiguration(classes = SpringConfig.class)
6 years ago
@ComponentScan("core.thrift")
6 years ago
public class ThriftTest {
private static Logger log = LogManager.getLogger();
@Test
public void commentSum() throws Exception {
6 years ago
MyAsyncMethodCallback<Integer> call = new MyAsyncMethodCallback<>();
ThriftClientPool.doExecute(client -> client.commentSum(49052, call), QueryComment.AsyncClient.class);
log.info(call.getResult());
6 years ago
}
@Test
public void download() throws Exception {
MyAsyncMethodCallback<String> call = new MyAsyncMethodCallback<>();
6 years ago
ThriftClientPool.doExecute(client -> client.download(new ArrayList<Integer>() {{
add(49052);
}}, "test", call), QueryComment.AsyncClient.class);
6 years ago
log.info(call.getResult());
}
6 years ago
@Test
public void work() throws Exception {
MyAsyncMethodCallback<Boolean> call = new MyAsyncMethodCallback<>();
6 years ago
ThriftClientPool.doExecute(client -> client.qiandao(call), TSDM.AsyncClient.class);
6 years ago
log.info(call.getResult());
}
6 years ago
}
6 years ago