| 1 |
package oauth.signpost; |
| 2 |
|
| 3 |
import static org.mockito.Mockito.when; |
| 4 |
import oauth.signpost.http.HttpRequest; |
| 5 |
import oauth.signpost.http.HttpParameters; |
| 6 |
|
| 7 |
import org.junit.Before; |
| 8 |
import org.junit.BeforeClass; |
| 9 |
import org.mockito.Mock; |
| 10 |
import org.mockito.MockitoAnnotations; |
| 11 |
|
| 12 |
public abstract class SignpostTestBase { |
| 13 |
|
| 14 |
public static final String OAUTH_VERSION = "1.0"; |
| 15 |
|
| 16 |
public static final String CONSUMER_KEY = "dpf43f3p2l4k3l03"; |
| 17 |
|
| 18 |
public static final String CONSUMER_SECRET = "kd94hf93k423kf44"; |
| 19 |
|
| 20 |
public static final String TOKEN = "nnch734d00sl2jdk"; |
| 21 |
|
| 22 |
public static final String TOKEN_SECRET = "pfkkdhi9sl3r4s00"; |
| 23 |
|
| 24 |
public static final String NONCE = "kllo9940pd9333jh"; |
| 25 |
|
| 26 |
public static final String TIMESTAMP = "1191242096"; |
| 27 |
|
| 28 |
public static final String SIGNATURE_METHOD = "HMAC-SHA1"; |
| 29 |
|
| 30 |
public static final String REQUEST_TOKEN_ENDPOINT_URL = "http://api.test.com/request_token"; |
| 31 |
|
| 32 |
public static final String ACCESS_TOKEN_ENDPOINT_URL = "http://api.test.com/access_token"; |
| 33 |
|
| 34 |
public static final String AUTHORIZE_WEBSITE_URL = "http://www.test.com/authorize"; |
| 35 |
|
| 36 |
public static final HttpParameters OAUTH_PARAMS = new HttpParameters(); |
| 37 |
|
| 38 |
public static final HttpParameters EMPTY_PARAMS = new HttpParameters(); |
| 39 |
|
| 40 |
@Mock |
| 41 |
protected HttpRequest httpGetMock; |
| 42 |
|
| 43 |
@Mock |
| 44 |
protected HttpRequest httpGetMockWithQueryString; |
| 45 |
@Mock |
| 46 |
protected HttpRequest httpPostMock; |
| 47 |
|
| 48 |
@BeforeClass |
| 49 |
public static void initOAuthParams() { |
| 50 |
OAUTH_PARAMS.put("oauth_consumer_key", CONSUMER_KEY); |
| 51 |
OAUTH_PARAMS.put("oauth_signature_method", SIGNATURE_METHOD); |
| 52 |
OAUTH_PARAMS.put("oauth_timestamp", TIMESTAMP); |
| 53 |
OAUTH_PARAMS.put("oauth_nonce", NONCE); |
| 54 |
OAUTH_PARAMS.put("oauth_version", OAUTH_VERSION); |
| 55 |
OAUTH_PARAMS.put("oauth_token", TOKEN); |
| 56 |
} |
| 57 |
|
| 58 |
@Before |
| 59 |
public void initRequestMocks() { |
| 60 |
MockitoAnnotations.initMocks(this); |
| 61 |
|
| 62 |
when(httpGetMock.getMethod()).thenReturn("GET"); |
| 63 |
when(httpGetMock.getRequestUrl()).thenReturn("http://www.example.com"); |
| 64 |
|
| 65 |
when(httpGetMockWithQueryString.getMethod()).thenReturn("GET"); |
| 66 |
when(httpGetMockWithQueryString.getRequestUrl()).thenReturn("http://www.example.com?foo=bar"); |
| 67 |
|
| 68 |
when(httpPostMock.getMethod()).thenReturn("POST"); |
| 69 |
when(httpPostMock.getRequestUrl()).thenReturn("http://www.example.com"); |
| 70 |
} |
| 71 |
} |