MRUnit Context object returning empty configuration

101 Views Asked by At

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.

1

There are 1 best solutions below

1
Binary Nerd On

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());