View Javadoc
1   /*
2    *
3    * The DbUnit Database Testing Framework
4    * Copyright (C)2005, DbUnit.org
5    *
6    * This library is free software; you can redistribute it and/or
7    * modify it under the terms of the GNU Lesser General Public
8    * License as published by the Free Software Foundation; either
9    * version 2.1 of the License, or (at your option) any later version.
10   *
11   * This library is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14   * Lesser General Public License for more details.
15   *
16   * You should have received a copy of the GNU Lesser General Public
17   * License along with this library; if not, write to the Free Software
18   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19   *
20   */
21  package org.dbunit.database.search;
22  
23  import org.dbunit.database.IDatabaseConnection;
24  
25  /**
26   * @author Felipe Leme (dbunit@felipeal.net)
27   * @version $Revision$
28   * @since Aug 28, 2005
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 }