21
21
import static org .mockito .Mockito .when ;
22
22
23
23
import java .net .URI ;
24
+ import java .net .URISyntaxException ;
24
25
import org .junit .Assert ;
25
26
import org .junit .Before ;
26
27
import org .junit .Test ;
33
34
import software .amazon .awssdk .core .client .config .ClientOverrideConfiguration ;
34
35
import software .amazon .awssdk .core .client .config .SdkAdvancedClientOption ;
35
36
import software .amazon .awssdk .core .exception .SdkClientException ;
36
- import software .amazon .awssdk .http .ExecuteRequest ;
37
- import software .amazon .awssdk .http .InvokeableHttpRequest ;
37
+ import software .amazon .awssdk .http .ExecutableHttpRequest ;
38
+ import software .amazon .awssdk .http .HttpExecuteRequest ;
38
39
import software .amazon .awssdk .http .SdkHttpClient ;
39
40
import software .amazon .awssdk .http .SdkHttpRequest ;
40
41
import software .amazon .awssdk .regions .Region ;
@@ -50,7 +51,7 @@ public class EndpointTraitTest {
50
51
private SdkHttpClient mockHttpClient ;
51
52
52
53
@ Mock
53
- private InvokeableHttpRequest abortableCallable ;
54
+ private ExecutableHttpRequest abortableCallable ;
54
55
55
56
private ProtocolJsonEndpointTraitClient client ;
56
57
@@ -71,32 +72,39 @@ public void setup() throws Exception {
71
72
}
72
73
73
74
@ Test
74
- public void hostExpression_withoutInputMemberLabel () {
75
+ public void hostExpression_withoutInputMemberLabel () throws URISyntaxException {
75
76
try {
76
77
client .endpointTraitOne (EndpointTraitOneRequest .builder ().build ());
77
78
Assert .fail ("Expected an exception" );
78
79
} catch (SdkClientException exception ) {
79
- ArgumentCaptor <ExecuteRequest > httpRequestCaptor = ArgumentCaptor .forClass (ExecuteRequest .class );
80
+ ArgumentCaptor <HttpExecuteRequest > httpRequestCaptor = ArgumentCaptor .forClass (HttpExecuteRequest .class );
80
81
verify (mockHttpClient ).prepareRequest (httpRequestCaptor .capture ());
81
82
82
83
SdkHttpRequest request = httpRequestCaptor .getAllValues ().get (0 ).httpRequest ();
83
84
assertThat (request .host ()).isEqualTo ("data.localhost.com" );
85
+ assertThat (request .port ()).isEqualTo (443 );
86
+ assertThat (request .encodedPath ()).isEqualTo ("/" );
87
+ assertThat (request .getUri ()).isEqualTo (new URI ("http://data.localhost.com:443/" ));
84
88
}
85
89
}
86
90
87
91
@ Test
88
- public void hostExpression_withInputMemberLabel () {
92
+ public void hostExpression_withInputMemberLabel () throws URISyntaxException {
89
93
try {
90
94
client .endpointTraitTwo (EndpointTraitTwoRequest .builder ()
91
95
.stringMember ("123456" )
96
+ .pathIdempotentToken ("dummypath" )
92
97
.build ());
93
98
Assert .fail ("Expected an exception" );
94
99
} catch (SdkClientException exception ) {
95
- ArgumentCaptor <ExecuteRequest > httpRequestCaptor = ArgumentCaptor .forClass (ExecuteRequest .class );
100
+ ArgumentCaptor <HttpExecuteRequest > httpRequestCaptor = ArgumentCaptor .forClass (HttpExecuteRequest .class );
96
101
verify (mockHttpClient ).prepareRequest (httpRequestCaptor .capture ());
97
102
98
103
SdkHttpRequest request = httpRequestCaptor .getAllValues ().get (0 ).httpRequest ();
99
104
assertThat (request .host ()).isEqualTo ("123456-localhost.com" );
105
+ assertThat (request .port ()).isEqualTo (443 );
106
+ assertThat (request .encodedPath ()).isEqualTo ("/dummypath" );
107
+ assertThat (request .getUri ()).isEqualTo (new URI ("http://123456-localhost.com:443/dummypath" ));
100
108
}
101
109
}
102
110
@@ -116,7 +124,7 @@ public void clientWithDisabledHostPrefix_withoutInputMemberLabel_usesOriginalUri
116
124
clientWithDisabledHostPrefix .endpointTraitOne (EndpointTraitOneRequest .builder ().build ());
117
125
Assert .fail ("Expected an exception" );
118
126
} catch (SdkClientException exception ) {
119
- ArgumentCaptor <ExecuteRequest > httpRequestCaptor = ArgumentCaptor .forClass (ExecuteRequest .class );
127
+ ArgumentCaptor <HttpExecuteRequest > httpRequestCaptor = ArgumentCaptor .forClass (HttpExecuteRequest .class );
120
128
verify (mockHttpClient ).prepareRequest (httpRequestCaptor .capture ());
121
129
122
130
SdkHttpRequest request = httpRequestCaptor .getAllValues ().get (0 ).httpRequest ();
@@ -132,7 +140,7 @@ public void clientWithDisabledHostPrefix_withInputMemberLabel_usesOriginalUri()
132
140
.build ());
133
141
Assert .fail ("Expected an exception" );
134
142
} catch (SdkClientException exception ) {
135
- ArgumentCaptor <ExecuteRequest > httpRequestCaptor = ArgumentCaptor .forClass (ExecuteRequest .class );
143
+ ArgumentCaptor <HttpExecuteRequest > httpRequestCaptor = ArgumentCaptor .forClass (HttpExecuteRequest .class );
136
144
verify (mockHttpClient ).prepareRequest (httpRequestCaptor .capture ());
137
145
138
146
SdkHttpRequest request = httpRequestCaptor .getAllValues ().get (0 ).httpRequest ();
@@ -145,7 +153,7 @@ private StaticCredentialsProvider mockCredentials() {
145
153
}
146
154
147
155
private String getEndpoint () {
148
- return "http://localhost.com" ;
156
+ return "http://localhost.com:443 " ;
149
157
}
150
158
151
159
private ProtocolJsonEndpointTraitClientBuilder clientBuilder () {
0 commit comments