INTSAMPLES-19 Change Return Type to List<> from Array
This commit is contained in:
@@ -17,6 +17,7 @@ package org.springframework.integration.samples.testing.externalgateway;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.context.support.AbstractApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
@@ -36,8 +37,8 @@ public class Main {
|
||||
BufferedReader console = new BufferedReader(new InputStreamReader(System.in));
|
||||
String zip = console.readLine().trim();
|
||||
WeatherAndTraffic weatherAndTraffic = context.getBean("wat", WeatherAndTraffic.class);
|
||||
String[] result = weatherAndTraffic.getByZip(zip);
|
||||
System.out.println(result[0] + "\r\n" + result[1] + "\r\n");
|
||||
List<String> result = weatherAndTraffic.getByZip(zip);
|
||||
System.out.println(result.get(0) + "\r\n" + result.get(1) + "\r\n");
|
||||
context.close();
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package org.springframework.integration.samples.testing.externalgateway;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Gary Russell
|
||||
* @since 2.0.2
|
||||
@@ -22,6 +24,6 @@ package org.springframework.integration.samples.testing.externalgateway;
|
||||
*/
|
||||
public interface WeatherAndTraffic {
|
||||
|
||||
public String[] getByZip(String zip);
|
||||
public List<String> getByZip(String zip);
|
||||
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
<channel id="aggregatorChannel" />
|
||||
|
||||
<aggregator input-channel="aggregatorChannel"
|
||||
expression="#this.![payload].toArray()"/>
|
||||
expression="#this.![payload]"/>
|
||||
|
||||
<task:executor id="executor" pool-size="10"/>
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@ package org.springframework.integration.samples.testing.externalgateway;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
@@ -45,14 +45,12 @@ public class ExternalGatewaySubstitutionTests {
|
||||
|
||||
@Test
|
||||
public void doTest() {
|
||||
String[] results = weatherAndTraffic.getByZip("12345");
|
||||
assertEquals(2, results.length);
|
||||
List<String> list = new ArrayList<String>();
|
||||
list.add(results[0]);
|
||||
list.add(results[1]);
|
||||
Collections.sort(list);
|
||||
assertEquals("Dummy traffic for zip:12345", list.get(0));
|
||||
assertEquals("Dummy weather for zip:12345", list.get(1));
|
||||
List<String> results = weatherAndTraffic.getByZip("12345");
|
||||
assertEquals(2, results.size());
|
||||
Collections.sort(results);
|
||||
Iterator<String> result = results.iterator();
|
||||
assertEquals("Dummy traffic for zip:12345", result.next());
|
||||
assertEquals("Dummy weather for zip:12345", result.next());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user