コード例 #1
0
 static FieldTable getHeaders(String... entries) {
   FieldTable headers = FieldTableFactory.newFieldTable();
   for (String s : entries) {
     String[] parts = s.split("=", 2);
     headers.setObject(parts[0], parts.length > 1 ? parts[1] : "");
   }
   return headers;
 }
コード例 #2
0
  private FieldTable load() throws IOException {
    FieldTable result = FieldTableFactory.newFieldTable();
    result.setLong("one", 1L);
    result.setLong("two", 2L);
    result.setLong("three", 3L);
    result.setLong("four", 4L);
    result.setLong("five", 5L);

    return result;
  }
コード例 #3
0
 void check() throws JMSException, AMQFrameDecodingException {
   for (Object m : received) {
     ByteBuffer buffer = ((JMSBytesMessage) m).getData();
     FieldTable actual = FieldTableFactory.newFieldTable(buffer, buffer.remaining());
     for (String key : _expected.keys()) {
       assertEquals(
           "Values for " + key + " did not match",
           _expected.getObject(key),
           actual.getObject(key));
     }
   }
 }
コード例 #4
0
  public void testBindQueue() throws Exception {
    AMQQueue queue = createTestQueue(QUEUE_NAME, "queueOwner", false);
    Binding binding =
        new Binding(
            UUIDGenerator.generateRandomUUID(),
            ROUTING_KEY,
            queue,
            _exchange,
            FieldTable.convertToMap(_bindingArgs));
    _store.bindQueue(binding);

    reopenStore();

    ByteBuffer argsAsBytes = ByteBuffer.wrap(_bindingArgs.getDataAsBytes());

    verify(_bindingRecoveryHandler)
        .binding(binding.getId(), _exchange.getId(), queue.getId(), ROUTING_KEY, argsAsBytes);
  }
コード例 #5
0
 void send(int count) throws JMSException, IOException {
   // create a publisher
   MessageProducer producer = _session.createProducer(_destination);
   for (int i = 0; i < count; i++) {
     BytesMessage msg = _session.createBytesMessage();
     msg.writeBytes(_expected.getDataAsBytes());
     producer.send(msg);
   }
 }
コード例 #6
0
  public void testCreateQueueAMQQueueFieldTable() throws Exception {
    AMQQueue queue = createTestQueue(getName(), getName() + "Owner", true);
    Map<String, Object> attributes = new HashMap<String, Object>();
    attributes.put("x-qpid-dlq-enabled", Boolean.TRUE);
    attributes.put("x-qpid-maximum-delivery-count", new Integer(10));

    FieldTable arguments = FieldTable.convertToFieldTable(attributes);
    _store.createQueue(queue, arguments);

    reopenStore();
    verify(_queueRecoveryHandler)
        .queue(_queueId, getName(), getName() + "Owner", true, arguments, null);
  }
コード例 #7
0
  public void testUnbindQueue() throws Exception {
    AMQQueue queue = createTestQueue(QUEUE_NAME, "queueOwner", false);
    Binding binding =
        new Binding(
            UUIDGenerator.generateRandomUUID(),
            ROUTING_KEY,
            queue,
            _exchange,
            FieldTable.convertToMap(_bindingArgs));
    _store.bindQueue(binding);

    _store.unbindQueue(binding);
    reopenStore();

    verify(_bindingRecoveryHandler, never())
        .binding(
            any(UUID.class), any(UUID.class), any(UUID.class), anyString(), isA(ByteBuffer.class));
  }
コード例 #8
0
  public void testUpdateQueueAlternateExchange() throws Exception {
    // create queue
    AMQQueue queue = createTestQueue(getName(), getName() + "Owner", true);
    Map<String, Object> attributes = new HashMap<String, Object>();
    attributes.put("x-qpid-dlq-enabled", Boolean.TRUE);
    attributes.put("x-qpid-maximum-delivery-count", new Integer(10));
    FieldTable arguments = FieldTable.convertToFieldTable(attributes);
    _store.createQueue(queue, arguments);

    // update the queue to have exclusive=false
    Exchange alternateExchange = createTestAlternateExchange();
    queue = createTestQueue(getName(), getName() + "Owner", false, alternateExchange);
    _store.updateQueue(queue);

    reopenStore();
    verify(_queueRecoveryHandler)
        .queue(
            _queueId, getName(), getName() + "Owner", false, arguments, alternateExchange.getId());
  }
コード例 #9
0
  public void setUp() throws Exception {
    super.setUp();

    _queueId = UUIDGenerator.generateRandomUUID();
    _exchangeId = UUIDGenerator.generateRandomUUID();

    _storeName = getName();
    _storePath = TMP_FOLDER + File.separator + _storeName;
    FileUtils.delete(new File(_storePath), true);
    setTestSystemProperty("QPID_WORK", TMP_FOLDER);
    _configuration = mock(Configuration.class);
    _recoveryHandler = mock(ConfigurationRecoveryHandler.class);
    _queueRecoveryHandler = mock(QueueRecoveryHandler.class);
    _exchangeRecoveryHandler = mock(ExchangeRecoveryHandler.class);
    _bindingRecoveryHandler = mock(BindingRecoveryHandler.class);
    _storedMessageRecoveryHandler = mock(StoredMessageRecoveryHandler.class);
    _logRecoveryHandler = mock(TransactionLogRecoveryHandler.class);
    _messageStoreRecoveryHandler = mock(MessageStoreRecoveryHandler.class);
    _queueEntryRecoveryHandler =
        mock(TransactionLogRecoveryHandler.QueueEntryRecoveryHandler.class);
    _dtxRecordRecoveryHandler = mock(TransactionLogRecoveryHandler.DtxRecordRecoveryHandler.class);

    when(_messageStoreRecoveryHandler.begin()).thenReturn(_storedMessageRecoveryHandler);
    when(_recoveryHandler.begin(isA(MessageStore.class))).thenReturn(_exchangeRecoveryHandler);
    when(_exchangeRecoveryHandler.completeExchangeRecovery()).thenReturn(_queueRecoveryHandler);
    when(_queueRecoveryHandler.completeQueueRecovery()).thenReturn(_bindingRecoveryHandler);
    when(_logRecoveryHandler.begin(any(MessageStore.class))).thenReturn(_queueEntryRecoveryHandler);
    when(_queueEntryRecoveryHandler.completeQueueEntryRecovery())
        .thenReturn(_dtxRecordRecoveryHandler);
    when(_exchange.getNameShortString()).thenReturn(AMQShortString.valueOf(EXCHANGE_NAME));
    when(_exchange.getId()).thenReturn(_exchangeId);
    when(_configuration.getString(eq(MessageStoreConstants.ENVIRONMENT_PATH_PROPERTY), anyString()))
        .thenReturn(_storePath);

    _bindingArgs = new FieldTable();
    AMQShortString argKey = AMQPFilterTypes.JMS_SELECTOR.getValue();
    String argValue = "some selector expression";
    _bindingArgs.put(argKey, argValue);

    reopenStore();
  }
コード例 #10
0
  public void testRemoveQueue() throws Exception {
    // create queue
    AMQQueue queue = createTestQueue(getName(), getName() + "Owner", true);
    Map<String, Object> attributes = new HashMap<String, Object>();
    attributes.put("x-qpid-dlq-enabled", Boolean.TRUE);
    attributes.put("x-qpid-maximum-delivery-count", new Integer(10));
    FieldTable arguments = FieldTable.convertToFieldTable(attributes);
    _store.createQueue(queue, arguments);

    // remove queue
    _store.removeQueue(queue);
    reopenStore();
    verify(_queueRecoveryHandler, never())
        .queue(
            any(UUID.class),
            anyString(),
            anyString(),
            anyBoolean(),
            any(FieldTable.class),
            any(UUID.class));
  }