补全单元测试

This commit is contained in:
2018-07-07 09:41:41 +08:00
parent 4630ac4dc5
commit 139f89ede2
3 changed files with 38 additions and 12 deletions

20
sql.sql
View File

@@ -1,4 +1,4 @@
DROP DATABASE db_shiroTest;
DROP DATABASE IF EXISTS db_shiroTest;
GRANT ALL ON db_shiroTest.* TO trs@localhost
IDENTIFIED BY 'shiro';
FLUSH PRIVILEGES;
@@ -84,13 +84,11 @@ INSERT INTO user_role (rid, uid) VALUE ('1', '1');
INSERT INTO user_role (rid, uid) VALUE ('2', '2');
INSERT INTO user_role (rid, uid) VALUE ('3', '3');
SELECT
u.*,
r.*,
p.*
FROM user u
INNER JOIN user_role ur ON ur.uid = u.uid
INNER JOIN role r ON ur.uid = r.rid
INNER JOIN permission_role pr ON r.rid = pr.rid
INNER JOIN permission p ON pr.pid = p.pid
WHERE u.username
CREATE VIEW v_user_role_permission
AS
SELECT u.username,r.rname,p.name,p.url
FROM user u
INNER JOIN user_role ur ON ur.uid = u.uid
INNER JOIN role r ON ur.uid = r.rid
INNER JOIN permission_role pr ON r.rid = pr.rid
INNER JOIN permission p ON pr.pid = p.pid

View File

@@ -7,6 +7,6 @@ import top.fjy8018.shiro.dataobject.User;
* @date 2018/7/5 21:27
*/
public interface UserService {
User findByUsername(String username);
}

View File

@@ -0,0 +1,28 @@
package top.fjy8018.shiro.service;
import lombok.extern.slf4j.Slf4j;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import top.fjy8018.shiro.ShiroApplicationTests;
import top.fjy8018.shiro.dataobject.User;
import static org.junit.Assert.*;
@Slf4j
@Component
public class UserServiceTest extends ShiroApplicationTests {
@Autowired
private UserService userService;
private static final String USERNAME = "admin";
@Test
public void findByUsername() {
User userRes = userService.findByUsername(USERNAME);
log.info("【User】:{}",userRes);
Assert.assertNotNull(userRes);
}
}