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
Expand Up @@ -168,7 +168,7 @@ public MessageListenerContainer getUnregisteredListenerContainer(String id) {
refreshContextContainers();
return this.unregisteredContainers.get(id);
}
return null;
return container;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,15 @@
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;

import org.springframework.context.support.GenericApplicationContext;
import org.springframework.kafka.listener.ConcurrentMessageListenerContainer;
import org.springframework.kafka.listener.MessageListenerContainer;

/**
* @author Gary Russell
* @author Joo Hyuk Kim
* @author Artem Bilan
*
* @since 2.8.9
*/
public class KafkaListenerEndpointRegistryTests {
Expand Down Expand Up @@ -139,6 +143,21 @@ void getListenerContainersMatchingBiPredicate(List<String> names, BiPredicate<St
assertThat(listeners).hasSize(expectedCount);
}

@Test
void verifyUnregisteredListenerContainer() {
KafkaListenerEndpointRegistry registry = new KafkaListenerEndpointRegistry();
GenericApplicationContext applicationContext = new GenericApplicationContext();
ConcurrentMessageListenerContainer<?, ?> listenerContainerMock = mock(ConcurrentMessageListenerContainer.class);
given(listenerContainerMock.getListenerId()).willReturn("testListenerContainer");
applicationContext.registerBean(ConcurrentMessageListenerContainer.class, () -> listenerContainerMock);
applicationContext.refresh();
registry.setApplicationContext(applicationContext);
// Lazy-load from application context
assertThat(registry.getUnregisteredListenerContainer("testListenerContainer")).isNotNull();
// From internal map
assertThat(registry.getUnregisteredListenerContainer("testListenerContainer")).isNotNull();
}

/**
* Provides parameters for the getListenerContainersMatchingBiPredicate test.
* Each set of parameters includes a list of names, a bi-predicate, and the expected count of matching containers.
Expand Down