updating with test case (#947)
* Update pom.xml * Add files via upload * Update Application.java * Create DataLoader.java * Create DataLoader.java * Delete DataLoader.java
This commit is contained in:
parent
4018d45a2c
commit
99e86c5f19
|
@ -27,6 +27,10 @@
|
|||
<groupId>io.projectreactor</groupId>
|
||||
<artifactId>reactor-bus</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -4,13 +4,12 @@ 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.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import com.baeldung.consumer.NotificationConsumer;
|
||||
|
||||
import reactor.Environment;
|
||||
import reactor.bus.EventBus;
|
||||
|
||||
import static reactor.bus.selector.Selectors.$;
|
||||
|
@ -18,6 +17,7 @@ import static reactor.bus.selector.Selectors.$;
|
|||
@Configuration
|
||||
@EnableAutoConfiguration
|
||||
@ComponentScan
|
||||
@Import(Config.class)
|
||||
public class Application implements CommandLineRunner {
|
||||
|
||||
@Autowired
|
||||
|
@ -26,16 +26,6 @@ public class Application implements CommandLineRunner {
|
|||
@Autowired
|
||||
private NotificationConsumer notificationConsumer;
|
||||
|
||||
@Bean
|
||||
Environment env() {
|
||||
return Environment.initializeIfEmpty().assignErrorJournal();
|
||||
}
|
||||
|
||||
@Bean
|
||||
EventBus createEventBus(Environment env) {
|
||||
return EventBus.create(env, Environment.THREAD_POOL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(String... args) throws Exception {
|
||||
eventBus.on($("notificationConsumer"), notificationConsumer);
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package com.baeldung;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import reactor.Environment;
|
||||
import reactor.bus.EventBus;
|
||||
|
||||
@Configuration
|
||||
public class Config {
|
||||
|
||||
@Bean
|
||||
Environment env() {
|
||||
return Environment.initializeIfEmpty().assignErrorJournal();
|
||||
}
|
||||
|
||||
@Bean
|
||||
EventBus createEventBus(Environment env) {
|
||||
return EventBus.create(env, Environment.THREAD_POOL);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.baeldung;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = {Application.class})
|
||||
public class DataLoader {
|
||||
|
||||
@Test
|
||||
public void exampleTest() {
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
restTemplate.getForObject("http://localhost:8080/startNotification/10", String.class);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue