Search in sources :

Example 1 with TAzureStorageQueueOutputProperties

use of org.talend.components.azurestorage.queue.tazurestoragequeueoutput.TAzureStorageQueueOutputProperties in project components by Talend.

the class AzureStorageQueueComponentsTest method testTAzureStorageQueueOutputProperties.

@Test
public void testTAzureStorageQueueOutputProperties() {
    TAzureStorageQueueOutputProperties op = new TAzureStorageQueueOutputProperties("test");
    op.setupProperties();
    HashSet<PropertyPathConnector> connectors = new HashSet<>();
    connectors.add(op.FLOW_CONNECTOR);
    assertEquals(connectors, op.getAllSchemaPropertiesConnectors(true));
    connectors.clear();
    connectors.add(op.MAIN_CONNECTOR);
    assertEquals(connectors, op.getAllSchemaPropertiesConnectors(false));
}
Also used : PropertyPathConnector(org.talend.components.api.component.PropertyPathConnector) TAzureStorageQueueOutputProperties(org.talend.components.azurestorage.queue.tazurestoragequeueoutput.TAzureStorageQueueOutputProperties) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 2 with TAzureStorageQueueOutputProperties

use of org.talend.components.azurestorage.queue.tazurestoragequeueoutput.TAzureStorageQueueOutputProperties in project components by Talend.

the class AzureStorageQueueSinkTest method testCreateWriteOperation.

/**
 * Test method for
 * {@link org.talend.components.azurestorage.queue.runtime.AzureStorageQueueSink#createWriteOperation()}.
 */
@Test
public final void testCreateWriteOperation() {
    AzureStorageQueueSink sink = new AzureStorageQueueSink();
    TAzureStorageQueueOutputProperties p = new TAzureStorageQueueOutputProperties("test");
    p.connection.setupProperties();
    p.setupProperties();
    sink.initialize(null, p);
    assertNotNull(sink.createWriteOperation());
    assertNotNull(sink.createWriteOperation().createWriter(null));
    assertEquals(sink, sink.createWriteOperation().getSink());
    List<Result> writerResults = new ArrayList<Result>();
    Result r = new Result("test");
    writerResults.add(r);
    AzureStorageQueueWriteOperation wo = (AzureStorageQueueWriteOperation) sink.createWriteOperation();
    wo.initialize(null);
    assertNotNull(wo.finalize(writerResults, null));
}
Also used : ArrayList(java.util.ArrayList) TAzureStorageQueueOutputProperties(org.talend.components.azurestorage.queue.tazurestoragequeueoutput.TAzureStorageQueueOutputProperties) Result(org.talend.components.api.component.runtime.Result) Test(org.junit.Test)

Example 3 with TAzureStorageQueueOutputProperties

use of org.talend.components.azurestorage.queue.tazurestoragequeueoutput.TAzureStorageQueueOutputProperties in project components by Talend.

the class AzureStorageQueueOutputWriterTestIT method testWriteSimpleMessage.

@Test
public void testWriteSimpleMessage() throws Throwable {
    queue.clear();
    // 
    TAzureStorageQueueOutputProperties properties = new TAzureStorageQueueOutputProperties("tests");
    properties = (TAzureStorageQueueOutputProperties) setupConnectionProperties((AzureStorageProvideConnectionProperties) properties);
    properties.setupProperties();
    properties.queueName.setValue(TEST_QUEUE_NAME);
    Writer<?> writer = createWriter(properties);
    writer.open("test-uid");
    for (String m : messages) {
        IndexedRecord entity = new GenericData.Record(properties.schema.schema.getValue());
        entity.put(0, m + "SIMPLE");
        writer.write(entity);
    }
    writer.close();
    queue.downloadAttributes();
    assertEquals(3, queue.getApproximateMessageCount());
    for (CloudQueueMessage msg : queue.retrieveMessages(3)) {
        assertNotNull(msg.getMessageContentAsString());
        assertTrue(msg.getMessageContentAsString().indexOf("SIMPLE") > 0);
    }
}
Also used : IndexedRecord(org.apache.avro.generic.IndexedRecord) CloudQueueMessage(com.microsoft.azure.storage.queue.CloudQueueMessage) TAzureStorageQueueOutputProperties(org.talend.components.azurestorage.queue.tazurestoragequeueoutput.TAzureStorageQueueOutputProperties) IndexedRecord(org.apache.avro.generic.IndexedRecord) Test(org.junit.Test)

Example 4 with TAzureStorageQueueOutputProperties

use of org.talend.components.azurestorage.queue.tazurestoragequeueoutput.TAzureStorageQueueOutputProperties in project components by Talend.

the class AzureStorageQueueWriterTest method setUp.

@Before
public void setUp() throws Exception {
    AzureStorageQueueSink sink = new AzureStorageQueueSink();
    TAzureStorageQueueOutputProperties p = new TAzureStorageQueueOutputProperties("test");
    p.connection.setupProperties();
    p.setupProperties();
    sink.initialize(null, p);
    writer = (AzureStorageQueueWriter) sink.createWriteOperation().createWriter(null);
}
Also used : TAzureStorageQueueOutputProperties(org.talend.components.azurestorage.queue.tazurestoragequeueoutput.TAzureStorageQueueOutputProperties) Before(org.junit.Before)

Example 5 with TAzureStorageQueueOutputProperties

use of org.talend.components.azurestorage.queue.tazurestoragequeueoutput.TAzureStorageQueueOutputProperties in project components by Talend.

the class AzureStorageQueuePurgeReaderTestIT method fillInQueue.

@Before
public void fillInQueue() throws Throwable {
    TAzureStorageQueueOutputProperties properties = new TAzureStorageQueueOutputProperties("tests");
    properties = (TAzureStorageQueueOutputProperties) setupConnectionProperties((AzureStorageProvideConnectionProperties) properties);
    properties.setupProperties();
    properties.queueName.setValue(TEST_QUEUE_NAME);
    AzureStorageQueueSink sink = new AzureStorageQueueSink();
    sink.initialize(null, properties);
    sink.validate(null);
    Writer<?> writer = sink.createWriteOperation().createWriter(null);
    writer.open("test-uid");
    for (String m : messages) {
        IndexedRecord entity = new GenericData.Record(properties.schema.schema.getValue());
        entity.put(0, m + "SIMPLE");
        writer.write(entity);
    }
    writer.close();
    queue.downloadAttributes();
    assertTrue(queue.getApproximateMessageCount() > 3);
}
Also used : AzureStorageQueueSink(org.talend.components.azurestorage.queue.runtime.AzureStorageQueueSink) IndexedRecord(org.apache.avro.generic.IndexedRecord) TAzureStorageQueueOutputProperties(org.talend.components.azurestorage.queue.tazurestoragequeueoutput.TAzureStorageQueueOutputProperties) IndexedRecord(org.apache.avro.generic.IndexedRecord) Before(org.junit.Before)

Aggregations

TAzureStorageQueueOutputProperties (org.talend.components.azurestorage.queue.tazurestoragequeueoutput.TAzureStorageQueueOutputProperties)7 Test (org.junit.Test)5 IndexedRecord (org.apache.avro.generic.IndexedRecord)4 CloudQueueMessage (com.microsoft.azure.storage.queue.CloudQueueMessage)3 Before (org.junit.Before)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 PropertyPathConnector (org.talend.components.api.component.PropertyPathConnector)1 Result (org.talend.components.api.component.runtime.Result)1 AzureStorageQueueSink (org.talend.components.azurestorage.queue.runtime.AzureStorageQueueSink)1