Browse Source

开发者工具链

pull/1/head
richie 5 years ago
parent
commit
b9208d285e
  1. 26
      pom.xml
  2. 33
      src/main/java/com/fanruan/api/FineKit.java
  3. 22
      src/main/java/com/fanruan/api/session/SessionFactory.java
  4. 20
      src/main/java/com/fanruan/api/util/GeneralUtils.java
  5. 1
      src/main/resources/version.properties
  6. 33
      src/test/java/com/fanruan/api/Prepare.java
  7. 17
      src/test/java/com/fanruan/api/session/SessionFactoryTest.java
  8. 18
      src/test/java/com/fanruan/api/util/GeneralUtilsTest.java

26
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"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.fanruan.api</groupId> <groupId>com.fanruan.api</groupId>
<artifactId>tool-chain</artifactId> <artifactId>toolchain</artifactId>
<version>10.0</version> <version>10.0</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<properties> <properties>
@ -99,6 +99,18 @@
<version>3.5.1</version> <version>3.5.1</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-easymock</artifactId>
<version>1.7.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>1.7.1</version>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
@ -106,12 +118,20 @@
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version> <version>3.1</version>
<configuration> <configuration>
<source>1.7</source> <source>1.8</source>
<target>1.7</target> <target>1.8</target>
<!--不生成target/generated-sources/annotations--> <!--不生成target/generated-sources/annotations-->
<proc>none</proc> <proc>none</proc>
</configuration> </configuration>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins> </plugins>
</build> </build>
</project> </project>

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

22
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);
}
}

20
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();
}
}

1
src/main/resources/version.properties

@ -0,0 +1 @@
version=1.0

33
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);
}
}

17
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 {
}
}

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