當前位置: 首頁>>代碼示例>>Java>>正文


Java JumblrException類代碼示例

本文整理匯總了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);
    }
}
 
開發者ID:tumblr,項目名稱:jumblr,代碼行數:21,代碼來源:RequestBuilder.java

示例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);
}
 
開發者ID:tumblr,項目名稱:jumblr,代碼行數:24,代碼來源:RequestBuilder.java

示例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);
    }
}
 
開發者ID:tumblr,項目名稱:jumblr,代碼行數:14,代碼來源:RequestBuilder.java

示例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);
    }
}
 
開發者ID:tumblr,項目名稱:jumblr,代碼行數:8,代碼來源:RequestBuilder.java

示例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);
}
 
開發者ID:tumblr,項目名稱:jumblr,代碼行數:10,代碼來源:RequestBuilderTest.java

示例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);
}
 
開發者ID:tumblr,項目名稱:jumblr,代碼行數:10,代碼來源:RequestBuilderTest.java

示例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);
}
 
開發者ID:tumblr,項目名稱:jumblr,代碼行數:10,代碼來源:RequestBuilderTest.java

示例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);
}
 
開發者ID:tumblr,項目名稱:jumblr,代碼行數:12,代碼來源:JumblrClientErrorTest.java

示例9: user

import com.tumblr.jumblr.exceptions.JumblrException; //導入依賴的package包/類
/**
 * User methods
 */

@Test
public void user() {
    thrown.expect(JumblrException.class);
    client.user();
}
 
開發者ID:tumblr,項目名稱:jumblr,代碼行數:10,代碼來源:JumblrClientErrorTest.java

示例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);
}
 
開發者ID:tumblr,項目名稱:jumblr,代碼行數:9,代碼來源:JumblrClientErrorTest.java

示例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);
}
 
開發者ID:tumblr,項目名稱:jumblr,代碼行數:9,代碼來源:JumblrClientErrorTest.java

示例12: userAvatar

import com.tumblr.jumblr.exceptions.JumblrException; //導入依賴的package包/類
/**
 * Blog methods
 */

@Test
public void userAvatar() {
    thrown.expect(JumblrException.class);
    client.blogAvatar("hey.com");
}
 
開發者ID:tumblr,項目名稱:jumblr,代碼行數:10,代碼來源:JumblrClientErrorTest.java

示例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");
}
 
開發者ID:tumblr,項目名稱:jumblr,代碼行數:9,代碼來源:JumblrClientErrorTest.java

示例14: postDelete

import com.tumblr.jumblr.exceptions.JumblrException; //導入依賴的package包/類
/**
 * Post methods
 */

@Test
public void postDelete() {
    thrown.expect(JumblrException.class);
    client.postDelete("hey.com", 42L);
}
 
開發者ID:tumblr,項目名稱:jumblr,代碼行數:10,代碼來源:JumblrClientErrorTest.java

示例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);
}
 
開發者ID:tumblr,項目名稱:jumblr,代碼行數:12,代碼來源:JumblrClientErrorTest.java


注:本文中的com.tumblr.jumblr.exceptions.JumblrException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。