为了账号安全,请及时绑定邮箱和手机立即绑定

运行为什么junit会报找不到要运行的方法


package com.cn;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.mgt.DefaultSecurityManager;
import org.apache.shiro.realm.SimpleAccountRealm;
import org.apache.shiro.subject.Subject;
import org.junit.Before;
import org.junit.Test;

import java.text.SimpleDateFormat;

/**
 * @Author:.
 * @Description:
 * @Date:Created in 2019/3/13 15:38
 * @Modified By:
 */
public class AuthenticationTest {

    SimpleAccountRealm simpleAccountRealm=new SimpleAccountRealm();

    @Before
    public void addUser(){
        simpleAccountRealm.addAccount("Mark","123456");
    }


    @Test
    public void testAuthentication(){

        //1.构建SecurityManager环境
        DefaultSecurityManager defaultSecurityManager=new DefaultSecurityManager();
        defaultSecurityManager.setRealm(simpleAccountRealm);

        //2.主体提交认证请求
        SecurityUtils.setSecurityManager(defaultSecurityManager);
        Subject subject=SecurityUtils.getSubject();
        UsernamePasswordToken token=new UsernamePasswordToken("Mark","123456");
        subject.login(token);
        System.out.println("isAuthenticated"+subject.isAuthenticated());

    }
}


正在回答

1 回答

AuthenticationTest


上面要加注解

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

运行为什么junit会报找不到要运行的方法

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信