Search in sources :

Example 1 with TAzureStorageQueueInputProperties

use of org.talend.components.azurestorage.queue.tazurestoragequeueinput.TAzureStorageQueueInputProperties in project components by Talend.

the class AzureStorageQueueComponentsTest method testTAzureStorageQueueInputProperties.

@Test
public void testTAzureStorageQueueInputProperties() {
    TAzureStorageQueueInputProperties ip = new TAzureStorageQueueInputProperties("test");
    ip.connection.setupProperties();
    ip.setupProperties();
    ip.peekMessages.setValue(false);
    ip.afterPeekMessages();
    assertFalse(ip.deleteMessages.getValue());
    ip.deleteMessages.setValue(true);
    ip.afterDeleteMessages();
    assertTrue(ip.deleteMessages.getValue());
    assertFalse(ip.peekMessages.getValue());
}
Also used : TAzureStorageQueueInputProperties(org.talend.components.azurestorage.queue.tazurestoragequeueinput.TAzureStorageQueueInputProperties) Test(org.junit.Test)

Example 2 with TAzureStorageQueueInputProperties

use of org.talend.components.azurestorage.queue.tazurestoragequeueinput.TAzureStorageQueueInputProperties in project components by Talend.

the class AzureStorageQueueInputReaderTest method setup.

@Before
public void setup() throws IOException {
    properties = new TAzureStorageQueueInputProperties(PROP_ + "QueueInputReader");
    properties.setupProperties();
    properties.connection = getValidFakeConnection();
    properties.queueName.setValue("some-queue-name");
}
Also used : TAzureStorageQueueInputProperties(org.talend.components.azurestorage.queue.tazurestoragequeueinput.TAzureStorageQueueInputProperties) Before(org.junit.Before)

Example 3 with TAzureStorageQueueInputProperties

use of org.talend.components.azurestorage.queue.tazurestoragequeueinput.TAzureStorageQueueInputProperties 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 4 with TAzureStorageQueueInputProperties

use of org.talend.components.azurestorage.queue.tazurestoragequeueinput.TAzureStorageQueueInputProperties 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 5 with TAzureStorageQueueInputProperties

use of org.talend.components.azurestorage.queue.tazurestoragequeueinput.TAzureStorageQueueInputProperties in project components by Talend.

the class AzureStorageQueueComponentsTest method testQueueInputProperties.

@Test
public void testQueueInputProperties() {
    TAzureStorageQueueInputProperties properties = new TAzureStorageQueueInputProperties("test");
    properties.connection.accountName.setValue("dummy");
    properties.connection.accountKey.setValue("dummy");
    properties.setupProperties();
    properties.queueName.setValue("queueok");
    AzureStorageQueueSourceOrSink sos = new AzureStorageQueueSourceOrSink();
    // number of messages
    properties.numberOfMessages.setValue(-1);
    sos.initialize(null, properties);
    assertEquals(ValidationResult.Result.ERROR, sos.validate(null).getStatus());
    properties.numberOfMessages.setValue(0);
    sos.initialize(null, properties);
    assertEquals(ValidationResult.Result.ERROR, sos.validate(null).getStatus());
    properties.numberOfMessages.setValue(1001);
    sos.initialize(null, properties);
    assertEquals(ValidationResult.Result.ERROR, sos.validate(null).getStatus());
    properties.numberOfMessages.setValue(1);
    sos.initialize(null, properties);
    assertEquals(ValidationResult.OK.getStatus(), sos.validate(null).getStatus());
    properties.numberOfMessages.setValue(32);
    sos.initialize(null, properties);
    assertEquals(ValidationResult.OK.getStatus(), sos.validate(null).getStatus());
    // visibility timeout
    properties.visibilityTimeoutInSeconds.setValue(-1);
    sos.initialize(null, properties);
    assertEquals(ValidationResult.Result.ERROR, sos.validate(null).getStatus());
    properties.visibilityTimeoutInSeconds.setValue(1);
    sos.initialize(null, properties);
    assertEquals(ValidationResult.OK.getStatus(), sos.validate(null).getStatus());
}
Also used : AzureStorageQueueSourceOrSink(org.talend.components.azurestorage.queue.runtime.AzureStorageQueueSourceOrSink) TAzureStorageQueueInputProperties(org.talend.components.azurestorage.queue.tazurestoragequeueinput.TAzureStorageQueueInputProperties) Test(org.junit.Test)

Aggregations

TAzureStorageQueueInputProperties (org.talend.components.azurestorage.queue.tazurestoragequeueinput.TAzureStorageQueueInputProperties)5 Before (org.junit.Before)2 Test (org.junit.Test)2 TAzureStorageQueueListProperties (org.talend.components.azurestorage.queue.tazurestoragequeuelist.TAzureStorageQueueListProperties)2 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