RestSleepTest
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
package org.redkale.test.http;
|
package org.redkale.test.http;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.net.*;
|
import java.net.*;
|
||||||
import org.junit.jupiter.api.*;
|
import org.junit.jupiter.api.*;
|
||||||
import org.redkale.boot.Application;
|
import org.redkale.boot.Application;
|
||||||
@@ -20,11 +21,8 @@ import org.redkale.util.*;
|
|||||||
/** @author zhangjx */
|
/** @author zhangjx */
|
||||||
public class RestSleepTest {
|
public class RestSleepTest {
|
||||||
|
|
||||||
private boolean main;
|
|
||||||
|
|
||||||
public static void main(String[] args) throws Throwable {
|
public static void main(String[] args) throws Throwable {
|
||||||
RestSleepTest test = new RestSleepTest();
|
RestSleepTest test = new RestSleepTest();
|
||||||
test.main = true;
|
|
||||||
test.run();
|
test.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,6 +35,9 @@ public class RestSleepTest {
|
|||||||
final ResourceFactory resFactory = ResourceFactory.create();
|
final ResourceFactory resFactory = ResourceFactory.create();
|
||||||
resFactory.register(JsonConvert.root());
|
resFactory.register(JsonConvert.root());
|
||||||
resFactory.register(BsonConvert.root());
|
resFactory.register(BsonConvert.root());
|
||||||
|
Method method = Application.class.getDeclaredMethod("initWorkExecutor");
|
||||||
|
method.setAccessible(true);
|
||||||
|
method.invoke(application);
|
||||||
|
|
||||||
// ------------------------ 初始化 CService ------------------------------------
|
// ------------------------ 初始化 CService ------------------------------------
|
||||||
RestSleepService service = Sncp.createSimpleLocalService(RestSleepService.class, resFactory);
|
RestSleepService service = Sncp.createSimpleLocalService(RestSleepService.class, resFactory);
|
||||||
@@ -69,7 +70,6 @@ public class RestSleepTest {
|
|||||||
System.out.println("返回结果: " + new String(bytes, 0, pos));
|
System.out.println("返回结果: " + new String(bytes, 0, pos));
|
||||||
System.out.println("耗时: " + e + " ms");
|
System.out.println("耗时: " + e + " ms");
|
||||||
server.shutdown();
|
server.shutdown();
|
||||||
int exptime = Runtime.getRuntime().availableProcessors() > 2 ? 600 : 1100;
|
Assertions.assertTrue(e < 600);
|
||||||
Assertions.assertTrue(e < exptime);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user