APISonar


com.aliyuncs.http.FormatType.XML

> com > aliyuncs > http > FormatType > XML
com APIs aliyuncs APIs http APIs FormatType APIs XML APIs

Example 1
public static Reader createInstance(FormatType format) {
        if (FormatType.JSON == format) {
            return new JsonReader();
        }
        if (FormatType.XML == format) {
            return new XmlReader();
        }

        throw new IllegalStateException("Server response has a bad format type: " + format);
    }
Example 2
public void getUnmarshallerTest() {
        Unmarshaller unmarshaller = UnmarshallerFactory.getUnmarshaller(FormatType.XML);
        Assert.assertTrue("is xml unmarshaller", unmarshaller.getClass() == XmlUnmashaller.class);
        Unmarshaller unmarshaller2 = UnmarshallerFactory.getUnmarshaller(FormatType.JSON);
        Assert.assertTrue("is json unmarshaller", unmarshaller2.getClass() == JsonUnmashaller.class);
        try {
            UnmarshallerFactory.getUnmarshaller(FormatType.FORM);
        } catch (Exception e) {
            Assert.assertEquals("Unsupported response format: FORM", e.getMessage());
            return;
        }
        Assert.fail();
    }
Example 3
public void testRPCComposer() {
        Signer signer = new HmacSHA1Signer();
        @SuppressWarnings("rawtypes")
        AcsRequest request = new DescribeRegionsRequest();

        ISignatureComposer composer = RpcSignatureComposer.getComposer();
        Map<String, String> immune = composer.refreshSignParameters(request.getSysQueryParameters(), signer, "testid",
                FormatType.XML);
        String strToSign = composer.composeStringToSign(request.getSysMethod(), null, signer, immune, null, null);
        assertEquals(0, strToSign.indexOf("GET&%2F&AccessKeyId%3Dtestid%26Action%3DDescribeRegions%26Format%3DXML%26"));
        assertEquals(true, strToSign.endsWith("Version%3D2014-05-26"));
    }