BAEL-5636 Move the files from patterns/ into patterns-modules/ (#12742)

This commit is contained in:
bipster
2022-09-20 00:49:57 -04:00
committed by GitHub
parent b695aa51b5
commit 2842e5cee7
7 changed files with 0 additions and 0 deletions
@@ -0,0 +1,48 @@
package com.baeldung.seda.apachecamel;
import java.util.HashMap;
import java.util.Map;
import org.apache.camel.RoutesBuilder;
import org.apache.camel.test.junit5.CamelTestSupport;
import org.junit.jupiter.api.Test;
import com.baeldung.seda.apachecamel.WordCountRoute;
public class ApacheCamelSedaIntegrationTest extends CamelTestSupport {
@Test
public void givenTextWithCapitalAndSmallCaseAndWithoutDuplicateWords_whenSendingTextToInputUri_thenWordCountReturnedAsMap() throws InterruptedException {
Map<String, Long> expected = new HashMap<>();
expected.put("my", 1L);
expected.put("name", 1L);
expected.put("is", 1L);
expected.put("hesam", 1L);
getMockEndpoint(WordCountRoute.returnResponse).expectedBodiesReceived(expected);
template.sendBody(WordCountRoute.receiveTextUri, "My name is Hesam");
assertMockEndpointsSatisfied();
}
@Test
public void givenTextWithDuplicateWords_whenSendingTextToInputUri_thenWordCountReturnedAsMap() throws InterruptedException {
Map<String, Long> expected = new HashMap<>();
expected.put("the", 3L);
expected.put("dog", 1L);
expected.put("chased", 1L);
expected.put("rabbit", 1L);
expected.put("into", 1L);
expected.put("jungle", 1L);
getMockEndpoint(WordCountRoute.returnResponse).expectedBodiesReceived(expected);
template.sendBody(WordCountRoute.receiveTextUri, "the dog chased the rabbit into the jungle");
assertMockEndpointsSatisfied();
}
@Override
protected RoutesBuilder createRouteBuilder() throws Exception {
RoutesBuilder wordCountRoute = new WordCountRoute();
return wordCountRoute;
}
}
@@ -0,0 +1,50 @@
package com.baeldung.seda.springintegration;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.integration.annotation.IntegrationComponentScan;
import org.springframework.integration.config.EnableIntegration;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.support.AnnotationConfigContextLoader;
@ExtendWith(SpringExtension.class)
@ContextConfiguration(loader = AnnotationConfigContextLoader.class, classes = { TaskExecutorConfiguration.class, ChannelConfiguration.class, IntegrationConfiguration.class })
@EnableIntegration
@IntegrationComponentScan(basePackages = { "com.baeldung.seda.springintegration" })
public class SpringIntegrationSedaIntegrationTest {
@Autowired
TestGateway testGateway;
@Test
void givenTextWithCapitalAndSmallCaseAndWithoutDuplicateWords_whenCallingCountWordOnGateway_thenWordCountReturnedAsMap() {
Map<String, Long> actual = testGateway.countWords("My name is Hesam");
Map<String, Long> expected = new HashMap<>();
expected.put("my", 1L);
expected.put("name", 1L);
expected.put("is", 1L);
expected.put("hesam", 1L);
org.junit.Assert.assertEquals(expected, actual);
}
@Test
void givenTextWithDuplicateWords_whenCallingCountWordOnGateway_thenWordCountReturnedAsMap() {
Map<String, Long> actual = testGateway.countWords("the dog chased the rabbit into the jungle");
Map<String, Long> expected = new HashMap<>();
expected.put("the", 3L);
expected.put("dog", 1L);
expected.put("chased", 1L);
expected.put("rabbit", 1L);
expected.put("into", 1L);
expected.put("jungle", 1L);
org.junit.Assert.assertEquals(expected, actual);
}
}