38
38
39
39
import test .org .springdoc .api .AbstractSpringDocTest ;
40
40
41
- // @TestPropertySource(properties = Constants.SPRINGDOC_CACHE_DISABLED + "=true ")
41
+ @ TestPropertySource (properties = Constants .SPRINGDOC_CACHE_DISABLED + "=false " )
42
42
public class SpringDocApp170Test extends AbstractSpringDocTest {
43
43
44
44
@ SpringBootApplication
45
- static class SpringDocTestApp {}
45
+ static class SpringDocTestApp {
46
+ }
46
47
47
48
@ Bean
48
49
public LocaleResolver localeResolver () {
49
50
SessionLocaleResolver localeResolver = new SessionLocaleResolver ();
50
- localeResolver .setDefaultLocale (Locale .US );
51
51
return localeResolver ;
52
52
}
53
53
54
54
@ Test
55
- @ Override
55
+ @ Override
56
56
public void testApp () throws Exception {
57
- Locale locale = new Locale ("en" ,"US" );
58
- Locale .setDefault (locale );
59
-
60
- className = getClass ().getSimpleName ();
61
- String testNumber = className .replaceAll ("[^0-9]" , "" );
62
- MvcResult mockMvcResult =
63
- mockMvc .perform (get (Constants .DEFAULT_API_DOCS_URL ).locale (locale ).header (HttpHeaders .ACCEPT_LANGUAGE , locale .toLanguageTag ())).andExpect (status ().isOk ())
64
- .andExpect (jsonPath ("$.openapi" , is ("3.0.1" ))).andReturn ();
65
- String result = mockMvcResult .getResponse ().getContentAsString ();
66
- String expected = getContent ("results/app" + testNumber + "-1.json" );
67
- assertEquals (expected , result , true );
57
+ testApp (Locale .US );
58
+ testApp (Locale .FRANCE );
68
59
}
69
60
70
- @ Test
71
- public void testAppFr () throws Exception {
72
- Locale locale = new Locale ("fr" ,"FR" );
61
+ private void testApp (Locale locale ) throws Exception {
73
62
Locale .setDefault (locale );
74
63
75
64
className = getClass ().getSimpleName ();
76
65
String testNumber = className .replaceAll ("[^0-9]" , "" );
77
66
MvcResult mockMvcResult =
78
67
mockMvc .perform (get (Constants .DEFAULT_API_DOCS_URL ).locale (locale ).header (HttpHeaders .ACCEPT_LANGUAGE , locale .toLanguageTag ())).andExpect (status ().isOk ())
79
- .andExpect (jsonPath ("$.openapi" , is ("3.0.1" ))).andReturn ();
68
+ .andExpect (jsonPath ("$.openapi" , is ("3.0.1" ))).andReturn ();
80
69
String result = mockMvcResult .getResponse ().getContentAsString ();
81
- String expected = getContent ("results/app" + testNumber + "-2 .json" );
70
+ String expected = getContent ("results/app" + testNumber + "-" + locale . getLanguage () + " .json" );
82
71
assertEquals (expected , result , true );
83
72
}
84
-
85
- }
73
+ }
0 commit comments