Merge pull request #8402 from kwoyke/BAEL-19928
BAEL-19928: Refactor spring-reactor module
This commit is contained in:
commit
c2ac76bc83
|
@ -1,8 +1,7 @@
|
|||
package com.baeldung;
|
||||
package com.baeldung.reactorbus;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import reactor.Environment;
|
||||
import reactor.bus.EventBus;
|
||||
|
||||
|
@ -10,13 +9,12 @@ import reactor.bus.EventBus;
|
|||
public class Config {
|
||||
|
||||
@Bean
|
||||
Environment env() {
|
||||
public Environment env() {
|
||||
return Environment.initializeIfEmpty().assignErrorJournal();
|
||||
}
|
||||
|
||||
@Bean
|
||||
EventBus createEventBus(Environment env) {
|
||||
public EventBus createEventBus(Environment env) {
|
||||
return EventBus.create(env, Environment.THREAD_POOL);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,24 +1,16 @@
|
|||
package com.baeldung;
|
||||
package com.baeldung.reactorbus;
|
||||
|
||||
import com.baeldung.reactorbus.consumer.NotificationConsumer;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import com.baeldung.consumer.NotificationConsumer;
|
||||
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import reactor.bus.EventBus;
|
||||
|
||||
import static reactor.bus.selector.Selectors.$;
|
||||
|
||||
@Configuration
|
||||
@EnableAutoConfiguration
|
||||
@ComponentScan
|
||||
@Import(Config.class)
|
||||
public class Application implements CommandLineRunner {
|
||||
@SpringBootApplication
|
||||
public class NotificationApplication implements CommandLineRunner {
|
||||
|
||||
@Autowired
|
||||
private EventBus eventBus;
|
||||
|
@ -32,7 +24,6 @@ public class Application implements CommandLineRunner {
|
|||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Application.class, args);
|
||||
SpringApplication.run(NotificationApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
package com.baeldung.consumer;
|
||||
package com.baeldung.reactorbus.consumer;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baeldung.doman.NotificationData;
|
||||
import com.baeldung.service.NotificationService;
|
||||
import com.baeldung.reactorbus.domain.NotificationData;
|
||||
import com.baeldung.reactorbus.service.NotificationService;
|
||||
|
||||
import reactor.bus.Event;
|
||||
import reactor.fn.Consumer;
|
|
@ -1,11 +1,11 @@
|
|||
package com.baeldung.controller;
|
||||
package com.baeldung.reactorbus.controller;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.baeldung.doman.NotificationData;
|
||||
import com.baeldung.reactorbus.domain.NotificationData;
|
||||
|
||||
import reactor.bus.Event;
|
||||
import reactor.bus.EventBus;
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.doman;
|
||||
package com.baeldung.reactorbus.domain;
|
||||
|
||||
public class NotificationData {
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package com.baeldung.service;
|
||||
package com.baeldung.reactorbus.service;
|
||||
|
||||
import com.baeldung.doman.NotificationData;
|
||||
import com.baeldung.reactorbus.domain.NotificationData;
|
||||
|
||||
public interface NotificationService {
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
package com.baeldung.service.impl;
|
||||
package com.baeldung.reactorbus.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baeldung.doman.NotificationData;
|
||||
import com.baeldung.service.NotificationService;
|
||||
import com.baeldung.reactorbus.domain.NotificationData;
|
||||
import com.baeldung.reactorbus.service.NotificationService;
|
||||
|
||||
@Service
|
||||
public class NotificationServiceimpl implements NotificationService {
|
|
@ -1,14 +0,0 @@
|
|||
package com.baeldung;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
public class DataLoaderLiveTest {
|
||||
|
||||
@Test
|
||||
public void exampleTest() {
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
restTemplate.getForObject("http://localhost:8080/startNotification/10", String.class);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,14 +1,14 @@
|
|||
package org.baeldung;
|
||||
package com.baeldung;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import com.baeldung.Application;
|
||||
import com.baeldung.reactorbus.NotificationApplication;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = Application.class)
|
||||
@SpringBootTest(classes = NotificationApplication.class)
|
||||
public class SpringContextTest {
|
||||
|
||||
@Test
|
|
@ -0,0 +1,22 @@
|
|||
package com.baeldung.reactorbus;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.web.server.LocalServerPort;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
public class NotificationApplicationIntegrationTest {
|
||||
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
@Test
|
||||
public void givenAppStarted_whenNotificationTasksSubmitted_thenProcessed() {
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
restTemplate.getForObject("http://localhost:" + port + "/startNotification/10", String.class);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue