补全单元测试

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 GRANT ALL ON db_shiroTest.* TO trs@localhost
IDENTIFIED BY 'shiro'; IDENTIFIED BY 'shiro';
FLUSH PRIVILEGES; 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 ('2', '2');
INSERT INTO user_role (rid, uid) VALUE ('3', '3'); INSERT INTO user_role (rid, uid) VALUE ('3', '3');
SELECT CREATE VIEW v_user_role_permission
u.*, AS
r.*, SELECT u.username,r.rname,p.name,p.url
p.* FROM user u
FROM user u INNER JOIN user_role ur ON ur.uid = u.uid
INNER JOIN user_role ur ON ur.uid = u.uid INNER JOIN role r ON ur.uid = r.rid
INNER JOIN role r ON ur.uid = r.rid INNER JOIN permission_role pr ON r.rid = pr.rid
INNER JOIN permission_role pr ON r.rid = pr.rid INNER JOIN permission p ON pr.pid = p.pid
INNER JOIN permission p ON pr.pid = p.pid
WHERE u.username

View File

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