import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
+import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
String d = IOUtils.readURL(uc);
return d;
}
- public String fetchStartErrorMessage(String query) throws IOException {
- String d = runRegister(query);
+ public String fetchStartErrorMessage(String d) throws IOException {
String formFail = "<div class='formError'>";
int idx = d.indexOf(formFail);
assertNotEquals(-1, idx);
+ "&pword1=" + URLEncoder.encode(password, "UTF-8")
+ "&pword2=" + URLEncoder.encode(password, "UTF-8")
+ "&day=1&month=1&year=1910&cca_agree=1";
- String data = fetchStartErrorMessage(query);
+ String data = fetchStartErrorMessage(runRegister(query));
assertTrue(data, data.startsWith("</div>"));
} catch (UnsupportedEncodingException e) {
throw new Error(e);
public String createUniqueName() {
return "test" + System.currentTimeMillis() + "a" + (count++);
}
+ public String login(String email, String pw) throws IOException {
+ URL u = new URL("https://" + getServerName() + "/login");
+ HttpURLConnection huc = (HttpURLConnection) u.openConnection();
+ huc.setDoOutput(true);
+ OutputStream os = huc.getOutputStream();
+ String data = "username=" + URLEncoder.encode(email, "UTF-8")
+ + "&password=" + URLEncoder.encode(pw, "UTF-8");
+ os.write(data.getBytes());
+ os.flush();
+ String headerField = huc.getHeaderField("Set-Cookie");
+ headerField = headerField.substring(0, headerField.indexOf(';'));
+ return headerField;
+ }
}