exceptionfactory commented on code in PR #10331:
URL: https://github.com/apache/nifi/pull/10331#discussion_r2370151822
##########
nifi-registry/nifi-registry-extensions/nifi-registry-aws/nifi-registry-aws-extensions/src/test/java/org/apache/nifi/registry/aws/S3BundlePersistenceProviderIT.java:
##########
@@ -66,43 +82,129 @@ public void setup() {
properties.put(S3BundlePersistenceProvider.CREDENTIALS_PROVIDER_PROP,
S3BundlePersistenceProvider.CredentialProvider.DEFAULT_CHAIN.name());
properties.put(S3BundlePersistenceProvider.ENDPOINT_URL_PROP,
endpointUrl);
+ properties.put(S3BundlePersistenceProvider.FORCE_PATH_STYLE_PROP,
forcePathStyle);
configurationContext = mock(ProviderConfigurationContext.class);
when(configurationContext.getProperties()).thenReturn(properties);
provider = new S3BundlePersistenceProvider();
provider.onConfigured(configurationContext);
- // Create a separate client just for the IT test so we can setup a new
bucket
+ // Create a separate client just for the IT test so we can set up a
new bucket
s3Client = ((S3BundlePersistenceProvider)
provider).createS3Client(configurationContext);
final CreateBucketRequest createBucketRequest =
CreateBucketRequest.builder()
.bucket(bucketName)
.build();
s3Client.createBucket(createBucketRequest);
-
+ LOGGER.info("Created bucket: {}", bucketName);
}
@AfterEach
public void teardown() {
try {
provider.preDestruction();
} catch (Exception e) {
- e.printStackTrace();
+ LOGGER.warn("Error during provider destruction", e);
}
try {
s3Client.close();
} catch (Exception e) {
- e.printStackTrace();
+ LOGGER.warn("Error closing S3 client", e);
+ }
+ }
+
+ private void listBucketContents() {
+ try {
+ ListObjectsResponse response =
s3Client.listObjects(ListObjectsRequest.builder()
+ .bucket(bucketName)
+ .build());
+
+ LOGGER.info("Bucket '{}' contents ({} objects):", bucketName,
response.contents().size());
+ for (S3Object s3Object : response.contents()) {
+ LOGGER.info(" - Key: {}, Size: {}, LastModified: {}",
+ s3Object.key(), s3Object.size(),
s3Object.lastModified());
+ }
+ } catch (Exception e) {
+ LOGGER.error("Failed to list bucket contents", e);
+ }
+ }
+
+ private String getKeyViaReflection(BundleVersionCoordinate coordinate) {
Review Comment:
Using reflection and overriding visibility is generally poor practice for
tests, as it makes the test more brittle, and tightens the coupling between the
test and the implementation class. I recommend removing this method and either
simplifying the test method or evaluating other available output from public
methods.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]