Search in sources :

Example 1 with ControllerProxy

use of com.tvd12.ezyhttp.server.core.reflect.ControllerProxy in project ezyfox-server by youngmonkeys.

the class EzyRequestControllerTest method test.

@Test
public void test() {
    Object instance = new HelloController();
    EzyRequestControllerProxy controllerProxy = new EzyRequestControllerProxy(instance);
    assert controllerProxy.getInstance() == instance;
    // noinspection ConstantConditions
    assert controllerProxy.getExceptionHandlerMethods().size() >= 0;
    System.out.println(controllerProxy);
}
Also used : HelloController(com.tvd12.ezyfoxserver.support.test.controller.HelloController) EzyRequestControllerProxy(com.tvd12.ezyfoxserver.support.reflect.EzyRequestControllerProxy) Test(org.testng.annotations.Test)

Example 2 with ControllerProxy

use of com.tvd12.ezyhttp.server.core.reflect.ControllerProxy in project ezyhttp by youngmonkeys.

the class ControllerProxyTest method isManagementTest.

@Test
public void isManagementTest() {
    // given
    ControllerProxy sut = new ControllerProxy(new InternalController());
    // when
    // then
    Asserts.assertTrue(sut.isManagement());
}
Also used : ControllerProxy(com.tvd12.ezyhttp.server.core.reflect.ControllerProxy) BaseTest(com.tvd12.test.base.BaseTest) Test(org.testng.annotations.Test)

Example 3 with ControllerProxy

use of com.tvd12.ezyhttp.server.core.reflect.ControllerProxy in project ezyhttp by youngmonkeys.

the class RequestHandlerImplementerTest method test.

@Test
public void test() {
    RequestHandlerImplementer.setDebug(true);
    ControllerProxy homeController = new ControllerProxy(new HomeController());
    for (RequestHandlerMethod method : homeController.getRequestHandlerMethods()) {
        RequestHandlerImplementer implementer = new RequestHandlerImplementer(homeController, method);
        implementer.implement();
    }
}
Also used : RequestHandlerMethod(com.tvd12.ezyhttp.server.core.reflect.RequestHandlerMethod) HomeController(com.tvd12.ezyhttp.server.core.test.controller.HomeController) RequestHandlerImplementer(com.tvd12.ezyhttp.server.core.asm.RequestHandlerImplementer) ControllerProxy(com.tvd12.ezyhttp.server.core.reflect.ControllerProxy) BaseTest(com.tvd12.test.base.BaseTest) Test(org.testng.annotations.Test)

Example 4 with ControllerProxy

use of com.tvd12.ezyhttp.server.core.reflect.ControllerProxy in project ezyhttp by youngmonkeys.

the class RequestHandlerImplementerTest method implementOneFailed.

@Test
public void implementOneFailed() throws Exception {
    // given
    ControllerProxy controller = new ControllerProxy(new Controller());
    RequestHandlerMethod handlerMethod = new RequestHandlerMethod("/", new EzyMethod(Controller.class.getDeclaredMethod("doGet")));
    RequestHandlerImplementer sut = new RequestHandlerImplementer(controller, handlerMethod);
    // when
    Throwable e = Asserts.assertThrows(sut::implement);
    // then
    Asserts.assertEquals(0, handlerMethod.getParameterTypes().length);
    Asserts.assertThat(e).isEqualsType(IllegalStateException.class);
}
Also used : RequestHandlerMethod(com.tvd12.ezyhttp.server.core.reflect.RequestHandlerMethod) RequestHandlerImplementer(com.tvd12.ezyhttp.server.core.asm.RequestHandlerImplementer) ControllerProxy(com.tvd12.ezyhttp.server.core.reflect.ControllerProxy) EzyMethod(com.tvd12.ezyfox.reflect.EzyMethod) Test(org.testng.annotations.Test)

Example 5 with ControllerProxy

use of com.tvd12.ezyhttp.server.core.reflect.ControllerProxy in project ezyhttp by youngmonkeys.

the class ControllerProxyTest method test.

@Test
public void test() {
    ControllerProxy home = new ControllerProxy(new HomeController());
    System.out.println(home);
}
Also used : HomeController(com.tvd12.ezyhttp.server.boot.test.controller.HomeController) ControllerProxy(com.tvd12.ezyhttp.server.core.reflect.ControllerProxy) BaseTest(com.tvd12.test.base.BaseTest) Test(org.testng.annotations.Test)

Aggregations

ControllerProxy (com.tvd12.ezyhttp.server.core.reflect.ControllerProxy)10 Test (org.testng.annotations.Test)10 BaseTest (com.tvd12.test.base.BaseTest)8 RequestHandlerMethod (com.tvd12.ezyhttp.server.core.reflect.RequestHandlerMethod)5 RequestHandlerImplementer (com.tvd12.ezyhttp.server.core.asm.RequestHandlerImplementer)4 HomeController (com.tvd12.ezyhttp.server.boot.test.controller.HomeController)2 HomeController (com.tvd12.ezyhttp.server.core.test.controller.HomeController)2 HomeController (com.tvd12.ezyhttp.server.jetty.test.controller.HomeController)2 EzyMethod (com.tvd12.ezyfox.reflect.EzyMethod)1 EzyLoggable (com.tvd12.ezyfox.util.EzyLoggable)1 EzyRequestControllerProxy (com.tvd12.ezyfoxserver.support.reflect.EzyRequestControllerProxy)1 HelloController (com.tvd12.ezyfoxserver.support.test.controller.HelloController)1 HttpMethod (com.tvd12.ezyhttp.core.constant.HttpMethod)1 RequestHandler (com.tvd12.ezyhttp.server.core.handler.RequestHandler)1 RequestURIDecorator (com.tvd12.ezyhttp.server.core.handler.RequestURIDecorator)1 ExceptionHandlerMethod (com.tvd12.ezyhttp.server.core.reflect.ExceptionHandlerMethod)1 RequestURI (com.tvd12.ezyhttp.server.core.request.RequestURI)1 RequestURIMeta (com.tvd12.ezyhttp.server.core.request.RequestURIMeta)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1