use of java.util.HashSet in project camel by apache.
the class DefaultHeaderFilterStrategyTest method testCaseInsensitiveHeaderNameDoFilterDefaultHeaderFilterStrategy.
public void testCaseInsensitiveHeaderNameDoFilterDefaultHeaderFilterStrategy() {
DefaultHeaderFilterStrategy comp = new DefaultHeaderFilterStrategy();
comp.setCaseInsensitive(true);
Set<String> set = new HashSet<String>();
set.add("Content-Type");
comp.setOutFilter(set);
Exchange exchange = new DefaultExchange(context);
exchange.getIn().setHeader("content-type", "application/xml");
exchange.getIn().setHeader("Content-Type", "application/json");
assertTrue(comp.applyFilterToCamelHeaders("content-type", "application/xml", exchange));
assertTrue(comp.applyFilterToCamelHeaders("Content-Type", "application/json", exchange));
}
use of java.util.HashSet in project camel by apache.
the class DefaultHeaderFilterStrategyTest method testInFilterDoFilterDefaultHeaderFilterStrategy.
public void testInFilterDoFilterDefaultHeaderFilterStrategy() {
DefaultHeaderFilterStrategy comp = new DefaultHeaderFilterStrategy();
Set<String> set = new HashSet<String>();
set.add("foo");
comp.setInFilter(set);
Exchange exchange = new DefaultExchange(context);
exchange.getIn().setHeader("bar", 123);
exchange.getIn().setHeader("foo", "cheese");
assertFalse(comp.applyFilterToExternalHeaders("bar", 123, exchange));
assertTrue(comp.applyFilterToExternalHeaders("foo", "cheese", exchange));
}
use of java.util.HashSet in project camel by apache.
the class SplitterTest method testSendingAMessageUsingMulticastReceivesItsOwnExchange.
public void testSendingAMessageUsingMulticastReceivesItsOwnExchange() throws Exception {
MockEndpoint resultEndpoint = getMockEndpoint("mock:result");
resultEndpoint.expectedBodiesReceived("James", "Guillaume", "Hiram", "Rob");
// InOnly
template.send("direct:seqential", new Processor() {
public void process(Exchange exchange) {
Message in = exchange.getIn();
in.setBody("James,Guillaume,Hiram,Rob");
in.setHeader("foo", "bar");
}
});
assertMockEndpointsSatisfied();
Set<String> ids = new HashSet<String>();
Set<String> ids2 = new HashSet<String>();
List<Exchange> list = resultEndpoint.getReceivedExchanges();
for (int i = 0; i < 4; i++) {
Exchange exchange = list.get(i);
Message in = exchange.getIn();
ids.add(in.getMessageId());
ids2.add(exchange.getExchangeId());
assertNotNull("The in message should not be null.", in);
assertProperty(exchange, Exchange.SPLIT_INDEX, i);
assertProperty(exchange, Exchange.SPLIT_SIZE, 4);
}
assertEquals("The sub messages should have unique message ids", 4, ids.size());
assertEquals("The sub messages should have unique exchange ids", 4, ids2.size());
}
use of java.util.HashSet in project camel by apache.
the class AbstractJsseParametersTest method createPropertiesPlaceholderAwareContext.
protected CamelContext createPropertiesPlaceholderAwareContext(Properties supplementalProperties) throws IOException {
Properties properties = new Properties(supplementalProperties);
properties.load(AbstractJsseParametersTest.class.getResourceAsStream("test.properties"));
if (supplementalProperties != null) {
Properties mergedProps = new Properties();
Set<String> keys = new HashSet<String>();
keys.addAll(properties.stringPropertyNames());
keys.addAll(supplementalProperties.stringPropertyNames());
for (String key : keys) {
mergedProps.setProperty(key, properties.getProperty(key));
}
properties = mergedProps;
}
properties.store(new FileOutputStream("target/jsse-test.properties"), "Generated by " + AbstractJsseParametersTest.class.getName());
PropertiesComponent pc = new PropertiesComponent();
pc.setLocation("file:./target/jsse-test.properties");
CamelContext context = new DefaultCamelContext();
context.addComponent("properties", pc);
return context;
}
use of java.util.HashSet in project camel by apache.
the class FlexibleAggregationStrategiesTest method testHashSet.
@Test
public void testHashSet() throws Exception {
HashSet<String> r = new HashSet<>();
r.add("FIRST");
r.add("SECOND");
NotifyBuilder notify = new NotifyBuilder(context).whenDone(1).and().whenExactlyFailed(0).create();
Set result = template.requestBody("direct:hashset", Arrays.asList("FIRST", "SECOND"), Set.class);
assertTrue(notify.matches(10, TimeUnit.SECONDS));
assertEquals(r, result);
}
Aggregations