Package test.user

Source Code of test.user.TestEmailTokenDao

package test.user;

import java.net.URL;
import java.util.List;

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.user.dao.EmailTokenDao;
import com.skyline.user.model.EmailToken;
import com.skyline.user.type.EmailTokenType;

public class TestEmailTokenDao {
  private static EmailTokenDao emailTokenDao;

  static {
    URL url = TestEmailTokenDao.class.getClassLoader().getResource("config/logger/log4j.properties");
    PropertyConfigurator.configure(url);
  }

  @BeforeClass
  public static void before() {
    ApplicationContext ctx = new ClassPathXmlApplicationContext("config/context/applicationContext.xml");
    emailTokenDao = (EmailTokenDao) ctx.getBean("emailTokenDao");
  }

  //@Test
  public void queryTokenByEmailAndTypeAndChecked() {
    String email = "burningcl@gmail.com";
    EmailTokenType type = EmailTokenType.PASSWORD_FIND;
    boolean checked = true;
    List<EmailToken> ts = emailTokenDao.queryTokenByEmailAndTypeAndChecked(email, type, checked);
    for (EmailToken t : ts) {
      System.out.println(t.getId() + "\t" + t.getEmail() + "\t" + t.getUserId() + "\t" + t.getToken() + "\t" + t.getCheckTime() + "\t" + t.getType().toString());
    }
  }

  //@Test
  public void queryTokenByUserIdAndTypeAndChecked() {
    long userId = 1;
    EmailTokenType type = EmailTokenType.PASSWORD_FIND;
    boolean checked = true;
    List<EmailToken> ts = emailTokenDao.queryTokenByUserIdAndTypeAndChecked(userId, type, checked);
    for (EmailToken t : ts) {
      System.out.println(t.getId() + "\t" + t.getEmail() + "\t" + t.getUserId() + "\t" + t.getToken() + "\t" + t.getCheckTime() + "\t" + t.getType().toString());
    }
  }

  //@Test
  public void insertToken() {
    EmailToken t=new EmailToken();
    t.setEmail("burningcl@gmail.com1");
    t.setToken("this is token4");
    t.setType(EmailTokenType.PASSWORD_FIND);
    t.setUserId(2);
    emailTokenDao.insertToken(t);
  }

  //@Test
  public void updateTokenChecked() {
    emailTokenDao.updateTokenChecked(3, true);
  }
 
  @Test
  public void testQueryToken (){
    String tokenStr="032ea1486ed8f5266589d8c9b6e7411d";
    EmailToken token=emailTokenDao.queryToken(tokenStr);
    System.out.println(token.getEmail());
  }
}
TOP

Related Classes of test.user.TestEmailTokenDao

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.