Search in sources :

Example 6 with ExceptionHandlerMethod

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

the class ExceptionHandlerImplementerTest method test.

@Test
public void test() {
    ExceptionHandlerImplementer.setDebug(true);
    ExceptionHandlerProxy exceptionHandler = new ExceptionHandlerProxy(new GlobalExceptionHandler());
    for (ExceptionHandlerMethod method : exceptionHandler.getExceptionHandlerMethods()) {
        ExceptionHandlerImplementer implementer = new ExceptionHandlerImplementer(exceptionHandler, method);
        implementer.implement();
    }
}
Also used : GlobalExceptionHandler(com.tvd12.ezyhttp.server.jetty.test.controller.GlobalExceptionHandler) ExceptionHandlerImplementer(com.tvd12.ezyhttp.server.core.asm.ExceptionHandlerImplementer) ExceptionHandlerProxy(com.tvd12.ezyhttp.server.core.reflect.ExceptionHandlerProxy) ExceptionHandlerMethod(com.tvd12.ezyhttp.server.core.reflect.ExceptionHandlerMethod) BaseTest(com.tvd12.test.base.BaseTest) Test(org.testng.annotations.Test)

Example 7 with ExceptionHandlerMethod

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

the class ControllerProxyTest method test.

@Test
public void test() {
    // given
    HomeController homeController = new HomeController();
    ControllerProxy sut = new ControllerProxy(homeController);
    // when
    List<ExceptionHandlerMethod> exceptionHandlerMethods = sut.getExceptionHandlerMethods();
    // then
    Asserts.assertEquals(2, exceptionHandlerMethods.size());
    Asserts.assertFalse(sut.isPayment());
    Asserts.assertNull(sut.getFeature());
    System.out.println(sut);
}
Also used : HomeController(com.tvd12.ezyhttp.server.core.test.controller.HomeController) ControllerProxy(com.tvd12.ezyhttp.server.core.reflect.ControllerProxy) ExceptionHandlerMethod(com.tvd12.ezyhttp.server.core.reflect.ExceptionHandlerMethod) BaseTest(com.tvd12.test.base.BaseTest) Test(org.testng.annotations.Test)

Example 8 with ExceptionHandlerMethod

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

the class ExceptionHandlersImplementer method implement.

public Map<Class<?>, UncaughtExceptionHandler> implement(Object exceptionHandler) {
    Map<Class<?>, UncaughtExceptionHandler> handlers = new HashMap<>();
    ExceptionHandlerProxy proxy = new ExceptionHandlerProxy(exceptionHandler);
    for (ExceptionHandlerMethod method : proxy.getExceptionHandlerMethods()) {
        ExceptionHandlerImplementer implementer = newImplementer(proxy, method);
        UncaughtExceptionHandler handler = implementer.implement();
        for (Class<?> exceptionClass : method.getExceptionClasses()) {
            handlers.put(exceptionClass, handler);
        }
    }
    return handlers;
}
Also used : HashMap(java.util.HashMap) ExceptionHandlerProxy(com.tvd12.ezyhttp.server.core.reflect.ExceptionHandlerProxy) UncaughtExceptionHandler(com.tvd12.ezyhttp.server.core.handler.UncaughtExceptionHandler) ExceptionHandlerMethod(com.tvd12.ezyhttp.server.core.reflect.ExceptionHandlerMethod)

Example 9 with ExceptionHandlerMethod

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

the class ExceptionHandlerImplementerTest method test.

@Test
public void test() {
    ExceptionHandlerImplementer.setDebug(true);
    ExceptionHandlerProxy exceptionHandler = new ExceptionHandlerProxy(new GlobalExceptionHandler());
    for (ExceptionHandlerMethod method : exceptionHandler.getExceptionHandlerMethods()) {
        ExceptionHandlerImplementer implementer = new ExceptionHandlerImplementer(exceptionHandler, method);
        implementer.implement();
    }
}
Also used : GlobalExceptionHandler(com.tvd12.ezyhttp.server.boot.test.controller.GlobalExceptionHandler) ExceptionHandlerImplementer(com.tvd12.ezyhttp.server.core.asm.ExceptionHandlerImplementer) ExceptionHandlerProxy(com.tvd12.ezyhttp.server.core.reflect.ExceptionHandlerProxy) ExceptionHandlerMethod(com.tvd12.ezyhttp.server.core.reflect.ExceptionHandlerMethod) BaseTest(com.tvd12.test.base.BaseTest) Test(org.testng.annotations.Test)

Aggregations

ExceptionHandlerMethod (com.tvd12.ezyhttp.server.core.reflect.ExceptionHandlerMethod)7 ExceptionHandlerProxy (com.tvd12.ezyhttp.server.core.reflect.ExceptionHandlerProxy)5 Test (org.testng.annotations.Test)5 EzyMethod (com.tvd12.ezyfox.reflect.EzyMethod)4 ExceptionHandlerImplementer (com.tvd12.ezyhttp.server.core.asm.ExceptionHandlerImplementer)4 BaseTest (com.tvd12.test.base.BaseTest)4 TryCatch (com.tvd12.ezyhttp.server.core.annotation.TryCatch)2 ArrayList (java.util.ArrayList)2 EzyFunction (com.tvd12.ezyfox.asm.EzyFunction)1 EzyBody (com.tvd12.ezyfox.asm.EzyFunction.EzyBody)1 EzyInstruction (com.tvd12.ezyfox.asm.EzyInstruction)1 EzyClass (com.tvd12.ezyfox.reflect.EzyClass)1 EzyClassTree (com.tvd12.ezyfox.reflect.EzyClassTree)1 GlobalExceptionHandler (com.tvd12.ezyhttp.server.boot.test.controller.GlobalExceptionHandler)1 UncaughtExceptionHandler (com.tvd12.ezyhttp.server.core.handler.UncaughtExceptionHandler)1 ControllerProxy (com.tvd12.ezyhttp.server.core.reflect.ControllerProxy)1 GlobalExceptionHandler (com.tvd12.ezyhttp.server.core.test.controller.GlobalExceptionHandler)1 HomeController (com.tvd12.ezyhttp.server.core.test.controller.HomeController)1 GlobalExceptionHandler (com.tvd12.ezyhttp.server.jetty.test.controller.GlobalExceptionHandler)1 HashMap (java.util.HashMap)1