You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.3 KiB
46 lines
1.3 KiB
package org.airsonic.player.validator;
|
|
|
|
import junit.framework.TestCase;
|
|
import org.airsonic.player.command.PasswordSettingsCommand;
|
|
import org.junit.Before;
|
|
import org.springframework.validation.BeanPropertyBindingResult;
|
|
import org.springframework.validation.Errors;
|
|
|
|
public class PasswordSettingsValidatorTestCase extends TestCase {
|
|
|
|
private PasswordSettingsCommand psc;
|
|
|
|
@Before
|
|
public void setUp() {
|
|
psc = new PasswordSettingsCommand();
|
|
psc.setUsername("username");
|
|
psc.setPassword("1234");
|
|
}
|
|
|
|
private Errors validatePassword() {
|
|
PasswordSettingsValidator psv = new PasswordSettingsValidator();
|
|
Errors errors = new BeanPropertyBindingResult(psc, "psv");
|
|
psv.validate(psc, errors);
|
|
return errors;
|
|
}
|
|
|
|
public void testValidateEmptyPassword() {
|
|
psc.setPassword("");
|
|
Errors errors = this.validatePassword();
|
|
assertTrue(errors.hasErrors());
|
|
}
|
|
|
|
public void testValidateDifferentPasswords() {
|
|
psc.setConfirmPassword("5678");
|
|
|
|
Errors errors = this.validatePassword();
|
|
assertTrue(errors.hasErrors());
|
|
}
|
|
|
|
public void testValidateEverythingOK() {
|
|
psc.setConfirmPassword("1234");
|
|
|
|
Errors errors = this.validatePassword();
|
|
assertFalse(errors.hasErrors());
|
|
}
|
|
}
|
|
|