Package com.microsoft.windowsazure.services.servicebus.models

Examples of com.microsoft.windowsazure.services.servicebus.models.BrokeredMessage


    @Test
    public void peekLockedMessageCanBeCompleted() throws Exception {
        // Arrange
        String queueName = "TestPeekLockedMessageCanBeCompleted";
        service.createQueue(new QueueInfo(queueName));
        service.sendQueueMessage(queueName, new BrokeredMessage("Hello Again"));
        BrokeredMessage message = service.receiveQueueMessage(queueName,
                PEEK_LOCK_5_SECONDS).getValue();

        // Act
        String lockToken = message.getLockToken();
        Date lockedUntil = message.getLockedUntilUtc();
        String lockLocation = message.getLockLocation();

        service.deleteMessage(message);

        // Assert
        assertNotNull(lockToken);
View Full Code Here


    @Test
    public void peekLockedMessageCanBeUnlocked() throws Exception {
        // Arrange
        String queueName = "TestPeekLockedMessageCanBeUnlocked";
        service.createQueue(new QueueInfo(queueName));
        service.sendQueueMessage(queueName, new BrokeredMessage("Hello Again"));
        BrokeredMessage peekedMessage = service.receiveQueueMessage(queueName,
                PEEK_LOCK_5_SECONDS).getValue();

        // Act
        String lockToken = peekedMessage.getLockToken();
        Date lockedUntil = peekedMessage.getLockedUntilUtc();

        service.unlockMessage(peekedMessage);
        BrokeredMessage receivedMessage = service.receiveQueueMessage(
                queueName, RECEIVE_AND_DELETE_5_SECONDS).getValue();

        // Assert
        assertNotNull(lockToken);
        assertNotNull(lockedUntil);
        assertNull(receivedMessage.getLockToken());
        assertNull(receivedMessage.getLockedUntilUtc());
    }
View Full Code Here

    @Test
    public void peekLockedMessageCanBeDeleted() throws Exception {
        // Arrange
        String queueName = "TestPeekLockedMessageCanBeDeleted";
        service.createQueue(new QueueInfo(queueName));
        service.sendQueueMessage(queueName, new BrokeredMessage("Hello Again"));
        BrokeredMessage peekedMessage = service.receiveQueueMessage(queueName,
                PEEK_LOCK_5_SECONDS).getValue();

        // Act
        String lockToken = peekedMessage.getLockToken();
        Date lockedUntil = peekedMessage.getLockedUntilUtc();

        service.deleteMessage(peekedMessage);
        BrokeredMessage receivedMessage = service.receiveQueueMessage(
                queueName, RECEIVE_AND_DELETE_5_SECONDS).getValue();

        // Assert
        assertNotNull(lockToken);
        assertNotNull(lockedUntil);
View Full Code Here

        // Arrange
        String queueName = "testEmptyQueueReturnsNullMessage";
        service.createQueue(new QueueInfo(queueName));

        // Act
        BrokeredMessage brokeredMessage = service.receiveQueueMessage(
                queueName, PEEK_LOCK_5_SECONDS).getValue();

        // Assert
        assertNull(brokeredMessage);
    }
View Full Code Here

        // Arrange
        String queueName = "TestContentTypePassesThrough";
        service.createQueue(new QueueInfo(queueName));

        // Act
        service.sendQueueMessage(queueName, new BrokeredMessage(
                "<data>Hello Again</data>").setContentType("text/xml"));

        BrokeredMessage message = service.receiveQueueMessage(queueName,
                RECEIVE_AND_DELETE_5_SECONDS).getValue();

        // Assert
        assertNotNull(message);
        assertEquals("text/xml", message.getContentType());
    }
View Full Code Here

    public void subscriptionWillReceiveMessage() throws Exception {
        // Arrange
        String topicName = "TestSubscriptionWillReceiveMessage";
        service.createTopic(new TopicInfo(topicName));
        service.createSubscription(topicName, new SubscriptionInfo("sub"));
        service.sendTopicMessage(topicName, new BrokeredMessage(
                "<p>Testing subscription</p>").setContentType("text/html"));

        // Act
        BrokeredMessage message = service.receiveSubscriptionMessage(topicName,
                "sub", RECEIVE_AND_DELETE_5_SECONDS).getValue();

        // Assert
        assertNotNull(message);

        byte[] data = new byte[100];
        int size = message.getBody().read(data);
        assertEquals("<p>Testing subscription</p>", new String(data, 0, size));
        assertEquals("text/html", message.getContentType());
    }
View Full Code Here

        // Arrange
        String queueName = "TestMessagesMayHaveCustomProperties";
        service.createQueue(new QueueInfo(queueName));

        // Act
        service.sendQueueMessage(queueName, new BrokeredMessage("")
                .setProperty("hello", "world").setProperty("foo", 42));
        BrokeredMessage message = service.receiveQueueMessage(queueName,
                RECEIVE_AND_DELETE_5_SECONDS).getValue();

        // Assert
        assertEquals("world", message.getProperty("hello"));
        assertEquals(42, message.getProperty("foo"));
    }
View Full Code Here

TOP

Related Classes of com.microsoft.windowsazure.services.servicebus.models.BrokeredMessage

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.