Package com.comcast.cqs.persistence

Examples of com.comcast.cqs.persistence.ICQSQueuePersistence


        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);
   
    for (CQSQueue queue: queueList) {
      persistence.deleteQueue(queue.getRelativeUrl());
    }
    }
View Full Code Here


    try {
     
      String region = CMBProperties.getInstance().getRegion();
     
      ICQSQueuePersistence persistence = new CQSQueueCassandraPersistence();
      deleteQueuesTest();
     
      List<CQSQueue> queueList = persistence.listQueues(user.getUserId(), null, false);
      assertEquals(queueList.size(), 0);

        String queueName = QUEUE_PREFIX + randomGenerator.nextLong();
     
      CQSQueue queue = new CQSQueue(queueName, user.getUserId());
      persistence.createQueue(queue);
     
      queueName = QUEUE_PREFIX + randomGenerator.nextLong();
      queue = new CQSQueue(queueName, user.getUserId());
      persistence.createQueue(queue);

      queueName = QUEUE_PREFIX + randomGenerator.nextLong();
      queue = new CQSQueue(queueName, user.getUserId());

      persistence.createQueue(queue);
     
      queue = persistence.getQueue(user.getUserId(), queueName);
      assertQueue(region, queue);

      assertTrue(queue.getName().equals(queueName));
     
      queueList = persistence.listQueues(user.getUserId(), QUEUE_PREFIX, false);
      assertEquals(queueList.size(), 3);

      for (CQSQueue queue1 : queueList) {
        assertQueue(region, queue1);
      }
     
      assertEquals(queueList.size(), 3);
     
      for (CQSQueue queue1 : queueList) {
        assertQueue(region, queue1);
        persistence.deleteQueue(queue1.getRelativeUrl());
      }           

      queueList = persistence.listQueues(user.getUserId(), null, false);
      assertEquals(queueList.size(), 0);
         
    } catch (Exception ex) {
     
      logger.error("test failed", ex);
View Full Code Here

    assertTrue(queue.getVisibilityTO() > 0);
  }
 
  public void deleteQueuesTest() {
   
    ICQSQueuePersistence persistence = new CQSQueueCassandraPersistence();
    List<CQSQueue> queueList;
   
    try {
     
      queueList = persistence.listQueues(user.getUserId(), null, false);
     
      for (CQSQueue queue1 : queueList) {
        persistence.deleteQueue(queue1.getRelativeUrl());
      }       
     
    } catch (PersistenceException ex) {
            logger.error("test failed", ex);
      fail("Test failed: " + ex.toString());
View Full Code Here

  }
 
  @Test
  public void updatePolicyTest() {
   
    ICQSQueuePersistence persistence = new CQSQueueCassandraPersistence();
    String policy = "{\n" +
          "\"Version\": \"2008-10-17\",\n" +
          "\"Id\": \"arn:aws:cqs:us-west-1:544265793414:MyTestQueue1/CQSDefaultPolicy\",\n" +
          "\"Statement\": [\n" +
            "{\n" +
              "\"Sid\": \"Sid1331673493955\",\n" +
              "\"Effect\": \"Allow\",\n" +
              "\"Principal\": {\n" +
                "\"AWS\": \"*\"\n" +
              "},\n" +
              "\"Action\": [\n" +
                "\"CQS:ReceiveMessage\",\n" +
                "\"CQS:SendMessage\"\n" +
              "],\n" +
              "\"Resource\": \"arn:aws:cqs:us-west-1:544265793414:MyTestQueue1\"\n" +
            "}\n" +
          "]\n" +
        "}";
   
    try {
     
        String queueName1 = QUEUE_PREFIX + randomGenerator.nextLong();
      CQSQueue queue1 = new CQSQueue(queueName1, user.getUserId());
      queue1.setPolicy(policy);
      persistence.createQueue(queue1);
     
        String queueName2 = QUEUE_PREFIX + randomGenerator.nextLong();
      CQSQueue queue2 = new CQSQueue(queueName2, user.getUserId());
      persistence.createQueue(queue2);
      persistence.updatePolicy(queue2.getRelativeUrl(), policy);
     
      for (CQSQueue e: persistence.listQueues(user.getUserId(), QUEUE_PREFIX, false)) {
        CQSQueue q = persistence.getQueue(e.getRelativeUrl());
        assertTrue(policy.equals(q.getPolicy()));
        persistence.deleteQueue(e.getRelativeUrl());
      }
     
    } catch (PersistenceException e) {
      fail("Test failed:" +  e.toString());
    }   
View Full Code Here

    try {
     
      String userId = user.getUserId();
     
      ICQSQueuePersistence persistence = new CQSQueueCassandraPersistence();
      //deleteQueuesTest();
     
      List<CQSQueue> queueList = persistence.listQueues(userId, null, false);
      assertEquals(queueList.size(), 0);

        String queueName = QUEUE_PREFIX + randomGenerator.nextLong();
      CQSQueue queue = new CQSQueue(queueName, userId);
      persistence.createQueue(queue);
     
      queueList = persistence.listQueues(userId, null, false);
      assertEquals(queueList.size(), 1);
     
      String queueURL = queue.getRelativeUrl();
      String key = CQSConstants.COL_VISIBILITY_TO;
      String value = "5";
      String key2 = CQSConstants.COL_MSG_RETENTION_PERIOD;
      String value2 = "30";
      String key3 = CQSConstants.COL_MAX_MSG_SIZE;
      String value3 = "4002";
      String key4 = CQSConstants.COL_DELAY_SECONDS;
      String value4 = "26";
      String key5 = CQSConstants.COL_POLICY;
      String value5 = "no";

      HashMap<String, String> values = new HashMap<String, String>();
      values.put(key, value);
      values.put(key2, value2);
      values.put(key3, value3);
      values.put(key4, value4);
      values.put(key5, value5);
      persistence.updateQueueAttribute(queueURL, values);
      queueName = queue.getName();
      CQSQueue queue2 = persistence.getQueue(userId, queueName);
      assertTrue(queue2.getVisibilityTO() == 5);
      assertTrue(queue2.getMsgRetentionPeriod() == 30);
      assertTrue(queue2.getMaxMsgSize() == 4002);
      assertTrue(queue2.getDelaySeconds() == 26);
      assertTrue(queue2.getPolicy().equals("no"));
     
      key3 = CQSConstants.COL_MAX_MSG_SIZE;
      value3 = "4150";
      key4 = CQSConstants.COL_DELAY_SECONDS;
      value4 = "20";
     
      HashMap<String, String> values2 = new HashMap<String, String>();
      values2.put(key3, value3);
      values2.put(key4, value4);
      persistence.updateQueueAttribute(queueURL, values2);
     
      CQSQueue queue3 = persistence.getQueue(userId, queueName);
      assertTrue(queue3.getVisibilityTO() == 5);
      assertTrue(queue3.getMsgRetentionPeriod() == 30);
      assertTrue(queue3.getMaxMsgSize() == 4150);
      assertTrue(queue3.getDelaySeconds() == 20);
      assertTrue(queue3.getPolicy().equals("no"));
     
      key = CQSConstants.COL_VISIBILITY_TO;
      value = "8";
      key2 = CQSConstants.COL_MSG_RETENTION_PERIOD;
      value2 = "32";

      HashMap<String, String> values3 = new HashMap<String, String>();
      values3.put(key, value);
      values3.put(key2, value2);
      persistence.updateQueueAttribute(queueURL, values3);
     
      CQSQueue queue4 = persistence.getQueue(userId, queueName);
      assertTrue(queue4.getVisibilityTO() == 8);
      assertTrue(queue4.getMsgRetentionPeriod() == 32);
      assertTrue(queue4.getMaxMsgSize() == 4150);
      assertTrue(queue4.getDelaySeconds() == 20);
      assertTrue(queue4.getPolicy().equals("no"));
     
      queueList = persistence.listQueues(user.getUserId(), null, false);
     
      for(CQSQueue queue_: queueList) {
        persistence.deleteQueue(queue_.getRelativeUrl());
      }
     
    } catch (PersistenceException e) {
      fail("Test failed:" +  e.toString());
    }   
View Full Code Here

TOP

Related Classes of com.comcast.cqs.persistence.ICQSQueuePersistence

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.