Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Springboot Plus
Commits
5e4296bb
"git@ustchcs.com:wwwanlingxiao/LeetCodeAnimation.git" did not exist on "4f4ed06d0f3ba70c3b1b533d6d6979d3474d6821"
Commit
5e4296bb
authored
Feb 21, 2018
by
xiandafu
Browse files
init
parent
321361c9
Changes
6
Hide whitespace changes
Inline
Side-by-side
admin-core/src/test/java/com/ibeetl/admin/core/CoreTestApplication.java
deleted
100644 → 0
View file @
321361c9
package
com.ibeetl.admin.core
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.cache.annotation.EnableCaching
;
@SpringBootApplication
public
class
CoreTestApplication
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
CoreTestApplication
.
class
,
args
);
}
}
\ No newline at end of file
admin-core/src/test/java/com/ibeetl/admin/test/BaseXLSUnitTest.java
deleted
100644 → 0
View file @
321361c9
package
com.ibeetl.admin.test
;
import
java.util.List
;
import
org.beetl.sql.core.SQLManager
;
import
org.junit.BeforeClass
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.mockito.Mockito
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.boot.test.mock.mockito.MockBean
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.coamc.xlsunit.BeetlSqlDBAccess
;
import
com.coamc.xlsunit.XLSFileLoader
;
import
com.coamc.xlsunit.XLSLoader
;
import
com.ibeetl.admin.core.entity.CoreOrg
;
import
com.ibeetl.admin.core.entity.CoreUser
;
import
com.ibeetl.admin.core.service.CorePlatformService
;
import
com.ibeetl.admin.core.service.CoreUserService
;
import
com.ibeetl.admin.core.util.HttpRequestLocal
;
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
@Transactional
public
class
BaseXLSUnitTest
{
protected
BeetlSqlDBAccess
dbAccess
=
null
;
@Autowired
protected
SQLManager
sqlManager
;
@MockBean
protected
HttpRequestLocal
httpRequestLocal
;
@Autowired
protected
CoreUserService
userService
;
public
static
XLSLoader
loader
=
null
;
@BeforeClass
public
static
void
initData
(){
String
root
=
System
.
getProperty
(
"user.dir"
)+
"/src/test/resources/xls"
;
loader
=
new
XLSFileLoader
(
root
);
}
public
void
init
()
{
dbAccess
=
new
BeetlSqlDBAccess
(
sqlManager
);
}
/**
* 模拟用户登录
* @param userId
* @param orgId
*/
protected
void
login
(
Long
userId
,
Long
orgId
){
CoreUser
user
=
userService
.
getUserById
(
userId
);
CoreOrg
org
=
userService
.
getOrgById
(
orgId
);
List
<
CoreOrg
>
orgs
=
userService
.
getUserOrg
(
userId
,
orgId
);
Mockito
.
when
(
httpRequestLocal
.
getSessionValue
(
Mockito
.
eq
(
CorePlatformService
.
ACCESS_CURRENT_USER
))).
thenReturn
(
user
);
Mockito
.
when
(
httpRequestLocal
.
getSessionValue
(
Mockito
.
eq
(
CorePlatformService
.
ACCESS_CURRENT_ORG
))).
thenReturn
(
org
);
Mockito
.
when
(
httpRequestLocal
.
getSessionValue
(
Mockito
.
eq
(
CorePlatformService
.
ACCESS_USER_ORGS
))).
thenReturn
(
orgs
);
Mockito
.
when
(
httpRequestLocal
.
getSessionValue
(
Mockito
.
eq
(
"ip"
))).
thenReturn
(
"127.0.01"
);
}
@Test
public
void
testSkip
(){
}
}
admin-core/src/test/java/com/ibeetl/admin/test/CoreTest.java
deleted
100644 → 0
View file @
321361c9
package
com.ibeetl.admin.test
;
import
static
org
.
junit
.
Assert
.
fail
;
import
java.util.List
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.annotation.Rollback
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
com.coamc.xlsunit.RowHolderFacotoy
;
import
com.coamc.xlsunit.VariableTable
;
import
com.coamc.xlsunit.XLSParser
;
import
com.ibeetl.admin.core.entity.CoreOrg
;
import
com.ibeetl.admin.core.rbac.UserLoginInfo
;
import
com.ibeetl.admin.core.rbac.tree.OrgItem
;
import
com.ibeetl.admin.core.service.CorePlatformService
;
import
com.ibeetl.admin.core.service.CoreUserService
;
import
junit.framework.Assert
;
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
public
class
CoreTest
extends
BaseXLSUnitTest
{
@Autowired
CorePlatformService
platformService
;
@Autowired
CoreUserService
sysUserService
;
XLSParser
userParser
=
null
;
@Before
public
void
init
()
{
super
.
init
();
userParser
=
new
XLSParser
(
BaseXLSUnitTest
.
loader
,
"coreTest.xlsx"
,
dbAccess
,
new
RowHolderFacotoy
.
RowBeetlSQLHolderFactory
());
}
@Test
public
void
testUserLogin
()
{
VariableTable
vars
=
new
VariableTable
();
userParser
.
init
(
vars
);
//执行某个测试场景的初始化工作,初始化user表
userParser
.
prepare
(
"用户相关测试"
,
vars
);
String
password
=
vars
.
findString
(
"user.password"
);
UserLoginInfo
userInfo
=
sysUserService
.
login
(
"jk01"
,
password
);
if
(
userInfo
==
null
){
fail
(
"用户未找到"
);
}
List
<
CoreOrg
>
orgs
=
userInfo
.
getOrgs
();
}
@Test
public
void
testOrgInfo
()
{
VariableTable
vars
=
new
VariableTable
();
userParser
.
init
(
vars
);
//执行某个测试场景的初始化工作,初始化user表
userParser
.
prepare
(
"用户相关测试"
,
vars
);
Long
adminId
=
vars
.
findLong
(
"user.adminId"
);
//根节点,能看到所有
Long
orgId
=
1
l
;
super
.
login
(
adminId
,
orgId
);
OrgItem
root
=
platformService
.
getUserOrgTree
();
//超级管理员可以看到所有组织结构
org
.
junit
.
Assert
.
assertEquals
(
1
l
,
root
.
getId
().
longValue
());
//研发管理员,能看到所在公司的结果
Long
jkItManager
=
vars
.
findLong
(
"user.deptAdmin"
);
Long
departmentId
=
vars
.
findLong
(
"org.it"
);
long
corpId
=
vars
.
findLong
(
"org.jk"
);
super
.
login
(
jkItManager
,
corpId
);
OrgItem
deptItem
=
platformService
.
getUserOrgTree
();
org
.
junit
.
Assert
.
assertEquals
(
corpId
,
deptItem
.
getId
().
longValue
());
}
@Test
public
void
testFunctionAccess
()
{
VariableTable
vars
=
new
VariableTable
();
userParser
.
init
(
vars
);
//执行某个测试场景的初始化工作,初始化user表
userParser
.
prepare
(
"用户相关测试"
,
vars
);
Long
adminId
=
vars
.
findLong
(
"user.adminId"
);
//根节点,能看到所有
Long
orgId
=
1
l
;
super
.
login
(
adminId
,
orgId
);
boolean
access
=
platformService
.
canAcessFunction
(
adminId
,
orgId
,
"user"
);
org
.
junit
.
Assert
.
assertTrue
(
access
);
access
=
platformService
.
canAcessFunction
(
adminId
,
orgId
,
"user.edit"
);
org
.
junit
.
Assert
.
assertTrue
(
access
);
Long
ceo
=
vars
.
findLong
(
"user.corpCEO"
);
Long
corpId
=
vars
.
findLong
(
"org.jk"
);
super
.
login
(
ceo
,
corpId
);
access
=
platformService
.
canAcessFunction
(
ceo
,
corpId
,
"user.query"
);
org
.
junit
.
Assert
.
assertTrue
(
access
);
//ceo 不能编辑
access
=
platformService
.
canAcessFunction
(
ceo
,
corpId
,
"user.edit"
);
org
.
junit
.
Assert
.
assertFalse
(
access
);
Long
assist
=
vars
.
findLong
(
"user.assist"
);
super
.
login
(
assist
,
corpId
);
access
=
platformService
.
canAcessFunction
(
assist
,
corpId
,
"user.query"
);
org
.
junit
.
Assert
.
assertTrue
(
access
);
// 助理能编辑用户
access
=
platformService
.
canAcessFunction
(
assist
,
corpId
,
"user.edit"
);
org
.
junit
.
Assert
.
assertTrue
(
access
);
}
}
\ No newline at end of file
admin-core/src/test/resources/application.properties
deleted
100644 → 0
View file @
321361c9
spring.datasource.url
=
jdbc:mysql://172.16.86.56:3306/sample-test?useUnicode=true&characterEncoding=UTF-8
spring.datasource.username
=
root
spring.datasource.password
=
123456
spring.datasource.driver-class-name
=
com.mysql.cj.jdbc.Driver
spring.session.store-type
=
HASH_MAP
#spring.cache.type=
spring.cache.type
=
None
logging.level.root
=
info
\ No newline at end of file
admin-core/src/test/resources/xls/coreTest.xlsx
deleted
100644 → 0
View file @
321361c9
File deleted
admin-core/src/test/resources/xls/init.xlsx
deleted
100644 → 0
View file @
321361c9
File deleted
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment