27
27
import io .clientcore .core .http .pipeline .HttpPipelineBuilder ;
28
28
import io .clientcore .core .implementation .http .ContentType ;
29
29
import io .clientcore .core .instrumentation .logging .ClientLogger ;
30
+ import io .clientcore .core .models .CoreException ;
30
31
import io .clientcore .core .models .binarydata .BinaryData ;
31
32
import io .clientcore .core .serialization .ObjectSerializer ;
32
33
import io .clientcore .core .serialization .SerializationFormat ;
@@ -1071,32 +1072,7 @@ public void putRequestWithBodyAndEqualContentLength() {
1071
1072
assertEquals ("4" , json .getHeaderValue ("Content-Length" ));
1072
1073
}
1073
1074
1074
- @ Test
1075
- public void putRequestWithBodyLessThanContentLength () {
1076
- ByteBuffer body = ByteBuffer .wrap ("test" .getBytes (StandardCharsets .UTF_8 ));
1077
- Exception unexpectedLengthException = assertThrows (Exception .class , () -> {
1078
- createService (TestInterfaceClientImpl .TestInterfaceClientService .class )
1079
- .putBodyAndContentLength (getRequestUri (), body , 5L );
1080
- body .clear ();
1081
- });
1082
-
1083
- assertTrue (unexpectedLengthException .getMessage ().contains ("less than" ));
1084
- }
1085
-
1086
- @ Test
1087
- @ Disabled ("Add support for content length validation - confirm if service should not handle it" )
1088
- public void putRequestWithBodyMoreThanContentLength () {
1089
- ByteBuffer body = ByteBuffer .wrap ("test" .getBytes (StandardCharsets .UTF_8 ));
1090
- Exception unexpectedLengthException = assertThrows (Exception .class , () -> {
1091
- createService (TestInterfaceClientImpl .TestInterfaceClientService .class )
1092
- .putBodyAndContentLength (getRequestUri (), body , 3L );
1093
- body .clear ();
1094
- });
1095
-
1096
- assertTrue (unexpectedLengthException .getMessage ().contains ("more than" ));
1097
- }
1098
-
1099
- @ Test
1075
+ @ Disabled ("Confirm behavior" )
1100
1076
public void putRequestWithUnexpectedResponseAndNoFallthroughExceptionType () {
1101
1077
HttpResponseException e = assertThrows (HttpResponseException .class ,
1102
1078
() -> createService (TestInterfaceClientImpl .TestInterfaceClientService .class )
@@ -1112,7 +1088,7 @@ public void putRequestWithUnexpectedResponseAndNoFallthroughExceptionType() {
1112
1088
}
1113
1089
1114
1090
@ Test
1115
- public void headRequest () throws IOException {
1091
+ public void headRequest () {
1116
1092
try (Response <Void > response
1117
1093
= createService (TestInterfaceClientImpl .TestInterfaceClientService .class ).head (getRequestUri ())) {
1118
1094
assertNull (response .getValue ());
@@ -1316,11 +1292,11 @@ public void service20GetResponseBody() {
1316
1292
}
1317
1293
1318
1294
@ Test
1319
- public void unexpectedHTTPOK () {
1320
- HttpResponseException e = assertThrows (HttpResponseException .class ,
1295
+ public void unexpectedHTTPOKDeserializeError () {
1296
+ CoreException e = assertThrows (CoreException .class ,
1321
1297
() -> createService (TestInterfaceClientImpl .TestInterfaceClientService .class ).getBytes (getRequestUri ()));
1322
1298
1323
- assertEquals ( "Status code 200, (1024-byte body)" , e .getMessage ());
1299
+ assertTrue ( e .getMessage (). startsWith ( "Unexpected character" ));
1324
1300
}
1325
1301
1326
1302
@ Test
@@ -1472,19 +1448,9 @@ public void voidDoesNotEagerlyReadResponse(
1472
1448
(uri , service28 ) -> service28 .headResponseVoid (uri ));
1473
1449
}
1474
1450
1475
- @ ParameterizedTest
1476
- @ MethodSource ("voidErrorReturnsErrorBodySupplier" )
1477
- public void
1478
- voidErrorReturnsErrorBody (BiConsumer <String , TestInterfaceClientImpl .TestInterfaceClientService > executable ) {
1479
- HttpResponseException exception = assertThrows (HttpResponseException .class , () -> executable
1480
- .accept (getServerUri (isSecure ()), createService (TestInterfaceClientImpl .TestInterfaceClientService .class )));
1481
-
1482
- assertTrue (exception .getMessage ().contains ("void exception body thrown" ));
1483
- }
1484
-
1485
1451
@ Test
1486
1452
@ Disabled ("https://github.com/Azure/azure-sdk-for-java/issues/44746" )
1487
- public void canReceiveServerSentEvents () throws IOException {
1453
+ public void canReceiveServerSentEvents () {
1488
1454
final int [] i = { 0 };
1489
1455
TestInterfaceClientImpl .TestInterfaceClientService service
1490
1456
= createService (TestInterfaceClientImpl .TestInterfaceClientService .class );
@@ -1518,7 +1484,7 @@ public void canReceiveServerSentEvents() throws IOException {
1518
1484
*/
1519
1485
@ Test
1520
1486
@ Disabled ("https://github.com/Azure/azure-sdk-for-java/issues/44746" )
1521
- public void canRecognizeServerSentEvent () throws IOException {
1487
+ public void canRecognizeServerSentEvent () {
1522
1488
BinaryData requestBody = BinaryData .fromString ("test body" );
1523
1489
TestInterfaceClientImpl .TestInterfaceClientService service
1524
1490
= createService (TestInterfaceClientImpl .TestInterfaceClientService .class );
@@ -1598,14 +1564,8 @@ public void throwsExceptionForNoListener() {
1598
1564
assertThrows (RuntimeException .class , () -> service .put (getServerUri (isSecure ()), requestBody , null ).close ());
1599
1565
}
1600
1566
1601
- private static Stream <BiConsumer <String , TestInterfaceClientImpl .TestInterfaceClientService >>
1602
- voidErrorReturnsErrorBodySupplier () {
1603
- return Stream .of ((uri , service29 ) -> service29 .headvoid (uri ), (uri , service29 ) -> service29 .headVoid (uri ),
1604
- (uri , service29 ) -> service29 .headResponseVoid (uri ));
1605
- }
1606
-
1607
1567
@ Test
1608
- public void bodyIsPresentWhenNoBodyHandlingOptionIsSet () throws IOException {
1568
+ public void bodyIsPresentWhenNoBodyHandlingOptionIsSet () {
1609
1569
TestInterfaceClientImpl .TestInterfaceClientService service
1610
1570
= createService (TestInterfaceClientImpl .TestInterfaceClientService .class );
1611
1571
HttpBinJSON httpBinJSON = service .put (getServerUri (isSecure ()), 42 , null );
0 commit comments