Package org.apache.hadoop.chukwa.rest.bean

Examples of org.apache.hadoop.chukwa.rest.bean.UserBean


import com.sun.jersey.api.client.Client;

public class TestUserResource extends SetupTestEnv {
  public void testUserSave() {
    try {
    UserBean user = new UserBean();
    user.setId("admin");
    user.setProperty("testKey", "testValue");
    JSONArray ja = new JSONArray();
    user.setViews(ja);
    client = Client.create();
    resource = client.resource("http://localhost:"+restPort);
    ReturnCodeBean result = resource.path("/hicc/v1/user").
    header("Content-Type","application/json").
    header("Authorization", authorization).
View Full Code Here


  }
 
  public void testUserLoad() {
    client = Client.create();
    resource = client.resource("http://localhost:"+restPort);
    UserBean user = resource.path("/hicc/v1/user/uid/admin").header("Authorization", authorization).get(UserBean.class);
    try {
      assertEquals("admin", user.getId());
      assertEquals("testValue", user.getPropertyValue("testKey"));
    } catch (Exception e) {
      fail(ExceptionUtil.getStackTrace(e));
    }
  }
View Full Code Here

          FSDataInputStream profileStream = fs.open(fstatus[i].getPath());
          byte[] buffer = new byte[(int)size];
          profileStream.readFully(buffer);
          profileStream.close();
          try {
            UserBean user = new UserBean((JSONObject) JSONValue.parse(new String(buffer)));
            list.add(user.getId());
          } catch (Exception e) {
            log.error(ExceptionUtil.getStackTrace(e));
          }
        }
      }
View Full Code Here

 
  @GET
  @Path("uid/{uid}")
  public UserBean getProfile(@PathParam("uid") String uid) {
    UserStore user;
    UserBean result;
    try {
      user = new UserStore(uid);
      result = user.get();
    } catch (Exception e) {
      log.error(ExceptionUtil.getStackTrace(e));
View Full Code Here

        byte[] buffer = new byte[(int)size];
        viewStream.readFully(buffer);
        viewStream.close();
        try {
          JSONObject json = (JSONObject) JSONValue.parse(new String(buffer));
          profile = new UserBean(json);
        } catch (Exception e) {
          log.error(ExceptionUtil.getStackTrace(e));
          throw new IllegalAccessException("Unable to access user profile database.");
        }
      } else {
        profile = new UserBean();
        profile.setId(uid);
        JSONArray ja = new JSONArray();
        profile.setViews(ja);
        JSONObject json = new JSONObject();
        profile.setProperties(json.toString());
View Full Code Here

        byte[] buffer = new byte[(int)size];
        viewStream.readFully(buffer);
        viewStream.close();
        try {
          JSONObject json = new JSONObject(new String(buffer));
          profile = new UserBean(json);
        } catch (Exception e) {
          log.error(ExceptionUtil.getStackTrace(e));
          throw new IllegalAccessException("Unable to access user profile database.");
        }
      } else {
        profile = new UserBean();
        profile.setId(uid);
        JSONArray ja = new JSONArray();
        profile.setViews(ja);
        JSONObject json = new JSONObject();
        profile.setProperties(json.toString());
View Full Code Here

          FSDataInputStream profileStream = fs.open(fstatus[i].getPath());
          byte[] buffer = new byte[(int)size];
          profileStream.readFully(buffer);
          profileStream.close();
          try {
            UserBean user = new UserBean(new JSONObject(new String(buffer)));
            list.put(user.getId());
          } catch (Exception e) {
            log.error(ExceptionUtil.getStackTrace(e));
          }
        }
      }
View Full Code Here

 
  @GET
  @Path("uid/{uid}")
  public UserBean getProfile(@PathParam("uid") String uid) {
    UserStore user;
    UserBean result;
    try {
      user = new UserStore(uid);
      result = user.get();
    } catch (Exception e) {
      log.error(ExceptionUtil.getStackTrace(e));
View Full Code Here

import com.sun.jersey.api.client.Client;

public class TestUserResource extends SetupTestEnv {
  public void testUserSave() {
    try {
    UserBean user = new UserBean();
    user.setId("admin");
    user.setProperty("testKey", "testValue");
    JSONArray ja = new JSONArray();
    user.setViews(ja);
    client = Client.create();
    resource = client.resource("http://localhost:"+restPort);
    ReturnCodeBean result = resource.path("/hicc/v1/user").
    header("Content-Type","application/json").
    header("Authorization", authorization).
View Full Code Here

  }
 
  public void testUserLoad() {
    client = Client.create();
    resource = client.resource("http://localhost:"+restPort);
    UserBean user = resource.path("/hicc/v1/user/uid/admin").header("Authorization", authorization).get(UserBean.class);
    try {
      assertEquals("admin", user.getId());
      assertEquals("testValue", user.getPropertyValue("testKey"));
    } catch (Exception e) {
      fail(ExceptionUtil.getStackTrace(e));
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.chukwa.rest.bean.UserBean

Copyright © 2018 www.massapicom. 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.