### Question:
HadoopCodecFactory { public static CodecFactory fromHadoopString(String hadoopCodecClass) { CodecFactory o = null; try { String avroCodec = HADOOP_AVRO_NAME_MAP.get(hadoopCodecClass); if (avroCodec != null) { o = CodecFactory.fromString(avroCodec); } } catch (Exception e) { throw new AvroRuntimeException("Unrecognized hadoop codec: " + hadoopCodecClass, e); } return o; }  static CodecFactory fromHadoopString(String hadoopCodecClass); static String getAvroCodecName(String hadoopCodecClass);  }### Answer:
@Test public void testHadoopCodecFactoryDeflate() { CodecFactory hadoopDeflateCodec = HadoopCodecFactory.fromHadoopString("org.apache.hadoop.io.compress.DeflateCodec"); CodecFactory avroDeflateCodec = CodecFactory.fromString("deflate"); assertTrue(hadoopDeflateCodec.getClass().equals(avroDeflateCodec.getClass())); }
@Test public void testHadoopCodecFactorySnappy() { CodecFactory hadoopSnappyCodec = HadoopCodecFactory.fromHadoopString("org.apache.hadoop.io.compress.SnappyCodec"); CodecFactory avroSnappyCodec = CodecFactory.fromString("snappy"); assertTrue(hadoopSnappyCodec.getClass().equals(avroSnappyCodec.getClass())); }
@Test public void testHadoopCodecFactoryBZip2() { CodecFactory hadoopSnappyCodec = HadoopCodecFactory.fromHadoopString("org.apache.hadoop.io.compress.BZip2Codec"); CodecFactory avroSnappyCodec = CodecFactory.fromString("bzip2"); assertTrue(hadoopSnappyCodec.getClass().equals(avroSnappyCodec.getClass())); }
@Test public void testHadoopCodecFactoryGZip() { CodecFactory hadoopSnappyCodec = HadoopCodecFactory.fromHadoopString("org.apache.hadoop.io.compress.GZipCodec"); CodecFactory avroSnappyCodec = CodecFactory.fromString("deflate"); assertTrue(hadoopSnappyCodec.getClass().equals(avroSnappyCodec.getClass())); }
@Test public void testHadoopCodecFactoryFail() { CodecFactory hadoopSnappyCodec = HadoopCodecFactory.fromHadoopString("org.apache.hadoop.io.compress.FooCodec"); assertTrue(hadoopSnappyCodec == null); }