1
package oauth.signpost;
3
import static org.mockito.Mockito.when;
5
import java.util.HashMap;
7
import oauth.signpost.http.HttpRequest;
9
import org.junit.Before;
10
import org.junit.BeforeClass;
11
import org.mockito.Mock;
12
import org.mockito.MockitoAnnotations;
14
public abstract class SignpostTestBase {
16
public static final String OAUTH_VERSION = "1.0";
18
public static final String CONSUMER_KEY = "dpf43f3p2l4k3l03";
20
public static final String CONSUMER_SECRET = "kd94hf93k423kf44";
22
public static final String TOKEN = "nnch734d00sl2jdk";
24
public static final String TOKEN_SECRET = "pfkkdhi9sl3r4s00";
26
public static final String NONCE = "kllo9940pd9333jh";
28
public static final String TIMESTAMP = "1191242096";
30
public static final String SIGNATURE_METHOD = "HMAC-SHA1";
32
public static final String REQUEST_TOKEN_ENDPOINT_URL = "http://api.test.com/request_token";
34
public static final String ACCESS_TOKEN_ENDPOINT_URL = "http://api.test.com/access_token";
36
public static final String AUTHORIZE_WEBSITE_URL = "http://www.test.com/authorize";
38
public static final HashMap<String, String> OAUTH_PARAMS = new HashMap<String, String>();
41
protected HttpRequest httpGetMock;
44
protected HttpRequest httpPostMock;
47
public static void initOAuthParams() {
48
OAUTH_PARAMS.put("oauth_consumer_key", CONSUMER_KEY);
49
OAUTH_PARAMS.put("oauth_signature_method", SIGNATURE_METHOD);
50
OAUTH_PARAMS.put("oauth_timestamp", TIMESTAMP);
51
OAUTH_PARAMS.put("oauth_nonce", NONCE);
52
OAUTH_PARAMS.put("oauth_version", OAUTH_VERSION);
53
OAUTH_PARAMS.put("oauth_token", TOKEN);
57
public void initRequestMocks() {
58
MockitoAnnotations.initMocks(this);
60
when(httpGetMock.getMethod()).thenReturn("GET");
61
when(httpGetMock.getRequestUrl()).thenReturn("http://www.example.com");
63
when(httpPostMock.getMethod()).thenReturn("POST");
64
when(httpPostMock.getRequestUrl()).thenReturn("http://www.example.com");