Search in sources :

Example 21 with BoundedReader

use of org.talend.components.api.component.runtime.BoundedReader in project components by Talend.

the class AzureStorageGetReaderTestIT method testBlobGetAllInvalidPrefixFailure.

@SuppressWarnings("rawtypes")
@Test
public void testBlobGetAllInvalidPrefixFailure() throws Exception {
    cleanupLists();
    prefixes.add("bizarre-bizarre/");
    includes.add(true);
    creates.add(true);
    BoundedReader reader = createGetReader(false);
    assertFalse(reader.start());
    reader.close();
}
Also used : BoundedReader(org.talend.components.api.component.runtime.BoundedReader) Test(org.junit.Test)

Example 22 with BoundedReader

use of org.talend.components.api.component.runtime.BoundedReader in project components by Talend.

the class AzureStorageGetReaderTestIT method testBlobGetAllMakeParentDirectoriesFailure.

@SuppressWarnings("rawtypes")
@Test(expected = FileNotFoundException.class)
public void testBlobGetAllMakeParentDirectoriesFailure() throws Exception {
    cleanupLists();
    prefixes.add("");
    includes.add(true);
    creates.add(false);
    BoundedReader reader = createGetReader(true);
    assertFalse(reader.start());
    reader.close();
}
Also used : BoundedReader(org.talend.components.api.component.runtime.BoundedReader) Test(org.junit.Test)

Example 23 with BoundedReader

use of org.talend.components.api.component.runtime.BoundedReader in project components by Talend.

the class TAzureStorageOuputTableTestIT method testMerge.

@SuppressWarnings("rawtypes")
@Test
public void testMerge() throws Throwable {
    currentTable = tbl_test + "Merge";
    insertTestValues(currentTable);
    properties.schema.schema.setValue(getMergeSchema());
    properties.actionOnData.setValue(ActionOnData.Merge);
    properties.schemaListener.afterSchema();
    Writer<?> writer = createWriter(properties);
    writer.open("test-uid");
    for (String p : partitions) {
        for (String r : rows) {
            IndexedRecord entity = new GenericData.Record(getMergeSchema());
            assertEquals(3, entity.getSchema().getFields().size());
            entity.put(0, p);
            entity.put(1, r);
            entity.put(2, 1000000L * 2);
            writer.write(entity);
        }
    }
    writer.close();
    // check results...
    BoundedReader reader = createReader(currentTable, filter, false);
    int counted = 0;
    assertTrue(reader.start());
    do {
        counted++;
        IndexedRecord current = (IndexedRecord) reader.getCurrent();
        assertEquals(1000000L * 2, current.get(current.getSchema().getField("longy").pos()));
        // checks that other fields remained the sames...
        assertEquals(current.get(current.getSchema().getField("daty").pos()), testTimestamp);
        assertEquals(current.get(current.getSchema().getField("inty").pos()), 1000);
        assertEquals(current.get(current.getSchema().getField("stringy").pos()), testString);
        assertEquals(current.get(current.getSchema().getField("doubly").pos()), 100.5562);
        assertEquals(new String((byte[]) current.get(current.getSchema().getField("bytys").pos())), "ABCDEFGH");
        assertEquals(10, current.getSchema().getFields().size());
    } while (reader.advance());
    reader.close();
    // we should have read 9 rows...
    assertEquals(9, counted);
}
Also used : IndexedRecord(org.apache.avro.generic.IndexedRecord) IndexedRecord(org.apache.avro.generic.IndexedRecord) BoundedReader(org.talend.components.api.component.runtime.BoundedReader) Test(org.junit.Test)

Example 24 with BoundedReader

use of org.talend.components.api.component.runtime.BoundedReader in project components by Talend.

the class TAzureStorageOuputTableTestIT method testDelete.

@SuppressWarnings("rawtypes")
@Test
public void testDelete() throws Throwable {
    currentTable = tbl_test + "Delete";
    // 
    insertTestValues(currentTable);
    // 
    cleanupEntities(currentTable);
    BoundedReader reader = createReader(currentTable, filter, false);
    assertFalse(reader.start());
    reader.close();
}
Also used : BoundedReader(org.talend.components.api.component.runtime.BoundedReader) Test(org.junit.Test)

Example 25 with BoundedReader

use of org.talend.components.api.component.runtime.BoundedReader in project components by Talend.

the class TAzureStorageOuputTableTestIT method testReplace.

@SuppressWarnings("rawtypes")
@Test
public void testReplace() throws Throwable {
    currentTable = tbl_test + "Replace";
    insertTestValues(currentTable);
    properties.schema.schema.setValue(getSimpleTestSchema());
    properties.actionOnData.setValue(ActionOnData.Replace);
    properties.schemaListener.afterSchema();
    Writer<?> writer = createWriter(properties);
    writer.open("test-uid");
    for (String p : partitions) {
        for (String r : rows) {
            // IndexedRecord entity = new GenericData.Record(getWriteSchema());
            IndexedRecord entity = new GenericData.Record(getSimpleTestSchema());
            entity.put(0, p);
            entity.put(1, r);
            entity.put(2, "NewValue");
            writer.write(entity);
        }
    }
    writer.close();
    // check results...
    BoundedReader reader = createReader(currentTable, filter, false);
    int counted = 0;
    assertTrue(reader.start());
    do {
        counted++;
        IndexedRecord current = (IndexedRecord) reader.getCurrent();
        assertEquals(current.get(current.getSchema().getField("StringValue").pos()), "NewValue");
        assertEquals(4, current.getSchema().getFields().size());
    } while (reader.advance());
    reader.close();
    // we should have read 9 rows...
    assertEquals(9, counted);
}
Also used : IndexedRecord(org.apache.avro.generic.IndexedRecord) IndexedRecord(org.apache.avro.generic.IndexedRecord) BoundedReader(org.talend.components.api.component.runtime.BoundedReader) Test(org.junit.Test)

Aggregations

BoundedReader (org.talend.components.api.component.runtime.BoundedReader)45 Test (org.junit.Test)37 IndexedRecord (org.apache.avro.generic.IndexedRecord)24 Matchers.anyString (org.mockito.Matchers.anyString)6 ArrayList (java.util.ArrayList)5 TAzureStorageQueueCreateProperties (org.talend.components.azurestorage.queue.tazurestoragequeuecreate.TAzureStorageQueueCreateProperties)4 GenericData (org.apache.avro.generic.GenericData)3 RemoteBlobsTable (org.talend.components.azurestorage.blob.helpers.RemoteBlobsTable)2 TAzureStorageQueueDeleteProperties (org.talend.components.azurestorage.queue.tazurestoragequeuedelete.TAzureStorageQueueDeleteProperties)2 Drive (com.google.api.services.drive.Drive)1 File (com.google.api.services.drive.model.File)1 FileList (com.google.api.services.drive.model.FileList)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 Map (java.util.Map)1 Before (org.junit.Before)1 TAzureStorageContainerCreateProperties (org.talend.components.azurestorage.blob.tazurestoragecontainercreate.TAzureStorageContainerCreateProperties)1 TAzureStorageContainerDeleteProperties (org.talend.components.azurestorage.blob.tazurestoragecontainerdelete.TAzureStorageContainerDeleteProperties)1 TAzureStorageContainerExistProperties (org.talend.components.azurestorage.blob.tazurestoragecontainerexist.TAzureStorageContainerExistProperties)1 TAzureStorageContainerListProperties (org.talend.components.azurestorage.blob.tazurestoragecontainerlist.TAzureStorageContainerListProperties)1