use of com.aliyun.oss.common.comm.DefaultServiceClient in project aliyun-oss-java-sdk by aliyun.
the class OSSObjectOperationTest method testPopulateCopyObjectHeaders.
@Test
public void testPopulateCopyObjectHeaders() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, URISyntaxException {
CopyObjectRequest request = new CopyObjectRequest("srcbucket", "srckey", "destbucket", "destkey");
request.setServerSideEncryption(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION);
Method[] testMethods = OSSObjectOperation.class.getDeclaredMethods();
Method testMethod = null;
for (Method m : testMethods) {
if (m.getName().equals("populateCopyObjectHeaders")) {
testMethod = m;
}
}
testMethod.setAccessible(true);
OSSObjectOperation operations = new OSSObjectOperation(new DefaultServiceClient(new ClientConfiguration()), new DefaultCredentialProvider(new DefaultCredentials("id", "key")));
Map<String, String> headers = new HashMap<String, String>();
Object[] params = new Object[2];
params[0] = request;
params[1] = headers;
testMethod.invoke(operations, params);
assertEquals("/srcbucket/srckey", headers.get(OSSHeaders.COPY_OBJECT_SOURCE));
assertEquals(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION, headers.get(OSSHeaders.OSS_SERVER_SIDE_ENCRYPTION));
assertEquals(null, headers.get(OSSHeaders.COPY_OBJECT_METADATA_DIRECTIVE));
}
Aggregations