File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed
src/test/java/org/springframework/data/redis/connection/lettuce Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change 21
21
import static org .junit .Assert .*;
22
22
import static org .junit .Assume .*;
23
23
24
- import io .lettuce .core .ReadFrom ;
25
24
import io .lettuce .core .EpollProvider ;
26
25
import io .lettuce .core .KqueueProvider ;
26
+ import io .lettuce .core .ReadFrom ;
27
27
import io .lettuce .core .RedisException ;
28
28
import io .lettuce .core .api .async .RedisAsyncCommands ;
29
29
import io .lettuce .core .api .reactive .BaseRedisReactiveCommands ;
Original file line number Diff line number Diff line change 35
35
import org .junit .runners .Parameterized ;
36
36
import org .junit .runners .Parameterized .Parameters ;
37
37
import org .springframework .data .redis .ConnectionFactoryTracker ;
38
+ import org .springframework .data .redis .SettingsUtils ;
38
39
import org .springframework .data .redis .connection .AbstractConnectionIntegrationTests ;
39
40
import org .springframework .data .redis .connection .DefaultStringRedisConnection ;
41
+ import org .springframework .data .redis .connection .RedisConnection ;
40
42
import org .springframework .data .redis .connection .RedisSentinelConfiguration ;
41
43
import org .springframework .data .redis .connection .RedisSentinelConnection ;
42
44
import org .springframework .data .redis .connection .RedisServer ;
@@ -210,4 +212,26 @@ public void factoryWithReadFromSlaveSettings() {
210
212
connection .close ();
211
213
}
212
214
}
215
+
216
+ @ Test // DATAREDIS-580
217
+ public void factoryUsesMasterSlaveConnections () {
218
+
219
+ LettuceClientConfiguration configuration = LettuceTestClientConfiguration .builder ().readFrom (ReadFrom .SLAVE )
220
+ .build ();
221
+
222
+ LettuceConnectionFactory factory = new LettuceConnectionFactory (SettingsUtils .standaloneConfiguration (),
223
+ configuration );
224
+ factory .afterPropertiesSet ();
225
+
226
+ RedisConnection connection = factory .getConnection ();
227
+
228
+ try {
229
+ assertThat (connection .ping (), is (equalTo ("PONG" )));
230
+ assertThat (connection .info ().getProperty ("role" ), is (equalTo ("slave" )));
231
+ } finally {
232
+ this .connection .close ();
233
+ }
234
+
235
+ factory .destroy ();
236
+ }
213
237
}
You can’t perform that action at this time.
0 commit comments