oauth2 v2 update

This commit is contained in:
Sola
2016-03-27 03:12:58 +08:00
parent 910bdca8a8
commit 850e45a2d8
48 changed files with 799 additions and 422 deletions

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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() {

View File

@@ -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();
}
}

View 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!!&")
);
}
}

View File

@@ -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);
}
}