Skip to content

Commit 0c39f1a

Browse files
committed
lab-4
1 parent 9123ab7 commit 0c39f1a

7 files changed

Lines changed: 781 additions & 55 deletions

File tree

labs/lab-4/src/test/java/pragmatech/digital/workshops/lab4/experiment/SampleIT.java

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,36 @@
33
import com.github.tomakehurst.wiremock.WireMockServer;
44
import org.junit.jupiter.api.Test;
55
import org.springframework.beans.factory.annotation.Autowired;
6+
import org.springframework.boot.resttestclient.autoconfigure.AutoConfigureRestTestClient;
7+
import org.springframework.boot.resttestclient.autoconfigure.AutoConfigureTestRestTemplate;
68
import org.springframework.boot.test.context.SpringBootTest;
9+
import org.springframework.boot.test.web.server.LocalServerPort;
710
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
11+
import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc;
12+
import org.springframework.boot.webtestclient.autoconfigure.AutoConfigureWebTestClient;
813
import org.springframework.test.context.ContextConfiguration;
14+
import org.springframework.test.web.reactive.server.WebTestClient;
15+
import org.springframework.test.web.servlet.MockMvc;
916
import org.testcontainers.containers.PostgreSQLContainer;
1017
import org.testcontainers.junit.jupiter.Container;
1118
import org.testcontainers.junit.jupiter.Testcontainers;
1219
import pragmatech.digital.workshops.lab4.config.OpenLibraryApiStub;
1320
import pragmatech.digital.workshops.lab4.config.WireMockContextInitializer;
1421

15-
@Testcontainers
16-
@SpringBootTest
17-
@ContextConfiguration(initializers = WireMockContextInitializer.class)
22+
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
23+
@AutoConfigureWebTestClient
24+
@AutoConfigureTestRestTemplate
25+
@AutoConfigureRestTestClient
1826
class SampleIT {
1927

20-
@Container
21-
@ServiceConnection
22-
static final PostgreSQLContainer<?> postgresContainer = new PostgreSQLContainer<>("postgres:16-alpine")
23-
.withDatabaseName("testdb")
24-
.withUsername("test")
25-
.withPassword("test");
28+
@LocalServerPort
29+
private int port;
2630

2731
@Autowired
28-
private WireMockServer wireMockServer;
29-
30-
@Autowired
31-
private OpenLibraryApiStub openLibraryApiStub;
32+
private WebTestClient webTestClient;
3233

3334
@Test
3435
void sampleTest() {
36+
this.webTestClient.get().uri("/api/books").exchangeSuccessfully();
3537
}
3638
}
Lines changed: 329 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,329 @@
1+
{
2+
"type": "excalidraw",
3+
"version": 2,
4+
"source": "mcp-excalidraw-server",
5+
"elements": [
6+
{
7+
"id": "title1",
8+
"type": "text",
9+
"x": 140,
10+
"y": 20,
11+
"width": 560,
12+
"height": 30,
13+
"strokeColor": "#1e1e1e",
14+
"text": "@SpringBootTest (MOCK) — Single Thread, No Real Server",
15+
"fontSize": 20,
16+
"createdAt": "2026-02-28T15:10:43.522Z",
17+
"updatedAt": "2026-02-28T15:10:43.522Z",
18+
"version": 1
19+
},
20+
{
21+
"id": "lane-bg",
22+
"type": "rectangle",
23+
"x": 60,
24+
"y": 60,
25+
"width": 720,
26+
"height": 460,
27+
"backgroundColor": "#e9ecef",
28+
"strokeColor": "#868e96",
29+
"strokeWidth": 1,
30+
"opacity": 40,
31+
"createdAt": "2026-02-28T15:10:43.522Z",
32+
"updatedAt": "2026-02-28T15:10:43.522Z",
33+
"version": 1
34+
},
35+
{
36+
"id": "lane-label",
37+
"type": "text",
38+
"x": 80,
39+
"y": 68,
40+
"width": 200,
41+
"height": 24,
42+
"strokeColor": "#868e96",
43+
"text": "JVM — Single Thread",
44+
"fontSize": 15,
45+
"createdAt": "2026-02-28T15:10:43.522Z",
46+
"updatedAt": "2026-02-28T15:10:43.522Z",
47+
"version": 1
48+
},
49+
{
50+
"id": "box-test",
51+
"type": "rectangle",
52+
"x": 100,
53+
"y": 100,
54+
"width": 220,
55+
"height": 60,
56+
"backgroundColor": "#a5d8ff",
57+
"strokeColor": "#1971c2",
58+
"strokeWidth": 2,
59+
"label": {
60+
"text": "Test Class\n@SpringBootTest"
61+
},
62+
"fontSize": 15,
63+
"createdAt": "2026-02-28T15:10:43.522Z",
64+
"updatedAt": "2026-02-28T15:10:43.522Z",
65+
"version": 1
66+
},
67+
{
68+
"id": "box-mockmvc",
69+
"type": "rectangle",
70+
"x": 100,
71+
"y": 220,
72+
"width": 220,
73+
"height": 60,
74+
"backgroundColor": "#a5d8ff",
75+
"strokeColor": "#1971c2",
76+
"strokeWidth": 2,
77+
"label": {
78+
"text": "MockMvc.perform()\npost(\"/api/books\")"
79+
},
80+
"fontSize": 15,
81+
"createdAt": "2026-02-28T15:10:43.522Z",
82+
"updatedAt": "2026-02-28T15:10:43.522Z",
83+
"version": 1
84+
},
85+
{
86+
"id": "box-dispatcher",
87+
"type": "rectangle",
88+
"x": 100,
89+
"y": 340,
90+
"width": 220,
91+
"height": 60,
92+
"backgroundColor": "#b2f2bb",
93+
"strokeColor": "#2f9e44",
94+
"strokeWidth": 2,
95+
"label": {
96+
"text": "DispatcherServlet"
97+
},
98+
"fontSize": 15,
99+
"createdAt": "2026-02-28T15:10:43.522Z",
100+
"updatedAt": "2026-02-28T15:10:43.522Z",
101+
"version": 1
102+
},
103+
{
104+
"id": "box-controller",
105+
"type": "rectangle",
106+
"x": 100,
107+
"y": 460,
108+
"width": 220,
109+
"height": 60,
110+
"backgroundColor": "#b2f2bb",
111+
"strokeColor": "#2f9e44",
112+
"strokeWidth": 2,
113+
"label": {
114+
"text": "Controller → Service\n→ Repository"
115+
},
116+
"fontSize": 15,
117+
"createdAt": "2026-02-28T15:10:43.522Z",
118+
"updatedAt": "2026-02-28T15:10:43.522Z",
119+
"version": 1
120+
},
121+
{
122+
"id": "arrow-test-mockmvc",
123+
"type": "arrow",
124+
"x": 210,
125+
"y": 168,
126+
"width": 0,
127+
"height": 60,
128+
"strokeColor": "#1971c2",
129+
"strokeWidth": 2,
130+
"points": [
131+
[
132+
0,
133+
0
134+
],
135+
[
136+
0,
137+
44
138+
]
139+
],
140+
"createdAt": "2026-02-28T15:10:43.523Z",
141+
"updatedAt": "2026-02-28T15:10:43.523Z",
142+
"version": 1,
143+
"startBinding": {
144+
"elementId": "box-test",
145+
"focus": 0,
146+
"gap": 8
147+
},
148+
"endBinding": {
149+
"elementId": "box-mockmvc",
150+
"focus": 0,
151+
"gap": 8
152+
}
153+
},
154+
{
155+
"id": "arrow-mockmvc-dispatcher",
156+
"type": "arrow",
157+
"x": 210,
158+
"y": 288,
159+
"width": 0,
160+
"height": 60,
161+
"strokeColor": "#1971c2",
162+
"strokeWidth": 2,
163+
"label": {
164+
"text": "same thread\nno network"
165+
},
166+
"fontSize": 13,
167+
"points": [
168+
[
169+
0,
170+
0
171+
],
172+
[
173+
0,
174+
44
175+
]
176+
],
177+
"createdAt": "2026-02-28T15:10:43.523Z",
178+
"updatedAt": "2026-02-28T15:10:43.523Z",
179+
"version": 1,
180+
"startBinding": {
181+
"elementId": "box-mockmvc",
182+
"focus": 0,
183+
"gap": 8
184+
},
185+
"endBinding": {
186+
"elementId": "box-dispatcher",
187+
"focus": 0,
188+
"gap": 8
189+
}
190+
},
191+
{
192+
"id": "arrow-dispatcher-ctrl",
193+
"type": "arrow",
194+
"x": 210,
195+
"y": 408,
196+
"width": 0,
197+
"height": 60,
198+
"strokeColor": "#2f9e44",
199+
"strokeWidth": 2,
200+
"points": [
201+
[
202+
0,
203+
0
204+
],
205+
[
206+
0,
207+
44
208+
]
209+
],
210+
"createdAt": "2026-02-28T15:10:43.523Z",
211+
"updatedAt": "2026-02-28T15:10:43.523Z",
212+
"version": 1,
213+
"startBinding": {
214+
"elementId": "box-dispatcher",
215+
"focus": 0,
216+
"gap": 8
217+
},
218+
"endBinding": {
219+
"elementId": "box-controller",
220+
"focus": 0,
221+
"gap": 8
222+
}
223+
},
224+
{
225+
"id": "real-box",
226+
"type": "rectangle",
227+
"x": 380,
228+
"y": 320,
229+
"width": 360,
230+
"height": 220,
231+
"backgroundColor": "#b2f2bb",
232+
"strokeColor": "#2f9e44",
233+
"strokeWidth": 2,
234+
"opacity": 50,
235+
"createdAt": "2026-02-28T15:10:43.523Z",
236+
"updatedAt": "2026-02-28T15:10:43.523Z",
237+
"version": 1
238+
},
239+
{
240+
"id": "real-title",
241+
"type": "text",
242+
"x": 395,
243+
"y": 330,
244+
"width": 330,
245+
"height": 24,
246+
"strokeColor": "#2f9e44",
247+
"text": "Spring MVC infrastructure — REAL ✅",
248+
"fontSize": 15,
249+
"createdAt": "2026-02-28T15:10:43.523Z",
250+
"updatedAt": "2026-02-28T15:10:43.523Z",
251+
"version": 1
252+
},
253+
{
254+
"id": "real-items",
255+
"type": "text",
256+
"x": 395,
257+
"y": 358,
258+
"width": 330,
259+
"height": 170,
260+
"strokeColor": "#1e1e1e",
261+
"text": "• @RequestMapping routing\n• Security filter chain\n• Bean Validation (@Valid)\n• @ControllerAdvice handlers\n• Servlet filters",
262+
"fontSize": 14,
263+
"createdAt": "2026-02-28T15:10:43.523Z",
264+
"updatedAt": "2026-02-28T15:10:43.523Z",
265+
"version": 1
266+
},
267+
{
268+
"id": "notreal-box",
269+
"type": "rectangle",
270+
"x": 380,
271+
"y": 100,
272+
"width": 360,
273+
"height": 80,
274+
"backgroundColor": "#ffc9c9",
275+
"strokeColor": "#e03131",
276+
"strokeWidth": 2,
277+
"opacity": 60,
278+
"createdAt": "2026-02-28T15:10:43.523Z",
279+
"updatedAt": "2026-02-28T15:10:43.523Z",
280+
"version": 1
281+
},
282+
{
283+
"id": "notreal-text",
284+
"type": "text",
285+
"x": 395,
286+
"y": 112,
287+
"width": 330,
288+
"height": 56,
289+
"strokeColor": "#e03131",
290+
"text": "NOT real ❌\nTCP stack · Tomcat thread pool\nHTTP connection management",
291+
"fontSize": 14,
292+
"createdAt": "2026-02-28T15:10:43.523Z",
293+
"updatedAt": "2026-02-28T15:10:43.523Z",
294+
"version": 1
295+
},
296+
{
297+
"id": "txn-box",
298+
"type": "rectangle",
299+
"x": 380,
300+
"y": 560,
301+
"width": 360,
302+
"height": 60,
303+
"backgroundColor": "#99e9f2",
304+
"strokeColor": "#0c8599",
305+
"strokeWidth": 2,
306+
"createdAt": "2026-02-28T15:10:43.523Z",
307+
"updatedAt": "2026-02-28T15:10:43.523Z",
308+
"version": 1
309+
},
310+
{
311+
"id": "txn-text",
312+
"type": "text",
313+
"x": 395,
314+
"y": 575,
315+
"width": 330,
316+
"height": 30,
317+
"strokeColor": "#0c8599",
318+
"text": "@Transactional on test → wraps full call chain → auto-rollback ✅",
319+
"fontSize": 14,
320+
"createdAt": "2026-02-28T15:10:43.523Z",
321+
"updatedAt": "2026-02-28T15:10:43.523Z",
322+
"version": 1
323+
}
324+
],
325+
"appState": {
326+
"viewBackgroundColor": "#ffffff",
327+
"gridSize": null
328+
}
329+
}

0 commit comments

Comments
 (0)