Browse Source

test

Signed-off-by: lidongy <1879087903@qq.com>
pull/1/head
lidongy 5 years ago
parent
commit
74400ef6b9
  1. 69
      src/test/java/com/fanruan/api/decision/login/LoginKitTest.java

69
src/test/java/com/fanruan/api/decision/login/LoginKitTest.java

@ -0,0 +1,69 @@
package com.fanruan.api.decision.login;
import com.fanruan.api.security.JwtKit;
import com.fr.config.dao.DaoContext;
import com.fr.config.dao.impl.LocalClassHelperDao;
import com.fr.config.dao.impl.LocalEntityDao;
import com.fr.config.dao.impl.LocalXmlEntityDao;
import com.fr.decision.config.AppearanceConfig;
import com.fr.decision.webservice.Response;
import com.fr.decision.webservice.bean.authentication.LoginClientBean;
import com.fr.decision.webservice.exception.login.LoginInfoNotAvailableException;
import com.fr.decision.webservice.utils.DecisionStatusService;
import com.fr.runtime.FineRuntime;
import com.fr.store.StateHubManager;
import com.fr.store.impl.MemoryLock;
import com.fr.store.impl.MemoryStore;
import com.fr.transaction.Configurations;
import com.fr.transaction.LocalConfigurationHelper;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
/**
* @author lidongy
* @version 10.0
* Created by lidongy on 2019/10/25
*/
public class LoginKitTest {
@Before
public void start() {
FineRuntime.start();
DaoContext.setEntityDao(new LocalEntityDao());
DaoContext.setClassHelperDao(new LocalClassHelperDao());
DaoContext.setXmlEntityDao(new LocalXmlEntityDao());
Configurations.setHelper(new LocalConfigurationHelper());
StateHubManager.setStorage(new MemoryStore());
StateHubManager.setLock(new MemoryLock());
}
@Test
public void testRefreshToken() throws Exception{
String jwtString = JwtKit.createDefaultJWT("123");
Object responseData = new Object();
String errorCode = "";
String errorMsg = "";
try {
Response response = (Response) LoginKit.refreshToken(jwtString, 1000 * 60, null, responseData, errorCode, errorMsg);
} catch (Exception e) {
Assert.assertTrue(e instanceof LoginInfoNotAvailableException);
}
LoginClientBean loginClientBean = new LoginClientBean();
DecisionStatusService.loginStatusService().put(jwtString, loginClientBean);
try {
Response response = (Response) LoginKit.refreshToken(jwtString, 1000 * 60, null, responseData, errorCode, errorMsg);
} catch (Exception e) {
Assert.assertFalse(e instanceof LoginInfoNotAvailableException);
}
}
@Test
public void TestGetLoginPageId() {
AppearanceConfig.getInstance().setLoginPageId("111");
Assert.assertEquals(LoginKit.getLoginPageId(), "111");
AppearanceConfig.getInstance().setLoginPageId("aaa");
Assert.assertEquals(LoginKit.getLoginPageId(), "aaa");
}
}
Loading…
Cancel
Save