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.
44 lines
1.4 KiB
44 lines
1.4 KiB
package thrift;
|
|
|
|
import core.thrift.FactoryPool;
|
|
import core.thrift.MyAsyncMethodCallback;
|
|
import core.thrift.comment.QueryComment;
|
|
import org.apache.logging.log4j.LogManager;
|
|
import org.apache.logging.log4j.Logger;
|
|
import org.junit.Test;
|
|
import org.junit.runner.RunWith;
|
|
import org.springframework.test.context.ContextConfiguration;
|
|
import org.springframework.test.context.junit.jupiter.web.SpringJUnitWebConfig;
|
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
//让测试运行于Spring环境
|
|
@RunWith(SpringJUnit4ClassRunner.class)
|
|
@SpringJUnitWebConfig
|
|
@ContextConfiguration(classes = SpringConfig.class)
|
|
public class ThriftTest {
|
|
|
|
@Resource
|
|
private FactoryPool factoryPool;
|
|
|
|
private static Logger log = LogManager.getLogger();
|
|
|
|
@Test
|
|
public void test1() throws Exception {
|
|
MyAsyncMethodCallback<Integer> call=new MyAsyncMethodCallback<>();
|
|
factoryPool.doExecute(QueryComment.AsyncClient.class,client -> client.commentSum(49052,call));
|
|
log.info(call.getResult());
|
|
|
|
}
|
|
|
|
@Test
|
|
public void test2() throws Exception{
|
|
MyAsyncMethodCallback result=new MyAsyncMethodCallback();
|
|
factoryPool.doExecute(QueryComment.Client.class, (client, aBoolean) ->
|
|
result.setResult(client.commentSum(49052)),result);
|
|
log.info(result.getResult());
|
|
}
|
|
|
|
}
|
|
|
|
|