Search in sources :

Example 1 with TAzureStorageQueueListProperties

use of org.talend.components.azurestorage.queue.tazurestoragequeuelist.TAzureStorageQueueListProperties in project components by Talend.

the class AzureStorageQueueSourceOrSinkTest method setUp.

@Before
public void setUp() throws Exception {
    sos = new AzureStorageQueueSourceOrSink();
    props = new TAzureStorageQueueListProperties("tests");
    props.setupProperties();
    queueInputProperties = new TAzureStorageQueueInputProperties("test");
    queueInputProperties.setupProperties();
    queueInputProperties.connection.accountName.setValue("fakeAccountName");
    queueInputProperties.connection.accountKey.setValue("fakeAccountKey=ANBHFYRJJFHRIKKJFU");
    runtimeContainer = new RuntimeContainerMock();
}
Also used : TAzureStorageQueueListProperties(org.talend.components.azurestorage.queue.tazurestoragequeuelist.TAzureStorageQueueListProperties) TAzureStorageQueueInputProperties(org.talend.components.azurestorage.queue.tazurestoragequeueinput.TAzureStorageQueueInputProperties) RuntimeContainerMock(org.talend.components.azurestorage.RuntimeContainerMock) Before(org.junit.Before)

Example 2 with TAzureStorageQueueListProperties

use of org.talend.components.azurestorage.queue.tazurestoragequeuelist.TAzureStorageQueueListProperties in project components by Talend.

the class AzureStorageQueueSourceOrSink method validate.

@Override
public ValidationResult validate(RuntimeContainer container) {
    ValidationResult vr = super.validate(container);
    if (vr != ValidationResult.OK)
        return vr;
    if (properties instanceof TAzureStorageQueueListProperties) {
        // no validation needed...
        return ValidationResult.OK;
    }
    if (properties instanceof AzureStorageQueueProperties) {
        String q = ((AzureStorageQueueProperties) properties).queueName.getValue();
        if (q.isEmpty()) {
            return new ValidationResult(ValidationResult.Result.ERROR, i18nMessages.getMessage("error.NameEmpty"));
        }
        if (q.length() < 3 || q.length() > 63) {
            return new ValidationResult(ValidationResult.Result.ERROR, i18nMessages.getMessage("error.LengthError"));
        }
        if (q.indexOf("--") > -1) {
            return new ValidationResult(ValidationResult.Result.ERROR, i18nMessages.getMessage("error.TwoDashError"));
        }
        if (!queueCheckNamePattern.matcher(q.replaceAll("-", "")).matches()) {
            return new ValidationResult(ValidationResult.Result.ERROR, i18nMessages.getMessage("error.QueueNameError"));
        }
    }
    if (properties instanceof TAzureStorageQueueInputProperties) {
        int nom = ((TAzureStorageQueueInputProperties) properties).numberOfMessages.getValue();
        if (nom < 1 || nom > 32) {
            return new ValidationResult(ValidationResult.Result.ERROR, i18nMessages.getMessage("error.ParameterLengthError"));
        }
        int vtimeout = ((TAzureStorageQueueInputProperties) properties).visibilityTimeoutInSeconds.getValue();
        if (vtimeout < 0) {
            return new ValidationResult(ValidationResult.Result.ERROR, i18nMessages.getMessage("error.ParameterValueError"));
        }
    }
    return ValidationResult.OK;
}
Also used : TAzureStorageQueueListProperties(org.talend.components.azurestorage.queue.tazurestoragequeuelist.TAzureStorageQueueListProperties) TAzureStorageQueueInputProperties(org.talend.components.azurestorage.queue.tazurestoragequeueinput.TAzureStorageQueueInputProperties) ValidationResult(org.talend.daikon.properties.ValidationResult) AzureStorageQueueProperties(org.talend.components.azurestorage.queue.AzureStorageQueueProperties)

Example 3 with TAzureStorageQueueListProperties

use of org.talend.components.azurestorage.queue.tazurestoragequeuelist.TAzureStorageQueueListProperties in project components by Talend.

the class AzureStorageQueueListReaderTest method setUp.

@Before
public void setUp() throws Exception {
    dummyCredential = new StorageCredentialsSharedAccessSignature("fakesaas");
    properties = new TAzureStorageQueueListProperties(PROP_ + "QueueList");
    properties.setupProperties();
    properties.connection = getValidFakeConnection();
}
Also used : StorageCredentialsSharedAccessSignature(com.microsoft.azure.storage.StorageCredentialsSharedAccessSignature) TAzureStorageQueueListProperties(org.talend.components.azurestorage.queue.tazurestoragequeuelist.TAzureStorageQueueListProperties) Before(org.junit.Before)

Example 4 with TAzureStorageQueueListProperties

use of org.talend.components.azurestorage.queue.tazurestoragequeuelist.TAzureStorageQueueListProperties in project components by Talend.

the class AzureStorageQueueComponentsTest method testQueueListProperties.

@Test
public void testQueueListProperties() {
    TAzureStorageQueueListProperties properties = new TAzureStorageQueueListProperties("test");
    properties.connection.accountName.setValue("dummy");
    properties.connection.accountKey.setValue("dummy");
    properties.setupProperties();
    AzureStorageQueueSourceOrSink sos = new AzureStorageQueueSourceOrSink();
    sos.initialize(null, properties);
    assertEquals(ValidationResult.OK.getStatus(), sos.validate(null).getStatus());
}
Also used : TAzureStorageQueueListProperties(org.talend.components.azurestorage.queue.tazurestoragequeuelist.TAzureStorageQueueListProperties) AzureStorageQueueSourceOrSink(org.talend.components.azurestorage.queue.runtime.AzureStorageQueueSourceOrSink) Test(org.junit.Test)

Example 5 with TAzureStorageQueueListProperties

use of org.talend.components.azurestorage.queue.tazurestoragequeuelist.TAzureStorageQueueListProperties in project components by Talend.

the class AzureStorageQueueListReaderTestIT method testListQueues.

@SuppressWarnings("rawtypes")
@Test
public void testListQueues() throws Throwable {
    TAzureStorageQueueListProperties properties = new TAzureStorageQueueListProperties("tests");
    properties.setupProperties();
    properties = (TAzureStorageQueueListProperties) setupConnectionProperties((AzureStorageProvideConnectionProperties) properties);
    BoundedReader reader = createBoundedReader(properties);
    assertTrue(reader.start());
    do {
        IndexedRecord current = (IndexedRecord) reader.getCurrent();
        assertNotNull(current);
        assertTrue(current.get(0) instanceof String);
    } while (reader.advance());
    assertTrue((int) reader.getReturnValues().get(AzureStorageDefinition.RETURN_TOTAL_RECORD_COUNT) > 0);
    reader.close();
}
Also used : TAzureStorageQueueListProperties(org.talend.components.azurestorage.queue.tazurestoragequeuelist.TAzureStorageQueueListProperties) IndexedRecord(org.apache.avro.generic.IndexedRecord) BoundedReader(org.talend.components.api.component.runtime.BoundedReader) Test(org.junit.Test)

Aggregations

TAzureStorageQueueListProperties (org.talend.components.azurestorage.queue.tazurestoragequeuelist.TAzureStorageQueueListProperties)5 Before (org.junit.Before)2 Test (org.junit.Test)2 TAzureStorageQueueInputProperties (org.talend.components.azurestorage.queue.tazurestoragequeueinput.TAzureStorageQueueInputProperties)2 StorageCredentialsSharedAccessSignature (com.microsoft.azure.storage.StorageCredentialsSharedAccessSignature)1 IndexedRecord (org.apache.avro.generic.IndexedRecord)1 BoundedReader (org.talend.components.api.component.runtime.BoundedReader)1 RuntimeContainerMock (org.talend.components.azurestorage.RuntimeContainerMock)1 AzureStorageQueueProperties (org.talend.components.azurestorage.queue.AzureStorageQueueProperties)1 AzureStorageQueueSourceOrSink (org.talend.components.azurestorage.queue.runtime.AzureStorageQueueSourceOrSink)1 ValidationResult (org.talend.daikon.properties.ValidationResult)1