Package com.comcast.cmb.common.persistence

Examples of com.comcast.cmb.common.persistence.UserCassandraPersistence


  @Test
  public void testCreateDeleteUser() {

    try {
      IUserPersistence persistence = new UserCassandraPersistence()
      User user = createUser(persistence, "vvenkatraman1234", "venu1234");
     
      persistence.deleteUser(user.getUserName());
      verifyUserCleanup((new ArrayList<User>(Arrays.asList(user))), persistence);
            logger.info("testCreateDeleteUser succeeded");

    } catch (Exception ex) {
            logger.error("test failed", ex);
View Full Code Here


  }
 
  @Test
  public void testGetAllUsers() {
    try {
      IUserPersistence persistence = new UserCassandraPersistence()
     
            List<User> users = new LinkedList<User>();
            User user = createUser(persistence, "vvenkatraman1234", "venu1234");
            users.add(user);
            user = createUser(persistence, "bcheng1234", "baosen1234");
            users.add(user);
      user = createUser(persistence, "mchiang1234", "mchiang1234");
            users.add(user);
     
      List<User> userList = persistence.getAllUsers();
      assertTrue(userList != null && userList.size() >= 3);
     
      for (User user1 : users) {
        persistence.deleteUser(user1.getUserName());
      }
     
      userList = persistence.getAllUsers();
      verifyUserCleanup(users, persistence);

            logger.info("testGetAllUsers succeeded");
     
View Full Code Here

  @Test
  public void testCreateAdmin(){
    try{
      String ADMIN_NAME = "cns_admin";
      String ADMIN_PASSWORD = "cns_admin";
      IUserPersistence persistence = new UserCassandraPersistence()
      User user = persistence.getUserByName(ADMIN_NAME);
      if (user != null) {
        persistence.deleteUser(ADMIN_NAME);
      }
      user = persistence.createUser(ADMIN_NAME, ADMIN_PASSWORD, true);
      assertAdmin(ADMIN_NAME, user);
      persistence.deleteUser(ADMIN_NAME);
    }catch(Exception ex){
      logger.error("test failed", ex);
      fail("Test failed: " + ex.toString());
    }
  }
View Full Code Here

    return false;
  }
 
  @Test
  public void testgetUserByIdNameAndKey() throws Exception {
    IUserPersistence persistence = new UserCassandraPersistence();     
    User user;
    try {
        List<User> users = new LinkedList<User>();
      user = createUser(persistence, "vvenkatraman1234", "venu1234");
      users.add(user);
      user = createUser(persistence, "bcheng1234", "boasen1234");
      users.add(user);
      String accessKey = user.getAccessKey();
      user = persistence.createUser("mchiang1234", "mchiang1234");
      users.add(user);
      String userId = user.getUserId();
     
      String userName = "vvenkatraman1234";
      user = persistence.getUserByName(userName);
      assertUser(userName, user);
     
      user = persistence.getUserById(userId);
      assertUser("mchiang1234", user);
      assertTrue(user.getUserId().equals(userId));
     
      user = persistence.getUserByAccessKey(accessKey);
      assertUser("bcheng1234", user);
      assertTrue(user.getAccessKey().equals(accessKey));
     
     
      for (User u : users) {
          persistence.deleteUser(u.getUserName());
      }
     
      verifyUserCleanup(users, persistence);

            logger.info("testgetUserByIdNameAndKey succeeded");
View Full Code Here

      Util.initLog4jTest();
        CMBControllerServlet.valueAccumulator.initializeAllCounters();
        PersistenceFactory.reset();

        IUserPersistence userHandler = new UserCassandraPersistence();
        user = userHandler.getUserByName("cqs_unit_test");

        if (user == null) {
            user =  userHandler.createUser("cqs_unit_test", "cqs_unit_test");
        }

    topicHandler = new CNSTopicCassandraPersistence();
    subscriptionHandler = new CNSSubscriptionCassandraPersistence();
    attributeHandler = new CNSAttributesCassandraPersistence();
View Full Code Here

     
        Util.initLog4jTest();
        CMBControllerServlet.valueAccumulator.initializeAllCounters();
        PersistenceFactory.reset();

        IUserPersistence userPersistence = new UserCassandraPersistence();
        user = userPersistence.getUserByName("cqs_unit_test");

        if (user == null) {
            user = userPersistence.createUser("cqs_unit_test", "cqs_unit_test");
        }
       
        ICQSQueuePersistence persistence = new CQSQueueCassandraPersistence();
   
    List<CQSQueue> queueList = persistence.listQueues(user.getUserId(), null, false);
View Full Code Here

        attributeParams.put("MessageRetentionPeriod", "6000"); // the number of seconds when a message is available in the system - 10 hours
        attributeParams.put("VisibilityTimeout", "60"); // the number of seconds a message is hidden from the next user - 1 min

        try {
          IUserPersistence userPersistence = new UserCassandraPersistence();
          user = userPersistence.getUserByName("cqs_stress_user");

          if (user == null) {
              user = userPersistence.createUser("cqs_stress_user", "cqs_stress_user");
          }

        } catch (Exception ex) {
            logger.error("Action=setup status=exception ", ex);
        }
View Full Code Here

   
        Util.initLog4jTest();
        CMBControllerServlet.valueAccumulator.initializeAllCounters();
        PersistenceFactory.reset();

        IUserPersistence userPersistence = new UserCassandraPersistence();
        User user = userPersistence.getUserByName("cqs_unit_test");

        if (user == null) {
            user = userPersistence.createUser("cqs_unit_test", "cqs_unit_test");
        }
       
      String queueName = QUEUE_PREFIX + randomGenerator.nextLong();
        String queueUrl = CMBProperties.getInstance().getCQSServiceUrl() + user.getUserId() + "/" + queueName;
View Full Code Here

      AWSCredentials awsCredentials = null;
      User user = null;
     
      if (useLocalSns) {
       
        IUserPersistence dao = new UserCassandraPersistence();
       
        try {
          user = dao.getUserByName(USER_NAME);
        } catch (Exception ex) {
          user =  dao.createUser(USER_NAME, USER_NAME);
        }
       
        if (user == null) {
          user =  dao.createUser(USER_NAME, USER_NAME);
        }
       
        awsCredentials = new BasicAWSCredentials(user.getAccessKey(), user.getAccessSecret());
     
      } else {
View Full Code Here

   
    @Before
    public void setUp() throws Exception {
        Util.initLog4jTest();

        IUserPersistence userHandler = new UserCassandraPersistence();
       
        User user = userHandler.getUserByName("cmb_unit_test");

        if (user == null) {
            user = userHandler.createUser("cmb_unit_test", "cmb_unit_test");
        }

        authModule = new UserAuthModule();
        authModule.setUserPersistence(userHandler);
        CMBControllerServlet.valueAccumulator.initializeAllCounters();
View Full Code Here

TOP

Related Classes of com.comcast.cmb.common.persistence.UserCassandraPersistence

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.