本文整理汇总了Java中com.tumblr.jumblr.exceptions.JumblrException类的典型用法代码示例。如果您正苦于以下问题:Java JumblrException类的具体用法?Java JumblrException怎么用?Java JumblrException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JumblrException类属于com.tumblr.jumblr.exceptions包,在下文中一共展示了JumblrException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: clear
import com.tumblr.jumblr.exceptions.JumblrException; //导入依赖的package包/类
ResponseWrapper clear(Response response) {
if (response.getCode() == 200 || response.getCode() == 201) {
String json = response.getBody();
try {
Gson gson = new GsonBuilder().
registerTypeAdapter(JsonElement.class, new JsonElementDeserializer()).
create();
ResponseWrapper wrapper = gson.fromJson(json, ResponseWrapper.class);
if (wrapper == null) {
throw new JumblrException(response);
}
wrapper.setClient(client);
return wrapper;
} catch (JsonSyntaxException ex) {
throw new JumblrException(response);
}
} else {
throw new JumblrException(response);
}
}
示例2: parseXAuthResponse
import com.tumblr.jumblr.exceptions.JumblrException; //导入依赖的package包/类
private Token parseXAuthResponse(final Response response) {
String responseStr = response.getBody();
if (responseStr != null) {
// Response is received in the format "oauth_token=value&oauth_token_secret=value".
String extractedToken = null, extractedSecret = null;
final String[] values = responseStr.split("&");
for (String value : values) {
final String[] kvp = value.split("=");
if (kvp != null && kvp.length == 2) {
if (kvp[0].equals("oauth_token")) {
extractedToken = kvp[1];
} else if (kvp[0].equals("oauth_token_secret")) {
extractedSecret = kvp[1];
}
}
}
if (extractedToken != null && extractedSecret != null) {
return new Token(extractedToken, extractedSecret);
}
}
// No good
throw new JumblrException(response);
}
示例3: getRedirectUrl
import com.tumblr.jumblr.exceptions.JumblrException; //导入依赖的package包/类
public String getRedirectUrl(String path) {
OAuthRequest request = this.constructGet(path, null);
sign(request);
boolean presetVal = HttpURLConnection.getFollowRedirects();
HttpURLConnection.setFollowRedirects(false);
Response response = request.send();
HttpURLConnection.setFollowRedirects(presetVal);
if (response.getCode() == 301 || response.getCode() == 302) {
return response.getHeader("Location");
} else {
throw new JumblrException(response);
}
}
示例4: clearXAuth
import com.tumblr.jumblr.exceptions.JumblrException; //导入依赖的package包/类
Token clearXAuth(Response response) {
if (response.getCode() == 200 || response.getCode() == 201) {
return parseXAuthResponse(response);
} else {
throw new JumblrException(response);
}
}
示例5: testClearEmptyJson
import com.tumblr.jumblr.exceptions.JumblrException; //导入依赖的package包/类
@Test
public void testClearEmptyJson() {
Response r = mock(Response.class);
when(r.getCode()).thenReturn(200);
when(r.getBody()).thenReturn("");
thrown.expect(JumblrException.class);
ResponseWrapper got = rb.clear(r);
}
示例6: testXauthForbidden
import com.tumblr.jumblr.exceptions.JumblrException; //导入依赖的package包/类
@Test
public void testXauthForbidden() {
Response r = mock(Response.class);
when(r.getCode()).thenReturn(403);
when(r.getBody()).thenReturn("");
thrown.expect(JumblrException.class);
rb.clearXAuth(r);
}
示例7: testXauthBadResponseGoodCode
import com.tumblr.jumblr.exceptions.JumblrException; //导入依赖的package包/类
@Test
public void testXauthBadResponseGoodCode() {
Response r = mock(Response.class);
when(r.getCode()).thenReturn(200);
when(r.getBody()).thenReturn("");
thrown.expect(JumblrException.class);
rb.clearXAuth(r);
}
示例8: setup
import com.tumblr.jumblr.exceptions.JumblrException; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Before
public void setup() throws IOException {
builder = mock(RequestBuilder.class);
client = new JumblrClient("ck", "cs", "@", "@");
client.setRequestBuilder(builder);
when(builder.get(anyString(), anyMap())).thenThrow(JumblrException.class);
when(builder.post(anyString(), anyMap())).thenThrow(JumblrException.class);
when(builder.postMultipart(anyString(), anyMap())).thenThrow(JumblrException.class);
when(builder.getRedirectUrl(anyString())).thenThrow(JumblrException.class);
}
示例9: user
import com.tumblr.jumblr.exceptions.JumblrException; //导入依赖的package包/类
/**
* User methods
*/
@Test
public void user() {
thrown.expect(JumblrException.class);
client.user();
}
示例10: like
import com.tumblr.jumblr.exceptions.JumblrException; //导入依赖的package包/类
@Test
public void like() {
Long id = 42L;
String reblogKey = "hello";
thrown.expect(JumblrException.class);
client.like(id, reblogKey);
}
示例11: unlike
import com.tumblr.jumblr.exceptions.JumblrException; //导入依赖的package包/类
@Test
public void unlike() {
Long id = 42L;
String reblogKey = "hello";
thrown.expect(JumblrException.class);
client.unlike(id, reblogKey);
}
示例12: userAvatar
import com.tumblr.jumblr.exceptions.JumblrException; //导入依赖的package包/类
/**
* Blog methods
*/
@Test
public void userAvatar() {
thrown.expect(JumblrException.class);
client.blogAvatar("hey.com");
}
示例13: blogInfo
import com.tumblr.jumblr.exceptions.JumblrException; //导入依赖的package包/类
@Test
public void blogInfo() {
Map<String, String> map = new HashMap<String, String>();
map.put("api_key", "ck");
thrown.expect(JumblrException.class);
client.blogInfo("blog_name");
}
示例14: postDelete
import com.tumblr.jumblr.exceptions.JumblrException; //导入依赖的package包/类
/**
* Post methods
*/
@Test
public void postDelete() {
thrown.expect(JumblrException.class);
client.postDelete("hey.com", 42L);
}
示例15: tagged
import com.tumblr.jumblr.exceptions.JumblrException; //导入依赖的package包/类
/**
* Tagged methods
*/
@Test
public void tagged() {
String tag = "coolio";
thrown.expect(JumblrException.class);
client.tagged(tag);
}