diff --git a/pom.xml b/pom.xml index 097389b..20755fc 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 com.fanruan.api - tool-chain + toolchain 10.0 jar @@ -99,6 +99,18 @@ 3.5.1 test + + org.powermock + powermock-api-easymock + 1.7.1 + test + + + org.powermock + powermock-module-junit4 + 1.7.1 + test + @@ -106,12 +118,20 @@ maven-compiler-plugin 3.1 - 1.7 - 1.7 + 1.8 + 1.8 none + + org.apache.maven.plugins + maven-compiler-plugin + + 8 + 8 + + \ No newline at end of file diff --git a/src/main/java/com/fanruan/api/FineKit.java b/src/main/java/com/fanruan/api/FineKit.java new file mode 100644 index 0000000..750f597 --- /dev/null +++ b/src/main/java/com/fanruan/api/FineKit.java @@ -0,0 +1,33 @@ +package com.fanruan.api; + +import java.io.IOException; +import java.util.Properties; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-08-09 + */ +public class FineKit { + + private static String version; + + static { + Properties properties = new Properties(); + try { + properties.load(FineKit.class.getResourceAsStream("version.properties")); + version = properties.getProperty("version"); + } catch (IOException ignore) { + version = "1.0"; + } + } + + /** + * 获取开发者工具套件的版本信息 + * @return 版本信息 + */ + public static String version() { + return version; + } + +} diff --git a/src/main/java/com/fanruan/api/session/SessionFactory.java b/src/main/java/com/fanruan/api/session/SessionFactory.java new file mode 100644 index 0000000..d8376ad --- /dev/null +++ b/src/main/java/com/fanruan/api/session/SessionFactory.java @@ -0,0 +1,22 @@ +package com.fanruan.api.session; + +import com.fr.stable.web.SessionProvider; +import com.fr.web.core.SessionPoolManager; +import org.jetbrains.annotations.NotNull; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-08-09 + */ +public class SessionFactory { + + /** + * 根据sessionID信息返回会话对象 + * @param sessionID 会话唯一标识符 + * @return 会话对象 + */ + public static SessionProvider getSession(@NotNull String sessionID) { + return SessionPoolManager.getSessionIDInfor(sessionID, SessionProvider.class); + } +} diff --git a/src/main/java/com/fanruan/api/util/GeneralUtils.java b/src/main/java/com/fanruan/api/util/GeneralUtils.java new file mode 100644 index 0000000..1e9e8c3 --- /dev/null +++ b/src/main/java/com/fanruan/api/util/GeneralUtils.java @@ -0,0 +1,20 @@ +package com.fanruan.api.util; + +import java.io.IOException; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-08-09 + */ +public class GeneralUtils { + + /** + * 返回系统的首选MAC地址 + * + * @return 表示系统MAC地址的字符串 + */ + public static String getMacAddress() throws IOException { + return com.fr.general.GeneralUtils.getMacAddress(); + } +} diff --git a/src/main/resources/version.properties b/src/main/resources/version.properties new file mode 100644 index 0000000..2a453a0 --- /dev/null +++ b/src/main/resources/version.properties @@ -0,0 +1 @@ +version=1.0 \ No newline at end of file diff --git a/src/test/java/com/fanruan/api/Prepare.java b/src/test/java/com/fanruan/api/Prepare.java new file mode 100644 index 0000000..485e952 --- /dev/null +++ b/src/test/java/com/fanruan/api/Prepare.java @@ -0,0 +1,33 @@ +package com.fanruan.api; + +import com.fr.config.dao.DaoContext; +import com.fr.config.dao.impl.LocalClassHelperDao; +import com.fr.config.dao.impl.LocalEntityDao; +import com.fr.config.dao.impl.LocalXmlEntityDao; +import com.fr.runtime.FineRuntime; +import org.junit.After; +import org.junit.Before; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-08-09 + */ +public class Prepare { + + @Before + public void start() { + FineRuntime.start(); + DaoContext.setEntityDao(new LocalEntityDao()); + DaoContext.setClassHelperDao(new LocalClassHelperDao()); + DaoContext.setXmlEntityDao(new LocalXmlEntityDao()); + } + + @After + public void stop() { + DaoContext.setEntityDao(null); + DaoContext.setClassHelperDao(null); + DaoContext.setXmlEntityDao(null); + } + +} diff --git a/src/test/java/com/fanruan/api/session/SessionFactoryTest.java b/src/test/java/com/fanruan/api/session/SessionFactoryTest.java new file mode 100644 index 0000000..6174169 --- /dev/null +++ b/src/test/java/com/fanruan/api/session/SessionFactoryTest.java @@ -0,0 +1,17 @@ +package com.fanruan.api.session; + +import com.fanruan.api.Prepare; +import org.junit.Test; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-08-09 + */ +public class SessionFactoryTest extends Prepare { + + @Test + public void getSession() throws Exception { + + } +} \ No newline at end of file diff --git a/src/test/java/com/fanruan/api/util/GeneralUtilsTest.java b/src/test/java/com/fanruan/api/util/GeneralUtilsTest.java new file mode 100644 index 0000000..6bd7235 --- /dev/null +++ b/src/test/java/com/fanruan/api/util/GeneralUtilsTest.java @@ -0,0 +1,18 @@ +package com.fanruan.api.util; + +import com.fanruan.api.Prepare; +import org.junit.Assert; +import org.junit.Test; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-08-09 + */ +public class GeneralUtilsTest extends Prepare { + + @Test + public void getMacAddress() throws Exception{ + Assert.assertEquals(GeneralUtils.getMacAddress(), com.fr.general.GeneralUtils.getMacAddress()); + } +} \ No newline at end of file