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 ImportAndExportKeysSearchCallbackOwnFileTest extends AbstractMetaDataBasedSearchCallbackTestCase {
31    
32    
33    public static final String SQL_FILE = "hypersonic_import_export.sql";
34  
35    public ImportAndExportKeysSearchCallbackOwnFileTest(String testName) {
36     super(testName, SQL_FILE);
37     }
38    
39    public static final String[][] SINGLE_INPUT = new String[][] {
40      new String[] { "A" }, 
41      new String[] { "B" }, 
42      new String[] { "C" },
43      new String[] { "D" }, 
44      new String[] { "E" }, 
45      new String[] { "F" }
46    };
47  
48    	public static String[][] getSingleInputWithSchema(String schema) {
49    		String[][] singleInputWithSchema = new String[SINGLE_INPUT.length][];
50    		for (int i = 0; i < SINGLE_INPUT.length; i++) {
51    			String[] currentInputWithoutSchema = SINGLE_INPUT[i];
52    			singleInputWithSchema[i] = new String[currentInputWithoutSchema.length];
53    			for (int j = 0; j < currentInputWithoutSchema.length; j++) {
54    				singleInputWithSchema[i][j] = "TEST_SCHEMA." + currentInputWithoutSchema[j];
55    			}
56    		}
57    		return singleInputWithSchema;
58    	}
59  
60    public static final String[][] COMPOUND_INPUT = new String[][] {
61      new String[] { "A", "D" }, 
62      new String[] { "D", "A" },
63      new String[] { "B", "F" }, 
64      new String[] { "F", "B" },
65      new String[] { "A", "E" }, 
66      new String[] { "E", "A" }
67    };
68    
69    public static final String[][] SINGLE_OUTPUT = new String[][] {
70      new String[] { "B", "A", "C" },
71      new String[] { "B", "A", "C" },
72      new String[] { "B", "A", "C" },
73      new String[] { "F", "E", "D" },
74      new String[] { "F", "E", "D" },
75      new String[] { "F", "E", "D" }    
76    };
77  
78    public static final String[][] COMPOUND_OUTPUT = new String[][] {  
79          new String[] { "B", "A", "C", "F", "E", "D" },       
80          new String[] { "F", "E", "D", "B", "A", "C" },
81          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      };
86    
87    protected String[][] getInput() { 
88      String[][] input = new String[SINGLE_INPUT.length+COMPOUND_INPUT.length][];
89      System.arraycopy(SINGLE_INPUT, 0, input, 0, SINGLE_INPUT.length);
90      System.arraycopy(COMPOUND_INPUT,0,input,SINGLE_INPUT.length,COMPOUND_INPUT.length);
91      return input;
92    }
93    
94    protected String[][] getExpectedOutput() { 
95      String[][] output = new String[SINGLE_OUTPUT.length+COMPOUND_OUTPUT.length][];
96      System.arraycopy(SINGLE_OUTPUT, 0, output, 0, SINGLE_OUTPUT.length);
97      System.arraycopy(COMPOUND_OUTPUT,0,output,SINGLE_OUTPUT.length,COMPOUND_OUTPUT.length);
98      return output;    
99    }
100 
101   protected AbstractMetaDataBasedSearchCallback getCallback(IDatabaseConnection connection) {
102     return new ImportedAndExportedKeysSearchCallback(connection);
103   }
104 
105 }