encode decode test

This commit is contained in:
geek 2017-09-05 12:41:14 +09:00
parent c94f55fbd3
commit 7058602752

View File

@ -0,0 +1,43 @@
package com.loafle.overflow.commons.utils;
import com.loafle.overflow.spring.AppConfigTest;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.net.URLDecoder;
import java.net.URLEncoder;
import static org.junit.Assert.*;
/**
* Created by geek on 17. 9. 5.
*/
@Ignore
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {AppConfigTest.class})
public class EmailSenderTest {
@Autowired
private EmailSender emailSender;
@Test
public void encrypt() throws Exception {
// dZQgXM1o/Cx48X8DM+6ec/oPfqA2l/LdWtijOZ2EnWk=
String en = this.emailSender.encrypt("geekdev@naver.com");
String encode = URLEncoder.encode(en, "UTF-8");
Assert.assertEquals(encode , "dZQgXM1o%2FCx48X8DM%2B6ec%2FoPfqA2l%2FLdWtijOZ2EnWk%3D");
}
@Test
public void decrypt() throws Exception {
String decode = URLDecoder.decode("dZQgXM1o%2FCx48X8DM%2B6ec%2FoPfqA2l%2FLdWtijOZ2EnWk%3D", "UTF-8");
String dn = this.emailSender.decrypt(decode);
Assert.assertEquals(dn , "geekdev@naver.com");
}
}