当前位置: 首页>>代码示例>>Java>>正文


Java RiposteErrorHandler类代码示例

本文整理汇总了Java中com.nike.riposte.server.error.handler.RiposteErrorHandler的典型用法代码示例。如果您正苦于以下问题:Java RiposteErrorHandler类的具体用法?Java RiposteErrorHandler怎么用?Java RiposteErrorHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RiposteErrorHandler类属于com.nike.riposte.server.error.handler包,在下文中一共展示了RiposteErrorHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: constructor_gracefully_handles_some_null_args

import com.nike.riposte.server.error.handler.RiposteErrorHandler; //导入依赖的package包/类
@Test
public void constructor_gracefully_handles_some_null_args() {
    // when
    HttpChannelInitializer hci = new HttpChannelInitializer(
        null, 42, Arrays.asList(getMockEndpoint("/some/path")), null, null, mock(RiposteErrorHandler.class), mock(RiposteUnhandledErrorHandler.class),
        null, null, mock(ResponseSender.class), null, 4242L, null,
        null, null, 121, 42, 321, 100, false, null);

    // then
    assertThat(extractField(hci, "sslCtx"), nullValue());
    Executor longRunningTaskExecutor = extractField(hci, "longRunningTaskExecutor");
    assertThat(longRunningTaskExecutor, notNullValue());
    assertThat(longRunningTaskExecutor, instanceOf(ThreadPoolExecutor.class));
    assertThat(((ThreadPoolExecutor)longRunningTaskExecutor).getMaximumPoolSize(), is(Integer.MAX_VALUE));
    assertThat(((ThreadPoolExecutor)longRunningTaskExecutor).getKeepAliveTime(TimeUnit.SECONDS), is(60L));
    assertThat(extractField(hci, "validationService"), nullValue());
    assertThat(extractField(hci, "requestContentDeserializer"), nullValue());
    assertThat(extractField(hci, "metricsListener"), nullValue());
    assertThat(extractField(hci, "accessLogger"), nullValue());
    assertThat(extractField(hci, "beforeSecurityRequestFilterHandler"), nullValue());
    assertThat(extractField(hci, "afterSecurityRequestFilterHandler"), nullValue());
    assertThat(extractField(hci, "cachedResponseFilterHandler"), nullValue());
    assertThat(extractField(hci, "userIdHeaderKeys"), nullValue());
}
 
开发者ID:Nike-Inc,项目名称:riposte,代码行数:25,代码来源:HttpChannelInitializerTest.java

示例2: constructor_handles_empty_after_security_request_handlers

import com.nike.riposte.server.error.handler.RiposteErrorHandler; //导入依赖的package包/类
@Test
public void constructor_handles_empty_after_security_request_handlers() {
    // given
    RequestAndResponseFilter beforeSecurityRequestFilter = mock(RequestAndResponseFilter.class);
    doReturn(true).when(beforeSecurityRequestFilter).shouldExecuteBeforeSecurityValidation();
    List<RequestAndResponseFilter> reqResFilters = Arrays.asList(beforeSecurityRequestFilter);

    // when
    HttpChannelInitializer hci = new HttpChannelInitializer(
            null, 42, Arrays.asList(getMockEndpoint("/some/path")), reqResFilters, null, mock(RiposteErrorHandler.class), mock(RiposteUnhandledErrorHandler.class),
            null, null, mock(ResponseSender.class), null, 4242L, null,
            null, null, 121, 42, 321, 100, false, null);

    // then
    RequestFilterHandler beforeSecReqFH = extractField(hci, "beforeSecurityRequestFilterHandler");
    assertThat(extractField(beforeSecReqFH, "filters"), is(Collections.singletonList(beforeSecurityRequestFilter)));

    assertThat(extractField(hci, "afterSecurityRequestFilterHandler"), nullValue());

    ResponseFilterHandler responseFilterHandler = extractField(hci, "cachedResponseFilterHandler");
    assertThat(extractField(responseFilterHandler, "filtersInResponseProcessingOrder"), is(reqResFilters));
}
 
开发者ID:Nike-Inc,项目名称:riposte,代码行数:23,代码来源:HttpChannelInitializerTest.java

示例3: constructor_handles_empty_before_security_request_handlers

import com.nike.riposte.server.error.handler.RiposteErrorHandler; //导入依赖的package包/类
@Test
public void constructor_handles_empty_before_security_request_handlers() {
    // given
    RequestAndResponseFilter afterSecurityRequestFilter = mock(RequestAndResponseFilter.class);
    doReturn(false).when(afterSecurityRequestFilter).shouldExecuteBeforeSecurityValidation();
    List<RequestAndResponseFilter> reqResFilters = Arrays.asList(afterSecurityRequestFilter);

    // when
    HttpChannelInitializer hci = new HttpChannelInitializer(
            null, 42, Arrays.asList(getMockEndpoint("/some/path")), reqResFilters, null, mock(RiposteErrorHandler.class), mock(RiposteUnhandledErrorHandler.class),
            null, null, mock(ResponseSender.class), null, 4242L, null,
            null, null, 121, 42, 321, 100, false, null);

    // then
    RequestFilterHandler beforeSecReqFH = extractField(hci, "afterSecurityRequestFilterHandler");
    assertThat(extractField(beforeSecReqFH, "filters"), is(Collections.singletonList(afterSecurityRequestFilter)));

    assertThat(extractField(hci, "beforeSecurityRequestFilterHandler"), nullValue());

    ResponseFilterHandler responseFilterHandler = extractField(hci, "cachedResponseFilterHandler");
    assertThat(extractField(responseFilterHandler, "filtersInResponseProcessingOrder"), is(reqResFilters));
}
 
开发者ID:Nike-Inc,项目名称:riposte,代码行数:23,代码来源:HttpChannelInitializerTest.java

示例4: riposteErrorHandler

import com.nike.riposte.server.error.handler.RiposteErrorHandler; //导入依赖的package包/类
/**
 * @return The error handler that should be used for this application for handling known errors. For things that
 * fall through the cracks they will be handled by {@link #riposteUnhandledErrorHandler()}.
 *
 * <p>NOTE: The default implementation returned if you don't override this method is a very basic Backstopper impl -
 * it will not know about your application's {@link ProjectApiErrors} and will instead create a dummy {@link
 * ProjectApiErrors} that only supports the {@link com.nike.backstopper.apierror.sample.SampleCoreApiError} values.
 * This method should be overridden for most real applications to return a real implementation tailored for your
 * app. In practice this usually means copy/pasting this method and simply supplying the correct {@link
 * ProjectApiErrors} for the app. The rest is usually fine for defaults.
 */
default RiposteErrorHandler riposteErrorHandler() {
    ProjectApiErrors projectApiErrors = new SampleProjectApiErrorsBase() {
        @Override
        protected List<ApiError> getProjectSpecificApiErrors() {
            return null;
        }

        @Override
        protected ProjectSpecificErrorCodeRange getProjectSpecificErrorCodeRange() {
            return null;
        }
    };
    return BackstopperRiposteConfigHelper
        .defaultErrorHandler(projectApiErrors, ApiExceptionHandlerUtils.DEFAULT_IMPL);
}
 
开发者ID:Nike-Inc,项目名称:riposte,代码行数:27,代码来源:ServerConfig.java

示例5: GuiceProvidedServerConfigValues

import com.nike.riposte.server.error.handler.RiposteErrorHandler; //导入依赖的package包/类
@Inject
public GuiceProvidedServerConfigValues(@Named("endpoints.port") Integer endpointsPort,
                                       @Named("endpoints.sslPort") Integer endpointsSslPort,
                                       @Named("endpoints.useSsl") Boolean endpointsUseSsl,
                                       @Named("netty.bossThreadCount") Integer numBossThreads,
                                       @Named("netty.workerThreadCount") Integer numWorkerThreads,
                                       @Named("netty.maxRequestSizeInBytes") Integer maxRequestSizeInBytes,
                                       @Named("appEndpoints") Set<Endpoint<?>> appEndpoints,
                                       @Named("debugActionsEnabled") Boolean debugActionsEnabled,
                                       @Named("debugChannelLifecycleLoggingEnabled") Boolean debugChannelLifecycleLoggingEnabled,
                                       RiposteErrorHandler riposteErrorHandler,
                                       RiposteUnhandledErrorHandler riposteUnhandledErrorHandler,
                                       RequestValidator validationService,
                                       @Nullable CodahaleMetricsListener metricsListener,
                                       @Named("appInfoFuture") CompletableFuture<AppInfo> appInfoFuture,
                                       CmsRequestSecurityValidator cmsRequestSecurityValidator,
                                       HystrixRequestAndResponseFilter hystrixRequestAndResponseFilter
) {
    super(endpointsPort, endpointsSslPort, endpointsUseSsl, numBossThreads, numWorkerThreads, maxRequestSizeInBytes, appEndpoints,
          debugActionsEnabled, debugChannelLifecycleLoggingEnabled);

    this.riposteErrorHandler = riposteErrorHandler;
    this.riposteUnhandledErrorHandler = riposteUnhandledErrorHandler;
    this.validationService = validationService;
    this.metricsListener = metricsListener;
    this.appInfoFuture = appInfoFuture;
    this.cmsRequestSecurityValidator = cmsRequestSecurityValidator;
    this.requestAndResponseFilters = Lists.newArrayList(hystrixRequestAndResponseFilter);
}
 
开发者ID:Nike-Inc,项目名称:cerberus-management-service,代码行数:30,代码来源:GuiceProvidedServerConfigValues.java

示例6: ExceptionHandlingHandler

import com.nike.riposte.server.error.handler.RiposteErrorHandler; //导入依赖的package包/类
public ExceptionHandlingHandler(RiposteErrorHandler riposteErrorHandler,
                                RiposteUnhandledErrorHandler riposteUnhandledErrorHandler) {
    if (riposteErrorHandler == null)
        throw new IllegalArgumentException("riposteErrorHandler cannot be null");

    if (riposteUnhandledErrorHandler == null)
        throw new IllegalArgumentException("riposteUnhandledErrorHandler cannot be null");

    this.riposteErrorHandler = riposteErrorHandler;
    this.riposteUnhandledErrorHandler = riposteUnhandledErrorHandler;
}
 
开发者ID:Nike-Inc,项目名称:riposte,代码行数:12,代码来源:ExceptionHandlingHandler.java

示例7: beforeMethod

import com.nike.riposte.server.error.handler.RiposteErrorHandler; //导入依赖的package包/类
@Before
public void beforeMethod() {
    riposteErrorHandlerMock = mock(RiposteErrorHandler.class);
    riposteUnhandledErrorHandlerMock = mock(RiposteUnhandledErrorHandler.class);
    handler = new ExceptionHandlingHandler(riposteErrorHandlerMock, riposteUnhandledErrorHandlerMock);
    channelMock = mock(Channel.class);
    ctxMock = mock(ChannelHandlerContext.class);
    stateAttributeMock = mock(Attribute.class);
    state = new HttpProcessingState();
    doReturn(channelMock).when(ctxMock).channel();
    doReturn(stateAttributeMock).when(channelMock).attr(ChannelAttributes.HTTP_PROCESSING_STATE_ATTRIBUTE_KEY);
    doReturn(state).when(stateAttributeMock).get();
}
 
开发者ID:Nike-Inc,项目名称:riposte,代码行数:14,代码来源:ExceptionHandlingHandlerTest.java

示例8: constructor_works_with_valid_args

import com.nike.riposte.server.error.handler.RiposteErrorHandler; //导入依赖的package包/类
@Test
public void constructor_works_with_valid_args() {
    // given
    ExceptionHandlingHandler handler = new ExceptionHandlingHandler(mock(RiposteErrorHandler.class), mock(RiposteUnhandledErrorHandler.class));

    // expect
    assertThat(handler, notNullValue());
}
 
开发者ID:Nike-Inc,项目名称:riposte,代码行数:9,代码来源:ExceptionHandlingHandlerTest.java

示例9: mock

import com.nike.riposte.server.error.handler.RiposteErrorHandler; //导入依赖的package包/类
@Test
public void processError_gets_requestInfo_then_calls_riposteErrorHandler_then_converts_to_response_using_setupResponseInfoBasedOnErrorResponseInfo() throws UnexpectedMajorErrorHandlingError, JsonProcessingException {
    // given
    HttpProcessingState stateMock = mock(HttpProcessingState.class);
    Object msg = new Object();
    Throwable cause = new Exception();

    ExceptionHandlingHandler handlerSpy = spy(handler);
    RequestInfo<?> requestInfoMock = mock(RequestInfo.class);
    ErrorResponseInfo errorResponseInfoMock = mock(ErrorResponseInfo.class);

    RiposteErrorHandler riposteErrorHandlerMock = mock(RiposteErrorHandler.class);
    Whitebox.setInternalState(handlerSpy, "riposteErrorHandler", riposteErrorHandlerMock);

    doReturn(requestInfoMock).when(handlerSpy).getRequestInfo(stateMock, msg);
    doReturn(errorResponseInfoMock).when(riposteErrorHandlerMock).maybeHandleError(cause, requestInfoMock);

    // when
    ResponseInfo<ErrorResponseBody> response = handlerSpy.processError(stateMock, msg, cause);

    // then
    verify(handlerSpy).getRequestInfo(stateMock, msg);
    verify(riposteErrorHandlerMock).maybeHandleError(cause, requestInfoMock);
    ArgumentCaptor<ResponseInfo> responseInfoArgumentCaptor = ArgumentCaptor.forClass(ResponseInfo.class);
    verify(handlerSpy).setupResponseInfoBasedOnErrorResponseInfo(responseInfoArgumentCaptor.capture(), eq(errorResponseInfoMock));
    ResponseInfo<ErrorResponseBody> responseInfoPassedIntoSetupMethod = responseInfoArgumentCaptor.getValue();
    assertThat(response, is(responseInfoPassedIntoSetupMethod));
}
 
开发者ID:Nike-Inc,项目名称:riposte,代码行数:29,代码来源:ExceptionHandlingHandlerTest.java

示例10: constructor_throws_IllegalArgumentException_if_endpoints_is_null

import com.nike.riposte.server.error.handler.RiposteErrorHandler; //导入依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void constructor_throws_IllegalArgumentException_if_endpoints_is_null() {
    // expect
    new HttpChannelInitializer(
        null, 42, null, null, null, mock(RiposteErrorHandler.class), mock(RiposteUnhandledErrorHandler.class),
        null, null, mock(ResponseSender.class), null, 4242L, null,
        null, null, 121, 42, 321, 100, false, null);
}
 
开发者ID:Nike-Inc,项目名称:riposte,代码行数:9,代码来源:HttpChannelInitializerTest.java

示例11: constructor_throws_IllegalArgumentException_if_endpoints_is_empty

import com.nike.riposte.server.error.handler.RiposteErrorHandler; //导入依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void constructor_throws_IllegalArgumentException_if_endpoints_is_empty() {
    // expect
    new HttpChannelInitializer(
        null, 42, Collections.emptyList(), null, null, mock(RiposteErrorHandler.class), mock(RiposteUnhandledErrorHandler.class),
        null, null, mock(ResponseSender.class), null, 4242L, null,
        null, null, 121, 42, 321, 100, false, null);
}
 
开发者ID:Nike-Inc,项目名称:riposte,代码行数:9,代码来源:HttpChannelInitializerTest.java

示例12: constructor_throws_IllegalArgumentException_if_riposteUnhandledErrorHandler_is_null

import com.nike.riposte.server.error.handler.RiposteErrorHandler; //导入依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void constructor_throws_IllegalArgumentException_if_riposteUnhandledErrorHandler_is_null() {
    // expect
    new HttpChannelInitializer(
        null, 42, Arrays.asList(getMockEndpoint("/some/path")), null, null, mock(RiposteErrorHandler.class), null,
        null, null, mock(ResponseSender.class), null, 4242L, null,
        null, null, 121, 42, 321, 100, false, null);
}
 
开发者ID:Nike-Inc,项目名称:riposte,代码行数:9,代码来源:HttpChannelInitializerTest.java

示例13: constructor_throws_IllegalArgumentException_if_responseSender_is_null

import com.nike.riposte.server.error.handler.RiposteErrorHandler; //导入依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void constructor_throws_IllegalArgumentException_if_responseSender_is_null() {
    // expect
    new HttpChannelInitializer(
        null, 42, Arrays.asList(getMockEndpoint("/some/path")), null, null, mock(RiposteErrorHandler.class), mock(RiposteUnhandledErrorHandler.class),
        null, null, null, null, 4242L, null,
        null, null, 121, 42, 321, 100, false, null);
}
 
开发者ID:Nike-Inc,项目名称:riposte,代码行数:9,代码来源:HttpChannelInitializerTest.java

示例14: basicHttpChannelInitializer

import com.nike.riposte.server.error.handler.RiposteErrorHandler; //导入依赖的package包/类
private HttpChannelInitializer basicHttpChannelInitializer(SslContext sslCtx, long workerChannelIdleTimeoutMillis, int maxOpenChannelsThreshold,
                                                           boolean debugChannelLifecycleLoggingEnabled, RequestValidator validationService,
                                                           List<RequestAndResponseFilter> requestAndResponseFilters) {
    return new HttpChannelInitializer(
        sslCtx, 42, Arrays.asList(getMockEndpoint("/some/path")), requestAndResponseFilters, null, mock(RiposteErrorHandler.class),
        mock(RiposteUnhandledErrorHandler.class), validationService, null, mock(ResponseSender.class), null, 4242L, null,
        null, null, workerChannelIdleTimeoutMillis, 4200, 1234, maxOpenChannelsThreshold, debugChannelLifecycleLoggingEnabled,
        null);
}
 
开发者ID:Nike-Inc,项目名称:riposte,代码行数:10,代码来源:HttpChannelInitializerTest.java

示例15: basicHttpChannelInitializerNoUtilityHandlers

import com.nike.riposte.server.error.handler.RiposteErrorHandler; //导入依赖的package包/类
@Test
public void initChannel_adds_ExceptionHandlingHandler_immediately_before_ResponseSenderHandler_and_after_NonblockingEndpointExecutionHandler_and_uses_riposteErrorHandler_and_riposteUnhandledErrorHandler() {
    // given
    HttpChannelInitializer hci = basicHttpChannelInitializerNoUtilityHandlers();
    RiposteErrorHandler expectedRiposteErrorHandler = extractField(hci, "riposteErrorHandler");
    RiposteUnhandledErrorHandler
        expectedRiposteUnhandledErrorHandler = extractField(hci, "riposteUnhandledErrorHandler");

    // when
    hci.initChannel(socketChannelMock);

    // then
    ArgumentCaptor<ChannelHandler> channelHandlerArgumentCaptor = ArgumentCaptor.forClass(ChannelHandler.class);
    verify(channelPipelineMock, atLeastOnce()).addLast(anyString(), channelHandlerArgumentCaptor.capture());
    List<ChannelHandler> handlers = channelHandlerArgumentCaptor.getAllValues();
    Pair<Integer, ResponseSenderHandler> responseSenderHandler = findChannelHandler(handlers, ResponseSenderHandler.class);
    Pair<Integer, NonblockingEndpointExecutionHandler> nonblockingEndpointExecutionHandler = findChannelHandler(handlers, NonblockingEndpointExecutionHandler.class);
    Pair<Integer, ExceptionHandlingHandler> exceptionHandlingHandler = findChannelHandler(handlers, ExceptionHandlingHandler.class);

    assertThat(responseSenderHandler, notNullValue());
    assertThat(nonblockingEndpointExecutionHandler, notNullValue());
    assertThat(exceptionHandlingHandler, notNullValue());

    assertThat(exceptionHandlingHandler.getLeft(), is(responseSenderHandler.getLeft() - 1));
    assertThat(exceptionHandlingHandler.getLeft(), is(greaterThan(nonblockingEndpointExecutionHandler.getLeft())));

    // and then
    RiposteErrorHandler
        actualRiposteErrorHandler = (RiposteErrorHandler) Whitebox.getInternalState(exceptionHandlingHandler.getRight(), "riposteErrorHandler");
    RiposteUnhandledErrorHandler
        actualRiposteUnhandledErrorHandler = (RiposteUnhandledErrorHandler) Whitebox.getInternalState(exceptionHandlingHandler.getRight(), "riposteUnhandledErrorHandler");
    assertThat(actualRiposteErrorHandler, is(expectedRiposteErrorHandler));
    assertThat(actualRiposteUnhandledErrorHandler, is(expectedRiposteUnhandledErrorHandler));
}
 
开发者ID:Nike-Inc,项目名称:riposte,代码行数:35,代码来源:HttpChannelInitializerTest.java


注:本文中的com.nike.riposte.server.error.handler.RiposteErrorHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。