use of org.talend.components.couchbase.runtime.CouchbaseSource in project components by Talend.
the class CouchbaseInputTestIT method testReader.
@Test
public void testReader() {
populateBucket();
Reader reader = null;
try {
CouchbaseInputDefinition definition = new CouchbaseInputDefinition();
CouchbaseInputProperties properties = (CouchbaseInputProperties) definition.createRuntimeProperties();
properties.bootstrapNodes.setValue(bootstrapNodes);
properties.bucket.setValue(bucketName);
properties.password.setValue(password);
source = new CouchbaseSource();
source.initialize(null, properties);
reader = source.createReader(null);
boolean hasRecords = reader.start();
assertTrue(hasRecords);
IndexedRecord row = (IndexedRecord) reader.getCurrent();
assertNotNull(row);
assertEquals("foo", row.get(EventSchemaField.KEY_IDX));
assertEquals("{\"bar\":42}", new String(((byte[]) row.get(EventSchemaField.CONTENT_IDX))));
reader.close();
} catch (IOException e) {
fail(e.getMessage());
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e) {
fail(e.getMessage());
}
}
}
}
Aggregations