Search in sources :

Example 1 with Predicate

use of org.apache.camel.Predicate in project camel by apache.

the class DnsDigEndpointTest method testDigForMonkey.

@Test
public void testDigForMonkey() throws Exception {
    resultEndpoint.expectedMessageCount(1);
    resultEndpoint.expectedMessagesMatches(new Predicate() {

        public boolean matches(Exchange exchange) {
            String str = ((Message) exchange.getIn().getBody()).getSectionArray(Section.ANSWER)[0].rdataToString();
            return RESPONSE_MONKEY.equals(str);
        }
    });
    Map<String, Object> headers = new HashMap<String, Object>();
    headers.put("dns.name", "monkey.wp.dg.cx");
    headers.put("dns.type", "TXT");
    template.sendBodyAndHeaders(null, headers);
    resultEndpoint.assertIsSatisfied();
}
Also used : Exchange(org.apache.camel.Exchange) HashMap(java.util.HashMap) Predicate(org.apache.camel.Predicate) Test(org.junit.Test)

Example 2 with Predicate

use of org.apache.camel.Predicate in project camel by apache.

the class DnsLookupEndpointSpringTest method testDNSWithNameHeaderAndType.

@Test
@Ignore("Testing behind nat produces timeouts")
public void testDNSWithNameHeaderAndType() throws Exception {
    resultEndpoint.expectedMessageCount(1);
    resultEndpoint.expectedMessagesMatches(new Predicate() {

        public boolean matches(Exchange exchange) {
            Record[] record = (Record[]) exchange.getIn().getBody();
            return record[0].getName().toString().equals("www.example.com.");
        }
    });
    Map<String, Object> headers = new HashMap<String, Object>();
    headers.put("dns.name", "www.example.com");
    headers.put("dns.type", "A");
    template.sendBodyAndHeaders("hello", headers);
    resultEndpoint.assertIsSatisfied();
}
Also used : Exchange(org.apache.camel.Exchange) HashMap(java.util.HashMap) Record(org.xbill.DNS.Record) Predicate(org.apache.camel.Predicate) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 3 with Predicate

use of org.apache.camel.Predicate in project camel by apache.

the class DnsLookupEndpointSpringTest method testDNSWithNameHeader.

@Test
@Ignore("Testing behind nat produces timeouts")
public void testDNSWithNameHeader() throws Exception {
    resultEndpoint.expectedMessageCount(1);
    resultEndpoint.expectedMessagesMatches(new Predicate() {

        public boolean matches(Exchange exchange) {
            Record[] record = (Record[]) exchange.getIn().getBody();
            return record[0].getName().toString().equals("www.example.com.");
        }
    });
    Map<String, Object> headers = new HashMap<String, Object>();
    headers.put("dns.name", "www.example.com");
    template.sendBodyAndHeaders("hello", headers);
    resultEndpoint.assertIsSatisfied();
}
Also used : Exchange(org.apache.camel.Exchange) HashMap(java.util.HashMap) Record(org.xbill.DNS.Record) Predicate(org.apache.camel.Predicate) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 4 with Predicate

use of org.apache.camel.Predicate in project camel by apache.

the class DnsLookupEndpointTest method testDNSWithNameHeaderAndType.

@Test
@Ignore("Testing behind nat produces timeouts")
public void testDNSWithNameHeaderAndType() throws Exception {
    resultEndpoint.expectedMessageCount(1);
    resultEndpoint.expectedMessagesMatches(new Predicate() {

        public boolean matches(Exchange exchange) {
            Record[] record = (Record[]) exchange.getIn().getBody();
            return record[0].getName().toString().equals("www.example.com.");
        }
    });
    Map<String, Object> headers = new HashMap<String, Object>();
    headers.put("dns.name", "www.example.com");
    headers.put("dns.type", "A");
    template.sendBodyAndHeaders("hello", headers);
    resultEndpoint.assertIsSatisfied();
}
Also used : Exchange(org.apache.camel.Exchange) HashMap(java.util.HashMap) Record(org.xbill.DNS.Record) Predicate(org.apache.camel.Predicate) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 5 with Predicate

use of org.apache.camel.Predicate in project camel by apache.

the class WikipediaEndpointTest method testWikipediaForMonkey.

@Test
@Ignore("Testing behind nat produces timeouts")
public void testWikipediaForMonkey() throws Exception {
    resultEndpoint.expectedMessageCount(1);
    resultEndpoint.expectedMessagesMatches(new Predicate() {

        public boolean matches(Exchange exchange) {
            String str = (String) exchange.getIn().getBody();
            return RESPONSE_MONKEY.equals(str);
        }
    });
    Map<String, Object> headers = new HashMap<String, Object>();
    headers.put("term", "monkey");
    template.sendBodyAndHeaders(null, headers);
    resultEndpoint.assertIsSatisfied();
}
Also used : Exchange(org.apache.camel.Exchange) HashMap(java.util.HashMap) Predicate(org.apache.camel.Predicate) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

Predicate (org.apache.camel.Predicate)124 Exchange (org.apache.camel.Exchange)70 Test (org.junit.Test)40 HashMap (java.util.HashMap)25 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)23 Expression (org.apache.camel.Expression)22 Processor (org.apache.camel.Processor)19 DefaultExchange (org.apache.camel.impl.DefaultExchange)10 RouteBuilder (org.apache.camel.builder.RouteBuilder)9 File (java.io.File)8 Matchers.containsString (org.hamcrest.Matchers.containsString)8 ByteArrayInputStream (java.io.ByteArrayInputStream)7 Map (java.util.Map)7 Ignore (org.junit.Ignore)7 IOException (java.io.IOException)6 ArrayList (java.util.ArrayList)6 AggregateProcessor (org.apache.camel.processor.aggregate.AggregateProcessor)6 AggregationStrategy (org.apache.camel.processor.aggregate.AggregationStrategy)6 PDDocument (org.apache.pdfbox.pdmodel.PDDocument)6 BodyInAggregatingStrategy (org.apache.camel.processor.BodyInAggregatingStrategy)5