1818
1919package org .apache .hadoop .fs .azurebfs ;
2020
21+ import static org .assertj .core .api .Assertions .assertThat ;
22+ import static org .junit .jupiter .api .Assumptions .assumeTrue ;
23+ import static org .junit .jupiter .api .Assumptions .assumeFalse ;
24+
2125import java .io .IOException ;
2226import java .net .URI ;
2327import java .util .Hashtable ;
2832import java .util .concurrent .ExecutionException ;
2933import java .util .concurrent .Future ;
3034
31- import org .assertj .core .api .Assertions ;
32- import org .junit .After ;
33- import org .junit .Assume ;
34- import org .junit .Before ;
35+ import org .junit .jupiter .api .AfterEach ;
36+ import org .junit .jupiter .api .BeforeEach ;
3537import org .slf4j .Logger ;
3638import org .slf4j .LoggerFactory ;
3739
7375import static org .apache .hadoop .fs .azurebfs .contracts .services .AzureServiceErrorCode .FILE_SYSTEM_NOT_FOUND ;
7476import static org .apache .hadoop .fs .azurebfs .constants .TestConfigurationKeys .*;
7577import static org .apache .hadoop .test .LambdaTestUtils .intercept ;
76- import static org .junit .Assume .assumeTrue ;
7778
7879/**
7980 * Base for AzureBlobFileSystem Integration tests.
@@ -111,8 +112,8 @@ protected AbstractAbfsIntegrationTest() throws Exception {
111112 // check if accountName is set using different config key
112113 accountName = rawConfig .get (FS_AZURE_ABFS_ACCOUNT_NAME );
113114 }
114- assumeTrue ("Not set: " + FS_AZURE_ABFS_ACCOUNT_NAME ,
115- accountName != null && ! accountName . isEmpty () );
115+ assumeTrue (accountName != null && ! accountName . isEmpty () ,
116+ "Not set: " + FS_AZURE_ABFS_ACCOUNT_NAME );
116117
117118 final String abfsUrl = this .getFileSystemName () + "@" + this .getAccountName ();
118119 URI defaultUri = null ;
@@ -188,7 +189,7 @@ public TracingContext getTestTracingContext(AzureBlobFileSystem fs,
188189 FSOperationType .TEST_OP , needsPrimaryReqId , format , null );
189190 }
190191
191- @ Before
192+ @ BeforeEach
192193 public void setup () throws Exception {
193194 //Create filesystem first to make sure getWasbFileSystem() can return an existing filesystem.
194195 createFileSystem ();
@@ -221,7 +222,7 @@ public void setup() throws Exception {
221222 }
222223 }
223224
224- @ After
225+ @ AfterEach
225226 public void teardown () throws Exception {
226227 try {
227228 IOUtils .closeStream (wasb );
@@ -565,23 +566,22 @@ protected AbfsOutputStream createAbfsOutputStreamWithFlushEnabled(
565566 */
566567 protected long assertAbfsStatistics (AbfsStatistic statistic ,
567568 long expectedValue , Map <String , Long > metricMap ) {
568- assertEquals ("Mismatch in " + statistic .getStatName (), expectedValue ,
569- ( long ) metricMap . get ( statistic .getStatName () ));
569+ assertEquals (expectedValue , ( long ) metricMap . get ( statistic .getStatName ()) ,
570+ "Mismatch in " + statistic .getStatName ());
570571 return expectedValue ;
571572 }
572573
573574 protected void assumeValidTestConfigPresent (final Configuration conf , final String key ) {
574575 String configuredValue = conf .get (accountProperty (key , accountName ),
575576 conf .get (key , "" ));
576- Assume . assumeTrue (String . format ( "Missing Required Test Config: %s." , key ),
577- ! configuredValue . isEmpty ( ));
577+ assumeTrue (! configuredValue . isEmpty ( ),
578+ String . format ( "Missing Required Test Config: %s." , key ));
578579 }
579580
580581 protected void assumeValidAuthConfigsPresent () {
581582 final AuthType currentAuthType = getAuthType ();
582- Assume .assumeFalse (
583- "SAS Based Authentication Not Allowed For Integration Tests" ,
584- currentAuthType == AuthType .SAS );
583+ assumeFalse (currentAuthType == AuthType .SAS ,
584+ "SAS Based Authentication Not Allowed For Integration Tests" );
585585 if (currentAuthType == AuthType .SharedKey ) {
586586 assumeValidTestConfigPresent (getRawConfiguration (), FS_AZURE_ACCOUNT_KEY );
587587 } else {
@@ -612,7 +612,7 @@ public AbfsServiceType getIngressServiceType() {
612612 * @param path path to create. Can be relative or absolute.
613613 */
614614 protected void createAzCopyFolder (Path path ) throws Exception {
615- Assume . assumeTrue (getAbfsServiceType () == AbfsServiceType .BLOB );
615+ assumeTrue (getAbfsServiceType () == AbfsServiceType .BLOB );
616616 assumeValidTestConfigPresent (getRawConfiguration (), FS_AZURE_TEST_FIXED_SAS_TOKEN );
617617 String sasToken = getRawConfiguration ().get (FS_AZURE_TEST_FIXED_SAS_TOKEN );
618618 AzcopyToolHelper azcopyHelper = AzcopyToolHelper .getInstance (sasToken );
@@ -624,7 +624,7 @@ protected void createAzCopyFolder(Path path) throws Exception {
624624 * @param path path to create. Can be relative or absolute.
625625 */
626626 protected void createAzCopyFile (Path path ) throws Exception {
627- Assume . assumeTrue (getAbfsServiceType () == AbfsServiceType .BLOB );
627+ assumeTrue (getAbfsServiceType () == AbfsServiceType .BLOB );
628628 assumeValidTestConfigPresent (getRawConfiguration (), FS_AZURE_TEST_FIXED_SAS_TOKEN );
629629 String sasToken = getRawConfiguration ().get (FS_AZURE_TEST_FIXED_SAS_TOKEN );
630630 AzcopyToolHelper azcopyHelper = AzcopyToolHelper .getInstance (sasToken );
@@ -642,17 +642,17 @@ private String getAzcopyAbsolutePath(Path path) throws IOException {
642642 * Otherwise, the test will be skipped.
643643 */
644644 protected void assumeBlobServiceType () {
645- Assume . assumeTrue ("Blob service type is required for this test" ,
646- getAbfsServiceType () == AbfsServiceType . BLOB );
645+ assumeTrue (getAbfsServiceType () == AbfsServiceType . BLOB ,
646+ "Blob service type is required for this test" );
647647 }
648648
649649 /**
650650 * Utility method to assume that the test is running against a DFS service.
651651 * Otherwise, the test will be skipped.
652652 */
653653 protected void assumeDfsServiceType () {
654- Assume . assumeTrue ("DFS service type is required for this test" ,
655- getAbfsServiceType () == AbfsServiceType . DFS );
654+ assumeTrue (getAbfsServiceType () == AbfsServiceType . DFS ,
655+ "DFS service type is required for this test" );
656656 }
657657
658658 /**
@@ -670,7 +670,7 @@ protected void assumeHnsEnabled() throws IOException {
670670 * @throws IOException if an error occurs while checking the account type.
671671 */
672672 protected void assumeHnsEnabled (String errorMessage ) throws IOException {
673- Assume . assumeTrue (errorMessage , getIsNamespaceEnabled (getFileSystem ()));
673+ assumeTrue (getIsNamespaceEnabled (getFileSystem ()), errorMessage );
674674 }
675675
676676 /**
@@ -688,7 +688,7 @@ protected void assumeHnsDisabled() throws IOException {
688688 * @throws IOException if an error occurs while checking the account type.
689689 */
690690 protected void assumeHnsDisabled (String message ) throws IOException {
691- Assume . assumeFalse (message , getIsNamespaceEnabled (getFileSystem ()));
691+ assumeFalse (getIsNamespaceEnabled (getFileSystem ()), message );
692692 }
693693
694694 /**
@@ -699,7 +699,7 @@ protected void assumeHnsDisabled(String message) throws IOException {
699699 protected void assertPathDns (Path path ) {
700700 String expectedDns = getAbfsServiceType () == AbfsServiceType .BLOB
701701 ? ABFS_BLOB_DOMAIN_NAME : ABFS_DFS_DOMAIN_NAME ;
702- Assertions . assertThat (path .toString ())
702+ assertThat (path .toString ())
703703 .describedAs ("Path does not contain expected DNS" )
704704 .contains (expectedDns );
705705 }
@@ -745,19 +745,23 @@ protected void checkFuturesForExceptions(List<Future<?>> futures, int exceptionV
745745 protected void assumeRecoveryThroughClientTransactionID (boolean isCreate )
746746 throws IOException {
747747 // Assumes that recovery through client transaction ID is enabled.
748- Assume . assumeTrue ("Recovery through client transaction ID is not enabled" ,
749- getConfiguration (). getIsClientTransactionIdEnabled () );
748+ assumeTrue (getConfiguration (). getIsClientTransactionIdEnabled () ,
749+ "Recovery through client transaction ID is not enabled" );
750750 // Assumes that service type is DFS.
751751 assumeDfsServiceType ();
752752 // Assumes that namespace is enabled for the given AzureBlobFileSystem.
753753 assumeHnsEnabled ();
754754 if (isCreate ) {
755755 // Assume that create client is DFS client.
756- Assume . assumeTrue ("Ingress service type is not DFS" ,
757- AbfsServiceType . DFS . equals ( getIngressServiceType ()) );
756+ assumeTrue (AbfsServiceType . DFS . equals ( getIngressServiceType ()) ,
757+ "Ingress service type is not DFS" );
758758 // Assume that append blob is not enabled in DFS client.
759- Assume . assumeFalse ("Append blob is enabled in DFS client" ,
760- isAppendBlobEnabled () );
759+ assumeFalse (isAppendBlobEnabled () ,
760+ "Append blob is enabled in DFS client" );
761761 }
762762 }
763+
764+ protected void assumeNotNull (Object objects ) {
765+ assumeTrue (objects != null );
766+ }
763767}
0 commit comments