|
| 1 | +/* |
| 2 | + * |
| 3 | + * * Copyright 2019-2020 the original author or authors. |
| 4 | + * * |
| 5 | + * * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | + * * you may not use this file except in compliance with the License. |
| 7 | + * * You may obtain a copy of the License at |
| 8 | + * * |
| 9 | + * * https://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * * |
| 11 | + * * Unless required by applicable law or agreed to in writing, software |
| 12 | + * * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * * See the License for the specific language governing permissions and |
| 15 | + * * limitations under the License. |
| 16 | + * |
| 17 | + */ |
| 18 | + |
| 19 | +package test.org.springdoc.api.app189; |
| 20 | + |
| 21 | +import org.json.JSONException; |
| 22 | +import org.junit.jupiter.api.Test; |
| 23 | +import org.springdoc.core.Constants; |
| 24 | +import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest; |
| 25 | +import org.springframework.test.web.reactive.server.EntityExchangeResult; |
| 26 | +import test.org.springdoc.api.AbstractCommonTest; |
| 27 | + |
| 28 | +import java.time.Duration; |
| 29 | + |
| 30 | +import static org.skyscreamer.jsonassert.JSONAssert.assertEquals; |
| 31 | + |
| 32 | +@WebFluxTest |
| 33 | +public class SpringDocApp189Test extends AbstractCommonTest { |
| 34 | + |
| 35 | + @Test |
| 36 | + public void testWithDifferentLocales() throws Exception { |
| 37 | + runTestWithLocale("en-GB"); |
| 38 | + runTestWithLocale("de-DE"); |
| 39 | + } |
| 40 | + |
| 41 | + private void runTestWithLocale(String locale) throws JSONException { |
| 42 | + EntityExchangeResult<byte[]> getResult = webTestClient.mutate().responseTimeout(Duration.ofMinutes(1000)).build() |
| 43 | + .get().uri(Constants.DEFAULT_API_DOCS_URL) |
| 44 | + .header("Accept-Language", locale) |
| 45 | + .exchange() |
| 46 | + .expectStatus().isOk().expectBody().returnResult(); |
| 47 | + |
| 48 | + String result = new String(getResult.getResponseBody()); |
| 49 | + String className = getClass().getSimpleName(); |
| 50 | + String testNumber = className.replaceAll("[^0-9]", ""); |
| 51 | + String expected = getContent("results/app" + testNumber + ".json"); |
| 52 | + assertEquals(expected, result, true); |
| 53 | + } |
| 54 | + |
| 55 | +} |
0 commit comments