First Commit
This commit is contained in:
56
src/test/java/quant/rich/EmoneyAutoApplicationTests.java
Normal file
56
src/test/java/quant/rich/EmoneyAutoApplicationTests.java
Normal file
@@ -0,0 +1,56 @@
|
||||
package quant.rich;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import nano.CandleStickNewWithIndexExResponse.CandleStickNewWithIndexEx_Response;
|
||||
import nano.CandleStickRequest.CandleStick_Request;
|
||||
import nano.CandleStickWithIndexRequest.CandleStickWithIndex_Request;
|
||||
import nano.CandleStickWithIndexRequest.CandleStickWithIndex_Request.IndexInfo;
|
||||
import quant.rich.emoney.EmoneyAutoApplication;
|
||||
import quant.rich.emoney.client.EmoneyClient;
|
||||
|
||||
|
||||
@SpringBootTest
|
||||
@ContextConfiguration(classes = EmoneyAutoApplication.class)
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@Slf4j
|
||||
class EmoneyAutoApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
EmoneyClient.loginWithAnonymous();
|
||||
|
||||
CandleStickWithIndex_Request request = new CandleStickWithIndex_Request();
|
||||
|
||||
CandleStick_Request candleRequest = new CandleStick_Request();
|
||||
candleRequest.setBeginPosition(0)
|
||||
.setDataPeriod(50000)
|
||||
.setExFlag(0).setGoodsId(1300684)
|
||||
.setLastVolume(0).setLimitSize(250)
|
||||
.setReqFhsp(false).setReqHisShares(false);
|
||||
request.candleRequest = candleRequest;
|
||||
|
||||
//IndexInfo indexRequest = new IndexInfo().setIndexName("CPX");
|
||||
//request.indexRequest = new IndexInfo[] {indexRequest};
|
||||
|
||||
//emoneyClient.getEmoneyRequestHeader().setXProtocolId(2422).setXRequestIdWithTimestamp();
|
||||
|
||||
CandleStickNewWithIndexEx_Response response = EmoneyClient.post(
|
||||
request, CandleStickNewWithIndexEx_Response.class,
|
||||
2422, String.valueOf(System.currentTimeMillis()));
|
||||
//JSONObject jo = JSONObject.from(request);
|
||||
ObjectNode jo = new ObjectMapper().valueToTree(response);
|
||||
log.info(jo.toPrettyString());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
42
src/test/java/quant/rich/PatchOkHttpTest.java
Normal file
42
src/test/java/quant/rich/PatchOkHttpTest.java
Normal file
@@ -0,0 +1,42 @@
|
||||
package quant.rich;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import quant.rich.emoney.patch.okhttp.RequestContext;
|
||||
import quant.rich.emoney.patch.okhttp.PatchOkHttpRule;
|
||||
|
||||
public class PatchOkHttpTest {
|
||||
|
||||
@Test
|
||||
void test() {
|
||||
|
||||
PatchOkHttpRule rule;
|
||||
RequestContext context;
|
||||
|
||||
rule = PatchOkHttpRule.when().isHttps().build();
|
||||
context = new RequestContext(Map.of(), "https", "localhost");
|
||||
|
||||
Assertions.assertTrue(rule.matches(context), "测试失败");
|
||||
|
||||
rule = PatchOkHttpRule.when().hostEndsWith("emoney.com")
|
||||
.or(r -> r.hostContains("emapp"))
|
||||
.build();
|
||||
context = new RequestContext(Map.of(), "https", "mbs.emoney.com");
|
||||
|
||||
Assertions.assertTrue(rule.matches(context), "测试失败");
|
||||
|
||||
context = new RequestContext(Map.of(), "https", "emapp-static.oss-cn-shanghai.aliyuncs.com");
|
||||
Assertions.assertTrue(rule.matches(context), "测试失败");
|
||||
|
||||
context = new RequestContext(Map.of(), "https", "hao123.com");
|
||||
Assertions.assertFalse(rule.matches(context), "测试失败");
|
||||
|
||||
|
||||
//Assertions.assertEquals("{\"info\":\"m\",\"weight\":\"100kg/m\"}", JSON.toJSONString(humanWeight));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user