1 package com.atlassian.security.auth.trustedapps.request.commonshttpclient;
2
3 import com.atlassian.security.auth.trustedapps.request.TrustedRequest;
4
5 import org.apache.commons.httpclient.HttpMethod;
6
7 import com.mockobjects.dynamic.C;
8 import com.mockobjects.dynamic.Mock;
9
10 import junit.framework.TestCase;
11
12
13
14
15 public class TestCommonsHttpClientTrustedRequest extends TestCase
16 {
17 private Mock mockHttpMethod;
18
19 private TrustedRequest trustedRequest;
20
21 protected void setUp() throws Exception
22 {
23 mockHttpMethod = new Mock(HttpMethod.class);
24 trustedRequest = new CommonsHttpClientTrustedRequest((HttpMethod) mockHttpMethod.proxy());
25 }
26
27 protected void tearDown() throws Exception
28 {
29 trustedRequest = null;
30 }
31
32 public void testCannotCreateWithNullHttpMethod()
33 {
34 try
35 {
36 new CommonsHttpClientTrustedRequest(null);
37 fail();
38 }
39 catch (IllegalArgumentException e)
40 {
41
42 }
43 }
44
45 public void testAddRequestParameter()
46 {
47 final String paramName = "some name";
48 final String paramValue = "some value";
49 mockHttpMethod.expect("addRequestHeader", C.args(C.eq(paramName), C.eq(paramValue)));
50
51 trustedRequest.addRequestParameter(paramName, paramValue);
52 }
53 }