### Question:
S3Util { public static byte[] domainControllerDataToByteBuffer(List<DomainControllerData> data) throws Exception { final ByteArrayOutputStream out_stream = new ByteArrayOutputStream(512); byte[] result; try (DataOutputStream out = new DataOutputStream(out_stream)) { Iterator<DomainControllerData> iter = data.iterator(); while (iter.hasNext()) { DomainControllerData dcData = iter.next(); dcData.writeTo(out); if (iter.hasNext()) { S3Util.writeString(SEPARATOR, out); } } result = out_stream.toByteArray(); } return result; }  static List<DomainControllerData> domainControllerDataFromByteBuffer(byte[] buffer); static byte[] domainControllerDataToByteBuffer(List<DomainControllerData> data); static String generatePreSignedUrl(String awsAccessKey, String awsSecretAccessKey, String method,
            String bucket, String key, long expirationDate); static String readString(DataInput in); static void writeString(String s, DataOutput out);  }### Answer:
@Test public void testDomainControllerDataToByteBuffer() throws Exception { List<DomainControllerData> data = Arrays.asList(new DomainControllerData[]{new DomainControllerData(REMOTE.toString(), "native.example.com", 9999), new DomainControllerData(REMOTE_HTTP.toString(), "http.example.com", 9990)}); byte[] bytes = S3Util.domainControllerDataToByteBuffer(data); assertThat(bytes, is(notNullValue())); assertThat(bytes.length, is(78)); List<DomainControllerData> result = S3Util.domainControllerDataFromByteBuffer(bytes); assertThat(result, is(notNullValue())); assertThat(result.size(), is(2)); }