use of java.util.LinkedHashMap in project camel by apache.
the class FlatpackFixedLengthDataFormatTest method testMarshalWithDefinition.
@Test
public void testMarshalWithDefinition() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:marshal");
// by default we get on big message
mock.expectedMessageCount(1);
List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();
Map<String, Object> row = new LinkedHashMap<String, Object>();
row.put("FIRSTNAME", "JOHN");
row.put("LASTNAME", "DOE");
row.put("ADDRESS", "1234 CIRCLE CT");
row.put("CITY", "ELYRIA");
row.put("STATE", "OH");
row.put("ZIP", "44035");
data.add(row);
template.sendBody("direct:marshal", data);
assertMockEndpointsSatisfied();
String s = mock.getExchanges().get(0).getIn().getBody(String.class);
assertTrue(s.startsWith("JOHN DOE"));
}
use of java.util.LinkedHashMap in project camel by apache.
the class FlatpackDelimitedDataFormatTest method testMarshalWithDefinition.
@Test
public void testMarshalWithDefinition() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:marshal");
// by default we get on big message
mock.expectedMessageCount(1);
List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();
Map<String, Object> row = new LinkedHashMap<String, Object>();
row.put("ITEM_DESC", "SOME VALVE");
row.put("IN_STOCK", "2");
row.put("PRICE", "5.00");
row.put("LAST_RECV_DT", "20050101");
data.add(row);
Map<String, Object> row2 = new LinkedHashMap<String, Object>();
row2.put("ITEM_DESC", "AN ENGINE");
row2.put("IN_STOCK", "100");
row2.put("PRICE", "1000.00");
row2.put("LAST_RECV_DT", "20040601");
data.add(row2);
template.sendBody("direct:marshal", data);
assertMockEndpointsSatisfied();
}
use of java.util.LinkedHashMap in project camel by apache.
the class CreateModelFromXmlTest method testCreateModelFromXmlForInputStreamWithDefaultNamespace.
@Test
public void testCreateModelFromXmlForInputStreamWithDefaultNamespace() throws Exception {
RoutesDefinition routesDefinition = createModelFromXml("simpleRoute.xml", false);
assertNotNull(routesDefinition);
Map<String, String> expectedNamespaces = new LinkedHashMap<>();
expectedNamespaces.put("xmlns", NS_CAMEL);
assertNamespacesPresent(routesDefinition, expectedNamespaces);
}
use of java.util.LinkedHashMap in project camel by apache.
the class BlueprintContainerRegistry method lookupByType.
public static <T> Map<String, T> lookupByType(BlueprintContainer blueprintContainer, Class<T> type, boolean includeNonSingletons) {
Bundle bundle = (Bundle) blueprintContainer.getComponentInstance("blueprintBundle");
Map<String, T> objects = new LinkedHashMap<String, T>();
Set<String> ids = blueprintContainer.getComponentIds();
for (String id : ids) {
try {
ComponentMetadata metadata = blueprintContainer.getComponentMetadata(id);
Class<?> cl = null;
if (metadata instanceof BeanMetadata) {
BeanMetadata beanMetadata = (BeanMetadata) metadata;
// should we skip the bean if its prototype and we are only looking for singletons?
if (!includeNonSingletons) {
String scope = beanMetadata.getScope();
if (BeanMetadata.SCOPE_PROTOTYPE.equals(scope)) {
continue;
}
}
cl = bundle.loadClass(beanMetadata.getClassName());
} else if (metadata instanceof ReferenceMetadata) {
ReferenceMetadata referenceMetadata = (ReferenceMetadata) metadata;
cl = bundle.loadClass(referenceMetadata.getInterface());
}
if (cl != null && type.isAssignableFrom(cl)) {
Object o = blueprintContainer.getComponentInstance(metadata.getId());
objects.put(metadata.getId(), type.cast(o));
}
} catch (Throwable t) {
// ignore
}
}
return objects;
}
use of java.util.LinkedHashMap in project camel by apache.
the class XPathBuilder method logDiscoveredNamespaces.
private void logDiscoveredNamespaces(NodeList namespaces) {
Map<String, HashSet<String>> map = new LinkedHashMap<String, HashSet<String>>();
for (int i = 0; i < namespaces.getLength(); i++) {
Node n = namespaces.item(i);
if (n.getNodeName().equals("xmlns:xml")) {
// skip the implicit XML namespace as it provides no value
continue;
}
String prefix = namespaces.item(i).getNodeName();
if (prefix.equals("xmlns")) {
prefix = "DEFAULT";
}
// add to map
if (!map.containsKey(prefix)) {
map.put(prefix, new HashSet<String>());
}
map.get(prefix).add(namespaces.item(i).getNodeValue());
}
LOG.info("Namespaces discovered in message: {}.", map);
}
Aggregations