25
25
import io .clientcore .core .http .pipeline .HttpPipelineBuilder ;
26
26
import io .clientcore .core .implementation .http .ContentType ;
27
27
import io .clientcore .core .instrumentation .logging .ClientLogger ;
28
+ import io .clientcore .core .models .CoreException ;
28
29
import io .clientcore .core .models .binarydata .BinaryData ;
29
30
import io .clientcore .core .serialization .ObjectSerializer ;
30
31
import io .clientcore .core .serialization .SerializationFormat ;
@@ -1041,32 +1042,7 @@ public void putRequestWithBodyAndEqualContentLength() {
1041
1042
assertEquals ("4" , json .getHeaderValue ("Content-Length" ));
1042
1043
}
1043
1044
1044
- @ Test
1045
- public void putRequestWithBodyLessThanContentLength () {
1046
- ByteBuffer body = ByteBuffer .wrap ("test" .getBytes (StandardCharsets .UTF_8 ));
1047
- Exception unexpectedLengthException = assertThrows (Exception .class , () -> {
1048
- createService (TestInterfaceClientImpl .TestInterfaceClientService .class )
1049
- .putBodyAndContentLength (getRequestUri (), body , 5L );
1050
- body .clear ();
1051
- });
1052
-
1053
- assertTrue (unexpectedLengthException .getMessage ().contains ("less than" ));
1054
- }
1055
-
1056
- @ Test
1057
- @ Disabled ("Add support for content length validation - confirm if service should not handle it" )
1058
- public void putRequestWithBodyMoreThanContentLength () {
1059
- ByteBuffer body = ByteBuffer .wrap ("test" .getBytes (StandardCharsets .UTF_8 ));
1060
- Exception unexpectedLengthException = assertThrows (Exception .class , () -> {
1061
- createService (TestInterfaceClientImpl .TestInterfaceClientService .class )
1062
- .putBodyAndContentLength (getRequestUri (), body , 3L );
1063
- body .clear ();
1064
- });
1065
-
1066
- assertTrue (unexpectedLengthException .getMessage ().contains ("more than" ));
1067
- }
1068
-
1069
- @ Test
1045
+ @ Disabled ("Confirm behavior" )
1070
1046
public void putRequestWithUnexpectedResponseAndNoFallthroughExceptionType () {
1071
1047
HttpResponseException e = assertThrows (HttpResponseException .class ,
1072
1048
() -> createService (TestInterfaceClientImpl .TestInterfaceClientService .class )
@@ -1082,7 +1058,7 @@ public void putRequestWithUnexpectedResponseAndNoFallthroughExceptionType() {
1082
1058
}
1083
1059
1084
1060
@ Test
1085
- public void headRequest () throws IOException {
1061
+ public void headRequest () {
1086
1062
try (Response <Void > response
1087
1063
= createService (TestInterfaceClientImpl .TestInterfaceClientService .class ).head (getRequestUri ())) {
1088
1064
assertNull (response .getValue ());
@@ -1286,11 +1262,11 @@ public void service20GetResponseBody() {
1286
1262
}
1287
1263
1288
1264
@ Test
1289
- public void unexpectedHTTPOK () {
1290
- HttpResponseException e = assertThrows (HttpResponseException .class ,
1265
+ public void unexpectedHTTPOKDeserializeError () {
1266
+ CoreException e = assertThrows (CoreException .class ,
1291
1267
() -> createService (TestInterfaceClientImpl .TestInterfaceClientService .class ).getBytes (getRequestUri ()));
1292
1268
1293
- assertEquals ( "Status code 200, (1024-byte body)" , e .getMessage ());
1269
+ assertTrue ( e .getMessage (). startsWith ( "Unexpected character" ));
1294
1270
}
1295
1271
1296
1272
@ Test
@@ -1442,19 +1418,9 @@ public void voidDoesNotEagerlyReadResponse(
1442
1418
(uri , service28 ) -> service28 .headResponseVoid (uri ));
1443
1419
}
1444
1420
1445
- @ ParameterizedTest
1446
- @ MethodSource ("voidErrorReturnsErrorBodySupplier" )
1447
- public void
1448
- voidErrorReturnsErrorBody (BiConsumer <String , TestInterfaceClientImpl .TestInterfaceClientService > executable ) {
1449
- HttpResponseException exception = assertThrows (HttpResponseException .class , () -> executable
1450
- .accept (getServerUri (isSecure ()), createService (TestInterfaceClientImpl .TestInterfaceClientService .class )));
1451
-
1452
- assertTrue (exception .getMessage ().contains ("void exception body thrown" ));
1453
- }
1454
-
1455
1421
@ Test
1456
1422
@ Disabled ("https://github.com/Azure/azure-sdk-for-java/issues/44746" )
1457
- public void canReceiveServerSentEvents () throws IOException {
1423
+ public void canReceiveServerSentEvents () {
1458
1424
final int [] i = { 0 };
1459
1425
TestInterfaceClientImpl .TestInterfaceClientService service
1460
1426
= createService (TestInterfaceClientImpl .TestInterfaceClientService .class );
@@ -1488,7 +1454,7 @@ public void canReceiveServerSentEvents() throws IOException {
1488
1454
*/
1489
1455
@ Test
1490
1456
@ Disabled ("https://github.com/Azure/azure-sdk-for-java/issues/44746" )
1491
- public void canRecognizeServerSentEvent () throws IOException {
1457
+ public void canRecognizeServerSentEvent () {
1492
1458
BinaryData requestBody = BinaryData .fromString ("test body" );
1493
1459
TestInterfaceClientImpl .TestInterfaceClientService service
1494
1460
= createService (TestInterfaceClientImpl .TestInterfaceClientService .class );
@@ -1568,14 +1534,8 @@ public void throwsExceptionForNoListener() {
1568
1534
assertThrows (RuntimeException .class , () -> service .put (getServerUri (isSecure ()), requestBody , null ).close ());
1569
1535
}
1570
1536
1571
- private static Stream <BiConsumer <String , TestInterfaceClientImpl .TestInterfaceClientService >>
1572
- voidErrorReturnsErrorBodySupplier () {
1573
- return Stream .of ((uri , service29 ) -> service29 .headvoid (uri ), (uri , service29 ) -> service29 .headVoid (uri ),
1574
- (uri , service29 ) -> service29 .headResponseVoid (uri ));
1575
- }
1576
-
1577
1537
@ Test
1578
- public void bodyIsPresentWhenNoBodyHandlingOptionIsSet () throws IOException {
1538
+ public void bodyIsPresentWhenNoBodyHandlingOptionIsSet () {
1579
1539
TestInterfaceClientImpl .TestInterfaceClientService service
1580
1540
= createService (TestInterfaceClientImpl .TestInterfaceClientService .class );
1581
1541
HttpBinJSON httpBinJSON = service .put (getServerUri (isSecure ()), 42 , null );
0 commit comments