MentaTutorials

Compare Revisions

Regard whitespace Rev 17 → Rev 18

/MentaRefAppWithService/trunk/src/test/java/org/menta/action/LoginActionTest.java
1,10 → 1,12
package org.menta.action;
 
import static org.mentawai.core.Action.*;
import static org.mentawai.core.Action.ERROR;
import static org.mentawai.core.Action.SUCCESS;
import junit.framework.Assert;
 
import org.junit.Test;
import org.menta.AbstractBaseTest;
import org.menta.exception.LoginException.Type;
import org.menta.model.Group;
import org.menta.model.Language;
import org.menta.model.User;
36,41 → 38,25
 
String result, errorId;
// test only post...
User user = new User();
result = login.execute();
Assert.assertEquals(ERROR, result);
input.setProperty("method", "post");
// testing missing username or password...
result = login.execute();
errorId = login.getError("username");
Assert.assertEquals(ERROR, result);
Assert.assertEquals("no_username", errorId);
// test wrong password...
input.setValue("username", "testUser");
input.setValue("password", "wrong_pass");
input.inject(user);
result = login.execute(user);
result = login.execute();
errorId = login.getError("username");
errorId = login.getError("password");
Assert.assertEquals(ERROR, result);
Assert.assertEquals("bad_password", errorId);
Assert.assertEquals(Type.WRONG_PASSWORD.toString(), errorId);
// test success...
input.setValue("password", "abc123");
input.inject(user);
result = login.execute(user);
result = login.execute();
Assert.assertEquals(SUCCESS, result);
}