/** * Compare contents of two resources (files) by performing some sort of processing on input resource. * * @param inputResourceUri * uri of the resource to process. * @param expectedContentResourceUri * uri of the resource to compare with processed content. * @param processor * a closure used to process somehow the input content. */ public static void compareProcessedResourceContents(final String inputResourceUri, final String expectedContentResourceUri, final ResourcePostProcessor processor) throws IOException { final Reader resultReader = getReaderFromUri(inputResourceUri); final Reader expectedReader = getReaderFromUri(expectedContentResourceUri); compare(resultReader, expectedReader, processor); }
private static void compareFromDifferentFolders(final File sourceFolder, final File targetFolder, final IOFileFilter fileFilter, final Transformer<String> toTargetFileName, final ResourcePostProcessor processor) throws IOException { // TODO use ProcessorsUtils compareFromDifferentFolders(sourceFolder, targetFolder, fileFilter, toTargetFileName, new ResourcePreProcessor() { public void process(final Resource resource, final Reader reader, final Writer writer) throws IOException { processor.process(reader, writer); } }); }
public UriLocator getInstance(final String uri) { return createResourceMockingLocator(); } };
LOG.debug("comparing with: {}", targetFile.getName()); try { compare(new FileInputStream(file), targetFileStream, new ResourcePostProcessor() { public void process(final Reader reader, final Writer writer) throws IOException { logSuccess(processedNumber);
public static void compare(final InputStream input, final InputStream expected, final ResourcePostProcessor processor) throws IOException { compare(new InputStreamReader(input), new InputStreamReader(expected), processor); }
private static Reader getReaderFromUri(final String uri) throws IOException { // wrap reader with bufferedReader for top efficiency return new BufferedReader(new InputStreamReader(createDefaultUriLocatorFactory().locate(uri))); }
/** * @return a {@link BaseWroManagerFactory} which uses an empty model. */ public static BaseWroManagerFactory simpleManagerFactory() { return new BaseWroManagerFactory().setModelFactory(simpleModelFactory(new WroModel())); }
/** * Run the task concurrently 50 times. */ public static void runConcurrently(final Callable<Void> task) throws Exception { runConcurrently(task, 50); }
/** * @return the injector */ public static void initProcessor(final ResourcePostProcessor processor) { initProcessor((ResourcePreProcessor) new ProcessorDecorator(processor)); }
/** * Compares two strings by removing trailing spaces & tabs for correct comparison. */ public static void compare(final String expected, final String actual) { try { final String in = replaceTabsWithSpaces(expected.trim()); final String out = replaceTabsWithSpaces(actual.trim()); Assert.assertEquals(in, out); LOG.debug("Compare.... [OK]"); } catch (final ComparisonFailure e) { LOG.error("Compare.... [FAIL]", e.getMessage()); throw e; } }
/** * Applies a function for each file from a folder. The folder should contain at least one file to process, otherwise * an exception will be thrown. * * @param folder * {@link File} representing the folder where the files will be used from processing. * @param function * {@link Function} to apply on each found file. */ public static void forEachFileInFolder(final File folder, final Function<File, Void> function) { Validate.notNull(function); final Collection<File> files = FileUtils.listFiles(folder, TrueFileFilter.TRUE, FalseFileFilter.INSTANCE); int processedNumber = 0; for (final File file : files) { try { function.apply(file); } catch (final Exception e) { throw new RuntimeException("Problem while applying function on file: " + file, e); } processedNumber++; } logSuccess(processedNumber); }
LOG.debug("comparing with: {}", targetFile.getName()); try { compare(sourceFileStream = new FileInputStream(file), targetFileStream, new ResourcePostProcessor() { public void process(final Reader reader, final Writer writer) throws IOException { logSuccess(processedNumber);
public static void compare(final InputStream input, final InputStream expected, final ResourcePostProcessor processor) throws IOException { compare(new InputStreamReader(input), new InputStreamReader(expected), processor); }
private static Reader getReaderFromUri(final String uri) throws IOException { // wrap reader with bufferedReader for top efficiency return new BufferedReader(new InputStreamReader(createDefaultUriLocatorFactory().locate(uri))); }
/** * @return a {@link BaseWroManagerFactory} which uses an empty model. */ public static BaseWroManagerFactory simpleManagerFactory() { return new BaseWroManagerFactory().setModelFactory(simpleModelFactory(new WroModel())); }
/** * Run the task concurrently 50 times. */ public static void runConcurrently(final Callable<Void> task) throws Exception { runConcurrently(task, 50); }
/** * @return the injector */ public static void initProcessor(final ResourcePostProcessor processor) { initProcessor((ResourcePreProcessor) new ProcessorDecorator(processor)); }
/** * Compares two strings by removing trailing spaces & tabs for correct comparison. */ public static void compare(final String expected, final String actual) { try { final String in = replaceTabsWithSpaces(expected.trim()); final String out = replaceTabsWithSpaces(actual.trim()); Assert.assertEquals(in, out); LOG.debug("Compare.... [OK]"); } catch (final ComparisonFailure e) { LOG.error("Compare.... [FAIL]", e.getMessage()); throw e; } }
/** * Applies a function for each file from a folder. The folder should contain at least one file to process, otherwise * an exception will be thrown. * * @param folder * {@link File} representing the folder where the files will be used from processing. * @param function * {@link Function} to apply on each found file. */ public static void forEachFileInFolder(final File folder, final Function<File, Void> function) { Validate.notNull(function); final Collection<File> files = FileUtils.listFiles(folder, TrueFileFilter.TRUE, FalseFileFilter.INSTANCE); int processedNumber = 0; for (final File file : files) { try { function.apply(file); } catch (final Exception e) { throw new RuntimeException("Problem while applying function on file: " + file, e); } processedNumber++; } logSuccess(processedNumber); }
compare(new FileInputStream(file), targetFileStream, new ResourcePostProcessor() { public void process(final Reader reader, final Writer writer) throws IOException { logSuccess(processedNumber);