Hi,

You are not setting the input key. I would use withInput(key, value).

Brock


On Sun, Jul 14, 2013 at 1:23 PM, شجاع الرحمن بیگ <shujamughal@gmail.com> wrote:
Hi All

I am trying to run mr unit test but it saying No Input was provided. The test case is from the book The Hadoop Definitive Guide. ch5. Here is my POM file

  <dependencies>

<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-core</artifactId>
<version>2.0.0-mr1-cdh4.1.2 </version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-client</artifactId>
<version>2.0.0-cdh4.1.2  </version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId> hadoop-common </artifactId>
<version>2.0.0-cdh4.1.2  </version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId> hadoop-hdfs  </artifactId>
<version>2.0.0-cdh4.1.2  </version>
</dependency>
     <dependency>
    <groupId>org.apache.mrunit</groupId>
    <artifactId>mrunit</artifactId>
    <version>0.9.0-incubating</version>
    <classifier>hadoop2</classifier> 
    <scope>test</scope>
</dependency>
            <dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-test</artifactId>
<version>1.1.2</version>
</dependency>
            
    
    <dependency>
        <groupId>org.hamcrest</groupId>
        <artifactId>hamcrest-all</artifactId>
        <version>1.1</version>
        <scope>test</scope>
      </dependency>
    
  </dependencies>


and TestCase is 

 @Test
  public void processesValidRecord() throws IOException, InterruptedException {
    Text value = new Text("0043011990999991950051518004+68750+023550FM-12+0382" +
                                  // Year ^^^^
        "99999V0203201N00261220001CN9999999N9-00111+99999999999");
                              // Temperature ^^^^^
    new MapDriver<LongWritable, Text, Text, IntWritable>()
      .withMapper(new MaxTemperatureMapper())
      .withInputValue(value)
      .withOutput(new Text("1950"), new IntWritable(-11))
      .runTest();
  }

and Mapper class is 

public class MaxTemperatureMapper
  extends Mapper<LongWritable, Text, Text, IntWritable> {
  
  @Override
  public void map(LongWritable key, Text value, Context context)
      throws IOException, InterruptedException {
    
    String line = value.toString();
    String year = line.substring(15, 19);
    int airTemperature = Integer.parseInt(line.substring(87, 92));
    context.write(new Text(year), new IntWritable(airTemperature));
  }
}

Any Clue??????

--
Regards
Shuja-ur-Rehman Baig




--
Apache MRUnit - Unit testing MapReduce - http://mrunit.apache.org