5656@ RunWith (JUnit4 .class )
5757public class CallOptionsTest {
5858 private String sampleAuthority = "authority" ;
59+ private String sampleCompressor = "compressor" ;
5960 private Deadline .Ticker ticker = new DeadlineTest .FakeTicker ();
6061 private Deadline sampleDeadline = Deadline .after (1 , NANOSECONDS , ticker );
6162 private Key <String > sampleKey = Attributes .Key .of ("sample" );
6263 private Attributes sampleAffinity = Attributes .newBuilder ().set (sampleKey , "blah" ).build ();
6364 private CallCredentials sampleCreds = mock (CallCredentials .class );
65+ private CallOptions .Key <String > option1 = CallOptions .Key .of ("option1" , "default" );
66+ private CallOptions .Key <String > option2 = CallOptions .Key .of ("option2" , "default" );
6467 private CallOptions allSet = CallOptions .DEFAULT
6568 .withAuthority (sampleAuthority )
6669 .withDeadline (sampleDeadline )
6770 .withAffinity (sampleAffinity )
6871 .withCredentials (sampleCreds )
69- .withWaitForReady ();
70- private CallOptions .Key <String > option1 = CallOptions .Key .of ("option1" , "default" );
71- private CallOptions .Key <String > option2 = CallOptions .Key .of ("option2" , "default" );
72+ .withCompression (sampleCompressor )
73+ .withWaitForReady ()
74+ .withExecutor (directExecutor ())
75+ .withOption (option1 , "value1" )
76+ .withOption (option2 , "value2" );
7277
7378 @ Test
7479 public void defaultsAreAllNull () {
@@ -77,6 +82,7 @@ public void defaultsAreAllNull() {
7782 assertThat (CallOptions .DEFAULT .getAffinity ()).isEqualTo (Attributes .EMPTY );
7883 assertThat (CallOptions .DEFAULT .getExecutor ()).isNull ();
7984 assertThat (CallOptions .DEFAULT .getCredentials ()).isNull ();
85+ assertThat (CallOptions .DEFAULT .getCompressor ()).isNull ();
8086 assertThat (CallOptions .DEFAULT .isWaitForReady ()).isFalse ();
8187 }
8288
@@ -93,6 +99,10 @@ public void allWiths() {
9399 assertThat (allSet .getDeadline ()).isSameAs (sampleDeadline );
94100 assertThat (allSet .getAffinity ()).isSameAs (sampleAffinity );
95101 assertThat (allSet .getCredentials ()).isSameAs (sampleCreds );
102+ assertThat (allSet .getCompressor ()).isSameAs (sampleCompressor );
103+ assertThat (allSet .getExecutor ()).isSameAs (directExecutor ());
104+ assertThat (allSet .getOption (option1 )).isSameAs ("value1" );
105+ assertThat (allSet .getOption (option2 )).isSameAs ("value2" );
96106 assertThat (allSet .isWaitForReady ()).isTrue ();
97107 }
98108
@@ -150,8 +160,8 @@ public void withDeadlineAfter() {
150160 public void toStringMatches_noDeadline_default () {
151161 String expected = "CallOptions{deadline=null, authority=authority, callCredentials=null, "
152162 + "affinity={sample=blah}, "
153- + "executor=class io.grpc.internal.SerializingExecutor, compressorName=null , "
154- + "customOptions=[], waitForReady=false }" ;
163+ + "executor=class io.grpc.internal.SerializingExecutor, compressorName=compressor , "
164+ + "customOptions=[[option2, value2 ], [option1, value1]], waitForReady=true }" ;
155165 String actual = allSet
156166 .withDeadline (null )
157167 .withExecutor (new SerializingExecutor (directExecutor ()))
0 commit comments