1.0版本完成

This commit is contained in:
hupeng
2019-11-06 21:34:55 +08:00
commit a7f03930ca
644 changed files with 40190 additions and 0 deletions

View File

@ -0,0 +1,31 @@
package co.yixiang.utils;
import org.junit.Assert;
import org.junit.Test;
public class EncryptUtilsTest {
/**
* 对称加密
*/
@Test
public void testDesEncrypt() {
try {
Assert.assertEquals("7772841DC6099402", EncryptUtils.desEncrypt("123456"));
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 对称解密
*/
@Test
public void testDesDecrypt() {
try {
Assert.assertEquals("123456", EncryptUtils.desDecrypt("7772841DC6099402"));
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,36 @@
package co.yixiang.utils;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.mock.web.MockMultipartFile;
import static org.junit.Assert.*;
public class FileUtilTest {
@Test
public void testToFile() {
long retval = FileUtil.toFile(new MockMultipartFile("foo", (byte[]) null)).getTotalSpace();
assertEquals(500695072768L, retval);
}
@Test
public void testGetExtensionName() {
Assert.assertEquals("foo", FileUtil.getExtensionName("foo"));
Assert.assertEquals("exe", FileUtil.getExtensionName("bar.exe"));
}
@Test
public void testGetFileNameNoEx() {
Assert.assertEquals("foo", FileUtil.getFileNameNoEx("foo"));
Assert.assertEquals("bar", FileUtil.getFileNameNoEx("bar.txt"));
}
@Test
public void testGetSize() {
Assert.assertEquals("1000B ", FileUtil.getSize(1000));
Assert.assertEquals("1.00KB ", FileUtil.getSize(1024));
Assert.assertEquals("1.00MB ", FileUtil.getSize(1048576));
Assert.assertEquals("1.00GB ", FileUtil.getSize(1073741824));
}
}

View File

@ -0,0 +1,49 @@
package co.yixiang.utils;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.mock.web.MockHttpServletRequest;
import java.text.SimpleDateFormat;
import java.util.*;
import static org.junit.Assert.*;
public class StringUtilsTest {
@Test
public void testInString() {
assertTrue(StringUtils.inString("?", "?"));
assertFalse(StringUtils.inString("?", new String[]{}));
}
@Test
public void testToCamelCase() {
assertNull(StringUtils.toCamelCase(null));
}
@Test
public void testToCapitalizeCamelCase() {
assertNull(StringUtils.toCapitalizeCamelCase(null));
Assert.assertEquals("HelloWorld", StringUtils.toCapitalizeCamelCase("hello_world"));
}
@Test
public void testToUnderScoreCase() {
assertNull(StringUtils.toUnderScoreCase(null));
Assert.assertEquals("hello_world", StringUtils.toUnderScoreCase("helloWorld"));
Assert.assertEquals("\u0000\u0000", StringUtils.toUnderScoreCase("\u0000\u0000"));
Assert.assertEquals("\u0000_a", StringUtils.toUnderScoreCase("\u0000A"));
}
@Test
public void testGetWeekDay() {
SimpleDateFormat simpleDateformat = new SimpleDateFormat("E");
Assert.assertEquals(simpleDateformat.format(new Date()), StringUtils.getWeekDay());
}
@Test
public void testGetIP() {
Assert.assertEquals("127.0.0.1", StringUtils.getIP(new MockHttpServletRequest()));
}
}