Commit 686bf764 by jianglong

国结代码修改:移动测试方法到junit

parent 9dfad951
...@@ -36,8 +36,6 @@ import java.util.regex.Pattern; ...@@ -36,8 +36,6 @@ import java.util.regex.Pattern;
public class Element2MxForSSTF { public class Element2MxForSSTF {
//测试要素报文
private static String MSG_FILE ;
//xml报文临时目录 //xml报文临时目录
private static String TEMPLATE_DIR ; private static String TEMPLATE_DIR ;
//存放env.yml //存放env.yml
...@@ -61,8 +59,6 @@ public class Element2MxForSSTF { ...@@ -61,8 +59,6 @@ public class Element2MxForSSTF {
private static final Logger logger = LoggerFactory.getLogger(Element2MxForSSTF.class); private static final Logger logger = LoggerFactory.getLogger(Element2MxForSSTF.class);
static { static {
MSG_FILE = "D:\\WorkArea\\Repositories_git\\swiftMx2Mt-sstf\\swiftCore\\src\\main\\resources\\temp\\0820\\snd_txt\\36350871-pacs009cov.txt";
if (StrUtil.isNotEmpty(System.getenv("TD2HOME"))){ if (StrUtil.isNotEmpty(System.getenv("TD2HOME"))){
TEMPLATE_DIR=System.getenv("TD2HOME")+File.separator+"tmp"; TEMPLATE_DIR=System.getenv("TD2HOME")+File.separator+"tmp";
}else { }else {
...@@ -72,35 +68,6 @@ public class Element2MxForSSTF { ...@@ -72,35 +68,6 @@ public class Element2MxForSSTF {
getEnvMap(); getEnvMap();
} }
/**
@Test
private void test1() throws Exception {
String mx=FileUtil.readString("D:\\WorkArea\\Repositories_git\\swiftMx2Mt-sstf\\swiftCore\\src\\main\\resources\\temp\\test.xml" ,StandardCharsets.UTF_8);
xmlFieldMap=new HashMap<>();
xmlFieldMap.put("t","t");
mx=addXmlField(mx,"pacs00800108",xmlFieldMap);
Map<String, Object> rtnMap = mt2MxWithFile(MSG_FILE);
rtnMap.forEach((key, value) -> {
System.out.println(key);
System.out.println(value);
});
}
*/
/**
* 测试方法:使用模拟的要素报文文件(TD产生)转换为xml报文
* 接口调用:直接调用mt2Mx(orgMsg)
*/
@Test
public void test() throws Exception {
Map<String, Object> rtnMap = mt2MxWithFile(MSG_FILE);
rtnMap.forEach((key, value) -> {
System.out.println(key);
System.out.println(value);
});
}
/* /*
功能:传入要素报文文件,返回结果,功能同mt2Mx()方法 功能:传入要素报文文件,返回结果,功能同mt2Mx()方法
......
...@@ -30,8 +30,6 @@ import java.time.format.DateTimeFormatter; ...@@ -30,8 +30,6 @@ import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
public class Mx2ElementForSSTF { public class Mx2ElementForSSTF {
//xml文件所在的目录
private static final String XML_FILE ;
//txt落地文件所在的目录 //txt落地文件所在的目录
private static String TEMPLATE_DIR ; private static String TEMPLATE_DIR ;
//存放env.yml //存放env.yml
...@@ -51,8 +49,6 @@ public class Mx2ElementForSSTF { ...@@ -51,8 +49,6 @@ public class Mx2ElementForSSTF {
private static final Logger logger = LoggerFactory.getLogger(Element2MxForSSTF.class); private static final Logger logger = LoggerFactory.getLogger(Element2MxForSSTF.class);
static { static {
XML_FILE = "D:\\WorkArea\\Repositories_git\\swiftMx2Mt-sstf\\swiftCore\\src\\main\\resources\\temp\\ack.xml";
if (StrUtil.isNotEmpty(System.getenv("TD2HOME"))){ if (StrUtil.isNotEmpty(System.getenv("TD2HOME"))){
TEMPLATE_DIR=System.getenv("TD2HOME")+File.separator+"tmp"; TEMPLATE_DIR=System.getenv("TD2HOME")+File.separator+"tmp";
}else { }else {
...@@ -61,17 +57,6 @@ public class Mx2ElementForSSTF { ...@@ -61,17 +57,6 @@ public class Mx2ElementForSSTF {
getEnvMap(); getEnvMap();
} }
//测试方法
@Test
public void test() throws Exception {
Map<String, Object> resMap = mx2MtWithFile(XML_FILE);
for (Map.Entry<String, Object> entry : resMap.entrySet()) {
System.out.println(entry.getKey() + entry.getValue().toString());
}
}
public static Map<String, Object> mx2MtWithFile(String xmlFileNm) { public static Map<String, Object> mx2MtWithFile(String xmlFileNm) {
FileReader fileReader = new FileReader(xmlFileNm); FileReader fileReader = new FileReader(xmlFileNm);
......
...@@ -16,9 +16,40 @@ import java.util.List; ...@@ -16,9 +16,40 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import com.brilliance.swift.element2mx.Element2MxForSSTF;
public class Element2MxTest { public class Element2MxTest {
/**
@Test
private void test1() throws Exception {
String mx=FileUtil.readString("D:\\WorkArea\\Repositories_git\\swiftMx2Mt-sstf\\swiftCore\\src\\main\\resources\\temp\\test.xml" ,StandardCharsets.UTF_8);
xmlFieldMap=new HashMap<>();
xmlFieldMap.put("t","t");
mx=addXmlField(mx,"pacs00800108",xmlFieldMap);
Map<String, Object> rtnMap = mt2MxWithFile(MSG_FILE);
rtnMap.forEach((key, value) -> {
System.out.println(key);
System.out.println(value);
});
}
*/
/**
* 测试方法:使用模拟的要素报文文件(TD产生)转换为xml报文
* 接口调用:直接调用mt2Mx(orgMsg)
*/
@Test
public void element2MxForSSTF() throws Exception {
String MSG_FILE = "D:\\WorkArea\\Repositories_git\\swiftMx2Mt-sstf\\swiftCore\\src\\main\\resources\\temp\\0820\\snd_txt\\36350871-pacs009cov.txt";
Map<String, Object> rtnMap = Element2MxForSSTF.mt2MxWithFile(MSG_FILE);
rtnMap.forEach((key, value) -> {
System.out.println(key);
System.out.println(value);
});
}
@Test @Test
public void testElement2Pacs00800108() throws IOException, ParseException, DatatypeConfigurationException { public void testElement2Pacs00800108() throws IOException, ParseException, DatatypeConfigurationException {
//File file = FileUtils.toFile(Mx2MtTest.class.getResource("/swiftXml/MxCamt05300108_950.xml")); //File file = FileUtils.toFile(Mx2MtTest.class.getResource("/swiftXml/MxCamt05300108_950.xml"));
......
...@@ -8,10 +8,20 @@ import java.io.File; ...@@ -8,10 +8,20 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
import java.util.Map; import java.util.Map;
import com.brilliance.swift.mx2element.Mx2ElementForSSTF;
public class Mx2ElementTest { public class Mx2ElementTest {
@Test @Test
public void mx2ElementForSSTF() throws Exception {
String XML_FILE = "D:\\WorkArea\\Repositories_git\\swiftMx2Mt-sstf\\swiftCore\\src\\main\\resources\\temp\\ack.xml";
Map<String, Object> resMap = Mx2ElementForSSTF.mx2MtWithFile(XML_FILE);
for (Map.Entry<String, Object> entry : resMap.entrySet()) {
System.out.println(entry.getKey() + entry.getValue().toString());
}
}
@Test
public void testPacs008001() { public void testPacs008001() {
File file = FileUtils.toFile(Mx2MtTest.class.getResource("/swiftXml/MxPacs00800108.xml")); File file = FileUtils.toFile(Mx2MtTest.class.getResource("/swiftXml/MxPacs00800108.xml"));
String elementStr = SwiftTransfer.mx2Element(file); String elementStr = SwiftTransfer.mx2Element(file);
......
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