### Question:
OnlyTitleProcessor implements EntryProcessor { public static OnlyTitleProcessor getProcessor(TtsVoice voice) { try { return OnlyTitleProcessor.CACHE.get(voice); } catch (final GenerationException e) { } return null; } protected  OnlyTitleProcessor(TtsVoice voice); static OnlyTitleProcessor getProcessor(TtsVoice voice); static OnlyTitleProcessor getProcessor(Lang language); ProcessedEntry processEntry(SyndEntry entry);  }### Answer:
@Test public void langCacheTest() { final Lang frLang = Factories.LANG.findByIsoCode("fr-FR"); final Lang usLang = Factories.LANG.findByIsoCode("en-US"); Assert.assertNotNull(frLang); Assert.assertNotNull(usLang); new TtsVoiceMock(0, "my voice fr", "command", frLang, "str", true, false); new TtsVoiceMock(0, "my voice us", "command", usLang, "str", true, false); final OnlyTitleProcessor processor1 = OnlyTitleProcessor.getProcessor(usLang); final OnlyTitleProcessor processor2 = OnlyTitleProcessor.getProcessor(frLang); final OnlyTitleProcessor processor3 = OnlyTitleProcessor.getProcessor(usLang); final OnlyTitleProcessor processor4 = OnlyTitleProcessor.getProcessor(frLang); Assert.assertSame(processor1, processor3); Assert.assertSame(processor2, processor4); Assert.assertNotSame(processor1, processor2); }
@Test public void voiceCacheTest() { final Lang frLang = Factories.LANG.findByIsoCode("fr-FR"); final Lang usLang = Factories.LANG.findByIsoCode("en-US"); Assert.assertNotNull(frLang); Assert.assertNotNull(usLang); final TtsVoice frVoice = new TtsVoiceMock(0, "my voice fr", "command", frLang, "str", true, false); final TtsVoice usVoice = new TtsVoiceMock(0, "my voice us", "command", usLang, "str", true, false); final OnlyTitleProcessor processor1 = OnlyTitleProcessor.getProcessor(usVoice); final OnlyTitleProcessor processor2 = OnlyTitleProcessor.getProcessor(frVoice); final OnlyTitleProcessor processor3 = OnlyTitleProcessor.getProcessor(usVoice); final OnlyTitleProcessor processor4 = OnlyTitleProcessor.getProcessor(frVoice); Assert.assertSame(processor1, processor3); Assert.assertSame(processor2, processor4); Assert.assertNotSame(processor1, processor2); }
@Test public void bothCachesTest() { final Lang frLang = Factories.LANG.findByIsoCode("fr-FR"); final Lang usLang = Factories.LANG.findByIsoCode("en-US"); Assert.assertNotNull(frLang); Assert.assertNotNull(usLang); final TtsVoice frVoice = new TtsVoiceMock(0, "my voice fr", "command", frLang, "str", true, false); final TtsVoice usVoice = new TtsVoiceMock(0, "my voice us", "command", usLang, "str", true, false); final OnlyTitleProcessor processor1 = OnlyTitleProcessor.getProcessor(usVoice); final OnlyTitleProcessor processor2 = OnlyTitleProcessor.getProcessor(frVoice); final OnlyTitleProcessor processor3 = OnlyTitleProcessor.getProcessor(usLang); final OnlyTitleProcessor processor4 = OnlyTitleProcessor.getProcessor(frLang); Assert.assertSame(processor1, processor3); Assert.assertSame(processor2, processor4); Assert.assertNotSame(processor1, processor2); }