@Test public void testCreateTokenFilter() throws Exception{ Properties properties = new Properties(); properties.setProperty(ReplaceFilterFactory.FILE_PATH_PARAMETER, TEST_FILE_1); expect(mapFileReaderFactory.createMapFileReader(TEST_FILE_1)).andReturn(mapFileReader); expect(mapFileReader.readMap()).andReturn(mapping); replay(mapFileReaderFactory); replay(mapFileReader); TokenFilter tokenFilter = replaceFilterFactory.createTokenFilter(tokenStream, properties); assertEquals(ReplaceFilter.class, tokenFilter.getClass()); ReplaceFilter replaceFilter = (ReplaceFilter) tokenFilter; assertEquals(mapping, replaceFilter.getMapping()); verify(mapFileReaderFactory); verify(mapFileReader); reset(mapFileReaderFactory); reset(mapFileReader); replay(mapFileReaderFactory); replay(mapFileReader); tokenFilter = replaceFilterFactory.createTokenFilter(tokenStream, properties); verify(mapFileReaderFactory); verify(mapFileReader); replaceFilter = (ReplaceFilter) tokenFilter; assertEquals(mapping, replaceFilter.getMapping()); }
public TokenFilter createTokenFilter(TokenStream tokenStream, Properties properties) throws IOException { String filePath = properties.getProperty(FILE_PATH_PARAMETER); return new ReplaceFilter(tokenStream, getMapping(filePath)); }
ReplaceFilterFactory implements TokenFilterFactory { public TokenFilter createTokenFilter(TokenStream tokenStream, Properties properties) throws IOException { String filePath = properties.getProperty(FILE_PATH_PARAMETER); return new ReplaceFilter(tokenStream, getMapping(filePath)); } }
ReplaceFilterFactory implements TokenFilterFactory { public TokenFilter createTokenFilter(TokenStream tokenStream, Properties properties) throws IOException { String filePath = properties.getProperty(FILE_PATH_PARAMETER); return new ReplaceFilter(tokenStream, getMapping(filePath)); } ReplaceFilterFactory(MapFileReaderFactory mapFileReaderFactory); }
ReplaceFilterFactory implements TokenFilterFactory { public TokenFilter createTokenFilter(TokenStream tokenStream, Properties properties) throws IOException { String filePath = properties.getProperty(FILE_PATH_PARAMETER); return new ReplaceFilter(tokenStream, getMapping(filePath)); } ReplaceFilterFactory(MapFileReaderFactory mapFileReaderFactory); TokenFilter createTokenFilter(TokenStream tokenStream, Properties properties); void preloadResources(Properties properties); Map<String, String> getMapping(String filePath); }
ReplaceFilterFactory implements TokenFilterFactory { public TokenFilter createTokenFilter(TokenStream tokenStream, Properties properties) throws IOException { String filePath = properties.getProperty(FILE_PATH_PARAMETER); return new ReplaceFilter(tokenStream, getMapping(filePath)); } ReplaceFilterFactory(MapFileReaderFactory mapFileReaderFactory); TokenFilter createTokenFilter(TokenStream tokenStream, Properties properties); void preloadResources(Properties properties); Map<String, String> getMapping(String filePath); static final String FILE_PATH_PARAMETER; }