ProfilingWriter extends Writer { public ProfilingWriter(LanguageProfile profile) { this.profile = profile; } ProfilingWriter(LanguageProfile profile);  ProfilingWriter(); LanguageProfile getProfile(); LanguageIdentifier getLanguage(); @Override void write(char[] cbuf, int off, int len); @Override void close(); @Override void flush();  }
@Test public void testProfilingWriter() throws IOException { ProfilingWriter writer = new ProfilingWriter(); writer.write(" foo+BAR FooBar\n"); writer.close(); LanguageProfile profile = writer.getProfile(); assertEquals(2, profile.getCount("_fo")); assertEquals(2, profile.getCount("foo")); assertEquals(1, profile.getCount("oo_")); assertEquals(1, profile.getCount("oob")); assertEquals(1, profile.getCount("oba")); assertEquals(1, profile.getCount("_ba")); assertEquals(2, profile.getCount("bar")); assertEquals(2, profile.getCount("ar_")); }