當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。