File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2727 <groupId >io.projectreactor</groupId >
2828 <artifactId >reactor-bus</artifactId >
2929 </dependency >
30+ <dependency >
31+ <groupId >org.springframework.boot</groupId >
32+ <artifactId >spring-boot-starter-test</artifactId >
33+ </dependency >
3034 </dependencies >
3135
3236 <build >
Original file line number Diff line number Diff line change 44import org .springframework .boot .CommandLineRunner ;
55import org .springframework .boot .SpringApplication ;
66import org .springframework .boot .autoconfigure .EnableAutoConfiguration ;
7- import org .springframework .context .annotation .Bean ;
87import org .springframework .context .annotation .ComponentScan ;
98import org .springframework .context .annotation .Configuration ;
9+ import org .springframework .context .annotation .Import ;
1010
1111import com .baeldung .consumer .NotificationConsumer ;
1212
13- import reactor .Environment ;
1413import reactor .bus .EventBus ;
1514
1615import static reactor .bus .selector .Selectors .$ ;
1716
1817@ Configuration
1918@ EnableAutoConfiguration
2019@ ComponentScan
20+ @ Import (Config .class )
2121public class Application implements CommandLineRunner {
2222
2323 @ Autowired
@@ -26,16 +26,6 @@ public class Application implements CommandLineRunner {
2626 @ Autowired
2727 private NotificationConsumer notificationConsumer ;
2828
29- @ Bean
30- Environment env () {
31- return Environment .initializeIfEmpty ().assignErrorJournal ();
32- }
33-
34- @ Bean
35- EventBus createEventBus (Environment env ) {
36- return EventBus .create (env , Environment .THREAD_POOL );
37- }
38-
3929 @ Override
4030 public void run (String ... args ) throws Exception {
4131 eventBus .on ($ ("notificationConsumer" ), notificationConsumer );
Original file line number Diff line number Diff line change 1+ package com .baeldung ;
2+
3+ import org .springframework .context .annotation .Bean ;
4+ import org .springframework .context .annotation .Configuration ;
5+
6+ import reactor .Environment ;
7+ import reactor .bus .EventBus ;
8+
9+ @ Configuration
10+ public class Config {
11+
12+ @ Bean
13+ Environment env () {
14+ return Environment .initializeIfEmpty ().assignErrorJournal ();
15+ }
16+
17+ @ Bean
18+ EventBus createEventBus (Environment env ) {
19+ return EventBus .create (env , Environment .THREAD_POOL );
20+ }
21+
22+ }
Original file line number Diff line number Diff line change 1+ package com .baeldung ;
2+
3+ import org .junit .Test ;
4+ import org .junit .runner .RunWith ;
5+ import org .springframework .test .context .ContextConfiguration ;
6+ import org .springframework .test .context .junit4 .SpringJUnit4ClassRunner ;
7+ import org .springframework .web .client .RestTemplate ;
8+
9+
10+ @ RunWith (SpringJUnit4ClassRunner .class )
11+ @ ContextConfiguration (classes = {Application .class })
12+ public class DataLoader {
13+
14+ @ Test
15+ public void exampleTest () {
16+ RestTemplate restTemplate = new RestTemplate ();
17+ restTemplate .getForObject ("http://localhost:8080/startNotification/10" , String .class );
18+ }
19+
20+ }
You can’t perform that action at this time.
0 commit comments