Package com.renren.api.client.services

Source Code of com.renren.api.client.services.BlogServiceTest

package com.renren.api.client.services;
import junit.framework.Assert;

import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.junit.Test;

import com.renren.api.client.AbstractServiceTest;
import com.renren.api.client.param.impl.AccessToken;
public class BlogServiceTest extends AbstractServiceTest{
   
    @Test
    public void testAddBlog(){
        String title="测试日志";
        String content="这是一篇测试的日志";
        int res=this.getRenrenApiClient().getBlogService().addBlog(title, content,new AccessToken(this.getAccessToken()));
        System.out.println(res);
        Assert.assertTrue(res>0);
    }
   
    @Test
    public void testGetBlog(){
        long blogid=790501086L;
        long uid=432801017L;
        int comment=0;
        String password="";
       
        JSONObject json=this.getRenrenApiClient().getBlogService().getBlog(uid, blogid, comment, password, BlogService.BLOG_FOR_USER,new AccessToken(this.getAccessToken()));
        long id=(Long) json.get("id");
        Assert.assertEquals(blogid, id);
    }
   
    @Test
    public void testGetBlogs(){
        long uid=432801017L;
        int page=1;
        int count=1;
        JSONObject blogs=this.getRenrenApiClient().getBlogService().getBlogs(uid, page, count, BlogService.BLOG_FOR_USER,new AccessToken(this.getAccessToken()));
        long user_id=Long.parseLong((String) blogs.get("uid"));
        Assert.assertEquals(user_id, uid);
    }
   
    @Test
    public void testAddComments(){
        long id=790501086L;
        long uid=432801017L;
        String content="测试评论";
        long rid=0;
        int type=0;
        int res=this.getRenrenApiClient().getBlogService().addComment(id, uid, content, rid, type, BlogService.BLOG_FOR_USER,new AccessToken(this.getAccessToken()));
        Assert.assertEquals(1, res);
    }
   
    @Test
    public void testGetComments(){
        long id=790501086L;
        long uid=432801017L;
        int page=1;
        int count=1;
        JSONArray comments=this.getRenrenApiClient().getBlogService().getComments(uid, id, page, count,0, BlogService.BLOG_FOR_USER,new AccessToken(this.getAccessToken()));
        System.out.println(comments.get(0));
        Assert.assertEquals(1, comments.size());
    }
   
}
TOP

Related Classes of com.renren.api.client.services.BlogServiceTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.