Skip to content

Commit f6c9d1a

Browse files
committed
test update
1 parent ea9e072 commit f6c9d1a

File tree

6 files changed

+19
-73
lines changed

6 files changed

+19
-73
lines changed

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

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import io.clientcore.core.http.models.HttpRequest;
88
import io.clientcore.core.http.models.Response;
99
import io.clientcore.core.http.pipeline.HttpPipeline;
10+
import io.clientcore.core.implementation.utils.UriEscapers;
1011
import io.clientcore.core.models.binarydata.BinaryData;
1112
import io.clientcore.annotation.processor.test.implementation.ParameterizedHostService;
1213
import io.clientcore.core.instrumentation.logging.ClientLogger;

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

+2
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

+4-2
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

-20
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

+3-2
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

+9-49
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import io.clientcore.core.http.pipeline.HttpPipelineBuilder;
2626
import io.clientcore.core.implementation.http.ContentType;
2727
import io.clientcore.core.instrumentation.logging.ClientLogger;
28+
import io.clientcore.core.models.CoreException;
2829
import io.clientcore.core.models.binarydata.BinaryData;
2930
import io.clientcore.core.serialization.ObjectSerializer;
3031
import io.clientcore.core.serialization.SerializationFormat;
@@ -1041,32 +1042,7 @@ public void putRequestWithBodyAndEqualContentLength() {
10411042
assertEquals("4", json.getHeaderValue("Content-Length"));
10421043
}
10431044

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")
10701046
public void putRequestWithUnexpectedResponseAndNoFallthroughExceptionType() {
10711047
HttpResponseException e = assertThrows(HttpResponseException.class,
10721048
() -> createService(TestInterfaceClientImpl.TestInterfaceClientService.class)
@@ -1082,7 +1058,7 @@ public void putRequestWithUnexpectedResponseAndNoFallthroughExceptionType() {
10821058
}
10831059

10841060
@Test
1085-
public void headRequest() throws IOException {
1061+
public void headRequest() {
10861062
try (Response<Void> response
10871063
= createService(TestInterfaceClientImpl.TestInterfaceClientService.class).head(getRequestUri())) {
10881064
assertNull(response.getValue());
@@ -1286,11 +1262,11 @@ public void service20GetResponseBody() {
12861262
}
12871263

12881264
@Test
1289-
public void unexpectedHTTPOK() {
1290-
HttpResponseException e = assertThrows(HttpResponseException.class,
1265+
public void unexpectedHTTPOKDeserializeError() {
1266+
CoreException e = assertThrows(CoreException.class,
12911267
() -> createService(TestInterfaceClientImpl.TestInterfaceClientService.class).getBytes(getRequestUri()));
12921268

1293-
assertEquals("Status code 200, (1024-byte body)", e.getMessage());
1269+
assertTrue(e.getMessage().startsWith("Unexpected character"));
12941270
}
12951271

12961272
@Test
@@ -1442,19 +1418,9 @@ public void voidDoesNotEagerlyReadResponse(
14421418
(uri, service28) -> service28.headResponseVoid(uri));
14431419
}
14441420

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-
14551421
@Test
14561422
@Disabled("https://github.com/Azure/azure-sdk-for-java/issues/44746")
1457-
public void canReceiveServerSentEvents() throws IOException {
1423+
public void canReceiveServerSentEvents() {
14581424
final int[] i = { 0 };
14591425
TestInterfaceClientImpl.TestInterfaceClientService service
14601426
= createService(TestInterfaceClientImpl.TestInterfaceClientService.class);
@@ -1488,7 +1454,7 @@ public void canReceiveServerSentEvents() throws IOException {
14881454
*/
14891455
@Test
14901456
@Disabled("https://github.com/Azure/azure-sdk-for-java/issues/44746")
1491-
public void canRecognizeServerSentEvent() throws IOException {
1457+
public void canRecognizeServerSentEvent() {
14921458
BinaryData requestBody = BinaryData.fromString("test body");
14931459
TestInterfaceClientImpl.TestInterfaceClientService service
14941460
= createService(TestInterfaceClientImpl.TestInterfaceClientService.class);
@@ -1568,14 +1534,8 @@ public void throwsExceptionForNoListener() {
15681534
assertThrows(RuntimeException.class, () -> service.put(getServerUri(isSecure()), requestBody, null).close());
15691535
}
15701536

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-
15771537
@Test
1578-
public void bodyIsPresentWhenNoBodyHandlingOptionIsSet() throws IOException {
1538+
public void bodyIsPresentWhenNoBodyHandlingOptionIsSet() {
15791539
TestInterfaceClientImpl.TestInterfaceClientService service
15801540
= createService(TestInterfaceClientImpl.TestInterfaceClientService.class);
15811541
HttpBinJSON httpBinJSON = service.put(getServerUri(isSecure()), 42, null);

0 commit comments

Comments
 (0)