Skip to content

Commit 36d8f7b

Browse files
atptroJacksonTian
authored andcommitted
Fixed an issue where the format was empty
1 parent 0cbb150 commit 36d8f7b

4 files changed

Lines changed: 19 additions & 4 deletions

File tree

aliyun-java-sdk-core/src/main/java/com/aliyuncs/RpcAcsRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public RpcAcsRequest(String product, String version, String action, String locat
4545

4646
private void initialize() {
4747
this.setSysMethod(MethodType.GET);
48-
this.setAcceptFormat(FormatType.XML);
48+
this.setSysAcceptFormat(FormatType.JSON);
4949
this.setHttpContentType(FormatType.FORM);
5050
this.composer = RpcSignatureComposer.getComposer();
5151
}

aliyun-java-sdk-core/src/main/java/com/aliyuncs/auth/RoaSignatureComposer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public Map<String, String> refreshSignParameters(Map<String, String> parameters,
4040
Map<String, String> immutableMap = new HashMap<String, String>(parameters);
4141
immutableMap.put("Date", ParameterHelper.getRFC2616Date(new Date()));
4242
if (null == format) {
43-
format = FormatType.RAW;
43+
format = FormatType.JSON;
4444
}
4545
immutableMap.put("Accept", FormatType.mapFormatToAccept(format));
4646
immutableMap.put("x-acs-signature-method", signer.getSignerName());

aliyun-java-sdk-core/src/test/java/com/aliyuncs/auth/RoaSignatureComposerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,13 @@ public void refreshSignParametersTest() {
149149
when(signer.getSignerVersion()).thenReturn("signerVersion1");
150150
when(signer.getSignerType()).thenReturn("signerType1");
151151
PowerMockito.mockStatic(FormatType.class);
152-
BDDMockito.given(FormatType.mapFormatToAccept(FormatType.RAW)).willReturn("raw");
152+
BDDMockito.given(FormatType.mapFormatToAccept(FormatType.JSON)).willReturn("json");
153153
String accessKeyId = "ak";
154154
FormatType formatType = null;
155155
Map<String, String> res = composer.refreshSignParameters(parameters, signer, accessKeyId, formatType);
156156
Assert.assertEquals("paraValue1", res.get("paraKey1"));
157157
Assert.assertEquals("signerVersion1", res.get("x-acs-signature-version"));
158-
Assert.assertEquals("raw", res.get("Accept"));
158+
Assert.assertEquals("json", res.get("Accept"));
159159
Assert.assertEquals("signerType1", res.get("x-acs-signature-type"));
160160
Assert.assertEquals("signerName1", res.get("x-acs-signature-method"));
161161
Assert.assertNotNull(res.get("Date"));

java-sdk-function-test/src/test/java/com/aliyuncs/ErrorHandlingTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.aliyuncs;
22

3+
import com.aliyuncs.airec.model.v20181012.PushDocumentRequest;
34
import com.aliyuncs.exceptions.ClientException;
45
import org.junit.Assert;
56
import org.junit.Test;
@@ -42,4 +43,18 @@ public void timeOutErrorTest() {
4243
);
4344
}
4445
}
46+
47+
@Test
48+
public void badFormatTypeTest() throws ClientException {
49+
PushDocumentRequest request = new PushDocumentRequest();
50+
request.setInstanceId("ff");
51+
request.setTableName("test");
52+
try {
53+
this.client.getAcsResponse(request);
54+
Assert.fail();
55+
} catch (ClientException e) {
56+
Assert.assertEquals("InstanceNotExist", e.getErrCode());
57+
Assert.assertEquals("The specified instance does not exist.", e.getErrMsg());
58+
}
59+
}
4560
}

0 commit comments

Comments
 (0)