Package org.apache.commons.httpclient

Examples of org.apache.commons.httpclient.NameValuePair


            }
            if (hasChar() && (chars[pos] == separator)) {
                pos++; // skip separator
            }
            if (paramName != null && !(paramName.equals("") && paramValue == null)) {
                params.add(new NameValuePair(paramName, paramValue));
            }
        }       
        return params;
    }
View Full Code Here


    public void testSelectorFormForRootResource() throws Exception {
        String resource = SERVLET_CONTEXT.equals("") ? "/" : SERVLET_CONTEXT;
       
        String content = getContent(HTTP_BASE_URL + "/system/sling/selector/login", CONTENT_TYPE_HTML,
                Arrays.asList(new NameValuePair("resource", resource)), 200);

        assertTrue("form action is not correct.", content.contains("action=\"" + SERVLET_CONTEXT + "/j_security_check\""));
        assertTrue("sling image reference is not correct.",
                content.contains("<img border=\"0\" src=\"" + SERVLET_CONTEXT + "/sling-logo.png\"/>"));
    }
View Full Code Here

    public void testSelectorFormForNonRootResource() throws Exception {
        String resource = SERVLET_CONTEXT + "/var/classes.json";
       
        String content = getContent(HTTP_BASE_URL + "/system/sling/selector/login", CONTENT_TYPE_HTML,
                Arrays.asList(new NameValuePair("resource", resource)), 200);

        assertTrue("form action is not correct.",
                content.contains("action=\"" + SERVLET_CONTEXT + "/var/classes.json/j_security_check\""));
        assertTrue("sling image reference is not correct.",
                content.contains("<img border=\"0\" src=\"" + SERVLET_CONTEXT + "/sling-logo.png\"/>"));
View Full Code Here

     * @throws Exception
     */
    public void testRedirectToSelectorLoginFormAfterLoginError() throws Exception {
      //login failure
        List<NameValuePair> params = new ArrayList<NameValuePair>();
        params.add(new NameValuePair("j_username", "___bogus___"));
        params.add(new NameValuePair("j_password", "not_a_real_user"));
        final String loginPageUrl = String.format("%s/system/sling/selector/login", HTTP_BASE_URL);
    PostMethod post = (PostMethod)assertPostStatus(HTTP_BASE_URL + "/j_security_check",
            HttpServletResponse.SC_MOVED_TEMPORARILY,
            params,
            null,
View Full Code Here

     * @throws Exception
     */
    public void testRedirectToOpenIDLoginFormAfterLoginError() throws Exception {
      //login failure
        List<NameValuePair> params = new ArrayList<NameValuePair>();
        params.add(new NameValuePair("openid_identifier", "___bogus___"));
        final String loginPageUrl = String.format("%s/system/sling/openid/login", HTTP_BASE_URL);
    PostMethod post = (PostMethod)assertPostStatus(HTTP_BASE_URL + "/j_security_check",
            HttpServletResponse.SC_MOVED_TEMPORARILY,
            params,
            null,
View Full Code Here

    // this method assumes the use of the selector auth bundle
    @Test
    public void testWithAcceptHeaderIncorrectCredentials() throws Exception {
        List<NameValuePair> params = new ArrayList<NameValuePair>();
        params.add(new NameValuePair("j_username", "garbage"));
        params.add(new NameValuePair("j_password", "garbage"));

        // simulate a browser request
        List<Header> headers = new ArrayList<Header>();
        headers.add(new Header("User-Agent", "Mozilla/5.0 Sling Integration Test"));
View Full Code Here

   *
   * @throws ContactsException
   */
  public void doLogin() throws ContactsException {
    try {
      NameValuePair params[] = { new NameValuePair("domain", "126.com"),
          new NameValuePair("language", "0"),
          new NameValuePair("user", getUsername(email)),
          new NameValuePair("username", email),
          new NameValuePair("password", password),
          new NameValuePair("style", "3") };

      Calendar calendar = Calendar.getInstance();
      calendar.set(2099, 11, 31);

      client.getState().addCookies(
View Full Code Here

   *
   * @throws ContactsException
   */
  public void doLogin() throws ContactsException {
    try {
      NameValuePair params[] = { new NameValuePair("type", "0"),
          new NameValuePair("style", "10"),
          new NameValuePair("user", getUsername(email)),
          new NameValuePair("pass", password),
          new NameValuePair("verifycookie", "y") };
      indexPage = doPost(loginUrl, params, "http://mail.tom.com");
    } catch (Exception e) {
      throw new ContactsException("tom protocol has changed", e);
    }
  }
View Full Code Here

    @Override
    protected void doLogin() throws ContactsException {
        try {
            String responseStr = doGet(preLoginUrl, "http://webmail6.189.cn/webmail/");
            String loginUrl = lastUrl.substring(0, lastUrl.indexOf("PassportLogin")) + getFormUrl(responseStr);
            NameValuePair params[] = {
                new NameValuePair("__EVENTTARGET", ""),
                new NameValuePair("__EVENTARGUMENT", ""),
                new NameValuePair("__VIEWSTATE", getInputValue("__VIEWSTATE", responseStr)),
                new NameValuePair("__EVENTVALIDATION", getInputValue("__EVENTVALIDATION", responseStr)),
                new NameValuePair("txtUserId", getUsername(email)),
                new NameValuePair("txtPwd", password),
                new NameValuePair("ibtn_Login", ""),
                new NameValuePair("HiddenReg", getInputValue("HiddenReg", responseStr)),
                new NameValuePair("HiddenErrMsg", ""),
                new NameValuePair("TimeMsg", "")
            };
            responseStr = doPost(loginUrl, params, lastUrl);
            String redirectUrl = getHrefUrl(responseStr, "/webmail/logon.do");
            doGet(lastUrl.substring(0, lastUrl.indexOf("/webmail/")) + redirectUrl, loginUrl);
        } catch (Exception e) {
View Full Code Here

     * @throws com.huangzhimin.contacts.exception.ContactsException
     */
    @Override
    protected void doLogin() throws ContactsException {
        try {
            NameValuePair params[] = {
                new NameValuePair("UserName", getUsername(email)),
                new NameValuePair("Password", password),
                new NameValuePair("VerifyCode", "")
            };
            String responseStr = doPost(loginUrl, params,
                    "http://mail.139.com");
            String redirectUrl = getHrefUrl(responseStr, "http://");
            responseStr = doGet(redirectUrl, loginUrl);
View Full Code Here

TOP

Related Classes of org.apache.commons.httpclient.NameValuePair

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.