Package com.netflix.suro.message

Examples of com.netflix.suro.message.MessageContainer


        assertEquals("sink1", route.getSink());

        Map<String, Map<String, String>> obj = Maps.newHashMap();
        obj.put("foo", ImmutableMap.of("bar", "tESt"));

        MessageContainer container = Mockito.mock(MessageContainer.class);
        Mockito.when(container.getEntity(Map.class)).thenReturn(obj);
        assertEquals(true, route.getFilter().doFilter(container));
    }
View Full Code Here


public class FilterTestUtil {
    private static final Splitter PATH_SPLITTER = Splitter.on("/").omitEmptyStrings().trimResults();

    // Returns a message container that has the given routing key , and payload that has the given path and given value
    public static MessageContainer makeMessageContainer(String routingKey, String path, Object value) throws Exception {
        MessageContainer container = mock(MessageContainer.class);
        when(container.getRoutingKey()).thenReturn(routingKey);

        if(path == null) {
            return container;
        }
        List<String> steps = Lists.newArrayList(PATH_SPLITTER.split(path));
        Map<String, Object> map = Maps.newHashMap();
        Map<String, Object> current = map;

        for(int i = 0; i < steps.size() - 1; i++) {
            String step = steps.get(i);
            Map<String, Object> obj = Maps.newHashMap();
            current.put(step, obj);
            current = obj;
        }
        current.put(steps.get(steps.size() - 1), value);

        when(container.getEntity(Map.class)).thenReturn(map);

        return container;
    }
View Full Code Here

public class RoutingKeyFilterTest {
    @Test
    public void testDoFilter() throws Exception {
        RoutingKeyFilter filter = new RoutingKeyFilter("(?i)key");

        MessageContainer container = makeMessageContainer("routingkEYname", null, null);

        assertTrue(filter.doFilter(container));
    }
View Full Code Here

    @Test
    public void negativeTest() throws Exception {
        RoutingKeyFilter filter = new RoutingKeyFilter("nomatch");

        MessageContainer container = makeMessageContainer("routingkey", null, null);

        assertFalse(filter.doFilter(container));
    }
View Full Code Here

TOP

Related Classes of com.netflix.suro.message.MessageContainer

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.