WritableName { public static synchronized Class<?> getClass(String name, Configuration conf ) throws IOException { Class<?> writableClass = NAME_TO_CLASS.get(name); if (writableClass != null) return writableClass.asSubclass(Writable.class); try { return conf.getClassByName(name); } catch (ClassNotFoundException e) { IOException newE = new IOException("WritableName can't load class: " + name); newE.initCause(e); throw newE; } } private  WritableName(); static synchronized void setName(Class<?> writableClass, String name); static synchronized void addName(Class<?> writableClass, String name); static synchronized String getName(Class<?> writableClass); static synchronized Class<?> getClass(String name, Configuration conf
                                            );  }
@Test public void testGoodName() throws Exception { Configuration conf = new Configuration(); Class<?> test = WritableName.getClass("long",conf); assertTrue(test != null); }
@Test public void testBadName() throws Exception { Configuration conf = new Configuration(); try { WritableName.getClass("unknown_junk",conf); assertTrue(false); } catch(IOException e) { assertTrue(e.getMessage().matches(".*unknown_junk.*")); } }