Source:
public static void testSetBucketPolicy(String objectPrefix, PolicyType policyType) throws Exception { if (!mintEnv) { System.out.println("Test: " + policyType + ": setBucketPolicy(String bucketName, " + " String objectPrefix, PolicyType policyType)"); } long startTime = System.currentTimeMillis(); try { client.setBucketPolicy(bucketName, objectPrefix, policyType); Thread.sleep(15000); String objectName = objectPrefix + "/" + getRandomName(); String urlString = client.getObjectUrl(bucketName, objectName); byte[] data = "hello, world".getBytes(StandardCharsets.UTF_8); if (policyType == PolicyType.READ_ONLY) { client.putObject(bucketName, objectName, new ByteArrayInputStream(data), data.length, customContentType); } if ((policyType == PolicyType.READ_WRITE) || (policyType == PolicyType.WRITE_ONLY)) { writeObject(urlString, data); } if ((policyType == PolicyType.READ_WRITE) || (policyType == PolicyType.READ_ONLY)) { readObject(urlString); } client.removeObject(bucketName, objectName); mintSuccessLog("setBucketPolicy(String bucketName, String objectPrefix, " + "PolicyType policyType)", null, startTime); } catch (Exception e) { ErrorResponse errorResponse = null; if (e instanceof ErrorResponseException) { ErrorResponseException exp = (ErrorResponseException) e; errorResponse = exp.errorResponse(); } if (errorResponse != null && errorResponse.errorCode() == ErrorCode.NOT_IMPLEMENTED) { mintIgnoredLog("setBucketPolicy(String bucketName, String objectPrefix, " + "PolicyType policyType)", null, startTime); } else { mintFailedLog("setBucketPolicy(String bucketName, String objectPrefix, " + "PolicyType policyType)", null, startTime, null, e.toString() + " >>> " + Arrays.toString(e.getStackTrace())); throw e; } } }

Target:
public static void testSetBucketPolicy(String objectPrefix, PolicyType policyType) throws Exception { if (!mintEnv) { System.out.println("Test: " + policyType + ": setBucketPolicy(String bucketName, " + " String objectPrefix, PolicyType policyType)"); } long startTime = System.currentTimeMillis(); try { client.setBucketPolicy(bucketName, objectPrefix, policyType); Thread.sleep(15000); String objectName = objectPrefix + "/" + getRandomName(); String urlString = client.getObjectUrl(bucketName, objectName); byte[] data = "hello, world".getBytes(StandardCharsets.UTF_8); if (policyType == PolicyType.READ_ONLY) { client.putObject(bucketName, objectName, new ByteArrayInputStream(data), data.length, customContentType); } if ((policyType == PolicyType.READ_WRITE) || (policyType == PolicyType.WRITE_ONLY)) { writeObject(urlString, data); InputStream is = client.getObject(bucketName, objectName); byte[] readBytes = readAllBytes(is); is.close(); if (!Arrays.equals(data, readBytes)) { throw new Exception("content differs"); } } if ((policyType == PolicyType.READ_WRITE) || (policyType == PolicyType.READ_ONLY)) { readObject(urlString); } client.removeObject(bucketName, objectName); mintSuccessLog("setBucketPolicy(String bucketName, String objectPrefix, " + "PolicyType policyType)", null, startTime); } catch (Exception e) { ErrorResponse errorResponse = null; if (e instanceof ErrorResponseException) { ErrorResponseException exp = (ErrorResponseException) e; errorResponse = exp.errorResponse(); } if (errorResponse != null && errorResponse.errorCode() == ErrorCode.NOT_IMPLEMENTED) { mintIgnoredLog("setBucketPolicy(String bucketName, String objectPrefix, " + "PolicyType policyType)", null, startTime); } else { mintFailedLog("setBucketPolicy(String bucketName, String objectPrefix, " + "PolicyType policyType)", null, startTime, null, e.toString() + " >>> " + Arrays.toString(e.getStackTrace())); throw e; } } }