File tree Expand file tree Collapse file tree
gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3838import com .google .api .gax .rpc .StreamController ;
3939import com .google .auth .Credentials ;
4040import com .google .protobuf .Field ;
41- import java .io .IOException ;
4241import java .util .Collections ;
4342import java .util .HashMap ;
4443import java .util .List ;
@@ -89,17 +88,17 @@ class BodySizeRecordingTest {
8988 private TestApiTracer tracer ;
9089
9190 @ BeforeAll
92- public static void initialize () {
91+ static void initialize () {
9392 executorService = Executors .newFixedThreadPool (2 );
9493 }
9594
9695 @ AfterAll
97- public static void destroy () {
96+ static void destroy () {
9897 executorService .shutdownNow ();
9998 }
10099
101100 @ BeforeEach
102- void setUp () throws IOException {
101+ void setUp () {
103102 channel =
104103 ManagedHttpJsonChannel .newBuilder ()
105104 .setEndpoint ("google.com:443" )
@@ -189,7 +188,9 @@ void testBodySizeRecordingServerStreaming() throws Exception {
189188 request ,
190189 new ResponseObserver <Field >() {
191190 @ Override
192- public void onStart (StreamController controller ) {}
191+ public void onStart (StreamController controller ) {
192+ // no behavior needed
193+ }
193194
194195 @ Override
195196 public void onResponse (Field response ) {
Original file line number Diff line number Diff line change @@ -252,6 +252,16 @@ void testMergeWithTracer() {
252252 .isSameInstanceAs (defaultTracer );
253253 }
254254
255+ @ Test
256+ void testWithTracer () {
257+ ApiTracer tracer = Mockito .mock (ApiTracer .class );
258+ HttpJsonCallContext emptyContext = HttpJsonCallContext .createDefault ();
259+ // Default context has a default tracer.
260+ assertNotNull (emptyContext .getTracer ());
261+ HttpJsonCallContext context = emptyContext .withTracer (tracer );
262+ Truth .assertThat (context .getTracer ()).isSameInstanceAs (tracer );
263+ }
264+
255265 @ Test
256266 void testWithRetrySettings () {
257267 RetrySettings retrySettings = Mockito .mock (RetrySettings .class );
Original file line number Diff line number Diff line change 3131
3232import static com .google .api .gax .util .TimeConversionTestUtils .testDurationMethod ;
3333import static com .google .api .gax .util .TimeConversionTestUtils .testInstantMethod ;
34+ import static com .google .common .truth .Truth .assertThat ;
3435
36+ import com .google .api .gax .tracing .ApiTracer ;
3537import org .junit .jupiter .api .Test ;
38+ import org .mockito .Mockito ;
3639
3740public class HttpJsonCallOptionsTest {
3841 private final HttpJsonCallOptions .Builder OPTIONS_BUILDER = HttpJsonCallOptions .newBuilder ();
3942
43+ @ Test
44+ public void testTracer () {
45+ ApiTracer tracer = Mockito .mock (ApiTracer .class );
46+ HttpJsonCallOptions options = OPTIONS_BUILDER .setTracer (tracer ).build ();
47+ assertThat (options .getTracer ()).isSameInstanceAs (tracer );
48+ }
49+
4050 @ Test
4151 public void testDeadline () {
4252 final long millis = 3 ;
You can’t perform that action at this time.
0 commit comments