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 ImportNodesFilterSearchCallbackTest extends AbstractMetaDataBasedSearchCallbackTestCase {
31    
32    public static final String SQL_FILE = "hypersonic_import.sql";
33  
34    public static final String[][] SINGLE_INPUT = new String[][] {
35      new String[] { "A" }, 
36      new String[] { "B" }, 
37      new String[] { "C" },
38      new String[] { "D" }, 
39      new String[] { "E" }, 
40      new String[] { "F" },
41      new String[] { "G" }, 
42      new String[] { "H" }
43    };
44    
45    public static final String[][] COMPOUND_INPUT = new String[][] {
46      new String[] { "A", "H" }, 
47      new String[] { "H", "A" },
48      new String[] { "A", "B" }, 
49      new String[] { "B", "A" },
50      new String[] { "B", "A", "A", "B", "D", "G" } 
51    };
52    
53    public static final String[][] SINGLE_OUTPUT = new String[][] {
54      new String[] { "G", "D", "A" },
55      new String[] { "G", "D", "A", "F", "C", "E", "H", "B" },
56      new String[] { "G", "D", "A", "F", "C" },
57      new String[] { "A", "G", "D" }, 
58      new String[] { "G", "D", "A", "E" },
59      new String[] { "A", "G", "D", "F" }, 
60      new String[] { "D", "A", "G" },
61      new String[] { "H" },    
62    };
63  
64    public static final String[][] COMPOUND_OUTPUT = new String[][] {
65      new String[] { "G", "D", "A", "H" },
66      new String[] { "H", "G", "D", "A" },
67      new String[] { "G", "D", "A", "F", "C", "E", "H", "B" },
68      new String[] { "G", "D", "A", "F", "C", "E", "H", "B" },
69      new String[] { "G", "D", "A", "F", "C", "E", "H", "B" }     
70    };
71    
72     public ImportNodesFilterSearchCallbackTest(String testName) {
73     super(testName, SQL_FILE);
74     }
75       
76    protected String[][] getInput() { 
77      String[][] input = new String[SINGLE_INPUT.length+COMPOUND_INPUT.length][];
78      System.arraycopy( SINGLE_INPUT, 0, input, 0, SINGLE_INPUT.length);
79      System.arraycopy(COMPOUND_INPUT,0,input,SINGLE_INPUT.length,COMPOUND_INPUT.length);
80      return input;
81    }
82    protected String[][] getExpectedOutput() { 
83      String[][] output = new String[SINGLE_OUTPUT.length+COMPOUND_OUTPUT.length][];
84      System.arraycopy( SINGLE_OUTPUT, 0, output, 0, SINGLE_OUTPUT.length);
85      System.arraycopy(COMPOUND_OUTPUT,0,output,SINGLE_OUTPUT.length,COMPOUND_OUTPUT.length);
86      return output;    
87    }
88  
89    protected AbstractMetaDataBasedSearchCallback getCallback(IDatabaseConnection connection) {
90      return new ImportedKeysSearchCallback(connection);
91    }
92  
93  }