Browse Source

KERNEL-1198 新添加方法的单元测试

pull/1/head
Mars.Ma 5 years ago
parent
commit
fc36f997c7
  1. 14
      src/test/java/com/fanruan/api/util/CodeKitTest.java
  2. 38
      src/test/java/com/fanruan/api/xml/XmlKitTest.java

14
src/test/java/com/fanruan/api/util/CodeKitTest.java

@ -1,5 +1,6 @@
package com.fanruan.api.util; package com.fanruan.api.util;
import com.fr.stable.CodeUtils;
import com.fr.stable.CommonCodeUtils; import com.fr.stable.CommonCodeUtils;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
@ -9,4 +10,17 @@ public class CodeKitTest {
public void passwordDecode(String passwordText) { public void passwordDecode(String passwordText) {
Assert.assertEquals(CodeKit.passwordDecode(passwordText), 123); Assert.assertEquals(CodeKit.passwordDecode(passwordText), 123);
} }
@Test
public void cjkDecode() {
String s = "中文 한글 日本語";
String encode = CodeUtils.cjkEncode(s);
try {
String decode = CodeKit.cjkDecode(encode);
Assert.assertTrue(s.equals(decode));
} catch (Exception e) {
}
}
} }

38
src/test/java/com/fanruan/api/xml/XmlKitTest.java

@ -0,0 +1,38 @@
package com.fanruan.api.xml;
import com.fr.base.Parameter;
import com.fr.base.TableData;
import com.fr.plugin.db.json.core.JSONTableData;
import com.fr.stable.ParameterProvider;
import com.fr.stable.bridge.StableFactory;
import com.fr.stable.xml.StableXMLUtils;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLUtils;
import com.fr.stable.xml.XMLableReader;
import com.fr.third.javax.xml.stream.XMLStreamException;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.Assert.*;
public class XmlKitTest {
@Test
public void readParameter() {
try {
XMLableReader xml = XMLableReader.createXMLableReader("<!-- Edited by XMLSpy® -->\n" +
"<note>\n" +
"<Parameter>Tove</Parameter>\n" +
"<from>Jani</from>\n" +
"<heading>Reminder</heading>\n" +
"<body>Don't forget me this weekend!</body>\n" +
"</note>");
Parameter parameter = new Parameter("test", 1);
StableFactory.registerXMLDescription("Parameter",parameter);
Parameter p = (Parameter)XmlKit.readParameter(xml);
Assert.assertTrue(p.getName().equals("test"));
} catch (XMLStreamException e) {
e.printStackTrace();
}
}
}
Loading…
Cancel
Save