~s-friedemann/tomdroid/sshfs

« back to all changes in this revision

Viewing changes to lib/signpost/signpost-core/src/test/java/oauth/signpost/basic/HttpRequestAdapterTestBase.java

  • Committer: Benoit Garret
  • Date: 2010-03-06 20:39:56 UTC
  • mto: (185.4.1 sync-ui)
  • mto: This revision was merged to the branch mainline in revision 186.
  • Revision ID: benoit.garret_launchpad@gadz.org-20100306203956-k6vlss6hk2d91j4n
Put the signpost and commons-codec libraries in lib/

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package oauth.signpost.basic;
 
2
 
 
3
import static org.junit.Assert.assertEquals;
 
4
 
 
5
import java.io.BufferedReader;
 
6
import java.io.InputStreamReader;
 
7
 
 
8
import oauth.signpost.http.HttpRequest;
 
9
 
 
10
import org.junit.Before;
 
11
import org.junit.Test;
 
12
 
 
13
public abstract class HttpRequestAdapterTestBase {
 
14
 
 
15
    protected static final String URL = "http://www.example.com/protected";
 
16
 
 
17
    protected static final String HTTP_POST_METHOD = "POST";
 
18
 
 
19
    protected static final String CONTENT_TYPE = "text/plain";
 
20
 
 
21
    protected static final String HEADER_NAME = "test-header";
 
22
 
 
23
    protected static final String HEADER_VALUE = "test-header-value";
 
24
 
 
25
    protected static final String PAYLOAD = "message-body";
 
26
 
 
27
    protected HttpRequest request;
 
28
 
 
29
    @Before
 
30
    public abstract void prepareRequest() throws Exception;
 
31
 
 
32
    @Test
 
33
    public void shouldReturnCorrectRequestUrl() {
 
34
        assertEquals(URL, request.getRequestUrl());
 
35
    }
 
36
 
 
37
    @Test
 
38
    public void shouldReturnCorrectRequestMethod() {
 
39
        assertEquals(HTTP_POST_METHOD, request.getMethod());
 
40
    }
 
41
 
 
42
    @Test
 
43
    public void shouldGetAndSetRequestHeaders() {
 
44
        assertEquals(HEADER_VALUE, request.getHeader(HEADER_NAME));
 
45
 
 
46
        request.setHeader("a", "b");
 
47
        assertEquals("b", request.getHeader("a"));
 
48
    }
 
49
 
 
50
    @Test
 
51
    public void shouldReturnCorrectContentType() {
 
52
        assertEquals(CONTENT_TYPE, request.getContentType());
 
53
    }
 
54
 
 
55
    @Test
 
56
    public void shouldReturnCorrectMessagePayload() throws Exception {
 
57
        String actual = new BufferedReader(new InputStreamReader(
 
58
                request.getMessagePayload())).readLine();
 
59
        assertEquals(PAYLOAD, actual);
 
60
    }
 
61
}