修改新增接口,可以发送json或者xml类型的消息
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.gzzn.omms.msgexchangeapi.service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -10,6 +11,7 @@ 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;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
@@ -44,4 +46,30 @@ public class ExchangeServiceImplTest {
|
||||
|
||||
//assertThat(jsonPath("$.", matcher)).
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testXmlToMap() throws JsonParseException, JsonMappingException, IOException
|
||||
{
|
||||
String xmlString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n" +
|
||||
"<MSG xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"unisysaodbsis.xsd\">\r\n" +
|
||||
" <META>\r\n" +
|
||||
" <SNDR>AODB</SNDR>\r\n" +
|
||||
"<SEQN>282266</SEQN>\r\n" +
|
||||
"<DTTM>20181121224147</DTTM>\r\n" +
|
||||
"<TYPE>FLOP</TYPE>\r\n" +
|
||||
"<STYP>DELY</STYP>\r\n" +
|
||||
"</META>\r\n" +
|
||||
"<FLOP>\r\n" +
|
||||
"<FLID>11485800</FLID>\r\n" +
|
||||
"<FFID>OZ-OZ324-D-22NOV180035-I</FFID>\r\n" +
|
||||
" <DELY CODE = \"022\" STRT = \"22NOV180035\" DURA = \"0355\">NO REMARKS</DELY>\r\n" +
|
||||
"</FLOP>\r\n" +
|
||||
"</MSG>";
|
||||
|
||||
|
||||
XmlMapper xmlMapper = new XmlMapper();
|
||||
|
||||
Map map = xmlMapper.readValue(xmlString,Map.class);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user