提交可正常处理acft消息的代码
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
package com.gzzn.omms.msgexchangeapi.service;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
@@ -12,6 +16,9 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
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.schd.dnld.DNLDMsg;
|
||||
import com.gzzn.omms.msgexchangeapi.utils.JsonUtil;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
@@ -19,6 +26,9 @@ public class ExchangeServiceImplTest {
|
||||
@Autowired
|
||||
private IExchangeService exchangeService;
|
||||
|
||||
@Autowired
|
||||
private CminmsgDao cminmsgDao;
|
||||
|
||||
|
||||
@Test
|
||||
public void testXmlToJson() throws JsonParseException, JsonMappingException, IOException {
|
||||
@@ -72,4 +82,22 @@ public class ExchangeServiceImplTest {
|
||||
|
||||
Map map = xmlMapper.readValue(xmlString,Map.class);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testXmlToDNLDMsg() throws JsonParseException, JsonMappingException, IOException
|
||||
{
|
||||
String xml = cminmsgDao.findOne(300L).getCminmsgsClobMsg();
|
||||
|
||||
DNLDMsg dNLDMsg = exchangeService.xmlstrToObject(xml, DNLDMsg.class);
|
||||
String jsonString=JsonUtil.getString(dNLDMsg);
|
||||
|
||||
File file = new File("schd.json");
|
||||
FileOutputStream fos = new FileOutputStream(file);
|
||||
fos.write(jsonString.getBytes("utf-8"));
|
||||
fos.close();
|
||||
|
||||
|
||||
System.out.println(jsonString);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user