2
2
3
3
import org .junit .Test ;
4
4
5
+ import java .util .HashMap ;
6
+ import java .util .Map ;
7
+
5
8
import static org .junit .Assert .assertEquals ;
6
9
7
10
public class WbCdxApiTest {
8
11
@ Test
9
- public void hostFromSurt () throws Exception {
12
+ public void hostFromSurt () {
10
13
assertEquals ("org,example" , WbCdxApi .hostFromSurt ("org,example)/foo/bar" ));
11
14
assertEquals ("org,example" , WbCdxApi .hostFromSurt ("org,example" ));
12
15
}
16
+
17
+ @ Test
18
+ public void queryDefaultShouldExpandPrefixWildcards () {
19
+ Map <String ,String > params = new HashMap <>();
20
+ params .put ("url" , "http://example.org/*" );
21
+ WbCdxApi .Query query = new WbCdxApi .Query (params );
22
+ query .expandWildcards ();
23
+ assertEquals (WbCdxApi .MatchType .PREFIX , query .matchType );
24
+ assertEquals ("http://example.org/" , query .url );
25
+ }
26
+
27
+ @ Test
28
+ public void queryDefaultShouldExpandDomainWildcards () {
29
+ Map <String ,String > params = new HashMap <>();
30
+ params .put ("url" , "*.example.org" );
31
+ WbCdxApi .Query query = new WbCdxApi .Query (params );
32
+ query .expandWildcards ();
33
+ assertEquals (WbCdxApi .MatchType .DOMAIN , query .matchType );
34
+ assertEquals ("example.org" , query .url );
35
+ }
36
+
37
+ @ Test
38
+ public void queryExactMatchShouldNotExpandWildcards () {
39
+ Map <String ,String > params = new HashMap <>();
40
+ params .put ("url" , "http://example.org/*" );
41
+ params .put ("matchType" , "exact" );
42
+ WbCdxApi .Query query = new WbCdxApi .Query (params );
43
+ query .expandWildcards ();
44
+ assertEquals (WbCdxApi .MatchType .EXACT , query .matchType );
45
+ assertEquals ("http://example.org/*" , query .url );
46
+ }
13
47
}
0 commit comments