Package ro.isdc.wro.model.resource

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


  @Test
  public void shouldBeThreadSafeWhenMutated()
      throws Exception {
    final Group group = new Group("group");
    final List<Resource> resources = new ArrayList<Resource>();
    final Resource r1 = Resource.create("/some.css", ResourceType.CSS);
    resources.add(r1);

    WroTestUtils.runConcurrently(new Callable<Void>() {
      public Void call()
          throws Exception {
View Full Code Here


    decorator = new LifecycleCallbackDecorator(null);
  }
 
  @Test
  public void shouldCatchCallbacksExceptionsAndContinueExecution() {
    final Resource changedResource = Resource.create("test.js");
    final LifecycleCallback callback = Mockito.spy(new PerformanceLoggerCallback());
    decorator = new LifecycleCallbackDecorator(callback);
   
    final LifecycleCallbackRegistry registry = new LifecycleCallbackRegistry();
    registry.registerCallback(new ObjectFactory<LifecycleCallback>() {
View Full Code Here

  }
 
  @Test
  public void shouldInvokeRegisteredCallbacks() {
    final LifecycleCallback callback = Mockito.mock(LifecycleCallback.class);
    final Resource changedResource = Resource.create("test.js");
    registry.registerCallback(factoryFor(callback));
   
    registry.onBeforeModelCreated();
    Mockito.verify(callback).onBeforeModelCreated();
   
View Full Code Here

 
  @Test
  public void shouldCatchCallbacksExceptionsAndContinueExecution() {
    final LifecycleCallback failingCallback = Mockito.mock(LifecycleCallback.class);
    final LifecycleCallback simpleCallback = Mockito.spy(new LifecycleCallbackSupport());
    final Resource changedResource = Resource.create("test.js");
   
    Mockito.doThrow(new IllegalStateException()).when(failingCallback).onBeforeModelCreated();
    Mockito.doThrow(new IllegalStateException()).when(failingCallback).onAfterModelCreated();
    Mockito.doThrow(new IllegalStateException()).when(failingCallback).onBeforePreProcess();
    Mockito.doThrow(new IllegalStateException()).when(failingCallback).onAfterPreProcess();
View Full Code Here

    final Collection<ResourcePostProcessor> processors = processorsFactory.getPostProcessors();
    LOG.debug("appying post processors: {}", processors);
    if (processors.isEmpty()) {
      return content;
    }
    final Resource resource = Resource.create(cacheKey.getGroupName(), cacheKey.getType());

    Reader reader = new StringReader(content.toString());
    Writer writer = null;
    for (final ResourcePostProcessor processor : processors) {
      final ResourcePreProcessor decoratedProcessor = decorateProcessor(processor, cacheKey.isMinimize());
View Full Code Here

    // it should be sorted
    final List<Resource> imports = new ArrayList<Resource>();
    final String css = cssContent;
    final List<String> foundImports = findImports(css);
    for (final String importUrl : foundImports) {
      final Resource importedResource = createImportedResource(resourceUri, importUrl);
      // check if already exist
      if (imports.contains(importedResource)) {
        LOG.debug("[WARN] Duplicate imported resource: {}", importedResource);
      } else {
        imports.add(importedResource);
        onImportDetected(importedResource.getUri());
      }
    }
    return imports;
  }
View Full Code Here

    }
    if (type != null) {
      final String minimizeAsString = resourceElement.getAttribute(ATTR_MINIMIZE);
      final boolean minimize = StringUtils.isEmpty(minimizeAsString) ? true
          : Boolean.valueOf(resourceElement.getAttribute(ATTR_MINIMIZE));
      final Resource resource = Resource.create(uri, type);
      resource.setMinimize(minimize);
      LOG.debug("\t\tadding resource: {}", resource);
      resources.add(resource);
    }
  }
View Full Code Here

            LOG.debug("\tresourcePath: {}", resourcePath);
            LOG.debug("\tfile path: {}", file.getPath());
            final String computedResourceUri = resourcePath
                + StringUtils.removeStart(file.getPath(), baseNameFolder).replace('\\', '/');

            final Resource expandedResource = Resource.create(computedResourceUri, resource.getType());
            LOG.debug("\texpanded resource: {}", expandedResource);
            expandedResources.add(expandedResource);
          }
          LOG.debug("\treplace resource {}", resource);
          group.replace(resource, expandedResources);
View Full Code Here

   * @param resourceUri
   *          the resource should return.
   * @return mocked {@link 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

   * @param resourceUri
   *          the resource should return.
   * @return mocked {@link 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

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.