18
18
19
19
package org .apache .hadoop .fs .azurebfs ;
20
20
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
+
21
25
import java .io .IOException ;
22
26
import java .net .URI ;
23
27
import java .util .Hashtable ;
28
32
import java .util .concurrent .ExecutionException ;
29
33
import java .util .concurrent .Future ;
30
34
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 ;
35
37
import org .slf4j .Logger ;
36
38
import org .slf4j .LoggerFactory ;
37
39
73
75
import static org .apache .hadoop .fs .azurebfs .contracts .services .AzureServiceErrorCode .FILE_SYSTEM_NOT_FOUND ;
74
76
import static org .apache .hadoop .fs .azurebfs .constants .TestConfigurationKeys .*;
75
77
import static org .apache .hadoop .test .LambdaTestUtils .intercept ;
76
- import static org .junit .Assume .assumeTrue ;
77
78
78
79
/**
79
80
* Base for AzureBlobFileSystem Integration tests.
@@ -111,8 +112,8 @@ protected AbstractAbfsIntegrationTest() throws Exception {
111
112
// check if accountName is set using different config key
112
113
accountName = rawConfig .get (FS_AZURE_ABFS_ACCOUNT_NAME );
113
114
}
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 );
116
117
117
118
final String abfsUrl = this .getFileSystemName () + "@" + this .getAccountName ();
118
119
URI defaultUri = null ;
@@ -188,7 +189,7 @@ public TracingContext getTestTracingContext(AzureBlobFileSystem fs,
188
189
FSOperationType .TEST_OP , needsPrimaryReqId , format , null );
189
190
}
190
191
191
- @ Before
192
+ @ BeforeEach
192
193
public void setup () throws Exception {
193
194
//Create filesystem first to make sure getWasbFileSystem() can return an existing filesystem.
194
195
createFileSystem ();
@@ -221,7 +222,7 @@ public void setup() throws Exception {
221
222
}
222
223
}
223
224
224
- @ After
225
+ @ AfterEach
225
226
public void teardown () throws Exception {
226
227
try {
227
228
IOUtils .closeStream (wasb );
@@ -565,23 +566,22 @@ protected AbfsOutputStream createAbfsOutputStreamWithFlushEnabled(
565
566
*/
566
567
protected long assertAbfsStatistics (AbfsStatistic statistic ,
567
568
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 ());
570
571
return expectedValue ;
571
572
}
572
573
573
574
protected void assumeValidTestConfigPresent (final Configuration conf , final String key ) {
574
575
String configuredValue = conf .get (accountProperty (key , accountName ),
575
576
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 ));
578
579
}
579
580
580
581
protected void assumeValidAuthConfigsPresent () {
581
582
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" );
585
585
if (currentAuthType == AuthType .SharedKey ) {
586
586
assumeValidTestConfigPresent (getRawConfiguration (), FS_AZURE_ACCOUNT_KEY );
587
587
} else {
@@ -612,7 +612,7 @@ public AbfsServiceType getIngressServiceType() {
612
612
* @param path path to create. Can be relative or absolute.
613
613
*/
614
614
protected void createAzCopyFolder (Path path ) throws Exception {
615
- Assume . assumeTrue (getAbfsServiceType () == AbfsServiceType .BLOB );
615
+ assumeTrue (getAbfsServiceType () == AbfsServiceType .BLOB );
616
616
assumeValidTestConfigPresent (getRawConfiguration (), FS_AZURE_TEST_FIXED_SAS_TOKEN );
617
617
String sasToken = getRawConfiguration ().get (FS_AZURE_TEST_FIXED_SAS_TOKEN );
618
618
AzcopyToolHelper azcopyHelper = AzcopyToolHelper .getInstance (sasToken );
@@ -624,7 +624,7 @@ protected void createAzCopyFolder(Path path) throws Exception {
624
624
* @param path path to create. Can be relative or absolute.
625
625
*/
626
626
protected void createAzCopyFile (Path path ) throws Exception {
627
- Assume . assumeTrue (getAbfsServiceType () == AbfsServiceType .BLOB );
627
+ assumeTrue (getAbfsServiceType () == AbfsServiceType .BLOB );
628
628
assumeValidTestConfigPresent (getRawConfiguration (), FS_AZURE_TEST_FIXED_SAS_TOKEN );
629
629
String sasToken = getRawConfiguration ().get (FS_AZURE_TEST_FIXED_SAS_TOKEN );
630
630
AzcopyToolHelper azcopyHelper = AzcopyToolHelper .getInstance (sasToken );
@@ -642,17 +642,17 @@ private String getAzcopyAbsolutePath(Path path) throws IOException {
642
642
* Otherwise, the test will be skipped.
643
643
*/
644
644
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" );
647
647
}
648
648
649
649
/**
650
650
* Utility method to assume that the test is running against a DFS service.
651
651
* Otherwise, the test will be skipped.
652
652
*/
653
653
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" );
656
656
}
657
657
658
658
/**
@@ -670,7 +670,7 @@ protected void assumeHnsEnabled() throws IOException {
670
670
* @throws IOException if an error occurs while checking the account type.
671
671
*/
672
672
protected void assumeHnsEnabled (String errorMessage ) throws IOException {
673
- Assume . assumeTrue (errorMessage , getIsNamespaceEnabled (getFileSystem ()));
673
+ assumeTrue (getIsNamespaceEnabled (getFileSystem ()), errorMessage );
674
674
}
675
675
676
676
/**
@@ -688,7 +688,7 @@ protected void assumeHnsDisabled() throws IOException {
688
688
* @throws IOException if an error occurs while checking the account type.
689
689
*/
690
690
protected void assumeHnsDisabled (String message ) throws IOException {
691
- Assume . assumeFalse (message , getIsNamespaceEnabled (getFileSystem ()));
691
+ assumeFalse (getIsNamespaceEnabled (getFileSystem ()), message );
692
692
}
693
693
694
694
/**
@@ -699,7 +699,7 @@ protected void assumeHnsDisabled(String message) throws IOException {
699
699
protected void assertPathDns (Path path ) {
700
700
String expectedDns = getAbfsServiceType () == AbfsServiceType .BLOB
701
701
? ABFS_BLOB_DOMAIN_NAME : ABFS_DFS_DOMAIN_NAME ;
702
- Assertions . assertThat (path .toString ())
702
+ assertThat (path .toString ())
703
703
.describedAs ("Path does not contain expected DNS" )
704
704
.contains (expectedDns );
705
705
}
@@ -745,19 +745,23 @@ protected void checkFuturesForExceptions(List<Future<?>> futures, int exceptionV
745
745
protected void assumeRecoveryThroughClientTransactionID (boolean isCreate )
746
746
throws IOException {
747
747
// 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" );
750
750
// Assumes that service type is DFS.
751
751
assumeDfsServiceType ();
752
752
// Assumes that namespace is enabled for the given AzureBlobFileSystem.
753
753
assumeHnsEnabled ();
754
754
if (isCreate ) {
755
755
// 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" );
758
758
// 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" );
761
761
}
762
762
}
763
+
764
+ protected void assumeNotNull (Object objects ) {
765
+ assumeTrue (objects != null );
766
+ }
763
767
}
0 commit comments