Examples of ResourcePreProcessor


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

  }

  @Test
  public void shouldMinimizeWhenUsedAsLazyProcessor()
      throws Exception {
    final ResourcePreProcessor victim = new LazyProcessorDecorator(new LazyInitializer<ResourcePreProcessor>() {
      @Override
      protected ResourcePreProcessor initialize() {
        return new GoogleClosureCompressorProcessor();
      }
    });
    WroTestUtils.createInjector().inject(victim);
    final StringWriter sw = new StringWriter();
    victim.process(null, new StringReader("alert(1);"), sw);
    assertEquals("alert(1);", sw.toString());
  }
View Full Code Here

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

    assertEquals(0, Context.countActive());
  }

  @Before
  public void setUp() {
    final ResourcePreProcessor decoratedProcessor = new JSMinProcessor();
    processor = CopyrightKeeperProcessorDecorator.decorate(decoratedProcessor);
    Context.set(Context.standaloneContext());
    WroTestUtils.createInjector().inject(decoratedProcessor);
  }
View Full Code Here

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

  }

  @Test
  public void shouldCompileAllFromFolder()
      throws Exception {
    final ResourcePreProcessor processor = new NodeCoffeeScriptProcessor();
    final URL url = getClass().getResource("coffeeScript/advanced");

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

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

  }

  @Test
  public void shouldCompileAllFromFolderUsingBareOption()
      throws Exception {
    final ResourcePreProcessor processor = new NodeCoffeeScriptProcessor() {
      @Override
      protected String[] buildOptionalArguments() {
        return new String[] {"--bare"};
      }
    };
View Full Code Here

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

   * Test that processing invalid less css produces exceptions
   */
  @Test
  public void shouldFailWhenInvalidScriptIsProcessed()
      throws Exception {
    final ResourcePreProcessor processor = new NodeCoffeeScriptProcessor();
    final URL url = getClass().getResource("coffeeScript/exceptions");

    final File testFolder = new File(url.getFile(), "test");
    WroTestUtils.forEachFileInFolder(testFolder, new Function<File, Void>() {
      @Override
      public Void apply(final File input)
          throws Exception {
        try {
          processor.process(null, new FileReader(input), new StringWriter());
          Assert.fail("Expected to fail, but didn't");
        } catch (final WroRuntimeException e) {
          //expected to throw exception, continue
        }
        return null;
View Full Code Here

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

  @Test
  public void testExceptions()
    throws IOException {
    final URL url = getClass().getResource("coffeeScript/exceptions");
    final AtomicInteger counter = new AtomicInteger();
    final ResourcePreProcessor processor = new ExceptionHandlingProcessorDecorator(new NodeCoffeeScriptProcessor() {
      @Override
      protected void onException(final Exception e, final String content) {
        counter.incrementAndGet();
        throw WroRuntimeException.wrap(e);
      }
View Full Code Here

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

  }

  @Test
  public void shouldWorkProperlyWithCssImportPreProcessor()
      throws Exception {
    final ResourcePreProcessor processor = ChainedProcessor.create(initProcessor(new CssImportPreProcessor()),
        initProcessor((ResourcePreProcessor) new NodeLessCssProcessor()));
    final URL url = getClass().getResource("lesscss");

    final File testFolder = new File(url.getFile(), "test");
    final File expectedFolder = new File(url.getFile(), "expectedUrlRewriting");
View Full Code Here

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

   * Test that processing invalid less css produces exceptions
   */
  @Test
  public void shouldFailWhenInvalidLessCssIsProcessed()
      throws Exception {
    final ResourcePreProcessor processor = new NodeLessCssProcessor();
    final URL url = getClass().getResource("lesscss");

    final File testFolder = new File(url.getFile(), "invalid");
    WroTestUtils.forEachFileInFolder(testFolder, new Function<File, Void>() {
      @Override
      public Void apply(final File input)
          throws Exception {
        try {
          processor.process(null, new FileReader(input), new StringWriter());
          Assert.fail("Expected to fail, but didn't");
        } catch (final WroRuntimeException e) {
          //expected to throw exception, continue
        }
        return null;
View Full Code Here

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

  }

  @Test
  public void shouldBeThreadSafe()
      throws Exception {
    final ResourcePreProcessor processor = new RhinoTypeScriptProcessor() {
      @Override
      protected void onException(final Exception e, final String content) {
        throw WroRuntimeException.wrap(e);
      }
    };
    final Callable<Void> task = new Callable<Void>() {
      @Override
      public Void call() {
        try {
          processor.process(null, new StringReader("class Animal {}"), new StringWriter());
        } catch (final Exception e) {
          throw new RuntimeException(e);
        }
        return null;
      }
View Full Code Here

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

  @Test
  public void shouldFailWhenInvalidTypeScriptIsProcessed()
      throws Exception {
    final URL url = getClass().getResource("typescript");
    final File testFolder = new File(url.getFile(), "invalid");
    final ResourcePreProcessor decorated = new ExceptionHandlingProcessorDecorator(victim);
    WroTestUtils.createInjector().inject(decorated);
    WroTestUtils.forEachFileInFolder(testFolder, new Function<File, Void>() {
      @Override
      public Void apply(final File input)
          throws Exception {
        try {
          decorated.process(Resource.create(input.getPath(), ResourceType.JS), new FileReader(input),
              new StringWriter());
          Assert.fail("Expected to fail, but didn't");
        } catch (final WroRuntimeException e) {
          // expected to throw exception, continue
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.