1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.dbunit.database.search;
22
23 import org.dbunit.database.IDatabaseConnection;
24
25
26
27
28
29
30 public class ImportAndExportKeysSearchCallbackIT
31 extends AbstractMetaDataBasedSearchCallbackTestCase
32 {
33
34 public static final String SQL_FILE = "hypersonic_import_export.sql";
35
36 @Override
37 protected String getSqlFile()
38 {
39 return SQL_FILE;
40 }
41
42 @Override
43 protected String[] getTestTableNames()
44 {
45 return new String[] {"C", "D", "E", "A", "B", "F"};
46 }
47
48 public static final String[][] SINGLE_INPUT = new String[][] {
49 new String[] {"A"}, new String[] {"B"}, new String[] {"C"},
50 new String[] {"D"}, new String[] {"E"}, new String[] {"F"}};
51
52 public static String[][] getSingleInputWithSchema(final String schema)
53 {
54 final String[][] singleInputWithSchema =
55 new String[SINGLE_INPUT.length][];
56 for (int i = 0; i < SINGLE_INPUT.length; i++)
57 {
58 final String[] currentInputWithoutSchema = SINGLE_INPUT[i];
59 singleInputWithSchema[i] =
60 new String[currentInputWithoutSchema.length];
61 for (int j = 0; j < currentInputWithoutSchema.length; j++)
62 {
63 singleInputWithSchema[i][j] =
64 "TEST_SCHEMA." + currentInputWithoutSchema[j];
65 }
66 }
67 return singleInputWithSchema;
68 }
69
70 public static final String[][] COMPOUND_INPUT =
71 new String[][] {new String[] {"A", "D"}, new String[] {"D", "A"},
72 new String[] {"B", "F"}, new String[] {"F", "B"},
73 new String[] {"A", "E"}, new String[] {"E", "A"}};
74
75 public static final String[][] SINGLE_OUTPUT = new String[][] {
76 new String[] {"B", "A", "C"}, new String[] {"B", "A", "C"},
77 new String[] {"B", "A", "C"}, new String[] {"F", "E", "D"},
78 new String[] {"F", "E", "D"}, new String[] {"F", "E", "D"}};
79
80 public static final String[][] COMPOUND_OUTPUT =
81 new String[][] {new String[] {"B", "A", "C", "F", "E", "D"},
82 new String[] {"F", "E", "D", "B", "A", "C"},
83 new String[] {"B", "A", "C", "F", "E", "D"},
84 new String[] {"F", "E", "D", "B", "A", "C"},
85 new String[] {"B", "A", "C", "F", "E", "D"},
86 new String[] {"F", "E", "D", "B", "A", "C"}};
87
88 @Override
89 protected String[][] getInput()
90 {
91 final String[][] input =
92 new String[SINGLE_INPUT.length + COMPOUND_INPUT.length][];
93 System.arraycopy(SINGLE_INPUT, 0, input, 0, SINGLE_INPUT.length);
94 System.arraycopy(COMPOUND_INPUT, 0, input, SINGLE_INPUT.length,
95 COMPOUND_INPUT.length);
96 return input;
97 }
98
99 @Override
100 protected String[][] getExpectedOutput()
101 {
102 final String[][] output =
103 new String[SINGLE_OUTPUT.length + COMPOUND_OUTPUT.length][];
104 System.arraycopy(SINGLE_OUTPUT, 0, output, 0, SINGLE_OUTPUT.length);
105 System.arraycopy(COMPOUND_OUTPUT, 0, output, SINGLE_OUTPUT.length,
106 COMPOUND_OUTPUT.length);
107 return output;
108 }
109
110 @Override
111 protected AbstractMetaDataBasedSearchCallback getCallback(
112 final IDatabaseConnection connection)
113 {
114 return new ImportedAndExportedKeysSearchCallback(connection);
115 }
116
117 }