mirror of
https://github.com/ZSCNetSupportDept/WechatTicketSystem.git
synced 2025-10-29 16:14:16 +08:00
oauth2 v2 update
This commit is contained in:
@@ -1,34 +1,23 @@
|
||||
package love.sola.netsupport.api;
|
||||
|
||||
import com.google.common.reflect.ClassPath;
|
||||
import org.junit.Test;
|
||||
import org.reflections.Reflections;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2014/8/20.
|
||||
* Created by Sola on 2016/3/26.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
*/
|
||||
public class ReflectionTest {
|
||||
|
||||
@Test
|
||||
public void test() throws IOException, IllegalAccessException, InstantiationException {
|
||||
int count = 0;
|
||||
ClassPath path = ClassPath.from(getClass().getClassLoader());
|
||||
Set<ClassPath.ClassInfo> classes = path.getTopLevelClassesRecursive(getClass().getPackage().getName());
|
||||
for (ClassPath.ClassInfo info : classes) {
|
||||
Class<?> clz = info.load();
|
||||
if (!API.class.equals(clz) && API.class.isAssignableFrom(clz)) {
|
||||
System.out.println("Loading API: " + clz.getName());
|
||||
API obj = (API) clz.newInstance();
|
||||
System.out.println("Registered API: " + obj);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
System.out.println("Total " + count + " API(s) loaded.");
|
||||
public void test() {
|
||||
Reflections reflections = new Reflections(getClass().getPackage().getName());
|
||||
Set<Class<? extends API>> set = reflections.getSubTypesOf(API.class);
|
||||
assert set.size() == 14;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
package love.sola.netsupport.wechat;
|
||||
package love.sola.netsupport.config;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/12/3.
|
||||
* Created by Sola on 2016/3/26.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
*/
|
||||
public class TestDate {
|
||||
public class ReflectionTest {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
System.out.println(new Date());
|
||||
public void testLang() {
|
||||
assert Lang.messages != null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package love.sola.netsupport.wechat;
|
||||
package love.sola.netsupport.enums;
|
||||
|
||||
import love.sola.netsupport.enums.Block;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
@@ -9,11 +8,21 @@ import org.junit.Test;
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
*/
|
||||
public class TestReflection {
|
||||
public class ReflectionTest {
|
||||
|
||||
@Test
|
||||
public void testBlock() {
|
||||
assert Block.inverseMap != null;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAccess() {
|
||||
assert Access.inverseMap != null;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStatus() {
|
||||
assert Status.inverseMap != null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package love.sola.netsupport.wechat;
|
||||
package love.sola.netsupport.util;
|
||||
|
||||
import love.sola.netsupport.util.RSAUtil;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.junit.Test;
|
||||
import org.mindrot.jbcrypt.BCrypt;
|
||||
@@ -16,7 +15,7 @@ import java.security.spec.X509EncodedKeySpec;
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
*/
|
||||
public class TestEncrypt {
|
||||
public class EncryptTest {
|
||||
|
||||
@Test
|
||||
public void testBCrypt() {
|
||||
@@ -1,11 +1,9 @@
|
||||
package love.sola.netsupport.wechat;
|
||||
package love.sola.netsupport.util;
|
||||
|
||||
import com.google.gson.*;
|
||||
import love.sola.netsupport.config.Lang;
|
||||
import love.sola.netsupport.enums.ISP;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
@@ -14,12 +12,7 @@ import java.util.Date;
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
*/
|
||||
public class TestMessageFormat {
|
||||
|
||||
@Test
|
||||
public void testLang() {
|
||||
assert Lang.messages != null;
|
||||
}
|
||||
public class GsonTest {
|
||||
|
||||
@Test
|
||||
public void testJsonDate() {
|
||||
@@ -35,14 +28,4 @@ public class TestMessageFormat {
|
||||
assert gson.toJson(ISP.TELECOM).equals("1");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLong() {
|
||||
assert "15838838438".equals(MessageFormat.format("{0,number,#}", 15838838438L));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOpInfo() {
|
||||
assert !Lang.format("Operator_Info", 1541, "Sola", 0, 0, 4).isEmpty();
|
||||
}
|
||||
|
||||
}
|
||||
34
src/test/java/love/sola/netsupport/util/URLEncodeTest.java
Normal file
34
src/test/java/love/sola/netsupport/util/URLEncodeTest.java
Normal file
@@ -0,0 +1,34 @@
|
||||
package love.sola.netsupport.util;
|
||||
|
||||
import com.google.common.net.UrlEscapers;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2016/3/26.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
*/
|
||||
public class URLEncodeTest {
|
||||
|
||||
@Test
|
||||
public void testEncode() throws UnsupportedEncodingException {
|
||||
assertThat(
|
||||
UrlEscapers.urlFragmentEscaper().escape("Test Title"),
|
||||
equalTo("Test%20Title")
|
||||
);
|
||||
assertThat(
|
||||
Redirect.success()
|
||||
.title("Test Title")
|
||||
.msg("Test Message")
|
||||
.toString(),
|
||||
equalTo("http://topaz.sinaapp.com/nm/v2/result.html?type=1&title=!!Test%20Title!!&msg=!!Test%20Message!!&")
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package love.sola.netsupport.wechat;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/11/26.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
*/
|
||||
public class TestRegex {
|
||||
|
||||
public static final String STUDENT_ID_REGEX = "^(2012|2013|2014|2015)[0-9]{9}";
|
||||
|
||||
@Test
|
||||
public void testStudentId() {
|
||||
assert !"2011130201233".matches(STUDENT_ID_REGEX);
|
||||
assert "2015130201233".matches(STUDENT_ID_REGEX);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user