org.springframework.mock.web

## Class MockPart

- java.lang.Object
- - org.springframework.mock.web.MockPart

- All Implemented Interfaces:
    Part

      public class MockPart
      extends Object
      implements Part

  Mock implementation of `javax.servlet.http.Part`.
  Since:
    4.3.12
  Author:
    Rossen Stoyanchev, Juergen Hoeller
  See Also:
    `MockHttpServletRequest.addPart(javax.servlet.http.Part)`, `MockMultipartFile`

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `MockPart(String name, byte[] content)` Constructor for a part with byte[] content only.
    `MockPart(String name, String filename, byte[] content)` Constructor for a part with a filename and byte[] content.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `delete()`
    `String` | `getContentType()`
    `String` | `getHeader(String name)`
    `Collection<String>` | `getHeaderNames()`
    `HttpHeaders` | `getHeaders()` Return the `HttpHeaders` backing header related accessor methods, allowing for populating selected header entries.
    `Collection<String>` | `getHeaders(String name)`
    `InputStream` | `getInputStream()`
    `String` | `getName()`
    `long` | `getSize()`
    `String` | `getSubmittedFileName()`
    `void` | `write(String fileName)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### MockPart

          public MockPart(String name,
                          @Nullable
                          byte[] content)

      Constructor for a part with byte[] content only.
      See Also:
        `getHeaders()`

    - #### MockPart

          public MockPart(String name,
                          @Nullable
                          String filename,
                          @Nullable
                          byte[] content)

      Constructor for a part with a filename and byte[] content.
      See Also:
        `getHeaders()`

  - ### Method Detail

    - #### getName

          public String getName()

      Specified by:
        `getName` in interface `Part`

    - #### getSubmittedFileName

          @Nullable
          public String getSubmittedFileName()

      Specified by:
        `getSubmittedFileName` in interface `Part`

    - #### getContentType

          @Nullable
          public String getContentType()

      Specified by:
        `getContentType` in interface `Part`

    - #### getSize

          public long getSize()

      Specified by:
        `getSize` in interface `Part`

    - #### getInputStream

          public InputStream getInputStream()
                                     throws IOException

      Specified by:
        `getInputStream` in interface `Part`
      Throws:
        `IOException`

    - #### write

          public void write(String fileName)
                     throws IOException

      Specified by:
        `write` in interface `Part`
      Throws:
        `IOException`

    - #### delete

          public void delete()
                      throws IOException

      Specified by:
        `delete` in interface `Part`
      Throws:
        `IOException`

    - #### getHeader

          @Nullable
          public String getHeader(String name)

      Specified by:
        `getHeader` in interface `Part`

    - #### getHeaders

          public Collection<String> getHeaders(String name)

      Specified by:
        `getHeaders` in interface `Part`

    - #### getHeaderNames

          public Collection<String> getHeaderNames()

      Specified by:
        `getHeaderNames` in interface `Part`

    - #### getHeaders

          public final HttpHeaders getHeaders()

      Return the `HttpHeaders` backing header related accessor methods, allowing for populating selected header entries.