use of java.util.List in project camel by apache.
the class JdbcProducer method extractRows.
@SuppressWarnings("unchecked")
private List extractRows(ResultSetIterator iterator) throws SQLException {
List result = new ArrayList();
int maxRowCount = readSize == 0 ? Integer.MAX_VALUE : readSize;
for (int i = 0; iterator.hasNext() && i < maxRowCount; i++) {
Map<String, Object> row = iterator.next();
Object value;
if (getEndpoint().getOutputClass() != null) {
value = newBeanInstance(row);
} else {
value = row;
}
result.add(value);
}
return result;
}
use of java.util.List in project camel by apache.
the class JcloudsSpringBlobstoreTest method testBlobStoreRemoveBlobs.
@Test
public void testBlobStoreRemoveBlobs() throws InterruptedException {
Boolean result = template.requestBody("direct:exists", "Some message", Boolean.class);
assertEquals(true, result);
List blobsToRemove = new ArrayList<>();
blobsToRemove.add("testName");
Map<String, Object> headers = new HashMap<String, Object>();
headers.put(JcloudsConstants.OPERATION, JcloudsConstants.REMOVE_BLOBS);
headers.put(JcloudsConstants.CONTAINER_NAME, "foo");
headers.put(JcloudsConstants.BLOB_NAME_LIST, blobsToRemove);
template.sendBodyAndHeaders("direct:remove-blobs", null, headers);
Long count = template.requestBody("direct:count-after-remove-blobs", null, Long.class);
assertEquals(new Long(0), count);
}
use of java.util.List in project camel by apache.
the class JcloudsBlobStoreProducer method process.
@Override
public void process(Exchange exchange) throws Exception {
String container = getContainerName(exchange);
String blobName = getBlobName(exchange);
String operation = getOperation(exchange);
List blobNames = getBlobNameList(exchange);
if (LOG.isTraceEnabled()) {
LOG.trace("Processing {} operation on '{}'", operation, container + "/" + blobName);
}
if (JcloudsConstants.GET.equals(operation)) {
exchange.getOut().setBody(JcloudsBlobStoreHelper.readBlob(blobStore, container, blobName));
} else if (JcloudsConstants.COUNT_BLOBS.equals(operation)) {
exchange.getOut().setBody(JcloudsBlobStoreHelper.countBlob(blobStore, container));
} else if (JcloudsConstants.REMOVE_BLOB.equals(operation)) {
JcloudsBlobStoreHelper.removeBlob(blobStore, container, blobName);
} else if (JcloudsConstants.CLEAR_CONTAINER.equals(operation)) {
JcloudsBlobStoreHelper.clearContainer(blobStore, container);
} else if (JcloudsConstants.DELETE_CONTAINER.equals(operation)) {
JcloudsBlobStoreHelper.deleteContainer(blobStore, container);
} else if (JcloudsConstants.CONTAINER_EXISTS.equals(operation)) {
exchange.getOut().setBody(JcloudsBlobStoreHelper.containerExists(blobStore, container));
} else if (JcloudsConstants.REMOVE_BLOBS.equals(operation)) {
JcloudsBlobStoreHelper.removeBlobs(blobStore, container, blobNames);
} else {
Payload body = exchange.getIn().getBody(Payload.class);
JcloudsBlobStoreHelper.writeBlob(blobStore, container, blobName, body);
}
}
use of java.util.List in project camel by apache.
the class JdbcProducerConcurrenctTest method doSendMessages.
@SuppressWarnings("rawtypes")
private void doSendMessages(int files, int poolSize) throws Exception {
mock.expectedMessageCount(files);
ExecutorService executor = Executors.newFixedThreadPool(poolSize);
// we access the responses Map below only inside the main thread,
// so no need for a thread-safe Map implementation
Map<Integer, Future<List<?>>> responses = new HashMap<Integer, Future<List<?>>>();
for (int i = 0; i < files; i++) {
final int index = i;
Future<List<?>> out = executor.submit(new Callable<List<?>>() {
public List<?> call() throws Exception {
int id = (index % 2) + 1;
return template.requestBody("direct:start", "select * from customer where id = 'cust" + id + "'", List.class);
}
});
responses.put(index, out);
}
assertMockEndpointsSatisfied();
assertEquals(files, responses.size());
for (int i = 0; i < files; i++) {
List<?> rows = responses.get(i).get();
Map columns = (Map) rows.get(0);
if (i % 2 == 0) {
assertEquals("jstrachan", columns.get("NAME"));
} else {
assertEquals("nsandhu", columns.get("NAME"));
}
}
executor.shutdownNow();
}
use of java.util.List in project camel by apache.
the class JdbcProducerOutputTypeSelectListOutputClassTest method testOutputTypeSelectListOutputClass.
@Test
public void testOutputTypeSelectListOutputClass() throws Exception {
mock.expectedMessageCount(1);
template.sendBody("direct:start", "select * from customer order by ID");
assertMockEndpointsSatisfied();
List list = assertIsInstanceOf(List.class, mock.getReceivedExchanges().get(0).getIn().getBody(List.class));
assertNotNull(list);
assertEquals(3, list.size());
CustomerModel cust1 = (CustomerModel) list.get(0);
assertEquals("cust1", cust1.getId());
assertEquals("jstrachan", cust1.getName());
CustomerModel cust2 = (CustomerModel) list.get(1);
assertEquals("cust2", cust2.getId());
assertEquals("nsandhu", cust2.getName());
CustomerModel cust3 = (CustomerModel) list.get(2);
assertEquals("cust3", cust3.getId());
assertEquals("willem", cust3.getName());
}
Aggregations