Search in sources :

Example 1 with AzureStorageQueueSourceOrSink

use of org.talend.components.azurestorage.queue.runtime.AzureStorageQueueSourceOrSink in project components by Talend.

the class AzureStorageQueueComponentsTest method testQueueNameValidation.

@Test
public void testQueueNameValidation() {
    ValidationResult vrEmpty = new ValidationResult(Result.ERROR, i18nMessages.getMessage("error.NameEmpty"));
    ValidationResult vrSize = new ValidationResult(Result.ERROR, i18nMessages.getMessage("error.LengthError"));
    ValidationResult vrDash = new ValidationResult(Result.ERROR, i18nMessages.getMessage("error.TwoDashError"));
    ValidationResult vrName = new ValidationResult(Result.ERROR, i18nMessages.getMessage("error.QueueNameError"));
    // 
    TAzureStorageQueueCreateProperties properties = new TAzureStorageQueueCreateProperties("test");
    properties.connection.accountName.setValue("dummy");
    properties.connection.accountKey.setValue("dummy");
    properties.setupProperties();
    AzureStorageQueueSourceOrSink sos = new AzureStorageQueueSourceOrSink();
    // empty queue name
    sos.initialize(null, properties);
    assertEquals(vrEmpty.getMessage(), sos.validate(null).getMessage());
    // invalid queue size
    properties.queueName.setValue("in");
    sos.initialize(null, properties);
    assertEquals(vrSize.getMessage(), sos.validate(null).getMessage());
    properties.queueName.setValue("a-too-long-queue-name-a-too-long-queue-name-a-too-long-queue-name");
    sos.initialize(null, properties);
    assertEquals(vrSize.getMessage(), sos.validate(null).getMessage());
    // invalid queue name dashes
    properties.queueName.setValue("in--in");
    sos.initialize(null, properties);
    assertEquals(vrDash.getMessage(), sos.validate(null).getMessage());
    // invalid queue name
    properties.queueName.setValue("a-wrongQueueName");
    sos.initialize(null, properties);
    assertEquals(vrName.getMessage(), sos.validate(null).getMessage());
    // a good queue name
    properties.queueName.setValue("a-good-queue-name");
    sos.initialize(null, properties);
    assertEquals(ValidationResult.OK.getStatus(), sos.validate(null).getStatus());
}
Also used : AzureStorageQueueSourceOrSink(org.talend.components.azurestorage.queue.runtime.AzureStorageQueueSourceOrSink) TAzureStorageQueueCreateProperties(org.talend.components.azurestorage.queue.tazurestoragequeuecreate.TAzureStorageQueueCreateProperties) ValidationResult(org.talend.daikon.properties.ValidationResult) Test(org.junit.Test)

Example 2 with AzureStorageQueueSourceOrSink

use of org.talend.components.azurestorage.queue.runtime.AzureStorageQueueSourceOrSink 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)

Example 3 with AzureStorageQueueSourceOrSink

use of org.talend.components.azurestorage.queue.runtime.AzureStorageQueueSourceOrSink 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)

Aggregations

Test (org.junit.Test)3 AzureStorageQueueSourceOrSink (org.talend.components.azurestorage.queue.runtime.AzureStorageQueueSourceOrSink)3 TAzureStorageQueueCreateProperties (org.talend.components.azurestorage.queue.tazurestoragequeuecreate.TAzureStorageQueueCreateProperties)1 TAzureStorageQueueInputProperties (org.talend.components.azurestorage.queue.tazurestoragequeueinput.TAzureStorageQueueInputProperties)1 TAzureStorageQueueListProperties (org.talend.components.azurestorage.queue.tazurestoragequeuelist.TAzureStorageQueueListProperties)1 ValidationResult (org.talend.daikon.properties.ValidationResult)1