插件开发工具库,推荐依赖该工具库。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

84 lines
2.2 KiB

package com.fanruan.api.util;
import com.fanruan.api.Prepare;
import com.fr.general.GeneralUtils;
import com.fr.license.utils.JsonUtil;
import com.fr.stable.StableUtils;
import org.junit.Assert;
import org.junit.Test;
import java.util.Locale;
/**
* @author richie
* @version 10.0
* Created by richie on 2019-08-09
*/
public class GeneralKitTest extends Prepare {
@Test
public void getMacAddress() throws Exception{
Assert.assertEquals(GeneralKit.getMacAddress(), com.fr.general.GeneralUtils.getMacAddress());
}
@Test
public void objectToString() {
Integer s = 1;
Assert.assertEquals(GeneralKit.objectToString(s),"1");
}
@Test
public void readBuildNO() {
Assert.assertEquals(GeneralKit.readBuildNO(), GeneralUtils.readBuildNO());
}
@Test
public void compare() {
Integer s = 1;
Integer s3 = 1;
Integer s1 = 2;
Integer s2 = 0;
Assert.assertEquals(GeneralKit.compare(s,s1),-1);
Assert.assertEquals(GeneralKit.compare(s,s3),0);
Assert.assertEquals(GeneralKit.compare(s,s2),1);
}
@Test
public void equals() {
String str1 = "a";
String str2 = "a";
String str3 = "b";
int i1 = 1;
int i2 = 1;
int i3 = 2;
Assert.assertEquals(GeneralKit.equals(str1,str2),true);
Assert.assertEquals(GeneralKit.equals(str1,str3),false);
Assert.assertEquals(GeneralKit.equals(i1,i2),true);
Assert.assertEquals(GeneralKit.equals(i1,i3),false);
}
@Test
public void join() {
Object obj[] = {1, 2, 3, 4};
String result = "1-2-3-4";
Assert.assertEquals(GeneralKit.join(obj, "-"), result);
}
@Test
public void getLocale() {
Assert.assertEquals(GeneralKit.getLocale(), Locale.CHINA);
}
@Test
public void pathJoin(){
String strArray[] = {"abc", "def"};
Assert.assertEquals(GeneralKit.pathJoin(strArray), "abc/def");
}
@Test
public void testClassForName() throws ClassNotFoundException {
String className = "com.fanruan.api.util.GeneralKitTest";
Assert.assertEquals(GeneralKit.classForName(className), StableUtils.classForName(className));
}
}