/** * <p> * Creates a new instance with the specified pattern, * {@code SimpMessageType.SUBSCRIBE}, and {@link PathMatcher}. * * @param pattern the pattern to use * @param matcher the {@link PathMatcher} to use. */ public static SimpDestinationMessageMatcher createSubscribeMatcher(String pattern, PathMatcher matcher) { return new SimpDestinationMessageMatcher(pattern, SimpMessageType.SUBSCRIBE, matcher); }
/** * <p> * Creates a new instance with the specified pattern, {@code SimpMessageType.MESSAGE}, * and {@link PathMatcher}. * * @param pattern the pattern to use * @param matcher the {@link PathMatcher} to use. */ public static SimpDestinationMessageMatcher createMessageMatcher(String pattern, PathMatcher matcher) { return new SimpDestinationMessageMatcher(pattern, SimpMessageType.MESSAGE, matcher); } }
public void constructorOnlyPathNoError() { new SimpDestinationMessageMatcher("/path"); }
public MessageMatcher<?> build() { if (type == null) { return new SimpDestinationMessageMatcher(pattern, pathMatcher); } else if (SimpMessageType.MESSAGE == type) { return SimpDestinationMessageMatcher.createMessageMatcher(pattern, pathMatcher); } else if (SimpMessageType.SUBSCRIBE == type) { return SimpDestinationMessageMatcher.createSubscribeMatcher(pattern, pathMatcher); } throw new IllegalStateException(type + " is not supported since it does not have a destination"); } }
@Test(expected = IllegalArgumentException.class) public void constructorPatternNull() { new SimpDestinationMessageMatcher(null); }
@Test public void matchesFalseWithDestination() throws Exception { matcher = new SimpDestinationMessageMatcher("/nomatch"); messageBuilder.setHeader(SimpMessageHeaderAccessor.DESTINATION_HEADER, "/destination/1"); assertThat(matcher.matches(messageBuilder.build())).isFalse(); }
@Test public void matchesSpecificWithDestination() throws Exception { matcher = new SimpDestinationMessageMatcher("/destination/1"); messageBuilder.setHeader(SimpMessageHeaderAccessor.DESTINATION_HEADER, "/destination/1"); assertThat(matcher.matches(messageBuilder.build())).isTrue(); }
@Before public void setup() { messageBuilder = MessageBuilder.withPayload("M"); matcher = new SimpDestinationMessageMatcher("/**"); pathMatcher = new AntPathMatcher(); }
@Test public void matchesNullMessageType() throws Exception { matcher = new SimpDestinationMessageMatcher("/match"); messageBuilder.setHeader(SimpMessageHeaderAccessor.DESTINATION_HEADER, "/match"); messageBuilder.setHeader(SimpMessageHeaderAccessor.MESSAGE_TYPE_HEADER, SimpMessageType.MESSAGE); assertThat(matcher.matches(messageBuilder.build())).isTrue(); }
public MessageMatcher<?> build() { if (type == null) { return new SimpDestinationMessageMatcher(pattern, pathMatcher); } else if (SimpMessageType.MESSAGE == type) { return SimpDestinationMessageMatcher.createMessageMatcher(pattern, pathMatcher); } else if (SimpMessageType.SUBSCRIBE == type) { return SimpDestinationMessageMatcher.createSubscribeMatcher(pattern, pathMatcher); } throw new IllegalStateException(type + " is not supported since it does not have a destination"); } }
/** * <p> * Creates a new instance with the specified pattern, * {@code SimpMessageType.SUBSCRIBE}, and {@link PathMatcher}. * * @param pattern the pattern to use * @param matcher the {@link PathMatcher} to use. */ public static SimpDestinationMessageMatcher createSubscribeMatcher(String pattern, PathMatcher matcher) { return new SimpDestinationMessageMatcher(pattern, SimpMessageType.SUBSCRIBE, matcher); }
/** * <p> * Creates a new instance with the specified pattern, {@code SimpMessageType.MESSAGE}, * and {@link PathMatcher}. * * @param pattern the pattern to use * @param matcher the {@link PathMatcher} to use. */ public static SimpDestinationMessageMatcher createMessageMatcher(String pattern, PathMatcher matcher) { return new SimpDestinationMessageMatcher(pattern, SimpMessageType.MESSAGE, matcher); } }
public MessageMatcher<?> build() { if (type == null) { return new SimpDestinationMessageMatcher(pattern, pathMatcher); } else if (SimpMessageType.MESSAGE == type) { return SimpDestinationMessageMatcher.createMessageMatcher(pattern, pathMatcher); } else if (SimpMessageType.SUBSCRIBE == type) { return SimpDestinationMessageMatcher.createSubscribeMatcher(pattern, pathMatcher); } throw new IllegalStateException(type + " is not supported since it does not have a destination"); } }