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 public void typeConstructorParameterIsTransmitted() throws Exception { matcher = SimpDestinationMessageMatcher.createMessageMatcher("/match", pathMatcher); MessageMatcher<Object> expectedTypeMatcher = new SimpMessageTypeMatcher( SimpMessageType.MESSAGE); assertThat(matcher.getMessageTypeMatcher()).isEqualTo(expectedTypeMatcher); }
@Test public void matchesFalseMessageTypeNotDisconnectType() throws Exception { matcher = SimpDestinationMessageMatcher.createMessageMatcher("/match", pathMatcher); messageBuilder.setHeader(SimpMessageHeaderAccessor.MESSAGE_TYPE_HEADER, SimpMessageType.DISCONNECT); assertThat(matcher.matches(messageBuilder.build())).isFalse(); }
@Test public void matchesTrueMessageType() throws Exception { matcher = SimpDestinationMessageMatcher.createMessageMatcher("/match", pathMatcher); 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"); } }
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"); } }