Search in sources :

Example 11 with Connection

use of org.jsoup.Connection in project jsoup by jhy.

the class HttpConnectionTest method cookie.

@Test
public void cookie() {
    Connection con = HttpConnection.connect("http://example.com/");
    con.cookie("Name", "Val");
    assertEquals("Val", con.request().cookie("Name"));
}
Also used : Connection(org.jsoup.Connection) Test(org.junit.Test) ParseTest(org.jsoup.integration.ParseTest)

Example 12 with Connection

use of org.jsoup.Connection in project jsoup by jhy.

the class HttpConnectionTest method timeout.

@Test
public void timeout() {
    Connection con = HttpConnection.connect("http://example.com/");
    assertEquals(30 * 1000, con.request().timeout());
    con.timeout(1000);
    assertEquals(1000, con.request().timeout());
}
Also used : Connection(org.jsoup.Connection) Test(org.junit.Test) ParseTest(org.jsoup.integration.ParseTest)

Example 13 with Connection

use of org.jsoup.Connection in project jsoup by jhy.

the class HttpConnectionTest method method.

@Test
public void method() {
    Connection con = HttpConnection.connect("http://example.com/");
    assertEquals(Connection.Method.GET, con.request().method());
    con.method(Connection.Method.POST);
    assertEquals(Connection.Method.POST, con.request().method());
}
Also used : Connection(org.jsoup.Connection) Test(org.junit.Test) ParseTest(org.jsoup.integration.ParseTest)

Example 14 with Connection

use of org.jsoup.Connection in project jsoup by jhy.

the class HttpConnectionTest method requestBody.

@Test
public void requestBody() {
    Connection con = HttpConnection.connect("http://example.com/");
    con.requestBody("foo");
    assertEquals("foo", con.request().requestBody());
}
Also used : Connection(org.jsoup.Connection) Test(org.junit.Test) ParseTest(org.jsoup.integration.ParseTest)

Example 15 with Connection

use of org.jsoup.Connection in project jsoup by jhy.

the class HttpConnectionTest method throwsExceptionOnParseWithoutExecute.

/* most actual network http connection tests are in integration */
@Test(expected = IllegalArgumentException.class)
public void throwsExceptionOnParseWithoutExecute() throws IOException {
    Connection con = HttpConnection.connect("http://example.com");
    con.response().parse();
}
Also used : Connection(org.jsoup.Connection) Test(org.junit.Test) ParseTest(org.jsoup.integration.ParseTest)

Aggregations

Connection (org.jsoup.Connection)47 Test (org.junit.Test)42 Document (org.jsoup.nodes.Document)26 ParseTest (org.jsoup.integration.ParseTest)13 IOException (java.io.IOException)3 URL (java.net.URL)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Element (org.jsoup.nodes.Element)2 Elements (org.jsoup.select.Elements)2 JsonArray (com.google.gson.JsonArray)1 JsonObject (com.google.gson.JsonObject)1 JsonParser (com.google.gson.JsonParser)1 JsonSyntaxException (com.google.gson.JsonSyntaxException)1 News (com.itculturalfestival.smartcampus.entity.News)1 DisposableHolder (com.vegen.smartcampus.baseframework.network.DisposableHolder)1 ObservableOnSubscribe (io.reactivex.ObservableOnSubscribe)1 Disposable (io.reactivex.disposables.Disposable)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1