Package ro.isdc.wro.model.resource.processor

Examples of ro.isdc.wro.model.resource.processor.ResourcePreProcessor


  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);
      }
    });
View Full Code Here


   * {@inheritDoc}
   */
  @Override
  public void process(final Resource resource, final Reader reader, final Writer writer)
      throws IOException {
    final ResourcePreProcessor decoratedProcessor = getDecoratedObject();
    if (decoratedProcessor instanceof SupportAware) {
      if (!((SupportAware) decoratedProcessor).isSupported()) {
        throw new WroRuntimeException(toString() + " processor is not supported on this environment");
      }
    }
View Full Code Here

   * Ignored because it fails when running the test from command line.
   */
  @Test
  public void testFromFolder()
      throws Exception {
    final ResourcePreProcessor processor = new WroManagerProcessor();
    final URL url = getClass().getResource("wroManager");

    final File testFolder = new File(url.getFile(), "test");
    final File expectedFolder = new File(url.getFile(), "expected");
    WroTestUtils.compareFromDifferentFoldersByExtension(testFolder, expectedFolder, "js", processor);
View Full Code Here

    assertFalse(createCssImportInspector("#someId {color: red}").containsImport());
    assertFalse(createCssImportInspector("#import {display: block}").containsImport());
  }

  private ResourcePreProcessor createFindImportsProcessor() {
    return new ResourcePreProcessor() {
      public void process(final Resource resource, final Reader reader, final Writer writer)
          throws IOException {
        final List<String> results = createCssImportInspector(IOUtils.toString(reader)).findImports();
        for (final String string : results) {
          writer.write(string + "\n");
View Full Code Here

      }
    };
  }

  private ResourcePreProcessor createImportsRemovalProcessor() {
    return new ResourcePreProcessor() {
      public void process(final Resource resource, final Reader reader, final Writer writer)
          throws IOException {
        writer.write(createCssImportInspector("").removeImportsFromComments(IOUtils.toString(reader)));
      }
    };
View Full Code Here

      }
    };
  }

  private ResourcePreProcessor createRemoveImportsProcessor() {
    return new ResourcePreProcessor() {
      public void process(final Resource resource, final Reader reader, final Writer writer)
          throws IOException {
        writer.write(createCssImportInspector(IOUtils.toString(reader)).removeImportStatements());
      }
    };
View Full Code Here

  }

  @Test
  public void shouldInvokePreProcessorWhenImportIsSupported()
      throws Exception {
    final ResourcePreProcessor processor = Mockito.spy(new ImportAwareProcessor());
    victim = new ImportAwareProcessorDecorator(processor, ProcessingType.IMPORT_ONLY);
    initVictim();
    victim.process(mockReader, mockWriter);
    Mockito.verify(processor, Mockito.atLeastOnce()).process(Mockito.any(Resource.class), Mockito.any(Reader.class),
        Mockito.any(Writer.class));
View Full Code Here

    final File expectedFolder = new File(url.getFile(), expectedFolderName);
    WroTestUtils.compareFromDifferentFoldersByExtension(testFolder, expectedFolder, "css", processor);
  }

  private ResourcePreProcessor createProcessorWithHandler(final ItemHandler handler) {
    return new ResourcePreProcessor() {
      public void process(final Resource resource, final Reader reader, final Writer writer)
          throws IOException {
        writer.write(victim.findAndReplace(IOUtils.toString(reader), handler));
      }
    };
View Full Code Here

*/
public class TestCopyrightKeeperProcessorDecorator {
  @Test
  public void testCopyrightStripperProcessor()
      throws Exception {
    final ResourcePreProcessor decoratedProcessor = new CssMinProcessor();
    final ResourcePreProcessor processor = CopyrightKeeperProcessorDecorator.decorate(decoratedProcessor);
    final URL url = ResourcePreProcessor.class.getResource("copyright");

    final File testFolder = new File(url.getFile(), "test");
    final File expectedFolder = new File(url.getFile(), "expected");
    WroTestUtils.compareFromDifferentFoldersByExtension(testFolder, expectedFolder, "css", processor);
View Full Code Here

  @Test
  public void testCopyrightAwareProcessor()
      throws Exception {
    //This procesor won't remove copyright headers.
    final ResourcePreProcessor decoratedProcessor = new ResourcePreProcessor() {
      public void process(final Resource resource, final Reader reader, final Writer writer)
        throws IOException {
        IOUtils.copy(reader, writer);
      }
    };
    final ResourcePreProcessor processor = CopyrightKeeperProcessorDecorator.decorate(decoratedProcessor);
    final URL url = ResourcePreProcessor.class.getResource("copyright");

    final File testFolder = new File(url.getFile(), "test");
    final File expectedFolder = new File(url.getFile(), "expectedCopyrightAware");
    WroTestUtils.compareFromDifferentFoldersByExtension(testFolder, expectedFolder, "css", processor);
View Full Code Here

TOP

Related Classes of ro.isdc.wro.model.resource.processor.ResourcePreProcessor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.