重构提取转历史航班的代码
This commit is contained in:
@@ -18,6 +18,6 @@ public class RedisServiceTest {
|
||||
@Test
|
||||
public void removeFlightInfo()
|
||||
{
|
||||
redisService.del(Arrays.asList("flightInfo:"));
|
||||
redisService.del(Arrays.asList("flightInfo"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.gzzn.omms.msgexchangeapi.service;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.kafka.core.KafkaTemplate;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class KafkaServiceImplTest {
|
||||
@Autowired
|
||||
private KafkaTemplate kafkaTemplate;
|
||||
|
||||
/***
|
||||
* @param n 字符串长度
|
||||
* @return 返回n长度的随机字符串
|
||||
***/
|
||||
private String randomString(Integer n) {
|
||||
String str = "abcdefghijklmnopqrstuvwxyz9876543210";
|
||||
|
||||
StringBuffer tmp = new StringBuffer();
|
||||
for (int i = 0; i < n; i++) {
|
||||
int beginIndex = (int) Math.floor(Math.random() * str.length());
|
||||
String randomStr = str.substring(beginIndex, beginIndex + 1);
|
||||
tmp.append(randomStr);
|
||||
}
|
||||
|
||||
return tmp.toString();
|
||||
} //end funciont
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void msgSendTest() {
|
||||
String topic = "schd";
|
||||
String msg = randomString(4*1024*1024);
|
||||
|
||||
|
||||
kafkaTemplate.send(topic, msg);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user