Merge pull request #18697 from izeye

* pr/18697:
  Polish

Closes gh-18697
pull/18702/head
Stephane Nicoll 5 years ago
commit 31a7ace38f

@ -16,12 +16,9 @@
package org.springframework.boot.autoconfigure.security.rsocket; package org.springframework.boot.autoconfigure.security.rsocket;
import java.util.List;
import io.rsocket.RSocketFactory; import io.rsocket.RSocketFactory;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor; import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.rsocket.RSocketMessagingAutoConfiguration; import org.springframework.boot.autoconfigure.rsocket.RSocketMessagingAutoConfiguration;
@ -34,6 +31,8 @@ import org.springframework.security.config.annotation.rsocket.RSocketSecurity;
import org.springframework.security.rsocket.core.SecuritySocketAcceptorInterceptor; import org.springframework.security.rsocket.core.SecuritySocketAcceptorInterceptor;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
/** /**
* Tests for {@link RSocketSecurityAutoConfiguration}. * Tests for {@link RSocketSecurityAutoConfiguration}.
@ -59,15 +58,14 @@ class RSocketSecurityAutoConfigurationTests {
@Test @Test
void autoConfigurationAddsCustomizerForServerRSocketFactory() { void autoConfigurationAddsCustomizerForServerRSocketFactory() {
RSocketFactory.ServerRSocketFactory factory = Mockito.mock(RSocketFactory.ServerRSocketFactory.class); RSocketFactory.ServerRSocketFactory factory = mock(RSocketFactory.ServerRSocketFactory.class);
ArgumentCaptor<SecuritySocketAcceptorInterceptor> captor = ArgumentCaptor ArgumentCaptor<SecuritySocketAcceptorInterceptor> captor = ArgumentCaptor
.forClass(SecuritySocketAcceptorInterceptor.class); .forClass(SecuritySocketAcceptorInterceptor.class);
this.contextRunner.run((context) -> { this.contextRunner.run((context) -> {
ServerRSocketFactoryProcessor customizer = context.getBean(ServerRSocketFactoryProcessor.class); ServerRSocketFactoryProcessor customizer = context.getBean(ServerRSocketFactoryProcessor.class);
customizer.process(factory); customizer.process(factory);
Mockito.verify(factory).addSocketAcceptorPlugin(captor.capture()); verify(factory).addSocketAcceptorPlugin(captor.capture());
List<SecuritySocketAcceptorInterceptor> values = captor.getAllValues(); assertThat(captor.getValue()).isInstanceOf(SecuritySocketAcceptorInterceptor.class);
assertThat(values.get(0)).isInstanceOf(SecuritySocketAcceptorInterceptor.class);
}); });
} }

@ -55,7 +55,7 @@ public class RSocketPortInfoApplicationContextInitializer
private static final String PROPERTY_NAME = "local.rsocket.server.port"; private static final String PROPERTY_NAME = "local.rsocket.server.port";
private ConfigurableApplicationContext applicationContext; private final ConfigurableApplicationContext applicationContext;
Listener(ConfigurableApplicationContext applicationContext) { Listener(ConfigurableApplicationContext applicationContext) {
this.applicationContext = applicationContext; this.applicationContext = applicationContext;

@ -170,7 +170,7 @@ class BindableTests {
} }
@Test // gh-18218 @Test // gh-18218
void withSuppliedValueValueDoesNotForgetAnnotations() { void withSuppliedValueDoesNotForgetAnnotations() {
Annotation annotation = AnnotationUtils.synthesizeAnnotation(TestAnnotation.class); Annotation annotation = AnnotationUtils.synthesizeAnnotation(TestAnnotation.class);
Bindable<?> bindable = Bindable.of(String.class).withAnnotations(annotation).withSuppliedValue(() -> ""); Bindable<?> bindable = Bindable.of(String.class).withAnnotations(annotation).withSuppliedValue(() -> "");
assertThat(bindable.getAnnotations()).containsExactly(annotation); assertThat(bindable.getAnnotations()).containsExactly(annotation);

Loading…
Cancel
Save