private TcpDeserializationExceptionEvent doDeserialize(AbstractByteArraySerializer deser, String expectedMessage, byte[] data, int mms) { final AtomicReference<TcpDeserializationExceptionEvent> event = new AtomicReference<TcpDeserializationExceptionEvent>(); class Publisher implements ApplicationEventPublisher { @Override public void publishEvent(ApplicationEvent anEvent) { event.set((TcpDeserializationExceptionEvent) anEvent); } @Override public void publishEvent(Object event) { } } Publisher publisher = new Publisher(); ByteArrayInputStream bais = new ByteArrayInputStream(data); deser.setApplicationEventPublisher(publisher); deser.setMaxMessageSize(mms); try { deser.deserialize(bais); fail("expected exception"); } catch (Exception e) { assertNotNull(event.get()); assertSame(e, event.get().getCause()); assertThat(e.getMessage(), containsString(expectedMessage)); } return event.get(); }
throw new IllegalArgumentException("Invalid encoding: " + this.encoding); codec.setApplicationEventPublisher(this.applicationEventPublisher); if (this.maxMessageSize != null) { codec.setMaxMessageSize(this.maxMessageSize);
throw new IllegalArgumentException("Invalid encoding: " + this.encoding); codec.setApplicationEventPublisher(this.applicationEventPublisher); if (this.maxMessageSize != null) { codec.setMaxMessageSize(this.maxMessageSize);
throw new IllegalArgumentException("Invalid encoding: " + this.encoding); codec.setApplicationEventPublisher(this.applicationEventPublisher); if (this.maxMessageSize != null) { codec.setMaxMessageSize(this.maxMessageSize);
throw new IllegalArgumentException("Invalid encoding: " + this.encoding); codec.setApplicationEventPublisher(this.applicationEventPublisher); if (this.maxMessageSize != null) { codec.setMaxMessageSize(this.maxMessageSize);