Skip to content

Commit

Permalink
Removed external URL from testsuite
Browse files Browse the repository at this point in the history
Don't want external dependencies on the build
  • Loading branch information
jhy committed Jul 5, 2019
1 parent fb58877 commit 8d1d503
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/test/java/org/jsoup/integration/ConnectTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,11 @@ public void postFiles() throws IOException {

@Test
public void multiCookieSet() throws IOException {
Connection con = Jsoup.connect("http://direct.infohound.net/tools/302-cookie.pl");
Connection con = Jsoup
.connect(RedirectServlet.Url)
.data(RedirectServlet.CodeParam, "302")
.data(RedirectServlet.SetCookiesParam, "true")
.data(RedirectServlet.LocationParam, echoUrl);
Connection.Response res = con.execute();

// test cookies set by redirect:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.jsoup.integration.TestServer;

import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
Expand All @@ -11,6 +12,7 @@ public class RedirectServlet extends BaseServlet {
public static final String Url = TestServer.map(RedirectServlet.class);
public static final String LocationParam = "loc";
public static final String CodeParam = "code";
public static final String SetCookiesParam = "setCookies";
private static final int DefaultCode = HttpServletResponse.SC_MOVED_TEMPORARILY;

@Override
Expand All @@ -24,6 +26,11 @@ protected void doGet(HttpServletRequest req, HttpServletResponse res) throws IOE
if (code != null)
intCode = Integer.parseInt(code);

if (req.getParameter(SetCookiesParam) != null) {
res.addCookie(new Cookie("token", "asdfg123"));
res.addCookie(new Cookie("uid", "jhy"));
}

res.setHeader("Location", location);
res.setStatus(intCode);
}
Expand Down

0 comments on commit 8d1d503

Please sign in to comment.