use of com.microsoft.azure.storage.queue.CloudQueue in project components by Talend.
the class AzureStorageQueueService method retrieveMessages.
public Iterable<CloudQueueMessage> retrieveMessages(String queueName, int numberOfMessages) throws InvalidKeyException, URISyntaxException, StorageException {
CloudQueueClient client = connection.getCloudStorageAccount().createCloudQueueClient();
CloudQueue queueRef = client.getQueueReference(queueName);
return queueRef.retrieveMessages(numberOfMessages);
}
use of com.microsoft.azure.storage.queue.CloudQueue in project components by Talend.
the class AzureStorageQueueService method deleteQueueIfExists.
public boolean deleteQueueIfExists(String queueName) throws InvalidKeyException, URISyntaxException, StorageException {
CloudQueueClient client = connection.getCloudStorageAccount().createCloudQueueClient();
CloudQueue queueRef = client.getQueueReference(queueName);
return queueRef.deleteIfExists();
}
use of com.microsoft.azure.storage.queue.CloudQueue in project components by Talend.
the class AzureStorageQueueListReaderTest method testAdvanceAsNonAdvancable.
@Test
public void testAdvanceAsNonAdvancable() {
AzureStorageQueueSource source = new AzureStorageQueueSource();
ValidationResult vr = source.initialize(getDummyRuntimeContiner(), properties);
assertNotNull(vr);
assertEquals(ValidationResult.OK.getStatus(), vr.getStatus());
reader = (AzureStorageQueueListReader) source.createReader(getDummyRuntimeContiner());
reader.queueService = queueService;
final List<CloudQueue> list = new ArrayList<>();
try {
list.add(new CloudQueue(new URI("https://storagesample.queue.core.windows.net/queue-1"), dummyCredential));
when(queueService.listQueues()).thenReturn(new Iterable<CloudQueue>() {
@Override
public Iterator<CloudQueue> iterator() {
return new DummyCloudQueueIterator(list);
}
});
assertTrue(reader.start());
assertFalse(reader.advance());
} catch (InvalidKeyException | URISyntaxException | StorageException | IOException e) {
fail("should not throw " + e.getMessage());
}
}
use of com.microsoft.azure.storage.queue.CloudQueue in project components by Talend.
the class AzureStorageQueueListReaderTest method testGetCurrent.
@Test
public void testGetCurrent() {
AzureStorageQueueSource source = new AzureStorageQueueSource();
ValidationResult vr = source.initialize(getDummyRuntimeContiner(), properties);
assertNotNull(vr);
assertEquals(ValidationResult.OK.getStatus(), vr.getStatus());
reader = (AzureStorageQueueListReader) source.createReader(getDummyRuntimeContiner());
reader.queueService = queueService;
final List<CloudQueue> list = new ArrayList<>();
try {
list.add(new CloudQueue(new URI("https://storagesample.queue.core.windows.net/queue-1"), dummyCredential));
when(queueService.listQueues()).thenReturn(new Iterable<CloudQueue>() {
@Override
public Iterator<CloudQueue> iterator() {
return new DummyCloudQueueIterator(list);
}
});
assertTrue(reader.start());
IndexedRecord current = reader.getCurrent();
assertNotNull(current);
assertEquals("queue-1", current.get(0));
} catch (InvalidKeyException | URISyntaxException | StorageException | IOException e) {
fail("should not throw " + e.getMessage());
}
}
use of com.microsoft.azure.storage.queue.CloudQueue in project components by Talend.
the class AzureStorageQueueListReaderTest method testGetReturnValues.
@Test
public void testGetReturnValues() {
AzureStorageQueueSource source = new AzureStorageQueueSource();
ValidationResult vr = source.initialize(getDummyRuntimeContiner(), properties);
assertNotNull(vr);
assertEquals(ValidationResult.OK.getStatus(), vr.getStatus());
reader = (AzureStorageQueueListReader) source.createReader(getDummyRuntimeContiner());
reader.queueService = queueService;
final List<CloudQueue> list = new ArrayList<>();
try {
list.add(new CloudQueue(new URI("https://storagesample.queue.core.windows.net/queue-1"), dummyCredential));
list.add(new CloudQueue(new URI("https://storagesample.queue.core.windows.net/queue-2"), dummyCredential));
list.add(new CloudQueue(new URI("https://storagesample.queue.core.windows.net/queue-3"), dummyCredential));
when(queueService.listQueues()).thenReturn(new Iterable<CloudQueue>() {
@Override
public Iterator<CloudQueue> iterator() {
return new DummyCloudQueueIterator(list);
}
});
assertTrue(reader.start());
while (reader.advance()) {
// read all records
}
Map<String, Object> returnedValues = reader.getReturnValues();
assertNotNull(returnedValues);
assertEquals(3, returnedValues.get(TAzureStorageQueueListDefinition.RETURN_NB_QUEUE));
} catch (InvalidKeyException | URISyntaxException | StorageException | IOException e) {
fail("should not throw " + e.getMessage());
}
}
Aggregations