1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.common.jdbc.supplier;
17
18 import java.util.ArrayList;
19 import java.util.List;
20
21 import org.junit.Test;
22 import org.kuali.common.jdbc.DefaultSqlReader;
23 import org.kuali.common.jdbc.SqlMetaData;
24 import org.kuali.common.jdbc.SqlReader;
25 import org.slf4j.Logger;
26 import org.slf4j.LoggerFactory;
27 import org.springframework.util.Assert;
28
29 public class ComplexStringSupplierTest {
30
31 private static final Logger logger = LoggerFactory.getLogger(ComplexStringSupplierTest.class);
32
33 @Test
34 public void test() {
35 String singleSqlStatement = "select sysdate from dual\n/\n";
36 int count = 5;
37 StringBuilder sb = new StringBuilder();
38 for (int i = 0; i < count; i++) {
39 sb.append(singleSqlStatement);
40 }
41 List<String> list = new ArrayList<String>();
42 list.add(sb.toString());
43 list.add(sb.toString());
44 list.add(sb.toString());
45 list.add("select sysdate from dual");
46
47 SqlReader reader = new DefaultSqlReader();
48
49 ComplexStringSupplier supplier = new ComplexStringSupplier();
50 supplier.setStrings(list);
51 supplier.setReader(reader);
52
53 supplier.fillInMetaData();
54 SqlMetaData smd = supplier.getMetaData();
55
56 Assert.isTrue(smd.getCount() == count * 3 + 1);
57
58 supplier.open();
59 List<String> sql = supplier.getSql();
60 while (sql != null) {
61 for (String s : sql) {
62 logger.info(s);
63 }
64 sql = supplier.getSql();
65 }
66 supplier.close();
67
68 }
69
70 }