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

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


    return new XmlModelFactory();
  }

  @Override
  protected UriLocatorFactory newUriLocatorFactory() {
    return new SimpleUriLocatorFactory().addLocator(newServletContextUriLocator()).addLocators(
        new DefaultUriLocatorFactory().getUriLocators());
  }
View Full Code Here


  @Before
  public void setUp() {
    Context.set(Context.standaloneContext());
    final WroManagerFactory managerFactory = new BaseWroManagerFactory()
        .setUriLocatorFactory(new SimpleUriLocatorFactory().addLocator(WroTestUtils.createResourceMockingLocator()));
    final Injector injector = InjectorBuilder.create(managerFactory).build();
    injector.inject(this);
  }
View Full Code Here

  /**
   * @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

    assertEquals(0, Context.countActive());
  }
 
  @Before
  public void setUp() {
    factory = new SimpleUriLocatorFactory();
  }
View Full Code Here

  }

  @Test
  public void shouldInjectEachLocatorWhenLocatorFactoryIsUsed()
      throws Exception {
    final SimpleUriLocatorFactory locatorFactory = new SimpleUriLocatorFactory();
    final ServletContextUriLocator locator = new ServletContextUriLocator();
    locatorFactory.addLocator(locator);
    final DispatcherStreamLocator dispatcherLocator = Mockito.mock(DispatcherStreamLocator.class);
    when(
        dispatcherLocator.getInputStream(Mockito.any(HttpServletRequest.class), Mockito.any(HttpServletResponse.class),
            Mockito.anyString())).thenReturn(WroUtil.EMPTY_STREAM);
    final Injector injector = InjectorBuilder.create(new BaseWroManagerFactory().setUriLocatorFactory(locatorFactory)).setDispatcherLocator(
View Full Code Here

      public InputStream locate(final String uri)
          throws IOException {
        return new ByteArrayInputStream("".getBytes());
      }
    };
    final UriLocatorFactory locatorFactory = new SimpleUriLocatorFactory().addLocator(emptyStreamLocator);
    // init executor
    final WroManagerFactory managerFactory = new BaseWroManagerFactory().setUriLocatorFactory(locatorFactory);
    InjectorBuilder.create(managerFactory).build().inject(victim);

    final List<Resource> resources = new ArrayList<Resource>();
View Full Code Here

  public void shouldNotCommentMergedContentWhenLastLineContainsComment()
      throws Exception {
    final List<Resource> resources = new ArrayList<Resource>();
    resources.add(Resource.create("var a=1;//comment", ResourceType.JS));
    resources.add(Resource.create("a=2;", ResourceType.JS));
    final UriLocatorFactory locatorFactory = new SimpleUriLocatorFactory().addLocator(WroTestUtils.createResourceMockingLocator());
    final WroManagerFactory managerFactory = new BaseWroManagerFactory().setUriLocatorFactory(locatorFactory).setProcessorsFactory(
        new SimpleProcessorsFactory());
    InjectorBuilder.create(managerFactory).build().inject(victim);

    final String result = victim.processAndMerge(resources, false);
View Full Code Here

  public void shouldNotAddRedundantNewLinesAfterMerge()
      throws Exception {
    final List<Resource> resources = new ArrayList<Resource>();
    resources.add(Resource.create("1\n\n", ResourceType.JS));
    resources.add(Resource.create("2", ResourceType.JS));
    final UriLocatorFactory locatorFactory = new SimpleUriLocatorFactory().addLocator(WroTestUtils.createResourceMockingLocator());
    final WroManagerFactory managerFactory = new BaseWroManagerFactory().setUriLocatorFactory(locatorFactory).setProcessorsFactory(
        new SimpleProcessorsFactory());
    InjectorBuilder.create(managerFactory).build().inject(victim);

    final String result = victim.processAndMerge(resources, false);
View Full Code Here

  public void shouldLeaveContentUnchangedWhenAProcessorFails() {
    final CacheKey key = new CacheKey(groupName, ResourceType.JS, true);
    final Group group = new Group(groupName).addResource(Resource.create("1.js")).addResource(Resource.create("2.js"));
    final WroModelFactory modelFactory = WroTestUtils.simpleModelFactory(new WroModel().addGroup(group));
    // the locator which returns the name of the resource as its content
    final UriLocatorFactory locatorFactory = new SimpleUriLocatorFactory().addLocator(WroTestUtils.createResourceMockingLocator());
   
    final ResourcePreProcessor failingPreProcessor = new ResourcePreProcessor() {
      public void process(final Resource resource, final Reader reader, final Writer writer)
          throws IOException {
        throw new IOException("BOOM!");
View Full Code Here

public class DragomeWroManagerFactory extends BaseWroManagerFactory
{
  protected UriLocatorFactory newUriLocatorFactory()
  {
    SimpleUriLocatorFactory uriLocatorFactory= (SimpleUriLocatorFactory) super.newUriLocatorFactory();
    uriLocatorFactory.addLocator(new ClasspathUriLocator());
    uriLocatorFactory.addLocator(new ServletContextUriLocator());
    uriLocatorFactory.addLocator(new UrlUriLocator());
    return uriLocatorFactory;
  }
View Full Code Here

TOP

Related Classes of ro.isdc.wro.model.resource.locator.factory.SimpleUriLocatorFactory

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.