Package jodd.lagarto.form

Source Code of jodd.lagarto.form.FormTextTest

// Copyright (c) 2003-2014, Jodd Team (jodd.org). All Rights Reserved.

package jodd.lagarto.form;

import jodd.http.HttpRequest;
import jodd.http.HttpResponse;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

public class FormTextTest {

  @BeforeClass
  public static void beforeClass() {
    LagartoFormSuite.startTomcat();
  }

  @AfterClass
  public static void afterClass() {
    LagartoFormSuite.stopTomcat();
  }

  private static final String TEXT_RESULT = "<input name=\"iname\" type=\"text\" value=\"foo\">";

  @Test
  public void testFormTagTextGet() {
    HttpResponse response = HttpRequest
        .get("localhost:8173/text.jsp")
        .query("iname", "foo")
        .send();

    assertEquals(TEXT_RESULT, response.bodyText().trim());
  }

  @Test
  public void testFormTagTextGetWithValue() {
    HttpResponse response = HttpRequest
        .get("localhost:8173/text2.jsp")
        .query("iname", "foo")
        .send();

    assertEquals(TEXT_RESULT, response.bodyText().trim());
  }

  @Test
  public void testFormTagTextPost() {
    HttpResponse response = HttpRequest
        .post("localhost:8173/text.jsp")
        .form("iname", "foo")
        .send();

    assertEquals(TEXT_RESULT, response.bodyText().trim());
  }

  @Test
  public void testFormTagTextPostMulti() {
    HttpResponse response = HttpRequest
        .post("localhost:8173/text.jsp")
        .form("iname", "foo")
        .multipart(true)
        .send();

    assertEquals(TEXT_RESULT, response.bodyText().trim());
  }
}
TOP

Related Classes of jodd.lagarto.form.FormTextTest

TOP
Copyright © 2018 www.massapi.com. 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.