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