Package test.user

Source Code of test.user.TestAcountInfo

package test.user;

import java.net.URL;
import java.util.Date;

import org.apache.commons.codec.digest.DigestUtils;
import org.apache.log4j.PropertyConfigurator;
import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.skyline.base.type.Authority;
import com.skyline.user.model.User;
import com.skyline.user.service.AccountInfoService;

public class TestAcountInfo {
  private static AccountInfoService service;

  static {
    URL url = TestAcountInfo.class.getClassLoader().getResource("config/logger/log4j.properties");
    PropertyConfigurator.configure(url);
  }
 
  @BeforeClass
  public static void before() {
    ApplicationContext ctx = new ClassPathXmlApplicationContext(
        "config/context/applicationContext.xml");
    service = (AccountInfoService) ctx.getBean("accountInfoService");
  }

  //@Test
  public void checkSecurityAnswer(){
    boolean ans=service.checkSecurityAnswer(Long.valueOf(4), "securityAnswer");
    System.out.println(ans);
  }
 
  //@Test
  public void querySecurityQuestion(){
   
    Date d1 =new Date();
    User user=service.getSecurityQuestion("buringcl@163.com");
    if(user!=null){
      System.out.println(user.getSecurityQuestion());
    }
    Date d2 =new Date();
    System.out.println(d2.getTime()-d1.getTime());
  }
 
  @Test
  public void queryAccountInfo(){
    User user=service.getAccountInfoByUserID(Long.valueOf(4));
    if(user!=null){
      System.out.println(user.getId());
      System.out.println(user.getSecurityQuestion());
      System.out.println(user.getSecurityAnswer());
      System.out.println(user.getSecurityEmail());
      System.out.println(user.getAuthority());
    }
  }
 
  @Test
  public void updatePassword() {
   
    String oldPassword = String.valueOf(DigestUtils.md5Hex("password"));
    String newPassword = String.valueOf(DigestUtils.md5Hex("newpassword1"));
    service.modifyPassword("burningcl@gmail.com", oldPassword, newPassword);
  }

 
  public void updateSecurityInfo() {
    service.modifySecurityInfo(Long.valueOf(4), Authority.ONLY_TO_FANS,
        "securityQuestion", "securityAnswer", "securityEmail1");
  }

}
TOP

Related Classes of test.user.TestAcountInfo

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.