Skip to content

Commit 87408e4

Browse files
committed
add unit test for plain text scenarios
1 parent 47762d0 commit 87408e4

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerOptions.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1631,6 +1631,7 @@ public Builder usePlainText() {
16311631
this.experimentalHost = "http://" + this.experimentalHost;
16321632
super.setHost(this.experimentalHost);
16331633
}
1634+
this.usePlainText = true;
16341635
return this;
16351636
}
16361637

google-cloud-spanner/src/test/java/com/google/cloud/spanner/SpannerOptionsTest.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,4 +1199,27 @@ public void testExperimentalHostOptions() {
11991199
assertTrue(options.getSessionPoolOptions().getUseMultiplexedSessionForRW());
12001200
assertTrue(options.getSessionPoolOptions().getUseMultiplexedSessionPartitionedOps());
12011201
}
1202+
1203+
@Test
1204+
public void testPlainTextOptions() {
1205+
SpannerOptions options =
1206+
SpannerOptions.newBuilder().setExperimentalHost("localhost:8080").usePlainText().build();
1207+
assertEquals("http://localhost:8080", options.getHost());
1208+
assertEquals(NoCredentials.getInstance(), options.getCredentials());
1209+
options =
1210+
SpannerOptions.newBuilder()
1211+
.setExperimentalHost("http://localhost:8080")
1212+
.usePlainText()
1213+
.build();
1214+
assertEquals("http://localhost:8080", options.getHost());
1215+
options =
1216+
SpannerOptions.newBuilder().usePlainText().setExperimentalHost("localhost:8080").build();
1217+
assertEquals("http://localhost:8080", options.getHost());
1218+
options =
1219+
SpannerOptions.newBuilder()
1220+
.usePlainText()
1221+
.setExperimentalHost("http://localhost:8080")
1222+
.build();
1223+
assertEquals("http://localhost:8080", options.getHost());
1224+
}
12021225
}

0 commit comments

Comments
 (0)