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

Examples of ro.isdc.wro.model.resource.locator.ClasspathUriLocator


  public void shouldReturnClasspathResource()
      throws IOException {
    final String resourceUri = "classpath:" + packagePath + "/" + "test.css";
    when(mockAuthorizationManager.isAuthorized(resourceUri)).thenReturn(true);
    when(request.getParameter(ResourceProxyRequestHandler.PARAM_RESOURCE_ID)).thenReturn(resourceUri);
    when(mockUriLocator.locate(anyString())).thenReturn(new ClasspathUriLocator().locate(resourceUri));

    victim.handle(request, response);

    final String body = outputStream.toString();
    final String expectedBody = IOUtils.toString(getInputStream("test.css"));
View Full Code Here


  public void cannotProxyUnauthorizedResources()
      throws IOException {
    final String resourceUri = "classpath:" + packagePath + "/" + "test.css";
    when(mockAuthorizationManager.isAuthorized(resourceUri)).thenReturn(false);
    when(request.getParameter(ResourceProxyRequestHandler.PARAM_RESOURCE_ID)).thenReturn(resourceUri);
    when(mockUriLocator.locate(anyString())).thenReturn(new ClasspathUriLocator().locate(resourceUri));

    victim.handle(request, response);
  }
View Full Code Here

  public void shouldSetResponseLength()
      throws IOException {
    final String resourceUri = "classpath:" + packagePath + "/" + "test.css";
    when(mockAuthorizationManager.isAuthorized(resourceUri)).thenReturn(true);
    when(request.getParameter(ResourceProxyRequestHandler.PARAM_RESOURCE_ID)).thenReturn(resourceUri);
    when(mockUriLocator.locate(anyString())).thenReturn(new ClasspathUriLocator().locate(resourceUri));

    victim.handle(request, response);
    final int expectedLength = IOUtils.toString(getInputStream("test.css")).length();

    verify(response, times(1)).setContentLength(expectedLength);
View Full Code Here

  /**
   * {@inheritDoc}
   */
  public Map<String, UriLocator> provideLocators() {
    final Map<String, UriLocator> map = new TreeMap<String, UriLocator>();
    map.put(ClasspathUriLocator.ALIAS, new ClasspathUriLocator());
    map.put(ServletContextUriLocator.ALIAS, new ServletContextUriLocator());
    map.put(ServletContextUriLocator.ALIAS_DISPATCHER_FIRST,
        new ServletContextUriLocator().setLocatorStrategy(LocatorStrategy.DISPATCHER_FIRST));
    map.put(ServletContextUriLocator.ALIAS_SERVLET_CONTEXT_FIRST,
        new ServletContextUriLocator().setLocatorStrategy(LocatorStrategy.SERVLET_CONTEXT_FIRST));
View Full Code Here

  public void shouldRedirectStreamWhenSendRedirectIsInvoked() throws Exception {
    final String message = "Hello world!";
    victim = new RedirectedStreamServletResponseWrapper(redirectedStream, mockResponse) {
      @Override
      protected UriLocator newExternalResourceLocator() {
        return new ClasspathUriLocator() {
          @Override
          public InputStream locate(final String uri)
              throws IOException {
            return new ByteArrayInputStream(message.getBytes());
          }
View Full Code Here

      public InputStream locate(final String uri)
          throws IOException {
        try {
          return super.locate(uri);
        } catch (final Exception e) {
          return new ClasspathUriLocator().locate(PROXY_RESOURCE_PATH + "test1.png");
        }
      }
    }).addLocator(new UrlUriLocator() {
      @Override
      public InputStream locate(final String uri)
          throws IOException {
        // avoid external connections
        if (uri.startsWith("http")) {
          return new ClasspathUriLocator().locate(PROXY_RESOURCE_PATH + "test2.png");
        }
        return super.locate(uri);
      }
    });
    return locatorFactory;
View Full Code Here

              "tools.expose-1.0.5.js", "tools.overlay-1.1.2.js", "tools.overlay.apple-1.0.1.js",
              "tools.overlay.gallery-1.0.0.js"
            }), Arrays.toString(filenameList.toArray()));
      };
    };
    final UriLocator uriLocator = new ClasspathUriLocator() {
      @Override
      public WildcardStreamLocator newWildcardStreamLocator() {
        return locator;
      }
    };
    uriLocator.locate("classpath:" + WroUtil.toPackageAsFolder(getClass()) + "/*.js");
  }
View Full Code Here

      void triggerWildcardExpander(final Collection<File> allFiles, final WildcardContext wildcardContext)
          throws IOException {
        assertEquals(2, allFiles.size());
      };
    };
    final UriLocator uriLocator = new ClasspathUriLocator() {
      @Override
      public WildcardStreamLocator newWildcardStreamLocator() {
        return locator;
      }
    };
    uriLocator.locate("classpath:" + WroUtil.toPackageAsFolder(getClass()) + "/*.css");
  }
View Full Code Here

  }
 
  @Test(expected = WroRuntimeException.class)
  public void shouldFailWhenNoCapableLocatorAvailable()
      throws Exception {
    factory.addLocator(new ClasspathUriLocator());
    factory.locate("http://www.google.com");
  }
View Full Code Here

  }
 
  @Test
  public void testValidUri()
      throws Exception {
    factory.addLocator(new ClasspathUriLocator());
    assertNotNull(factory.locate("classpath:" + WroUtil.toPackageAsFolder(TestUriLocatorFactory.class)));
  }
View Full Code Here

TOP

Related Classes of ro.isdc.wro.model.resource.locator.ClasspathUriLocator

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.