1
1
/*
2
- * Copyright 2002-2017 the original author or authors.
2
+ * Copyright 2002-2018 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
36
36
*/
37
37
public class AcceptHeaderLocaleResolverTests {
38
38
39
- private AcceptHeaderLocaleResolver resolver = new AcceptHeaderLocaleResolver ();
39
+ private final AcceptHeaderLocaleResolver resolver = new AcceptHeaderLocaleResolver ();
40
40
41
41
42
42
@ Test
43
- public void resolve () throws Exception {
43
+ public void resolve () {
44
44
assertEquals (CANADA , this .resolver .resolveLocale (request (CANADA )));
45
45
assertEquals (US , this .resolver .resolveLocale (request (US , CANADA )));
46
46
}
47
47
48
48
@ Test
49
- public void resolvePreferredSupported () throws Exception {
49
+ public void resolvePreferredSupported () {
50
50
this .resolver .setSupportedLocales (Collections .singletonList (CANADA ));
51
51
assertEquals (CANADA , this .resolver .resolveLocale (request (US , CANADA )));
52
52
}
53
53
54
54
@ Test
55
- public void resolvePreferredNotSupported () throws Exception {
55
+ public void resolvePreferredNotSupported () {
56
56
this .resolver .setSupportedLocales (Collections .singletonList (CANADA ));
57
57
assertEquals (US , this .resolver .resolveLocale (request (US , UK )));
58
58
}
59
+
59
60
@ Test
61
+ public void resolvePreferredAgainstLanguageOnly () {
62
+ this .resolver .setSupportedLocales (Collections .singletonList (ENGLISH ));
63
+ assertEquals (ENGLISH , this .resolver .resolveLocale (request (GERMANY , US , UK )));
64
+ }
60
65
66
+ @ Test
61
67
public void resolvePreferredNotSupportedWithDefault () {
62
68
this .resolver .setSupportedLocales (Arrays .asList (US , JAPAN ));
63
69
this .resolver .setDefaultLocale (Locale .JAPAN );
@@ -69,7 +75,7 @@ public void resolvePreferredNotSupportedWithDefault() {
69
75
}
70
76
71
77
@ Test
72
- public void defaultLocale () throws Exception {
78
+ public void defaultLocale () {
73
79
this .resolver .setDefaultLocale (JAPANESE );
74
80
MockHttpServletRequest request = new MockHttpServletRequest ();
75
81
assertEquals (JAPANESE , this .resolver .resolveLocale (request ));
0 commit comments