Commit ceb0887ed442006d52440d9f6fc9d7d183847178
1 parent
788c9cf1
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
11 additions
and
11 deletions
Show diff stats
impl/extension/servlet/src/test/java/security/SecurityTest.java
... | ... | @@ -3,15 +3,15 @@ package security; |
3 | 3 | import static org.junit.Assert.assertEquals; |
4 | 4 | |
5 | 5 | import java.io.IOException; |
6 | +import java.net.URISyntaxException; | |
6 | 7 | import java.net.URL; |
7 | 8 | |
8 | 9 | import org.apache.http.HttpResponse; |
9 | 10 | import org.apache.http.HttpStatus; |
10 | 11 | import org.apache.http.client.ClientProtocolException; |
11 | 12 | import org.apache.http.client.methods.HttpGet; |
13 | +import org.apache.http.client.utils.URIBuilder; | |
12 | 14 | import org.apache.http.impl.client.DefaultHttpClient; |
13 | -import org.apache.http.params.HttpParams; | |
14 | -import org.apache.http.params.HttpParamsNames; | |
15 | 15 | import org.jboss.arquillian.container.test.api.Deployment; |
16 | 16 | import org.jboss.arquillian.junit.Arquillian; |
17 | 17 | import org.jboss.arquillian.test.api.ArquillianResource; |
... | ... | @@ -38,24 +38,24 @@ public class SecurityTest { |
38 | 38 | } |
39 | 39 | |
40 | 40 | @Test |
41 | - public void loginSucessfull() throws ClientProtocolException, IOException { | |
42 | - DefaultHttpClient client = new DefaultHttpClient(); | |
43 | -// HttpGet get = new HttpGet(deploymentUrl + "/login"); | |
44 | -// get.getParams().setParameter("username", "demoiselle"); | |
45 | -// get.getParams().setParameter("password", "changeit"); | |
46 | - HttpGet get = new HttpGet(deploymentUrl + "/login?username=demoiselle&password=changeit"); | |
47 | - HttpResponse response = client.execute(get); | |
41 | + public void loginSucessfull() throws ClientProtocolException, IOException, URISyntaxException { | |
42 | + URIBuilder uriBuilder = new URIBuilder(deploymentUrl + "/login"); | |
43 | + uriBuilder.setParameter("username", "demoiselle"); | |
44 | + uriBuilder.setParameter("password", "changeit"); | |
45 | + | |
46 | + HttpGet httpGet = new HttpGet(uriBuilder.build()); | |
47 | + HttpResponse response = new DefaultHttpClient().execute(httpGet); | |
48 | 48 | |
49 | 49 | int status = response.getStatusLine().getStatusCode(); |
50 | 50 | assertEquals(HttpStatus.SC_OK, status); |
51 | 51 | } |
52 | - | |
52 | + | |
53 | 53 | @Test |
54 | 54 | public void loginFailed() throws ClientProtocolException, IOException { |
55 | 55 | DefaultHttpClient client = new DefaultHttpClient(); |
56 | 56 | HttpGet get = new HttpGet(deploymentUrl + "/login?username=demoiselle&password=wrongpass"); |
57 | 57 | HttpResponse response = client.execute(get); |
58 | - | |
58 | + | |
59 | 59 | int status = response.getStatusLine().getStatusCode(); |
60 | 60 | assertEquals(HttpStatus.SC_UNAUTHORIZED, status); |
61 | 61 | } | ... | ... |