25
25
26
26
import org .junit .jupiter .api .Test ;
27
27
import org .skyscreamer .jsonassert .JSONAssert ;
28
+ import org .slf4j .Logger ;
29
+ import org .slf4j .LoggerFactory ;
28
30
import org .springdoc .core .Constants ;
29
31
30
32
import org .springframework .beans .factory .annotation .Autowired ;
33
35
import org .springframework .test .web .reactive .server .EntityExchangeResult ;
34
36
import org .springframework .test .web .reactive .server .WebTestClient ;
35
37
38
+ import static org .skyscreamer .jsonassert .JSONAssert .assertEquals ;
39
+
36
40
@ WebFluxTest
37
41
@ ActiveProfiles ("test" )
38
42
public abstract class AbstractSpringDocTest {
39
43
40
44
@ Autowired
41
45
private WebTestClient webTestClient ;
46
+ protected static final Logger LOGGER = LoggerFactory .getLogger (AbstractSpringDocTest .class );
42
47
43
48
public static String getContent (String fileName ) {
44
49
try {
@@ -53,14 +58,20 @@ public static String getContent(String fileName) {
53
58
54
59
@ Test
55
60
public void testApp () throws Exception {
56
- EntityExchangeResult <byte []> getResult = webTestClient .get ().uri (Constants .DEFAULT_API_DOCS_URL ).exchange ()
57
- .expectStatus ().isOk ().expectBody ().returnResult ();
58
-
59
- String result = new String (getResult .getResponseBody ());
60
- String className = getClass ().getSimpleName ();
61
- String testNumber = className .replaceAll ("[^0-9]" , "" );
61
+ String result = null ;
62
+ try {
63
+ EntityExchangeResult <byte []> getResult = webTestClient .get ().uri (Constants .DEFAULT_API_DOCS_URL ).exchange ()
64
+ .expectStatus ().isOk ().expectBody ().returnResult ();
62
65
63
- String expected = getContent ("results/app" + testNumber + ".json" );
64
- JSONAssert .assertEquals (expected , result , true );
66
+ result = new String (getResult .getResponseBody ());
67
+ String className = getClass ().getSimpleName ();
68
+ String testNumber = className .replaceAll ("[^0-9]" , "" );
69
+ String expected = getContent ("results/app" + testNumber + ".json" );
70
+ assertEquals (expected , result , true );
71
+ }
72
+ catch (java .lang .AssertionError e ) {
73
+ LOGGER .error (result );
74
+ throw e ;
75
+ }
65
76
}
66
77
}
0 commit comments