From 50204f18faa9194f9110bed1d62bab89e4fafb6d Mon Sep 17 00:00:00 2001 From: zjz1993 <1429595365@qq.com> Date: Thu, 5 Sep 2019 15:11:54 +0800 Subject: [PATCH 1/3] =?UTF-8?q?update:=20=E6=96=B0=E5=A2=9E=E6=96=B9?= =?UTF-8?q?=E6=B3=95=EF=BC=8C=E7=BB=93=E6=9E=84=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../table/action/UITableEditAction.java | 4 ++-- .../table/model/UITableModelAdapter.java | 1 + .../com/fanruan/api/security/SecurityKit.java | 9 +++++++++ .../com/fanruan/api/plugin/PluginKitTest.java | 13 ------------- .../com/fanruan/api/plugin/TestExtraClass.java | 12 ------------ .../fanruan/api/security/SecurityKitTest.java | 18 ++++++++++++++++++ 6 files changed, 30 insertions(+), 27 deletions(-) delete mode 100644 src/test/java/com/fanruan/api/plugin/PluginKitTest.java delete mode 100644 src/test/java/com/fanruan/api/plugin/TestExtraClass.java create mode 100644 src/test/java/com/fanruan/api/security/SecurityKitTest.java diff --git a/src/main/java/com/fanruan/api/design/ui/component/table/action/UITableEditAction.java b/src/main/java/com/fanruan/api/design/ui/component/table/action/UITableEditAction.java index 1c441cf..60da73c 100644 --- a/src/main/java/com/fanruan/api/design/ui/component/table/action/UITableEditAction.java +++ b/src/main/java/com/fanruan/api/design/ui/component/table/action/UITableEditAction.java @@ -5,8 +5,8 @@ import java.awt.event.ActionEvent; public class UITableEditAction extends com.fr.design.gui.itableeditorpane.UITableEditAction { @Override - public void checkEnabled() { - } + public void checkEnabled(){}; + @Override public void actionPerformed(ActionEvent e) { diff --git a/src/main/java/com/fanruan/api/design/ui/component/table/model/UITableModelAdapter.java b/src/main/java/com/fanruan/api/design/ui/component/table/model/UITableModelAdapter.java index be69b7a..a26bd78 100644 --- a/src/main/java/com/fanruan/api/design/ui/component/table/model/UITableModelAdapter.java +++ b/src/main/java/com/fanruan/api/design/ui/component/table/model/UITableModelAdapter.java @@ -20,6 +20,7 @@ public abstract class UITableModelAdapter extends com.fr.design.gui.itableedi super(strings); } + @Override public abstract UITableEditAction[] createAction(); diff --git a/src/main/java/com/fanruan/api/security/SecurityKit.java b/src/main/java/com/fanruan/api/security/SecurityKit.java index e6e903c..59c90d8 100644 --- a/src/main/java/com/fanruan/api/security/SecurityKit.java +++ b/src/main/java/com/fanruan/api/security/SecurityKit.java @@ -35,4 +35,13 @@ public class SecurityKit { public static String passwordDecode(String passwordText) { return CodeUtils.passwordDecode(passwordText); } + + /** + * 给字符串加密 + * @param passwordText 待加密的字符串 + * @return 解加密的字符串 + */ + public static String passwordEncode(String passwordText) { + return CodeUtils.passwordEncode(passwordText); + } } diff --git a/src/test/java/com/fanruan/api/plugin/PluginKitTest.java b/src/test/java/com/fanruan/api/plugin/PluginKitTest.java deleted file mode 100644 index 4c8a72f..0000000 --- a/src/test/java/com/fanruan/api/plugin/PluginKitTest.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.fanruan.api.plugin; - -import org.junit.Assert; -import org.junit.Test; - -public class PluginKitTest { - @Test - public void getArray(){ - PluginKit p1 = new PluginKit(); - TestExtraClass p2 = new TestExtraClass(); - Assert.assertEquals(p1.getArray("abcd"), p2.getArray("abcd")); - } -} diff --git a/src/test/java/com/fanruan/api/plugin/TestExtraClass.java b/src/test/java/com/fanruan/api/plugin/TestExtraClass.java deleted file mode 100644 index f81ed57..0000000 --- a/src/test/java/com/fanruan/api/plugin/TestExtraClass.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.fanruan.api.plugin; -import com.fr.plugin.injectable.PluginSingleInjection; - -public class TestExtraClass extends com.fr.plugin.AbstractExtraClassManager{ - protected boolean mountSpecific(PluginSingleInjection injection){ - return true; - } - - protected boolean demountSpecific(PluginSingleInjection injection){ - return true; - } -} diff --git a/src/test/java/com/fanruan/api/security/SecurityKitTest.java b/src/test/java/com/fanruan/api/security/SecurityKitTest.java new file mode 100644 index 0000000..6760606 --- /dev/null +++ b/src/test/java/com/fanruan/api/security/SecurityKitTest.java @@ -0,0 +1,18 @@ +package com.fanruan.api.security; + +import java.util.*; + +import com.fr.stable.CommonCodeUtils; +import org.junit.Assert; +import org.junit.Test; + +public class SecurityKitTest { + @Test + public void passwordDecode(){ + Assert.assertEquals(SecurityKit.passwordDecode("1234"), CommonCodeUtils.passwordDecode("1234")); + } + @Test + public void passwordEncode(){ + Assert.assertEquals(SecurityKit.passwordEncode("1234"), CommonCodeUtils.passwordEncode("1234")); + } +} From c7340eb5d9164d6e6c567ee7d7713c165b6fed8d Mon Sep 17 00:00:00 2001 From: rinoux Date: Thu, 5 Sep 2019 18:01:50 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=B5=84=E6=BA=90=E4=BB=93=E5=BA=93kit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fanruan/api/io/ResourceModuleKit.java | 41 ++++++ .../fanruan/api/io/ResourceModuleKitTest.java | 124 ++++++++++++++++++ 2 files changed, 165 insertions(+) create mode 100644 src/main/java/com/fanruan/api/io/ResourceModuleKit.java create mode 100644 src/test/java/com/fanruan/api/io/ResourceModuleKitTest.java diff --git a/src/main/java/com/fanruan/api/io/ResourceModuleKit.java b/src/main/java/com/fanruan/api/io/ResourceModuleKit.java new file mode 100644 index 0000000..295c8b5 --- /dev/null +++ b/src/main/java/com/fanruan/api/io/ResourceModuleKit.java @@ -0,0 +1,41 @@ +package com.fanruan.api.io; + +import com.fr.io.base.provider.RepositoryFactoryProvider; +import com.fr.io.context.ResourceModuleContext; +import org.jetbrains.annotations.NotNull; + +/** + * + * 资源仓库插件开发套件 + * + * @author rinoux + * @version 10.0 + * Created by rinoux on 2019/9/5 + */ +public class ResourceModuleKit { + + + /** + * 添加一个资源仓库工厂 + * + * @param factory 工厂 + * @param 工厂类型 + */ + public static void addFactory(@NotNull T factory) { + ResourceModuleContext.addFactory(factory); + } + + + /** + * 移除一个资源仓库工厂 + * + * @param factory 工厂 + * @param 工厂类型 + */ + public static void removeFactory(@NotNull T factory) { + ResourceModuleContext.removeFactory(factory.getIdentity()); + } + + + +} diff --git a/src/test/java/com/fanruan/api/io/ResourceModuleKitTest.java b/src/test/java/com/fanruan/api/io/ResourceModuleKitTest.java new file mode 100644 index 0000000..e5d3f50 --- /dev/null +++ b/src/test/java/com/fanruan/api/io/ResourceModuleKitTest.java @@ -0,0 +1,124 @@ +package com.fanruan.api.io; + +import com.fr.io.base.provider.FactoryLoaderProvider; +import com.fr.io.base.provider.RepositoryFactoryProvider; +import com.fr.io.base.provider.RepositoryInstallerProvider; +import com.fr.io.base.provider.RepositoryManagerProvider; +import com.fr.io.config.RepositoryConfig; +import com.fr.io.config.ResourceModuleConfigProvider; +import com.fr.io.context.RepositoryContextProvider; +import com.fr.io.context.ResourceModuleContext; +import com.fr.io.lock.LockFactory; +import org.easymock.EasyMock; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import java.util.HashMap; +import java.util.Map; + +/** + * ResourceModuleKit Tester. + * + * @author + * @version 1.0 + * @since
9月 5, 2019
+ */ +public class ResourceModuleKitTest { + + @Before + public void before() throws Exception { + final FactoryLoaderProvider loaderProvider = new FactoryLoaderProvider() { + final Map map = new HashMap<>(); + + @Override + public void add(RepositoryFactoryProvider factory) { + map.put(factory.getIdentity(), factory); + } + + @Override + public void remove(String identity) { + map.remove(identity); + } + + @Override + @SuppressWarnings("unchecked") + public RepositoryFactoryProvider get(String identity) { + return map.get(identity); + } + }; + + ResourceModuleContext.setRepositoryContext(new RepositoryContextProvider() { + @Override + public FactoryLoaderProvider getFactoryLoader() { + + return loaderProvider; + } + + @Override + public ResourceModuleConfigProvider getConfig() { + return null; + } + + @Override + public RepositoryManagerProvider getManager() { + return null; + } + + @Override + public RepositoryInstallerProvider getInstaller() { + return null; + } + + @Override + public LockFactory getLockFactory() { + return null; + } + }); + } + + @After + public void after() throws Exception { + ResourceModuleContext.setRepositoryContext(null); + } + + /** + * Method: addFactory(@NotNull T factory) + */ + @Test + public void testAddFactory() throws Exception { + RepositoryFactoryProvider factory = EasyMock.createMock(RepositoryFactoryProvider.class); + EasyMock.expect(factory.getIdentity()).andReturn("MockRF").anyTimes(); + + EasyMock.replay(factory); + + Assert.assertNull(ResourceModuleContext.getFactory("MockRF")); + + ResourceModuleKit.addFactory(factory); + + Assert.assertNotNull(ResourceModuleContext.getFactory("MockRF")); + } + + + /** + * Method: addFactory(@NotNull T factory) + */ + @Test + public void testRemoveFactory() throws Exception { + RepositoryFactoryProvider factory = EasyMock.createMock(RepositoryFactoryProvider.class); + EasyMock.expect(factory.getIdentity()).andReturn("MockRF").anyTimes(); + + EasyMock.replay(factory); + + Assert.assertNull(ResourceModuleContext.getFactory("MockRF")); + + ResourceModuleKit.addFactory(factory); + + Assert.assertNotNull(ResourceModuleContext.getFactory("MockRF")); + + ResourceModuleKit.removeFactory(factory); + + Assert.assertNull(ResourceModuleContext.getFactory("MockRF")); + } +} From 0fc41e9f70a368544dbe828c15324d1e7e14984b Mon Sep 17 00:00:00 2001 From: richie Date: Fri, 6 Sep 2019 11:51:04 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E8=BF=9E=E6=8E=A5?= =?UTF-8?q?=E6=8A=BD=E8=B1=A1=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fanruan/api/data/open/BaseConnection.java | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 src/main/java/com/fanruan/api/data/open/BaseConnection.java diff --git a/src/main/java/com/fanruan/api/data/open/BaseConnection.java b/src/main/java/com/fanruan/api/data/open/BaseConnection.java new file mode 100644 index 0000000..95d8c0c --- /dev/null +++ b/src/main/java/com/fanruan/api/data/open/BaseConnection.java @@ -0,0 +1,51 @@ +package com.fanruan.api.data.open; + +import com.fanruan.api.util.ArrayKit; +import com.fr.data.impl.AbstractDatabaseConnection; +import com.fr.data.impl.Connection; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-09-06 + * 用于数据连接插件的抽象类 + */ +public abstract class BaseConnection extends AbstractDatabaseConnection { + + /** + * 测试连接 + * + * @throws Exception 异常 + */ + @Override + public abstract void testConnection() throws Exception; + + /** + * 创建连接 + * + * @return 返回连接 + * @throws Exception 异常 + */ + @Override + public java.sql.Connection createConnection() throws Exception { + return Connection.IGNORE; + } + + /** + * 连接成功或失败时给出的信息 + * + * @return 信息 + */ + @Override + public abstract String connectMessage(boolean status); + + + /** + * 获取数据连接的摘要信息 + * + * @return 摘要 + */ + public String[] summary(String... args) { + return ArrayKit.EMPTY_STRING_ARRAY; + } +}