Examples of UriLocatorFactory


Examples of ro.isdc.wro.model.resource.locator.factory.UriLocatorFactory

            jsTestBaseDirAsPath = jsTestBaseDirAsPath.substring(1);
        }

        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")) {
View Full Code Here

Examples of ro.isdc.wro.model.resource.locator.factory.UriLocatorFactory

        List<Resource> resources = group.getResources();

        assertEquals(4, resources.size());

        List<String> resourceNames = new ArrayList<String>(resources.size());
        final UriLocatorFactory uriLocatorFactory = new GeonetworkMavenWrojManagerFactory().newUriLocatorFactory();

        for (Resource resource : resources) {
            resourceNames.add(resource.getUri());
            assertCanLoadResource(uriLocatorFactory, resource);
View Full Code Here

Examples of ro.isdc.wro.model.resource.locator.factory.UriLocatorFactory

        assertRequireModel(wroModel, true);
    }

    private void assertRequireModel(WroModel wroModel, boolean testMinimized) throws IOException {
        Set<String> groupNames = new HashSet<String>();
        final UriLocatorFactory uriLocatorFactory = new GeonetworkMavenWrojManagerFactory().newUriLocatorFactory();

        Set<String> nonMinifiedFiles = Sets.newHashSet("1a.css", "sampleFile2a.js", "sampleFile1b.js");

        for (Group group : wroModel.getGroups()) {
            groupNames.add(group.getName());
View Full Code Here

Examples of ro.isdc.wro.model.resource.locator.factory.UriLocatorFactory

  @Before
  public void setUp()
      throws Exception {
    MockitoAnnotations.initMocks(this);
    mockLocatorFactory = new UriLocatorFactory() {
      public InputStream locate(final String uri)
          throws IOException {
        return mockLocator.locate(uri);
      }
View Full Code Here

Examples of ro.isdc.wro.model.resource.locator.factory.UriLocatorFactory

  public boolean isResourceChanged(final Resource resource) {
    notNull(resource, "Invalid resource provided");

    final WroManager manager = getManagerFactory().create();
    final HashStrategy hashStrategy = manager.getHashStrategy();
    final UriLocatorFactory locatorFactory = manager.getUriLocatorFactory();
    // using AtomicBoolean because we need to mutate this variable inside an anonymous class.
    final AtomicBoolean changeDetected = new AtomicBoolean(false);
    try {
      final String fingerprint = hashStrategy.getHash(locatorFactory.locate(resource.getUri()));
      final String previousFingerprint = getBuildContextHolder().getValue(resource.getUri());

      final boolean newValue = fingerprint != null && !fingerprint.equals(previousFingerprint);
      changeDetected.set(newValue);

      if (!changeDetected.get() && resource.getType() == ResourceType.CSS) {
        final Reader reader = new InputStreamReader(locatorFactory.locate(resource.getUri()));
        getLog().debug("Check @import directive from " + resource);
        // detect changes in imported resources.
        detectChangeForCssImports(resource, reader, changeDetected);
      }
      return changeDetected.get();
View Full Code Here

Examples of ro.isdc.wro.model.resource.locator.factory.UriLocatorFactory

   *          {@link Resource} to touch.
   */
  public void remember(final Resource resource) {
    final WroManager manager = getManagerFactory().create();
    final HashStrategy hashStrategy = manager.getHashStrategy();
    final UriLocatorFactory locatorFactory = manager.getUriLocatorFactory();

    if (rememberedSet.contains(resource.getUri())) {
      // only calculate fingerprints and check imports if not already done
      getLog().debug("Resource with uri '" + resource.getUri() + "' has already been updated in this run.");
    } else {
      try {
        final String fingerprint = hashStrategy.getHash(locatorFactory.locate(resource.getUri()));
        getBuildContextHolder().setValue(resource.getUri(), fingerprint);
        rememberedSet.add(resource.getUri());
        getLog().debug("Persist fingerprint for resource '" + resource.getUri() + "' : " + fingerprint);
        if (resource.getType() == ResourceType.CSS) {
          final Reader reader = new InputStreamReader(locatorFactory.locate(resource.getUri()));
          getLog().debug("Check @import directive from " + resource);
          // persist fingerprints in imported resources.
          persistFingerprintsForCssImports(resource, reader);
        }
      } catch (final IOException e) {
View Full Code Here

Examples of ro.isdc.wro.model.resource.locator.factory.UriLocatorFactory

  }

  public Injector createInjector() {
    final WroModel model = new WroModel().addGroup(new Group(GROUP_NAME).addResource(Resource.create(RESOURCE_URI)));
    final WroModelFactory modelFactory = WroTestUtils.simpleModelFactory(model);
    final UriLocatorFactory locatorFactory = WroTestUtils.createResourceMockingLocatorFactory();
    final BaseWroManagerFactory factory = new BaseWroManagerFactory().setModelFactory(modelFactory).setUriLocatorFactory(
        locatorFactory);
    factory.setProcessorsFactory(new SimpleProcessorsFactory());
    final Injector injector = InjectorBuilder.create(factory).setResourceWatcher(mockResourceWatcher).build();
    return injector;
View Full Code Here

Examples of ro.isdc.wro.model.resource.locator.factory.UriLocatorFactory

    victim = new StandaloneWroManagerFactory();
  }

  @Test
  public void shouldHaveMoreLocatorsThanDefaultFactoryHas() {
    final UriLocatorFactory locatorFactory = victim.newUriLocatorFactory();
    final List<?> availableLocators = ((SimpleUriLocatorFactory) locatorFactory).getUriLocators();
    final List<?> defaultLocators = new DefaultUriLocatorFactory().getUriLocators();
    Assert.assertTrue(availableLocators.size() > defaultLocators.size());
  }
View Full Code Here

Examples of ro.isdc.wro.model.resource.locator.factory.UriLocatorFactory

  /**
   * @return a locator factory which handles absolute url locations and failed servletContext relative url's by serving
   *         proxy resources from classpath. This is useful to make test pass without internet connection.
   */
  private UriLocatorFactory createLocatorFactory() {
    final UriLocatorFactory locatorFactory = new SimpleUriLocatorFactory().addLocator(new ServletContextUriLocator() {
      @Override
      public InputStream locate(final String uri)
          throws IOException {
        try {
          return super.locate(uri);
View Full Code Here

Examples of ro.isdc.wro.model.resource.locator.factory.UriLocatorFactory

    victim.destroy();
    Context.unset();
  }

  public Injector createDefaultInjector() {
    final UriLocatorFactory locatorFactory = new AbstractUriLocatorFactory() {
      public UriLocator getInstance(final String uri) {
        return mockLocator;
      }
    };
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.