Package ro.isdc.wro.model.resource

Examples of ro.isdc.wro.model.resource.Resource


  @Test
  public void shouldNotMinimizeDecoratedResourcesWithMinimizationDisabled()
      throws Exception {
    final List<Resource> resources = new ArrayList<Resource>();
    final Resource resource = Resource.create("classpath:1.js");
    resource.setMinimize(false);
    resources.add(resource);
    final ResourcePreProcessor preProcessor = CopyrightKeeperProcessorDecorator.decorate(new JSMinProcessor() {
      @Override
      public void process(final Resource resource, final Reader reader, final Writer writer)
          throws IOException {
View Full Code Here


    processInvalidImport();
  }

  private void processInvalidImport()
      throws IOException {
    final Resource resource = Resource.create("someResource.css");
    final Reader reader = new StringReader("@import('/path/to/invalid.css');");
    victim.process(resource, reader, new StringWriter());
  }
View Full Code Here

      protected void onImportDetected(final String foundImportUri) {
        times.incrementAndGet();
      }
    };
    WroTestUtils.initProcessor(victim);
    final Resource resource = Resource.create("someResource.css");
    final Reader reader = new StringReader("@import('/path/to/invalid.css');");
    victim.process(resource, reader, new StringWriter());
    assertEquals(1, times.get());
  }
View Full Code Here

    WroTestUtils.runConcurrently(new ContextPropagatingCallable<Void>(new Callable<Void>() {
      public Void call()
          throws Exception {
        Context.set(Context.standaloneContext());
        final Reader reader = new StringReader("@import('/path/to/imported');");
        final Resource resource1 = Resource.create("resource1.css");
        final Resource resource2 = Resource.create("resource2.css");
        if (new Random().nextBoolean()) {
          victim.process(resource1, reader, new StringWriter());
        } else {
          victim.process(resource2, reader, new StringWriter());
        }
View Full Code Here

   * @param resourceUri
   *          the resource should return.
   * @return mocked {@link ro.isdc.wro.model.resource.Resource} object.
   */
  private Resource createMockResource(final String resourceUri) {
    final Resource resource = Mockito.mock(Resource.class);
    Mockito.when(resource.getUri()).thenReturn(resourceUri);
    return resource;
  }
View Full Code Here

  @Test
  public void shouldInvokePreProcessorWithResourceWantingMinimize()
      throws Exception {
    victim = new MinimizeAwareProcessorDecorator(mockPreProcessor);
    initVictim();
    final Resource resource = Resource.create("someResource.js");
    resource.setMinimize(true);
    victim.process(resource, mockReader, mockWriter);
    Mockito.verify(mockPreProcessor, Mockito.atLeastOnce()).process(Mockito.any(Resource.class), Mockito.any(Reader.class),
        Mockito.any(Writer.class));
  }
View Full Code Here

  @Test
  public void shouldInvokePreProcessorWithResourceNotWantingMinimize()
      throws Exception {
    victim = new MinimizeAwareProcessorDecorator(mockPreProcessor);
    initVictim();
    final Resource resource = Resource.create("someResource.js");
    resource.setMinimize(false);
    victim.process(resource, mockReader, mockWriter);
    Mockito.verify(mockPreProcessor, Mockito.atLeastOnce()).process(Mockito.any(Resource.class), Mockito.any(Reader.class),
        Mockito.any(Writer.class));
  }
View Full Code Here

  @Test
  public void shouldInvokeMinimizeAwarePreProcessorWithResourceWantingMinimize()
      throws Exception {
    victim = new MinimizeAwareProcessorDecorator(new MinimizeAwareProcessor());
    initVictim();
    final Resource resource = Resource.create("someResource.js");
    resource.setMinimize(true);
    victim.process(resource, mockReader, mockWriter);
    Mockito.verify(mockPreProcessor, Mockito.never()).process(Mockito.any(Resource.class), Mockito.any(Reader.class),
        Mockito.any(Writer.class));
  }
View Full Code Here

  @Test
  public void shouldNotInvokeMinimizeAwarePreProcessorWithResourceNotWantingMinimize()
      throws Exception {
    victim = new MinimizeAwareProcessorDecorator(new MinimizeAwareProcessor());
    initVictim();
    final Resource resource = Resource.create("someResource.js");
    resource.setMinimize(false);
    victim.process(resource, mockReader, mockWriter);
    Mockito.verify(mockPreProcessor, Mockito.never()).process(Mockito.any(Resource.class), Mockito.any(Reader.class),
        Mockito.any(Writer.class));
  }
View Full Code Here

 
  @Test
  public void testExpandWildcardRootDir()
      throws Exception {
    final String uri = "/**.js";
    final Resource resource = Resource.create(uri, ResourceType.JS);
    final Group group = new Group("group").addResource(resource);
   
    final String baseNameFolder = WroUtil.toPackageAsFolder(getClass());
    final Function<Collection<File>, Void> expanderHandler = transformer.createExpanderHandler(group, resource,
        baseNameFolder);
View Full Code Here

TOP

Related Classes of ro.isdc.wro.model.resource.Resource

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.