2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 package org
.apache
.sqoop
.hcat
;
21 import junit
.framework
.TestCase
;
23 import org
.junit
.Before
;
25 import com
.cloudera
.sqoop
.SqoopOptions
;
26 import com
.cloudera
.sqoop
.tool
.ExportTool
;
27 import com
.cloudera
.sqoop
.tool
.ImportTool
;
30 * Test basic HCatalog related features.
32 public class TestHCatalogBasic
extends TestCase
{
33 private static ImportTool importTool
;
34 private static ExportTool exportTool
;
39 importTool
= new ImportTool();
40 exportTool
= new ExportTool();
42 private SqoopOptions
parseImportArgs(String
[] argv
) throws Exception
{
43 SqoopOptions opts
= importTool
.parseArguments(argv
, null
, null
, false
);
47 private SqoopOptions
parseExportArgs(String
[] argv
) throws Exception
{
48 SqoopOptions opts
= exportTool
.parseArguments(argv
, null
, null
, false
);
52 public void testHCatalogHomeWithImport() throws Exception
{
58 SqoopOptions opts
= parseImportArgs(args
);
61 public void testHCatalogHomeWithExport() throws Exception
{
67 SqoopOptions opts
= parseExportArgs(args
);
70 public void testHCatalogImport() throws Exception
{
76 SqoopOptions opts
= parseImportArgs(args
);
79 public void testHCatalogExport() throws Exception
{
85 SqoopOptions opts
= parseExportArgs(args
);
88 public void testHCatImportWithTargetDir() throws Exception
{
100 SqoopOptions opts
= parseImportArgs(args
);
101 importTool
.validateOptions(opts
);
102 fail("Expected InvalidOptionsException");
103 } catch (SqoopOptions
.InvalidOptionsException ioe
) {
108 public void testHCatImportWithWarehouseDir() throws Exception
{
120 SqoopOptions opts
= parseImportArgs(args
);
121 importTool
.validateOptions(opts
);
122 fail("Expected InvalidOptionsException");
123 } catch (SqoopOptions
.InvalidOptionsException ioe
) {
128 public void testHCatImportWithHiveImport() throws Exception
{
139 SqoopOptions opts
= parseImportArgs(args
);
140 importTool
.validateOptions(opts
);
141 fail("Expected InvalidOptionsException");
142 } catch (SqoopOptions
.InvalidOptionsException ioe
) {
147 public void testHCatExportWithExportDir() throws Exception
{
159 SqoopOptions opts
= parseExportArgs(args
);
160 exportTool
.validateOptions(opts
);
161 fail("Expected InvalidOptionsException");
162 } catch (SqoopOptions
.InvalidOptionsException ioe
) {
167 public void testHCatImportWithDirect() throws Exception
{
178 SqoopOptions opts
= parseImportArgs(args
);
179 importTool
.validateOptions(opts
);
180 fail("Expected InvalidOptionsException");
181 } catch (SqoopOptions
.InvalidOptionsException ioe
) {
186 public void testHCatImportWithSequenceFile() throws Exception
{
197 SqoopOptions opts
= parseImportArgs(args
);
198 importTool
.validateOptions(opts
);
199 fail("Expected InvalidOptionsException");
200 } catch (SqoopOptions
.InvalidOptionsException ioe
) {
205 public void testHCatImportWithAvroFile() throws Exception
{
216 SqoopOptions opts
= parseImportArgs(args
);
217 importTool
.validateOptions(opts
);
218 fail("Expected InvalidOptionsException");
219 } catch (SqoopOptions
.InvalidOptionsException ioe
) {
223 public void testHCatImportWithCreateTable() throws Exception
{
227 "--create-hcatalog-table",
229 SqoopOptions opts
= parseImportArgs(args
);
232 public void testHCatImportWithStorageStanza() throws Exception
{
236 "--hcatalog-storage-stanza",
237 "stored as textfile",
239 SqoopOptions opts
= parseImportArgs(args
);
242 public void testHCatImportWithDatabase() throws Exception
{
246 "--hcatalog-database",
249 SqoopOptions opts
= parseImportArgs(args
);