parent
a1310b127d
commit
b56e1a8deb
@ -0,0 +1,26 @@
|
|||||||
|
package com.platform.test;
|
||||||
|
|
||||||
|
public class Brick {
|
||||||
|
private String ip;
|
||||||
|
private String path;
|
||||||
|
|
||||||
|
public Brick(String ip, String path) {
|
||||||
|
super();
|
||||||
|
this.ip = ip;
|
||||||
|
this.path = path;
|
||||||
|
}
|
||||||
|
public String getIp() {
|
||||||
|
return ip;
|
||||||
|
}
|
||||||
|
public void setIp(String ip) {
|
||||||
|
this.ip = ip;
|
||||||
|
}
|
||||||
|
public String getPath() {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
public void setPath(String path) {
|
||||||
|
this.path = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package com.platform.test;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.platform.entities.FolderNode;
|
||||||
|
|
||||||
|
public class FolderReader {
|
||||||
|
|
||||||
|
public static FolderNode reader(String path) {
|
||||||
|
FolderNode folderNode = null;
|
||||||
|
File file = new File(path);
|
||||||
|
if (file.exists()) {
|
||||||
|
List<FolderNode> childrens = new ArrayList<FolderNode>();
|
||||||
|
if (file.isDirectory()) {
|
||||||
|
File[] files = file.listFiles();
|
||||||
|
for (int i = 0; i < files.length; i++) {
|
||||||
|
FolderNode children = reader(files[i].getAbsolutePath());
|
||||||
|
if (children != null)
|
||||||
|
childrens.add(children);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return folderNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
FolderReader folderReader = new FolderReader();
|
||||||
|
FolderNode folderNode = folderReader.reader("D:/bootstrap");
|
||||||
|
//folderReader.print(folderNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package com.platform.test;
|
||||||
|
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.context.support.FileSystemXmlApplicationContext;
|
||||||
|
|
||||||
|
public class SMBasedTest {
|
||||||
|
|
||||||
|
public ApplicationContext applicationContext;
|
||||||
|
|
||||||
|
public SMBasedTest() {
|
||||||
|
applicationContext = new FileSystemXmlApplicationContext(
|
||||||
|
"test/spring-applicationContext-test.xml");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
package com.platform.test;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.DriverManager;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
import com.platform.utils.Configs;
|
||||||
|
|
||||||
|
public class TestConnectOralce {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
try{
|
||||||
|
Class.forName("oracle.jdbc.driver.OracleDriver");
|
||||||
|
Configs.CONSOLE_LOGGER.info("Oracle驱动加载成功");
|
||||||
|
}catch(Exception e){
|
||||||
|
System.out.println(e);
|
||||||
|
}
|
||||||
|
String url = "jdbc:oracle:thin:@192.168.0.110:60758:orcl";
|
||||||
|
try {
|
||||||
|
Connection conn = DriverManager.getConnection(url, "system", "oracle");
|
||||||
|
System.out.println("连接成功");
|
||||||
|
} catch (SQLException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,53 @@
|
|||||||
|
package com.platform.test;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
|
import com.platform.entities.EncodedInfoEntity;
|
||||||
|
import com.platform.service.EncodeInfoService;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
public class TestController {
|
||||||
|
// private static Logger logger = Logger.getLogger(TestController.class);
|
||||||
|
@Resource(name = "encodeInfoService")
|
||||||
|
private EncodeInfoService eis;
|
||||||
|
|
||||||
|
public void setEis(EncodeInfoService eis) {
|
||||||
|
this.eis = eis;
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/hello")
|
||||||
|
@ResponseBody
|
||||||
|
public List<EncodedInfoEntity> hello(String name, HttpServletResponse res) {
|
||||||
|
System.out.println(name);
|
||||||
|
return eis.getAllEncodeInfo("system_info");
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/json")
|
||||||
|
@ResponseBody
|
||||||
|
public List<User> getJson(HttpServletRequest res, HttpServletResponse req) {
|
||||||
|
List<User> list = new ArrayList<User>();
|
||||||
|
list.add(new User("lisi", 1, "男"));
|
||||||
|
list.add(new User("zhansan", 2, "男"));
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("log")
|
||||||
|
public void testLog(HttpServletResponse res) {
|
||||||
|
System.out.println(eis.getEncodeNameByCode("1", "system_info"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/data111.json")
|
||||||
|
public void test(String name, HttpServletResponse res){
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,64 @@
|
|||||||
|
package com.platform.test;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import com.platform.dao.EncodeInfoDao;
|
||||||
|
import com.platform.entities.EncodedInfoEntity;
|
||||||
|
|
||||||
|
public class TestEncodeInfoDao extends SMBasedTest {
|
||||||
|
|
||||||
|
private EncodeInfoDao eiDao;
|
||||||
|
private String testTableName;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void initBeforeFunction() {
|
||||||
|
eiDao = (EncodeInfoDao) this.applicationContext
|
||||||
|
.getBean("encodeInfoDao");
|
||||||
|
testTableName = "system_info";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetAllEntityInfo() {
|
||||||
|
List<EncodedInfoEntity> allEntities = eiDao
|
||||||
|
.getAllEntityInfo(testTableName);
|
||||||
|
System.out.println(allEntities);
|
||||||
|
Assert.assertTrue(allEntities.size() > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetEncodeNameByCode() {
|
||||||
|
String result = eiDao.getEncodeNameByCode("1", testTableName);
|
||||||
|
Assert.assertTrue(result.equals("预算执行系统"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetEncodeCodeByName() {
|
||||||
|
List<String> result = eiDao
|
||||||
|
.getEncodeCodeByName("预算执行系统", testTableName);
|
||||||
|
Assert.assertTrue(result.size() > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateEncodeNameByCode() {
|
||||||
|
int result = eiDao
|
||||||
|
.updateEncodeNameByCode("3", "财政一体化平台", testTableName);
|
||||||
|
Assert.assertTrue(result > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testInsertEncodeEntity() {
|
||||||
|
int result = eiDao.insertEncodeEntity(new EncodedInfoEntity("非税收入系统",
|
||||||
|
"4"), testTableName);
|
||||||
|
Assert.assertTrue(result == 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDeleteEncodeByCode() {
|
||||||
|
int result = eiDao.deleteEncodeByCode("5", testTableName);
|
||||||
|
Assert.assertTrue(result >= 1);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
package com.platform.test;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import com.platform.entities.EncodedInfoEntity;
|
||||||
|
import com.platform.service.EncodeInfoService;
|
||||||
|
|
||||||
|
public class TestEncodeService extends SMBasedTest {
|
||||||
|
|
||||||
|
private EncodeInfoService eis;
|
||||||
|
private String testTableName;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void initBeforeFunction() {
|
||||||
|
eis = (EncodeInfoService) this.applicationContext
|
||||||
|
.getBean("encodeInfoService");
|
||||||
|
testTableName = "system_info";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetEncodeNameByCode() {
|
||||||
|
String result = eis.getEncodeNameByCode("2", testTableName);
|
||||||
|
Assert.assertTrue(result.equals("部门预算"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 事务测试
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testDeleteEncodeByCode() {
|
||||||
|
eis.deleteEncodeByCode("4", testTableName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetAllEncodeInfo() {
|
||||||
|
List<EncodedInfoEntity> allEntities = eis
|
||||||
|
.getAllEncodeInfo(testTableName);
|
||||||
|
System.out.println(allEntities);
|
||||||
|
Assert.assertTrue(allEntities.size() >= 1);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
package com.platform.test;
|
||||||
|
|
||||||
|
public class User {
|
||||||
|
private String name;
|
||||||
|
private int id;
|
||||||
|
private String sex;
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSex() {
|
||||||
|
return sex;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSex(String sex) {
|
||||||
|
this.sex = sex;
|
||||||
|
}
|
||||||
|
|
||||||
|
public User(String name, int id, String sex) {
|
||||||
|
super();
|
||||||
|
this.name = name;
|
||||||
|
this.id = id;
|
||||||
|
this.sex = sex;
|
||||||
|
}
|
||||||
|
|
||||||
|
public User(){
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,64 @@
|
|||||||
|
package com.platform.test;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.platform.entities.FolderNode;
|
||||||
|
|
||||||
|
public class Volume {
|
||||||
|
private String name;
|
||||||
|
private long totalSize;
|
||||||
|
private long usedSize;
|
||||||
|
private List<Brick> bricks;
|
||||||
|
private List<FolderNode> folderNode;
|
||||||
|
|
||||||
|
public Volume(String volume, long totalSize, long usedSize,
|
||||||
|
List<Brick> bricks, List<FolderNode> folderNode) {
|
||||||
|
super();
|
||||||
|
this.name = volume;
|
||||||
|
this.totalSize = totalSize;
|
||||||
|
this.usedSize = usedSize;
|
||||||
|
this.bricks = bricks;
|
||||||
|
this.folderNode = folderNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVolume() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVolume(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getTotalSize() {
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotalSize(long totalSize) {
|
||||||
|
this.totalSize = totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getUsedSize() {
|
||||||
|
return usedSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsedSize(long usedSize) {
|
||||||
|
this.usedSize = usedSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Brick> getBricks() {
|
||||||
|
return bricks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBricks(List<Brick> bricks) {
|
||||||
|
this.bricks = bricks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<FolderNode> getFolderNode() {
|
||||||
|
return folderNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFolderNode(List<FolderNode> folderNode) {
|
||||||
|
this.folderNode = folderNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
package com.platform.test;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
|
||||||
|
import com.platform.dao.DataInfoDao;
|
||||||
|
|
||||||
|
public class testSystemInfoDao extends SMBasedTest {
|
||||||
|
private DataInfoDao dfDao;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void initBeforeFunction() {
|
||||||
|
dfDao = (DataInfoDao) this.applicationContext.getBean("dataInfoDao");
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Test @Test
|
||||||
|
public void test() {
|
||||||
|
//System.out.println(dfDao.getCount());
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,64 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
|
||||||
|
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"
|
||||||
|
xmlns:context="http://www.springframework.org/schema/context"
|
||||||
|
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||||
|
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||||
|
http://www.springframework.org/schema/tx
|
||||||
|
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
|
||||||
|
http://www.springframework.org/schema/aop
|
||||||
|
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
|
||||||
|
http://www.springframework.org/schema/context
|
||||||
|
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
|
||||||
|
<!-- 读取db.properties中的属性值 -->
|
||||||
|
<bean
|
||||||
|
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
|
||||||
|
<property name="location" value="/WebContent/WEB-INF/config/config.properties"></property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<!-- 连接MySQL数据库 -->
|
||||||
|
<bean id="mySQLDataSource"
|
||||||
|
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
|
||||||
|
<property name="driverClassName" value="${jdbc.mysql.driver}" />
|
||||||
|
<property name="url" value="${jdbc.mysql.url}" />
|
||||||
|
<property name="username" value="${jdbc.mysql.username}" />
|
||||||
|
<property name="password" value="${jdbc.mysql.password}" />
|
||||||
|
</bean>
|
||||||
|
<bean id="mySQLSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
|
||||||
|
<property name="configLocation" value="/WebContent/WEB-INF/config/mybatis-applicationConfig.xml" />
|
||||||
|
<property name="dataSource" ref="mySQLDataSource" />
|
||||||
|
</bean>
|
||||||
|
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
|
||||||
|
<property name="basePackage" value="com.platform.dao" />
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<!-- 配置声明式事物 -->
|
||||||
|
<bean id="mySQLTxManager"
|
||||||
|
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
|
||||||
|
<property name="dataSource" ref="mySQLDataSource" />
|
||||||
|
</bean>
|
||||||
|
<tx:advice id="txAdvice" transaction-manager="mySQLTxManager">
|
||||||
|
<tx:attributes>
|
||||||
|
<tx:method name="delete*" propagation="REQUIRED" />
|
||||||
|
<tx:method name="insert*" propagation="REQUIRED" />
|
||||||
|
<tx:method name="update*" propagation="REQUIRED" />
|
||||||
|
<tx:method name="get*" read-only="true" />
|
||||||
|
<tx:method name="select*" read-only="true" />
|
||||||
|
</tx:attributes>
|
||||||
|
</tx:advice>
|
||||||
|
<aop:config>
|
||||||
|
<aop:pointcut expression="execution(* com.platform.service.*.*(..))"
|
||||||
|
id="pointcut" />
|
||||||
|
<aop:advisor advice-ref="txAdvice" pointcut-ref="pointcut" />
|
||||||
|
</aop:config>
|
||||||
|
<bean id="user" class="com.platform.test.User">
|
||||||
|
<property name="name" value="伍名" />
|
||||||
|
<property name="id" value="1" />
|
||||||
|
<property name="sex" value="男" />
|
||||||
|
</bean>
|
||||||
|
<context:component-scan base-package="com.platform.*">
|
||||||
|
<context:exclude-filter type="annotation"
|
||||||
|
expression="org.springframework.stereotype.Controller" />
|
||||||
|
</context:component-scan>
|
||||||
|
</beans>
|
Loading…
Reference in new issue