Expose DefaultSubscriptionRegistry's cache limit through SimpleBrokerMessageHandler and MessageBrokerRegistry
Issue: SPR-14516
(cherry picked from commit 6d5af60)
This commit is contained in:
@@ -16,9 +16,6 @@
|
||||
|
||||
package org.springframework.messaging.simp.config;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
@@ -73,6 +70,9 @@ import org.springframework.validation.Errors;
|
||||
import org.springframework.validation.Validator;
|
||||
import org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
/**
|
||||
* Test fixture for {@link AbstractMessageBrokerConfiguration}.
|
||||
*
|
||||
@@ -392,6 +392,13 @@ public class MessageBrokerConfigurationTests {
|
||||
assertEquals(false, new DirectFieldAccessor(resolver).getPropertyValue("keepLeadingSlash"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customCacheLimit() {
|
||||
SimpleBrokerMessageHandler broker = this.customContext.getBean(SimpleBrokerMessageHandler.class);
|
||||
DefaultSubscriptionRegistry registry = (DefaultSubscriptionRegistry) broker.getSubscriptionRegistry();
|
||||
assertEquals(8192, registry.getCacheLimit());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void userBroadcasts() throws Exception {
|
||||
SimpUserRegistry userRegistry = this.brokerRelayContext.getBean(SimpUserRegistry.class);
|
||||
@@ -441,6 +448,7 @@ public class MessageBrokerConfigurationTests {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static class BaseTestMessageBrokerConfig extends AbstractMessageBrokerConfiguration {
|
||||
|
||||
@Override
|
||||
@@ -449,6 +457,7 @@ public class MessageBrokerConfigurationTests {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Configuration
|
||||
static class SimpleBrokerConfig extends BaseTestMessageBrokerConfig {
|
||||
@@ -477,6 +486,7 @@ public class MessageBrokerConfigurationTests {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Configuration
|
||||
static class BrokerRelayConfig extends SimpleBrokerConfig {
|
||||
|
||||
@@ -488,10 +498,12 @@ public class MessageBrokerConfigurationTests {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Configuration
|
||||
static class DefaultConfig extends BaseTestMessageBrokerConfig {
|
||||
}
|
||||
|
||||
|
||||
@Configuration
|
||||
static class CustomConfig extends BaseTestMessageBrokerConfig {
|
||||
|
||||
@@ -525,6 +537,7 @@ public class MessageBrokerConfigurationTests {
|
||||
registry.configureBrokerChannel().setInterceptors(this.interceptor, this.interceptor, this.interceptor);
|
||||
registry.configureBrokerChannel().taskExecutor().corePoolSize(31).maxPoolSize(32).keepAliveSeconds(33).queueCapacity(34);
|
||||
registry.setPathMatcher(new AntPathMatcher(".")).enableSimpleBroker("/topic", "/queue");
|
||||
registry.setCacheLimit(8192);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -540,6 +553,7 @@ public class MessageBrokerConfigurationTests {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static class TestValidator implements Validator {
|
||||
|
||||
@Override
|
||||
@@ -552,6 +566,7 @@ public class MessageBrokerConfigurationTests {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
private static class CustomThreadPoolTaskExecutor extends ThreadPoolTaskExecutor {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user