domain-constructor.
rs.close();
}
- public EmailAddress(String address, User owner) {
+ public EmailAddress(User owner, String address) {
if ( !EmailProvider.MAIL.matcher(address).matches()) {
throw new IllegalArgumentException("Invalid email.");
}
String formMail = req.getParameter("newemail");
mail = formMail;
try {
- EmailAddress addr = new EmailAddress(mail, target);
+ EmailAddress addr = new EmailAddress(target, mail);
addr.insert(Page.getLanguage(req));
} catch (IllegalArgumentException e) {
out.println("<div class='formError'>Error: Invalid address!</div>");
buildup.setDob(myDoB.getDate());
buildup.insert(password);
int memid = buildup.getId();
- EmailAddress ea = new EmailAddress(buildup.getEmail(), buildup);
+ EmailAddress ea = new EmailAddress(buildup, buildup.getEmail());
ea.insert(Page.getLanguage(req));
PreparedStatement ps = DatabaseConnection.getInstance().prepare("insert into `alerts` set `memid`=?," + " `general`=?, `country`=?, `regional`=?, `radius`=?");
@Test
public void testEmailCache() {
- EmailAddress em = new EmailAddress(createUniqueName() + "@example.org", User.getById(uid));
+ EmailAddress em = new EmailAddress(User.getById(uid), createUniqueName() + "@example.org");
em.insert(Language.getInstance(Locale.ENGLISH));
assertThat(em, is(sameInstance(EmailAddress.getById(em.getId()))));
int id = createVerifiedUser("aä", "b", uq + "a@email.org", TEST_PASSWORD);
User u = User.getById(id);
- new EmailAddress(uq + "b@email.org", u).insert(Language.getInstance(Locale.ENGLISH));
- new EmailAddress(uq + "c@email.org", u).insert(Language.getInstance(Locale.ENGLISH));
+ new EmailAddress(u, uq + "b@email.org").insert(Language.getInstance(Locale.ENGLISH));
+ new EmailAddress(u, uq + "c@email.org").insert(Language.getInstance(Locale.ENGLISH));
new Domain(u, uq + "a.testdomain.org").insert();
new Domain(u, uq + "b.testdomain.org").insert();
new Domain(u, uq + "c.testdomain.org").insert();
@Test
public void testMailAddInternalFaulty() {
try {
- new EmailAddress("kurti ", u);
+ new EmailAddress(u, "kurti ");
fail();
} catch (IllegalArgumentException e) {
// Intended.
@Test
public void testMailSetDefaultWebUnverified() throws MalformedURLException, UnsupportedEncodingException, IOException, InterruptedException, GigiApiException {
- EmailAddress adrr = new EmailAddress(createUniqueName() + "test@test.tld", u);
+ EmailAddress adrr = new EmailAddress(u, createUniqueName() + "test@test.tld");
adrr.insert(Language.getInstance(Locale.ENGLISH));
assertNotNull(executeBasicWebInteraction(cookie, path, "makedefault&emailid=" + adrr.getId()));
assertNotEquals(User.getById(u.getId()).getEmail(), adrr.getAddress());
}
public static EmailAddress createVerifiedEmail(User u) throws InterruptedException, GigiApiException {
- EmailAddress adrr = new EmailAddress(createUniqueName() + "test@test.tld", u);
+ EmailAddress adrr = new EmailAddress(u, createUniqueName() + "test@test.tld");
adrr.insert(Language.getInstance(Locale.ENGLISH));
TestMail testMail = getMailReciever().recieve();
assertEquals(adrr.getAddress(), testMail.getTo());
public static void run(String[] args, boolean truncate) throws ClassNotFoundException, SQLException, IOException {
Class.forName(args[0]);
Connection conn = DriverManager.getConnection(args[1], args[2], args[3]);
+ conn.setAutoCommit(false);
Statement stmt = conn.createStatement();
addFile(stmt, new File("doc/tableStructure.sql"), truncate);
File localData = new File("doc/sampleData.sql");
addFile(stmt, localData, false);
}
stmt.executeBatch();
+ conn.commit();
stmt.close();
}