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:
Abhinab Kanrar 2017-01-03 22:23:24 +05:30 committed by Grzegorz Piwowarek
parent 4018d45a2c
commit 99e86c5f19
4 changed files with 48 additions and 12 deletions

View File

@ -27,6 +27,10 @@
<groupId>io.projectreactor</groupId> <groupId>io.projectreactor</groupId>
<artifactId>reactor-bus</artifactId> <artifactId>reactor-bus</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -4,13 +4,12 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner; import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import com.baeldung.consumer.NotificationConsumer; import com.baeldung.consumer.NotificationConsumer;
import reactor.Environment;
import reactor.bus.EventBus; import reactor.bus.EventBus;
import static reactor.bus.selector.Selectors.$; import static reactor.bus.selector.Selectors.$;
@ -18,6 +17,7 @@ import static reactor.bus.selector.Selectors.$;
@Configuration @Configuration
@EnableAutoConfiguration @EnableAutoConfiguration
@ComponentScan @ComponentScan
@Import(Config.class)
public class Application implements CommandLineRunner { public class Application implements CommandLineRunner {
@Autowired @Autowired
@ -26,16 +26,6 @@ public class Application implements CommandLineRunner {
@Autowired @Autowired
private NotificationConsumer notificationConsumer; private NotificationConsumer notificationConsumer;
@Bean
Environment env() {
return Environment.initializeIfEmpty().assignErrorJournal();
}
@Bean
EventBus createEventBus(Environment env) {
return EventBus.create(env, Environment.THREAD_POOL);
}
@Override @Override
public void run(String... args) throws Exception { public void run(String... args) throws Exception {
eventBus.on($("notificationConsumer"), notificationConsumer); eventBus.on($("notificationConsumer"), notificationConsumer);

View File

@ -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);
}
}

View File

@ -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);
}
}