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

53 lines
1.7 KiB

package thrift;
import core.thrift.MyAsyncMethodCallback;
import core.thrift.ThriftClientPool;
import core.thrift.comment.QueryComment;
import core.thrift.task.TSDM;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.context.annotation.ComponentScan;
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
@ContextConfiguration(classes = SpringConfig.class)
@ComponentScan("core.thrift")
public class ThriftTest {
private static Logger log = LogManager.getLogger();
@Test
public void commentSum() throws Exception {
MyAsyncMethodCallback<Integer> call = new MyAsyncMethodCallback<>();
ThriftClientPool.doExecute(client -> client.commentSum(49052, call), QueryComment.AsyncClient.class);
log.info(call.getResult());
}
@Test
public void download() throws Exception {
MyAsyncMethodCallback<String> call = new MyAsyncMethodCallback<>();
ThriftClientPool.doExecute(client -> client.download(new ArrayList<Integer>() {{
add(49052);
}}, "test", call), QueryComment.AsyncClient.class);
log.info(call.getResult());
}
@Test
public void work() throws Exception {
MyAsyncMethodCallback<Boolean> call = new MyAsyncMethodCallback<>();
ThriftClientPool.doExecute(client -> client.qiandao(call), TSDM.AsyncClient.class);
log.info(call.getResult());
}
}