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


Java HandlerCollection.getHandlers方法代码示例

本文整理汇总了Java中org.eclipse.jetty.server.handler.HandlerCollection.getHandlers方法的典型用法代码示例。如果您正苦于以下问题:Java HandlerCollection.getHandlers方法的具体用法?Java HandlerCollection.getHandlers怎么用?Java HandlerCollection.getHandlers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jetty.server.handler.HandlerCollection的用法示例。


在下文中一共展示了HandlerCollection.getHandlers方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: shouldAddDefaultHeadersForRootContext

import org.eclipse.jetty.server.handler.HandlerCollection; //导入方法依赖的package包/类
@Test
public void shouldAddDefaultHeadersForRootContext() throws Exception {
    ArgumentCaptor<HandlerCollection> captor = ArgumentCaptor.forClass(HandlerCollection.class);
    jetty9Server.configure();

    verify(server, times(1)).setHandler(captor.capture());
    HandlerCollection handlerCollection = captor.getValue();
    Jetty9Server.GoServerWelcomeFileHandler handler = (Jetty9Server.GoServerWelcomeFileHandler)handlerCollection.getHandlers()[0];
    Handler rootPathHandler = handler.getHandler();

    HttpServletResponse response = mock(HttpServletResponse.class);
    when(response.getWriter()).thenReturn(mock(PrintWriter.class));

    HttpServletRequest request = mock(HttpServletRequest.class);
    when(request.getPathInfo()).thenReturn("/");

    rootPathHandler.handle("/", mock(Request.class), request, response);

    verify(response).setHeader("X-XSS-Protection", "1; mode=block");
    verify(response).setHeader("X-Content-Type-Options", "nosniff");
    verify(response).setHeader("X-Frame-Options", "SAMEORIGIN");
    verify(response).setHeader("X-UA-Compatible", "chrome=1");
}
 
开发者ID:gocd,项目名称:gocd,代码行数:24,代码来源:Jetty9ServerTest.java

示例2: shouldSkipDefaultHeadersIfContextPathIsGoRootPath

import org.eclipse.jetty.server.handler.HandlerCollection; //导入方法依赖的package包/类
@Test
public void shouldSkipDefaultHeadersIfContextPathIsGoRootPath() throws Exception {
    ArgumentCaptor<HandlerCollection> captor = ArgumentCaptor.forClass(HandlerCollection.class);
    jetty9Server.configure();

    verify(server, times(1)).setHandler(captor.capture());
    HandlerCollection handlerCollection = captor.getValue();
    Jetty9Server.GoServerWelcomeFileHandler handler = (Jetty9Server.GoServerWelcomeFileHandler)handlerCollection.getHandlers()[0];
    Handler rootPathHandler = handler.getHandler();

    HttpServletResponse response = mock(HttpServletResponse.class);
    when(response.getWriter()).thenReturn(mock(PrintWriter.class));

    HttpServletRequest request = mock(HttpServletRequest.class);
    when(request.getPathInfo()).thenReturn("/go");

    rootPathHandler.handle("/go", mock(Request.class), request, response);

    verify(response, never()).setHeader("X-XSS-Protection", "1; mode=block");
    verify(response, never()).setHeader("X-Content-Type-Options", "nosniff");
    verify(response, never()).setHeader("X-Frame-Options", "SAMEORIGIN");
    verify(response, never()).setHeader("X-UA-Compatible", "chrome=1");
}
 
开发者ID:gocd,项目名称:gocd,代码行数:24,代码来源:Jetty9ServerTest.java

示例3: shouldSkipDefaultHeadersIfContextPathIsAnyOtherUrlWithinGo

import org.eclipse.jetty.server.handler.HandlerCollection; //导入方法依赖的package包/类
@Test
public void shouldSkipDefaultHeadersIfContextPathIsAnyOtherUrlWithinGo() throws Exception {
    ArgumentCaptor<HandlerCollection> captor = ArgumentCaptor.forClass(HandlerCollection.class);
    jetty9Server.configure();

    verify(server, times(1)).setHandler(captor.capture());
    HandlerCollection handlerCollection = captor.getValue();
    Jetty9Server.GoServerWelcomeFileHandler handler = (Jetty9Server.GoServerWelcomeFileHandler)handlerCollection.getHandlers()[0];
    Handler rootPathHandler = handler.getHandler();

    HttpServletResponse response = mock(HttpServletResponse.class);
    when(response.getWriter()).thenReturn(mock(PrintWriter.class));

    HttpServletRequest request = mock(HttpServletRequest.class);
    when(request.getPathInfo()).thenReturn("/go/pipelines");

    rootPathHandler.handle("/go/pipelines", mock(Request.class), request, response);

    verify(response, never()).setHeader("X-XSS-Protection", "1; mode=block");
    verify(response, never()).setHeader("X-Content-Type-Options", "nosniff");
    verify(response, never()).setHeader("X-Frame-Options", "SAMEORIGIN");
    verify(response, never()).setHeader("X-UA-Compatible", "chrome=1");
}
 
开发者ID:gocd,项目名称:gocd,代码行数:24,代码来源:Jetty9ServerTest.java

示例4: shouldAddWebAppContextHandler

import org.eclipse.jetty.server.handler.HandlerCollection; //导入方法依赖的package包/类
@Test
public void shouldAddWebAppContextHandler() throws Exception {
    ArgumentCaptor<HandlerCollection> captor = ArgumentCaptor.forClass(HandlerCollection.class);
    jetty9Server.configure();

    verify(server, times(1)).setHandler(captor.capture());
    HandlerCollection handlerCollection = captor.getValue();
    assertThat(handlerCollection.getHandlers().length, is(3));

    Handler handler = handlerCollection.getHandlers()[2];
    assertThat(handler instanceof WebAppContext, is(true));
    WebAppContext webAppContext = (WebAppContext) handler;
    List<String> configClasses = new ArrayList<>(Arrays.asList(webAppContext.getConfigurationClasses()));
    assertThat(configClasses.contains(WebInfConfiguration.class.getCanonicalName()), is(true));
    assertThat(configClasses.contains(WebXmlConfiguration.class.getCanonicalName()), is(true));
    assertThat(configClasses.contains(JettyWebXmlConfiguration.class.getCanonicalName()), is(true));
    assertThat(webAppContext.getContextPath(), is("context"));
    assertThat(webAppContext.getWar(), is("cruise.war"));
    assertThat(webAppContext.isParentLoaderPriority(), is(true));
    assertThat(webAppContext.getDefaultsDescriptor(), is("jar:file:cruise.war!/WEB-INF/webdefault.xml"));
}
 
开发者ID:gocd,项目名称:gocd,代码行数:22,代码来源:Jetty9ServerTest.java

示例5: shouldAddWelcomeRequestHandler

import org.eclipse.jetty.server.handler.HandlerCollection; //导入方法依赖的package包/类
@Test
public void shouldAddWelcomeRequestHandler() throws Exception {
    ArgumentCaptor<HandlerCollection> captor = ArgumentCaptor.forClass(HandlerCollection.class);
    jetty9Server.configure();

    verify(server, times(1)).setHandler(captor.capture());
    HandlerCollection handlerCollection = captor.getValue();
    assertThat(handlerCollection.getHandlers().length, is(3));
    Handler handler = handlerCollection.getHandlers()[0];
    assertThat(handler instanceof Jetty9Server.GoServerWelcomeFileHandler, is(true));

    Jetty9Server.GoServerWelcomeFileHandler welcomeFileHandler = (Jetty9Server.GoServerWelcomeFileHandler) handler;
    assertThat(welcomeFileHandler.getContextPath(), is("/"));
}
 
开发者ID:gocd,项目名称:gocd,代码行数:15,代码来源:Jetty9ServerTest.java

示例6: shouldAddResourceHandlerForAssets

import org.eclipse.jetty.server.handler.HandlerCollection; //导入方法依赖的package包/类
@Test
public void shouldAddResourceHandlerForAssets() throws Exception {
    ArgumentCaptor<HandlerCollection> captor = ArgumentCaptor.forClass(HandlerCollection.class);
    jetty9Server.configure();

    verify(server, times(1)).setHandler(captor.capture());
    HandlerCollection handlerCollection = captor.getValue();
    assertThat(handlerCollection.getHandlers().length, is(3));

    Handler handler = handlerCollection.getHandlers()[1];
    assertThat(handler instanceof AssetsContextHandler, is(true));
    AssetsContextHandler assetsContextHandler = (AssetsContextHandler) handler;
    assertThat(assetsContextHandler.getContextPath(), is("context/assets"));
}
 
开发者ID:gocd,项目名称:gocd,代码行数:15,代码来源:Jetty9ServerTest.java

示例7: shouldSetErrorHandlerForWebAppContext

import org.eclipse.jetty.server.handler.HandlerCollection; //导入方法依赖的package包/类
@Test
public void shouldSetErrorHandlerForWebAppContext() throws Exception {
    ArgumentCaptor<HandlerCollection> captor = ArgumentCaptor.forClass(HandlerCollection.class);
    jetty9Server.configure();

    verify(server, times(1)).setHandler(captor.capture());
    HandlerCollection handlerCollection = captor.getValue();
    assertThat(handlerCollection.getHandlers().length, is(3));

    Handler handler = handlerCollection.getHandlers()[2];
    assertThat(handler instanceof WebAppContext, is(true));
    WebAppContext webAppContext = (WebAppContext) handler;

    assertThat(webAppContext.getErrorHandler() instanceof JettyCustomErrorPageHandler, is(true));
}
 
开发者ID:gocd,项目名称:gocd,代码行数:16,代码来源:Jetty9ServerTest.java


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