Browse Source

Merge pull request #28 in TC/finekit from ~MARS.MA/finekit:master to master

* commit 'fc36f997c76474ba8ae2d6ba81cce4d50f24b81f':
  KERNEL-1198 新添加方法的单元测试
  KERNEL-1198 按要求修改
  KERNEL-1198 去除不必要修改修改
  KERNEL-1198 按要求修改
  KERNEL-1198 JSON插件第二次提交
  KERNEL-1198 消除不必要改动
  KERNEL-1198 JSON插件第一波FineKit提交。
pull/19/head
superman 5 years ago
parent
commit
50668e6fe4
  1. 1
      src/main/java/com/fanruan/api/cal/ParameterKit.java
  2. 41
      src/main/java/com/fanruan/api/conf/ConfigurationKit.java
  3. 1
      src/main/java/com/fanruan/api/data/TableDataKit.java
  4. 10
      src/main/java/com/fanruan/api/util/CodeKit.java
  5. 13
      src/main/java/com/fanruan/api/xml/XmlKit.java
  6. 14
      src/test/java/com/fanruan/api/util/CodeKitTest.java
  7. 38
      src/test/java/com/fanruan/api/xml/XmlKitTest.java

1
src/main/java/com/fanruan/api/cal/ParameterKit.java

@ -135,5 +135,4 @@ public class ParameterKit {
return parameters;
}
}

41
src/main/java/com/fanruan/api/conf/ConfigurationKit.java

@ -1,41 +0,0 @@
package com.fanruan.api.conf;
import com.fr.config.Configuration;
import com.fr.config.holder.ConfigChangeListener;
import com.fr.transaction.Configurations;
import com.fr.transaction.ValidateProxy;
import com.fr.transaction.WorkerFacade;
/**
* @author richie
* @version 10.0
* Created by richie on 2019-08-30
* 配置监听管理器
*/
public class ConfigurationKit {
/**
* 注册监听配置变化的监听器
*
* @param listener 监听器
*/
public static void registerListener(ConfigChangeListener listener) {
ValidateProxy.getInstance().getValidateManager().registerListener(listener);
}
/**
* 保存配置
*
* @param type 配置的类型
* @param action 保存动作
*/
public static void modify(Class<? extends Configuration> type, Runner action) {
Configurations.modify(new WorkerFacade(type) {
@Override
public void run() {
action.run();
}
});
}
}

1
src/main/java/com/fanruan/api/data/TableDataKit.java

@ -74,4 +74,5 @@ public class TableDataKit {
public static void renameTableData(@NotNull String oldName, @NotNull String newName) {
TableDataConfig.getInstance().renameTableData(oldName, newName);
}
}

10
src/main/java/com/fanruan/api/util/CodeKit.java

@ -12,4 +12,14 @@ public class CodeKit {
public static String passwordDecode(String passwordText) {
return CodeUtils.passwordDecode(passwordText);
}
/**
* 将经过处理的中日韩文字符串解码成原先的中日韩文
* @param text 经过处理的中日韩文字
* @return 中日韩文字
* @throws Exception
*/
public static String cjkDecode(String text) throws Exception {
return CodeUtils.cjkDecode(text);
}
}

13
src/main/java/com/fanruan/api/xml/XmlKit.java

@ -3,11 +3,13 @@ package com.fanruan.api.xml;
import com.fr.data.core.DataCoreXmlUtils;
import com.fr.data.impl.Connection;
import com.fr.general.xml.GeneralXMLTools;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.ParameterProvider;
import com.fr.stable.xml.XMLReadable;
import com.fr.stable.xml.XMLTools;
import com.fr.stable.xml.XMLable;
import com.fr.stable.xml.XMLableReader;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.StableXMLUtils;
import java.io.InputStream;
@ -76,4 +78,13 @@ public class XmlKit {
DataCoreXmlUtils.writeXMLConnection(writer, connection);
}
/**
*读出xml参数
* @param reader xml读出对象
* @return 返回保存参数数组
*/
public static ParameterProvider readParameter(XMLableReader reader) {
return StableXMLUtils.readParameter(reader);
}
}

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

@ -1,5 +1,6 @@
package com.fanruan.api.util;
import com.fr.stable.CodeUtils;
import com.fr.stable.CommonCodeUtils;
import org.junit.Assert;
import org.junit.Test;
@ -9,4 +10,17 @@ public class CodeKitTest {
public void passwordDecode(String passwordText) {
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