Package org.mule.api.routing.filter

Examples of org.mule.api.routing.filter.Filter


    }

    public void testTransformerOnGlobalEndpoint()
    {
        Flow flow1 = muleContext.getRegistry().lookupObject("flow1");
        Filter flow1Filter = ((MessageFilter) flow1.getMessageProcessors().get(0)).getFilter();
        Flow flow2 = muleContext.getRegistry().lookupObject("flow2");
        Filter flow2Filter = ((MessageFilter) flow2.getMessageProcessors().get(0)).getFilter();

        assertNotSame(flow1Filter, flow2Filter);
    }
View Full Code Here


public class ExpressionFilterParser
{
    public Filter parseFilterString(String filterString) throws DefaultMuleException
    {
        List<String> strings = split(filterString);
        Filter filter = null;

        for (String s : strings)
        {
            s = s.trim();
            if (s.equals("AND"))
View Full Code Here

    public void testEndpointConfig() throws MuleException
    {
        ImmutableEndpoint endpoint1 = muleContext.getRegistry().lookupEndpointBuilder("endpoint1").buildInboundEndpoint();
        assertNotNull(endpoint1);
        Filter filter1 = endpoint1.getFilter();
        assertNotNull(filter1);
        assertTrue(filter1 instanceof JmsSelectorFilter);
        assertEquals(1, endpoint1.getProperties().size());
        assertEquals("true", endpoint1.getProperty(JmsConstants.DISABLE_TEMP_DESTINATIONS_PROPERTY));
       
        ImmutableEndpoint endpoint2 = muleContext.getRegistry().lookupEndpointBuilder("endpoint2").buildOutboundEndpoint();
        assertNotNull(endpoint2);
        Filter filter2 = endpoint2.getFilter();
        assertNotNull(filter2);
        assertTrue(filter2 instanceof NotFilter);
        Filter filter3 = ((NotFilter) filter2).getFilter();
        assertNotNull(filter3);
        assertTrue(filter3 instanceof JmsPropertyFilter);

        InboundEndpoint inboundEndpoint = (InboundEndpoint) ((ServiceCompositeMessageSource) muleContext.getRegistry().lookupService("testService").getMessageSource()).getEndpoints().get(0);
        assertNotNull(inboundEndpoint);
View Full Code Here

public class FilterExpressionParserTestCase extends AbstractMuleTestCase
{
    public void testSimpleFilters() throws Exception
    {
        ExpressionFilterParser parser = new ExpressionFilterParser();
        Filter f = parser.parseFilterString("#[regex:foo bar]");
        assertNotNull(f);
        assertTrue(f instanceof ExpressionFilter);

        MuleMessage message = new DefaultMuleMessage("foo bar baz", muleContext);
        assertTrue(f.accept(message));


        f = parser.parseFilterString("#[regex:.* bar] AND #[wildcard:foo*]");
        assertNotNull(f);
        assertTrue(f instanceof AndFilter);
        assertEquals(2, ((AndFilter)f).getFilters().size());
        assertTrue(((AndFilter)f).getFilters().get(0) instanceof ExpressionFilter);
        assertEquals("regex", ((ExpressionFilter)((AndFilter)f).getFilters().get(0)).getEvaluator());
        assertTrue(((AndFilter)f).getFilters().get(1) instanceof ExpressionFilter);
        assertEquals("wildcard", ((ExpressionFilter)((AndFilter)f).getFilters().get(1)).getEvaluator());

        message = new DefaultMuleMessage("foo bar", muleContext);
        assertTrue(f.accept(message));

        message = new DefaultMuleMessage("foo car", muleContext);
        assertFalse(f.accept(message));

        f = parser.parseFilterString("#[regex:.* bar] OR #[wildcard:foo*]");
        assertNotNull(f);

        message = new DefaultMuleMessage("foo bar", muleContext);
        assertTrue(f.accept(message));

        message = new DefaultMuleMessage("foo car", muleContext);
        assertTrue(f.accept(message));

    }
View Full Code Here

            endpointBuilder.setTransformers(transformers);
        }

        if (epData.getFilter() != null)
        {
            Filter filter = (Filter) convertProperty(Filter.class, epData.getFilter());
            endpointBuilder.addMessageProcessor(new MessageFilter(filter));

        }

        if (epData.getEncoding() != null)
View Full Code Here

        return transformer;
    }
   
    private Filter lookupFilter(String name)
    {
        Filter filter = muleContext.getRegistry().lookupObject(name);
        assertNotNull(filter);
        return filter;
    }
View Full Code Here

        List<Transformer> transformers = new ArrayList<Transformer>();
        transformers.add(trans1);
        transformers.add(trans2);

        Filter filter = new PayloadTypeFilter(Object.class);
        EndpointBuilder endpointBuilder = new EndpointURIEndpointBuilder("test://serializationTest",
            muleContext);
        endpointBuilder.setTransformers(transformers);
        endpointBuilder.setName("epBuilderTest");
        endpointBuilder.addMessageProcessor(new MessageFilter(filter));
View Full Code Here

    class TestMessageFilter extends MessageFilter
    {
        public TestMessageFilter(final boolean accept)
        {
            super(new Filter()
            {
                public boolean accept(MuleMessage message)
                {
                    return accept;
                }
View Full Code Here

        assertEquals(event.getMessage().getPayload(), tapListener.event.getMessage().getPayload());
    }

    public void testWireTapFilterAccepted() throws Exception
    {
        wireTap.setFilter(new Filter()
        {
            public boolean accept(MuleMessage message)
            {
                return true;
            }
View Full Code Here

        assertEquals(event.getMessage().getPayload(), tapListener.event.getMessage().getPayload());
    }

    public void testWireTapFilterUnaccepted() throws Exception
    {
        wireTap.setFilter(new Filter()
        {
            public boolean accept(MuleMessage message)
            {
                return false;
            }
View Full Code Here

TOP

Related Classes of org.mule.api.routing.filter.Filter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.