Commit d2ac773fbe93461e1e44cb4d060b602bf495a05e
1 parent
8f83b890
Exists in
master
IN PROGRESS - issue FWK-119: Testes da extensão Servlet
https://demoiselle.atlassian.net/browse/FWK-119
Showing
1 changed file
with
13 additions
and
9 deletions
Show diff stats
impl/extension/servlet/src/test/java/security/SecurityTest.java
1 | 1 | package security; |
2 | 2 | |
3 | +import static org.apache.http.HttpStatus.SC_FORBIDDEN; | |
4 | +import static org.apache.http.HttpStatus.SC_OK; | |
3 | 5 | import static org.junit.Assert.assertEquals; |
4 | 6 | |
5 | 7 | import java.io.IOException; |
... | ... | @@ -7,11 +9,10 @@ import java.net.URISyntaxException; |
7 | 9 | import java.net.URL; |
8 | 10 | |
9 | 11 | import org.apache.http.HttpResponse; |
10 | -import org.apache.http.HttpStatus; | |
11 | 12 | import org.apache.http.client.ClientProtocolException; |
12 | 13 | import org.apache.http.client.methods.HttpGet; |
13 | 14 | import org.apache.http.client.utils.URIBuilder; |
14 | -import org.apache.http.impl.client.DefaultHttpClient; | |
15 | +import org.apache.http.impl.client.HttpClientBuilder; | |
15 | 16 | import org.jboss.arquillian.container.test.api.Deployment; |
16 | 17 | import org.jboss.arquillian.junit.Arquillian; |
17 | 18 | import org.jboss.arquillian.test.api.ArquillianResource; |
... | ... | @@ -44,19 +45,22 @@ public class SecurityTest { |
44 | 45 | uriBuilder.setParameter("password", "changeit"); |
45 | 46 | |
46 | 47 | HttpGet httpGet = new HttpGet(uriBuilder.build()); |
47 | - HttpResponse httpResponse = new DefaultHttpClient().execute(httpGet); | |
48 | + HttpResponse httpResponse = HttpClientBuilder.create().build().execute(httpGet); | |
48 | 49 | |
49 | 50 | int status = httpResponse.getStatusLine().getStatusCode(); |
50 | - assertEquals(HttpStatus.SC_OK, status); | |
51 | + assertEquals(SC_OK, status); | |
51 | 52 | } |
52 | 53 | |
53 | 54 | @Test |
54 | - public void loginFailed() throws ClientProtocolException, IOException { | |
55 | - DefaultHttpClient client = new DefaultHttpClient(); | |
56 | - HttpGet get = new HttpGet(deploymentUrl + "/login?username=demoiselle&password=wrongpass"); | |
57 | - HttpResponse response = client.execute(get); | |
55 | + public void loginFailed() throws ClientProtocolException, IOException, URISyntaxException { | |
56 | + URIBuilder uriBuilder = new URIBuilder(deploymentUrl + "/login"); | |
57 | + uriBuilder.setParameter("username", "invalid"); | |
58 | + uriBuilder.setParameter("password", "invalid"); | |
59 | + | |
60 | + HttpGet get = new HttpGet(uriBuilder.build()); | |
61 | + HttpResponse response = HttpClientBuilder.create().build().execute(get); | |
58 | 62 | |
59 | 63 | int status = response.getStatusLine().getStatusCode(); |
60 | - assertEquals(HttpStatus.SC_FORBIDDEN, status); | |
64 | + assertEquals(SC_FORBIDDEN, status); | |
61 | 65 | } |
62 | 66 | } | ... | ... |