16
16
17
17
package org .springframework .cloud .function .rsocket ;
18
18
19
+ import java .time .Duration ;
19
20
import java .util .function .Function ;
20
21
21
- import io .rsocket .routing .client .spring .RoutingMetadata ;
22
+ import io .rsocket .broker .client .spring .BrokerMetadata ;
22
23
import org .junit .jupiter .api .AfterEach ;
23
24
import org .junit .jupiter .api .Disabled ;
24
25
import org .junit .jupiter .api .Test ;
@@ -64,7 +65,7 @@ public void cleanup() {
64
65
public void testRoutingWithProperty () throws Exception {
65
66
this .setup (true );
66
67
RSocketRequester requester = clientContext .getBean (RSocketRequester .class );
67
- // route(uppercase) used to find function, must match io.rsocket.routing .client.address entry
68
+ // route(uppercase) used to find function, must match io.rsocket.broker .client.address entry
68
69
Mono <String > result = requester .route ("uppercase" )
69
70
// auto creates metadata
70
71
.data ("\" hello\" " )
@@ -74,14 +75,14 @@ public void testRoutingWithProperty() throws Exception {
74
75
.create (result )
75
76
.expectNext ("HELLO" )
76
77
.expectComplete ()
77
- .verify ();
78
+ .verify (Duration . ofSeconds ( 15 ) );
78
79
}
79
80
80
81
@ Test
81
82
public void testRoutingWithMessage () throws Exception {
82
83
this .setup (false );
83
84
RSocketRequester requester = clientContext .getBean (RSocketRequester .class );
84
- RoutingMetadata metadata = clientContext .getBean (RoutingMetadata .class );
85
+ BrokerMetadata metadata = clientContext .getBean (BrokerMetadata .class );
85
86
Mono <String > result = requester .route ("uppercase" ) // used to find function
86
87
.metadata (metadata .address ("samplefn" ))
87
88
.data ("\" hello\" " )
@@ -91,41 +92,40 @@ public void testRoutingWithMessage() throws Exception {
91
92
.create (result )
92
93
.expectNext ("HELLO" )
93
94
.expectComplete ()
94
- .verify ();
95
+ .verify (Duration . ofSeconds ( 15 ) );
95
96
}
96
97
97
98
private void setup (boolean routingWithProperty ) {
98
- int routingBrokerProxyPort = SocketUtils .findAvailableTcpPort ();
99
- int routingBrokerClusterPort = SocketUtils .findAvailableTcpPort ();
99
+ int brokerProxyPort = SocketUtils .findAvailableTcpPort ();
100
+ int brokerClusterPort = SocketUtils .findAvailableTcpPort ();
100
101
// start broker
101
102
brokerContext = new SpringApplicationBuilder (SimpleConfiguration .class ).web (WebApplicationType .NONE ).run (
102
- "--logging.level.io.rsocket.routing. broker=TRACE" ,
103
+ "--logging.level.io.rsocket.broker=TRACE" ,
103
104
"--spring.cloud.function.rsocket.enabled=false" ,
104
- "--io.rsocket.routing .client.enabled=false" ,
105
- "--io.rsocket.routing. broker.enabled=true" ,
106
- "--io.rsocket.routing. broker.tcp.port= " + routingBrokerProxyPort ,
107
- "--io.rsocket.routing. broker.cluster.port= " + routingBrokerClusterPort );
105
+ "--io.rsocket.broker .client.enabled=false" ,
106
+ "--io.rsocket.broker.enabled=true" ,
107
+ "--io.rsocket.broker.uri=tcp://localhost: " + brokerProxyPort ,
108
+ "--io.rsocket.broker.cluster.uri=tcp://localhost: " + brokerClusterPort );
108
109
109
110
// start function connecting to broker, service-name=samplefn
110
111
functionContext = new SpringApplicationBuilder (SampleFunctionConfiguration .class ).web (WebApplicationType .NONE )
111
112
.run ("--logging.level.org.springframework.cloud.function=DEBUG" ,
112
- "--io.rsocket.routing .client.enabled=true " ,
113
- "--io.rsocket.routing .client.service-name=samplefn " ,
114
- "--io.rsocket.routing .client.brokers[0].tcp.host=localhost " ,
115
- "--io.rsocket.routing .client.brokers[0].tcp.port= " + routingBrokerProxyPort ,
116
- "--io.rsocket.routing. broker.enabled=false" ,
113
+ "--logging.level. io.rsocket.broker .client=TRACE " ,
114
+ "--io.rsocket.broker .client.enabled=true " ,
115
+ "--io.rsocket.broker .client.service-name=samplefn " ,
116
+ "--io.rsocket.broker .client.brokers[0]=tcp://localhost: " + brokerProxyPort ,
117
+ "--io.rsocket.broker.enabled=false" ,
117
118
"--spring.cloud.function.definition=uppercase" );
118
119
119
120
// start testclient connecting to broker, for RSocketRequester
120
121
clientContext = new SpringApplicationBuilder (SimpleConfiguration .class ).web (WebApplicationType .NONE ).run (
121
- "--logging.level.io.rsocket.routing .client=TRACE" ,
122
+ "--logging.level.io.rsocket.broker .client=TRACE" ,
122
123
"--spring.cloud.function.rsocket.enabled=false" ,
123
- "--io.rsocket.routing.client.enabled=true" ,
124
- "--io.rsocket.routing.client.service-name=testclient" ,
125
- routingWithProperty ? "--io.rsocket.routing.client.address.uppercase.service_name=samplefn" : "" ,
126
- "--io.rsocket.routing.client.brokers[0].tcp.host=localhost" ,
127
- "--io.rsocket.routing.client.brokers[0].tcp.port=" + routingBrokerProxyPort ,
128
- "--io.rsocket.routing.broker.enabled=false" );
124
+ "--io.rsocket.broker.client.enabled=true" ,
125
+ "--io.rsocket.broker.client.service-name=testclient" ,
126
+ routingWithProperty ? "--io.rsocket.broker.client.address.uppercase.service_name=samplefn" : "" ,
127
+ "--io.rsocket.broker.client.brokers[0]=tcp://localhost:" + brokerProxyPort ,
128
+ "--io.rsocket.broker.enabled=false" );
129
129
}
130
130
131
131
@@ -140,9 +140,7 @@ public static class SimpleConfiguration {
140
140
public static class SampleFunctionConfiguration {
141
141
@ Bean
142
142
public Function <String , String > uppercase () {
143
- return v -> {
144
- return v .toUpperCase ();
145
- };
143
+ return v -> v .toUpperCase ();
146
144
}
147
145
}
148
146
}
0 commit comments