Skip to content

Commit 446bb56

Browse files
committed
test: fix unavailable exception
1 parent 38ac1e6 commit 446bb56

File tree

1 file changed

+65
-2
lines changed
  • sdk-platform-java/java-showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it

1 file changed

+65
-2
lines changed

sdk-platform-java/java-showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITOtelTracing.java

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import static com.google.common.truth.Truth.assertThat;
3434
import static org.junit.Assert.assertThrows;
3535

36-
import com.google.api.client.http.javanet.NetHttpTransport;
3736
import com.google.api.gax.core.NoCredentialsProvider;
3837
import com.google.api.gax.retrying.RetrySettings;
3938
import com.google.api.gax.rpc.StatusCode;
@@ -328,7 +327,71 @@ void testTracing_retry_httpjson() throws Exception {
328327
.setTransportChannelProvider(
329328
EchoSettings.defaultHttpJsonTransportProviderBuilder()
330329
.setHttpTransport(
331-
new NetHttpTransport.Builder().doNotValidateCertificate().build())
330+
new com.google.api.client.http.HttpTransport() {
331+
@Override
332+
protected com.google.api.client.http.LowLevelHttpRequest buildRequest(
333+
String method, String url) {
334+
return new com.google.api.client.http.LowLevelHttpRequest() {
335+
@Override
336+
public void addHeader(String name, String value) {}
337+
338+
@Override
339+
public com.google.api.client.http.LowLevelHttpResponse execute() {
340+
return new com.google.api.client.http.LowLevelHttpResponse() {
341+
@Override
342+
public java.io.InputStream getContent() {
343+
return new java.io.ByteArrayInputStream("{}".getBytes());
344+
}
345+
346+
@Override
347+
public String getContentEncoding() {
348+
return null;
349+
}
350+
351+
@Override
352+
public long getContentLength() {
353+
return 2;
354+
}
355+
356+
@Override
357+
public String getContentType() {
358+
return "application/json";
359+
}
360+
361+
@Override
362+
public String getStatusLine() {
363+
return "HTTP/1.1 503 Service Unavailable";
364+
}
365+
366+
@Override
367+
public int getStatusCode() {
368+
return 503;
369+
}
370+
371+
@Override
372+
public String getReasonPhrase() {
373+
return "Service Unavailable";
374+
}
375+
376+
@Override
377+
public int getHeaderCount() {
378+
return 0;
379+
}
380+
381+
@Override
382+
public String getHeaderName(int index) {
383+
return null;
384+
}
385+
386+
@Override
387+
public String getHeaderValue(int index) {
388+
return null;
389+
}
390+
};
391+
}
392+
};
393+
}
394+
})
332395
.setEndpoint("http://localhost:7469")
333396
.build())
334397
.build();

0 commit comments

Comments
 (0)