Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -23,6 +23,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Objects;
import java.util.Properties;
import java.util.stream.Collectors;

Expand All @@ -42,6 +43,8 @@
import org.springframework.messaging.support.GenericMessage;
import org.springframework.util.Assert;

import com.fasterxml.jackson.annotation.JsonCreator;

/**
* @author Mark Fisher
* @author Artem Bilan
Expand Down Expand Up @@ -133,7 +136,7 @@ else if (message instanceof AdviceMessage) {
return message;
}


@JsonCreator
private MessageHistory(List<Properties> components) {
Assert.notEmpty(components, "component list must not be empty");
this.components = components;
Expand Down Expand Up @@ -205,6 +208,21 @@ public int lastIndexOf(Object o) {
return this.components.lastIndexOf(o);
}

@Override public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof MessageHistory)) {
return false;
}
MessageHistory that = (MessageHistory) o;
return this.components.equals(that.components);
}

@Override public int hashCode() {
return Objects.hash(this.components);
}

@Override
public String toString() {
return this.components
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -158,7 +158,8 @@ private static final class AllowlistTypeIdResolver implements TypeIdResolver {
"org.springframework.messaging.support",
"org.springframework.integration.support",
"org.springframework.integration.message",
"org.springframework.integration.store"
"org.springframework.integration.store",
"org.springframework.integration.history"
);

private final TypeIdResolver delegate;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2007-2019 the original author or authors.
* Copyright 2007-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -40,6 +40,7 @@
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.channel.NullChannel;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.history.MessageHistory;
import org.springframework.integration.message.AdviceMessage;
Expand Down Expand Up @@ -143,7 +144,7 @@ public void testRemoveMessageGroup() {
store.removeMessageGroup(this.groupId);
MessageGroup messageGroupA = store.getMessageGroup(this.groupId);
assertThat(messageGroupA).isNotSameAs(messageGroup);
// assertEquals(0, messageGroupA.getMarked().size());
// assertEquals(0, messageGroupA.getMarked().size());
assertThat(messageGroupA.getMessages().size()).isEqualTo(0);
assertThat(messageGroupA.size()).isEqualTo(0);

Expand Down Expand Up @@ -438,6 +439,9 @@ public void testJsonSerialization() {
store.setValueSerializer(serializer);

Message<?> genericMessage = new GenericMessage<>(new Date());
NullChannel testComponent = new NullChannel();
testComponent.setBeanName("testChannel");
genericMessage = MessageHistory.write(genericMessage, testComponent);
Message<?> mutableMessage = new MutableMessage<>(UUID.randomUUID());
Message<?> adviceMessage = new AdviceMessage<>("foo", genericMessage);
ErrorMessage errorMessage = new ErrorMessage(new RuntimeException("test exception"), mutableMessage);
Expand All @@ -448,6 +452,7 @@ public void testJsonSerialization() {
assertThat(messageGroup.size()).isEqualTo(4);
List<Message<?>> messages = new ArrayList<>(messageGroup.getMessages());
assertThat(messages.get(0)).isEqualTo(genericMessage);
assertThat(messages.get(0).getHeaders()).containsKeys(MessageHistory.HEADER_NAME);
assertThat(messages.get(1)).isEqualTo(mutableMessage);
assertThat(messages.get(2)).isEqualTo(adviceMessage);
Message<?> errorMessageResult = messages.get(3);
Expand Down