提交测试用例
This commit is contained in:
@@ -1,5 +1,17 @@
|
||||
package com.gzzn.omms.msgexchangeapi.service;
|
||||
|
||||
public class CmoutmsgServiceImplTest {
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class CmoutmsgServiceImplTest {
|
||||
|
||||
@Test
|
||||
private void testSendSchdGetMsg()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,9 @@ package com.gzzn.omms.msgexchangeapi.service;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.math.BigInteger;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
@@ -15,8 +18,15 @@ import com.fasterxml.jackson.core.JsonParseException;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
|
||||
import com.gzzn.omms.msgexchangeapi.dao.CminmsgDao;
|
||||
import com.gzzn.omms.msgexchangeapi.entity.msg.MESSAGESUBTYPES;
|
||||
import com.gzzn.omms.msgexchangeapi.entity.msg.MESSAGETYPES;
|
||||
import com.gzzn.omms.msgexchangeapi.entity.msg.MSG;
|
||||
import com.gzzn.omms.msgexchangeapi.entity.msg.RQFD;
|
||||
import com.gzzn.omms.msgexchangeapi.entity.msg.SUBSYSTEMS;
|
||||
import com.gzzn.omms.msgexchangeapi.entity.msg.builder.METABuilder;
|
||||
import com.gzzn.omms.msgexchangeapi.entity.msg.builder.MSGBuilder;
|
||||
import com.gzzn.omms.msgexchangeapi.service.exchange.IExchangeService;
|
||||
import com.gzzn.omms.msgexchangeapi.utils.DateTimeUtil;
|
||||
import com.gzzn.omms.msgexchangeapi.utils.JsonUtil;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@@ -50,7 +60,7 @@ public class ExchangeServiceImplTest {
|
||||
"</PSDT>\r\n" +
|
||||
"</FLOP>\r\n" +
|
||||
"</MSG>";
|
||||
String jsonString = exchangeService.xmlstrToJson(xmlString);
|
||||
String jsonString = exchangeService.xmlMsgToJsonMsg(xmlString);
|
||||
System.out.println(jsonString);
|
||||
|
||||
//assertThat(jsonPath("$.", matcher)).
|
||||
@@ -88,7 +98,7 @@ public class ExchangeServiceImplTest {
|
||||
{
|
||||
String xml = cminmsgDao.findOne(300L).getCminmsgsClobMsg();
|
||||
|
||||
MSG dNLDMsg = exchangeService.xmlstrToObject(xml, MSG.class);
|
||||
MSG dNLDMsg = exchangeService.xmlToMsg(xml);
|
||||
String jsonString=JsonUtil.getString(dNLDMsg);
|
||||
|
||||
File file = new File("schd.json");
|
||||
@@ -99,4 +109,40 @@ public class ExchangeServiceImplTest {
|
||||
|
||||
System.out.println(jsonString);
|
||||
}
|
||||
|
||||
/**
|
||||
* POJO 转xml字符串
|
||||
*/
|
||||
@Test
|
||||
public void testObjectToXmlstr()
|
||||
{
|
||||
Long nowtime = System.currentTimeMillis();
|
||||
MSG rqfdMsg = new MSGBuilder().
|
||||
setMETA(
|
||||
new METABuilder()
|
||||
.setSNDR(SUBSYSTEMS.OSH5)
|
||||
.setTYPE(MESSAGETYPES.RQFD)
|
||||
.setSTYP(MESSAGESUBTYPES.NONE)
|
||||
.setDTTM(new BigInteger(nowtime.toString()))
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
|
||||
RQFD rqfd = new RQFD();
|
||||
rqfd.setSTDB(getDateStr(new Date()));
|
||||
rqfd.setSTDE(getDateStr(new Date()));
|
||||
rqfdMsg.setRQFD(rqfd);
|
||||
|
||||
//打印xml结果
|
||||
System.out.println(exchangeService.msgToXml(rqfdMsg));
|
||||
}
|
||||
|
||||
private String getDateStr(Date date)
|
||||
{
|
||||
return DateTimeUtil.gtFormatStr(
|
||||
date,
|
||||
"ddMMMyyHHmm",
|
||||
Locale.ENGLISH)
|
||||
.toUpperCase();
|
||||
}//end function
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user