Search in sources :

Example 1 with TAzureStorageQueueCreateProperties

use of org.talend.components.azurestorage.queue.tazurestoragequeuecreate.TAzureStorageQueueCreateProperties 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 TAzureStorageQueueCreateProperties

use of org.talend.components.azurestorage.queue.tazurestoragequeuecreate.TAzureStorageQueueCreateProperties in project components by Talend.

the class AzureStorageQueueCreateReaderTestIT method testCreateExistingQueue.

@SuppressWarnings("rawtypes")
@Test
public void testCreateExistingQueue() throws Throwable {
    TAzureStorageQueueCreateProperties properties = new TAzureStorageQueueCreateProperties("tests");
    properties.setupProperties();
    properties = (TAzureStorageQueueCreateProperties) setupConnectionProperties((AzureStorageProvideConnectionProperties) properties);
    String fqueue = TEST_QUEUE_NAME_CREATE + getRandomTestUID() + "b";
    properties.queueName.setValue(fqueue);
    BoundedReader reader = createBoundedReader(properties);
    assertTrue(reader.start());
    assertTrue((int) reader.getReturnValues().get(AzureStorageDefinition.RETURN_TOTAL_RECORD_COUNT) > 0);
    reader.close();
    // 
    assertFalse(reader.start());
    assertTrue((int) reader.getReturnValues().get(AzureStorageDefinition.RETURN_TOTAL_RECORD_COUNT) > 0);
    reader.close();
}
Also used : TAzureStorageQueueCreateProperties(org.talend.components.azurestorage.queue.tazurestoragequeuecreate.TAzureStorageQueueCreateProperties) BoundedReader(org.talend.components.api.component.runtime.BoundedReader) Test(org.junit.Test)

Example 3 with TAzureStorageQueueCreateProperties

use of org.talend.components.azurestorage.queue.tazurestoragequeuecreate.TAzureStorageQueueCreateProperties in project components by Talend.

the class AzureStorageQueueCreateRuntime method initialize.

@Override
public ValidationResult initialize(RuntimeContainer runtimeContainer, ComponentProperties properties) {
    ValidationResult vr = super.initialize(runtimeContainer, properties);
    if (!ValidationResult.OK.getStatus().equals(vr.getStatus())) {
        return vr;
    }
    this.dieOnError = ((TAzureStorageQueueCreateProperties) properties).dieOnError.getValue();
    this.queueService = new AzureStorageQueueService(getAzureConnection(runtimeContainer));
    return ValidationResult.OK;
}
Also used : AzureStorageQueueService(org.talend.components.azurestorage.queue.AzureStorageQueueService) TAzureStorageQueueCreateProperties(org.talend.components.azurestorage.queue.tazurestoragequeuecreate.TAzureStorageQueueCreateProperties) ValidationResult(org.talend.daikon.properties.ValidationResult)

Example 4 with TAzureStorageQueueCreateProperties

use of org.talend.components.azurestorage.queue.tazurestoragequeuecreate.TAzureStorageQueueCreateProperties in project components by Talend.

the class AzureStorageQueueCreateRuntimeTest method setup.

@Before
public void setup() throws IOException {
    properties = new TAzureStorageQueueCreateProperties(PROP_ + "Get");
    properties.setupProperties();
    // valid connection
    properties.connection = new TAzureStorageConnectionProperties(PROP_ + "Connection");
    properties.connection.protocol.setValue(Protocol.HTTP);
    properties.connection.accountName.setValue("fakeAccountName");
    properties.connection.accountKey.setValue("fakeAccountKey=ANBHFYRJJFHRIKKJFU");
    runtimeContainer = new RuntimeContainerMock();
    this.azureStorageQueueCreate = new AzureStorageQueueCreateRuntime();
}
Also used : TAzureStorageQueueCreateProperties(org.talend.components.azurestorage.queue.tazurestoragequeuecreate.TAzureStorageQueueCreateProperties) RuntimeContainerMock(org.talend.components.azurestorage.RuntimeContainerMock) TAzureStorageConnectionProperties(org.talend.components.azurestorage.tazurestorageconnection.TAzureStorageConnectionProperties) Before(org.junit.Before)

Example 5 with TAzureStorageQueueCreateProperties

use of org.talend.components.azurestorage.queue.tazurestoragequeuecreate.TAzureStorageQueueCreateProperties in project components by Talend.

the class AzureStorageQueueRuntimeTest method setup.

@Before
public void setup() throws IOException {
    properties = new TAzureStorageQueueCreateProperties(PROP_ + "Get");
    properties.setupProperties();
    // valid connection
    properties.connection = new TAzureStorageConnectionProperties(PROP_ + "Connection");
    properties.connection.protocol.setValue(Protocol.HTTP);
    properties.connection.accountName.setValue("fakeAccountName");
    properties.connection.accountKey.setValue("fakeAccountKey=ANBHFYRJJFHRIKKJFU");
    runtimeContainer = new RuntimeContainerMock();
    this.azureStorageQueue = new AzureStorageQueueRuntime() {
    };
}
Also used : TAzureStorageQueueCreateProperties(org.talend.components.azurestorage.queue.tazurestoragequeuecreate.TAzureStorageQueueCreateProperties) RuntimeContainerMock(org.talend.components.azurestorage.RuntimeContainerMock) TAzureStorageConnectionProperties(org.talend.components.azurestorage.tazurestorageconnection.TAzureStorageConnectionProperties) Before(org.junit.Before)

Aggregations

TAzureStorageQueueCreateProperties (org.talend.components.azurestorage.queue.tazurestoragequeuecreate.TAzureStorageQueueCreateProperties)9 Test (org.junit.Test)5 BoundedReader (org.talend.components.api.component.runtime.BoundedReader)4 IndexedRecord (org.apache.avro.generic.IndexedRecord)2 Before (org.junit.Before)2 RuntimeContainerMock (org.talend.components.azurestorage.RuntimeContainerMock)2 TAzureStorageConnectionProperties (org.talend.components.azurestorage.tazurestorageconnection.TAzureStorageConnectionProperties)2 ValidationResult (org.talend.daikon.properties.ValidationResult)2 BeforeClass (org.junit.BeforeClass)1 AzureStorageQueueService (org.talend.components.azurestorage.queue.AzureStorageQueueService)1 AzureStorageQueueSource (org.talend.components.azurestorage.queue.runtime.AzureStorageQueueSource)1 AzureStorageQueueSourceOrSink (org.talend.components.azurestorage.queue.runtime.AzureStorageQueueSourceOrSink)1 TAzureStorageQueueDeleteProperties (org.talend.components.azurestorage.queue.tazurestoragequeuedelete.TAzureStorageQueueDeleteProperties)1