2

Need one help with MRUnit. I am adding my config file to MapReduceDriver as below.

conf = mapReduceDriver.getConfiguration();
conf.addResource("path_to_config.xml");

When reducer class is trying to access the the property in setUp() mehtod, its not getting the values from the passed in configuration file.

Configuration conf = context.getConfiguration();
String appNameListStr = conf.get("CODE.MAPPING");

// this appNameListStr is returned as null;

Any suggestions/hints on this.

SurjanSRawat
  • 489
  • 1
  • 6
  • 20

1 Answers1

0

According to the javadocs passing in a String causes the classpath to be examined for a file with that name. You're trying to load a file from the local file system.

You should use addResource(URL url) or addResource(Path file) to look at the local file system.

For example:

conf.addResource(new File("path_to_config.xml").toURI().toURL());

Binary Nerd
  • 13,872
  • 4
  • 42
  • 44
  • Hi BN, I am still facing the same issue. The passed in config values are reflected in Test class but when the control reaches Mapper class all the config values are null. Have also tried setting the properties using config.set(name,value). Any suggestions/hints – SurjanSRawat Jul 14 '16 at 04:00