3535import  io .opentelemetry .testing .internal .armeria .common .MediaType ;
3636import  io .opentelemetry .testing .internal .armeria .common .ResponseHeaders ;
3737import  io .opentelemetry .testing .internal .armeria .testing .junit5 .server .mock .RecordedRequest ;
38+ import  java .lang .reflect .InvocationTargetException ;
3839import  java .lang .reflect .Method ;
3940import  java .net .URI ;
4041import  java .nio .charset .StandardCharsets ;
4142import  java .time .Duration ;
4243import  java .util .ArrayList ;
4344import  java .util .List ;
4445import  java .util .concurrent .Callable ;
46+ import  java .util .concurrent .ExecutionException ;
4547import  java .util .concurrent .Future ;
4648import  java .util .function .Function ;
4749import  java .util .stream .Stream ;
@@ -96,7 +98,7 @@ private static void assumeSupportedConfig(String operation) {
9698  // Force localhost instead of relying on mock server because using ip is yet another corner case 
9799  // of the virtual bucket changes introduced by aws sdk v2.18.0. When using IP, there is no way to 
98100  // prefix the hostname with the bucket name as label. 
99-   URI  clientUri  = URI .create ("http://localhost:"  + server .httpPort ());
101+   private   final   URI  clientUri  = URI .create ("http://localhost:"  + server .httpPort ());
100102
101103  private  static  final  String  ec2BodyContent  =
102104      "<AllocateAddressResponse xmlns=\" http://ec2.amazonaws.com/doc/2016-11-15/\" >" 
@@ -110,26 +112,6 @@ private static void assumeSupportedConfig(String operation) {
110112          + " <ResponseMetadata><RequestId>0ac9cda2-bbf4-11d3-f92b-31fa5e8dbc99</RequestId></ResponseMetadata>" 
111113          + "</DeleteOptionGroupResponse>" ;
112114
113-   S3ClientBuilder  s3ClientBuilder () throws  Exception  {
114-     S3ClientBuilder  builder  = S3Client .builder ();
115-     if  (Boolean .getBoolean ("testLatestDeps" )) {
116-       Method  forcePathStyleMethod  =
117-           S3ClientBuilder .class .getMethod ("forcePathStyle" , Boolean .class );
118-       forcePathStyleMethod .invoke (builder , true );
119-     }
120-     return  builder ;
121-   }
122- 
123-   S3AsyncClientBuilder  s3AsyncClientBuilder () throws  Exception  {
124-     S3AsyncClientBuilder  builder  = S3AsyncClient .builder ();
125-     if  (Boolean .getBoolean ("testLatestDeps" )) {
126-       Method  forcePathStyleMethod  =
127-           S3AsyncClientBuilder .class .getMethod ("forcePathStyle" , Boolean .class );
128-       forcePathStyleMethod .invoke (builder , true );
129-     }
130-     return  builder ;
131-   }
132- 
133115  @ SuppressWarnings ("deprecation" ) // uses deprecated semconv 
134116  private  void  clientAssertions (
135117      String  service , String  operation , String  method , Object  response , String  requestId ) {
@@ -259,7 +241,12 @@ private static Stream<Arguments> provideS3Arguments() {
259241  @ MethodSource ("provideS3Arguments" )
260242  void  testS3SendOperationRequestWithBuilder (
261243      String  operation , String  method , Function <S3Client , Object > call ) throws  Exception  {
262-     S3ClientBuilder  builder  = s3ClientBuilder ();
244+     S3ClientBuilder  builder  = S3Client .builder ();
245+     if  (Boolean .getBoolean ("testLatestDeps" )) {
246+       Method  forcePathStyleMethod  =
247+           S3ClientBuilder .class .getMethod ("forcePathStyle" , Boolean .class );
248+       forcePathStyleMethod .invoke (builder , true );
249+     }
263250    configureSdkClient (builder );
264251    S3Client  client  =
265252        builder 
@@ -287,8 +274,17 @@ void testS3AsyncSendOperationRequestWithBuilder(
287274      Function <S3Client , Object > call ,
288275      Function <S3AsyncClient , Future <?>> asyncCall ,
289276      String  body )
290-       throws  Exception  {
291-     S3AsyncClientBuilder  builder  = s3AsyncClientBuilder ();
277+       throws  NoSuchMethodException ,
278+           InvocationTargetException ,
279+           IllegalAccessException ,
280+           ExecutionException ,
281+           InterruptedException  {
282+     S3AsyncClientBuilder  builder  = S3AsyncClient .builder ();
283+     if  (Boolean .getBoolean ("testLatestDeps" )) {
284+       Method  forcePathStyleMethod  =
285+           S3AsyncClientBuilder .class .getMethod ("forcePathStyle" , Boolean .class );
286+       forcePathStyleMethod .invoke (builder , true );
287+     }
292288    configureSdkClient (builder );
293289    S3AsyncClient  client  =
294290        builder 
@@ -519,14 +515,7 @@ void testEc2SendOperationRequestWithBuilder() throws Exception {
519515            .credentialsProvider (CREDENTIALS_PROVIDER )
520516            .build ();
521517
522-     String  content  =
523-         "<AllocateAddressResponse xmlns=\" http://ec2.amazonaws.com/doc/2016-11-15/\" >" 
524-             + " <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>" 
525-             + " <publicIp>192.0.2.1</publicIp>" 
526-             + " <domain>standard</domain>" 
527-             + "</AllocateAddressResponse>" ;
528- 
529-     server .enqueue (HttpResponse .of (HttpStatus .OK , MediaType .PLAIN_TEXT_UTF_8 , content ));
518+     server .enqueue (HttpResponse .of (HttpStatus .OK , MediaType .PLAIN_TEXT_UTF_8 , ec2BodyContent ));
530519    Object  response  = client .allocateAddress ();
531520
532521    assertThat (response .getClass ().getSimpleName ())
0 commit comments