Skip to content

Upgrade spring-boot version to latest snapshot #7510

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
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-2017 the original author or authors.
* Copyright 2002-2019 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 @@ -16,10 +16,8 @@
package sample;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.rsocket.context.RSocketServerInitializedEvent;
import org.springframework.boot.rsocket.context.LocalRSocketServerPort;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.context.ApplicationListener;
import org.springframework.messaging.rsocket.RSocketRequester;
import org.springframework.security.rsocket.metadata.BasicAuthenticationEncoder;
import org.springframework.security.rsocket.metadata.UsernamePasswordMetadata;
Expand All @@ -36,6 +34,7 @@

/**
* @author Rob Winch
* @author Eddú Meléndez
* @since 5.0
*/
@RunWith(SpringRunner.class)
Expand All @@ -46,13 +45,16 @@ public class HelloRSocketApplicationITests {
@Autowired
RSocketRequester.Builder requester;

@LocalRSocketServerPort
int port;

@Test
public void messageWhenAuthenticatedThenSuccess() {
UsernamePasswordMetadata credentials = new UsernamePasswordMetadata("user", "password");
RSocketRequester requester = this.requester
.rsocketStrategies(builder -> builder.encoder(new BasicAuthenticationEncoder()))
.setupMetadata(credentials, BASIC_AUTHENTICATION_MIME_TYPE)
.connectTcp("localhost", getPort())
.connectTcp("localhost", this.port)
.block();

String message = requester.route("message")
Expand All @@ -66,7 +68,7 @@ public void messageWhenAuthenticatedThenSuccess() {
@Test
public void messageWhenNotAuthenticatedThenError() {
RSocketRequester requester = this.requester
.connectTcp("localhost", getPort())
.connectTcp("localhost", this.port)
.block();

assertThatThrownBy(() -> requester.route("message")
Expand All @@ -76,23 +78,4 @@ public void messageWhenNotAuthenticatedThenError() {
.isNotNull();
}

// FIXME: Waiting for @LocalRSocketServerPort
// https://github.com/spring-projects/spring-boot/pull/18287

@Autowired
Config config;

private int getPort() {
return this.config.port;
}

@TestConfiguration
static class Config implements ApplicationListener<RSocketServerInitializedEvent> {
private int port;

@Override
public void onApplicationEvent(RSocketServerInitializedEvent event) {
this.port = event.getServer().address().getPort();
}
}
}