### Question:
PutRecordRequestMarshaller implements Marshaller<Request<PutRecordRequest>, PutRecordRequest> { public Request<PutRecordRequest> marshall(PutRecordRequest putRecordRequest) { if (putRecordRequest == null) { throw new AmazonClientException("Invalid argument passed to marshall(...)"); } Request<PutRecordRequest> request = new DefaultRequest<PutRecordRequest>(putRecordRequest, "AmazonKinesis"); String target = "Kinesis_20131202.PutRecord"; request.addHeader("X-Amz-Target", target); request.setHttpMethod(HttpMethodName.POST); request.setResourcePath(""); try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); GZIPOutputStream gos = new GZIPOutputStream(baos, 8192); Writer writer = new OutputStreamWriter(gos, StringUtils.UTF8); AwsJsonWriter jsonWriter = JsonUtils.getJsonWriter(writer); jsonWriter.beginObject(); if (putRecordRequest.getStreamName() != null) { jsonWriter.name("StreamName").value(putRecordRequest.getStreamName()); } if (putRecordRequest.getData() != null) { jsonWriter.name("Data").value(putRecordRequest.getData()); } if (putRecordRequest.getPartitionKey() != null) { jsonWriter.name("PartitionKey").value(putRecordRequest.getPartitionKey()); } if (putRecordRequest.getExplicitHashKey() != null) { jsonWriter.name("ExplicitHashKey").value(putRecordRequest.getExplicitHashKey()); } if (putRecordRequest.getSequenceNumberForOrdering() != null) { jsonWriter.name("SequenceNumberForOrdering").value(putRecordRequest.getSequenceNumberForOrdering()); } jsonWriter.endObject(); jsonWriter.flush(); gos.finish(); writer.close(); byte[] content = baos.toByteArray(); request.setContent(new ByteArrayInputStream(content)); request.addHeader("Content-Length", Integer.toString(content.length)); request.addHeader("Content-Type", "application/x-amz-json-1.1"); request.addHeader("Content-Encoding", "gzip"); } catch(Throwable t) { throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); } return request; }  Request<PutRecordRequest> marshall(PutRecordRequest putRecordRequest);  }### Answer:
@Ignore @Test public void test() throws Exception { PutRecordRequest putRecordRequest = new PutRecordRequest(); putRecordRequest.setStreamName("stream name"); putRecordRequest.setSequenceNumberForOrdering("sequence number for ordering"); putRecordRequest.setPartitionKey("partition key"); String randomStr = RandomStringUtils.random(128 * 1024); putRecordRequest.setData(ByteBuffer.wrap(randomStr.getBytes(StringUtils.UTF8))); PutRecordRequestMarshaller marshaller = new PutRecordRequestMarshaller(); Request<PutRecordRequest> request = marshaller.marshall(putRecordRequest); assertEquals("content encoding", "gzip", request.getHeaders().get("Content-Encoding")); byte[] content = IOUtils.toByteArray(request.getContent()); assertEquals("content length", request.getHeaders().get("Content-Length"), String.valueOf(content.length)); GZIPInputStream gis = new GZIPInputStream(new ByteArrayInputStream(content)); String str = IOUtils.toString(gis); Map<String, String> map = JsonUtils.jsonToMap(str); assertEquals("StreamName", "stream name", map.get("StreamName")); String data = new String(BinaryUtils.fromBase64(map.get("Data")), StringUtils.UTF8); assertEquals("same data", randomStr, data); }