Search in sources :

Example 1 with ArrayList

use of java.util.ArrayList in project camel by apache.

the class CacheBasedTokenReplacerTest method testCacheBasedTokenReplacer.

@Test
public void testCacheBasedTokenReplacer() throws Exception {
    log.debug("Beginning Test ---> testCacheBasedTokenReplacer()");
    resultEndpoint.expectedMessageCount(1);
    List<String> keys = new ArrayList<String>();
    keys.add("novel");
    keys.add("author");
    keys.add("number");
    keys.add("quote");
    for (final String key : keys) {
        producerTemplate.send(new Processor() {

            public void process(Exchange exchange) throws Exception {
                exchange.setProperty(Exchange.CHARSET_NAME, "UTF-8");
                Message in = exchange.getIn();
                in.setHeader(CacheConstants.CACHE_OPERATION, CacheConstants.CACHE_OPERATION_ADD);
                in.setHeader(CacheConstants.CACHE_KEY, key);
                if (key.equalsIgnoreCase("novel")) {
                    in.setBody("Rubaiyat");
                } else if (key.equalsIgnoreCase("author")) {
                    in.setBody("Omar Khayyam");
                } else if (key.equalsIgnoreCase("number")) {
                    in.setBody("one");
                } else {
                    in.setBody(quote);
                }
            }
        });
    }
    resultEndpoint.assertIsSatisfied();
    log.debug("Completed Test ---> testCacheBasedTokenReplacer()");
}
Also used : Exchange(org.apache.camel.Exchange) Processor(org.apache.camel.Processor) Message(org.apache.camel.Message) ArrayList(java.util.ArrayList) Test(org.junit.Test) BaseCacheTest(org.apache.camel.component.BaseCacheTest)

Example 2 with ArrayList

use of java.util.ArrayList in project camel by apache.

the class CacheBasedXPathElementReplacerTest method testCacheBasedXPathElementReplacer.

@Test
public void testCacheBasedXPathElementReplacer() throws Exception {
    log.debug("Beginning Test ---> testCacheBasedXPathElementReplacer()");
    resultEndpoint.expectedMessageCount(1);
    List<String> keys = new ArrayList<String>();
    keys.add("book1");
    keys.add("book2");
    keys.add("XML_FRAGMENT");
    for (final String key : keys) {
        producerTemplate.send(new Processor() {

            public void process(Exchange exchange) throws Exception {
                exchange.setProperty(Exchange.CHARSET_NAME, "UTF-8");
                Message in = exchange.getIn();
                in.setHeader(CacheConstants.CACHE_OPERATION, CacheConstants.CACHE_OPERATION_ADD);
                in.setHeader(CacheConstants.CACHE_KEY, key);
                if (key.equalsIgnoreCase("book1")) {
                    in.setBody(book1);
                } else if (key.equalsIgnoreCase("book2")) {
                    in.setBody(book2);
                } else {
                    in.setBody(xmlFragment);
                }
            }
        });
    }
    resultEndpoint.assertIsSatisfied();
    log.debug("Completed Test ---> testCacheBasedXPathElementReplacer()");
}
Also used : Exchange(org.apache.camel.Exchange) Processor(org.apache.camel.Processor) Message(org.apache.camel.Message) ArrayList(java.util.ArrayList) Test(org.junit.Test) BaseCacheTest(org.apache.camel.component.BaseCacheTest)

Example 3 with ArrayList

use of java.util.ArrayList in project camel by apache.

the class CamelMockBundle method findEntries.

public Enumeration<URL> findEntries(String path, String filePattern, boolean recurse) {
    if (path.equals("/org/apache/camel/core/osgi/test") && filePattern.equals("*.class")) {
        List<URL> urls = new ArrayList<URL>();
        URL url = getClass().getClassLoader().getResource("org/apache/camel/core/osgi/test/MyTypeConverter.class");
        urls.add(url);
        url = getClass().getClassLoader().getResource("org/apache/camel/core/osgi/test/MyRouteBuilder.class");
        urls.add(url);
        return new ListEnumeration<URL>(urls);
    } else {
        return CastUtils.cast(super.findEntries(path, filePattern, recurse));
    }
}
Also used : ArrayList(java.util.ArrayList) URL(java.net.URL)

Example 4 with ArrayList

use of java.util.ArrayList in project camel by apache.

the class PGPKeyAccessDataFormat method createSignatureGenerator.

protected List<PGPSignatureGenerator> createSignatureGenerator(Exchange exchange, OutputStream out) throws Exception {
    if (secretKeyAccessor == null) {
        return null;
    }
    List<String> sigKeyUserids = determineSignaturenUserIds(exchange);
    List<PGPSecretKeyAndPrivateKeyAndUserId> sigSecretKeysWithPrivateKeyAndUserId = secretKeyAccessor.getSignerKeys(exchange, sigKeyUserids);
    if (sigSecretKeysWithPrivateKeyAndUserId.isEmpty()) {
        return null;
    }
    exchange.getOut().setHeader(NUMBER_OF_SIGNING_KEYS, Integer.valueOf(sigSecretKeysWithPrivateKeyAndUserId.size()));
    List<PGPSignatureGenerator> sigGens = new ArrayList<PGPSignatureGenerator>();
    for (PGPSecretKeyAndPrivateKeyAndUserId sigSecretKeyWithPrivateKeyAndUserId : sigSecretKeysWithPrivateKeyAndUserId) {
        PGPPrivateKey sigPrivateKey = sigSecretKeyWithPrivateKeyAndUserId.getPrivateKey();
        PGPSignatureSubpacketGenerator spGen = new PGPSignatureSubpacketGenerator();
        spGen.setSignerUserID(false, sigSecretKeyWithPrivateKeyAndUserId.getUserId());
        int algorithm = sigSecretKeyWithPrivateKeyAndUserId.getSecretKey().getPublicKey().getAlgorithm();
        PGPSignatureGenerator sigGen = new PGPSignatureGenerator(new JcaPGPContentSignerBuilder(algorithm, findHashAlgorithm(exchange)).setProvider(getProvider()));
        sigGen.init(PGPSignature.BINARY_DOCUMENT, sigPrivateKey);
        sigGen.setHashedSubpackets(spGen.generate());
        sigGen.generateOnePassVersion(false).encode(out);
        sigGens.add(sigGen);
    }
    return sigGens;
}
Also used : PGPSignatureGenerator(org.bouncycastle.openpgp.PGPSignatureGenerator) JcaPGPContentSignerBuilder(org.bouncycastle.openpgp.operator.jcajce.JcaPGPContentSignerBuilder) ArrayList(java.util.ArrayList) PGPSignatureSubpacketGenerator(org.bouncycastle.openpgp.PGPSignatureSubpacketGenerator) PGPPrivateKey(org.bouncycastle.openpgp.PGPPrivateKey)

Example 5 with ArrayList

use of java.util.ArrayList in project camel by apache.

the class AbstractCamelContextFactoryBean method initPropertyPlaceholder.

protected void initPropertyPlaceholder() throws Exception {
    if (getCamelPropertyPlaceholder() != null) {
        CamelPropertyPlaceholderDefinition def = getCamelPropertyPlaceholder();
        List<PropertiesLocation> locations = new ArrayList<>();
        if (def.getLocation() != null) {
            ObjectHelper.createIterable(def.getLocation()).forEach(location -> locations.add(new PropertiesLocation((String) location)));
        }
        if (def.getLocations() != null) {
            def.getLocations().forEach(definition -> locations.add(definition.toLocation()));
        }
        PropertiesComponent pc = new PropertiesComponent();
        pc.setLocations(locations);
        pc.setEncoding(def.getEncoding());
        if (def.isCache() != null) {
            pc.setCache(def.isCache());
        }
        if (def.isIgnoreMissingLocation() != null) {
            pc.setIgnoreMissingLocation(def.isIgnoreMissingLocation());
        }
        // if using a custom resolver
        if (ObjectHelper.isNotEmpty(def.getPropertiesResolverRef())) {
            PropertiesResolver resolver = CamelContextHelper.mandatoryLookup(getContext(), def.getPropertiesResolverRef(), PropertiesResolver.class);
            pc.setPropertiesResolver(resolver);
        }
        // if using a custom parser
        if (ObjectHelper.isNotEmpty(def.getPropertiesParserRef())) {
            PropertiesParser parser = CamelContextHelper.mandatoryLookup(getContext(), def.getPropertiesParserRef(), PropertiesParser.class);
            pc.setPropertiesParser(parser);
        }
        pc.setPropertyPrefix(def.getPropertyPrefix());
        pc.setPropertySuffix(def.getPropertySuffix());
        if (def.isFallbackToUnaugmentedProperty() != null) {
            pc.setFallbackToUnaugmentedProperty(def.isFallbackToUnaugmentedProperty());
        }
        if (def.getDefaultFallbackEnabled() != null) {
            pc.setDefaultFallbackEnabled(def.getDefaultFallbackEnabled());
        }
        pc.setPrefixToken(def.getPrefixToken());
        pc.setSuffixToken(def.getSuffixToken());
        if (def.getFunctions() != null && !def.getFunctions().isEmpty()) {
            for (CamelPropertyPlaceholderFunctionDefinition function : def.getFunctions()) {
                String ref = function.getRef();
                PropertiesFunction pf = CamelContextHelper.mandatoryLookup(getContext(), ref, PropertiesFunction.class);
                pc.addFunction(pf);
            }
        }
        // register the properties component
        getContext().addComponent("properties", pc);
    }
}
Also used : PropertiesParser(org.apache.camel.component.properties.PropertiesParser) PropertiesResolver(org.apache.camel.component.properties.PropertiesResolver) ArrayList(java.util.ArrayList) PropertiesLocation(org.apache.camel.component.properties.PropertiesLocation) PropertiesFunction(org.apache.camel.component.properties.PropertiesFunction) PropertiesComponent(org.apache.camel.component.properties.PropertiesComponent)

Aggregations

ArrayList (java.util.ArrayList)55702 Test (org.junit.Test)8169 List (java.util.List)6815 HashMap (java.util.HashMap)5856 IOException (java.io.IOException)3899 Map (java.util.Map)3195 File (java.io.File)3090 HashSet (java.util.HashSet)2245 Iterator (java.util.Iterator)1591 Test (org.testng.annotations.Test)1074 SQLException (java.sql.SQLException)1046 ResultSet (java.sql.ResultSet)1017 Date (java.util.Date)997 Set (java.util.Set)917 LinkedHashMap (java.util.LinkedHashMap)886 PreparedStatement (java.sql.PreparedStatement)882 Collection (java.util.Collection)751 LinkedList (java.util.LinkedList)677 BufferedReader (java.io.BufferedReader)663 Path (org.apache.hadoop.fs.Path)611