Skip to content

Commit 4802a3e

Browse files
committed
test update
1 parent e892e7c commit 4802a3e

File tree

5 files changed

+18
-73
lines changed

5 files changed

+18
-73
lines changed

sdk/clientcore/annotation-processor-test/src/main/java/io/clientcore/annotation/processor/test/ParameterizedMultipleHostServiceImpl.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@
88
import io.clientcore.core.http.models.HttpRequest;
99
import io.clientcore.core.http.models.Response;
1010
import io.clientcore.core.http.pipeline.HttpPipeline;
11+
import io.clientcore.core.implementation.utils.UriEscapers;
1112
import io.clientcore.core.models.binarydata.BinaryData;
1213
import io.clientcore.annotation.processor.test.implementation.ParameterizedMultipleHostService;
1314
import io.clientcore.core.instrumentation.logging.ClientLogger;
1415
import io.clientcore.core.serialization.json.JsonSerializer;
1516
import io.clientcore.core.serialization.xml.XmlSerializer;
1617
import io.clientcore.core.utils.CoreUtils;
1718
import java.lang.reflect.ParameterizedType;
19+
import io.clientcore.core.utils.Base64Uri;
1820
import io.clientcore.core.serialization.SerializationFormat;
1921
import java.io.IOException;
2022
import io.clientcore.core.http.models.HttpResponseException;

sdk/clientcore/annotation-processor-test/src/main/java/io/clientcore/annotation/processor/test/SimpleXmlSerializableServiceImpl.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,16 @@
88
import io.clientcore.core.http.models.HttpRequest;
99
import io.clientcore.core.http.models.Response;
1010
import io.clientcore.core.http.pipeline.HttpPipeline;
11+
import io.clientcore.core.implementation.utils.UriEscapers;
1112
import io.clientcore.core.models.binarydata.BinaryData;
1213
import io.clientcore.annotation.processor.test.implementation.SimpleXmlSerializableService;
1314
import io.clientcore.core.instrumentation.logging.ClientLogger;
1415
import io.clientcore.core.serialization.json.JsonSerializer;
1516
import io.clientcore.core.serialization.xml.XmlSerializer;
16-
import java.lang.reflect.ParameterizedType;
17-
import io.clientcore.core.utils.CoreUtils;
1817
import io.clientcore.core.serialization.SerializationFormat;
18+
import io.clientcore.core.utils.CoreUtils;
19+
import java.lang.reflect.ParameterizedType;
20+
import io.clientcore.core.utils.Base64Uri;
1921
import java.io.IOException;
2022
import io.clientcore.core.http.models.HttpResponseException;
2123
import java.nio.charset.StandardCharsets;

sdk/clientcore/annotation-processor-test/src/main/java/io/clientcore/annotation/processor/test/implementation/TestInterfaceClientImpl.java

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -297,26 +297,6 @@ HttpBinJSON putBodyAndContentLength(@HostParam("uri") String uri,
297297
@BodyParam(ContentType.APPLICATION_OCTET_STREAM) ByteBuffer body,
298298
@HeaderParam("Content-Length") long contentLength);
299299

300-
@HttpRequestInformation(method = HttpMethod.PUT, path = "put", expectedStatusCodes = { 201 })
301-
HttpBinJSON putWithUnexpectedResponse(@HostParam("uri") String uri,
302-
@BodyParam(ContentType.APPLICATION_OCTET_STREAM) String putBody);
303-
304-
@HttpRequestInformation(method = HttpMethod.PUT, path = "put", expectedStatusCodes = { 201 })
305-
@UnexpectedResponseExceptionDetail(exceptionBodyClass = HttpBinJSON.class)
306-
HttpBinJSON putWithUnexpectedResponseAndExceptionType(@HostParam("uri") String uri,
307-
@BodyParam(ContentType.APPLICATION_OCTET_STREAM) String putBody);
308-
309-
@HttpRequestInformation(method = HttpMethod.PUT, path = "put", expectedStatusCodes = { 201 })
310-
@UnexpectedResponseExceptionDetail(statusCode = { 200 }, exceptionBodyClass = HttpBinJSON.class)
311-
HttpBinJSON putWithUnexpectedResponseAndDeterminedExceptionType(@HostParam("uri") String uri,
312-
@BodyParam(ContentType.APPLICATION_OCTET_STREAM) String putBody);
313-
314-
@HttpRequestInformation(method = HttpMethod.PUT, path = "put", expectedStatusCodes = { 201 })
315-
@UnexpectedResponseExceptionDetail(statusCode = { 400 })
316-
@UnexpectedResponseExceptionDetail(exceptionBodyClass = HttpBinJSON.class)
317-
HttpBinJSON putWithUnexpectedResponseAndFallthroughExceptionType(@HostParam("uri") String uri,
318-
@BodyParam(ContentType.APPLICATION_OCTET_STREAM) String putBody);
319-
320300
@HttpRequestInformation(method = HttpMethod.PUT, path = "put", expectedStatusCodes = { 201 })
321301
@UnexpectedResponseExceptionDetail(statusCode = { 400 }, exceptionBodyClass = HttpBinJSON.class)
322302
HttpBinJSON putWithUnexpectedResponseAndNoFallthroughExceptionType(@HostParam("uri") String uri,

sdk/clientcore/annotation-processor-test/src/main/java/io/clientcore/annotation/processor/test/implementation/TestInterfaceClientServiceImpl.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import io.clientcore.core.http.models.Response;
1313
import io.clientcore.core.http.models.ServerSentEventListener;
1414
import io.clientcore.core.http.pipeline.HttpPipeline;
15+
import io.clientcore.core.implementation.utils.UriEscapers;
1516
import io.clientcore.core.models.binarydata.BinaryData;
1617
import java.io.InputStream;
1718
import java.nio.ByteBuffer;
@@ -21,11 +22,11 @@
2122
import io.clientcore.core.instrumentation.logging.ClientLogger;
2223
import io.clientcore.core.serialization.json.JsonSerializer;
2324
import io.clientcore.core.serialization.xml.XmlSerializer;
25+
import io.clientcore.core.serialization.SerializationFormat;
2426
import io.clientcore.core.utils.CoreUtils;
2527
import java.lang.reflect.ParameterizedType;
2628
import java.util.LinkedHashMap;
27-
import io.clientcore.core.implementation.utils.UriEscapers;
28-
import io.clientcore.core.serialization.SerializationFormat;
29+
import io.clientcore.core.utils.Base64Uri;
2930
import java.util.stream.Collectors;
3031
import java.util.Arrays;
3132
import io.clientcore.core.http.models.HttpHeader;

sdk/clientcore/annotation-processor-test/src/test/java/io/clientcore/annotation/processor/test/TestInterfaceServiceClientGenerationTests.java

Lines changed: 9 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import io.clientcore.core.http.pipeline.HttpPipelineBuilder;
2828
import io.clientcore.core.implementation.http.ContentType;
2929
import io.clientcore.core.instrumentation.logging.ClientLogger;
30+
import io.clientcore.core.models.CoreException;
3031
import io.clientcore.core.models.binarydata.BinaryData;
3132
import io.clientcore.core.serialization.ObjectSerializer;
3233
import io.clientcore.core.serialization.SerializationFormat;
@@ -1071,32 +1072,7 @@ public void putRequestWithBodyAndEqualContentLength() {
10711072
assertEquals("4", json.getHeaderValue("Content-Length"));
10721073
}
10731074

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")
11001076
public void putRequestWithUnexpectedResponseAndNoFallthroughExceptionType() {
11011077
HttpResponseException e = assertThrows(HttpResponseException.class,
11021078
() -> createService(TestInterfaceClientImpl.TestInterfaceClientService.class)
@@ -1112,7 +1088,7 @@ public void putRequestWithUnexpectedResponseAndNoFallthroughExceptionType() {
11121088
}
11131089

11141090
@Test
1115-
public void headRequest() throws IOException {
1091+
public void headRequest() {
11161092
try (Response<Void> response
11171093
= createService(TestInterfaceClientImpl.TestInterfaceClientService.class).head(getRequestUri())) {
11181094
assertNull(response.getValue());
@@ -1316,11 +1292,11 @@ public void service20GetResponseBody() {
13161292
}
13171293

13181294
@Test
1319-
public void unexpectedHTTPOK() {
1320-
HttpResponseException e = assertThrows(HttpResponseException.class,
1295+
public void unexpectedHTTPOKDeserializeError() {
1296+
CoreException e = assertThrows(CoreException.class,
13211297
() -> createService(TestInterfaceClientImpl.TestInterfaceClientService.class).getBytes(getRequestUri()));
13221298

1323-
assertEquals("Status code 200, (1024-byte body)", e.getMessage());
1299+
assertTrue(e.getMessage().startsWith("Unexpected character"));
13241300
}
13251301

13261302
@Test
@@ -1472,19 +1448,9 @@ public void voidDoesNotEagerlyReadResponse(
14721448
(uri, service28) -> service28.headResponseVoid(uri));
14731449
}
14741450

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-
14851451
@Test
14861452
@Disabled("https://github.com/Azure/azure-sdk-for-java/issues/44746")
1487-
public void canReceiveServerSentEvents() throws IOException {
1453+
public void canReceiveServerSentEvents() {
14881454
final int[] i = { 0 };
14891455
TestInterfaceClientImpl.TestInterfaceClientService service
14901456
= createService(TestInterfaceClientImpl.TestInterfaceClientService.class);
@@ -1518,7 +1484,7 @@ public void canReceiveServerSentEvents() throws IOException {
15181484
*/
15191485
@Test
15201486
@Disabled("https://github.com/Azure/azure-sdk-for-java/issues/44746")
1521-
public void canRecognizeServerSentEvent() throws IOException {
1487+
public void canRecognizeServerSentEvent() {
15221488
BinaryData requestBody = BinaryData.fromString("test body");
15231489
TestInterfaceClientImpl.TestInterfaceClientService service
15241490
= createService(TestInterfaceClientImpl.TestInterfaceClientService.class);
@@ -1598,14 +1564,8 @@ public void throwsExceptionForNoListener() {
15981564
assertThrows(RuntimeException.class, () -> service.put(getServerUri(isSecure()), requestBody, null).close());
15991565
}
16001566

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-
16071567
@Test
1608-
public void bodyIsPresentWhenNoBodyHandlingOptionIsSet() throws IOException {
1568+
public void bodyIsPresentWhenNoBodyHandlingOptionIsSet() {
16091569
TestInterfaceClientImpl.TestInterfaceClientService service
16101570
= createService(TestInterfaceClientImpl.TestInterfaceClientService.class);
16111571
HttpBinJSON httpBinJSON = service.put(getServerUri(isSecure()), 42, null);

0 commit comments

Comments
 (0)