-
Notifications
You must be signed in to change notification settings - Fork 25
/
JsfValidatorTest.java
43 lines (36 loc) · 1.31 KB
/
JsfValidatorTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package org.ocpsoft.prettyfaces.annotation.basic.validate;
import static junit.framework.Assert.assertTrue;
import org.apache.http.client.methods.HttpGet;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ocpsoft.prettyfaces.test.PrettyFacesTest;
import org.ocpsoft.rewrite.test.HttpAction;
@RunWith(Arquillian.class)
public class JsfValidatorTest extends PrettyFacesTest
{
@Deployment(testable = false)
public static WebArchive getDeployment()
{
return getBaseDeployment()
.addClass(JsfValidatorBean.class)
.addClass(EvenLengthValidator.class)
.addAsWebResource("basic/validate.xhtml", "validate.xhtml");
}
@Test
public void testValidationSuccess() throws Exception
{
HttpAction<HttpGet> action = get("/validate/abcd");
assertTrue(action.getResponseContent().contains("Parameter = [abcd]"));
}
@Test
public void testValidationFailed() throws Exception
{
HttpAction<HttpGet> action = get("/validate/abc");
Assert.assertEquals(404, action.getStatusCode());
Assert.assertTrue(action.getResponseContent().contains("404"));
}
}