source: proiecte/HadoopJUnit/hadoop-0.20.1/src/test/org/apache/hadoop/mapred/lib/TestMultipleInputs.java @ 120

Last change on this file since 120 was 120, checked in by (none), 14 years ago

Added the mail files for the Hadoop JUNit Project

  • Property svn:executable set to *
File size: 3.0 KB
Line 
1/**
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
9 *
10 *     http://www.apache.org/licenses/LICENSE-2.0
11 *
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.
17 */
18package org.apache.hadoop.mapred.lib;
19
20import java.io.IOException;
21import java.util.Map;
22
23import junit.framework.TestCase;
24
25import org.apache.hadoop.fs.Path;
26import org.apache.hadoop.mapred.InputFormat;
27import org.apache.hadoop.mapred.JobConf;
28import org.apache.hadoop.mapred.KeyValueTextInputFormat;
29import org.apache.hadoop.mapred.Mapper;
30import org.apache.hadoop.mapred.OutputCollector;
31import org.apache.hadoop.mapred.Reporter;
32import org.apache.hadoop.mapred.TextInputFormat;
33
34/**
35 * @see TestDelegatingInputFormat
36 */
37public class TestMultipleInputs extends TestCase {
38 
39  public void testAddInputPathWithFormat() {
40    final JobConf conf = new JobConf();
41    MultipleInputs.addInputPath(conf, new Path("/foo"), TextInputFormat.class);
42    MultipleInputs.addInputPath(conf, new Path("/bar"),
43        KeyValueTextInputFormat.class);
44    final Map<Path, InputFormat> inputs = MultipleInputs
45       .getInputFormatMap(conf);
46    assertEquals(TextInputFormat.class, inputs.get(new Path("/foo")).getClass());
47    assertEquals(KeyValueTextInputFormat.class, inputs.get(new Path("/bar"))
48       .getClass());
49  }
50
51  public void testAddInputPathWithMapper() {
52    final JobConf conf = new JobConf();
53    MultipleInputs.addInputPath(conf, new Path("/foo"), TextInputFormat.class,
54       MapClass.class);
55    MultipleInputs.addInputPath(conf, new Path("/bar"),
56       KeyValueTextInputFormat.class, MapClass2.class);
57    final Map<Path, InputFormat> inputs = MultipleInputs
58       .getInputFormatMap(conf);
59    final Map<Path, Class<? extends Mapper>> maps = MultipleInputs
60       .getMapperTypeMap(conf);
61
62    assertEquals(TextInputFormat.class, inputs.get(new Path("/foo")).getClass());
63    assertEquals(KeyValueTextInputFormat.class, inputs.get(new Path("/bar"))
64       .getClass());
65    assertEquals(MapClass.class, maps.get(new Path("/foo")));
66    assertEquals(MapClass2.class, maps.get(new Path("/bar")));
67  }
68
69  static class MapClass implements Mapper<String, String, String, String> {
70
71    public void map(String key, String value,
72       OutputCollector<String, String> output, Reporter reporter)
73       throws IOException {
74    }
75
76    public void configure(JobConf job) {
77    }
78
79    public void close() throws IOException {
80    }
81  }
82
83  static class MapClass2 extends MapClass {
84  }
85}
Note: See TracBrowser for help on using the repository browser.