api_dev/src/main/java/com/google/appengine/tools/development/testing/FakeHttpServletRequest.java [552:789]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    throw new UnsupportedOperationException();
  }

  @Override
  public boolean authenticate(HttpServletResponse httpServletResponse)
      throws IOException, ServletException {
    throw new UnsupportedOperationException();
  }

  @Override
  public void login(String s, String s1) throws ServletException {
    throw new UnsupportedOperationException();
  }

  @Override
  public void logout() throws ServletException {
    throw new UnsupportedOperationException();
  }

  @Override
  public Collection<Part> getParts() throws IOException, ServletException {
    throw new UnsupportedOperationException();
  }

  @Override
  public Part getPart(String s) throws IOException, ServletException {
    throw new UnsupportedOperationException();
  }

  @Override
  public <T extends HttpUpgradeHandler> T upgrade(Class<T> aClass)
      throws IOException, ServletException {
    throw new UnsupportedOperationException();
  }

  @Override
  public boolean isRequestedSessionIdValid() {
    throw new UnsupportedOperationException();
  }

  @Override
  public boolean isUserInRole(String role) {
    throw new UnsupportedOperationException();
  }

  private static String paramsToString(ListMultimap<String, String> params) {
    try {
      StringBuilder sb = new StringBuilder();
      boolean first = true;
      for (Map.Entry<String, String> e : params.entries()) {
        if (!first) {
          sb.append('&');
        } else {
          first = false;
        }
        sb.append(URLEncoder.encode(e.getKey(), UTF_8.name()));
        if (!"".equals(e.getValue())) {
          sb.append('=').append(URLEncoder.encode(e.getValue(), UTF_8.name()));
        }
      }
      return sb.toString();
    } catch (UnsupportedEncodingException e) {
      throw new IllegalStateException(e);
    }
  }

  public void setParametersFromQueryString(String qs) {
    parameters.clear();
    if (qs != null) {
      for (String entry : Splitter.on('&').split(qs)) {
        List<String> kv = ImmutableList.copyOf(Splitter.on('=').limit(2).split(entry));
        try {
          parameters.put(
              URLDecoder.decode(kv.get(0), UTF_8.name()),
              kv.size() == 2 ? URLDecoder.decode(kv.get(1), UTF_8.name()) : "");
        } catch (UnsupportedEncodingException e) {
          throw new IllegalArgumentException(e);
        }
      }
    }
  }

  public void setHostName(String hostName) {
    this.hostName = hostName;
  }

  public void setPort(int port) {
    this.port = port;
  }

  /*
   * Set a header on this request.
   * Note that if the header implies other attributes of the request
   * I will set them accordingly. Specifically:
   *
   * If the header is "Cookie:" then I will automatically call
   * setCookie on all of the name-value pairs found therein.
   *
   * This makes the object easier to use because you can just feed it
   * headers and the object will remain consistent with the behavior
   * you'd expect from a request.
   */
  public void setHeader(String name, String value) {
    if (Ascii.equalsIgnoreCase(name, COOKIE_HEADER)) {
      for (String pair : Splitter.on(';').trimResults().omitEmptyStrings().split(value)) {
        int equalsPos = pair.indexOf('=');
        if (equalsPos != -1) {
          String cookieName = pair.substring(0, equalsPos);
          String cookieValue = pair.substring(equalsPos + 1);
          addToCookieMap(new Cookie(cookieName, cookieValue));
        }
      }
      setCookieHeader();
      return;
    }

    addToHeaderMap(name, value);

    if (Ascii.equalsIgnoreCase(name, HOST_HEADER)) {
      hostName = value;
    }
  }

  private void addToHeaderMap(String name, String value) {
    headers.put(Ascii.toLowerCase(name), value);
  }

  /**
   * Associates a set of cookies with this fake request.
   *
   * @param cookies the cookies associated with this request.
   */
  public void setCookies(Cookie... cookies) {
    for (Cookie cookie : cookies) {
      addToCookieMap(cookie);
    }
    setCookieHeader();
  }

  /**
   * Sets a single cookie associated with this fake request. Cookies are cumulative, but ones with
   * the same name will overwrite one another.
   *
   * @param c the cookie to associate with this request.
   */
  public void setCookie(Cookie c) {
    addToCookieMap(c);
    setCookieHeader();
  }

  private void addToCookieMap(Cookie c) {
    cookies.put(c.getName(), c);
  }

  /** Sets the "Cookie" HTTP header based on the current cookies. */
  private void setCookieHeader() {
    StringBuilder sb = new StringBuilder();
    boolean isFirst = true;
    for (Cookie c : cookies.values()) {
      if (!isFirst) {
        sb.append("; ");
      }
      sb.append(c.getName());
      sb.append("=");
      sb.append(c.getValue());
      isFirst = false;
    }

    // We cannot use setHeader() here, because setHeader() calls this method
    addToHeaderMap(COOKIE_HEADER, sb.toString());
  }

  public void addParameter(String key, String value) {
    parameters.put(key, value);
  }

  public void setMethod(String name) {
    method = name;
  }

  void setSerletPath(String servletPath) {
    this.servletPath = servletPath;
  }

  void setContextPath(String contextPath) {
    this.contextPath = contextPath;
  }

  void setPathInfo(String pathInfo) {
    if ("".equals(pathInfo)) {
      this.pathInfo = null;
    } else {
      this.pathInfo = pathInfo;
    }
  }

  /**
   * Specify the mock POST data.
   *
   * @param postString the mock post data
   * @param encoding format with which to encode mock post data
   */
  public void setPostData(String postString, Charset encoding) throws UnsupportedEncodingException {
    setPostData(postString, encoding.name());
  }

  /**
   * Specify the mock POST data.
   *
   * @param postString the mock post data
   * @param encoding format with which to encode mock post data
   */
  public void setPostData(String postString, String encoding) throws UnsupportedEncodingException {
    setPostData(postString.getBytes(encoding));
    characterEncoding = encoding;
  }

  /**
   * Specify the mock POST data in raw binary format.
   *
   * <p>This implicitly sets character encoding to not specified.
   *
   * @param data the mock post data; this is owned by the caller, so modifications made after this
   *     call will show up when the post data is read
   */
  public void setPostData(byte[] data) {
    bodyData = data;
    characterEncoding = null;
    setMethod(METHOD_POST);
  }

  /**
   * Sets the content type.
   *
   * @param contentType of the request.
   */
  public void setContentType(String contentType) {
    this.contentType = contentType;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



api_dev/src/main/java/com/google/appengine/tools/development/testing/ee10/FakeHttpServletRequest.java [541:778]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    throw new UnsupportedOperationException();
  }

  @Override
  public boolean authenticate(HttpServletResponse httpServletResponse)
      throws IOException, ServletException {
    throw new UnsupportedOperationException();
  }

  @Override
  public void login(String s, String s1) throws ServletException {
    throw new UnsupportedOperationException();
  }

  @Override
  public void logout() throws ServletException {
    throw new UnsupportedOperationException();
  }

  @Override
  public Collection<Part> getParts() throws IOException, ServletException {
    throw new UnsupportedOperationException();
  }

  @Override
  public Part getPart(String s) throws IOException, ServletException {
    throw new UnsupportedOperationException();
  }

  @Override
  public <T extends HttpUpgradeHandler> T upgrade(Class<T> aClass)
      throws IOException, ServletException {
    throw new UnsupportedOperationException();
  }

  @Override
  public boolean isRequestedSessionIdValid() {
    throw new UnsupportedOperationException();
  }

  @Override
  public boolean isUserInRole(String role) {
    throw new UnsupportedOperationException();
  }

  private static String paramsToString(ListMultimap<String, String> params) {
    try {
      StringBuilder sb = new StringBuilder();
      boolean first = true;
      for (Map.Entry<String, String> e : params.entries()) {
        if (!first) {
          sb.append('&');
        } else {
          first = false;
        }
        sb.append(URLEncoder.encode(e.getKey(), UTF_8.name()));
        if (!"".equals(e.getValue())) {
          sb.append('=').append(URLEncoder.encode(e.getValue(), UTF_8.name()));
        }
      }
      return sb.toString();
    } catch (UnsupportedEncodingException e) {
      throw new IllegalStateException(e);
    }
  }

  public void setParametersFromQueryString(String qs) {
    parameters.clear();
    if (qs != null) {
      for (String entry : Splitter.on('&').split(qs)) {
        List<String> kv = ImmutableList.copyOf(Splitter.on('=').limit(2).split(entry));
        try {
          parameters.put(
              URLDecoder.decode(kv.get(0), UTF_8.name()),
              kv.size() == 2 ? URLDecoder.decode(kv.get(1), UTF_8.name()) : "");
        } catch (UnsupportedEncodingException e) {
          throw new IllegalArgumentException(e);
        }
      }
    }
  }

  public void setHostName(String hostName) {
    this.hostName = hostName;
  }

  public void setPort(int port) {
    this.port = port;
  }

  /*
   * Set a header on this request.
   * Note that if the header implies other attributes of the request
   * I will set them accordingly. Specifically:
   *
   * If the header is "Cookie:" then I will automatically call
   * setCookie on all of the name-value pairs found therein.
   *
   * This makes the object easier to use because you can just feed it
   * headers and the object will remain consistent with the behavior
   * you'd expect from a request.
   */
  public void setHeader(String name, String value) {
    if (Ascii.equalsIgnoreCase(name, COOKIE_HEADER)) {
      for (String pair : Splitter.on(';').trimResults().omitEmptyStrings().split(value)) {
        int equalsPos = pair.indexOf('=');
        if (equalsPos != -1) {
          String cookieName = pair.substring(0, equalsPos);
          String cookieValue = pair.substring(equalsPos + 1);
          addToCookieMap(new Cookie(cookieName, cookieValue));
        }
      }
      setCookieHeader();
      return;
    }

    addToHeaderMap(name, value);

    if (Ascii.equalsIgnoreCase(name, HOST_HEADER)) {
      hostName = value;
    }
  }

  private void addToHeaderMap(String name, String value) {
    headers.put(Ascii.toLowerCase(name), value);
  }

  /**
   * Associates a set of cookies with this fake request.
   *
   * @param cookies the cookies associated with this request.
   */
  public void setCookies(Cookie... cookies) {
    for (Cookie cookie : cookies) {
      addToCookieMap(cookie);
    }
    setCookieHeader();
  }

  /**
   * Sets a single cookie associated with this fake request. Cookies are cumulative, but ones with
   * the same name will overwrite one another.
   *
   * @param c the cookie to associate with this request.
   */
  public void setCookie(Cookie c) {
    addToCookieMap(c);
    setCookieHeader();
  }

  private void addToCookieMap(Cookie c) {
    cookies.put(c.getName(), c);
  }

  /** Sets the "Cookie" HTTP header based on the current cookies. */
  private void setCookieHeader() {
    StringBuilder sb = new StringBuilder();
    boolean isFirst = true;
    for (Cookie c : cookies.values()) {
      if (!isFirst) {
        sb.append("; ");
      }
      sb.append(c.getName());
      sb.append("=");
      sb.append(c.getValue());
      isFirst = false;
    }

    // We cannot use setHeader() here, because setHeader() calls this method
    addToHeaderMap(COOKIE_HEADER, sb.toString());
  }

  public void addParameter(String key, String value) {
    parameters.put(key, value);
  }

  public void setMethod(String name) {
    method = name;
  }

  void setSerletPath(String servletPath) {
    this.servletPath = servletPath;
  }

  void setContextPath(String contextPath) {
    this.contextPath = contextPath;
  }

  void setPathInfo(String pathInfo) {
    if ("".equals(pathInfo)) {
      this.pathInfo = null;
    } else {
      this.pathInfo = pathInfo;
    }
  }

  /**
   * Specify the mock POST data.
   *
   * @param postString the mock post data
   * @param encoding format with which to encode mock post data
   */
  public void setPostData(String postString, Charset encoding) throws UnsupportedEncodingException {
    setPostData(postString, encoding.name());
  }

  /**
   * Specify the mock POST data.
   *
   * @param postString the mock post data
   * @param encoding format with which to encode mock post data
   */
  public void setPostData(String postString, String encoding) throws UnsupportedEncodingException {
    setPostData(postString.getBytes(encoding));
    characterEncoding = encoding;
  }

  /**
   * Specify the mock POST data in raw binary format.
   *
   * <p>This implicitly sets character encoding to not specified.
   *
   * @param data the mock post data; this is owned by the caller, so modifications made after this
   *     call will show up when the post data is read
   */
  public void setPostData(byte[] data) {
    bodyData = data;
    characterEncoding = null;
    setMethod(METHOD_POST);
  }

  /**
   * Sets the content type.
   *
   * @param contentType of the request.
   */
  public void setContentType(String contentType) {
    this.contentType = contentType;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



