クラス MockMvcWebConnection

java.lang.ObjectSE
org.springframework.test.web.servlet.htmlunit.MockMvcWebConnection
実装されているすべてのインターフェース:
AutoCloseableSE, org.htmlunit.WebConnection

public final class MockMvcWebConnection extends ObjectSE implements org.htmlunit.WebConnection
MockMvcWebConnection を使用すると、MockMvc は WebRequest を WebResponse に変換できます。

これは HtmlUnit とのコア統合です。

使用例を以下に示します。

WebClient webClient = new WebClient();
MockMvc mockMvc = ...
MockMvcWebConnection webConnection = new MockMvcWebConnection(mockMvc, webClient);
webClient.setWebConnection(webConnection);

// Use webClient as normal ...
導入:
4.2
作成者:
Rob Winch, Sam Brannen
関連事項:
  • コンストラクターの詳細

    • MockMvcWebConnection

      public MockMvcWebConnection(MockMvc mockMvc, org.htmlunit.WebClient webClient)
      アプリケーションのコンテキストパスが "" (ルートコンテキスト)であることを前提とする新しいインスタンスを作成します。

      例: URL http://localhost/test/this は、コンテキストパスとして "" を使用します。

      パラメーター:
      mockMvc - 使用する MockMvc インスタンス。null
      webClient - 使用する WebClient  null
    • MockMvcWebConnection

      public MockMvcWebConnection(MockMvc mockMvc, org.htmlunit.WebClient webClient, @Nullable StringSE contextPath)
      指定されたコンテキストパスで新しいインスタンスを作成します。

      パスは null 形式にすることができます。その場合、URL の最初のパスセグメントは contextPath 形式に変換されます。それ以外の場合は、HttpServletRequest.getContextPath() 形式に準拠する必要があります。HttpServletRequest.getContextPath() 形式は、パスが空文字列であっても構わないことを規定しており、パスが "/" 文字で始まり、"/" 文字で終わってはならないことを規定しています。

      パラメーター:
      mockMvc - 使用する MockMvc インスタンス (非 null)
      webClient - 使用する WebClient (非 null)
      contextPath - 使用する contextPath
  • メソッドの詳細

    • setWebClient

      public void setWebClient(org.htmlunit.WebClient webClient)
    • getResponse

      public org.htmlunit.WebResponse getResponse(org.htmlunit.WebRequest webRequest) throws IOExceptionSE
      次で指定:
      インターフェース org.htmlunit.WebConnectiongetResponse 
      例外:
      IOExceptionSE
    • close

      public void close()
      次で指定:
      インターフェース AutoCloseableSEclose 
      次で指定:
      インターフェース org.htmlunit.WebConnectionclose