Package ro.isdc.wro.model.resource.locator

Examples of ro.isdc.wro.model.resource.locator.UriLocator.locate()


        assertEquals(7, resources.size());
        for (Resource resource : resources) {
            final UriLocatorFactory uriLocatorFactory = new GeonetworkMavenWrojManagerFactory().newUriLocatorFactory();
            final UriLocator instance = uriLocatorFactory.getInstance(resource.getUri());
            final String deps = IOUtils.toString(instance.locate(resource.getUri()), "UTF-8");
            if (resource.getUri().contains("sampleFile1a.js")) {
                assertEquals("goog.addDependency('" + PATH_TO_WEBAPP_BASE_FROM_CLOSURE_BASE_JS_FILE + "/" + jsTestBaseDirAsPath +
                             "/sampleFile1a.js', ['1a'], ['2a']);\n", deps);
            } else if (resource.getUri().contains("sampleFile1b.js")) {
                assertEquals("goog.addDependency('" + PATH_TO_WEBAPP_BASE_FROM_CLOSURE_BASE_JS_FILE + "/" + jsTestBaseDirAsPath +
View Full Code Here


        assertTrue(exists);
    }

    private void assertCanLoadResource(UriLocatorFactory uriLocatorFactory, Resource resource) throws IOException {
        final UriLocator instance = uriLocatorFactory.getInstance(resource.getUri());
        final InputStream locate = instance.locate(resource.getUri());
        try {
            assertNotNull(locate);

            final int read = locate.read();
            assertTrue(-1 != read);
View Full Code Here

    final UriLocator uriLocator = getInstance(uri);
    if (uriLocator == null) {
      throw new WroRuntimeException("No locator is capable of handling uri: " + uri);
    }
    LOG.debug("[OK] locating {} using locator: {}", uri, uriLocator.getClass().getSimpleName());
    return new AutoCloseInputStream(uriLocator.locate(uri));
  }
}
View Full Code Here

      throws IOException {
    final UriLocator locator = getInstance(uri);
    if (locator == null) {
      return getDecoratedObject().locate(uri);
    }
    return locator.locate(uri);
  }

  public UriLocator getInstance(final String uri) {
    final UriLocator instance = getDecoratedObject().getInstance(uri);
    if (instance != null) {
View Full Code Here

        LOG.debug("baseNameFolder: {}", baseNameFolder);

        expandedHandler.setWildcardExpanderHandler(createExpanderHandler(group, resource, baseNameFolder));
        try {
          // trigger the wildcard replacement
          uriLocator.locate(resource.getUri());
        } catch (final IOException e) {
          // log only
          LOG.debug("[FAIL] problem while trying to expand wildcard for the following resource uri: {}",
              resource.getUri());
        } finally {
View Full Code Here

      @Override
      public WildcardStreamLocator newWildcardStreamLocator() {
        return locator;
      }
    };
    uriLocator.locate("classpath:" + WroUtil.toPackageAsFolder(getClass()) + "/*.js");
  }
 
  @Test
  public void testWildcardLocator()
      throws IOException {
View Full Code Here

      @Override
      public WildcardStreamLocator newWildcardStreamLocator() {
        return locator;
      }
    };
    uriLocator.locate("classpath:" + WroUtil.toPackageAsFolder(getClass()) + "/*.css");
  }
}
View Full Code Here

  public void shouldFindNoResourcesWhenNoneExist()
      throws IOException {
    final ThreadLocal<Collection<String>> filenameListHolder = new ThreadLocal<Collection<String>>();
    final UriLocator uriLocator = createJarLocator(filenameListHolder);
    // there are no js resources in the jar
    uriLocator.locate("classpath:com/**.js");
    final Collection<String> filenameList = filenameListHolder.get();
    Assert.assertNotNull(filenameList);
    Assert.assertTrue(filenameList.isEmpty());
  }
 
View Full Code Here

  @Test
  public void shouldOrderedAlphabeticallyWildcardResources()
      throws IOException {
    final ThreadLocal<Collection<String>> filenameListHolder = new ThreadLocal<Collection<String>>();
    final UriLocator uriLocator = createJarLocator(filenameListHolder);
    uriLocator.locate("classpath:com/app/**.css");
    final Collection<String> filenameList = filenameListHolder.get();
    Assert.assertNotNull(filenameList);
    Assert.assertEquals(Arrays.toString(new String[] {
      "com/app/level1/level2/styles/style.css", "com/app/level1/level2/level2.css", "com/app/level1/level1.css"
    }), Arrays.toString(filenameList.toArray()));
View Full Code Here

  @Test
  public void shouldFindAllChildFoldersAndFiles()
      throws IOException {
    final ThreadLocal<Collection<String>> filenameListHolder = new ThreadLocal<Collection<String>>();
    final UriLocator uriLocator = createJarLocator(filenameListHolder);
    uriLocator.locate("classpath:com/app/**");
    final Collection<String> filenameList = filenameListHolder.get();
    Assert.assertNotNull(filenameList);
    Assert.assertEquals(
        Arrays.toString(new String[] {
          "com/app/level1", "com/app/level1/level2", "com/app/level1/level2/styles",
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.