From 1ebe514798ef1040f70faf7605e77840c302a248 Mon Sep 17 00:00:00 2001 From: Gustavo Martin Morcuende Date: Tue, 31 Jan 2017 02:02:10 +0100 Subject: [PATCH] Renaming tests --- .../spring/kafka/ReceiverIntegrationTest.java | 45 ++++++++++++++++++++++ .../de/example/spring/kafka/ReceiverShould.java | 45 ---------------------- .../spring/kafka/SenderIntegrationTest.java | 42 ++++++++++++++++++++ .../java/de/example/spring/kafka/SenderShould.java | 42 -------------------- 4 files changed, 87 insertions(+), 87 deletions(-) create mode 100644 SpringJava/Kafka/SpringCloudStream/spring-stream-kafka-consumer/src/test/java/de/example/spring/kafka/ReceiverIntegrationTest.java delete mode 100644 SpringJava/Kafka/SpringCloudStream/spring-stream-kafka-consumer/src/test/java/de/example/spring/kafka/ReceiverShould.java create mode 100644 SpringJava/Kafka/SpringCloudStream/spring-stream-kafka-producer/src/test/java/de/example/spring/kafka/SenderIntegrationTest.java delete mode 100644 SpringJava/Kafka/SpringCloudStream/spring-stream-kafka-producer/src/test/java/de/example/spring/kafka/SenderShould.java diff --git a/SpringJava/Kafka/SpringCloudStream/spring-stream-kafka-consumer/src/test/java/de/example/spring/kafka/ReceiverIntegrationTest.java b/SpringJava/Kafka/SpringCloudStream/spring-stream-kafka-consumer/src/test/java/de/example/spring/kafka/ReceiverIntegrationTest.java new file mode 100644 index 0000000..9a01a2d --- /dev/null +++ b/SpringJava/Kafka/SpringCloudStream/spring-stream-kafka-consumer/src/test/java/de/example/spring/kafka/ReceiverIntegrationTest.java @@ -0,0 +1,45 @@ +package de.example.spring.kafka; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; +import static org.mockito.Mockito.doNothing; + +import javax.inject.Inject; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.cloud.stream.messaging.Sink; +import org.springframework.messaging.Message; +import org.springframework.messaging.support.GenericMessage; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +@RunWith(SpringJUnit4ClassRunner.class) +@SpringBootTest(classes = { Receiver.class }) +@DirtiesContext +public class ReceiverIntegrationTest { + + @Inject + Sink source; + + @MockBean + DummyService dummyService; + + @Test + public void callSomeDummy() { + String productName = "product"; + String productDescription = "productDescription"; + Product product = new Product(productName, productDescription); + ArgumentCaptor dummyArgCaptor = ArgumentCaptor.forClass(String.class); + doNothing().when(dummyService).iAmVeryDummy(dummyArgCaptor.capture()); + + Message message = new GenericMessage<>(product); + source.input().send(message); + + assertThat(dummyArgCaptor.getValue(), is(product.getName())); + } + +} diff --git a/SpringJava/Kafka/SpringCloudStream/spring-stream-kafka-consumer/src/test/java/de/example/spring/kafka/ReceiverShould.java b/SpringJava/Kafka/SpringCloudStream/spring-stream-kafka-consumer/src/test/java/de/example/spring/kafka/ReceiverShould.java deleted file mode 100644 index 6291ea4..0000000 --- a/SpringJava/Kafka/SpringCloudStream/spring-stream-kafka-consumer/src/test/java/de/example/spring/kafka/ReceiverShould.java +++ /dev/null @@ -1,45 +0,0 @@ -package de.example.spring.kafka; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; -import static org.mockito.Mockito.doNothing; - -import javax.inject.Inject; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.ArgumentCaptor; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.cloud.stream.messaging.Sink; -import org.springframework.messaging.Message; -import org.springframework.messaging.support.GenericMessage; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -@RunWith(SpringJUnit4ClassRunner.class) -@SpringBootTest(classes = { Receiver.class }) -@DirtiesContext -public class ReceiverShould { - - @Inject - Sink source; - - @MockBean - DummyService dummyService; - - @Test - public void callSomeDummy() { - String productName = "product"; - String productDescription = "productDescription"; - Product product = new Product(productName, productDescription); - ArgumentCaptor dummyArgCaptor = ArgumentCaptor.forClass(String.class); - doNothing().when(dummyService).iAmVeryDummy(dummyArgCaptor.capture()); - - Message message = new GenericMessage<>(product); - source.input().send(message); - - assertThat(dummyArgCaptor.getValue(), is(product.getName())); - } - -} diff --git a/SpringJava/Kafka/SpringCloudStream/spring-stream-kafka-producer/src/test/java/de/example/spring/kafka/SenderIntegrationTest.java b/SpringJava/Kafka/SpringCloudStream/spring-stream-kafka-producer/src/test/java/de/example/spring/kafka/SenderIntegrationTest.java new file mode 100644 index 0000000..d424fac --- /dev/null +++ b/SpringJava/Kafka/SpringCloudStream/spring-stream-kafka-producer/src/test/java/de/example/spring/kafka/SenderIntegrationTest.java @@ -0,0 +1,42 @@ +package de.example.spring.kafka; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + +import javax.inject.Inject; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.cloud.stream.messaging.Source; +import org.springframework.cloud.stream.test.binder.MessageCollector; +import org.springframework.messaging.Message; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +@RunWith(SpringJUnit4ClassRunner.class) +@SpringBootTest(classes = { Sender.class }) +@DirtiesContext +public class SenderIntegrationTest { + + @Inject + Source source; + + @Inject + Sender sender; + + @Inject + private MessageCollector messageCollector; + + @Test + public void sendSomeProduct() { + Product product = new Product("hello", "this is some description"); + + sender.sendMessage("hello"); + + Message received = (Message) messageCollector.forChannel(source.output()).poll(); + + assertThat(received.getPayload().getDescription(), is(product.getDescription())); + } + +} diff --git a/SpringJava/Kafka/SpringCloudStream/spring-stream-kafka-producer/src/test/java/de/example/spring/kafka/SenderShould.java b/SpringJava/Kafka/SpringCloudStream/spring-stream-kafka-producer/src/test/java/de/example/spring/kafka/SenderShould.java deleted file mode 100644 index 71fbfec..0000000 --- a/SpringJava/Kafka/SpringCloudStream/spring-stream-kafka-producer/src/test/java/de/example/spring/kafka/SenderShould.java +++ /dev/null @@ -1,42 +0,0 @@ -package de.example.spring.kafka; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; - -import javax.inject.Inject; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.cloud.stream.messaging.Source; -import org.springframework.cloud.stream.test.binder.MessageCollector; -import org.springframework.messaging.Message; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -@RunWith(SpringJUnit4ClassRunner.class) -@SpringBootTest(classes = { Sender.class }) -@DirtiesContext -public class SenderShould { - - @Inject - Source source; - - @Inject - Sender sender; - - @Inject - private MessageCollector messageCollector; - - @Test - public void sendSomeProduct() { - Product product = new Product("hello", "this is some description"); - - sender.sendMessage("hello"); - - Message received = (Message) messageCollector.forChannel(source.output()).poll(); - - assertThat(received.getPayload().getDescription(), is(product.getDescription())); - } - -} -- 2.1.4