20
20
21
21
import org .junit .jupiter .api .Test ;
22
22
23
- import java .util .Optional ;
24
-
25
23
import static org .junit .jupiter .api .Assertions .assertEquals ;
26
24
import static org .junit .jupiter .api .Assertions .assertThrows ;
27
25
@@ -32,20 +30,19 @@ class DLFAuthProviderFactoryTest {
32
30
void getRegion () {
33
31
String region = "cn-hangzhou" ;
34
32
String ipPortUri = "http://127.0.0.1:8080" ;
35
- assertEquals (region , DLFAuthProviderFactory .getRegion (Optional .of (region ), ipPortUri ));
36
33
String url = "https://dlf-" + region + "-internal.aliyuncs.com" ;
37
- assertEquals (region , DLFAuthProviderFactory .getRegion ( Optional . empty (), url ));
34
+ assertEquals (region , DLFAuthProviderFactory .parseRegionFromUri ( url ));
38
35
url = "https://dlf-" + region + ".aliyuncs.com" ;
39
- assertEquals (region , DLFAuthProviderFactory .getRegion ( Optional . empty (), url ));
36
+ assertEquals (region , DLFAuthProviderFactory .parseRegionFromUri ( url ));
40
37
url = "https://dlf-pre-" + region + ".aliyuncs.com" ;
41
- assertEquals (region , DLFAuthProviderFactory .getRegion ( Optional . empty (), url ));
38
+ assertEquals (region , DLFAuthProviderFactory .parseRegionFromUri ( url ));
42
39
region = "us-east-1" ;
43
40
url = "https://dlf-" + region + ".aliyuncs.com" ;
44
- assertEquals (region , DLFAuthProviderFactory .getRegion ( Optional . empty (), url ));
41
+ assertEquals (region , DLFAuthProviderFactory .parseRegionFromUri ( url ));
45
42
url = "https://dlf-" + region + "-internal.aliyuncs.com" ;
46
- assertEquals (region , DLFAuthProviderFactory .getRegion ( Optional . empty (), url ));
43
+ assertEquals (region , DLFAuthProviderFactory .parseRegionFromUri ( url ));
47
44
assertThrows (
48
45
IllegalArgumentException .class ,
49
- () -> DLFAuthProviderFactory .getRegion ( Optional . empty (), ipPortUri ));
46
+ () -> DLFAuthProviderFactory .parseRegionFromUri ( ipPortUri ));
50
47
}
51
48
}
0 commit comments