Browse Source

Merging in latest from upstream (TC/finekit:refs/heads/master)

* commit 'aa488ac8c7854d25c94d0426b23bb497746ad805':
  数据连接抽象类
  资源仓库kit
  update: 新增方法,结构调整
remotes/1611766341912730171/master
Mars.Ma 5 years ago
parent
commit
5ea3af547c
  1. 51
      src/main/java/com/fanruan/api/data/open/BaseConnection.java
  2. 4
      src/main/java/com/fanruan/api/design/ui/component/table/action/UITableEditAction.java
  3. 1
      src/main/java/com/fanruan/api/design/ui/component/table/model/UITableModelAdapter.java
  4. 41
      src/main/java/com/fanruan/api/io/ResourceModuleKit.java
  5. 9
      src/main/java/com/fanruan/api/security/SecurityKit.java
  6. 124
      src/test/java/com/fanruan/api/io/ResourceModuleKitTest.java
  7. 18
      src/test/java/com/fanruan/api/security/SecurityKitTest.java

51
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;
}
}

4
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 { public class UITableEditAction extends com.fr.design.gui.itableeditorpane.UITableEditAction {
@Override @Override
public void checkEnabled() { public void checkEnabled(){};
}
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {

1
src/main/java/com/fanruan/api/design/ui/component/table/model/UITableModelAdapter.java

@ -20,6 +20,7 @@ public abstract class UITableModelAdapter<T> extends com.fr.design.gui.itableedi
super(strings); super(strings);
} }
@Override
public abstract UITableEditAction[] createAction(); public abstract UITableEditAction[] createAction();

41
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 <T> 工厂类型
*/
public static <T extends RepositoryFactoryProvider> void addFactory(@NotNull T factory) {
ResourceModuleContext.addFactory(factory);
}
/**
* 移除一个资源仓库工厂
*
* @param factory 工厂
* @param <T> 工厂类型
*/
public static <T extends RepositoryFactoryProvider> void removeFactory(@NotNull T factory) {
ResourceModuleContext.removeFactory(factory.getIdentity());
}
}

9
src/main/java/com/fanruan/api/security/SecurityKit.java

@ -35,4 +35,13 @@ public class SecurityKit {
public static String passwordDecode(String passwordText) { public static String passwordDecode(String passwordText) {
return CodeUtils.passwordDecode(passwordText); return CodeUtils.passwordDecode(passwordText);
} }
/**
* 给字符串加密
* @param passwordText 待加密的字符串
* @return 解加密的字符串
*/
public static String passwordEncode(String passwordText) {
return CodeUtils.passwordEncode(passwordText);
}
} }

124
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 <Authors name>
* @version 1.0
* @since <pre>9月 5, 2019</pre>
*/
public class ResourceModuleKitTest {
@Before
public void before() throws Exception {
final FactoryLoaderProvider loaderProvider = new FactoryLoaderProvider() {
final Map<String, RepositoryFactoryProvider> map = new HashMap<>();
@Override
public <T extends RepositoryConfig> void add(RepositoryFactoryProvider<T> factory) {
map.put(factory.getIdentity(), factory);
}
@Override
public void remove(String identity) {
map.remove(identity);
}
@Override
@SuppressWarnings("unchecked")
public <T extends RepositoryConfig> RepositoryFactoryProvider<T> 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"));
}
}

18
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"));
}
}
Loading…
Cancel
Save