Commit 280437db authored by zhoushiguang's avatar zhoushiguang

单元测试

parent 07ec0e0b
......@@ -271,6 +271,23 @@
<groupId>com.github.kokorin.jaffree</groupId>
<artifactId>jaffree</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>com.vaadin.external.google</groupId>
<artifactId>android-json</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
</dependencies>
......
/**
*
*/
import com.alibaba.fastjson.JSONObject;
import net.wanji.common.gts.Tools;
import net.wanji.datacenter.DataCenterApplication;
import net.wanji.datacenter.kafka.KafkaProducerServiceHandler;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.util.Date;
/**
* @author fengyi
* @date 2019年1月19日
*/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = DataCenterApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class KafkaTest {
@Resource
private KafkaProducerServiceHandler kafkaProducerServiceHandler;
@Test
public void testProducerTrack() {
//插入通知
JSONObject insertNoticeJson = new JSONObject();
insertNoticeJson.put("insertTime", Tools.dateToStr(new Date()));
insertNoticeJson.put("eventSerialNumber","sdsdsdsdsds");
kafkaProducerServiceHandler.send("event.insert.notice.topic",System.currentTimeMillis()+"",insertNoticeJson.toJSONString());
System.out.println();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment