Search in sources :

Example 6 with LinkedHashMap

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"));
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Example 7 with LinkedHashMap

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();
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Example 8 with LinkedHashMap

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);
}
Also used : RoutesDefinition(org.apache.camel.model.RoutesDefinition) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Example 9 with LinkedHashMap

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;
}
Also used : BeanMetadata(org.osgi.service.blueprint.reflect.BeanMetadata) Bundle(org.osgi.framework.Bundle) ComponentMetadata(org.osgi.service.blueprint.reflect.ComponentMetadata) ReferenceMetadata(org.osgi.service.blueprint.reflect.ReferenceMetadata) LinkedHashMap(java.util.LinkedHashMap)

Example 10 with LinkedHashMap

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);
}
Also used : Node(org.w3c.dom.Node) LinkedHashMap(java.util.LinkedHashMap) HashSet(java.util.HashSet)

Aggregations

LinkedHashMap (java.util.LinkedHashMap)1944 ArrayList (java.util.ArrayList)575 Map (java.util.Map)561 HashMap (java.util.HashMap)373 Test (org.junit.Test)275 List (java.util.List)255 IOException (java.io.IOException)122 HashSet (java.util.HashSet)91 Set (java.util.Set)79 File (java.io.File)76 LinkedHashSet (java.util.LinkedHashSet)68 TreeMap (java.util.TreeMap)68 Node (org.apache.hadoop.hive.ql.lib.Node)59 NodeProcessor (org.apache.hadoop.hive.ql.lib.NodeProcessor)58 Rule (org.apache.hadoop.hive.ql.lib.Rule)58 Date (java.util.Date)57 GraphWalker (org.apache.hadoop.hive.ql.lib.GraphWalker)56 Dispatcher (org.apache.hadoop.hive.ql.lib.Dispatcher)55 Iterator (java.util.Iterator)54 DefaultRuleDispatcher (org.apache.hadoop.hive.ql.lib.DefaultRuleDispatcher)54